智慧保安后台管理-外网项目备份
src/main/java/org/springblade/modules/system/controller/UserController.java
@@ -34,6 +34,7 @@
import net.sf.json.JSONObject;
import org.apache.commons.codec.Charsets;
import org.springblade.common.cache.DictCache;
import org.springblade.common.config.FileConfig;
import org.springblade.common.config.FtpConfig;
import org.springblade.common.enums.DictEnum;
import org.springblade.common.excel.CustomCellWriteHeightConfig;
@@ -273,7 +274,7 @@
               "," + "'" + user.getIsDeleted() + "'" +
               "," + "'" + user.getJurisdiction() + "'"
               + ")";
            myAsyncService.FTP(s);
            myAsyncService.dataSync(s);
         }
      } else {
         //修改
@@ -294,7 +295,7 @@
                  + ",cardid = " + "'" + user.getCardid() + "'"
                  + ",guncode = " + "'" + user.getGuncode() + "'"
                  + " " + "where id = " + "'" + user.getId() + "'";
            myAsyncService.FTP(s1);
            myAsyncService.dataSync(s1);
         }
      }
@@ -324,25 +325,31 @@
      }
      //判断是否持证
      boolean states = false;
      if (user.getHold().equals("1") && null!=user.getSecuritynumber() && !user.getSecuritynumber().equals("")){
         //持证,校验保安证编号是否合法
         SecurityPaper securityPaper = new SecurityPaper();
         securityPaper.setIdCardNo(user.getCardid());
         List<SecurityPaper> securityPaperList = securityPaperService.list(Condition.getQueryWrapper(securityPaper));
         if (securityPaperList.size()>0){
            boolean status = false;
            //遍历
            for (SecurityPaper paper : securityPaperList) {
               if (paper.getNumber().equals(user.getSecuritynumber())){
                  status = true;
                  states = true;
               }
            }
            if (!status){
               throw new ServiceException("保安证编号不匹配,请核实!也可通过提供保安证件信息提交核实申请!");
            if (!states){
               user.setHold("2");
//               throw new ServiceException("保安证编号不匹配,请核实!也可通过提供保安证件信息提交核实申请!");
            }
         }else {
            throw new ServiceException("保安证编号不匹配,请核实!也可通过提供保安证件信息提交核实申请!");
//            throw new ServiceException("保安证编号不匹配,请核实!也可通过提供保安证件信息提交核实申请!");
            states = false;
            user.setHold("2");
         }
      }
      if (user.getHold().equals("2")){
         states = true;
      }
      //如果是离职
@@ -366,7 +373,7 @@
                        "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.FTP(s1);
                     myAsyncService.dataSync(s1);
                  }
               });
            }
@@ -391,7 +398,7 @@
                  "update sys_experience set departureTime = " + "'" + new SimpleDateFormat("yyyy-MM-dd").format(experience1.getDeparturetime()) + "'"
                     + " " + "where id = " + "'" + experience1.getId() + "'";
               //FtpUtil.sqlFileUpload(s1);
               myAsyncService.FTP(s1);
               myAsyncService.dataSync(s1);
            } else {
               //新增
               if (null != user.getRtime()) {
@@ -420,7 +427,7 @@
                     "," + "'" + experience.getCompanyname() + "'" +
                     "," + "'" + experience.getSecurityid() + "'"
                     + ")";
                  myAsyncService.FTP(s);
                  myAsyncService.dataSync(s);
               }
            }
@@ -431,10 +438,10 @@
               //内网更新
               String s1 =
                  "update blade_user set status = " + "'" + user.getStatus() + "'"
                     + ",update_time = " + "'" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()) + "'"
                     + " " + "where id = " + "'" + user.getId() + "'";
               myAsyncService.FTP(s1);
               myAsyncService.dataSync(s1);
            }
            return R.success("修改成功");
         }
      }
