diff --git a/src/views/enm_coalbase/power.vue b/src/views/enm_coalbase/power.vue index 8a24d42d..809ca81b 100644 --- a/src/views/enm_coalbase/power.vue +++ b/src/views/enm_coalbase/power.vue @@ -24,13 +24,12 @@ > - + 煤磨工段主要设备(100KW以上)单位产品电耗数据表 设备名称 - 设备编号 单位 上个小时 昨日 @@ -44,27 +43,27 @@ :key="item1" > {{ item1 }} {{ item1 }} {{ item1 }} @@ -307,142 +306,103 @@ export default { mounted() { let that = this; var myDate = new Date(); - let year = myDate.getFullYear(); - let month = myDate.getMonth() + 1; - let days = myDate.getDate(); - let hours = myDate.getHours(); - let timeDate = myDate.getTime(); - let dayTime = 24 * 60 * 60 * 1000; - //昨天的计算 - let year_d = year, - month_d = month, - days_d = days; - if (hours < 21) { - //21点前,查找昨日数据为前一天数据 - let newDate = timeDate - dayTime; - let lastDate = new Date(newDate); - year_d = lastDate.getFullYear(); - month_d = lastDate.getMonth() + 1; - days_d = lastDate.getDate(); - } - //上一小时的计算 - let hourTime = timeDate - 3600000; - let hourDate = new Date(hourTime); - let year_h = hourDate.getFullYear(); - let month_h = hourDate.getMonth() + 1; - let days_h = hourDate.getDate(); - let hours_h = hourDate.getHours(); - this.$API.mtm.mgroup.list - .req({ page: 0, search: "煤磨" }) - .then((res) => { - console.log("煤磨", res); - that.query.mgroup = res[0].id; - //本月 - let params2 = {}; - params2.page = 0; - params2.year_s = year; - params2.month_s = month; - params2.type = "month_s"; - params2.mgroup = that.query.mgroup; - that.$API.enm.enstat - .req(params2) - .then((res2) => { - if (res2.length > 0) { - let hourProduct = (that.allValMonth = - res2[0].total_production); //当前条件下的总产量 - params2.mpoint__ep_monitored__power_kw__gte = 100; - that.$API.enm.mpoint.stat - .req(params2) - .then((res) => { - let data2 = res; - for (let i = 0; i < data2.length; i++) { - that.tableDatas[i] = []; - that.tableDatas[i][0] = - data2[i].ep_monitored_name; - that.tableDatas[i][1] = - data2[i].ep_monitored_number; - that.tableDatas[i][2] = "KW·h/t"; - let val = - hourProduct == 0 - ? "/" - : ( - data2[i].val / - hourProduct - ).toFixed(2); - that.tableDatas[i][5] = val; - } - }); - } - }) - .then((res2) => { - //昨日 - let params3 = {}; - params3.page = 0; - params3.year_s = year_d; - params3.month_s = month_d; - params3.day_s = days_d; - params3.type = "day_s"; - params3.mgroup = that.query.mgroup; - that.$API.enm.enstat.req(params3).then((res3) => { - if (res3.length > 0) { - let hourProduct = (that.allValDays = - res3[0].total_production); - params3.mpoint__ep_monitored__power_kw__gte = 100; - that.$API.enm.mpoint.stat - .req(params3) - .then((res) => { - let data3 = res3; - for (let j = 0; j < data3.length; j++) { - let val = - hourProduct == 0 - ? "/" - : ( - data3[j].val / - hourProduct - ).toFixed(2); - that.tableDatas[j][4] = val; - } - }); - } - }); - //上小时 - let params4 = {}; - params4.page = 0; - params4.year = year_h; - params4.month = month_h; - params4.day = days_h; - params4.hour = hours_h; - params4.type = "hour_s"; - params4.mgroup = that.query.mgroup; - that.$API.enm.enstat.req(params4).then((res4) => { - if (res4.length > 0) { - let hourProduct = (that.allValHour = - res4[0].total_production); - params4.mpoint__ep_monitored__power_kw__gte = 100; - that.$API.enm.mpoint.stat - .req(params4) - .then((res) => { - let data4 = res4; - for (let k = 0; k < data4.length; k++) { - let val = - hourProduct == 0 - ? "/" - : ( - data4[k].val / - hourProduct - ).toFixed(2); - that.tableDatas[k][3] = val; - } - }); - } - }); - }); - that.getHourData(); - that.getDayData(); - that.getMonthData(); - }); + that.year = myDate.getFullYear(); + that.month = myDate.getMonth() + 1; + that.days = myDate.getDate(); + that.hours = myDate.getHours(); + that.getTableHourData(); + that.getHourData(); + that.getDayData(); + that.getMonthData(); }, methods: { + getTableHourData() { + let that = this; + that.tableDatas = []; + let timeDate = new Date().getTime(); + let hourTime = timeDate - 3600000; + let hourDate = new Date(hourTime); + let year_h = hourDate.getFullYear(); + let month_h = hourDate.getMonth() + 1; + let days_h = hourDate.getDate(); + let hours_h = hourDate.getHours(); + let minutes = hourDate.getMinutes(); + month_h = month_h > 9 ? month_h : "0" + month_h; + days_h = days_h > 9 ? days_h : "0" + days_h; + if (hours_h > 5) { + hours_h = hours_h > 9 ? hours_h : "0" + hours_h; + } else { + hours_h = hours_h - 1; + hours_h = hours_h > 9 ? hours_h : "0" + hours_h; + } + let obj = {}; + obj.type = "hour_s"; + obj.year = year_h; + obj.month = month_h; + obj.day = days_h; + obj.hour = hours_h; + obj.mgroup__name = "煤磨"; + obj.mpoint__material__code__in = "elec,elec_0"; + obj.mpoint__ep_monitored__isnull = 0; + obj.mpoint__need_display = 1; + obj.page = 0; + this.$API.enm.mpoint.stat + .req(obj) + .then((res) => { + console.log("getTableHourData", res); + res.forEach((item) => { + let obj = []; + obj[0] = item.ep_monitored_name; + obj[1] = "KW·h/t"; + obj[2] = item.elec_consume_unit; + obj[3] = 0; + obj[4] = 0; + that.tableDatas.push(obj); + }); + }) + .then(() => { + let yetTime = timeDate - 3600000 * 24; + let ystDate = new Date(yetTime); + let year_h = ystDate.getFullYear(); + let month_h = ystDate.getMonth() + 1; + let days_h = ystDate.getDate(); + month_h = month_h > 9 ? month_h : "0" + month_h; + days_h = days_h > 9 ? days_h : "0" + days_h; + let obj = {}; + obj.type = "day_s"; + obj.year_s = year_h; + obj.month_s = month_h; + obj.day_s = days_h; + obj.mgroup__name = "煤磨"; + obj.mpoint__material__code__in = "elec,elec_0"; + obj.mpoint__ep_monitored__isnull = 0; + obj.mpoint__need_display = 1; + obj.page = 0; + this.$API.enm.mpoint.stat.req(obj).then((res) => { + console.log("getTableHourData", res); + res.forEach((item, index) => { + that.tableDatas[index][3] = item.elec_consume_unit; + }); + }); + }) + .then(() => { + let obj = {}; + obj.type = "month_s"; + obj.year_s = that.year; + obj.month_s = that.month; + obj.mgroup__name = "煤磨"; + obj.mpoint__material__code__in = "elec,elec_0"; + obj.mpoint__ep_monitored__isnull = 0; + obj.mpoint__need_display = 1; + obj.page = 0; + this.$API.enm.mpoint.stat.req(obj).then((res) => { + console.log("getTableHourData", res); + res.forEach((item, index) => { + that.tableDatas[index][4] = item.elec_consume_unit; + }); + }); + }); + }, //获取小时数据 getHourData() { let that = this; @@ -459,17 +419,11 @@ export default { seriesData1 = []; let data = response; data.forEach((item) => { - let ind = item.hour; - let val = 0; - if (that.allValHour == 0) { - val = ""; - } else { - val = (item.val / that.allValHour).toFixed(2); - } - if (item.equip_name == "煤磨排风机主电机") { - seriesData0[ind] = val; - } else if (item.equip_name == "煤磨主电机") { - seriesData1[ind] = val; + let ind = item.hour - 1; + if (item.ep_monitored_name == "煤磨排风机主电机") { + seriesData0[ind] = item.elec_consume_unit; + } else if (item.ep_monitored_name == "煤磨主电机") { + seriesData1[ind] = item.elec_consume_unit; } }); let options = { ...that.option1 }; @@ -499,18 +453,11 @@ export default { seriesData1 = []; let data = response; data.forEach((item) => { - // debugger; - let ind = item.day_s; - let val = 0; - if (that.allValDays == 0) { - val = ""; - } else { - val = (item.val / that.allValDays).toFixed(2); - } - if (item.equip_name == "煤磨排风机主电机") { - seriesData0[ind] = val; - } else if (item.equip_name == "煤磨主电机") { - seriesData1[ind] = val; + let ind = item.day_s - 1; + if (item.ep_monitored_name == "煤磨排风机主电机") { + seriesData0[ind] = item.elec_consume_unit; + } else if (item.ep_monitored_name == "煤磨主电机") { + seriesData1[ind] = item.elec_consume_unit; } }); let options = { ...that.option2 }; @@ -539,17 +486,11 @@ export default { seriesData1 = []; let data = response; data.forEach((item) => { - let ind = item.month_s; - let val = 0; - if (that.allValMonth == 0) { - val = ""; - } else { - val = (item.val / that.allValMonth).toFixed(2); - } - if (item.equip_name == "煤磨排风机主电机") { - seriesData0[ind] = val; - } else if (item.equip_name == "煤磨主电机") { - seriesData1[ind] = val; + let ind = item.month_s - 1; + if (item.ep_monitored_name == "煤磨排风机主电机") { + seriesData0[ind] = item.elec_consume_unit; + } else if (item.ep_monitored_name == "煤磨主电机") { + seriesData1[ind] = item.elec_consume_unit; } }); let options = { ...that.option3 }; diff --git a/src/views/enm_kilnbase/power.vue b/src/views/enm_kilnbase/power.vue index c5fca9bb..cec9e863 100644 --- a/src/views/enm_kilnbase/power.vue +++ b/src/views/enm_kilnbase/power.vue @@ -24,13 +24,12 @@ > - + 回转窑工段主要设备(100KW以上)单位产品电耗数据表 设备名称 - 设备编号 单位 上个小时 昨日 @@ -44,27 +43,27 @@ :key="item1" > {{ item1 }} {{ item1 }} {{ item1 }} @@ -193,9 +192,9 @@ export default { }, tableName: "主要设备(100KW以上)单位产品电耗数据表", tableDatas: [ - ["尾排风机", "", "KW·h/t", "", "", ""], - ["高温风机", "", "KW·h/t", "", "", ""], - ["头排风机", "", "KW·h/t", "", "", ""], + ["尾排风机", "KW·h/t", "", "", ""], + ["高温风机", "KW·h/t", "", "", ""], + ["头排风机", "KW·h/t", "", "", ""], ], modelValue: true, type: "hour_s", @@ -340,184 +339,137 @@ export default { mounted() { let that = this; var myDate = new Date(); - let year = myDate.getFullYear(); - let month = myDate.getMonth() + 1; - let days = myDate.getDate(); - let hours = myDate.getHours(); - let timeDate = myDate.getTime(); - let dayTime = 24 * 60 * 60 * 1000; - //昨天的计算 - let year_d = year, - month_d = month, - days_d = days; - if (hours < 21) { - //21点前,查找昨日数据为前一天数据 - let newDate = timeDate - dayTime; - let lastDate = new Date(newDate); - year_d = lastDate.getFullYear(); - month_d = lastDate.getMonth() + 1; - days_d = lastDate.getDate(); - } - //上一小时的计算 - let hourTime = timeDate - 3600000; - let hourDate = new Date(hourTime); - let year_h = hourDate.getFullYear(); - let month_h = hourDate.getMonth() + 1; - let days_h = hourDate.getDate(); - let hours_h = hourDate.getHours(); - that.$API.mtm.mgroup.list - .req({ page: 0, search: "回转窑" }) - .then((res) => { - console.log("回转窑", res); - that.query.mgroup = res[0].id; - //本月 - let params2 = {}; - params2.page = 0; - params2.year_s = year; - params2.month_s = month; - params2.type = "month_s"; - params2.mgroup = this.query.mgroup; - this.$API.enm.enstat - .req(params2) - .then((res2) => { - if (res2.length > 0) { - let allValMonth = (that.allValMonth = - res2[0].total_production); //当前条件下的总产量 - params2.mpoint__ep_monitored__power_kw__gte = 100; - this.$API.enm.mpoint.stat - .req(params2) - .then((res) => { - let data2 = res; - for (let i = 0; i < data2.length; i++) { - that.tableDatas[i] = []; - that.tableDatas[i][0] = - data2[i].ep_monitored_name; - that.tableDatas[i][1] = - data2[i].ep_monitored_number; - that.tableDatas[i][2] = "KW·h/t"; - let val = - allValMonth == 0 - ? "/" - : ( - data2[i].val / - allValMonth - ).toFixed(2); - that.tableDatas[i][5] = val; - } - }); - } - }) - .then((res2) => { - //昨日 - let params3 = {}; - params3.page = 0; - params3.year_s = year_d; - params3.month_s = month_d; - params3.day_s = days_d; - params3.type = "day_s"; - params3.mgroup = this.query.mgroup; - this.$API.enm.enstat.req(params3).then((res3) => { - if (res3.length > 0) { - let allValDays = (that.allValDays = - res3[0].total_production); - params3.mpoint__ep_monitored__power_kw__gte = 100; - this.$API.enm.mpoint.stat - .req(params3) - .then((res) => { - let data3 = res3; - for (let j = 0; j < data3.length; j++) { - let val = - allValDays == 0 - ? "/" - : ( - data3[j].val / - allValDays - ).toFixed(2); - that.tableDatas[j][4] = val; - } - }); - } - }); - //上小时 - let params4 = {}; - params4.page = 0; - params4.year = year_h; - params4.month = month_h; - params4.day = days_h; - params4.hour = hours_h; - params4.type = "hour_s"; - params4.mgroup = this.query.mgroup; - this.$API.enm.enstat.req(params4).then((res4) => { - if (res4.length > 0) { - let hourProduct = (that.allValHour = - res4[0].total_production); - params4.mpoint__ep_monitored__power_kw__gte = 100; - this.$API.enm.mpoint.stat - .req(params4) - .then((res) => { - let data4 = res4; - for (let k = 0; k < data4.length; k++) { - let val = - hourProduct == 0 - ? "/" - : ( - data4[k].val / - hourProduct - ).toFixed(2); - that.tableDatas[k][3] = val; - } - }); - } - }); - }); - that.getHourData(); - that.getDayData(); - that.getMonthData(); - }); + that.year = myDate.getFullYear(); + that.month = myDate.getMonth() + 1; + that.days = myDate.getDate(); + that.hours = myDate.getHours(); + that.getTableHourData(); + that.getHourData(); + that.getDayData(); + that.getMonthData(); }, methods: { + getTableHourData() { + let that = this; + that.tableDatas = []; + let timeDate = new Date().getTime(); + let hourTime = timeDate - 3600000; + let hourDate = new Date(hourTime); + let year_h = hourDate.getFullYear(); + let month_h = hourDate.getMonth() + 1; + let days_h = hourDate.getDate(); + let hours_h = hourDate.getHours(); + let minutes = hourDate.getMinutes(); + month_h = month_h > 9 ? month_h : "0" + month_h; + days_h = days_h > 9 ? days_h : "0" + days_h; + if (hours_h > 5) { + hours_h = hours_h > 9 ? hours_h : "0" + hours_h; + } else { + hours_h = hours_h - 1; + hours_h = hours_h > 9 ? hours_h : "0" + hours_h; + } + let obj = {}; + obj.type = "hour_s"; + obj.year = year_h; + obj.month = month_h; + obj.day = days_h; + obj.hour = hours_h; + obj.mgroup__name = "回转窑"; + obj.mpoint__material__code__in = "elec,elec_0"; + obj.mpoint__ep_monitored__isnull = 0; + obj.mpoint__need_display = 1; + obj.page = 0; + this.$API.enm.mpoint.stat + .req(obj) + .then((res) => { + console.log("getTableHourData", res); + res.forEach((item) => { + let obj = []; + obj[0] = item.ep_monitored_name; + obj[1] = "KW·h/t"; + obj[2] = item.elec_consume_unit; + obj[3] = 0; + obj[4] = 0; + that.tableDatas.push(obj); + }); + }) + .then(() => { + let yetTime = timeDate - 3600000 * 24; + let ystDate = new Date(yetTime); + let year_h = ystDate.getFullYear(); + let month_h = ystDate.getMonth() + 1; + let days_h = ystDate.getDate(); + month_h = month_h > 9 ? month_h : "0" + month_h; + days_h = days_h > 9 ? days_h : "0" + days_h; + let obj = {}; + obj.type = "day_s"; + obj.year_s = year_h; + obj.month_s = month_h; + obj.day_s = days_h; + obj.mgroup__name = "回转窑"; + obj.mpoint__material__code__in = "elec,elec_0"; + obj.mpoint__ep_monitored__isnull = 0; + obj.mpoint__need_display = 1; + obj.page = 0; + this.$API.enm.mpoint.stat.req(obj).then((res) => { + console.log("getTableHourData", res); + res.forEach((item, index) => { + that.tableDatas[index][3] = item.elec_consume_unit; + }); + }); + }) + .then(() => { + let obj = {}; + obj.type = "month_s"; + obj.year_s = that.year; + obj.month_s = that.month; + obj.mgroup__name = "回转窑"; + obj.mpoint__material__code__in = "elec,elec_0"; + obj.mpoint__ep_monitored__isnull = 0; + obj.mpoint__need_display = 1; + obj.page = 0; + this.$API.enm.mpoint.stat.req(obj).then((res) => { + console.log("getTableHourData", res); + res.forEach((item, index) => { + that.tableDatas[index][4] = item.elec_consume_unit; + }); + }); + }); + }, //获取小时数据 getHourData() { let that = this; - let query = {}; - query.page = 0; - query.year_s = that.year; - query.month_s = that.month; - query.day_s = that.days; - query.type = "hour_s"; - query.mgroup = that.query.mgroup; - query.mpoint__ep_monitored__power_kw__gte = 100; - this.$API.enm.mpoint.stat.req(query).then((response) => { + let obj = {}; + obj.type = "hour_s"; + obj.year_s = that.year; + obj.month_s = that.month; + obj.day_s = that.days; + obj.mgroup__name = "回转窑"; + obj.mpoint__material__code__in = "elec,elec_0"; + obj.mpoint__ep_monitored__isnull = 0; + obj.mpoint__need_display = 1; + obj.page = 0; + this.$API.enm.mpoint.stat.req(obj).then((response) => { let seriesData0 = [], seriesData1 = [], - seriesData2 = [], - seriesData3 = []; - let data = response; - data.forEach((item) => { - let ind = item.hour; - let val = 0; - if (that.allValHour == 0) { - val = ""; - } else { - val = (item.val / that.allValHour).toFixed(2); - } - if (item.equip_name == "尾排风机") { - seriesData0[ind] = val; - } else if (item.equip_name == "高温风机") { - seriesData1[ind] = val; - } else if (item.equip_name == "头排风机") { - seriesData2[ind] = val; - } else if (item.equip_name == "低压变压器柜") { - seriesData3[ind] = val; + seriesData2 = []; + response.forEach((item) => { + console.log(item.ep_monitored_name); + let ind = item.hour - 1; + if (item.ep_monitored_name == "尾排风机") { + seriesData0[ind] = item.elec_consume_unit; + } else if (item.ep_monitored_name == "高温风机") { + seriesData1[ind] = item.elec_consume_unit; + } else if (item.ep_monitored_name == "头排风机") { + seriesData2[ind] = item.elec_consume_unit; } }); let options = { ...that.option1 }; options.series[0].data = seriesData0; options.series[1].data = seriesData1; options.series[2].data = seriesData2; - options.series[3].data = seriesData3; let hourXAxis = []; - for (let i = 1; i <= that.hours; i++) { + for (let i = 1; i < that.hours + 1; i++) { let item = i + "时"; hourXAxis.push(item); } @@ -528,43 +480,34 @@ export default { //获取天数据 getDayData() { let that = this; - let query1 = {}; - query1.page = 0; - query1.year_s = that.year; - query1.month_s = that.month; - query1.type = "day_s"; - query1.mgroup = this.query.mgroup; - query1.mpoint__ep_monitored__power_kw__gte = 100; - this.$API.enm.enstat.req(query1).then((response) => { + let obj = {}; + obj.type = "day_s"; + obj.year_s = that.year; + obj.month_s = that.month; + obj.mgroup__name = "回转窑"; + obj.mpoint__material__code__in = "elec,elec_0"; + obj.mpoint__ep_monitored__isnull = 0; + obj.mpoint__need_display = 1; + obj.page = 0; + this.$API.enm.mpoint.stat.req(obj).then((response) => { let seriesData0 = [], seriesData1 = [], - seriesData2 = [], - seriesData3 = []; + seriesData2 = []; let data = response; data.forEach((item) => { - // debugger; - let ind = item.day_s; - let val = 0; - if (that.allValDays == 0) { - val = ""; - } else { - val = (item.val / that.allValDays).toFixed(2); - } - if (item.equip_name == "尾排风机") { - seriesData0[ind] = val; - } else if (item.equip_name == "高温风机") { - seriesData1[ind] = val; - } else if (item.equip_name == "头排风机") { - seriesData2[ind] = val; - } else if (item.equip_name == "低压变压器柜") { - seriesData3[ind] = val; + let ind = item.day_s - 1; + if (item.ep_monitored_name == "尾排风机") { + seriesData0[ind] = item.elec_consume_unit; + } else if (item.ep_monitored_name == "高温风机") { + seriesData1[ind] = item.elec_consume_unit; + } else if (item.ep_monitored_name == "头排风机") { + seriesData2[ind] = item.elec_consume_unit; } }); let options = { ...that.option2 }; options.series[0].data = seriesData0; options.series[1].data = seriesData1; options.series[2].data = seriesData2; - options.series[3].data = seriesData3; let dayXAxis = []; for (let i = 1; i <= that.days; i++) { let item = i + "日"; @@ -577,41 +520,33 @@ export default { //获取月数据 getMonthData() { let that = this; - let query2 = {}; - query2.page = 0; - query2.year_s = that.year; - query2.type = "month_s"; - query2.mgroup = that.query.mgroup; - query2.mpoint__ep_monitored__power_kw__gte = 100; - this.$API.enm.enstat.req(query2).then((response) => { + let obj = {}; + obj.type = "month_s"; + obj.year_s = that.year; + obj.mgroup__name = "回转窑"; + obj.mpoint__material__code__in = "elec,elec_0"; + obj.mpoint__ep_monitored__isnull = 0; + obj.mpoint__need_display = 1; + obj.page = 0; + this.$API.enm.mpoint.stat.req(obj).then((response) => { let seriesData0 = [], seriesData1 = [], - seriesData2 = [], - seriesData3 = []; + seriesData2 = []; let data = response; data.forEach((item) => { - let ind = item.month_s; - let val = 0; - if (that.allValMonth == 0) { - val = ""; - } else { - val = (item.val / that.allValMonth).toFixed(2); - } - if (item.equip_name == "尾排风机") { - seriesData0[ind] = val; - } else if (item.equip_name == "高温风机") { - seriesData1[ind] = val; - } else if (item.equip_name == "头排风机") { - seriesData2[ind] = val; - } else if (item.equip_name == "低压变压器柜") { - seriesData3[ind] = val; + let ind = item.month_s - 1; + if (item.ep_monitored_name == "尾排风机") { + seriesData0[ind] = item.elec_consume_unit; + } else if (item.ep_monitored_name == "高温风机") { + seriesData1[ind] = item.elec_consume_unit; + } else if (item.ep_monitored_name == "头排风机") { + seriesData2[ind] = item.elec_consume_unit; } }); let options = { ...that.option3 }; options.series[0].data = seriesData0; options.series[1].data = seriesData1; options.series[2].data = seriesData2; - options.series[3].data = seriesData3; let monthXAxis = []; for (let i = 1; i <= that.month; i++) { let item = i + "月"; diff --git a/src/views/enm_rmbase/power.vue b/src/views/enm_rmbase/power.vue index 7d144b67..7c1f8600 100644 --- a/src/views/enm_rmbase/power.vue +++ b/src/views/enm_rmbase/power.vue @@ -24,13 +24,12 @@ > - + 原料磨工段主要设备(100KW以上)单位产品电耗数据表 设备名称 - 设备编号 单位 上个小时 昨日 @@ -44,27 +43,27 @@ :key="item1" > {{ item1 }} {{ item1 }} {{ item1 }} @@ -141,7 +140,7 @@ let toolbox = { }; let legend = { top: "2%", - data: ["辊压机", "循环风机", "调配变压器", "低压变压器柜器"], + data: ["辊压机", "循环风机"], }; let yAxis = { type: "value", @@ -175,17 +174,17 @@ export default { optionHour: {}, optionDay: {}, optionMonth: {}, - year: 2023, - month: 1, - days: 1, + year: 2024, + month: 5, + days: 13, hours: 1, query: { mgroup: "", }, tableName: "主要设备(100KW以上)单位产品电耗数据表", tableDatas: [ - ["辊压机", "", "KW·h/t", "", "", ""], - ["循环风机", "", "KW·h/t", "", "", ""], + // ["辊压机", "KW·h/t", "", "", ""], + // ["循环风机", "KW·h/t", "", "", ""], ], modelValue: true, type: "hour_s", @@ -224,16 +223,6 @@ export default { type: "bar", data: [], }, - { - name: "调配变压器", - type: "bar", - data: [], - }, - { - name: "低压变压器柜器", - type: "bar", - data: [], - }, ], }, option2: { @@ -262,16 +251,6 @@ export default { type: "bar", data: [], }, - { - name: "调配变压器", - type: "bar", - data: [], - }, - { - name: "低压变压器柜器", - type: "bar", - data: [], - }, ], }, option3: { @@ -313,202 +292,141 @@ export default { type: "bar", data: [], }, - { - name: "调配变压器", - type: "bar", - data: [], - }, - { - name: "低压变压器柜器", - type: "bar", - data: [], - }, ], }, + mpointList: [], }; }, mounted() { let that = this; var myDate = new Date(); - let year = (that.year = myDate.getFullYear()); - let month = (that.month = myDate.getMonth() + 1); - let days = (that.days = myDate.getDate()); - let hours = (that.hours = myDate.getHours()); - let timeDate = myDate.getTime(); - that.timeStamp = timeDate; - let dayTime = 24 * 60 * 60 * 1000; - //昨天的计算 - let year_d = year, - month_d = month, - days_d = days; - if (hours < 21) { - //21点前,查找昨日数据为前一天数据 - let newDate = timeDate - dayTime; - let lastDate = new Date(newDate); - year_d = lastDate.getFullYear(); - month_d = lastDate.getMonth() + 1; - days_d = lastDate.getDate(); - } - //上一小时的计算 - let hourTime = timeDate - 3600000; - let hourDate = new Date(hourTime); - let year_h = hourDate.getFullYear(); - let month_h = hourDate.getMonth() + 1; - let days_h = hourDate.getDate(); - let hours_h = hourDate.getHours(); - this.$API.mtm.mgroup.list - .req({ page: 0, search: "原料磨" }) - .then((res) => { - console.log("原料磨", res); - that.query.mgroup = res[0].id; - //本月 - let params2 = {}; - params2.page = 0; - params2.year_s = year; - params2.month_s = month; - params2.type = "month_s"; - params2.mgroup = this.query.mgroup; - this.$API.enm.enstat - .req(params2) - .then((res2) => { - if (res2.length > 0) { - let hourProduct = (that.allValMonth = - res2[0].total_production); //当前条件下的总产量 - params2.mpoint__ep_monitored__power_kw__gte = 100; - this.$API.enm.mpoint.stat - .req(params2) - .then((res) => { - let data2 = res; - for (let i = 0; i < data2.length; i++) { - that.tableDatas[i] = []; - that.tableDatas[i][0] = - data2[i].ep_monitored_name; - that.tableDatas[i][1] = - data2[i].ep_monitored_number; - that.tableDatas[i][2] = "KW·h/t"; - let val = - hourProduct == 0 - ? "/" - : ( - data2[i].val / - hourProduct - ).toFixed(2); - that.tableDatas[i][5] = val; - } - }); - } - }) - .then((res2) => { - //昨日 - let params3 = {}; - params3.page = 0; - params3.year_s = year_d; - params3.month_s = month_d; - params3.day_s = days_d; - params3.type = "day_s"; - params3.mgroup = this.query.mgroup; - this.$API.enm.enstat.req(params3).then((res3) => { - if (res3.length > 0) { - let hourProduct = (that.allValDays = - res3[0].total_production); - params3.mpoint__ep_monitored__power_kw__gte = 100; - this.$API.enm.mpoint.stat - .req(params3) - .then((res) => { - let data3 = res3; - for (let j = 0; j < data3.length; j++) { - let val = - hourProduct == 0 - ? "/" - : ( - data3[j].val / - hourProduct - ).toFixed(2); - that.tableDatas[j][4] = val; - } - }); - } - }); - //上小时 - let params4 = {}; - params4.page = 0; - params4.year = year_h; - params4.month = month_h; - params4.day = days_h; - params4.hour = hours_h; - params4.type = "hour_s"; - params4.mgroup = this.query.mgroup; - this.$API.enm.enstat.req(params4).then((res4) => { - if (res4.length > 0) { - let hourProduct = (that.allValHour = - res4[0].total_production); - params4.mpoint__ep_monitored__power_kw__gte = 100; - this.$API.enm.mpoint.stat - .req(params4) - .then((res) => { - let data4 = res4; - for (let k = 0; k < data4.length; k++) { - let val = - hourProduct == 0 - ? "/" - : ( - data4[k].val / - hourProduct - ).toFixed(2); - that.tableDatas[k][3] = val; - } - }); - } - }); - }); - that.getHourData(); - that.getDayData(); - that.getMonthData(); - }); + that.year = myDate.getFullYear(); + that.month = myDate.getMonth() + 1; + that.days = myDate.getDate(); + that.hours = myDate.getHours(); + that.getTableHourData(); + that.getHourData(); + that.getDayData(); + that.getMonthData(); }, methods: { + getTableHourData() { + let that = this; + that.tableDatas = []; + let timeDate = new Date().getTime(); + let hourTime = timeDate - 3600000; + let hourDate = new Date(hourTime); + let year_h = hourDate.getFullYear(); + let month_h = hourDate.getMonth() + 1; + let days_h = hourDate.getDate(); + let hours_h = hourDate.getHours(); + let minutes = hourDate.getMinutes(); + month_h = month_h > 9 ? month_h : "0" + month_h; + days_h = days_h > 9 ? days_h : "0" + days_h; + if (hours_h > 5) { + hours_h = hours_h > 9 ? hours_h : "0" + hours_h; + } else { + hours_h = hours_h - 1; + hours_h = hours_h > 9 ? hours_h : "0" + hours_h; + } + let obj = {}; + obj.type = "hour_s"; + obj.year = year_h; + obj.month = month_h; + obj.day = days_h; + obj.hour = hours_h; + obj.mgroup__name = "原料磨"; + obj.mpoint__material__code__in = "elec,elec_0"; + obj.mpoint__ep_monitored__isnull = 0; + obj.mpoint__need_display = 1; + obj.page = 0; + this.$API.enm.mpoint.stat + .req(obj) + .then((res) => { + console.log("getTableHourData", res); + res.forEach((item) => { + let obj = []; + obj[0] = item.ep_monitored_name; + obj[1] = "KW·h/t"; + obj[2] = item.elec_consume_unit; + obj[3] = 0; + obj[4] = 0; + that.tableDatas.push(obj); + }); + }) + .then(() => { + let yetTime = timeDate - 3600000 * 24; + let ystDate = new Date(yetTime); + let year_h = ystDate.getFullYear(); + let month_h = ystDate.getMonth() + 1; + let days_h = ystDate.getDate(); + month_h = month_h > 9 ? month_h : "0" + month_h; + days_h = days_h > 9 ? days_h : "0" + days_h; + let obj = {}; + obj.type = "day_s"; + obj.year_s = year_h; + obj.month_s = month_h; + obj.day_s = days_h; + obj.mgroup__name = "原料磨"; + obj.mpoint__material__code__in = "elec,elec_0"; + obj.mpoint__ep_monitored__isnull = 0; + obj.mpoint__need_display = 1; + obj.page = 0; + this.$API.enm.mpoint.stat.req(obj).then((res) => { + console.log("getTableHourData", res); + res.forEach((item, index) => { + that.tableDatas[index][3] = item.elec_consume_unit; + }); + }); + }) + .then(() => { + let obj = {}; + obj.type = "month_s"; + obj.year_s = that.year; + obj.month_s = that.month; + obj.mgroup__name = "原料磨"; + obj.mpoint__material__code__in = "elec,elec_0"; + obj.mpoint__ep_monitored__isnull = 0; + obj.mpoint__need_display = 1; + obj.page = 0; + this.$API.enm.mpoint.stat.req(obj).then((res) => { + console.log("getTableHourData", res); + res.forEach((item, index) => { + that.tableDatas[index][4] = item.elec_consume_unit; + }); + }); + }); + }, //获取小时数据 getHourData() { let that = this; - let query = {}; - query.page = 0; - query.year_s = that.year; - query.month_s = that.month; - query.day_s = that.days; - query.type = "hour_s"; - query.mgroup = that.query.mgroup; - query.mpoint__ep_monitored__power_kw__gte = 100; - this.$API.enm.mpoint.stat.req(query).then((response) => { + let obj = {}; + obj.type = "hour_s"; + obj.year_s = that.year; + obj.month_s = that.month; + obj.day_s = that.days; + obj.mgroup__name = "原料磨"; + obj.mpoint__material__code__in = "elec,elec_0"; + obj.mpoint__ep_monitored__isnull = 0; + obj.mpoint__need_display = 1; + obj.page = 0; + this.$API.enm.mpoint.stat.req(obj).then((response) => { let seriesData0 = [], - seriesData1 = [], - seriesData2 = [], - seriesData3 = []; - let data = response; - data.forEach((item) => { - let ind = item.hour; - let val = 0; - if (that.allValHour == 0) { - val = ""; - } else { - val = (item.val / that.allValHour).toFixed(2); - } - if (item.equip_name == "辊压机") { - seriesData0[ind] = val; - } else if (item.equip_name == "循环风机") { - seriesData1[ind] = val; - } else if (item.equip_name == "调配变压器") { - seriesData2[ind] = val; - } else if (item.equip_name == "低压变压器柜器") { - seriesData3[ind] = val; + seriesData1 = []; + response.forEach((item) => { + console.log(item.ep_monitored_name); + let ind = item.hour - 1; + if (item.ep_monitored_name == "辊压机") { + seriesData0[ind] = item.elec_consume_unit; + } else if (item.ep_monitored_name == "循环风机") { + seriesData1[ind] = item.elec_consume_unit; } }); let options = { ...that.option1 }; options.series[0].data = seriesData0; options.series[1].data = seriesData1; - options.series[2].data = seriesData2; - options.series[3].data = seriesData3; let hourXAxis = []; - for (let i = 1; i <= that.hours; i++) { + for (let i = 1; i < that.hours + 1; i++) { let item = i + "时"; hourXAxis.push(item); } @@ -519,42 +437,30 @@ export default { //获取天数据 getDayData() { let that = this; - let query1 = {}; - query1.page = 0; - query1.year_s = that.year; - query1.month_s = that.month; - query1.type = "day_s"; - query1.mgroup = this.query.mgroup; - query1.mpoint__ep_monitored__power_kw__gte = 100; - this.$API.enm.enstat.req(query1).then((response) => { + let obj = {}; + obj.type = "day_s"; + obj.year_s = that.year; + obj.month_s = that.month; + obj.mgroup__name = "原料磨"; + obj.mpoint__material__code__in = "elec,elec_0"; + obj.mpoint__ep_monitored__isnull = 0; + obj.mpoint__need_display = 1; + obj.page = 0; + this.$API.enm.mpoint.stat.req(obj).then((response) => { let seriesData0 = [], - seriesData1 = [], - seriesData2 = [], - seriesData3 = []; + seriesData1 = []; let data = response; data.forEach((item) => { - let ind = item.day_s; - let val = 0; - if (that.allValDays == 0) { - val = ""; - } else { - val = (item.val / that.allValDays).toFixed(2); - } - if (item.equip_name == "辊压机") { - seriesData0[ind] = val; - } else if (item.equip_name == "循环风机") { - seriesData1[ind] = val; - } else if (item.equip_name == "调配变压器") { - seriesData2[ind] = val; - } else if (item.equip_name == "低压变压器柜器") { - seriesData3[ind] = val; + let ind = item.day_s - 1; + if (item.ep_monitored_name == "辊压机") { + seriesData0[ind] = item.elec_consume_unit; + } else if (item.ep_monitored_name == "循环风机") { + seriesData1[ind] = item.elec_consume_unit; } }); let options = { ...that.option2 }; options.series[0].data = seriesData0; options.series[1].data = seriesData1; - options.series[2].data = seriesData2; - options.series[3].data = seriesData3; let dayXAxis = []; for (let i = 1; i <= that.days; i++) { let item = i + "日"; @@ -567,41 +473,29 @@ export default { //获取月数据 getMonthData() { let that = this; - let query2 = {}; - query2.page = 0; - query2.year_s = that.year; - query2.type = "month_s"; - query2.mgroup = that.query.mgroup; - query2.mpoint__ep_monitored__power_kw__gte = 100; - this.$API.enm.enstat.req(query2).then((response) => { + let obj = {}; + obj.type = "month_s"; + obj.year_s = that.year; + obj.mgroup__name = "原料磨"; + obj.mpoint__material__code__in = "elec,elec_0"; + obj.mpoint__ep_monitored__isnull = 0; + obj.mpoint__need_display = 1; + obj.page = 0; + this.$API.enm.mpoint.stat.req(obj).then((response) => { let seriesData0 = [], - seriesData1 = [], - seriesData2 = [], - seriesData3 = []; + seriesData1 = []; let data = response; data.forEach((item) => { - let ind = item.month_s; - let val = 0; - if (that.allValMonth == 0) { - val = ""; - } else { - val = (item.val / that.allValMonth).toFixed(2); - } - if (item.equip_name == "辊压机") { - seriesData0[ind] = val; - } else if (item.equip_name == "循环风机") { - seriesData1[ind] = val; - } else if (item.equip_name == "调配变压器") { - seriesData2[ind] = val; - } else if (item.equip_name == "低压变压器柜器") { - seriesData3[ind] = val; + let ind = item.month_s - 1; + if (item.ep_monitored_name == "辊压机") { + seriesData0[ind] = item.elec_consume_unit; + } else if (item.ep_monitored_name == "循环风机") { + seriesData1[ind] = item.elec_consume_unit; } }); let options = { ...that.option3 }; options.series[0].data = seriesData0; options.series[1].data = seriesData1; - options.series[2].data = seriesData2; - options.series[3].data = seriesData3; let monthXAxis = []; for (let i = 1; i <= that.month; i++) { let item = i + "月";