Browse Source

经济运行报告

王波 5 ngày trước cách đây
mục cha
commit
5341154a80

+ 2 - 1
runeconomy-xk/src/main/java/com/gyee/RunEconomyApplication.java

@@ -8,6 +8,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
 import org.springframework.boot.system.ApplicationHome;
 import org.springframework.context.ConfigurableApplicationContext;
 import org.springframework.core.env.Environment;
+import org.springframework.scheduling.annotation.EnableScheduling;
 
 import java.net.InetAddress;
 import java.net.UnknownHostException;
@@ -15,7 +16,7 @@ import java.net.UnknownHostException;
 
 @Log4j2
 @SpringBootApplication
-//@EnableScheduling
+@EnableScheduling
 @MapperScan("com.gyee.runeconomy.mapper")
 public class RunEconomyApplication {
 

+ 0 - 19
runeconomy-xk/src/main/java/com/gyee/runeconomy/controller/ProBasicBranchController.java

@@ -1,19 +0,0 @@
-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-05-13
- */
-@RestController
-@RequestMapping("//pro-basic-branch")
-public class ProBasicBranchController {
-
-}

+ 3 - 0
runeconomy-xk/src/main/java/com/gyee/runeconomy/model/auto/StationInfoDay.java

@@ -71,5 +71,8 @@ public class StationInfoDay implements Serializable {
      */
     private BigDecimal jhfdl;
 
+    private BigDecimal cftfs;
+    private BigDecimal cftfx;
+
 
 }

+ 9 - 0
runeconomy-xk/src/main/java/com/gyee/runeconomy/model/auto/TurbineInfoDay.java

@@ -183,5 +183,14 @@ public class TurbineInfoDay implements Serializable {
     @TableField("lxcs")
     private Integer lxcs;
 
+    @TableField("fx")
+    private BigDecimal fx;
+
+    @TableField("yxfss")
+    private BigDecimal yxfss;
+
+
+    @TableField("jfpl")
+    private BigDecimal jfpl;
 
 }

+ 15 - 7
runeconomy-xk/src/main/java/com/gyee/runeconomy/service/EarlyWarning/ReportService.java

@@ -138,11 +138,15 @@ public class ReportService {
         ).setScale(2, RoundingMode.HALF_UP)
                 .doubleValue(); // 去年同期小风切入风速
 
-        double currentSmallWindRate = 0.95; // 本月小风切入合格率
-        double lastYearSmallWindRate = 0.93; // 去年同期小风切入合格率
+//        double currentSmallWindRate = 0.95; // 本月小风切入合格率
+//        double lastYearSmallWindRate = 0.93; // 去年同期小风切入合格率
 
-        double currentRunningWindHours = 0.1; // 本月有效风时数
-        double lastYearRunningWindHours = 0.1; // 去年同期有效风时数
+        double currentRunningWindHours = turbineList.stream()
+                .mapToDouble(t -> t.getYxfss() == null ? 0 : Math.round(t.getYxfss().doubleValue() * 100.0) / 100.0)
+                .sum(); // 本月有效风时数
+        double lastYearRunningWindHours = tqturbineList.stream()
+                .mapToDouble(t -> t.getYxfss() == null ? 0 : Math.round(t.getYxfss().doubleValue() * 100.0) / 100.0)
+                .sum(); // 去年同期有效风时数
 
         double currentFaultLossPower = turbineList.stream()
                 .mapToDouble(t -> t.getGzss() == null ? 0 : Math.round(t.getGzss().doubleValue() * 100.0) / 100.0)
@@ -216,8 +220,12 @@ public class ReportService {
                 .mapToDouble(t -> t.getTjMin() == null ? 0 : Math.round(t.getTjMin().doubleValue() * 100.0) / 100.0)
                 .sum(); // 去年同期通讯中断时间
 
-        double currentCalmWindFrequency = 0.05; // 本月静风频率
-        double lastYearCalmWindFrequency = 0.04; // 去年同期静风频率
+        double currentCalmWindFrequency = turbineList.stream()
+                .mapToDouble(t -> t.getJfpl() == null ? 0 : Math.round(t.getJfpl().doubleValue() * 100.0) / 100.0)
+                .sum(); // 本月静风频率
+        double lastYearCalmWindFrequency = tqturbineList.stream()
+                .mapToDouble(t -> t.getJfpl() == null ? 0 : Math.round(t.getJfpl().doubleValue() * 100.0) / 100.0)
+                .sum(); // 去年同期静风频率
 
         // 使用方法来简化添加数据
         result.add(createIndicatorData("实际发电量", currentPower, lastYearPower));
@@ -227,7 +235,7 @@ public class ReportService {
         result.add(createIndicatorData("设备可利用率", currentEquipmentUtilization, lastYearEquipmentUtilization));
         result.add(createIndicatorData("等效可用系数", currentEfficiencyCoefficient, lastYearEfficiencyCoefficient));
         result.add(createIndicatorData("小风切入风速", currentSmallWindSpeed, lastYearSmallWindSpeed));
-        result.add(createIndicatorData("小风切入合格率", currentSmallWindRate, lastYearSmallWindRate));
+//        result.add(createIndicatorData("小风切入合格率", currentSmallWindRate, lastYearSmallWindRate));
         result.add(createIndicatorData("有效风时数", currentRunningWindHours, lastYearRunningWindHours));
         result.add(createIndicatorData("故障损失电量", currentFaultLossPower, lastYearFaultLossPower));
         result.add(createIndicatorData("调度限电损失电量", currentDispatchLossPower, lastYearDispatchLossPower));

+ 30 - 11
runeconomy-xk/src/main/java/com/gyee/runeconomy/service/WindDirection/WindMachineService.java

@@ -3,6 +3,7 @@ package com.gyee.runeconomy.service.WindDirection;
 
 import com.gyee.runeconomy.init.CacheContext;
 import com.gyee.runeconomy.model.auto.*;
+import com.gyee.runeconomy.service.auto.IStationInfoDayService;
 import com.gyee.runeconomy.service.auto.ITurbineInfoDayService;
 import org.springframework.stereotype.Service;
 
@@ -20,6 +21,8 @@ public class WindMachineService {
 
     @Resource
     private ITurbineInfoDayService turbineInfoDayService;
+    @Resource
+    private IStationInfoDayService stationInfoDayService;
 
 
     public Object machine(String wpid) throws Exception {
@@ -32,6 +35,7 @@ public class WindMachineService {
 
         Map<String, List> monthlyData = new LinkedHashMap<>();
 
+
         // 风机循环:每台风机每个月一个 WindData 对象
         for (ProBasicEquipment eq : collect) {
 
@@ -49,6 +53,7 @@ public class WindMachineService {
             String endOfYearStr = endOfYear.format(formatter);
 
             List<TurbineInfoDay> turbineList = turbineInfoDayService.getTurbineList(eq.getId(), startOfYearStr, endOfYearStr);
+            List<StationInfoDay> infoDays = stationInfoDayService.getTurbineList(wpid, startOfYearStr, endOfYearStr);
             List<String> zb = new ArrayList<>();
             zb.add("fsavg");
             zb.add("cftfsavg");
@@ -81,30 +86,44 @@ public class WindMachineService {
                             })
                             .collect(Collectors.toList());
 
-                    //风速
+                    List<StationInfoDay> dayfilteredList = infoDays.stream()
+                            .filter(turbine -> {
+                                // 获取 turbineInfoDay 的 recordDate(类型为 LocalDate)
+                                LocalDate dateFromTurbine = turbine.getRecordDate();
+
+                                // 获取记录的月份(注意,月份从 1 开始,1 表示1月)
+                                int recordMonth = dateFromTurbine.getMonthValue();
+
+                                // 判断记录的月份是否等于给定的 time
+                                return recordMonth == finalMonth;  // 比较 int 类型的月份和 time 变量
+                            })
+                            .collect(Collectors.toList());
+
+                    // 风速
                     double fsaverage = filteredList.stream()
-                            .mapToDouble(turbineInfoDay -> turbineInfoDay.getPjfs().doubleValue())
+                            .mapToDouble(turbineInfoDay -> Optional.ofNullable(turbineInfoDay.getPjfs()).map(Number::doubleValue).orElse(0.0))
                             .average()
                             .orElse(0.0);  // 默认值0.0
 
-                    //风向
+                    // 风向
                     double fxaverage = filteredList.stream()
-                            .mapToDouble(turbineInfoDay -> turbineInfoDay.getPjfs().doubleValue())
+                            .mapToDouble(turbineInfoDay -> Optional.ofNullable(turbineInfoDay.getFx()).map(Number::doubleValue).orElse(0.0))
                             .average()
                             .orElse(0.0);  // 默认值0.0
 
-                    //测风塔风速
-                    double cftfsaverage = filteredList.stream()
-                            .mapToDouble(turbineInfoDay -> turbineInfoDay.getPjfs().doubleValue())
+                    // 测风塔风速
+                    double cftfsaverage = dayfilteredList.stream()
+                            .mapToDouble(turbineInfoDay -> Optional.ofNullable(turbineInfoDay.getCftfs()).map(Number::doubleValue).orElse(0.0))
                             .average()
-                            .orElse(0.0);  // 默认值0.0
+                            .orElse(0.0); // 默认值0.0
 
-                    //测风塔风向
-                    double cftfxaverage = filteredList.stream()
-                            .mapToDouble(turbineInfoDay -> turbineInfoDay.getPjfs().doubleValue())
+                    // 测风塔风向
+                    double cftfxaverage = dayfilteredList.stream()
+                            .mapToDouble(turbineInfoDay -> Optional.ofNullable(turbineInfoDay.getCftfx()).map(Number::doubleValue).orElse(0.0))
                             .average()
                             .orElse(0.0);  // 默认值0.0
 
+
                     double zbsj = 0.0;
 
                     if (z.toString().equals("fsavg")) {

+ 2 - 1
runeconomy-xk/src/main/java/com/gyee/runeconomy/service/auto/IStationInfoDayService.java

@@ -3,6 +3,7 @@ package com.gyee.runeconomy.service.auto;
 import com.gyee.runeconomy.model.auto.StationInfoDay;
 import com.baomidou.mybatisplus.extension.service.IService;
 
+import java.text.ParseException;
 import java.util.Date;
 import java.util.List;
 
@@ -17,5 +18,5 @@ import java.util.List;
 public interface IStationInfoDayService extends IService<StationInfoDay> {
 
     List<StationInfoDay> getmax(String foreignKeyId, Date date);
-
+    List<StationInfoDay> getTurbineList(String wpid, String kssj, String jssj) throws ParseException;
 }

+ 15 - 4
runeconomy-xk/src/main/java/com/gyee/runeconomy/service/auto/impl/StationInfoDayServiceImpl.java

@@ -6,14 +6,14 @@ import com.gyee.common.util.DateUtils;
 import com.gyee.runeconomy.model.auto.ProEconPowerstationInfoDay5;
 import com.gyee.runeconomy.model.auto.StationInfoDay;
 import com.gyee.runeconomy.mapper.auto.StationInfoDayMapper;
+import com.gyee.runeconomy.model.auto.TurbineInfoDay;
 import com.gyee.runeconomy.service.auto.IStationInfoDayService;
 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;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.*;
 
 /**
  * <p>
@@ -76,4 +76,15 @@ public class StationInfoDayServiceImpl extends ServiceImpl<StationInfoDayMapper,
         return currlist;
     }
 
+    @Override
+    public List<StationInfoDay> getTurbineList(String wpid, String kssj, String jssj) throws ParseException {
+        QueryWrapper<StationInfoDay> qw = new QueryWrapper<>();
+        Date kssjDate = new SimpleDateFormat("yyyy-MM-dd").parse(kssj);
+        Date jssjDate = new SimpleDateFormat("yyyy-MM-dd").parse(jssj);
+        qw.lambda().eq(StationInfoDay::getStationId,wpid);
+        qw.lambda().between(StationInfoDay::getRecordDate,kssjDate,jssjDate);
+        List<StationInfoDay> list = baseMapper.selectList(qw);
+        return list;
+    }
+
 }