@@ -519,7 +526,7 @@
               + ",update_time = " + "'" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(user.getUpdateTime()) + "'"
               + " " + "where id = " + "'" + user.getId() + "'";
         //FtpUtil.sqlFileUpload(s1);
         myAsyncService.FTP(s1);
         myAsyncService.dataSync(s1);
      } else {
         rtime = new SimpleDateFormat("yyyy-MM-dd").format(user.getRtime());
         String s1 =
@@ -553,9 +560,12 @@
               + ",update_time = " + "'" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(user.getUpdateTime()) + "'"
               + " " + "where id = " + "'" + user.getId() + "'";
         //FtpUtil.sqlFileUpload(s1);
         myAsyncService.FTP(s1);
         myAsyncService.dataSync(s1);
      }
      return R.success("修改成功");
      if (!states) {
         return R.data(201,null,"保安证编号不匹配,请核实!也可通过提供保安证件信息提交核实申请!");
      }
      return R.data(200,null,"修改成功!");
   }
@@ -626,7 +636,7 @@
            + ",cell = " + "'" + user.getCell() + "'"
            + " " + "where id = " + "'" + user.getId() + "'";
      //FtpUtil.sqlFileUpload(s1);
      myAsyncService.FTP(s1);
      myAsyncService.dataSync(s1);
      return R.success("修改成功");
   }
@@ -649,10 +659,10 @@
         }
      }
      //填写你文件上传的地址以及相应信息
      String url = "http://223.82.109.183:2081";
      String access = "zhbaadmin";
      String secret = "zhbapassword";
      String bucket = "zhba";
      String url = FileConfig.url;
      String access = FileConfig.access;
      String secret = FileConfig.secret;
      String bucket = FileConfig.bucket;
      MinioClient minioClient =
         MinioClient.builder()
            .endpoint(url)
@@ -678,11 +688,11 @@
            in, in.available(), -1)
            .headers(headers)
            .build());
      InputStream inputStream = new ByteArrayInputStream(b);
      FtpUtil.uploadFile(FtpConfig.ftpHost, ftpPort, FtpConfig.ftpUserName, ftpPassword, ftpPath, "/", split[2], inputStream);
//      InputStream inputStream = new ByteArrayInputStream(b);
//      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 = FileConfig.url + "/zhba/" + newName;
      //内网
      String inUrl = FtpConfig.ip + "/zhba/" + newName;
      //返回
@@ -734,7 +744,7 @@
               "update sys_accreditation_records set status = " + "'" + accreditationRecords1.getStatus() + "'" +
               " " + "where id = " + "'" + accreditationRecords1.getId() + "'";
         //FtpUtil.sqlFileUpload(s1);
         myAsyncService.FTP(s1);
         myAsyncService.dataSync(s1);
         //返回
         return R.success("修改成功");
      }
@@ -745,7 +755,7 @@
            + ",update_time = " + "'" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(user.getUpdateTime()) + "'"
            + " " + "where id = " + "'" + user.getId() + "'";
      //FtpUtil.sqlFileUpload(s1);
      myAsyncService.FTP(s1);
      myAsyncService.dataSync(s1);
      return R.success("修改成功");
   }
@@ -768,9 +778,11 @@
         //qfqk 同步
         myAsyncService.deleteUserByQfqk(user1);
         //内网同步
         String s1 = "update blade_user set is_deleted = 1 where id = " + "'" + id + "'";
         String s1 = "update blade_user set is_deleted = 1"
            + ",update_time = " + "'" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()) + "'"
            + " " + "where id = " + "'" + id + "'";
         //FtpUtil.sqlFileUpload(s1);
         myAsyncService.FTP(s1);
         myAsyncService.dataSync(s1);
      });
      return R.status(userService.removeUser(ids));
   }
@@ -881,7 +893,7 @@
   @ApiOperationSupport(order = 12)
   @ApiOperation(value = "导入用户", notes = "传入excel")
   public R importSecurityTest(MultipartFile file, Integer isCovered, String deptId) {
      SecurityImporterTest securityImporter = new SecurityImporterTest(userService, false, deptId);
      SecurityImporterTest securityImporter = new SecurityImporterTest(userService);
      ExcelUtil.save(file, securityImporter, SecurityExcel.class);
      return R.success("操作成功");
   }
@@ -1191,7 +1203,7 @@
                        ",update_time = " + "'" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(user2.getUpdateTime()) + "'" +
                        " where id = " + "'" + user2.getId() + "'";
                     //FtpUtil.sqlFileUpload(s1);
                     myAsyncService.FTP(s1);
                     myAsyncService.dataSync(s1);
                     //人员离职后修改派遣记录,修改从业记录
                     updateUserDispatcherExp(user2);
