LIVE_YE 2 rokov pred
rodič
commit
6606b207b6

+ 16 - 0
ruoyi-common/pom.xml

@@ -125,6 +125,22 @@
             <artifactId>javax.servlet-api</artifactId>
         </dependency>
 
+        <dependency>
+            <groupId>org.apache.httpcomponents</groupId>
+            <artifactId>httpclient</artifactId>
+            <version>4.5</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.httpcomponents</groupId>
+            <artifactId>httpmime</artifactId>
+            <version>4.5</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.httpcomponents</groupId>
+            <artifactId>httpcore</artifactId>
+            <version>4.4.1</version>
+        </dependency>
+
     </dependencies>
 
 </project>

+ 125 - 0
ruoyi-common/src/main/java/com/ruoyi/common/utils/http/HttpClientUtils.java

@@ -0,0 +1,125 @@
+package com.ruoyi.common.utils.http;
+
+import org.apache.http.NameValuePair;
+import org.apache.http.client.config.RequestConfig;
+import org.apache.http.client.entity.UrlEncodedFormEntity;
+import org.apache.http.client.methods.CloseableHttpResponse;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClients;
+import org.apache.http.message.BasicNameValuePair;
+import org.apache.http.util.EntityUtils;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+public class HttpClientUtils {
+
+    final static int TIMEOUT = 1000;
+    final static int TIMEOUT_MSEC = 5 * 1000;
+
+    public static String doPost(String url, Map<String, String> paramMap) throws IOException {
+        // 创建Httpclient对象
+        CloseableHttpClient httpClient = HttpClients.createDefault();
+        CloseableHttpResponse response = null;
+        String resultString = "";
+        try {
+            // 创建Http Post请求
+            HttpPost httpPost = new HttpPost(url);
+            // 创建参数列表
+            if (paramMap != null) {
+                List<NameValuePair> paramList = new ArrayList<>();
+                for (Map.Entry<String, String> param : paramMap.entrySet()) {
+                    paramList.add(new BasicNameValuePair(param.getKey(), param.getValue()));
+                }
+                // 模拟表单
+                UrlEncodedFormEntity entity = new UrlEncodedFormEntity(paramList);
+                httpPost.setEntity(entity);
+            }
+
+            httpPost.setConfig(builderRequestConfig());
+
+            // 执行http请求
+            response = httpClient.execute(httpPost);
+
+            resultString = EntityUtils.toString(response.getEntity(), "UTF-8");
+        } catch (Exception e) {
+            throw e;
+        } finally {
+            try {
+                response.close();
+            } catch (IOException e) {
+                throw e;
+            }
+        }
+
+        return resultString;
+    }
+
+    public static String doGet(String url, Map<String, String> paramMap) throws IOException {
+        //url += "?appid=" + paramMap.get("appid") + "&secret=" + paramMap.get("secret") + "&js_code=" + paramMap.get("js_code") + "&grant_type=" + paramMap.get("grant_type");
+
+        int i = 1;
+        if(!paramMap.isEmpty()){
+            for (Map.Entry<String, String> stringStringEntry : paramMap.entrySet()) {
+                if(i==1){
+                    url = url + "?" + stringStringEntry.getKey() +"="+ stringStringEntry.getValue();
+                }else{
+                    url = url + "&" + stringStringEntry.getKey() +"="+ stringStringEntry.getValue();
+                }
+                i++;
+            }
+        }
+
+        // 创建Httpclient对象
+        CloseableHttpClient httpClient = HttpClients.createDefault();
+        CloseableHttpResponse response = null;
+        String resultString = "";
+        try {
+            // 创建Http get请求
+            HttpGet httpGet = new HttpGet(url);
+            // 执行http请求
+            response = httpClient.execute(httpGet);
+            resultString = EntityUtils.toString(response.getEntity(), "UTF-8");
+        } catch (Exception e) {
+            throw e;
+        } finally {
+            try {
+                response.close();
+            } catch (IOException e) {
+                throw e;
+            }
+        }
+        return resultString;
+    }
+
+    public static String doGet1(String url) throws IOException {
+        // 创建Httpclient对象
+        CloseableHttpClient httpClient = HttpClients.createDefault();
+        CloseableHttpResponse response = null;
+        String resultString = "";
+        try {
+            // 创建Http Post请求
+            HttpGet httpGet = new HttpGet(url);
+            // 执行http请求
+            response = httpClient.execute(httpGet);
+            resultString = EntityUtils.toString(response.getEntity(), "UTF-8");
+        } catch (Exception e) {
+            throw e;
+        } finally {
+            assert response != null;
+            response.close();
+        }
+        return resultString;
+    }
+
+    private static RequestConfig builderRequestConfig() {
+        return RequestConfig.custom()
+                .setConnectTimeout(TIMEOUT_MSEC)
+                .setConnectionRequestTimeout(TIMEOUT_MSEC)
+                .setSocketTimeout(TIMEOUT_MSEC).build();
+    }
+}

