Parcourir la source

BI数据统计结果排序

zhaops il y a 5 ans
Parent
commit
cc6e2e380d

+ 0 - 1
bi-service/src/main/java/com/diagbot/aggregate/PrecmanAgg.java

@@ -1,6 +1,5 @@
 package com.diagbot.aggregate;
 
-import com.diagbot.client.IcssmanServiceClient;
 import com.diagbot.client.PrecmanServiceClient;
 import com.diagbot.dto.BIItemDTO;
 import com.diagbot.dto.RespDTO;

+ 0 - 1
bi-service/src/main/java/com/diagbot/client/NeoServiceClient.java

@@ -2,7 +2,6 @@ package com.diagbot.client;
 
 import com.diagbot.client.hystrix.NeoServiceHystrix;
 import com.diagbot.dto.BIItemDTO;
-import com.diagbot.dto.RespDTO;
 import org.springframework.cloud.openfeign.FeignClient;
 import org.springframework.web.bind.annotation.PostMapping;
 

+ 64 - 0
bi-service/src/main/java/com/diagbot/enums/StatisticsDetailTypeEnum.java

@@ -0,0 +1,64 @@
+package com.diagbot.enums;
+
+import com.diagbot.core.KeyedNamed;
+import lombok.Setter;
+
+/**
+ * @Description:
+ * @Author:zhaops
+ * @time: 2019/10/22 10:23
+ */
+public enum StatisticsDetailTypeEnum implements KeyedNamed {
+    DiseaseCount(1, "疾病总数"),
+    NeoDiseaseCount(2, "图谱推送的疾病"),
+    NeoPediatricDiseaseCount(3, "图谱推送的儿科疾病"),
+    SymptomCount(4, "症状标准词"),
+    VitalResultCount(5, "体征结果"),
+    VitalIndexCount(6, "体征指标"),
+    LisPackageCount(7, "化验套餐"),
+    LisDetailCount(8, "化验细项"),
+    PacsItemCount(9, "辅检项目"),
+    DrugCount(10, "药品通用名"),
+    OperationCount(11, "手术项目"),
+    GaugeCount(12, "量表总数"),
+    PrecSymptomCount(13, "预问诊症状条目"),
+    TreatCount(14, "治疗数目"),
+    ConceptDetailCount(15, "静态知识总数"),
+    ConceptDetailDiseaseCount(16, "疾病"),
+    LisTableCount(17, "化验公表项");
+
+    @Setter
+    private int key;
+
+    @Setter
+    private String name;
+
+    StatisticsDetailTypeEnum(int key, String name) {
+        this.key = key;
+        this.name = name;
+    }
+
+    public static StatisticsDetailTypeEnum getEnum(int key) {
+        for (StatisticsDetailTypeEnum item : StatisticsDetailTypeEnum.values()) {
+            if (item.key == key) {
+                return item;
+            }
+        }
+        return null;
+    }
+
+    public static String getName(int key) {
+        StatisticsDetailTypeEnum item = getEnum(key);
+        return item != null ? item.name : null;
+    }
+
+    @Override
+    public int getKey() {
+        return key;
+    }
+
+    @Override
+    public String getName() {
+        return name;
+    }
+}

+ 181 - 6
bi-service/src/main/java/com/diagbot/facade/StatisticsFacade.java

@@ -3,12 +3,14 @@ package com.diagbot.facade;
 import com.diagbot.dto.BIDTO;
 import com.diagbot.dto.BIItemDTO;
 import com.diagbot.dto.BIModuleDTO;
+import com.diagbot.enums.StatisticsDetailTypeEnum;
 import com.diagbot.enums.StatisticsTypeEnum;
 import com.diagbot.exception.CommonErrorCode;
 import com.diagbot.exception.CommonException;
 import com.diagbot.util.DateUtil;
 import com.diagbot.util.EntityUtil;
 import com.diagbot.util.ListUtil;
