Co-authored-by: Cursor <[email protected]>production
| @@ -622,11 +622,11 @@ open class SchedulerService( | |||||
| } | } | ||||
| /** | /** | ||||
| * FP-MTMS Version Checklist | Functions Ref. No. 92 | v1.0.0 | 2026-11-06 | |||||
| * Close through [date] (default yesterday). Catch-up from last closed day, capped by catchUpDays. | * Close through [date] (default yesterday). Catch-up from last closed day, capped by catchUpDays. | ||||
| * Rejects date >= today. | * Rejects date >= today. | ||||
| */ | */ | ||||
| open fun runStockLotDayClose(date: LocalDate? = null): String { | open fun runStockLotDayClose(date: LocalDate? = null): String { | ||||
| val currentTime = LocalDateTime.now() | |||||
| return try { | return try { | ||||
| val result = stockLotDayCloseService.closeThrough( | val result = stockLotDayCloseService.closeThrough( | ||||
| target = date, | target = date, | ||||
| @@ -635,36 +635,13 @@ open class SchedulerService( | |||||
| if (result.skipped) { | if (result.skipped) { | ||||
| val msg = "stock_lot_day close skipped: ${result.skipReason}" | val msg = "stock_lot_day close skipped: ${result.skipReason}" | ||||
| logger.warn("Scheduler - {}", msg) | logger.warn("Scheduler - {}", msg) | ||||
| saveSyncLog( | |||||
| type = "STOCK_LOT_DAY", | |||||
| status = "SKIPPED", | |||||
| result = SyncResult(0, 0, 0, msg), | |||||
| start = currentTime, | |||||
| ) | |||||
| return msg | return msg | ||||
| } | } | ||||
| val query = "from=${result.dateFrom} to=${result.dateTo} days=${result.days.size} catchUpDays=$stockLotDayCloseCatchUpDays" | val query = "from=${result.dateFrom} to=${result.dateTo} days=${result.days.size} catchUpDays=$stockLotDayCloseCatchUpDays" | ||||
| saveSyncLog( | |||||
| type = "STOCK_LOT_DAY", | |||||
| status = "SUCCESS", | |||||
| result = SyncResult( | |||||
| totalProcessed = result.days.size, | |||||
| totalSuccess = result.totalRows, | |||||
| totalFail = 0, | |||||
| query = query, | |||||
| ), | |||||
| start = currentTime, | |||||
| ) | |||||
| logger.info("Scheduler - stock_lot_day close done {}", query) | logger.info("Scheduler - stock_lot_day close done {}", query) | ||||
| "stock_lot_day close ok $query rows=${result.totalRows}" | "stock_lot_day close ok $query rows=${result.totalRows}" | ||||
| } catch (e: Exception) { | } catch (e: Exception) { | ||||
| logger.error("Scheduler - stock_lot_day close failed: ${e.message}", e) | logger.error("Scheduler - stock_lot_day close failed: ${e.message}", e) | ||||
| saveSyncLog( | |||||
| type = "STOCK_LOT_DAY", | |||||
| status = "FAILED", | |||||
| error = e.message, | |||||
| start = currentTime, | |||||
| ) | |||||
| throw e | throw e | ||||
| } | } | ||||
| } | } | ||||
| @@ -53,6 +53,7 @@ class StockLotLedgerReportController( | |||||
| return mapOf("earliest" to earliest.format(DateTimeFormatter.ISO_LOCAL_DATE)) | return mapOf("earliest" to earliest.format(DateTimeFormatter.ISO_LOCAL_DATE)) | ||||
| } | } | ||||
| /** FP-MTMS Version Checklist | Functions Ref. No. 91 | v1.0.0 | 2026-11-06 */ | |||||
| @GetMapping("/print-stock-lot-ledger-excel") | @GetMapping("/print-stock-lot-ledger-excel") | ||||
| fun exportStockLotLedgerReportExcel( | fun exportStockLotLedgerReportExcel( | ||||
| @RequestParam(required = false) itemCode: String?, | @RequestParam(required = false) itemCode: String?, | ||||
| @@ -71,7 +72,6 @@ class StockLotLedgerReportController( | |||||
| dbData = result.rows, | dbData = result.rows, | ||||
| reportPeriodStart = period.startStr, | reportPeriodStart = period.startStr, | ||||
| reportPeriodEnd = period.endStr, | reportPeriodEnd = period.endStr, | ||||
| timings = result.timings, | |||||
| ) | ) | ||||
| val excelMs = (System.nanoTime() - tExcel) / 1_000_000 | val excelMs = (System.nanoTime() - tExcel) / 1_000_000 | ||||
| val totalMs = (System.nanoTime() - tAll) / 1_000_000 | val totalMs = (System.nanoTime() - tAll) / 1_000_000 | ||||
| @@ -209,11 +209,11 @@ class StockLotLedgerReportController( | |||||
| return v?.toString() == "1" | return v?.toString() == "1" | ||||
| } | } | ||||
| /** FP-MTMS Version Checklist | Functions Ref. No. 91 | v1.0.0 | 2026-11-06 */ | |||||
| private fun createExcel( | private fun createExcel( | ||||
| dbData: List<Map<String, Any>>, | dbData: List<Map<String, Any>>, | ||||
| reportPeriodStart: String, | reportPeriodStart: String, | ||||
| reportPeriodEnd: String, | reportPeriodEnd: String, | ||||
| timings: List<String>, | |||||
| ): ByteArray { | ): ByteArray { | ||||
| val workbook = SXSSFWorkbook(100) | val workbook = SXSSFWorkbook(100) | ||||
| workbook.setCompressTempFiles(true) | workbook.setCompressTempFiles(true) | ||||
| @@ -252,16 +252,6 @@ class StockLotLedgerReportController( | |||||
| cellStyle = styles.subtitle | cellStyle = styles.subtitle | ||||
| } | } | ||||
| sheet.addMergedRegion(CellRangeAddress(1, 1, 5, totalColumns - 1)) | sheet.addMergedRegion(CellRangeAddress(1, 1, 5, totalColumns - 1)) | ||||
| if (timings.isNotEmpty()) { | |||||
| val timingRow = sheet.createRow(rowIndex++) | |||||
| timingRow.createCell(0).apply { | |||||
| setCellValue("耗時:${timings.joinToString(" | ")}") | |||||
| cellStyle = styles.subtitle | |||||
| } | |||||
| sheet.addMergedRegion(CellRangeAddress(2, 2, 0, totalColumns - 1)) | |||||
| } else { | |||||
| sheet.createRow(rowIndex++) | |||||
| } | |||||
| val headerRowIndex = rowIndex | val headerRowIndex = rowIndex | ||||
| val headerRow = sheet.createRow(rowIndex++) | val headerRow = sheet.createRow(rowIndex++) | ||||
| @@ -40,7 +40,7 @@ scheduler: | |||||
| # Job order: at 00:00:15 daily, process JOs whose planStart was yesterday (hide or reschedule). | # Job order: at 00:00:15 daily, process JOs whose planStart was yesterday (hide or reschedule). | ||||
| jo: | jo: | ||||
| planStart: | planStart: | ||||
| enabled: true | |||||
| enabled: false | |||||
| # One-time DO1 catch-up jobs (production only — requires scheduler.m18Sync.enabled=true in application-prod.yml). | # One-time DO1 catch-up jobs (production only — requires scheduler.m18Sync.enabled=true in application-prod.yml). | ||||
| do1CatchUp: | do1CatchUp: | ||||
| enabled: false | enabled: false | ||||