zhaops 5 years ago
parent
commit
9bee4a3c3b

+ 8 - 1
bi-service/src/main/java/com/diagbot/client/KnowledgemanServiceClient.java

@@ -1,7 +1,13 @@
 package com.diagbot.client;
 
 import com.diagbot.client.hystrix.KnowledgemanServiceHystrix;
+import com.diagbot.dto.BIItemDTO;
+import com.diagbot.dto.PrecCountDTO;
+import com.diagbot.dto.RespDTO;
 import org.springframework.cloud.openfeign.FeignClient;
+import org.springframework.web.bind.annotation.PostMapping;
+
+import java.util.List;
 
 /**
  * @Description: 调用知识库后台
@@ -10,5 +16,6 @@ import org.springframework.cloud.openfeign.FeignClient;
  */
 @FeignClient(value = "knowledgeman-service", fallback = KnowledgemanServiceHystrix.class)
 public interface KnowledgemanServiceClient {
-
+    @PostMapping("/conceptDetail/conceptDetailBI")
+    RespDTO<List<BIItemDTO>> conceptDetailBI();
 }

+ 2 - 2
bi-service/src/main/java/com/diagbot/client/PrecmanServiceClient.java

@@ -1,7 +1,7 @@
 package com.diagbot.client;
 
 import com.diagbot.client.hystrix.PrecmanServiceHystrix;
-import com.diagbot.dto.PrecCountDTO;
+import com.diagbot.dto.BIItemDTO;
 import com.diagbot.dto.RespDTO;
 import org.springframework.cloud.openfeign.FeignClient;
 import org.springframework.web.bind.annotation.PostMapping;
@@ -15,5 +15,5 @@ import org.springframework.web.bind.annotation.PostMapping;
 public interface PrecmanServiceClient {
 
     @PostMapping("/count_prec/getCount")
-    RespDTO<PrecCountDTO> getCount();
+    RespDTO<BIItemDTO> getCount();
 }

+ 10 - 1
bi-service/src/main/java/com/diagbot/client/hystrix/KnowledgemanServiceHystrix.java

@@ -1,9 +1,14 @@
 package com.diagbot.client.hystrix;
 
 import com.diagbot.client.KnowledgemanServiceClient;
+import com.diagbot.dto.BIItemDTO;
+import com.diagbot.dto.PrecCountDTO;
+import com.diagbot.dto.RespDTO;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.stereotype.Component;
 
+import java.util.List;
+
 /**
  * @Description: 调用知识库后台
  * @author: gaodm
@@ -12,5 +17,9 @@ import org.springframework.stereotype.Component;
 @Component
 @Slf4j
 public class KnowledgemanServiceHystrix implements KnowledgemanServiceClient {
-
+    @Override
+    public RespDTO<List<BIItemDTO>> conceptDetailBI() {
+        log.error("【hystrix】调用{}异常", "conceptDetailBI");
+        return null;
+    }
 }

+ 2 - 2
bi-service/src/main/java/com/diagbot/client/hystrix/PrecmanServiceHystrix.java

@@ -1,7 +1,7 @@
 package com.diagbot.client.hystrix;
 
 import com.diagbot.client.PrecmanServiceClient;
-import com.diagbot.dto.PrecCountDTO;
+import com.diagbot.dto.BIItemDTO;
 import com.diagbot.dto.RespDTO;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.stereotype.Component;
@@ -16,7 +16,7 @@ import org.springframework.stereotype.Component;
 public class PrecmanServiceHystrix implements PrecmanServiceClient {
 
     @Override
-    public RespDTO<PrecCountDTO> getCount() {
+    public RespDTO<BIItemDTO> getCount() {
         log.error("【hystrix】调用{}异常", "getCount");
         return null;
     }

+ 25 - 0
bi-service/src/main/java/com/diagbot/dto/BIDTO.java

@@ -0,0 +1,25 @@
+package com.diagbot.dto;
+
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * @Description:
+ * @Author:zhaops
+ * @time: 2019/10/15 16:30
+ */
+@Getter
+@Setter
+public class BIDTO {
+    private BIModuleDTO diagnose;
+    private BIModuleDTO symptom;
+    private BIModuleDTO vital;
+    private BIModuleDTO lis;
+    private BIModuleDTO pacs;
+    private BIModuleDTO drug;
+    private BIModuleDTO operation;
+    private BIModuleDTO gauge;
+    private BIModuleDTO prec;
+    private BIModuleDTO treat;
+    private BIModuleDTO conceptDetail;
+}