+ 9 - 0
ruoyi-system/src/main/java/com/ruoyi/system/domain/UserInfo.java

@@ -237,6 +237,14 @@ public class UserInfo extends BaseEntity
         this.collectPlace = collectPlace;
     }
 
+    public String getDeptId() {
+        return deptId;
+    }
+
+    public void setDeptId(String deptId) {
+        this.deptId = deptId;
+    }
+
     @Override
     public String toString() {
         return "UserInfo{" +
@@ -246,6 +254,7 @@ public class UserInfo extends BaseEntity
                 ", age=" + age +
                 ", idCard='" + idCard + '\'' +
                 ", phoneNum='" + phoneNum + '\'' +
+                ", deptId='" + deptId + '\'' +
                 ", collectPlace='" + collectPlace + '\'' +
                 ", nucleicCollectTime='" + nucleicCollectTime + '\'' +
                 ", nucleicResultsTime='" + nucleicResultsTime + '\'' +

+ 24 - 0
ruoyi-system/src/main/java/com/ruoyi/system/domain/UserNucleicTime.java

@@ -36,6 +36,12 @@ public class UserNucleicTime extends BaseEntity
     /** 核酸结果 0:阴性1:阳性 */
     private String nucleicResult;
 
+    /** 职业类别 */
+    private String jobStyle;
+
+    /** 重点人群分类 */
+    private String focusCrowdStyle;
+
     public void setId(Long id) 
     {
         this.id = id;
@@ -99,6 +105,22 @@ public class UserNucleicTime extends BaseEntity
         this.idCard = idCard;
     }
 
+    public String getJobStyle() {
+        return jobStyle;
+    }
+
+    public String getFocusCrowdStyle() {
+        return focusCrowdStyle;
+    }
+
+    public void setJobStyle(String jobStyle) {
+        this.jobStyle = jobStyle;
+    }
+
+    public void setFocusCrowdStyle(String focusCrowdStyle) {
+        this.focusCrowdStyle = focusCrowdStyle;
+    }
+
     @Override
     public String toString() {
         return "UserNucleicTime{" +
@@ -109,6 +131,8 @@ public class UserNucleicTime extends BaseEntity
                 ", nucleicCollectTime='" + nucleicCollectTime + '\'' +
                 ", nucleicResultsTime='" + nucleicResultsTime + '\'' +
                 ", nucleicResult='" + nucleicResult + '\'' +
+                ", jobStyle='" + jobStyle + '\'' +
+                ", focusCrowdStyle='" + focusCrowdStyle + '\'' +
                 '}';
     }
 }

+ 1 - 1
ruoyi-system/src/main/java/com/ruoyi/system/service/IUserInfoService.java

@@ -59,5 +59,5 @@ public interface IUserInfoService
      */
     public int deleteUserInfoById(Long id);
 
-    String importUser(List<UserInfo> userList, String jobStyle, String focusCrowdStyle, String detectionNumber, String detectionScope, String startTime, String endTime);
+    String importUser(List<UserInfo> userList, String jobStyle, String focusCrowdStyle, String detectionNumber, String detectionScope, String startTime, String endTime) throws Exception;
 }

+ 83 - 14
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/UserInfoServiceImpl.java

@@ -1,20 +1,25 @@
 package com.ruoyi.system.service.impl;
 
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-import com.ruoyi.common.core.domain.entity.SysDictType;
+import com.alibaba.fastjson2.JSON;
+import com.alibaba.fastjson2.JSONArray;
+import com.alibaba.fastjson2.JSONObject;
+import com.alibaba.fastjson2.TypeReference;
 import com.ruoyi.common.core.domain.entity.SysUser;
 import com.ruoyi.common.utils.DateUtils;
 import com.ruoyi.common.utils.SecurityUtils;
+import com.ruoyi.common.utils.http.HttpClientUtils;
+import com.ruoyi.common.utils.http.HttpUtils;
+import com.ruoyi.system.domain.UserInfo;
 import com.ruoyi.system.mapper.SysDictTypeMapper;
-import com.ruoyi.system.service.ISysDictTypeService;
+import com.ruoyi.system.mapper.UserInfoMapper;
 import com.ruoyi.system.service.IUserInfoService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
