@@ -14,8 +14,8 @@ import java.time.LocalDateTime | |||||
open class EscalationLog : BaseEntity<Long>() { | open class EscalationLog : BaseEntity<Long>() { | ||||
@NotNull | @NotNull | ||||
@ManyToOne | @ManyToOne | ||||
@JoinColumn(name = "personInCharge", nullable = false, referencedColumnName = "id") | |||||
open var personInCharge: User? = null | |||||
@JoinColumn(name = "handlerId", nullable = false, referencedColumnName = "id") | |||||
open var handler: User? = null | |||||
@Size(max = 100) | @Size(max = 100) | ||||
@Column(name = "type", nullable = false, length = 100) | @Column(name = "type", nullable = false, length = 100) | ||||
@@ -52,16 +52,16 @@ interface EscalationLogInfo { | |||||
@get:Value("#{target.stockInLine?.item?.itemUoms.^[stockUnit == true && deleted == false]?.uom.udfudesc}") | @get:Value("#{target.stockInLine?.item?.itemUoms.^[stockUnit == true && deleted == false]?.uom.udfudesc}") | ||||
val stockUomDesc: String? | val stockUomDesc: String? | ||||
@get:Value("#{target.personInCharge?.id}") | |||||
val personInChargeId: Long? | |||||
@get:Value("#{target.personInCharge?.department} - #{target.personInCharge?.title} - #{target.personInCharge?.name}") | |||||
val personInCharge: String? | |||||
@get:Value("#{target.personInCharge?.name}") | |||||
val personInChargeName: String? | |||||
@get:Value("#{target.personInCharge?.title}") | |||||
val personInChargeTitle: String? | |||||
@get:Value("#{target.personInCharge?.department}") | |||||
val personInChargeDepartment: String? | |||||
@get:Value("#{target.handler?.id}") | |||||
val handlerId: Long? | |||||
@get:Value("#{target.handler?.department} - #{target.handler?.title} - #{target.handler?.name}") | |||||
val handler: String? | |||||
@get:Value("#{target.handler?.name}") | |||||
val handlerName: String? | |||||
@get:Value("#{target.handler?.title}") | |||||
val handlerTitle: String? | |||||
@get:Value("#{target.handler?.department}") | |||||
val handlerDepartment: String? | |||||
// @get:Value("#{target.type}") | // @get:Value("#{target.type}") | ||||
// val escalationLevel: String | // val escalationLevel: String | ||||
@@ -6,10 +6,10 @@ import java.io.Serializable | |||||
@Repository | @Repository | ||||
interface EscalationLogRepository: AbstractRepository<EscalationLog, Long> { | interface EscalationLogRepository: AbstractRepository<EscalationLog, Long> { | ||||
// fun findAllByPersonInCharge(personInCharge: Long): List<SupervisionApprovalLog> | |||||
// fun findAllByHandler(handler: Long): List<SupervisionApprovalLog> | |||||
fun findAllInfoByDeletedFalse(): List<EscalationLogInfo> | fun findAllInfoByDeletedFalse(): List<EscalationLogInfo> | ||||
fun findAllInfoByDeletedFalseAndStockInLineIdIn(stockInLineIds: List<Serializable>): List<EscalationLogInfo> | fun findAllInfoByDeletedFalseAndStockInLineIdIn(stockInLineIds: List<Serializable>): List<EscalationLogInfo> | ||||
fun findAllInfoByDeletedFalseAndPersonInChargeIdIs(personInChargeId: Serializable): List<EscalationLogInfo> | |||||
fun findAllInfoByDeletedFalseAndHandlerIdIs(handlerId: Serializable): List<EscalationLogInfo> | |||||
} | } |
@@ -37,14 +37,14 @@ open class EscalationLogService( | |||||
open fun getLogsByUser(): List<EscalationLogInfo> { | open fun getLogsByUser(): List<EscalationLogInfo> { | ||||
val user = SecurityUtils.getUser().orElseThrow() | val user = SecurityUtils.getUser().orElseThrow() | ||||
val logs = user.id?.let { escalationLogRepository.findAllInfoByDeletedFalseAndPersonInChargeIdIs(it) } ?: listOf() | |||||
val logs = user.id?.let { escalationLogRepository.findAllInfoByDeletedFalseAndHandlerIdIs(it) } ?: listOf() | |||||
return logs | return logs | ||||
} | } | ||||
open fun saveEscalationLog(request: SaveEscalationLogRequest): SaveEscalationLogResponse{ | open fun saveEscalationLog(request: SaveEscalationLogRequest): SaveEscalationLogResponse{ | ||||
val escalationLog = request.id?.let { escalationLogRepository.findById(it).getOrNull() } ?: EscalationLog() | val escalationLog = request.id?.let { escalationLogRepository.findById(it).getOrNull() } ?: EscalationLog() | ||||
val personInCharge = request.personInChargeId.let { userService.getUserById(it) } | |||||
if (personInCharge == null && escalationLog.personInCharge == null) { | |||||
val handler = request.handlerId.let { userService.getUserById(it) } | |||||
if (handler == null && escalationLog.handler == null) { | |||||
throw NoSuchElementException("Person In Charge is null."); | throw NoSuchElementException("Person In Charge is null."); | ||||
} | } | ||||
@@ -57,7 +57,7 @@ open class EscalationLogService( | |||||
val status = request.status.let { status -> EscalationLogStatus.entries.find{ it.value == status} } | val status = request.status.let { status -> EscalationLogStatus.entries.find{ it.value == status} } | ||||
escalationLog.apply { | escalationLog.apply { | ||||
this.personInCharge = personInCharge | |||||
this.handler = handler | |||||
type = request.type | type = request.type | ||||
this.stockInLine = stockInLine | this.stockInLine = stockInLine | ||||
this.stockOutLine = stockOutLine | this.stockOutLine = stockOutLine | ||||
@@ -73,10 +73,10 @@ open class EscalationLogService( | |||||
id = it.id, | id = it.id, | ||||
stockInLineId = it.stockInLine?.id, | stockInLineId = it.stockInLine?.id, | ||||
stockOutLineId = it.stockOutLine?.id, | stockOutLineId = it.stockOutLine?.id, | ||||
personInChargeId = it.personInCharge?.id, | |||||
personInChargeName = it.personInCharge?.name, | |||||
personInChargeTitle = it.personInCharge?.title, | |||||
personInChargeDepartment = it.personInCharge?.department, | |||||
handlerId = it.handler?.id, | |||||
handlerName = it.handler?.name, | |||||
handlerTitle = it.handler?.title, | |||||
handlerDepartment = it.handler?.department, | |||||
recordDate = it.recordDate, | recordDate = it.recordDate, | ||||
status = it.status?.value, | status = it.status?.value, | ||||
reason = it.reason, | reason = it.reason, | ||||
@@ -7,7 +7,7 @@ import java.time.LocalDateTime | |||||
data class SaveEscalationLogRequest( | data class SaveEscalationLogRequest( | ||||
val id: Long?, | val id: Long?, | ||||
@field:NotNull(message = "Person In Charge cannot be empty") | @field:NotNull(message = "Person In Charge cannot be empty") | ||||
val personInChargeId: Long, | |||||
val handlerId: Long, | |||||
val type: String?, | val type: String?, | ||||
val stockInLineId: Long?, | val stockInLineId: Long?, | ||||
val stockOutLineId: Long?, | val stockOutLineId: Long?, | ||||
@@ -6,10 +6,10 @@ data class SaveEscalationLogResponse( | |||||
val id: Long?, | val id: Long?, | ||||
val stockInLineId: Long?, | val stockInLineId: Long?, | ||||
val stockOutLineId: Long?, | val stockOutLineId: Long?, | ||||
val personInChargeId: Long?, | |||||
val personInChargeName: String?, | |||||
val personInChargeTitle: String?, | |||||
val personInChargeDepartment: String?, | |||||
val handlerId: Long?, | |||||
val handlerName: String?, | |||||
val handlerTitle: String?, | |||||
val handlerDepartment: String?, | |||||
val recordDate: LocalDateTime?, | val recordDate: LocalDateTime?, | ||||
val status: String?, | val status: String?, | ||||
val reason: String?, | val reason: String?, | ||||
@@ -0,0 +1,11 @@ | |||||
-- liquibase formatted sql | |||||
-- changeset cyril:rename_escalation_log | |||||
ALTER TABLE `escalation_log` | |||||
DROP FOREIGN KEY `FK_SUPERVISION_APPROVAL_LOG_ON_PERSONINCHARGE`; | |||||
ALTER TABLE `escalation_log` | |||||
CHANGE COLUMN `personInCharge` `handlerId` INT NOT NULL ; | |||||
ALTER TABLE `escalation_log` | |||||
ADD CONSTRAINT `FK_SUPERVISION_APPROVAL_LOG_ON_PERSONINCHARGE` | |||||
FOREIGN KEY (`handlerId`) | |||||
REFERENCES `user` (`id`); |