|
@@ -1,17 +1,29 @@
|
|
|
package thyyxxk.webserver.service.lisdock;
|
|
|
|
|
|
-import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.web.client.RestTemplate;
|
|
|
+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;
|
|
|
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.pojo.examinations.lisdock.CustomerInfo;
|
|
|
+import thyyxxk.webserver.pojo.examinations.lisdock.HealthCardResult;
|
|
|
+import thyyxxk.webserver.pojo.examinations.lisdock.ItemResults;
|
|
|
+import thyyxxk.webserver.pojo.examinations.lisdock.PushResultParam;
|
|
|
+import thyyxxk.webserver.service.examinations.InspectionsService;
|
|
|
import thyyxxk.webserver.utils.MD5Util;
|
|
|
+import thyyxxk.webserver.utils.ResultVoUtil;
|
|
|
|
|
|
-import java.io.IOException;
|
|
|
-import java.util.Map;
|
|
|
+import java.text.DateFormat;
|
|
|
+import java.util.*;
|
|
|
+import java.util.concurrent.ExecutionException;
|
|
|
|
|
|
@Slf4j
|
|
|
@Service
|
|
@@ -19,6 +31,119 @@ 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 static final String GET_CUSTOMER_INFO = "https://api.hnocc.com/commonInterface/selectUserInfo";
|
|
|
+ private static final String PUSH_RESULT = "https://api.hnocc.com/commonInterface/pushResult";
|
|
|
+// private static final String GET_CUSTOMER_INFO = "http://api.ingeye.com/commonInterface/selectUserInfo";
|
|
|
+// private static final String PUSH_RESULT = "http://api.ingeye.com/commonInterface/pushResult";
|
|
|
+ private final InspectionsDao dao;
|
|
|
+ private final InspectionsService service;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ public LisDockService(InspectionsDao dao, InspectionsService service) {
|
|
|
+ this.dao = dao;
|
|
|
+ this.service = service;
|
|
|
+ }
|
|
|
+
|
|
|
+ public ResultVo<Map<String, Object>> scanBarCode(String barCode) throws Exception {
|
|
|
+ JSONObject customerInfo = getCustomerInfo(barCode);
|
|
|
+ if (null == customerInfo) {
|
|
|
+ return ResultVoUtil.fail(ExceptionEnum.NULL_POINTER, "未查询到此条码对应的身份信息。");
|
|
|
+ }
|
|
|
+
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+ map.put("customerInfo", customerInfo);
|
|
|
+ String tjNo = dao.selectTjNo(customerInfo.getString("idCard"));
|
|
|
+ QueryInspectionParam param = new QueryInspectionParam();
|
|
|
+ param.setType(3);
|
|
|
+ param.setContent(tjNo);
|
|
|
+ param.setStart(DateFormat.getDateInstance().parse("2021-02-20"));
|
|
|
+ param.setEnd(new Date());
|
|
|
+ List<InspectionsIndex> list = service.queryInspectionsIndex(param).get().getData();
|
|
|
+ list.removeIf(item -> !item.getAPLY_CTNT().contains("大便培养") &&
|
|
|
+ !item.getAPLY_CTNT().contains("甲肝抗体") && !item.getAPLY_CTNT().contains("戊肝抗体"));
|
|
|
+ map.put("inspectionsIndex", list);
|
|
|
+ return ResultVoUtil.success(map);
|
|
|
+ }
|
|
|
+
|
|
|
+ public ResultVo<String> pushSelectedResult(PushResultParam param) throws ExecutionException, InterruptedException {
|
|
|
+ String itemCode; // JK01-大便培养,JK02-血液检查
|
|
|
+ CustomerInfo customerInfo = param.getCustomerInfo();
|
|
|
+ for (InspectionsIndex index : param.getInspectionsIndex()) {
|
|
|
+ if (index.getAPLY_CTNT().contains("大便培养")) {
|
|
|
+ customerInfo.setType("0");
|
|
|
+ itemCode = "JK01";
|
|
|
+ } else {
|
|
|
+ customerInfo.setType("1");
|
|
|
+ itemCode = "JK02";
|
|
|
+ }
|
|
|
+ HealthCardResult result = new HealthCardResult();
|
|
|
+ result.setAppId(APP_ID);
|
|
|
+ result.setCustomerInfo(customerInfo);
|
|
|
+
|
|
|
+ InspectionDetail detail = service.queryInspectionDetail(index.getORDR_ID()).get().getData();
|
|
|
+ InspectionHeader header = detail.getInspectionHeader();
|
|
|
+
|
|
|
+ List<ItemResults> itemResults = new ArrayList<>();
|
|
|
+ if (itemCode.equals("JK01")) {
|
|
|
+ if (detail.getInspectionItems().get(0).getITM_STR_VALUE().contains("未检出")) {
|
|
|
+ ItemResults xjxlj = new ItemResults();
|
|
|
+ xjxlj.setItemCode(itemCode);
|
|
|
+ xjxlj.setItemName("细菌性痢疾");
|
|
|
+ xjxlj.setOpter(header.getTEST_USR_NAME());
|
|
|
+ xjxlj.setAuditOpter(header.getAUDT_USR_NAME());
|
|
|
+ xjxlj.setTestTime(header.getORDR_CREATE_DATE().substring(0, 10));
|
|
|
+ xjxlj.setAuditTime(header.getAUDT_TIME().substring(0, 10));
|
|
|
+ xjxlj.setResult("未见异常");
|
|
|
+ xjxlj.setStatus("0");
|
|
|
+ xjxlj.setReference("");
|
|
|
+ xjxlj.setUnit("");
|
|
|
+ itemResults.add(xjxlj);
|
|
|
+ ItemResults ambxlj = xjxlj.clone();
|
|
|
+ ambxlj.setItemName("阿米巴性痢疾");
|
|
|
+ itemResults.add(ambxlj);
|
|
|
+ ItemResults shhfsh = xjxlj.clone();
|
|
|
+ shhfsh.setItemName("伤寒和副伤寒");
|
|
|
+ itemResults.add(shhfsh);
|
|
|
+ ItemResults hl = xjxlj.clone();
|
|
|
+ hl.setItemName("霍乱");
|
|
|
+ itemResults.add(hl);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ for (InspectionItem item : detail.getInspectionItems()) {
|
|
|
+ ItemResults results = new ItemResults();
|
|
|
+ results.setItemCode(itemCode);
|
|
|
+ results.setItemName(item.getITM_NAME());
|
|
|
+ results.setOpter(header.getTEST_USR_NAME());
|
|
|
+ results.setAuditOpter(header.getAUDT_USR_NAME());
|
|
|
+ results.setTestTime(header.getORDR_CREATE_DATE().substring(0, 10));
|
|
|
+ results.setAuditTime(header.getAUDT_TIME().substring(0, 10));
|
|
|
+ results.setResult(item.getITM_STR_VALUE());
|
|
|
+ if (item.getITM_STR_VALUE().contains("未")) {
|
|
|
+ results.setStatus("0");
|
|
|
+ } else {
|
|
|
+ results.setStatus("1");
|
|
|
+ }
|
|
|
+ results.setReference("");
|
|
|
+ results.setUnit("");
|
|
|
+ itemResults.add(results);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ result.setItemResults(itemResults);
|
|
|
+ String reportUrl = html2image(result);
|
|
|
+ if (null == reportUrl) {
|
|
|
+ return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "生成检验报告图片失败!");
|
|
|
+ }
|
|
|
+ String[] sign = sign();
|
|
|
+ result.getCustomerInfo().setReportUrl(reportUrl);
|
|
|
+ result.setTimeStamp(sign[0]);
|
|
|
+ result.setSignature(sign[1]);
|
|
|
+ int code = pushResult(result);
|
|
|
+ if (code != 0) {
|
|
|
+ return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "推送失败!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return ResultVoUtil.success();
|
|
|
+ }
|
|
|
|
|
|
private String[] sign() {
|
|
|
String timeStamp = String.valueOf(System.currentTimeMillis());
|
|
@@ -26,37 +151,40 @@ public class LisDockService {
|
|
|
return new String[] { timeStamp, MD5Util.encrypt(MD5Util.encrypt(ori)) };
|
|
|
}
|
|
|
|
|
|
- private String html2image(JSONObject obj) {
|
|
|
+ private String html2image(HealthCardResult param) {
|
|
|
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);
|
|
|
+ Map<String, Object> res = restTemplate.postForObject(url, param, 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();
|
|
|
+ return IMG_URL_PREFIX + res.get("path").toString();
|
|
|
}
|
|
|
|
|
|
- private void pushResult(JSONObject obj) {
|
|
|
- String url = "http://api.ingeye.com/commonInterface/pushResult";
|
|
|
+ private int pushResult(HealthCardResult param) {
|
|
|
+ JSONObject obj = JSONObject.parseObject(JSONObject.toJSONString(param));
|
|
|
+ log.info("推送内容:{}", obj);
|
|
|
RestTemplate restTemplate = new RestTemplate();
|
|
|
- String res = restTemplate.postForObject(url, obj, String.class);
|
|
|
- System.out.println("推送结果:" + res);
|
|
|
+ String res = restTemplate.postForObject(PUSH_RESULT, obj, String.class);
|
|
|
+ log.info("推送结果:{}", res);
|
|
|
+ JSONObject resObj = JSONObject.parseObject(res);
|
|
|
+ return resObj.getIntValue("code");
|
|
|
}
|
|
|
|
|
|
private JSONObject getCustomerInfo(String barCode) {
|
|
|
- String url = "http://api.ingeye.com/commonInterface/selectUserInfo";
|
|
|
- String[] signInfo = sign();
|
|
|
+ String[] sign = sign();
|
|
|
JSONObject param = new JSONObject();
|
|
|
param.put("barCode", barCode);
|
|
|
param.put("appId", APP_ID);
|
|
|
- param.put("timeStamp", signInfo[0]);
|
|
|
- param.put("signature", signInfo[1]);
|
|
|
+ param.put("timeStamp", sign[0]);
|
|
|
+ param.put("signature", sign[1]);
|
|
|
RestTemplate restTemplate = new RestTemplate();
|
|
|
- String res = restTemplate.postForObject(url, param, String.class);
|
|
|
+ String res = restTemplate.postForObject(GET_CUSTOMER_INFO, param, String.class);
|
|
|
+ log.info("查询健康证【{}】个人信息:{}", barCode, res);
|
|
|
JSONObject resObj = JSONObject.parseObject(res);
|
|
|
if (resObj.getIntValue("code") == 0) {
|
|
|
JSONObject data = resObj.getJSONObject("data");
|
|
@@ -70,68 +198,4 @@ public class LisDockService {
|
|
|
}
|
|
|
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);
|
|
|
- }
|
|
|
}
|