瀏覽代碼

记录调试信息

zhoutg 4 年之前
父節點
當前提交
12b6e354ba

+ 8 - 4
src/main/java/com/diagbot/aggregate/IndicationAggregate.java

@@ -12,6 +12,8 @@ import io.github.lvyahui8.spring.annotation.InvokeParameter;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
+import java.util.Map;
+
 /**
  * @Description: 提醒类聚合
  * @author: zhoutg
@@ -29,17 +31,19 @@ public class IndicationAggregate {
     public IndicationDTO indicationAll(
             @InvokeParameter("wordCrfDTO") WordCrfDTO wordCrfDTO,
             @InvokeParameter("indicationPushVO") IndicationPushVO indicationPushVO,
+            @InvokeParameter("debug") Map<String, Object> debug,
             @DataConsumer("bill") IndicationDTO billDTO,
             @DataConsumer("highrisk") IndicationDTO highrisk) {
         IndicationDTO res = new IndicationDTO();
         if (billDTO != null) {
             res.setBillMsgList(billDTO.getBillMsgList());
-            res.getDebugStr().addAll(billDTO.getDebugStr()); // 调试信息
+            debug.putAll(billDTO.getDebug()); // 调试信息
         }
         if (highrisk != null) {
             res.setHighRiskList(highrisk.getHighRiskList());
-            res.getDebugStr().addAll(highrisk.getDebugStr()); // 调试信息
+            debug.putAll(highrisk.getDebug()); // 调试信息
         }
+        res.setDebug(debug);
         return res;
     }
 
@@ -58,7 +62,7 @@ public class IndicationAggregate {
         // 开单合理性
         if (indicationPushVO != null && indicationPushVO.getRuleTypeList().contains("2")) {
             billFacade.billFac(indicationPushVO, wordCrfDTO, res);
-            CoreUtil.getDebugStr(start, "开单规则", res.getDebugStr());
+            CoreUtil.getDebugStr(start, "开单规则耗时", res.getDebug());
             return res;
         }
         return null;
@@ -79,7 +83,7 @@ public class IndicationAggregate {
         // 高风险提示
         if (indicationPushVO != null && indicationPushVO.getRuleTypeList().contains("3")) {
             highRiskFacade.highRiskFac(indicationPushVO, wordCrfDTO, res);
-            CoreUtil.getDebugStr(start, "高风险提示", res.getDebugStr());
+            CoreUtil.getDebugStr(start, "高风险提示耗时", res.getDebug());
             return res;
         }
         return null;

+ 3 - 2
src/main/java/com/diagbot/dto/IndicationDTO.java

@@ -3,8 +3,9 @@ package com.diagbot.dto;
 import lombok.Data;
 
 import java.util.ArrayList;
-import java.util.LinkedList;
+import java.util.LinkedHashMap;
 import java.util.List;
+import java.util.Map;
 
 /**
  * @description: 提示信息出参
@@ -20,5 +21,5 @@ public class IndicationDTO {
     // 高危药品、手术
     private List<BillMsg> highRiskList = new ArrayList<>();
     // 记录调试信息
-    private List<String> debugStr = new LinkedList<>();
+    private Map<String, Object> debug = new LinkedHashMap<>();
 }

+ 6 - 6
src/main/java/com/diagbot/facade/IndicationFacade.java

@@ -16,6 +16,7 @@ import org.springframework.stereotype.Component;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.HashMap;
+import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
 
@@ -53,7 +54,7 @@ public class IndicationFacade {
      */
     public IndicationDTO indicationFac(IndicationPushVO indicationPushVO) {
         IndicationDTO res = new IndicationDTO();
-
+        Map<String, Object> debug = new LinkedHashMap<>();
         //方法适配处理
         List<String> ruleTypeList = Arrays.asList(indicationPushVO.getRuleType().split(","));
         indicationPushVO.setRuleTypeList(ruleTypeList);
@@ -78,7 +79,7 @@ public class IndicationFacade {
         if (methodList.contains("crf")) {
             wordCrfDTO = commonFacade.crf_process(indicationPushVO);
         }
-        long crfEnd = System.currentTimeMillis();
+        CoreUtil.getDebugStr(crfStart, "模型处理耗时", debug);
 
         // 标准词转换
         long standStart = System.currentTimeMillis();
@@ -87,21 +88,20 @@ public class IndicationFacade {
             Map<String, Map<String, String>> standConvertMap = neoFacade.standConvertCrf(standConvert);
             commonFacade.dataTypeSet(wordCrfDTO, standConvertMap);
         }
-        long standEnd = System.currentTimeMillis();
+        CoreUtil.getDebugStr(standStart, "标准词转换耗时", debug);
 
         try {
             Map<String, Object> invokeParams = new HashMap<>();
             invokeParams.put("wordCrfDTO", wordCrfDTO);
             invokeParams.put("indicationPushVO", indicationPushVO);
+            invokeParams.put("debug", debug);
             res = DataFacade.get("indicationAll", invokeParams, IndicationDTO.class);
         } catch (Exception e) {
             throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "提醒类服务出错" + e.getMessage());
         }
 
         // 输入调试信息
-        CoreUtil.getDebugStrFirst(standStart, standEnd, "同义词转换", res.getDebugStr());
-        CoreUtil.getDebugStrFirst(crfStart, crfEnd, "处理模型数据", res.getDebugStr());
-        CoreUtil.getDebugStr(l1, "本次调用总计", res.getDebugStr());
+        CoreUtil.getDebugStr(l1, "本次调用总计耗时", res.getDebug());
         return res;
     }
 }

+ 3 - 25
src/main/java/com/diagbot/util/CoreUtil.java

@@ -476,33 +476,11 @@ public class CoreUtil {
      *
      * @param start
      * @param msg
-     * @param debugStr
+     * @param debugMap
      */
-    public static void getDebugStr(long start, String msg, List<String> debugStr) {
+    public static void getDebugStr(long start, String msg, Map<String, Object> debugMap) {
         long end = System.currentTimeMillis();
-        debugStr.add(msg + "需要" + (end - start) / 1000.0 + "秒");
-    }
-
-    /**
-     * 输出调试信息
-     *
-     * @param start
-     * @param msg
-     * @param debugStr
-     */
-    public static void getDebugStr(long start, long end, String msg, List<String> debugStr) {
-        debugStr.add(msg + "需要" + (end - start) / 1000.0 + "秒");
-    }
-
-    /**
-     * 输出调试信息
-     *
-     * @param start
-     * @param msg
-     * @param debugStr
-     */
-    public static void getDebugStrFirst(long start, long end, String msg, List<String> debugStr) {
-        debugStr.add(0, msg + "需要" + (end - start) / 1000.0 + "秒");
+        debugMap.put(msg,  + (end - start) / 1000.0 + "秒");
     }
 
     public static void main(String[] args) {