Browse Source

系统效率

wangb@gyee-china.com 1 year ago
parent
commit
0335a33936
19 changed files with 1096 additions and 42 deletions
  1. 14 0
      realtime/generationXK-service/src/main/java/com/gyee/generation/init/CacheContext.java
  2. 19 14
      realtime/generationXK-service/src/main/java/com/gyee/generation/model/auto/ProEconSystemEfficiency.java
  3. 15 15
      realtime/generationXK-service/src/main/java/com/gyee/generation/model/auto/ProEconSystemEfficiencyEquipment.java
  4. 230 0
      realtime/generationXK-service/src/main/java/com/gyee/generation/model/vo/PrAnalysisVo.java
  5. 491 0
      realtime/generationXK-service/src/main/java/com/gyee/generation/service/PVSystemEfficiencyCalculator.java
  6. 1 1
      realtime/generationXK-service/src/main/java/com/gyee/generation/service/auto/IProBasicPowerstationPointService.java
  7. 4 1
      realtime/generationXK-service/src/main/java/com/gyee/generation/service/auto/IProEconEquipmentInfoDay1Service.java
  8. 4 1
      realtime/generationXK-service/src/main/java/com/gyee/generation/service/auto/IProEconPowerstationInfoDay1Service.java
  9. 4 1
      realtime/generationXK-service/src/main/java/com/gyee/generation/service/auto/IProEconPowerstationInfoDay5Service.java
  10. 3 1
      realtime/generationXK-service/src/main/java/com/gyee/generation/service/auto/IProEconSystemEfficiencyEquipmentService.java
  11. 6 1
      realtime/generationXK-service/src/main/java/com/gyee/generation/service/auto/IProEconSystemEfficiencyService.java
  12. 68 2
      realtime/generationXK-service/src/main/java/com/gyee/generation/service/auto/impl/ProBasicPowerstationPointServiceImpl.java
  13. 57 0
      realtime/generationXK-service/src/main/java/com/gyee/generation/service/auto/impl/ProEconEquipmentInfoDay1ServiceImpl.java
  14. 33 0
      realtime/generationXK-service/src/main/java/com/gyee/generation/service/auto/impl/ProEconPowerstationInfoDay1ServiceImpl.java
  15. 58 0
      realtime/generationXK-service/src/main/java/com/gyee/generation/service/auto/impl/ProEconPowerstationInfoDay5ServiceImpl.java
  16. 27 2
      realtime/generationXK-service/src/main/java/com/gyee/generation/service/auto/impl/ProEconSystemEfficiencyEquipmentServiceImpl.java
  17. 28 2
      realtime/generationXK-service/src/main/java/com/gyee/generation/service/auto/impl/ProEconSystemEfficiencyServiceImpl.java
  18. 25 0
      realtime/generationXK-service/src/main/resources/xxl-job-efficiency.properties
  19. 9 1
      realtime/generationXK-service/src/test/java/com/gyee/generation/GenerationTest.java

+ 14 - 0
realtime/generationXK-service/src/main/java/com/gyee/generation/init/CacheContext.java

@@ -128,6 +128,8 @@ public class CacheContext implements CommandLineRunner {
     public static Map<String,Map<String, ProBasicPowerstationPoint>> propointmap =new HashMap<>();
     public static Map<String,Map<String, ProBasicPowerstationPoint>> wppointmap =new HashMap<>();
     public static Map<String,Map<String, ProBasicPowerstationPoint>> subwppointmap =new HashMap<>();
+
+    public static Map<String, Map<String, ProBasicPowerstationPoint>> weatherwppointmap = new HashMap<>();
     public static Map<String,Map<String, ProBasicPowerstationPoint>> wswppointmap =new HashMap<>();
     public static Map<String,Map<String, ProBasicPowerstationPoint>> companypointmap =new HashMap<>();
     public static Map<String,Map<String, ProBasicPowerstationPoint>> regionpointmap =new HashMap<>();
@@ -503,6 +505,18 @@ public class CacheContext implements CommandLineRunner {
 
         });
 
