浏览代码

统计采用异步并发采取

gaodm 5 年之前
父节点
当前提交
2aed93bb48

+ 6 - 0
bi-service/pom.xml

@@ -154,6 +154,12 @@
             <artifactId>spring-cloud-starter-stream-rabbit</artifactId>
         </dependency>
 
+        <dependency>
+            <groupId>io.github.lvyahui8</groupId>
+            <artifactId>spring-boot-data-aggregator-starter</artifactId>
+            <version>1.1.0</version>
+        </dependency>
+
     </dependencies>
 
     <build>

+ 29 - 0
bi-service/src/main/java/com/diagbot/aggregate/BiAggregate.java

@@ -0,0 +1,29 @@
+package com.diagbot.aggregate;
+
+import com.diagbot.dto.BIItemDTO;
+import com.diagbot.util.ListUtil;
+import io.github.lvyahui8.spring.annotation.DataConsumer;
+import io.github.lvyahui8.spring.annotation.DataProvider;
+import org.springframework.stereotype.Component;
+
+import java.util.List;
+
+/**
+ * @Description:
+ * @author: gaodm
+ * @time: 2019/10/16 13:37
+ */
+@Component
+public class BiAggregate {
+    @DataProvider("biAll")
+    public List<BIItemDTO> biAll(
+            @DataConsumer("conceptDetailBI") List<BIItemDTO> biItemDTOListA,
+            @DataConsumer("queryLibTypeCou") List<BIItemDTO> biItemDTOListB,
+            @DataConsumer("precGetCount") List<BIItemDTO> biItemDTOListC){
+        List<BIItemDTO> res = ListUtil.newArrayList();
+        res.addAll(biItemDTOListA);
+        res.addAll(biItemDTOListB);
+        res.addAll(biItemDTOListC);
+        return res;
+    }
+}

+ 43 - 0
bi-service/src/main/java/com/diagbot/aggregate/KnowledgemanAgg.java

@@ -0,0 +1,43 @@
+package com.diagbot.aggregate;
+
+import com.diagbot.client.KnowledgemanServiceClient;
+import com.diagbot.dto.BIItemDTO;
+import com.diagbot.dto.RespDTO;
+import com.diagbot.util.RespDTOUtil;
+import com.google.common.collect.Lists;
+import io.github.lvyahui8.spring.annotation.DataProvider;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.util.List;
+
+/**
+ * @Description:
+ * @author: gaodm
+ * @time: 2019/10/16 13:29
+ */
+@Component
+public class KnowledgemanAgg {
+    @Autowired
+    private KnowledgemanServiceClient knowledgemanServiceClient;
+
+    @DataProvider("conceptDetailBI")
+    public List<BIItemDTO> conceptDetailBI(){
+        List<BIItemDTO> biItemDTOList = Lists.newLinkedList();
+        RespDTO<List<BIItemDTO>> cdResp = knowledgemanServiceClient.conceptDetailBI();
+        if (RespDTOUtil.respIsOK(cdResp)) {
+            biItemDTOList.addAll(cdResp.data);
+        }
+        return biItemDTOList;
+    }
+
+    @DataProvider("queryLibTypeCou")
+    public List<BIItemDTO> queryLibTypeCou(){
+        List<BIItemDTO> biItemDTOList = Lists.newLinkedList();
+        RespDTO<List<BIItemDTO>> conceptResp = knowledgemanServiceClient.queryLibTypeCou();
+        if (RespDTOUtil.respIsOK(conceptResp)) {
+            biItemDTOList.addAll(conceptResp.data);
+        }
+        return biItemDTOList;
+    }
+}

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

