Tommy\2Fi-Staff před 5 hodinami
rodič
revize
5da40f969e
3 změnil soubory, kde provedl 198 přidání a 16 odebrání
  1. +141
    -0
      src/main/java/com/ffii/fpsms/modules/master/service/ItemsService.kt
  2. +41
    -0
      src/main/java/com/ffii/fpsms/modules/master/web/ItemsController.kt
  3. +16
    -16
      src/main/resources/DeliveryNote/DeliveryNoteCartonLabelsPDF.jrxml

+ 141
- 0
src/main/java/com/ffii/fpsms/modules/master/service/ItemsService.kt Zobrazit soubor

@@ -790,6 +790,147 @@ open class ItemsService(
return jdbcDao.queryForList(sql.toString(), args);
}

open fun getItemOrderOrderedItems(search: String?, type: String? = null): List<Map<String, Any>> {
val sql = StringBuilder(
"""
SELECT
i.id,
i.code,
i.name,
i.item_Order as itemOrder,
i.store_id as storeId,
i.warehouse,
i.area,
i.slot,
i.LocationCode as locationCode
FROM items i
WHERE i.deleted = false
AND i.item_Order IS NOT NULL
""".trimIndent()
)
val args = mutableMapOf<String, Any>()
val typeTrim = type?.trim()
if (!typeTrim.isNullOrEmpty()) {
sql.append(" AND i.type = :type ")
args["type"] = typeTrim
}
val s = search?.trim()
if (!s.isNullOrEmpty()) {
sql.append(" AND (i.code LIKE :search OR i.name LIKE :search) ")
args["search"] = "%$s%"
}
sql.append(" ORDER BY i.item_Order ASC, i.code ASC ")
return jdbcDao.queryForList(sql.toString(), args)
}

open fun getItemOrderUnorderedItems(search: String?, type: String? = null): List<Map<String, Any>> {
// To keep UI responsive, do not allow fetching the whole "unordered items" list without search.
// Use the dedicated search API with LIMIT instead.
val sql = StringBuilder(
"""
SELECT
i.id,
i.code,
i.name,
i.item_Order as itemOrder,
i.store_id as storeId,
i.warehouse,
i.area,
i.slot,
i.LocationCode as locationCode
FROM items i
WHERE i.deleted = false
AND i.item_Order IS NULL
""".trimIndent()
)
val args = mutableMapOf<String, Any>()
val typeTrim = type?.trim()
if (!typeTrim.isNullOrEmpty()) {
sql.append(" AND i.type = :type ")
args["type"] = typeTrim
}
val s = search?.trim()
if (s.isNullOrEmpty()) {
return emptyList()
}
sql.append(" AND (i.code LIKE :search OR i.name LIKE :search) ")
args["search"] = "%$s%"
sql.append(" ORDER BY i.code ASC ")
return jdbcDao.queryForList(sql.toString(), args)
}

open fun searchItemOrderUnorderedItems(search: String, type: String? = null, limit: Int = 200): List<Map<String, Any>> {
val s = search.trim()
if (s.isEmpty()) return emptyList()
val safeLimit = limit.coerceIn(1, 500)
val sql = StringBuilder(
"""
SELECT
i.id,
i.code,
i.name,
i.item_Order as itemOrder,
i.store_id as storeId,
i.warehouse,
i.area,
i.slot,
i.LocationCode as locationCode
FROM items i
WHERE i.deleted = false
AND i.item_Order IS NULL
AND (i.code LIKE :search OR i.name LIKE :search)
""".trimIndent()
)
val args = mutableMapOf<String, Any>(
"search" to "%$s%",
"limit" to safeLimit,
)
val typeTrim = type?.trim()
if (!typeTrim.isNullOrEmpty()) {
sql.append(" AND i.type = :type ")
args["type"] = typeTrim
}
sql.append(" ORDER BY i.code ASC LIMIT :limit ")
return jdbcDao.queryForList(sql.toString(), args)
}

