chenminghua 2 年 前
コミット
a304d671bf

+ 31 - 2
gyee-sample-impala/src/main/java/com/gyee/impala/controller/sample/cases/CaseWarningController.java

@@ -1,16 +1,21 @@
 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.model.master.Casewarningcustom;
 import com.gyee.impala.model.master.Casewarningscada;
+import com.gyee.impala.model.master.Powercurvebasic;
 import com.gyee.impala.service.master.CasewarningcustomService;
 import com.gyee.impala.service.master.CasewarningscadaService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
+
+import java.util.ArrayList;
 import java.util.List;
+import java.util.Map;
+import java.util.TreeMap;
+import java.util.stream.Collectors;
 
 /**
  * 故障样本库操作
@@ -33,7 +38,31 @@ public class CaseWarningController {
     @GetMapping("/warning/custom/list")
     public JSONObject warnCustomAll(String station, String wtId, String code, String st, String et) {
         List<Casewarningcustom> list = customService.getAll(station, wtId, code, st, et);
-        return JsonResult.successData(ResultCode.SUCCESS, list);
+        /**过滤  同类风机  次数、时长相加**/
+        TreeMap<String, Map<String, List<Casewarningcustom>>> collect = list.stream()
+                .collect(Collectors.groupingBy(Casewarningcustom::getWindturbineid, TreeMap::new,
+                        Collectors.groupingBy(Casewarningcustom::getWarntype)));
+
+        /** 通过类型风机次数、时长相加 **/
+        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);
+            }
+        }));
+        return JsonResult.successData(ResultCode.SUCCESS, ls);
     }
 
 

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

@@ -116,19 +116,11 @@ public class PowercurvebasicServiceImpl extends ServiceImpl<PowercurvebasicMappe
             if (list == null || list.size() == 0)
                 return null;
             /**多层分组**/
-            Map<Integer, Map<String, Map<String, List<Powercurvebasic>>>> collect = list.stream().
-                    collect(Collectors.groupingBy(Powercurvebasic::getIntervals,
+            Map<Integer, Map<String, Map<String, List<Powercurvebasic>>>> map = list.stream().
+                    collect(Collectors.groupingBy(Powercurvebasic::getIntervals, TreeMap::new,
                             Collectors.groupingBy(Powercurvebasic::getTime,
                                     Collectors.groupingBy(Powercurvebasic::getStationen))));
 
-            /**排序**/
-            Map<Integer, Map<String, Map<String, List<Powercurvebasic>>>> map = new TreeMap<>();
-            collect.forEach((k, v) -> {
-                Map<String, Map<String, List<Powercurvebasic>>> mp = new TreeMap<>();
-                collect.get(k).forEach(mp::put);
-                map.put(k, mp);
-            });
-
             map.forEach((k, v) -> {
                 String key = (k / 60) < 1 ? "1秒钟" : (k / 60) + "分钟";
                 List<Object> l1 = new ArrayList<>();