瀏覽代碼

自定义报警调整

chenminghua 2 年之前
父節點
當前提交
a4cfdfbca5

+ 3 - 3
gyee-sample-impala/src/main/java/com/gyee/impala/common/spring/InitialRunner.java

@@ -122,15 +122,15 @@ public class InitialRunner implements CommandLineRunner {
         faultType.stream().forEach(obj -> {
             if (obj.getCategory().equals("GZ")) {
                 faultTypeList.add(obj);
-                faultTypeMap.put(obj.getCode(), obj.getName().toUpperCase());
+                faultTypeMap.put(obj.getCode().toUpperCase(), obj.getName());
             }
             else if (obj.getCategory().equals("SCADABJ")) {
                 scadaWarnList.add(obj);
-                scadaWarnMap.put(obj.getCode(), obj.getName().toUpperCase());
+                scadaWarnMap.put(obj.getCode().toUpperCase(), obj.getName());
             }
             else if (obj.getCategory().equals("CUSTOMBJ")) {
                 customWarnList.add(obj);
-                customWarnMap.put(obj.getCode(), obj.getName().toUpperCase());
+                customWarnMap.put(obj.getCode().toUpperCase(), obj.getName());
             }
         });
     }

+ 23 - 17
gyee-sample-impala/src/main/java/com/gyee/impala/controller/sample/cases/CaseWarningController.java

@@ -3,6 +3,7 @@ package com.gyee.impala.controller.sample.cases;
 import com.alibaba.fastjson.JSONObject;
 import com.gyee.impala.common.result.JsonResult;
 import com.gyee.impala.common.result.ResultCode;
+import com.gyee.impala.common.spring.InitialRunner;
 import com.gyee.impala.model.master.Casewarningcustom;
 import com.gyee.impala.model.master.Casewarningscada;
 import com.gyee.impala.model.master.Powercurvebasic;
@@ -36,31 +37,36 @@ public class CaseWarningController {
      * @return
      */
     @GetMapping("/warning/custom/list")
-    public JSONObject warnCustomAll(String station, String wtId, String code, String st, String et) {
+    public JSONObject warnCustomAll(String station, String wtId, String[] code, String st, String et) {
         List<Casewarningcustom> list = customService.getAll(station, wtId, code, st, et);
         /**过滤  同类风机  次数、时长相加**/
         TreeMap<String, Map<String, List<Casewarningcustom>>> collect = list.stream()
                 .collect(Collectors.groupingBy(Casewarningcustom::getWindturbineid, TreeMap::new,
-                        Collectors.groupingBy(Casewarningcustom::getWarntype)));
+                        Collectors.groupingBy(Casewarningcustom::getWarncode)));
 
         /** 通过类型风机次数、时长相加 **/
         List<Casewarningcustom> ls = new ArrayList<>();
         collect.forEach((k, v) -> v.forEach((k1, v1) -> {
-            Casewarningcustom cs = new Casewarningcustom();
-            int count = 0;
-            double duration = 0;
-            for (Casewarningcustom o : v1) {
-                count += o.getCount();
-                duration += o.getDuration();
-                cs.setWarndes(o.getWarndes());
-            }
-            if (count != 0 && duration != 0){
-                cs.setWindturbineid(k);
-                cs.setWarntype(k1);
-                cs.setCount(count);
-                cs.setDuration(duration);
-                ls.add(cs);
-            }
+            Map<String, List<Casewarningcustom>> mpType = v1.stream().collect(Collectors.groupingBy(Casewarningcustom::getWarndes));
+            mpType.forEach((k2, v2) -> {
+                Casewarningcustom cs = new Casewarningcustom();
+                int count = 0;
+                double duration = 0;
+                for (Casewarningcustom o : v2) {
+                    count += o.getCount();
+                    duration += o.getDuration();
+                    cs.setWarndes(o.getWarndes());
+                }
+                if (count != 0 && duration != 0){
+                    cs.setWindturbineid(k);
+                    cs.setWarncode(k1);
+                    cs.setWarntype(InitialRunner.customWarnMap.get(k1));
+                    cs.setWarndes(k2);
+                    cs.setCount(count);
+                    cs.setDuration(duration);
+                    ls.add(cs);
+                }
+            });
         }));
         return JsonResult.successData(ResultCode.SUCCESS, ls);
     }

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

@@ -24,11 +24,11 @@ public class CasewarningcustomServiceImpl extends ServiceImpl<CasewarningcustomM
     private KuduDataSourceConfig kuduConfig;
 
     @Override
-    public List<Casewarningcustom> getAll(String station, String wtId, String warnCode, String st, String et) {
+    public List<Casewarningcustom> getAll(String station, String wtId, String[] warnCode, String st, String et) {
         ExcludeQueryWrapper<Casewarningcustom> wrapper = new ExcludeQueryWrapper<>();
         wrapper.eq("stationen", station)
                 .eq("windturbineid", wtId)
-                .eq("warncode", warnCode)
+                .in("warncode", warnCode)
                 .ge("time", st)
                 .le("time", et);
         try{

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

@@ -16,7 +16,7 @@ public interface CasewarningcustomService extends IService<Casewarningcustom> {
      * @param et   结束时间
      * @return
      */
-    List<Casewarningcustom> getAll(String station, String wtId, String warnCode, String st, String et);
+    List<Casewarningcustom> getAll(String station, String wtId, String[] warnCode, String st, String et);
 
     /**
      * 批量插入