瀏覽代碼

诊断报告部件过滤

chenminghua 2 年之前
父節點
當前提交
705f0a8c02

+ 18 - 8
gyee-sample-impala/src/main/java/com/gyee/impala/common/exception/AdviceException.java

@@ -3,25 +3,23 @@ package com.gyee.impala.common.exception;
 import com.alibaba.fastjson.JSONObject;
 import com.alibaba.fastjson.JSONObject;
 import com.gyee.impala.common.result.JsonResult;
 import com.gyee.impala.common.result.JsonResult;
 import com.gyee.impala.common.result.ResultCode;
 import com.gyee.impala.common.result.ResultCode;
+import lombok.extern.slf4j.Slf4j;
 import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.Logger;
 import org.apache.logging.log4j.Logger;
 import org.springframework.web.bind.annotation.ExceptionHandler;
 import org.springframework.web.bind.annotation.ExceptionHandler;
 import org.springframework.web.bind.annotation.RestControllerAdvice;
 import org.springframework.web.bind.annotation.RestControllerAdvice;
 
 
-
+@Slf4j
 @RestControllerAdvice
 @RestControllerAdvice
 public class AdviceException {
 public class AdviceException {
 
 
-    private static Logger logger = LogManager.getLogger(AdviceException.class);
-
-
     /**
     /**
      * 拦截未知的运行时异常
      * 拦截未知的运行时异常
      */
      */
     @ExceptionHandler(Exception.class)
     @ExceptionHandler(Exception.class)
     public JSONObject runException(Exception e)
     public JSONObject runException(Exception e)
     {
     {
-        logger.error(e.getMessage());
+        log.error(e.getMessage());
         return JsonResult.error(ResultCode.ERROR);
         return JsonResult.error(ResultCode.ERROR);
     }
     }
 
 
@@ -30,20 +28,32 @@ public class AdviceException {
      * 拦截未知的运行时异常
      * 拦截未知的运行时异常
      */
      */
     @ExceptionHandler(NullPointerException.class)
     @ExceptionHandler(NullPointerException.class)
-    public JSONObject nullPointerException(Exception e)
+    public JSONObject nullPointerException(NullPointerException e)
+    {
+        log.error(e.getMessage());
+        return JsonResult.error(ResultCode.ERROR);
+    }
+
+
+    /**
+     * 拦截自定义异常
+     */
+    @ExceptionHandler(RuntimeException.class)
+    public JSONObject runException(RuntimeException e)
     {
     {
-        logger.error(e.getMessage());
+        log.error(e.getMessage());
         return JsonResult.error(ResultCode.ERROR);
         return JsonResult.error(ResultCode.ERROR);
     }
     }
 
 
 
 
+
     /**
     /**
      * 拦截自定义异常
      * 拦截自定义异常
      */
      */
     @ExceptionHandler(CustomException.class)
     @ExceptionHandler(CustomException.class)
     public JSONObject customException(CustomException e)
     public JSONObject customException(CustomException e)
     {
     {
-        logger.error(e.getMessage());
+        log.error(e.getMessage());
         return JsonResult.error(e.getCode(), e.getMessage());
         return JsonResult.error(e.getCode(), e.getMessage());
     }
     }
 
 

+ 17 - 6
gyee-sample-impala/src/main/java/com/gyee/impala/controller/diagnose/DiagnoseReportController.java

@@ -1,5 +1,7 @@
 package com.gyee.impala.controller.diagnose;
 package com.gyee.impala.controller.diagnose;
 
 
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.alibaba.fastjson.JSONObject;
 import com.gyee.impala.common.result.JsonResult;
 import com.gyee.impala.common.result.JsonResult;
 import com.gyee.impala.common.result.ResultCode;
 import com.gyee.impala.common.result.ResultCode;
@@ -7,7 +9,9 @@ import com.gyee.impala.common.spring.InitialRunner;
 import com.gyee.impala.common.util.DateUtil;
 import com.gyee.impala.common.util.DateUtil;
 import com.gyee.impala.model.custom.diagnose.DataInfo;
 import com.gyee.impala.model.custom.diagnose.DataInfo;
 import com.gyee.impala.model.custom.diagnose.PointData;
 import com.gyee.impala.model.custom.diagnose.PointData;
+import com.gyee.impala.model.custom.diagnose.TrainPointWeight;
 import com.gyee.impala.model.master.Casefaultalg;
 import com.gyee.impala.model.master.Casefaultalg;
+import com.gyee.impala.model.master.diagnose.Diagnosepoint;
 import com.gyee.impala.model.master.diagnose.Diagnosetrainhistory;
 import com.gyee.impala.model.master.diagnose.Diagnosetrainhistory;
 import com.gyee.impala.service.custom.diagnose.AlarmService;
 import com.gyee.impala.service.custom.diagnose.AlarmService;
 import com.gyee.impala.service.master.CasefaultalgService;
 import com.gyee.impala.service.master.CasefaultalgService;
@@ -18,10 +22,7 @@ import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 import org.springframework.web.bind.annotation.RestController;
 
 
-import java.util.Calendar;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 import java.util.stream.Collectors;
 import java.util.stream.Collectors;
 import java.util.stream.Stream;
 import java.util.stream.Stream;
 
 
@@ -61,14 +62,23 @@ public class DiagnoseReportController {
         info.setStartTs(cal.getTimeInMillis() + "");
         info.setStartTs(cal.getTimeInMillis() + "");
         cal.add(Calendar.MINUTE, 15);
         cal.add(Calendar.MINUTE, 15);
         info.setEndTs(cal.getTimeInMillis() + "");
         info.setEndTs(cal.getTimeInMillis() + "");
+
         Map<String, List<PointData>> mappoint = diagnosereportService.getpointweightDataList(info, history.get(0).getPointweight());
         Map<String, List<PointData>> mappoint = diagnosereportService.getpointweightDataList(info, history.get(0).getPointweight());
         Map<String, Object> alarm = alarmService.getAlarmTree(fault.getStationen(), fault.getWindturbineid(), fault.getStarttime());
         Map<String, Object> alarm = alarmService.getAlarmTree(fault.getStationen(), fault.getWindturbineid(), fault.getStarttime());
 
 
+        List<TrainPointWeight> collect = new ArrayList<>();
+        List<TrainPointWeight> list = JSONArray.parseArray(history.get(0).getPointweight(), TrainPointWeight.class);
+        for (TrainPointWeight t : list){
+            if (mappoint.containsKey(t.getMeasuring_point()))
+                collect.add(t);
+        }
+        history.get(0).setPointweight(JSON.toJSONString(collect));
+
         Map<String, Object> map = new HashMap<>();
         Map<String, Object> map = new HashMap<>();
         map.put("fault", fault);
         map.put("fault", fault);
         map.put("info", history);
         map.put("info", history);
         map.put("alarm", alarm);
         map.put("alarm", alarm);
-        map.put("curve",mappoint);
+        map.put("curve", mappoint);
         return JsonResult.successData(ResultCode.SUCCESS, map);
         return JsonResult.successData(ResultCode.SUCCESS, map);
     }
     }
 
 
@@ -102,7 +112,7 @@ public class DiagnoseReportController {
      * @return
      * @return
      */
      */
     @GetMapping("/grads")
     @GetMapping("/grads")
-    public JSONObject getGrads(String station, String model, String wtId, String time){
+    public JSONObject getGrads(String station, String model, String wtId, String time, String fault){
         List<Diagnosetrainhistory> collect = InitialRunner.historyModelMap.get(station + "_" + model)
         List<Diagnosetrainhistory> collect = InitialRunner.historyModelMap.get(station + "_" + model)
                 .stream().filter(a -> a.isEnable()).collect(Collectors.toList());
                 .stream().filter(a -> a.isEnable()).collect(Collectors.toList());
 
 
@@ -111,6 +121,7 @@ public class DiagnoseReportController {
         info.setStationId(station);
         info.setStationId(station);
         info.setModelId(model);
         info.setModelId(model);
         info.setThingId(wtId);
         info.setThingId(wtId);
+        info.setFaultType(fault);
         cal.setTime(DateUtil.parseStrtoDate(time, DateUtil.YYYY_MM_DD_HH_MM_SS));
         cal.setTime(DateUtil.parseStrtoDate(time, DateUtil.YYYY_MM_DD_HH_MM_SS));
         cal.add(Calendar.MINUTE, -10);
         cal.add(Calendar.MINUTE, -10);
         info.setStartTs(cal.getTimeInMillis() + "");
         info.setStartTs(cal.getTimeInMillis() + "");

+ 3 - 1
gyee-sample-impala/src/main/java/com/gyee/impala/model/custom/diagnose/DataInfo.java

@@ -1,5 +1,7 @@
 package com.gyee.impala.model.custom.diagnose;
 package com.gyee.impala.model.custom.diagnose;
 
 
+import org.apache.commons.lang3.StringUtils;
+
 /**
 /**
  * 数据信息
  * 数据信息
  * @author xysn
  * @author xysn
@@ -84,7 +86,7 @@ public class DataInfo {
     }
     }
 
 
     public String getFaultType() {
     public String getFaultType() {
-        return faultType;
+        return StringUtils.isEmpty(faultType) ? "" : faultType;
     }
     }
 
 
     public void setFaultType(String faultType) {
     public void setFaultType(String faultType) {

+ 6 - 0
gyee-sample-impala/src/main/java/com/gyee/impala/model/custom/diagnose/TrainPointWeight.java

@@ -1,12 +1,18 @@
 package com.gyee.impala.model.custom.diagnose;
 package com.gyee.impala.model.custom.diagnose;
 
 
+import com.alibaba.fastjson.annotation.JSONField;
 import lombok.Data;
 import lombok.Data;
 
 
 @Data
 @Data
 public class TrainPointWeight {
 public class TrainPointWeight {
 
 
+    @JSONField(name = "Importance")
     private String Importance;
     private String Importance;
+    @JSONField(name = "UniformCode")
     private String UniformCode;
     private String UniformCode;
+    @JSONField(name = "Measuring_point")
     private String Measuring_point;
     private String Measuring_point;
+    @JSONField(name = "index")
     private int index;
     private int index;
+
 }
 }

+ 3 - 2
gyee-sample-impala/src/main/java/com/gyee/impala/service/impl/master/diagnose/DiagnosereportServiceImpl.java

@@ -76,6 +76,7 @@ public class DiagnosereportServiceImpl extends ServiceImpl<DiagnosereportMapper,
         }
         }
     }
     }
 
 
+
     @Override
     @Override
     public Map<String, List<PointData>> getpointweightDataList(DataInfo info, String pointweight) {
     public Map<String, List<PointData>> getpointweightDataList(DataInfo info, String pointweight) {
         List<Diagnosepoint> point = InitialRunner.mapPoint.get(info.getStationId()).get(info.getModelId()).stream()
         List<Diagnosepoint> point = InitialRunner.mapPoint.get(info.getStationId()).get(info.getModelId()).stream()
@@ -93,8 +94,8 @@ public class DiagnosereportServiceImpl extends ServiceImpl<DiagnosereportMapper,
             }
             }
 
 
             Diagnosepoint pt = map.get(uniformCode);
             Diagnosepoint pt = map.get(uniformCode);
-            if (null != pt && (info.getFaultType().equalsIgnoreCase(pt.getWidgetcode()) || pt.getWidgetcode().equalsIgnoreCase("QT"))){
-                newpoint.add(map.get(uniformCode));
+            if (null != pt && (info.getFaultType().equals(pt.getWidgetcode()) || pt.getWidgetcode().equals("QT"))){
+                newpoint.add(pt);
             }
             }
         }
         }
         dataPointService.formatUniformcode(newpoint);
         dataPointService.formatUniformcode(newpoint);