|
@@ -0,0 +1,85 @@
|
|
|
+package org.diagbot.common.push.filter;
|
|
|
+
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import org.diagbot.common.work.FeatureRate;
|
|
|
+import org.diagbot.common.work.ResponseData;
|
|
|
+import org.diagbot.graph.util.CacheUtil;
|
|
|
+
|
|
|
+import java.util.*;
|
|
|
+
|
|
|
+/**
|
|
|
+ * Created by kwz on 2019/8/5.
|
|
|
+ */
|
|
|
+public class ClassifyDiag {
|
|
|
+ public static void main(String[] args) {
|
|
|
+ Map<String, String> diagClassifyCache = CacheUtil.getDiagClassifyCache();
|
|
|
+ for(Map.Entry<String,String>d:diagClassifyCache.entrySet()){
|
|
|
+ System.out.println(d.getKey()+"\t"+d.getValue());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据诊断依据规则过滤诊断
|
|
|
+ * @param graphResponseData 把过滤的诊断包装在这个对象里
|
|
|
+ * @param graphFeatures 过滤前的诊断结果
|
|
|
+ * @return 返回过滤后的诊断结果
|
|
|
+ */
|
|
|
+ public List<FeatureRate> filterDiag(ResponseData graphResponseData,List<FeatureRate> graphFeatures){
|
|
|
+ //根据诊断依据规则过滤掉的诊断列表
|
|
|
+ List<String> excludeDiag = graphResponseData.getExcludeDiag();
|
|
|
+ //将需要排除的诊断从列表中删除
|
|
|
+ List<FeatureRate> updateFeatures = new ArrayList<>();
|
|
|
+ for(int j = 0;j<graphFeatures.size();j++){
|
|
|
+ if(excludeDiag.indexOf(graphFeatures.get(j).getFeatureName()) == -1){
|
|
|
+ updateFeatures.add(graphFeatures.get(j));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return updateFeatures;
|
|
|
+ }
|
|
|
+
|
|
|
+ //get diagClassifyCache
|
|
|
+ Map<String, String> diagClassifyCache = CacheUtil.getDiagClassifyCache();
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 诊断归一
|
|
|
+ * @param updateFeatures 归一前的诊断
|
|
|
+ * @return 归一后的诊断
|
|
|
+ */
|
|
|
+ public List<FeatureRate> diagClassify(List<FeatureRate> updateFeatures){
|
|
|
+ List<FeatureRate> finalDiagList = new LinkedList<>();//最终返回
|
|
|
+ List<String> highDiagList = new LinkedList<>();//警惕集合
|
|
|
+ List<String> queDiagList = new LinkedList<>();//确诊集合
|
|
|
+ List<String> bigDiagList = new LinkedList<>();//可能诊断集合
|
|
|
+ if(updateFeatures != null && updateFeatures.size()>0){
|
|
|
+ for(FeatureRate featureRate:updateFeatures){
|
|
|
+ String featureName = featureRate.getFeatureName();
|
|
|
+ String desc = featureRate.getDesc();
|
|
|
+ Map<String,Object> d = new HashMap<>();
|
|
|
+ if(desc != null){
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(desc);
|
|
|
+ d = jsonObject;
|
|
|
+ if(d.keySet().size() == 1 && "警惕".equals(d.keySet().toArray()[0])){
|
|
|
+ highDiagList.add(featureName);
|
|
|
+ }else {
|
|
|
+ queDiagList.add(featureName);
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ bigDiagList.add(featureName);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //先把警惕的加进去
|
|
|
+ if(highDiagList.size()>0){
|
|
|
+ for(int j =0;j<updateFeatures.size();j++){
|
|
|
+ if(highDiagList.indexOf(updateFeatures.get(j).getFeatureName()) == 1){
|
|
|
+ finalDiagList.add(updateFeatures.get(j));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //归一确诊
|
|
|
+
|
|
|
+
|
|
|
+ return finalDiagList;
|
|
|
+
|
|
|
+ }
|
|
|
+}
|