Bladeren bron

首页数据获取接口

xusl 6 maanden geleden
bovenliggende
commit
4b613ff09d

+ 75 - 69
cpp-admin/src/main/java/com/cpp/web/controller/largeScreen/LargeScreenController.java

@@ -4,8 +4,10 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.cpp.common.core.domain.R;
 import com.cpp.system.service.ISysConfigService;
 import com.cpp.web.domain.station.*;
+import com.cpp.web.domain.station.enums.ElectricFieldTypeEnum;
 import com.cpp.web.service.station.*;
 import com.cpp.web.utils.DateTimeUtil;
+import com.cpp.web.utils.LatestDataUtil;
 import lombok.RequiredArgsConstructor;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
@@ -42,33 +44,25 @@ public class LargeScreenController {
 
     @GetMapping("/getBizData")
     public R getBizData() {
-        Date dayStartTime = DateTimeUtil.getDayStartTime(System.currentTimeMillis());
-        Date dayEndTime = DateTimeUtil.getDayLastTime(System.currentTimeMillis());
-
-        Map bizDataMap = new HashMap();
+        // 获取所有场站
+        List<ElectricField> electricFieldList = electricFieldService.list();
         // 定义首页实际功率、可用、理论总和
         BigDecimal realSum = BigDecimal.ZERO;
         BigDecimal ableSum = BigDecimal.ZERO;
         BigDecimal theorySum = BigDecimal.ZERO;
         BigDecimal cdqSum = BigDecimal.ZERO;
         BigDecimal dqSum = BigDecimal.ZERO;
-        // 首页实际、可用、理论曲线图数组
-        List<Object> realList = new ArrayList<>();
-        List<Object> ableList = new ArrayList<>();
-        List<Object> theoryList = new ArrayList<>();
-        List<Object> cdqList = new ArrayList<>();
-        List<Object> dqList = new ArrayList<>();
+        BigDecimal fzdSum = BigDecimal.ZERO;
+        BigDecimal wsSum = BigDecimal.ZERO;
+        int fzdSumCount = 0;
+        int wsSumCount = 0;
         // 限电场站数定义
         int xdCount = 0;
-        // 查询实际功率、可用、理论
-        Date currentTime5 = DateTimeUtil.getMomentTimeFor5Minute(System.currentTimeMillis());
-        List<PowerStationStatusData> powerStationStatusDataList = powerStationStatusDataService.findByTimeBetween(dayStartTime,dayEndTime);
-        // 按场时间分组
-        Map<Long, List<PowerStationStatusData>> powerStationStatusDataGroup = powerStationStatusDataList.stream().collect(Collectors.groupingBy(s->s.getTime().getTime()));
-        // 统计当前时刻实际功率的总和
-        if (powerStationStatusDataGroup.get(currentTime5.getTime())!=null){
-            List<PowerStationStatusData> currentPowerStationDataList = powerStationStatusDataGroup.get(currentTime5.getTime());
-            for (PowerStationStatusData powerStationStatusData:currentPowerStationDataList){
+        // 获取每个场站的实时功率、可用、理论、超短期、短期
+        for (ElectricField electricField:electricFieldList){
+            // 实时功率、可用、理论、限电
+            PowerStationStatusData powerStationStatusData = LatestDataUtil.getData(electricField.getStationCode(), PowerStationStatusData.class);
+            if (powerStationStatusData!=null){
                 realSum = realSum.add(powerStationStatusData.getRealValue());
                 ableSum = ableSum.add(powerStationStatusData.getAbleValue());
                 theorySum = theorySum.add(powerStationStatusData.getTheoryValue());
@@ -76,9 +70,68 @@ public class LargeScreenController {
                     xdCount++;
                 }
             }
+            // 超短期
+            ForecastPowerUltraShortTermStation forecastPowerUltraShortTermStation = LatestDataUtil.getData(electricField.getStationCode(), ForecastPowerUltraShortTermStation.class);
+            if (forecastPowerUltraShortTermStation!=null){
+                cdqSum = cdqSum.add(forecastPowerUltraShortTermStation.getFpValue());
+            }
+            // 短期
+            ForecastPowerShortTermStation forecastPowerShortTermStation = LatestDataUtil.getData(electricField.getStationCode(), ForecastPowerShortTermStation.class);
+            if (forecastPowerShortTermStation!=null){
+                dqSum = dqSum.add(forecastPowerShortTermStation.getFpValue());
+            }
+            // 获取气象站或者测风塔
+            if (ElectricFieldTypeEnum.E1.name().equals(electricField.getElectricFieldTypeEnum())){
+                WeatherStationStatusData weatherStationStatusData = LatestDataUtil.getData(electricField.getStationCode(), WeatherStationStatusData.class);
+                if (weatherStationStatusData!=null){
+                    fzdSum = fzdSum.add(weatherStationStatusData.getGlobalR());
+                    fzdSumCount++;
+                }
+            }
+            else{
+                WindTowerStatusData windTowerStatusData = LatestDataUtil.getData(electricField.getStationCode(), WindTowerStatusData.class);
+                if (windTowerStatusData!=null){
+                    wsSum = wsSum.add(windTowerStatusData.getWsHubHeight());
+                    wsSumCount++;
+                }
+            }
         }
+        Map bizDataMap = new HashMap();
+        // 定义总和map
+        Map sumMap = new HashMap();
+        sumMap.put("realSum",realSum);
+        sumMap.put("ableSum",ableSum);
+        sumMap.put("theorySum",theorySum);
+        bizDataMap.put("sumMap",sumMap);
+        Map envDataMap = new HashMap();
+        BigDecimal wsAvg = BigDecimal.ZERO;
+        if (wsSum.compareTo(BigDecimal.ZERO)==1){
+            wsAvg = wsAvg.divide(new BigDecimal(wsSumCount),2, BigDecimal.ROUND_HALF_UP);
+        }
+        envDataMap.put("wsAvg",wsAvg);
+        BigDecimal fzdAvg = BigDecimal.ZERO;
+        if (fzdSum.compareTo(BigDecimal.ZERO)==1){
+            fzdAvg = fzdAvg.divide(new BigDecimal(fzdSumCount),2, BigDecimal.ROUND_HALF_UP);
+        }
+        envDataMap.put("fzdAvg",fzdAvg);
+        bizDataMap.put("envDataMap",envDataMap);
 
 
+        Date dayStartTime = DateTimeUtil.getDayStartTime(System.currentTimeMillis());
+        Date dayEndTime = DateTimeUtil.getDayLastTime(System.currentTimeMillis());
+        // 首页实际、可用、理论曲线图数组
+        List<Object> realList = new ArrayList<>();
+        List<Object> ableList = new ArrayList<>();
+        List<Object> theoryList = new ArrayList<>();
+        List<Object> cdqList = new ArrayList<>();
+        List<Object> dqList = new ArrayList<>();
+
+        // 查询实际功率、可用、理论
+        Date currentTime5 = DateTimeUtil.getMomentTimeFor5Minute(System.currentTimeMillis());
+        List<PowerStationStatusData> powerStationStatusDataList = powerStationStatusDataService.findByTimeBetween(dayStartTime,dayEndTime);
+        // 按场时间分组
+        Map<Long, List<PowerStationStatusData>> powerStationStatusDataGroup = powerStationStatusDataList.stream().collect(Collectors.groupingBy(s->s.getTime().getTime()));
+
         // 获取超短期
         String cdqHowLongAgo = configService.selectConfigByKey("cdqHowLongAgo");
         QueryWrapper cdqysWrapper = new QueryWrapper<>();
@@ -87,14 +140,6 @@ public class LargeScreenController {
         List<ForecastPowerUltraShortTermStation> forecastPowerUltraShortTermStationList = forecastPowerUltraShortTermStationService.list(cdqysWrapper);
         // 按场时间分组
         Map<Long, List<ForecastPowerUltraShortTermStation>> utraShortTermStationDataGroup = forecastPowerUltraShortTermStationList.stream().collect(Collectors.groupingBy(s->s.getTime().getTime()));
-        Date currentTime15 = DateTimeUtil.getMomentTimeFor15Minute(System.currentTimeMillis());
-        // 统计当前时刻超短期的总和
-        if (utraShortTermStationDataGroup.get(currentTime15.getTime())!=null){
-            List<ForecastPowerUltraShortTermStation> ultraShortTermDataList = utraShortTermStationDataGroup.get(currentTime15.getTime());
-            for (ForecastPowerUltraShortTermStation forecastPowerUltraShortTermStation:ultraShortTermDataList){
-                cdqSum = cdqSum.add(forecastPowerUltraShortTermStation.getFpValue());
-            }
-        }
 
         // 获取短期上报
         String dqHowLongAgo = configService.selectConfigByKey("dqHowLongAgo");
@@ -104,13 +149,6 @@ public class LargeScreenController {
         List<ForecastPowerShortTermRegulation> forecastPowerShortTermRegulationList = forecastPowerShortTermRegulationService.list(dqsbWrapper);
         // 按场时间分组
         Map<Long, List<ForecastPowerShortTermRegulation>> shortTermDataGroup = forecastPowerShortTermRegulationList.stream().collect(Collectors.groupingBy(s->s.getTime().getTime()));
-        // 统计当前时刻短期的总和
-        if (shortTermDataGroup.get(currentTime15.getTime())!=null){
-            List<ForecastPowerShortTermRegulation> shortTermDataList = shortTermDataGroup.get(currentTime15.getTime());
-            for (ForecastPowerShortTermRegulation forecastPowerShortTermRegulation:shortTermDataList){
-                dqSum = dqSum.add(forecastPowerShortTermRegulation.getFpValue());
-            }
-        }
 
         Long momentTime = 15 * 60 * 1000L;
         for (Long tempTime = dayStartTime.getTime(); tempTime <= dayEndTime.getTime(); tempTime = tempTime + momentTime) {
@@ -167,13 +205,6 @@ public class LargeScreenController {
                 dqList.add(null);
             }
         }
-
-
-        // 定义总和map
-        Map sumMap = new HashMap();
-        sumMap.put("realSum",realSum);
-        sumMap.put("ableSum",ableSum);
-        sumMap.put("theorySum",theorySum);
         // 定义曲线map
         Map curveMap = new HashMap();
         curveMap.put("realList",realList);
@@ -183,8 +214,8 @@ public class LargeScreenController {
         curveMap.put("cdqList",cdqList);
         sumMap.put("dqSum",dqSum);
         curveMap.put("dqList",dqList);
-        // 获取所有场站
-        List<ElectricField> electricFieldList = electricFieldService.list();
+        bizDataMap.put("curveMap",curveMap);
+
         // 定义限电图map
         Map xdMap = new HashMap();
         // 总场站数
@@ -204,34 +235,9 @@ public class LargeScreenController {
             totalCapacity = totalCapacity.add(electricField.getCapacity());
         }
         xdMap.put("totalCapacity",totalCapacity);
+        bizDataMap.put("xdMap",xdMap);
 
-        // 首页风速、辐照度平均值统计
-        Map envDataMap = new HashMap();
-        BigDecimal wsAvg = BigDecimal.ZERO;
-        // 获取当前时刻的所有风塔数据
-        List<WindTowerStatusData> windTowerStatusDataList = windTowerStatusDataService.findByBetweenTimeAndStationCode(currentTime5, currentTime5, null);
-        for (WindTowerStatusData windTowerStatusData:windTowerStatusDataList){
-            wsAvg = wsAvg.add(windTowerStatusData.getWsHubHeight());
-        }
-        if (wsAvg.compareTo(BigDecimal.ZERO)==1){
-            wsAvg = wsAvg.divide(new BigDecimal(windTowerStatusDataList.size()),2, BigDecimal.ROUND_HALF_UP);
-        }
-        envDataMap.put("wsAvg",wsAvg);
-        BigDecimal fzdAvg = BigDecimal.ZERO;
-        // 获取当前时刻的所有气象站数据
-        List<WeatherStationStatusData> weatherStationStatusDataList = weatherStationStatusDataService.findByBetweenTimeAndStationCode(currentTime5, currentTime5, null);
-        for (WeatherStationStatusData weatherStationStatusData:weatherStationStatusDataList){
-            fzdAvg = fzdAvg.add(weatherStationStatusData.getGlobalR());
-        }
-        if (fzdAvg.compareTo(BigDecimal.ZERO)==1){
-            fzdAvg = fzdAvg.divide(new BigDecimal(weatherStationStatusDataList.size()),2, BigDecimal.ROUND_HALF_UP);
-        }
-        envDataMap.put("fzdAvg",fzdAvg);
 
-        bizDataMap.put("sumMap",sumMap);
-        bizDataMap.put("curveMap",curveMap);
-        bizDataMap.put("xdMap",xdMap);
-        bizDataMap.put("envDataMap",envDataMap);
         return R.ok(bizDataMap);
     }
 }

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

@@ -217,10 +217,17 @@ public class DqRegulationController {
         tempShortRegulationQueryWrapper.eq("tk_date", DateTimeUtil.getDayStartTime(System.currentTimeMillis()));
         tempShortRegulationService.remove(tempShortRegulationQueryWrapper);
 
+        LoginUser loginUser = SecurityUtils.getLoginUser();
+        // 插入调控主表
+        TempShortRegulation tempShortRegulation = new TempShortRegulation();
+        tempShortRegulation.setStationCode(tempShortRegulationDto.getStationCode());
+        tempShortRegulation.setForecastDate(tempShortRegulationDto.getForecastDate());
+        tempShortRegulation.setTkDate(tempShortRegulationDto.getTkDate());
+        tempShortRegulation.setCreateBy(loginUser.getUsername());
+        tempShortRegulationService.save(tempShortRegulation);
 
         // 封装新的调控明细插入数据
         List<TempShortRegulationDetail> tempShortRegulationDetailList = new ArrayList<>();
-        LoginUser loginUser = SecurityUtils.getLoginUser();
         for (TempShortRegulationDto tempShortRegulationDto1 : tempShortRegulationDtoList) {
             TempShortRegulationDetail tempShortRegulationDetail = new TempShortRegulationDetail();
             tempShortRegulationDetail.setStationCode(tempShortRegulationDto1.getStationCode());
@@ -233,16 +240,11 @@ public class DqRegulationController {
             tempShortRegulationDetail.setTkValue(tempShortRegulationDto1.getTkValue());
             tempShortRegulationDetail.setYsValue(tempShortRegulationDto1.getYsValue());
             tempShortRegulationDetail.setCreateBy(loginUser.getUsername());
+            tempShortRegulationDetail.setRegulationId(tempShortRegulation.getId());
             tempShortRegulationDetailList.add(tempShortRegulationDetail);
         }
         tempShortRegulationDetailService.saveBatch(tempShortRegulationDetailList);
-        // 插入调控主表
-        TempShortRegulation tempShortRegulation = new TempShortRegulation();
-        tempShortRegulation.setStationCode(tempShortRegulationDto.getStationCode());
-        tempShortRegulation.setForecastDate(tempShortRegulationDto.getForecastDate());
-        tempShortRegulation.setTkDate(tempShortRegulationDto.getTkDate());
-        tempShortRegulation.setCreateBy(loginUser.getUsername());
-        tempShortRegulationService.save(tempShortRegulation);
+
 
         return R.ok();
     }

+ 1 - 1
cpp-ui/src/views/largeScreen/echarts-data.js

@@ -172,7 +172,7 @@ export let lineOption = {
   ],
   yAxis: [
     {
-      name: '万KW',
+      name: 'MW',
       type: 'value'
     }
   ],

+ 20 - 5
cpp-ui/src/views/largeScreen/index.vue

@@ -427,15 +427,30 @@ export default {
     clearInterval(this.sysBizDataTimer);
   },
   methods: {
+    formatNumber(num) {
+      // 转换为字符串以便处理
+      const numStr = num.toString();
+      let nums = numStr.split(".")
+      if (nums[0].length == 1 || nums[0].length == 2) {
+        return num.toFixed(2);
+      }
+      if (nums[0].length == 3) {
+
+        return parseFloat(num.toFixed(1));
+      }
+      else{
+        return nums[0];
+      }
+    },
     async getBizData() {
       await this.$axios({url: '/largeScreenController/getBizData', method: 'get'}).then(response => {
         // 顶部统计值
         let sumMap = response.data.sumMap
-        this.digitalDisk[0].num = sumMap.realSum + ''
-        this.digitalDisk[1].num = sumMap.theorySum + ''
-        this.digitalDisk[2].num = sumMap.ableSum + ''
-        this.digitalDisk[3].num = sumMap.cdqSum + ''
-        this.digitalDisk[4].num = sumMap.dqSum + ''
+        this.digitalDisk[0].num = this.formatNumber(sumMap.realSum) + ''
+        this.digitalDisk[1].num = this.formatNumber(sumMap.theorySum) + ''
+        this.digitalDisk[2].num = this.formatNumber(sumMap.ableSum) + ''
+        this.digitalDisk[3].num = this.formatNumber(sumMap.cdqSum) + ''
+        this.digitalDisk[4].num = this.formatNumber(sumMap.dqSum) + ''
         // 曲线图
         let curveMap = response.data.curveMap
         this.realList = curveMap.realList

+ 184 - 0
cpp-ui/src/views/regulation/dqRegulationRecord/index.vue

@@ -0,0 +1,184 @@
+<template>
+  <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-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="beforeQuery">查询
+          </el-button>
+        </el-form-item>
+      </el-form>
+    </div>
+    <div style="padding-top: 10px">
+      <vxe-table
+        ref="xTable"
+        align="center"
+        class="mytable-style"
+        auto-resize
+        border
+        resizable
+        export-config
+        highlight-current-row
+        show-overflow
+        :data="tableData"
+        :radio-config="{trigger: 'row'}">
+        <vxe-table-column field="tkDate" title="调控日期"></vxe-table-column>
+        <vxe-table-column field="stationCode" title="调控场站" :formatter="stationCodeFormat"></vxe-table-column>
+        <vxe-table-column field="time" title="上报预测日期"></vxe-table-column>
+
+        <vxe-table-column field="activePower" title="上报状态"></vxe-table-column>
+        <vxe-table-column field="reactivePower" title="调控人"></vxe-table-column>
+        <vxe-table-column field="voltage" title="电压(V)"></vxe-table-column>
+        <vxe-table-column field="electricalCurrent" title="电流(A)"></vxe-table-column>
+        <vxe-table-column field="dayElectricQuantity" title="当日发电量(kW·h)"></vxe-table-column>
+        <vxe-table-column field="cumulativeGeneratedEnergy" title="累积发电量(MW·h)"></vxe-table-column>
+        <vxe-table-column field="dayGridConnectedHours" title="当日并网小时数"></vxe-table-column>
+      </vxe-table>
+      <vxe-pager
+        background
+        :loading="loading"
+        :current-page.sync="currentPage"
+        :page-size.sync="pageSize"
+        :total="total"
+        @page-change="handlePageChange"
+        :layouts="['PrevJump', 'PrevPage', 'JumpNumber', 'NextPage', 'NextJump', 'Sizes', 'FullJump', 'Total']">
+      </vxe-pager>
+    </div>
+  </div>
+</template>
+
+<script>
+export default {
+  name: 'inverterinfo',
+  data() {
+    return {
+      expireDateOption: {
+        disabledDate(time) {
+          return time.getTime() > Date.now()
+        }
+      },
+      dateTime: [new Date(new Date().toLocaleDateString()).getTime(), new Date(new Date().toLocaleDateString()).getTime()],
+      total: 0,
+      sortOrder: 'asc',
+      pageSize: 10,
+      currentPage: 1,
+      stationList: [],
+      stationCode: [],
+      searchForm: {},
+      tableData: [],
+      nameList:[],
+      loading: false,
+      modId: '',//备用id
+    }
+  },
+  created(){
+    // 获取所有逆变器名称(列表转义应用)
+    this.$axios.get('/inverterinfo/findAll').then((res) => {
+      this.nameList = res.data
+    }).catch((error) => {
+      this.$message.error('获取逆变器转义名称出错' + error)
+    })
+    // 获取场站下拉列表
+    this.getStationCode()
+  },
+  mounted() {
+
+  },
+  computed: {},
+  methods: {
+    beforeQuery(){
+      this.currentPage = 1
+      this.pageSize = 10
+      // 判断日期间隔最多不能超出30天
+      let startTime = Math.round(this.dateTime[0])
+      let endTime = Math.round(this.dateTime[1])
+
+      if(endTime-startTime> 60 * 60 * 24 * 1000*29){
+        this.$message.error("最多只能查询30天的数据!")
+        return
+      }
+
+      // this.dataQuery()
+    },
+    nameFormat({cellValue, row, column}) {
+      const item = this.nameList.find(item => item.value === cellValue)
+      return item ? item.label : ''
+    },
+    stationCodeFormat({cellValue, row, column}) {
+      const item = this.stationList.find(item => item.value === cellValue)
+      return item ? item.label : ''
+    },
+    statusFormat({cellValue, row, column}) {
+      if (cellValue == 1) {
+        return '运行'
+      } else if (cellValue == 2) {
+        return '待机'
+      } else if (cellValue == 3) {
+        return '停用'
+      } else if (cellValue == 4) {
+        return '故障'
+      }
+    },
+    handlePageChange({currentPage, pageSize}) {
+      this.currentPage = currentPage
+      this.pageSize = pageSize
+      this.dataQuery();
+    },
+    dataQuery() {
+      let startTime = Math.round(this.dateTime[0])
+      let endTime = Math.round(this.dateTime[1])
+      if (endTime <= startTime) {
+        this.$message.error("开始时间不能大于结束时间")
+        return
+      }
+
+      this.loading = true
+      let queryParams = {
+        "currentPage": this.currentPage,
+        "pageSize": this.pageSize,
+        "stationCode": this.stationCode,
+        "startTime": startTime,
+        "endTime": endTime,
+      }
+
+      this.$axios.get('/inverterstatusdata/getByStationCodeAndEquipmentIdAndTimeBetween', {params: queryParams}).then(response => {
+        this.tableData = response.data.records
+        this.total = response.data.total
+        this.loading = false
+      }).catch(() => {
+        this.loading = false
+      })
+    },
+    async getStationCode() {
+      await 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>