| | |
| | | import org.springblade.core.tool.support.Kv; |
| | | import org.springblade.core.tool.utils.*; |
| | | import org.springblade.modules.FTP.FtpUtil; |
| | | import org.springblade.modules.FTP.Monitor; |
| | | import org.springblade.modules.FTP.Result; |
| | | import org.springblade.modules.accreditation.entity.AccreditationRecords; |
| | | import org.springblade.modules.accreditation.service.AccreditationRecordsService; |
| | | import org.springblade.modules.dispatcher.entity.Dispatcher; |
| | |
| | | import org.springblade.modules.system.wrapper.UserWrapper; |
| | | import org.springblade.modules.training.entity.TrainingRegistration; |
| | | import org.springblade.modules.training.service.TrainingRegistrationService; |
| | | import org.springframework.data.redis.core.RedisTemplate; |
| | | import org.springframework.scheduling.annotation.Async; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.web.bind.annotation.*; |
| | |
| | | private final SecurityPaperService securityPaperService; |
| | | |
| | | private final MyAsyncService myAsyncService; |
| | | |
| | | private final RedisTemplate redisTemplate; |
| | | |
| | | /** |
| | | * 查询单条 |
| | |
| | | } |
| | | } |
| | | //填写你文件上传的地址以及相应信息 |
| | | String url = "http://223.82.109.183:2081"; |
| | | String url = "http://61.131.136.25:2081"; |
| | | String access = "zhbaadmin"; |
| | | String secret = "zhbapassword"; |
| | | String bucket = "zhba"; |
| | |
| | | FtpUtil.uploadFile(FtpConfig.ftpHost, ftpPort, FtpConfig.ftpUserName, ftpPassword, ftpPath, "/", split[2], inputStream); |
| | | in.close(); |
| | | //外围url |
| | | String urls = "http://223.82.109.183:2081/zhba/" + newName; |
| | | String urls = "http://61.131.136.25:2081/zhba/" + newName; |
| | | //内网 |
| | | String inUrl = FtpConfig.ip + "/zhba/" + newName; |
| | | //返回 |
| | |
| | | user.setDispatch("1"); |
| | | user.setExaminationType("0"); |
| | | user.setAccount(user.getCardid()); |
| | | user.setStatus(1); |
| | | |
| | | User user1 = new User(); |
| | | user1.setIsDeleted(0); |
| | |
| | | experience.setPost("保安员"); |
| | | experienceService.save(experience); |
| | | |
| | | |
| | | //发证日期处理 |
| | | // if (user.getPaperTime() == null) { |
| | | // paperTime = ""; |
| | | // } else { |
| | | // paperTime = new SimpleDateFormat("yyyy-MM-dd").format(user.getPaperTime()); |
| | | // } |
| | | //头像 |
| | | if (null != user.getAvatar() && !user.getAvatar().equals("")) { |
| | | user.setAvatar(FtpConfig.ip + user.getAvatar().substring(26)); |
| | |
| | | } |
| | | |
| | | /** |
| | | * 保安员新增(外网不能存敏感数据) |
| | | * @since 2022-04-26 |
| | | * @param userMap |
| | | */ |
| | | @PostMapping("/securitySaves") |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public R securitySaves(@Valid @RequestBody Map<String, Object> userMap) throws Exception { |
| | | //获取user |
| | | User user = JSON.parseObject(JSON.toJSONString(userMap.get("user")), User.class); |
| | | |
| | | //分配保安角色 |
| | | Role role = new Role(); |
| | | role.setRoleAlias("保安"); |
| | | Role oneRole = roleService.getOne(Condition.getQueryWrapper(role)); |
| | | user.setRoleId(oneRole.getId().toString()); |
| | | user.setDispatch("1"); |
| | | user.setExaminationType("0"); |
| | | user.setAccount(user.getRealName()); |
| | | |
| | | //密码加密 |
| | | if (Func.isNotEmpty(user.getCardid())) { |
| | | //取身份证号码后6位作为密码 |
| | | user.setPassword(DigestUtil.encrypt(user.getCardid().substring(user.getCardid().length() - 6))); |
| | | } |
| | | user.setCreateTime(new Date()); |
| | | user.setTenantId("000000"); |
| | | //用户新增 |
| | | // boolean status = userService.save(user); |
| | | |
| | | |
| | | User user1 = user; |
| | | //头像 |
| | | if (null != user.getAvatar() && !user.getAvatar().equals("")) { |
| | | user1.setAvatar(FtpConfig.ip + user.getAvatar().substring(26)); |
| | | } |
| | | //指纹 |
| | | String url = ""; |
| | | if (null != user.getFingerprint() && !user.getFingerprint().equals("")) { |
| | | if (user.getFingerprint().length() > 100) { |
| | | String s = uploadBase64String(user); |
| | | String[] split = s.split(","); |
| | | user.setFingerprint(split[0]); |
| | | url = split[1]; |
| | | user1.setFingerprint(url); |
| | | } |
| | | } |
| | | |
| | | //生成随机数 |
| | | String uuid = UUID.randomUUID().toString(); |
| | | //将 user 存入 redis |
| | | redisTemplate.opsForValue().set(uuid,JSON.toJSONString(user)); |
| | | //user1 临时设置uuid 到 reason_for_leav 离职原因字段 |
| | | user1.setReasonForLeav(uuid); |
| | | |
| | | //数据推送 |
| | | Map<String, Object> map = new HashMap<>(1); |
| | | map.put("user",user1); |
| | | myAsyncService.FTPObject(map); |
| | | |
| | | int count = 0; |
| | | int flag = 1; |
| | | Result result = new Result(); |
| | | //调用ftp获取返回数据 |
| | | while (true){ |
| | | Thread.sleep(1000); |
| | | //调用ftp获取返回数据 |
| | | result = Monitor.isFTPFileExist(uuid); |
| | | //如果返回true,就退处 |
| | | if (result.getCode()==200){ |
| | | flag = 1; |
| | | break; |
| | | }else if (result.getCode()==201){ |
| | | flag = 2; |
| | | break; |
| | | }else if (result.getCode()==202){ |
| | | flag = 3; |
| | | break; |
| | | }else{ |
| | | //计数 |
| | | count++; |
| | | //如果超过10s 没有读取到,则退出 |
| | | if (count == 10) { |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | if (flag==1 || flag==2) { |
| | | //返回 |
| | | return R.data(200, null, "新增成功!"); |
| | | }else if (flag==3){ |
| | | throw new ServiceException(result.getMsg()); |
| | | }else{ |
| | | //返回 |
| | | return R.data(400, null, "新增失败!"); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 修改派遣记录,修改从业记录 |
| | | * |
| | | * @param user |