From 7bf37b28ce332b1f214c255573e602fdb31d2c99 Mon Sep 17 00:00:00 2001 From: "vluk@2fi-solutions.com.hk" Date: Sun, 18 Jan 2026 20:57:54 +0800 Subject: [PATCH] fixing the ps query --- .../service/ProductionScheduleService.kt | 26 ++++++++++--------- 1 file changed, 14 insertions(+), 12 deletions(-) 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 cdb27f4..496c8b3 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 @@ -627,9 +627,8 @@ open class ProductionScheduleService( SELECT i.outputQty, i.avgQtyLastMonth, - (i.onHandQty -500), -- (i.onHandQty -500) * 1.0 / i.avgQtyLastMonth as daysLeft, - i.avgQtyLastMonth * 2.6 - stockQty as needQty, + 0 as needQty, i.stockQty, -- CASE -- WHEN stockQty * 1.0 / i.avgQtyLastMonth <= 1.9 THEN @@ -640,7 +639,7 @@ open class ProductionScheduleService( 0 AS needNoOfJobOrder, 0 AS batchNeed, i.pendingJobQty, - ((i.stockQty * 1.0) + (i.needNoOfJobOrder * i.outputQty) ) / i.avgQtyLastMonth as daysLeft, + ((i.stockQty * 1.0) + ifnull(i.pendingJobQty, 0) ) / i.avgQtyLastMonth as daysLeft, 25 + 25 + markDark + markFloat + markDense + markAS + markTimeSequence + markComplexity as priority, i.* @@ -784,15 +783,16 @@ open class ProductionScheduleService( //match id with rough schedule record to create new record val targetRecord = needQtyList.find { it.id == updatedScheduleRecord.id } //??? this should be the bom output Qty * no. of job order needed - val prodDifference = updatedScheduleRecord.outputQty - (targetRecord?.outputQty ?: 0.0) - updatedScheduleRecord.itemPriority = priority; - + val prodDifference = 0 + updatedScheduleRecord.itemPriority = priority; + detailedScheduleOutputList.add(updatedScheduleRecord) + if (updatedScheduleRecord.batchNeed.toInt() > 0) { //have enough quoter for adjustment machineCap -= prodDifference; - detailedScheduleOutputList.add(updatedScheduleRecord) - accProdCount += updatedScheduleRecord.outputQty + println("[INFO] item " + updatedScheduleRecord.name + " added " + (updatedScheduleRecord.batchNeed.toInt() * updatedScheduleRecord.outputQty)); + accProdCount += updatedScheduleRecord.batchNeed.toInt() * updatedScheduleRecord.outputQty fgCount++ } else { println("[INFO] item " + updatedScheduleRecord.name + " have bee skipped"); @@ -820,7 +820,7 @@ open class ProductionScheduleService( val isSunday = targetDate.dayOfWeek == DayOfWeek.SUNDAY val isFriSat = isFri || isSat - logger.info("##targetDate:" + targetDate + " isFri:"+ isFri + " isSat:" + isSat + " isSunday:" + isSunday) + println("##targetDate:" + targetDate + " isFri:"+ isFri + " isSat:" + isSat + " isSunday:" + isSunday) fgCount = 0 @@ -828,15 +828,17 @@ open class ProductionScheduleService( sortedOutputList.forEach { record -> record.stockQty = record.stockQty + (record.outputQty * record.needNoOfJobOrder.toInt()) - record.avgQtyLastMonth - //compare if less than 1.9 days + //compare if less than 1.9 days record.daysLeft = record.stockQty / record.avgQtyLastMonth - + println("name: " + record.name + " stockQty:" + record.stockQty + " avgQtyLastMonth:" + record.avgQtyLastMonth + " daysLeft:" + record.daysLeft) + var safetyStockDay = 2.0 var redLine = 1.9 if(isFriSat){ //record.daysLeft = record.daysLeft safetyStockDay = 2.6 + redLine = 3.0 } if(record.daysLeft < redLine){ @@ -859,7 +861,7 @@ open class ProductionScheduleService( record.batchNeed = 0 } - logger.info(record.name + " record.batchNeed: " + record.batchNeed + " record.stockQty:" + record.stockQty + " record.daysLeft:" + record.daysLeft) + println(record.name + " record.batchNeed: " + record.batchNeed + " record.stockQty:" + record.stockQty + " record.daysLeft:" + record.daysLeft) }