| | |
| | | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.google.zxing.WriterException; |
| | |
| | | private final IExperienceService experienceService; |
| | | private final MyAsyncService myAsyncService; |
| | | private final SecurityPaperService securityPaperService; |
| | | private final IUserDetailService userDetailService; |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | |
| | | * @param isCovered |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void importSecurity(List<SecurityExcel> data, Boolean isCovered, String deptId) { |
| | | long time = System.currentTimeMillis(); |
| | | //将不能导入的保安员账号存起来 |
| | | List<String> errorList = new ArrayList<>(); |
| | | //年龄不符的保安员信息存入集合 |
| | |
| | | } |
| | | |
| | | //性别 |
| | | if (null != userExcel.getSex()) { |
| | | if (userExcel.getSex().equals("男")) { |
| | | user.setSex(1); |
| | | } |
| | | if (userExcel.getSex().equals("女")) { |
| | | user.setSex(2); |
| | | } |
| | | } |
| | | |
| | | user.setSex(Integer.parseInt(userExcel.getSex())); |
| | | // 学历 |
| | | if (null != userExcel.getEducation()) { |
| | | if (userExcel.getEducation().equals("初中及以下") |
| | | || userExcel.getEducation().equals("初中") |
| | | ) { |
| | | user.setEducation("1"); |
| | | } |
| | | if (userExcel.getEducation().equals("高中/中技/中专") |
| | | || userExcel.getEducation().equals("高中") |
| | | || userExcel.getEducation().equals("中技") |
| | | || userExcel.getEducation().equals("中专") |
| | | ) { |
| | | user.setEducation("2"); |
| | | } |
| | | if (userExcel.getEducation().equals("大专")) { |
| | | user.setEducation("3"); |
| | | } |
| | | if (userExcel.getEducation().equals("本科")) { |
| | | user.setEducation("4"); |
| | | } |
| | | if (userExcel.getEducation().equals("博士")) { |
| | | user.setEducation("5"); |
| | | } |
| | | if (userExcel.getEducation().equals("硕士")) { |
| | | user.setEducation("6"); |
| | | } |
| | | } |
| | | user.setEducation(userExcel.getEducation()); |
| | | |
| | | //判断当前用户是否已在本单位,如果是的更新数据 |
| | | User user1 = new User(); |
| | |
| | | user.setStatus(1); |
| | | user.setIsDeleted(0); |
| | | user.setHold("2"); |
| | | //判断是否持证 |
| | | // if (null != userExcel.getSecuritynumber() && userExcel.getSecuritynumber() != "") { |
| | | // user.setHold("1"); |
| | | // //校验保安员证编号是否合规 |
| | | // SecurityPaper securityPaper = new SecurityPaper(); |
| | | // securityPaper.setIdCardNo(userExcel.getCardid()); |
| | | // List<SecurityPaper> securityPaperList = securityPaperService.list(Condition.getQueryWrapper(securityPaper)); |
| | | // if (securityPaperList.size()>0){ |
| | | // boolean state = false; |
| | | // //遍历 |
| | | // for (SecurityPaper paper : securityPaperList) { |
| | | // if (paper.getNumber().equals(user.getSecuritynumber())){ |
| | | // state = true; |
| | | // } |
| | | // } |
| | | // if (!state){ |
| | | // user.setHold("2"); |
| | | // user.setSecuritynumber(null); |
| | | // securityInvalidList.add(userExcel.getCardid()); |
| | | // securityInvalidStatus.set(false); |
| | | // } |
| | | // }else { |
| | | // user.setHold("2"); |
| | | // user.setSecuritynumber(null); |
| | | // securityInvalidList.add(userExcel.getCardid()); |
| | | // securityInvalidStatus.set(false); |
| | | // } |
| | | // }else { |
| | | // user.setHold("2"); |
| | | // } |
| | | //判断年龄,超过60岁的不入 |
| | | // if (AgeUtil.idCardToAge(user.getCardid())<60) { |
| | | //分配保安角色 |
| | | Role role = new Role(); |
| | | role.setRoleAlias("保安"); |
| | |
| | | user.setDispatch("1"); |
| | | user.setExaminationType("0"); |
| | | //新增 |
| | | // this.save(user); |
| | | boolean save = this.save(user); |
| | | //并更新详情数据 |
| | | if(save){ |
| | | UserDetailEntity detailEntity = new UserDetailEntity(); |
| | | detailEntity.setUserId(user.getId()); |
| | | detailEntity.setDwellAddress(userExcel.getDwellAddress()); |
| | | detailEntity.setEducationExperience(userExcel.getEducationExperience()); |
| | | detailEntity.setMemberOfFamily(userExcel.getMemberOfFamily()); |
| | | detailEntity.setWorkExperience(userExcel.getWorkExperience()); |
| | | detailEntity.setPermanentResidenceAddress(userExcel.getPermanentResidenceAddress()); |
| | | detailEntity.setMarriageStatus(Integer.parseInt(userExcel.getMarriageStatus())); |
| | | detailEntity.setSignLevel(Integer.parseInt(userExcel.getSignLevel())); |
| | | userDetailService.save(detailEntity); |
| | | } |
| | | //加入集合 |
| | | userList.add(user); |
| | | // userList.add(user); |
| | | //从业记录新增 |
| | | Experience experience = new Experience(); |
| | | experience.setCardid(user.getCardid()); |
| | | // experience.setSecurityid(user.getId().toString()); |
| | | experience.setCompanyname(userExcel.getDeptId()); |
| | | experience.setName(user.getRealName()); |
| | | experience.setPost("保安员"); |
| | | experience.setEntrytime(new Date()); |
| | | // experienceService.save(experience); |
| | | // 新增 |
| | | experienceService.save(experience); |
| | | //加入集合 |
| | | experienceList.add(experience); |
| | | // experienceList.add(experience); |
| | | |
| | | }else { |
| | | //匹配组织机构是否一致,如果不一致 |
| | |
| | | continue; |
| | | }else { |
| | | //如果是一致,则更新用户数据 |
| | | //判断是否持证 |
| | | // if (null != userExcel.getSecuritynumber() && userExcel.getSecuritynumber() != "") { |
| | | // user2.setHold("1"); |
| | | // user2.setSecuritynumber(user.getSecuritynumber()); |
| | | // //校验保安员证编号是否合规 |
| | | // SecurityPaper securityPaper = new SecurityPaper(); |
| | | // securityPaper.setIdCardNo(userExcel.getCardid()); |
| | | // List<SecurityPaper> securityPaperList = securityPaperService.list(Condition.getQueryWrapper(securityPaper)); |
| | | // if (securityPaperList.size()>0){ |
| | | // boolean state = false; |
| | | // //遍历 |
| | | // for (SecurityPaper paper : securityPaperList) { |
| | | // if (paper.getNumber().equals(user.getSecuritynumber())){ |
| | | // state = true; |
| | | // } |
| | | // } |
| | | // if (!state){ |
| | | // user2.setHold("2"); |
| | | // user2.setSecuritynumber(null); |
| | | // securityInvalidList.add(userExcel.getCardid()); |
| | | // securityInvalidStatus.set(false); |
| | | // } |
| | | // }else { |
| | | // user2.setHold("2"); |
| | | // user2.setSecuritynumber(null); |
| | | // securityInvalidList.add(userExcel.getCardid()); |
| | | // securityInvalidStatus.set(false); |
| | | // } |
| | | // }else { |
| | | // user2.setHold("2"); |
| | | // } |
| | | // user2.setHold("2"); |
| | | if (null!=userExcel.getRegistered()){ |
| | | user2.setRegistered(userExcel.getRegistered()); |
| | | }else { |
| | |
| | | |
| | | user2.setUpdateTime(new Date()); |
| | | //更新用户数据 |
| | | this.updateById(user2); |
| | | boolean update = this.updateById(user2); |
| | | //并更新详情数据 |
| | | if(update){ |
| | | // 通过用户id 查询,如果存在则更新,不存在则更新 |
| | | QueryWrapper<UserDetailEntity> wrapper = new QueryWrapper<>(); |
| | | wrapper.eq("is_deleted",0).eq("user_id",user2.getId()); |
| | | UserDetailEntity one = userDetailService.getOne(wrapper); |
| | | if (null!=one){ |
| | | one.setDwellAddress(userExcel.getDwellAddress()); |
| | | one.setEducationExperience(userExcel.getEducationExperience()); |
| | | one.setMemberOfFamily(userExcel.getMemberOfFamily()); |
| | | one.setWorkExperience(userExcel.getWorkExperience()); |
| | | one.setPermanentResidenceAddress(userExcel.getPermanentResidenceAddress()); |
| | | one.setMarriageStatus(Integer.parseInt(userExcel.getMarriageStatus())); |
| | | one.setSignLevel(Integer.parseInt(userExcel.getSignLevel())); |
| | | userDetailService.updateById(one); |
| | | }else { |
| | | UserDetailEntity detailEntity = new UserDetailEntity(); |
| | | detailEntity.setUserId(user2.getId()); |
| | | detailEntity.setDwellAddress(userExcel.getDwellAddress()); |
| | | detailEntity.setEducationExperience(userExcel.getEducationExperience()); |
| | | detailEntity.setMemberOfFamily(userExcel.getMemberOfFamily()); |
| | | detailEntity.setWorkExperience(userExcel.getWorkExperience()); |
| | | detailEntity.setPermanentResidenceAddress(userExcel.getPermanentResidenceAddress()); |
| | | detailEntity.setMarriageStatus(Integer.parseInt(userExcel.getMarriageStatus())); |
| | | detailEntity.setSignLevel(Integer.parseInt(userExcel.getSignLevel())); |
| | | userDetailService.save(detailEntity); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | //批量插入 |
| | | //用户批量插入 |
| | | if (userList.size()>0) { |
| | | baseMapper.batchUserList(userList); |
| | | //装换成map |
| | | Map<String, User> userMap = userList.stream().collect(Collectors.toMap(user -> user.getCardid(), user -> user)); |
| | | //匹配 |
| | | experienceList = experienceList.stream().map(experience -> { |
| | | if (experience.getCardid().equals(userMap.get(experience.getCardid()).getCardid())) { |
| | | experience.setSecurityid(userMap.get(experience.getCardid()).getId().toString()); |
| | | } |
| | | return experience; |
| | | }).collect(Collectors.toList()); |
| | | //批量插入从业记录 |
| | | baseMapper.batchExperienceList(experienceList); |
| | | } |
| | | // System.out.println("导入时间: = " + (System.currentTimeMillis()-time)); |
| | | // if (userList.size()>0) { |
| | | // baseMapper.batchUserList(userList); |
| | | // //装换成map |
| | | // Map<String, User> userMap = userList.stream().collect(Collectors.toMap(user -> user.getCardid(), user -> user)); |
| | | // //匹配 |
| | | // experienceList = experienceList.stream().map(experience -> { |
| | | // if (experience.getCardid().equals(userMap.get(experience.getCardid()).getCardid())) { |
| | | // experience.setSecurityid(userMap.get(experience.getCardid()).getId().toString()); |
| | | // } |
| | | // return experience; |
| | | // }).collect(Collectors.toList()); |
| | | // //批量插入从业记录 |
| | | // baseMapper.batchExperienceList(experienceList); |
| | | // } |
| | | |
| | | //如果所有数据导入有一个异常 |
| | | StringBuilder errorBuilder = new StringBuilder(); |