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. | |||
| * Rejects date >= today. | |||
| */ | |||
| open fun runStockLotDayClose(date: LocalDate? = null): String { | |||
| val currentTime = LocalDateTime.now() | |||
| return try { | |||
| val result = stockLotDayCloseService.closeThrough( | |||
| target = date, | |||
| @@ -635,36 +635,13 @@ open class SchedulerService( | |||
| if (result.skipped) { | |||
| val msg = "stock_lot_day close skipped: ${result.skipReason}" | |||
| logger.warn("Scheduler - {}", msg) | |||
| saveSyncLog( | |||
| type = "STOCK_LOT_DAY", | |||
| status = "SKIPPED", | |||
| result = SyncResult(0, 0, 0, msg), | |||
| start = currentTime, | |||
| ) | |||
| return msg | |||
| } | |||
| 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) | |||
| "stock_lot_day close ok $query rows=${result.totalRows}" | |||
| } catch (e: Exception) { | |||
| 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 | |||
| } | |||
| } | |||
| @@ -53,6 +53,7 @@ class StockLotLedgerReportController( | |||
| 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") | |||
| fun exportStockLotLedgerReportExcel( | |||
| @RequestParam(required = false) itemCode: String?, | |||
| @@ -71,7 +72,6 @@ class StockLotLedgerReportController( | |||
| dbData = result.rows, | |||
| reportPeriodStart = period.startStr, | |||
| reportPeriodEnd = period.endStr, | |||
| timings = result.timings, | |||
| ) | |||
| val excelMs = (System.nanoTime() - tExcel) / 1_000_000 | |||
| val totalMs = (System.nanoTime() - tAll) / 1_000_000 | |||
| @@ -209,11 +209,11 @@ class StockLotLedgerReportController( | |||
| return v?.toString() == "1" | |||
| } | |||
| /** FP-MTMS Version Checklist | Functions Ref. No. 91 | v1.0.0 | 2026-11-06 */ | |||
| private fun createExcel( | |||
| dbData: List<Map<String, Any>>, | |||
| reportPeriodStart: String, | |||
| reportPeriodEnd: String, | |||
| timings: List<String>, | |||
| ): ByteArray { | |||
| val workbook = SXSSFWorkbook(100) | |||
| workbook.setCompressTempFiles(true) | |||
| @@ -252,16 +252,6 @@ class StockLotLedgerReportController( | |||
| cellStyle = styles.subtitle | |||
| } | |||
| 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 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). | |||
| jo: | |||
| planStart: | |||
| enabled: true | |||
| enabled: false | |||
| # One-time DO1 catch-up jobs (production only — requires scheduler.m18Sync.enabled=true in application-prod.yml). | |||
| do1CatchUp: | |||
| enabled: false | |||