Browse Source

系统效率部分代码

wangb@gyee-china.com 1 year ago
parent
commit
7aaf648b29
15 changed files with 654 additions and 78 deletions
  1. 8 9
      web/runeconomy-xk/src/main/java/com/gyee/runeconomy/controller/PVSystemEfficiencyCalculator/PVSystemEfficiencyCalculatorController.java
  2. 20 0
      web/runeconomy-xk/src/main/java/com/gyee/runeconomy/controller/ProEconSystemEfficiencyEquipmentController.java
  3. 16 0
      web/runeconomy-xk/src/main/java/com/gyee/runeconomy/mapper/auto/ProEconSystemEfficiencyEquipmentMapper.java
  4. 0 4
      web/runeconomy-xk/src/main/java/com/gyee/runeconomy/model/auto/ProEconSystemEfficiency.java
  5. 98 0
      web/runeconomy-xk/src/main/java/com/gyee/runeconomy/model/auto/ProEconSystemEfficiencyEquipment.java
  6. 22 12
      web/runeconomy-xk/src/main/java/com/gyee/runeconomy/service/Comprehensive/ComprehensiveelectricityService.java
  7. 328 45
      web/runeconomy-xk/src/main/java/com/gyee/runeconomy/service/Comprehensive/PVSystemEfficiencyCalculator.java
  8. 2 2
      web/runeconomy-xk/src/main/java/com/gyee/runeconomy/service/analysis/AnalysisNewService.java
  9. 5 0
      web/runeconomy-xk/src/main/java/com/gyee/runeconomy/service/auto/IProEconEquipmentInfoDay1Service.java
  10. 18 0
      web/runeconomy-xk/src/main/java/com/gyee/runeconomy/service/auto/IProEconSystemEfficiencyEquipmentService.java
  11. 4 2
      web/runeconomy-xk/src/main/java/com/gyee/runeconomy/service/auto/IProEconSystemEfficiencyService.java
  12. 3 2
      web/runeconomy-xk/src/main/java/com/gyee/runeconomy/service/auto/impl/ProEconAnalysisSubtableBottomServiceImpl.java
  13. 58 0
      web/runeconomy-xk/src/main/java/com/gyee/runeconomy/service/auto/impl/ProEconEquipmentInfoDay1ServiceImpl.java
  14. 45 0
      web/runeconomy-xk/src/main/java/com/gyee/runeconomy/service/auto/impl/ProEconSystemEfficiencyEquipmentServiceImpl.java
  15. 27 2
      web/runeconomy-xk/src/main/java/com/gyee/runeconomy/service/auto/impl/ProEconSystemEfficiencyServiceImpl.java

+ 8 - 9
web/runeconomy-xk/src/main/java/com/gyee/runeconomy/controller/PVSystemEfficiencyCalculator/PVSystemEfficiencyCalculatorController.java

@@ -10,8 +10,6 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.ResponseBody;
 
 import javax.annotation.Resource;
-import java.util.LinkedHashMap;
-import java.util.Map;
 
 @Controller
 @RequestMapping("//PVSystemEfficiency")
@@ -27,14 +25,15 @@ public class PVSystemEfficiencyCalculatorController {
 
     public AjaxResult forecast() throws Exception {
 
-        Map<String, Object> resultList = new LinkedHashMap<>();
+//        Map<String, Object> resultList = new LinkedHashMap<>();
 
-            resultList = calculator.planvalue();
-        if (null != resultList) {
-            return AjaxResult.successData(200, resultList);
-        } else {
-            return AjaxResult.error(500, "操作失败");
-        }
+            calculator.planvalue();
+//        if (null != resultList) {
+//            return AjaxResult.successData(200, resultList);
+//        } else {
+//            return AjaxResult.error(500, "操作失败");
+//        }
 
+        return AjaxResult.successData(200, null);
     }
 }

+ 20 - 0
web/runeconomy-xk/src/main/java/com/gyee/runeconomy/controller/ProEconSystemEfficiencyEquipmentController.java

@@ -0,0 +1,20 @@
+package com.gyee.runeconomy.controller;
+
+
+import org.springframework.web.bind.annotation.RequestMapping;
+
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * <p>
+ * 光伏系统效率 前端控制器
+ * </p>
+ *
+ * @author wang
+ * @since 2023-10-24
+ */
+@RestController
+@RequestMapping("//pro-econ-system-efficiency-equipment")
+public class ProEconSystemEfficiencyEquipmentController {
+
+}

+ 16 - 0
web/runeconomy-xk/src/main/java/com/gyee/runeconomy/mapper/auto/ProEconSystemEfficiencyEquipmentMapper.java

@@ -0,0 +1,16 @@
+package com.gyee.runeconomy.mapper.auto;
+
+import com.gyee.runeconomy.model.auto.ProEconSystemEfficiencyEquipment;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * <p>
+ * 光伏系统效率 Mapper 接口
+ * </p>
+ *
+ * @author wang
+ * @since 2023-10-24
+ */
+public interface ProEconSystemEfficiencyEquipmentMapper extends BaseMapper<ProEconSystemEfficiencyEquipment> {
+
+}

+ 0 - 4
web/runeconomy-xk/src/main/java/com/gyee/runeconomy/model/auto/ProEconSystemEfficiency.java

