Przeglądaj źródła

系统效率代码修改

wangb@gyee-china.com 1 rok temu
rodzic
commit
a080233546

+ 49 - 45
web/runeconomy-xk/src/main/java/com/gyee/runeconomy/service/Comprehensive/PVSystemEfficiencyCalculator.java

@@ -81,7 +81,7 @@ public class PVSystemEfficiencyCalculator {
         List<ProBasicPowerstation> wplsG = CacheContext.wplsG;
         List<ProBasicProject> pjlsG = CacheContext.pjls.stream().filter(p -> p.getSpare4().equals("2")).collect(Collectors.toList());
         List<ProBasicLine> lnlsG = CacheContext.lnls.stream().filter(p -> p.getSpare4().equals("2")).collect(Collectors.toList());
-        List<ProBasicEquipment> wtlsG = CacheContext.wtls.stream().filter(p -> p.getSpare1().equals("IN")).collect(Collectors.toList());
+//        List<ProBasicEquipment> wtlsG = CacheContext.wtls.stream().filter(p -> p.getSpare1().equals("IN")).collect(Collectors.toList());
 
 
 //        计算场站级别
@@ -390,73 +390,77 @@ public class PVSystemEfficiencyCalculator {
         int calFirstMonth4 = calFirstDayZeroHour4.get(Calendar.MONTH) + 1;
         Date date = null;
         List<ProEconSystemEfficiencyEquipment> stringList = new ArrayList<>();
-        for (ProBasicEquipment wt : wtlsG) {
+        for (ProBasicPowerstation wp : CacheContext.wplsG) {
+            List<ProBasicEquipment> wtlsG = CacheContext.wtls.stream().filter(p -> p.getSpare1().equals("IN") && wp.getId().equals(p.getWindpowerstationId())).collect(Collectors.toList());
 
-            List<ProEconEquipmentmodel> collect = CacheContext.equipmentmodels.stream().filter(w -> wt.getModelId().equals(w.getId())).collect(Collectors.toList());
+            for (ProBasicEquipment wt : wtlsG) {
+
+                List<ProEconEquipmentmodel> collect = CacheContext.equipmentmodels.stream().filter(w -> wt.getModelId().equals(w.getId())).collect(Collectors.toList());
 
 //            for (int i = 0; i < currentMonth; i++) {
 
 
-            if (calFirstMonth4 == currentMonth && dqnf == currentyear) {
-                Calendar calendar5 = Calendar.getInstance();
-                ts4 = calendar5.get(Calendar.DAY_OF_MONTH);
-            } else {
-                // 获取当前月份的天数
-                ts4 = calFirstDayZeroHour4.getActualMaximum(Calendar.DAY_OF_MONTH);
-            }
+                if (calFirstMonth4 == currentMonth && dqnf == currentyear) {
+                    Calendar calendar5 = Calendar.getInstance();
+                    ts4 = calendar5.get(Calendar.DAY_OF_MONTH);
+                } else {
+                    // 获取当前月份的天数
+                    ts4 = calFirstDayZeroHour4.getActualMaximum(Calendar.DAY_OF_MONTH);
+                }
 
-            List<ProEconEquipmentInfoDay1> rzqdls = proEconEquipmentInfoDay1Service.getmax(wt.getId(), firstDayZeroHour4);
+                List<ProEconEquipmentInfoDay1> rzqdls = proEconEquipmentInfoDay1Service.getmax(wt.getId(), firstDayZeroHour4);
 
-            double solarRadiationWattsPerSquareMeter = 0.0; // 太阳能辐射,单位为W/m²
-            double actualPowerOutputKilowattHours = 0.0; // 实际发电量,单位为千瓦时(kWh)
-            double moduleCapacityKilowatts = 0.0; // 光伏模块额定容量,单位为千瓦(kW)
-            double pr = 0.0;
+                double solarRadiationWattsPerSquareMeter = 0.0; // 太阳能辐射,单位为W/m²
+                double actualPowerOutputKilowattHours = 0.0; // 实际发电量,单位为千瓦时(kWh)
+                double moduleCapacityKilowatts = 0.0; // 光伏模块额定容量,单位为千瓦(kW)
+                double pr = 0.0;
 
-            if (!rzqdls.isEmpty() && rzqdls != null) {
-                for (ProEconEquipmentInfoDay1 day : rzqdls) {
-                    actualPowerOutputKilowattHours = day.getYfdl().doubleValue();
-                    solarRadiationWattsPerSquareMeter = day.getYpjfs().doubleValue();
-                    date = day.getRecordDate();
+                if (!rzqdls.isEmpty() && rzqdls != null) {
+                    for (ProEconEquipmentInfoDay1 day : rzqdls) {
+                        actualPowerOutputKilowattHours = day.getYfdl().doubleValue();
+                        solarRadiationWattsPerSquareMeter = day.getYpjfs().doubleValue();
+                        date = day.getRecordDate();
+                    }
                 }
-            }
 
 
-            moduleCapacityKilowatts = collect.get(0).getPowerProduction();
+                moduleCapacityKilowatts = collect.get(0).getPowerProduction();
 
-            double expectedPowerOutputKilowattHours = calculateExpectedPowerOutput(solarRadiationWattsPerSquareMeter, moduleCapacityKilowatts, ts4); // 预期发电量(kWh)
-            pr = calculatePR(actualPowerOutputKilowattHours, expectedPowerOutputKilowattHours); // 计算PR
+                double expectedPowerOutputKilowattHours = calculateExpectedPowerOutput(solarRadiationWattsPerSquareMeter, moduleCapacityKilowatts, ts4); // 预期发电量(kWh)
+                pr = calculatePR(actualPowerOutputKilowattHours, expectedPowerOutputKilowattHours); // 计算PR
 
-            pr = StringUtils.round(pr, 2);
-            solarRadiationWattsPerSquareMeter = StringUtils.round(solarRadiationWattsPerSquareMeter, 2);
+                pr = StringUtils.round(pr, 2);
+                solarRadiationWattsPerSquareMeter = StringUtils.round(solarRadiationWattsPerSquareMeter, 2);
 
 
-            ProEconSystemEfficiencyEquipment power = new ProEconSystemEfficiencyEquipment();
-            if (date != null) {
-                power.setId(StringUtils.getUUID());
-                power.setForeignKeyId(wt.getNemCode());
-                power.setStationId(wt.getWindpowerstationId());
-                power.setProjectId(wt.getProjectId());
-                power.setLineId(wt.getLineId());
-                power.setEquipmentId(wt.getId());
-                power.setLocation("wt");
-                power.setDataDate(date);
-                power.setPowerGeneration(actualPowerOutputKilowattHours);
-                power.setLlfdlmax(expectedPowerOutputKilowattHours);
-                power.setRzqd(solarRadiationWattsPerSquareMeter);
-                power.setEfficiency(pr);
-                power.setOrderNum(wt.getOrderNum());
-                stringList.add(power);
-            }
+                ProEconSystemEfficiencyEquipment power = new ProEconSystemEfficiencyEquipment();
+                if (date != null) {
+                    power.setId(StringUtils.getUUID());
+                    power.setForeignKeyId(wt.getNemCode());
+                    power.setStationId(wt.getWindpowerstationId());
+                    power.setProjectId(wt.getProjectId());
+                    power.setLineId(wt.getLineId());
+                    power.setEquipmentId(wt.getId());
+                    power.setLocation("wt");
+                    power.setDataDate(date);
+                    power.setPowerGeneration(actualPowerOutputKilowattHours);
+                    power.setLlfdlmax(expectedPowerOutputKilowattHours);
+                    power.setRzqd(solarRadiationWattsPerSquareMeter);
+                    power.setEfficiency(pr);
+                    power.setOrderNum(wt.getOrderNum());
+                    stringList.add(power);
+                }
 
 
 //
 //            firstDayZeroHour4 = DateUtils.addMonths(firstDayZeroHour4, 1);
 //            calFirstDayZeroHour4.setTime(firstDayZeroHour4);
 //            calFirstMonth4 = calFirstDayZeroHour4.get(Calendar.MONTH) + 1;
-            ts4 = calFirstDayZeroHour4.getActualMaximum(Calendar.DAY_OF_MONTH);
+                ts4 = calFirstDayZeroHour4.getActualMaximum(Calendar.DAY_OF_MONTH);
 //        }
-            // 恢复初始值
+                // 恢复初始值
 //            firstDayZeroHour4 = initialFirstDayZeroHour4;
+            }
         }
 
         efficiencyEquipmentService.batchAdd(stringList);

+ 122 - 36
web/runeconomy-xk/src/main/java/com/gyee/runeconomy/service/auto/impl/ProEconSystemEfficiencyEquipmentServiceImpl.java

@@ -50,7 +50,6 @@ public class ProEconSystemEfficiencyEquipmentServiceImpl extends ServiceImpl<Pro
 
         return true;
     }
-
     @Override
     public List<ProEconSystemEfficiencyEquipment> getbq(String foreignKeyId, Date date) {
         List<ProEconSystemEfficiencyEquipment> currlist = new ArrayList<>();
@@ -58,10 +57,11 @@ public class ProEconSystemEfficiencyEquipmentServiceImpl extends ServiceImpl<Pro
             List<ProBasicEquipment> collect = CacheContext.wtls.stream()
                     .filter(wt -> foreignKeyId.equals(wt.getWindpowerstationId()))
                     .collect(Collectors.toList());
-            for (ProBasicEquipment wt : collect) {
+
+            collect.stream().forEach(i -> {
                 QueryWrapper<ProEconSystemEfficiencyEquipment> qw = new QueryWrapper<>();
-                if (StringUtils.isNotEmpty(wt.getId())) {
-                    qw.lambda().eq(ProEconSystemEfficiencyEquipment::getEquipmentId, wt.getId());
+                if (StringUtils.isNotEmpty(i.getId())) {
+                    qw.lambda().eq(ProEconSystemEfficiencyEquipment::getEquipmentId, i.getId());
                 }
                 SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");
                 String dateString = sdf.format(date);
@@ -69,7 +69,7 @@ public class ProEconSystemEfficiencyEquipmentServiceImpl extends ServiceImpl<Pro
                 qw.lambda().orderByDesc(ProEconSystemEfficiencyEquipment::getDataDate).last("LIMIT 1");
                 List<ProEconSystemEfficiencyEquipment> selectedList = baseMapper.selectList(qw);
                 currlist.addAll(selectedList);
-            }
+            });
         }
         return currlist;
     }
@@ -89,10 +89,10 @@ public class ProEconSystemEfficiencyEquipmentServiceImpl extends ServiceImpl<Pro
             cal.add(Calendar.MONTH, -1);
             Date previousMonth = cal.getTime();
 
-            for (ProBasicEquipment wt : collect) {
+            collect.stream().forEach(i -> {
                 QueryWrapper<ProEconSystemEfficiencyEquipment> qw = new QueryWrapper<>();
-                if (StringUtils.isNotEmpty(wt.getId())) {
-                    qw.lambda().eq(ProEconSystemEfficiencyEquipment::getEquipmentId, wt.getId());
+                if (StringUtils.isNotEmpty(i.getId())) {
+                    qw.lambda().eq(ProEconSystemEfficiencyEquipment::getEquipmentId, i.getId());
                 }
                 SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");
                 String dateString = sdf.format(previousMonth);
@@ -100,7 +100,7 @@ public class ProEconSystemEfficiencyEquipmentServiceImpl extends ServiceImpl<Pro
                 qw.lambda().orderByDesc(ProEconSystemEfficiencyEquipment::getDataDate).last("LIMIT 1");
                 List<ProEconSystemEfficiencyEquipment> selectedList = baseMapper.selectList(qw);
                 currlist.addAll(selectedList);
-            }
+            });
         }
         return currlist;
     }
@@ -108,29 +108,6 @@ public class ProEconSystemEfficiencyEquipmentServiceImpl extends ServiceImpl<Pro
 
     @Override
     public List<ProEconSystemEfficiencyEquipment> gettb(String foreignKeyId, Date date) {
-//        QueryWrapper<ProEconSystemEfficiencyEquipment> qw = null;
-//        // 当前数据
-//        List<ProEconSystemEfficiencyEquipment> currlist = new ArrayList<>();
-//        if (null != date) {
-//            Calendar cal = Calendar.getInstance();
-//            cal.setTime(date);
-//            cal.add(Calendar.YEAR, -1);
-//            Date oneYearAgo = cal.getTime();
-//
-//            qw = new QueryWrapper<>();
-//            if (StringUtils.isNotEmpty(foreignKeyId)) {
-//                qw.lambda().eq(ProEconSystemEfficiencyEquipment::getStationId, foreignKeyId);
-//            }
-//            // 获取传入日期的年月
-//            String yearMonth = new SimpleDateFormat("yyyy-MM").format(oneYearAgo);
-//            // 设置日期为固定的一天(如1日)
-//            String fixedDate = yearMonth + "-01";
-//            qw.lambda().apply("to_char(data_date, 'YYYY-MM-DD')::timestamp without time zone >= to_timestamp('" + fixedDate + "', 'YYYY-MM-DD')");
-//            qw.lambda().apply("to_char(data_date, 'YYYY-MM-DD')::timestamp without time zone < to_timestamp('" + fixedDate + "', 'YYYY-MM-DD') + interval '1 month'");
-//            qw.lambda().orderByAsc(ProEconSystemEfficiencyEquipment::getOrderNum);
-//            currlist = baseMapper.selectList(qw);
-//        }
-//        return currlist;
 
         List<ProEconSystemEfficiencyEquipment> currlist = new ArrayList<>();
         if (date != null) {
@@ -144,10 +121,10 @@ public class ProEconSystemEfficiencyEquipmentServiceImpl extends ServiceImpl<Pro
             cal.add(Calendar.YEAR, -1);
             Date oneYearAgo = cal.getTime();
 
-            for (ProBasicEquipment wt : collect) {
+            collect.stream().forEach(i -> {
                 QueryWrapper<ProEconSystemEfficiencyEquipment> qw = new QueryWrapper<>();
-                if (StringUtils.isNotEmpty(wt.getId())) {
-                    qw.lambda().eq(ProEconSystemEfficiencyEquipment::getEquipmentId, wt.getId());
+                if (StringUtils.isNotEmpty(i.getId())) {
+                    qw.lambda().eq(ProEconSystemEfficiencyEquipment::getEquipmentId, i.getId());
                 }
                 SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");
                 String dateString = sdf.format(oneYearAgo);
@@ -155,9 +132,118 @@ public class ProEconSystemEfficiencyEquipmentServiceImpl extends ServiceImpl<Pro
                 qw.lambda().orderByDesc(ProEconSystemEfficiencyEquipment::getDataDate).last("LIMIT 1");
                 List<ProEconSystemEfficiencyEquipment> selectedList = baseMapper.selectList(qw);
                 currlist.addAll(selectedList);
-            }
+            });
         }
         return currlist;
     }
 
+//    @Override
+//    public List<ProEconSystemEfficiencyEquipment> getbq(String foreignKeyId, Date date) {
+//        List<ProEconSystemEfficiencyEquipment> currlist = new ArrayList<>();
+//        if (date != null) {
+//            List<ProBasicEquipment> collect = CacheContext.wtls.stream()
+//                    .filter(wt -> foreignKeyId.equals(wt.getWindpowerstationId()))
+//                    .collect(Collectors.toList());
+//            for (ProBasicEquipment wt : collect) {
+//                QueryWrapper<ProEconSystemEfficiencyEquipment> qw = new QueryWrapper<>();
+//                if (StringUtils.isNotEmpty(wt.getId())) {
+//                    qw.lambda().eq(ProEconSystemEfficiencyEquipment::getEquipmentId, wt.getId());
+//                }
+//                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");
+//                String dateString = sdf.format(date);
+//                qw.lambda().apply("to_char(data_date, 'YYYY-MM') = '" + dateString + "'");
+//                qw.lambda().orderByDesc(ProEconSystemEfficiencyEquipment::getDataDate).last("LIMIT 1");
+//                List<ProEconSystemEfficiencyEquipment> selectedList = baseMapper.selectList(qw);
+//                currlist.addAll(selectedList);
+//            }
+//        }
+//        return currlist;
+//    }
+
+//    @Override
+//    public List<ProEconSystemEfficiencyEquipment> gethb(String foreignKeyId, Date date) {
+//
+//        List<ProEconSystemEfficiencyEquipment> currlist = new ArrayList<>();
+//        if (date != null) {
+//            List<ProBasicEquipment> collect = CacheContext.wtls.stream()
+//                    .filter(wt -> foreignKeyId.equals(wt.getWindpowerstationId()))
+//                    .collect(Collectors.toList());
+//
+//            // 将日期减去一个月
+//            Calendar cal = Calendar.getInstance();
+//            cal.setTime(date);
+//            cal.add(Calendar.MONTH, -1);
+//            Date previousMonth = cal.getTime();
+//
+//            for (ProBasicEquipment wt : collect) {
+//                QueryWrapper<ProEconSystemEfficiencyEquipment> qw = new QueryWrapper<>();
+//                if (StringUtils.isNotEmpty(wt.getId())) {
+//                    qw.lambda().eq(ProEconSystemEfficiencyEquipment::getEquipmentId, wt.getId());
+//                }
+//                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");
+//                String dateString = sdf.format(previousMonth);
+//                qw.lambda().apply("to_char(data_date, 'YYYY-MM') = '" + dateString + "'");
+//                qw.lambda().orderByDesc(ProEconSystemEfficiencyEquipment::getDataDate).last("LIMIT 1");
+//                List<ProEconSystemEfficiencyEquipment> selectedList = baseMapper.selectList(qw);
+//                currlist.addAll(selectedList);
+//            }
+//        }
+//        return currlist;
+//    }
+
+
+//    @Override
+//    public List<ProEconSystemEfficiencyEquipment> gettb(String foreignKeyId, Date date) {
+////        QueryWrapper<ProEconSystemEfficiencyEquipment> qw = null;
+////        // 当前数据
+////        List<ProEconSystemEfficiencyEquipment> currlist = new ArrayList<>();
+////        if (null != date) {
+////            Calendar cal = Calendar.getInstance();
+////            cal.setTime(date);
+////            cal.add(Calendar.YEAR, -1);
+////            Date oneYearAgo = cal.getTime();
+////
+////            qw = new QueryWrapper<>();
+////            if (StringUtils.isNotEmpty(foreignKeyId)) {
+////                qw.lambda().eq(ProEconSystemEfficiencyEquipment::getStationId, foreignKeyId);
+////            }
+////            // 获取传入日期的年月
+////            String yearMonth = new SimpleDateFormat("yyyy-MM").format(oneYearAgo);
+////            // 设置日期为固定的一天(如1日)
+////            String fixedDate = yearMonth + "-01";
+////            qw.lambda().apply("to_char(data_date, 'YYYY-MM-DD')::timestamp without time zone >= to_timestamp('" + fixedDate + "', 'YYYY-MM-DD')");
+////            qw.lambda().apply("to_char(data_date, 'YYYY-MM-DD')::timestamp without time zone < to_timestamp('" + fixedDate + "', 'YYYY-MM-DD') + interval '1 month'");
+////            qw.lambda().orderByAsc(ProEconSystemEfficiencyEquipment::getOrderNum);
+////            currlist = baseMapper.selectList(qw);
+////        }
+////        return currlist;
+//
+//        List<ProEconSystemEfficiencyEquipment> currlist = new ArrayList<>();
+//        if (date != null) {
+//            List<ProBasicEquipment> collect = CacheContext.wtls.stream()
+//                    .filter(wt -> foreignKeyId.equals(wt.getWindpowerstationId()))
+//                    .collect(Collectors.toList());
+//
+//            // 将日期减去一个月
+//            Calendar cal = Calendar.getInstance();
+//            cal.setTime(date);
+//            cal.add(Calendar.YEAR, -1);
+//            Date oneYearAgo = cal.getTime();
+//
+//            for (ProBasicEquipment wt : collect) {
+//                QueryWrapper<ProEconSystemEfficiencyEquipment> qw = new QueryWrapper<>();
+//                if (StringUtils.isNotEmpty(wt.getId())) {
+//                    qw.lambda().eq(ProEconSystemEfficiencyEquipment::getEquipmentId, wt.getId());
+//                }
+//                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");
+//                String dateString = sdf.format(oneYearAgo);
+//                qw.lambda().apply("to_char(data_date, 'YYYY-MM') = '" + dateString + "'");
+//                qw.lambda().orderByDesc(ProEconSystemEfficiencyEquipment::getDataDate).last("LIMIT 1");
+//                List<ProEconSystemEfficiencyEquipment> selectedList = baseMapper.selectList(qw);
+//                currlist.addAll(selectedList);
+//            }
+//        }
+//        return currlist;
+//    }
+
 }