Selaa lähdekoodia

添加体检结果查询模块

lighter 3 vuotta sitten
vanhempi
commit
b9eb0ba6ac

+ 1 - 1
pom.xml

@@ -10,7 +10,7 @@
     </parent>
     <groupId>thyyxxk</groupId>
     <artifactId>wxservice-server</artifactId>
-    <version>8.1</version>
+    <version>8.2</version>
     <name>wxservice-server</name>
     <description>server for wxservice-web</description>
 

+ 1 - 0
src/main/java/thyyxxk/wxservice_server/config/exception/ExceptionEnum.java

@@ -15,6 +15,7 @@ public enum ExceptionEnum {
     INTERNAL_SERVER_ERROR(1001, "服务器内部错误!"),
     NULL_POINTER(1002, "空指针异常!"),
     NETWORK_ERROR(1003, "网络异常!"),
+    NO_DATA_EXIST(1004, "没有查询到有效数据!"),
     /**
      * 以下是需要弹窗提示的错误
      * */

+ 27 - 0
src/main/java/thyyxxk/wxservice_server/controller/PowersiPhysicalCheckController.java

@@ -0,0 +1,27 @@
+package thyyxxk.wxservice_server.controller;
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+import thyyxxk.wxservice_server.entity.ResultVo;
+import thyyxxk.wxservice_server.service.PowersiPhysicalCheckService;
+
+@RestController
+@RequestMapping("/physicalCheck")
+public class PowersiPhysicalCheckController {
+    private final PowersiPhysicalCheckService service;
+
+    @Autowired
+    public PowersiPhysicalCheckController(PowersiPhysicalCheckService service) {
+        this.service = service;
+    }
+
+    @GetMapping("/getPhysicalCheckResult")
+    public ResultVo<JSONObject> getPhysicalCheckResult(@RequestParam("tjid") String tjid) {
+        return service.getPhysicalCheckResult(tjid);
+    }
+}

+ 120 - 0
src/main/java/thyyxxk/wxservice_server/service/PowersiPhysicalCheckService.java

@@ -0,0 +1,120 @@
+package thyyxxk.wxservice_server.service;
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Service;
+import org.springframework.web.client.RestTemplate;
+import thyyxxk.wxservice_server.config.exception.ExceptionEnum;
+import thyyxxk.wxservice_server.entity.ResultVo;
+import thyyxxk.wxservice_server.utils.DateUtil;
+import thyyxxk.wxservice_server.utils.ResultVoUtil;
+
+import java.util.Comparator;
+import java.util.List;
+
+@Service
+public class PowersiPhysicalCheckService {
+    @Value("${physicalCheck}")
+    private String physicalCheckUrl;
+
+    public ResultVo<JSONObject> getPhysicalCheckResult(String tjid) {
+        ResultVo<JSONObject> summary = getSummary(tjid);
+        if (summary.getCode() != ExceptionEnum.SUCCESS.getCode()) {
+            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, summary.getMessage());
+        }
+        ResultVo<List<JSONObject>> checkItems = getExamItems(tjid);
+        if (checkItems.getCode() != ExceptionEnum.SUCCESS.getCode()) {
+            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, checkItems.getMessage());
+        }
+        ResultVo<JSONObject> examResult = getExamResult(tjid);
+        if (examResult.getCode() != ExceptionEnum.SUCCESS.getCode()) {
+            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, examResult.getMessage());
+        }
+        JSONObject result = new JSONObject();
+        result.put("summary", summary.getData());
+        List<JSONObject> itemdata = checkItems.getData();
+        itemdata.removeIf(item -> !examResult.getData().containsKey(item.getString("体检单元名称")));
+        result.put("checkItems", itemdata);
+        result.put("examResult", examResult.getData());
+        return ResultVoUtil.success(result);
+    }
+
+    private ResultVo<JSONObject> getSummary(String tjid) {
+        RestTemplate template = new RestTemplate();
+        JSONObject rawdata = template.getForObject(physicalCheckUrl + "7033a7386d0e45d295b7a13dd079704e?tjid=" + tjid, JSONObject.class);
+        if (null == rawdata) {
+            return ResultVoUtil.fail(ExceptionEnum.NETWORK_ERROR);
+        }
+        JSONObject resultCode = rawdata.getJSONObject("result");
+        if (null == resultCode) {
+            return ResultVoUtil.fail(ExceptionEnum.NETWORK_ERROR);
+        }
+        if (resultCode.getInteger("code") == 0) {
+            JSONArray rows = rawdata.getJSONArray("rows");
+            if (null != rows && rows.size() > 0) {
+                return ResultVoUtil.success(rows.getJSONObject(0));
+            }
+            return ResultVoUtil.fail(ExceptionEnum.NO_DATA_EXIST);
+        }
+        return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, resultCode.getString("message"));
+    }
+
+    private ResultVo<List<JSONObject>> getExamItems(String tjid) {
+        RestTemplate template = new RestTemplate();
+        JSONObject rawdata = template.getForObject(physicalCheckUrl + "f9c6ad55fa1b43b8a6f9e44cc7e126b9?tjid=" + tjid, JSONObject.class);
+        if (null == rawdata) {
+            return ResultVoUtil.fail(ExceptionEnum.NETWORK_ERROR);
+        }
+        JSONObject resultCode = rawdata.getJSONObject("result");
+        if (null == resultCode) {
+            return ResultVoUtil.fail(ExceptionEnum.NETWORK_ERROR);
+        }
+        if (resultCode.getInteger("code") == 0) {
+            JSONArray rows = rawdata.getJSONArray("rows");
+            if (null != rows && rows.size() > 0) {
+                List<JSONObject> list = JSONArray.parseArray(rows.toJSONString(), JSONObject.class);
+                list.sort(Comparator.comparing(obj -> ((JSONObject) obj).getLong("检查日期")));
+                for (JSONObject item : list) {
+                    item.put("name", item.getString("体检单元名称"));
+                    item.put("checkTime", DateUtil.parseTimestamp(item.getLong("检查日期")));
+                }
+                return ResultVoUtil.success(list);
+            }
+            return ResultVoUtil.fail(ExceptionEnum.NO_DATA_EXIST);
+        }
+        return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, resultCode.getString("message"));
+    }
+
+    private ResultVo<JSONObject> getExamResult(String tjid) {
+        RestTemplate template = new RestTemplate();
+        JSONObject rawdata = template.getForObject(physicalCheckUrl + "92eef45c69974df4869b3eed05f5234f?tjid=" + tjid, JSONObject.class);
+        if (null == rawdata) {
+            return ResultVoUtil.fail(ExceptionEnum.NETWORK_ERROR);
+        }
+        JSONObject resultCode = rawdata.getJSONObject("result");
+        if (null == resultCode) {
+            return ResultVoUtil.fail(ExceptionEnum.NETWORK_ERROR);
+        }
+        if (resultCode.getInteger("code") == 0) {
+            JSONArray rows = rawdata.getJSONArray("rows");
+            if (null != rows && rows.size() > 0) {
+                JSONObject result = new JSONObject();
+                for (int i = 0; i < rows.size(); i++) {
+                    JSONObject item = rows.getJSONObject(i);
+                    String key = item.getString("检查单元C");
+                    if (result.containsKey(key)) {
+                        result.getJSONArray(key).add(item);
+                    } else {
+                        JSONArray array = new JSONArray();
+                        array.add(item);
+                        result.put(key, array);
+                    }
+                }
+                return ResultVoUtil.success(result);
+            }
+            return ResultVoUtil.fail(ExceptionEnum.NO_DATA_EXIST);
+        }
+        return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, resultCode.getString("message"));
+    }
+}

