From 7686ec2eac235073aa65b080f4f9dac9053a4c72 Mon Sep 17 00:00:00 2001 From: harid Date: Thu, 11 Jun 2026 16:55:16 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B8=81=E0=B8=A3=E0=B8=93=E0=B8=B5=E0=B8=99?= =?UTF-8?q?=E0=B8=B1=E0=B9=88=E0=B8=87=E0=B8=97=E0=B8=B1=E0=B8=9A=E0=B8=97?= =?UTF-8?q?=E0=B8=B5=E0=B9=88=E0=B8=95=E0=B9=89=E0=B8=AD=E0=B8=87=E0=B9=80?= =?UTF-8?q?=E0=B8=9B=E0=B9=87=E0=B8=99=E0=B8=95=E0=B8=B3=E0=B9=81=E0=B8=AB?= =?UTF-8?q?=E0=B8=99=E0=B9=88=E0=B8=87=E0=B8=88=E0=B8=A3=E0=B8=B4=E0=B8=87?= =?UTF-8?q?=E0=B8=82=E0=B8=AD=E0=B8=87=E0=B9=80=E0=B8=82=E0=B8=B2=20#251?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/services/PositionService.ts | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/src/services/PositionService.ts b/src/services/PositionService.ts index 37c5f083..2c454a39 100644 --- a/src/services/PositionService.ts +++ b/src/services/PositionService.ts @@ -11,6 +11,7 @@ import { PosMasterHistory } from "../entities/PosMasterHistory"; import { Position } from "../entities/Position"; import { ProfileEducation } from "../entities/ProfileEducation"; import { RequestWithUser } from "../middlewares/user"; +import { Profile } from "../entities/Profile"; /** * function สำหรับดึงตำแหน่งที่รักษาการแทน @@ -85,6 +86,7 @@ export async function CreatePosMasterHistoryOfficer( const repoHistory = transactionManager.getRepository(PosMasterHistory); const repoOrgRevision = transactionManager.getRepository(OrgRevision); const repoPosition = transactionManager.getRepository(Position); + const repoProfile = transactionManager.getRepository(Profile); const pm = await repoPosmaster.findOne({ where: { id: posMasterId }, @@ -132,6 +134,21 @@ export async function CreatePosMasterHistoryOfficer( : null; } + let position = selectedPosition?.positionName ?? _null; + let posTypeName = selectedPosition?.posType?.posTypeName ?? _null; + let posLevelName = selectedPosition?.posLevel?.posLevelName ?? _null; + let posExecutiveName = selectedPosition?.posExecutive?.posExecutiveName ?? _null; + if (pm.isSit && pm.current_holderId) { + const profile = await repoProfile.findOne({ + where: { id: pm.current_holderId }, + relations: ["posType", "posLevel"] + }); + position = profile?.position ?? _null; + posTypeName = profile?.posType?.posTypeName ?? _null; + posLevelName = profile?.posLevel?.posLevelName ?? _null; + posExecutiveName = profile?.posExecutive ?? _null; + } + h.ancestorDNA = pm.ancestorDNA ? pm.ancestorDNA : _null; if (!type || type != "DELETE") { if (checkCurrentRevision) { @@ -144,9 +161,9 @@ export async function CreatePosMasterHistoryOfficer( h.firstName = pm.next_holder?.firstName || _null; h.lastName = pm.next_holder?.lastName || _null; } - h.position = selectedPosition?.positionName ?? _null; - h.posType = selectedPosition?.posType?.posTypeName ?? _null; - h.posLevel = selectedPosition?.posLevel?.posLevelName ?? _null; + h.position = position; + h.posType = posTypeName; + h.posLevel = posLevelName; } h.rootDnaId = pm.orgRoot?.ancestorDNA || _null; h.child1DnaId = pm.orgChild1?.ancestorDNA || _null; @@ -156,7 +173,7 @@ export async function CreatePosMasterHistoryOfficer( h.posMasterNoPrefix = pm.posMasterNoPrefix ?? _null; h.posMasterNo = pm.posMasterNo ?? _null; h.posMasterNoSuffix = pm.posMasterNoSuffix ?? _null; - h.posExecutive = selectedPosition?.posExecutive?.posExecutiveName ?? _null; + h.posExecutive = posExecutiveName; h.shortName = [ pm.orgChild4?.orgChild4ShortName,