ソースを参照

双率bug修复

wangb@gyee-china.com 1 年間 前
コミット
9e5f1f3aaf

+ 106 - 11
web/runeconomy-jjyx/src/main/java/com/gyee/runeconomy/service/Economic/EconomicService.java

@@ -602,9 +602,65 @@ public class EconomicService {
 
         List<ProEconFaultFault> getlist = proEconFaultFaultService.getlist(beginDate,endDate);
 
+        Map<String, List<ProEconFaultFault>> zfrequencyls = new LinkedHashMap<>();
 
-        Map<String,List<ProEconFaultFault>> zfrequencyls = getlist.stream()
-                .filter( wp-> wpids.equals(wp.getWindpowerstationId())).collect(Collectors.groupingBy(ProEconFaultFault::getEquipmentId));
+        List<String> ll = new ArrayList<>();
+        Map<String, List<ProBasicOrganizeEquipment>> collect = null;
+        if (!wpids.isEmpty()) {
+            zfrequencyls = getlist.stream()
+                    .filter(wp -> wpids.equals(wp.getWindpowerstationId())).collect(Collectors.groupingBy(ProEconFaultFault::getEquipmentId));
+        }
+
+        if (wpids.isEmpty() && companys.endsWith("ZGS")){
+            collect = CacheContext.organizeEquipmentList.stream()
+                    .filter(wt1 -> companys.contains(wt1.getCompanyId())).collect(Collectors.groupingBy(ProBasicOrganizeEquipment::getWindpowerstationId));
+
+//            for (Map.Entry <String, List<ProBasicOrganizeEquipment>>  wtid : collect.entrySet()) {
+//                String key = wtid.getKey();
+//                zfrequencyls = getlist.stream()
+//                        .filter(wp -> key.equals(wp.getWindpowerstationId())).collect(Collectors.groupingBy(ProEconFaultFault::getEquipmentId));
+//            }
+
+            Map<String, List<ProEconFaultFault>> resultMap = new LinkedHashMap<>();
+            for (Map.Entry<String, List<ProBasicOrganizeEquipment>> wtid : collect.entrySet()) {
+                String key = wtid.getKey();
+                zfrequencyls = getlist.stream()
+                        .filter(wp -> key.equals(wp.getWindpowerstationId()))
+                        .collect(Collectors.groupingBy(ProEconFaultFault::getEquipmentId));
+                // 合并到最终结果中
+                for (Map.Entry<String, List<ProEconFaultFault>> entry : zfrequencyls.entrySet()) {
+                    String equipmentId = entry.getKey();
+                    List<ProEconFaultFault> faults = entry.getValue();
+                    List<ProEconFaultFault> existingFaults = resultMap.getOrDefault(equipmentId, new ArrayList<>());
+                    existingFaults.addAll(faults);
+                    resultMap.put(equipmentId, existingFaults);
+                }
+            }
+            zfrequencyls = resultMap;
+
+
+        }
+        if (wpids.isEmpty() && companys.endsWith("RGN")){
+            collect = CacheContext.organizeEquipmentList.stream()
+                    .filter(wt1 -> companys.contains(wt1.getRegionId())).collect(Collectors.groupingBy(ProBasicOrganizeEquipment::getWindpowerstationId));
+
+            Map<String, List<ProEconFaultFault>> resultMap = new LinkedHashMap<>();
+            for (Map.Entry<String, List<ProBasicOrganizeEquipment>> wtid : collect.entrySet()) {
+                String key = wtid.getKey();
+                zfrequencyls = getlist.stream()
+                        .filter(wp -> key.equals(wp.getWindpowerstationId()))
+                        .collect(Collectors.groupingBy(ProEconFaultFault::getEquipmentId));
+                // 合并到最终结果中
+                for (Map.Entry<String, List<ProEconFaultFault>> entry : zfrequencyls.entrySet()) {
+                    String equipmentId = entry.getKey();
+                    List<ProEconFaultFault> faults = entry.getValue();
+                    List<ProEconFaultFault> existingFaults = resultMap.getOrDefault(equipmentId, new ArrayList<>());
+                    existingFaults.addAll(faults);
+                    resultMap.put(equipmentId, existingFaults);
+                }
+            }
+            zfrequencyls = resultMap;
+        }
 
         for (String wtid : zfrequencyls.keySet()) {
             Tmelinessvo vo = new Tmelinessvo();
@@ -649,16 +705,42 @@ public class EconomicService {
 
         List<ProEconCleaningInput> getlist = proEconCleaningInputService.getlist(beginDate,endDate);
 
-        QueryWrapper<ProEconEquipmentInfoDay1> qw = new QueryWrapper<>();
-        qw.between("record_date", DateUtil.offsetDay(beginDate,-5), beginDate);
-        qw.like("windpowerstation_id",wpids);
-        List<ProEconEquipmentInfoDay1> qwt = proEconEquipmentInfoDay1Service.list(qw);
+        List<ProEconEquipmentInfoDay1> qwt =null;
+        List<ProEconEquipmentInfoDay1> hwt = null;
+        if (!wpids.isEmpty()) {
+            QueryWrapper<ProEconEquipmentInfoDay1> qw = new QueryWrapper<>();
+            qw.between("record_date", DateUtil.offsetDay(beginDate, -5), beginDate);
+            qw.like("windpowerstation_id", wpids);
+            qwt = proEconEquipmentInfoDay1Service.list(qw);
 
 
-        QueryWrapper<ProEconEquipmentInfoDay1> hw = new QueryWrapper<>();
-        hw.between("record_date", beginDate,DateUtil.offsetDay(beginDate,+5));
-        hw.like("windpowerstation_id",wpids);
-        List<ProEconEquipmentInfoDay1> hwt = proEconEquipmentInfoDay1Service.list(hw);
+            QueryWrapper<ProEconEquipmentInfoDay1> hw = new QueryWrapper<>();
+            hw.between("record_date", beginDate, DateUtil.offsetDay(beginDate, +5));
+            hw.like("windpowerstation_id", wpids);
+            hwt = proEconEquipmentInfoDay1Service.list(hw);
+        }
+        if (wpids.isEmpty() && companys.endsWith("ZGS")){
+            QueryWrapper<ProEconEquipmentInfoDay1> qw = new QueryWrapper<>();
+            qw.between("record_date", DateUtil.offsetDay(beginDate,-5), beginDate);
+            qw.like("company_id",companys);
+            qwt = proEconEquipmentInfoDay1Service.list(qw);
+
+            QueryWrapper<ProEconEquipmentInfoDay1> hw = new QueryWrapper<>();
+            hw.between("record_date", beginDate,DateUtil.offsetDay(beginDate,+5));
+            qw.like("company_id",companys);
+            hwt = proEconEquipmentInfoDay1Service.list(hw);
+        }
+        if (wpids.isEmpty() && companys.endsWith("RGN")){
+            QueryWrapper<ProEconEquipmentInfoDay1> qw = new QueryWrapper<>();
+            qw.between("record_date", DateUtil.offsetDay(beginDate,-5), beginDate);
+            qw.like("region_id",companys);
+            qwt = proEconEquipmentInfoDay1Service.list(qw);
+
+            QueryWrapper<ProEconEquipmentInfoDay1> hw = new QueryWrapper<>();
+            hw.between("record_date", beginDate,DateUtil.offsetDay(beginDate,+5));
+            qw.like("region_id",companys);
+            hwt = proEconEquipmentInfoDay1Service.list(hw);
+        }
 
 
       for (ProEconEquipmentInfoDay1 q : qwt)
@@ -681,7 +763,20 @@ public class EconomicService {
         Map<String,List<MaxVo>> qwtls = qwtpj.stream().collect(Collectors.groupingBy(MaxVo::getId));
 
         Map<String,List<Glqx>> hwtls = hwtpj.stream().collect(Collectors.groupingBy(Glqx::getId));
-        List<ProBasicOrganizeEquipment> collect = CacheContext.organizeEquipmentList.stream().filter(wt1 -> wpids.contains(wt1.getWindpowerstationId())).collect(Collectors.toList());
+
+        List<ProBasicOrganizeEquipment> collect = null;
+        if (!wpids.isEmpty()) {
+             collect = CacheContext.organizeEquipmentList.stream()
+                    .filter(wt1 -> wpids.contains(wt1.getWindpowerstationId())).collect(Collectors.toList());
+        }
+        if (wpids.isEmpty() && companys.endsWith("ZGS")){
+            collect = CacheContext.organizeEquipmentList.stream()
+                    .filter(wt1 -> companys.contains(wt1.getCompanyId())).collect(Collectors.toList());
+        }
+        if (wpids.isEmpty() && companys.endsWith("RGN")){
+            collect = CacheContext.organizeEquipmentList.stream()
+                    .filter(wt1 -> companys.contains(wt1.getRegionId())).collect(Collectors.toList());
+        }
 
         for (Map.Entry<String, List<MaxVo>> entry : qwtls.entrySet()) {
             String qkey = entry.getKey();  //设备