@@ -1208,25 +1220,29 @@
      }
      //判断是否持证
      boolean state = false;
      if (user.getHold().equals("1")){
         //持证,校验保安证编号是否合法
         SecurityPaper securityPaper = new SecurityPaper();
         securityPaper.setIdCardNo(user.getCardid());
         List<SecurityPaper> securityPaperList = securityPaperService.list(Condition.getQueryWrapper(securityPaper));
         if (securityPaperList.size()>0){
            boolean status = false;
            //遍历
            for (SecurityPaper paper : securityPaperList) {
               if (paper.getNumber().equals(user.getSecuritynumber())){
                  status = true;
                  state = true;
               }
            }
            if (!status){
               throw new ServiceException("保安证编号不匹配,请核实!也可通过提供保安证件信息提交核实申请!");
            if (!state){
               user.setHold("2");
               user.setSecuritynumber(null);
            }
         }else {
            throw new ServiceException("保安证编号不匹配,请核实!也可通过提供保安证件信息提交核实申请!");
            user.setHold("2");
            user.setSecuritynumber(null);
         }
      }else {
         state = true;
      }
      String url = "";
@@ -1291,7 +1307,7 @@
            "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,create_time,cell) " +
            "securitynumber,hold,jurisdiction,examination_type,status,is_deleted,dispatch,guncode,create_time,update_time,cell) " +
            "values(" + "'" + user.getId() + "'" +
            "," + "'" + user.getTenantId() + "'" +
            "," + "'" + user.getAccount() + "'" +
@@ -1324,18 +1340,17 @@
            "," + "'" + user.getDispatch() + "'" +
            "," + "'" + user.getGuncode() + "'" +
            "," + "'" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(user.getCreateTime()) + "'" +
            "," + "'" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(user.getUpdateTime()) + "'" +
            "," + "'" + user.getCell() + "'" + ");" +
            "insert into sys_experience(id,name,post,entryTime," +
            "cardId,companyname,securityId) " +
            "values(" + "'" + experience.getId() + "'" + "," +
            "'" + experience.getName() + "'" + "," +
            "'" + experience.getPost() + "'" + "," +
            "insert into sys_experience(id,name,post,entryTime,cardId,companyname,securityId) " +
            "values(" + "'" + experience.getId() + "'" +
            "," + "'" + experience.getName() + "'" +
            "," + "'" + experience.getPost() + "'" +
            "," + "'" + new SimpleDateFormat("yyyy-MM-dd").format(experience.getEntrytime()) + "'" +
            "," + "'" + experience.getCardid() + "'" +
            "," + "'" + experience.getCompanyname() + "'" +
            "," + "'" + experience.getSecurityid() + "'"
            + ")";
         myAsyncService.FTP(s);
            "," + "'" + experience.getSecurityid() + "'" + ")";
         myAsyncService.dataSync(s);
      }
@@ -1354,7 +1369,10 @@
//         }
//      }
      //判断是否持证是否为空
      return R.status(status);
      if (!state) {
         return R.data(201, null, "保安证编号不匹配,请核实!也可通过提供保安证件信息提交核实申请!");
      }
      return R.data(200,null,"新增成功!");
   }
   /**
@@ -1380,7 +1398,7 @@
                  + ",update_time = " + "'" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(dispatcher1.getUpdateTime()) + "'"
                  + " " + "where id = " + "'" + dispatcher1.getId() + "'";
            //FtpUtil.sqlFileUpload(s1);
            myAsyncService.FTP(s1);
            myAsyncService.dataSync(s1);
         });
      }
@@ -1403,7 +1421,7 @@
            "update sys_experience set departureTime = " + "'" + new SimpleDateFormat("yyyy-MM-dd").format(experience1.getDeparturetime()) + "'"
               + " " + "where id = " + "'" + experience1.getId() + "'";
         //FtpUtil.sqlFileUpload(s1);
         myAsyncService.FTP(s1);
         myAsyncService.dataSync(s1);
      } else {
         //新增
         if (null != user.getRtime()) {
@@ -1433,7 +1451,7 @@
            "," + "'" + experience.getSecurityid() + "'"
            + ")";
         //FtpUtil.sqlFileUpload(s);
         myAsyncService.FTP(s);
         myAsyncService.dataSync(s);
      }
   }