|
@@ -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);
|
|
|
}
|
|
|
}
|