| | |
| | | package com.doumee.service.business.impl; |
| | | |
| | | import com.doumee.core.annotation.excel.ExcelImporter; |
| | | import com.doumee.core.constants.ResponseStatus; |
| | | import com.doumee.core.exception.BusinessException; |
| | | import com.doumee.core.model.PageData; |
| | | import com.doumee.core.model.PageWrap; |
| | | import com.doumee.core.utils.Constants; |
| | | import com.doumee.core.utils.Utils; |
| | | import com.doumee.dao.business.InsuranceMapper; |
| | | import com.doumee.dao.business.WorktypeMapper; |
| | | import com.doumee.dao.business.dto.WorkTypeQueryDTO; |
| | | import com.doumee.dao.business.dto.WorktypeImport; |
| | | import com.doumee.dao.business.model.Worktype; |
| | | import com.doumee.service.business.WorktypeService; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.CollectionUtils; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | |
| | |
| | | |
| | | @Autowired |
| | | private WorktypeMapper worktypeMapper; |
| | | @Autowired |
| | | private InsuranceMapper insuranceMapper; |
| | | |
| | | @Override |
| | | public Integer create(Worktype worktype) { |
| | |
| | | QueryWrapper<Worktype> wrapper = new QueryWrapper<>(worktype); |
| | | return worktypeMapper.selectCount(wrapper); |
| | | } |
| | | @Override |
| | | public List<String> importBatch(MultipartFile file,Integer id){ |
| | | List<Worktype> list = new ArrayList<>(); |
| | | if(id!=null){ |
| | | Worktype param = new Worktype(); |
| | | param.setIsdeleted(Constants.ZERO); |
| | | param.setDataType(Constants.ZERO); |
| | | param.setInsuranceId(id); |
| | | list = findList(param); |
| | | } |
| | | ExcelImporter ie = null; |
| | | List<WorktypeImport> dataList =null; |
| | | try { |
| | | ie = new ExcelImporter(file,0,0); |
| | | dataList = ie.getDataList(WorktypeImport.class,null); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | if(dataList == null || dataList.size() ==0){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"对不起,录入数据为空!"); |
| | | } |
| | | List<String> result = new ArrayList<>(); |
| | | for(WorktypeImport model : dataList){ |
| | | if(StringUtils.isNotBlank(model.getName()) && !isNewWorkTypeByName(model.getName(),list)){ |
| | | result.add(model.getName()); |
| | | } |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | private boolean isNewWorkTypeByName(String name, List<Worktype> list) { |
| | | if( list!=null && list.size()>0){ |
| | | for(Worktype m : list){ |
| | | if(StringUtils.equals(name,m.getName())){ |
| | | return true; |
| | | } |
| | | } |
| | | } |
| | | return false; |
| | | } |
| | | } |