fix:tkx电石渣工序班组月度对比修改

This commit is contained in:
shijing 2024-12-30 09:59:16 +08:00
parent 4bad854f10
commit 11d38f5508
1 changed files with 123 additions and 145 deletions

View File

@ -95,24 +95,11 @@ export default {
let year = myDate.getFullYear();
this.timeStamp = myDate.getTime();
that.query.year_s = year;
this.$API.mtm.mgroup.list
.req({ page: 0, search: "电石渣" })
.then((res) => {
that.query.mgroup = res[0].id;
let params = {};
params.page = 0;
params.year = year;
params.mgroup = that.query.mgroup;
this.$API.mtm.goal.list.req(params).then((res) => {
if (res.length > 0) {
res.forEach((item) => {
if (item.goal_cate_name == "单位产品分布电耗KW·h/t") {
that.getData(item);
}
})
}
});
});
this.$API.mtm.mgroup.list.req({ page: 0, search: "电石渣" }).then((res) => {
console.log("工段数据:", res);
that.query.mgroup = res[0].id;
that.getGoalData();
});
},
methods: {
getGoalData() {
@ -121,18 +108,18 @@ export default {
params.page = 0;
params.year = self.query.year_s;
params.mgroup = self.query.mgroup;
this.$API.mtm.goal.list.req(params).then((res) => {
self.$API.mtm.goal.list.req(params).then((res) => {
if (res.length > 0) {
res.forEach((item) => {
if (item.goal_cate_name == "单位产品分布电耗(KW·h/t") {
this.getData(item);
}
})
}
})
.catch((error) => {
console.error('获取目标数据失败:', error);
});
res.forEach((item) => {
if (item.goal_cate_name == "单位产品分布电耗(kW·h/t") {
console.log("目标数据:", item);
self.getData(item);
}
})
}
}).catch((error) => {
console.error('获取目标数据失败:', error);
});
},
getData(goalData) {
let that = this;
@ -155,120 +142,118 @@ export default {
} else {
}
});
this.$API.enm.enstat.req(that.query).then((res) => {
let data = res;
if (data.length > 0) {
data.forEach((item, index) => {
//
let compareArr = [];
compareArr.push(item.month_s);
compareArr.push(item.team_name);
compareArr.push(item.elec_consume_unit);
compareArr0[index]=compareArr;
if (!month_obj[item.month_s]) {
month_obj[item.month_s] = [];
this.$API.enm.enstat.req(that.query).then((res) => {
let data = res;
if (data.length > 0) {
data.forEach((item, index) => {
//
let compareArr = [];
compareArr.push(item.month_s);
compareArr.push(item.team_name);
compareArr.push(item.elec_consume_unit);
compareArr0[index]=compareArr;
if (!month_obj[item.month_s]) {
month_obj[item.month_s] = [];
}
month_obj[item.month_s].push(
{
team:item.team_name,
value: item.elec_consume_unit,
elec_consume: item.elec_consume
}
month_obj[item.month_s].push(
{
team:item.team_name,
value: item.elec_consume_unit,
elec_consume: item.elec_consume
}
);
// month_list.push(month_obj)
});
data.forEach((item) => {
//
let n = item.month_s;
let arr = [];
let time = "" + item.year_s + "." + item.month_s;
arr.push(time);
arr.push(item.team_name);
arr.push(item.total_production);
arr.push(item.production_hour);
);
// month_list.push(month_obj)
});
data.forEach((item) => {
//
let n = item.month_s;
let arr = [];
let time = "" + item.year_s + "." + item.month_s;
arr.push(time);
arr.push(item.team_name);
arr.push(item.total_production);
arr.push(item.production_hour);
arr[4] = item.elec_consume_unit; //KW·h/t
let keyVale = "goal_val_" + n;
arr[5] = goalData[keyVale]; //KW·h/t//
arr[6] = (arr[4] - arr[5]).toFixed(2); //KW·h/t
let ind_pre = 0,
huanqi = 0,
huanqicha = 0,
tongqi = 0,
tongqicha = 0;
if (n == 1) {
ind_pre = 12;
huanqi = wrapArr0[ind_pre]
? wrapArr0[ind_pre].elec_consume_unit
: "/";
} else {
// wrapArr0wrapArritem.month_s1 item.namehuanbi
compareArr0.forEach((item0) => {
if (item0[0] == item.month_s - 1 && item0[1] == item.team_name) {
huanqi = item0[2];
}
})
arr[4] = item.elec_consume_unit; //KW·h/t
let keyVale = "goal_val_" + n;
arr[5] = goalData[keyVale]; //KW·h/t//
arr[6] = (arr[4] - arr[5]).toFixed(2); //KW·h/t
let ind_pre = 0,
huanqi = 0,
tongqi = 0,
tongqicha = 0;
if (n == 1) {
ind_pre = 12;
huanqi = wrapArr0[ind_pre]
? wrapArr0[ind_pre].elec_consume_unit
: "/";
} else {
// wrapArr0wrapArritem.month_s1 item.namehuanbi
compareArr0.forEach((item0) => {
if (item0[0] == item.month_s - 1 && item0[1] == item.team_name) {
huanqi = item0[2];
}
arr[7] = huanqi; //KW·h/t
if (arr[6] !== "/"){
arr[8] = (arr[4] - arr[7]).toFixed(2); //KW·h/t
}else{
arr[8] = "/"; //KW·h/t
})
}
arr[7] = Number(huanqi); //KW·h/t
if (arr[6] !== "/"){
arr[8] = (Number(arr[4]) - arr[7]).toFixed(2); //KW·h/t
}else{
arr[8] = "/"; //KW·h/t
}
let growthRate = 0;
if (arr[8]!== "/" && arr[7]!== 0 && arr[8]!== 0 ) {
growthRate = ((Number(arr[8]) /arr[7]) * 100).toFixed(2);
} else{
growthRate = "/";
}
arr[9] = growthRate; //%
if (wrapArr0[n]) {
tongqicha =
item.celec_consume_unit -
wrapArr0[n].celec_consume_unit;
tongqi = tongqicha / tongqi;
} else {
tongqicha = item.celec_consume_unit;
tongqi = 0;
}
arr[10] = tongqi; //%
//n = month_listkeyvalue, index==0arr[11] = 100 index==1arr[11] = 80 index==2arr[11] = 70 index==3arr[11] = 0
if (month_obj[n]) {
const monthData = month_obj[n];
const itemValue = item.elec_consume_unit; //
const sortedData = monthData.sort((a, b) => parseFloat(b.value) - parseFloat(a.value));
const index = sortedData.findIndex(obj => parseFloat(obj.value) === parseFloat(itemValue));
if (index === 0){
arr[11] = 50;
} else if (index === 1) {
arr[11] = 40;
} else if (index === 2) {
arr[11] = 30;
} else if (index === 3) {
arr[11] = 20;
}
// arr[8] = huanqicha; //KW·h/t
let growthRate = 0;
if (arr[8]!== "/" && arr[7]!== 0 && arr[8]!== 0 ) {
growthRate = ((arr[8] / arr[7]) * 100).toFixed(2);
} else{
growthRate = "/";
const total_elec_consume = item.elec_consume;
const sortedTotalData = monthData.sort((a, b) => parseFloat(b.elec_consume) - parseFloat(a.elec_consume));
const totalIndex = sortedTotalData.findIndex(obj => parseFloat(obj.elec_consume) === parseFloat(total_elec_consume));
let total_elec_consume_score = 0;
if (totalIndex === 0){
total_elec_consume_score = 50;
} else if (totalIndex === 1) {
total_elec_consume_score = 40;
} else if (totalIndex === 2) {
total_elec_consume_score = 30;
} else if (totalIndex === 3) {
total_elec_consume_score = 20;
}
arr[9] = growthRate; //%
if (wrapArr0[n]) {
tongqicha =
item.celec_consume_unit -
wrapArr0[n].celec_consume_unit;
tongqi = tongqicha / tongqi;
} else {
tongqicha = item.celec_consume_unit;
tongqi = 0;
}
arr[10] = tongqi; //%
//n = month_listkeyvalue, index==0arr[11] = 100 index==1arr[11] = 80 index==2arr[11] = 70 index==3arr[11] = 0
if (month_obj[n]) {
const monthData = month_obj[n];
const itemValue = item.elec_consume_unit; //
const sortedData = monthData.sort((a, b) => parseFloat(b.value) - parseFloat(a.value));
const index = sortedData.findIndex(obj => parseFloat(obj.value) === parseFloat(itemValue));
if (index === 0){
arr[11] = 50;
} else if (index === 1) {
arr[11] = 40;
} else if (index === 2) {
arr[11] = 30;
} else if (index === 3) {
arr[11] = 20;
}
const total_elec_consume = item.elec_consume;
const sortedTotalData = monthData.sort((a, b) => parseFloat(b.elec_consume) - parseFloat(a.elec_consume));
const totalIndex = sortedTotalData.findIndex(obj => parseFloat(obj.elec_consume) === parseFloat(total_elec_consume));
let total_elec_consume_score = 0;
if (totalIndex === 0){
total_elec_consume_score = 50;
} else if (totalIndex === 1) {
total_elec_consume_score = 40;
} else if (totalIndex === 2) {
total_elec_consume_score = 30;
} else if (totalIndex === 3) {
total_elec_consume_score = 20;
}
arr[11] += total_elec_consume_score; //
}
wrapArr.push(arr);
});
that.tableDatas = wrapArr;
} else {
}
});
arr[11] += total_elec_consume_score; //
}
wrapArr.push(arr);
});
that.tableDatas = wrapArr;
} else {
}
});
},
handleQuery() {
this.tableDatas = [];
@ -278,13 +263,6 @@ export default {
this.type = type;
this.asynDialog = true;
},
itemClick1(type, item) {
this.chartShow = false;
this.$API.bi.dataset.exec.req("3322567213885833216").then((res) => {
this.myOption = JSON.parse(res.echart_options);
this.chartShow = true;
});
},
handlePrint() {
this.$PRINT("#myReport");
},