智慧保安后台管理-外网项目备份
钟日健
2026-06-01 62eb499b0c969f246d3245d1429a97da4de1ce28
src/main/java/org/springblade/modules/system/controller/UserController.java
@@ -338,6 +338,28 @@
      return R.data(200,null,"修改成功!");
   }
   /**
    * 离职
    */
   @PostMapping("/userLeave")
   @ApiOperationSupport(order = 5)
   @ApiOperation(value = "修改", notes = "传入User")
   @Transactional(rollbackFor = Exception.class)
   public R userLeave(@Valid @RequestBody Map<String, Object> userMap) throws Exception {
      //获取user
      User user = JSON.parseObject(JSON.toJSONString(userMap), User.class);
      //分配保安角色
      CacheUtil.clear(USER_CACHE);
      // 指纹设置
      fingerprintSet(user);
      //如果是离职
      boolean b = leaveHandle(user);
      return R.status(b);
   }
   /**
    * 离职处理
    * @param user
@@ -359,13 +381,13 @@
                  dispatcher1.setStatus(1);
                  dispatcher1.setUpdateTime(new Date());
                  boolean b = dispatcherService.updateById(dispatcher1);
                  if (b) {
                     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() + "'";
                     myAsyncService.dataSync(s1);
                  }
//                  if (b) {
//                     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() + "'";
//                     myAsyncService.dataSync(s1);
//                  }
               });
            }
@@ -384,12 +406,12 @@
               experience1.setDeparturetime(new Date());
               //更新从业记录信息
               experienceService.updateById(experience1);
               //数据同步
               String s1 =
                  "update sys_experience set departureTime = " + "'" + new SimpleDateFormat("yyyy-MM-dd").format(experience1.getDeparturetime()) + "'"
                     + " " + "where id = " + "'" + experience1.getId() + "'";
               //FtpUtil.sqlFileUpload(s1);
               myAsyncService.dataSync(s1);
//               //数据同步
//               String s1 =
//                  "update sys_experience set departureTime = " + "'" + new SimpleDateFormat("yyyy-MM-dd").format(experience1.getDeparturetime()) + "'"
//                     + " " + "where id = " + "'" + experience1.getId() + "'";
//               //FtpUtil.sqlFileUpload(s1);
//               myAsyncService.dataSync(s1);
            } else {
               experience.setDeparturetime(new Date());
               experience.setName(user.getRealName());
@@ -1400,5 +1422,45 @@
      return R.status(result);
   }
   /**
    * 导入保安员制证时间
    */
   @PostMapping("import-security-paperTime")
   @ApiOperationSupport(order = 12)
   @ApiOperation(value = "导入用户", notes = "传入excel")
   public R importSecurityPaperTime(MultipartFile file, Integer isCovered, String deptId) {
      UserCertificateExcelImporter userCertificateExcelImporter = new UserCertificateExcelImporter(userService, false, deptId);
      ExcelUtil.save(file, userCertificateExcelImporter, UserCertificateExcel.class);
      return R.success("操作成功");
   }
   /**
    * 保安员制证时间导出模板
    */
   @GetMapping("export-template-security-paperTime")
   @ApiOperationSupport(order = 14)
   @ApiOperation(value = "导出模板")
   public void exportPaperTimeExcelTemplate(HttpServletResponse response) throws IOException {
      List<UserCertificateExcel> list = new ArrayList<>();
      UserCertificateExcel userCertificateExcel = new UserCertificateExcel();
      userCertificateExcel.setRealName("张三");
      userCertificateExcel.setCardid("360XXX19XXXXXX****");
      userCertificateExcel.setPaperTime("2023-12-26");
      list.add(userCertificateExcel);
      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(), UserCertificateExcel.class).sheet("发证时间导入数据表").registerWriteHandler(new RowWriteHandler()).doWrite(list);
      } catch (Throwable var6) {
         throw var6;
      }
   }
}