瀏覽代碼

正推代码优化

kongwz 4 年之前
父節點
當前提交
9fa0dfa1cf
共有 1 個文件被更改,包括 39 次插入15 次删除
  1. 39 15
      src/main/java/com/diagbot/facade/NeoFacade.java

+ 39 - 15
src/main/java/com/diagbot/facade/NeoFacade.java

@@ -20,6 +20,7 @@ import com.diagbot.vo.*;
 import com.diagbot.vo.neoPushEntity.ChiefPushVo;
 import com.diagbot.vo.neoPushEntity.Diag;
 import com.diagbot.vo.neoPushEntity.PresentPushVo;
+import com.google.common.collect.Lists;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Qualifier;
@@ -178,7 +179,7 @@ public class NeoFacade {
      */
     public List<NeoPushDTO> getPush(NeoPushVO pushVO) {
         List<NeoPushDTO> neoPushDTOS = new ArrayList<>();
-
+        List<String> allDis = Lists.newArrayList();
         // 如果没有诊断名称,则通过其它信息推送诊断
         ChiefPushVo chiefPushVo = pushVO.getChiefPushVo();
         PresentPushVo presentPushVo = pushVO.getPresentPushVo();
@@ -197,17 +198,36 @@ public class NeoFacade {
         }
         symptoms = Stream.of(symptom_chief,symptom_present).flatMap(Collection::stream).distinct().collect(Collectors.toList());
         //症状推疾病
-        getDisBySymptom(symptoms);
+        List<String> allDis_bySymptom = getDisBySymptom(symptoms);
+        allDis.addAll(allDis_bySymptom);
+        //体征推出的疾病
+        //化验推出的疾病辅检
+        //辅检推出的疾病
 
+        Map<String, Long> disCountSortMap = disCountSort(allDis);
+//      String dis_first = dis_count.entrySet().stream().map(x -> x.getKey()).collect(Collectors.toList()).get(0);
 
         return neoPushDTOS;
     }
 
-    public void getDisBySymptom(List<String> symptoms){
+    public List<String> getDisBySymptom(List<String> symptoms){
         List<String> symptomCache = getSymptomCache();
         //取交集
         symptoms.retainAll(symptomCache);
-        List<String> allDis = new ArrayList<>();
+        List<String> allDis_bySymptom = pushDis(symptomNameRepository, symptoms);
+        return allDis_bySymptom;
+        }
+
+
+
+    /**
+     * 症状、体征、化验、辅检等其他推送疾病
+     * @param symptomNameRepository
+     * @param symptoms
+     * @return
+     */
+    public List<String> pushDis(SymptomNameRepository symptomNameRepository,List<String> symptoms){
+        List<String> allDis = Lists.newArrayList();
         if(ListUtil.isNotEmpty(symptoms)){
             symptoms.forEach(x ->{
                 List<Symptom> byNameIs = symptomNameRepository.findByNameIs(x);
@@ -219,28 +239,32 @@ public class NeoFacade {
                 }
             });
         }
+        return allDis;
+    }
 
+    /**
+     * 推送的疾病计数排序
+     * @param allDis
+     * @return
+     */
+    public Map<String, Long> disCountSort(List<String> allDis) {
         Map<String, Long> dis_count = allDis.stream().collect(
+
                 Collectors.groupingBy(Function.identity(), Collectors.counting())
         );
-        if(dis_count != null && dis_count.size() > 0){
-            dis_count = dis_count.entrySet().stream().sorted((o1,o2)->o2.getValue().compareTo(o1.getValue()))
+        if (dis_count != null && dis_count.size() > 0) {
+            dis_count = dis_count.entrySet().stream().sorted((o1, o2) -> o2.getValue().compareTo(o1.getValue()))
                     .map(entry -> {
                         Map<String, Long> result = new LinkedHashMap();
-                        result.put(entry.getKey(),entry.getValue());
+                        result.put(entry.getKey(), entry.getValue());
                         return result;
-                    }).reduce((map1,map2) ->{
-                        map2.entrySet().forEach(entry ->map1.put(entry.getKey(),entry.getValue()));
+                    }).reduce((map1, map2) -> {
+                        map2.entrySet().forEach(entry -> map1.put(entry.getKey(), entry.getValue()));
                         return map1;
                     }).get();
-            System.out.println();
-
-//            String dis_first = dis_count.entrySet().stream().map(x -> x.getKey()).collect(Collectors.toList()).get(0);
 
         }
-
-
-
+        return dis_count;
     }
 
     /**