chc 8 months ago
parent
commit
65bb63fa75

+ 187 - 18
src/views/currentSystem/dashboard/compts/electricRealData/index.vue

@@ -3,14 +3,14 @@
     <el-row class="box-top">
       <el-col :span="8">
         <div>
-          <div>{{ Math.round(Number(now)) }}</div>
+          <div>{{ Math.round(Number(nowValue)) }}</div>
           <div>(KWH)</div>
           <div>{{ nowWords }}实时用电量</div>
         </div>
       </el-col>
       <el-col :span="8">
         <div>
-          <div>{{ Math.round(Number(yesterday)) }}</div>
+          <div>{{ Math.round(Number(yesterdayValue)) }}</div>
           <div>(KWH)</div>
           <div>{{ yesWords }}同时段用电量</div>
         </div>
@@ -34,13 +34,17 @@
         </div>
       </el-col>
       <el-col :span="5" class="col-right">
-        <span>{{ Math.round(Number(leakage)) }}</span>
+        <span>{{ Math.round(Number(this.nowValue* 0.0035)) }}</span>
       </el-col>
     </el-row>
   </div>
 </template>
 
 <script>
+  import {
+  queryScadaDataweHistory,
+} from '@/api/yizhuan/scada'
+import moment from 'moment'
   export default {
     props: {
       waterElecData: {
@@ -51,68 +55,102 @@
       },
       dmy: {
         type: String
-      }
+      },
+      belongToCollege: {
+        type: String
+      },
     },
     data() {
       return {
-        now: null,
-        yesterday: null,
+        nowValue: null,
+        yesterdayValue: null,
         pecent: null,
         nowWords: '昨日',
         yesWords: '前日',
         nWords: '本日',
         huanbi: '环比',
-        leakage: null
+        leakage: null,
+        nowDay: '',
+        nowDayStart: '',
+        yesterday: '',
+        yesterdayStart: '',
+        nowDayLastYear: '',
+        nowDayStartLastYear: '',
+        yesterdayLastYear: '',
+        yesterdayStartLastYear: '',
+        nowMonthStart: '', //这月开始
+        lastMonth: '',
+        lastMonthStart: '',
+        nowMonthStartLastYear: '', //去年这月开始
+        lastMonthLastYear: '',
+        lastMonthStartLastYear: '', //
+        nowYearStart: '',
+        lastYear: '',
+        lastYearStart: '',
       }
     },
     watch: {
       waterElecData: {
         // immediate: true,
         handler(n, o) {
-          this.handleData()
+          if(this.dmy!='0'){
+            this.handleData()
+          }else{
+            this.getsearch()
+          }
         }
       },
       lastWaterElecData: {
         // immediate: true,
         handler(n, o) {
-          this.handleData()
+          if(this.dmy!='0'){
+            this.handleData()
+          }else{
+            this.getsearch()
+          }
         }
       },
       dmy: {
         // immediate: true,
         handler(n, o) {
           if (n == '1') {
-            this.now = ''
+            this.nowValue = 0
+            this.yestaryValue = 0
             this.nowWords = '当月'
             this.yesWords = '上月'
             this.nWords = '本月'
             this.huanbi = '环比'
             this.handleData()
           } else if (n == '2') {
-            this.now = ''
+            this.nowValue = 0
+            this.yestaryValue = 0
             this.nowWords = '当年'
             this.yesWords = '去年'
             this.nWords = '本年'
             this.huanbi = '同比'
             this.handleData()
           } else if (n == '0') {
-            this.now = ''
+            this.nowValue = 0
+            this.yestaryValue = 0
             this.nowWords = '昨日'
             this.yesWords = '前日'
             this.nWords = '昨日'
             this.huanbi = '环比'
-            this.handleData()
+            // this.handleData()
+            this.getsearch()
           }
         }
       }
     },
     mounted() {
+      this.getDate()
       this.handleData()
+      this.getsearch()
     },
     computed: {
       handleclc() {
-        if (this.now && this.yesterday) {
-          this.pecent = Math.round(((Number(this.now) - Number(this.yesterday)) / Number(this.yesterday)) * 100)
+        if (this.nowValue && this.yesterdayValue) {
+          this.pecent = Math.round(((Number(this.nowValue) - Number(this.yesterdayValue)) / Number(this.yesterdayValue)) * 100)
           return Math.abs(this.pecent)
         }
       },
@@ -132,11 +170,52 @@
       }
     },
     methods: {
+      getsearch(){
+        queryScadaDataweHistory({
+                belongToCollege: this.belongToCollege,
+                statisticsType: 1, //统计类型:0小时统计 1天统计 2月统计 3年统计
+                start: this.nowDayStart,
+                // 当前时间
+                end: this.nowDay,
+                // 水是2,电是7
+                allIndexType: '7',
+                // 不传name查分表,传'总表'查总表
+                name: '总表'
+              }).then((r) => {
+                if (r.code == 1) {
+                  // console.log(r,33)
+                  let sum=0
+                  r.result.forEach(e => {
+                    sum+=Number(e.diff)*1000/1000
+                  });
+                  this.nowValue=sum
+                }
+              })
+            queryScadaDataweHistory({
+                belongToCollege: this.belongToCollege,
+                statisticsType: 1, //统计类型:0小时统计 1天统计 2月统计 3年统计
+                start: this.yesterdayStart,
+                // 当前时间
+                end: this.yesterday,
+                // 水是2,电是7
+                allIndexType: '7',
+                // 不传name查分表,传'总表'查总表
+                name: '总表'
+              }).then((r) => {
+                if (r.code == 1) {
+                  let sum=0
+                  r.result.forEach(e => {
+                    sum+=Number(e.diff)*1000/1000
+                  });
+                  this.yesterdayValue=sum
+                }
+              })
+      },
       handleData() {
         if (this.waterElecData.length > 0) {
           this.waterElecData.forEach((i) => {
             if (i.type == '1') {
-              this.now = i.nowSum
+              this.nowValue = i.nowSum
               this.leakage = i.leakage
             }
           })
@@ -144,11 +223,101 @@
         if (this.lastWaterElecData.length > 0) {
           this.lastWaterElecData.forEach((i) => {
             if (i.type == '1') {
-              this.yesterday = i.nowSum
+              this.yesterdayValue = i.nowSum
             }
           })
         }
-      }
+      },
+        // 获取时间
+    getDate() {
+      this.nowDay = moment()
+        .subtract(1, 'days')
+        .endOf('days')
+        .format('YYYY-MM-DD HH:mm:ss') //当前时间 改成昨天的结束时间
+      this.nowDayStart = moment()
+        .subtract(1, 'days')
+        .startOf('days')
+        .format('YYYY-MM-DD HH:mm:ss') //今天开始时间 改成昨天开始的时间
+      this.yesterday = moment()
+        .subtract(2, 'days')
+        .endOf('days')
+        .format('YYYY-MM-DD HH:mm:ss') //昨天时间 改成前天结束的时间
+      this.yesterdayStart = moment()
+        .subtract(2, 'days')
+        .startOf('days')
+        .format('YYYY-MM-DD HH:mm:ss') //昨天开始时间 改成前天开始的时间
+      this.nowDayLastYear = moment()
+        .subtract(1, 'days')
+        .subtract(1, 'year')
+        .endOf('days')
+        .format('YYYY-MM-DD HH:mm:ss') //当前时间 改成昨天的结束时间
+      this.nowDayStartLastYear = moment()
+        .subtract(1, 'days')
+        .subtract(1, 'year')
+        .startOf('days')
+        .format('YYYY-MM-DD HH:mm:ss') //今天开始时间 改成昨天开始的时间
+      this.yesterdayLastYear = moment()
+        .subtract(2, 'days')
+        .subtract(1, 'year')
+        .endOf('days')
+        .format('YYYY-MM-DD HH:mm:ss') //昨天时间 改成前天结束的时间
+      this.yesterdayStartLastYear = moment()
+        .subtract(2, 'days')
+        .subtract(1, 'year')
+        .startOf('days')
+        .format('YYYY-MM-DD HH:mm:ss') //昨天开始时间 改成前天开始的时间
+      // 这个月的开始
+      this.nowMonthStart = moment()
+        .startOf('month')
+        .format('YYYY-MM-DD HH:mm:ss')
+      this.lastMonth = moment()
+        .subtract(1, 'month')
+        .subtract(1, 'days')
+        .endOf('days')
+        .format('YYYY-MM-DD HH:mm:ss') //上个月的时间 从上个月的昨天开始
+
+      // // 上个月的第一天
+      this.lastMonthStart = moment()
+        .month(moment().month() - 1)
+        .startOf('month')
+        .format('YYYY-MM-DD HH:mm:ss')
+        .valueOf()
+      // 这个月的开始
+      this.nowMonthStartLastYear = moment()
+        .subtract(1, 'year')
+        .startOf('month')
+        .format('YYYY-MM-DD HH:mm:ss')
+      this.lastMonthLastYear = moment()
+        .subtract(1, 'year')
+        .subtract(1, 'month')
+        .subtract(1, 'days')
+        .endOf('days')
+        .format('YYYY-MM-DD HH:mm:ss') //上个月的时间 从上个月的昨天开始
+
+      // // 上个月的第一天
+      this.lastMonthStartLastYear = moment()
+        .subtract(1, 'year')
+        .month(moment().month() - 1)
+        .startOf('month')
+        .format('YYYY-MM-DD HH:mm:ss')
+        .valueOf()
+      // 当年的第一天
+      this.nowYearStart = moment()
+        .startOf('year')
+        .format('YYYY-MM-DD HH:mm:ss')
+      this.lastYear = moment()
+        .subtract(1, 'year')
+        .format('YYYY-MM-DD HH:mm:ss') //昨年的时间
+      // // 上个月最后一天
+      // const endDate = moment().month(moment().month() - 1).endOf('month').format('YYYY-MM-DD HH:mm:ss').valueOf();
+      //   // 昨年的第一天
+      this.lastYearStart = moment()
+        .year(moment().year() - 1)
+        .startOf('year')
+        .format('YYYY-MM-DD HH:mm:ss')
+        .valueOf()
+      // console.log(moment().year(moment().year() - 1).endOf('year').format('YYYY-MM-DD HH:mm:ss').valueOf());
+    }
     }
   }
 </script>

