|
|
|
@@ -1505,6 +1505,14 @@ open class DeliveryOrderService( |
|
|
|
pickOrderEntity.consoCode = consoCode |
|
|
|
pickOrderEntity.status = com.ffii.fpsms.modules.pickOrder.enums.PickOrderStatus.RELEASED |
|
|
|
pickOrderRepository.saveAndFlush(pickOrderEntity) |
|
|
|
// 创建 stock out |
|
|
|
val stockOut = StockOut().apply { |
|
|
|
this.type = "do" |
|
|
|
this.consoPickOrderCode = consoCode |
|
|
|
this.status = StockOutStatus.PENDING.status |
|
|
|
this.handler = request.userId |
|
|
|
} |
|
|
|
val savedStockOut = stockOutRepository.saveAndFlush(stockOut) |
|
|
|
|
|
|
|
// 创建 suggestions 和 hold inventory |
|
|
|
val lines = pickOrderLineRepository.findAllByPickOrderId(pickOrderEntity.id!!) |
|
|
|
@@ -1514,7 +1522,7 @@ open class DeliveryOrderService( |
|
|
|
val saveSuggestedPickLots = suggestedPickLotService.saveAll(suggestions.suggestedList) |
|
|
|
val insufficientCount = suggestions.suggestedList.count { it.suggestedLotLine == null } |
|
|
|
if (insufficientCount > 0) { |
|
|
|
println("⚠️ WARNING: $insufficientCount items have insufficient stock (issues auto-created)") |
|
|
|
println(" WARNING: $insufficientCount items have insufficient stock (issues auto-created)") |
|
|
|
} |
|
|
|
val inventoryLotLines = inventoryLotLineRepository.findAllByIdIn( |
|
|
|
saveSuggestedPickLots.mapNotNull { it.suggestedLotLine?.id } |
|
|
|
@@ -1531,16 +1539,10 @@ open class DeliveryOrderService( |
|
|
|
} |
|
|
|
inventoryLotLineRepository.saveAll(inventoryLotLines) |
|
|
|
|
|
|
|
// 创建 stock out |
|
|
|
val stockOut = StockOut().apply { |
|
|
|
this.type = "do" |
|
|
|
this.consoPickOrderCode = consoCode |
|
|
|
this.status = StockOutStatus.PENDING.status |
|
|
|
this.handler = request.userId |
|
|
|
} |
|
|
|
val savedStockOut = stockOutRepository.saveAndFlush(stockOut) |
|
|
|
|
|
|
|
|
|
|
|
// No-lot (insufficient stock) lines are created in suggestedPickLotService.saveAll → createStockOutLineForSuggestion; skip here to avoid duplicates. |
|
|
|
saveSuggestedPickLots.forEach { lot -> |
|
|
|
if (lot.suggestedLotLine == null) return@forEach |
|
|
|
val polId = lot.pickOrderLine?.id |
|
|
|
val illId = lot.suggestedLotLine?.id |
|
|
|
if (polId != null) { |
|
|
|
|