From 8d29727a2b8266728c597a27d2fc62a6f9d19510 Mon Sep 17 00:00:00 2001 From: "CANCERYS\\kw093" Date: Sat, 31 Jan 2026 22:44:24 +0800 Subject: [PATCH] update putaway --- .../jobOrder/service/JobOrderService.kt | 8 +++-- .../stock/service/StockInLineService.kt | 36 ++++++++++++++----- 2 files changed, 34 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/ffii/fpsms/modules/jobOrder/service/JobOrderService.kt b/src/main/java/com/ffii/fpsms/modules/jobOrder/service/JobOrderService.kt index 43df6e9..b5b57a3 100644 --- a/src/main/java/com/ffii/fpsms/modules/jobOrder/service/JobOrderService.kt +++ b/src/main/java/com/ffii/fpsms/modules/jobOrder/service/JobOrderService.kt @@ -419,8 +419,12 @@ open class JobOrderService( } jobOrderRepository.save(jo) - val pols = jo.jobms.filter { it.item?.type != "CMB"&& it.item?.type != "consumables" && it.item?.type != "NM"}. - map { + val pols = jo.jobms.filter { + it.item?.type != "CMB" && + it.item?.type != "consumables" && + it.item?.type != "NM" && + it.item?.isFee != true // 添加:跳过 isFee 为 true 的物料 + }.map { SavePickOrderLineRequest( itemId = it.item?.id, qty = it.reqQty ?: BigDecimal.ZERO, diff --git a/src/main/java/com/ffii/fpsms/modules/stock/service/StockInLineService.kt b/src/main/java/com/ffii/fpsms/modules/stock/service/StockInLineService.kt index cf0e86a..cdc80c3 100644 --- a/src/main/java/com/ffii/fpsms/modules/stock/service/StockInLineService.kt +++ b/src/main/java/com/ffii/fpsms/modules/stock/service/StockInLineService.kt @@ -226,7 +226,6 @@ open class StockInLineService( val response = request.inventoryLotLines?.let { lines -> val saveLines = mutableListOf(); lines.forEach { line -> - val inventoryLotLine = InventoryLotLine() val warehouse = warehouseRepository.findById(line.warehouseId!!).orElseThrow() val stockItemUom = itemUomRepository.findBaseUnitByItemIdAndStockUnitIsTrueAndDeletedIsFalse( itemId = request.itemId @@ -237,17 +236,38 @@ open class StockInLineService( } else { (line.qty) } - inventoryLotLine.apply { - this.inventoryLot = stockInLine.inventoryLot - this.warehouse = warehouse - this.inQty = convertedBaseQty - this.status = InventoryLotLineStatus.AVAILABLE - this.stockUom = stockItemUom + + // ✅ Find existing inventory lot line for same warehouse and inventory lot + val existingLotLine = stockInLine.inventoryLot?.id?.let { inventoryLotId -> + inventoryLotLineRepository.findByInventoryLotStockInLineIdAndWarehouseId( + inventoryLotStockInLineId = stockInLine.id!!, + warehouseId = warehouse.id!! + ) + } + + if (existingLotLine != null) { + // ✅ Update existing inventory lot line (add to existing qty) + existingLotLine.apply { + this.inQty = (this.inQty ?: BigDecimal.ZERO) + convertedBaseQty + this.status = InventoryLotLineStatus.AVAILABLE + } + saveLines.add(existingLotLine) + } else { + // ✅ Create new inventory lot line (first put away for this warehouse) + val inventoryLotLine = InventoryLotLine() + inventoryLotLine.apply { + this.inventoryLot = stockInLine.inventoryLot + this.warehouse = warehouse + this.inQty = convertedBaseQty + this.status = InventoryLotLineStatus.AVAILABLE + this.stockUom = stockItemUom + } + saveLines.add(inventoryLotLine) } - saveLines.add(inventoryLotLine) } inventoryLotLineRepository.saveAll(saveLines) } + return response ?: emptyList(); // val inventoryLotLine = InventoryLotLine()