fix:全厂能源电量消耗报表

This commit is contained in:
shijing 2024-05-08 14:08:18 +08:00
parent 4b52570a4d
commit 054829996e
3 changed files with 626 additions and 709 deletions

View File

@ -136,43 +136,13 @@ export default {
return {
year: "",
month: "",
days: "",
myChart: null,
search_date: "",
headerLength: 33,
itemVisible: false,
xAxisData: [],
tableDatas: [
["石灰石破碎", "破碎机", "kw.h"], //0
["石灰石破碎", "堆取料机", "kw.h"],
["石灰石破碎", "低压变压器柜", "kw.h"],
["石灰石破碎", "石灰石破碎合计", "kw.h"],
["原料磨", "循环风机", "kw.h"],
["原料磨", "辊压机", "kw.h"],
["原料磨", "调配变压器", "kw.h"],
["原料磨", "低压变压器柜器", "kw.h"],
["原料磨", "原料磨系统合计", "kw.h"],
["回转窑", "尾排风机", "kw.h"],
["回转窑", "高温风机", "kw.h"],
["回转窑", "头排风机", "kw.h"],
["回转窑", "低压变压器柜", "kw.h"],
["回转窑", "回转窑烧成系统合计", "kw.h"],
["煤磨", "煤磨主电机", "kw.h"],
["煤磨", "煤磨排风机", "kw.h"],
["煤磨", "低压变压器柜", "kw.h"],
["煤磨", "煤磨系统合计", "kw.h"],
["余热发电", "余热发电量", "kw.h"],
["余热发电", "余热发电自用电量", "kw.h"],
["余热发电", "余热供电量", "kw.h"],
["空压机", "1#空压机", "kw.h"],
["空压机", "2#空压机", "kw.h"],
["空压机", "3#空压机", "kw.h"],
["空压机", "4#空压机", "kw.h"],
["空压机", "空压机合计", "kw.h"],
["富氧燃烧系统", "富氧燃烧耗电设备", "kw.h"],
["生产总耗电量", "生产部分总耗电", "kw.h"],
["全厂进线", "全厂耗电量", "kw.h"],
],
mpointList: [],
tableDatas: [],
timeStamp: null,
tableWidth: "3300",
itemChartTitle: "",
@ -275,26 +245,20 @@ export default {
mounted() {
let that = this;
var nowDate = new Date();
that.year = nowDate.getFullYear();
that.month = nowDate.getMonth() + 1;
that.days = new Date(that.year, that.month, 0).getDate();
let year = nowDate.getFullYear();
let month = nowDate.getMonth() + 1;
month = month > 9 ? month : "0" + month;
that.search_date = year + "-" + month;
that.year = year;
that.month = month;
that.days = new Date(year, month, 0).getDate();
that.timeStamp = nowDate.getTime();
let month0 = that.month > 9 ? that.month : "0" + that.month;
that.search_date = that.year + "-" + month0;
that.headerLength = that.days + 4;
that.tableWidth = that.headerLength * 100 + "";
let tableDatas = that.tableDatas;
for (let i = 0; i < tableDatas.length; i++) {
for (let j = 0; j < that.days; j++) {
let k = 3 + j;
that.tableDatas[i][k] = 0;
this.$forceUpdate();
}
}
for (let n = 1; n <= that.days; n++) {
that.xAxisData.push(n + "日");
}
this.getData();
this.getMPoints();
},
methods: {
dateChange(e) {
@ -302,215 +266,263 @@ export default {
let arr = e.split("-");
that.year = Number(arr[0]);
that.month = Number(arr[1]);
for (let i = 0; i < that.tableDatas.length; i++) {
for (let j = 0; j < that.days + 1; j++) {
let k = 3 + j;
that.tableDatas[i][k] = 0;
this.$forceUpdate();
}
}
let nowDate = new Date();
that.timeStamp = nowDate.getTime();
this.getData();
this.dataLoop();
},
getData() {
getMPoints() {
let that = this;
function dataPush(name) {
let index = 0;
if (name == "破碎机") {
index = 0;
} else if (name == "堆取料机") {
index = 1;
} else if (name == "低压变压器柜") {
index = 2;
} else if (name == "循环风机") {
index = 4;
} else if (name == "调配变压器") {
index = 6;
} else if (name == "低压变压器柜器") {
index = 7;
} else if (name == "尾排风机") {
index = 9;
} else if (name == "高温风机") {
index = 10;
} else if (name == "头排风机") {
index = 11;
} else if (name == "煤磨主电机") {
index = 14;
} else if (name == "煤磨排风机") {
index = 15;
} else if (name == "低压变压器柜") {
index = 16;
} else if (name == "余热发电量") {
index = 18;
} else if (name == "余热发电自用电量") {
index = 19;
} else if (name == "1#空压机") {
index = 21;
} else if (name == "2#空压机") {
index = 22;
} else if (name == "3#空压机") {
index = 23;
} else if (name == "4#空压机") {
index = 24;
} else if (name == "富氧燃烧耗电设备") {
index = 26;
}
return index;
}
function sumNum(a, b, c, d) {
let sum = 0;
if (typeof a !== "undefined" && a !== "NaN") {
sum = sum + Number(a);
}
if (typeof b !== "undefined" && a !== "NaN") {
sum = sum + Number(b);
}
if (typeof c !== "undefined" && a !== "NaN") {
sum = sum + Number(c);
}
if (typeof d !== "undefined" && a !== "NaN") {
sum = sum + Number(d);
}
return sum;
}
let obj = {};
obj.type = "day_s";
obj.year_s = that.year;
obj.month_s = that.month;
obj.page = 0;
obj.mpoint__ep_monitored__power_kw__gte = 100;
this.$API.enm.mpoint.stat
.req(obj)
.then((res) => {
let wrapArr = [],
innerArr = [];
res.forEach((item) => {
let day = item.day_s;
if (wrapArr[day]) {
wrapArr[day].push(item);
} else {
wrapArr[day] = [];
wrapArr[day].push(item);
}
});
wrapArr.forEach((inner, inde) => {
inner.forEach((item) => {
let i = dataPush(item.mpoint_name);
let k = 0;
if (
i == 0 ||
i == 4 ||
i == 9 ||
i == 14 ||
i == 18 ||
i == 21 ||
i == 26 ||
i == 27 ||
i == 28
) {
k = 3 + inde;
} else {
k = 2 + inde;
}
that.tableDatas[i][k] = item.val;
});
});
for (let k = 0; k < that.headerLength; k++) {
let m = k + 3;
let n = k + 1;
//
that.tableDatas[3][m] = sumNum(
that.tableDatas[0][m],
that.tableDatas[1][m],
that.tableDatas[2][m]
);
//
// that.tableDatas[5][m] = sumNum();
//
that.tableDatas[8][m] =
sumNum(
that.tableDatas[4][m],
// that.tableDatas[5][m],
that.tableDatas[6][m],
that.tableDatas[7][m]
) -
sumNum(
that.tableDatas[1][m],
that.tableDatas[2][m]
);
//
// that.tableDatas[12][m] = sumNum(
// that.tableDatas[9][m],
// that.tableDatas[10][m],
// that.tableDatas[11][m]
// );
//
that.tableDatas[13][m] =
typeof that.tableDatas[12][m] !== "undefined"
? sumNum(
that.tableDatas[9][m],
that.tableDatas[10][m],
that.tableDatas[11][m],
that.tableDatas[12][m]
)
: sumNum(
that.tableDatas[9][m],
that.tableDatas[10][m],
that.tableDatas[11][m]
);
//
let sum17 = sumNum(
that.tableDatas[14][m],
that.tableDatas[15][m],
that.tableDatas[16][m]
);
that.tableDatas[17][m] =
typeof that.tableDatas[21][m] !== "undefined"
? sum17 - that.tableDatas[21][m]
: sum17;
//
that.tableDatas[20][m] =
typeof that.tableDatas[19][m] !== "undefined"
? that.tableDatas[18][m] -
that.tableDatas[19][m]
: that.tableDatas[18][m];
//
that.tableDatas[25][m] = sumNum(
that.tableDatas[21][m],
that.tableDatas[22][m],
that.tableDatas[23][m],
that.tableDatas[24][m]
);
//
that.tableDatas[27][m] = sumNum(
that.tableDatas[3][m],
that.tableDatas[8][m],
that.tableDatas[13][m],
that.tableDatas[17][m],
that.tableDatas[18][m],
that.tableDatas[25][m],
that.tableDatas[26][m]
);
//
// that.tableDatas[28][m] = sumNum(
// that.tableDatas[27][m],
// that.tableDatas[26][m]
// );
}
that.tableDatas.forEach((inner, inde) => {
let sumlast = 0;
inner.forEach((num, ind) => {
if (ind > 2 && ind < that.headerLength) {
sumlast = sumlast + Number(num);
}
});
inner[that.headerLength] = sumlast;
});
that.$API.enm.mpoint.list
.req({
page: 0,
enabled: true,
need_display: true,
ordering: "report_sortstr",
mpoint__material__code: "elec",
})
.then(() => {});
.then((res) => {
let data = res.slice(3);
that.mpointList = data;
that.dataLoop();
});
},
dataLoop() {
let that = this;
that.tableDatas = [];
that.mpointList.forEach((item, index) => {
let arr = [];
arr[0] =
item.mgroup_name != null
? item.mgroup_name
: item.nickname != null
? item.nickname
: item.name;
arr[1] = item.nickname != null ? item.nickname : item.name;
arr[2] = item.unit;
for (let i = 0; i < that.days; i++) {
arr[i + 3] = 0;
}
that.tableDatas.push(arr);
that.getData(item.id, index);
});
},
getData(id, index) {
let that = this;
let obj = {};
obj.type = "day";
obj.year = that.year;
obj.month = that.month;
obj.mpoint__material__code = "elec";
obj.mpoint__need_display = 1;
obj.mpoint = id;
obj.page = 0;
this.$API.enm.mpoint.stat.req(obj).then((res) => {
console.log(res);
res.forEach((item) => {
let ind = item.day + 2;
that.tableDatas[index][ind] = item.val;
});
that.$forceUpdate();
});
},
// getData() {
// let that = this;
// function dataPush(name) {
// let index = 0;
// if (name == "") {
// index = 0;
// } else if (name == "") {
// index = 1;
// } else if (name == "") {
// index = 2;
// } else if (name == "") {
// index = 4;
// } else if (name == "") {
// index = 6;
// } else if (name == "") {
// index = 7;
// } else if (name == "") {
// index = 9;
// } else if (name == "") {
// index = 10;
// } else if (name == "") {
// index = 11;
// } else if (name == "") {
// index = 14;
// } else if (name == "") {
// index = 15;
// } else if (name == "") {
// index = 16;
// } else if (name == "") {
// index = 18;
// } else if (name == "") {
// index = 19;
// } else if (name == "1#") {
// index = 21;
// } else if (name == "2#") {
// index = 22;
// } else if (name == "3#") {
// index = 23;
// } else if (name == "4#") {
// index = 24;
// } else if (name == "") {
// index = 26;
// }
// return index;
// }
// function sumNum(a, b, c, d) {
// let sum = 0;
// if (typeof a !== "undefined" && a !== "NaN") {
// sum = sum + Number(a);
// }
// if (typeof b !== "undefined" && a !== "NaN") {
// sum = sum + Number(b);
// }
// if (typeof c !== "undefined" && a !== "NaN") {
// sum = sum + Number(c);
// }
// if (typeof d !== "undefined" && a !== "NaN") {
// sum = sum + Number(d);
// }
// return sum;
// }
// let obj = {};
// obj.type = "day_s";
// obj.year_s = that.year;
// obj.month_s = that.month;
// obj.page = 0;
// obj.mpoint__ep_monitored__power_kw__gte = 100;
// this.$API.enm.mpoint.stat
// .req(obj)
// .then((res) => {
// let wrapArr = [],
// innerArr = [];
// res.forEach((item) => {
// let day = item.day_s;
// if (wrapArr[day]) {
// wrapArr[day].push(item);
// } else {
// wrapArr[day] = [];
// wrapArr[day].push(item);
// }
// });
// wrapArr.forEach((inner, inde) => {
// inner.forEach((item) => {
// let i = dataPush(item.mpoint_name);
// let k = 0;
// if (
// i == 0 ||
// i == 4 ||
// i == 9 ||
// i == 14 ||
// i == 18 ||
// i == 21 ||
// i == 26 ||
// i == 27 ||
// i == 28
// ) {
// k = 3 + inde;
// } else {
// k = 2 + inde;
// }
// that.tableDatas[i][k] = item.val;
// });
// });
// for (let k = 0; k < that.headerLength; k++) {
// let m = k + 3;
// let n = k + 1;
// //
// that.tableDatas[3][m] = sumNum(
// that.tableDatas[0][m],
// that.tableDatas[1][m],
// that.tableDatas[2][m]
// );
// //
// // that.tableDatas[5][m] = sumNum();
// //
// that.tableDatas[8][m] =
// sumNum(
// that.tableDatas[4][m],
// // that.tableDatas[5][m],
// that.tableDatas[6][m],
// that.tableDatas[7][m]
// ) -
// sumNum(
// that.tableDatas[1][m],
// that.tableDatas[2][m]
// );
// //
// // that.tableDatas[12][m] = sumNum(
// // that.tableDatas[9][m],
// // that.tableDatas[10][m],
// // that.tableDatas[11][m]
// // );
// //
// that.tableDatas[13][m] =
// typeof that.tableDatas[12][m] !== "undefined"
// ? sumNum(
// that.tableDatas[9][m],
// that.tableDatas[10][m],
// that.tableDatas[11][m],
// that.tableDatas[12][m]
// )
// : sumNum(
// that.tableDatas[9][m],
// that.tableDatas[10][m],
// that.tableDatas[11][m]
// );
// //
// let sum17 = sumNum(
// that.tableDatas[14][m],
// that.tableDatas[15][m],
// that.tableDatas[16][m]
// );
// that.tableDatas[17][m] =
// typeof that.tableDatas[21][m] !== "undefined"
// ? sum17 - that.tableDatas[21][m]
// : sum17;
// //
// that.tableDatas[20][m] =
// typeof that.tableDatas[19][m] !== "undefined"
// ? that.tableDatas[18][m] -
// that.tableDatas[19][m]
// : that.tableDatas[18][m];
// //
// that.tableDatas[25][m] = sumNum(
// that.tableDatas[21][m],
// that.tableDatas[22][m],
// that.tableDatas[23][m],
// that.tableDatas[24][m]
// );
// //
// that.tableDatas[27][m] = sumNum(
// that.tableDatas[3][m],
// that.tableDatas[8][m],
// that.tableDatas[13][m],
// that.tableDatas[17][m],
// that.tableDatas[18][m],
// that.tableDatas[25][m],
// that.tableDatas[26][m]
// );
// //
// // that.tableDatas[28][m] = sumNum(
// // that.tableDatas[27][m],
// // that.tableDatas[26][m]
// // );
// }
// that.tableDatas.forEach((inner, inde) => {
// let sumlast = 0;
// inner.forEach((num, ind) => {
// if (ind > 2 && ind < that.headerLength) {
// sumlast = sumlast + Number(num);
// }
// });
// inner[that.headerLength] = sumlast;
// });
// })
// .then(() => {});
// },
itemClick(item, index) {
let that = this;
let lineData = that.tableDatas[index].slice(3, that.headerLength);

View File

@ -46,7 +46,7 @@
<th>设备</th>
<th>单位</th>
<th v-for="item in 24" :key="item">
{{ item }}
{{ item - 1 }}
</th>
<th>本日合计</th>
</tr>
@ -135,11 +135,11 @@ export default {
},
data() {
return {
day: "",
year: "",
month: "",
day: "",
search_date: "",
tableDatas: [
tableDatas1: [
["石灰石破碎", "破碎机", "kw.h"], //0
["石灰石破碎", "堆取料机", "kw.h"],
["石灰石破碎", "低压变压器柜", "kw.h"],
@ -170,10 +170,30 @@ export default {
["生产总耗电量", "生产部分总耗电", "kw.h"],
["全厂进线", "全厂耗电量", "kw.h"],
],
mpointList: [],
tableDatas: [],
hours: [
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
19, 20, 21, 22, 23, 24,
],
mgroupList: [
"石灰石破碎",
"原料磨",
"回转窑",
"煤磨",
"余热发电",
"空压机",
"富氧燃烧系统",
"生产总耗电量",
"全厂进线",
],
mgroup: "石灰石破碎",
itemChartTitle: "",
itemChartData: [],
itemChartXData: [],
itemChartYData: [],
itemChartLegend: [],
itemChartSeries: [],
timeStamp: null,
itemVisible: false,
exportLoading: false,
@ -269,12 +289,16 @@ export default {
mounted() {
let that = this;
var nowDate = new Date();
that.year = nowDate.getFullYear();
that.month = nowDate.getMonth() + 1;
that.day = nowDate.getDate();
let year = nowDate.getFullYear();
let month = nowDate.getMonth() + 1;
let day = nowDate.getDate();
that.timeStamp = nowDate.getTime();
let month0 = that.month > 9 ? that.month : "0" + that.month;
that.search_date = that.year + "-" + month0 + "-" + that.day;
month = month > 9 ? month : "0" + month;
day = day > 9 ? day : "0" + day;
that.day = day;
that.year = year;
that.month = month;
that.search_date = year + "-" + month + "-" + day;
for (let i = 0; i < that.tableDatas.length; i++) {
for (let j = 0; j < 24; j++) {
let k = 3 + j;
@ -285,224 +309,292 @@ export default {
for (let n = 0; n < 24; n++) {
that.xAxisData.push(n + "时");
}
this.getData();
this.getMPoints();
},
methods: {
dateChange(e) {
let that = this;
let arr = e.split("-");
that.tableDatas = [];
let arr = that.search_date.split("-");
that.year = Number(arr[0]);
that.month = Number(arr[1]);
that.day = Number(arr[2]);
for (let i = 0; i < that.tableDatas.length; i++) {
for (let j = 0; j < 25; j++) {
let k = 3 + j;
that.tableDatas[i][k] = 0;
this.$forceUpdate();
}
}
// for (let i = 0; i < that.tableDatas.length; i++) {
// for (let j = 0; j < 25; j++) {
// let k = 3 + j;
// that.tableDatas[i][k] = 0;
// this.$forceUpdate();
// }
// }
let nowDate = new Date();
that.timeStamp = nowDate.getTime();
this.getData();
that.dataLoop();
},
getData() {
getMPoints() {
let that = this;
function dataPush(name) {
let index = 0;
if (name == "破碎机") {
index = 0;
} else if (name == "堆取料机") {
index = 1;
} else if (name == "低压变压器柜") {
index = 2;
} else if (name == "循环风机") {
index = 4;
} else if (name == "调配变压器") {
index = 6;
} else if (name == "低压变压器柜器") {
index = 7;
} else if (name == "尾排风机") {
index = 9;
} else if (name == "高温风机") {
index = 10;
} else if (name == "头排风机") {
index = 11;
} else if (name == "煤磨主电机") {
index = 14;
} else if (name == "煤磨排风机") {
index = 15;
} else if (name == "低压变压器柜") {
index = 16;
} else if (name == "余热发电量") {
index = 18;
} else if (name == "余热发电自用电量") {
index = 19;
} else if (name == "1#空压机") {
index = 21;
} else if (name == "2#空压机") {
index = 22;
} else if (name == "3#空压机") {
index = 23;
} else if (name == "4#空压机") {
index = 24;
} else if (name == "富氧燃烧耗电设备") {
index = 26;
}
return index;
}
function sumNum(a, b, c, d) {
let sum = 0;
if (typeof a !== "undefined" && a !== "NaN") {
sum = sum + Number(a);
}
if (typeof b !== "undefined" && a !== "NaN") {
sum = sum + Number(b);
}
if (typeof c !== "undefined" && a !== "NaN") {
sum = sum + Number(c);
}
if (typeof d !== "undefined" && a !== "NaN") {
sum = sum + Number(d);
}
return sum;
}
let obj = {};
obj.type = "hour_s";
obj.year_s = that.year;
obj.month_s = that.month;
obj.day_s = that.day;
obj.page = 0;
obj.mpoint__ep_monitored__power_kw__gte = 100;
this.$API.enm.mpoint.stat
.req(obj)
.then((res) => {
let wrapArr = [],
innerArr = [];
res.forEach((item) => {
let hour = item.hour;
if (wrapArr[hour]) {
wrapArr[hour].push(item);
} else {
wrapArr[hour] = [];
wrapArr[hour].push(item);
}
});
wrapArr.forEach((inner, inde) => {
inner.forEach((item) => {
let i = dataPush(item.mpoint_name);
let k = 0;
if (
i == 0 ||
i == 4 ||
i == 9 ||
i == 14 ||
i == 18 ||
i == 21 ||
i == 26 ||
i == 27 ||
i == 28
) {
k = 3 + inde;
} else {
k = 2 + inde;
}
that.tableDatas[i][k] = item.val;
});
});
for (let k = 0; k < 24; k++) {
let m = k + 3;
let n = k + 1;
//
that.tableDatas[3][m] = sumNum(
that.tableDatas[0][m],
that.tableDatas[1][m],
that.tableDatas[2][m]
);
//
// that.tableDatas[5][m] = sumNum();
//
that.tableDatas[8][m] =
sumNum(
that.tableDatas[4][m],
// that.tableDatas[5][m],
that.tableDatas[6][m],
that.tableDatas[7][m]
) -
sumNum(
that.tableDatas[1][m],
that.tableDatas[2][m]
);
//
// that.tableDatas[12][m] = sumNum(
// that.tableDatas[9][m],
// that.tableDatas[10][m],
// that.tableDatas[11][m]
// );
//
that.tableDatas[13][m] =
typeof that.tableDatas[12][m] !== "undefined"
? sumNum(
that.tableDatas[9][m],
that.tableDatas[10][m],
that.tableDatas[11][m],
that.tableDatas[12][m]
)
: sumNum(
that.tableDatas[9][m],
that.tableDatas[10][m],
that.tableDatas[11][m]
);
//
let sum17 = sumNum(
that.tableDatas[14][m],
that.tableDatas[15][m],
that.tableDatas[16][m]
);
that.tableDatas[17][m] =
typeof that.tableDatas[21][m] !== "undefined"
? sum17 - that.tableDatas[21][m]
: sum17;
//
that.tableDatas[20][m] =
typeof that.tableDatas[19][m] !== "undefined"
? that.tableDatas[18][m] -
that.tableDatas[19][m]
: that.tableDatas[18][m];
//
that.tableDatas[25][m] = sumNum(
that.tableDatas[21][m],
that.tableDatas[22][m],
that.tableDatas[23][m],
that.tableDatas[24][m]
);
//
that.tableDatas[27][m] = sumNum(
that.tableDatas[3][m],
that.tableDatas[8][m],
that.tableDatas[13][m],
that.tableDatas[17][m],
that.tableDatas[18][m],
that.tableDatas[25][m],
that.tableDatas[26][m]
);
//
// that.tableDatas[28][m] = sumNum(
// that.tableDatas[27][m],
// that.tableDatas[26][m]
// );
}
that.tableDatas.forEach((inner, inde) => {
let sum27 = 0;
inner.forEach((num, ind) => {
if (ind > 2 && ind < 27) {
sum27 = sum27 + Number(num);
}
});
inner[27] = sum27;
});
that.$API.enm.mpoint.list
.req({
page: 0,
enabled: true,
need_display: true,
ordering: "report_sortstr",
mpoint__material__code: "elec",
})
.then(() => {});
.then((res) => {
let data = res.slice(3);
that.mpointList = data;
that.dataLoop();
});
},
dataLoop() {
let that = this;
that.tableDatas = [];
that.mpointList.forEach((item, index) => {
let arr = [];
arr[0] =
item.mgroup_name != null
? item.mgroup_name
: item.nickname != null
? item.nickname
: item.name;
arr[1] = item.nickname != null ? item.nickname : item.name;
arr[2] = item.unit;
for (let i = 0; i < 24; i++) {
arr[i + 3] = 0;
}
that.tableDatas.push(arr);
that.getData(item.id, index);
});
},
getData(id, index) {
let that = this;
let obj = {};
obj.type = "hour";
obj.year = that.year;
obj.month = that.month;
obj.day = that.day;
obj.mpoint__material__code = "elec";
obj.mpoint__need_display = 1;
obj.mpoint = id;
obj.page = 0;
this.$API.enm.mpoint.stat.req(obj).then((res) => {
console.log(res);
res.forEach((item) => {
let ind = item.hour + 3;
that.tableDatas[index][ind] = item.val;
});
that.$forceUpdate();
});
},
// getData(id) {
// let that = this;
// function dataPush(name) {
// let index = 0;
// if (name == "") {
// index = 0;
// } else if (name == "") {
// index = 1;
// } else if (name == "") {
// index = 2;
// } else if (name == "") {
// index = 4;
// } else if (name == "") {
// index = 6;
// } else if (name == "") {
// index = 7;
// } else if (name == "") {
// index = 9;
// } else if (name == "") {
// index = 10;
// } else if (name == "") {
// index = 11;
// } else if (name == "") {
// index = 14;
// } else if (name == "") {
// index = 15;
// } else if (name == "") {
// index = 16;
// } else if (name == "") {
// index = 18;
// } else if (name == "") {
// index = 19;
// } else if (name == "1#") {
// index = 21;
// } else if (name == "2#") {
// index = 22;
// } else if (name == "3#") {
// index = 23;
// } else if (name == "4#") {
// index = 24;
// } else if (name == "") {
// index = 26;
// }
// return index;
// }
// function sumNum(a, b, c, d) {
// let sum = 0;
// if (typeof a !== "undefined" && a !== "NaN") {
// sum = sum + Number(a);
// }
// if (typeof b !== "undefined" && a !== "NaN") {
// sum = sum + Number(b);
// }
// if (typeof c !== "undefined" && a !== "NaN") {
// sum = sum + Number(c);
// }
// if (typeof d !== "undefined" && a !== "NaN") {
// sum = sum + Number(d);
// }
// return sum;
// }
// let obj = {};
// obj.type = "hour_s";
// obj.year_s = that.year;
// obj.month_s = that.month;
// obj.day_s = that.day;
// obj.page = 0;
// obj.mpoint__ep_monitored__power_kw__gte = 100;
// this.$API.enm.mpoint.stat
// .req(obj)
// .then((res) => {
// let wrapArr = [],
// innerArr = [];
// res.forEach((item) => {
// let hour = item.hour;
// if (wrapArr[hour]) {
// wrapArr[hour].push(item);
// } else {
// wrapArr[hour] = [];
// wrapArr[hour].push(item);
// }
// });
// wrapArr.forEach((inner, inde) => {
// inner.forEach((item) => {
// let i = dataPush(item.mpoint_name);
// let k = 0;
// if (
// i == 0 ||
// i == 4 ||
// i == 9 ||
// i == 14 ||
// i == 18 ||
// i == 21 ||
// i == 26 ||
// i == 27 ||
// i == 28
// ) {
// k = 3 + inde;
// } else {
// k = 2 + inde;
// }
// that.tableDatas[i][k] = item.val;
// });
// });
// for (let k = 0; k < 24; k++) {
// let m = k + 3;
// let n = k + 1;
// //
// that.tableDatas[3][m] = sumNum(
// that.tableDatas[0][m],
// that.tableDatas[1][m],
// that.tableDatas[2][m]
// );
// //
// // that.tableDatas[5][m] = sumNum();
// //
// that.tableDatas[8][m] =
// sumNum(
// that.tableDatas[4][m],
// // that.tableDatas[5][m],
// that.tableDatas[6][m],
// that.tableDatas[7][m]
// ) -
// sumNum(
// that.tableDatas[1][m],
// that.tableDatas[2][m]
// );
// //
// // that.tableDatas[12][m] = sumNum(
// // that.tableDatas[9][m],
// // that.tableDatas[10][m],
// // that.tableDatas[11][m]
// // );
// //
// that.tableDatas[13][m] =
// typeof that.tableDatas[12][m] !== "undefined"
// ? sumNum(
// that.tableDatas[9][m],
// that.tableDatas[10][m],
// that.tableDatas[11][m],
// that.tableDatas[12][m]
// )
// : sumNum(
// that.tableDatas[9][m],
// that.tableDatas[10][m],
// that.tableDatas[11][m]
// );
// //
// let sum17 = sumNum(
// that.tableDatas[14][m],
// that.tableDatas[15][m],
// that.tableDatas[16][m]
// );
// that.tableDatas[17][m] =
// typeof that.tableDatas[21][m] !== "undefined"
// ? sum17 - that.tableDatas[21][m]
// : sum17;
// //
// that.tableDatas[20][m] =
// typeof that.tableDatas[19][m] !== "undefined"
// ? that.tableDatas[18][m] -
// that.tableDatas[19][m]
// : that.tableDatas[18][m];
// //
// that.tableDatas[25][m] = sumNum(
// that.tableDatas[21][m],
// that.tableDatas[22][m],
// that.tableDatas[23][m],
// that.tableDatas[24][m]
// );
// //
// that.tableDatas[27][m] = sumNum(
// that.tableDatas[3][m],
// that.tableDatas[8][m],
// that.tableDatas[13][m],
// that.tableDatas[17][m],
// that.tableDatas[18][m],
// that.tableDatas[25][m],
// that.tableDatas[26][m]
// );
// //
// // that.tableDatas[28][m] = sumNum(
// // that.tableDatas[27][m],
// // that.tableDatas[26][m]
// // );
// }
// that.tableDatas.forEach((inner, inde) => {
// let sum27 = 0;
// inner.forEach((num, ind) => {
// if (ind > 2 && ind < 27) {
// sum27 = sum27 + Number(num);
// }
// });
// inner[27] = sum27;
// });
// })
// .then(() => {});
// },
getHourData() {
let that = this;
let m = 0;
let date = new Date();
let year = date.getFullYear();
let month = date.getMonth() + 1;
let day = date.getDate();
let hour = date.getHours();
let minute = date.getMinutes();
let second = date.getSeconds();
},
getTableData() {
for (let i = 0; i < this.tableDatas.length; i++) {

View File

@ -45,7 +45,7 @@
<th>工段</th>
<th>设备</th>
<th>单位</th>
<th v-for="item in 12" :key="item">
<th v-for="item in months" :key="item">
{{ item }}
</th>
<th>本年合计</th>
@ -135,40 +135,9 @@ export default {
data() {
return {
year: "",
month: "",
day: "",
search_date: "",
tableDatas: [
["石灰石破碎", "破碎机", "kw.h"], //0
["石灰石破碎", "堆取料机", "kw.h"],
["石灰石破碎", "低压变压器柜", "kw.h"],
["石灰石破碎", "石灰石破碎合计", "kw.h"],
["原料磨", "循环风机", "kw.h"],
["原料磨", "辊压机", "kw.h"],
["原料磨", "调配变压器", "kw.h"],
["原料磨", "低压变压器柜器", "kw.h"],
["原料磨", "原料磨系统合计", "kw.h"],
["回转窑", "尾排风机", "kw.h"],
["回转窑", "高温风机", "kw.h"],
["回转窑", "头排风机", "kw.h"],
["回转窑", "低压变压器柜", "kw.h"],
["回转窑", "回转窑烧成系统合计", "kw.h"],
["煤磨", "煤磨主电机", "kw.h"],
["煤磨", "煤磨排风机", "kw.h"],
["煤磨", "低压变压器柜", "kw.h"],
["煤磨", "煤磨系统合计", "kw.h"],
["余热发电", "余热发电量", "kw.h"],
["余热发电", "余热发电自用电量", "kw.h"],
["余热发电", "余热供电量", "kw.h"],
["空压机", "1#空压机", "kw.h"],
["空压机", "2#空压机", "kw.h"],
["空压机", "3#空压机", "kw.h"],
["空压机", "4#空压机", "kw.h"],
["空压机", "空压机合计", "kw.h"],
["富氧燃烧系统", "富氧燃烧耗电设备", "kw.h"],
["生产总耗电量", "生产部分总耗电", "kw.h"],
["全厂进线", "全厂耗电量", "kw.h"],
],
mpointList: [],
tableDatas: [],
timeStamp: null,
itemVisible: false,
months: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],
@ -278,228 +247,72 @@ export default {
let that = this;
var nowDate = new Date();
that.year = nowDate.getFullYear();
that.search_date = that.year + "";
that.search_date = that.year;
that.timeStamp = nowDate.getTime();
let tableDatas = that.tableDatas;
for (let i = 0; i < tableDatas.length; i++) {
for (let j = 0; j < 12; j++) {
let k = 3 + j;
that.tableDatas[i][k] = 0;
this.$forceUpdate();
}
}
this.getData();
this.getMPoints();
},
methods: {
dateChange() {
let that = this;
for (let i = 0; i < that.tableDatas.length; i++) {
for (let j = 0; j < 13; j++) {
let k = 3 + j;
that.tableDatas[i][k] = 0;
this.$forceUpdate();
}
}
that.tableDatas = [];
that.year = that.search_date;
let nowDate = new Date();
that.timeStamp = nowDate.getTime();
this.getData();
that.dataLoop();
},
getData() {
getMPoints() {
let that = this;
function dataPush(name) {
let index = 0;
if (name == "破碎机") {
index = 0;
} else if (name == "堆取料机") {
index = 1;
} else if (name == "低压变压器柜") {
index = 2;
} else if (name == "循环风机") {
index = 4;
} else if (name == "调配变压器") {
index = 6;
} else if (name == "低压变压器柜器") {
index = 7;
} else if (name == "尾排风机") {
index = 9;
} else if (name == "高温风机") {
index = 10;
} else if (name == "头排风机") {
index = 11;
} else if (name == "煤磨主电机") {
index = 14;
} else if (name == "煤磨排风机") {
index = 15;
} else if (name == "低压变压器柜") {
index = 16;
} else if (name == "余热发电量") {
index = 18;
} else if (name == "余热发电自用电量") {
index = 19;
} else if (name == "1#空压机") {
index = 21;
} else if (name == "2#空压机") {
index = 22;
} else if (name == "3#空压机") {
index = 23;
} else if (name == "4#空压机") {
index = 24;
} else if (name == "富氧燃烧耗电设备") {
index = 26;
}
return index;
}
function sumNum(a, b, c, d) {
let sum = 0;
if (typeof a !== "undefined" && a !== "NaN") {
sum = sum + Number(a);
}
if (typeof b !== "undefined" && a !== "NaN") {
sum = sum + Number(b);
}
if (typeof c !== "undefined" && a !== "NaN") {
sum = sum + Number(c);
}
if (typeof d !== "undefined" && a !== "NaN") {
sum = sum + Number(d);
}
return sum;
}
let obj = {};
obj.type = "month_s";
obj.year_s = that.year;
obj.page = 0;
obj.mpoint__ep_monitored__power_kw__gte = 100;
this.$API.enm.mpoint.stat
.req(obj)
.then((res) => {
let wrapArr = [],
innerArr = [];
res.forEach((item) => {
let month = item.month;
if (wrapArr[month]) {
wrapArr[month].push(item);
} else {
wrapArr[month] = [];
wrapArr[month].push(item);
}
});
wrapArr.forEach((inner, inde) => {
inner.forEach((item) => {
let i = dataPush(item.mpoint_name);
let k = 0;
if (
i == 0 ||
i == 4 ||
i == 9 ||
i == 14 ||
i == 18 ||
i == 21 ||
i == 26 ||
i == 27 ||
i == 28
) {
k = 3 + inde;
} else {
k = 2 + inde;
}
that.tableDatas[i][k] = item.val;
});
});
for (let k = 0; k < 24; k++) {
let m = k + 3;
let n = k + 1;
//
that.tableDatas[3][m] = sumNum(
that.tableDatas[0][m],
that.tableDatas[1][m],
that.tableDatas[2][m]
);
//
// that.tableDatas[5][m] = sumNum();
//
that.tableDatas[8][m] =
sumNum(
that.tableDatas[4][m],
// that.tableDatas[5][m],
that.tableDatas[6][m],
that.tableDatas[7][m]
) -
sumNum(
that.tableDatas[1][m],
that.tableDatas[2][m]
);
//
// that.tableDatas[12][m] = sumNum(
// that.tableDatas[9][m],
// that.tableDatas[10][m],
// that.tableDatas[11][m]
// );
//
that.tableDatas[13][m] =
typeof that.tableDatas[12][m] !== "undefined"
? sumNum(
that.tableDatas[9][m],
that.tableDatas[10][m],
that.tableDatas[11][m],
that.tableDatas[12][m]
)
: sumNum(
that.tableDatas[9][m],
that.tableDatas[10][m],
that.tableDatas[11][m]
);
//
let sum17 = sumNum(
that.tableDatas[14][m],
that.tableDatas[15][m],
that.tableDatas[16][m]
);
that.tableDatas[17][m] =
typeof that.tableDatas[21][m] !== "undefined"
? sum17 - that.tableDatas[21][m]
: sum17;
//
that.tableDatas[20][m] =
typeof that.tableDatas[19][m] !== "undefined"
? that.tableDatas[18][m] -
that.tableDatas[19][m]
: that.tableDatas[18][m];
//
that.tableDatas[25][m] = sumNum(
that.tableDatas[21][m],
that.tableDatas[22][m],
that.tableDatas[23][m],
that.tableDatas[24][m]
);
//
that.tableDatas[27][m] = sumNum(
that.tableDatas[3][m],
that.tableDatas[8][m],
that.tableDatas[13][m],
that.tableDatas[17][m],
that.tableDatas[18][m],
that.tableDatas[25][m],
that.tableDatas[26][m]
);
//
// that.tableDatas[28][m] = sumNum(
// that.tableDatas[27][m],
// that.tableDatas[26][m]
// );
}
that.tableDatas.forEach((inner, inde) => {
let sum15 = 0;
inner.forEach((num, ind) => {
if (ind > 2 && ind < 15) {
sum15 = sum15 + Number(num);
}
});
inner[15] = sum15;
});
that.$API.enm.mpoint.list
.req({
page: 0,
enabled: true,
need_display: true,
ordering: "report_sortstr",
mpoint__material__code: "elec",
})
.then(() => {});
.then((res) => {
let data = res.slice(3);
that.mpointList = data;
that.dataLoop();
});
},
dataLoop() {
let that = this;
that.tableDatas = [];
that.mpointList.forEach((item, index) => {
let arr = [];
arr[0] =
item.mgroup_name != null
? item.mgroup_name
: item.nickname != null
? item.nickname
: item.name;
arr[1] = item.nickname != null ? item.nickname : item.name;
arr[2] = item.unit;
for (let i = 0; i < 12; i++) {
arr[i + 3] = 0;
}
that.tableDatas.push(arr);
that.getData(item.id, index);
});
},
getData(id, index) {
let that = this;
let obj = {};
obj.type = "month";
obj.year = that.year;
obj.mpoint__material__code = "elec";
obj.mpoint__need_display = 1;
obj.mpoint = id;
obj.page = 0;
this.$API.enm.mpoint.stat.req(obj).then((res) => {
console.log(res);
res.forEach((item) => {
let ind = item.month + 2;
that.tableDatas[index][ind] = item.val;
});
that.$forceUpdate();
});
},
itemClick(item, index) {
let that = this;