From 8f62a41db3307ef4c59bbc32e3b49e539ee86bba Mon Sep 17 00:00:00 2001 From: AdisakKanthawilang Date: Fri, 5 Sep 2025 13:06:52 +0700 Subject: [PATCH] update --- src/controllers/CommandController.ts | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/src/controllers/CommandController.ts b/src/controllers/CommandController.ts index fc9eebde..701f8462 100644 --- a/src/controllers/CommandController.ts +++ b/src/controllers/CommandController.ts @@ -3540,10 +3540,29 @@ export class CommandController extends Controller { profile.lastUpdateUserId = req.user.sub; profile.lastUpdateFullName = req.user.name; profile.lastUpdatedAt = new Date(); + const clearProfile = await checkCommandType(String(item.commandId)); + + //ปั๊มประวัติก่อนลบตำแหน่ง + const curRevition = await this.orgRevisionRepo.findOne({ + where: { orgRevisionIsCurrent: true, orgRevisionIsDraft: false } + }) + + if(curRevition){ + const curPosMaster = await this.posMasterRepository.findOne({ + where:{ + current_holderId: profile.id, + orgRevisionId: curRevition.id + } + }) + if (curPosMaster && clearProfile.LeaveType != "RETIRE_OUT_EMP") { + await CreatePosMasterHistoryOfficer(curPosMaster.id, req); + } + } + + //ลบตำแหน่ง if (item.isLeave == true) { await removeProfileInOrganize(profile.id, "OFFICER"); } - const clearProfile = await checkCommandType(String(item.commandId)); if (clearProfile.status) { if (profile.keycloak != null) { const delUserKeycloak = await deleteUser(profile.keycloak); @@ -3601,7 +3620,7 @@ export class CommandController extends Controller { positionNew.positionIsSelected = true; await this.positionRepository.save(positionNew, { data: req }); } - // await CreatePosMasterHistoryOfficer(posMaster.id, req); + await CreatePosMasterHistoryOfficer(posMaster.id, req); } const newMapProfileSalary = { profileId: profile.id, @@ -3706,11 +3725,6 @@ export class CommandController extends Controller { profile.isActive = true; } await this.profileRepository.save(profile); - console.log("item>>>", item); - console.log("clearProfile.LeaveType >>>", clearProfile.LeaveType ); - if (item.posmasterId && clearProfile.LeaveType != "RETIRE_OUT_EMP") { - await CreatePosMasterHistoryOfficer(item.posmasterId, req); - } }), );