+ 2 - 1
src/views/currentSystem/dashboard/compts/infoBoard/index.vue

@@ -87,7 +87,7 @@ export default {
             this.area += Number(i.area)
             this.population += Number(i.personCount)
           })
-          // console.log(this.population,this.area );
+          console.log(this.population,this.area,29929 );
         }
       })
     },
@@ -100,6 +100,7 @@ export default {
           this.nowElec = Number(i.nowSum) 
         }
       })
+      console.log(this.waterElecData,7272)
      }
 
     }

+ 193 - 18
src/views/currentSystem/dashboard/compts/waterRealData/index.vue

@@ -3,14 +3,14 @@
     <el-row class="box-top">
       <el-col :span="8">
         <div>
-          <div>{{ Math.round(Number(now)) }}</div>
+          <div>{{ Math.round(Number(nowValue)) }}</div>
           <div>(m³)</div>
           <div>{{ nowWords }}实时用水量</div>
         </div>
       </el-col>
       <el-col :span="8">
         <div>
-          <div>{{ Math.round(Number(yesterday)) }}</div>
+          <div>{{ Math.round(Number(yesterdayValue)) }}</div>
           <div>(m³)</div>
           <div>{{ yesWords }}同时段用水量</div>
         </div>
@@ -42,6 +42,11 @@
 
 <script>
   import { getLeakRate } from '@/api/yizhuan/scada'
