Browse Source

增加实际功率

xusl 3 years ago
parent
commit
15711396a4

+ 7 - 0
ipfcst-console/src/main/frontend/router/modules/dataquery.js

@@ -13,6 +13,13 @@ const dataqueryRouter = {
   },
   children: [
     {
+      path: 'realPowerQuery',
+      component: () => import('@/views/dataquery/realPowerQuery'),
+      name: 'inverterStatusData',
+      meta: { title: '实际功率', noCache: true },
+      sign: 'currency'
+    },
+    {
       path: 'inverterStatusData',
       component: () => import('@/views/dataquery/inverterStatusData'),
       name: 'inverterStatusData',

+ 384 - 0
ipfcst-console/src/main/frontend/views/dataquery/realPowerQuery/charts/index.vue

@@ -0,0 +1,384 @@
+<template>
+  <div style="width: 100%;height: 100%">
+    <div id="rpcharts"></div>
+  </div>
+</template>
+
+<script>
+  import resize from '../../../../components/Charts/mixins/resize'
+  import echarts from 'echarts'
+  import cc from '../../../../components/curvecolors'
+
+  export default {
+    mixins: [resize],
+    watch: {
+      drawData: {
+        handler(newValue, oldValue) {
+          console.log(newValue)
+          this.draw(newValue.times, newValue.realValueDatas,newValue.ableValueDatas,newValue.theoryValueDatas,newValue.referencePowerByMeasuringDatas,newValue.referencePowerBySampleDatas,newValue.ablePowerByMeasuringDatas,newValue.ablePowerBySampleDatas,newValue.displayKyLl,newValue.cap)
+        },
+        deep: true
+      },
+      resizeKey: function (newQuestion, oldQuestion) {
+        if (this.chart != null) {
+          this.chart.resize();
+        }
+      }
+    },
+    props: {
+      drawData: {
+        type: Object,
+      },
+      resizeKey: {
+        type: Number
+      }
+    },
+    data() {
+      return {
+        chart: null,
+      }
+    },
+    mounted() {
+    },
+    beforeDestroy() {
+      if (!this.chart) {
+        return
+      }
+      this.chart.dispose()
+      this.chart = null
+    },
+    methods: {
+      draw(timeaxis, realpower,ablepower,theorypower,referencePowerByMeasuringpower,referencePowerBySamplepower,ablePowerByMeasuringe,ablePowerBySample,displayKyLl,cap) {
+        console.log(referencePowerByMeasuringpower)
+        console.log(ablePowerByMeasuringe)
+
+        this.chart = echarts.init(document.getElementById('rpcharts'))
+          var option = {
+          backgroundColor: 'transparent',
+          title: {
+            top: 20,
+            text: '实际功率实时查询',
+            textStyle: {
+              fontWeight: 'normal',
+              fontSize: 16,
+              color: '#F1F1F3'
+            },
+            left: '1%'
+          },
+          tooltip: {
+            trigger: 'axis',
+            axisPointer: {
+              lineStyle: {
+                color: '#57617B'
+              }
+            }
+          },
+          legend: {
+            top: 20,
+            icon: 'rect',
+            itemWidth: 14,
+            itemHeight: 5,
+            itemGap: 13,
+            data: ['实际功率'],
+            right: '4%',
+            textStyle: {
+              fontSize: 12,
+              color: '#F1F1F3'
+            }
+          },
+          dataZoom: [{
+            show: true,
+            realtime: true,
+            start: 0,
+            end: 100,
+            left: "15%",
+            right: "15%",
+            textStyle: {
+              color: "#ffffff"
+            }
+          }, {
+            type: 'inside'
+          }],
+          grid: {
+            top: 100,
+            left: '2%',
+            right: '2%',
+            bottom: '10%',
+            containLabel: true
+          },
+          xAxis: [{
+            type: 'category',
+            boundaryGap: false,
+            axisLine: {
+              lineStyle: {
+                color: '#ffffff'
+              }
+            },
+            data: timeaxis
+          }],
+          yAxis: [{
+            type: 'value',
+            name: '(MW)',
+            axisTick: {
+              show: false
+            },
+            axisLine: {
+              lineStyle: {
+                color: '#ffffff'
+              }
+            },
+            axisLabel: {
+              margin: 10,
+              textStyle: {
+                fontSize: 14
+              }
+            },
+            splitLine: {
+              lineStyle: {
+                color: '#57617B'
+              }
+            }
+          }],
+          series: [{
+            name: '实际功率',
+            type: 'line',
+            smooth: false,
+            symbol: 'circle',
+            symbolSize: 5,
+            showSymbol: false,
+            lineStyle: {
+              normal: {
+                width: 2
+              }
+            },
+            itemStyle: {
+              normal: {
+
+                color: cc.sj,
+                borderColor: 'rgba(219,50,51,0.2)',
+                borderWidth: 12
+              }
+            },
+            data: realpower
+          }]
+        }
+
+        option.yAxis[0].max = cap
+
+        if(displayKyLl == 1){
+          option.legend.data = ['实际功率','可用功率','理论功率','参照理论功率(测风、测光法)','参照理论功率(样板机法)','参照可用功率(测风、测光法)','参照可用功率(样板机法)']
+          option.series.push({
+            name: '可用功率',
+            type: 'line',
+            smooth: true,
+            symbol: 'circle',
+            symbolSize: 5,
+            showSymbol: false,
+            lineStyle: {
+              normal: {
+                width: 2
+              }
+            },
+            areaStyle: {
+              normal: {
+                color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
+                  offset: 0,
+                  color: 'rgba(219, 50, 51, 0.3)'
+                }, {
+                  offset: 0.8,
+                  color: 'rgba(219, 50, 51, 0)'
+                }], false),
+                shadowColor: 'rgba(0, 0, 0, 0.1)',
+                shadowBlur: 10
+              }
+            },
+            itemStyle: {
+              normal: {
+
+                color: cc.kygl,
+                borderColor: 'rgba(219,50,51,0.2)',
+                borderWidth: 12
+              }
+            },
+            data: ablepower
+          },{
+            name: '理论功率',
+            type: 'line',
+            smooth: true,
+            symbol: 'circle',
+            symbolSize: 5,
+            showSymbol: false,
+            lineStyle: {
+              normal: {
+                width: 2
+              }
+            },
+            areaStyle: {
+              normal: {
+                color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
+                  offset: 0,
+                  color: 'rgba(219, 50, 51, 0.3)'
+                }, {
+                  offset: 0.8,
+                  color: 'rgba(219, 50, 51, 0)'
+                }], false),
+                shadowColor: 'rgba(0, 0, 0, 0.1)',
+                shadowBlur: 10
+              }
+            },
+            itemStyle: {
+              normal: {
+
+                color: cc.llgl,
+                borderColor: 'rgba(219,50,51,0.2)',
+                borderWidth: 12
+              }
+            },
+            data: theorypower
+          },{
+            name: '参照理论功率(测风、测光法)',
+            type: 'line',
+            smooth: true,
+            symbol: 'circle',
+            symbolSize: 5,
+            showSymbol: false,
+            lineStyle: {
+              normal: {
+                width: 2
+              }
+            },
+            areaStyle: {
+              normal: {
+                color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
+                  offset: 0,
+                  color: 'rgba(219, 50, 51, 0.3)'
+                }, {
+                  offset: 0.8,
+                  color: 'rgba(219, 50, 51, 0)'
+                }], false),
+                shadowColor: 'rgba(0, 0, 0, 0.1)',
+                shadowBlur: 10
+              }
+            },
+            itemStyle: {
+              normal: {
+
+                color: cc.cfgf,
+                borderColor: 'rgba(219,50,51,0.2)',
+                borderWidth: 12
+              }
+            },
+            data: referencePowerByMeasuringpower
+          },{
+            name: '参照理论功率(样板机法)',
+            type: 'line',
+            smooth: true,
+            symbol: 'circle',
+            symbolSize: 5,
+            showSymbol: false,
+            lineStyle: {
+              normal: {
+                width: 2
+              }
+            },
+            areaStyle: {
+              normal: {
+                color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
+                  offset: 0,
+                  color: 'rgba(219, 50, 51, 0.3)'
+                }, {
+                  offset: 0.8,
+                  color: 'rgba(219, 50, 51, 0)'
+                }], false),
+                shadowColor: 'rgba(0, 0, 0, 0.1)',
+                shadowBlur: 10
+              }
+            },
+            itemStyle: {
+              normal: {
+
+                color: cc.ybjf,
+                borderColor: 'rgba(219,50,51,0.2)',
+                borderWidth: 12
+              }
+            },
+            data: referencePowerBySamplepower
+          },{
+            name: '参照可用功率(测风、测光法)',
+            type: 'line',
+            smooth: true,
+            symbol: 'circle',
+            symbolSize: 5,
+            showSymbol: false,
+            lineStyle: {
+              normal: {
+                width: 2
+              }
+            },
+            areaStyle: {
+              normal: {
+                color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
+                  offset: 0,
+                  color: 'rgba(219, 50, 51, 0.3)'
+                }, {
+                  offset: 0.8,
+                  color: 'rgba(219, 50, 51, 0)'
+                }], false),
+                shadowColor: 'rgba(0, 0, 0, 0.1)',
+                shadowBlur: 10
+              }
+            },
+            itemStyle: {
+              normal: {
+                color: cc.kycfgf,
+                borderColor: 'rgba(219,50,51,0.2)',
+                borderWidth: 12
+              }
+            },
+            data: ablePowerByMeasuringe
+          },{
+            name: '参照可用功率(样板机法)',
+            type: 'line',
+            smooth: true,
+            symbol: 'circle',
+            symbolSize: 5,
+            showSymbol: false,
+            lineStyle: {
+              normal: {
+                width: 2
+              }
+            },
+            areaStyle: {
+              normal: {
+                color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
+                  offset: 0,
+                  color: 'rgba(219, 50, 51, 0.3)'
+                }, {
+                  offset: 0.8,
+                  color: 'rgba(219, 50, 51, 0)'
+                }], false),
+                shadowColor: 'rgba(0, 0, 0, 0.1)',
+                shadowBlur: 10
+              }
+            },
+            itemStyle: {
+              normal: {
+                color: cc.kyybjf,
+                borderColor: 'rgba(219,50,51,0.2)',
+                borderWidth: 12
+              }
+            },
+            data: ablePowerBySample
+          })
+        }
+        this.chart.setOption(option,true)
+      },
+    }
+  }
+</script>
+<style scoped>
+  #rpcharts {
+    width: 100%;
+    height: calc(80vh - 50px);
+  }
+</style>

