1.修复报表不显示问题,并且优化逻辑只显示有数据的月份,其他的月份不填充数据
main
liuhr 2 years ago
parent 918efb6c12
commit 0f89262d3b

@ -130,6 +130,7 @@ import { equipmentRecordApi } from 'src/api/equipmentRecord/equipmentRecordApi';
// import screen1 from 'src/json/screen1.json'
import { Vue3SeamlessScroll } from "vue3-seamless-scroll"; //
import { useScreenStore } from 'src/stores/useScreenStore'
import lodash from 'lodash'
//
const screenStore = useScreenStore();
@ -421,25 +422,31 @@ const EquipmentRecordStateMonthTotal = () => {
let totalAlarmTime: any = []; //
let totalStopTime: any = []; //
let month: any = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12];
let result: Array<object> = [];
//
equipmentRecordApi.getEquipmentRecordStateMonthTotal().then((res: any) => {
month.forEach((m: any) => {
res.forEach((item: any) => {
// let isMonth = month.filter((m: any) => m === item.totalMonth)
if (item.totalMonth == m) {
totalRunningTime.push(item.totalRunningTime);
totalStopTime.push(item.totalStopTime);
totalAlarmTime.push(item.totalAlarmTime);
}
else {
totalRunningTime.push(0);
totalStopTime.push(0);
totalAlarmTime.push(0);
}
})
res.forEach((item: any) => {
result.push({ product: item.totalMonth + '月', ...item })
})
// month.forEach((m: any) => {
// res.forEach((item: any) => {
// // let isMonth = month.filter((m: any) => m === item.totalMonth)
// if (item.totalMonth == m) {
// totalRunningTime.push(item.totalRunningTime);
// totalStopTime.push(item.totalStopTime);
// totalAlarmTime.push(item.totalAlarmTime);
// }
// else {
// totalRunningTime.push(0);
// totalStopTime.push(0);
// totalAlarmTime.push(0);
// }
// })
// })
//
let equipmentRecordStateMonthTotalOption = {
title: {
@ -492,7 +499,8 @@ const EquipmentRecordStateMonthTotal = () => {
xAxis: [
{
type: 'category',
data: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'],
// data: month,
// data: ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12'],
axisPointer: {
type: 'shadow'
}
@ -522,11 +530,15 @@ const EquipmentRecordStateMonthTotal = () => {
}
}
],
dataset: {
dimensions: ['product', 'totalRunningTime', 'totalAlarmTime', 'totalStopTime'],
source: result
},
series: [
{
name: '运行时间',
type: 'bar',
data: totalRunningTime,
// data: totalRunningTime,
itemStyle: {
normal: {
label: {
@ -545,7 +557,7 @@ const EquipmentRecordStateMonthTotal = () => {
{
name: '待机时间',
type: 'bar',
data: totalStopTime,
// data: totalStopTime,
itemStyle: {
normal: {
label: {
@ -564,7 +576,7 @@ const EquipmentRecordStateMonthTotal = () => {
{
name: '报警时间',
type: 'bar',
data: totalAlarmTime,
// data: totalAlarmTime,
itemStyle: {
normal: {
label: {
@ -592,18 +604,23 @@ const EquipmentRecordStateMonthTotal = () => {
const EquipmentRecordOEEMonthTotal = () => {
let oeeData: any = []; //
let month: any = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12];
let result: Array<object> = [];
// OEE
equipmentRecordApi.getEquipmentRecordOEEMonthTotal().then((res: any) => {
month.forEach((m: any) => {
res.forEach((item: any) => {
if (item.totalMonth == m) {
oeeData.push(item.oee);
}
else {
oeeData.push(0);
}
})
// month.forEach((m: any) => {
// res.forEach((item: any) => {
// if (item.totalMonth == m) {
// oeeData.push(item.oee);
// }
// else {
// oeeData.push(0);
// }
// })
// })
res.forEach((item: any) => {
result.push({ product: item.totalMonth + '月', ...item })
})
//
@ -655,10 +672,14 @@ const EquipmentRecordOEEMonthTotal = () => {
right: '2%',
data: ['OEE数据']
},
dataset: {
dimensions: ['product', 'oee'],
source: result
},
xAxis: [
{
type: 'category',
data: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'],
// data: ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12'],
// axisPointer: {
// type: 'shadow'
// }
@ -692,7 +713,7 @@ const EquipmentRecordOEEMonthTotal = () => {
{
name: 'OEE数据',
type: 'line',
data: oeeData,
// data: oeeData,
itemStyle: {
normal: {
label: {
@ -743,32 +764,68 @@ const EquipmentRecordFurnaceMonthTotal = () => {
let CemeCon: any = [];
let Ionbond: any = [];
let month: any = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12];
let result: Array<object> = [];
//
equipmentRecordApi.getEquipmentRecordFurnaceMonthTotal().then((res: any) => {
month.forEach((m: any) => {
res.forEach((item: any) => {
if (item.totalMonth == m) {
if (item.equipmentType == 'Balzers') {
Balzers.push(item.furnaceNum);
}
if (item.equipmentType == 'CemeCon') {
CemeCon.push(item.furnaceNum);
}
if (item.equipmentType == 'Ionbond') {
Ionbond.push(item.furnaceNum);
}
} else {
if (item.equipmentType == 'Balzers') {
Balzers.push(0);
}
if (item.equipmentType == 'CemeCon') {
CemeCon.push(0);
}
if (item.equipmentType == 'Ionbond') {
Ionbond.push(0);
// month.forEach((m: any) => {
// res.forEach((item: any) => {
// if (item.totalMonth == m) {
// if (item.equipmentType == 'Balzers') {
// Balzers.push(item.furnaceNum);
// }
// if (item.equipmentType == 'CemeCon') {
// CemeCon.push(item.furnaceNum);
// }
// if (item.equipmentType == 'Ionbond') {
// Ionbond.push(item.furnaceNum);
// }
// } else {
// if (item.equipmentType == 'Balzers') {
// Balzers.push(0);
// }
// if (item.equipmentType == 'CemeCon') {
// CemeCon.push(0);
// }
// if (item.equipmentType == 'Ionbond') {
// Ionbond.push(0);
// }
// }
// })
// })
// let grouped_data = lodash.groupBy(res, 'totalMonth');
// console.log(grouped_data);
var obj = {}, newArr = [];
res.forEach(function (item, suffix) {
//
if (!obj[item.totalMonth]) {
var arr = [];
arr.push(item);
newArr.push(arr);
obj[item.totalMonth] = item;
} else {
newArr.forEach(function (value, index) {
//
if (value[0].totalMonth == item.totalMonth) {
value.push(item)
}
}
})
}
})
newArr.forEach((item: any) => {
let CemeCon = item.filter(c => {
return c.equipmentType == 'CemeCon'
})
let Balzers = item.filter(b => { return b.equipmentType == 'Balzers' })
let Ionbond = item.filter(i => { return i.equipmentType == 'Ionbond' })
result.push({
product: item[0].totalMonth + '月',
CemeCon: CemeCon[0].furnaceNum,
Balzers: Balzers[0].furnaceNum,
Ionbond: Ionbond[0].furnaceNum,
})
})
@ -815,7 +872,7 @@ const EquipmentRecordFurnaceMonthTotal = () => {
},
xAxis: {
type: 'category',
data: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'],
// data: ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12'],
axisLine: {
show: true,
lineStyle: {
@ -849,11 +906,15 @@ const EquipmentRecordFurnaceMonthTotal = () => {
show: true //线
}
},
dataset: {
dimensions: ['product', 'Balzers', 'CemeCon', 'Ionbond'],
source: result
},
series: [
{
name: 'Balzers',
type: 'bar',
data: Balzers,
// data: Balzers,
itemStyle: {
normal: {
label: {
@ -872,7 +933,7 @@ const EquipmentRecordFurnaceMonthTotal = () => {
{
name: 'CemeCon',
type: 'bar',
data: CemeCon,
// data: CemeCon,
itemStyle: {
normal: {
label: {
@ -891,7 +952,7 @@ const EquipmentRecordFurnaceMonthTotal = () => {
{
name: 'Ionbond',
type: 'bar',
data: Ionbond,
// data: Ionbond,
itemStyle: {
normal: {
label: {

Loading…
Cancel
Save