|
@@ -1,11 +1,13 @@
|
|
|
package com.diagbot.aggregate;
|
|
|
|
|
|
+import com.diagbot.dto.AllRulesDTO;
|
|
|
import com.diagbot.dto.RuleBaseDTO;
|
|
|
import com.diagbot.dto.RuleBaseInitDTO;
|
|
|
import com.diagbot.dto.RuleConditionDTO;
|
|
|
import com.diagbot.dto.RuleConditionInitDTO;
|
|
|
import com.diagbot.dto.RuleDTO;
|
|
|
import com.diagbot.dto.RuleInitDTO;
|
|
|
+import com.diagbot.entity.KlRuleSearch;
|
|
|
import com.diagbot.enums.BaseTypeEnum;
|
|
|
import com.diagbot.enums.LexiconEnum;
|
|
|
import com.diagbot.enums.RedisEnum;
|
|
@@ -26,6 +28,7 @@ import org.springframework.stereotype.Component;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.HashMap;
|
|
|
+import java.util.HashSet;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
@@ -43,14 +46,18 @@ public class RuleAggregate {
|
|
|
private RedisUtil redisUtil;
|
|
|
|
|
|
@DataProvider("getAllRules")
|
|
|
- public Map<String, RuleDTO> getAllRules(
|
|
|
+ public AllRulesDTO getAllRules(
|
|
|
@DataConsumer("getRuleInit") Map<String, List<RuleInitDTO>> ruleInits,
|
|
|
@DataConsumer("getRuleConditionInit") Map<Integer, Map<String, List<RuleConditionInitDTO>>> ruleConditionInits,
|
|
|
@DataConsumer("getRuleBaseInit") Map<Integer, List<RuleBaseInitDTO>> ruleBaseInits) {
|
|
|
try {
|
|
|
- Map<String, RuleDTO> res = new HashMap();
|
|
|
+ //有效规则Map
|
|
|
+ Map<String, RuleDTO> ruleDTOMap = new HashMap();
|
|
|
//药物过敏源
|
|
|
Map<String, Integer> drugAllergen = new HashMap<>();
|
|
|
+ //规则搜索有效的规则ID
|
|
|
+ HashSet<Long> ruleIdSet = new HashSet<>();
|
|
|
+ List<KlRuleSearch> klRuleSearchList = new ArrayList<>();
|
|
|
//结果判空第一层规则类型
|
|
|
if (MapUtils.isNotEmpty(ruleInits)) {
|
|
|
for (String ruleKey : ruleInits.keySet()) {
|
|
@@ -117,6 +124,13 @@ public class RuleAggregate {
|
|
|
}
|
|
|
}
|
|
|
ruleConditionMap.put(ruleConditionDTO1.toString(), 1);
|
|
|
+ //规则搜索有效的规则ID
|
|
|
+ if (!ruleIdSet.contains(ruleInitDTO.getRuleId())){
|
|
|
+ ruleIdSet.add(ruleInitDTO.getRuleId());
|
|
|
+ KlRuleSearch klRuleSearch = new KlRuleSearch();
|
|
|
+ klRuleSearch.setId(ruleInitDTO.getRuleId());
|
|
|
+ klRuleSearchList.add(klRuleSearch);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -133,17 +147,25 @@ public class RuleAggregate {
|
|
|
if (!ruleConditionMap.containsKey(ruleConditionDTO.toString())) {
|
|
|
ruleDTO.getRuleConditionDTOList().add(ruleConditionDTO);
|
|
|
ruleConditionMap.put(ruleConditionDTO.toString(), 1);
|
|
|
+ //规则搜索有效的规则ID
|
|
|
+ if (!ruleIdSet.contains(ruleInitDTO.getRuleId())){
|
|
|
+ ruleIdSet.add(ruleInitDTO.getRuleId());
|
|
|
+ KlRuleSearch klRuleSearch = new KlRuleSearch();
|
|
|
+ klRuleSearch.setId(ruleInitDTO.getRuleId());
|
|
|
+ klRuleSearchList.add(klRuleSearch);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- res.put(RedisEnum.allRule.getName() + ruleDTO.getLibType() + "_" + ruleDTO.getLibName() + "_" + ruleDTO.getRuleType(), ruleDTO);
|
|
|
- }
|
|
|
- //直接加载缓存
|
|
|
- if (MapUtils.isNotEmpty(drugAllergen)) {
|
|
|
- redisUtil.set(RedisEnum.drugAllergen.getName(), drugAllergen);
|
|
|
+ ruleDTOMap.put(RedisEnum.allRule.getName() + ruleDTO.getLibType() + "_" + ruleDTO.getLibName() + "_" + ruleDTO.getRuleType(), ruleDTO);
|
|
|
}
|
|
|
}
|
|
|
- return res;
|
|
|
+ //出参设置
|
|
|
+ AllRulesDTO allRulesDTO = new AllRulesDTO();
|
|
|
+ allRulesDTO.setRuleDTOMap(ruleDTOMap);
|
|
|
+ allRulesDTO.setDrugAllergen(drugAllergen);
|
|
|
+ allRulesDTO.setKlRuleSearchList(klRuleSearchList);
|
|
|
+ return allRulesDTO;
|
|
|
} catch (Exception e) {
|
|
|
throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "全部规则加载出错:" + e.getMessage());
|
|
|
}
|
|
@@ -170,18 +192,18 @@ public class RuleAggregate {
|
|
|
// }
|
|
|
|
|
|
@DataProvider("getRuleConditionInit")
|
|
|
- public Map<Integer, Map<String, List<RuleConditionInitDTO>>> getRuleConditionInit() {
|
|
|
+ public Map<Long, Map<String, List<RuleConditionInitDTO>>> getRuleConditionInit() {
|
|
|
List<RuleConditionInitDTO> list = klRuleFacade.getRuleConditionInitDTO();
|
|
|
- Map<Integer, List<RuleConditionInitDTO>> map = EntityUtil.makeEntityListMap(list, "ruleId");
|
|
|
- Map<Integer, Map<String, List<RuleConditionInitDTO>>> res = new HashMap<>();
|
|
|
- for (Integer ruleId : map.keySet()) {
|
|
|
+ Map<Long, List<RuleConditionInitDTO>> map = EntityUtil.makeEntityListMap(list, "ruleId");
|
|
|
+ Map<Long, Map<String, List<RuleConditionInitDTO>>> res = new HashMap<>();
|
|
|
+ for (Long ruleId : map.keySet()) {
|
|
|
res.put(ruleId, EntityUtil.makeEntityListMap(map.get(ruleId), "ruleGroup"));
|
|
|
}
|
|
|
return res;
|
|
|
}
|
|
|
|
|
|
@DataProvider("getRuleBaseInit")
|
|
|
- public Map<Integer, List<RuleBaseInitDTO>> getRuleBaseInit(
|
|
|
+ public Map<Long, List<RuleBaseInitDTO>> getRuleBaseInit(
|
|
|
@DataConsumer("getRuleBaseInitNotHaveClass") List<RuleBaseInitDTO> ruleBaseNotHaveClass,
|
|
|
@DataConsumer("getRuleBaseInitHaveClass") List<RuleBaseInitDTO> ruleBaseHaveClass) {
|
|
|
List<RuleBaseInitDTO> list = new ArrayList<>();
|