+
+        wswpls = proBasicWeatherStationService.list().stream().filter(i -> i.getIsAble() == 1).collect(Collectors.toList());
+        wswpls.stream().forEach(weather -> {
+
+            String subString = redisService.get(weather.getId());
+            Map<String, ProBasicPowerstationPoint> stringWindpowerstationpointnewMap = JSONObject.parseObject(subString, new TypeReference<Map<String, ProBasicPowerstationPoint>>() {
+            });
+            weatherwppointmap.put(weather.getId(), stringWindpowerstationpointnewMap);
+
+
+        });
+
         wswpls = proBasicWeatherStationService.list().stream().filter(i->runWpids.contains(i.getWindpowerstationId()) && i.getIsAble()==1).collect(Collectors.toList());
         wswpls.stream().forEach(ws->{
 

+ 19 - 14
realtime/generationXK-service/src/main/java/com/gyee/generation/model/auto/ProEconSystemEfficiency.java

@@ -1,18 +1,20 @@
 package com.gyee.generation.model.auto;
 
-import java.math.BigDecimal;
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.extension.activerecord.Model;
-import java.time.LocalDateTime;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
 
+import java.util.Date;
+
 /**
  * <p>
- * 光伏系统效率-场站、期次、线路
+ * 光伏系统效率
  * </p>
  *
- * @author shilin
- * @since 2023-11-28
+ * @author wang
+ * @since 2023-10-23
  */
 @Data
 @EqualsAndHashCode(callSuper = true)
@@ -20,6 +22,7 @@ public class ProEconSystemEfficiency extends Model {
 
     private static final long serialVersionUID = 1L;
 
+    @TableId(value = "id", type = IdType.INPUT)
     private String id;
 
     /**
@@ -42,6 +45,7 @@ public class ProEconSystemEfficiency extends Model {
      */
     private String lineId;
 
+
     /**
      * 所属位置(区域、区域风、区域光、公司、公司、公司风、公司光、场站、期次、线路)
      */
@@ -50,47 +54,48 @@ public class ProEconSystemEfficiency extends Model {
     /**
      * 数据日期
      */
-    private LocalDateTime dataDate;
+    private Date dataDate;
 
     /**
      * 日照强度
      */
-    private BigDecimal rzqd;
+    private Double rzqd;
 
     /**
      * 发电量
      */
-    private BigDecimal powerGeneration;
+    private Double powerGeneration;
+
 
     /**
      * 最大理论发电量
      */
-    private BigDecimal llfdlmax;
+    private Double llfdlmax;
 
     /**
      * 离散率
      */
-    private BigDecimal scatter;
+    private Double scatter;
 
     /**
      * 转换效率
      */
-    private BigDecimal conversionEfficiency;
+    private Double conversionEfficiency;
 
     /**
      * 等效发电时
      */
-    private BigDecimal equivalentGeneratingTime;
+    private Double equivalentGeneratingTime;
 
     /**
      * 利用小时
      */
-    private BigDecimal utilizationHours;
+    private Double utilizationHours;
 
     /**
      * 系统效率
      */
-    private BigDecimal efficiency;
+    private Double efficiency;
 
 
 }

+ 15 - 15
realtime/generationXK-service/src/main/java/com/gyee/generation/model/auto/ProEconSystemEfficiencyEquipment.java

@@ -1,18 +1,18 @@
 package com.gyee.generation.model.auto;
 
-import java.math.BigDecimal;
 import com.baomidou.mybatisplus.extension.activerecord.Model;
-import java.time.LocalDateTime;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
 
+import java.util.Date;
+
 /**
  * <p>
- * 光伏系统效率-设备
+ * 光伏系统效率
  * </p>
  *
- * @author shilin
- * @since 2023-11-28
+ * @author wang
+ * @since 2023-10-24
  */
 @Data
 @EqualsAndHashCode(callSuper = true)
@@ -52,52 +52,52 @@ public class ProEconSystemEfficiencyEquipment extends Model {
     /**
      * 数据日期
      */
-    private LocalDateTime dataDate;
+    private Date dataDate;
 
     /**
      * 日照强度
      */
-    private BigDecimal rzqd;
+    private Double rzqd;
 
     /**
      * 发电量
      */
-    private BigDecimal powerGeneration;
+    private Double powerGeneration;
 
     /**
      * 最大理论发电量
      */
-    private BigDecimal llfdlmax;
+    private Double llfdlmax;
 
     /**
      * 离散率
      */
-    private BigDecimal scatter;
+    private Double scatter;
 
     /**
      * 转换效率
      */
-    private BigDecimal conversionEfficiency;
+    private Double conversionEfficiency;
 
     /**
      * 等效发电时
      */
-    private BigDecimal equivalentGeneratingTime;
+    private Double equivalentGeneratingTime;
 
     /**
      * 利用小时
      */
-    private BigDecimal utilizationHours;
+    private Double utilizationHours;
 
     /**
      * 系统效率
      */
-    private BigDecimal efficiency;
+    private Double efficiency;
 
     /**
      * 顺序
      */
-    private Integer orderNum;
 
+    private Integer orderNum;
 
 }

+ 230 - 0
realtime/generationXK-service/src/main/java/com/gyee/generation/model/vo/PrAnalysisVo.java

@@ -0,0 +1,230 @@
+package com.gyee.generation.model.vo;
+
+public class PrAnalysisVo {
+
+    /**
+     * 设备编号
+     */
+    private String wtid;
+
+    /**
+     * 运行等级
+     */
+
+    private String level;
+    /**
+     * 容量
+     */
+
+    private Double rl;
+
+    /**
+     * 累计光照
+     */
+
+    private Double ljgzz;
+
+    /**
+     * 发电量
+     */
+
+    private Double fdl;
+
+    /**
+     * 最大理论发电量
+     */
+
+    private Double llfdlmax;
+
+    /**
+     * pr值
+     */
+
+    private Double pr = 0.0;
+
+    /**
+     * pr环比
+     */
+    private Double prhb = 0.0;
+
+    /**
+     * pr环比增长率
+     */
+    private Double prhbzzl = 0.0;
+
+
+    /**
+     * pr同比
+     */
+    private Double prtb = 0.0;
+
+    /**
+     * pr同比增长率
+     */
+    private Double prtbzzl = 0.0;
+
+    private Integer prpm;
+
+
+//    private Integer wtidpm;
+    private Integer prhbpm;
+    private Integer prtbpm;
+
+    private Integer fdlpm;
+    private Integer llfdlmaxpm;
+    private Integer ljgzzpm;
+    private Integer prhbzzlpm;
+    private Integer prtbzzlpm;
+
+    public Integer getPrhbpm() {
+        return prhbpm;
+    }
+
+    public void setPrhbpm(Integer prhbpm) {
+        this.prhbpm = prhbpm;
+    }
+
+    public Integer getPrtbpm() {
+        return prtbpm;
+    }
+
+    public void setPrtbpm(Integer prtbpm) {
+        this.prtbpm = prtbpm;
+    }
+
+    public Integer getPrhbzzlpm() {
+        return prhbzzlpm;
+    }
+
+    public void setPrhbzzlpm(Integer prhbzzlpm) {
+        this.prhbzzlpm = prhbzzlpm;
+    }
+
+    public Integer getPrtbzzlpm() {
+        return prtbzzlpm;
+    }
+
+    public void setPrtbzzlpm(Integer prtbzzlpm) {
+        this.prtbzzlpm = prtbzzlpm;
+    }
+
+    public String getWtid() {
+        return wtid;
+    }
+
+    public void setWtid(String wtid) {
+        this.wtid = wtid;
+    }
+
+    public Double getPr() {
+        return pr;
+    }
+
+    public void setPr(Double pr) {
+        this.pr = pr;
+    }
+
+    public Double getPrhb() {
+        return prhb;
+    }
+
+    public void setPrhb(Double prhb) {
+        this.prhb = prhb;
+    }
+
+    public Double getPrhbzzl() {
+        return prhbzzl;
+    }
+
+    public void setPrhbzzl(Double prhbzzl) {
+        this.prhbzzl = prhbzzl;
+    }
+
+    public Double getPrtb() {
+        return prtb;
+    }
+
+    public void setPrtb(Double prtb) {
+        this.prtb = prtb;
+    }
+
+    public Double getPrtbzzl() {
+        return prtbzzl;
+    }
+
+    public void setPrtbzzl(Double prtbzzl) {
+        this.prtbzzl = prtbzzl;
+    }
+
+    public Integer getPrpm() {
+        return prpm;
+    }
+
+    public void setPrpm(Integer prpm) {
+        this.prpm = prpm;
+    }
+
+    public Double getRl() {
+        return rl;
+    }
+
+    public void setRl(Double rl) {
+        this.rl = rl;
+    }
+
+    public Double getFdl() {
+        return fdl;
+    }
+
+    public void setFdl(Double fdl) {
+        this.fdl = fdl;
+    }
+
+    public Double getLlfdlmax() {
+        return llfdlmax;
+    }
+
+    public void setLlfdlmax(Double llfdlmax) {
+        this.llfdlmax = llfdlmax;
+    }
+
+    public Double getLjgzz() {
+        return ljgzz;
+    }
+
+    public void setLjgzz(Double ljgzz) {
+        this.ljgzz = ljgzz;
+    }
+
+    public String getLevel() {
+        return level;
+    }
+
+    public void setLevel(String level) {
+        this.level = level;
+    }
+
+    public Integer getFdlpm() {
+        return fdlpm;
+    }
+
+    public void setFdlpm(Integer fdlpm) {
+        this.fdlpm = fdlpm;
+    }
+
+    public Integer getllfdlmaxpm() {
+        return llfdlmaxpm;
+    }
+
+    public void setllfdlmaxpm(Integer llfdlmaxpm) {
+        this.llfdlmaxpm = llfdlmaxpm;
+    }
+
+    public Integer getljgzzpm() {
+        return ljgzzpm;
+    }
+
+    public void setLjgzzpm(Integer ljgzzpm) {
+        this.ljgzzpm = ljgzzpm;
+    }
+}

+ 491 - 0
realtime/generationXK-service/src/main/java/com/gyee/generation/service/PVSystemEfficiencyCalculator.java

@@ -0,0 +1,491 @@
+package com.gyee.generation.service;
+
+import com.gyee.common.contant.ContantXk;
+import com.gyee.common.model.StringUtils;
+import com.gyee.common.util.DateUtils;
+import com.gyee.generation.init.CacheContext;
+import com.gyee.generation.model.auto.*;
+import com.gyee.generation.service.auto.IProBasicPowerstationPointService;
+import com.gyee.generation.service.auto.IProEconEquipmentInfoDay1Service;
+import com.gyee.generation.service.auto.IProEconPowerstationInfoDay1Service;
+import com.gyee.generation.service.auto.IProEconPowerstationInfoDay5Service;
+import com.gyee.generation.service.auto.impl.ProEconSystemEfficiencyEquipmentServiceImpl;
+import com.gyee.generation.service.auto.impl.ProEconSystemEfficiencyServiceImpl;
+import com.gyee.generation.util.realtimesource.IEdosUtil;
+
+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.stream.Collectors;
+
+@Service
+public class PVSystemEfficiencyCalculator {
+    @Resource
+    private IProEconPowerstationInfoDay5Service proEconPowerstationInfoDay5Service;
+    @Resource
+    private IProEconPowerstationInfoDay1Service proEconPowerstationInfoDay1Service;
+
+    @Resource
+    private IProEconEquipmentInfoDay1Service proEconEquipmentInfoDay1Service;
+
+    @Resource
+    private ProEconSystemEfficiencyServiceImpl systemEfficiencyService;
+
+    @Resource
+    private ProEconSystemEfficiencyEquipmentServiceImpl efficiencyEquipmentService;
+
+    @Resource
+    private IProBasicPowerstationPointService proBasicPowerstationPointService;
+
+    @Resource
+    private IEdosUtil edosUtil;
+
+    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);//本年
+
+        // 设置为本年一月一号0点
+        Calendar calendar1 = Calendar.getInstance();
+        calendar1.setTime(new Date());
+        calendar1.set(Calendar.YEAR, currentyear); // 根据当前年份变化
+        calendar1.set(Calendar.MONTH, Calendar.JANUARY); // 0表示一月
+        calendar1.set(Calendar.DAY_OF_MONTH, 1);
+        calendar1.set(Calendar.HOUR_OF_DAY, 0);
+        calendar1.set(Calendar.MINUTE, 0);
+        calendar1.set(Calendar.SECOND, 0);
+        calendar1.set(Calendar.MILLISECOND, 0);
+        Date firstDayZeroHour = calendar1.getTime();
+
+        // 初始化初始值
+        Date initialFirstDayZeroHour = (Date) firstDayZeroHour.clone();
+        // 获取firstDayZeroHour的月份
+        Calendar calFirstDayZeroHour = Calendar.getInstance();
+        calFirstDayZeroHour.setTime(firstDayZeroHour);
+        int calFirstMonth = calFirstDayZeroHour.get(Calendar.MONTH) + 1;
+
+        //当前时间月份
+        Calendar calendar = Calendar.getInstance();
+        int currentMonth = calendar.get(Calendar.MONTH);
+        currentMonth = currentMonth + 1;
+
+        List<ProBasicPowerstation> wplsG = CacheContext.wpls.stream().filter(w->w.getId().endsWith("GDC_STA")).collect(Collectors.toList());
+        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 < currentMonth; i++) {
+
+                Date date = null;
+                List<ProEconSystemEfficiency> stringList = new ArrayList<>();
+
+                if (calFirstMonth == currentMonth && dqnf == currentyear) {
+                    Calendar calendar5 = Calendar.getInstance();
+                    ts = calendar5.get(Calendar.DAY_OF_MONTH);
+                } else {
+                    // 获取当前月份的天数
+                    ts = calFirstDayZeroHour.getActualMaximum(Calendar.DAY_OF_MONTH);
+                }
+
+                double rfdlsj = 0.0;
+                List<ProEconPowerstationInfoDay5> day5List = proEconPowerstationInfoDay5Service.getmax(wp.getId(), firstDayZeroHour);
+
+                List<ProEconPowerstationInfoDay1> rzqdls = proEconPowerstationInfoDay1Service.getmax(wp.getId(), firstDayZeroHour);
+
+                ProBasicPowerstationPoint rfdlvalue = proBasicPowerstationPointService.getPowerstationPoint(wp.getId(), ContantXk.RFDL);
+                rfdlsj = edosUtil.getRealData(rfdlvalue).getPointValueInDouble();
+
+                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) {
+                        if (calFirstMonth == currentMonth) {
+                            actualPowerOutputKilowattHours = day.getYfdldb().doubleValue() + rfdlsj;
+                        } else {
+                            actualPowerOutputKilowattHours = day.getYfdldb().doubleValue();
+                        }
+                        date = day.getRecordDate();
+                    }
+                }
+                if (!rzqdls.isEmpty() && rzqdls != null) {
+                    for (ProEconPowerstationInfoDay1 rz : rzqdls) {
+                        solarRadiationWattsPerSquareMeter = rz.getYpjfs().doubleValue();
+                    }
+                }
+                moduleCapacityKilowatts = wp.getJrCapacity();
+
+                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);
+
+                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;
+        }
+
+//        计算期次级别
+        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);
+                }
+
+                double rfdlsj = 0.0;
+                List<ProEconPowerstationInfoDay5> day5List = proEconPowerstationInfoDay5Service.getmax(pj.getId(), firstDayZeroHour2);
+                List<ProEconPowerstationInfoDay1> rzqdls = proEconPowerstationInfoDay1Service.getmax(pj.getId(), firstDayZeroHour2);
+                ProBasicPowerstationPoint rfdlvalue = proBasicPowerstationPointService.getPowerstationPoint(pj.getId(), ContantXk.RFDL);
+                rfdlsj = edosUtil.getRealData(rfdlvalue).getPointValueInDouble();
+                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) {
+                        if (calFirstMonth2 == currentMonth && dqnf == currentyear) {
+                            actualPowerOutputKilowattHours = day.getYfdldb().doubleValue() + rfdlsj;
+                        } else {
+                            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 currentDate = new Date();
+
+        // 创建 Calendar 对象,并设置为当前日期
+        Calendar calendar4 = Calendar.getInstance();
+        calendar4.setTime(currentDate);
+
+        // 将时间设为0点
+        calendar4.set(Calendar.HOUR_OF_DAY, 0);
+        calendar4.set(Calendar.MINUTE, 0);
+        calendar4.set(Calendar.SECOND, 0);
+        calendar4.set(Calendar.MILLISECOND, 0);
+
+        // 设置 beginDate 为前一天的0点
+        calendar4.add(Calendar.DAY_OF_MONTH, -1);
+        Date firstDayZeroHour4 = calendar4.getTime();
+
+        // 初始化初始值
+        Date initialFirstDayZeroHour4 = (Date) firstDayZeroHour4.clone();
+
+        // 获取firstDayZeroHour的月份
+        Calendar calFirstDayZeroHour4 = Calendar.getInstance();
+        calFirstDayZeroHour4.setTime(firstDayZeroHour4);
+        int calFirstMonth4 = calFirstDayZeroHour4.get(Calendar.MONTH) + 1;
+        Date date = null;
+        List<ProEconSystemEfficiencyEquipment> stringList = new ArrayList<>();
+        for (ProBasicPowerstation wp : CacheContext.wpls.stream().filter(w->w.getId().endsWith("GDC_STA")).collect(Collectors.toList())) {
+
+                List<ProBasicEquipment> wtlsG = CacheContext.wtls.stream().filter(p -> p.getSpare1().equals("IN") && wp.getId().equals(p.getWindpowerstationId())).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);
+                    }
+
+                    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();
+                    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(Integer.valueOf(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);
+//        }
+                    // 恢复初始值
+//            firstDayZeroHour4 = initialFirstDayZeroHour4;
+                }
+            efficiencyEquipmentService.batchAdd(stringList);
+            stringList.clear();
+        }
+
+
+
+
+    }
+
+    // 计算预期发电量的方法
+    public static double calculateExpectedPowerOutput(double solarRadiationWattsPerSquareMeter, double moduleCapacityKilowatts, double ts) {
+        double hoursOfDaylight = 12.0; // 假设日照时间为12小时
+        //辐照度*容量
+        //
+        return (solarRadiationWattsPerSquareMeter * moduleCapacityKilowatts);
+    }
+
+    // 计算光伏系统效率PR的方法
+    public static double calculatePR(double actualPowerOutputKilowattHours, double expectedPowerOutputKilowattHours) {
+        if (expectedPowerOutputKilowattHours == 0) {
+            return actualPowerOutputKilowattHours;
+        }
+        // 实际发电量/预期发电量
+        return (actualPowerOutputKilowattHours / expectedPowerOutputKilowattHours) * 100;
+    }
+}

