瀏覽代碼

update escalation

master
kelvinsuen 19 小時之前
父節點
當前提交
ae716e906c
共有 9 個文件被更改,包括 75 次插入14 次删除
  1. +2
    -0
      src/main/java/com/ffii/fpsms/modules/stock/entity/EscalationLogInfo.kt
  2. +2
    -0
      src/main/java/com/ffii/fpsms/modules/stock/entity/EscalationLogRepository.kt
  3. +5
    -0
      src/main/java/com/ffii/fpsms/modules/stock/entity/StockInLine.kt
  4. +3
    -0
      src/main/java/com/ffii/fpsms/modules/stock/entity/projection/StockInLineInfo.kt
  5. +1
    -0
      src/main/java/com/ffii/fpsms/modules/stock/enums/EscalationLogEnum.kt
  6. +1
    -1
      src/main/java/com/ffii/fpsms/modules/stock/service/EscalationLogService.kt
  7. +54
    -8
      src/main/java/com/ffii/fpsms/modules/stock/service/StockInLineService.kt
  8. +5
    -5
      src/main/java/com/ffii/fpsms/modules/stock/web/model/SaveEscalationLogRequest.kt
  9. +2
    -0
      src/main/java/com/ffii/fpsms/modules/stock/web/model/SaveStockInRequest.kt

+ 2
- 0
src/main/java/com/ffii/fpsms/modules/stock/entity/EscalationLogInfo.kt 查看文件

@@ -68,4 +68,6 @@ interface EscalationLogInfo {
val qcTotalCount: Int?;
val qcFailCount: Int?;
val reason: String?;
@get:Value("#{target.status?.value}")
val status: String?;
}

+ 2
- 0
src/main/java/com/ffii/fpsms/modules/stock/entity/EscalationLogRepository.kt 查看文件

@@ -11,5 +11,7 @@ interface EscalationLogRepository: AbstractRepository<EscalationLog, Long> {

fun findAllInfoByDeletedFalseAndStockInLineIdIn(stockInLineIds: List<Serializable>): List<EscalationLogInfo>

fun findAllByDeletedFalseAndStockInLineIdIn(stockInLineIds: List<Serializable>): List<EscalationLog>

fun findAllInfoByDeletedFalseAndHandlerIdIs(handlerId: Serializable): List<EscalationLogInfo>
}

+ 5
- 0
src/main/java/com/ffii/fpsms/modules/stock/entity/StockInLine.kt 查看文件

@@ -1,6 +1,7 @@
package com.ffii.fpsms.modules.stock.entity

import com.fasterxml.jackson.annotation.JsonBackReference
import com.fasterxml.jackson.annotation.JsonManagedReference
import com.ffii.core.entity.BaseEntity
import com.ffii.fpsms.modules.master.entity.Items
import com.ffii.fpsms.modules.purchaseOrder.entity.PurchaseOrder
@@ -97,4 +98,8 @@ open class StockInLine : BaseEntity<Long>() {
@Column(name = "remarks")
open var remarks: String? = null

@JsonManagedReference
@OneToMany(mappedBy = "stockInLine", cascade = [CascadeType.ALL], orphanRemoval = true)
open var escalationLog: MutableList<EscalationLog>? = mutableListOf()

}

+ 3
- 0
src/main/java/com/ffii/fpsms/modules/stock/entity/projection/StockInLineInfo.kt 查看文件

@@ -3,6 +3,7 @@ package com.ffii.fpsms.modules.stock.entity.projection
import com.ffii.fpsms.modules.master.entity.Items
import com.ffii.fpsms.modules.master.entity.ItemsRepository
import com.ffii.fpsms.modules.master.entity.UomConversion
import com.ffii.fpsms.modules.stock.enums.EscalationLogStatus
import org.springframework.beans.factory.annotation.Value
import java.math.BigDecimal
import java.time.LocalDate
@@ -45,4 +46,6 @@ interface StockInLineInfo {
val itemType: String
val dnNo: String
val dnDate: LocalDateTime?
@get:Value("#{target.escalationLog.^[status.value == 'pending']?.handler?.id}")
val handlerId: Long?
}

