From ed12bbc1dabce1fcbbea51c1b105bb9e81ee694b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=9C=E7=AC=99=E6=AD=8C?= <2277317060@qq.com> Date: Tue, 22 Nov 2022 16:26:03 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=8F=91=E6=B3=A1=E7=BA=BF?= =?UTF-8?q?=E7=94=9F=E4=BA=A7=E7=BB=9F=E8=AE=A1=E6=95=B0=E6=8D=AE=E8=A1=A8?= =?UTF-8?q?=E6=A0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../templates/scada/NorthFoamerMesPlan.html | 13 +++- .../templates/scada/NorthFoamerMesPlan2.html | 64 ++++++++++++++----- 2 files changed, 59 insertions(+), 18 deletions(-) diff --git a/ruoyi-admin/src/main/resources/templates/scada/NorthFoamerMesPlan.html b/ruoyi-admin/src/main/resources/templates/scada/NorthFoamerMesPlan.html index 5dad47f..a7a2e6c 100644 --- a/ruoyi-admin/src/main/resources/templates/scada/NorthFoamerMesPlan.html +++ b/ruoyi-admin/src/main/resources/templates/scada/NorthFoamerMesPlan.html @@ -469,7 +469,6 @@ let title = ['编号', '型号', '状态', '目标', '计划', '累计', '达成率', '8:00', '9:00', '10:00', '11:00', '12:00', '13:00', '14:00', '15:00', '16:00', '17:00', '18:00', '19:00'] let dataA = [title] let dataB = [title] - console.log(data) data.forEach(e => { if (!Object.keys(name).includes(e.orderType)) { name[e.orderType] = [e.deviceID] @@ -481,7 +480,6 @@ } } }) - console.log(name) Object.keys(name).forEach(e => { name[e].forEach(val => { let arr = [] @@ -493,6 +491,17 @@ dataInit.push(arr) }) }) + let i = [] + dataInit.forEach((e,index)=> { + if(e[0].orderType === '其他型号'){ + i.push(index) + } + }) + i.forEach((e,index) => { + let a = dataInit.splice(e-index,1) + console.log(a) + dataInit.push(...a) + }) console.log(dataInit) dataInit.forEach((val, index) => { if (index < 6) { diff --git a/ruoyi-admin/src/main/resources/templates/scada/NorthFoamerMesPlan2.html b/ruoyi-admin/src/main/resources/templates/scada/NorthFoamerMesPlan2.html index c63910a..c050c61 100644 --- a/ruoyi-admin/src/main/resources/templates/scada/NorthFoamerMesPlan2.html +++ b/ruoyi-admin/src/main/resources/templates/scada/NorthFoamerMesPlan2.html @@ -456,37 +456,69 @@ }).reduce((a, b) => a + b) } autoUpdate('/system/FoamerMes/getPlanHourInfo', INTERVAL, data => { - let name = [] - let dataA = [] - let dataB = [] - dataA.push(['型号', '状态', '目标', '计划', '累计', '达成率', '8:00', '9:00', '10:00', '11:00', '12:00', '13:00', '14:00', '15:00', '16:00', '17:00', '18:00', '19:00']) - dataB.push(['型号', '状态', '目标', '计划', '累计', '达成率', '8:00', '9:00', '10:00', '11:00', '12:00', '13:00', '14:00', '15:00', '16:00', '17:00', '18:00', '19:00']) + let name = {} + let dataInit = [] + let title = ['编号', '型号', '状态', '目标', '计划', '累计', '达成率', '8:00', '9:00', '10:00', '11:00', '12:00', '13:00', '14:00', '15:00', '16:00', '17:00', '18:00', '19:00'] + let dataA = [title] + let dataB = [title] data.forEach(e => { - if (!name.includes(e.orderType)) { - name.push(e.orderType) + if (!Object.keys(name).includes(e.orderType)) { + name[e.orderType] = [e.deviceID] + } else { + let arr = name[e.orderType] + if (!arr.includes(e.deviceID)) { + arr.push(e.deviceID) + name[e.orderType] = arr + } } }) - name.forEach((val, index) => { + Object.keys(name).forEach(e => { + name[e].forEach(val => { + let arr = [] + data.forEach(item => { + if (item.orderType === e && item.deviceID === val) { + arr.push(item) + } + }) + dataInit.push(arr) + }) + }) + let i = [] + dataInit.forEach((e,index)=> { + if(e[0].orderType === '其他型号'){ + i.push(index) + } + }) + i.forEach((e,index) => { + let a = dataInit.splice(e-index,1) + console.log(a) + dataInit.push(...a) + }) + console.log(dataInit) + dataInit.forEach((val, index) => { if (index < 6) { - let arr = data.filter(e => e.orderType === val) + let arr = val let plannedProduction = arr.map(e => e.plannedProduction).reduce((a, b) => a + b) || 0 let actualProduction = arr.map(e => e.actualProduction).reduce((a, b) => a + b) || 0 - dataA.push([val.split(',')[0], '正常', arr[0].target, plannedProduction, actualProduction, plannedProduction === 0 ? '0%' : ((actualProduction / plannedProduction) * 100).toString().substr(0, 5) + '%', filter(arr, 'recordTime', 8, 'actualProduction') || 0, filter(arr, 'recordTime', 9, 'actualProduction') || 0, filter(arr, 'recordTime', 10, 'actualProduction') || 0, filter(arr, 'recordTime', 11, 'actualProduction') || 0, filter(arr, 'recordTime', 12, 'actualProduction') || 0, filter(arr, 'recordTime', 13, 'actualProduction') || 0, filter(arr, 'recordTime', 14, 'actualProduction') || 0, filter(arr, 'recordTime', 15, 'actualProduction') || 0, filter(arr, 'recordTime', 16, 'actualProduction') || 0, filter(arr, 'recordTime', 17, 'actualProduction') || 0, filter(arr, 'recordTime', 18, 'actualProduction') || 0, filter(arr, 'recordTime', 19, 'actualProduction') || 0]) + dataA.push([val[0].deviceID, val[0].orderType.split(',')[0], '正常', arr[0].target, plannedProduction, actualProduction, plannedProduction === 0 ? '0%' : ((actualProduction / plannedProduction) * 100).toString().substr(0, 5) + '%', filter(arr, 'recordTime', 8, 'actualProduction') || 0, filter(arr, 'recordTime', 9, 'actualProduction') || 0, filter(arr, 'recordTime', 10, 'actualProduction') || 0, filter(arr, 'recordTime', 11, 'actualProduction') || 0, filter(arr, 'recordTime', 12, 'actualProduction') || 0, filter(arr, 'recordTime', 13, 'actualProduction') || 0, filter(arr, 'recordTime', 14, 'actualProduction') || 0, filter(arr, 'recordTime', 15, 'actualProduction') || 0, filter(arr, 'recordTime', 16, 'actualProduction') || 0, filter(arr, 'recordTime', 17, 'actualProduction') || 0, filter(arr, 'recordTime', 18, 'actualProduction') || 0, filter(arr, 'recordTime', 19, 'actualProduction') || 0]) } else { - let arr = data.filter(e => e.orderType === val) + let arr = val let plannedProduction = arr.map(e => e.plannedProduction).reduce((a, b) => a + b) || 0 let actualProduction = arr.map(e => e.actualProduction).reduce((a, b) => a + b) || 0 - dataB.push([val.split(',')[0], '正常', arr[0].target, plannedProduction, actualProduction, plannedProduction === 0 ? '0%' : ((actualProduction / plannedProduction) * 100).toString().substr(0, 5) + '%', filter(arr, 'recordTime', 8, 'actualProduction') || 0, filter(arr, 'recordTime', 9, 'actualProduction') || 0, filter(arr, 'recordTime', 10, 'actualProduction') || 0, filter(arr, 'recordTime', 11, 'actualProduction') || 0, filter(arr, 'recordTime', 12, 'actualProduction') || 0, filter(arr, 'recordTime', 13, 'actualProduction') || 0, filter(arr, 'recordTime', 14, 'actualProduction') || 0, filter(arr, 'recordTime', 15, 'actualProduction') || 0, filter(arr, 'recordTime', 16, 'actualProduction') || 0, filter(arr, 'recordTime', 17, 'actualProduction') || 0, filter(arr, 'recordTime', 18, 'actualProduction') || 0, filter(arr, 'recordTime', 19, 'actualProduction') || 0]) + dataB.push([val[0].deviceID, val[0].orderType.split(',')[0], '正常', arr[0].target, plannedProduction, actualProduction, plannedProduction === 0 ? '0%' : ((actualProduction / plannedProduction) * 100).toString().substr(0, 5) + '%', filter(arr, 'recordTime', 8, 'actualProduction') || 0, filter(arr, 'recordTime', 9, 'actualProduction') || 0, filter(arr, 'recordTime', 10, 'actualProduction') || 0, filter(arr, 'recordTime', 11, 'actualProduction') || 0, filter(arr, 'recordTime', 12, 'actualProduction') || 0, filter(arr, 'recordTime', 13, 'actualProduction') || 0, filter(arr, 'recordTime', 14, 'actualProduction') || 0, filter(arr, 'recordTime', 15, 'actualProduction') || 0, filter(arr, 'recordTime', 16, 'actualProduction') || 0, filter(arr, 'recordTime', 17, 'actualProduction') || 0, filter(arr, 'recordTime', 18, 'actualProduction') || 0, filter(arr, 'recordTime', 19, 'actualProduction') || 0]) } }) - dataA.push(['合计', '', totle(dataA, 2), totle(dataA, 3), totle(dataA, 4), totle(dataB, 3) === 0 ? '0%' : ((totle(dataA, 4) / totle(dataA, 3)) * 100).toString().substr(0, 5) + '%', totle(dataA, 6), totle(dataA, 7), totle(dataA, 8), totle(dataA, 9), totle(dataA, 10), totle(dataA, 11), totle(dataA, 12), totle(dataA, 13), totle(dataA, 14), totle(dataA, 15), totle(dataA, 16), totle(dataA, 17)]) - dataB.push(['合计', '', totle(dataB, 2), totle(dataB, 3), totle(dataB, 4), totle(dataB, 3) === 0 ? '0%' : ((totle(dataB, 4) / totle(dataB, 3)) * 100).toString().substr(0, 5) + '%', totle(dataB, 6), totle(dataB, 7), totle(dataB, 8), totle(dataB, 9), totle(dataB, 10), totle(dataB, 11), totle(dataB, 12), totle(dataB, 13), totle(dataB, 14), totle(dataB, 15), totle(dataB, 16), totle(dataB, 17)]) + dataA.push([' ', '合计', '', totle([...dataA], 2), totle([...dataA], 3), totle([...dataA], 4), totle(dataB, 3) === 0 ? '0%' : ((totle([...dataA], 4) / totle([...dataA], 3)) * 100).toString().substr(0, 5) + '%', totle([...dataA], 6), totle([...dataA], 7), totle([...dataA], 8), totle([...dataA], 9), totle([...dataA], 10), totle([...dataA], 11), totle([...dataA], 12), totle([...dataA], 13), totle([...dataA], 14), totle([...dataA], 15), totle([...dataA], 16), totle([...dataA], 17)]) + dataB.push([' ', '合计', '', totle([...dataB], 2), totle([...dataB], 3), totle([...dataB], 4), totle([...dataB], 3) === 0 ? '0%' : ((totle([...dataB], 4) / totle([...dataB], 3)) * 100).toString().substr(0, 5) + '%', totle([...dataB], 6), totle([...dataB], 7), totle([...dataB], 8), totle([...dataB], 9), totle([...dataB], 10), totle([...dataB], 11), totle([...dataB], 12), totle([...dataB], 13), totle([...dataB], 14), totle([...dataB], 15), totle([...dataB], 16), totle([...dataB], 17)]) - planInfo.loadData(dataA, 18, { + planInfo.loadData([...dataA], 19, { includeHead: true, }) - planInfo2.loadData(dataB.length > 2 ? dataB : dataA, 18, { + if (dataB.length <= 2) { + dataB = dataA + } + planInfo2.loadData([...dataB], 19, { includeHead: true, }) })