@@ -45,10 +45,6 @@ public class ProEconSystemEfficiency extends Model {
      */
     private String lineId;
 
-    /**
-     * 设备
-     */
-    private String equipmentId;
 
     /**
      * 所属位置(区域、区域风、区域光、公司、公司、公司风、公司光、场站、期次、线路)

+ 98 - 0
web/runeconomy-xk/src/main/java/com/gyee/runeconomy/model/auto/ProEconSystemEfficiencyEquipment.java

@@ -0,0 +1,98 @@
+package com.gyee.runeconomy.model.auto;
+
+import com.baomidou.mybatisplus.extension.activerecord.Model;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import java.util.Date;
+
+/**
+ * <p>
+ * 光伏系统效率
+ * </p>
+ *
+ * @author wang
+ * @since 2023-10-24
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+public class ProEconSystemEfficiencyEquipment extends Model {
+
+    private static final long serialVersionUID = 1L;
+
+    private String id;
+
+    /**
+     * 外键编号
+     */
+    private String foreignKeyId;
+
+    /**
+     * 场站
+     */
+    private String stationId;
+
+    /**
+     * 期次
+     */
+    private String projectId;
+
+    /**
+     * 线路
+     */
+    private String lineId;
+
+    private String equipmentId;
+
+    /**
+     * 所属位置(区域、区域风、区域光、公司、公司、公司风、公司光、场站、期次、线路)
+     */
+    private String location;
+
+    /**
+     * 数据日期
+     */
+    private Date dataDate;
+
+    /**
+     * 日照强度
+     */
+    private Double rzqd;
+
+    /**
+     * 发电量
+     */
+    private Double powerGeneration;
+
+    /**
+     * 最大理论发电量
+     */
+    private Double llfdlmax;
+
+    /**
+     * 离散率
+     */
+    private Double scatter;
+
+    /**
+     * 转换效率
+     */
+    private Double conversionEfficiency;
+
+    /**
+     * 等效发电时
+     */
+    private Double equivalentGeneratingTime;
+
+    /**
+     * 利用小时
+     */
+    private Double utilizationHours;
+
+    /**
+     * 系统效率
+     */
+    private Double efficiency;
+
+
+}

+ 22 - 12
web/runeconomy-xk/src/main/java/com/gyee/runeconomy/service/Comprehensive/ComprehensiveelectricityService.java

@@ -153,9 +153,9 @@ public class ComprehensiveelectricityService {
                     swdlhb = hbzbls.get(0).getYswdldb().doubleValue() / 10000;
                     gwdlhb = hbzbls.get(0).getYgwgwdldb().doubleValue() / 10000;
                     if (sjdlhb!=0) {
-                        zhcydlltb = (sjdlhb - swdlhb + gwdlhb) / sjdlhb;
+                        zhcydllhb = (sjdlhb - swdlhb + gwdlhb) / sjdlhb;
                     }else {
-                        zhcydlltb = (sjdlhb - swdlhb + gwdlhb) / 1;
+                        zhcydllhb = (sjdlhb - swdlhb + gwdlhb) / 1;
                     }
                 }
 
