|
|
|
@@ -12,10 +12,8 @@ import org.springframework.stereotype.Service |
|
|
|
import org.springframework.web.server.ResponseStatusException |
|
|
|
|
|
|
|
/** |
|
|
|
* Open **section** rounds block only items that appear on that round's stock-take records |
|
|
|
* (a section round that skipped lots already on an item round does not freeze those items). |
|
|
|
* Open **item** rounds block only items on their records. |
|
|
|
* If a section-mode round has no records yet, freeze the whole section (conservative). |
|
|
|
* Open **section** rounds freeze the whole section (all items / warehouses in that section). |
|
|
|
* Open **item** rounds block only items that appear on their stock-take records (same section). |
|
|
|
* Stock-take's own variance posting does not call this guard. |
|
|
|
*/ |
|
|
|
@Service |
|
|
|
@@ -42,20 +40,9 @@ class StockTakeLocationGuard( |
|
|
|
StockTakeRoundMode.ITEM.equals(row.getStockTakeRoundMode()?.trim(), ignoreCase = true) |
|
|
|
} |
|
|
|
|
|
|
|
// Section round: always freeze the entire section (not only items on records). |
|
|
|
if (sectionModeOpens.isNotEmpty()) { |
|
|
|
val sectionRecords = loadRecords(sectionModeOpens).filter { rec -> |
|
|
|
section.equals(rec.stockTakeSection?.trim(), ignoreCase = true) |
|
|
|
} |
|
|
|
if (sectionRecords.isEmpty()) { |
|
|
|
// Header created but placeholders not yet → freeze whole section |
|
|
|
return "盤點進行中,區域 $section 暫停出入庫" |
|
|
|
} |
|
|
|
if (itemId == null || itemId <= 0L) { |
|
|
|
return "盤點進行中,區域 $section 暫停出入庫" |
|
|
|
} |
|
|
|
if (sectionRecords.any { it.itemId == itemId }) { |
|
|
|
return "盤點進行中,區域 $section 暫停出入庫" |
|
|
|
} |
|
|
|
return "盤點進行中,區域 $section 暫停出入庫" |
|
|
|
} |
|
|
|
|
|
|
|
if (itemModeOpens.isEmpty()) return null |
|
|
|
|