Browse Source

药品映射

zhaops 3 years ago
parent
commit
098f387d30

+ 30 - 26
cdssman-service/src/main/java/com/diagbot/facade/MappingConfigFacade.java

@@ -377,16 +377,25 @@ public class MappingConfigFacade extends MappingConfigServiceImpl {
             if (StringUtil.isBlank(item.getHisDetailName())) {
                 item.setHisDetailName("");
             }
+            item.setId(null);
+            item.setHospitalId(null);
         }
 
-        Map<String, List<MappingConfig>> hisMap = list.stream().collect(Collectors.groupingBy(MappingConfig::getHisName));
+        list = list.stream().distinct().collect(Collectors.toList());
+
+        Map<String, List<MappingConfig>> hisMap = list.stream()
+                .filter(i -> StringUtil.isNotBlank(i.getHisName()))
+                .collect(Collectors.groupingBy(MappingConfig::getHisName));
         for (Map.Entry<String, List<MappingConfig>> entry : hisMap.entrySet()) {
             Map<String, Map<Long, List<Long>>> subMap = new HashMap<>();
             Map<String, List<MappingConfig>> detailMap = entry.getValue().stream()
                     .collect(Collectors.groupingBy(MappingConfig::getHisDetailName));
             for (Map.Entry<String, List<MappingConfig>> subEntry : detailMap.entrySet()) {
-                subMap.put(subEntry.getKey(), subEntry.getValue().stream().collect(Collectors.groupingBy(MappingConfig::getConceptId,
-                        Collectors.mapping(MappingConfig::getFormConceptId, Collectors.toList()))));
+                subMap.put(subEntry.getKey(),
+                        subEntry.getValue()
+                                .stream()
+                                .collect(Collectors.groupingBy(MappingConfig::getConceptId,
+                                        Collectors.mapping(MappingConfig::getFormConceptId, Collectors.toList()))));
             }
             retMap.put(entry.getKey(), subMap);
         }
@@ -433,37 +442,32 @@ public class MappingConfigFacade extends MappingConfigServiceImpl {
         RespDTOUtil.respNGDealCover(respDTO, "标准术语校验失败");
         List<IndexBatchDTO> indexList = respDTO.data;
         if (ListUtil.isNotEmpty(indexList)) {
-            Map<Long, List<IndexBatchDTO>> indexMap
-                    = indexList.stream().collect(Collectors.groupingBy(IndexBatchDTO::getId));
+            Map<Long, String> idNameMap
+                    = indexList.stream().collect(Collectors.toMap(IndexBatchDTO::getId, IndexBatchDTO::getName));
             for (Map.Entry<String, Map<String, Map<Long, List<Long>>>> entry : idMap.entrySet()) {
                 Map<String, Map<String, List<String>>> subMap = new HashMap<>();
                 for (Map.Entry<String, Map<Long, List<Long>>> subEntry : entry.getValue().entrySet()) {
                     Map<String, List<String>> thirdMap = new HashMap<>();
-                    List<String> uniqueNames = Lists.newArrayList();
-                    List<String> forms = Lists.newArrayList();
-                    for (Long conceptId : subEntry.getValue().keySet()) {
-                        uniqueNames.addAll(indexMap.get(conceptId).stream().map(IndexBatchDTO::getName).collect(Collectors.toList()));
-                    }
-                    List<Long> formConceptIds = subEntry.getValue().values()
-                            .stream()
-                            .flatMap(Collection::stream)
-                            .distinct()
-                            .collect(Collectors.toList());
-                    for (Long formConceptId : formConceptIds) {
-                        if (formConceptId == null) {
-                            forms.add("");
-                        } else {
-                            forms.addAll(indexMap.get(formConceptId).stream().map(IndexBatchDTO::getName).collect(Collectors.toList()));
+                    for (Map.Entry<Long, List<Long>> thirdEntry : subEntry.getValue().entrySet()) {
+                        List<Long> formConceptIds = thirdEntry.getValue();
+                        List<String> forms = Lists.newArrayList();
+                        if (ListUtil.isNotEmpty(formConceptIds)) {
+                            for (Long formConceptId : formConceptIds) {
+                                if (formConceptId == null) {
+                                    forms.add("");
+                                } else {
+                                    forms.add(idNameMap.get(formConceptId));
+                                }
+                            }
+                            forms = forms.stream().distinct().collect(Collectors.toList());
+                            thirdMap.put(idNameMap.get(thirdEntry.getKey()), forms);
                         }
                     }
-                    forms = forms.stream().distinct().collect(Collectors.toList());
-                    for (String uniqueName : uniqueNames) {
-                        thirdMap.put(uniqueName, forms);
-                    }
-
                     subMap.put(subEntry.getKey(), thirdMap);
                 }
-                retMap.put(entry.getKey(), subMap);
+                if (subMap != null && subMap.size() > 0) {
+                    retMap.put(entry.getKey(), subMap);
+                }
             }
         }
         return retMap;