feat(报表): 添加分条线统计组件并扩展合同字段

添加分条线专用的统计组件SplitSummary,用于展示分条处理的产出与消耗对比数据
在多个报表模板中集成该组件并添加钢卷高亮功能
扩展CrmOrder相关类的合同信息字段
This commit is contained in:
砂糖
2026-04-13 16:23:40 +08:00
parent 5ee730bffa
commit 37dc213605
11 changed files with 582 additions and 16 deletions

View File

@@ -229,9 +229,76 @@ const calcMSummary = (list, lossList) => {
}
}
// 处理分条信息的统计信息
const calcSplitSummary = (originOutputlist, originLossList, commonCoilIds) => {
// 1. 将commonCoilIds中的coilId的卷从originOutputlist和originLossList中剔除
const list = originOutputlist.filter(item => !commonCoilIds.includes(item.coilId))
const lossList = originLossList.filter(item => !commonCoilIds.includes(item.coilId))
// 总钢卷数量、总重、均重
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
// 损失钢卷数量、总重、均重
const lossCount = lossList.length
const lossTotalWeight = lossList.reduce((acc, cur) => acc + (parseFloat(cur.netWeight) || 0), 0) // 增加容错
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 countDiff = Math.abs(outCount - lossCount)
const weightDiff = Math.abs(parseFloat((outTotalWeight - lossTotalWeight).toFixed(2)))
const avgWeightDiff = Math.abs(parseFloat((outAvgWeight - lossAvgWeight).toFixed(2)))
// 成品比率
const passRate = outCount > 0 && lossTotalWeight > 0 ? (outTotalWeight / lossTotalWeight) : 0
// 损失比率
const lossRate = totalCount > 0 ? (1 - passRate) : 0
// 异常率,成品在warehouseId在'2019583656787259393',
// '2019583325311414274',
// '2019583429955104769',
// '2019583137616310273',这四个库中的占比
const abStatus = ['O', 'C-', 'C+', 'C', 'D-', 'D+', 'D']
const abRate = totalCount != 0 ? list.filter(item => {
// 质量状态为O, C- , C+, C, D-, D+, D的钢卷也属于异常
return (item.warehouseId == '2019583656787259393'
|| item.warehouseId == '2019583325311414274'
|| item.warehouseId == '2019583429955104769'
|| item.warehouseId == '2019583137616310273'
|| abStatus.includes(item.qualityStatus)
)
}).length / outCount : 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,
countDiff,
weightDiff,
avgWeightDiff,
passRate: (passRate * 100)?.toFixed(2) + '%',
lossRate: (lossRate * 100)?.toFixed(2) + '%',
abRate: (abRate * 100)?.toFixed(2) + '%' || 0,
passRate2: (passRate2 * 100)?.toFixed(2) + '%' || 0,
}
}
export {
calcSummary,
calcAbSummary,
calcTeamSummary,
calcMSummary,
calcSplitSummary
}