CANCERYS\kw093 2 giorni fa
parent
commit
4bfa566a52
1 ha cambiato i file con 15 aggiunte e 6 eliminazioni
  1. +15
    -6
      src/main/java/com/ffii/fpsms/modules/stock/service/StockInLineService.kt

+ 15
- 6
src/main/java/com/ffii/fpsms/modules/stock/service/StockInLineService.kt Vedi File

@@ -96,9 +96,18 @@ open class StockInLineService(

open fun assignLotNo(): String {
val prefix = "LT"
val midfix = CodeGenerator.DEFAULT_MIDFIX
val latestCode = inventoryLotRepository.findLatestLotNoByPrefix("${prefix}-${midfix}")
return CodeGenerator.generateNo(prefix = prefix, latestCode = latestCode)
// ✅ 每次调用都取今天的日期段
val midfix = LocalDate.now().format(CodeGenerator.DEFAULT_FORMATTER)
// ✅ 用同一个 midfix 去查最新记录
val latestCode = inventoryLotRepository.findLatestLotNoByPrefix("$prefix-$midfix")
// ✅ 并且把同一个 midfix 传给 CodeGenerator
return CodeGenerator.generateNo(
prefix = prefix,
midfix = midfix,
latestCode = latestCode
)
}

@Throws(IOException::class)
@@ -791,7 +800,7 @@ open class StockInLineService(

// Step 2: Create a row in stock_in_line table
val item = itemRepository.findById(request.itemId).orElseThrow()
val newLotNo = request.lotNo ?: assignLotNo()
val stockInLine = StockInLine().apply {
this.item = item
this.itemNo = request.itemNo
@@ -802,7 +811,7 @@ open class StockInLineService(
this.productionDate = LocalDateTime.now()
this.expiryDate = request.expiryDate
this.status = StockInLineStatus.COMPLETE.status
this.lotNo = request.lotNo ?: assignLotNo()
this.lotNo = newLotNo
this.productLotNo = request.productLotNo
this.dnNo = request.dnNo
this.type = request.type
@@ -811,7 +820,7 @@ open class StockInLineService(


// Step 3: Create a row in inventory_lot table
val lotNo = request.lotNo ?: assignLotNo()
val lotNo = newLotNo
val inventoryLot = InventoryLot().apply {
this.item = item
this.stockInLine = savedStockInLine


Caricamento…
Annulla
Salva