|
@@ -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>
|