|
@@ -8,7 +8,9 @@ import org.diagbot.common.push.cache.ApplicationCacheUtil;
|
|
|
import org.springframework.util.StringUtils;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
+import java.util.Arrays;
|
|
|
import java.util.HashMap;
|
|
|
+import java.util.HashSet;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.Set;
|
|
@@ -21,6 +23,7 @@ public class CrisisApplication {
|
|
|
|
|
|
public Map<String, List<CrisisDetail>> crisisContent(SearchData searchData) {
|
|
|
Map<String, List<Rule>> rules = searchData.getRules();
|
|
|
+ List<String> ruleTypeIdList = null;
|
|
|
if (rules == null) {
|
|
|
return new HashMap<String, List<CrisisDetail>>();
|
|
|
}
|
|
@@ -28,8 +31,16 @@ public class CrisisApplication {
|
|
|
|
|
|
Map<String, List<CrisisDetail>> crisisMap = new HashMap<>();
|
|
|
List<CrisisDetail> crisisList = null;
|
|
|
+ if (StringUtils.isEmpty(searchData.getRuleTypeId())) {
|
|
|
+ ruleTypeIdList = getallRuleId(ruleApps);
|
|
|
+ } else {
|
|
|
+ ruleTypeIdList = Arrays.asList(searchData.getRuleTypeId().split(","));
|
|
|
+ }
|
|
|
for (Map.Entry<String, RuleApp> app : ruleApps.entrySet()) {
|
|
|
- if (StringUtils.isEmpty(app.getValue().getRuleIds())) {
|
|
|
+ if (StringUtils.isEmpty(app.getValue().getRuleIds()) || StringUtils.isEmpty(app.getValue().getTypeId())) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (!ruleTypeIdList.contains(app.getValue().getTypeId())) {
|
|
|
continue;
|
|
|
}
|
|
|
String[] ruleIds = app.getValue().getRuleIds().split(",");
|
|
@@ -58,6 +69,7 @@ public class CrisisApplication {
|
|
|
crisisDetail.setOriginText(originText);
|
|
|
crisisDetail.setStandardText(standardText);
|
|
|
crisisDetail.setRemindText(app.getValue().getRemind());
|
|
|
+ crisisDetail.setTypeId(app.getValue().getTypeId());
|
|
|
|
|
|
crisisList = crisisMap.get(key);
|
|
|
if (crisisList == null) {
|
|
@@ -78,6 +90,15 @@ public class CrisisApplication {
|
|
|
return crisisMap;
|
|
|
}
|
|
|
|
|
|
+ private List<String> getallRuleId(Map<String, RuleApp> ruleApps) {
|
|
|
+ Set<String> typeIdSet = new HashSet<>();
|
|
|
+ for (Map.Entry<String, RuleApp> ruleAppEntry : ruleApps.entrySet()) {
|
|
|
+ typeIdSet.add(ruleAppEntry.getValue().getTypeId());
|
|
|
+ }
|
|
|
+ List<String> allTypeIdList = new ArrayList<>(typeIdSet);
|
|
|
+ return allTypeIdList;
|
|
|
+ }
|
|
|
+
|
|
|
private String mergeStandardText(Rule rule) {
|
|
|
//标准值最优先匹配
|
|
|
StringBuffer sb = new StringBuffer();
|