+ 17 - 0
bi-service/src/main/java/com/diagbot/dto/BIItemDTO.java

@@ -0,0 +1,17 @@
+package com.diagbot.dto;
+
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * @Description:
+ * @Author:zhaops
+ * @time: 2019/10/15 15:32
+ */
+@Getter
+@Setter
+public class BIItemDTO {
+    private String moduleName;
+    private String itemName;
+    private Integer count;
+}

+ 18 - 0
bi-service/src/main/java/com/diagbot/dto/BIModuleDTO.java

@@ -0,0 +1,18 @@
+package com.diagbot.dto;
+
+import lombok.Getter;
+import lombok.Setter;
+
+import java.util.List;
+
+/**
+ * @Description:
+ * @Author:zhaops
+ * @time: 2019/10/15 16:30
+ */
+@Getter
+@Setter
+public class BIModuleDTO {
+    private String moduleName;
+    private List<BIItemDTO> items;
+}

+ 58 - 0
bi-service/src/main/java/com/diagbot/enums/StatisticsTypeEnum.java

@@ -0,0 +1,58 @@
+package com.diagbot.enums;
+
+import com.diagbot.core.KeyedNamed;
+import lombok.Setter;
+
+/**
+ * @Description:
+ * @Author:zhaops
+ * @time: 2019/10/15 17:00
+ */
+public enum StatisticsTypeEnum implements KeyedNamed {
+    DIAGNOSE(1, "疾病"),
+    SYMPTOM(2, "症状"),
+    VITAL(3, "体征"),
+    LIS(4, "化验"),
+    PACS(5, "辅检"),
+    DRUG(6, "药品"),
+    OPERATION(7, "手术"),
+    GAUGE(8, "量表"),
+    PREC(9, "智能预问诊"),
+    TREAT(10, "治疗"),
+    CONCEPT_DETAIL(11, "静态知识");
+
+    @Setter
+    private Integer key;
+
+    @Setter
+    private String name;
+
+    StatisticsTypeEnum(Integer key, String name) {
+        this.key = key;
+        this.name = name;
+    }
+
+    public static StatisticsTypeEnum getEnum(Integer key) {
+        for (StatisticsTypeEnum item : StatisticsTypeEnum.values()) {
+            if (item.key == key) {
+                return item;
+            }
+        }
+        return null;
+    }
+
+    public static String getName(Integer key) {
+        StatisticsTypeEnum item = getEnum(key);
+        return item != null ? item.name : null;
+    }
+
+    @Override
+    public int getKey() {
+        return key;
+    }
+
+    @Override
+    public String getName() {
+        return name;
+    }
+}

+ 74 - 0
bi-service/src/main/java/com/diagbot/facade/StatisticsFacade.java

@@ -0,0 +1,74 @@
+package com.diagbot.facade;
+
+import com.diagbot.client.KnowledgemanServiceClient;
+import com.diagbot.client.PrecmanServiceClient;
+import com.diagbot.dto.BIDTO;
+import com.diagbot.dto.BIItemDTO;
+import com.diagbot.dto.BIModuleDTO;
+import com.diagbot.dto.RespDTO;
+import com.diagbot.enums.StatisticsTypeEnum;
+import com.diagbot.util.EntityUtil;
+import com.diagbot.util.RespDTOUtil;
+import com.google.common.collect.Lists;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @Description:
+ * @Author:zhaops
+ * @time: 2019/10/15 16:23
+ */
+@Component
+public class StatisticsFacade {
+    @Autowired
+    private KnowledgemanServiceClient knowledgemanServiceClient;
+    @Autowired
+    private PrecmanServiceClient precmanServiceClient;
+
+    public BIDTO count() {
+        BIDTO bidto = new BIDTO();
+        List<BIItemDTO> biItemDTOList = Lists.newLinkedList();
+        //静态知识统计
+        RespDTO<List<BIItemDTO>> cdResp = knowledgemanServiceClient.conceptDetailBI();
+        if (RespDTOUtil.respIsOK(cdResp)) {
+            biItemDTOList.addAll(cdResp.data);
+        }
+        //预问诊统计
+        RespDTO<BIItemDTO> precResp = precmanServiceClient.getCount();
+        if (RespDTOUtil.respIsOK(precResp)) {
+            biItemDTOList.add(precResp.data);
+        }
+
+        //术语统计
+
+        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()));
+
+        return bidto;
+    }
+
+    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 {
+            return null;
+        }
+    }
+
+}

