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

短期调控保存调控值

xusl пре 6 месеци
родитељ
комит
fc46e305f5

+ 59 - 10
cpp-admin/src/main/java/com/cpp/web/controller/regulation/DqRegulationController.java

@@ -3,6 +3,7 @@ package com.cpp.web.controller.regulation;
 import cn.hutool.core.date.DatePattern;
 import cn.hutool.core.date.DateTime;
 import cn.hutool.core.date.DateUtil;
+import cn.hutool.core.util.StrUtil;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.cpp.common.core.domain.R;
 import com.cpp.common.utils.DateUtils;
@@ -13,6 +14,7 @@ import com.cpp.web.domain.regulation.TempShortRegulation;
 import com.cpp.web.domain.station.ElectricField;
 import com.cpp.web.domain.station.ForecastPowerShortTermStation;
 import com.cpp.web.domain.station.WeatherStationStatusData;
+import com.cpp.web.domain.station.WindTurbineInfo;
 import com.cpp.web.dto.TempShortRegulationDto;
 import com.cpp.web.service.accuracy.AccuracyPassRateService;
 import com.cpp.web.service.regulation.TempShortRegulationService;
@@ -22,9 +24,7 @@ import com.cpp.web.utils.DateTimeUtil;
 import lombok.RequiredArgsConstructor;
 import org.checkerframework.checker.units.qual.A;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 
 import java.math.BigDecimal;
 import java.util.*;
