| @@ -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. | * 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. | * Supports comma-separated values for stockCategory (items.type) and itemCode. | ||||
| * Adds `poM18CreatorDisplay` from `purchase_order.m18CreatedUId` via [M18GrnRules.formatM18CreatedUidForReport]. | |||||
| */ | */ | ||||
| fun searchStockInTraceabilityReport( | fun searchStockInTraceabilityReport( | ||||
| stockCategory: String?, | stockCategory: String?, | ||||
| @@ -705,7 +704,6 @@ return result | |||||
| COALESCE(wh.code, '') as storeLocation, | COALESCE(wh.code, '') as storeLocation, | ||||
| COALESCE(sp_si.code, sp_po.code, '') as supplierID, | COALESCE(sp_si.code, sp_po.code, '') as supplierID, | ||||
| COALESCE(sp_si.name, sp_po.name, '') as supplierName, | 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 totalStockInQty, | ||||
| TRIM(TRAILING '.' FROM TRIM(TRAILING '0' FROM FORMAT(SUM(COALESCE(sil.acceptedQty, 0)) OVER (PARTITION BY it.id), 2))) as totalIqcSampleQty | 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 | FROM stock_in_line sil | ||||
| @@ -740,20 +738,7 @@ return result | |||||
| ORDER BY it.code, sil.lotNo | ORDER BY it.code, sil.lotNo | ||||
| """.trimIndent() | """.trimIndent() | ||||
| val rows = jdbcDao.queryForList(sql, args) | |||||
| return rows.map { row -> | |||||
| val m = LinkedHashMap<String, Any?>(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<String, Any> | |||||
| } | |||||
| 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(ROUND(COALESCE(pol.up, 0) * COALESCE(sil.acceptedQty, 0), 2)) AS lineAmount, | ||||
| MAX(COALESCE(cur.code, '')) AS currencyCode, | MAX(COALESCE(cur.code, '')) AS currencyCode, | ||||
| MAX(grn.grn_code) AS grnCode, | 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 | FROM stock_in_line sil | ||||
| LEFT JOIN items it ON sil.itemId = it.id | LEFT JOIN items it ON sil.itemId = it.id | ||||
| LEFT JOIN purchase_order po ON sil.purchaseOrderId = po.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), | "lineAmount" to (row["lineAmount"]?.let { n -> (n as? Number)?.toDouble() } ?: 0.0), | ||||
| "currencyCode" to row["currencyCode"], | "currencyCode" to row["currencyCode"], | ||||
| "grnCode" to row["grnCode"], | "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() | |||||
| }, | |||||
| ), | |||||
| ) | ) | ||||
| } | } | ||||
| } | } | ||||
| @@ -57,7 +57,6 @@ | |||||
| <field name="storeLocation" class="java.lang.String"/> | <field name="storeLocation" class="java.lang.String"/> | ||||
| <field name="supplierID" class="java.lang.String"/> | <field name="supplierID" class="java.lang.String"/> | ||||
| <field name="supplierName" class="java.lang.String"/> | <field name="supplierName" class="java.lang.String"/> | ||||
| <field name="poM18CreatorDisplay" class="java.lang.String"/> | |||||
| <field name="totalStockInQty" class="java.lang.String"/> | <field name="totalStockInQty" class="java.lang.String"/> | ||||
| <field name="totalIqcSampleQty" class="java.lang.String"/> | <field name="totalIqcSampleQty" class="java.lang.String"/> | ||||
| <field name="totalIqcDefectQty" class="java.lang.String"/> | <field name="totalIqcDefectQty" class="java.lang.String"/> | ||||
| @@ -174,7 +173,7 @@ | |||||
| <text><![CDATA[送貨單編號]]></text> | <text><![CDATA[送貨單編號]]></text> | ||||
| </staticText> | </staticText> | ||||
| <staticText> | <staticText> | ||||
| <reportElement stretchType="RelativeToTallestObject" x="690" y="80" width="65" height="28" uuid="db5b9c55-0185-420b-ba6c-0e10d154cc8a"> | |||||
| <reportElement stretchType="RelativeToTallestObject" x="690" y="80" width="108" height="28" uuid="db5b9c55-0185-420b-ba6c-0e10d154cc8a"> | |||||
| <property name="com.jaspersoft.studio.unit.y" value="px"/> | <property name="com.jaspersoft.studio.unit.y" value="px"/> | ||||
| <property name="com.jaspersoft.studio.unit.height" value="px"/> | <property name="com.jaspersoft.studio.unit.height" value="px"/> | ||||
| <property name="com.jaspersoft.studio.unit.width" value="px"/> | <property name="com.jaspersoft.studio.unit.width" value="px"/> | ||||
| @@ -184,18 +183,6 @@ | |||||
| </textElement> | </textElement> | ||||
| <text><![CDATA[供應商名稱]]></text> | <text><![CDATA[供應商名稱]]></text> | ||||
| </staticText> | </staticText> | ||||
| <staticText> | |||||
| <reportElement stretchType="RelativeToTallestObject" x="758" y="80" width="42" height="28" uuid="a1b2c3d4-e5f6-7890-abcd-ef1234567890"> | |||||
| <property name="com.jaspersoft.studio.unit.y" value="px"/> | |||||
| <property name="com.jaspersoft.studio.unit.height" value="px"/> | |||||
| <property name="com.jaspersoft.studio.unit.width" value="px"/> | |||||
| </reportElement> | |||||
| <textElement textAlignment="Left" verticalAlignment="Middle"> | |||||
| <font fontName="微軟正黑體" size="9"/> | |||||
| </textElement> | |||||
| <text><![CDATA[PO建立者 | |||||
| (M18)]]></text> | |||||
| </staticText> | |||||
| <staticText> | <staticText> | ||||
| <reportElement stretchType="RelativeToTallestObject" x="220" y="80" width="60" height="28" uuid="cd7a146a-1af0-4428-9b88-dcb159691656"> | <reportElement stretchType="RelativeToTallestObject" x="220" y="80" width="60" height="28" uuid="cd7a146a-1af0-4428-9b88-dcb159691656"> | ||||
| <property name="com.jaspersoft.studio.unit.y" value="px"/> | <property name="com.jaspersoft.studio.unit.y" value="px"/> | ||||
| @@ -484,7 +471,7 @@ | |||||
| <textFieldExpression><![CDATA[$F{storeLocation}]]></textFieldExpression> | <textFieldExpression><![CDATA[$F{storeLocation}]]></textFieldExpression> | ||||
| </textField> | </textField> | ||||
| <textField textAdjust="StretchHeight"> | <textField textAdjust="StretchHeight"> | ||||
| <reportElement x="690" y="2" width="65" height="18" uuid="eb6ed0fc-bfda-4a89-a163-fe08b00a0120"> | |||||
| <reportElement x="690" y="2" width="108" height="18" uuid="eb6ed0fc-bfda-4a89-a163-fe08b00a0120"> | |||||
| <property name="com.jaspersoft.studio.unit.height" value="px"/> | <property name="com.jaspersoft.studio.unit.height" value="px"/> | ||||
| </reportElement> | </reportElement> | ||||
| <textElement textAlignment="Left" verticalAlignment="Top"> | <textElement textAlignment="Left" verticalAlignment="Top"> | ||||
| @@ -492,15 +479,6 @@ | |||||
| </textElement> | </textElement> | ||||
| <textFieldExpression><![CDATA[$F{supplierName}]]></textFieldExpression> | <textFieldExpression><![CDATA[$F{supplierName}]]></textFieldExpression> | ||||
| </textField> | </textField> | ||||
| <textField textAdjust="StretchHeight"> | |||||
| <reportElement x="758" y="2" width="42" height="18" uuid="f2e3d4c5-b6a7-8901-cdef-234567890abc"> | |||||
| <property name="com.jaspersoft.studio.unit.height" value="px"/> | |||||
| </reportElement> | |||||
| <textElement textAlignment="Left" verticalAlignment="Top"> | |||||
| <font fontName="微軟正黑體" size="9"/> | |||||
| </textElement> | |||||
| <textFieldExpression><![CDATA[$F{poM18CreatorDisplay}]]></textFieldExpression> | |||||
| </textField> | |||||
| </band> | </band> | ||||
| </detail> | </detail> | ||||
| </jasperReport> | </jasperReport> | ||||