| | |
| | | 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.dto.UserDTO; |
| | | import org.springblade.modules.system.entity.*; |
| | | import org.springblade.modules.system.excel.*; |
| | | import org.springblade.modules.system.mapper.UserMapper; |
| | |
| | | User user = new User(); |
| | | user.setPassword(DigestUtil.encrypt(CommonConstant.DEFAULT_PASSWORD)); |
| | | user.setUpdateTime(DateUtil.now()); |
| | | return this.update(user, Wrappers.<User>update().lambda().in(User::getId, Func.toLongList(userIds))); |
| | | boolean update = this.update(user, Wrappers.<User>update().lambda().in(User::getId, Func.toLongList(userIds))); |
| | | if (update){ |
| | | //如果是保安员同步群防群控 |
| | | List<String> list = Arrays.asList(userIds.split(",")); |
| | | for (String s : list) { |
| | | User user1 = getById(userIds); |
| | | UserDTO userDTO = new UserDTO(); |
| | | userDTO.setAccount(user1.getAccount()); |
| | | userDTO.setPassword(user1.getPassword()); |
| | | userDTO.setSecurityId(user1.getId().toString()); |
| | | userDTO.setPhone(user1.getPhone()); |
| | | userDTO.setRealName(user1.getRealName()); |
| | | userDTO.setCardid(user1.getCardid()); |
| | | userDTO.setSex(user1.getSex()); |
| | | //异步修改群防群控 |
| | | myAsyncService.updateUserByAccount(userDTO); |
| | | } |
| | | } |
| | | return update; |
| | | } |
| | | |
| | | @Override |
| | |
| | | */ |
| | | @Override |
| | | public void importSecurity(List<SecurityExcel> data, Boolean isCovered, String deptId) { |
| | | long time = System.currentTimeMillis(); |
| | | //uuidList |
| | | List<String> uuidList = new ArrayList<>(); |
| | | //将不能导入的保安员账号存起来 |
| | | List<String> errorList = new ArrayList<>(); |
| | | //年龄不符的保安员信息存入集合 |
| | | List<String> ageErrorList = new ArrayList<>(); |
| | | //保安员证编号不符的保安员信息存入集合 |
| | | List<String> securityInvalidList = new ArrayList<>(); |
| | | //将需要更新的保安员信息存入集合 |
| | | List<User> updateList = new ArrayList<>(); |
| | | //需要推送内网的保安员信息集合 |
| | | List<User> userList = new ArrayList<>(); |
| | | //需要新增的保安员集合 |
| | | List<User> addList = new ArrayList<>(); |
| | | //需要新增的从业记录集合 |
| | | List<Experience> experienceList = 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)); |
| | |
| | | user.setStatus(1); |
| | | user.setIsDeleted(0); |
| | | //分配保安角色 |
| | | // Role role = new Role(); |
| | | // role.setRoleAlias("保安"); |
| | | // Role oneRole = roleService.getOne(Condition.getQueryWrapper(role)); |
| | | user.setRoleId("1412226235153731586"); |
| | | |
| | | if (null!=user.getSecuritynumber() && !user.getSecuritynumber().equals("")){ |
| | |
| | | } |
| | | |
| | | //性别 |
| | | if (null != userExcel.getSex()) { |
| | | if (userExcel.getSex().equals("男")) { |
| | | user.setSex(1); |
| | | }else if (userExcel.getSex().equals("女")) { |
| | | user.setSex(2); |
| | | }else { |
| | | user.setSex(1); |
| | | } |
| | | }else { |
| | | if (IdCardNoUtil.getSex(userExcel.getCardid()).equals("男")) { |
| | | user.setSex(1); |
| | | }else { |
| | | user.setSex(2); |
| | | } |
| | | |
| | | //设置账号 |
| | | String realName = user.getRealName(); |
| | | String cardid = user.getCardid(); |
| | | // user.setAccount(user.getRealName()); |
| | | user.setAccount(realName.substring(0,1)+cardid.substring(cardid.length()-4)); |
| | | //加密 |
| | | user.setPassword(DigestUtil.encrypt(user.getCardid().substring(user.getCardid().length() - 6))); |
| | |
| | | user0.setReasonForLeav(uuid); |
| | | //加入集合 |
| | | userList.add(user0); |
| | | uuidList.add(uuid); |
| | | } |
| | | |
| | | Result result = new Result(); |
| | | //用户批量插入 |
| | | if (userList.size()>0) { |
| | | //生成随机数 |
| | |
| | | Map<String, Object> map = new HashMap<>(1); |
| | | map.put(uuid, userList); |
| | | myAsyncService.FTPObjectList(map); |
| | | |
| | | // int count = 0; |
| | | // //调用ftp获取返回数据 |
| | | // while (true){ |
| | | // try { |
| | | // Thread.sleep(4000); |
| | | // } catch (InterruptedException e) { |
| | | // e.printStackTrace(); |
| | | // } |
| | | // //调用ftp获取返回数据 |
| | | // result = Monitor.getFtpDataByUuidList(uuid); |
| | | // //如果返回true,就退处 |
| | | // if (result.getCode() == 200) { |
| | | // break; |
| | | // } |
| | | // else { |
| | | // count++; |
| | | // if (count == 20) { |
| | | // break; |
| | | // } |
| | | // } |
| | | // } |
| | | } |
| | | |
| | | // if (null!=result){ |
| | |
| | | // } |
| | | |
| | | // //如果所有数据导入有一个异常 |
| | | // StringBuilder errorBuilder = new StringBuilder(); |
| | | StringBuilder errorBuilder = new StringBuilder(); |
| | | // if (!status.get()){ |
| | | // String errorAccount = StringUtils.join(errorList, "\\\n"); |
| | | // errorBuilder.append("用户:[" + errorAccount + "]导入失败!已在其他单位存在!"); |
| | | // } |
| | | // if (!agetStatus.get()){ |
| | | // String errorAccount = StringUtils.join(ageErrorList, "\\\n"); |
| | | // errorBuilder.append("用户:[" + 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 + "]保安证编号不匹配,请核实!"); |
| | | // errorBuilder.append("用户:[" + errorAccount + "]保安证编号不匹配,请核实!也可通过提供保安证件信息提交核实申请!"); |
| | | // } |
| | | // //抛出异常 |
| | | // if (errorBuilder.length()>0){ |
| | | // throw new ServiceException(errorBuilder.toString()); |
| | | // } |
| | | //抛出异常 |
| | | if (errorBuilder.length()>0){ |
| | | throw new ServiceException(errorBuilder.toString()); |
| | | } |
| | | } |
| | | |
| | | /** |