Bladeren bron

增加气象站列表查询和辐射图

xusl 7 maanden geleden
bovenliggende
commit
ca86d3ad54

+ 121 - 0
cpp-admin/src/main/java/com/cpp/web/controller/stationDataQuery/WeatherStationStatusDataController.java

@@ -0,0 +1,121 @@
+package com.cpp.web.controller.stationDataQuery;
+
+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.web.domain.station.WeatherStationStatusData;
+import com.cpp.web.domain.station.WindTowerStatusData;
+import com.cpp.web.service.station.WeatherStationStatusDataService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.RequiredArgsConstructor;
+import org.springframework.web.bind.annotation.*;
+
+import java.math.BigDecimal;
+import java.text.SimpleDateFormat;
+import java.util.*;
+
+
+/**
+ * idp_weather_station_status_data
+ *
+ * @author whc
+ * @date 2022-03-18 15:49:50
+ */
+@RestController
+@RequiredArgsConstructor
+@RequestMapping("/weatherstationstatusdata")
+@Api(value = "weatherstationstatusdata", tags = "idp_weather_station_status_data管理")
+public class WeatherStationStatusDataController {
+
+    private final WeatherStationStatusDataService weatherStationStatusDataService;
+
+    /**
+     * 分页查询
+     *
+     * @param page                     分页对象
+     * @param weatherStationStatusData idp_weather_station_status_data
+     * @return
+     */
+    @ApiOperation(value = "分页查询", notes = "分页查询")
+    @GetMapping("/page")
+    public R getWeatherStationStatusDataPage(Page page, WeatherStationStatusData weatherStationStatusData) {
+        return R.ok(weatherStationStatusDataService.page(page, Wrappers.query(weatherStationStatusData)).addOrder(OrderItem.asc("time")));
+    }
+
+    /**
+     * 通过id查询idp_weather_station_status_data
+     *
+     * @param id id
+     * @return R
+     */
+    @ApiOperation(value = "通过id查询", notes = "通过id查询")
+    @GetMapping("/{id}")
+    public R getById(@PathVariable("id") String id) {
+        return R.ok(weatherStationStatusDataService.getById(id));
+    }
+
+    @ApiOperation(value = "根据条件查询", notes = "查询")
+    @GetMapping("/queryCharts")
+    public R queryCharts(String stationCode, Long startTime, Long endTime, String equipmentId) {
+        return R.ok(weatherStationStatusDataService.findByStationCodeAndeTimeBetweenAndEquipmentId(stationCode, new Date(startTime), new Date(endTime), equipmentId));
+    }
+
+    @ApiOperation(value = "根据条件查询", notes = "分页查询")
+    @GetMapping("/queryTableData")
+    public R queryTableData(String stationCode, Long startTime, Long endTime) {
+        QueryWrapper<WeatherStationStatusData> queryWrapper = new QueryWrapper<>();
+        queryWrapper.between("time", new Date(startTime), new Date(endTime));
+        queryWrapper.eq("station_code", stationCode);
+        List<WeatherStationStatusData> talbeList = weatherStationStatusDataService.list(queryWrapper);
+        talbeList.sort(Comparator.comparing(WeatherStationStatusData::getTime));
+        Map<String, WeatherStationStatusData> dataGroupMap = new HashMap<>();
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
+        for (WeatherStationStatusData weatherStationStatusData : talbeList) {
+            dataGroupMap.put(sdf.format(weatherStationStatusData.getTime()), weatherStationStatusData);
+        }
+        // 封装各层高风速
+        List<String> timeList = new ArrayList<>();
+        List<BigDecimal> globalRList = new ArrayList<>();
+        List<BigDecimal> directRList = new ArrayList<>();
+        List<BigDecimal> diffuseRList = new ArrayList<>();
+        Long momentTime = 5 * 60 * 1000L;
+        for (Long tempTime = startTime; tempTime <= endTime; tempTime = tempTime + momentTime) {
+            // 设置时间
+            String tempTimeStr  = sdf.format(tempTime);
+            timeList.add(tempTimeStr);
+            if (dataGroupMap.get(tempTimeStr)!=null){
+                WeatherStationStatusData weatherStationStatusData = dataGroupMap.get(tempTimeStr);
+                // 总辐射
+                BigDecimal globalR = weatherStationStatusData.getGlobalR();
+                globalRList.add(globalR);
+                // 直接辐射
+                BigDecimal directR = weatherStationStatusData.getDirectR();
+                directRList.add(directR);
+                // 散辐射
+                BigDecimal diffuseR = weatherStationStatusData.getDiffuseR();
+                diffuseRList.add(diffuseR);
+            }
+            else{
+                globalRList.add(null);
+                directRList.add(null);
+                diffuseRList.add(null);
+            }
+        }
+        Map<String, List<BigDecimal>> radiationDataMap = new HashMap<>();
+        radiationDataMap.put("globalRs", globalRList);
+        radiationDataMap.put("directRs", directRList);
+        radiationDataMap.put("diffuseRs", diffuseRList);
+
+
+        Map<String, Object> returnMap = new HashMap<>();
+        returnMap.put("tableList", talbeList);
+        returnMap.put("timeList", timeList);
+        returnMap.put("radiationData", radiationDataMap);
+
+        return R.ok(returnMap);
+
+    }
+}