+ 309 - 0
ipfcst-console/src/main/frontend/views/dataquery/realPowerQuery/index.vue

@@ -0,0 +1,309 @@
+<template>
+  <div class="chart-container">
+    <div class="filter">
+      <span style="font-weight: bold;font-size: 14px">场站名称:</span>
+      <el-select style="width:250px" clearable v-model="stationCode" size="small">
+        <el-option
+          v-for="item in stationList"
+          :key="item.stationCode"
+          :label="item.name"
+          :value="item.stationCode">
+          <span style="float: left">{{ item.name }}</span>
+          <span style="float: right; color: #8492a6;font-size: 13px">{{ item.stationCode }}</span>
+        </el-option>
+      </el-select>
+      <span style="font-weight: bold;font-size: 14px">起始时间:</span>
+      <el-date-picker
+        v-model="startTime"
+        :clearable="false"
+        type="datetime"
+        value-format="timestamp"
+        placeholder="选择日期">
+      </el-date-picker>
+      <span style="font-weight: bold;font-size: 14px">截止时间:</span>
+      <el-date-picker
+        v-model="endTime"
+        :clearable="false"
+        type="datetime"
+        value-format="timestamp"
+        placeholder="选择日期">
+      </el-date-picker>
+      <el-button :loading=loading size="small" @click="dateQuery">查询</el-button>
+    </div>
+
+    <div class="content">
+      <el-tabs type="card" v-model="activeName" @tab-click="Byresize">
+        <el-tab-pane label="图表" name="first">
+          <chart :drawData = this.drawData :resizeKey=this.resizeKey  />
+        </el-tab-pane>
+        <el-tab-pane label="表格" name="second">
+          <div class="tableContent">
+            <vxe-grid
+              id="nwpTable"
+              ref="nwpRef"
+              border
+              export-config
+              :loading="loading"
+              @sort-change="sortChangeEvent"
+              :custom-config="{storage: true, checkMethod: checkColumnMethod}"
+              :auto-resize="true"
+              highlight-hover-row
+              :header-cell-style="{background:'black',color:'white',border:'white'}"
+              max-height="90%"
+              :cell-style="{background:'black',color:'white'}"
+              align="center"
+              :data="tableData"
+              :columns="tableColumn"
+            >
+            </vxe-grid>
+            <div class="rtPageturning">
+              <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>
+          <!-- <Table height="100%" width="100%" :queryTime=this.queryTime @sendLoading="getLoadingFormTable"></Table>-->
+        </el-tab-pane>
+      </el-tabs>
+    </div>
+  </div>
+</template>
+
+<script>
+import Chart from './charts'
+import resize from '../../../components/Charts/mixins/resize'
+export default {
+  name: 'nwp',
+  components: { Chart},
+  mixins: [resize],
+  data(){
+    return{
+      tableToolbar: {
+        export: true,
+        custom: true
+      },
+      stationCode: '',
+      stationList: [],
+      tableColumn:[],
+      chart: null,
+      queryStartTime:'',
+      queryEndTime:'',
+      startTime:new Date(new Date().toLocaleDateString()).getTime(),
+      endTime:new Date(new Date().toLocaleDateString()).getTime() + 60 * 60 * 24 * 1000*1-1,
+      loading:false,
+      drawLoading:true,
+      tableLoading:true,
+      resizeKey:1,
+      activeName: 'first',
+      drawData:{datas:[],times:[]},
+      tableData:[],
+      total:0,
+      sortOrder:'asc',
+      pageSize: 10,
+      currentPage: 1,
+      showToolBar:false,
+      /*menuKey:1,
+      isRenderingTime : new Date().getTime()*/
+      abandonmentRates:[]
+    }
+  },
+  created () {
+    this.$nextTick(() => {
+      // 手动将表格和工具栏进行关联
+      this.$refs.nwpRef.connect(this.$refs.nwpToolBar)
+    })
+  },
+  mounted() {
+    this.getStationList()
+  },
+  methods:{
+    init(){
+      this.queryStartTime = this.startTime
+      this.queryEndTime = this.endTime
+      this.loading = true
+      // this.getDraw(this.queryStartTime,this.queryEndTime,this.stationCode)
+      // this.getTable()
+
+    },
+    getStationList() {
+      this.$axios.get('/electricField/getElectricField').then((res) => {
+        this.stationList = res.data
+      }).catch((error) => {
+        this.$message.error('获取场站下拉框出错' + error)
+      })
+    },
+    getDraw(startTime,endTime,stationCode){
+      this.drawLoading = true
+      this.$axios.get('/powerStationStatus/'+startTime+'/'+endTime+'/'+stationCode).then((res) => {
+        this.drawData = res.data
+        this.abandonmentRates = res.data.abandonmentRates
+        this.drawLoading = false
+        this.tableColumn = []
+        if(this.drawData.displayKyLl == '1'){
+          this.tableColumn = [
+            { field: 'time', title: '接入时间',formatter:this.dateFormat,sortable:true,minWidth:"150",width:"180" },
+            { field: 'realValue', title: '实际功率',minWidth:"60"},
+            { field: 'ableValue', title: '可用功率',minWidth:"60"},
+            { field: 'theoryValue', title: '理论功率',minWidth:"60"},
+            { field: 'referencePowerByMeasuring', title: '参照理论功率(测风、测光法)',minWidth:"60"},
+            { field: 'referencePowerBySample', title: '参照理论功率(样板机法)',minWidth:"60"},
+            { field: 'ablePowerByMeasuring', title: '参照可用功率(测风、测光法)',minWidth:"60"},
+            { field: 'ablePowerBySample', title: '参照可用功率(样板机法)',minWidth:"60"},
+            { field: 'openCapacity', title: '开机容量',minWidth:"60"},
+            { field: 'isRationingByManualControl', title: '人工判断是否限电',formatter:this.isRationingByManualControl,minWidth:"60"},
+            { field: 'isRationingByAutoControl', title: '系统判断是否限电',formatter:this.isRationingByAutoControl,minWidth:"60"},
+            { field: 'capacity', title: '装机容量',minWidth:"60"},
+            { field: 'onGridNum', title: '并网设备',minWidth:"60"}
+          ]
+        }else {
+          this.tableColumn = [
+            { field: 'time', title: '接入时间',formatter:this.dateFormat,sortable:true,minWidth:"150",width:"180" },
+            { field: 'realValue', title: '实际功率',minWidth:"60"},
+            { field: 'openCapacity', title: '开机容量',minWidth:"60"},
+            { field: 'isRationingByManualControl', title: '人工判断是否限电',formatter:this.isRationingByManualControl,minWidth:"60"},
+            { field: 'isRationingByAutoControl', title: '系统判断是否限电',formatter:this.isRationingByAutoControl,minWidth:"60"},
+            { field: 'capacity', title: '装机容量',minWidth:"60"},
+            { field: 'onGridNum', title: '并网设备',minWidth:"60"}
+          ]
+        }
+        if(this.drawData.abnormalShow == '1'){
+          this.tableColumn .push({ field: 'abnormalOfMeasuring', title: '测风光法的异常值',minWidth:"60"})
+          this.tableColumn .push({ field: 'abnormalOfSample', title: '样板机法的异常值',minWidth:"60"})
+        }
+        if(this.drawData.displaySz == '1'){
+          this.tableColumn .push({ field: 'onSiteObstructed', title: '站内受阻功率',minWidth:"60"})
+          this.tableColumn .push({ field: 'offSiteObstructed', title: '站外受阻功率',minWidth:"60"})
+          this.tableColumn .push({ field: 'abandonmentRates', title: '弃电率指标%',minWidth:"60"})
+        }
+        if(!this.drawLoading && !this.tableLoading){
+          this.loading = false
+        }
+      }).catch((error) => {
+        this.drawLoading = false
+        if(!this.drawLoading && !this.tableLoading){
+          this.loading = false
+        }
+        this.$message.error('查询实时预测短期echarts出错' + error)
+      })
+    },
+    getTable(){
+      this.tableLoading = true
+      this.$axios.get('/powerStationStatus/'+this.queryStartTime+'/'+this.queryEndTime+'/'+this.currentPage+'/'+this.pageSize+'/'+this.stationCode+'?sortOrder='+this.sortOrder).then((res) => {
+        this.tableData = res.data.content
+        // 表分页格数据总条数
+        this.total = res.data.count
+
+        this.tableLoading = false
+        if(!this.drawLoading && !this.tableLoading){
+          this.loading = false
+        }
+      }).catch((error) => {
+        this.tableLoading = false
+        if(!this.drawLoading && !this.tableLoading){
+          this.loading = false
+        }
+        this.$message.error('查询table出错' + error)
+      })
+
+    },
+    handlePageChange ({ currentPage, pageSize }) {
+      this.currentPage = currentPage
+      this.pageSize = pageSize
+      this.startTime = this.queryStartTime
+      this.endTime = this.queryEndTime
+      this.loading = true
+      this.getTable();
+    },
+    dateFormat({ cellValue, row, column }) {
+      // return this.$XEUtils.toDateString(cellValue, 'yyyy-MM-dd HH:mm:ss')
+      const date = new Date(cellValue) // 时间戳为10位需*1000,时间戳为13位的话不需乘1000
+      const Y = date.getFullYear() + '-'
+      const M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-'
+      const D = (date.getDate() < 10 ? '0' + (date.getDate()) : date.getDate()) + '    '
+      const H = (date.getHours() < 10 ? '0' + (date.getHours()) : date.getHours()) + ':'
+      const m = (date.getMinutes() < 10 ? '0' + (date.getMinutes()) : date.getMinutes()) + ':'
+      const s = (date.getSeconds() < 10 ? '0' + (date.getSeconds()) : date.getSeconds())
+      return Y + M + D + H + m + s
+    },
+    isRationingByManualControl({ cellValue, row, column }) {
+      if (cellValue == 1){
+        return '限电'
+      }
+      if (cellValue == 0){
+        return '系统判断'
+      }
+      return '不限电'
+    },
+    isRationingByAutoControl({ cellValue, row, column }) {
+      if (cellValue){
+        return '限电'
+      }
+      return '不限电'
+    },
+    sortChangeEvent ({ column, property, order }) {
+      if(order == null){
+        order = 'asc'
+      }
+      this.currentPage = 1
+      this.sortOrder = order
+      this.loading = true
+      this.getTable()
+    },
+    checkColumnMethod ({ column }) {
+      if (column.property === 'preTime') {
+        return false
+      }
+      return true
+    },
+    dateQuery(){
+      let queryParam = this.stationCode;
+      if (queryParam == '') {
+        this.$message.error("请选择场站")
+        return;
+      }
+      this.loading = true
+      if(this.endTime<=this.startTime){
+        this.$message.error("开始时间不能小于结束时间")
+        this.startTime = this.queryStartTime
+        this.endTime = this.queryEndTime
+        this.loading = false
+        return
+      }
+      if(this.endTime-this.startTime> 60 * 60 * 24 * 1000*31){
+        this.startTime = this.queryStartTime
+        this.endTime = this.queryEndTime
+        this.$message.error("只能最多查询31天的数据哦")
+        this.loading = false
+        return
+      }
+      this.queryStartTime = this.startTime
+      this.queryEndTime = this.endTime
+      this.getDraw(this.queryStartTime,this.queryEndTime,this.stationCode)
+      this.getTable()
+    },
+    Byresize(tab){
+      if(tab.name =='first'){
+        this.resizeKey++
+        this.showToolBar = false
+      }else{
+        this.showToolBar = true
+      }
+
+    },
+  }
+}
+</script>
+
+<style scoped>
+
+.my_table_insert .vxe-body--row.is--new {
+  background-color: #f1fdf1;
+}
+</style>
+