+import com.google.common.collect.Lists;
 import io.github.lvyahui8.spring.aggregate.facade.DataBeanAggregateQueryFacade;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
@@ -54,14 +56,187 @@ public class StatisticsFacade {
     }
 
     public BIModuleDTO getBIModuleDTO(Map<String, List<BIItemDTO>> map, Integer key) {
-        if (map.get(StatisticsTypeEnum.getName(key)) != null) {
-            BIModuleDTO biModuleDTO = new BIModuleDTO();
-            biModuleDTO.setModuleName(StatisticsTypeEnum.getName(key));
-            biModuleDTO.setItems(map.get(StatisticsTypeEnum.getName(key)));
-            return biModuleDTO;
-        } else {
+        BIModuleDTO biModuleDTO = new BIModuleDTO();
+        if (map.get(StatisticsTypeEnum.getName(key)) == null) {
             return null;
         }
+        List<BIItemDTO> queryItemList = Lists.newLinkedList();
+        List<BIItemDTO> biItemDTOList = map.get(StatisticsTypeEnum.getName(key));
+        Map<String, BIItemDTO> biItemMap = EntityUtil.makeEntityMap(biItemDTOList, "itemName");
+        switch (StatisticsTypeEnum.getEnum(key)) {
+            case DIAGNOSE:
+                if (biItemMap.get(StatisticsDetailTypeEnum.getName(StatisticsDetailTypeEnum.DiseaseCount.getKey())) != null) {
+                    queryItemList.add(biItemMap.get(StatisticsDetailTypeEnum.getName(StatisticsDetailTypeEnum.DiseaseCount.getKey())));
+                } else {
+                    BIItemDTO biItemDTO = getItem(StatisticsTypeEnum.getName(StatisticsTypeEnum.DIAGNOSE.getKey()),
+                            StatisticsDetailTypeEnum.getName(StatisticsDetailTypeEnum.DiseaseCount.getKey()), 0);
+                    queryItemList.add(biItemDTO);
+                }
+                if (biItemMap.get(StatisticsDetailTypeEnum.getName(StatisticsDetailTypeEnum.NeoDiseaseCount.getKey())) != null) {
+                    queryItemList.add(biItemMap.get(StatisticsDetailTypeEnum.getName(StatisticsDetailTypeEnum.NeoDiseaseCount.getKey())));
+                } else {
+                    BIItemDTO biItemDTO = getItem(StatisticsTypeEnum.getName(StatisticsTypeEnum.DIAGNOSE.getKey()),
+                            StatisticsDetailTypeEnum.getName(StatisticsDetailTypeEnum.NeoDiseaseCount.getKey()), 0);
+                    queryItemList.add(biItemDTO);
+                }
+                if (biItemMap.get(StatisticsDetailTypeEnum.getName(StatisticsDetailTypeEnum.NeoPediatricDiseaseCount.getKey())) != null) {
+                    queryItemList.add(biItemMap.get(StatisticsDetailTypeEnum.getName(StatisticsDetailTypeEnum.NeoPediatricDiseaseCount.getKey())));
+                } else {
+                    BIItemDTO biItemDTO = getItem(StatisticsTypeEnum.getName(StatisticsTypeEnum.DIAGNOSE.getKey()),
+                            StatisticsDetailTypeEnum.getName(StatisticsDetailTypeEnum.NeoPediatricDiseaseCount.getKey()), 0);
+                    queryItemList.add(biItemDTO);
+                }
+                break;
+            case SYMPTOM:
+                if (biItemMap.get(StatisticsDetailTypeEnum.getName(StatisticsDetailTypeEnum.SymptomCount.getKey())) != null) {
+                    queryItemList.add(biItemMap.get(StatisticsDetailTypeEnum.getName(StatisticsDetailTypeEnum.SymptomCount.getKey())));
+                } else {
+                    BIItemDTO biItemDTO = getItem(StatisticsTypeEnum.getName(StatisticsTypeEnum.SYMPTOM.getKey()),
+                            StatisticsDetailTypeEnum.getName(StatisticsDetailTypeEnum.SymptomCount.getKey()), 0);
+                    queryItemList.add(biItemDTO);
+                }
+                break;
+            case VITAL:
+                if (biItemMap.get(StatisticsDetailTypeEnum.getName(StatisticsDetailTypeEnum.VitalResultCount.getKey())) != null) {
+                    queryItemList.add(biItemMap.get(StatisticsDetailTypeEnum.getName(StatisticsDetailTypeEnum.VitalResultCount.getKey())));
+                } else {
+                    BIItemDTO biItemDTO = getItem(StatisticsTypeEnum.getName(StatisticsTypeEnum.VITAL.getKey()),
+                            StatisticsDetailTypeEnum.getName(StatisticsDetailTypeEnum.VitalResultCount.getKey()), 0);
+                    queryItemList.add(biItemDTO);
+                }
+                if (biItemMap.get(StatisticsDetailTypeEnum.getName(StatisticsDetailTypeEnum.VitalIndexCount.getKey())) != null) {
+                    queryItemList.add(biItemMap.get(StatisticsDetailTypeEnum.getName(StatisticsDetailTypeEnum.VitalIndexCount.getKey())));
+                } else {
+                    BIItemDTO biItemDTO = getItem(StatisticsTypeEnum.getName(StatisticsTypeEnum.VITAL.getKey()),
+                            StatisticsDetailTypeEnum.getName(StatisticsDetailTypeEnum.VitalIndexCount.getKey()), 0);
+                    queryItemList.add(biItemDTO);
+                }
+                break;
+            case LIS:
+                if (biItemMap.get(StatisticsDetailTypeEnum.getName(StatisticsDetailTypeEnum.LisPackageCount.getKey())) != null) {
+                    queryItemList.add(biItemMap.get(StatisticsDetailTypeEnum.getName(StatisticsDetailTypeEnum.LisPackageCount.getKey())));
+                } else {
+                    BIItemDTO biItemDTO = getItem(StatisticsTypeEnum.getName(StatisticsTypeEnum.LIS.getKey()),
+                            StatisticsDetailTypeEnum.getName(StatisticsDetailTypeEnum.LisPackageCount.getKey()), 0);
+                    queryItemList.add(biItemDTO);
+                }
+                if (biItemMap.get(StatisticsDetailTypeEnum.getName(StatisticsDetailTypeEnum.LisDetailCount.getKey())) != null) {
+                    queryItemList.add(biItemMap.get(StatisticsDetailTypeEnum.getName(StatisticsDetailTypeEnum.LisDetailCount.getKey())));
+                } else {
+                    BIItemDTO biItemDTO = getItem(StatisticsTypeEnum.getName(StatisticsTypeEnum.LIS.getKey()),
+                            StatisticsDetailTypeEnum.getName(StatisticsDetailTypeEnum.LisDetailCount.getKey()), 0);
+                    queryItemList.add(biItemDTO);
+                }
+                break;
+            case PACS:
+                if (biItemMap.get(StatisticsDetailTypeEnum.getName(StatisticsDetailTypeEnum.PacsItemCount.getKey())) != null) {
+                    queryItemList.add(biItemMap.get(StatisticsDetailTypeEnum.getName(StatisticsDetailTypeEnum.PacsItemCount.getKey())));
+                } else {
+                    BIItemDTO biItemDTO = getItem(StatisticsTypeEnum.getName(StatisticsTypeEnum.PACS.getKey()),
+                            StatisticsDetailTypeEnum.getName(StatisticsDetailTypeEnum.PacsItemCount.getKey()), 0);
+                    queryItemList.add(biItemDTO);
+                }
+                break;
+            case DRUG:
+                if (biItemMap.get(StatisticsDetailTypeEnum.getName(StatisticsDetailTypeEnum.DrugCount.getKey())) != null) {
+                    queryItemList.add(biItemMap.get(StatisticsDetailTypeEnum.getName(StatisticsDetailTypeEnum.DrugCount.getKey())));
+                } else {
+                    BIItemDTO biItemDTO = getItem(StatisticsTypeEnum.getName(StatisticsTypeEnum.DRUG.getKey()),
+                            StatisticsDetailTypeEnum.getName(StatisticsDetailTypeEnum.DrugCount.getKey()), 0);
+                    queryItemList.add(biItemDTO);
+                }
+                break;
+            case OPERATION:
+                if (biItemMap.get(StatisticsDetailTypeEnum.getName(StatisticsDetailTypeEnum.OperationCount.getKey())) != null) {
+                    queryItemList.add(biItemMap.get(StatisticsDetailTypeEnum.getName(StatisticsDetailTypeEnum.OperationCount.getKey())));
+                } else {
+                    BIItemDTO biItemDTO = getItem(StatisticsTypeEnum.getName(StatisticsTypeEnum.OPERATION.getKey()),
+                            StatisticsDetailTypeEnum.getName(StatisticsDetailTypeEnum.OperationCount.getKey()), 0);
+                    queryItemList.add(biItemDTO);
+                }
+                break;
+            case GAUGE:
+                if (biItemMap.get(StatisticsDetailTypeEnum.getName(StatisticsDetailTypeEnum.GaugeCount.getKey())) != null) {
+                    queryItemList.add(biItemMap.get(StatisticsDetailTypeEnum.getName(StatisticsDetailTypeEnum.GaugeCount.getKey())));
+                } else {
+                    BIItemDTO biItemDTO = getItem(StatisticsTypeEnum.getName(StatisticsTypeEnum.GAUGE.getKey()),
+                            StatisticsDetailTypeEnum.getName(StatisticsDetailTypeEnum.GaugeCount.getKey()), 0);
+                    queryItemList.add(biItemDTO);
+                }
+                break;
+            case PREC:
+                if (biItemMap.get(StatisticsDetailTypeEnum.getName(StatisticsDetailTypeEnum.PrecSymptomCount.getKey())) != null) {
+                    queryItemList.add(biItemMap.get(StatisticsDetailTypeEnum.getName(StatisticsDetailTypeEnum.PrecSymptomCount.getKey())));
+                } else {
+                    BIItemDTO biItemDTO = getItem(StatisticsTypeEnum.getName(StatisticsTypeEnum.PREC.getKey()),
+                            StatisticsDetailTypeEnum.getName(StatisticsDetailTypeEnum.PrecSymptomCount.getKey()), 0);
+                    queryItemList.add(biItemDTO);
+                }
+                break;
+            case TREAT:
+                if (biItemMap.get(StatisticsDetailTypeEnum.getName(StatisticsDetailTypeEnum.TreatCount.getKey())) != null) {
+                    queryItemList.add(biItemMap.get(StatisticsDetailTypeEnum.getName(StatisticsDetailTypeEnum.TreatCount.getKey())));
+                } else {
+                    BIItemDTO biItemDTO = getItem(StatisticsTypeEnum.getName(StatisticsTypeEnum.TREAT.getKey()),
+                            StatisticsDetailTypeEnum.getName(StatisticsDetailTypeEnum.TreatCount.getKey()), 0);
+                    queryItemList.add(biItemDTO);
+                }
+                break;
+            case CONCEPT_DETAIL:
+                if (biItemMap.get(StatisticsDetailTypeEnum.getName(StatisticsDetailTypeEnum.ConceptDetailCount.getKey())) != null) {
+                    queryItemList.add(biItemMap.get(StatisticsDetailTypeEnum.getName(StatisticsDetailTypeEnum.ConceptDetailCount.getKey())));
+                } else {
+                    BIItemDTO biItemDTO = getItem(StatisticsTypeEnum.getName(StatisticsTypeEnum.CONCEPT_DETAIL.getKey()),
+                            StatisticsDetailTypeEnum.getName(StatisticsDetailTypeEnum.ConceptDetailCount.getKey()), 0);
+                    queryItemList.add(biItemDTO);
+                }
+                if (biItemMap.get(StatisticsDetailTypeEnum.getName(StatisticsDetailTypeEnum.ConceptDetailDiseaseCount.getKey())) != null) {
+                    queryItemList.add(biItemMap.get(StatisticsDetailTypeEnum.getName(StatisticsDetailTypeEnum.ConceptDetailDiseaseCount.getKey())));
+                } else {
+                    BIItemDTO biItemDTO = getItem(StatisticsTypeEnum.getName(StatisticsTypeEnum.CONCEPT_DETAIL.getKey()),
+                            StatisticsDetailTypeEnum.getName(StatisticsDetailTypeEnum.ConceptDetailDiseaseCount.getKey()), 0);
+                    queryItemList.add(biItemDTO);
+                }
+                if (biItemMap.get(StatisticsDetailTypeEnum.getName(StatisticsDetailTypeEnum.LisTableCount.getKey())) != null) {
+                    queryItemList.add(biItemMap.get(StatisticsDetailTypeEnum.getName(StatisticsDetailTypeEnum.LisTableCount.getKey())));
+                } else {
+                    BIItemDTO biItemDTO = getItem(StatisticsTypeEnum.getName(StatisticsTypeEnum.CONCEPT_DETAIL.getKey()),
+                            StatisticsDetailTypeEnum.getName(StatisticsDetailTypeEnum.LisTableCount.getKey()), 0);
+                    queryItemList.add(biItemDTO);
+                }
+                if (biItemMap.get(StatisticsDetailTypeEnum.getName(StatisticsDetailTypeEnum.PacsItemCount.getKey())) != null) {
+                    queryItemList.add(biItemMap.get(StatisticsDetailTypeEnum.getName(StatisticsDetailTypeEnum.PacsItemCount.getKey())));
+                } else {
+                    BIItemDTO biItemDTO = getItem(StatisticsTypeEnum.getName(StatisticsTypeEnum.CONCEPT_DETAIL.getKey()),
+                            StatisticsDetailTypeEnum.getName(StatisticsDetailTypeEnum.PacsItemCount.getKey()), 0);
+                    queryItemList.add(biItemDTO);
+                }
+                if (biItemMap.get(StatisticsDetailTypeEnum.getName(StatisticsDetailTypeEnum.DrugCount.getKey())) != null) {
+                    queryItemList.add(biItemMap.get(StatisticsDetailTypeEnum.getName(StatisticsDetailTypeEnum.DrugCount.getKey())));
+                } else {
+                    BIItemDTO biItemDTO = getItem(StatisticsTypeEnum.getName(StatisticsTypeEnum.CONCEPT_DETAIL.getKey()),
+                            StatisticsDetailTypeEnum.getName(StatisticsDetailTypeEnum.DrugCount.getKey()), 0);
+                    queryItemList.add(biItemDTO);
+                }
+                break;
+            default:
+                biModuleDTO = null;
+                break;
+
+        }
+        if (biModuleDTO != null) {
+            biModuleDTO.setModuleName(StatisticsTypeEnum.getName(key));
+            biModuleDTO.setItems(queryItemList);
+        }
+        return biModuleDTO;
     }
 
+
+    public BIItemDTO getItem(String moduleName,String itemName,Integer count) {
+        BIItemDTO biItemDTO = new BIItemDTO();
+        biItemDTO.setModuleName(moduleName);
+        biItemDTO.setItemName(itemName);
+        biItemDTO.setCount(count);
+        return biItemDTO;
+    }
 }