CANCERYS\kw093 1 неделю назад
Родитель
Сommit
ba20fd43fa
2 измененных файлов: 15 добавлений и 7 удалений
  1. +11
    -5
      src/main/java/com/ffii/fpsms/modules/stock/service/StockTakeRecordService.kt
  2. +4
    -2
      src/main/java/com/ffii/fpsms/modules/stock/web/StockTakeRecordController.kt

+ 11
- 5
src/main/java/com/ffii/fpsms/modules/stock/service/StockTakeRecordService.kt Просмотреть файл

@@ -1250,7 +1250,7 @@ open class StockTakeRecordService(
return toRemove.size return toRemove.size
} }


open fun listStockTakeRoundCards(yearMonth: String?): StockTakeRoundCardsRes {
open fun listStockTakeRoundCards(yearMonth: String?, view: String? = null): StockTakeRoundCardsRes {
val all = stockTakeRepository.findAll().filter { !it.deleted } val all = stockTakeRepository.findAll().filter { !it.deleted }
if (all.isEmpty()) { if (all.isEmpty()) {
val thisMonth = java.time.YearMonth.now().toString() val thisMonth = java.time.YearMonth.now().toString()
@@ -1285,13 +1285,19 @@ open class StockTakeRecordService(
val completedYearMonths = ( val completedYearMonths = (
cards.filter { !it.open }.map { it.yearMonth } + thisMonth cards.filter { !it.open }.map { it.yearMonth } + thisMonth
).distinct().filter { it <= thisMonth }.sortedDescending() ).distinct().filter { it <= thisMonth }.sortedDescending()
val rounds = if (hasOpenRounds) {
val openRoundsSorted = run {
val openCards = cards.filter { it.open } val openCards = cards.filter { it.open }
val thisMonthOpen = openCards.filter { it.yearMonth == thisMonth } val thisMonthOpen = openCards.filter { it.yearMonth == thisMonth }
thisMonthOpen + openCards.filter { it.yearMonth != thisMonth } thisMonthOpen + openCards.filter { it.yearMonth != thisMonth }
} else {
val ym = yearMonth?.trim()?.takeIf { it.matches(Regex("\\d{4}-\\d{2}")) } ?: thisMonth
cards.filter { !it.open && it.yearMonth == ym }
}
val historyYm = yearMonth?.trim()?.takeIf { it.matches(Regex("\\d{4}-\\d{2}")) } ?: thisMonth
val historyRounds = cards.filter { !it.open && it.yearMonth == historyYm }
val viewNorm = view?.trim()?.lowercase().orEmpty()
val rounds = when (viewNorm) {
"open" -> openRoundsSorted
"history" -> historyRounds
// 舊行為:有進行中只回 open,否則回該月歷史(PickerCardList 等相容)
else -> if (hasOpenRounds) openRoundsSorted else historyRounds
} }
return StockTakeRoundCardsRes( return StockTakeRoundCardsRes(
hasOpenRounds = hasOpenRounds, hasOpenRounds = hasOpenRounds,


+ 4
- 2
src/main/java/com/ffii/fpsms/modules/stock/web/StockTakeRecordController.kt Просмотреть файл

@@ -190,9 +190,11 @@ class StockTakeRecordController(


@GetMapping("/stockTakeRoundCards") @GetMapping("/stockTakeRoundCards")
fun stockTakeRoundCards( fun stockTakeRoundCards(
@RequestParam(required = false) yearMonth: String?
@RequestParam(required = false) yearMonth: String?,
/** open=進行中;history=歷史(依 yearMonth);未傳則維持舊互斥行為 */
@RequestParam(required = false) view: String?,
): StockTakeRoundCardsRes { ): StockTakeRoundCardsRes {
return stockOutRecordService.listStockTakeRoundCards(yearMonth)
return stockOutRecordService.listStockTakeRoundCards(yearMonth, view)
} }


@GetMapping("/busyStockTakeSections") @GetMapping("/busyStockTakeSections")


Загрузка…
Отмена
Сохранить