|
@@ -0,0 +1,243 @@
|
|
|
|
+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;
|
|
|
|
+
|
|
|
|
+import java.util.LinkedHashMap;
|
|
|
|
+import java.util.List;
|
|
|
|
+import java.util.Map;
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * @Description:
|
|
|
|
+ * @Author:zhaops
|
|
|
|
+ * @time: 2019/10/15 16:23
|
|
|
|
+ */
|
|
|
|
+@Component
|
|
|
|
+public class StatisticsFacade {
|
|
|
|
+ @Autowired
|
|
|
|
+ DataBeanAggregateQueryFacade dataBeanAggregateQueryFacade;
|
|
|
|
+
|
|
|
|
+ public BIDTO count() {
|
|
|
|
+ BIDTO bidto = new BIDTO();
|
|
|
|
+ List<BIItemDTO> biItemDTOList = ListUtil.newArrayList();
|
|
|
|
+ try {
|
|
|
|
+ biItemDTOList
|
|
|
|
+ = dataBeanAggregateQueryFacade.get("biAll", null, List.class);
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ throw new CommonException(CommonErrorCode.SERVER_IS_ERROR);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ Map<String, List<BIItemDTO>> map = EntityUtil.makeEntityListMap(biItemDTOList, "moduleName");
|
|
|
|
+ bidto.setDiagnose(getBIModuleDTO(map, StatisticsTypeEnum.DIAGNOSE.getKey()));
|
|
|
|
+ bidto.setSymptom(getBIModuleDTO(map, StatisticsTypeEnum.SYMPTOM.getKey()));
|
|
|
|
+ bidto.setVital(getBIModuleDTO(map, StatisticsTypeEnum.VITAL.getKey()));
|
|
|
|
+ bidto.setLis(getBIModuleDTO(map, StatisticsTypeEnum.LIS.getKey()));
|
|
|
|
+ bidto.setPacs(getBIModuleDTO(map, StatisticsTypeEnum.PACS.getKey()));
|
|
|
|
+ bidto.setDrug(getBIModuleDTO(map, StatisticsTypeEnum.DRUG.getKey()));
|
|
|
|
+ bidto.setOperation(getBIModuleDTO(map, StatisticsTypeEnum.OPERATION.getKey()));
|
|
|
|
+ bidto.setGauge(getBIModuleDTO(map, StatisticsTypeEnum.GAUGE.getKey()));
|
|
|
|
+ bidto.setPrec(getBIModuleDTO(map, StatisticsTypeEnum.PREC.getKey()));
|
|
|
|
+ bidto.setTreat(getBIModuleDTO(map, StatisticsTypeEnum.TREAT.getKey()));
|
|
|
|
+ bidto.setConceptDetail(getBIModuleDTO(map, StatisticsTypeEnum.CONCEPT_DETAIL.getKey()));
|
|
|
|
+ bidto.setGmtOperate(DateUtil.now());
|
|
|
|
+
|
|
|
|
+ return bidto;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public BIModuleDTO getBIModuleDTO(Map<String, List<BIItemDTO>> map, Integer key) {
|
|
|
|
+ BIModuleDTO biModuleDTO = new BIModuleDTO();
|
|
|
|
+ List<BIItemDTO> queryItemList = Lists.newLinkedList();
|
|
|
|
+ Map<String, BIItemDTO> biItemMap = new LinkedHashMap<>();
|
|
|
|
+ if (map.get(StatisticsTypeEnum.getName(key)) != null) {
|
|
|
|
+ List<BIItemDTO> biItemDTOList = map.get(StatisticsTypeEnum.getName(key));
|
|
|
|
+ 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;
|
|
|
|
+ }
|
|
|
|
+}
|