Browse Source

1、缓存支持各地可配
2、增加例外基本处理

louhr 5 years ago
parent
commit
0653f61720

+ 4 - 2
kernel/src/main/java/com/lantone/qc/kernel/analysis/QCAnalysis.java

@@ -6,6 +6,8 @@ import com.lantone.qc.kernel.client.SimilarityServiceClient;
 import com.lantone.qc.kernel.structure.ai.AIAnalyze;
 import com.lantone.qc.kernel.util.CatalogueUtil;
 import com.lantone.qc.kernel.util.RedisUtil;
+import com.lantone.qc.pub.exception.AIException;
+import com.lantone.qc.pub.exception.CatalogueException;
 import com.lantone.qc.pub.model.InputInfo;
 import com.lantone.qc.pub.model.OutputInfo;
 import com.lantone.qc.pub.model.vo.QueryVo;
@@ -33,7 +35,7 @@ public class QCAnalysis {
     @Autowired
     private RedisUtil redisUtil;
 
-    public OutputInfo anlysis(QueryVo queryVo) {
+    public OutputInfo anlysis(QueryVo queryVo) throws AIException, CatalogueException, Exception {
         OutputInfo outputInfo = new OutputInfo();
         InputInfo inputInfo = TransDispatch.trans(queryVo);
         inputInfo.setInputCatalogueMap(queryVo.getInputCatalogueMap());
@@ -41,7 +43,7 @@ public class QCAnalysis {
         try{
             aiAnalyze.aiProcess(inputInfo);
         }catch (Exception e){
-            e.printStackTrace();
+            throw new AIException("AI模型执行错误:" + e.getMessage());
         }
         for (Map.Entry<String, Map<String, String>> entry : inputInfo.getInputCatalogueMap().entrySet()) {
             if (CatalogueUtil.qcCatalogueMap.get(entry.getKey()) == null) {

+ 17 - 11
kernel/src/main/java/com/lantone/qc/kernel/util/CacheUtil.java

@@ -8,6 +8,7 @@ import org.apache.commons.lang3.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.boot.ApplicationArguments;
 import org.springframework.boot.ApplicationRunner;
 import org.springframework.stereotype.Component;
@@ -29,6 +30,9 @@ public class CacheUtil implements ApplicationRunner {
     @Autowired
     private RedisUtil redisUtil;
 
+    @Value("${qc.hospital_id}")
+    private String hospitalId;
+
     public void run(ApplicationArguments var1) {
         try {
             this.putConceptDiagPropertyMap();//疾病相关信息放入缓存 包括疾病是否是慢病、传染病、常见症状、同义词
@@ -48,7 +52,7 @@ public class CacheUtil implements ApplicationRunner {
      */
     public void putConceptDiagPropertyMap() throws Exception {
         Configuration configuration = new DefaultConfig();
-        List<String> lines = configuration.readTargetFileContents("cache/concept_diag_properties.dict");
+        List<String> lines = configuration.readTargetFileContents("cache/" + hospitalId + "/concept_diag_properties.dict");
 
         Map<String, Map<String, Object>> diagMap = new HashMap<>();
         for (String line : lines) {
@@ -57,14 +61,16 @@ public class CacheUtil implements ApplicationRunner {
                 List<String> synonymsList = new ArrayList<>();
                 List<String> symptomsList = new ArrayList<>();
                 if (StringUtils.isNotEmpty(line_arr[3])) {
+                    line_arr[3] = line_arr[3].trim();
                     synonymsList = java.util.Arrays.asList(line_arr[3].split(","));
                 }
                 if (StringUtils.isNotEmpty(line_arr[4])) {
+                    line_arr[4] = line_arr[4].trim();
                     symptomsList = java.util.Arrays.asList(line_arr[4].split(","));
                 }
                 Map<String, Object> map = new HashMap<>();
-                map.put("infectious", line_arr[2]);
-                map.put("chronic", line_arr[1]);
+                map.put("infectious", line_arr[2].trim());
+                map.put("chronic", line_arr[1].trim());
                 map.put("synonyms", synonymsList);
                 map.put("symptoms", symptomsList);
                 diagMap.put(line_arr[0], map);
@@ -79,7 +85,7 @@ public class CacheUtil implements ApplicationRunner {
      */
     public void putHospitalDoctorInfoMap() throws Exception {
         Configuration configuration = new DefaultConfig();
-        List<String> lines = configuration.readTargetFileContents("cache/hospital_doctor_info.dict");
+        List<String> lines = configuration.readTargetFileContents("cache/" + hospitalId + "/hospital_doctor_info.dict");
 
         Map<String, Map<String, Object>> hospitalDoctorMap = new HashMap<>();
         for (String line : lines) {
@@ -101,11 +107,11 @@ public class CacheUtil implements ApplicationRunner {
      */
     public void putHospitalDiagMap() throws Exception {
         Configuration configuration = new DefaultConfig();
-        List<String> lines = configuration.readTargetFileContents("cache/hospital_diag_info.dict");
+        List<String> lines = configuration.readTargetFileContents("cache/" + hospitalId + "/hospital_diag_info.dict");
         Map<String, Map<String, String>> hospitalDiagMap = new HashMap<>();
         for (String line : lines) {
             Map<String, String> detail = new HashMap<>();
-            detail.put("name", line);
+            detail.put("name", line.trim());
             detail.put("icd10", "A001");
             hospitalDiagMap.put(line, detail);
         }
@@ -117,11 +123,11 @@ public class CacheUtil implements ApplicationRunner {
      */
     public void putHospitalDiagHuaZMap() throws Exception {
         Configuration configuration = new DefaultConfig();
-        List<String> lines = configuration.readTargetFileContents("cache/hospital_diag_info.dict");
+        List<String> lines = configuration.readTargetFileContents("cache/" + hospitalId + "/hospital_diag_info.dict");
         Map<String, Map<String, String>> hospitalDiagMap = new HashMap<>();
         for (String line : lines) {
             Map<String, String> detail = new HashMap<>();
-            detail.put("name", line);
+            detail.put("name", line.trim());
             detail.put("icd10", "A001");
             hospitalDiagMap.put(line, detail);
         }
@@ -133,11 +139,11 @@ public class CacheUtil implements ApplicationRunner {
      */
     public void putLantoneDiagHuaZMap() throws Exception {
         Configuration configuration = new DefaultConfig();
-        List<String> lines = configuration.readTargetFileContents("cache/hospital_diag_info.dict");
+        List<String> lines = configuration.readTargetFileContents("cache/" + hospitalId + "/hospital_diag_info.dict");
         Map<String, Map<String, String>> hospitalDiagMap = new HashMap<>();
         for (String line : lines) {
             Map<String, String> detail = new HashMap<>();
-            detail.put("name", line);
+            detail.put("name", line.trim());
             detail.put("icd10", "A001");
             hospitalDiagMap.put(line, detail);
         }
@@ -148,7 +154,7 @@ public class CacheUtil implements ApplicationRunner {
      */
     public void putClinicBodyPartMap() throws Exception {
         Configuration configuration = new DefaultConfig();
-        List<String> lines = configuration.readTargetFileContents("cache/concept_clinic_bodypart_properties.dict");
+        List<String> lines = configuration.readTargetFileContents("cache/" + hospitalId + "/concept_clinic_bodypart_properties.dict");
         List<String> clinicBodyPartList = new ArrayList<>();
         for (String line : lines) {
             clinicBodyPartList.add(line);

+ 18 - 1
kernel/src/main/java/com/lantone/qc/kernel/web/controller/QCController.java

@@ -1,6 +1,9 @@
 package com.lantone.qc.kernel.web.controller;
 
 import com.lantone.qc.kernel.analysis.QCAnalysis;
+import com.lantone.qc.pub.exception.AIException;
+import com.lantone.qc.pub.exception.CatalogueException;
+import com.lantone.qc.pub.exception.TransException;
 import com.lantone.qc.pub.model.OutputInfo;
 import com.lantone.qc.pub.model.vo.QueryVo;
 import com.lantone.qc.pub.res.Response;
@@ -30,7 +33,21 @@ public class QCController {
     @PostMapping("rec")
     public Response<OutputInfo> extract(@RequestBody QueryVo queryVo) {
         Response response = new Response();
-        response.setData(qCAnalysis.anlysis(queryVo));
+        try {
+            response.setData(qCAnalysis.anlysis(queryVo));
+        } catch (AIException aie) {
+            response.setRet(-1);
+            response.setMsg(aie.getMessage());
+        } catch (TransException trae) {
+            response.setRet(-2);
+            response.setMsg(trae.getMessage());
+        } catch (CatalogueException ce) {
+            response.setRet(-3);
+            response.setMsg(ce.getMessage());
+        } catch (Exception e) {
+            response.setRet(-9);
+            response.setMsg("质控出错:" + e.getMessage());
+        }
         return response;
     }
 

+ 2 - 2
kernel/src/main/java/com/lantone/qc/kernel/web/controller/QCTestController.java

@@ -47,7 +47,7 @@ public class QCTestController {
 
     @ApiOperation(value = "质控测试接口,无需token信息", notes = "")
     @PostMapping("qc_test")
-    public Response<OutputInfo> qc(String cid, String caseNumber, String hospitalId) {
+    public Response<OutputInfo> qc(String cid, String caseNumber, String hospitalId) throws Exception {
         Response response = new Response();
         if (StringUtils.isEmpty(hospitalId)) {
             response.setData("未填写医院流水号(hospitalId)......");
@@ -101,7 +101,7 @@ public class QCTestController {
 
     @ApiOperation(value = "质控单个病历测试,无需token信息", notes = "")
     @PostMapping("qc_test_single")
-    public Response<OutputInfo> qc_test_single(String cid, String caseNumber, String hospitalId) {
+    public Response<OutputInfo> qc_test_single(String cid, String caseNumber, String hospitalId) throws Exception {
         Response response = new Response();
         if (StringUtils.isEmpty(hospitalId)) {
             response.setData("未填写医院流水号(hospitalId)......");

+ 3 - 0
kernel/src/main/resources/application.yml

@@ -24,6 +24,9 @@ spring:
         max-wait: -1ms
         max-idle: 8
 
+qc:
+  hospital_id: 3
+
 CRF:
   url: http://192.168.2.234:3456/api/mr_info_ex/entity_predict
 

+ 84 - 0
kernel/src/main/resources/cache/1/concept_clinic_bodypart_properties.dict

@@ -0,0 +1,84 @@
+sjwPlFuzwYtdGy/Xru8l0w==
+sjwPlFuzwYuOwjk+wlafMb496h/s94Lp
+GaEOqMDeIR/A3JPjaU/OYQ==
+KUZ84E/l6BtIxYdpVp2d2udw4JKVz6fxOAPHyqzXUMY=
+ClvKDL868eyBa0I3oBBXTiLG5UIUjigm
+cpVuhYfN0VLL15lmAanTHLudBba0KZdGSmARnfpRl/s=
+tgLfZiBNXVfe46uqWooJfQ==
++elokrz+5ZZ4nftSAgjXeP9VC/9mRBPm
+u18AKL/dfo8=
+FXYCcRyAS3o=
+1y8RNUzpzDDA3JPjaU/OYQ==
+GDAzhKkwugqOwjk+wlafMb496h/s94Lp
+vVsbjXwCHtKFIWuMj59JFg==
+S00FGSMpzFYRJHHOrCiJIw==
+LQ4RQ5c6TvEfVJH7s8MZNQ==
+KkqtLy22gBtRq6Y4vkNXyQ==
+FpNKk6eB+A78k09Y7waUfQ==
+55LO8f+DGuqsZzaaPHDG7A==
+anCWsr9KEAcfVJH7s8MZNQ==
+Ms4itbwo4woHjnX6dZF4Ew==
+eE2lKBuqkGwbZW204O8pbL496h/s94Lp
+KPTiLOQlvfcHjnX6dZF4Ew==
+EHYxrOGlbsJINCuQrfA+Qw==
+IoIoNIGjGAkfVJH7s8MZNQ==
+TkKCqeWSukdcNzQgT7Qg/y/95Ux1UGf/
+5sS2G/r6ssUfVJH7s8MZNQ==
+Fz6WuGDyOlM=
+6BJE0DCYV4PN7oAmfhVFQqHIcEkBIHl+SmARnfpRl/s=
+ClvKDL868ewfVJH7s8MZNQ==
+IoIoNIGjGAmt+3F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
+1boew8BvzsDzIpTnzy5Qnw==
+/CIzubCbNzzkzFf+CBlT64JiFWxfW6DV
+teXiWF5i953EeSAoaVSW+wBBqlZ1ciHqSmARnfpRl/s=
+CTNjqF5g7EIfVJH7s8MZNQ==
+OOQuqjL/h5M16D9aZjbrRw==
+ZfWBQ/To1p1p84i3DCFu/g==
+Q449MTqnm/c=
+xmHl5DY7FyM=
+hV3gMCbT8x+fXEA0j/uq7Q==

File diff suppressed because it is too large
+ 49448 - 0
kernel/src/main/resources/cache/1/concept_diag_properties.dict


File diff suppressed because it is too large
+ 49448 - 0
kernel/src/main/resources/cache/1/hospital_diag_info.dict


File diff suppressed because it is too large
+ 1443 - 0
kernel/src/main/resources/cache/1/hospital_doctor_info.dict


File diff suppressed because it is too large
+ 2402 - 2402
kernel/src/main/resources/cache/3/hospital_doctor_info.dict


+ 13 - 0
public/src/main/java/com/lantone/qc/pub/exception/AIException.java

@@ -0,0 +1,13 @@
+package com.lantone.qc.pub.exception;
+
+/**
+ * @ClassName : AIException
+ * @Description : 算法类例外集中处理
+ * @Author : 楼辉荣
+ * @Date: 2020-04-28 13:43
+ */
+public class AIException extends Exception {
+    public AIException(String msg) {
+        super(msg);
+    }
+}

+ 13 - 0
public/src/main/java/com/lantone/qc/pub/exception/CatalogueException.java

@@ -0,0 +1,13 @@
+package com.lantone.qc.pub.exception;
+
+/**
+ * @ClassName : CatalogueException
+ * @Description : 条目执行例外
+ * @Author : 楼辉荣
+ * @Date: 2020-04-28 13:45
+ */
+public class CatalogueException extends Exception {
+    public CatalogueException(String msg) {
+        super(msg);
+    }
+}

+ 13 - 0
public/src/main/java/com/lantone/qc/pub/exception/TransException.java

@@ -0,0 +1,13 @@
+package com.lantone.qc.pub.exception;
+
+/**
+ * @ClassName : TransException
+ * @Description : 客户数据解析例外处理
+ * @Author : 楼辉荣
+ * @Date: 2020-04-28 14:02
+ */
+public class TransException extends Exception {
+    public TransException(String msg) {
+        super(msg);
+    }
+}