瀏覽代碼

update new escalation flow

master
kelvinsuen 3 月之前
父節點
當前提交
c3b645d67e
共有 5 個檔案被更改,包括 29 行新增5 行删除
  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 查看文件

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

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

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



+ 15
- 5
src/main/java/com/ffii/fpsms/modules/stock/service/StockInLineService.kt 查看文件

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

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

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

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

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

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


+ 1
- 0
src/main/java/com/ffii/fpsms/modules/stock/web/model/SaveStockInRequest.kt 查看文件

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


+ 4
- 0
src/main/resources/db/changelog/changes/20250827_01_kelvin/01_update_stock_in_line.sql 查看文件

@@ -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 查看文件

@@ -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…
取消
儲存