+ 1 - 1
realtime/generationXK-service/src/main/java/com/gyee/generation/service/auto/IProBasicPowerstationPointService.java

@@ -16,5 +16,5 @@ import com.baomidou.mybatisplus.extension.service.IService;
  * @since 2022-10-31
  */
 public interface IProBasicPowerstationPointService extends IService<ProBasicPowerstationPoint> {
-
+    public ProBasicPowerstationPoint getPowerstationPoint(String wpId, String uniformCode);
 }

+ 4 - 1
realtime/generationXK-service/src/main/java/com/gyee/generation/service/auto/IProEconEquipmentInfoDay1Service.java

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

+ 4 - 1
realtime/generationXK-service/src/main/java/com/gyee/generation/service/auto/IProEconPowerstationInfoDay1Service.java

@@ -3,6 +3,9 @@ package com.gyee.generation.service.auto;
 import com.gyee.generation.model.auto.ProEconPowerstationInfoDay1;
 import com.baomidou.mybatisplus.extension.service.IService;
 
+import java.util.Date;
+import java.util.List;
+
 /**
  * <p>
  * 场站五损电量 服务类
@@ -12,5 +15,5 @@ import com.baomidou.mybatisplus.extension.service.IService;
  * @since 2022-11-01
  */
 public interface IProEconPowerstationInfoDay1Service extends IService<ProEconPowerstationInfoDay1> {
-
+    List<ProEconPowerstationInfoDay1> getmax(String foreignKeyId , Date date);
 }

