Przeglądaj źródła

负荷、源网、设备模型

hsshuxian 9 miesięcy temu
rodzic
commit
cabef7f768

+ 17 - 0
ems-ui/src/api/mgr/elecUseH.js

@@ -17,6 +17,23 @@ export function listHSum(query) {
   })
 }
 
+// 根据设施查询能耗统计
+export function sumByFacsH(query) {
+  return request({
+    url: '/ems/elec/use/hour/sumByFacs',
+    method: 'get',
+    params: query
+  })
+}
+//能耗总览统计
+export function sumBySubCategoryH(query) {
+  return request({
+    url: '/ems/elec/use/hour/sumBySubCategory',
+    method: 'get',
+    params: query
+  })
+}
+
 // 查询用能计量-小时详细
 export function getH(id) {
   return request({

+ 40 - 12
ems-ui/src/views/basecfg/device/model.vue

@@ -1,5 +1,11 @@
 <template>
   <div class="app-container">
+    <el-tabs v-model="activeObjType" @tab-click="handleTabClick">
+      <el-tab-pane label="设施模型" name="1"></el-tab-pane>
+      <el-tab-pane label="设备模型" name="2"></el-tab-pane>
+      <el-tab-pane label="设备部件" name="3"></el-tab-pane>
+    </el-tabs>
+
     <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
       <el-form-item label="模型编码" prop="modelCode">
         <el-input
@@ -119,14 +125,12 @@
         <el-form-item label="模型名称" prop="modelName">
           <el-input v-model="form.modelName" placeholder="请输入模型名称"/>
         </el-form-item>
-        <el-form-item label="对象类型" prop="objType">
-          <el-select v-model="form.objType" placeholder="请选择对象类型">
-            <el-option v-for="item in objTypeOptions"
-                       :label="item.name"
-                       :value="item.code"
-                       :key="item.code" />
-          </el-select>
-        </el-form-item>
+        <!-- 对象类型选择,但值由标签页控制 -->
+<!--        <el-form-item label="对象类型" prop="objType">-->
+<!--          <el-select v-model="form.objType" placeholder="请选择对象类型" disabled>-->
+<!--            <el-option :label="objTypeMapping[activeObjType]" :value="activeObjType" />-->
+<!--          </el-select>-->
+<!--        </el-form-item>-->
       </el-form>
       <div slot="footer" class="dialog-footer">
         <el-button type="primary" @click="submitForm">确 定</el-button>
@@ -192,7 +196,6 @@
             </el-dialog>
           </el-tab-pane>
 
-
           <el-tab-pane label="对象事件" name="second">
             <el-row :gutter="10" class="mb8">
               <el-col :span="1.5">
@@ -335,6 +338,8 @@ export default {
       total: 0,
       // 能源对象属性表格数据
       modelList: [],
+      filteredModelList:[],
+      activeObjType: '1', // 当前激活的 objType
       // 弹出层标题
       title: '',
       // 是否显示弹出层
@@ -379,7 +384,12 @@ export default {
       },
       curRow: {},
       // 表单参数
-      form: {},
+      form: {
+        id: null,
+        modelCode: null,
+        modelName: null,
+        objType: null // 这里将由标签页控制
+      },
       eventForm: {},
       attrForm: {},
       abilityForm: {},
@@ -445,10 +455,27 @@ export default {
       subKey: 'attr'
     }
   },
+  // computed: {
+  //   filteredModelList() {
+  //     // 根据当前激活的 objType 过滤模型列表
+  //     return this.modelList.filter(item => item.objType.toString() === this.activeObjType);
+  //   }
+  // },
+  // watch: {
+  //   activeObjType(newVal) {
+  //     // 当激活的 objType 变化时,重新获取列表数据
+  //     this.getList();
+  //   }
+  // },
   created() {
     this.getList()
   },
   methods: {
+    handleTabClick(tab) {
+      this.activeObjType = tab.name;
+      this.form.objType = null; // 重置表单时清除预设的 objType
+      this.getList();
+    },
     // 设配详情
     handleDetail(row) {
       this.showDrawer = true
@@ -484,7 +511,7 @@ export default {
     /** 查询能源对象属性列表 */
     getList() {
       this.loading = true
-      listModel(this.queryParams).then(response => {
+      listModel({ objType: this.activeObjType }).then(response => {
         this.modelList = response.rows
         this.total = response.total
         this.loading = false
@@ -506,7 +533,6 @@ export default {
     /** 查询能源对象属性列表 */
     getAttrList(modelcode) {
       this.loading = true
-      console.log('对象属性!!!!')
       getModelByCode(modelcode).then(response => {
         const data = response.data
         console.log('data', data)
@@ -753,6 +779,7 @@ export default {
       this.reset()
       this.open = true
       this.title = '添加能源对象属性'
+      this.form.objType = this.activeObjType; // 设置默认对象类型
     },
     /** 修改按钮操作 */
     handleUpdate(row) {
@@ -760,6 +787,7 @@ export default {
       const id = row.id || this.ids
       getModel(id).then(response => {
         this.form = response.data
+        this.form.objType = this.activeObjType; // 设置默认对象类型
         this.open = true
         this.title = '修改能源对象属性'
       })

+ 88 - 8
ems-ui/src/views/mgr/powergrid.vue

@@ -4,10 +4,12 @@
       <el-tab-pane label="总览" name="summery">
         <el-row type="flex" :gutter="20" style="margin-top: 20px">
           <el-col :span="12">
-            <PieChartBlock title="当日供电量(单位:kW·h)" :opt-cfg="elecQuantity"/>
+            <PieChartBlock title="当日供电量(单位:kW·h)" :opt-cfg="elecQuantity" >
+            </PieChartBlock>
           </el-col>
           <el-col :span="12">
-            <PieChartBlock title="当日电费(单位:元)" :opt-cfg="elecCost"></PieChartBlock>
+            <PieChartBlock title="当日电费(单位:元)" :opt-cfg="elecCost" >
+            </PieChartBlock>
           </el-col>
         </el-row>
         <el-row type="flex" :gutter="20" style="margin-top: 20px">
@@ -213,11 +215,26 @@ export default {
           }
         ]
       },
+
+
       elecQuantity: {
         series: [
           {
             type: 'pie',
-            data: []
+            data: [],
+            label: {
+              show: true,
+              position: 'center',
+              rich: {
+                totalSupply: {
+                  fontSize: 12,
+                  color: '#000',
+                  lineHeight: 20,
+                  align: 'center'
+                }
+              },
+              formatter: this.getLabelContentForElecQuantity // 使用方法生成标签内容
+            }
           }
         ]
       },
@@ -225,10 +242,42 @@ export default {
         series: [
           {
             type: 'pie',
-            data: []
+
+            data: [],
+            label: {
+              show: true,
+              position: 'center',
+              rich: {
+                totalCost: {
+                  fontSize: 12,
+                  color: '#000',
+                  lineHeight: 20,
+                  align: 'center'
+                }
+              },
+              formatter: this.getLabelContentForElecCost // 使用方法生成标签内容
+            }
           }
         ]
       },
+
+
+      // elecQuantity: {
+      //   series: [
+      //     {
+      //       type: 'pie',
+      //       data: []
+      //     }
+      //   ]
+      // },
+      // elecCost: {
+      //   series: [
+      //     {
+      //       type: 'pie',
+      //       data: []
+      //     }
+      //   ]
+      // },
       pvSupplyIndex: {
         unit: '  ',
         xAxis: {
@@ -236,7 +285,9 @@ export default {
           data: []
         },
         series: []
-      }
+      },
+      totalSupply: 0,
+      totalCost: 0
     }
   },
   computed: {
@@ -415,6 +466,12 @@ export default {
     await this.getSummery()
   },
   methods: {
+    getLabelContentForElecQuantity() {
+      return `总供电{totalSupply|${this.totalSupply} kW·h}`;
+    },
+    getLabelContentForElecCost() {
+      return `供电成本{totalCost|${this.totalCost} 元}`;
+    },
     tabClick() {
       if (this.activeName !== 'summery') {
         this.dateRange = [dayjs().format(DateTool.DateFormat.YYYY_MM_DD_00_00_00), dayjs().format(DateTool.DateFormat.YYYY_MM_DD_23_59_59)]
@@ -445,6 +502,12 @@ export default {
         pv,
         supply
       } = data
+
+      // 计算总供电量
+      const totalSupply = (supply?.quantity || 0) + (pv?.useQuantity || 0);
+      // 计算总电费
+      const totalCost = (supply?.cost || 0) + (pv?.upEarn || 0);
+
       this.elecQuantity.series[0].data = [
         {
           value: supply?.quantity,
@@ -478,8 +541,11 @@ export default {
           }
         }
       ]
-
+      // 更新饼图中间显示的总和
+      this.totalSupply = totalSupply;
+      this.totalCost = totalCost;
     },
+
     async getHSummery() {
       const {
         data,
@@ -577,13 +643,27 @@ export default {
         this.queryParams.endRecTime = endRecTime
       }
       if (this.activeName === 'first') {
-        listPgSupplyH(this.queryParams).then(response => {
+        listPgSupplyH(
+          {
+            startRecTime: dayjs().format(DateTool.DateFormat.YYYY_MM_DD_00_00_00),
+            endRecTime: dayjs().format(DateTool.DateFormat.YYYY_MM_DD_23_59_59),
+            areaCode: this.queryParams.areaCode,
+            pageNum: 1,
+            pageSize: 999
+          }
+      ).then(response => {
           this.pgSupplyHList = response.rows
           this.total = response.total
           this.loading = false
         })
       } else {
-        listPvSupplyH(this.queryParams).then(response => {
+        listPvSupplyH({
+          startRecTime: dayjs().format(DateTool.DateFormat.YYYY_MM_DD_00_00_00),
+          endRecTime: dayjs().format(DateTool.DateFormat.YYYY_MM_DD_23_59_59),
+          areaCode: this.queryParams.areaCode,
+          pageNum: 1,
+          pageSize: 999
+        }).then(response => {
           this.pvSupplyHList = response.rows
           this.total = response.total
           this.loading = false

+ 206 - 16
ems-ui/src/views/mgr/poweruse.vue

@@ -2,10 +2,24 @@
   <div class="app-container">
     <el-tabs v-model="activeName" @tab-click="tabClick">
       <el-tab-pane label="总览" name="summery">
+        <div class="First">
+          <div class="time-range-buttons">
+            <el-button
+              :class="{ 'is-active': selectedTimeRange === 'day' }"
+              @click="changeTimeRange('day')">日</el-button>
+            <el-button
+              :class="{ 'is-active': selectedTimeRange === 'month' }"
+              @click="changeTimeRange('month')">月</el-button>
+            <el-button
+              :class="{ 'is-active': selectedTimeRange === 'year' }"
+              @click="changeTimeRange('year')">年</el-button>
+          </div>
+          <!-- 图表容器 -->
+          <div ref="sumBySubCategoryChart" style="height: 400px;" class="chart-container"/>
+        </div>
 
       </el-tab-pane>
-
-      <el-tab-pane v-for="item in facsCategoryOptions" :key="item.code" :label="item.name" :name="item.code">
+      <el-tab-pane v-for="item in facsCategoryOptions" :key="item.code" :label="item.name" :name="item.code" >
         <el-col :span="4" :xs="24">
           <div class="head-container">
             <el-input v-model="areaName" placeholder="请输入区域名称" clearable size="small"
@@ -30,27 +44,45 @@
               </el-form-item>
             </el-form>
           </div>
+
           <div class="container-block">
-            <BaseChart width="100%" height="300px" :option="barChartOptions"/>
-          </div>
-          <div class="container-block">
-            <div class="ctl-container">
+            <div class="ctl-container" style="display: flex; justify-content: flex-end;">
               <el-select v-model="objCode" placeholder="选择设施" clearable  @visible-change="handleObjSelectClick" @change="getList">
                 <el-option v-for="item in objOptions"
                            :label="item.facsName"
                            :value="item.facsCode"
-                           :key="item.facsCode"
-                />
+                           :key="item.facsCode"/>
 
               </el-select>
               <el-date-picker v-model="dateRange" type="datetimerange" @change="getList" :picker-options="pickerOptions"
                               value-format="yyyy-MM-dd hh:mm:ss" range-separator="至" start-placeholder="开始日期"
                               end-placeholder="结束日期"
-                              align="right"
-              >
+                              align="right">
               </el-date-picker>
             </div>
-
+          <!-- 表格  -->
+            <el-table v-loading="loading" :data="sumByFacsList"  style="width: 100%; margin-top: 10px" >
+              <el-table-column label="设施编码" align="center" prop="objCode">
+                <template slot-scope="scope">
+                  <span>{{ scope.row.objCode }}</span>
+                </template>
+              </el-table-column>
+              <el-table-column label="设施名称" align="center" prop="objName">
+                <template slot-scope="scope">
+                  <span>{{ scope.row.objName }}</span>
+                </template>
+              </el-table-column>
+              <el-table-column label="用电量(kW·h)" align="center" prop="elecQuantity">
+                <template slot-scope="scope">
+                  <span>{{ scope.row.elecQuantity }}</span>
+                </template>
+              </el-table-column>
+            </el-table>
+         <!--柱状图-->
+          <div class="container-block" style="margin-top: 20px;">
+            <BaseChart width="100%" height="300px" :option="barChartOptions"/>
+          </div>
+            <!--表格-->
             <el-table v-loading="loading" :data="hList">
               <el-table-column label="设施" align="center" prop="objName">
                 <template slot-scope="scope">
@@ -86,7 +118,8 @@
 </template>
 
 <script>
-import { listHSum } from '@/api/mgr/elecUseH'
+import * as echarts from 'echarts/core';
+import {listHSum, sumByFacsH, sumBySubCategoryH} from '@/api/mgr/elecUseH'
 import { getFacsCategorygetByCode } from '@/api/basecfg/emsfacs'
 import { areaWithFacsCategoryAsTree } from '@/api/basecfg/area'
 import { listAllFacs } from '@/api/basecfg/emsfacs'
@@ -121,12 +154,15 @@ export default {
       total: 0,
       // 用能计量-小时表格数据
       hList: [],
+      //查能耗
+      sumByFacsList:[],
       // 弹出层标题
       title: '',
       // 是否显示弹出层
       open: false,
       facsCategory: undefined,
       facsSubCategory: undefined,
+
       // 区域名称
       areaName: undefined,
       selectedLabel: '全部',
@@ -136,6 +172,12 @@ export default {
       },
       areaOptions: [],
       facsCategoryOptions: [],
+      sumBySubCategoryChartOption: {},
+      // 存储图表配置的变量
+      selectedTimeRange: 'day',
+      chartInstance: null,
+      // 用于存储 ECharts 实例
+      totalElecQuantity: 0,
       objOptions: [],
       objCode: undefined,
       dateRange: [dayjs().format(DateTool.DateFormat.YYYY_MM_DD_00_00_00), dayjs().format(DateTool.DateFormat.YYYY_MM_DD_23_59_59)],
@@ -202,6 +244,8 @@ export default {
     this.getFacsCategory(this.facsCategory)
     this.getAreaTree(this.facsCategory, this.facsSubCategory)
     this.getList()
+    this.getsumByFacsH()
+    this.getSumBySubCategoryH();
   },
   computed: {
     barChartOptions() {
@@ -244,12 +288,138 @@ export default {
     getList() {
       this.loading = true
       this.queryParams.objCode = this.objCode
-      listHSum(this.queryParams).then(response => {
-        this.hList = response.rows
-        this.total = response.total
-        this.loading = false
+        listHSum(this.queryParams).then(response => {
+          this.hList = response.rows
+          this.total = response.total
+          this.loading = false
+        })
+      this.getsumByFacsH()
+    },
+    /**根据设施查询能耗统计 */
+    getsumByFacsH(){
+      const params = {
+        startRecTime: dayjs(this.dateRange[0]).format('YYYY-MM-DD HH:mm:ss'),
+        endRecTime: dayjs(this.dateRange[1]).format('YYYY-MM-DD HH:mm:ss'),
+        areaCode: this.queryParams.areaCode,
+        facsSubCategory: this.activeName,
+        objCode:this.queryParams.objCode
+      };
+      sumByFacsH(params).then(response => {
+        this.sumByFacsList = response.data
+        console.log("能耗",this.sumByFacsList)
+
       })
     },
+
+    /**时间范围切换按钮点击事件处理器*/
+    changeTimeRange(rangeType) {
+      this.selectedTimeRange = rangeType;
+      let start = dayjs();
+      let end = dayjs();
+
+      if (rangeType === 'day') {
+        // 日:当前日期的 00:00:00 到 23:59:59
+        start = start.startOf('day');
+        end = end.endOf('day');
+      } else if (rangeType === 'month') {
+        // 月:当前月份的第一天 00:00:00 到 最后一天 23:59:59
+        start = start.date(1).hour(0).minute(0).second(0);
+        end = end.endOf('month').hour(23).minute(59).second(59);
+      } else if (rangeType === 'year') {
+        // 年:当前年份的第一天 00:00:00 到 最后一天 23:59:59
+        start = start.startOf('year');
+        end = end.endOf('year').hour(23).minute(59).second(59);
+      }
+      this.dateRange = [start.format('YYYY-MM-DD HH:mm:ss'), end.format('YYYY-MM-DD HH:mm:ss')];
+      this.getSumBySubCategoryH(); // 重新获取数据
+    },
+
+    /**总览饼图*/
+    getSumBySubCategoryH(){
+      const params = {
+        startRecTime: dayjs(this.dateRange[0]).format('YYYY-MM-DD HH:mm:ss'),
+        endRecTime: dayjs(this.dateRange[1]).format('YYYY-MM-DD HH:mm:ss'),
+        areaCode: this.queryParams.areaCode,
+      };
+      sumBySubCategoryH(params).then(response => {
+        this.processDataForChart(response.data); // 处理数据并生成图表配置
+        console.log("pie图",response.data)
+
+      })
+    },
+    processDataForChart(data) {
+      this.totalElecQuantity = data.reduce((sum, item) => sum + (item.elecQuantity || 0), 0);
+      // 处理数据,生成图表配置
+      const seriesData = data.map(item => ({
+        name: item.objName,
+        value: item.elecQuantity,
+        percent: ((item.elecQuantity || 0) / this.totalElecQuantity * 100).toFixed(2),
+        subentry: item.subentry.map(subItem => ({
+          name: subItem.objName,
+          value: subItem.elecQuantity
+        }))
+      }));
+
+      // 设置图表配置
+      this.sumBySubCategoryChartOption = {
+        title: {
+          text: '总览能耗',
+          left: 'center'
+        },
+        tooltip: {
+          trigger: 'item',
+          formatter: function (params) {
+            const { name, value, percent } = params;
+            const subentries = params.data.subentry;
+            let tooltipContent = `<div><h4>${name}</h4><p>${value} (${percent}%)</p><ul>`;
+            subentries.forEach(subItem => {
+              tooltipContent += `<li>${subItem.name}: ${subItem.value} kW·h</li>`;
+            });
+            tooltipContent += `</ul></div>`;
+            return tooltipContent;
+          }
+        },
+        legend: {
+          orient: 'vertical',
+          left: 'left',
+          data: data.map(item => item.objName)
+        },
+        series: [
+          {
+            name: '能耗',
+            type: 'pie',
+            radius: ['40%', '55%'],
+            data: seriesData,
+            emphasis: {
+              itemStyle: {
+                shadowBlur: 10,
+                shadowOffsetX: 0,
+                shadowColor: 'rgba(0, 0, 0, 0.5)',}
+            },
+            label: {
+              show: true,
+              position: 'outside',
+              formatter: '{b}\n{d}%',
+            },
+
+            labelLine: {
+              show: true,
+              length: 30, // 标签线长度
+              lineStyle: {
+                width: 1,
+                type: 'dashed', // 设置虚线样式
+              }
+            }
+          }
+        ]
+      };
+
+      // 渲染图表
+      this.$nextTick(() => {
+        const chart = echarts.init(this.$refs.sumBySubCategoryChart);
+        chart.setOption(this.sumBySubCategoryChartOption);
+      });
+  },
     async getFacsCategory(code) {
       getFacsCategorygetByCode(code).then(response => {
         this.facsCategoryOptions = response.data.subtypeList
@@ -293,6 +463,7 @@ export default {
     },
     handleObjSelectClick() {
       this.getFacsObj(this.queryParams.areaCode, this.facsCategory, this.activeName)
+      this.getsumByFacsH();
     },
     // 筛选节点
     filterNode(value, data) {
@@ -317,3 +488,22 @@ export default {
   }
 }
 </script>
+<style lang="css" scoped>
+
+.chart-container {
+  position: fixed;
+  top: 30px;
+  left: 20px;
+  width: 50%;
+  height: 350px;
+  z-index: 1000; /* 确保图表在其他内容之上 */
+}
+
+.is-active {
+  background-color: #409eff;
+  color: white;
+}
+</style>
+
+
+}