From bee502b0f33773a76d17085ccd3de2a2eb0b3611 Mon Sep 17 00:00:00 2001 From: kelvinsuen Date: Tue, 2 Sep 2025 04:58:38 +0800 Subject: [PATCH] update escalation log --- .../modules/stock/entity/EscalationLogInfo.kt | 2 ++ .../stock/service/StockInLineService.kt | 18 ++++++++++++++---- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/ffii/fpsms/modules/stock/entity/EscalationLogInfo.kt b/src/main/java/com/ffii/fpsms/modules/stock/entity/EscalationLogInfo.kt index 924a652..90dc59f 100644 --- a/src/main/java/com/ffii/fpsms/modules/stock/entity/EscalationLogInfo.kt +++ b/src/main/java/com/ffii/fpsms/modules/stock/entity/EscalationLogInfo.kt @@ -68,6 +68,8 @@ interface EscalationLogInfo { // @get:Value("#{target.type}") // val escalationLevel: String + @get:Value("#{target.createdBy}") + val submitter: String? val qcTotalCount: Int?; val qcFailCount: Int?; val reason: String?; diff --git a/src/main/java/com/ffii/fpsms/modules/stock/service/StockInLineService.kt b/src/main/java/com/ffii/fpsms/modules/stock/service/StockInLineService.kt index 4e475ea..b55cf85 100644 --- a/src/main/java/com/ffii/fpsms/modules/stock/service/StockInLineService.kt +++ b/src/main/java/com/ffii/fpsms/modules/stock/service/StockInLineService.kt @@ -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) {