+ 4 - 1
realtime/generationXK-service/src/main/java/com/gyee/generation/service/auto/IProEconPowerstationInfoDay5Service.java

@@ -3,6 +3,9 @@ package com.gyee.generation.service.auto;
 import com.gyee.generation.model.auto.ProEconPowerstationInfoDay5;
 import com.baomidou.mybatisplus.extension.service.IService;
 
+import java.util.Date;
+import java.util.List;
+
 /**
  * <p>
  * 电表发电量 服务类
@@ -12,5 +15,5 @@ import com.baomidou.mybatisplus.extension.service.IService;
  * @since 2022-11-01
  */
 public interface IProEconPowerstationInfoDay5Service extends IService<ProEconPowerstationInfoDay5> {
-
+    List<ProEconPowerstationInfoDay5> getmax(String foreignKeyId , Date date);
 }

+ 3 - 1
realtime/generationXK-service/src/main/java/com/gyee/generation/service/auto/IProEconSystemEfficiencyEquipmentService.java

@@ -3,6 +3,8 @@ package com.gyee.generation.service.auto;
 import com.gyee.generation.model.auto.ProEconSystemEfficiencyEquipment;
 import com.baomidou.mybatisplus.extension.service.IService;
 
+import java.util.List;
+
 /**
  * <p>
  * 光伏系统效率-设备 服务类
@@ -12,5 +14,5 @@ import com.baomidou.mybatisplus.extension.service.IService;
  * @since 2023-11-28
  */
 public interface IProEconSystemEfficiencyEquipmentService extends IService<ProEconSystemEfficiencyEquipment> {
-
+    boolean batchAdd (List<ProEconSystemEfficiencyEquipment> proEconStationPowers);
 }