+ 6 - 0
src/main/java/thyyxxk/wxservice_server/utils/DateUtil.java

@@ -30,6 +30,12 @@ public class DateUtil {
         }
     }
 
+    public static String parseTimestamp(Long timestamp) {
+        Date date = new Date(timestamp);
+        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        return df.format(date);
+    }
+
     public static String[] getDatesInOneWeek() {
         String[] result = new String[7];
         SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");

+ 1 - 0
src/main/resources/application-8083.yml

@@ -33,4 +33,5 @@ mybatis:
 
 hrgApiUrl: http://172.16.32.160:81/thmz/api/v1
 inspectionUrl: http://172.16.32.178:622/pushservice.asmx?wsdl
+physicalCheck: http://172.16.32.183:8888/bdp/dataservice/api/
 production: true

+ 1 - 0
src/main/resources/application-8085.yml

@@ -33,4 +33,5 @@ mybatis:
 
 hrgApiUrl: http://172.16.32.160:81/thmz/api/v1
 inspectionUrl: http://172.16.32.178:622/pushservice.asmx?wsdl
+physicalCheck: http://172.16.32.183:8888/bdp/dataservice/api/
 production: true

+ 1 - 0
src/main/resources/application.yml

@@ -34,4 +34,5 @@ mybatis:
 #hrgApiUrl: http://172.16.30.33:8089/thmz/api/v1
 hrgApiUrl: http://172.16.32.160:81/thmz/api/v1
 inspectionUrl: http://172.16.32.178:622/pushservice.asmx?wsdl
+physicalCheck: http://172.16.32.183:8888/bdp/dataservice/api/
 production: false