@@ -0,0 +1,33 @@
+package com.diagbot.aggregate;
+
+import com.diagbot.client.IcssmanServiceClient;
+import com.diagbot.client.PrecmanServiceClient;
+import com.diagbot.dto.BIItemDTO;
+import com.diagbot.dto.RespDTO;
+import com.diagbot.util.RespDTOUtil;
+import com.google.common.collect.Lists;
+import io.github.lvyahui8.spring.annotation.DataProvider;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.util.List;
+
+/**
+ * @Description:
+ * @author: gaodm
+ * @time: 2019/10/16 13:35
+ */
+@Component
+public class PrecmanAgg {
+    @Autowired
+    private PrecmanServiceClient precmanServiceClient;
+    @DataProvider("precGetCount")
+    public List<BIItemDTO> precGetCount(){
+        List<BIItemDTO> biItemDTOList = Lists.newLinkedList();
+        RespDTO<BIItemDTO> precResp = precmanServiceClient.getCount();
+        if (RespDTOUtil.respIsOK(precResp)) {
+            biItemDTOList.add(precResp.data);
+        }
+        return biItemDTOList;
+    }
+}

+ 29 - 18
bi-service/src/main/java/com/diagbot/facade/StatisticsFacade.java

@@ -5,11 +5,12 @@ 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.exception.CommonErrorCode;
+import com.diagbot.exception.CommonException;
 import com.diagbot.util.EntityUtil;
-import com.diagbot.util.RespDTOUtil;
-import com.google.common.collect.Lists;
+import com.diagbot.util.ListUtil;
+import io.github.lvyahui8.spring.aggregate.facade.DataBeanAggregateQueryFacade;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
@@ -28,25 +29,35 @@ public class StatisticsFacade {
     @Autowired
     private PrecmanServiceClient precmanServiceClient;
 
+    @Autowired
+    DataBeanAggregateQueryFacade dataBeanAggregateQueryFacade;
+
     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);
+        List<BIItemDTO> biItemDTOList = ListUtil.newArrayList();
+        try {
+            biItemDTOList
+                    = dataBeanAggregateQueryFacade.get("biAll", null, List.class);
+        } catch (Exception e){
+            throw new CommonException(CommonErrorCode.SERVER_IS_ERROR);
         }
 
-        //术语统计
-        RespDTO<List<BIItemDTO>> conceptResp = knowledgemanServiceClient.queryLibTypeCou();
-        if (RespDTOUtil.respIsOK(conceptResp)) {
-            biItemDTOList.addAll(conceptResp.data);
-        }
+        //        //静态知识统计
+        //        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);
+        //        }
+        //
+        //        //术语统计
+        //        RespDTO<List<BIItemDTO>> conceptResp = knowledgemanServiceClient.queryLibTypeCou();
+        //        if (RespDTOUtil.respIsOK(conceptResp)) {
+        //            biItemDTOList.addAll(conceptResp.data);
+        //        }
 
         Map<String, List<BIItemDTO>> map = EntityUtil.makeEntityListMap(biItemDTOList, "moduleName");
         bidto.setDiagnose(getBIModuleDTO(map, StatisticsTypeEnum.DIAGNOSE.getKey()));

+ 1 - 0
config-server/src/main/resources/shared/bi-service-dev.yml

@@ -95,3 +95,4 @@ mybatis-plus:
     map-underscore-to-camel-case: true
     cache-enabled: false
 
+io.github.lvyahui8.spring.base-packages: com.diagbot.aggregate

+ 1 - 0
config-server/src/main/resources/shared/bi-service-local.yml

@@ -95,3 +95,4 @@ mybatis-plus:
     map-underscore-to-camel-case: true
     cache-enabled: false
 
+io.github.lvyahui8.spring.base-packages: com.diagbot.aggregate

+ 1 - 0
config-server/src/main/resources/shared/bi-service-pro.yml

@@ -95,3 +95,4 @@ mybatis-plus:
     map-underscore-to-camel-case: true
     cache-enabled: false
 
+io.github.lvyahui8.spring.base-packages: com.diagbot.aggregate

+ 1 - 0
config-server/src/main/resources/shared/bi-service-test.yml

@@ -95,3 +95,4 @@ mybatis-plus:
     map-underscore-to-camel-case: true
     cache-enabled: false
 
+io.github.lvyahui8.spring.base-packages: com.diagbot.aggregate