2026-02-27 13:05:36 +08:00
|
|
|
|
const calcSummary = (list, lossList) => {
|
2026-02-26 15:09:14 +08:00
|
|
|
|
// 总钢卷数量、总重、均重
|
|
|
|
|
|
const outCount = list.length
|
|
|
|
|
|
const outTotalWeight = list.reduce((acc, cur) => acc + (parseFloat(cur.netWeight) || 0), 0) // 增加容错
|
|
|
|
|
|
const outAvgWeight = outCount > 0 ? (outTotalWeight / outCount)?.toFixed(2) : 0
|
|
|
|
|
|
|
|
|
|
|
|
// 损失钢卷数量、总重、均重
|
2026-02-27 13:05:36 +08:00
|
|
|
|
const lossCount = lossList.length
|
|
|
|
|
|
const lossTotalWeight = lossList.reduce((acc, cur) => acc + (parseFloat(cur.netWeight) || 0), 0) // 增加容错
|
2026-02-26 15:09:14 +08:00
|
|
|
|
const lossAvgWeight = lossCount > 0 ? (lossTotalWeight / lossCount)?.toFixed(2) : 0
|
|
|
|
|
|
// 合计数量、总重、均重
|
|
|
|
|
|
const totalCount = outCount + lossCount
|
|
|
|
|
|
const totalWeight = parseFloat((outTotalWeight + lossTotalWeight).toFixed(2))
|
|
|
|
|
|
const totalAvgWeight = totalCount > 0 ? (totalWeight / totalCount)?.toFixed(2) : 0
|
|
|
|
|
|
|
|
|
|
|
|
// 成品比率
|
2026-03-20 13:34:56 +08:00
|
|
|
|
const passRate = outCount > 0 && lossTotalWeight > 0 ? (outTotalWeight / lossTotalWeight) : 0
|
2026-02-26 15:09:14 +08:00
|
|
|
|
// 损失比率
|
|
|
|
|
|
const lossRate = totalCount > 0 ? (1 - passRate) : 0
|
|
|
|
|
|
// 异常率,成品在warehouseId在'2019583656787259393',
|
|
|
|
|
|
// '2019583325311414274',
|
|
|
|
|
|
// '2019583429955104769',
|
|
|
|
|
|
// '2019583137616310273',这四个库中的占比
|
|
|
|
|
|
const abRate = totalCount != 0 ? list.filter(item => {
|
|
|
|
|
|
return item.warehouseId == '2019583656787259393' || item.warehouseId == '2019583325311414274' || item.warehouseId == '2019583429955104769' || item.warehouseId == '2019583137616310273'
|
|
|
|
|
|
}).length / totalCount : 0
|
|
|
|
|
|
|
2026-03-20 10:33:51 +08:00
|
|
|
|
// 正品率(1-异常率)
|
2026-03-20 13:34:56 +08:00
|
|
|
|
const passRate2 = totalCount != 0 ? (1 - abRate) : 0
|
2026-03-20 10:33:51 +08:00
|
|
|
|
|
2026-02-26 15:09:14 +08:00
|
|
|
|
return {
|
|
|
|
|
|
outCount,
|
|
|
|
|
|
outTotalWeight: outTotalWeight.toFixed(2),
|
|
|
|
|
|
outAvgWeight,
|
|
|
|
|
|
lossCount,
|
|
|
|
|
|
lossTotalWeight: lossTotalWeight.toFixed(2),
|
|
|
|
|
|
lossAvgWeight,
|
|
|
|
|
|
totalCount,
|
|
|
|
|
|
totalWeight: totalWeight.toFixed(2),
|
|
|
|
|
|
totalAvgWeight,
|
|
|
|
|
|
passRate: (passRate * 100)?.toFixed(2) + '%',
|
|
|
|
|
|
lossRate: (lossRate * 100)?.toFixed(2) + '%',
|
|
|
|
|
|
abRate: (abRate * 100)?.toFixed(2) || 0,
|
2026-03-20 10:33:51 +08:00
|
|
|
|
passRate2: (passRate2 * 100)?.toFixed(2) || 0,
|
2026-02-26 15:09:14 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const calcAbSummary = (list) => {
|
|
|
|
|
|
// 异常统计,统计四个异常库中的各自的数量和总重
|
|
|
|
|
|
let o = {
|
|
|
|
|
|
jishuCount: 0,
|
|
|
|
|
|
miniCount: 0,
|
|
|
|
|
|
rubbishCount: 0,
|
|
|
|
|
|
returnCount: 0,
|
2026-03-20 10:33:51 +08:00
|
|
|
|
|
|
|
|
|
|
jishuWeight: 0,
|
|
|
|
|
|
miniWeight: 0,
|
|
|
|
|
|
rubbishWeight: 0,
|
2026-02-26 15:09:14 +08:00
|
|
|
|
returnWeight: 0,
|
2026-03-20 10:33:51 +08:00
|
|
|
|
|
|
|
|
|
|
// 计入技术部的钢卷占比
|
|
|
|
|
|
jishuRate: 0,
|
|
|
|
|
|
// 计入小钢卷库的钢卷占比
|
|
|
|
|
|
miniRate: 0,
|
|
|
|
|
|
// 计入废品库的钢卷占比
|
|
|
|
|
|
rubbishRate: 0,
|
|
|
|
|
|
// 计入退货库的钢卷占比
|
|
|
|
|
|
returnRate: 0,
|
2026-02-26 15:09:14 +08:00
|
|
|
|
}
|
2026-03-20 10:33:51 +08:00
|
|
|
|
const totalCount = list.length
|
2026-02-26 15:09:14 +08:00
|
|
|
|
for (let i = 0; i < list.length; i++) {
|
|
|
|
|
|
// { label: '技术部', value: '2019583656787259393' },
|
|
|
|
|
|
// { label: '小钢卷库', value: '2019583325311414274' },
|
|
|
|
|
|
// { label: '废品库', value: '2019583429955104769' },
|
|
|
|
|
|
// { label: '退货库', value: '2019583137616310273' },
|
|
|
|
|
|
// 技术部
|
|
|
|
|
|
const coil = list[i];
|
|
|
|
|
|
// 技术部
|
|
|
|
|
|
if (coil.warehouseId == '2019583656787259393') {
|
|
|
|
|
|
o['jishuCount'] = o['jishuCount'] + 1
|
|
|
|
|
|
o['jishuWeight'] = o['jishuWeight'] + parseFloat(coil.netWeight) || 0
|
|
|
|
|
|
}
|
|
|
|
|
|
// 小刚卷库
|
|
|
|
|
|
if (coil.warehouseId == '2019583325311414274') {
|
|
|
|
|
|
o['miniCount'] = o['miniCount'] + 1
|
|
|
|
|
|
o['miniWeight'] = o['miniWeight'] + parseFloat(coil.netWeight) || 0
|
|
|
|
|
|
}
|
|
|
|
|
|
// 废品库
|
|
|
|
|
|
if (coil.warehouseId == '2019583429955104769') {
|
|
|
|
|
|
o['rubbishCount'] = o['rubbishCount'] + 1
|
|
|
|
|
|
o['rubbishWeight'] = o['rubbishWeight'] + parseFloat(coil.netWeight) || 0
|
|
|
|
|
|
}
|
|
|
|
|
|
// 退货库
|
|
|
|
|
|
if (coil.warehouseId == '2019583137616310273') {
|
|
|
|
|
|
o['returnCount'] = o['returnCount'] + 1
|
|
|
|
|
|
o['returnWeight'] = o['returnWeight'] + parseFloat(coil.netWeight) || 0
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return [
|
|
|
|
|
|
{ label: '技术部钢卷数', value: o['jishuCount'] },
|
|
|
|
|
|
{ label: '小钢卷库钢卷数', value: o['miniCount'] },
|
|
|
|
|
|
{ label: '废品库钢卷数', value: o['rubbishCount'] },
|
|
|
|
|
|
{ label: '退货库钢卷数', value: o['returnCount'] },
|
2026-03-20 10:33:51 +08:00
|
|
|
|
|
2026-03-20 13:34:56 +08:00
|
|
|
|
{ label: '技术部钢卷重量', value: o['jishuWeight'].toFixed(2) },
|
|
|
|
|
|
{ label: '小钢卷库钢卷重量', value: o['miniWeight'].toFixed(2) },
|
|
|
|
|
|
{ label: '废品库钢卷重量', value: o['rubbishWeight'].toFixed(2) },
|
|
|
|
|
|
{ label: '退货库钢卷重量', value: o['returnWeight'].toFixed(2) },
|
2026-03-20 10:33:51 +08:00
|
|
|
|
|
2026-03-20 13:34:56 +08:00
|
|
|
|
{ label: '技术部占比', value: totalCount > 0 ? (o['jishuCount'] / totalCount * 100).toFixed(2) + '%' : '0.00%' },
|
|
|
|
|
|
{ label: '小钢卷库占比', value: totalCount > 0 ? (o['miniCount'] / totalCount * 100).toFixed(2) + '%' : '0.00%' },
|
|
|
|
|
|
{ label: '废品库占比', value: totalCount > 0 ? (o['rubbishCount'] / totalCount * 100).toFixed(2) + '%' : '0.00%' },
|
|
|
|
|
|
{ label: '退货库占比', value: totalCount > 0 ? (o['returnCount'] / totalCount * 100).toFixed(2) + '%' : '0.00%' },
|
2026-02-26 15:09:14 +08:00
|
|
|
|
]
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-02-27 13:05:36 +08:00
|
|
|
|
const calcTeamSummary = (list) => {
|
|
|
|
|
|
// 按照班组汇总信息
|
|
|
|
|
|
const teamSummary = {}
|
|
|
|
|
|
for (let i = 0; i < list.length; i++) {
|
|
|
|
|
|
const coil = list[i];
|
|
|
|
|
|
if (!teamSummary[coil.team]) {
|
|
|
|
|
|
teamSummary[coil.team] = {
|
|
|
|
|
|
count: 0,
|
|
|
|
|
|
weight: 0,
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
teamSummary[coil.team].count = teamSummary[coil.team].count + 1
|
|
|
|
|
|
teamSummary[coil.team].weight = teamSummary[coil.team].weight + parseFloat(coil.netWeight) || 0
|
|
|
|
|
|
}
|
|
|
|
|
|
return teamSummary
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-03-20 13:34:56 +08:00
|
|
|
|
const calcMSummary = (list, lossList) => {
|
|
|
|
|
|
// 统计,需要二外处理M卷,也就是钢卷的currentCoilNo中带有M的钢卷,在统计产出钢卷的数量和重量时需要忽略并记录,并且在统计消耗钢卷的总重量时也需要移除
|
|
|
|
|
|
|
|
|
|
|
|
// 筛选出 M 卷
|
|
|
|
|
|
const mCoils = list.filter(item => item.currentCoilNo && item.currentCoilNo.includes('M'))
|
|
|
|
|
|
// 非 M 卷
|
|
|
|
|
|
const nonMCoils = list.filter(item => !item.currentCoilNo || !item.currentCoilNo.includes('M'))
|
|
|
|
|
|
|
|
|
|
|
|
// 非 M 卷作为产出统计
|
|
|
|
|
|
const outCount = nonMCoils.length
|
|
|
|
|
|
const outTotalWeight = nonMCoils.reduce((acc, cur) => acc + (parseFloat(cur.netWeight) || 0), 0)
|
|
|
|
|
|
const outAvgWeight = outCount > 0 ? (outTotalWeight / outCount)?.toFixed(2) : 0
|
|
|
|
|
|
|
|
|
|
|
|
// 计算产出的 M 卷总重量
|
|
|
|
|
|
const mOutTotalWeight = mCoils.reduce((acc, cur) => acc + (parseFloat(cur.netWeight) || 0), 0)
|
|
|
|
|
|
|
|
|
|
|
|
// 消耗钢卷统计(数量包括所有卷,但总重量减去产出的 M 卷重量)
|
|
|
|
|
|
const lossCount = lossList.length
|
|
|
|
|
|
const lossTotalWeight = lossList.reduce((acc, cur) => acc + (parseFloat(cur.netWeight) || 0), 0) - mOutTotalWeight
|
|
|
|
|
|
const lossAvgWeight = lossCount > 0 ? (lossTotalWeight / lossCount)?.toFixed(2) : 0
|
|
|
|
|
|
|
|
|
|
|
|
// 合计
|
|
|
|
|
|
const totalCount = outCount + lossCount
|
|
|
|
|
|
const totalWeight = parseFloat((outTotalWeight + lossTotalWeight).toFixed(2))
|
|
|
|
|
|
const totalAvgWeight = totalCount > 0 ? (totalWeight / totalCount)?.toFixed(2) : 0
|
|
|
|
|
|
|
|
|
|
|
|
// 成品比率
|
|
|
|
|
|
const passRate = outCount > 0 && lossTotalWeight > 0 ? (outTotalWeight / lossTotalWeight) : 0
|
|
|
|
|
|
// 损失比率
|
|
|
|
|
|
const lossRate = totalCount > 0 ? (1 - passRate) : 0
|
|
|
|
|
|
|
|
|
|
|
|
// 异常率,成品在warehouseId在'2019583656787259393',
|
|
|
|
|
|
// '2019583325311414274',
|
|
|
|
|
|
// '2019583429955104769',
|
|
|
|
|
|
// '2019583137616310273',这四个库中的占比
|
|
|
|
|
|
const abRate = totalCount != 0 ? nonMCoils.filter(item => {
|
|
|
|
|
|
return item.warehouseId == '2019583656787259393' || item.warehouseId == '2019583325311414274' || item.warehouseId == '2019583429955104769' || item.warehouseId == '2019583137616310273'
|
|
|
|
|
|
}).length / totalCount : 0
|
|
|
|
|
|
|
|
|
|
|
|
// 正品率(1-异常率)
|
|
|
|
|
|
const passRate2 = totalCount != 0 ? (1 - abRate) : 0
|
|
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
|
outCount,
|
|
|
|
|
|
outTotalWeight: outTotalWeight.toFixed(2),
|
|
|
|
|
|
outAvgWeight,
|
|
|
|
|
|
lossCount,
|
|
|
|
|
|
lossTotalWeight: lossTotalWeight.toFixed(2),
|
|
|
|
|
|
lossAvgWeight,
|
|
|
|
|
|
totalCount,
|
|
|
|
|
|
totalWeight: totalWeight.toFixed(2),
|
|
|
|
|
|
totalAvgWeight,
|
|
|
|
|
|
passRate: (passRate * 100)?.toFixed(2) + '%',
|
|
|
|
|
|
lossRate: (lossRate * 100)?.toFixed(2) + '%',
|
|
|
|
|
|
abRate: (abRate * 100)?.toFixed(2) || 0,
|
|
|
|
|
|
passRate2: (passRate2 * 100)?.toFixed(2) || 0,
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-02-26 15:09:14 +08:00
|
|
|
|
export {
|
|
|
|
|
|
calcSummary,
|
|
|
|
|
|
calcAbSummary,
|
2026-02-27 13:05:36 +08:00
|
|
|
|
calcTeamSummary,
|
2026-03-20 13:34:56 +08:00
|
|
|
|
calcMSummary,
|
2026-02-26 15:09:14 +08:00
|
|
|
|
}
|