@@ -50,6 +50,7 @@ public class DqRegulationController {
     ElectricFieldService electricFieldService;
 
 
+
     @GetMapping("/queryData")
     public R queryData(String stationCode, Long time) {
         int howLongAgo = DateTimeUtil.getDaysBetweenTwoDate(System.currentTimeMillis(),time);
@@ -80,7 +81,8 @@ public class DqRegulationController {
             // 获取调控数据
             QueryWrapper<TempShortRegulation> tempShortRegulationQueryWrapper = new QueryWrapper<>();
             tempShortRegulationQueryWrapper.eq("station_code", stationCode);
-            tempShortRegulationQueryWrapper.eq("tk_date", new Date(time));
+            tempShortRegulationQueryWrapper.eq("tk_date", DateTimeUtil.getDayStartTime(System.currentTimeMillis()));
+            tempShortRegulationQueryWrapper.eq("forecast_date", new Date(time));
             tempShortRegulationQueryWrapper.between("time", new Date(time), new Date(endTime));
             List<TempShortRegulation> tempShortRegulationList = tempShortRegulationService.list(tempShortRegulationQueryWrapper);
             List<TempShortRegulationDto> tempList = new ArrayList<>();
@@ -88,14 +90,20 @@ public class DqRegulationController {
                 for (TempShortRegulation tempShortRegulation:tempShortRegulationList){
                     TempShortRegulationDto tempShortRegulationDto = new TempShortRegulationDto();
                     tempShortRegulationDto.setTime(DateUtils.parseDateToStr("HH:mm",tempShortRegulation.getTime()));
+                    tempShortRegulationDto.setForecastDate(tempShortRegulation.getForecastDate());
                     tempShortRegulationDto.setTkDate(tempShortRegulation.getTkDate());
                     tempShortRegulationDto.setYsValue(tempShortRegulation.getYsValue());
                     tempShortRegulationDto.setTkValue(tempShortRegulation.getTkValue());
                     tempShortRegulationDto.setSz(tempShortRegulation.getSz());
                     tempShortRegulationDto.setXs(tempShortRegulation.getXs());
+                    tempShortRegulationDto.setStationCode(stationCode);
                     tempList.add(tempShortRegulationDto);
                 }
             }
+            Map<Long, BigDecimal> tkShortMap = new HashMap<>();
+            for (TempShortRegulation tempShortRegulation:tempShortRegulationList) {
+                tkShortMap.putIfAbsent(tempShortRegulation.getTime().getTime(), tempShortRegulation.getTkValue());
+            }
             // 调控数据
             List<List<Object>> tkDataList = new ArrayList<>();
             // 原始短期数据
@@ -109,9 +117,6 @@ public class DqRegulationController {
             for (Long tempTime = time; tempTime <= endTime; tempTime = tempTime + momentTime) {
                 List<Object> listAfter = new ArrayList<>();
                 listAfter.add(DateUtils.parseDateToStr("HH:mm",new Date(tempTime)));
-                listAfter.add(ysShortMap.get(tempTime));
-                tkDataList.add(listAfter);
-
                 if (ysShortMap.get(tempTime)!=null){
                     ysList.add(ysShortMap.get(tempTime));
                     if (accuracySum>0){
@@ -134,12 +139,20 @@ public class DqRegulationController {
                         // 使用原始值
                         TempShortRegulationDto tempShortRegulationDto = new TempShortRegulationDto();
                         tempShortRegulationDto.setTime(DateUtils.parseDateToStr("HH:mm",new Date(tempTime)));
-                        tempShortRegulationDto.setTkDate(new Date(time));
+                        tempShortRegulationDto.setForecastDate(new Date(time));
+                        tempShortRegulationDto.setTkDate(new Date());
                         tempShortRegulationDto.setYsValue(ysShortMap.get(tempTime));
                         tempShortRegulationDto.setTkValue(ysShortMap.get(tempTime));
                         tempShortRegulationDto.setSz(new BigDecimal("0"));
                         tempShortRegulationDto.setXs(new BigDecimal("1"));
+                        tempShortRegulationDto.setStationCode(stationCode);
                         tempList.add(tempShortRegulationDto);
+                        // 调控曲线使用原始值
+                        listAfter.add(ysShortMap.get(tempTime));
+                    }
+                    else{
+                        // 封装调控值
+                        listAfter.add(tkShortMap.get(tempTime));
                     }
                 }
                 else{
@@ -148,12 +161,17 @@ public class DqRegulationController {
                     refDownList.add(null);
                     listAfter.add(null);
                 }
+                tkDataList.add(listAfter);
             }
-
+            // 原始值
             map.put("ysData",ysList);
+            // 参考上限
             map.put("refUpData",refUpList);
+            // 参考下限
             map.put("refDownData",refDownList);
+            // 页面列表
             map.put("tempShortRegulationList",tempList);
+            // 页面调控曲线数值
             map.put("tkDataList",tkDataList);
 
 
@@ -166,5 +184,36 @@ public class DqRegulationController {
             return R.fail("调控日期:"+timeStr+",今日无上报数据!");
         }
     }
-
+    @PostMapping("/updateDqRegulation")
+    public R updateDqRegulation(@RequestBody List<TempShortRegulationDto> tempShortRegulationDtoList) {
+        // 先删除调控表中已有的数据
+        TempShortRegulationDto tempShortRegulationDto = tempShortRegulationDtoList.get(0);
+        // 调控的预测日期
+        Date forecastDate = tempShortRegulationDto.getForecastDate();
+        Date startTime = DateTimeUtil.getDayStartTime(forecastDate.getTime());
+        Date endTime = DateTimeUtil.getDayLastTime(forecastDate.getTime());
+        QueryWrapper<TempShortRegulation> tempShortRegulationQueryWrapper = new QueryWrapper<>();
+        tempShortRegulationQueryWrapper.eq("station_code", tempShortRegulationDto.getStationCode());
+        tempShortRegulationQueryWrapper.eq("forecast_date", tempShortRegulationDto.getForecastDate());
+        tempShortRegulationQueryWrapper.eq("tk_date", DateTimeUtil.getDayStartTime(System.currentTimeMillis()));
+        tempShortRegulationQueryWrapper.between("time", startTime, endTime);
+        tempShortRegulationService.remove(tempShortRegulationQueryWrapper);
+        // 封装新的调控插入数据
+        List<TempShortRegulation> tempShortRegulationList = new ArrayList<>();
+        for (TempShortRegulationDto tempShortRegulationDto1 : tempShortRegulationDtoList) {
+            TempShortRegulation tempShortRegulation = new TempShortRegulation();
+            tempShortRegulation.setStationCode(tempShortRegulationDto1.getStationCode());
+            tempShortRegulation.setForecastDate(tempShortRegulationDto1.getForecastDate());
+            tempShortRegulation.setTkDate(tempShortRegulationDto1.getTkDate());
+            Date time = DateUtil.parse(DateUtil.format(tempShortRegulationDto1.getForecastDate(),"yyyy-MM-dd")+" "+tempShortRegulationDto1.getTime(), "yyyy-MM-dd HH:mm");
+            tempShortRegulation.setTime(time);
+            tempShortRegulation.setSz(tempShortRegulationDto1.getSz());
+            tempShortRegulation.setXs(tempShortRegulationDto1.getXs());
+            tempShortRegulation.setTkValue(tempShortRegulationDto1.getTkValue());
+            tempShortRegulation.setYsValue(tempShortRegulationDto1.getYsValue());
+            tempShortRegulationList.add(tempShortRegulation);
+        }
+        tempShortRegulationService.saveBatch(tempShortRegulationList);
+        return R.ok();
+    }
 }

+ 6 - 2
cpp-admin/src/main/java/com/cpp/web/domain/regulation/TempShortRegulation.java

@@ -45,10 +45,14 @@ public class TempShortRegulation extends BaseCppEntity {
     @ApiModelProperty(value = "调控值")
     @Digits(integer = 10, fraction = 2)
     private BigDecimal tkValue = new BigDecimal(-99);
-
+    /**
+     * 调控的预测日期
+     */
+    @ApiModelProperty(value = "调控日期")
+    private Date forecastDate;
 
     /**
-     * 调控日期
+     * 调控日
      */
     @ApiModelProperty(value = "调控日期")
     private Date tkDate;

+ 7 - 2
cpp-admin/src/main/java/com/cpp/web/dto/TempShortRegulationDto.java

@@ -34,9 +34,12 @@ public class TempShortRegulationDto{
     @Digits(integer = 10, fraction = 2)
     private BigDecimal tkValue = new BigDecimal(-99);
 
-
     /**
-     * 调控日期
+     * 调控预测日期
+     */
+    private Date forecastDate;
+    /**
+     * 调控日
      */
     private Date tkDate;
 
@@ -51,4 +54,6 @@ public class TempShortRegulationDto{
      */
     @Digits(integer = 10, fraction = 2)
     private BigDecimal xs = new BigDecimal(-99);
+
+    private String stationCode;
 }

+ 32 - 10
cpp-ui/src/views/regulation/dqRegulation/index.vue

@@ -2,11 +2,12 @@
   <div class="app-container">
     <div class="dark-el-input dark-el-button">
       <el-form ref="queryForm" size="small" :inline="true" popper-class="cpp-popper">
-        <el-form-item label="日期">
+        <el-form-item label="预测日期">
           <el-date-picker
             :clearable="false"
             v-model="dateTime"
             type="date"
+            :picker-options="expireDateOption"
             placeholder="选择生成日期">
           </el-date-picker>
         </el-form-item>
@@ -44,7 +45,7 @@
           <el-table
             :data="tableData"
             height="550px"
-
+            :loading="loading"
             size="mini"
             style="width: 100%">
             <el-table-column
@@ -115,6 +116,12 @@ export default {
   name: 'inverterinfo',
   data() {
     return {
+      expireDateOption:{
+        disabledDate(time){
+          return time.getTime()<Date.now()
+        }
+      },
+      loading: false,
       symbolSize: 8,
       capacity: '',
       tkData: [],
@@ -307,6 +314,13 @@ export default {
   mounted() {
     this.initChart()
   },
+  beforeDestroy() {
+    if (!this.chart) {
+      return
+    }
+    this.chart.dispose()
+    this.chart = null
+  },
   computed: {},
   methods: {
     // 调控列表提交
@@ -317,14 +331,21 @@ export default {
       }
       // 判断系数和数值2个字段是否有为空
       for (let i = 0; i < this.tableData.length; i++) {
-        console.log(this.tableData[i].xs == '')
-        console.log(this.tableData[i].sz == '')
-        if (this.tableData[i].xs == '' || this.tableData[i].sz == '') {
+        if (isNaN(this.tableData[i].tkValue)) {
           this.$message.warning(this.tableData[i].time + "存在空值,不能进行提交!")
           return
         }
       }
 
+      // 保存调控值列表
+      this.$axios.post('/dqRegulationController/updateDqRegulation', this.tableData).then((res) => {
+        this.$message.success('调控功率保存成功!')
+        // this.dataQuery()
+      }).catch((error) => {
+      })
+
+
+
     },
 
     //通过表格内系数或固定值修改  生成曲线以及最终预测结果
@@ -340,8 +361,6 @@ export default {
         }
         // 赋值给表格
         this.tableData[index] = row
-
-
         // 遍历tableData封装调控曲线数组
         let tkArray = new Array()
         for (var i = 0; i < this.tableData.length; i++) {
@@ -358,31 +377,34 @@ export default {
       }
     },
     dataQuery() {
+      this.loading = true
       let queryParams = {
         "stationCode": this.stationCode,
         "time": Math.round(this.dateTime),
       }
       this.$axios.get('/dqRegulationController/queryData', {params: queryParams}).then(response => {
+        this.chart.clear()
         this.capacity = response.data.electricField.capacity
         this.tableData = response.data.tempShortRegulationList
         this.ysData = response.data.ysData
         this.refUpData = response.data.refUpData
         this.refDownData = response.data.refDownData
         this.tkData = response.data.tkDataList
-        this.chart.clear()
-        // this.option.yAxis[0].max = this.capacity
         this.draData()
+        this.loading = false
       }).catch(() => {
         this.tableData = []
         this.ysData = []
         this.refUpData = []
         this.refDownData = []
         this.tkData = []
+        this.chart.clear()
         this.chartOption.series[0].data = this.ysData
         this.chartOption.series[1].data = this.tkData
         this.chartOption.series[2].data = this.refUpData
         this.chartOption.series[3].data = this.refDownData
         this.chart.setOption(this.chartOption)
+        this.loading = false
       });
     },
     draData() {
@@ -421,7 +443,7 @@ export default {
           })
         });
       }, 0);
-      window.addEventListener('resize', this1.updatePosition);
+      // window.addEventListener('resize', this1.updatePosition);
       myChart.on('dataZoom', this1.updatePosition);