| @@ -81,40 +81,10 @@ open class ReportService( | |||||
| lastOutDateEnd: String? | lastOutDateEnd: String? | ||||
| ): List<Map<String, Any>> { | ): List<Map<String, Any>> { | ||||
| val args = mutableMapOf<String, Any>() | val args = mutableMapOf<String, Any>() | ||||
| // Stock Category 过滤:通过 qc_category.code 或 qc_category.name | |||||
| val stockCategorySql = if (!stockCategory.isNullOrBlank()) { | |||||
| val categories = stockCategory.split(",").map { it.trim() }.filter { it.isNotBlank() } | |||||
| if (categories.isNotEmpty()) { | |||||
| val conditions = categories.mapIndexed { index, cat -> | |||||
| val paramName = "stockCategory_$index" | |||||
| args[paramName] = "%$cat%" | |||||
| "(qc.code LIKE :$paramName OR qc.name LIKE :$paramName)" | |||||
| } | |||||
| "AND (${conditions.joinToString(" OR ")})" | |||||
| } else { | |||||
| "" | |||||
| } | |||||
| } else { | |||||
| "" | |||||
| } | |||||
| // 修正:stockSubCategory 也过滤 qc_category.name(而不是 item_category.sub) | |||||
| val stockSubCategorySql = if (!stockSubCategory.isNullOrBlank()) { | |||||
| val values = stockSubCategory.split(",").map { it.trim() }.filter { it.isNotBlank() } | |||||
| if (values.isNotEmpty()) { | |||||
| val conditions = values.mapIndexed { index, value -> | |||||
| val paramName = "stockSubCategory_$index" | |||||
| args[paramName] = "%$value%" | |||||
| "qc.name LIKE :$paramName" | |||||
| } | |||||
| "AND (${conditions.joinToString(" OR ")})" | |||||
| } else { | |||||
| "" | |||||
| } | |||||
| } else { | |||||
| "" | |||||
| } | |||||
| val stockCategorySql = "" | |||||
| val stockSubCategorySql = "" | |||||
| val itemCodeSql = buildMultiValueLikeClause(itemCode, "it.code", "itemCode", args) | val itemCodeSql = buildMultiValueLikeClause(itemCode, "it.code", "itemCode", args) | ||||
| @@ -155,7 +125,7 @@ open class ReportService( | |||||
| ) AS DECIMAL(14,2) | ) AS DECIMAL(14,2) | ||||
| ) AS qtyNumeric, | ) AS qtyNumeric, | ||||
| CAST(ROUND(IFNULL(IFNULL(sol.qty, dol.qty), 0), 2) AS CHAR) AS qty, | |||||
| FORMAT(ROUND(IFNULL(IFNULL(sol.qty, dol.qty), 0), 0), 0) AS qty, | |||||
| COALESCE( | COALESCE( | ||||
| dpor.TruckLanceCode, | dpor.TruckLanceCode, | ||||
| (SELECT t2.TruckLanceCode | (SELECT t2.TruckLanceCode | ||||
| @@ -252,9 +222,10 @@ CAST(ROUND(IFNULL(IFNULL(sol.qty, dol.qty), 0), 2) AS CHAR) AS qty, | |||||
| $yearSql | $yearSql | ||||
| $lastOutDateStartSql | $lastOutDateStartSql | ||||
| $lastOutDateEndSql | $lastOutDateEndSql | ||||
| ORDER BY | |||||
| qc.name, | |||||
| ORDER BY | |||||
| it.code, | it.code, | ||||
| deliveryDate, | |||||
| qc.name, | |||||
| IFNULL(sil.lotNo, '') | IFNULL(sil.lotNo, '') | ||||
| """.trimIndent() | """.trimIndent() | ||||
| @@ -64,8 +64,8 @@ | |||||
| <field name="driver" class="java.lang.String"/> | <field name="driver" class="java.lang.String"/> | ||||
| <field name="deliveryOrderNo" class="java.lang.String"/> | <field name="deliveryOrderNo" class="java.lang.String"/> | ||||
| <field name="stockSubCategory" class="java.lang.String"/> | <field name="stockSubCategory" class="java.lang.String"/> | ||||
| <variable name="totalDeliveredQtyPerDeliveryOrder" class="java.math.BigDecimal" resetType="Group" resetGroup="Group1" incrementType="Group" incrementGroup="Group1" calculation="First"> | |||||
| <variableExpression><![CDATA[$F{qtyNumeric}]]></variableExpression> | |||||
| <variable name="totalDeliveredQtyPerDeliveryOrder" class="java.math.BigDecimal" resetType="Group" resetGroup="Group1" incrementType="Group" incrementGroup="Group1" calculation="Sum"> | |||||
| <variableExpression><![CDATA[$F{qtyNumeric} != null ? $F{qtyNumeric} : java.math.BigDecimal.ZERO]]></variableExpression> | |||||
| </variable> | </variable> | ||||
| <group name="Group1" keepTogether="true"> | <group name="Group1" keepTogether="true"> | ||||
| <groupExpression><![CDATA[$F{itemNo}]]></groupExpression> | <groupExpression><![CDATA[$F{itemNo}]]></groupExpression> | ||||
| @@ -90,12 +90,12 @@ | |||||
| </textElement> | </textElement> | ||||
| <text><![CDATA[每單交貨總數:]]></text> | <text><![CDATA[每單交貨總數:]]></text> | ||||
| </staticText> | </staticText> | ||||
| <textField> | |||||
| <textField pattern="#,##0"> | |||||
| <reportElement x="502" y="0" width="80" height="19" uuid="939e4c5b-176c-4154-aabd-bf06c2a0e594"/> | <reportElement x="502" y="0" width="80" height="19" uuid="939e4c5b-176c-4154-aabd-bf06c2a0e594"/> | ||||
| <textElement textAlignment="Right" verticalAlignment="Middle"> | <textElement textAlignment="Right" verticalAlignment="Middle"> | ||||
| <font fontName="微軟正黑體" size="10" isBold="true"/> | <font fontName="微軟正黑體" size="10" isBold="true"/> | ||||
| </textElement> | </textElement> | ||||
| <textFieldExpression><![CDATA[$F{qtyNumeric} != null ? $F{qtyNumeric}.toString() : "0.00"]]></textFieldExpression> | |||||
| <textFieldExpression><![CDATA[$V{totalDeliveredQtyPerDeliveryOrder}]]></textFieldExpression> | |||||
| </textField> | </textField> | ||||
| <line> | <line> | ||||
| <reportElement x="0" y="19" width="799" height="1" uuid="69c9e68d-5a48-4284-b977-d12984bde9bc"> | <reportElement x="0" y="19" width="799" height="1" uuid="69c9e68d-5a48-4284-b977-d12984bde9bc"> | ||||