Browse Source

update new escalation flow

master
kelvinsuen 3 months ago
parent
commit
c3b645d67e
5 changed files with 29 additions and 5 deletions
  1. +5
    -0
      src/main/java/com/ffii/fpsms/modules/qc/entity/QcResult.kt
  2. +15
    -5
      src/main/java/com/ffii/fpsms/modules/stock/service/StockInLineService.kt
  3. +1
    -0
      src/main/java/com/ffii/fpsms/modules/stock/web/model/SaveStockInRequest.kt
  4. +4
    -0
      src/main/resources/db/changelog/changes/20250827_01_kelvin/01_update_stock_in_line.sql
  5. +4
    -0
      src/main/resources/db/changelog/changes/20250828_01_kelvin/01_update_qc_result.sql

+ 5
- 0
src/main/java/com/ffii/fpsms/modules/qc/entity/QcResult.kt View File

@@ -3,6 +3,7 @@ package com.ffii.fpsms.modules.qc.entity
import com.ffii.core.entity.BaseEntity import com.ffii.core.entity.BaseEntity
import com.ffii.fpsms.modules.master.entity.Items import com.ffii.fpsms.modules.master.entity.Items
import com.ffii.fpsms.modules.master.entity.QcItem import com.ffii.fpsms.modules.master.entity.QcItem
import com.ffii.fpsms.modules.stock.entity.EscalationLog
import com.ffii.fpsms.modules.stock.entity.StockInLine import com.ffii.fpsms.modules.stock.entity.StockInLine
import com.ffii.fpsms.modules.stock.entity.StockOutLine import com.ffii.fpsms.modules.stock.entity.StockOutLine
import jakarta.persistence.* import jakarta.persistence.*
@@ -29,6 +30,10 @@ open class QcResult: BaseEntity<Long>() {
@JoinColumn(name = "stockOutLineId") @JoinColumn(name = "stockOutLineId")
open var stockOutLine: StockOutLine? = null open var stockOutLine: StockOutLine? = null


@ManyToOne
@JoinColumn(name = "escalationLogId")
open var escalationLog: EscalationLog? = null

@Column(name = "failQty") @Column(name = "failQty")
open var failQty: Double? = null open var failQty: Double? = null




+ 15
- 5
src/main/java/com/ffii/fpsms/modules/stock/service/StockInLineService.kt View File

@@ -41,6 +41,7 @@ import kotlinx.serialization.encodeToString
import net.sf.jasperreports.engine.JasperExportManager import net.sf.jasperreports.engine.JasperExportManager
import net.sf.jasperreports.engine.JasperPrint import net.sf.jasperreports.engine.JasperPrint
import java.io.File import java.io.File
import kotlin.jvm.optionals.getOrNull
import kotlin.math.max import kotlin.math.max


@Serializable @Serializable
@@ -196,11 +197,13 @@ open class StockInLineService(


@Throws(IOException::class) @Throws(IOException::class)
@Transactional @Transactional
fun saveQcResultWhenStockIn(request: SaveStockInLineRequest, stockInLine: StockInLine): List<QcResult>? {
fun saveQcResultWhenStockIn(request: SaveStockInLineRequest, stockInLine: StockInLine, escLogId: Long?= 0): List<QcResult>? {
if (!request.qcResult.isNullOrEmpty()) { if (!request.qcResult.isNullOrEmpty()) {
val qcResultEntries = request.qcResult!!.map { val qcResultEntries = request.qcResult!!.map {
val qcItem = qcItemsRepository.findById(it.qcItemId).orElseThrow() val qcItem = qcItemsRepository.findById(it.qcItemId).orElseThrow()
val item = itemRepository.findById(stockInLine.item!!.id!!).orElseThrow() val item = itemRepository.findById(stockInLine.item!!.id!!).orElseThrow()
val qcResult = QcResult();

QcResult().apply { QcResult().apply {
this.qcItem = qcItem this.qcItem = qcItem
this.item = item this.item = item
@@ -209,6 +212,7 @@ open class StockInLineService(
this.qcPassed = it.qcPassed this.qcPassed = it.qcPassed
this.type = "qc" // default as qc for now this.type = "qc" // default as qc for now
this.remarks = it.remarks this.remarks = it.remarks
this.escalationLog = escalationLogService.find(escLogId).getOrNull()
} }
} }
return qcResultRepository.saveAllAndFlush(qcResultEntries) return qcResultRepository.saveAllAndFlush(qcResultEntries)
@@ -247,7 +251,6 @@ open class StockInLineService(
val res = escalationLogService.saveEscalationLog(escReq) val res = escalationLogService.saveEscalationLog(escReq)
return res.id?.let { escalationLogRepository.findById(it).orElseThrow() }; return res.id?.let { escalationLogRepository.findById(it).orElseThrow() };
}; };
// return qcResultRepository.saveAllAndFlush(qcResultEntries)
} }
return null return null
} }
@@ -367,11 +370,17 @@ open class StockInLineService(


if (inventoryLotLines.sumOf { it.inQty ?: BigDecimal.ZERO } >= request.acceptQty?.times(ratio)) { if (inventoryLotLines.sumOf { it.inQty ?: BigDecimal.ZERO } >= request.acceptQty?.times(ratio)) {
stockInLine.apply { stockInLine.apply {
this.status = StockInLineStatus.COMPLETE.status
this.status = if (request.acceptQty?.compareTo(request.acceptedQty) == 0)
StockInLineStatus.COMPLETE.status else StockInLineStatus.PARTIALLY_COMPLETE.status
// this.inventoryLotLine = savedInventoryLotLine // this.inventoryLotLine = savedInventoryLotLine
} }
} }
} else if (request.status == StockInLineStatus.PENDING.status || request.status == StockInLineStatus.ESCALATED.status) { } else if (request.status == StockInLineStatus.PENDING.status || request.status == StockInLineStatus.ESCALATED.status) {
var escLogId : Long? = 0L;
// Escalation
if (request.status == StockInLineStatus.ESCALATED.status) {
//
}
// QC // QC
if (request.qcAccept == true) { if (request.qcAccept == true) {
// Accepted // Accepted
@@ -473,7 +482,7 @@ open class StockInLineService(
stockInLine.apply { stockInLine.apply {
this.status = StockInLineStatus.ESCALATED.status this.status = StockInLineStatus.ESCALATED.status
} }
saveEscalationLogWhenStockIn(request, stockInLine);
escLogId = saveEscalationLogWhenStockIn(request, stockInLine)?.id;
} else { } else {
// Rejected // Rejected
stockInLine.apply { stockInLine.apply {
@@ -481,7 +490,8 @@ open class StockInLineService(
} }
} }
} }
saveQcResultWhenStockIn(request, stockInLine)

saveQcResultWhenStockIn(request, stockInLine, escLogId)
} }
val savedStockInLine = saveAndFlush(stockInLine) val savedStockInLine = saveAndFlush(stockInLine)
// check if all line completed // check if all line completed


+ 1
- 0
src/main/java/com/ffii/fpsms/modules/stock/web/model/SaveStockInRequest.kt View File

@@ -20,6 +20,7 @@ enum class StockInLineStatus(val status: String) {
RECEIVING("receiving"), RECEIVING("receiving"),
RECEIVED("received"), RECEIVED("received"),
COMPLETE("completed"), COMPLETE("completed"),
PARTIALLY_COMPLETE("partially_completed"),
REJECT("rejected"); REJECT("rejected");
} }
data class SaveStockInRequest( data class SaveStockInRequest(


+ 4
- 0
src/main/resources/db/changelog/changes/20250827_01_kelvin/01_update_stock_in_line.sql View File

@@ -0,0 +1,4 @@
-- liquibase formatted sql
-- changeset kelvin:update stock in line table
ALTER TABLE `stock_in_line`
CHANGE COLUMN `status` `status` VARCHAR(100) NOT NULL DEFAULT 'pending' ;

+ 4
- 0
src/main/resources/db/changelog/changes/20250828_01_kelvin/01_update_qc_result.sql View File

@@ -0,0 +1,4 @@
-- liquibase formatted sql
-- changeset kelvin:update qc result table
ALTER TABLE `qc_result`
ADD COLUMN `escalationLogId` INT NULL DEFAULT NULL AFTER `stockOutLineId`;

Loading…
Cancel
Save