+ 6 - 1
realtime/generationXK-service/src/main/java/com/gyee/generation/service/auto/IProEconSystemEfficiencyService.java

@@ -1,7 +1,10 @@
 package com.gyee.generation.service.auto;
 
-import com.gyee.generation.model.auto.ProEconSystemEfficiency;
+
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.gyee.generation.model.auto.ProEconSystemEfficiency;
+
+import java.util.List;
 
 /**
  * <p>
@@ -13,4 +16,6 @@ import com.baomidou.mybatisplus.extension.service.IService;
  */
 public interface IProEconSystemEfficiencyService extends IService<ProEconSystemEfficiency> {
 
+
+    boolean batchAdd (List<ProEconSystemEfficiency> proEconStationPowers);
 }

+ 68 - 2
realtime/generationXK-service/src/main/java/com/gyee/generation/service/auto/impl/ProBasicPowerstationPointServiceImpl.java

@@ -1,11 +1,15 @@
 package com.gyee.generation.service.auto.impl;
 
-import com.gyee.generation.model.auto.ProBasicPowerstationPoint;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.gyee.common.model.StringUtils;
+import com.gyee.generation.init.CacheContext;
 import com.gyee.generation.mapper.auto.ProBasicPowerstationPointMapper;
+import com.gyee.generation.model.auto.ProBasicPowerstationPoint;
 import com.gyee.generation.service.auto.IProBasicPowerstationPointService;
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.springframework.stereotype.Service;
 