+ 118 - 0
ipfcst-console/src/main/java/com/jiayue/ipfcst/console/controller/PowerStationStatusDataController.java

@@ -0,0 +1,118 @@
+package com.jiayue.ipfcst.console.controller;
+
+import com.jiayue.ipfcst.common.core.web.vo.ResponseVO;
+import com.jiayue.ipfcst.common.data.entity.PowerStationStatusData;
+import com.jiayue.ipfcst.common.data.entity.SysParameter;
+import com.jiayue.ipfcst.common.data.repository.SysParameterRepository;
+import com.jiayue.ipfcst.console.service.PowerStationStatusDataService;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang.time.DateFormatUtils;
+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.RestController;
+
+import javax.servlet.http.HttpServletResponse;
+import java.io.BufferedOutputStream;
+import java.io.IOException;
+import java.net.URLEncoder;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 实际功率restful接口
+ *
+ * @author yh
+ * @version 1.0
+ * @since 2019/8/7 10:12
+ */
+@RestController
+@Slf4j
+public class PowerStationStatusDataController {
+
+  private final PowerStationStatusDataService powerStationStatusDataService;
+  private final SysParameterRepository sysParameterRepository;
+
+  @Autowired
+  public PowerStationStatusDataController(PowerStationStatusDataService powerStationStatusDataService, SysParameterRepository sysParameterRepository) {
+    this.powerStationStatusDataService = powerStationStatusDataService;
+    this.sysParameterRepository = sysParameterRepository;
+  }
+
+  /**
+   * 根据开始时间和结束时间查询 场站功率状态
+   *
+   * @param startTime 开始时间
+   * @param endTime   结束时间
+   * @return 结果集
+   */
+  @GetMapping(value = "/powerStationStatus/{startTime}/{endTime}/{stationCode}")
+  public ResponseVO findByTimeBetween(@PathVariable("startTime") Long startTime,
+                                      @PathVariable("endTime") Long endTime,
+                                      @PathVariable("stationCode") String stationCode) {
+    Map<String, Object> map = new HashMap<>();
+    try {
+      map = powerStationStatusDataService.findByTimeBetweenAndStationCode(new Date(startTime), new Date(endTime),stationCode);
+      return ResponseVO.success(map);
+    } catch (Exception e) {
+      e.printStackTrace();
+      log.error("场站功率状态查询错误");
+      return ResponseVO.fail(e.getMessage());
+    }
+  }
+
+  /**
+   * 分页查询 场站功率状态
+   *
+   * @param startTime 开始时间
+   * @param endTime   结束时间
+   * @param page      页码
+   * @param size      条数
+   * @param sortOrder 排序
+   * @return
+   */
+  @GetMapping(value = "/powerStationStatus/{startTime}/{endTime}/{page}/{size}")
+  public ResponseVO findByTimeBetweenForPaging(@PathVariable("startTime") Long startTime,
+                                               @PathVariable("endTime") Long endTime,
+                                               @PathVariable("page") Integer page,
+                                               @PathVariable("size") Integer size,
+                                               @PathVariable("stationCode") String stationCode,
+                                               String sortOrder) {
+    Map<String, Object> map = new HashMap<>();
+    try {
+      map = powerStationStatusDataService.findByTimeBetweenForPaging(new Date(startTime), new Date(endTime), page, size, stationCode,sortOrder);
+      return ResponseVO.success(map);
+    } catch (Exception e) {
+      e.printStackTrace();
+      log.error("场站功率状态分页查询错误");
+      return ResponseVO.fail(e.toString());
+    }
+
+
+  }
+
+  /**
+   * 分页查询 受阻电量
+   *
+   * @param startTime 开始时间
+   * @param endTime   结束时间
+   * @return
+   */
+  @GetMapping(value = "/balkPower/{startTime}/{endTime}")
+  public ResponseVO findBalkPower(@PathVariable("startTime") Long startTime,
+                                  @PathVariable("endTime") Long endTime) {
+    try {
+//      List<Map<String, Object>> balkPower = powerStationStatusDataService.findBalkPower(new Date(startTime), new Date(endTime));
+//      return ResponseVO.success(balkPower);
+    } catch (Exception e) {
+      e.printStackTrace();
+      log.error("受阻电量查询错误");
+      return ResponseVO.fail(e.toString());
+    }
+
+return null;
+  }
+}

