Browse Source

+ 大屏荷接口对接

chen.cheng 1 month ago
parent
commit
5400529800

+ 8 - 0
ems-ui-cloud/src/api/prediction/forecastConsume.js

@@ -42,3 +42,11 @@ export function delForecastConsume(id) {
     method: 'delete'
   })
 }
+
+export function listForecastConsumeDateRange(query) {
+  return request({
+    url: '/ems/forecastConsume/cal/dateRange',
+    method: 'get',
+    params: query
+  })
+}

+ 2 - 0
ems-ui-cloud/src/main.js

@@ -37,6 +37,8 @@ import DictTag from '@/components/DictTag'
 import VueMeta from 'vue-meta'
 // 字典数据组件
 import DictData from '@/components/DictData'
+
+
 import bus from './bus'
 Vue.prototype.$EventBus = bus
 // 全局方法挂载

+ 44 - 7
ems-ui-cloud/src/views/largeScreen/soc/left.vue

@@ -47,8 +47,9 @@ import {dateFormat} from '@/utils';
 import * as echarts from 'echarts'
 import {mapState} from 'vuex';
 import {cntDevice} from "@/api/device/meterDevice";
-import {qryDeviceDay} from "@/api/device/elecMeterH";
+import {listByFacs} from "@/api/device/elecMeterH";
 import {DateTool} from "@/utils/DateTool";
+import {pgSupplyDayTotalPv} from "@/api/screen";
 
 export default {
   name: 'SocLeft',
@@ -215,6 +216,7 @@ export default {
     qryPageDatas() {
       this.getCntDevice()
       this.getDeviceElecMeter()
+      this.getPgSupplyDayTotalPv()
     },
     async getCntDevice() {
       const {data} = await cntDevice({
@@ -232,14 +234,49 @@ export default {
       }
     },
     async getDeviceElecMeter() {
-      const {data} = await qryDeviceDay({
+      const params = {
+        startRecTime: DateTool.now(DateTool.DateFormat.YYYY_MM_DD_00_00_00),
+        endRecTime: DateTool.now(DateTool.DateFormat.YYYY_MM_DD_23_59_59),
+        meterCls: 45,
+        areaCode: this.areaType || -1,
+        facsCategory: 'Z',
+      };
+      listByFacs(params).then(response => {
+        this.energyUse = response.data.map(item => ({
+          name: item.objName,
+          value: item.quantity || 0,
+        }));
+      })
+    },
+    async getPgSupplyDayTotalPv() {
+      const {data: pgPvHisSupply} = await pgSupplyDayTotalPv({
         areaCode: this.areaType,
-        startRecTime: DateTool.now()
+        date: DateTool.now(DateTool.DateFormat.YYYY_MM)
+      })
+      if (!pgPvHisSupply) {
+        return
+      }
+
+      const dateTips = DateTool.getDayOfRange(DateTool.now(`${DateTool.DateFormat.YYYY_MM}-01`), DateTool.now());
+      const dateIndexMap = {}
+      pgPvHisSupply.forEach(item => {
+        dateIndexMap[item.date] = item
+      })
+      const lineData = []
+      dateTips.forEach((item, index) => {
+        if (dateIndexMap[item]) {
+          lineData.push({
+            xData: item,
+            yData: dateIndexMap[item].useElecQuantity
+          })
+        } else {
+          lineData.push({
+            xData: item,
+            yData: 0
+          })
+        }
       })
-      this.energyUse = data.map(item => ({
-        name: item.deviceName,
-        value: item.elecQuantity.toFixed(1)
-      }))
+      this.lineData = lineData
     },
   }
 }

+ 37 - 116
ems-ui-cloud/src/views/largeScreen/soc/right.vue

@@ -41,10 +41,12 @@ import CusModule from '../components/CusModule.vue';
 import CusProgress from '../components/CusProgress.vue';
 import BaseChart from '@/components/BaseChart/index.vue'
 import * as echarts from 'echarts'
-import {dateFormat, numToStr} from '@/utils'
+import {array2Map, numToStr} from '@/utils'
 import {mapState} from 'vuex';
-import {qryElecMeterByDate, qryWaterMeterByDate} from "@/api/device/elecMeterH";
+import {listByFacs, qryElecMeterByDate, qryWaterMeterByDate} from "@/api/device/elecMeterH";
 import {DateTool} from "@/utils/DateTool";
+import _ from 'lodash'
+import {listForecastConsumeDateRange} from "@/api/prediction/forecastConsume";
 
 export default {
   name: 'SocRight',
@@ -68,33 +70,7 @@ export default {
           unit: "吨",
         },
       ],
-      ranking: [
-        {
-          name: "公共设施",
-          color: "#14c5f2",
-          value: 500,
-        },
-        {
-          name: "空调",
-          color: "#14c5f2",
-          value: 400,
-        },
-        {
-          name: "照明",
-          color: "#14c5f2",
-          value: 300,
-        },
-        {
-          name: "电梯",
-          color: "#14c5f2",
-          value: 100,
-        },
-        {
-          name: "其他",
-          color: "#14c5f2",
-          value: 100,
-        },
-      ],
+      ranking: [],
       lineData: []
 
     }
@@ -122,12 +98,6 @@ export default {
             }
           }
         },
-        legend: {
-          data: ["用电量", "当日最高负荷"],
-          textStyle: {
-            color: "#ffffff"
-          }
-        },
         xAxis: {
           data: this.lineData.map(item => item.xData),
           axisLine: {
@@ -150,16 +120,7 @@ export default {
               color: '#334E5E'
             }
           },
-        },
-          {
-            type: "value",
-            name: "kW",
-            position: "right",
-            splitLine: {
-              show: false
-            },
-          }
-        ],
+        }],
         series: [
           {
             name: "用电量",
@@ -184,61 +145,6 @@ export default {
             },
             data: this.lineData.map(item => item.yData1)
           },
-          {
-            name: "当日最高负荷",
-            type: "line",
-            yAxisIndex: 1, //使用的 y 轴的 index,在单个图表实例中存在多个 y轴的时候有用
-            smooth: true, //平滑曲线显示
-            itemStyle: {
-              color: "#F5D6AD",
-              borderColor: "#fff",
-              borderWidth: 3
-            },
-            lineStyle: {
-              color: "#F5D6AD"
-            },
-            areaStyle: {
-              color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
-                offset: 0,
-                color: "#A18C74"
-              },
-                {
-                  offset: 1,
-                  color: "transparent"
-                }
-              ])
-            },
-            markLine: {
-              symbol: 'none',
-              silent: true,
-              lineStyle: {normal: {type: 'dashed'}},
-              label: {position: 'start'},
-              data: [
-                {
-                  yAxis: 190,
-                  lineStyle: {width: 1.656, color: '#ff6367'},
-                  label: {show: false}
-                },
-              ]
-            },
-            markPoint: {
-              silent: true,
-              data: [
-                {
-                  yAxis: 190,
-                  x: '100%',
-                  symbolSize: 0.1,
-                  label: {
-                    textStyle: {color: '#F59A23'},
-                    fontSize: 12,
-                    position: 'left',
-                    formatter: '历史最高负荷'
-                  }
-                },
-              ]
-            },
-            data: this.lineData.map(item => item.yData2)
-          },
         ]
       }
     }
