|
@@ -10,9 +10,11 @@ import com.diagbot.enums.RedisEnum;
|
|
|
import com.diagbot.facade.KlRuleFacade;
|
|
|
import com.diagbot.util.BeanUtil;
|
|
|
import com.diagbot.util.EntityUtil;
|
|
|
+import com.diagbot.util.ListUtil;
|
|
|
import io.github.lvyahui8.spring.annotation.DataConsumer;
|
|
|
import io.github.lvyahui8.spring.annotation.DataProvider;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.commons.collections.MapUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
@@ -37,38 +39,47 @@ public class RuleAggregate {
|
|
|
@DataConsumer("getRuleConditionInit") Map<Integer, Map<String, List<RuleConditionInitDTO>>> ruleConditionInits,
|
|
|
@DataConsumer("getRuleBaseInit") Map<Integer, RuleBaseInitDTO> ruleBaseInits) {
|
|
|
Map<String, RuleDTO> res = new HashMap();
|
|
|
- for (String ruleKey : ruleInits.keySet()) {
|
|
|
- RuleInitDTO ruleInitZeroDTO = ruleInits.get(ruleKey).get(0);
|
|
|
- RuleDTO ruleDTO = new RuleDTO();
|
|
|
- ruleDTO.setLibName(ruleInitZeroDTO.getLibName());
|
|
|
- ruleDTO.setLibType(ruleInitZeroDTO.getLibType());
|
|
|
- ruleDTO.setRuleType(ruleInitZeroDTO.getRuleType());
|
|
|
- for (RuleInitDTO ruleInitDTO : ruleInits.get(ruleKey)) {
|
|
|
- if (ruleInitDTO.getHasSubCond().equals(1)) {
|
|
|
- Map<String, List<RuleConditionInitDTO>> map = ruleConditionInits.get(ruleInitDTO.getRuleId());
|
|
|
- for (String key : map.keySet()) {
|
|
|
+ //结果判空第一层规则类型
|
|
|
+ if (MapUtils.isNotEmpty(ruleInits)) {
|
|
|
+ for (String ruleKey : ruleInits.keySet()) {
|
|
|
+ RuleInitDTO ruleInitZeroDTO = ruleInits.get(ruleKey).get(0);
|
|
|
+ RuleDTO ruleDTO = new RuleDTO();
|
|
|
+ ruleDTO.setLibName(ruleInitZeroDTO.getLibName());
|
|
|
+ ruleDTO.setLibType(ruleInitZeroDTO.getLibType());
|
|
|
+ ruleDTO.setRuleType(ruleInitZeroDTO.getRuleType());
|
|
|
+ for (RuleInitDTO ruleInitDTO : ruleInits.get(ruleKey)) {
|
|
|
+ if (ruleInitDTO.getHasSubCond().equals(1)) {
|
|
|
+ Map<String, List<RuleConditionInitDTO>> map = ruleConditionInits.get(ruleInitDTO.getRuleId());
|
|
|
+ //结果判空第二层条件组别
|
|
|
+ if (MapUtils.isNotEmpty(map)) {
|
|
|
+ for (String key : map.keySet()) {
|
|
|
+ RuleConditionDTO ruleConditionDTO = new RuleConditionDTO();
|
|
|
+ ruleConditionDTO.setHasSubCond(ruleInitDTO.getHasSubCond());
|
|
|
+ ruleConditionDTO.setMsg(ruleInitDTO.getMsg());
|
|
|
+ ruleConditionDTO.setRuleGroup(key);
|
|
|
+ //结果判空第三层条件明细
|
|
|
+ if (ListUtil.isNotEmpty(map.get(key))) {
|
|
|
+ for (RuleConditionInitDTO ruleConditionInitDTO : map.get(key)) {
|
|
|
+ RuleBaseDTO ruleBaseDTO = new RuleBaseDTO();
|
|
|
+ BeanUtil.copyProperties(ruleBaseInits.get(ruleConditionInitDTO.getRuleBaseId()), ruleBaseDTO);
|
|
|
+ ruleConditionDTO.getRuleBaseDTOList().add(ruleBaseDTO);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ruleDTO.getRuleConditionDTOList().add(ruleConditionDTO);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
RuleConditionDTO ruleConditionDTO = new RuleConditionDTO();
|
|
|
ruleConditionDTO.setHasSubCond(ruleInitDTO.getHasSubCond());
|
|
|
ruleConditionDTO.setMsg(ruleInitDTO.getMsg());
|
|
|
- ruleConditionDTO.setRuleGroup(key);
|
|
|
- for (RuleConditionInitDTO ruleConditionInitDTO : map.get(key)) {
|
|
|
- RuleBaseDTO ruleBaseDTO = new RuleBaseDTO();
|
|
|
- BeanUtil.copyProperties(ruleBaseInits.get(ruleConditionInitDTO.getRuleBaseId()), ruleBaseDTO);
|
|
|
- ruleConditionDTO.getRuleBaseDTOList().add(ruleBaseDTO);
|
|
|
- }
|
|
|
+ //无条件
|
|
|
+ ruleConditionDTO.setRuleGroup(ruleInitDTO.getRuleId() + "-1");
|
|
|
+ ruleConditionDTO.getRuleBaseDTOList().add(new RuleBaseDTO());
|
|
|
ruleDTO.getRuleConditionDTOList().add(ruleConditionDTO);
|
|
|
}
|
|
|
- } else {
|
|
|
- RuleConditionDTO ruleConditionDTO = new RuleConditionDTO();
|
|
|
- ruleConditionDTO.setHasSubCond(ruleInitDTO.getHasSubCond());
|
|
|
- ruleConditionDTO.setMsg(ruleInitDTO.getMsg());
|
|
|
- //无条件
|
|
|
- ruleConditionDTO.setRuleGroup(ruleInitDTO.getRuleId() + "-1");
|
|
|
- ruleConditionDTO.getRuleBaseDTOList().add(new RuleBaseDTO());
|
|
|
- ruleDTO.getRuleConditionDTOList().add(ruleConditionDTO);
|
|
|
}
|
|
|
+ res.put(RedisEnum.allRule.getName() + ruleDTO.getLibType() + "_" + ruleDTO.getLibName() + "_" + ruleDTO.getRuleType(), ruleDTO);
|
|
|
}
|
|
|
- res.put(RedisEnum.allRule.getName() + ruleDTO.getLibType() + "_" + ruleDTO.getLibName() + "_" + ruleDTO.getRuleType(), ruleDTO);
|
|
|
}
|
|
|
return res;
|
|
|
}
|