From 27e34d71ed781eedfd3f045b32424dffad02e292 Mon Sep 17 00:00:00 2001 From: "vluk@2fi-solutions.com.hk" Date: Wed, 7 Jan 2026 19:16:51 +0800 Subject: [PATCH] no message --- .../entity/ProductionScheduleRepository.kt | 2 + .../entity/projections/ProdScheduleInfo.kt | 2 + .../service/ProductionScheduleService.kt | 105 ++++++++++++------ 3 files changed, 72 insertions(+), 37 deletions(-) diff --git a/src/main/java/com/ffii/fpsms/modules/master/entity/ProductionScheduleRepository.kt b/src/main/java/com/ffii/fpsms/modules/master/entity/ProductionScheduleRepository.kt index 7ffc1e0..bf2e2c7 100644 --- a/src/main/java/com/ffii/fpsms/modules/master/entity/ProductionScheduleRepository.kt +++ b/src/main/java/com/ffii/fpsms/modules/master/entity/ProductionScheduleRepository.kt @@ -204,6 +204,7 @@ interface ProductionScheduleRepository : AbstractRepository= today + clearTodayAndFutureProdSchedule() + println("needQtyList - " + needQtyList); + //##### The 22000, 10000 machine cap just means the max warehouse storage qty, not production qty cap //##### The total production qty of the date is 10000 due to machine cap //##### search all items with bom to consider need or no need production @@ -1613,5 +1619,30 @@ open class ProductionScheduleService( return jdbcDao.queryForList(sql, args); } + + @Transactional + open fun clearTodayAndFutureProdSchedule() { + val deleteLinesSql = """ + DELETE FROM production_schedule_line + WHERE prodScheduleId IN ( + SELECT id FROM production_schedule + WHERE DATE(produceAt) >= DATE(NOW()) + ) + """.trimIndent() + + val deleteSchedulesSql = """ + DELETE FROM production_schedule + WHERE DATE(produceAt) >= DATE(NOW()) + """.trimIndent() + + // Execute child delete first + jdbcDao.executeUpdate(deleteLinesSql) + + // Then delete parent schedules + jdbcDao.executeUpdate(deleteSchedulesSql) + + // Optional: log the action (if you have logging setup) + // logger.info("Cleared all production schedules with produceAt >= today") + } } \ No newline at end of file