Преглед изворни кода

开发首页右下角发电量

xusl пре 7 месеци
родитељ
комит
7a9dddd26c

+ 57 - 21
cpp-admin/src/main/java/com/cpp/web/controller/largeScreen/LargeScreenController.java

@@ -2,13 +2,16 @@ package com.cpp.web.controller.largeScreen;
 
 import cn.hutool.core.date.DateUtil;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.cpp.common.core.cache.LocalCache;
 import com.cpp.common.core.domain.R;
 import com.cpp.system.service.ISysConfigService;
+import com.cpp.web.domain.powerGeneration.DayPowerGeneration;
 import com.cpp.web.domain.station.*;
 import com.cpp.web.domain.station.enums.ElectricFieldTypeEnum;
 import com.cpp.web.dto.largeScreen.ElectricFieldDataTotalDto;
 import com.cpp.web.dto.largeScreen.ForecastGeneratingDataDto;
 import com.cpp.web.dto.largeScreen.ProductionDataTotalDto;
+import com.cpp.web.service.powerGeneation.DayPowerGenerationService;
 import com.cpp.web.service.station.*;
 import com.cpp.web.utils.DateTimeUtil;
 import com.cpp.web.utils.LatestDataUtil;
@@ -19,6 +22,7 @@ import org.springframework.web.bind.annotation.*;
 
 import java.math.BigDecimal;
 import java.math.RoundingMode;
+import java.text.SimpleDateFormat;
 import java.util.*;
 import java.util.stream.Collectors;
 
