|
@@ -6,13 +6,17 @@ import com.diagbot.dto.RuleConditionDTO;
|
|
|
import com.diagbot.dto.RuleConditionInitDTO;
|
|
|
import com.diagbot.dto.RuleDTO;
|
|
|
import com.diagbot.dto.RuleInitDTO;
|
|
|
+import com.diagbot.enums.BaseTypeEnum;
|
|
|
+import com.diagbot.enums.LexiconEnum;
|
|
|
import com.diagbot.enums.RedisEnum;
|
|
|
+import com.diagbot.enums.RuleTypeEnum;
|
|
|
import com.diagbot.exception.CommonErrorCode;
|
|
|
import com.diagbot.exception.CommonException;
|
|
|
import com.diagbot.facade.KlRuleFacade;
|
|
|
import com.diagbot.util.BeanUtil;
|
|
|
import com.diagbot.util.EntityUtil;
|
|
|
import com.diagbot.util.ListUtil;
|
|
|
+import com.diagbot.util.RedisUtil;
|
|
|
import io.github.lvyahui8.spring.annotation.DataConsumer;
|
|
|
import io.github.lvyahui8.spring.annotation.DataProvider;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
@@ -35,6 +39,8 @@ import java.util.Map;
|
|
|
public class RuleAggregate {
|
|
|
@Autowired
|
|
|
private KlRuleFacade klRuleFacade;
|
|
|
+ @Autowired
|
|
|
+ private RedisUtil redisUtil;
|
|
|
|
|
|
@DataProvider("getAllRules")
|
|
|
public Map<String, RuleDTO> getAllRules(
|
|
@@ -43,6 +49,7 @@ public class RuleAggregate {
|
|
|
@DataConsumer("getRuleBaseInit") Map<Integer, List<RuleBaseInitDTO>> ruleBaseInits) {
|
|
|
try {
|
|
|
Map<String, RuleDTO> res = new HashMap();
|
|
|
+ List<String> drugAllergen = new ArrayList<>();
|
|
|
//结果判空第一层规则类型
|
|
|
if (MapUtils.isNotEmpty(ruleInits)) {
|
|
|
for (String ruleKey : ruleInits.keySet()) {
|
|
@@ -51,6 +58,12 @@ public class RuleAggregate {
|
|
|
ruleDTO.setLibName(ruleInitZeroDTO.getLibName());
|
|
|
ruleDTO.setLibType(ruleInitZeroDTO.getLibType());
|
|
|
ruleDTO.setRuleType(ruleInitZeroDTO.getRuleType());
|
|
|
+ //药物过敏源相关
|
|
|
+ Boolean allergenAdd = false;
|
|
|
+ if (ruleDTO.getRuleType().equals(RuleTypeEnum.bill.getKey())
|
|
|
+ && ruleDTO.getLibType().equals(LexiconEnum.Medicine.getKey())) {
|
|
|
+ allergenAdd = true;
|
|
|
+ }
|
|
|
Map<String, Integer> ruleConditionMap = new HashMap<>();
|
|
|
for (RuleInitDTO ruleInitDTO : ruleInits.get(ruleKey)) {
|
|
|
if (ruleInitDTO.getHasSubCond().equals(1)) {
|
|
@@ -75,6 +88,11 @@ public class RuleAggregate {
|
|
|
//笛卡尔积
|
|
|
List<List<RuleBaseDTO>> ruleBaseGroup = new ArrayList<>();
|
|
|
descartes(ruleBaseList, ruleBaseGroup, 0, new ArrayList<>());
|
|
|
+ //药物过敏源相关
|
|
|
+ if (allergenAdd
|
|
|
+ && ruleBaseGroup.size() == 1) {
|
|
|
+ allergenAdd = true;
|
|
|
+ }
|
|
|
for (List<RuleBaseDTO> ruleBaseDTOList : ruleBaseGroup) {
|
|
|
RuleConditionDTO ruleConditionDTO1 = new RuleConditionDTO();
|
|
|
ruleConditionDTO1.setHasSubCond(ruleConditionDTO.getHasSubCond());
|
|
@@ -83,6 +101,18 @@ public class RuleAggregate {
|
|
|
ruleConditionDTO1.getRuleBaseDTOList().addAll(ruleBaseDTOList);
|
|
|
if (!ruleConditionMap.containsKey(ruleConditionDTO1.toString())) {
|
|
|
ruleDTO.getRuleConditionDTOList().add(ruleConditionDTO1);
|
|
|
+ //药物过敏源相关
|
|
|
+ if (allergenAdd
|
|
|
+ && ruleBaseDTOList.size() == 1) {
|
|
|
+ RuleBaseDTO ruleBaseDTO = ruleBaseDTOList.get(0);
|
|
|
+ if (ruleBaseDTO.getBaseType().equals(BaseTypeEnum.B4.getKey())
|
|
|
+ && ruleDTO.getLibType().equals(ruleBaseDTO.getBaseLibType())
|
|
|
+ && ruleDTO.getLibName().equals(ruleBaseDTO.getBaseLibName())) {
|
|
|
+ if (!drugAllergen.contains(ruleDTO.getLibName())) {
|
|
|
+ drugAllergen.add(ruleDTO.getLibName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
ruleConditionMap.put(ruleConditionDTO1.toString(), 1);
|
|
|
}
|
|
|
}
|
|
@@ -104,6 +134,10 @@ public class RuleAggregate {
|
|
|
}
|
|
|
res.put(RedisEnum.allRule.getName() + ruleDTO.getLibType() + "_" + ruleDTO.getLibName() + "_" + ruleDTO.getRuleType(), ruleDTO);
|
|
|
}
|
|
|
+ //直接加载缓存
|
|
|
+ if (ListUtil.isNotEmpty(drugAllergen)) {
|
|
|
+ redisUtil.set(RedisEnum.drugAllergen.getName(), drugAllergen);
|
|
|
+ }
|
|
|
}
|
|
|
return res;
|
|
|
} catch (Exception e) {
|