| | |
| | | import org.springblade.core.tool.support.Kv; |
| | | import org.springblade.core.tool.utils.*; |
| | | import org.springblade.modules.FTP.FtpUtil; |
| | | import org.springblade.modules.dispatcher.entity.Dispatcher; |
| | | import org.springblade.modules.dispatcher.service.IDispatcherService; |
| | | import org.springblade.modules.exam.excel.ExportExamScoreExcel; |
| | | import org.springblade.modules.experience.entity.Experience; |
| | | import org.springblade.modules.experience.service.IExperienceService; |
| | |
| | | private final IExperienceService experienceService; |
| | | |
| | | private final JurisdictionService jurisdictionService; |
| | | |
| | | private final IDispatcherService dispatcherService; |
| | | |
| | | /** |
| | | * 查询单条 |
| | |
| | | } |
| | | } |
| | | |
| | | //如果是离职 |
| | | if (null!=user.getStatus()){ |
| | | if (user.getStatus()==2){ |
| | | //修改派遣状态 |
| | | user.setDispatch("1"); |
| | | //同时将派遣记录中的派遣状态修改 |
| | | //查询派遣记录(还在派遣中的) |
| | | Dispatcher dispatcher = new Dispatcher(); |
| | | dispatcher.setUserIds(user.getId().toString()); |
| | | dispatcher.setStatus(0); |
| | | List<Dispatcher> dispatcherList = dispatcherService.list(Condition.getQueryWrapper(dispatcher)); |
| | | if (dispatcherList.size()>0){ |
| | | dispatcherList.forEach(dispatcher1 -> { |
| | | dispatcher1.setStatus(1); |
| | | dispatcher1.setUpdateTime(new Date()); |
| | | String s1 = |
| | | "update sys_dispatcher set status = " + "'" + dispatcher1.getStatus() + "'" |
| | | + ",update_time = " + "'" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(dispatcher1.getUpdateTime()) + "'" |
| | | + " " + "where id = " + "'" + dispatcher1.getId() + "'"; |
| | | FtpUtil.sqlFileUpload(s1); |
| | | }); |
| | | } |
| | | } |
| | | } |
| | | |
| | | //如果是异常标记 |
| | | if (null!=user.getExaminationType() && !user.getExaminationType().equals("")){ |
| | | if (user.getExaminationType().equals("1")) { |
| | | //吊销保安证 |
| | | user.setHold("3"); |
| | | } |
| | | } |
| | | |
| | | user.setPassword(user1.getPassword()); |
| | | userService.updateById(user); |
| | | String rtime; |
| | |
| | | + ",address = " + "'" + user.getAddress() + "'" |
| | | + ",registered = " + "'" + user.getRegistered() + "'" |
| | | + ",rtime = " + "'" + rtime + "'" |
| | | + ",dispatch = " + "'" + user.getDispatch() + "'" |
| | | + ",securitynumber = " + "'" + user.getSecuritynumber() + "'" |
| | | + ",hold = " + "'" + user.getHold() + "'" |
| | | + ",jurisdiction = " + "'" + user.getJurisdiction() + "'" |
| | | + ",reason_for_leav = " + "'" + user.getReasonForLeav() + "'" |
| | | + ",guncode = " + "'" + user.getGuncode() + "'" |
| | | + " " + "where id = " + "'" + user.getId() + "'"; |
| | | FtpUtil.sqlFileUpload(s1); |
| | | return R.success("修改成功"); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 修改 |
| | | */ |
| | | @PostMapping("/updateUserInfo") |
| | | public R updateUserInfo(@Valid @RequestBody User user) throws Exception { |
| | | String url = null; |
| | | if (null!=user.getFingerprint() && !user.getFingerprint().equals("")) { |
| | | if (user.getFingerprint().length()>100) { |
| | | //指纹图片上传并返回url |
| | | String s = uploadBase64String(user); |
| | | String[] split = s.split(","); |
| | | user.setFingerprint(split[0]); |
| | | //内网指纹图片url |
| | | url = split[1]; |
| | | } |
| | | } |
| | | |
| | | userService.updateById(user); |
| | | |
| | | //内网同步 |
| | | String s1 = |
| | | "update blade_user set account = " + "'" + user.getCardid() + "'" |
| | | + ",real_name = " + "'" + user.getRealName() + "'" |
| | | + ",avatar = " + "'" + user.getAvatar() + "'" |
| | | + ",sex = " + "'" + user.getSex() + "'" |
| | | + ",cardid = " + "'" + user.getCardid() + "'" |
| | | + ",nation = " + "'" + user.getNation() + "'" |
| | | + ",fingerprint = " + "'" + url + "'" |
| | | + ",my_picture = " + "'" + user.getMyPicture() + "'" |
| | | + ",address = " + "'" + user.getAddress() + "'" |
| | | + ",registered = " + "'" + user.getRegistered() + "'" |
| | | + ",securitynumber = " + "'" + user.getSecuritynumber() + "'" |
| | | + ",hold = " + "'" + user.getHold() + "'" |
| | | + ",cell = " + "'" + user.getCell() + "'" |
| | | + " " + "where id = " + "'" + user.getId() + "'"; |
| | | FtpUtil.sqlFileUpload(s1); |
| | | return R.success("修改成功"); |
| | |
| | | @ApiOperation(value = "导入用户", notes = "传入excel") |
| | | public R importSecurity(MultipartFile file, Integer isCovered,String deptId) { |
| | | SecurityImporter securityImporter = new SecurityImporter(userService, false,deptId); |
| | | ExcelUtil.save(file, securityImporter, SecurityExcel.class); |
| | | return R.success("操作成功"); |
| | | } |
| | | |
| | | /** |
| | | * 导入保安员(test) |
| | | */ |
| | | @PostMapping("import-security-test") |
| | | @ApiOperationSupport(order = 12) |
| | | @ApiOperation(value = "导入用户", notes = "传入excel") |
| | | public R importSecurityTest(MultipartFile file, Integer isCovered,String deptId) { |
| | | SecurityImporterTest securityImporter = new SecurityImporterTest(userService, false,deptId); |
| | | ExcelUtil.save(file, securityImporter, SecurityExcel.class); |
| | | return R.success("操作成功"); |
| | | } |
| | |
| | | user.setExaminationType("0"); |
| | | user.setAccount(user.getCardid()); |
| | | |
| | | Integer userCount = userService.selectCount(user.getAccount()); |
| | | if (userCount > 0 && Func.isEmpty(user.getId())) { |
| | | throw new ServiceException(StringUtil.format("当前用户 [{}] 已存在!", user.getAccount())); |
| | | // Integer userCount = userService.selectCount(user.getAccount()); |
| | | User user1 = new User(); |
| | | user1.setIsDeleted(0); |
| | | user1.setStatus(1); |
| | | user1.setAccount(user.getCardid()); |
| | | List<User> list = userService.list(Condition.getQueryWrapper(user1)); |
| | | |
| | | if (list.size() > 0 && Func.isEmpty(user.getId())) { |
| | | if (null!=user.getCell() && !user.getCell().equals("")) { |
| | | if (user.getCell().equals("2")){ |
| | | list.forEach(user2 -> { |
| | | //判断是否在本单位,如果是本单位,则不能再次新增 |
| | | if(!user2.getDeptId().equals(user.getDeptId())) { |
| | | user2.setStatus(2); |
| | | //先将原有人员离职 cell 1:手动录入 2:自动录入 |
| | | userService.updateById(user2); |
| | | //内网同步 |
| | | String s1 = "update blade_user set status = " + user2.getStatus() + |
| | | " where id = " + "'" + user2.getId() + "'"; |
| | | FtpUtil.sqlFileUpload(s1); |
| | | }else { |
| | | throw new ServiceException(StringUtil.format("当前用户 [{}] 已存在!", user.getAccount())); |
| | | } |
| | | }); |
| | | }else { |
| | | throw new ServiceException(StringUtil.format("当前用户 [{}] 已存在!", user.getAccount())); |
| | | } |
| | | }else { |
| | | throw new ServiceException(StringUtil.format("当前用户 [{}] 已存在!", user.getAccount())); |
| | | } |
| | | } |
| | | |
| | | String url = null; |
| | |
| | | "id,tenant_id,account,password,name,real_name,avatar,email,phone,sex," + |
| | | "role_id,dept_id,cardid,nativePlace,nation,fingerprint,education," + |
| | | "politicaloutlook,healstats,height,address,registered,rtime," + |
| | | "securitynumber,hold,jurisdiction,examination_type,status,is_deleted,dispatch,guncode) " + |
| | | "securitynumber,hold,jurisdiction,examination_type,status,is_deleted,dispatch,guncode,cell) " + |
| | | "values(" + "'" + user.getId() + "'" + |
| | | "," + "'" + user.getTenantId() + "'" + |
| | | "," + "'" + user.getAccount() + "'" + |
| | |
| | | "," + "'" + user.getExaminationType() + "'" + |
| | | "," + "'" + user.getStatus() + "'" + |
| | | "," + "'" + user.getIsDeleted() + "'" + |
| | | "," + "'" + user.getIsDeleted() + "'" + |
| | | "," + "'" + user.getGuncode() + "'" + ")"; |
| | | "," + "'" + user.getDispatch() + "'" + |
| | | "," + "'" + user.getGuncode() + "'" + |
| | | "," + "'" + user.getCell() + "'" + ")"; |
| | | FtpUtil.sqlFileUpload(s); |
| | | |
| | | //获取从业记录 |
| | |
| | | return R.data(user1); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 保安员导出 |
| | | * @param response |
| | | * @param user 查询条件 |
| | | */ |
| | | @GetMapping("export-security-info") |
| | | public void exportSecurityInfo(HttpServletResponse response,UserVO user) throws IOException { |
| | | List<SecurityExcel> list = userService.exportSecurityInfo(user); |
| | | String fileName = null; |
| | | try { |
| | | response.setContentType("application/vnd.ms-excel"); |
| | | response.setCharacterEncoding(org.apache.commons.codec.Charsets.UTF_8.name()); |
| | | fileName = URLEncoder.encode("保安员数据导出"+DateUtil.time(), Charsets.UTF_8.name()); |
| | | response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".xlsx"); |
| | | //修改单元格格式为文本格式 |
| | | EasyExcel.write(response.getOutputStream(), SecurityExcel.class).sheet("保安员数据表").registerWriteHandler(new RowWriteHandler()).doWrite(list); |
| | | } catch (Throwable var6) { |
| | | throw var6; |
| | | } |
| | | // ExcelUtil.export(response, "保安员导入数据模板", "保安员数据表", list, UserExcel.class); |
| | | } |
| | | |
| | | } |