+ 2 - 0
cpp-admin/src/main/java/com/cpp/web/domain/station/WeatherStationStatusData.java

@@ -3,6 +3,7 @@ package com.cpp.web.domain.station;
 import com.baomidou.mybatisplus.annotation.TableName;
 
 import com.cpp.web.domain.BaseCppEntity;
+import com.fasterxml.jackson.annotation.JsonFormat;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
@@ -28,6 +29,7 @@ public class WeatherStationStatusData extends BaseCppEntity {
      * 时间
      */
     @ApiModelProperty(value = "时间")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
     private Date time;
 
     /**

+ 371 - 0
cpp-ui/src/views/stationDataQuery/weatherstationstatusdata/index.vue

@@ -0,0 +1,371 @@
+<template>
+  <div class="app-container">
+    <el-form ref="queryForm" size="small" :inline="true">
+      <el-form-item label="时间">
+        <el-date-picker
+          :clearable="false"
+          v-model="dateTime"
+          type="datetimerange"
+          range-separator="至"
+          start-placeholder="开始日期"
+          end-placeholder="结束日期"
+          :default-time="['00:00:00', '23:45:00']"
+        />
+      </el-form-item>
+      <el-form-item label="场站名称">
+        <el-select v-model="stationCode" placeholder="请选择">
+          <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 style="padding-top: 10px">
+      <el-tabs type="card" v-model="activeName" @tab-click="tabClick">
+        <el-tab-pane label="列表" name="first">
+          <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)"
+            height="535">
+            <vxe-table-column field="stationCode" title="场站名称" :formatter="stationCodeFormat" width="200px"
+                              fixed="left"></vxe-table-column>
+            <vxe-table-column field="time" title="时间" width="180px" fixed="left"></vxe-table-column>
+            <vxe-table-column field="globalR" title="总辐射(W/㎡)" width="180px"></vxe-table-column>
+            <vxe-table-column field="directR" title="直接辐射(W/㎡)" width="180px"></vxe-table-column>
+            <vxe-table-column field="diffuseR" title="散射辐射(W/㎡)" width="180px"></vxe-table-column>
+            <vxe-table-column field="airT" title="温度(℃)" width="180px"></vxe-table-column>
+            <vxe-table-column field="rh" title="湿度(%)" width="180px"></vxe-table-column>
+            <vxe-table-column field="p" title="气压(kPa)" width="180px"></vxe-table-column>
+            <vxe-table-column field="cellT" title="电池板温度(℃)" width="180px"></vxe-table-column>
+            <vxe-table-column field="ws" title="风速(m/s)" width="180px"></vxe-table-column>
+            <vxe-table-column field="wd" title="风向(°)" width="180px"></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>
+        </el-tab-pane>
+        <el-tab-pane label="辐射图" name="second">
+          <div style="float:left;width: 95%;height: 550px" id="fscharts"></div>
+        </el-tab-pane>
+        <el-tab-pane label="风速曲线图" name="three">
+          <div style="float:left;width: 95%;height: 550px" id="wscharts"></div>
+        </el-tab-pane>
+      </el-tabs>
+    </div>
+  </div>
+</template>
+
+<script>
+import * as echarts from "echarts";
+
+export default {
+  name: 'inverterinfo',
+  data() {
+    return {
+      wsChart: null,
+      wdChart: null,
+      activeName: 'first',
+      dateTime: [new Date(new Date().toLocaleDateString()).getTime(), new Date(new Date().toLocaleDateString()).getTime() + 60 * 60 * 24 * 1000 - 5 * 1000 * 60],
+      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.wsChart) {
+      return
+    }
+    this.wsChart.dispose()
+    this.wsChart = null
+    if (!this.fsChart) {
+      return
+    }
+    this.fsChart.dispose()
+    this.fsChart = null
+  },
+  computed: {},
+  methods: {
+    tabClick(tab) {
+      if (this.activeName == 'second') {
+        this.$nextTick(function () {
+          this.fsChart.resize();
+        })
+      }
+      if (this.activeName == 'three') {
+        this.$nextTick(function () {
+          this.wsChart.resize();
+        })
+      }
+    },
+    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 : ''
+    },
+    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])
+      if (endTime <= startTime) {
+        this.$message.error("开始时间不能大于结束时间")
+        return
+      }
+
+      this.loading = true
+      let queryParams = {
+        "stationCode": this.stationCode,
+        "startTime": startTime,
+        "endTime": endTime,
+      }
+      this.$axios.get('/weatherstationstatusdata/queryTableData', {params: queryParams}).then(response => {
+        this.tableData = response.data.tableList
+        this.total = response.data.tableList.length
+
+        let radiationData = response.data.radiationData
+        let timeList = response.data.timeList
+        // let wdMap = response.data.wdMap
+        // this.wsDraw(wsTime,wsMap)
+        // this.wdDraw(wdMap);
+        this.drawFs(timeList, radiationData)
+
+        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()
+        }
+      })
+    },
+
+    drawFs(timeaxis, radiationData) {
+      var globalR = []
+      var directR = []
+      var diffuseR = []
+      if (radiationData != null) {
+        if (radiationData.globalRs != null) {
+          globalR = radiationData.globalRs
+        }
+        if (radiationData.directRs != null) {
+          directR = radiationData.directRs
+        }
+        if (radiationData.diffuseRs != null) {
+          diffuseR = radiationData.diffuseRs
+        }
+      }
+
+      this.fsChart = echarts.init(document.getElementById('fscharts'))
+
+      this.fsChart.setOption({
+        backgroundColor: 'transparent',
+        title: {
+          top: 20,
+          text: '气象站辐射',
+          textStyle: {
+            fontWeight: 'normal',
+            fontSize: 16,
+            color: this.lineColor
+          },
+          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: this.lineColor
+          },
+          selected: {
+            '总辐射': true,
+            '直辐射': true,
+            '散辐射': true,
+          }
+        },
+        dataZoom: [{
+          show: true,
+          realtime: true,
+          start: 0,
+          end: 100,
+          left: "15%",
+          right: "15%",
+          textStyle: {
+            color: this.lineColor
+          }
+        }, {
+          type: 'inside'
+        }],
+        grid: {
+          top: 100,
+          left: '2%',
+          right: '2%',
+          bottom: '10%',
+          containLabel: true
+        },
+        xAxis: [{
+          type: 'category',
+          boundaryGap: false,
+          axisLine: {
+            lineStyle: {
+              color: this.lineColor
+            }
+          },
+          data: timeaxis
+        }],
+        yAxis: [{
+          type: 'value',
+          name: '瓦/平方米',
+          axisTick: {
+            show: false
+          },
+          axisLine: {
+            lineStyle: {
+              color: this.lineColor
+            }
+          },
+          axisLabel: {
+            margin: 10,
+            textStyle: {
+              fontSize: 14
+            }
+          },
+          splitLine: {
+            lineStyle: {
+              color: '#57617B'
+            }
+          }
+        }],
+        series: [{
+          name: '总辐射',
+          type: 'line',
+          smooth: true,
+          symbol: 'circle',
+          symbolSize: 5,
+          showSymbol: false,
+          connectNulls: true,
+          lineStyle: {
+            normal: {
+              width: 2
+            }
+          },
+          itemStyle: {
+            normal: {
+              color: 'rgb(219,50,51)',
+              borderColor: 'rgba(219,50,51,0.2)',
+              borderWidth: 12
+            }
+          },
+          data: globalR
+        },
+          {
+            name: '直辐射',
+            type: 'line',
+            smooth: true,
+            symbol: 'circle',
+            symbolSize: 5,
+            showSymbol: false,
+            connectNulls: true,
+            lineStyle: {
+              normal: {
+                width: 2
+              }
+            },
+            itemStyle: {
+              normal: {
+                color: 'rgb(0,136,212)',
+                borderColor: 'rgba(0,136,212,0.2)',
+                borderWidth: 12
+              }
+            },
+            data: directR
+          },
+          {
+            name: '散辐射',
+            type: 'line',
+            smooth: true,
+            symbol: 'circle',
+            connectNulls: true,
+            symbolSize: 5,
+            showSymbol: false,
+            lineStyle: {
+              normal: {
+                width: 2
+              }
+            },
+            itemStyle: {
+              normal: {
+                color: 'rgb(137,189,27)',
+                borderColor: 'rgba(137,189,2,0.27)',
+                borderWidth: 12
+              }
+            },
+            data: diffuseR
+          },
+        ]
+      })
+    },
+  },
+}
+</script>

+ 3 - 3
cpp-ui/src/views/stationDataQuery/windtowerstatusdata/index.vue

@@ -30,7 +30,7 @@
 
     <div style="padding-top: 10px">
       <el-tabs type="card" v-model="activeName" @tab-click="tabClick">
-        <el-tab-pane label="数据表格" name="first">
+        <el-tab-pane label="列表" name="first">
           <vxe-table
             highlight-hover-row
             :keep-source="true"
@@ -47,8 +47,8 @@
             <vxe-table-column field="stationCode" title="场站名称" :formatter="stationCodeFormat" width="200px" fixed="left"></vxe-table-column>
             <vxe-table-column field="time" title="时间" width="180px" fixed="left"></vxe-table-column>
             <vxe-table-column field="t" title="温度(℃)" width="180px"></vxe-table-column>
-            <vxe-table-column field="rh" title="湿度(%RH)" width="180px"></vxe-table-column>
-            <vxe-table-column field="pa" title="气压(hPa)" width="180px"></vxe-table-column>
+            <vxe-table-column field="rh" title="湿度(RH%)" width="180px"></vxe-table-column>
+            <vxe-table-column field="pa" title="气压(kPa)" width="180px"></vxe-table-column>
             <vxe-table-column field="wsHubHeight" title="轮毂风速(m/s)" width="180px"></vxe-table-column>
             <vxe-table-column field="wdHubHeight" title="轮毂风向(°)" width="180px"></vxe-table-column>
             <vxe-table-column field="ws10" title="10米风速(m/s)" width="180px"></vxe-table-column>