+ 1
- 0
src/main/java/com/ffii/fpsms/modules/stock/enums/EscalationLogEnum.kt 查看文件

@@ -4,4 +4,5 @@ enum class EscalationLogStatus(val value: String) {
PENDING("pending"),
ACCEPTED("accepted"),
REJECTED("rejected"),
ESCALATED("escalated"),
}

+ 1
- 1
src/main/java/com/ffii/fpsms/modules/stock/service/EscalationLogService.kt 查看文件

@@ -16,7 +16,7 @@ open class EscalationLogService(
private val jdbcDao: JdbcDao,
private val escalationLogRepository: EscalationLogRepository,
private val userService: UserService,
private val stockInLineService: StockInLineService,
// private val stockInLineService: StockInLineService,
private val stockOutLineService: StockOutLineService,
private val stockInLineRepository: StockInLineRepository,
private val stockOutLIneRepository: StockOutLIneRepository,


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

@@ -13,10 +13,6 @@ import com.ffii.fpsms.modules.qc.entity.QcResult
import com.ffii.fpsms.modules.qc.entity.QcResultRepository
import com.ffii.fpsms.modules.stock.entity.*
import com.ffii.fpsms.modules.stock.sql.StockSql.SQL.INVENTORY_COUNT
import com.ffii.fpsms.modules.stock.web.model.ExportQrCodeRequest
import com.ffii.fpsms.modules.stock.web.model.SaveStockInLineRequest
import com.ffii.fpsms.modules.stock.web.model.SaveStockInRequest
import com.ffii.fpsms.modules.stock.web.model.StockInLineStatus
import net.sf.jasperreports.engine.JasperCompileManager
import org.springframework.core.io.ClassPathResource
import org.springframework.stereotype.Service
@@ -33,11 +29,14 @@ import com.ffii.fpsms.modules.purchaseOrder.enums.PurchaseOrderLineStatus
import com.ffii.fpsms.modules.purchaseOrder.enums.PurchaseOrderStatus
import com.ffii.fpsms.modules.stock.entity.enum.InventoryLotLineStatus
import com.ffii.fpsms.modules.stock.entity.projection.StockInLineInfo
import com.ffii.fpsms.modules.stock.enums.EscalationLogStatus
import com.ffii.fpsms.modules.stock.web.model.*
import java.io.FileNotFoundException
import java.time.format.DateTimeFormatter
import kotlinx.serialization.Serializable
import kotlinx.serialization.json.Json
import kotlinx.serialization.encodeToString
import kotlin.math.max

@Serializable
data class QrContent(val itemId: Long, val stockInLineId: Long)
@@ -49,6 +48,8 @@ open class StockInLineService(
private val polRepository: PurchaseOrderLineRepository,
private val qcItemsRepository: QcItemRepository,
private val qcResultRepository: QcResultRepository,
private val escalationLogService: EscalationLogService,
private val escalationLogRepository: EscalationLogRepository,
private val stockInService: StockInService,
private val stockInRepository: StockInRepository,
private val stockInLineRepository: StockInLineRepository,
@@ -135,6 +136,7 @@ open class StockInLineService(
val savedInventoryLot = inventoryLotRepository.saveAndFlush(inventoryLot)
return savedInventoryLot
}

@Throws(IOException::class)
@Transactional
fun saveInventoryLotLineWhenStockIn(request: SaveStockInLineRequest, stockInLine: StockInLine): InventoryLotLine {
@@ -181,6 +183,42 @@ open class StockInLineService(
return null
}

@Throws(IOException::class)
@Transactional
fun saveEscalationLogWhenStockIn(request: SaveStockInLineRequest, stockInLine: StockInLine): EscalationLog? {
if (request.escalationLog != null) {
val escReq = request.escalationLog;

var qcTotal = 0;
var qcFailed = 0;
if (request.qcResult!!.isEmpty()) {
val escLogList = stockInLine.id?.let { escalationLogRepository.findAllByDeletedFalseAndStockInLineIdIn(listOf(it)); }
val latestLog = escLogList?.maxBy { it.id!! };
latestLog?.apply { status = EscalationLogStatus.ESCALATED }
escalationLogService.save(latestLog);

val qcRes = qcResultRepository.findQcResultInfoByStockInLineIdAndDeletedFalse(stockInLine.id!!);
qcTotal = qcRes.size;
qcFailed = qcRes.count{ !it.qcPassed};
} else {
qcTotal = request.qcResult?.size ?: 5;
qcFailed = request.qcResult?.count { !it.qcPassed } ?: 0;
}

escReq?.apply {
this.stockInLineId = stockInLine.id;
this.qcTotalCount = qcTotal;
this.qcFailCount = qcFailed;
}
if (escReq != null) {
val res = escalationLogService.saveEscalationLog(escReq)
return res.id?.let { escalationLogRepository.findById(it).orElseThrow() };
};
// return qcResultRepository.saveAllAndFlush(qcResultEntries)
}
return null
}

@Throws(IOException::class)
@Transactional
fun updatePurchaseOrderStatus(request: SaveStockInLineRequest) {
@@ -287,7 +325,7 @@ open class StockInLineService(
this.status = StockInLineStatus.COMPLETE.status
this.inventoryLotLine = savedInventoryLotLine
}
} else if (request.status == StockInLineStatus.PENDING.status) {
} else if (request.status == StockInLineStatus.PENDING.status || request.status == StockInLineStatus.ESCALATED.status) {
// QC
if (request.qcAccept == true) {
// Accepted
@@ -384,9 +422,17 @@ open class StockInLineService(
// )
// }
} else if (request.qcAccept == false) {
// Rejected
stockInLine.apply {
this.status = StockInLineStatus.REJECT.status
if (request.escalationLog != null) {
// Escalated
stockInLine.apply {
this.status = StockInLineStatus.ESCALATED.status
}
saveEscalationLogWhenStockIn(request, stockInLine);
} else {
// Rejected
stockInLine.apply {
this.status = StockInLineStatus.REJECT.status
}
}
}
saveQcResultWhenStockIn(request, stockInLine)


+ 5
- 5
src/main/java/com/ffii/fpsms/modules/stock/web/model/SaveEscalationLogRequest.kt 查看文件

@@ -9,12 +9,12 @@ data class SaveEscalationLogRequest(
@field:NotNull(message = "Person In Charge cannot be empty")
val handlerId: Long,
val type: String?,
val stockInLineId: Long?,
val stockOutLineId: Long?,
var stockInLineId: Long?,
var stockOutLineId: Long?,
val recordDate: LocalDateTime?,
@field:NotBlank(message = "Status cannot be empty")
val status: String,
var status: String,
val reason: String?,
val qcTotalCount: Int?,
val qcFailCount: Int?,
var qcTotalCount: Int?,
var qcFailCount: Int?,
)

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

@@ -13,6 +13,7 @@ enum class StockInStatus(val status: String) {
enum class StockInLineStatus(val status: String) {
PENDING("pending"),
QC("qc"),
ESCALATED("escalated"),
FirstDetermine("determine1"),
SecondDetermine("determine2"),
ThirdDetermine("determine3"),
@@ -53,6 +54,7 @@ data class SaveStockInLineRequest(
var productionDate: LocalDate?,
var qcAccept: Boolean?,
var qcResult: List<SaveQcResultRequest>?,
var escalationLog: SaveEscalationLogRequest?,
var warehouseId: Long?,
var rejectQty: BigDecimal?
)

Loading…
取消
儲存