| | |
| | | import org.springblade.modules.information.service.IInformationService; |
| | | import org.springblade.modules.jurisdiction.entity.Jurisdiction; |
| | | import org.springblade.modules.jurisdiction.service.JurisdictionService; |
| | | import org.springblade.modules.securitypaper.entity.SecurityPaper; |
| | | import org.springblade.modules.securitypaper.service.SecurityPaperService; |
| | | import org.springblade.modules.system.entity.*; |
| | | import org.springblade.modules.system.excel.QrCodeExcel; |
| | | import org.springblade.modules.system.excel.SecurityExcel; |
| | |
| | | private final JurisdictionService jurisdictionService; |
| | | private final IExperienceService experienceService; |
| | | private final MyAsyncService myAsyncService; |
| | | private final SecurityPaperService securityPaperService; |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | |
| | | List<String> errorList = new ArrayList<>(); |
| | | //年龄不符的保安员信息存入集合 |
| | | List<String> ageErrorList = new ArrayList<>(); |
| | | //保安员证编号不符的保安员信息存入集合 |
| | | List<String> securityInvalidList = new ArrayList<>(); |
| | | //将需要更新的保安员信息存入集合 |
| | | List<User> updateList = new ArrayList<>(); |
| | | //需要新增的保安员集合 |
| | |
| | | //导入状态,默认为true ,如果有一个出现问题则为 false |
| | | AtomicBoolean status = new AtomicBoolean(true); |
| | | AtomicBoolean agetStatus = new AtomicBoolean(true); |
| | | AtomicBoolean securityInvalidStatus = new AtomicBoolean(true); |
| | | //遍历 |
| | | for (SecurityExcel userExcel : data) { |
| | | User user = Objects.requireNonNull(BeanUtil.copy(userExcel, User.class)); |
| | |
| | | continue; |
| | | } |
| | | } |
| | | |
| | | //判断当前用户是否已在本单位,如果是的更新数据 |
| | | User user1 = new User(); |
| | | user1.setAccount(user.getCardid()); |
| | |
| | | //判断是否持证 |
| | | if (null != userExcel.getSecuritynumber() && userExcel.getSecuritynumber() != "") { |
| | | user.setHold("1"); |
| | | //校验保安员证编号是否合规 |
| | | if (null!=userExcel.getSecuritynumber() && !userExcel.getSecuritynumber().equals("")){ |
| | | //持证,校验保安证编号是否合法 |
| | | 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"); |
| | | } |
| | |
| | | user2.setDeptId(dept1.getId().toString()); |
| | | //判断是否持证 |
| | | if (null != userExcel.getSecuritynumber() && userExcel.getSecuritynumber() != "") { |
| | | user.setHold("1"); |
| | | }else { |
| | | user.setHold("2"); |
| | | } |
| | | 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.setUpdateTime(new Date()); |
| | | this.updateById(user2); |
| | | //qfqk异步推送 |
| | | myAsyncService.updateUserByQfqk(user2); |
| | | String s1 = |
| | | "update blade_user set hold = " + "'" + user2.getHold() + "'" |
| | | + ",securitynumber = " + "'" + user2.getSecuritynumber() + "'" |
| | |
| | | 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.setUpdateTime(new Date()); |
| | | //更新用户数据 |
| | | this.updateById(user2); |
| | | //qfqk异步推送 |
| | | myAsyncService.updateUserByQfqk(user2); |
| | | //内网数据sql |
| | | String s1 = |
| | | "update blade_user set hold = " + "'" + user2.getHold() + "'" |
| | | + ",securitynumber = " + "'" + user2.getSecuritynumber() + "'" |
| | |
| | | //用户批量插入 |
| | | if (userList.size()>0) { |
| | | baseMapper.batchUserList(userList); |
| | | //用户批量插入异步推送 |
| | | myAsyncService.batchUserList(userList); |
| | | //sql 拼接 |
| | | StringBuilder builder = new StringBuilder(); |
| | | StringBuilder builder1 = new StringBuilder(); |
| | |
| | | // System.out.println("导入时间: = " + (System.currentTimeMillis()-time)); |
| | | |
| | | //如果所有数据导入有一个异常 |
| | | if (!status.get() || !agetStatus.get()){ |
| | | if (!status.get() && agetStatus.get()) { |
| | | String errorAccount = StringUtils.join(errorList, "\\\n"); |
| | | throw new ServiceException("用户:[" + errorAccount + "]导入失败!已在其他单位存在!"); |
| | | } |
| | | if (!agetStatus.get() && status.get()) { |
| | | String errorAccount = StringUtils.join(ageErrorList, "\\\n"); |
| | | throw new ServiceException("用户:[" + errorAccount + "]导入失败!身份证号码不正确,请核对!"); |
| | | } |
| | | if (!status.get() && !agetStatus.get()) { |
| | | String errorAccount = StringUtils.join(errorList, "\\\n"); |
| | | String errorAgeAccount = StringUtils.join(ageErrorList, "\\\n"); |
| | | throw new ServiceException("用户:[" + errorAccount + "]导入失败!已在其他单位存在!"+ |
| | | "用户:[" + errorAgeAccount + "]导入失败!身份证号码不正确,请核对!"); |
| | | } |
| | | StringBuilder errorBuilder = new StringBuilder(); |
| | | if (!status.get()){ |
| | | String errorAccount = StringUtils.join(errorList, "\\\n"); |
| | | errorBuilder.append("用户:[" + errorAccount + "]导入失败!已在其他单位存在!"); |
| | | } |
| | | // if (!status.get()) { |
| | | // String errorAccount = StringUtils.join(errorList, "\\\n"); |
| | | // throw new ServiceException("用户:[" + errorAccount + "]导入失败!已在其他单位存在!"); |
| | | // } |
| | | if (!agetStatus.get()){ |
| | | String errorAccount = StringUtils.join(ageErrorList, "\\\n"); |
| | | errorBuilder.append("用户:[" + errorAccount + "]导入失败!已在其他单位存在!"); |
| | | } |
| | | if (!securityInvalidStatus.get()){ |
| | | String errorAccount = StringUtils.join(securityInvalidList, "\\\n"); |
| | | errorBuilder.append("用户:[" + errorAccount + "]保安证编号不匹配,请核实!也可通过提供保安证件信息提交核实申请!!"); |
| | | } |
| | | //抛出异常 |
| | | if (errorBuilder.length()>0){ |
| | | throw new ServiceException(errorBuilder.toString()); |
| | | } |
| | | } |
| | | |
| | | @Override |