fix:煤磨mgroup接口获取

This commit is contained in:
shijing 2024-04-26 10:41:11 +08:00
parent ffc08a38de
commit dbd019d0ef
4 changed files with 2626 additions and 2148 deletions

View File

@ -5,23 +5,28 @@
<el-button
type="primary"
@click="exportExcel()"
:loading = "exportLoading"
:loading="exportLoading"
>导出xlsx
</el-button>
<el-button
type="primary"
@click="handlePrint"
>打印
</el-button>
<el-button type="primary" @click="handlePrint">打印 </el-button>
</div>
</el-header>
<el-card style="margin-top:5px">
<el-card style="margin-top: 5px">
<div class="printWrap">
<div ref="print" id="myReport" class="printContainer">
<table border="1" width="1035" cellspacing="0" :key="timeStamp" class="myTable" id="myTable">
<table
border="1"
width="1035"
cellspacing="0"
:key="timeStamp"
class="myTable"
id="myTable"
>
<thead class="myTableHead">
<tr>
<th colspan="6">煤磨工段主要设备100KW以上单位产品电耗数据表</th>
<th colspan="6">
煤磨工段主要设备100KW以上单位产品电耗数据表
</th>
</tr>
<tr>
<th>设备名称</th>
@ -34,26 +39,64 @@
</thead>
<tbody>
<tr v-for="item in tableDatas" :key="item">
<template v-for="(item1,ind) in item" :key="item1">
<td v-if="ind==0||ind==1||ind==2" class="numCell">{{item1}}</td>
<td v-if="ind==3" class="numCell hoursItem" @click="itemClick('hour_s',item1)">{{item1}}</td>
<td v-if="ind==4" class="numCell monthItem" @click="itemClick('day_s',item1)">{{item1}}</td>
<td v-if="ind==5" class="numCell yearItem" @click="itemClick('month_s',item1)">{{item1}}</td>
<template
v-for="(item1, ind) in item"
:key="item1"
>
<td
v-if="ind == 0 || ind == 1 || ind == 2"
class="numCell"
>
{{ item1 }}
</td>
<td
v-if="ind == 3"
class="numCell hoursItem"
@click="itemClick('hour_s', item1)"
>
{{ item1 }}
</td>
<td
v-if="ind == 4"
class="numCell monthItem"
@click="itemClick('day_s', item1)"
>
{{ item1 }}
</td>
<td
v-if="ind == 5"
class="numCell yearItem"
@click="itemClick('month_s', item1)"
>
{{ item1 }}
</td>
</template>
</tr>
</tbody>
</table>
<div class="chartWrap">
<div class="chartTitle">小时生产参数统计图</div>
<scEcharts height="400px" width="1033px" :option="optionHour"></scEcharts>
<scEcharts
height="400px"
width="1033px"
:option="optionHour"
></scEcharts>
</div>
<div class="chartWrap">
<div class="chartTitle">本月生产参数统计图</div>
<scEcharts height="400px" width="1033px" :option="optionDay"></scEcharts>
<scEcharts
height="400px"
width="1033px"
:option="optionDay"
></scEcharts>
</div>
<div class="chartWrap">
<div class="chartTitle">本年生产参数统计图</div>
<scEcharts height="400px" width="1033px" :option="optionMonth"></scEcharts>
<scEcharts
height="400px"
width="1033px"
:option="optionMonth"
></scEcharts>
</div>
</div>
</div>
@ -62,128 +105,109 @@
:type="type"
:title="title"
:cate="cate"
:apiObj = "apiObj"
:apiObj="apiObj"
:mgroup="query.mgroup"
:modelValue="modelValue"
:showClose="showClose"
:echartType='echartType'
:echartType="echartType"
@closed="asynDialog = false"
></charts>
</el-card>
</div>
</template>
<script>
const colors =['#647bfe','#8698fe','#a9b6fe','#cbd3fe','#91CC75','#EE6666'];
let tooltip= {
const colors = [
"#647bfe",
"#8698fe",
"#a9b6fe",
"#cbd3fe",
"#91CC75",
"#EE6666",
];
let tooltip = {
show: true,
trigger: 'axis',
trigger: "axis",
axisPointer: {
type: 'cross'
type: "cross",
},
confine:false,
confine: false,
showContent: true,
triggerOn:"mousemove",
triggerOn: "mousemove",
// alwaysShowContent:true,
};
let grid={
right: '3%',
left:'7%',
top:'15%'
};
let toolbox={
right:'5%',
};
let grid = {
right: "3%",
left: "7%",
top: "15%",
};
let toolbox = {
right: "5%",
feature: {
dataView: { show: true, readOnly: false },
// restore: { show: true },
saveAsImage: { show: true }
}
};
let legend= {
top:'2%',
data:['煤磨排风机主电机', '煤磨主电机']
};
let yAxis= {
type: 'value',
name: '分布电耗(KW.h/t)',
saveAsImage: { show: true },
},
};
let legend = {
top: "2%",
data: ["煤磨排风机主电机", "煤磨主电机"],
};
let yAxis = {
type: "value",
name: "分布电耗(KW.h/t)",
alignTicks: true,
axisLine: {
show: true,
lineStyle: {
color: colors[3]
}
color: colors[3],
},
},
axisLabel: {
formatter: '{value}'
}
};
import scEcharts from "@/components/scEcharts";
import { defineAsyncComponent } from 'vue'
export default {
formatter: "{value}",
},
};
import scEcharts from "@/components/scEcharts";
import { defineAsyncComponent } from "vue";
export default {
components: {
scEcharts,
charts: defineAsyncComponent(() => import("@/components/scEnm/lineChartsdialog.vue")),
charts: defineAsyncComponent(() =>
import("@/components/scEnm/lineChartsdialog.vue")
),
},
data() {
return {
chartShow: false,
myOption: null,
optionHour:{},
optionDay:{},
optionMonth:{},
year:2023,
month:1,
days:1,
hours:1,
optionHour: {},
optionDay: {},
optionMonth: {},
year: 2023,
month: 1,
days: 1,
hours: 1,
query: {
mgroup:'3347217512021835776',
mgroup: "",
},
tableName:'主要设备100KW以上单位产品电耗数据表',
tableDatas:[
['煤磨排风机主电机','','KW·h/t','','',''],
['煤磨主电机','','KW·h/t','','',''],
tableName: "主要设备100KW以上单位产品电耗数据表",
tableDatas: [
["煤磨排风机主电机", "", "KW·h/t", "", "", ""],
["煤磨主电机", "", "KW·h/t", "", "", ""],
],
modelValue:true,
type:'hour_s',
title:'煤磨工段',
cate:'',
apiObj:this.$API.enm.mpoint.stat,
showClose:true,
echartType:'line',
asynDialog:false,
allValHour:0,
allValDays:0,
allValMonth:0,
option1:{
modelValue: true,
type: "hour_s",
title: "煤磨工段",
cate: "",
apiObj: this.$API.enm.mpoint.stat,
showClose: true,
echartType: "line",
asynDialog: false,
allValHour: 0,
allValDays: 0,
allValMonth: 0,
option1: {
color: colors,
tooltip:tooltip,
grid: grid,
toolbox: toolbox,
legend:legend,
xAxis: {
axisTick: {
show: true,
length: 5,
inside: true,
},
data: []
},
yAxis:yAxis,
series:[
{
name: '煤磨排风机主电机',
type: 'bar',
data:[]
},
{
name: '煤磨主电机',
type: 'bar',
data: []
},
]
},
option2:{
color: colors,
tooltip:tooltip,
tooltip: tooltip,
grid: grid,
toolbox: toolbox,
legend: legend,
@ -193,25 +217,25 @@ const colors =['#647bfe','#8698fe','#a9b6fe','#cbd3fe','#91CC75','#EE6666'];
length: 5,
inside: true,
},
data: []
data: [],
},
yAxis: yAxis,
series:[
series: [
{
name: '煤磨排风机主电机',
type: 'bar',
data:[]
name: "煤磨排风机主电机",
type: "bar",
data: [],
},
{
name: '煤磨主电机',
type: 'bar',
data: []
name: "煤磨主电机",
type: "bar",
data: [],
},
]
],
},
option3:{
option2: {
color: colors,
tooltip:tooltip,
tooltip: tooltip,
grid: grid,
toolbox: toolbox,
legend: legend,
@ -221,94 +245,166 @@ const colors =['#647bfe','#8698fe','#a9b6fe','#cbd3fe','#91CC75','#EE6666'];
length: 5,
inside: true,
},
data: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月']
data: [],
},
yAxis: yAxis,
series:[
series: [
{
name: '煤磨排风机主电机',
type: 'bar',
data:[]
name: "煤磨排风机主电机",
type: "bar",
data: [],
},
{
name: '煤磨主电机',
type: 'bar',
data: []
name: "煤磨主电机",
type: "bar",
data: [],
},
],
},
option3: {
color: colors,
tooltip: tooltip,
grid: grid,
toolbox: toolbox,
legend: legend,
xAxis: {
axisTick: {
show: true,
length: 5,
inside: true,
},
data: [
"一月",
"二月",
"三月",
"四月",
"五月",
"六月",
"七月",
"八月",
"九月",
"十月",
"十一月",
"十二月",
],
},
yAxis: yAxis,
series: [
{
name: "煤磨排风机主电机",
type: "bar",
data: [],
},
{
name: "煤磨主电机",
type: "bar",
data: [],
},
],
},
]
}
};
},
mounted() {
let that = this;
var myDate = new Date();
let year = myDate.getFullYear();
let month = myDate.getMonth()+1;
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 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;
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 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.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;
this.$API.enm.mpoint.stat.req(params2).then((res) => {
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;
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=>{
.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.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;
this.$API.enm.mpoint.stat.req(params3).then((res) => {
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 val =
hourProduct == 0
? "/"
: (
data3[j].val /
hourProduct
).toFixed(2);
that.tableDatas[j][4] = val;
}
})
});
}
})
});
//
let params4 = {};
params4.page = 0;
@ -316,163 +412,176 @@ const colors =['#647bfe','#8698fe','#a9b6fe','#cbd3fe','#91CC75','#EE6666'];
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.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;
this.$API.enm.mpoint.stat.req(params4).then((res) => {
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;
let val =
hourProduct == 0
? "/"
: (
data4[k].val /
hourProduct
).toFixed(2);
that.tableDatas[k][3] = val;
}
})
});
}
})
})
});
});
that.getHourData();
that.getDayData();
that.getMonthData();
});
},
methods: {
//
getHourData(){
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.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 seriesData0 = [],seriesData1 = [];
let seriesData0 = [],
seriesData1 = [];
let data = response;
data.forEach(item => {
data.forEach((item) => {
let ind = item.hour;
let val=0;
if(that.allValHour==0){
val = ''
}else{
val = (item.val/that.allValHour).toFixed(2);
let val = 0;
if (that.allValHour == 0) {
val = "";
} else {
val = (item.val / that.allValHour).toFixed(2);
}
if(item.equip_name=='煤磨排风机主电机'){
if (item.equip_name == "煤磨排风机主电机") {
seriesData0[ind] = val;
}else if(item.equip_name=='煤磨主电机'){
} else if (item.equip_name == "煤磨主电机") {
seriesData1[ind] = val;
}
});
let options = {...that.option1};
options.series[0].data=seriesData0;
options.series[1].data=seriesData1;
let options = { ...that.option1 };
options.series[0].data = seriesData0;
options.series[1].data = seriesData1;
let hourXAxis = [];
for (let i = 1; i <= that.hours; i++) {
let item = i+'时'
hourXAxis.push(item)
let item = i + "时";
hourXAxis.push(item);
}
options.xAxis.data = hourXAxis;
that.optionHour = options;
})
});
},
//
getDayData(){
getDayData() {
let that = this;
let query1 = {};
query1.page = 0;
query1.year_s = that.year;
query1.month_s = that.month;
query1.type = 'day_s';
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 seriesData0 = [],seriesData1 = [];
let seriesData0 = [],
seriesData1 = [];
let data = response;
data.forEach(item => {
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);
let val = 0;
if (that.allValDays == 0) {
val = "";
} else {
val = (item.val / that.allValDays).toFixed(2);
}
if(item.equip_name=='煤磨排风机主电机'){
if (item.equip_name == "煤磨排风机主电机") {
seriesData0[ind] = val;
}else if(item.equip_name=='煤磨主电机'){
} else if (item.equip_name == "煤磨主电机") {
seriesData1[ind] = val;
}
});
let options = {...that.option2};
options.series[0].data=seriesData0;
options.series[1].data=seriesData1;
let options = { ...that.option2 };
options.series[0].data = seriesData0;
options.series[1].data = seriesData1;
let dayXAxis = [];
for (let i = 1; i <= that.days; i++) {
let item = i+'日'
dayXAxis.push(item)
let item = i + "日";
dayXAxis.push(item);
}
options.xAxis.data = dayXAxis;
that.optionDay = options;
})
});
},
//
getMonthData(){
getMonthData() {
let that = this;
let query2 = {};
query2.page = 0;
query2.year_s = that.year;
query2.type = 'month_s';
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 seriesData0 = [],seriesData1 = [];
let seriesData0 = [],
seriesData1 = [];
let data = response;
data.forEach(item => {
data.forEach((item) => {
let ind = item.month_s;
let val=0;
if(that.allValMonth==0){
val = ''
}else{
val = (item.val/that.allValMonth).toFixed(2);
let val = 0;
if (that.allValMonth == 0) {
val = "";
} else {
val = (item.val / that.allValMonth).toFixed(2);
}
if(item.equip_name=='煤磨排风机主电机'){
if (item.equip_name == "煤磨排风机主电机") {
seriesData0[ind] = val;
}else if(item.equip_name=='煤磨主电机'){
} else if (item.equip_name == "煤磨主电机") {
seriesData1[ind] = val;
}
});
let options = {...that.option3};
options.series[0].data=seriesData0;
options.series[1].data=seriesData1;
let options = { ...that.option3 };
options.series[0].data = seriesData0;
options.series[1].data = seriesData1;
let monthXAxis = [];
for (let i = 1; i <= that.month; i++) {
let item = i+'月'
monthXAxis.push(item)
let item = i + "月";
monthXAxis.push(item);
}
options.xAxis.data = monthXAxis;
that.optionMonth = options;
})
});
},
itemClick(type,item){
this.type=type;
itemClick(type, item) {
this.type = type;
this.cate = item[0];
this.asynDialog = true;
},
handlePrint() {
this.$PRINT('#myReport');
this.$PRINT("#myReport");
},
exportExcel() {
this.exportLoading = true;
this.$XLSX('#myTable', this.tableName)
this.$XLSX("#myTable", this.tableName);
this.exportLoading = false;
},
}
};
},
};
</script>
<style scoped>
.printContainer{
.printContainer {
padding-left: 20px;
}
</style>

File diff suppressed because it is too large Load Diff

View File

@ -5,23 +5,28 @@
<el-button
type="primary"
@click="exportExcel()"
:loading = "exportLoading"
:loading="exportLoading"
>导出xlsx
</el-button>
<el-button
type="primary"
@click="handlePrint"
>打印
</el-button>
<el-button type="primary" @click="handlePrint">打印 </el-button>
</div>
</el-header>
<el-card style="margin-top:5px">
<el-card style="margin-top: 5px">
<div class="printWrap">
<div ref="print" id="myReport" class="printContainer">
<table border="1" width="1035" cellspacing="0" :key="timeStamp" class="myTable" id="myTable">
<table
border="1"
width="1035"
cellspacing="0"
:key="timeStamp"
class="myTable"
id="myTable"
>
<thead class="myTableHead">
<tr>
<th colspan="6">煤磨工段主要设备100KW以上单位产品电耗数据表</th>
<th colspan="6">
煤磨工段主要设备100KW以上单位产品电耗数据表
</th>
</tr>
<tr>
<th>设备名称</th>
@ -34,26 +39,64 @@
</thead>
<tbody>
<tr v-for="item in tableDatas" :key="item">
<template v-for="(item1,ind) in item" :key="item1">
<td v-if="ind==0||ind==1||ind==2" class="numCell">{{item1}}</td>
<td v-if="ind==3" class="numCell hoursItem" @click="itemClick('hour_s',item1)">{{item1}}</td>
<td v-if="ind==4" class="numCell monthItem" @click="itemClick('day_s',item1)">{{item1}}</td>
<td v-if="ind==5" class="numCell yearItem" @click="itemClick('month_s',item1)">{{item1}}</td>
<template
v-for="(item1, ind) in item"
:key="item1"
>
<td
v-if="ind == 0 || ind == 1 || ind == 2"
class="numCell"
>
{{ item1 }}
</td>
<td
v-if="ind == 3"
class="numCell hoursItem"
@click="itemClick('hour_s', item1)"
>
{{ item1 }}
</td>
<td
v-if="ind == 4"
class="numCell monthItem"
@click="itemClick('day_s', item1)"
>
{{ item1 }}
</td>
<td
v-if="ind == 5"
class="numCell yearItem"
@click="itemClick('month_s', item1)"
>
{{ item1 }}
</td>
</template>
</tr>
</tbody>
</table>
<div class="chartWrap">
<div class="chartTitle">小时生产参数统计图</div>
<scEcharts height="400px" width="1033px" :option="optionHour"></scEcharts>
<scEcharts
height="400px"
width="1033px"
:option="optionHour"
></scEcharts>
</div>
<div class="chartWrap">
<div class="chartTitle">本月生产参数统计图</div>
<scEcharts height="400px" width="1033px" :option="optionDay"></scEcharts>
<scEcharts
height="400px"
width="1033px"
:option="optionDay"
></scEcharts>
</div>
<div class="chartWrap">
<div class="chartTitle">本年生产参数统计图</div>
<scEcharts height="400px" width="1033px" :option="optionMonth"></scEcharts>
<scEcharts
height="400px"
width="1033px"
:option="optionMonth"
></scEcharts>
</div>
</div>
</div>
@ -62,128 +105,109 @@
:type="type"
:title="title"
:cate="cate"
:apiObj = "apiObj"
:apiObj="apiObj"
:mgroup="query.mgroup"
:modelValue="modelValue"
:showClose="showClose"
:echartType='echartType'
:echartType="echartType"
@closed="asynDialog = false"
></charts>
</el-card>
</div>
</template>
<script>
const colors =['#647bfe','#8698fe','#a9b6fe','#cbd3fe','#91CC75','#EE6666'];
let tooltip= {
const colors = [
"#647bfe",
"#8698fe",
"#a9b6fe",
"#cbd3fe",
"#91CC75",
"#EE6666",
];
let tooltip = {
show: true,
trigger: 'axis',
trigger: "axis",
axisPointer: {
type: 'cross'
type: "cross",
},
confine:false,
confine: false,
showContent: true,
triggerOn:"mousemove",
triggerOn: "mousemove",
// alwaysShowContent:true,
};
let grid={
right: '3%',
left:'7%',
top:'15%'
};
let toolbox={
right:'5%',
};
let grid = {
right: "3%",
left: "7%",
top: "15%",
};
let toolbox = {
right: "5%",
feature: {
dataView: { show: true, readOnly: false },
// restore: { show: true },
saveAsImage: { show: true }
}
};
let legend= {
top:'2%',
data:['煤磨排风机主电机', '煤磨主电机']
};
let yAxis= {
type: 'value',
name: '分布电耗(KW.h/t)',
saveAsImage: { show: true },
},
};
let legend = {
top: "2%",
data: ["煤磨排风机主电机", "煤磨主电机"],
};
let yAxis = {
type: "value",
name: "分布电耗(KW.h/t)",
alignTicks: true,
axisLine: {
show: true,
lineStyle: {
color: colors[3]
}
color: colors[3],
},
},
axisLabel: {
formatter: '{value}'
}
};
import scEcharts from "@/components/scEcharts";
import { defineAsyncComponent } from 'vue'
export default {
formatter: "{value}",
},
};
import scEcharts from "@/components/scEcharts";
import { defineAsyncComponent } from "vue";
export default {
components: {
scEcharts,
charts: defineAsyncComponent(() => import("@/components/scEnm/lineChartsdialog.vue")),
charts: defineAsyncComponent(() =>
import("@/components/scEnm/lineChartsdialog.vue")
),
},
data() {
return {
chartShow: false,
myOption: null,
optionHour:{},
optionDay:{},
optionMonth:{},
year:2023,
month:1,
days:1,
hours:1,
optionHour: {},
optionDay: {},
optionMonth: {},
year: 2023,
month: 1,
days: 1,
hours: 1,
query: {
mgroup:'3347217512021835776',
mgroup: "",
},
tableName:'主要设备100KW以上单位产品电耗数据表',
tableDatas:[
['煤磨排风机主电机','','KW·h/t','','',''],
['煤磨主电机','','KW·h/t','','',''],
tableName: "主要设备100KW以上单位产品电耗数据表",
tableDatas: [
["煤磨排风机主电机", "", "KW·h/t", "", "", ""],
["煤磨主电机", "", "KW·h/t", "", "", ""],
],
modelValue:true,
type:'hour_s',
title:'煤磨工段',
cate:'',
apiObj:this.$API.enm.mpoint.stat,
showClose:true,
echartType:'line',
asynDialog:false,
allValHour:0,
allValDays:0,
allValMonth:0,
option1:{
modelValue: true,
type: "hour_s",
title: "煤磨工段",
cate: "",
apiObj: this.$API.enm.mpoint.stat,
showClose: true,
echartType: "line",
asynDialog: false,
allValHour: 0,
allValDays: 0,
allValMonth: 0,
option1: {
color: colors,
tooltip:tooltip,
grid: grid,
toolbox: toolbox,
legend:legend,
xAxis: {
axisTick: {
show: true,
length: 5,
inside: true,
},
data: []
},
yAxis:yAxis,
series:[
{
name: '煤磨排风机主电机',
type: 'bar',
data:[]
},
{
name: '煤磨主电机',
type: 'bar',
data: []
},
]
},
option2:{
color: colors,
tooltip:tooltip,
tooltip: tooltip,
grid: grid,
toolbox: toolbox,
legend: legend,
@ -193,25 +217,25 @@ const colors =['#647bfe','#8698fe','#a9b6fe','#cbd3fe','#91CC75','#EE6666'];
length: 5,
inside: true,
},
data: []
data: [],
},
yAxis: yAxis,
series:[
series: [
{
name: '煤磨排风机主电机',
type: 'bar',
data:[]
name: "煤磨排风机主电机",
type: "bar",
data: [],
},
{
name: '煤磨主电机',
type: 'bar',
data: []
name: "煤磨主电机",
type: "bar",
data: [],
},
]
],
},
option3:{
option2: {
color: colors,
tooltip:tooltip,
tooltip: tooltip,
grid: grid,
toolbox: toolbox,
legend: legend,
@ -221,94 +245,166 @@ const colors =['#647bfe','#8698fe','#a9b6fe','#cbd3fe','#91CC75','#EE6666'];
length: 5,
inside: true,
},
data: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月']
data: [],
},
yAxis: yAxis,
series:[
series: [
{
name: '煤磨排风机主电机',
type: 'bar',
data:[]
name: "煤磨排风机主电机",
type: "bar",
data: [],
},
{
name: '煤磨主电机',
type: 'bar',
data: []
name: "煤磨主电机",
type: "bar",
data: [],
},
],
},
option3: {
color: colors,
tooltip: tooltip,
grid: grid,
toolbox: toolbox,
legend: legend,
xAxis: {
axisTick: {
show: true,
length: 5,
inside: true,
},
data: [
"一月",
"二月",
"三月",
"四月",
"五月",
"六月",
"七月",
"八月",
"九月",
"十月",
"十一月",
"十二月",
],
},
yAxis: yAxis,
series: [
{
name: "煤磨排风机主电机",
type: "bar",
data: [],
},
{
name: "煤磨主电机",
type: "bar",
data: [],
},
],
},
]
}
};
},
mounted() {
let that = this;
var myDate = new Date();
let year = myDate.getFullYear();
let month = myDate.getMonth()+1;
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 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;
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 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.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;
this.$API.enm.mpoint.stat.req(params2).then((res) => {
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;
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=>{
.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.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;
this.$API.enm.mpoint.stat.req(params3).then((res) => {
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 val =
hourProduct == 0
? "/"
: (
data3[j].val /
hourProduct
).toFixed(2);
that.tableDatas[j][4] = val;
}
})
});
}
})
});
//
let params4 = {};
params4.page = 0;
@ -316,163 +412,176 @@ const colors =['#647bfe','#8698fe','#a9b6fe','#cbd3fe','#91CC75','#EE6666'];
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.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;
this.$API.enm.mpoint.stat.req(params4).then((res) => {
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;
let val =
hourProduct == 0
? "/"
: (
data4[k].val /
hourProduct
).toFixed(2);
that.tableDatas[k][3] = val;
}
})
});
}
})
})
});
});
that.getHourData();
that.getDayData();
that.getMonthData();
});
},
methods: {
//
getHourData(){
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.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 seriesData0 = [],seriesData1 = [];
let seriesData0 = [],
seriesData1 = [];
let data = response;
data.forEach(item => {
data.forEach((item) => {
let ind = item.hour;
let val=0;
if(that.allValHour==0){
val = ''
}else{
val = (item.val/that.allValHour).toFixed(2);
let val = 0;
if (that.allValHour == 0) {
val = "";
} else {
val = (item.val / that.allValHour).toFixed(2);
}
if(item.equip_name=='煤磨排风机主电机'){
if (item.equip_name == "煤磨排风机主电机") {
seriesData0[ind] = val;
}else if(item.equip_name=='煤磨主电机'){
} else if (item.equip_name == "煤磨主电机") {
seriesData1[ind] = val;
}
});
let options = {...that.option1};
options.series[0].data=seriesData0;
options.series[1].data=seriesData1;
let options = { ...that.option1 };
options.series[0].data = seriesData0;
options.series[1].data = seriesData1;
let hourXAxis = [];
for (let i = 1; i <= that.hours; i++) {
let item = i+'时'
hourXAxis.push(item)
let item = i + "时";
hourXAxis.push(item);
}
options.xAxis.data = hourXAxis;
that.optionHour = options;
})
});
},
//
getDayData(){
getDayData() {
let that = this;
let query1 = {};
query1.page = 0;
query1.year_s = that.year;
query1.month_s = that.month;
query1.type = 'day_s';
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 seriesData0 = [],seriesData1 = [];
let seriesData0 = [],
seriesData1 = [];
let data = response;
data.forEach(item => {
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);
let val = 0;
if (that.allValDays == 0) {
val = "";
} else {
val = (item.val / that.allValDays).toFixed(2);
}
if(item.equip_name=='煤磨排风机主电机'){
if (item.equip_name == "煤磨排风机主电机") {
seriesData0[ind] = val;
}else if(item.equip_name=='煤磨主电机'){
} else if (item.equip_name == "煤磨主电机") {
seriesData1[ind] = val;
}
});
let options = {...that.option2};
options.series[0].data=seriesData0;
options.series[1].data=seriesData1;
let options = { ...that.option2 };
options.series[0].data = seriesData0;
options.series[1].data = seriesData1;
let dayXAxis = [];
for (let i = 1; i <= that.days; i++) {
let item = i+'日'
dayXAxis.push(item)
let item = i + "日";
dayXAxis.push(item);
}
options.xAxis.data = dayXAxis;
that.optionDay = options;
})
});
},
//
getMonthData(){
getMonthData() {
let that = this;
let query2 = {};
query2.page = 0;
query2.year_s = that.year;
query2.type = 'month_s';
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 seriesData0 = [],seriesData1 = [];
let seriesData0 = [],
seriesData1 = [];
let data = response;
data.forEach(item => {
data.forEach((item) => {
let ind = item.month_s;
let val=0;
if(that.allValMonth==0){
val = ''
}else{
val = (item.val/that.allValMonth).toFixed(2);
let val = 0;
if (that.allValMonth == 0) {
val = "";
} else {
val = (item.val / that.allValMonth).toFixed(2);
}
if(item.equip_name=='煤磨排风机主电机'){
if (item.equip_name == "煤磨排风机主电机") {
seriesData0[ind] = val;
}else if(item.equip_name=='煤磨主电机'){
} else if (item.equip_name == "煤磨主电机") {
seriesData1[ind] = val;
}
});
let options = {...that.option3};
options.series[0].data=seriesData0;
options.series[1].data=seriesData1;
let options = { ...that.option3 };
options.series[0].data = seriesData0;
options.series[1].data = seriesData1;
let monthXAxis = [];
for (let i = 1; i <= that.month; i++) {
let item = i+'月'
monthXAxis.push(item)
let item = i + "月";
monthXAxis.push(item);
}
options.xAxis.data = monthXAxis;
that.optionMonth = options;
})
});
},
itemClick(type,item){
this.type=type;
itemClick(type, item) {
this.type = type;
this.cate = item[0];
this.asynDialog = true;
},
handlePrint() {
this.$PRINT('#myReport');
this.$PRINT("#myReport");
},
exportExcel() {
this.exportLoading = true;
this.$XLSX('#myTable', this.tableName)
this.$XLSX("#myTable", this.tableName);
this.exportLoading = false;
},
}
};
},
};
</script>
<style scoped>
.printContainer{
.printContainer {
padding-left: 20px;
}
</style>

File diff suppressed because it is too large Load Diff