-import com.ruoyi.system.mapper.UserInfoMapper;
-import com.ruoyi.system.domain.UserInfo;
+
+import java.io.IOException;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.*;
 
 /**
  * 导入人员信息Service业务层处理
@@ -51,6 +56,8 @@ public class UserInfoServiceImpl implements IUserInfoService
     @Override
     public List<UserInfo> selectUserInfoList(UserInfo userInfo)
     {
+        SysUser user = SecurityUtils.getLoginUser().getUser();
+        userInfo.setDeptId(String.valueOf(user.getDeptId()));
         return userInfoMapper.selectUserInfoList(userInfo);
     }
 
@@ -104,22 +111,84 @@ public class UserInfoServiceImpl implements IUserInfoService
         return userInfoMapper.deleteUserInfoById(id);
     }
 
+    /**
+     * 核酸比对人员导入
+     * @param jobStyle  职业类别
+     * @param focusCrowdStyle 重点人群分类
+     * @param detectionNumber 检测频次(次数)
+     * @param detectionScope 检测频次(时间范围)
+     * @param startTime 比对开始时间
+     * @param endTime 比对结束时间
+     * @return
+     * @throws Exception
+     */
     @Override
     public String importUser(List<UserInfo> userList, String jobStyle, String focusCrowdStyle, String detectionNumber,
-                             String detectionScope, String startTime, String endTime) {
+                             String detectionScope, String startTime, String endTime) throws Exception{
 
         //todo 获取当前上传人员部门id
         SysUser user = SecurityUtils.getLoginUser().getUser();
         String deptId = String.valueOf(user.getDeptId());
 
-        //todo 向医院查询上传名单人员核酸数据(将时间段内所有人员数据查询出来),之后与上传人员名单比较,提取身份证号相同的数据
-        List<Map<String,Object>> yyMap = new ArrayList<>();
+        //计算两个时间相隔的天数
 
-        for (UserInfo userInfo : userList) {
-            for (Map<String, Object> yMap : yyMap) {
+        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
+        Date date1 = simpleDateFormat.parse(startTime);
+        Date date2 = simpleDateFormat.parse(endTime);
+        int dNum = DateUtils.differentDaysByMillisecond(date1,date2);
+
+        if(dNum<=Integer.getInteger(detectionScope)){
+
+
+        }else{
 
-            }
         }
+
+        String token = getToken();
+        String http = "http://60.171.171.235:9090/service/api/wjw/qsyyhsdbfx";
+        Map<String, String> paramMap = new HashMap<>();
+        paramMap.put("client_id", "066676ef5f7947e794b879550078cfb8");
+        paramMap.put("access_token", token);
+        paramMap.put("sfzhm", "340323200806306216");
+
+        paramMap.put("sjhm", "13585154184");
+        paramMap.put("xm", "陶建筑");
+
+        paramMap.put("start_time", "2022-01-01 10:00:59");
+        paramMap.put("end_time", "2022-08-14 10:00:59");
+        String data = HttpClientUtils.doGet(http, paramMap);
+        List<Map<String,Object>> list = JSON.parseObject(data,new TypeReference<ArrayList<Map<String,Object>>>(){});
+
+
+
+        //todo 向医院查询上传名单人员核酸数据(将时间段内所有人员数据查询出来),之后与上传人员名单比较,提取身份证号相同的数据
+        /*List<Map<String,Object>> yyMap = new ArrayList<>();
+        StringBuilder params = new StringBuilder();
+        for (UserInfo userInfo : userList) {
+            params.append("client_id=066676ef5f7947e794b879550078cfb8").append("&access_token=").append(token);
+            params.append("&sfzhm=").append(userInfo.getIdCard()).append("&sjhm=").append(userInfo.getPhoneNum());
+            params.append("&xm=").append(userInfo.getName()).append("&beginTime=").append(startTime).append("&endTime=").append(endTime);
+            String data = HttpUtils.sendGet(http, params.toString());
+            List<Map<String,Object>> list = JSON.parseObject(data,new TypeReference<ArrayList<Map<String,Object>>>(){});
+
+            //释放StringBuilder资源,重置params长度
+            params.setLength(0);
+        }*/
         return "操作成功";
     }
+
+
+    /**
+     * 获取政务网token
+     */
+    public String getToken() {
+        String token = "";
+        StringBuilder params = new StringBuilder();
+        params.append("client_id=066676ef5f7947e794b879550078cfb8&client_secret=r9jCwdTO");
+        String http = "http://60.171.171.235:9090/oauth/token";
+        String data = HttpUtils.sendGet(http, params.toString());
+        JSONObject jsonObject = JSONObject.parseObject(data);
+        token = jsonObject.getString("access_token");
+        return token;
+    }
 }

+ 3 - 1
ruoyi-system/src/main/resources/mapper/system/UserNucleicTimeMapper.xml

@@ -12,10 +12,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="nucleicCollectTime"    column="nucleic_collect_time"    />
         <result property="nucleicResultsTime"    column="nucleic_results_time"    />
         <result property="nucleicResult"    column="nucleic_result"    />
+        <result property="jobStyle"    column="job_style"    />
+        <result property="focusCrowdStyle"    column="focus_crowd_style"    />
     </resultMap>
 
     <sql id="selectUserNucleicTimeVo">
-        select id, info_id, id_card, collect_place, nucleic_collect_time, nucleic_results_time, nucleic_result from user_nucleic_time
+        select id, info_id, id_card, collect_place, nucleic_collect_time, nucleic_results_time, nucleic_result, job_style, focus_crowd_style from user_nucleic_time
     </sql>
 
     <select id="selectUserNucleicTimeList" parameterType="UserNucleicTime" resultMap="UserNucleicTimeResult">