|
|
@@ -485,7 +485,7 @@ open class ProductProcessService( |
|
|
println(" Service: Found ${lines.size} pending lines") |
|
|
println(" Service: Found ${lines.size} pending lines") |
|
|
return lines |
|
|
return lines |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
open fun productProcessDetailfindbyjoid(joid: Long): List<ProductProcessInfo> { |
|
|
open fun productProcessDetailfindbyjoid(joid: Long): List<ProductProcessInfo> { |
|
|
val productProcesses = productProcessRepository.findByJobOrder_Id(joid) |
|
|
val productProcesses = productProcessRepository.findByJobOrder_Id(joid) |
|
|
val jobOrder = jobOrderRepository.findById(joid).orElse(null) |
|
|
val jobOrder = jobOrderRepository.findById(joid).orElse(null) |
|
|
@@ -674,7 +674,9 @@ open class ProductProcessService( |
|
|
itemCode = line.item?.code?:"", |
|
|
itemCode = line.item?.code?:"", |
|
|
itemName = line.item?.name?:"", |
|
|
itemName = line.item?.name?:"", |
|
|
reqQty = line.reqQty?.toInt() ?: 0, |
|
|
reqQty = line.reqQty?.toInt() ?: 0, |
|
|
|
|
|
|
|
|
stockQty = stockQty, |
|
|
stockQty = stockQty, |
|
|
|
|
|
|
|
|
uom = uomName?:"", |
|
|
uom = uomName?:"", |
|
|
shortUom = shortUom?:"", |
|
|
shortUom = shortUom?:"", |
|
|
type = line.item?.type?: "", |
|
|
type = line.item?.type?: "", |
|
|
@@ -1321,7 +1323,10 @@ open class ProductProcessService( |
|
|
val productProcessLine = productProcessLineRepository.findById(productProcessLineId).orElse(null) |
|
|
val productProcessLine = productProcessLineRepository.findById(productProcessLineId).orElse(null) |
|
|
val productProcessId = productProcessLine?.productProcess?.id ?: 0L |
|
|
val productProcessId = productProcessLine?.productProcess?.id ?: 0L |
|
|
val allproductProcessLines=productProcessLineRepository.findByProductProcess_Id(productProcessId) |
|
|
val allproductProcessLines=productProcessLineRepository.findByProductProcess_Id(productProcessId) |
|
|
|
|
|
|
|
|
|
|
|
if(productProcessLine.startTime == null) { |
|
|
|
|
|
productProcessLine.startTime = LocalDateTime.now() |
|
|
|
|
|
productProcessLineRepository.save(productProcessLine) |
|
|
|
|
|
} |
|
|
if(allproductProcessLines.all { it.status == "Completed" }) { |
|
|
if(allproductProcessLines.all { it.status == "Completed" }) { |
|
|
updateProductProcessEndTime(productProcessId) |
|
|
updateProductProcessEndTime(productProcessId) |
|
|
updateProductProcessStatus(productProcessId, ProductProcessStatus.COMPLETED) |
|
|
updateProductProcessStatus(productProcessId, ProductProcessStatus.COMPLETED) |
|
|
@@ -1330,6 +1335,7 @@ open class ProductProcessService( |
|
|
if(jobOrder != null) { |
|
|
if(jobOrder != null) { |
|
|
jobOrder.status = JobOrderStatus.PENDING_QC |
|
|
jobOrder.status = JobOrderStatus.PENDING_QC |
|
|
jobOrderRepository.save(jobOrder) |
|
|
jobOrderRepository.save(jobOrder) |
|
|
|
|
|
|
|
|
stockInLineService.create( |
|
|
stockInLineService.create( |
|
|
SaveStockInLineRequest( |
|
|
SaveStockInLineRequest( |
|
|
itemId = productProcess?.item?.id?:0L, |
|
|
itemId = productProcess?.item?.id?:0L, |
|
|
@@ -1339,9 +1345,10 @@ open class ProductProcessService( |
|
|
jobOrderId = jobOrder.id, |
|
|
jobOrderId = jobOrder.id, |
|
|
acceptQty =jobOrder?.reqQty?:BigDecimal.ZERO , |
|
|
acceptQty =jobOrder?.reqQty?:BigDecimal.ZERO , |
|
|
expiryDate=null, |
|
|
expiryDate=null, |
|
|
status="", |
|
|
|
|
|
|
|
|
status="pending", |
|
|
) |
|
|
) |
|
|
) |
|
|
) |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
return MessageResponse( |
|
|
return MessageResponse( |
|
|
@@ -1598,26 +1605,56 @@ open fun getJobProcessStatus(): List<JobProcessStatusResponse> { |
|
|
val lines = productProcessLineRepository.findByProductProcess_Id(process.id ?: 0L) |
|
|
val lines = productProcessLineRepository.findByProductProcess_Id(process.id ?: 0L) |
|
|
.sortedBy { it.seqNo } |
|
|
.sortedBy { it.seqNo } |
|
|
val bom=bomRepository.findById(process.bom?.id ?: 0L).orElse(null) |
|
|
val bom=bomRepository.findById(process.bom?.id ?: 0L).orElse(null) |
|
|
val bomProcesses = bomProcessRepository.findByBomId(bom?.id ?: 0L).sortedBy { it.seqNo } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//val equipmentDetail = equipmentDetailRepository.findById(equipmentDetailId).orElse(null) |
|
|
|
|
|
// Calculate planEndTime based on first start time + remaining processing time |
|
|
|
|
|
val firstStartTime = lines.firstOrNull { it.startTime != null }?.startTime |
|
|
|
|
|
val calculatedPlanEndTime = if (firstStartTime != null) { |
|
|
|
|
|
// Calculate total remaining processing time (in minutes) for unfinished processes |
|
|
|
|
|
var totalRemainingMinutes = 0L |
|
|
|
|
|
lines.forEach { line -> |
|
|
|
|
|
if (line.endTime == null) { |
|
|
|
|
|
// Process is not finished, add its processing time |
|
|
|
|
|
totalRemainingMinutes += (line.processingTime ?: 0).toLong() |
|
|
|
|
|
totalRemainingMinutes += (line.setupTime ?: 0).toLong() |
|
|
|
|
|
totalRemainingMinutes += (line.changeoverTime ?: 0).toLong() |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
// Add remaining time to first start time |
|
|
|
|
|
firstStartTime.plusMinutes(totalRemainingMinutes) |
|
|
|
|
|
} else { |
|
|
|
|
|
// No process has started yet, use original planEndTime |
|
|
|
|
|
jobOrder?.planEnd |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
JobProcessStatusResponse( |
|
|
JobProcessStatusResponse( |
|
|
jobOrderId = jobOrder?.id ?: 0L, |
|
|
jobOrderId = jobOrder?.id ?: 0L, |
|
|
jobOrderCode = jobOrder?.code ?: "", |
|
|
jobOrderCode = jobOrder?.code ?: "", |
|
|
itemCode = process.item?.code ?: "", |
|
|
itemCode = process.item?.code ?: "", |
|
|
itemName = process.item?.name ?: "", |
|
|
itemName = process.item?.name ?: "", |
|
|
planEndTime = jobOrder?.planEnd, |
|
|
|
|
|
|
|
|
planEndTime = calculatedPlanEndTime, |
|
|
processes = (0 until 6).map { index -> |
|
|
processes = (0 until 6).map { index -> |
|
|
if (index < lines.size) { |
|
|
if (index < lines.size) { |
|
|
val line = lines[index] |
|
|
val line = lines[index] |
|
|
|
|
|
val bomProcesses = bomProcessRepository.findByBomId(bom?.id ?: 0L).sortedBy { it.seqNo } |
|
|
|
|
|
val equipmentDetailId = line.equipmentDetailId |
|
|
ProcessStatusInfo( |
|
|
ProcessStatusInfo( |
|
|
equipmentCode = bomProcesses[index].equipment?.code ?: "", |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
equipmentCode = if(equipmentDetailId != null) equipmentDetailRepository.findById(equipmentDetailId).orElse(null)?.code ?: "" else bomProcesses[index].equipment?.code ?: "", |
|
|
startTime = line.startTime, |
|
|
startTime = line.startTime, |
|
|
endTime = line.endTime, |
|
|
endTime = line.endTime, |
|
|
|
|
|
processingTime = line.processingTime, |
|
|
|
|
|
setupTime = line.setupTime, |
|
|
|
|
|
changeoverTime = line.changeoverTime, |
|
|
isRequired = true |
|
|
isRequired = true |
|
|
) |
|
|
) |
|
|
} else { |
|
|
} else { |
|
|
ProcessStatusInfo( |
|
|
ProcessStatusInfo( |
|
|
startTime = null, |
|
|
startTime = null, |
|
|
endTime = null, |
|
|
endTime = null, |
|
|
|
|
|
processingTime = null, |
|
|
|
|
|
setupTime = null, |
|
|
|
|
|
changeoverTime = null, |
|
|
isRequired = false, |
|
|
isRequired = false, |
|
|
equipmentCode = null, |
|
|
equipmentCode = null, |
|
|
) |
|
|
) |
|
|
|