+ 32 - 0
bi-service/src/main/java/com/diagbot/web/StatisticsController.java

@@ -0,0 +1,32 @@
+package com.diagbot.web;
+
+import com.diagbot.annotation.SysLogger;
+import com.diagbot.dto.BIDTO;
+import com.diagbot.dto.RespDTO;
+import com.diagbot.facade.StatisticsFacade;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * @Description:
+ * @Author:zhaops
+ * @time: 2019/10/15 17:33
+ */
+@RestController
+@RequestMapping("/statistics")
+@SuppressWarnings("unchecked")
+@Api(value = "BI-统计相关API", tags = { "BI-统计相关API" })
+public class StatisticsController {
+    StatisticsFacade statisticsFacade;
+
+    @ApiOperation(value = "数据统计[by:zhaops]", notes = "")
+    @PostMapping("/count")
+    @SysLogger("count")
+    public RespDTO<BIDTO> count() {
+        BIDTO data = statisticsFacade.count();
+        return RespDTO.onSuc(data);
+    }
+}

+ 17 - 0
precman-service/src/main/java/com/diagbot/dto/BIItemDTO.java

@@ -0,0 +1,17 @@
+package com.diagbot.dto;
+
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * @Description:
+ * @Author:zhaops
+ * @time: 2019/10/15 15:32
+ */
+@Getter
+@Setter
+public class BIItemDTO {
+    private String moduleName;
+    private String itemName;
+    private Integer count;
+}

+ 7 - 5
precman-service/src/main/java/com/diagbot/facade/CountFacade.java

@@ -1,7 +1,7 @@
 package com.diagbot.facade;
 
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.diagbot.dto.PrecCountDTO;
+import com.diagbot.dto.BIItemDTO;
 import com.diagbot.entity.QuestionInfo;
 import com.diagbot.enums.IsDeleteEnum;
 import com.diagbot.enums.QuestionTypeEnum;
@@ -25,14 +25,16 @@ public class CountFacade {
      *
      * @return
      */
-    public PrecCountDTO getCount() {
-        PrecCountDTO precCountDTO = new PrecCountDTO();
+    public BIItemDTO getCount() {
+        BIItemDTO biItemDTO = new BIItemDTO();
         int symptomNum = questionFacade.count(new QueryWrapper<QuestionInfo>()
                 .eq("is_deleted", IsDeleteEnum.N.getKey())
                 .eq("type", QuestionTypeEnum.Symptom.getKey())
                 .eq("tag_type", TagTypeEnum.T6.getKey())
         );
-        precCountDTO.setSymptomNum(symptomNum);
-        return precCountDTO;
+        biItemDTO.setModuleName("智能预问诊");
+        biItemDTO.setItemName("预问诊症状条目");
+        biItemDTO.setCount(symptomNum);
+        return biItemDTO;
     }
 }

+ 3 - 3
precman-service/src/main/java/com/diagbot/web/CountController.java

@@ -2,7 +2,7 @@ package com.diagbot.web;
 
 
 import com.diagbot.annotation.SysLogger;
-import com.diagbot.dto.PrecCountDTO;
+import com.diagbot.dto.BIItemDTO;
 import com.diagbot.dto.RespDTO;
 import com.diagbot.facade.CountFacade;
 import io.swagger.annotations.Api;
@@ -34,8 +34,8 @@ public class CountController {
             notes = "")
     @PostMapping("/getCount")
     @SysLogger("getCount")
-    public RespDTO<PrecCountDTO> getCount() {
-        PrecCountDTO data = countFacade.getCount();
+    public RespDTO<BIItemDTO> getCount() {
+        BIItemDTO data = countFacade.getCount();
         return RespDTO.onSuc(data);
     }
 }