| | |
| | | import org.springframework.util.CollectionUtils; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * 工种信息表Service实现 |
| | |
| | | ); |
| | | return list; |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | @Override |
| | | public PageData<Worktype> findPage(PageWrap<Worktype> pageWrap) { |
| | |
| | | return worktypeMapper.selectCount(wrapper); |
| | | } |
| | | @Override |
| | | public List<String> importBatch(MultipartFile file ){ |
| | | public List<String> importBatch(MultipartFile file){ |
| | | /* List<Worktype> list = new ArrayList<>(); |
| | | if(id!=null){ |
| | | Worktype param = new Worktype(); |
| | |
| | | if(StringUtils.isBlank(model.getName())){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"对不起,录入数据存在异常"); |
| | | } |
| | | if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(result)){ |
| | | if(!checkHaveName(model.getName(),result)){ |
| | | result.add(model.getName()); |
| | | } |
| | | } |
| | | // if(StringUtils.isNotBlank(model.getName()) && !isNewWorkTypeByName(model.getName(),list)){ |
| | | result.add(model.getName()); |
| | | // } |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public Set<Integer> importBatchForSolutions(MultipartFile file , Integer insuranceId){ |
| | | ExcelImporter ie = null; |
| | | List<WorktypeImport> dataList =null; |
| | | try { |
| | | ie = new ExcelImporter(file,1,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<Integer> result = new ArrayList<>(); |
| | | List<Worktype> inWorkTypeList = null; |
| | | if(Objects.nonNull(insuranceId)){ |
| | | inWorkTypeList = worktypeMapper.selectList(new QueryWrapper<Worktype>().lambda().eq(Worktype::getIsdeleted,Constants.ZERO) |
| | | .eq(Worktype::getInsuranceId,insuranceId).eq(Worktype::getDataType,Constants.TWO) |
| | | ); |
| | | } |
| | | for(WorktypeImport model : dataList){ |
| | | if(StringUtils.isBlank(model.getName())){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"对不起,录入数据存在异常"); |
| | | } |
| | | if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(inWorkTypeList)){ |
| | | Integer workTypeId = getHasWorkTypeByName(model.getName(),inWorkTypeList); |
| | | if(Objects.nonNull(workTypeId)){ |
| | | result.add(workTypeId); |
| | | } |
| | | } |
| | | } |
| | | Set<Integer> resultSet = new HashSet<>(result); |
| | | return resultSet; |
| | | } |
| | | |
| | | private boolean checkHaveName(String name, List<String> list) { |
| | | if( list!=null && list.size()>0){ |
| | | for(String m : list){ |
| | | if(StringUtils.equals(name,m)){ |
| | | return true; |
| | | } |
| | | } |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | private boolean isNewWorkTypeByName(String name, List<Worktype> list) { |
| | |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | private Integer getHasWorkTypeByName(String name, List<Worktype> list) { |
| | | if( list!=null && list.size()>0){ |
| | | for(Worktype m : list){ |
| | | if(StringUtils.equals(name,m.getName())){ |
| | | return m.getId(); |
| | | } |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | } |