|
|
|
@@ -507,14 +507,31 @@ console.log("🔍 DEBUG fgOrder.deliveryNos:", fgOrder.deliveryNos); |
|
|
|
|
|
|
|
mergedPickOrder.pickOrderLines.forEach((line: any) => { |
|
|
|
if (line.lots && line.lots.length > 0) { |
|
|
|
// ✅ 有 lots 的情况 |
|
|
|
// ✅ 修复:先对 lots 按 lotId 去重并合并 requiredQty |
|
|
|
const lotMap = new Map<number, any>(); |
|
|
|
|
|
|
|
line.lots.forEach((lot: any) => { |
|
|
|
const lotId = lot.id; |
|
|
|
if (lotMap.has(lotId)) { |
|
|
|
// ✅ 如果已存在,合并 requiredQty |
|
|
|
const existingLot = lotMap.get(lotId); |
|
|
|
existingLot.requiredQty = (existingLot.requiredQty || 0) + (lot.requiredQty || 0); |
|
|
|
// ✅ 保留其他字段(使用第一个遇到的 lot 的字段) |
|
|
|
} else { |
|
|
|
// ✅ 首次遇到,添加到 map |
|
|
|
lotMap.set(lotId, { ...lot }); |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
// ✅ 遍历去重后的 lots |
|
|
|
lotMap.forEach((lot: any) => { |
|
|
|
flatLotData.push({ |
|
|
|
// ✅ 使用合并后的数据 |
|
|
|
pickOrderConsoCode: mergedPickOrder.consoCode, |
|
|
|
pickOrderTargetDate: mergedPickOrder.targetDate, |
|
|
|
pickOrderStatus: mergedPickOrder.status, |
|
|
|
|
|
|
|
pickOrderId: mergedPickOrder.pickOrderIds?.[0] || 0, // ✅ 使用第一个 pickOrderId |
|
|
|
pickOrderCode: mergedPickOrder.pickOrderCodes?.[0] || "", |
|
|
|
pickOrderLineId: line.id, |
|
|
|
pickOrderLineRequiredQty: line.requiredQty, |
|
|
|
pickOrderLineStatus: line.status, |
|
|
|
@@ -531,7 +548,7 @@ console.log("🔍 DEBUG fgOrder.deliveryNos:", fgOrder.deliveryNos); |
|
|
|
location: lot.location, |
|
|
|
stockUnit: lot.stockUnit, |
|
|
|
availableQty: lot.availableQty, |
|
|
|
requiredQty: lot.requiredQty, |
|
|
|
requiredQty: lot.requiredQty, // ✅ 使用合并后的 requiredQty |
|
|
|
actualPickQty: lot.actualPickQty, |
|
|
|
inQty: lot.inQty, |
|
|
|
outQty: lot.outQty, |
|
|
|
@@ -561,7 +578,8 @@ console.log("🔍 DEBUG fgOrder.deliveryNos:", fgOrder.deliveryNos); |
|
|
|
pickOrderConsoCode: mergedPickOrder.consoCodes?.[0] || "", // ✅ 修复:consoCodes 是数组 |
|
|
|
pickOrderTargetDate: mergedPickOrder.targetDate, |
|
|
|
pickOrderStatus: mergedPickOrder.status, |
|
|
|
|
|
|
|
pickOrderId: mergedPickOrder.pickOrderIds?.[0] || 0, // ✅ 使用第一个 pickOrderId |
|
|
|
pickOrderCode: mergedPickOrder.pickOrderCodes?.[0] || "", |
|
|
|
pickOrderLineId: line.id, |
|
|
|
pickOrderLineRequiredQty: line.requiredQty, |
|
|
|
pickOrderLineStatus: line.status, |
|
|
|
|