Administrator
2021-08-31 61e8c756cc2a9e503d643672f103c3837fadc1d4
src/main/java/org/springblade/modules/system/controller/UserController.java
@@ -180,17 +180,17 @@
   public R submit(@Valid @RequestBody User user) throws Exception {
      CacheUtil.clear(USER_CACHE);
      //查询角色
      if (null!=user.getRoleId()){
         Role role = new Role();
         role.setId(Long.parseLong(user.getRoleId()));
         Role one = roleService.getOne(Condition.getQueryWrapper(role));
         if (one.getRoleAlias().equals("保安")){
            user.setHold("1");
         }
         if (one.getRoleAlias().equals("未持证保安")){
            user.setHold("2");
         }
      }
//      if (null!=user.getRoleId()){
//         Role role = new Role();
//         role.setId(Long.parseLong(user.getRoleId()));
//         Role one = roleService.getOne(Condition.getQueryWrapper(role));
//         if (one.getRoleAlias().equals("保安")){
//            user.setHold("1");
//         }
//         if (one.getRoleAlias().equals("未持证保安")){
//            user.setHold("2");
//         }
//      }
      //根据 deptId 查询dept信息,公安管理员
      Dept dept = iDeptService.getById(user.getDeptId());
@@ -203,13 +203,16 @@
         user.setJurisdiction(one.getId().toString());
      }
      userService.submit(user);
      String birthday = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(user.getBirthday());
      String rtime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(user.getRtime());
      //      String birthday = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(user.getBirthday());
      String rtime = null;
      if (null!=user.getRtime()) {
         rtime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(user.getRtime());
      }
      String s = "insert into blade_user(id,tenant_id,account,password,name,real_name,avatar,email,phone,birthday,sex,role_id,dept_id,cardid,nativePlace,nation,education," +
         "politicaloutlook,healstats,height,address,registered,rtime,securitynumber,hold,jurisdiction) " +
         "values(" + "'" + user.getId() + "'" + "," + "'" + 000000 + "'" + "," + "'" + user.getAccount() + "'" + "," +
         "'" + user.getPassword() + "'" + "," +"'" + user.getName() + "'" + "," + "'" + user.getRealName() + "'" + "," + "'" + user.getAvatar() + "'" + "," +
         "'" + user.getEmail() + "'" + "," + "'" + user.getPhone() + "'" + "," + "'" + birthday + "'" + "," + "'" + user.getSex() + "'" + "," + "'" + user.getRoleId() + "'" +
         "'" + user.getEmail() + "'" + "," + "'" + user.getPhone() + "'" + "," + "'" + user.getSex() + "'" + "," + "'" + user.getRoleId() + "'" +
         "," + "'" + user.getDeptId() + "'" + "," + "'" + user.getCardid() + "'" + "," + "'" + user.getNativeplace() + "'" + "," + "'"
         + user.getNation() + "'" + "," + "'" + user.getEducation() + "'" + "," + "'" + user.getPoliticaloutlook() + "'" + "," + "'" + user.getHealstats() + "'"
         + "," +"'" + user.getHeight() + "'" + "," + "'" + user.getAddress() + "'" +"," + "'" + user.getRegistered() + "'"+ "," +
@@ -348,7 +351,7 @@
   }
   /**
    * 导入用户
    * 导入用户page-security-apply
    */
   @PostMapping("import-user")
   @ApiOperationSupport(order = 12)
@@ -407,6 +410,40 @@
   @ApiOperation(value = "导出模板")
   public void exportSecurity(HttpServletResponse response) {
      List<UserExcel> list = new ArrayList<>();
      UserExcel userExcel = new UserExcel();
      userExcel.setDeptId("xxx保安公司");
      userExcel.setRealName("张三");
      userExcel.setEmail("xxx@**.com");
      userExcel.setPhone("12345678901");
      userExcel.setSex("男");
      userExcel.setCardid("360XXX19XXXXXX****");
      userExcel.setNativeplace("江西南昌");
      userExcel.setNation("汉");
      userExcel.setPoliticaloutlook("中共党员");
      userExcel.setHeight(180);
      userExcel.setAddress("江西省南昌市******");
      userExcel.setRegistered("江西南昌");
      userExcel.setRtime("2021-05-01");
      userExcel.setHold("是");
      userExcel.setSecuritynumber("赣洪202100001");
      list.add(userExcel);
      UserExcel userExcel1 = new UserExcel();
      userExcel1.setDeptId("xxx保安公司");
      userExcel1.setRealName("李四");
      userExcel1.setEmail("xxx@**.com");
      userExcel1.setPhone("12345678901");
      userExcel1.setSex("女");
      userExcel1.setCardid("360XXX19XXXXXX****");
      userExcel1.setNativeplace("江西南昌");
      userExcel1.setNation("汉");
      userExcel1.setPoliticaloutlook("中共党员");
      userExcel1.setHeight(180);
      userExcel1.setAddress("江西省南昌市******");
      userExcel1.setRegistered("江西南昌");
      userExcel1.setRtime("2021-05-01");
      userExcel1.setHold("否");
      userExcel1.setSecuritynumber("");
      list.add(userExcel1);
      ExcelUtil.export(response, "保安员导入数据模板", "保安员数据表", list, UserExcel.class);
   }
@@ -532,24 +569,24 @@
      //获取user
      User user = JSON.parseObject(JSON.toJSONString(userMap.get("user")),User.class);
      //判断是否为空
      if (null!=user.getHold()){
//      if (null!=user.getHold()){
         //持证
         if (user.getHold().equals("1")){
//         if (user.getHold().equals("1")){
            //分配保安角色
            Role role = new Role();
            role.setRoleAlias("保安");
            Role oneRole = roleService.getOne(Condition.getQueryWrapper(role));
            user.setRoleId(oneRole.getId().toString());
         }
//         }
         //未持证
         if (user.getHold().equals("2")){
            //分配未持证保安角色
            Role role = new Role();
            role.setRoleAlias("未持证保安");
            Role oneRole = roleService.getOne(Condition.getQueryWrapper(role));
            user.setRoleId(oneRole.getId().toString());
         }
      }
//         if (user.getHold().equals("2")){
//            //分配未持证保安角色
//            Role role = new Role();
//            role.setRoleAlias("未持证保安");
//            Role oneRole = roleService.getOne(Condition.getQueryWrapper(role));
//            user.setRoleId(oneRole.getId().toString());
//         }
//      }
      //密码加密
      if (Func.isNotEmpty(user.getPassword())) {
         user.setPassword(DigestUtil.encrypt(user.getPassword()));
@@ -606,5 +643,30 @@
   }
   /**
    * 保安员信息
    * @param user
    * @return
    */
   @GetMapping("/getUserDetails")
   public R getUserDetails(User user) {
      return R.data(userService.getUserDetails(user));
   }
   /**
    *
    * @param type  1:保安 2:公安
    * @param deptid
    * @param jurisdiction
    * @return
    */
   @GetMapping("/seleL")
   public R seleL(String type,String deptid, String jurisdiction,Long userId) {
      List<Map<String, Object>> list = userService.seleL(type,deptid, jurisdiction,userId);
      return R.data(list);
   }
}