Browse Source

方法适配器

gaodm 4 years ago
parent
commit
5dc0c9a008

+ 41 - 12
src/main/java/com/diagbot/facade/IndicationFacade.java

@@ -4,12 +4,15 @@ import com.diagbot.client.StandConvertServiceClient;
 import com.diagbot.dto.IndicationDTO;
 import com.diagbot.dto.WordCrfDTO;
 import com.diagbot.util.CoreUtil;
+import com.diagbot.util.ListUtil;
 import com.diagbot.vo.IndicationPushVO;
 import com.diagbot.vo.StandConvert;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
+import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
@@ -30,6 +33,15 @@ public class IndicationFacade {
     @Autowired
     StandConvertServiceClient standConvertServiceClient;
 
+    private static final Map<String, List<String>> methodMap;
+
+    static {
+        methodMap = new HashMap<>();
+        methodMap.put("2", Arrays.asList("M1", "M2"));
+        methodMap.put("3", Arrays.asList());
+    }
+
+
     /**
      * 病情提示总入口
      *
@@ -37,21 +49,38 @@ public class IndicationFacade {
      * @return
      */
     public IndicationDTO indicationFac(IndicationPushVO indicationPushVO) {
+        //方法适配处理
+        List<String> ruleTypeList = Arrays.asList(indicationPushVO.getRuleType().split(","));
+        List<String> methodList = new ArrayList<>();
+        for (String ruleType : ruleTypeList) {
+            if (ListUtil.isNotEmpty(methodMap.get(ruleType))) {
+                List<String> methods = methodMap.get(ruleType);
+                for (String method : methods) {
+                    if (!methodList.contains(method)) {
+                        methodList.add(method);
+                    }
+                }
+            }
+        }
+
         IndicationDTO res = new IndicationDTO();
+        WordCrfDTO wordCrfDTO = null;
         long l1 = System.currentTimeMillis();
-        // 模型处理数据
-        WordCrfDTO wordCrfDTO = commonFacade.crf_process(indicationPushVO);
-        CoreUtil.getDubugStr(l1, "处理模型数据", res.getDubugStr());
-
-        // 标准词转换
-        long l2 = System.currentTimeMillis();
-        StandConvert standConvert = commonFacade.dataTypeGet(wordCrfDTO);
-        Map<String, Map<String, String>> standConvertMap = neoFacade.standConvertCrf(standConvert);
-//        Map<String, Map<String, String>> standConvertMap = neoFacade.standConvert(standConvert);
-        commonFacade.dataTypeSet(wordCrfDTO, standConvertMap);
-        CoreUtil.getDubugStr(l2, "同义词转换", res.getDubugStr());
+        if (methodList.contains("M1")) {
+            // 模型处理数据
+            wordCrfDTO = commonFacade.crf_process(indicationPushVO);
+            CoreUtil.getDubugStr(l1, "处理模型数据", res.getDubugStr());
+        }
 
-        List<String> ruleTypeList = Arrays.asList(indicationPushVO.getRuleType().split(","));
+        if (methodList.contains("M2")) {
+            // 标准词转换
+            long l2 = System.currentTimeMillis();
+            StandConvert standConvert = commonFacade.dataTypeGet(wordCrfDTO);
+            Map<String, Map<String, String>> standConvertMap = neoFacade.standConvertCrf(standConvert);
+            //        Map<String, Map<String, String>> standConvertMap = neoFacade.standConvert(standConvert);
+            commonFacade.dataTypeSet(wordCrfDTO, standConvertMap);
+            CoreUtil.getDubugStr(l2, "同义词转换", res.getDubugStr());
+        }
 
         long l3 = System.currentTimeMillis();
         // 开单合理性

+ 1 - 1
src/main/java/com/diagbot/vo/IndicationPushVO.java

@@ -14,7 +14,7 @@ import javax.validation.constraints.NotBlank;
 @Setter
 public class IndicationPushVO extends SearchData {
     /**
-     * 规则类型(1:危急值提醒,2:开单合理项,3:管理评估,4:不良反应,5:药物推荐,6:异常值
+     * 规则类型(1:危急值提醒,2:开单合理项,3:)
      */
     @NotBlank(message = "ruleType不能为空")
     private String ruleType = "";