+ 1 - 1
ipfcst-console/src/main/java/com/jiayue/ipfcst/console/service/ForecastPowerUltraShortTermService.java

@@ -376,7 +376,7 @@ public class ForecastPowerUltraShortTermService extends BaseService {
       log.info(stationCode+"库中没有可用,本次可用计算数据采用短期*系数的方式生成数据");
 
       // 短期乘以系数
-      for (int i = 1; i < forecastPoints; i++) {
+      for (int i = 0; i < forecastPoints; i++) {
         stPower = forecastPowerShortTermList.get(i).getFpValue();
         ustPower = stPower.multiply(new BigDecimal(coe)).setScale(2, RoundingMode.HALF_UP);
         forecastPowerUltraShortTerm = new ForecastPowerUltraShortTerm();

+ 284 - 82
ipfcst-console/src/main/java/com/jiayue/ipfcst/console/service/PowerStationStatusDataService.java

@@ -1,12 +1,22 @@
 package com.jiayue.ipfcst.console.service;
+import com.jiayue.ipfcst.common.core.exception.BusinessException;
+import com.jiayue.ipfcst.common.data.entity.ElectricField;
 import com.jiayue.ipfcst.common.data.entity.PowerStationStatusData;
+import com.jiayue.ipfcst.common.data.entity.SysParameter;
 import com.jiayue.ipfcst.common.data.repository.PowerStationStatusDataRepository;
+import com.jiayue.ipfcst.common.data.repository.SysParameterRepository;
 import com.jiayue.ipfcst.common.data.service.BaseService;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.PageRequest;
+import org.springframework.data.domain.Pageable;
+import org.springframework.data.domain.Sort;
+import org.springframework.data.jpa.domain.Specification;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Propagation;
 import org.springframework.transaction.annotation.Transactional;
 
+import javax.persistence.criteria.Predicate;
 import java.math.BigDecimal;
 import java.text.SimpleDateFormat;
 import java.util.*;
@@ -19,12 +29,284 @@ import java.util.stream.Collectors;
 public class PowerStationStatusDataService extends BaseService {
 
   private final PowerStationStatusDataRepository powerStationStatusDataRepository;
+  private final SysParameterRepository sysParameterRepository;
 
   @Autowired
-  public PowerStationStatusDataService(PowerStationStatusDataRepository powerStationStatusDataRepository) {
+  public PowerStationStatusDataService(PowerStationStatusDataRepository powerStationStatusDataRepository, SysParameterRepository sysParameterRepository) {
     this.powerStationStatusDataRepository = powerStationStatusDataRepository;
+    this.sysParameterRepository = sysParameterRepository;
   }
 
+  /**
+   * 分页查询 场站功率状态 yh
+   *
+   * @param startTime 开始时间
+   * @param endTime   结束时间
+   * @param page      页码
+   * @param size      条数
+   * @param stationCode   场站编号
+   * @param sortOrder 排序
+   * @return
+   */
+  @Transactional(propagation = Propagation.NOT_SUPPORTED, readOnly = true)
+  public Map<String, Object> findByTimeBetweenForPaging(Date startTime, Date endTime,
+                                                        Integer page, Integer size,String stationCode,
+                                                        String sortOrder) {
+    Map<String, Object> map = new HashMap<>();
+    Sort sort = Sort.by(Sort.Direction.ASC, "time");
+    if (sortOrder.contains("desc")) {
+      sort = Sort.by(Sort.Direction.DESC, "time");
+    }
+    Specification<PowerStationStatusData> specification = this.Specification(startTime, endTime,stationCode);
+    Pageable pageable = PageRequest.of(page - 1, size, sort);
+    Page powerStationStatusData = powerStationStatusDataRepository.findAll(specification, pageable);
+    List<PowerStationStatusData> datas = new ArrayList<>();
+    datas = powerStationStatusData.getContent();
+    this.defaultReplace(datas);
+    List<Map<String, Object>> list = new ArrayList<>();
+    for (PowerStationStatusData powerStationStatusData1 : datas) {
+
+      Map<String, Object> map1 = new HashMap<>();
+
+      map1.put("time", powerStationStatusData1.getTime());
+      map1.put("ableValue", powerStationStatusData1.getAbleValue());
+      map1.put("theoryValue", powerStationStatusData1.getTheoryValue());
+      map1.put("realValue", powerStationStatusData1.getRealValue());
+      map1.put("referencePowerByMeasuring", powerStationStatusData1.getReferencePowerByMeasuring());
+      map1.put("referencePowerBySample", powerStationStatusData1.getReferencePowerBySample());
+      map1.put("openCapacity", powerStationStatusData1.getOpenCapacity());
+      map1.put("capacity", powerStationStatusData1.getCapacity());
+      map1.put("onGridNum", powerStationStatusData1.getOnGridNum());
+      map1.put("onSiteObstructed", powerStationStatusData1.getOnSiteObstructed());
+      map1.put("offSiteObstructed", powerStationStatusData1.getOffSiteObstructed());
+      map1.put("abnormalOfMeasuring", powerStationStatusData1.getAbnormalOfMeasuring());
+      map1.put("abnormalOfSample", powerStationStatusData1.getAbnormalOfSample());
+      map1.put("isRationingByManualControl", powerStationStatusData1.getIsRationingByManualControl());
+      map1.put("isRationingByAutoControl", powerStationStatusData1.getIsRationingByAutoControl());
+      map1.put("ablePowerByMeasuring", powerStationStatusData1.getAblePowerByMeasuring());
+      map1.put("ablePowerBySample", powerStationStatusData1.getAblePowerBySample());
+      if (powerStationStatusData1.getRealValue() != null && powerStationStatusData1.getRealValue().floatValue() != 0) {
+        BigDecimal b = powerStationStatusData1.getAbleValue().subtract(powerStationStatusData1.getRealValue());
+        map1.put("abandonmentRates", b.divide(powerStationStatusData1.getRealValue(), 2, BigDecimal.ROUND_HALF_UP));
+      } else {
+        map1.put("abandonmentRates", 0);
+      }
+      list.add(map1);
+    }
+
+    map.put("content", list);
+    map.put("count", powerStationStatusData.getTotalElements());
+    return map;
+  }
+  /**
+   * 对集合进行 -99替换null操作,主要用于图标展示空值
+   *
+   * @param datas 需要替换集合
+   */
+  public void defaultReplace(List<PowerStationStatusData> datas) {
+    BigDecimal nullBig = new BigDecimal(-99);
+    for (PowerStationStatusData p : datas) {
+      if (p.getRealValue().compareTo(nullBig) == 0) {
+        p.setRealValue(null);
+      }
+      if (p.getAbleValue().compareTo(nullBig) == 0) {
+        p.setAbleValue(null);
+      }
+      if (p.getTheoryValue().compareTo(nullBig) == 0) {
+        p.setTheoryValue(null);
+      }
+      if (p.getOpenCapacity().compareTo(nullBig) == 0) {
+        p.setOpenCapacity(null);
+      }
+      if (p.getCapacity().compareTo(nullBig) == 0) {
+        p.setCapacity(null);
+      }
+      if (p.getOnSiteObstructed().compareTo(nullBig) == 0) {
+        p.setOnSiteObstructed(null);
+      }
+      if (p.getOffSiteObstructed().compareTo(nullBig) == 0) {
+        p.setOffSiteObstructed(null);
+      }
+    }
+
+  }
+  /**
+   * 查询条件 yh
+   *
+   * @param startTime 开始时间
+   * @param endTime   结束时间
+   * @return 过滤条件
+   */
+  Specification<PowerStationStatusData> Specification(final Date startTime, final Date endTime,final String stationCode) {
+    return (Specification<PowerStationStatusData>) (root, criteriaQuery, cb) -> {
+      List<Predicate> predicates = new ArrayList<>();
+      predicates.add(cb.equal(root.get("stationCode").as(String.class),stationCode));
+      if (startTime != null) {
+        //大于或等于传入时间
+        predicates.add(cb.greaterThanOrEqualTo(root.get("time").as(Date.class), startTime));
+      }
+      if (endTime != null) {
+        //小于传入时间
+        predicates.add(cb.lessThan(root.get("time").as(Date.class), endTime));
+      }
+      //添加排序的功能
+      return cb.and(predicates.toArray(new Predicate[predicates.size()]));
+
+    };
+  }
+  /**
+   * 根据开始时间和结束时间查询 场站功率状态 yh
+   *
+   * @param startTime 开始时间
+   * @param endTime   结束时间
+   * @return 结果集
+   */
+  @Transactional(propagation = Propagation.NOT_SUPPORTED, readOnly = true)
+  public Map<String, Object> findByTimeBetweenAndStationCode(Date startTime, Date endTime,String stationCode){
+    Map<String, Object> map = new HashMap<>();
+    ElectricField electricField = null;
+    try {
+      electricField = super.getSingleStation(stationCode);
+    } catch (BusinessException e) {
+      e.printStackTrace();
+    }
+    map.put("cap", electricField.getCapacity());
+    List<PowerStationStatusData> list = new ArrayList<>();
+    List<PowerStationStatusData> checkList = new ArrayList<>();
+    list = powerStationStatusDataRepository.findByTimeBetweenAndStationCode(startTime, endTime,stationCode);
+
+    long startTimeLong = startTime.getTime();
+    long endTimeLong = endTime.getTime();
+    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+    long timeStep = 300000L;
+    if (startTimeLong % timeStep != 0) {
+      startTimeLong = startTimeLong - (startTimeLong % timeStep) + timeStep;
+    }
+    List<Float> realValueDatas = new ArrayList<>();
+    List<Float> ableValueDatas = new ArrayList<>();
+    List<Float> theoryValueDatas = new ArrayList<>();
+    List<Float> referencePowerByMeasuringDatas = new ArrayList<>();
+    List<Float> referencePowerBySampleDatas = new ArrayList<>();
+    List<Float> ablePowerByMeasuringDatas = new ArrayList<>();
+    List<Float> ablePowerBySampleDatas = new ArrayList<>();
+
+
+    List<String> times = new ArrayList<>();
+
+    for (long i = startTimeLong; i < endTimeLong; i = i + 300000) {
+      long finalI = i;
+      List<PowerStationStatusData> p = list.stream().filter(t -> t.getTime().getTime() == finalI).collect(Collectors.toList());
+      if (p != null && p.size() > 0) {
+        checkList.add(p.get(0));
+      } else {
+        checkList.add(new PowerStationStatusData());
+      }
+      String timeFormat = sdf.format(new Date(i));
+      times.add(timeFormat);
+    }
+
+    List<BigDecimal> realValues = checkList.stream().map(PowerStationStatusData::getRealValue).collect(Collectors.toList());
+
+    BigDecimal nullValue = new BigDecimal(-99);
+    for (BigDecimal b : realValues) {
+      if (b.compareTo(nullValue) == 0) {
+        realValueDatas.add(null);
+      } else {
+        realValueDatas.add(b.floatValue());
+      }
+    }
+
+    String displayKyLl = "0";
+    SysParameter sysParameter = sysParameterRepository.findBySysKeyEquals("DISPLAY_KY_LL");
+
+    if (sysParameter != null && sysParameter.getSysValue().equals("1")) {
+      displayKyLl = "1";
+
+      List<BigDecimal> ableValue = checkList.stream().map(PowerStationStatusData::getAbleValue).collect(Collectors.toList());
+      List<BigDecimal> theoryValue = checkList.stream().map(PowerStationStatusData::getTheoryValue).collect(Collectors.toList());
+      List<BigDecimal> referencePowerByMeasuring = checkList.stream().map(PowerStationStatusData::getReferencePowerByMeasuring).collect(Collectors.toList());
+      List<BigDecimal> referencePowerBySample = checkList.stream().map(PowerStationStatusData::getReferencePowerBySample).collect(Collectors.toList());
+      for (BigDecimal b : ableValue) {
+        if (b.compareTo(nullValue) == 0) {
+          ableValueDatas.add(null);
+        } else {
+          ableValueDatas.add(b.floatValue());
+        }
+      }
+      for (BigDecimal b : theoryValue) {
+        if (b.compareTo(nullValue) == 0) {
+          theoryValueDatas.add(null);
+        } else {
+          theoryValueDatas.add(b.floatValue());
+        }
+      }
+
+      for (BigDecimal b : referencePowerByMeasuring) {
+        if (b.compareTo(nullValue) == 0) {
+          referencePowerByMeasuringDatas.add(null);
+        } else {
+          referencePowerByMeasuringDatas.add(b.floatValue());
+        }
+      }
+
+      for (BigDecimal b : referencePowerBySample) {
+        if (b.compareTo(nullValue) == 0) {
+          referencePowerBySampleDatas.add(null);
+        } else {
+          referencePowerBySampleDatas.add(b.floatValue());
+        }
+      }
+
+      List<BigDecimal> ablePowerByMeasuring = checkList.stream().map(PowerStationStatusData::getAblePowerByMeasuring).collect(Collectors.toList());
+      List<BigDecimal> ablePowerBySample = checkList.stream().map(PowerStationStatusData::getAblePowerBySample).collect(Collectors.toList());
+
+      for (BigDecimal b : ablePowerByMeasuring) {
+        if (b == null || b.compareTo(nullValue) == 0) {
+          ablePowerByMeasuringDatas.add(null);
+        } else {
+          ablePowerByMeasuringDatas.add(b.floatValue());
+        }
+      }
+      for (BigDecimal b : ablePowerBySample) {
+        if (b == null || b.compareTo(nullValue) == 0) {
+          ablePowerBySampleDatas.add(null);
+        } else {
+          ablePowerBySampleDatas.add(b.floatValue());
+        }
+      }
+      map.put("ablePowerByMeasuringDatas", ablePowerByMeasuringDatas);
+      map.put("ablePowerBySampleDatas", ablePowerBySampleDatas);
+
+      map.put("ableValueDatas", ableValueDatas);
+      map.put("theoryValueDatas", theoryValueDatas);
+      map.put("referencePowerByMeasuringDatas", referencePowerByMeasuringDatas);
+      map.put("referencePowerBySampleDatas", referencePowerBySampleDatas);
+    }
+
+
+    String displaySz = "0";
+    SysParameter sysParameter2 = sysParameterRepository.findBySysKeyEquals("DISPLAY_SZ");
+
+    if (sysParameter2 != null && sysParameter2.getSysValue().equals("1")) {
+      displaySz = "1";
+    }
+
+    String abnormalShow = "0";
+    SysParameter abnormal_show = sysParameterRepository.findBySysKeyEquals("abnormal_show");
+
+    if (abnormal_show != null && abnormal_show.getSysValue().equals("1")) {
+      abnormalShow = "1";
+    }
+
+    map.put("times", times);
+    map.put("realValueDatas", realValueDatas);
+    map.put("displayKyLl", displayKyLl);
+    map.put("displaySz", displaySz);
+
+    map.put("abnormalShow", abnormalShow);
+
+    return map;
+  }
 
   /**
    * 根据开始时间和结束时间查询 场站功率状态
@@ -37,7 +319,7 @@ public class PowerStationStatusDataService extends BaseService {
   @Transactional(propagation = Propagation.NOT_SUPPORTED, readOnly = true)
   public Map<String, Object> findByTimeBetweenForContrast(Date startTime, Date endTime, Long timeStep) {
     Map<String, Object> map = new HashMap<>();
-    List<PowerStationStatusData> list ;
+    List<PowerStationStatusData> list = new ArrayList<>();
 
     list = powerStationStatusDataRepository.findByTimeBetween(startTime, endTime);
 
@@ -114,85 +396,5 @@ public class PowerStationStatusDataService extends BaseService {
 
     return map;
   }
-
-
-  /**
-   * 对集合进行 -99替换null操作,主要用于图标展示空值
-   *
-   * @param datas 需要替换集合
-   */
-  public void defaultReplace(List<PowerStationStatusData> datas) {
-    BigDecimal nullBig = new BigDecimal(-99);
-    for (PowerStationStatusData p : datas) {
-      if (p.getRealValue().compareTo(nullBig) == 0) {
-        p.setRealValue(null);
-      }
-      if (p.getAbleValue().compareTo(nullBig) == 0) {
-        p.setAbleValue(null);
-      }
-      if (p.getTheoryValue().compareTo(nullBig) == 0) {
-        p.setTheoryValue(null);
-      }
-      if (p.getOpenCapacity().compareTo(nullBig) == 0) {
-        p.setOpenCapacity(null);
-      }
-      if (p.getCapacity().compareTo(nullBig) == 0) {
-        p.setCapacity(null);
-      }
-      if (p.getOnSiteObstructed().compareTo(nullBig) == 0) {
-        p.setOnSiteObstructed(null);
-      }
-      if (p.getOffSiteObstructed().compareTo(nullBig) == 0) {
-        p.setOffSiteObstructed(null);
-      }
-    }
-
-  }
-
-  /**
-   * 受阻电量查询(已废弃)
-   *
-   * @param startTime 开始时间
-   * @param endTime   结束时间
-   */
-  @Transactional(propagation = Propagation.NOT_SUPPORTED, readOnly = true)
-  public List<Map<String, Object>> findBalkPower(Date startTime, Date endTime) {
-
-    List<Map<String, Object>> resultList = new ArrayList<>();
-
-
-    List<PowerStationStatusData> powerStationStatusDataList = powerStationStatusDataRepository.findByTimeBetween(startTime, endTime);
-
-    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
-    for (PowerStationStatusData powerStationStatusData : powerStationStatusDataList) {
-      Map<String, Object> map = new HashMap<>();
-      map.put("time", sdf.format(powerStationStatusData.getTime()));
-      map.put("onSiteObstructed", powerStationStatusData.getOnSiteObstructed());
-      map.put("offSiteObstructed", powerStationStatusData.getOffSiteObstructed());
-      BigDecimal b = powerStationStatusData.getAbleValue().subtract(powerStationStatusData.getRealValue());
-      if (powerStationStatusData.getRealValue().floatValue() != 0) {
-        map.put("abandonmentRate", b.divide(powerStationStatusData.getRealValue(), 2, BigDecimal.ROUND_HALF_UP));
-      } else {
-        map.put("abandonmentRate", 0);
-      }
-
-      resultList.add(map);
-
-    }
-    return resultList;
-  }
-
-  /**
-   * 根据时间查询数据并根据时间正序排序
-   *
-   * @param startTime 开始时间
-   * @param endTime   结束时间
-   */
-  @Transactional(propagation = Propagation.NOT_SUPPORTED, readOnly = true)
-  public List<PowerStationStatusData> findByTimeBetween(Long startTime, Long endTime) {
-    List<PowerStationStatusData> powerStationStatusDataList = powerStationStatusDataRepository.findByTimeBetween(new Date(startTime), new Date(endTime));
-    Collections.sort(powerStationStatusDataList, Comparator.comparing(PowerStationStatusData::getTime));
-    return powerStationStatusDataList;
-  }
 }