+  import {
+  queryScadaDataweHistory,
+} from '@/api/yizhuan/scada'
+import moment from 'moment'
+  
   export default {
     props: {
       waterElecData: {
@@ -52,12 +57,15 @@
       },
       dmy: {
         type: String
-      }
+      },
+      belongToCollege: {
+        type: String
+      },
     },
     data() {
       return {
-        now: null,
-        yesterday: null,
+        nowValue: 0,
+        yesterdayValue: 0,
         pecent: null,
         nowWords: '昨日',
         yesWords: '前日',
@@ -66,59 +74,95 @@
         leakage: null,
         yesterdayLeakRate: 0,
         monthLeakRate: 0,
-        yearLeakRate: 0
+        yearLeakRate: 0,
+        nowDay: '',
+        nowDayStart: '',
+        yesterday: '',
+        yesterdayStart: '',
+        nowDayLastYear: '',
+        nowDayStartLastYear: '',
+        yesterdayLastYear: '',
+        yesterdayStartLastYear: '',
+        nowMonthStart: '', //这月开始
+        lastMonth: '',
+        lastMonthStart: '',
+        nowMonthStartLastYear: '', //去年这月开始
+        lastMonthLastYear: '',
+        lastMonthStartLastYear: '', //
+        nowYearStart: '',
+        lastYear: '',
+        lastYearStart: '',
       }
     },
     watch: {
       waterElecData: {
         handler(n, o) {
-          this.handleData()
+          if(this.dmy!='0'){
+            this.handleData()
+          }else{
+            this.getsearch()
+          }
+          
           // console.log(this.now);
         }
       },
       lastWaterElecData: {
         handler(n, o) {
-          this.handleData()
+          if(this.dmy!='0'){
+            this.handleData()
+          }else{
+            this.getsearch()
+          }
         }
       },
       dmy: {
         handler(n, o) {
           if (n == '1') {
             this.leakage = this.monthLeakRate
-            this.now = ''
+            this.nowValue = 0
+            this.yestaryValue = 0
             this.nowWords = '当月'
             this.yesWords = '上月'
             this.nWords = '本月'
             this.huanbi = '环比'
             this.handleData()
+          
           } else if (n == '2') {
             this.leakage = this.yearLeakRate
-            this.now = ''
+            this.nowValue = 0
+            this.yestaryValue = 0
             this.nowWords = '当年'
             this.yesWords = '去年'
             this.nWords = '本年'
             this.huanbi = '同比'
             this.handleData()
+            
           } else if (n == '0') {
             this.leakage = this.yesterdayLeakRate
-            this.now = ''
+            this.nowValue = 0
+            this.yestaryValue = 0
             this.nowWords = '昨日'
             this.yesWords = '前日'
             this.nWords = '昨日'
             this.huanbi = '环比'
-            this.handleData()
+            // this.handleData()
+            this.getsearch()
           }
         }
       }
     },
     mounted() {
-      this.handleData()
+      this.getDate()
+      // this.handleData()
       this.getLeakRate()
+      this.getsearch()
+     
     },
     computed: {
+      
       handleclc() {
-        if (this.now && this.yesterday) {
-          this.pecent = Math.round(((Number(this.now) - Number(this.yesterday)) / Number(this.yesterday)) * 100)
+        if (this.nowValue && this.yesterdayValue) {
+          this.pecent = Math.round(((Number(this.nowValue) - Number(this.yesterdayValue)) / Number(this.yesterdayValue)) * 100)
           return Math.abs(this.pecent)
         }
       },
@@ -138,6 +182,47 @@
       }
     },
     methods: {
+      getsearch(){
+        queryScadaDataweHistory({
+                belongToCollege: this.belongToCollege,
+                statisticsType: 1, //统计类型:0小时统计 1天统计 2月统计 3年统计
+                start: this.nowDayStart,
+                // 当前时间
+                end: this.nowDay,
+                // 水是2,电是7
+                allIndexType: '2',
+                // 不传name查分表,传'总表'查总表
+                name: '总表'
+              }).then((r) => {
+                if (r.code == 1) {
+                  // console.log(r,33)
+                  let sum=0
+                  r.result.forEach(e => {
+                    sum+=Number(e.diff)*1000
+                  });
+                  this.nowValue=sum/1000
+                }
+              })
+            queryScadaDataweHistory({
+                belongToCollege: this.belongToCollege,
+                statisticsType: 1, //统计类型:0小时统计 1天统计 2月统计 3年统计
+                start: this.yesterdayStart,
+                // 当前时间
+                end: this.yesterday,
+                // 水是2,电是7
+                allIndexType: '2',
+                // 不传name查分表,传'总表'查总表
+                name: '总表'
+              }).then((r) => {
+                if (r.code == 1) {
+                  let sum=0
+                  r.result.forEach(e => {
+                    sum+=Number(e.diff)*1000
+                  });
+                  this.yesterdayValue=sum/1000
+                }
+              })
+      },
       getLeakRate() {
         getLeakRate().then((res) => {
           if (res.code == 1) {
@@ -152,18 +237,108 @@
         if (this.waterElecData.length > 0) {
           this.waterElecData.forEach((i) => {
             if (i.type == '0') {
-              this.now = i.nowSum
+              this.nowValue = i.nowSum
             }
           })
         }
         if (this.lastWaterElecData.length > 0) {
           this.lastWaterElecData.forEach((i) => {
             if (i.type == '0') {
-              this.yesterday = i.nowSum
+              this.yesterdayValue = i.nowSum
             }
           })
         }
-      }
+      },
+       // 获取时间
+    getDate() {
+      this.nowDay = moment()
+        .subtract(1, 'days')
+        .endOf('days')
+        .format('YYYY-MM-DD HH:mm:ss') //当前时间 改成昨天的结束时间
+      this.nowDayStart = moment()
+        .subtract(1, 'days')
+        .startOf('days')
+        .format('YYYY-MM-DD HH:mm:ss') //今天开始时间 改成昨天开始的时间
+      this.yesterday = moment()
+        .subtract(2, 'days')
+        .endOf('days')
+        .format('YYYY-MM-DD HH:mm:ss') //昨天时间 改成前天结束的时间
+      this.yesterdayStart = moment()
+        .subtract(2, 'days')
+        .startOf('days')
+        .format('YYYY-MM-DD HH:mm:ss') //昨天开始时间 改成前天开始的时间
+      this.nowDayLastYear = moment()
+        .subtract(1, 'days')
+        .subtract(1, 'year')
+        .endOf('days')
+        .format('YYYY-MM-DD HH:mm:ss') //当前时间 改成昨天的结束时间
+      this.nowDayStartLastYear = moment()
+        .subtract(1, 'days')
+        .subtract(1, 'year')
+        .startOf('days')
+        .format('YYYY-MM-DD HH:mm:ss') //今天开始时间 改成昨天开始的时间
+      this.yesterdayLastYear = moment()
+        .subtract(2, 'days')
+        .subtract(1, 'year')
+        .endOf('days')
+        .format('YYYY-MM-DD HH:mm:ss') //昨天时间 改成前天结束的时间
+      this.yesterdayStartLastYear = moment()
+        .subtract(2, 'days')
+        .subtract(1, 'year')
+        .startOf('days')
+        .format('YYYY-MM-DD HH:mm:ss') //昨天开始时间 改成前天开始的时间
+      // 这个月的开始
+      this.nowMonthStart = moment()
+        .startOf('month')
+        .format('YYYY-MM-DD HH:mm:ss')
+      this.lastMonth = moment()
+        .subtract(1, 'month')
+        .subtract(1, 'days')
+        .endOf('days')
+        .format('YYYY-MM-DD HH:mm:ss') //上个月的时间 从上个月的昨天开始
+
+      // // 上个月的第一天
+      this.lastMonthStart = moment()
+        .month(moment().month() - 1)
+        .startOf('month')
+        .format('YYYY-MM-DD HH:mm:ss')
+        .valueOf()
+      // 这个月的开始
+      this.nowMonthStartLastYear = moment()
+        .subtract(1, 'year')
+        .startOf('month')
+        .format('YYYY-MM-DD HH:mm:ss')
+      this.lastMonthLastYear = moment()
+        .subtract(1, 'year')
+        .subtract(1, 'month')
+        .subtract(1, 'days')
+        .endOf('days')
+        .format('YYYY-MM-DD HH:mm:ss') //上个月的时间 从上个月的昨天开始
+
+      // // 上个月的第一天
+      this.lastMonthStartLastYear = moment()
+        .subtract(1, 'year')
+        .month(moment().month() - 1)
+        .startOf('month')
+        .format('YYYY-MM-DD HH:mm:ss')
+        .valueOf()
+      // 当年的第一天
+      this.nowYearStart = moment()
+        .startOf('year')
+        .format('YYYY-MM-DD HH:mm:ss')
+      this.lastYear = moment()
+        .subtract(1, 'year')
+        .format('YYYY-MM-DD HH:mm:ss') //昨年的时间
+      // // 上个月最后一天
+      // const endDate = moment().month(moment().month() - 1).endOf('month').format('YYYY-MM-DD HH:mm:ss').valueOf();
+      //   // 昨年的第一天
+      this.lastYearStart = moment()
+        .year(moment().year() - 1)
+        .startOf('year')
+        .format('YYYY-MM-DD HH:mm:ss')
+        .valueOf()
+      // console.log(moment().year(moment().year() - 1).endOf('year').format('YYYY-MM-DD HH:mm:ss').valueOf());
+    }
     }
   }
 </script>

+ 5 - 2
src/views/currentSystem/dashboard/index.vue

@@ -9,6 +9,7 @@
                 :waterElecData="waterElecData"
                 :lastWaterElecData="lastWaterElecData"
                 :dmy="dmy"
+                :belongToCollege="this.belongToCollege"
               ></electricRealData>
             </template>
           </card>
@@ -35,7 +36,7 @@
         <div class="box-item right1">
           <card :icon="'el-icon-office-building'" :cardTitle="'实时用水量'">
             <template slot="body">
-              <waterRealData :waterElecData="waterElecData" :lastWaterElecData="lastWaterElecData" :dmy="dmy">
+              <waterRealData :waterElecData="waterElecData" :lastWaterElecData="lastWaterElecData" :dmy="dmy" :belongToCollege="this.belongToCollege">
               </waterRealData>
             </template>
           </card>
@@ -166,7 +167,9 @@ export default {
       elecpie: [],
       waterpie: [],
       code: [],
-      newTime: ''
+      newTime: '',
+      start:'',
+      end:''
     }
   },
   computed: {},

