From 9bae268e142683b70ff7304e8dfa0c306f1f842e Mon Sep 17 00:00:00 2001 From: mamoss <> Date: Fri, 18 Apr 2025 00:05:56 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B9=81=E0=B8=81=E0=B9=89=E0=B9=84=E0=B8=82?= =?UTF-8?q?=E0=B8=95=E0=B8=B3=E0=B9=81=E0=B8=AB=E0=B8=99=E0=B9=88=E0=B8=87?= =?UTF-8?q?=E0=B8=A5=E0=B8=B9=E0=B8=81=E0=B8=88=E0=B9=89=E0=B8=B2=E0=B8=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/EmployeePositionController.ts | 42 +++++++++++++++++++ .../EmployeeTempPositionController.ts | 42 +++++++++++++++++++ 2 files changed, 84 insertions(+) diff --git a/src/controllers/EmployeePositionController.ts b/src/controllers/EmployeePositionController.ts index d3d70b0c..4b6ef89f 100644 --- a/src/controllers/EmployeePositionController.ts +++ b/src/controllers/EmployeePositionController.ts @@ -888,6 +888,31 @@ export class EmployeePositionController extends Controller { await this.employeePositionRepository.save(position, { data: request }); }), ); + + if (posMaster.current_holderId != null) { + const profile = await this.profileRepository.findOne({ + where: { + id: posMaster.current_holderId, + }, + }); + if (profile != null) { + const positionNew = await this.employeePositionRepository.findOne({ + where: { + // positionIsSelected: true, + posMasterId: posMaster.id, + }, + }); + if (positionNew != null) { + profile.posLevelId = positionNew.posLevelId; + profile.posTypeId = positionNew.posTypeId; + profile.position = positionNew.positionName; + profile.employeeOc = posMaster?.orgRoot?.orgRootName ?? null; + profile.positionEmployeePositionId = positionNew.positionName; + + await this.profileRepository.save(profile); + } + } + } return new HttpSuccess(posMaster.id); } @@ -2242,6 +2267,23 @@ export class EmployeePositionController extends Controller { if (!dataMaster) { throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลตำแหน่งนี้"); } + if (dataMaster.current_holderId != null) { + const profile = await this.profileRepository.findOne({ + where: { + id: dataMaster.current_holderId, + }, + }); + const _null: any = null; + if (profile != null) { + profile.posLevelId = _null; + profile.posTypeId = _null; + profile.position = _null; + profile.employeeOc = _null; + profile.positionEmployeePositionId = _null; + await this.profileRepository.save(profile); + } + } + await this.employeePosMasterRepository.update(id, { isSit: false, next_holderId: null, diff --git a/src/controllers/EmployeeTempPositionController.ts b/src/controllers/EmployeeTempPositionController.ts index 46939932..b551fa95 100644 --- a/src/controllers/EmployeeTempPositionController.ts +++ b/src/controllers/EmployeeTempPositionController.ts @@ -689,6 +689,31 @@ export class EmployeeTempPositionController extends Controller { await this.employeePositionRepository.save(position, { data: request }); }), ); + + if (posMaster.current_holderId != null) { + const profile = await this.profileRepository.findOne({ + where: { + id: posMaster.current_holderId, + }, + }); + if (profile != null) { + const positionNew = await this.employeePositionRepository.findOne({ + where: { + // positionIsSelected: true, + posMasterId: posMaster.id, + }, + }); + if (positionNew != null) { + profile.posLevelId = positionNew.posLevelId; + profile.posTypeId = positionNew.posTypeId; + profile.position = positionNew.positionName; + profile.employeeOc = posMaster?.orgRoot?.orgRootName ?? null; + profile.positionEmployeePositionId = positionNew.positionName; + + await this.profileRepository.save(profile); + } + } + } return new HttpSuccess(posMaster.id); } @@ -1966,6 +1991,23 @@ export class EmployeeTempPositionController extends Controller { if (!dataMaster) { throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลตำแหน่งนี้"); } + if (dataMaster.current_holderId != null) { + const profile = await this.profileRepository.findOne({ + where: { + id: dataMaster.current_holderId, + }, + }); + const _null: any = null; + if (profile != null) { + profile.posLevelId = _null; + profile.posTypeId = _null; + profile.position = _null; + profile.employeeOc = _null; + profile.positionEmployeePositionId = _null; + await this.profileRepository.save(profile); + } + } + await this.employeeTempPosMasterRepository.update(id, { isSit: false, next_holderId: null,