From 05f1fc25ab5fb5eb0f3dfa088026e94651ed9a35 Mon Sep 17 00:00:00 2001 From: Fai Luk Date: Sun, 1 Feb 2026 17:34:59 +0800 Subject: [PATCH] make a fake onhand for scheduling --- .../modules/master/service/ProductionScheduleService.kt | 9 ++++++--- .../db/changelog/changes/20260201_fai/01_fake.sql | 6 ++++++ 2 files changed, 12 insertions(+), 3 deletions(-) create mode 100644 src/main/resources/db/changelog/changes/20260201_fai/01_fake.sql 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 98549a6..061f699 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 @@ -656,12 +656,14 @@ open class ProductionScheduleService( WHERE dol.itemId = items.id -- AND MONTH(do.estimatedArrivalDate) = MONTH(DATE_SUB(NOW(), INTERVAL 1 MONTH)) - AND do.estimatedArrivalDate >= '2025-12-01' AND do.estimatedArrivalDate < '2025-12-11' + AND do.estimatedArrivalDate >= '2026-01-12' AND do.estimatedArrivalDate < '2026-01-16' GROUP BY do.estimatedArrivalDate) AS d) AS avgQtyLastMonth, (select sum(reqQty) from job_order where bomId = bom.id and status != 'completed') AS pendingJobQty, - - inventory.onHandQty - 500 AS stockQty, + + CASE WHEN item_fake_onhand.onHandQty is not null THEN item_fake_onhand.onHandQty + ELSE inventory.onHandQty - 500 END AS stockQty, + bom.outputQty, bom.outputQtyUom, (SELECT @@ -706,6 +708,7 @@ open class ProductionScheduleService( bom LEFT JOIN items ON bom.itemId = items.id LEFT JOIN inventory ON items.id = inventory.itemId + left join item_fake_onhand on items.code = item_fake_onhand.itemCode WHERE bom.itemId != 16771) AS i WHERE 1 diff --git a/src/main/resources/db/changelog/changes/20260201_fai/01_fake.sql b/src/main/resources/db/changelog/changes/20260201_fai/01_fake.sql new file mode 100644 index 0000000..a33d83e --- /dev/null +++ b/src/main/resources/db/changelog/changes/20260201_fai/01_fake.sql @@ -0,0 +1,6 @@ +--liquibase formatted sql +--changeset author:vin fake onhand +CREATE TABLE `fpsmsdb`.`item_fake_onhand` ( + `itemCode` VARCHAR(100) NOT NULL, + `onHandQty` DECIMAL(14,2) NULL, + PRIMARY KEY (`itemCode`));