From 8e6f6217e52a635d1dfd4ccbb549b0427d3f9fa6 Mon Sep 17 00:00:00 2001
From: Administrator <admin>
Date: Wed, 27 Apr 2022 15:55:17 +0800
Subject: [PATCH] 新增保安员新增审查
---
src/main/java/org/springblade/modules/FTP/MyAsyncService.java | 88 ++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 88 insertions(+), 0 deletions(-)
diff --git a/src/main/java/org/springblade/modules/FTP/MyAsyncService.java b/src/main/java/org/springblade/modules/FTP/MyAsyncService.java
index d40c1fe..5116204 100644
--- a/src/main/java/org/springblade/modules/FTP/MyAsyncService.java
+++ b/src/main/java/org/springblade/modules/FTP/MyAsyncService.java
@@ -1,12 +1,28 @@
package org.springblade.modules.FTP;
+import org.json.JSONArray;
+import org.json.JSONObject;
+import org.springblade.common.utils.InvestigateUtil;
+import org.springblade.modules.system.entity.User;
+import org.springblade.modules.system.service.IUserService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
+
+import javax.annotation.PostConstruct;
+import java.util.Date;
/**
* @author Administrator
*/
@Service
public class MyAsyncService {
+
+ @Autowired
+ private IUserService userService;
+
+
+
/**
* FTP
* @param s sql语句
@@ -15,4 +31,76 @@
FtpUtil.sqlFileUpload(s);
}
+
+ /**
+ * 异步审查新增的保安员
+ * @param user0
+ */
+ @Async
+ public void checkUserExamineByCardNo(User user0){
+ User byId = userService.getById(user0.getId());
+ //如果是保安员
+ if (user0.getRoleId().equals("1412226235153731586")){
+ //读取身份证号
+ String cardid = user0.getCardid();
+ //创建用户对象
+ User user = new User();
+ user.setId(user.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);
+ }
+ }
+ }
+ //更新用户数据
+ userService.updateById(user);
+ }
+
+ }
+
}
--
Gitblit v1.9.3