Browse Source

no message

master
parent
commit
a0bf0a79f8
1 changed files with 55 additions and 3 deletions
  1. +55
    -3
      src/main/java/com/ffii/fpsms/modules/master/service/ProductionScheduleService.kt

+ 55
- 3
src/main/java/com/ffii/fpsms/modules/master/service/ProductionScheduleService.kt View File

@@ -644,8 +644,8 @@ open class ProductionScheduleService(
bom.itemId != 16771) AS i
WHERE 1
and i.avgQtyLastMonth is not null
and i.onHandQty is not null
and (i.onHandQty -500) * 1.0 / i.avgQtyLastMonth <= 1.9
and i.onHandQty is not null
-- and (i.onHandQty -500) * 1.0 / i.avgQtyLastMonth <= 1.9
-- and avgQtyLastMonth - (onHandQty - 500) > 0

""".trimIndent()
@@ -716,7 +716,7 @@ open class ProductionScheduleService(
updatedScheduleRecord.itemPriority = priority;
if (machineCap - prodDifference >= 0) {
if (updatedScheduleRecord.batchNeed.toInt() > 0) {
//have enough quoter for adjustment
machineCap -= prodDifference;
detailedScheduleOutputList.add(updatedScheduleRecord)
@@ -738,6 +738,37 @@ open class ProductionScheduleService(
}

saveDetailedScheduleOutput(sortedOutputList, accProdCount, fgCount, produceAt)

//do for 7 days to predict
for (i in 1..6) {
fgCount = 0
accProdCount = 0.0
sortedOutputList.forEach { record ->
record.stockQty = record.stockQty + (record.outputQty * record.needNoOfJobOrder.toInt()) - record.avgQtyLastMonth
//compare if less than 1.9 days
record.daysLeft = record.stockQty / record.avgQtyLastMonth

if(record.daysLeft <= 1.9){
record.needQty = (record.avgQtyLastMonth * 2) - record.stockQty;

if(record.needQty > 0.0){
record.batchNeed = ceil(record.needQty / record.outputQty)
record.needNoOfJobOrder = record.batchNeed

fgCount += 1
accProdCount += record.outputQty * record.batchNeed.toInt()
}else{
record.needNoOfJobOrder = 0
record.batchNeed = 0
}
}

logger.info(record.name + " record.batchNeed: " + record.batchNeed + " record.stockQty:" + record.stockQty + " record.daysLeft:" + record.daysLeft)

}

saveDetailedScheduleOutputPredict(sortedOutputList, accProdCount, fgCount, produceAt.plusDays(i.toLong()))
}
}
open fun saveDetailedScheduleOutput(
@@ -761,6 +792,27 @@ open class ProductionScheduleService(
}
}

open fun saveDetailedScheduleOutputPredict(
sortedEntries: List<NeedQtyRecord>,
accProdCount: Double,
fgCount: Long,
produceAt: LocalDateTime,
) {
val tempObj = ProductionSchedule()
tempObj.id = -1;
tempObj.scheduleAt = LocalDateTime.now()
tempObj.produceAt = produceAt;
tempObj.totalFGType = fgCount;
tempObj.totalEstProdCount = accProdCount;
tempObj.type = "detailed"
tempObj.id = saveProductionScheduleToDatabase(tempObj);

for (detailedScheduleRecord in sortedEntries) {
if(detailedScheduleRecord.batchNeed.toInt() > 0)
saveDetailedScheduleLineToDatabase(tempObj.id ?: -1, detailedScheduleRecord)
}
}

private fun saveDetailedScheduleLineToDatabase(parentId: Long, detailedScheduleObj: NeedQtyRecord) {
try {
val prodSchedule = productionScheduleRepository.findById(parentId).get()


Loading…
Cancel
Save