Преглед на файлове

增加短期历史对比列表查询

xusl преди 6 месеца
родител
ревизия
bd6552fa09

+ 112 - 0
cpp-admin/src/main/java/com/cpp/web/controller/regulation/DqHistoryContrastController.java

@@ -0,0 +1,112 @@
+package com.cpp.web.controller.regulation;
+
+import cn.hutool.core.util.StrUtil;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.OrderItem;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.cpp.common.core.domain.R;
+import com.cpp.common.utils.DateUtils;
+import com.cpp.web.domain.station.ElectricField;
+import com.cpp.web.domain.station.ForecastPowerShortTermRegulation;
+import com.cpp.web.domain.station.PowerStationStatusData;
+import com.cpp.web.domain.station.WeatherStationStatusData;
+import com.cpp.web.dto.DqHistoryContrastDto;
+import com.cpp.web.service.station.ElectricFieldService;
+import com.cpp.web.service.station.ForecastPowerShortTermRegulationService;
+import com.cpp.web.service.station.PowerStationStatusDataService;
+import com.cpp.web.service.station.WeatherStationStatusDataService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.RequiredArgsConstructor;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.math.BigDecimal;
+import java.text.SimpleDateFormat;
+import java.util.*;
+
+
+/**
+ * 短期历史对比
+ *
+ * @author whc
+ * @date 2022-03-18 15:49:50
+ */
+@RestController
+@RequiredArgsConstructor
+@RequestMapping("/dqHistoryContrastController")
+public class DqHistoryContrastController {
+    @Autowired
+    ElectricFieldService electricFieldService;
+    @Autowired
+    PowerStationStatusDataService powerStationStatusDataService;
+    @Autowired
+    ForecastPowerShortTermRegulationService forecastPowerShortTermRegulationService;
+
+    @ApiOperation(value = "根据条件查询", notes = "分页查询")
+    @GetMapping("/queryTableData")
+    public R queryTableData(String stationCode, Long startTime, Long endTime) {
+        Map map = new HashMap();
+        ElectricField electricField = electricFieldService.findByStationCode(stationCode);
+        String stationName = electricField.getName();
+        // 查询实际功率
+        QueryWrapper<PowerStationStatusData> powerStationStatusDataWrapper = new QueryWrapper<>();
+        powerStationStatusDataWrapper.between("time", new Date(startTime), new Date(endTime));
+        powerStationStatusDataWrapper.eq("station_code", stationCode);
+        List<PowerStationStatusData> powerStationStatusDataList = powerStationStatusDataService.list(powerStationStatusDataWrapper);
+        Map<Long, PowerStationStatusData> sjMap = new HashMap<>();
+        for (PowerStationStatusData powerStationStatusData : powerStationStatusDataList) {
+            sjMap.put(powerStationStatusData.getTime().getTime(), powerStationStatusData);
+        }
+        // 查询上报短期
+        List<ForecastPowerShortTermRegulation> forecastPowerShortTermRegulationList = forecastPowerShortTermRegulationService.findByForecastTimeBetweenAndForecastHowLongAgoAndStationCode(startTime, endTime, 1, stationCode);
+        Map<Long, ForecastPowerShortTermRegulation> dqsbMap = new HashMap<>();
+        for (ForecastPowerShortTermRegulation forecastPowerShortTermRegulation : forecastPowerShortTermRegulationList) {
+            dqsbMap.put(forecastPowerShortTermRegulation.getTime().getTime(), forecastPowerShortTermRegulation);
+        }
+        // 整合页面列表字段
+        Long momentTime = 15 * 60 * 1000L;
+        List<DqHistoryContrastDto> tableList = new ArrayList();
+        for (Long tempTime = startTime; tempTime <= endTime; tempTime = tempTime + momentTime) {
+            DqHistoryContrastDto dqHistoryContrastDto = new DqHistoryContrastDto();
+            dqHistoryContrastDto.setStationName(stationName);
+            // 设置时间
+            String time = DateUtils.parseDateToStr("yyyy-MM-dd HH:mm",new Date(tempTime));
+            dqHistoryContrastDto.setTime(time);
+            if (sjMap.get(tempTime)!=null){
+                PowerStationStatusData powerStationStatusData = sjMap.get(tempTime);
+                dqHistoryContrastDto.setOpenCapacity(powerStationStatusData.getOpenCapacity().toString());
+                dqHistoryContrastDto.setRealValue(powerStationStatusData.getRealValue().toString());
+            }
+            if (dqsbMap.get(tempTime)!=null){
+                ForecastPowerShortTermRegulation forecastPowerShortTermRegulation = dqsbMap.get(tempTime);
+                dqHistoryContrastDto.setDqValue(forecastPowerShortTermRegulation.getFpValue().toString());
+            }
+            // 计算短期与实际功率偏差及偏差比
+            if (StrUtil.isNotBlank(dqHistoryContrastDto.getDqValue()) && StrUtil.isNotBlank(dqHistoryContrastDto.getRealValue())){
+                // 偏差(短期-实际功率)
+                BigDecimal dqValue = new BigDecimal(dqHistoryContrastDto.getDqValue());
+                BigDecimal realValue = new BigDecimal(dqHistoryContrastDto.getRealValue());
+                dqHistoryContrastDto.setDqDeviation(dqValue.subtract(realValue).toString());
+                BigDecimal ratio = dqValue.subtract(realValue).divide(realValue,3,BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100")).stripTrailingZeros();
+                String ratioStr = "";
+                if (ratio.compareTo(new BigDecimal("0"))>=0){
+                    ratioStr = "+" + ratio.toPlainString() + "%";
+                }
+                else{
+                    ratioStr = ratio.toPlainString() + "%";
+                }
+                dqHistoryContrastDto.setDqDeviationRatio(ratioStr);
+            }
+            tableList.add(dqHistoryContrastDto);
+        }
+        map.put("tableList",tableList);
+
+        return R.ok(map);
+
+    }
+}

+ 27 - 0
cpp-admin/src/main/java/com/cpp/web/dto/DqHistoryContrastDto.java

@@ -0,0 +1,27 @@
+package com.cpp.web.dto;
+
+import lombok.Data;
+
+
+/**
+ * 短期历史对比
+ *
+ * @author jy
+ * @since 2024/10/25
+ */
+@Data
+public class DqHistoryContrastDto {
+    private String stationName;
+    private String time;
+    // 开机容量
+    private String openCapacity;
+    // 实际功率
+    private String realValue;
+    // 短期
+    private String dqValue;
+    // 短期偏差
+    private String dqDeviation;
+    // 短期偏差比
+    private String dqDeviationRatio;
+
+}

+ 164 - 0
cpp-ui/src/views/regulation/dqHistoryContrast/index.vue

@@ -0,0 +1,164 @@
+<template>
+  <div class="app-container">
+    <div class="dark-el-input dark-el-button">
+      <el-form ref="queryForm" size="small" :inline="true">
+        <el-form-item label="时间">
+          <el-date-picker
+              :picker-options="expireDateOption"
+              :clearable="false"
+              v-model="dateTime"
+              type="daterange"
+              range-separator="至"
+              start-placeholder="开始日期"
+              end-placeholder="结束日期"
+              popper-class="cpp-popper"
+          />
+        </el-form-item>
+        <el-form-item label="场站名称">
+          <el-select v-model="stationCode" placeholder="请选择" popper-class="cpp-popper">
+            <el-option
+                v-for="item in stationList"
+                :key="item.value"
+                :label="item.label"
+                :value="item.value">
+            </el-option>
+          </el-select>
+        </el-form-item>
+        <el-form-item>
+          <el-button type="primary" style="margin-left: 5px" icon="el-icon-search" @click="dataQuery">查询
+          </el-button>
+        </el-form-item>
+      </el-form>
+    </div>
+    <div style="padding-top: 10px">
+      <div style="width: 95%;height: 350px" id="fscharts"></div>
+    </div>
+    <div style="padding-top: 50px">
+      <vxe-table
+          highlight-hover-row
+          :keep-source="true"
+          align="center"
+          :loading="loading"
+          ref="xTable"
+          auto-resize
+          highlight-current-row
+          border
+          resizable
+          show-overflow
+          :data="tableData.slice((currentPage-1) * pageSize,currentPage * pageSize)">
+        <vxe-table-column field="time" title="时间" width="180px" fixed="left"></vxe-table-column>
+        <vxe-table-column field="stationName" title="场站名称"></vxe-table-column>
+        <vxe-table-column field="openCapacity" title="开机容量(MW)"></vxe-table-column>
+        <vxe-table-column field="realValue" title="实际功率(MW)"></vxe-table-column>
+        <vxe-table-column field="dqValue" title="短期预测功率(MW)"></vxe-table-column>
+        <vxe-table-column field="dqDeviation" title="短期预测偏差(MW)"></vxe-table-column>
+        <vxe-table-column field="dqDeviationRatio" title="短期预测偏差比(%)"></vxe-table-column>
+      </vxe-table>
+      <vxe-pager
+          perfect
+          :current-page.sync="currentPage"
+          :page-size.sync="pageSize"
+          :total="total"
+          :page-sizes=[10,50,100]
+          :layouts="['PrevJump', 'PrevPage','JumpNumber', 'NextPage', 'NextJump', 'Sizes', 'FullJump', 'Total']"
+          @page-change="handlePageChange"
+      >
+      </vxe-pager>
+    </div>
+  </div>
+</template>
+
+<script>
+import * as echarts from "echarts";
+
+export default {
+  name: 'inverterinfo',
+  data() {
+    return {
+      expireDateOption: {
+        disabledDate(time) {
+          return time.getTime() >= new Date(new Date().toLocaleDateString()).getTime()
+        }
+      },
+      fsChart: null,
+      sdChart: null,
+      activeName: 'first',
+      dateTime: [new Date(new Date().toLocaleDateString()).getTime() - 1000 * 60 * 60 * 24, new Date(new Date().toLocaleDateString()).getTime() - 1000 * 60 * 60 * 24],
+      total: 0,
+      sortOrder: 'asc',
+      pageSize: 10,
+      currentPage: 1,
+      stationList: [],
+      stationCode: [],
+      searchForm: {},
+      tableData: [],
+      nameList: [],
+      loading: false,
+      modId: '',//备用id
+      lineColor: '#3b3b3b',
+    }
+  },
+  created() {
+    this.getStationCode()
+  },
+  mounted() {
+
+  },
+  beforeDestroy() {
+    if (!this.sdChart) {
+      return
+    }
+    this.sdChart.dispose()
+    this.sdChart = null
+    if (!this.fsChart) {
+      return
+    }
+    this.fsChart.dispose()
+    this.fsChart = null
+  },
+  computed: {},
+  methods: {
+
+    nameFormat({cellValue, row, column}) {
+      const item = this.nameList.find(item => item.value === cellValue)
+      return item ? item.label : ''
+    },
+    handlePageChange({currentPage, pageSize}) {
+      this.currentPage = currentPage
+      this.pageSize = pageSize
+    },
+    async dataQuery() {
+      let startTime = Math.round(this.dateTime[0])
+      let endTime = Math.round(this.dateTime[1]) + 1000 * 60 * 60 * 24-1
+
+      if (endTime - startTime > 60 * 60 * 24 * 1000 * 29) {
+        this.$message.warning("最多只能查询30天的数据!")
+        return
+      }
+
+      this.loading = true
+      let queryParams = {
+        "stationCode": this.stationCode,
+        "startTime": startTime,
+        "endTime": endTime,
+      }
+      this.$axios.get('/dqHistoryContrastController/queryTableData', {params: queryParams}).then(response => {
+        this.tableData = response.data.tableList
+        this.total = response.data.tableList.length
+        this.loading = false
+      }).catch(() => {
+        this.loading = false
+      })
+    },
+    getStationCode() {
+      this.$axios({url: '/electricfield/all', method: 'get'}).then(response => {
+        this.stationList = response.data
+        if (this.stationList.length > 0) {
+          this.stationCode = this.stationList[0].value
+          // this.dataQuery()
+        }
+      })
+    },
+  },
+}
+</script>