|
|
|
@@ -223,15 +223,18 @@ open class StockInLineService( |
|
|
|
@Throws(IOException::class) |
|
|
|
@Transactional |
|
|
|
fun saveEscalationLogWhenStockIn(request: SaveStockInLineRequest, stockInLine: StockInLine): EscalationLog? { |
|
|
|
if (request.escalationLog != null) { |
|
|
|
if (request.escalationLog != null) { // Save Esc log |
|
|
|
val escReq = request.escalationLog; |
|
|
|
|
|
|
|
var qcTotal = 0; |
|
|
|
var qcFailed = 0; |
|
|
|
if (request.qcResult!!.isEmpty()) { |
|
|
|
// if (request.qcResult!!.isEmpty()) { |
|
|
|
if (request.status == StockInLineStatus.ESCALATED.status) { |
|
|
|
val escLogList = stockInLine.id?.let { escalationLogRepository.findAllByDeletedFalseAndStockInLineIdIn(listOf(it)); } |
|
|
|
val latestLog = escLogList?.maxBy { it.id!! }; |
|
|
|
latestLog?.apply { status = EscalationLogStatus.ESCALATED } |
|
|
|
latestLog?.apply { |
|
|
|
status = if (request.qcAccept == true) EscalationLogStatus.ACCEPTED else EscalationLogStatus.REJECTED |
|
|
|
} |
|
|
|
escalationLogService.save(latestLog); |
|
|
|
|
|
|
|
val qcRes = qcResultRepository.findQcResultInfoByStockInLineIdAndDeletedFalse(stockInLine.id!!); |
|
|
|
@@ -251,6 +254,13 @@ open class StockInLineService( |
|
|
|
val res = escalationLogService.saveEscalationLog(escReq) |
|
|
|
return res.id?.let { escalationLogRepository.findById(it).orElseThrow() }; |
|
|
|
}; |
|
|
|
} else { // Update log status |
|
|
|
val escLogList = stockInLine.id?.let { escalationLogRepository.findAllByDeletedFalseAndStockInLineIdIn(listOf(it)); } |
|
|
|
val latestLog = escLogList?.maxBy { it.id!! }; |
|
|
|
latestLog?.apply { |
|
|
|
status = if (request.qcAccept == true) EscalationLogStatus.ACCEPTED else EscalationLogStatus.REJECTED |
|
|
|
} |
|
|
|
escalationLogService.save(latestLog); |
|
|
|
} |
|
|
|
return null |
|
|
|
} |
|
|
|
@@ -379,7 +389,7 @@ open class StockInLineService( |
|
|
|
var escLogId : Long? = 0L; |
|
|
|
// Escalation |
|
|
|
if (request.status == StockInLineStatus.ESCALATED.status) { |
|
|
|
// |
|
|
|
saveEscalationLogWhenStockIn(request, stockInLine)?.id; |
|
|
|
} |
|
|
|
// QC |
|
|
|
if (request.qcAccept == true) { |
|
|
|
|