+import java.util.Map;
+
 /**
  * <p>
  * 场站测点,期次测点,线路测点,三级公司测点,区域测点
@@ -21,4 +25,66 @@ import org.springframework.stereotype.Service;
 @Service
 public class ProBasicPowerstationPointServiceImpl extends ServiceImpl<ProBasicPowerstationPointMapper, ProBasicPowerstationPoint> implements IProBasicPowerstationPointService {
 
+    @Override
+    public ProBasicPowerstationPoint getPowerstationPoint(String wpId, String uniformCode) {
+        ProBasicPowerstationPoint point = new ProBasicPowerstationPoint();
+
+        if (StringUtils.notEmp(wpId) && StringUtils.notEmp(uniformCode)) {
+            if (wpId.endsWith("0") || wpId.endsWith("-1") || wpId.endsWith("-2") || CacheContext.wpmap.containsKey(wpId)) {
+                if (CacheContext.wppointmap.containsKey(wpId)) {
+                    Map<String, ProBasicPowerstationPoint> map = CacheContext.wppointmap.get(wpId);
+                    if (map.containsKey(uniformCode)) {
+                        point = map.get(uniformCode);
+                    }
+                } else if (CacheContext.subwppointmap.containsKey(wpId)) {
+                    Map<String, ProBasicPowerstationPoint> map = CacheContext.subwppointmap.get(wpId);
+                    if (map.containsKey(uniformCode)) {
+                        point = map.get(uniformCode);
+                    }
+                } else if (CacheContext.weatherwppointmap.containsKey(wpId)) {
+                    Map<String, ProBasicPowerstationPoint> map = CacheContext.weatherwppointmap.get(wpId);
+                    if (map.containsKey(uniformCode)) {
+                        point = map.get(uniformCode);
+                    }
+                } else if (CacheContext.companypointmap.containsKey(wpId)) {
+                    Map<String, ProBasicPowerstationPoint> map = CacheContext.companypointmap.get(wpId);
+                    if (map.containsKey(uniformCode)) {
+                        point = map.get(uniformCode);
+                    }
+                } else if (CacheContext.regionpointmap.containsKey(wpId)) {
+                    Map<String, ProBasicPowerstationPoint> map = CacheContext.regionpointmap.get(wpId);
+                    if (map.containsKey(uniformCode)) {
+                        point = map.get(uniformCode);
+                    }
+                } else if (CacheContext.grouppointmap.containsKey(wpId)) {
+                    Map<String, ProBasicPowerstationPoint> map = CacheContext.grouppointmap.get(wpId);
+                    if (map.containsKey(uniformCode)) {
+                        point = map.get(uniformCode);
+                    }
+                }
+            } else if (CacheContext.pjmap.containsKey(wpId)) {
+                if (CacheContext.propointmap.containsKey(wpId)) {
+                    Map<String, ProBasicPowerstationPoint> map = CacheContext.propointmap.get(wpId);
+                    if (map.containsKey(uniformCode)) {
+                        point = map.get(uniformCode);
+                    }
+                }
+            } else if (CacheContext.lnmap.containsKey(wpId)) {
+                if (CacheContext.linepointmap.containsKey(wpId)) {
+                    Map<String, ProBasicPowerstationPoint> map = CacheContext.linepointmap.get(wpId);
+                    if (map.containsKey(uniformCode)) {
+                        point = map.get(uniformCode);
+                    }
+                }
+            } else if (CacheContext.weatherwppointmap.containsKey(wpId)) {
+                Map<String, ProBasicPowerstationPoint> map = CacheContext.weatherwppointmap.get(wpId);
+                if (map.containsKey(uniformCode)) {
+                    point = map.get(uniformCode);
+                }
+            }
+        }
+
+
+        return point;
+    }
 }

+ 57 - 0
realtime/generationXK-service/src/main/java/com/gyee/generation/service/auto/impl/ProEconEquipmentInfoDay1ServiceImpl.java

@@ -1,11 +1,19 @@
 package com.gyee.generation.service.auto.impl;
 
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.gyee.common.model.StringUtils;
+import com.gyee.common.util.DateUtils;
 import com.gyee.generation.model.auto.ProEconEquipmentInfoDay1;
 import com.gyee.generation.mapper.auto.ProEconEquipmentInfoDay1Mapper;
 import com.gyee.generation.service.auto.IProEconEquipmentInfoDay1Service;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.springframework.stereotype.Service;
 
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.List;
+
 /**
  * <p>
  * 五损电量 服务实现类
@@ -16,5 +24,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;
+    }
 }

+ 33 - 0
realtime/generationXK-service/src/main/java/com/gyee/generation/service/auto/impl/ProEconPowerstationInfoDay1ServiceImpl.java

@@ -1,11 +1,19 @@
 package com.gyee.generation.service.auto.impl;
 
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.gyee.common.model.StringUtils;
+import com.gyee.common.util.DateUtils;
 import com.gyee.generation.model.auto.ProEconPowerstationInfoDay1;
 import com.gyee.generation.mapper.auto.ProEconPowerstationInfoDay1Mapper;
 import com.gyee.generation.service.auto.IProEconPowerstationInfoDay1Service;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.springframework.stereotype.Service;
 
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.List;
+
 /**
  * <p>
  * 场站五损电量 服务实现类
@@ -16,5 +24,30 @@ import org.springframework.stereotype.Service;
  */
 @Service
 public class ProEconPowerstationInfoDay1ServiceImpl extends ServiceImpl<ProEconPowerstationInfoDay1Mapper, ProEconPowerstationInfoDay1> implements IProEconPowerstationInfoDay1Service {
+    @Override
+    public List<ProEconPowerstationInfoDay1> getmax(String foreignKeyId, Date date) {
+        QueryWrapper<ProEconPowerstationInfoDay1> qw = null;
+
+        Calendar calendar = Calendar.getInstance();
+        calendar.setTime(date);
+        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();
+        //当前数据
+        List<ProEconPowerstationInfoDay1> currlist = new ArrayList<>();
+        if (null != date) {
+            qw = new QueryWrapper<>();
+            if (StringUtils.isNotEmpty(foreignKeyId)) {
+                qw.lambda().eq(ProEconPowerstationInfoDay1::getForeignKeyId, foreignKeyId);
+            }
+            qw.lambda().between(ProEconPowerstationInfoDay1::getRecordDate, DateUtils.getMonthFirst(date), endOfDayOfLastDayOfMonth);
+            qw.lambda().orderByDesc(ProEconPowerstationInfoDay1::getRecordDate);
+            qw.last("limit 1");
+            currlist = baseMapper.selectList(qw);
 
+        }
+        return currlist;
+    }
 }