@@ -166,13 +166,15 @@ public class ComprehensiveelectricityService {
                 //添加综合厂用电量数据
                 vo.setZhcydl(StringUtils.round(zhcydl, 2));
                 if (zhcydltb != 0) {
-                    vo.setZhcydltb(StringUtils.round((zhcydl - zhcydltb) / zhcydltb * 100, 0));
+//                    vo.setZhcydltb(StringUtils.round((zhcydl - zhcydltb) / zhcydltb * 100, 0));
+                    vo.setZhcydltb(StringUtils.round( zhcydltb, 2));
                 } else {
                     vo.setZhcydltb(0.0);
                 }
 
                 if (zhcydlhb != 0) {
-                    vo.setZhcydlhb(StringUtils.round((zhcydl - zhcydlhb) / zhcydlhb * 100, 0));
+//                    vo.setZhcydlhb(StringUtils.round((zhcydl - zhcydlhb) / zhcydlhb * 100, 0));
+                    vo.setZhcydlhb(StringUtils.round( zhcydlhb, 2));
                 } else {
                     vo.setZhcydlhb(0.0);
                 }
@@ -184,12 +186,14 @@ public class ComprehensiveelectricityService {
                 vo.setSjdl(StringUtils.round(sjdl, 2));
 
                 if (sjdltb != 0) {
-                    vo.setSjdltb(StringUtils.round((sjdl - sjdltb) / sjdltb * 100, 0));
+//                    vo.setSjdltb(StringUtils.round((sjdl - sjdltb) / sjdltb * 100, 0));
+                    vo.setSjdltb(StringUtils.round(sjdltb, 2));
                 } else {
                     vo.setSjdltb(0.0);
                 }
                 if (sjdlhb != 0) {
-                    vo.setSjdlhb(StringUtils.round((sjdl - sjdlhb) / sjdlhb * 100, 0));
+//                    vo.setSjdlhb(StringUtils.round((sjdl - sjdlhb) / sjdlhb * 100, 0));
+                    vo.setSjdlhb(StringUtils.round(sjdlhb, 2));
                 } else {
                     vo.setSjdlhb(0.0);
                 }
@@ -197,12 +201,14 @@ public class ComprehensiveelectricityService {
                 //添加上网电量数据
                 vo.setSwdl(StringUtils.round(swdl, 2));
                 if (swdltb != 0) {
-                    vo.setSwdltb(StringUtils.round((swdl - swdltb) / swdltb * 100, 0));
+//                    vo.setSwdltb(StringUtils.round((swdl - swdltb) / swdltb * 100, 0));
+                    vo.setSwdltb(StringUtils.round(swdltb, 2));
                 } else {
                     vo.setSwdltb(0.0);
                 }
                 if (swdlhb != 0) {
-                    vo.setSwdlhb(StringUtils.round((swdl - swdlhb) / swdlhb * 100, 0));
+//                    vo.setSwdlhb(StringUtils.round((swdl - swdlhb) / swdlhb * 100, 0));
+                    vo.setSwdlhb(StringUtils.round(swdlhb, 2));
                 } else {
                     vo.setSwdlhb(0.0);
                 }
@@ -210,13 +216,15 @@ public class ComprehensiveelectricityService {
                 //添加购网电量数据
                 vo.setGwdl(StringUtils.round(gwdl, 2));
                 if (gwdltb != 0) {
-                    vo.setGwdltb(StringUtils.round((gwdl - gwdltb) / gwdltb * 100, 0));
+//                    vo.setGwdltb(StringUtils.round((gwdl - gwdltb) / gwdltb * 100, 0));
+                    vo.setGwdltb(StringUtils.round(gwdltb, 2));
                 } else {
                     vo.setGwdltb(0.0);
                 }
 
                 if (gwdlhb != 0) {
-                    vo.setGwdlhb(StringUtils.round((gwdl - gwdlhb) / gwdlhb * 100, 0));
+//                    vo.setGwdlhb(StringUtils.round((gwdl - gwdlhb) / gwdlhb * 100, 0));
+                    vo.setGwdlhb(StringUtils.round(gwdlhb, 2));
                 } else {
                     vo.setGwdlhb(0.0);
                 }
@@ -225,13 +233,15 @@ public class ComprehensiveelectricityService {
                 vo.setZhcydll(StringUtils.round(zhcydll * 100, 0));
 
                 if (zhcydlltb != 0) {
-                    vo.setZhcydlltb(StringUtils.round((zhcydll - zhcydlltb) / zhcydlltb * 100, 0));
+//                    vo.setZhcydlltb(StringUtils.round((zhcydll - zhcydlltb) / zhcydlltb * 100, 0));
+                    vo.setZhcydlltb(StringUtils.round(zhcydlltb, 2));
                 } else {
                     vo.setZhcydlltb(0.0);
                 }
 
                 if (zhcydllhb != 0) {
-                    vo.setZhcydllhb(StringUtils.round((zhcydll - zhcydllhb) / zhcydllhb * 100, 0));
+//                    vo.setZhcydllhb(StringUtils.round((zhcydll - zhcydllhb) / zhcydllhb * 100, 0));
+                    vo.setZhcydllhb(StringUtils.round(zhcydllhb, 2));
                 } else {
                     vo.setZhcydllhb(0.0);
                 }

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

@@ -1,19 +1,22 @@
 package com.gyee.runeconomy.service.Comprehensive;
 
+import com.gyee.common.model.StringUtils;
 import com.gyee.common.util.DateUtils;
 import com.gyee.runeconomy.init.CacheContext;
-import com.gyee.runeconomy.model.auto.ProBasicPowerstation;
-import com.gyee.runeconomy.model.auto.ProEconPowerstationInfoDay1;
-import com.gyee.runeconomy.model.auto.ProEconPowerstationInfoDay5;
+import com.gyee.runeconomy.model.auto.*;
+import com.gyee.runeconomy.service.auto.IProEconEquipmentInfoDay1Service;
 import com.gyee.runeconomy.service.auto.IProEconPowerstationInfoDay1Service;
 import com.gyee.runeconomy.service.auto.IProEconPowerstationInfoDay5Service;
+import com.gyee.runeconomy.service.auto.impl.ProEconSystemEfficiencyEquipmentServiceImpl;
+import com.gyee.runeconomy.service.auto.impl.ProEconSystemEfficiencyServiceImpl;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
+import java.util.ArrayList;
 import java.util.Calendar;
 import java.util.Date;
 import java.util.List;
-import java.util.Map;
+import java.util.stream.Collectors;
 
 @Service
 public class PVSystemEfficiencyCalculator {
@@ -22,12 +25,23 @@ public class PVSystemEfficiencyCalculator {
     @Resource
     private IProEconPowerstationInfoDay1Service proEconPowerstationInfoDay1Service;
 
-    public Map<String, Object> planvalue() throws Exception {
+    @Resource
+    private IProEconEquipmentInfoDay1Service proEconEquipmentInfoDay1Service;
+
+    @Resource
+    private ProEconSystemEfficiencyServiceImpl systemEfficiencyService;
+
+    @Resource
+    private ProEconSystemEfficiencyEquipmentServiceImpl efficiencyEquipmentService;
+
+    public void planvalue() throws Exception {
 
         String year = "2023";
         //参数所传年份
         int currentyear = Integer.parseInt(year);
+
         int ts = 1;
+
         Calendar cal = Calendar.getInstance();
         int dqnf = cal.get(Calendar.YEAR);//本年
 
@@ -43,6 +57,8 @@ public class PVSystemEfficiencyCalculator {
         calendar1.set(Calendar.MILLISECOND, 0);
         Date firstDayZeroHour = calendar1.getTime();
 
+        // 初始化初始值
+        Date initialFirstDayZeroHour = (Date) firstDayZeroHour.clone();
         // 获取firstDayZeroHour的月份
         Calendar calFirstDayZeroHour = Calendar.getInstance();
         calFirstDayZeroHour.setTime(firstDayZeroHour);
@@ -54,12 +70,18 @@ public class PVSystemEfficiencyCalculator {
         currentMonth = currentMonth + 1;
 
         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());
 
 
         //计算场站级别
         for (ProBasicPowerstation wp : wplsG) {
 
-            for (int i = 0; i < 12; i++) {
+            for (int i = 0; i < currentMonth; i++) {
+
+                Date date = null;
+                List<ProEconSystemEfficiency> stringList = new ArrayList<>();
 
                 if (calFirstMonth == currentMonth && dqnf == currentyear) {
                     Calendar calendar5 = Calendar.getInstance();
@@ -81,6 +103,7 @@ public class PVSystemEfficiencyCalculator {
                 if (!day5List.isEmpty() && day5List != null) {
                     for (ProEconPowerstationInfoDay5 day : day5List) {
                         actualPowerOutputKilowattHours = day.getYfdldb().doubleValue();
+                        date = day.getRecordDate();
                     }
                 }
                 if (!rzqdls.isEmpty() && rzqdls != null) {
@@ -90,54 +113,314 @@ public class PVSystemEfficiencyCalculator {
                 }
                 moduleCapacityKilowatts = wp.getJrCapacity();
 
-                double expectedPowerOutputKilowattHours = calculateExpectedPowerOutput(solarRadiationWattsPerSquareMeter, moduleCapacityKilowatts,ts); // 预期发电量(kWh)
+                double expectedPowerOutputKilowattHours = calculateExpectedPowerOutput(solarRadiationWattsPerSquareMeter, moduleCapacityKilowatts, ts); // 预期发电量(kWh)
                 pr = calculatePR(actualPowerOutputKilowattHours, expectedPowerOutputKilowattHours); // 计算PR
 
+//                DecimalFormat decimalFormat = new DecimalFormat("#");
+//                String formattedResult = decimalFormat.format(pr);
+                pr = StringUtils.round(pr, 2);
 
-                System.out.println("太阳能辐射: " + solarRadiationWattsPerSquareMeter + " W/m²");
-                System.out.println("实际发电量: " + actualPowerOutputKilowattHours + " kWh");
-                System.out.println("光伏模块额定容量: " + moduleCapacityKilowatts + " kW");
-                System.out.println("预期发电量: " + expectedPowerOutputKilowattHours + " kWh");
-                System.out.println("光伏系统效率 (PR): " + pr + "%");
+                solarRadiationWattsPerSquareMeter = StringUtils.round(solarRadiationWattsPerSquareMeter, 2);
+
+//                System.out.println("太阳能辐射: " + solarRadiationWattsPerSquareMeter + " W/m²");
+//                System.out.println("实际发电量: " + actualPowerOutputKilowattHours + " kWh");
+//                System.out.println("光伏模块额定容量: " + moduleCapacityKilowatts + " kW");
+//                System.out.println("预期发电量: " + expectedPowerOutputKilowattHours + " kWh");
+//                System.out.println("光伏系统效率 (PR): " + pr + "%");
+
+                ProEconSystemEfficiency power = new ProEconSystemEfficiency();
+                power.setId(StringUtils.getUUID());
+                power.setForeignKeyId(wp.getId());
+                power.setStationId(wp.getId());
+                power.setLocation("wp");
+                power.setDataDate(date);
+                power.setRzqd(solarRadiationWattsPerSquareMeter);
+                power.setEfficiency(pr);
+                stringList.add(power);
+                systemEfficiencyService.batchAdd(stringList);
 
                 firstDayZeroHour = DateUtils.addMonths(firstDayZeroHour, 1);
                 calFirstDayZeroHour.setTime(firstDayZeroHour);
                 calFirstMonth = calFirstDayZeroHour.get(Calendar.MONTH) + 1;
                 ts = calFirstDayZeroHour.getActualMaximum(Calendar.DAY_OF_MONTH);
             }
+            // 恢复初始值
+            firstDayZeroHour = initialFirstDayZeroHour;
         }
-        return null;
+
+        //计算期次级别
+        int ts2 = 1; // 设置为本年一月一号0点
+
+        Calendar calendar2 = Calendar.getInstance();
+        calendar2.setTime(new Date());
+        calendar2.set(Calendar.YEAR, currentyear); // 根据当前年份变化
+        calendar2.set(Calendar.MONTH, Calendar.JANUARY); // 0表示一月
+        calendar2.set(Calendar.DAY_OF_MONTH, 1);
+        calendar2.set(Calendar.HOUR_OF_DAY, 0);
+        calendar2.set(Calendar.MINUTE, 0);
+        calendar2.set(Calendar.SECOND, 0);
+        calendar2.set(Calendar.MILLISECOND, 0);
+        Date firstDayZeroHour2 = calendar2.getTime();
+
+        // 初始化初始值
+        Date initialFirstDayZeroHour2 = (Date) firstDayZeroHour2.clone();
+
+        // 获取firstDayZeroHour的月份
+        Calendar calFirstDayZeroHour2 = Calendar.getInstance();
+        calFirstDayZeroHour2.setTime(firstDayZeroHour2);
+        int calFirstMonth2 = calFirstDayZeroHour2.get(Calendar.MONTH) + 1;
+
+        for (ProBasicProject pj : pjlsG) {
+            for (int i = 0; i < currentMonth; i++) {
+                Date date = null;
+                List<ProEconSystemEfficiency> stringList = new ArrayList<>();
+
+                if (calFirstMonth2 == currentMonth && dqnf == currentyear) {
+                    Calendar calendar5 = Calendar.getInstance();
+                    ts2 = calendar5.get(Calendar.DAY_OF_MONTH);
+                } else {
+                    // 获取当前月份的天数
+                    ts2 = calFirstDayZeroHour2.getActualMaximum(Calendar.DAY_OF_MONTH);
+                }
+
+                List<ProEconPowerstationInfoDay5> day5List = proEconPowerstationInfoDay5Service.getmax(pj.getId(), firstDayZeroHour2);
+                List<ProEconPowerstationInfoDay1> rzqdls = proEconPowerstationInfoDay1Service.getmax(pj.getId(), firstDayZeroHour2);
+
+                double solarRadiationWattsPerSquareMeter = 0.0; // 太阳能辐射,单位为W/m²
+                double actualPowerOutputKilowattHours = 0.0; // 实际发电量,单位为千瓦时(kWh)
+                double moduleCapacityKilowatts = 0.0; // 光伏模块额定容量,单位为千瓦(kW)
+                double pr = 0.0;
+
+                if (!day5List.isEmpty() && day5List != null) {
+                    for (ProEconPowerstationInfoDay5 day : day5List) {
+                        actualPowerOutputKilowattHours = day.getYfdldb().doubleValue();
+                        date = day.getRecordDate();
+                    }
+                }
+
+                if (!rzqdls.isEmpty() && rzqdls != null) {
+                    for (ProEconPowerstationInfoDay1 rz : rzqdls) {
+                        solarRadiationWattsPerSquareMeter = rz.getYpjfs().doubleValue();
+                    }
+                }
+
+                moduleCapacityKilowatts = pj.getCapacity();
+
+                double expectedPowerOutputKilowattHours = calculateExpectedPowerOutput(solarRadiationWattsPerSquareMeter, moduleCapacityKilowatts, ts2); // 预期发电量(kWh)
+                pr = calculatePR(actualPowerOutputKilowattHours, expectedPowerOutputKilowattHours); // 计算PR
+
+                pr = StringUtils.round(pr, 2);
+                solarRadiationWattsPerSquareMeter = StringUtils.round(solarRadiationWattsPerSquareMeter, 2);
+
+
+                ProEconSystemEfficiency power = new ProEconSystemEfficiency();
+                power.setId(StringUtils.getUUID());
+                power.setForeignKeyId(pj.getId());
+                power.setStationId(pj.getWindpowerstationId());
+                power.setLocation("pj");
+                power.setDataDate(date);
+                power.setRzqd(solarRadiationWattsPerSquareMeter);
+                power.setEfficiency(pr);
+                stringList.add(power);
+                systemEfficiencyService.batchAdd(stringList);
+
+
+                firstDayZeroHour2 = DateUtils.addMonths(firstDayZeroHour2, 1);
+                calFirstDayZeroHour2.setTime(firstDayZeroHour2);
+                calFirstMonth2 = calFirstDayZeroHour2.get(Calendar.MONTH) + 1;
+                ts2 = calFirstDayZeroHour2.getActualMaximum(Calendar.DAY_OF_MONTH);
+            }
+            // 恢复初始值
+            firstDayZeroHour2 = initialFirstDayZeroHour2;
+        }
+
+
+        //计算期次级别
+        int ts3 = 1; // 设置为本年一月一号0点
+
+        Calendar calendar3 = Calendar.getInstance();
+        calendar3.setTime(new Date());
+        calendar3.set(Calendar.YEAR, currentyear); // 根据当前年份变化
+        calendar3.set(Calendar.MONTH, Calendar.JANUARY); // 0表示一月
+        calendar3.set(Calendar.DAY_OF_MONTH, 1);
+        calendar3.set(Calendar.HOUR_OF_DAY, 0);
+        calendar3.set(Calendar.MINUTE, 0);
+        calendar3.set(Calendar.SECOND, 0);
+        calendar3.set(Calendar.MILLISECOND, 0);
+        Date firstDayZeroHour3 = calendar3.getTime();
+
+        // 初始化初始值
+        Date initialFirstDayZeroHour3 = (Date) firstDayZeroHour3.clone();
+
+        // 获取firstDayZeroHour的月份
+        Calendar calFirstDayZeroHour3 = Calendar.getInstance();
+        calFirstDayZeroHour3.setTime(firstDayZeroHour3);
+        int calFirstMonth3 = calFirstDayZeroHour3.get(Calendar.MONTH) + 1;
+
+        for (ProBasicLine ln : lnlsG) {
+          List<ProBasicProject>  wpid = pjlsG.stream().filter(l->l.getId().equals(ln.getProjectId())).collect(Collectors.toList());
+            for (int i = 0; i < currentMonth; i++) {
+                Date date = null;
+                List<ProEconSystemEfficiency> stringList = new ArrayList<>();
+
+                if (calFirstMonth3 == currentMonth && dqnf == currentyear) {
+                    Calendar calendar5 = Calendar.getInstance();
+                    ts3 = calendar5.get(Calendar.DAY_OF_MONTH);
+                } else {
+                    // 获取当前月份的天数
+                    ts3 = calFirstDayZeroHour3.getActualMaximum(Calendar.DAY_OF_MONTH);
+                }
+
+                List<ProEconPowerstationInfoDay5> day5List = proEconPowerstationInfoDay5Service.getmax(ln.getId(), firstDayZeroHour3);
+                List<ProEconPowerstationInfoDay1> rzqdls = proEconPowerstationInfoDay1Service.getmax(ln.getId(), firstDayZeroHour3);
+
+                double solarRadiationWattsPerSquareMeter = 0.0; // 太阳能辐射,单位为W/m²
+                double actualPowerOutputKilowattHours = 0.0; // 实际发电量,单位为千瓦时(kWh)
+                double moduleCapacityKilowatts = 0.0; // 光伏模块额定容量,单位为千瓦(kW)
+                double pr = 0.0;
+
+                if (!day5List.isEmpty() && day5List != null) {
+                    for (ProEconPowerstationInfoDay5 day : day5List) {
+                        actualPowerOutputKilowattHours = day.getYfdldb().doubleValue();
+                        date = day.getRecordDate();
+                    }
+                }
+
+                if (!rzqdls.isEmpty() && rzqdls != null) {
+                    for (ProEconPowerstationInfoDay1 rz : rzqdls) {
+                        solarRadiationWattsPerSquareMeter = rz.getYpjfs().doubleValue();
+                    }
+                }
+
+                moduleCapacityKilowatts = ln.getCapacity();
+
+                double expectedPowerOutputKilowattHours = calculateExpectedPowerOutput(solarRadiationWattsPerSquareMeter, moduleCapacityKilowatts, ts3); // 预期发电量(kWh)
+                pr = calculatePR(actualPowerOutputKilowattHours, expectedPowerOutputKilowattHours); // 计算PR
+
+                pr = StringUtils.round(pr, 2);
+                solarRadiationWattsPerSquareMeter = StringUtils.round(solarRadiationWattsPerSquareMeter, 2);
+
+
+                ProEconSystemEfficiency power = new ProEconSystemEfficiency();
+                power.setId(StringUtils.getUUID());
+                power.setForeignKeyId(ln.getId());
+                power.setStationId(wpid.get(0).getWindpowerstationId());
+                power.setProjectId(wpid.get(0).getId());
+                power.setLineId(ln.getId());
+                power.setLocation("ln");
+                power.setDataDate(date);
+                power.setRzqd(solarRadiationWattsPerSquareMeter);
+                power.setEfficiency(pr);
+                stringList.add(power);
+                if (date!=null) {
+                    systemEfficiencyService.batchAdd(stringList);
+                }
+
+
+                firstDayZeroHour3 = DateUtils.addMonths(firstDayZeroHour3, 1);
+                calFirstDayZeroHour3.setTime(firstDayZeroHour3);
+                calFirstMonth3 = calFirstDayZeroHour3.get(Calendar.MONTH) + 1;
+                ts3 = calFirstDayZeroHour3.getActualMaximum(Calendar.DAY_OF_MONTH);
+            }
+            // 恢复初始值
+            firstDayZeroHour3 = initialFirstDayZeroHour3;
+        }
+
+
+
+        //计算设备级别
+        int ts4 = 1; // 设置为本年一月一号0点
+
+        Calendar calendar4 = Calendar.getInstance();
+        calendar4.setTime(new Date());
+        calendar4.set(Calendar.YEAR, currentyear); // 根据当前年份变化
+        calendar4.set(Calendar.MONTH, Calendar.JANUARY); // 0表示一月
+        calendar4.set(Calendar.DAY_OF_MONTH, 1);
+        calendar4.set(Calendar.HOUR_OF_DAY, 0);
+        calendar4.set(Calendar.MINUTE, 0);
+        calendar4.set(Calendar.SECOND, 0);
+        calendar4.set(Calendar.MILLISECOND, 0);
+        Date firstDayZeroHour4 = calendar4.getTime();
+
+        // 初始化初始值
+        Date initialFirstDayZeroHour4 = (Date) firstDayZeroHour4.clone();
+
+        // 获取firstDayZeroHour的月份
+        Calendar calFirstDayZeroHour4 = Calendar.getInstance();
+        calFirstDayZeroHour4.setTime(firstDayZeroHour4);
+        int calFirstMonth4 = calFirstDayZeroHour4.get(Calendar.MONTH) + 1;
+
+        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++) {
+                Date date = null;
+                List<ProEconSystemEfficiencyEquipment> stringList = new ArrayList<>();
+
+                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);
+
+                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();
+                    }
+                }
+
+
+                moduleCapacityKilowatts = collect.get(0).getPowerProduction();
+
+                double expectedPowerOutputKilowattHours = calculateExpectedPowerOutput(solarRadiationWattsPerSquareMeter, moduleCapacityKilowatts, ts4); // 预期发电量(kWh)
+                pr = calculatePR(actualPowerOutputKilowattHours, expectedPowerOutputKilowattHours); // 计算PR
+
+                pr = StringUtils.round(pr, 2);
+                solarRadiationWattsPerSquareMeter = StringUtils.round(solarRadiationWattsPerSquareMeter, 2);
+
+
+                ProEconSystemEfficiencyEquipment power = new ProEconSystemEfficiencyEquipment();
+                power.setId(StringUtils.getUUID());
+                power.setForeignKeyId(wt.getId());
+                power.setStationId(wt.getWindpowerstationId());
+                power.setProjectId(wt.getProjectId());
+                power.setLineId(wt.getLineId());
+                power.setEquipmentId(wt.getId());
+                power.setLocation("wt");
+                power.setDataDate(date);
+                power.setRzqd(solarRadiationWattsPerSquareMeter);
+                power.setEfficiency(pr);
+                stringList.add(power);
+                if (date!=null) {
+                    efficiencyEquipmentService.batchAdd(stringList);
+                }
+
+
+                firstDayZeroHour4 = DateUtils.addMonths(firstDayZeroHour4, 1);
+                calFirstDayZeroHour4.setTime(firstDayZeroHour4);
+                calFirstMonth4 = calFirstDayZeroHour4.get(Calendar.MONTH) + 1;
+                ts4 = calFirstDayZeroHour4.getActualMaximum(Calendar.DAY_OF_MONTH);
+            }
+            // 恢复初始值
+            firstDayZeroHour4 = initialFirstDayZeroHour4;
+        }
+
 
     }
-//        JSONObject radarData = new JSONObject();
-//
-//        // 创建指标数据
-//        JSONArray data = new JSONArray();
-//        data.add(45.6);  // 太阳能辐射
-//        data.add(38.9);  // 实际发电量
-//        data.add(50.0);  // 光伏模块额定容量
-//        data.add(42.3);  // 预期发电量
-//        data.add(70.5);  // 光伏系统效率
-//
-//        // 设置雷达图的标签
-//        JSONArray labels = new JSONArray();
-//        labels.add("太阳能辐射");
-//        labels.add("实际发电量");
-//        labels.add("光伏模块额定容量");
-//        labels.add("预期发电量");
-//        labels.add("光伏系统效率");
-//
-//        // 将数据和标签添加到雷达图数据中
-//        radarData.put("data", data);
-//        radarData.put("labels", labels);
-//
-//        System.out.println(radarData);
-//
-//
-
-
-    // 计算预期发电量的方法
-    public static double calculateExpectedPowerOutput(double solarRadiationWattsPerSquareMeter, double moduleCapacityKilowatts,double ts) {
+        // 计算预期发电量的方法
+    public static double calculateExpectedPowerOutput(double solarRadiationWattsPerSquareMeter, double moduleCapacityKilowatts, double ts) {
         double hoursOfDaylight = 12.0; // 假设日照时间为12小时
         //辐照度*容量
         //
@@ -146,10 +429,10 @@ public class PVSystemEfficiencyCalculator {
 
     // 计算光伏系统效率PR的方法
     public static double calculatePR(double actualPowerOutputKilowattHours, double expectedPowerOutputKilowattHours) {
-        if (expectedPowerOutputKilowattHours == 0){
-            expectedPowerOutputKilowattHours = 1;
+        if (expectedPowerOutputKilowattHours == 0) {
+            return actualPowerOutputKilowattHours;
         }
-        //实际发电量/预期发电量
+        // 实际发电量/预期发电量
         return (actualPowerOutputKilowattHours / expectedPowerOutputKilowattHours) * 100;
     }
 }

+ 2 - 2
web/runeconomy-xk/src/main/java/com/gyee/runeconomy/service/analysis/AnalysisNewService.java

@@ -77,9 +77,9 @@ public class AnalysisNewService {
         for (ProBasicPowerstation wp : CacheContext.wpls) {
 
 //            补充数据可将其打开
-//            if (wp.getId().equals("SXJ_KGDL_JR_GDC_STA")) {
+//            if (wp.getId().equals("SXJ_KGDL_GJY_FDC_STA")) {
 //
-//                for (int g = 0; g <= 44; g++) {
+//                for (int g = 0; g <= 52; g++) {
 
             List<ProBasicMeterPoint> meterPoints = proBasicMeterPointService.getBaseMapper().selectList(null);
 

+ 5 - 0
web/runeconomy-xk/src/main/java/com/gyee/runeconomy/service/auto/IProEconEquipmentInfoDay1Service.java

@@ -3,6 +3,9 @@ package com.gyee.runeconomy.service.auto;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.gyee.runeconomy.model.auto.ProEconEquipmentInfoDay1;
 
+import java.util.Date;
+import java.util.List;
+
 /**
  * <p>
  * 五损电量 服务类
@@ -13,4 +16,6 @@ import com.gyee.runeconomy.model.auto.ProEconEquipmentInfoDay1;
  */
 public interface IProEconEquipmentInfoDay1Service extends IService<ProEconEquipmentInfoDay1> {
 
+    List<ProEconEquipmentInfoDay1> getmax(String foreignKeyId , Date date);
+
 }

+ 18 - 0
web/runeconomy-xk/src/main/java/com/gyee/runeconomy/service/auto/IProEconSystemEfficiencyEquipmentService.java

@@ -0,0 +1,18 @@
+package com.gyee.runeconomy.service.auto;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.gyee.runeconomy.model.auto.ProEconSystemEfficiencyEquipment;
+
+import java.util.List;
+
+/**
+ * <p>
+ * 光伏系统效率 服务类
+ * </p>
+ *
+ * @author wang
+ * @since 2023-10-24
+ */
+public interface IProEconSystemEfficiencyEquipmentService extends IService<ProEconSystemEfficiencyEquipment> {
+    boolean batchAdd (List<ProEconSystemEfficiencyEquipment> proEconStationPowers);
+}

+ 4 - 2
web/runeconomy-xk/src/main/java/com/gyee/runeconomy/service/auto/IProEconSystemEfficiencyService.java

@@ -1,7 +1,9 @@
 package com.gyee.runeconomy.service.auto;
 
-import com.gyee.runeconomy.model.auto.ProEconSystemEfficiency;
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.gyee.runeconomy.model.auto.ProEconSystemEfficiency;
+
+import java.util.List;
 
 /**
  * <p>
@@ -12,5 +14,5 @@ import com.baomidou.mybatisplus.extension.service.IService;
  * @since 2023-10-23
  */
 public interface IProEconSystemEfficiencyService extends IService<ProEconSystemEfficiency> {
-
+    boolean batchAdd (List<ProEconSystemEfficiency> proEconStationPowers);
 }

+ 3 - 2
web/runeconomy-xk/src/main/java/com/gyee/runeconomy/service/auto/impl/ProEconAnalysisSubtableBottomServiceImpl.java

@@ -25,11 +25,12 @@ public class ProEconAnalysisSubtableBottomServiceImpl extends ServiceImpl<ProEco
         try {
             proEconStationPowers.stream().forEach(i -> {
                 QueryWrapper<ProEconAnalysisSubtableBottom> qw = new QueryWrapper<>();
-                qw.lambda().eq(ProEconAnalysisSubtableBottom::getId, i.getId());
                 qw.lambda().eq(ProEconAnalysisSubtableBottom::getRecordDate, i.getRecordDate());
                 qw.lambda().eq(ProEconAnalysisSubtableBottom::getMeterId, i.getMeterId());
                 int count = baseMapper.selectCount(qw);
-                if (count <= 0) {
+                if (count > 0) {
+                    baseMapper.update(i, qw);
+                } else if (count <= 0) {
                     baseMapper.insert(i);
                 }
 

+ 58 - 0
web/runeconomy-xk/src/main/java/com/gyee/runeconomy/service/auto/impl/ProEconEquipmentInfoDay1ServiceImpl.java

@@ -1,11 +1,19 @@
 package com.gyee.runeconomy.service.auto.impl;
 
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.gyee.common.model.StringUtils;
+import com.gyee.common.util.DateUtils;
 import com.gyee.runeconomy.mapper.auto.ProEconEquipmentInfoDay1Mapper;
 import com.gyee.runeconomy.model.auto.ProEconEquipmentInfoDay1;
 import com.gyee.runeconomy.service.auto.IProEconEquipmentInfoDay1Service;
 import org.springframework.stereotype.Service;
 
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.List;
+
 /**
  * <p>
  * 五损电量 服务实现类
@@ -17,4 +25,54 @@ import org.springframework.stereotype.Service;
 @Service
 public class ProEconEquipmentInfoDay1ServiceImpl extends ServiceImpl<ProEconEquipmentInfoDay1Mapper, ProEconEquipmentInfoDay1> implements IProEconEquipmentInfoDay1Service {
 
+    @Override
+    public List<ProEconEquipmentInfoDay1> getmax(String foreignKeyId, Date date) {
+        QueryWrapper<ProEconEquipmentInfoDay1> qw = null;
+
+
+        Calendar calendar = Calendar.getInstance();
+        calendar.setTime(date);
+        int specifiedYear = calendar.get(Calendar.YEAR);
+        int specifiedMonth = calendar.get(Calendar.MONTH) +1;
+        calendar.set(Calendar.DAY_OF_MONTH, calendar.getActualMaximum(Calendar.DAY_OF_MONTH));
+        calendar.set(Calendar.HOUR_OF_DAY, 23);
+        calendar.set(Calendar.MINUTE, 59);
+        calendar.set(Calendar.SECOND, 59);
+
+        Date endOfDayOfLastDayOfMonth = calendar.getTime();
+
+        // 获取当前日期的年份和月份
+        int currentYear = Calendar.getInstance().get(Calendar.YEAR);
+        int currentMonth = Calendar.getInstance().get(Calendar.MONTH)+1;
+
+
+        // 判断指定日期是否是当前月份
+        if (currentYear == specifiedYear && currentMonth == specifiedMonth) {
+            // 如果是当前月份,则将endOfDayOfLastDayOfMonth减去一天
+            Calendar calendar2 = Calendar.getInstance();  // 创建 Calendar 对象,表示当前时间
+            calendar2.add(Calendar.DAY_OF_MONTH, -1);  // 减去一天
+
+            // 设置时、分、秒为最后时刻
+            calendar2.set(Calendar.HOUR_OF_DAY, 23);
+            calendar2.set(Calendar.MINUTE, 59);
+            calendar2.set(Calendar.SECOND, 59);
+
+            endOfDayOfLastDayOfMonth = calendar2.getTime();  // 获取计算后的时间
+        }
+
+        //当前数据
+        List<ProEconEquipmentInfoDay1> currlist = new ArrayList<>();
+        if (null != date) {
+            qw = new QueryWrapper<>();
+            if (StringUtils.isNotEmpty(foreignKeyId)) {
+                qw.lambda().eq(ProEconEquipmentInfoDay1::getWindturbineId, foreignKeyId);
+            }
+            qw.lambda().between(ProEconEquipmentInfoDay1::getRecordDate, DateUtils.getMonthFirst(date), endOfDayOfLastDayOfMonth);
+            qw.lambda().orderByDesc(ProEconEquipmentInfoDay1::getRecordDate);
+            qw.last("limit 1");
+            currlist = baseMapper.selectList(qw);
+
+        }
+        return currlist;
+    }
 }

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

@@ -0,0 +1,45 @@
+package com.gyee.runeconomy.service.auto.impl;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.gyee.runeconomy.mapper.auto.ProEconSystemEfficiencyEquipmentMapper;
+import com.gyee.runeconomy.model.auto.ProEconSystemEfficiencyEquipment;
+import com.gyee.runeconomy.service.auto.IProEconSystemEfficiencyEquipmentService;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+/**
+ * <p>
+ * 光伏系统效率 服务实现类
+ * </p>
+ *
+ * @author wang
+ * @since 2023-10-24
+ */
+@Service
+public class ProEconSystemEfficiencyEquipmentServiceImpl extends ServiceImpl<ProEconSystemEfficiencyEquipmentMapper, ProEconSystemEfficiencyEquipment> implements IProEconSystemEfficiencyEquipmentService {
+
+    @Override
+    public boolean batchAdd(List<ProEconSystemEfficiencyEquipment> proEconStationPowers) {
+        try {
+            proEconStationPowers.stream().forEach(i -> {
+                QueryWrapper<ProEconSystemEfficiencyEquipment> qw = new QueryWrapper<>();
+                qw.lambda().eq(ProEconSystemEfficiencyEquipment::getDataDate, i.getDataDate());
+                qw.lambda().eq(ProEconSystemEfficiencyEquipment::getForeignKeyId,i.getForeignKeyId());
+                int count = baseMapper.selectCount(qw);
+                if (count > 0){
+                    baseMapper.update(i,qw);
+                } else if (count <= 0) {
+                    baseMapper.insert(i);
+                }
+
+            });
+        } catch (Exception e) {
+            e.printStackTrace();
+            return false;
+        }
+
+        return true;
+    }
+}

+ 27 - 2
web/runeconomy-xk/src/main/java/com/gyee/runeconomy/service/auto/impl/ProEconSystemEfficiencyServiceImpl.java

@@ -1,11 +1,14 @@
 package com.gyee.runeconomy.service.auto.impl;
 
-import com.gyee.runeconomy.model.auto.ProEconSystemEfficiency;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.gyee.runeconomy.mapper.auto.ProEconSystemEfficiencyMapper;
+import com.gyee.runeconomy.model.auto.ProEconSystemEfficiency;
 import com.gyee.runeconomy.service.auto.IProEconSystemEfficiencyService;
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.springframework.stereotype.Service;
 
+import java.util.List;
+
 /**
  * <p>
  * 光伏系统效率 服务实现类
@@ -17,4 +20,26 @@ import org.springframework.stereotype.Service;
 @Service
 public class ProEconSystemEfficiencyServiceImpl extends ServiceImpl<ProEconSystemEfficiencyMapper, ProEconSystemEfficiency> implements IProEconSystemEfficiencyService {
 
+    @Override
+    public boolean batchAdd(List<ProEconSystemEfficiency> proEconStationPowers) {
+        try {
+            proEconStationPowers.stream().forEach(i -> {
+                QueryWrapper<ProEconSystemEfficiency> qw = new QueryWrapper<>();
+                qw.lambda().eq(ProEconSystemEfficiency::getDataDate, i.getDataDate());
+                qw.lambda().eq(ProEconSystemEfficiency::getForeignKeyId,i.getForeignKeyId());
+                int count = baseMapper.selectCount(qw);
+                if (count > 0){
+                    baseMapper.update(i,qw);
+                } else if (count <= 0) {
+                    baseMapper.insert(i);
+                }
+
+            });
+        } catch (Exception e) {
+            e.printStackTrace();
+            return false;
+        }
+
+        return true;
+    }
 }