@@ -49,6 +53,8 @@ public class LargeScreenController {
     WindTowerStatusDataService windTowerStatusDataService;
     @Autowired
     WeatherStationStatusDataService weatherStationStatusDataService;
+    @Autowired
+    DayPowerGenerationService dayPowerGenerationService;
 
     @GetMapping("/getBizData")
     public R getBizData() {
@@ -116,7 +122,8 @@ public class LargeScreenController {
         ProductionDataTotalDto productionDataTotalDto = calGenerating();
         bizDataMap.put("productionDataTotalDto",productionDataTotalDto);
         // 获取预测发电量
-        calForecastGenerating();
+        Map forecastGeneratingMap = calForecastGenerating();
+        bizDataMap.put("forecastGeneratingMap",forecastGeneratingMap);
 
         // 定义首页实际功率、可用、理论总和
         BigDecimal realSum = BigDecimal.ZERO;
@@ -337,7 +344,7 @@ public class LargeScreenController {
             }
         }
         // 获取中心侧预测的当日所有短期预测功率,前提判断上个月哪个预测准确率更准确用哪个模型
-
+//        List<ForecastGeneratingDataDto> forecastGeneratingDataDtoList = calForecastGenerating();
 
 
 
@@ -362,28 +369,57 @@ public class LargeScreenController {
     }
 
     /**
-     * 统计首页未来15天预测总发电量
+     * 统计首页未来10天预测总发电量
      * @return
      */
-    private ForecastGeneratingDataDto calForecastGenerating(){
-        // 获取未来15天的上报预测值
-        Date startTime = DateTimeUtil.getDayStartTime(DateUtils.addDays(new Date(), 1).getTime());
-        Date endTime = DateTimeUtil.getDayLastTime(DateUtils.addDays(new Date(), 15).getTime());
-        QueryWrapper dqsbWrapper = new QueryWrapper<>();
-        dqsbWrapper.eq("forecast_how_long_ago",1);
-        dqsbWrapper.between("time", startTime, endTime);
-        List<ForecastPowerShortTermRegulation> forecastPowerShortTermRegulationList = forecastPowerShortTermRegulationService.list(dqsbWrapper);
+    private Map calForecastGenerating(){
+        // 获取未来10天的中心侧模型预测发电量
+        int counts = -3;
+        // 定义日期格式
+        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
+        // 定义开始日期和结束日期(使用Calendar对象)
+        Calendar currentDate = Calendar.getInstance();
+        Calendar endDate = Calendar.getInstance();
+        endDate.add(Calendar.DAY_OF_MONTH, counts);
+        List<DayPowerGeneration> dayPowerGenerationList = new ArrayList<>();
+        for (; !currentDate.before(endDate); currentDate.add(Calendar.DATE, -1)) {
+            QueryWrapper<DayPowerGeneration> generationWrapper = new QueryWrapper<>();
+            generationWrapper.eq("gen_date", formatter.format(currentDate.getTime()));
+            generationWrapper.eq("prediction_data_source", "云端下发");
+            dayPowerGenerationList = dayPowerGenerationService.list(generationWrapper);
+            if (!dayPowerGenerationList.isEmpty()){
+                // 查出数据就退出当前循环
+                break;
+            }
+            else{
+                // 否则,日期往前推一天,再查
+            }
+        }
         // 按场时间分组
-       Map<String, List<ForecastPowerShortTermRegulation>> shortTermDataGroup = forecastPowerShortTermRegulationList.stream()
-                .collect(Collectors.groupingBy(
-                        s -> {
-                            Date localDateTime = s.getTime();
-                            return DateUtil.format(localDateTime, "yyyy-MM-dd");
-                        }
-        ));
-        System.out.println(shortTermDataGroup);
-
+        Map<String, List<DayPowerGeneration>> shortTermDataGroup = dayPowerGenerationList.stream().collect(Collectors.groupingBy(s->s.getTime()));
+        Map<String,List> forecastGeneratingMap = new HashMap<>();
+        // 图表x轴时间数据
+        List<String> xDataList = new ArrayList<>();
+        // 图表y轴发电量数据
+        List<BigDecimal> pDataList = new ArrayList<>();
 
-        return null;
+        // 统计每天里所有电站发电量总和
+        if (shortTermDataGroup!=null){
+            List<Map.Entry<String, List<DayPowerGeneration>>> sortedGrouped = new ArrayList<>(shortTermDataGroup.entrySet());
+            sortedGrouped.sort(Map.Entry.comparingByKey());
+            sortedGrouped.forEach(entry->{
+                List<DayPowerGeneration> dayPowerGenerations = entry.getValue();
+                BigDecimal sum = BigDecimal.ZERO;
+                for (DayPowerGeneration dayPowerGeneration:dayPowerGenerations){
+                    sum = sum.add(dayPowerGeneration.getForecastPowerGeneration());
+                }
+                // 封装每天发电总量
+                xDataList.add(entry.getKey().substring(5));
+                pDataList.add(sum);
+                forecastGeneratingMap.put("xData",xDataList);
+                forecastGeneratingMap.put("pData",pDataList);
+            });
+        }
+        return forecastGeneratingMap;
     }
 }

+ 8 - 0
cpp-ui/src/views/largeScreen/components/right-bottom.vue

@@ -88,7 +88,13 @@ export default {
       const _this = this
       let option = JSON.parse(JSON.stringify(forecast10LineOption))
       option.xAxis.data = xData
+      // x轴文字间隔
+      option.xAxis.axisLabel.interval= 0
+      // x轴文字倾斜
+      option.xAxis.axisLabel.rotate= '45'
       option.series[0].data = pData
+      // 柱状图宽度
+      option.series[0].barWidth= '40%'
       this.chart.setOption(option, true)
       window.addEventListener("resize", function () {
         _this.chart.resize();
@@ -99,6 +105,8 @@ export default {
       let option = JSON.parse(JSON.stringify(forecast10LineOption))
       option.xAxis.data = xData
       option.series[0].data = pData
+      // 柱状图宽度
+      option.series[0].barWidth= '40%'
       this.fullChart.setOption(option, true)
     }
   }

+ 7 - 67
cpp-ui/src/views/largeScreen/index.vue

@@ -557,6 +557,7 @@ export default {
     },
     async getBizData() {
       await this.$axios({url: '/largeScreenController/getBizData', method: 'get'}).then(response => {
+        this.mockData()
         // 顶部场站数据统计值
         let electricFieldDataTotalDto = response.data.electricFieldDataTotalDto
         this.envData.wsAvg = electricFieldDataTotalDto.wsAvg
@@ -572,6 +573,8 @@ export default {
           theoryPowerSum: productionDataTotalDto.theoryPowerSum,
         }
 
+        this.rightBottomParams = response.data.forecastGeneratingMap
+
         // this.digitalDisk[0].num = this.formatNumber(sumMap.realSum) + ''
         // this.digitalDisk[1].num = this.formatNumber(sumMap.ableSum) + ''
         // this.digitalDisk[2].num = this.formatNumber(sumMap.theorySum) + ''
@@ -586,7 +589,7 @@ export default {
           cdqList: curveMap.cdqList,
           dqList: curveMap.dqList
         }
-        this.mockData()
+
         // 限电信息
         let xdMap = response.data.xdMap
         this.totality.number = xdMap.zczs
@@ -604,72 +607,9 @@ export default {
     },
     mockData(){
       this.rightBottomParams ={
-        xData: [
-          "12-01",
-          "12-02",
-          "12-03",
-          "12-04",
-          "12-05",
-          "12-06",
-          "12-07",
-          "12-08",
-          "12-09",
-          "12-10",
-          "12-11",
-          "12-12",
-          "12-13",
-          "12-14",
-          "12-15",
-          "12-16",
-          "12-17",
-          "12-18",
-          "12-19",
-          "12-20",
-          "12-21",
-          "12-22",
-          "12-23",
-          "12-24",
-          "12-25",
-          "12-26",
-          "12-27",
-          "12-28",
-          "12-29",
-          "12-30",
-          "12-31"
-        ],
-        pData: [
-          90.69,
-          121.28,
-          100.1,
-          66.02,
-          151.14,
-          316.08,
-          113.21,
-          100.14,
-          192.39,
-          317.92,
-          275.32,
-          184.14,
-          326.11,
-          473.03,
-          487.25,
-          361.38,
-          465.54,
-          443.73,
-          516.83,
-          369.04,
-          272.89,
-          198.42,
-          596.15,
-          351.34,
-          406.07,
-          582.7,
-          490.01,
-          488.05,
-          370.14,
-          88.29,
-          178.89
-        ]}
+        xData: [],
+        pData: []
+      }
       this.rightTopParams = [
         {sort: 1, name: '新疆光伏电站', accuracy: '99.8%'},
         {sort: 2, name: '新疆光伏电站', accuracy: '97.8%'},