+ 58 - 0
realtime/generationXK-service/src/main/java/com/gyee/generation/service/auto/impl/ProEconPowerstationInfoDay5ServiceImpl.java

@@ -1,11 +1,19 @@
 package com.gyee.generation.service.auto.impl;
 
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.gyee.common.model.StringUtils;
+import com.gyee.common.util.DateUtils;
 import com.gyee.generation.model.auto.ProEconPowerstationInfoDay5;
 import com.gyee.generation.mapper.auto.ProEconPowerstationInfoDay5Mapper;
 import com.gyee.generation.service.auto.IProEconPowerstationInfoDay5Service;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 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 ProEconPowerstationInfoDay5ServiceImpl extends ServiceImpl<ProEconPowerstationInfoDay5Mapper, ProEconPowerstationInfoDay5> implements IProEconPowerstationInfoDay5Service {
 
+    @Override
+    public List<ProEconPowerstationInfoDay5> getmax(String foreignKeyId, Date date) {
+        QueryWrapper<ProEconPowerstationInfoDay5> 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<ProEconPowerstationInfoDay5> currlist = new ArrayList<>();
+        if (null != date) {
+            qw = new QueryWrapper<>();
+            if (StringUtils.isNotEmpty(foreignKeyId)) {
+                qw.lambda().eq(ProEconPowerstationInfoDay5::getForeignKeyId, foreignKeyId);
+            }
+            qw.lambda().between(ProEconPowerstationInfoDay5::getRecordDate, DateUtils.getMonthFirst(date), endOfDayOfLastDayOfMonth);
+            qw.lambda().orderByDesc(ProEconPowerstationInfoDay5::getRecordDate);
+            qw.last("limit 1");
+            currlist = baseMapper.selectList(qw);
+
+        }
+        return currlist;
+    }
 }

