diff --git a/src/main/java/com/ffii/fpsms/modules/report/service/ReportService.kt b/src/main/java/com/ffii/fpsms/modules/report/service/ReportService.kt index b9c9d36..e9cf4d1 100644 --- a/src/main/java/com/ffii/fpsms/modules/report/service/ReportService.kt +++ b/src/main/java/com/ffii/fpsms/modules/report/service/ReportService.kt @@ -647,10 +647,9 @@ return result } /** - * Queries the database for Stock In Traceability Report data (PO 入倉 / 入倉追蹤 PDF). + * Queries the database for Stock In Traceability Report data (入倉追蹤 PDF). * Joins stock_in_line, stock_in, items, qc_result, inventory_lot, inventory_lot_line, warehouse, and shop tables. * Supports comma-separated values for stockCategory (items.type) and itemCode. - * Adds `poM18CreatorDisplay` from `purchase_order.m18CreatedUId` via [M18GrnRules.formatM18CreatedUidForReport]. */ fun searchStockInTraceabilityReport( stockCategory: String?, @@ -705,7 +704,6 @@ return result COALESCE(wh.code, '') as storeLocation, COALESCE(sp_si.code, sp_po.code, '') as supplierID, COALESCE(sp_si.name, sp_po.name, '') as supplierName, - po.m18CreatedUId AS poM18CreatedUId, TRIM(TRAILING '.' FROM TRIM(TRAILING '0' FROM FORMAT(SUM(COALESCE(sil.acceptedQty, 0)) OVER (PARTITION BY it.id), 2))) as totalStockInQty, TRIM(TRAILING '.' FROM TRIM(TRAILING '0' FROM FORMAT(SUM(COALESCE(sil.acceptedQty, 0)) OVER (PARTITION BY it.id), 2))) as totalIqcSampleQty FROM stock_in_line sil @@ -740,20 +738,7 @@ return result ORDER BY it.code, sil.lotNo """.trimIndent() - val rows = jdbcDao.queryForList(sql, args) - return rows.map { row -> - val m = LinkedHashMap(row) - val raw = m.remove("poM18CreatedUId") - val uid = when (raw) { - null -> null - is Number -> raw.toLong() - is BigDecimal -> raw.toLong() - else -> raw.toString().toLongOrNull() - } - m["poM18CreatorDisplay"] = M18GrnRules.formatM18CreatedUidForReport(uid) - @Suppress("UNCHECKED_CAST") - m as Map - } + return jdbcDao.queryForList(sql, args) } /** @@ -808,7 +793,8 @@ return result MAX(ROUND(COALESCE(pol.up, 0) * COALESCE(sil.acceptedQty, 0), 2)) AS lineAmount, MAX(COALESCE(cur.code, '')) AS currencyCode, MAX(grn.grn_code) AS grnCode, - MAX(grn.m18_record_id) AS grnId + MAX(grn.m18_record_id) AS grnId, + MAX(po.m18CreatedUId) AS poM18CreatedUId FROM stock_in_line sil LEFT JOIN items it ON sil.itemId = it.id LEFT JOIN purchase_order po ON sil.purchaseOrderId = po.id @@ -870,7 +856,15 @@ return result "lineAmount" to (row["lineAmount"]?.let { n -> (n as? Number)?.toDouble() } ?: 0.0), "currencyCode" to row["currencyCode"], "grnCode" to row["grnCode"], - "grnId" to row["grnId"] + "grnId" to row["grnId"], + "poM18CreatorDisplay" to M18GrnRules.formatM18CreatedUidForReport( + when (val v = row["poM18CreatedUId"]) { + null -> null + is Number -> v.toLong() + is BigDecimal -> v.toLong() + else -> v.toString().toLongOrNull() + }, + ), ) } } diff --git a/src/main/resources/jasper/StockInTraceabilityReport.jrxml b/src/main/resources/jasper/StockInTraceabilityReport.jrxml index 6804432..a3ce02c 100644 --- a/src/main/resources/jasper/StockInTraceabilityReport.jrxml +++ b/src/main/resources/jasper/StockInTraceabilityReport.jrxml @@ -57,7 +57,6 @@ - @@ -174,7 +173,7 @@ - + @@ -184,18 +183,6 @@ - - - - - - - - - - - @@ -484,7 +471,7 @@ - + @@ -492,15 +479,6 @@ - - - - - - - - -