Browse Source

离线故障诊断

chenminghua 2 years ago
parent
commit
222d91cab8

+ 18 - 4
gyee-sample-impala/src/main/java/com/gyee/impala/controller/diagnose/DiagnoseFaultController.java

@@ -8,6 +8,7 @@ import com.gyee.impala.model.custom.diagnose.FaultInfo;
 import com.gyee.impala.model.master.Casefaultalg;
 import com.gyee.impala.model.master.Casefaultalg;
 import com.gyee.impala.service.custom.diagnose.AutoCmdService;
 import com.gyee.impala.service.custom.diagnose.AutoCmdService;
 import com.gyee.impala.service.master.CasefaultalgService;
 import com.gyee.impala.service.master.CasefaultalgService;
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.bind.annotation.*;
 import java.util.ArrayList;
 import java.util.ArrayList;
@@ -30,6 +31,7 @@ public class DiagnoseFaultController {
 
 
     @GetMapping("/offline")
     @GetMapping("/offline")
     public JSONObject offline(@RequestParam(value = "station", required = false) String station,
     public JSONObject offline(@RequestParam(value = "station", required = false) String station,
+                              @RequestParam(value = "windturbindid", required = false) String wtId,
                               @RequestParam(value = "id", required = false) String[] id,
                               @RequestParam(value = "id", required = false) String[] id,
                               @RequestParam(value = "faultid", required = false) Long[] faultid,
                               @RequestParam(value = "faultid", required = false) Long[] faultid,
                               @RequestParam(value = "model", required = false) String[] model,
                               @RequestParam(value = "model", required = false) String[] model,
@@ -40,13 +42,20 @@ public class DiagnoseFaultController {
                               @RequestParam(value = "confirm", required = false) Optional<Boolean> confirm){
                               @RequestParam(value = "confirm", required = false) Optional<Boolean> confirm){
         boolean conf = confirm.isPresent() ? confirm.get() : false;
         boolean conf = confirm.isPresent() ? confirm.get() : false;
         if (conf){
         if (conf){
-            List<Casefaultalg> list = casefaultalgService.getAll(station, id, faultid, model, faultcode, st, et, algcode, false);
+            List<Casefaultalg> list = casefaultalgService.getAll(station, wtId, id, faultid, model, faultcode, st, et, algcode, false);
             return JsonResult.successData(ResultCode.SUCCESS, list);
             return JsonResult.successData(ResultCode.SUCCESS, list);
         }else{
         }else{
             List<Casefaultalg> array = new ArrayList<>();
             List<Casefaultalg> array = new ArrayList<>();
-            List<Casefaultalg> list = casefaultalgService.getAll(station, id, faultid, model, faultcode, st, et, algcode, false);
+            List<Casefaultalg> list = casefaultalgService.getAll(station, wtId, id, faultid, model, faultcode, st, et, algcode, false);
             List<FaultInfo> faults = remoteServiceBuilder.sharding().getFaultRecent(et);
             List<FaultInfo> faults = remoteServiceBuilder.sharding().getFaultRecent(et);
-            List<FaultInfo> collect = faults.stream().filter(f -> f.getCategory1().equals("FJ") && f.getCategory2().equals("GZ")).collect(Collectors.toList());
+            List<FaultInfo> collect;
+            if (!StringUtils.isEmpty(wtId))
+                collect = faults.stream().filter(f -> f.getCategory1().equals("FJ")
+                        && f.getCategory2().equals("GZ")&& f.getWindturbineId().equals(wtId)).collect(Collectors.toList());
+            else
+                collect = faults.stream().filter(f -> f.getCategory1().equals("FJ")
+                        && f.getCategory2().equals("GZ")).collect(Collectors.toList());
+
             for (int i = 0; i < collect.size(); i++){
             for (int i = 0; i < collect.size(); i++){
                 FaultInfo info = collect.get(i);
                 FaultInfo info = collect.get(i);
                 if (list == null || list.size() == 0){
                 if (list == null || list.size() == 0){
@@ -63,7 +72,12 @@ public class DiagnoseFaultController {
 
 
 
 
     @PostMapping("/offlinediagnose")
     @PostMapping("/offlinediagnose")
-    public JSONObject offlineDiagnose(@RequestBody List<Casefaultalg> faults){
+    public JSONObject offlineDiagnose(@RequestBody JSONObject json){
+        if (json == null)
+            return JsonResult.error(ResultCode.PARAM_IS_BLANK);
+
+        String model = json.getString("model");
+        List<Casefaultalg> faults = JSONObject.parseArray(json.getJSONArray("faults").toString(), Casefaultalg.class);
         faults.stream().forEach(obj -> {
         faults.stream().forEach(obj -> {
             FaultInfo info = new FaultInfo();
             FaultInfo info = new FaultInfo();
             info.setStationId(obj.getStationen());
             info.setStationId(obj.getStationen());

+ 2 - 1
gyee-sample-impala/src/main/java/com/gyee/impala/controller/sample/cases/CaseFaultAlgController.java

@@ -24,6 +24,7 @@ public class CaseFaultAlgController {
 
 
     @GetMapping("/faultalg/list")
     @GetMapping("/faultalg/list")
     public JSONObject faultAlgList(@RequestParam(value = "station", required = false) String station,
     public JSONObject faultAlgList(@RequestParam(value = "station", required = false) String station,
+                                   @RequestParam(value = "windturbindid", required = false) String wtId,
                                    @RequestParam(value = "id", required = false) String[] id,
                                    @RequestParam(value = "id", required = false) String[] id,
                                    @RequestParam(value = "faultid", required = false) Long[] faultid,
                                    @RequestParam(value = "faultid", required = false) Long[] faultid,
                                    @RequestParam(value = "model", required = false) String[] model,
                                    @RequestParam(value = "model", required = false) String[] model,
@@ -33,7 +34,7 @@ public class CaseFaultAlgController {
                                    @RequestParam(value = "algcode", required = false) String algcode,
                                    @RequestParam(value = "algcode", required = false) String algcode,
                                    @RequestParam(value = "confirm", required = false) Boolean confirm){
                                    @RequestParam(value = "confirm", required = false) Boolean confirm){
 
 
-        List<Casefaultalg> list = casefaultalgService.getAll(station, id, faultid, model, faultcode, st, et, algcode, confirm);
+        List<Casefaultalg> list = casefaultalgService.getAll(station, wtId, id, faultid, model, faultcode, st, et, algcode, confirm);
         return JsonResult.successData(ResultCode.SUCCESS, list);
         return JsonResult.successData(ResultCode.SUCCESS, list);
     }
     }
 
 

+ 2 - 1
gyee-sample-impala/src/main/java/com/gyee/impala/service/impl/master/CasefaultalgServiceImpl.java

@@ -52,10 +52,11 @@ public class CasefaultalgServiceImpl extends ServiceImpl<CasefaultalgMapper, Cas
 
 
 
 
     @Override
     @Override
-    public List<Casefaultalg> getAll(String station, String[] id, Long[] faultid, String[] model, String[] faultcode,
+    public List<Casefaultalg> getAll(String station, String wtId, String[] id, Long[] faultid, String[] model, String[] faultcode,
                                      String st, String et, String algcode, Boolean confirm) {
                                      String st, String et, String algcode, Boolean confirm) {
         ExcludeQueryWrapper<Casefaultalg> wrapper = new ExcludeQueryWrapper<>();
         ExcludeQueryWrapper<Casefaultalg> wrapper = new ExcludeQueryWrapper<>();
         wrapper.eq("stationen", station)
         wrapper.eq("stationen", station)
+                .eq("windturbineid", wtId)
                 .in("id", id)
                 .in("id", id)
                 .in("faultid", faultid)
                 .in("faultid", faultid)
                 .in("model", model)
                 .in("model", model)

+ 1 - 1
gyee-sample-impala/src/main/java/com/gyee/impala/service/impl/master/diagnose/DiagnosetrainhistoryServiceImpl.java

@@ -109,7 +109,7 @@ public class DiagnosetrainhistoryServiceImpl extends ServiceImpl<Diagnosetrainhi
         wrapper.eq("enable", enable);
         wrapper.eq("enable", enable);
         wrapper.eq("name", name);
         wrapper.eq("name", name);
         wrapper.eq("code", code);
         wrapper.eq("code", code);
-        wrapper.eq("model",model);
+        wrapper.like("model","%" + model + "%");
         try{
         try{
             return baseMapper.selectList(wrapper);
             return baseMapper.selectList(wrapper);
         } catch (Exception e){
         } catch (Exception e){

+ 1 - 1
gyee-sample-impala/src/main/java/com/gyee/impala/service/master/CasefaultalgService.java

@@ -34,7 +34,7 @@ public interface CasefaultalgService extends IService<Casefaultalg> {
      * @param confirm   是否筛选到结论样本库
      * @param confirm   是否筛选到结论样本库
      * @return
      * @return
      */
      */
-    List<Casefaultalg> getAll(String station, String[] id, Long[] faultid, String[] model, String[] faultcode,
+    List<Casefaultalg> getAll(String station, String wtId, String[] id, Long[] faultid, String[] model, String[] faultcode,
                               String st, String et, String algcode, Boolean confirm);
                               String st, String et, String algcode, Boolean confirm);