Browse Source

Merge remote-tracking branch 'origin/master'

MarkHuang 4 years ago
parent
commit
7bf6464832

+ 56 - 62
src/main/java/com/diagbot/facade/NeoFacade.java

@@ -28,6 +28,7 @@ import com.diagbot.repository.PACSNode;
 import com.diagbot.repository.PacsRepository;
 import com.diagbot.util.ListUtil;
 import com.diagbot.util.RedisUtil;
+import com.diagbot.util.StringUtil;
 import com.diagbot.vo.BillNeoVO;
 import com.diagbot.vo.PushNeoVO;
 import com.diagbot.vo.StandConvert;
@@ -304,97 +305,90 @@ public class NeoFacade {
 
     /**
      * 标准词转换
+     * 类型,疾病: disease,症状: symptom,手术和操作:operation,药品: drug,实验室检查:lis,辅助检查:pacs, 辅助检查:vital"
      *
      * @param standConvert
-     *
      * @return  Map<String, Map<String, String>> -->Map<类型, Map<原始词, 标准词>>
      */
     public Map<String, Map<String, String>> standConvertCrf(StandConvert standConvert) {
         Map<String, Map<String, String>> map = new LinkedHashMap<>();
 
         try {
-            Map<String, String> clinicalMap = new LinkedHashMap<>();
             List<String> clinicalList = standConvert.getClinicalList();
-            for (String s : clinicalList) {
-                StandConvertCrfVO standConvertCrfVO = new StandConvertCrfVO();
-                standConvertCrfVO.setWord_type("symptom");
-                standConvertCrfVO.setWord(s);
-                StandConvertCrfDTO standConvertCrfDTO = standConvertServiceClient.similarity(standConvertCrfVO);
-                if (ListUtil.isEmpty(standConvertCrfDTO.getStandard_words())) {
-                    clinicalMap.put(s, s);
-                } else {
-                    clinicalMap.put(s, standConvertCrfDTO.getStandard_words().get(0).get("standard_word"));
-                }
-
-            }
+            Map<String, String> clinicalMap = getStandConvertMap(clinicalList, "symptom");
             map.put(StandConvertEnum.clinical.getName(), clinicalMap);
 
-            Map<String, String> operationMap = new LinkedHashMap<>();
             List<String> operationList = standConvert.getOperationList();
-            for (String s : operationList) {
-                StandConvertCrfVO standConvertCrfVO = new StandConvertCrfVO();
-                standConvertCrfVO.setWord_type("operation");
-                standConvertCrfVO.setWord(s);
-                StandConvertCrfDTO standConvertCrfDTO = standConvertServiceClient.similarity(standConvertCrfVO);
-                if (ListUtil.isEmpty(standConvertCrfDTO.getStandard_words())) {
-                    operationMap.put(s, s);
-                } else {
-                    operationMap.put(s, standConvertCrfDTO.getStandard_words().get(0).get("standard_word"));
-                }
-
-            }
+            Map<String, String> operationMap = getStandConvertMap(operationList, "operation");
             map.put(StandConvertEnum.operation.getName(), operationMap);
 
-            Map<String, String> drugMap = new LinkedHashMap<>();
             List<String> drugList = standConvert.getDrugList();
-            for (String s : drugList) {
-                StandConvertCrfVO standConvertCrfVO = new StandConvertCrfVO();
-                standConvertCrfVO.setWord_type("drug");
-                standConvertCrfVO.setWord(s);
-                StandConvertCrfDTO standConvertCrfDTO = standConvertServiceClient.similarity(standConvertCrfVO);
-                if (ListUtil.isEmpty(standConvertCrfDTO.getStandard_words())) {
-                    drugMap.put(s, s);
-                } else {
-                    drugMap.put(s, standConvertCrfDTO.getStandard_words().get(0).get("standard_word"));
-                }
-
-            }
+            Map<String, String> drugMap = getStandConvertMap(drugList, "drug");
             map.put(StandConvertEnum.drug.getName(), drugMap);
 
-            Map<String, String> vitalMap = new LinkedHashMap<>();
             List<String> vitalList = standConvert.getDrugList();
-            for (String s : vitalList) {
-                StandConvertCrfVO standConvertCrfVO = new StandConvertCrfVO();
-                standConvertCrfVO.setWord_type("vital");
-                standConvertCrfVO.setWord(s);
-                StandConvertCrfDTO standConvertCrfDTO = standConvertServiceClient.similarity(standConvertCrfVO);
-                if (ListUtil.isEmpty(standConvertCrfDTO.getStandard_words())) {
-                    vitalMap.put(s, s);
-                } else {
-                    vitalMap.put(s, standConvertCrfDTO.getStandard_words().get(0).get("standard_word"));
-                }
-
-            }
+            Map<String, String> vitalMap = getStandConvertMap(vitalList, "vital");
             map.put(StandConvertEnum.vital.getName(), vitalMap);
 
-            Map<String, String> diseaseMap = new LinkedHashMap<>();
             List<String> diseaseList = standConvert.getDiaglList();
-            for (String s : diseaseList) {
+            Map<String, String> diseaseMap = getStandConvertMap(diseaseList, "disease");
+            map.put(StandConvertEnum.disease.getName(), diseaseMap);
+
+        } catch (Exception e) {
+            throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "标准词转换服务出错!【找毕金良】" + e.getMessage());
+        }
+        return map;
+    }
+
+
+    /**
+     * 标准词转换
+     *
+     * @param list 原词
+     * @param type 类型
+     * @return
+     */
+    public Map<String, String> getStandConvertMap(List<String> list, String type) {
+        // long l1 = System.currentTimeMillis();
+        Map<String, String> typeMap = redisUtil.getValueByType(type);
+        Map<String, String> standConvertMap = new LinkedHashMap<>();
+        List<String> notList = new ArrayList<>();
+
+        if (typeMap != null) {
+            for (String s : list) {
+                if (StringUtil.isBlank(typeMap.get(s))) {
+                    notList.add(s);
+                }
+            }
+        } else {
+            typeMap = new LinkedHashMap<>();
+            notList = list;
+        }
+
+        if (ListUtil.isNotEmpty(notList)) {
+            for (String s : notList) {
                 StandConvertCrfVO standConvertCrfVO = new StandConvertCrfVO();
-                standConvertCrfVO.setWord_type("disease");
+                standConvertCrfVO.setWord_type(type);
                 standConvertCrfVO.setWord(s);
                 StandConvertCrfDTO standConvertCrfDTO = standConvertServiceClient.similarity(standConvertCrfVO);
                 if (ListUtil.isEmpty(standConvertCrfDTO.getStandard_words())) {
-                    diseaseMap.put(s, s);
+                    standConvertMap.put(s, s);
                 } else {
-                    diseaseMap.put(s, standConvertCrfDTO.getStandard_words().get(0).get("standard_word"));
+                    standConvertMap.put(s, standConvertCrfDTO.getStandard_words().get(0).get("standard_word"));
                 }
             }
-            map.put(StandConvertEnum.disease.getName(), diseaseMap);
 
-        } catch (Exception e) {
-            throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "标准词转换服务出错!【找毕金良】" + e.getMessage());
+            if (standConvertMap != null && !standConvertMap.isEmpty()) {
+                typeMap.putAll(standConvertMap);
+            }
+            // long l2 = System.currentTimeMillis();
+            // System.out.println("存放前" + type + ":" + (l2 - l1) / 1000.0);
+            redisUtil.updateValueByType(typeMap, type);
+            // long l3 = System.currentTimeMillis();
+            // System.out.println("存放" + type + ":" + (l3 - l2) / 1000.0);
         }
-        return map;
+        // long l4 = System.currentTimeMillis();
+        // System.out.println("共耗时:" + type + ":" + (l4 - l1) / 1000.0);
+        return typeMap;
     }
 }

+ 12 - 0
src/main/java/com/diagbot/util/RedisUtil.java

@@ -41,6 +41,18 @@ public class RedisUtil {
     }
 
 
+    /**
+     * 获取指定类型的数据
+     *
+     * @param type
+     * @return
+     */
+    public Map<String, String> getValueByType(String type) {
+        Map<String, String> map = (Map<String, String>)redisTemplate.opsForValue().get(type);
+        return map;
+    }
+
+
     /**
      * 更新指定类型下的数据
      *