Преглед изворни кода

inventory search fix

production
CANCERYS\kw093 пре 1 месец
родитељ
комит
1a6cb36897
2 измењених фајлова са 28 додато и 17 уклоњено
  1. +12
    -12
      src/main/java/com/ffii/fpsms/modules/productProcess/service/ProductProcessService.kt
  2. +16
    -5
      src/main/java/com/ffii/fpsms/modules/stock/entity/InventoryRepository.kt

+ 12
- 12
src/main/java/com/ffii/fpsms/modules/productProcess/service/ProductProcessService.kt Прегледај датотеку

@@ -2385,11 +2385,11 @@ open class ProductProcessService(
val allLines = productProcessLineRepository.findByProductProcess_Id(productProcessId)
.sortedBy { it.seqNo ?: 0L }

println("=== findNewCreatedLineIds DEBUG START ===")
println("BOM bomProcessMap: $bomProcessMap")
println("All lines (sorted by seqNo):")
//println("=== findNewCreatedLineIds DEBUG START ===")
//println("BOM bomProcessMap: $bomProcessMap")
//println("All lines (sorted by seqNo):")
allLines.forEach { line ->
println(" id=${line.id}, seqNo=${line.seqNo}, bomProcessId=${line.bomProcess?.id}")
//println(" id=${line.id}, seqNo=${line.seqNo}, bomProcessId=${line.bomProcess?.id}")
}

// 创建一个集合来跟踪哪些 line 是新创建的
@@ -2402,18 +2402,18 @@ open class ProductProcessService(
iteration++
hasChanges = false

println("\n--- Iteration $iteration ---")
//println("\n--- Iteration $iteration ---")

// 获取剩余的 line(排除已标记为新创建的),按 seqNo 排序
val remainingLines = allLines.filter { it.id !in newCreatedLineIds }
.sortedBy { it.seqNo ?: 0L }

println("Remaining lines (excluding new created):")
//println("Remaining lines (excluding new created):")
remainingLines.forEach { line ->
println(" id=${line.id}, seqNo=${line.seqNo}, bomProcessId=${line.bomProcess?.id}")
//println(" id=${line.id}, seqNo=${line.seqNo}, bomProcessId=${line.bomProcess?.id}")
}

println("New created line IDs so far: $newCreatedLineIds")
//println("New created line IDs so far: $newCreatedLineIds")

// 计算每个剩余 line 的期望 seqNo(应该是连续的 1, 2, 3...)
val expectedSeqNoMap = remainingLines.mapIndexed { index, line ->
@@ -2430,7 +2430,7 @@ open class ProductProcessService(
val bomProcessId = line.bomProcess?.id
val expectedSeqNo = expectedSeqNoMap[line.id] ?: continue

println("\nChecking line id=${line.id}, seqNo=${line.seqNo}, bomProcessId=$bomProcessId, expectedSeqNo=$expectedSeqNo")
//println("\nChecking line id=${line.id}, seqNo=${line.seqNo}, bomProcessId=$bomProcessId, expectedSeqNo=$expectedSeqNo")

if (bomProcessId == null) {
println(" -> No bomProcessId, marking as new created")
@@ -2442,7 +2442,7 @@ open class ProductProcessService(
// 查找这个 bomProcessId 在 BOM 中的实际 seqNo
val bomProcessSeqNo = bomProcessMap[bomProcessId]

println(" -> BOM bomProcessId=$bomProcessId has seqNo=$bomProcessSeqNo in BOM")
//println(" -> BOM bomProcessId=$bomProcessId has seqNo=$bomProcessSeqNo in BOM")

if (bomProcessSeqNo == null) {
println(" -> bomProcessId not found in BOM, marking as new created")
@@ -2461,8 +2461,8 @@ open class ProductProcessService(
}
}
}
println("\n=== Final Result ===")
println("New created line IDs: $newCreatedLineIds")
//println("\n=== Final Result ===")
//println("New created line IDs: $newCreatedLineIds")
println("=== findNewCreatedLineIds DEBUG END ===\n")

return newCreatedLineIds


+ 16
- 5
src/main/java/com/ffii/fpsms/modules/stock/entity/InventoryRepository.kt Прегледај датотеку

@@ -14,11 +14,22 @@ import java.util.Optional
interface InventoryRepository: AbstractRepository<Inventory, Long> {
fun findInventoryInfoByDeletedIsFalse(): List<InventoryInfo>

@Query("SELECT i FROM Inventory i " +
"WHERE (:code IS NULL OR i.item.code LIKE CONCAT('%', :code, '%')) " +
"AND (:name IS NULL OR i.item.name LIKE CONCAT('%', :name, '%')) " +
"AND (:type IS NULL OR :type = '' OR i.item.type = :type) " +
"AND i.deleted = false")
@Query(
"""
SELECT i FROM Inventory i
WHERE (:code IS NULL OR i.item.code LIKE CONCAT('%', :code, '%'))
AND (:name IS NULL OR i.item.name LIKE CONCAT('%', :name, '%'))
AND (:type IS NULL OR :type = '' OR i.item.type = :type)
AND i.deleted = false
AND EXISTS (
SELECT 1 FROM ItemUom iu
WHERE iu.item.id = i.item.id
AND iu.deleted = false
AND iu.baseUnit = true
AND iu.uom.id = i.uom.id
)
"""
)
fun findInventoryInfoByItemCodeContainsAndItemNameContainsAndItemTypeAndDeletedIsFalse(code: String, name: String, type: String, pageable: Pageable): Page<InventoryInfo>

@Query("SELECT i FROM Inventory i " +


Loading…
Откажи
Сачувај