+ 27 - 2
realtime/generationXK-service/src/main/java/com/gyee/generation/service/auto/impl/ProEconSystemEfficiencyEquipmentServiceImpl.java

@@ -1,11 +1,15 @@
 package com.gyee.generation.service.auto.impl;
 
-import com.gyee.generation.model.auto.ProEconSystemEfficiencyEquipment;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.gyee.generation.mapper.auto.ProEconSystemEfficiencyEquipmentMapper;
+import com.gyee.generation.model.auto.ProEconSystemEfficiencyEquipment;
 import com.gyee.generation.service.auto.IProEconSystemEfficiencyEquipmentService;
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.springframework.stereotype.Service;
 
+import java.util.List;
+
 /**
  * <p>
  * 光伏系统效率-设备 服务实现类
@@ -16,5 +20,26 @@ import org.springframework.stereotype.Service;
  */
 @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;
+    }
 }

+ 28 - 2
realtime/generationXK-service/src/main/java/com/gyee/generation/service/auto/impl/ProEconSystemEfficiencyServiceImpl.java

@@ -1,11 +1,15 @@
 package com.gyee.generation.service.auto.impl;
 
-import com.gyee.generation.model.auto.ProEconSystemEfficiency;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.gyee.generation.mapper.auto.ProEconSystemEfficiencyMapper;
+import com.gyee.generation.model.auto.ProEconSystemEfficiency;
 import com.gyee.generation.service.auto.IProEconSystemEfficiencyService;
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.springframework.stereotype.Service;
 
+import java.util.List;
+
 /**
  * <p>
  * 光伏系统效率-场站、期次、线路 服务实现类
@@ -17,4 +21,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;
+    }
 }

+ 25 - 0
realtime/generationXK-service/src/main/resources/xxl-job-efficiency.properties

@@ -0,0 +1,25 @@
+### xxl-job admin address list, such as "http://address" or "http://address01,http://address02"
+xxl.job.admin.addresses=http://10.81.3.152:8179/xxl-job-admin
+
+### xxl-job, access token
+xxl.job.accessToken=
+
+### xxl-job executor appname
+### 场站计算
+#xxl.job.executor.appname=generationWP-job
+### 区域公司计算
+xxl.job.executor.appname=efficiency-job
+### xxl-job executor registry-address: default use address to registry , otherwise use ip:port if address is null
+xxl.job.executor.address=
+### xxl-job executor server-info
+xxl.job.executor.ip=
+#场站端口
+#xxl.job.executor.port=9201
+#区域端口
+xxl.job.executor.port=9379
+
+### xxl-job executor log-path
+xxl.job.executor.logpath=E:\gyee\log\efficiency
+### xxl-job executor log-retention-days
+xxl.job.executor.logretentiondays=30
+

+ 9 - 1
realtime/generationXK-service/src/test/java/com/gyee/generation/GenerationTest.java

@@ -1,5 +1,6 @@
 package com.gyee.generation;
 
+import com.gyee.generation.service.PVSystemEfficiencyCalculator;
 import com.gyee.generation.service.StationPower.StationPowerService;
 import com.gyee.generation.service.initalcache.CacheService;
 import com.gyee.generation.service.realtimelibrary.*;
@@ -44,6 +45,9 @@ public class GenerationTest {
     private SafetyDayService safetyDayService;
     @Resource
     private StationPowerService stationPowerService;
+
+    @Resource
+    private PVSystemEfficiencyCalculator calculator;
     @Test
     public void test1() throws Exception {
         cacheService.initRedisCache();
@@ -96,6 +100,10 @@ public class GenerationTest {
 
 //        safetyDayService.saveSafetyday();
 
-        stationPowerService.predictedPower();
+//        stationPowerService.predictedPower();
+
+
+        calculator.planvalue();
+
     }
 }