From 1fc0aac481a14e4441c99ea21f2441c8cbacf40c Mon Sep 17 00:00:00 2001 From: "vluk@2fi-solutions.com.hk" Date: Sun, 18 Jan 2026 23:55:14 +0800 Subject: [PATCH] trying to fix the ONPACK2030 6 files XML generation --- .../service/PlasticBagPrinterService.kt | 15 ++++++------ .../service/ProductionScheduleService.kt | 24 +++++++++++-------- 2 files changed, 22 insertions(+), 17 deletions(-) diff --git a/src/main/java/com/ffii/fpsms/modules/jobOrder/service/PlasticBagPrinterService.kt b/src/main/java/com/ffii/fpsms/modules/jobOrder/service/PlasticBagPrinterService.kt index 74ac5e7..334fc94 100644 --- a/src/main/java/com/ffii/fpsms/modules/jobOrder/service/PlasticBagPrinterService.kt +++ b/src/main/java/com/ffii/fpsms/modules/jobOrder/service/PlasticBagPrinterService.kt @@ -43,11 +43,12 @@ open class PlasticBagPrinterService( val baos = ByteArrayOutputStream() ZipOutputStream(baos).use { zos -> - // Reduced sizes to make files smaller while keeping readability/scanability - val productBmp = createMonochromeBitmap(productName, 520) // was 704 - val codeBmp = createMonochromeBitmap(itemCode, 900) // was 1173 - val expBmp = createMonochromeBitmap(expiryDate, 900) // was 1173 - val qrBmp = createQrCodeBitmap("$itemCode|$lotNo|$expiryDate", 450) // was 1000 + // Reduced heights by ~80% to hit the 12KB-17KB file size target + // These heights (100-180) will produce much smaller BMP files + val productBmp = createMonochromeBitmap(productName, 100) + val codeBmp = createMonochromeBitmap(itemCode, 180) + val expBmp = createMonochromeBitmap(expiryDate, 180) + val qrBmp = createQrCodeBitmap("$itemCode|$lotNo|$expiryDate", 250) val nameFile = "${lotNo}_product.bmp" val codeFile = "${lotNo}_code.bmp" @@ -59,8 +60,8 @@ open class PlasticBagPrinterService( addToZip(zos, expFile, expBmp.bytes) addToZip(zos, qrFile, qrBmp.bytes) - // Minified XML - no indentation/newlines between tags - val imageXml = """falseDEG_053007100LOGO0250BLACK$nameFile${productBmp.width}520LOGO_210001250BLACK$codeFile${codeBmp.width}900LOGO_35002500BLACK$expFile${expBmp.width}900LOGO_47503750BLACK$qrFile${qrBmp.width}450""".trimIndent() + // The XML Width/Height must match the ACTUAL generated bitmap dimensions + val imageXml = """falseDEG_053007100LOGO42505000BLACK$nameFile${productBmp.width}100LOGO_25100012500BLACK$codeFile${codeBmp.width}180LOGO_3650025000BLACK$expFile${expBmp.width}180LOGO_4750037500BLACK$qrFile${qrBmp.width}250""".trimIndent() addToZip(zos, "$lotNo.image", imageXml.toByteArray(Charsets.UTF_8)) diff --git a/src/main/java/com/ffii/fpsms/modules/master/service/ProductionScheduleService.kt b/src/main/java/com/ffii/fpsms/modules/master/service/ProductionScheduleService.kt index 496c8b3..8df80c1 100644 --- a/src/main/java/com/ffii/fpsms/modules/master/service/ProductionScheduleService.kt +++ b/src/main/java/com/ffii/fpsms/modules/master/service/ProductionScheduleService.kt @@ -837,7 +837,7 @@ open class ProductionScheduleService( if(isFriSat){ //record.daysLeft = record.daysLeft - safetyStockDay = 2.6 + safetyStockDay = 3.0 redLine = 3.0 } @@ -1431,7 +1431,7 @@ open class ProductionScheduleService( val sheet = workbook.createSheet(safeSheetName) val headers = listOf( - "Item Name", "Avg Qty Last Month", "Stock Qty", "Days Left", + "Item Code", "Item Name", "Avg Qty Last Month", "Stock Qty", "Days Left", "Output Qty", "Batch Need", "Priority" ) @@ -1449,13 +1449,15 @@ open class ProductionScheduleService( val row = sheet.createRow(index + 1) row.heightInPoints = 35f // Slightly taller for portrait readability - row.createCell(0).apply { setCellValue(line["itemName"]?.toString() ?: ""); cellStyle = wrapStyle } - row.createCell(1).apply { setCellValue(asDouble(line["avgQtyLastMonth"])); cellStyle = wrapStyle } - row.createCell(2).apply { setCellValue(asDouble(line["stockQty"])); cellStyle = wrapStyle } - row.createCell(3).apply { setCellValue(asDouble(line["daysLeft"])); cellStyle = wrapStyle } - row.createCell(4).apply { setCellValue(asDouble(line["outputdQty"] ?: line["outputQty"])); cellStyle = wrapStyle } - row.createCell(5).apply { setCellValue(asDouble(line["batchNeed"])); cellStyle = wrapStyle } - row.createCell(6).apply { setCellValue(asDouble(line["itemPriority"])); cellStyle = wrapStyle } + var j = 0; + row.createCell(j++).apply { setCellValue(line["itemCode"]?.toString() ?: ""); cellStyle = wrapStyle } + row.createCell(j++).apply { setCellValue(line["itemName"]?.toString() ?: ""); cellStyle = wrapStyle } + row.createCell(j++).apply { setCellValue(asDouble(line["avgQtyLastMonth"])); cellStyle = wrapStyle } + row.createCell(j++).apply { setCellValue(asDouble(line["stockQty"])); cellStyle = wrapStyle } + row.createCell(j++).apply { setCellValue(asDouble(line["daysLeft"])); cellStyle = wrapStyle } + row.createCell(j++).apply { setCellValue(asDouble(line["outputdQty"] ?: line["outputQty"])); cellStyle = wrapStyle } + row.createCell(j++).apply { setCellValue(asDouble(line["batchNeed"])); cellStyle = wrapStyle } + row.createCell(j++).apply { setCellValue(asDouble(line["itemPriority"])); cellStyle = wrapStyle } } // Auto-size with wider limits for portrait @@ -1744,7 +1746,8 @@ open class ProductionScheduleService( where ps.produceAt >= :fromDate and ps.id = (select id from production_schedule where produceAt = ps.produceAt order by id desc limit 1) - -- and it.code = 'PP2236' + -- This is water + AND it.code != 'GI3236' -- order by ps.produceAt asc, psl.itemPriority desc, itemCode asc group by matCode """; @@ -1796,6 +1799,7 @@ open class ProductionScheduleService( LIMIT 1 ) AND bm.itemId IS NOT NULL + AND itm.code != 'GI3236' GROUP BY itm.id, DATE(ps.produceAt)