| | |
| | | import com.doumee.core.utils.DateUtil; |
| | | import com.doumee.core.utils.Utils; |
| | | import com.doumee.dao.business.MemberMapper; |
| | | import com.doumee.dao.business.WorktypeMapper; |
| | | import com.doumee.dao.business.dto.MemberImport; |
| | | import com.doumee.dao.business.dto.MemberQueryDTO; |
| | | import com.doumee.dao.business.dto.WorktypeImport; |
| | | import com.doumee.dao.business.join.DispatchUnitJoinMapper; |
| | | import com.doumee.dao.business.join.MemberJoinMapper; |
| | | import com.doumee.dao.business.model.*; |
| | | import com.doumee.service.business.MemberService; |
| | |
| | | |
| | | @Autowired |
| | | private MemberJoinMapper memberJoinMapper; |
| | | |
| | | @Autowired |
| | | private DispatchUnitJoinMapper dispatchUnitJoinMapper; |
| | | |
| | | @Autowired |
| | | private WorktypeMapper worktypeMapper; |
| | | |
| | | @Override |
| | | public Integer create(Member member) { |
| | |
| | | |
| | | |
| | | @Override |
| | | public List<MemberImport> importBatch(MultipartFile file){ |
| | | public List<MemberImport> importBatch(MultipartFile file,Integer solutionId){ |
| | | LoginUserInfo loginUserInfo = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal(); |
| | | if(!loginUserInfo.getType().equals(Constants.ONE)){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"非企业人员无法进行该操作"); |
| | |
| | | if(idCardList.size() != set.size()){ |
| | | throw new BusinessException(ResponseStatus.DATA_ERRO.getCode(),"对不起,录入数据存在身份证号相同数据!"); |
| | | } |
| | | List<DispatchUnit> dispatchUnitList = new ArrayList<>(); |
| | | if(!Objects.isNull(solutionId)){ |
| | | dispatchUnitList = dispatchUnitJoinMapper.selectJoinList(DispatchUnit.class, |
| | | new MPJLambdaWrapper<DispatchUnit>() |
| | | .selectAll(DispatchUnit.class) |
| | | .select("(select b.id from du_solution b where b.isdeleted=0 and b.dispatch_unit_id=t.id and b.solution_id="+solutionId+" limit 1) as du_solution_id" ) |
| | | .eq(DispatchUnit::getIsdeleted,Constants.ZERO) |
| | | .eq(DispatchUnit::getStatus,Constants.ZERO) |
| | | .eq(DispatchUnit::getDataType,Constants.TWO) |
| | | .eq(loginUserInfo.getType().equals(Constants.ONE),DispatchUnit::getCompanyId,loginUserInfo.getCompanyId()) |
| | | .exists("select b.id from du_solution b where b.isdeleted=0 and b.dispatch_unit_id=t.id and b.status = 1 and b.solution_id="+solutionId ) |
| | | ); |
| | | if(CollectionUtils.isNotEmpty(dispatchUnitList)){ |
| | | for (DispatchUnit dispatchUnit:dispatchUnitList) { |
| | | List<Worktype> worktypeList = worktypeMapper.selectList(new QueryWrapper<Worktype>().lambda() |
| | | .eq(Worktype::getIsdeleted,Constants.ZERO) |
| | | .eq(Worktype::getDataType,Constants.TWO) |
| | | .eq(Worktype::getStatus,Constants.ZERO) |
| | | .apply("id in ( select dw.work_type_id from du_worktype dw where dw.status = 1" + |
| | | " and dw.du_solution_id = "+dispatchUnit.getDuSolutionId()+" )") |
| | | ); |
| | | dispatchUnit.setWorktypeList(worktypeList); |
| | | } |
| | | } |
| | | } |
| | | long index = Constants.TWO; |
| | | for(MemberImport model : dataList){ |
| | | if(StringUtils.isBlank(model.getIdCard())||model.getIdCard().length()!=18){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"对不起,第"+index+"行数据身份证信息异常!"); |
| | | } |
| | | if(StringUtils.isBlank(model.getName())){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"对不起,第"+index+"行数据姓名信息异常!"); |
| | | } |
| | | index = index + Constants.ONE; |
| | | if(CollectionUtils.isNotEmpty(list)){ |
| | | Optional<Member> memberOptional= list.stream().filter(m->m.getIdcardNo().equals(model.getIdCard())).findFirst(); |
| | | if(memberOptional.isPresent()){ |
| | |
| | | }else{ |
| | | model.setSex(Constants.getSexByIdCard(model.getIdCard())); |
| | | } |
| | | if(StringUtils.isNotBlank(model.getDuName())&&CollectionUtils.isNotEmpty(dispatchUnitList)){ |
| | | Optional<DispatchUnit> dispatchUnitOptional= dispatchUnitList.stream().filter(m->m.getName().equals(model.getDuName())).findFirst(); |
| | | if(dispatchUnitOptional.isPresent()){ |
| | | DispatchUnit dispatchUnit = dispatchUnitOptional.get(); |
| | | model.setDuId(dispatchUnit.getId()); |
| | | if(StringUtils.isNotBlank(model.getWorkTypeName())&&CollectionUtils.isNotEmpty(dispatchUnit.getWorktypeList())){ |
| | | Optional<Worktype> worktypeOptional= dispatchUnit.getWorktypeList().stream().filter(m->m.getName().equals(model.getWorkTypeName())).findFirst(); |
| | | if(worktypeOptional.isPresent()){ |
| | | Worktype worktype = worktypeOptional.get(); |
| | | model.setWorktypeId(worktype.getId()); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | if(Objects.isNull(model.getDuId())){ |
| | | model.setWorkTypeName(null); |
| | | model.setDuName(null); |
| | | }else if(Objects.isNull(model.getWorktypeId())){ |
| | | model.setWorkTypeName(null); |
| | | } |
| | | } |
| | | return dataList; |
| | | } |