+ 13 - 7
src/views/yizhuan/realtimeMonitor/index.vue

@@ -19,6 +19,7 @@
               default-expand-all
               node-key="id"
               :props="defaultProps"
+              :expand-on-click-node="false"
               ref="tree"
               @node-click="handleNodeClick"
               v-if="deviceType=='0'"
@@ -27,6 +28,7 @@
               :highlight-current="true"
               :data="elecTree"
               :filter-node-method="filterNode"
+              :expand-on-click-node="false"
               default-expand-all
               node-key="id"
               :props="defaultProps"
@@ -37,7 +39,7 @@
           </div>
         </div>
       </div>
-      <div class="right">
+      <div class="right" v-loading="loading">
         <div class="device-bar">
           <span style="font-size: 14px; color: #333333; font-family: SourceHanSansCN-Regular; font-weight: normal"
             >设备类型:</span
@@ -150,6 +152,7 @@
     },
     data() {
       return {
+        loading:false,
         select: 1,
         // 数据源
         originData: [],
@@ -381,6 +384,7 @@
       },
       // 查询所有实时设备信息
       queryScadaData() {
+        this.loading=true
         queryScadaData({
           'orders[0].asc': false,
           'orders[0].column': 'create_Time',
@@ -414,13 +418,13 @@
         this.report = 0
         let arr1 = []
         this.originData.forEach((i) => {
-          if(this.deviceType){
+          if(this.belongLineId){
             // 根据支路查询
-          if (i.deviceType == this.deviceType) {
-          if (i.belongLineId == this.belongLineId) {
-            arr1.push(i)
-          }
-        }
+              if (i.deviceType == this.deviceType) {
+              if (i.belongLineId == this.belongLineId) {
+                arr1.push(i)
+              }
+            }
           }else{
             //根据设备类型
           if (i.deviceType == this.deviceType) {
@@ -474,6 +478,7 @@
           this.currentList = offlineList.slice(this.size * (this.page - 1), this.size * this.page)
           this.total = offlineList.length
         }
+        this.loading=false
       },
       handleSelect(e) {
         this.select = e
@@ -550,6 +555,7 @@
         height: 100%;
         background: #f8f8f8;
         overflow-y: auto;
+        overflow-x: auto;
         &::-webkit-scrollbar {
           width: 4px;
           background: white;