Kaynağa Gözat

增加站端数据nwp、历史数据查询、气象站数据前端导出

xusl 7 ay önce
ebeveyn
işleme
e59ecaef0d

+ 28 - 0
cpp-ui/src/views/stationDataQuery/historyforecastdata/index.vue

@@ -27,6 +27,8 @@
         <el-form-item>
           <el-button type="primary" style="margin-left: 5px" icon="el-icon-search" @click="dataQuery">查询
           </el-button>
+          <el-button type="primary" style="margin-left: 5px" icon="el-icon-download" @click="exportFile">导出
+          </el-button>
         </el-form-item>
       </el-form>
     </div>
@@ -720,6 +722,32 @@ export default {
       this.currentPage = currentPage
       this.pageSize = pageSize
     },
+    exportFile(){
+      if (this.tableData.length>0){
+        const item = this.stationList.find(item => item.value === this.stationCode)
+        let filename = item.label
+        // 文件名日期
+        let startTime = this.$moment(this.dateTime[0]).format('YYYY-MM-DD')
+        let endTime = this.$moment(this.dateTime[1]).format('YYYY-MM-DD')
+        if (startTime===endTime){
+          filename=filename+startTime
+        }
+        else{
+          filename=filename+startTime+'至'+endTime
+        }
+        this.$refs.xTable.exportData({
+          filename: filename,
+          type: 'csv',
+          isHeader: true,
+          isFooter: true,
+          data: this.tableData
+        })
+      }
+      else{
+        this.$message.error("列表无数据不能导出文件!")
+        return
+      }
+    },
     async dataQuery() {
       let startTime = Math.round(this.dateTime[0])
       let endTime = Math.round(this.dateTime[1])

+ 73 - 67
cpp-ui/src/views/stationDataQuery/inverterstatusdata/index.vue

@@ -4,33 +4,34 @@
       <el-form ref="queryForm" size="small" :inline="true" popper-class="cpp-popper">
         <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']" popper-class="cpp-popper"
-            :picker-options="pickerOptions"
+              :clearable="false"
+              v-model="dateTime"
+              type="datetimerange"
+              range-separator="至"
+              start-placeholder="开始日期"
+              end-placeholder="结束日期"
+              :default-time="['00:00:00', '23:45:00']" popper-class="cpp-popper"
+              :picker-options="pickerOptions"
           />
         </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">
+                v-for="item in stationList"
+                :key="item.value"
+                :label="item.label"
+                :value="item.value">
             </el-option>
           </el-select>
         </el-form-item>
         <el-form-item label="逆变器设备">
-          <el-select v-model="equipmentId" multiple :multiple-limit="5" filterable  collapse-tags popper-class="cpp-popper">
+          <el-select v-model="equipmentId" multiple :multiple-limit="5" filterable collapse-tags
+                     popper-class="cpp-popper">
             <el-option
-              v-for="item in equipmentOptions"
-              :key="item.value"
-              :label="item.label"
-              :value="item.value">
+                v-for="item in equipmentOptions"
+                :key="item.value"
+                :label="item.label"
+                :value="item.value">
             </el-option>
           </el-select>
         </el-form-item>
@@ -44,17 +45,17 @@
     </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'}">
+          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="stationCode" title="所属场站" :formatter="stationCodeFormat"></vxe-table-column>
         <vxe-table-column field="equipmentId" title="设备名称" :formatter="nameFormat"></vxe-table-column>
         <vxe-table-column field="time" title="时间" width="150" :formatter="timeFormat"></vxe-table-column>
@@ -68,13 +69,13 @@
         <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']">
+          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>
@@ -86,8 +87,8 @@ export default {
   data() {
     return {
       equipmentId: [],
-      equipmentOptions:[],
-      dateTime: [new Date(new Date().toLocaleDateString()).getTime(), new Date(new Date().toLocaleDateString()).getTime() + 60 * 60 * 24 * 1000-5*1000*60],
+      equipmentOptions: [],
+      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,
@@ -96,7 +97,7 @@ export default {
       stationCode: [],
       searchForm: {},
       tableData: [],
-      nameList:[],
+      nameList: [],
       loading: false,
       modId: '',//备用id
 
@@ -105,7 +106,7 @@ export default {
       day30: 30 * 24 * 3600 * 1000,
       // 日期使用
       pickerOptions: {
-        onPick: ({ maxDate, minDate }) => {
+        onPick: ({maxDate, minDate}) => {
           if (minDate && this.pickerMinDate) {
             this.pickerMinDate = null;
           } else if (minDate) {
@@ -121,7 +122,7 @@ export default {
       },
     }
   },
-  created(){
+  created() {
     // 获取所有逆变器名称(列表转义应用)
     this.$axios.get('/inverterinfo/findAll').then((res) => {
       this.nameList = res.data
@@ -147,34 +148,39 @@ export default {
   computed: {},
   methods: {
     exportFile() {
-      if (this.equipmentId.length == 0) {
-        this.$message.error("请选择逆变器设备查询")
-        return
-      }
-      let startTime = Math.round(this.dateTime[0])
-      let endTime = Math.round(this.dateTime[1])
-      if (endTime <= startTime) {
-        this.$message.error("开始时间不能大于结束时间")
-        return
-      }
+      if (this.tableData.length > 0) {
+        if (this.equipmentId.length == 0) {
+          this.$message.error("请选择逆变器设备查询")
+          return
+        }
+        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,
-        "equipmentId": this.equipmentId.join(','),
-        "startTime": startTime,
-        "endTime": endTime,
+        this.loading = true
+        let queryParams = {
+          "stationCode": this.stationCode,
+          "equipmentId": this.equipmentId.join(','),
+          "startTime": startTime,
+          "endTime": endTime,
+        }
+        this.$axios.get('/inverterstatusdata/export', {
+          params: queryParams,
+          responseType: 'blob',// 用于解决中文乱码
+        }).then(response => {
+          this.loading = false
+        }).catch(() => {
+          this.loading = false
+        })
+      } else {
+        this.$message.error("列表无数据不能导出文件!")
+        return
       }
-      this.$axios.get('/inverterstatusdata/export', {
-        params: queryParams,
-        responseType: 'blob',// 用于解决中文乱码
-      }).then(response => {
-        this.loading = false
-      }).catch(() => {
-        this.loading = false
-      })
     },
-    beforeQuery(){
+    beforeQuery() {
       this.currentPage = 1
       this.pageSize = 10
       this.dataQuery()
@@ -190,7 +196,7 @@ export default {
         this.$message.error('获取逆变器设备出错' + error)
       })
     },
-    timeFormat({ cellValue, row, column }) {
+    timeFormat({cellValue, row, column}) {
       return this.$moment(cellValue).format('YYYY-MM-DD HH:mm')
     },
     nameFormat({cellValue, row, column}) {
@@ -251,7 +257,7 @@ export default {
       const param = {
         "type": 'E1',
       }
-      await this.$axios.get('/electricfield/findByType',{params: param}).then(response => {
+      await this.$axios.get('/electricfield/findByType', {params: param}).then(response => {
         this.stationList = response.data
         if (this.stationList.length > 0) {
           this.stationCode = this.stationList[0].value

+ 22 - 0
cpp-ui/src/views/stationDataQuery/nwpdata/index.vue

@@ -24,6 +24,8 @@
         <el-form-item>
           <el-button type="primary" style="margin-left: 5px" icon="el-icon-search" @click="dataQuery">查询
           </el-button>
+          <el-button type="primary" style="margin-left: 5px" icon="el-icon-download" @click="exportFile">导出
+          </el-button>
         </el-form-item>
       </el-form>
     </div>
@@ -698,6 +700,26 @@ export default {
       this.currentPage = currentPage
       this.pageSize = pageSize
     },
+    exportFile(){
+      if (this.tableData.length>0){
+        const item = this.stationList.find(item => item.value === this.stationCode)
+        let filename = item.label
+        // 文件名日期
+        let startTime = this.$moment(this.dateTime).format('YYYY-MM-DD')
+        filename=filename+startTime
+        this.$refs.xTable.exportData({
+          filename: filename,
+          type: 'csv',
+          isHeader: true,
+          isFooter: true,
+          data: this.tableData
+        })
+      }
+      else{
+        this.$message.error("列表无数据不能导出文件!")
+        return
+      }
+    },
     async dataQuery() {
       if (this.dateTime==undefined){
         this.$message.warning('请选择生成日期')

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

@@ -27,6 +27,8 @@
         <el-form-item>
           <el-button type="primary" style="margin-left: 5px" icon="el-icon-search" @click="dataQuery">查询
           </el-button>
+          <el-button type="primary" style="margin-left: 5px" icon="el-icon-download" @click="exportFile">导出
+          </el-button>
         </el-form-item>
       </el-form>
     </div>
@@ -152,6 +154,32 @@ export default {
       this.currentPage = currentPage
       this.pageSize = pageSize
     },
+    exportFile(){
+      if (this.tableData.length>0){
+        const item = this.stationList.find(item => item.value === this.stationCode)
+        let filename = item.label
+        // 文件名日期
+        let startTime = this.$moment(this.dateTime[0]).format('YYYY-MM-DD')
+        let endTime = this.$moment(this.dateTime[1]).format('YYYY-MM-DD')
+        if (startTime===endTime){
+          filename=filename+startTime
+        }
+        else{
+          filename=filename+startTime+'至'+endTime
+        }
+        this.$refs.xTable.exportData({
+          filename: filename,
+          type: 'csv',
+          isHeader: true,
+          isFooter: true,
+          data: this.tableData
+        })
+      }
+      else{
+        this.$message.error("列表无数据不能导出文件!")
+        return
+      }
+    },
     async dataQuery() {
       let startTime = Math.round(this.dateTime[0])
       let endTime = Math.round(this.dateTime[1])

+ 30 - 25
cpp-ui/src/views/stationDataQuery/windturbinestatusdata/index.vue

@@ -149,32 +149,37 @@ export default {
   computed: {},
   methods: {
     exportFile() {
-      if (this.equipmentId.length == 0) {
-        this.$message.error("请选择风机设备查询")
-        return
-      }
-      let startTime = Math.round(this.dateTime[0])
-      let endTime = Math.round(this.dateTime[1])
-      if (endTime <= startTime) {
-        this.$message.error("开始时间不能大于结束时间")
-        return
-      }
+      if (this.tableData.length > 0) {
+        if (this.equipmentId.length == 0) {
+          this.$message.error("请选择风机设备查询")
+          return
+        }
+        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,
-        "equipmentId": this.equipmentId.join(','),
-        "startTime": startTime,
-        "endTime": endTime,
+        this.loading = true
+        let queryParams = {
+          "stationCode": this.stationCode,
+          "equipmentId": this.equipmentId.join(','),
+          "startTime": startTime,
+          "endTime": endTime,
+        }
+        this.$axios.get('/windturbinestatusdata/export', {
+          params: queryParams,
+          responseType: 'blob',// 用于解决中文乱码
+        }).then(response => {
+          this.loading = false
+        }).catch(() => {
+          this.loading = false
+        })
+      } else {
+        this.$message.error("列表无数据不能导出文件!")
+        return
       }
-      this.$axios.get('/windturbinestatusdata/export', {
-        params: queryParams,
-        responseType: 'blob',// 用于解决中文乱码
-      }).then(response => {
-        this.loading = false
-      }).catch(() => {
-        this.loading = false
-      })
     },
     beforeQuery() {
       this.currentPage = 1
@@ -192,7 +197,7 @@ export default {
         this.$message.error('获取风机设备出错' + error)
       })
     },
-    timeFormat({ cellValue, row, column }) {
+    timeFormat({cellValue, row, column}) {
       return this.$moment(cellValue).format('YYYY-MM-DD HH:mm')
     },
     nameFormat({cellValue, row, column}) {