Browse Source

同义词转换bug处理

zhoutg 4 years ago
parent
commit
cfb9caba1c
1 changed files with 37 additions and 32 deletions
  1. 37 32
      src/main/java/com/diagbot/facade/NeoFacade.java

+ 37 - 32
src/main/java/com/diagbot/facade/NeoFacade.java

@@ -820,14 +820,14 @@ public class NeoFacade {
             throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "标准词转换【服务器】挂了!" + e.getMessage());
         }
         Map<String, Map<String, StandConvertCrfDTO>> crfMap = standConvertCrfBatchDTO.getData();
-        getConvertMap(crfMap, StandConvertEnum.symptom.toString(), clinicalConList, map);
-        getConvertMap(crfMap, StandConvertEnum.operation.toString(), operationConList, map);
-        getConvertMap(crfMap, StandConvertEnum.drug.toString(), drugConList, map);
-        getConvertMap(crfMap, StandConvertEnum.vital.toString(), vitallConList, map);
-        getConvertMap(crfMap, StandConvertEnum.disease.toString(), diseaseConList, map);
-        getConvertMap(crfMap, StandConvertEnum.pacs.toString(), pacsConList, map);
-        getConvertMap(crfMap, StandConvertEnum.lis.toString(), lisConList, map);
-        getConvertMap(crfMap, StandConvertEnum.transfusion.toString(), transfusionConList, map);
+        getConvertMap(crfMap, StandConvertEnum.symptom.toString(), clinicalConList, standConvert.getClinicalList(), map);
+        getConvertMap(crfMap, StandConvertEnum.operation.toString(), operationConList, standConvert.getOperationList(), map);
+        getConvertMap(crfMap, StandConvertEnum.drug.toString(), drugConList, standConvert.getDrugList(), map);
+        getConvertMap(crfMap, StandConvertEnum.vital.toString(), vitallConList, standConvert.getVitalList(), map);
+        getConvertMap(crfMap, StandConvertEnum.disease.toString(), diseaseConList, standConvert.getDiaglList(), map);
+        getConvertMap(crfMap, StandConvertEnum.pacs.toString(), pacsConList, standConvert.getPacsList(), map);
+        getConvertMap(crfMap, StandConvertEnum.lis.toString(), lisConList, standConvert.getLisList(), map);
+        getConvertMap(crfMap, StandConvertEnum.transfusion.toString(), transfusionConList, standConvert.getTransfusionList(), map);
 
         return map;
     }
@@ -871,41 +871,46 @@ public class NeoFacade {
      * @param map
      */
     public void getConvertMap(Map<String, Map<String, StandConvertCrfDTO>> crfDTO, String type, List<String> convertList,
-                              Map<String, Map<String, String>> map) {
-        if (ListUtil.isEmpty(convertList)) {
-            return ;
-        }
-        Map<String, StandConvertCrfDTO> crfMap = crfDTO.get(type);
+                              List<String> originList, Map<String, Map<String, String>> map) {
         Map<String, String> typeMap = new LinkedHashMap<>();
 
-        for (String s : convertList) {
-            String lastS = s;
-            if (crfMap != null) {
-                StandConvertCrfDTO standConvertCrfDTO = crfMap.get(s);
-                if (standConvertCrfDTO != null) {
-                    List<Map<String, String>> list = standConvertCrfDTO.getStandard_words();
-                    if (ListUtil.isEmpty(list)) {
-                        redisUtil.updateValue(type + "Conv:" + s, s);
-                    } else {
-                        String rateStr = standConvertCrfDTO.getStandard_words().get(0).get("rate");
-                        if (StringUtil.isBlank(rateStr)) {
+        if (ListUtil.isNotEmpty(convertList)) {
+            Map<String, StandConvertCrfDTO> crfMap = crfDTO.get(type);
+            for (String s : convertList) {
+                String lastS = s;
+                if (crfMap != null) {
+                    StandConvertCrfDTO standConvertCrfDTO = crfMap.get(s);
+                    if (standConvertCrfDTO != null) {
+                        List<Map<String, String>> list = standConvertCrfDTO.getStandard_words();
+                        if (ListUtil.isEmpty(list)) {
                             redisUtil.updateValue(type + "Conv:" + s, s);
                         } else {
-                            BigDecimal rate = new BigDecimal(rateStr);
-                            int flag = rate.compareTo(new BigDecimal(standConvertRate));
-                            if (flag < 0) {
+                            String rateStr = standConvertCrfDTO.getStandard_words().get(0).get("rate");
+                            if (StringUtil.isBlank(rateStr)) {
                                 redisUtil.updateValue(type + "Conv:" + s, s);
                             } else {
-                                redisUtil.updateValue(type + "Conv:" + s, standConvertCrfDTO.getStandard_words().get(0).get("standard_word"));
-                                lastS = standConvertCrfDTO.getStandard_words().get(0).get("standard_word");
+                                BigDecimal rate = new BigDecimal(rateStr);
+                                int flag = rate.compareTo(new BigDecimal(standConvertRate));
+                                if (flag < 0) {
+                                    redisUtil.updateValue(type + "Conv:" + s, s);
+                                } else {
+                                    redisUtil.updateValue(type + "Conv:" + s, standConvertCrfDTO.getStandard_words().get(0).get("standard_word"));
+                                    lastS = standConvertCrfDTO.getStandard_words().get(0).get("standard_word");
+                                }
                             }
                         }
+                    } else {
+                        redisUtil.updateValue(type + "Conv:" + s, s);
                     }
-                } else {
-                    redisUtil.updateValue(type + "Conv:" + s, s);
                 }
+                typeMap.put(s, lastS);
+            }
+        }
+        // 将所有的词放入typeMap中
+        for (String s : originList) {
+            if (!typeMap.containsKey(s)) {
+                typeMap.put(s, s);
             }
-            typeMap.put(s, lastS);
         }
         map.put(type, typeMap);
     }