Quellcode durchsuchen

准备LIS接口对接。

lighter vor 4 Jahren
Ursprung
Commit
25a5e5caf3

+ 1 - 1
pom.xml

@@ -10,7 +10,7 @@
     </parent>
     <groupId>thyyxxk</groupId>
     <artifactId>web-server</artifactId>
-    <version>3.6</version>
+    <version>4.1</version>
     <name>web-server</name>
     <description>server for yibao-web</description>
 

+ 5 - 4
src/main/java/thyyxxk/webserver/controller/examinations/InspectionsController.java

@@ -10,6 +10,7 @@ import thyyxxk.webserver.pojo.examinations.inspections.detail.InspectionDetail;
 import thyyxxk.webserver.service.examinations.InspectionsService;
 
 import java.util.List;
+import java.util.concurrent.ExecutionException;
 
 @RestController
 @RequestMapping("/inspections")
@@ -23,13 +24,13 @@ public class InspectionsController {
 
     @PassToken
     @PostMapping("/queryInspectionsIndex")
-    public ResultVo<List<InspectionsIndex>> queryInspectionsIndex(@RequestBody QueryInspectionParam param) {
-        return service.queryInspectionsIndex(param);
+    public ResultVo<List<InspectionsIndex>> queryInspectionsIndex(@RequestBody QueryInspectionParam param) throws ExecutionException, InterruptedException {
+        return service.queryInspectionsIndex(param).get();
     }
 
     @PassToken
     @GetMapping("/queryInspectionDetail")
-    public ResultVo<InspectionDetail> queryInspectionDetail(@RequestParam("orderId") String orderId) {
-        return service.queryInspectionDetail(orderId);
+    public ResultVo<InspectionDetail> queryInspectionDetail(@RequestParam("orderId") String orderId) throws ExecutionException, InterruptedException {
+        return service.queryInspectionDetail(orderId).get();
     }
 }

+ 19 - 0
src/main/java/thyyxxk/webserver/controller/lisdock/LisDockController.java

@@ -0,0 +1,19 @@
+package thyyxxk.webserver.controller.lisdock;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+import thyyxxk.webserver.pojo.ResultVo;
+import thyyxxk.webserver.service.lisdock.LisDockService;
+
+@RestController
+@RequestMapping("/lisDock")
+public class LisDockController {
+    private final LisDockService service;
+
+    @Autowired
+    public LisDockController(LisDockService service) {
+        this.service = service;
+    }
+
+}

+ 1 - 1
src/main/java/thyyxxk/webserver/pojo/adverseevent/ReportIndex.java

@@ -17,8 +17,8 @@ public class ReportIndex {
     @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
     private Date submitDatetime;
     private String userName;
-    private String department;
     private String deptCode;
+    private String department;
     private Integer accepted;
     private Integer handled;
     private String deptDealerName;

+ 11 - 21
src/main/java/thyyxxk/webserver/service/examinations/InspectionsService.java

@@ -10,10 +10,9 @@ import org.dom4j.Document;
 import org.dom4j.DocumentException;
 import org.dom4j.DocumentHelper;
 import org.dom4j.Element;
-import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.scheduling.annotation.Async;
 import org.springframework.stereotype.Service;
 import thyyxxk.webserver.config.exception.ExceptionEnum;
-import thyyxxk.webserver.dao_his.inspections.InspectionsDao;
 import thyyxxk.webserver.pojo.ResultVo;
 import thyyxxk.webserver.pojo.examinations.inspections.InspectionsIndex;
 import thyyxxk.webserver.pojo.examinations.inspections.QueryInspectionParam;
@@ -27,42 +26,33 @@ import java.lang.reflect.Method;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
+import java.util.concurrent.CompletableFuture;
 
 @Slf4j
 @Service
 public class InspectionsService {
     private static final String SOAP_URL = "http://172.16.32.178:622/pushservice.asmx?wsdl";
-    private final InspectionsDao dao;
 
-    @Autowired
-    public InspectionsService(InspectionsDao dao) {
-        this.dao = dao;
-    }
-
-    public ResultVo<List<InspectionsIndex>> queryInspectionsIndex(QueryInspectionParam param) {
-        String type;
-        if (3 == param.getType()) {
-            type = "";
-            param.setContent(dao.selectTjNo(param.getContent()));
-        } else {
-            type = "<PATIENT_TYPE>" + param.getType() + "</PATIENT_TYPE>";
-        }
-        String send = "<message>" + type +
+    @Async
+    public CompletableFuture<ResultVo<List<InspectionsIndex>>> queryInspectionsIndex(QueryInspectionParam param) {
+        String send = "<message>" +
+                "<PATIENT_TYPE>" + param.getType() + "</PATIENT_TYPE>" +
                 "<PTNT_NO>" + param.getContent() + "</PTNT_NO>" +
                 "<START_TIME>" + DateUtil.formatDatetime(param.getStart(), "yyyy-MM-dd") + "</START_TIME>" +
                 "<END_TIME>" + DateUtil.formatDatetime(param.getEnd(), "yyyy-MM-dd") + "</END_TIME>" +
                 "</message>";
         String xml = invokeRemoteMethod("GetLabReportIndex", new Object[]{send});
-        return analyzeReportIndex(xml.substring(1, xml.length() - 1));
+        return CompletableFuture.completedFuture(analyzeReportIndex(xml.substring(1, xml.length() - 1)));
     }
 
-    public ResultVo<InspectionDetail> queryInspectionDetail(String orderId) {
+    @Async
+    public CompletableFuture<ResultVo<InspectionDetail>> queryInspectionDetail(String orderId) {
         if (orderId == null || orderId.trim().equals("") || orderId.trim().equals("undefined")) {
-            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "报告ID不能为空!");
+            return CompletableFuture.completedFuture(ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "报告ID不能为空!"));
         }
         String send = "<message><ORDR_ID>" + orderId + "</ORDR_ID></message>";
         String xml = invokeRemoteMethod("GetLabReport", new Object[]{send});
-        return analyzeReportDetail(xml.substring(1, xml.length() - 1));
+        return CompletableFuture.completedFuture(analyzeReportDetail(xml.substring(1, xml.length() - 1)));
     }
 
     private String invokeRemoteMethod(String operation, Object[] parameters) {

+ 121 - 7
src/main/java/thyyxxk/webserver/service/lisdock/LisDockService.java

@@ -1,23 +1,137 @@
 package thyyxxk.webserver.service.lisdock;
 
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import lombok.extern.slf4j.Slf4j;
 import org.springframework.stereotype.Service;
+import org.springframework.web.client.RestTemplate;
+import thyyxxk.webserver.pojo.examinations.inspections.detail.InspectionDetail;
+import thyyxxk.webserver.pojo.examinations.inspections.detail.InspectionHeader;
+import thyyxxk.webserver.pojo.examinations.inspections.detail.InspectionItem;
 import thyyxxk.webserver.utils.MD5Util;
 
+import java.io.IOException;
+import java.util.Map;
+
+@Slf4j
 @Service
 public class LisDockService {
     private final static String APP_ID = "jkzd5e26bf01c5a0d79";
     private final static String SECRET = "957a642f1dae09fd226a3517a465";
+    private final static String IMG_URL_PREFIX = "http://staticweb.hnthyy.cn/inspections/";
 
-    private String sign() {
+    private String[] sign() {
         String timeStamp = String.valueOf(System.currentTimeMillis());
         String ori = APP_ID + timeStamp + SECRET;
-        return MD5Util.encrypt(MD5Util.encrypt(ori));
+        return new String[] { timeStamp, MD5Util.encrypt(MD5Util.encrypt(ori)) };
     }
 
-    public static void main(String[] args) {
-        String timeStamp = String.valueOf(System.currentTimeMillis());
-        String ori = APP_ID + timeStamp + SECRET;
-        System.out.println(timeStamp);
-        System.out.println(MD5Util.encrypt(MD5Util.encrypt(ori)));
+    private String html2image(JSONObject obj) {
+        String url = "http://192.168.200.3:8805/htmlToImage/healthCardImage/execute";
+        RestTemplate restTemplate = new RestTemplate();
+        Map<String, Object> res = restTemplate.postForObject(url, obj, Map.class);
+        log.info("生成检验报告图片结果:{}", res);
+        if (null == res) {
+            return null;
+        }
+        if ((int) res.get("code") != 200) {
+            return res.get("message").toString();
+        }
+        return res.get("path").toString();
+    }
+
+    private void pushResult(JSONObject obj) {
+        String url = "http://api.ingeye.com/commonInterface/pushResult";
+        RestTemplate restTemplate = new RestTemplate();
+        String res = restTemplate.postForObject(url, obj, String.class);
+        System.out.println("推送结果:" + res);
+    }
+
+    private JSONObject getCustomerInfo(String barCode) {
+        String url = "http://api.ingeye.com/commonInterface/selectUserInfo";
+        String[] signInfo = sign();
+        JSONObject param = new JSONObject();
+        param.put("barCode", barCode);
+        param.put("appId", APP_ID);
+        param.put("timeStamp", signInfo[0]);
+        param.put("signature", signInfo[1]);
+        RestTemplate restTemplate = new RestTemplate();
+        String res = restTemplate.postForObject(url, param, String.class);
+        JSONObject resObj = JSONObject.parseObject(res);
+        if (resObj.getIntValue("code") == 0) {
+            JSONObject data = resObj.getJSONObject("data");
+            JSONObject customerInfo = new JSONObject();
+            customerInfo.put("barCode", data.getString("barCode"));
+            customerInfo.put("name", data.getString("name"));
+            customerInfo.put("sex", data.getString("sex"));
+            customerInfo.put("age", data.getString("age"));
+            customerInfo.put("idCard", data.getString("idCard"));
+            return customerInfo;
+        }
+        return null;
+    }
+
+    private JSONObject makePushObjByExam(String barCode, InspectionDetail param) {
+        // TODO: 2021-03-03 获取到身份信息后,推送前要put reportUrl字段
+        JSONObject customerInfo = getCustomerInfo(barCode);
+        if (null == customerInfo) {
+            return null;
+        }
+        String itemCode; // JK01-大便培养,JK02-血液检查
+        if (param.getInspectionHeader().getAPLY_CNTN().contains("大便培养")) {
+            customerInfo.put("type", "0");
+            itemCode = "JK01";
+        } else {
+            customerInfo.put("type", "1");
+            itemCode = "JK02";
+        }
+
+        JSONObject pushObj = new JSONObject();
+        pushObj.put("appId", APP_ID);
+        pushObj.put("customerInfo", customerInfo);
+        JSONArray itemResult = new JSONArray();
+
+        InspectionHeader header = param.getInspectionHeader();
+
+        if (itemCode.equals("JK01")) {
+
+        } else {
+            for (InspectionItem item : param.getInspectionItems()) {
+                JSONObject itemObj = new JSONObject();
+                itemObj.put("itemCode", itemCode);
+                itemObj.put("itemName", item.getITM_NAME());
+                itemObj.put("opter", header.getORDR_USR_NAME());
+                itemObj.put("auditOpter", header.getAUDT_USR_NAME());
+                itemObj.put("testTime", header.getAUDT_TIME().substring(0, 10));
+                itemObj.put("auditTime", header.getAUDT_TIME().substring(0, 10));
+                itemObj.put("result", item.getITM_STR_VALUE());
+                if (item.getITM_STR_VALUE().contains("未")) {
+                    itemObj.put("status", "0");
+                } else {
+                    itemObj.put("status", "1");
+                }
+                itemObj.put("reference", "");
+                itemObj.put("unit", "");
+                itemResult.add(itemObj);
+            }
+        }
+
+        pushObj.put("itemResults", itemResult);
+        return pushObj;
+    }
+
+    public static void main(String[] args) throws IOException {
+        LisDockService service = new LisDockService();
+//        JSONObject push1 = service.test();
+        String[] signInfo = service.sign();
+        System.out.println("timeStamp:" + signInfo[0]);
+        System.out.println("signature:" + signInfo[1]);
+//        push1.put("timeStamp", signInfo[0]);
+//        push1.put("signature", signInfo[1]);
+//        JSONObject push2 = service.test2();
+//        push2.put("timeStamp", signInfo[0]);
+//        push2.put("signature", signInfo[1]);
+//        service.pushResult(push1);
+//        service.pushResult(push2);
     }
 }

+ 58 - 0
src/main/resources/application-dev.yml

@@ -0,0 +1,58 @@
+server:
+  port: 8707
+spring:
+  thymeleaf:
+    cache: false
+  datasource:
+    his:
+      jdbc-url: "jdbc:sqlserver://172.16.32.160:1433;databaseName=thxyhisdb"
+      username: "sa"
+      password:
+      type: "com.zaxxer.hikari.HikariDataSource"
+      driver-class-name: "com.microsoft.sqlserver.jdbc.SQLServerDriver"
+      minimum-idle: 10
+      idle-timeout: 180000
+      maximum-pool-size: 30
+      auto-commit: true
+      pool-name: hisDbPool
+      connection-timeout: 30000
+      connection-test-query: select 1
+    lis:
+      jdbc-url: "jdbc:sqlserver://172.16.32.178:1433;databaseName=eLimsCore"
+      username: "sa"
+      password: "hnthxyyy"
+      type: "com.zaxxer.hikari.HikariDataSource"
+      driver-class-name: "com.microsoft.sqlserver.jdbc.SQLServerDriver"
+      minimum-idle: 10
+      idle-timeout: 180000
+      maximum-pool-size: 30
+      auto-commit: true
+      pool-name: lisDbPool
+      connection-timeout: 30000
+      connection-test-query: select 1
+  rabbitmq:
+    host: 192.168.200.3
+    port: 5672
+    username: dj
+    password: 123456
+  jackson:
+    time-zone: GMT+8
+    date-format: yyyy-MM-dd HH:mm:ss
+  mvc:
+    format:
+      date: yyyy-MM-dd
+      date-time: yyyy-MM-dd HH:mm:ss
+mybatis:
+  configuration:
+    map-underscore-to-camel-case: true
+
+UPLOAD_BASE:
+  http://172.16.32.163
+CSSYB_BASE:
+  http://172.16.32.163:1000/cssyb/
+HNSYB_BASE:
+  http://172.16.32.163:2000/hnsyb/
+XNHYB_BASE:
+  http://172.16.32.163:3000/xnhyb/
+MT_PERSON_INFO:
+  http://172.16.32.163:2000/shengyb/mt/getPersonInfo