From 381f50210befd68e70c33af4b547a69d2b403181 Mon Sep 17 00:00:00 2001
From: Administrator <admin>
Date: Wed, 15 Jun 2022 10:40:12 +0800
Subject: [PATCH] 制证修改,导出修改6张照片每行,新增人员导入
---
src/main/java/org/springblade/modules/FTP/FtpUtil.java | 18 ++++
src/main/java/org/springblade/modules/accreditation/controller/AccreditationRecordsController.java | 4
src/main/java/org/springblade/modules/FTP/DataHanlder.java | 168 ++++++++++++++++++++++++++++++++++++++++++
src/main/java/org/springblade/modules/FTP/MyAsyncService.java | 2
src/main/resources/application-test.yml | 8 ++
src/main/java/org/springblade/modules/quartz/task/Task.java | 17 +++
6 files changed, 212 insertions(+), 5 deletions(-)
diff --git a/src/main/java/org/springblade/modules/FTP/DataHanlder.java b/src/main/java/org/springblade/modules/FTP/DataHanlder.java
index 4e03607..cb82dbb 100644
--- a/src/main/java/org/springblade/modules/FTP/DataHanlder.java
+++ b/src/main/java/org/springblade/modules/FTP/DataHanlder.java
@@ -1,7 +1,10 @@
package org.springblade.modules.FTP;
import com.alibaba.fastjson.JSON;
+import org.json.JSONArray;
+import org.json.JSONObject;
import org.springblade.common.utils.DesensitizedUtil;
+import org.springblade.common.utils.InvestigateUtil;
import org.springblade.common.utils.SecurityPaperUtil;
import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.mp.support.Condition;
@@ -21,6 +24,7 @@
import org.springblade.modules.system.service.IUserService;
import org.springblade.modules.system.vo.UserVO;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
import java.text.DecimalFormat;
@@ -396,6 +400,170 @@
}
/**
+ * 管理人员保安员导入并生成保安证编号
+ * @param json
+ */
+ public static void handlerSecurityPaperList(String json) {
+ Map map = JSON.parseObject(json, Map.class);
+ //取出 key(uuid)
+ String key = map.keySet().toArray()[0].toString();
+ Object users = map.get(key);
+ List<User> userList = JSON.parseArray(users.toString(), User.class);
+ //遍历
+ if (userList.size()>0) {
+ List<Result> resultList = new ArrayList<>();
+ //开始遍历
+ for (User user : userList) {
+ //取出 uuid
+ String uuid = user.getReasonForLeav();
+ //用户数据校验,是否已导入(本单位或其他单位)
+ Result result = userCheckOut(user);
+ //创建返回对象
+ Result result1 = new Result();
+ result1.setMsg(uuid);
+ if (result.getCode() == 200) {
+ user.setReasonForLeav("");
+ //直接去审查,审查异常则不新增
+ //异步审查
+ User user1 = hanlder.checkUserExamineByCardNos(user);
+ if (null!=user1){
+ if (user1.getExaminationType().equals("0")){
+ //生成保安证编号和记录
+ //去生成保安证编号
+ String pre = SecurityPaperUtil.getSecurityPaper();
+ //查询当前年份已有的保安证编号
+ int count = hanlder.userService.getSecurityPaperCount(pre);
+ String result0 = null;
+ if (count == 0) {
+ result0 = pre + "00001";
+ } else {
+ //格式化
+ DecimalFormat decimalFormat = new DecimalFormat("00000");
+ count++;
+ result0 = pre + (decimalFormat.format(count));
+ }
+ //修改制证状态为未制证
+ user.setUserType(7);
+ user.setSecuritynumber(result0);
+ //修改为持证保安
+ user.setHold("1");
+ user.setUpdateTime(new Date());
+ //更新保安数据
+ boolean save = hanlder.userService.save(user);
+
+ if (save) {
+ //生成保安证的同时向保安证管理表中插入一条数据
+ SecurityPaper securityPaper = new SecurityPaper();
+ securityPaper.setUserId(user.getId());
+ securityPaper.setNumber(result0);
+ securityPaper.setCreateTime(new Date());
+ securityPaper.setIdCardNo(user.getCardid());
+ securityPaper.setPeopleName(user.getRealName());
+ securityPaper.setSource(3);
+ hanlder.securityPaperService.save(securityPaper);
+
+ //异步新增从业记录
+ hanlder.myAsyncService.insertExperience(user);
+
+ //设置返回结果
+ result1.setCode(200);
+ result1.setUserId(user.getId());
+ result1.setMsg(result1.getMsg()+","+DesensitizedUtil.desensitizedSecurityNumber(result0));
+ }
+ }else {
+ //不新增,审查异常
+ result1.setCode(205);
+ result1.setUserId(null);
+ }
+ }
+ } else if (result.getCode() == 201) {
+ } else {
+ //不新增,不修改
+ //设置返回结果,以在其他单位存在
+ result1.setCode(202);
+ result1.setUserId(null);
+ }
+ //存入结果集
+ resultList.add(result1);
+ }
+ Result result = new Result(200, "", resultList);
+ Map<String, Object> map1 = new HashMap<>(1);
+ map1.put(key, result);
+ //向外网发送数据
+ FtpUtil.objectFileUploadPaperList(map1);
+ }
+ }
+
+
+ /**
+ * 异步审查新增的保安员,审查通过并生成保安员证编号
+ * @param user0
+ */
+ public User checkUserExamineByCardNos(User user0){
+ //如果是保安员
+ if (user0.getRoleId().equals("1412226235153731586")){
+ //创建用户对象
+ User user = new User();
+ user.setId(user0.getId());
+ //远程调用接口
+ String body = InvestigateUtil.httpGetOne(user0.getCardid());
+ JSONObject jsonObject = new JSONObject(body);
+ Object data = jsonObject.get("data");
+ JSONObject jsonData = new JSONObject(data.toString());
+ JSONArray res = jsonData.getJSONArray("res");
+ //设置审核时间
+ user.setAuditTime(new Date());
+ //如果有结果返回
+ if (res.length() == 0) {
+ //没有数据正常
+ user.setExaminationType("0");
+ } else {
+ int count = 0;
+ user.setExaminationType("1");
+ for (int i = 0; i < res.length(); i++) {
+ if (res.getJSONObject(i).get("zdrylbjh").toString() != null
+ && res.getJSONObject(i).get("zdrylbjh").toString() != ""
+ && res.getJSONObject(i).get("zdrylbjh").toString() != "null"
+ ) {
+ user.setExaminationMx(res.getJSONObject(i).get("zdrylbjh").toString());
+ //更新用户数据
+// userService.updateById(user);
+ break;
+ }
+ if (res.getJSONObject(i).get("zdryxlmc").toString() != null
+ && res.getJSONObject(i).get("zdryxlmc").toString() != ""
+ && res.getJSONObject(i).get("zdryxlmc").toString() != "null"
+ ) {
+ user.setExaminationMx(res.getJSONObject(i).get("zdryxlmc").toString());
+ //更新用户数据
+// userService.updateById(user);
+ break;
+ }
+ if (res.getJSONObject(i).get("ztrylx").toString() != null
+ && res.getJSONObject(i).get("ztrylx").toString() != ""
+ && res.getJSONObject(i).get("ztrylx").toString() != "null"
+ ) {
+ user.setExaminationMx(res.getJSONObject(i).get("ztrylx").toString());
+ //更新用户数据
+// userService.updateById(user);
+ break;
+ }
+ count++;
+ //条件中的数据都为空,则审查为正常
+ if (count==res.length()){
+ //更新用户数据,设为正常
+ user.setExaminationType("0");
+// userService.updateById(user);
+ }
+ }
+ }
+ //更新用户数据
+ return user;
+ }
+ return null;
+ }
+
+ /**
* 数据处理(单个保安员新增)
* @param json
*/
diff --git a/src/main/java/org/springblade/modules/FTP/FtpUtil.java b/src/main/java/org/springblade/modules/FTP/FtpUtil.java
index 480e5df..40f35f2 100644
--- a/src/main/java/org/springblade/modules/FTP/FtpUtil.java
+++ b/src/main/java/org/springblade/modules/FTP/FtpUtil.java
@@ -474,4 +474,22 @@
FtpUtil.uploadFile(ftpHost, ftpPort, ftpUserNameOut, ftpPasswordOut, ftpPath, "/", "ns"+response1+".json", in1);
MysqlCenlint.deletess("ns"+response1+".json");
}
+
+ /**
+ * 管理员新增保安员并生成保安员证编号
+ * @param obj
+ */
+ public static void objectFileUploadPaperList(Object obj) {
+ String json1 = JSON.toJSONString(obj);
+ String response1 = String.valueOf((new Date()).getTime());
+ OutJson.createJsonFile(json1, localPath, "np"+response1);
+ FileInputStream in1 = null;
+ try {
+ in1 = new FileInputStream(new File(localPath + "np"+response1+".json"));
+ } catch (FileNotFoundException e) {
+ e.printStackTrace();
+ }
+ FtpUtil.uploadFile(ftpHost, ftpPort, ftpUserNameOut, ftpPasswordOut, ftpPath, "/", "np"+response1+".json", in1);
+ MysqlCenlint.deletess("np"+response1+".json");
+ }
}
diff --git a/src/main/java/org/springblade/modules/FTP/MyAsyncService.java b/src/main/java/org/springblade/modules/FTP/MyAsyncService.java
index 09b9659..acb5995 100644
--- a/src/main/java/org/springblade/modules/FTP/MyAsyncService.java
+++ b/src/main/java/org/springblade/modules/FTP/MyAsyncService.java
@@ -124,9 +124,9 @@
" where id = " + "'" + user.getId() + "'";
FTP1(s1,user.getId().toString());
}
-
}
+
/**
* 异步新增用户从业记录
* @param user
diff --git a/src/main/java/org/springblade/modules/accreditation/controller/AccreditationRecordsController.java b/src/main/java/org/springblade/modules/accreditation/controller/AccreditationRecordsController.java
index 7083cf9..64e3881 100644
--- a/src/main/java/org/springblade/modules/accreditation/controller/AccreditationRecordsController.java
+++ b/src/main/java/org/springblade/modules/accreditation/controller/AccreditationRecordsController.java
@@ -311,7 +311,7 @@
// titleRow.createCell(1).setCellValue("员工照片");
HSSFPatriarch patriarch = sheet.createDrawingPatriarch();
//如果总数小于等于7
- if (list.size()<=7){
+ if (list.size()<=6){
HSSFRow row = sheet.createRow(0);
row.setHeight((short) 1980);
@@ -365,7 +365,7 @@
int rowNum = -2;
for (int i = 0; i < list.size(); i++) {
//每次从集合中读取7个对象,求余数
- if (i != 0 && (i + 1) % 7 == 0) {
+ if (i != 0 && (i + 1) % 6 == 0) {
excelList.add(list.get(i));
rowNum = rowNum + 2;
//写入表格
diff --git a/src/main/java/org/springblade/modules/quartz/task/Task.java b/src/main/java/org/springblade/modules/quartz/task/Task.java
index 1cd726c..d45a9c8 100644
--- a/src/main/java/org/springblade/modules/quartz/task/Task.java
+++ b/src/main/java/org/springblade/modules/quartz/task/Task.java
@@ -168,13 +168,26 @@
FtpUtil.deleteFile(ftpHost, ftpPort, ftpUserName, ftpPassword, "anbao/", fileName);
}
//考试实操成绩导入
- if(substring1.equals("e")){
+// if(substring1.equals("e")){
+// //把文件下载到本地
+// FtpUtil.downloadFtpFile(ftpHost, ftpUserName, ftpPassword, ftpPort, ftpPath, localPath, fileName);
+// //获取对象字符串
+// String json = OutJson.TestJson(fileName);
+// //考试实操成绩数据处理
+// DataHanlder.handlerUserExamScore(json);
+// //删除本地文件
+// MysqlCenlint.deletess(fileName);
+// //删除 ftp 文件
+// FtpUtil.deleteFile(ftpHost, ftpPort, ftpUserName, ftpPassword, "anbao/", fileName);
+// }
+ //管理人员保安员导入并生成保安证编号
+ if(substring1.equals("p")){
//把文件下载到本地
FtpUtil.downloadFtpFile(ftpHost, ftpUserName, ftpPassword, ftpPort, ftpPath, localPath, fileName);
//获取对象字符串
String json = OutJson.TestJson(fileName);
//考试实操成绩数据处理
- DataHanlder.handlerUserExamScore(json);
+ DataHanlder.handlerSecurityPaperList(json);
//删除本地文件
MysqlCenlint.deletess(fileName);
//删除 ftp 文件
diff --git a/src/main/resources/application-test.yml b/src/main/resources/application-test.yml
index 20b18d5..bdac060 100644
--- a/src/main/resources/application-test.yml
+++ b/src/main/resources/application-test.yml
@@ -20,6 +20,12 @@
username: root
password: ZHba@0112
+# rabbitmq:
+# host: 192.168.0.197
+# port: 5672
+# username: admin
+# password: admin
+
#ftp 设置
ftp:
sqlConnect: jdbc:mysql://61.131.136.25:2083/zhba?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true
@@ -36,6 +42,8 @@
sqlUsername: root
sqlPassword: ZHba@0112
+
+
#公共配置
common:
socketPort: 9034
--
Gitblit v1.9.3