@Transactional
open fun saveItemOrder(orderedItemIds: List<Long>): MessageResponse {
if (orderedItemIds.isEmpty()) {
return MessageResponse(
id = null,
name = "Items",
code = "items",
type = "itemOrder",
message = "No items provided",
errorPosition = "orderedItemIds",
)
}

val distinctIds = orderedItemIds.distinct()
distinctIds.forEachIndexed { idx, itemId ->
jdbcDao.executeUpdate(
"""
UPDATE items
SET item_Order = :itemOrder,
modified = NOW(),
version = version + 1
WHERE id = :id AND deleted = false
""".trimIndent(),
mapOf("itemOrder" to (idx + 1), "id" to itemId),
)
}

return MessageResponse(
id = null,
name = "Items",
code = "items",
type = "itemOrder",
message = "Item order saved",
errorPosition = null,
)
}

open fun getItemsIdWithSameCategoryForQc(args: Map<String, Any>): List<Int> {
val sql = StringBuilder(
"SELECT"


+ 41
- 0
src/main/java/com/ffii/fpsms/modules/master/web/ItemsController.kt Zobrazit soubor

@@ -103,6 +103,47 @@ class ItemsController(
throw e
}
}

@GetMapping("/itemOrder/ordered")
fun getItemOrderOrderedItems(
@RequestParam(required = false) search: String?,
@RequestParam(required = false) type: String?
): List<Map<String, Any>> {
return itemsService.getItemOrderOrderedItems(search, type)
}

@GetMapping("/itemOrder/unordered")
fun getItemOrderUnorderedItems(
@RequestParam(required = false) search: String?,
@RequestParam(required = false) type: String?
): List<Map<String, Any>> {
return itemsService.getItemOrderUnorderedItems(search, type)
}

@GetMapping("/itemOrder/unordered/search")
fun searchItemOrderUnorderedItems(
@RequestParam search: String,
@RequestParam(required = false) type: String?,
@RequestParam(required = false, defaultValue = "200") limit: Int,
): List<Map<String, Any>> {
return itemsService.searchItemOrderUnorderedItems(search, type, limit)
}

@PostMapping("/itemOrder/save")
fun saveItemOrder(@RequestBody request: Map<String, Any>): MessageResponse {
val idsAny = request["orderedItemIds"]
val ids = when (idsAny) {
is List<*> -> idsAny.mapNotNull {
when (it) {
is Number -> it.toLong()
is String -> it.toLongOrNull()
else -> null
}
}
else -> emptyList()
}
return itemsService.saveItemOrder(ids)
}
@GetMapping("/details/{id}")
fun getItems(@PathVariable id: Long): ItemWithQcResponse {
return itemsService.getItem(id)


+ 16
- 16
src/main/resources/DeliveryNote/DeliveryNoteCartonLabelsPDF.jrxml Zobrazit soubor

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.17.0.final using JasperReports Library version 6.17.0-6d93193241dd8cc42629e188b94f9e0bc5722efd -->
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="Blank_A4" pageWidth="425" pageHeight="283" columnWidth="425" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0" uuid="baa9f270-b398-4f1c-b01e-ba216b7997e9">
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="Blank_A4" pageWidth="405" pageHeight="283" columnWidth="405" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0" uuid="baa9f270-b398-4f1c-b01e-ba216b7997e9">
<property name="com.jaspersoft.studio.unit." value="pixel"/>
<property name="com.jaspersoft.studio.unit.pageHeight" value="pixel"/>
<property name="com.jaspersoft.studio.unit.pageWidth" value="pixel"/>
@@ -27,7 +27,7 @@
<band height="243" splitType="Stretch">
<property name="com.jaspersoft.studio.unit.height" value="px"/>
<textField>
<reportElement x="162" y="210" width="240" height="30" uuid="8fac39f8-4936-43a5-8e1f-1afbc8ccca9c">
<reportElement x="155" y="210" width="240" height="30" uuid="8fac39f8-4936-43a5-8e1f-1afbc8ccca9c">
<property name="com.jaspersoft.studio.unit.height" value="px"/>
<property name="com.jaspersoft.studio.unit.width" value="px"/>
</reportElement>
@@ -37,7 +37,7 @@
<textFieldExpression><![CDATA[$P{shopPurchaseOrderNo}]]></textFieldExpression>
</textField>
<staticText>
<reportElement x="22" y="210" width="140" height="30" uuid="e03fcb92-259c-4427-a68e-60fe5924d763">
<reportElement x="15" y="210" width="140" height="30" uuid="e03fcb92-259c-4427-a68e-60fe5924d763">
<property name="com.jaspersoft.studio.unit.width" value="px"/>
<property name="com.jaspersoft.studio.unit.height" value="px"/>
</reportElement>
@@ -48,7 +48,7 @@
]]></text>
</staticText>
<staticText>
<reportElement x="22" y="180" width="140" height="30" uuid="f3ffd4ee-0513-41a5-94d7-f1fdb9966a76">
<reportElement x="15" y="180" width="140" height="30" uuid="f3ffd4ee-0513-41a5-94d7-f1fdb9966a76">
<property name="com.jaspersoft.studio.unit.width" value="px"/>
<property name="com.jaspersoft.studio.unit.height" value="px"/>
</reportElement>
@@ -58,7 +58,7 @@
<text><![CDATA[送貨單編號:]]></text>
</staticText>
<textField>
<reportElement x="162" y="180" width="240" height="30" uuid="4319059b-9096-4c49-8275-287be93d3e6a">
<reportElement x="155" y="180" width="240" height="30" uuid="4319059b-9096-4c49-8275-287be93d3e6a">
<property name="com.jaspersoft.studio.unit.height" value="px"/>
<property name="com.jaspersoft.studio.unit.width" value="px"/>
</reportElement>
@@ -68,7 +68,7 @@
<textFieldExpression><![CDATA[$P{deliveryNoteCode}]]></textFieldExpression>
</textField>
<textField textAdjust="ScaleFont">
<reportElement x="20" y="0" width="220" height="50" uuid="9a440925-1bd4-4001-9b4b-7163ac27551e">
<reportElement x="13" y="0" width="220" height="50" uuid="9a440925-1bd4-4001-9b4b-7163ac27551e">
<property name="com.jaspersoft.studio.unit.height" value="px"/>
<property name="com.jaspersoft.studio.unit.width" value="px"/>
</reportElement>
@@ -78,7 +78,7 @@
<textFieldExpression><![CDATA[$P{shopCode}]]></textFieldExpression>
</textField>
<staticText>
<reportElement x="22" y="150" width="140" height="30" uuid="c8b9fafb-9e8b-479f-9a9f-dadda7854f95">
<reportElement x="15" y="150" width="140" height="30" uuid="c8b9fafb-9e8b-479f-9a9f-dadda7854f95">
<property name="com.jaspersoft.studio.unit.width" value="px"/>
<property name="com.jaspersoft.studio.unit.height" value="px"/>
</reportElement>
@@ -89,7 +89,7 @@
]]></text>
</staticText>
<textField>
<reportElement x="162" y="150" width="240" height="30" uuid="57f8e4fa-cea0-42c5-b9e5-a33f0a2710b8">
<reportElement x="155" y="150" width="240" height="30" uuid="57f8e4fa-cea0-42c5-b9e5-a33f0a2710b8">
<property name="com.jaspersoft.studio.unit.height" value="px"/>
<property name="com.jaspersoft.studio.unit.width" value="px"/>
</reportElement>
@@ -99,12 +99,12 @@
<textFieldExpression><![CDATA[$P{truckNo}]]></textFieldExpression>
</textField>
<line>
<reportElement x="22" y="140" width="380" height="1" uuid="3e37c027-d6e9-4a88-b64d-58ba1dd3b22e">
<reportElement x="15" y="140" width="380" height="1" uuid="3e37c027-d6e9-4a88-b64d-58ba1dd3b22e">
<property name="com.jaspersoft.studio.unit.height" value="px"/>
</reportElement>
</line>
<textField textAdjust="ScaleFont">
<reportElement x="250" y="0" width="152" height="99" uuid="ed6f8ce7-e351-4eeb-9f95-49d64e7ed2dd">
<reportElement x="243" y="0" width="152" height="99" uuid="ed6f8ce7-e351-4eeb-9f95-49d64e7ed2dd">
<property name="com.jaspersoft.studio.unit.height" value="px"/>
<property name="com.jaspersoft.studio.unit.width" value="px"/>
</reportElement>
@@ -117,7 +117,7 @@
<textFieldExpression><![CDATA[$P{shopCodeAbbr}]]></textFieldExpression>
</textField>
<textField textAdjust="ScaleFont">
<reportElement x="20" y="50" width="220" height="49" uuid="75a47bc6-5830-4636-9c62-1285163bf0b6">
<reportElement x="13" y="50" width="220" height="49" uuid="75a47bc6-5830-4636-9c62-1285163bf0b6">
<property name="com.jaspersoft.studio.unit.height" value="px"/>
</reportElement>
<textElement textAlignment="Left" verticalAlignment="Top">
@@ -126,7 +126,7 @@
<textFieldExpression><![CDATA[$P{shopName}]]></textFieldExpression>
</textField>
<staticText>
<reportElement x="22" y="106" width="140" height="30" uuid="0ccaeebc-681b-449e-b547-97fc86c35662">
<reportElement x="15" y="106" width="140" height="30" uuid="0ccaeebc-681b-449e-b547-97fc86c35662">
<property name="com.jaspersoft.studio.unit.width" value="px"/>
<property name="com.jaspersoft.studio.unit.height" value="px"/>
</reportElement>
@@ -136,7 +136,7 @@
<text><![CDATA[箱數:]]></text>
</staticText>
<staticText>
<reportElement x="282" y="106" width="120" height="30" uuid="05bc180b-a58d-4ad8-95f6-bc3090ee2c2d">
<reportElement x="275" y="106" width="120" height="30" uuid="05bc180b-a58d-4ad8-95f6-bc3090ee2c2d">
<property name="com.jaspersoft.studio.unit.width" value="px"/>
<property name="com.jaspersoft.studio.unit.height" value="px"/>
</reportElement>
@@ -146,7 +146,7 @@
<text><![CDATA[ 箱(蛋類除外)]]></text>
</staticText>
<textField>
<reportElement x="162" y="106" width="40" height="30" uuid="dab335a5-e253-498c-a9bf-b9707d8e1099">
<reportElement x="155" y="106" width="40" height="30" uuid="dab335a5-e253-498c-a9bf-b9707d8e1099">
<property name="com.jaspersoft.studio.unit.width" value="px"/>
<property name="com.jaspersoft.studio.unit.height" value="px"/>
</reportElement>
@@ -156,7 +156,7 @@
<textFieldExpression><![CDATA[$V{PAGE_NUMBER}]]></textFieldExpression>
</textField>
<textField evaluationTime="Report">
<reportElement x="237" y="106" width="40" height="30" uuid="66d50bad-7b39-49c1-b127-4d763133ee0c">
<reportElement x="230" y="106" width="40" height="30" uuid="66d50bad-7b39-49c1-b127-4d763133ee0c">
<property name="com.jaspersoft.studio.unit.width" value="px"/>
<property name="com.jaspersoft.studio.unit.height" value="px"/>
</reportElement>
@@ -166,7 +166,7 @@
<textFieldExpression><![CDATA[$V{PAGE_NUMBER}]]></textFieldExpression>
</textField>
<staticText>
<reportElement x="202" y="106" width="35" height="30" uuid="73c18ae5-a07b-4215-a753-fa72d6db87eb">
<reportElement x="195" y="106" width="35" height="30" uuid="73c18ae5-a07b-4215-a753-fa72d6db87eb">
<property name="com.jaspersoft.studio.unit.width" value="px"/>
<property name="com.jaspersoft.studio.unit.height" value="px"/>
</reportElement>


Načítá se…
Zrušit
Uložit