@@ -252,28 +158,43 @@ export default {
     this.getSocData()
   },
   methods: {
-    getDatesOfLastTenDays() {
-      var dates = [];
-      var today = new Date();
-      for (var i = 1; i < 11; i++) {
-        var pastDate = new Date(today);
-        pastDate.setDate(today.getDate() + i); // 减去i天
-        var formattedDate = dateFormat(pastDate, 'MM-dd');
-        dates.push(formattedDate);
-      }
-      return dates.map(item => ({
+    async getDeviceElecMeter() {
+      const params = {
+        startRecTime: DateTool.now(DateTool.DateFormat.YYYY_MM_DD_00_00_00),
+        endRecTime: DateTool.now(DateTool.DateFormat.YYYY_MM_DD_23_59_59),
+        meterCls: 45,
+        areaCode: this.areaType || -1,
+        facsCategory: 'Z',
+      };
+      listByFacs(params).then(response => {
+        const energyUse = response.data.map(item => ({
+          name: item.objName,
+          color: "#14c5f2",
+          value: item.quantity || 0,
+        }));
+        this.ranking = _.slice(_.orderBy(energyUse, ['value'], ['desc']), 0, 5);
+      })
+    },
+    async getDatesOfLastTenDays() {
+      const next7Day = DateTool.addDays(DateTool.now(), 7);
+      const {data} = await listForecastConsumeDateRange({
+        startTime: DateTool.now(DateTool.DateFormat.YYYY_MM_DD_00_00_00),
+        areaCode: this.areaType,
+        startRecTime: DateTool.now(),
+        endRecTime: next7Day,
+      })
+      const dates = DateTool.getDayOfRange(DateTool.now(), next7Day);
+      const mapIndex = array2Map(data, "date");
+
+      this.lineData = dates.map(item => ({
         xData: item,
-        yData1: parseFloat(((Math.random() * 100 + 200)).toFixed(1)),
-        yData2: parseFloat(((Math.random() * 100 + 100)).toFixed(1))
+        yData1: mapIndex[item] ? mapIndex[item].elecUseQuantity : 0
       }));
     },
     getSocData() {
       this.lineData = this.getDatesOfLastTenDays()
       this.getMeterElecWater()
-      this.ranking = this.ranking.map((item, index) => ({
-        ...item,
-        value: Math.floor(Math.random() * 100 + (index + 1) * 100)
-      })).reverse();
+      this.getDeviceElecMeter()
     },
     async getMeterElecWater() {
       const {data: elecMeter} = await qryElecMeterByDate(DateTool.now(), this.areaType)

+ 6 - 6
ems-ui-cloud/src/views/largeScreen/three/renderModel.js

@@ -133,12 +133,12 @@ class renderModel {
     this.controls.update();
     this.css3DRenderer.render(this.scene, this.camera);
     TWEEN.update();
-    // 检查模型位置是否发生变化
-    if (this.model) {
-      console.log('Model Position:', this.model.position);
-      console.log('Camera Position:', this.camera.position);
-      console.log('Controls Target:', this.controls.target);
-    }
+    // // 检查模型位置是否发生变化
+    // if (this.model) {
+    //   console.log('Model Position:', this.model.position);
+    //   console.log('Camera Position:', this.camera.position);
+    //   console.log('Controls Target:', this.controls.target);
+    // }
   }
   // 使用动画器不断更新场景
   sceneAnimation() {