From 38e5ed0e916319d2cded078fff32f33e2f04b977 Mon Sep 17 00:00:00 2001 From: adisak Date: Thu, 2 Apr 2026 12:04:33 +0700 Subject: [PATCH] =?UTF-8?q?#2387=20[=E0=B8=81=E0=B8=97=E0=B8=A1].=20?= =?UTF-8?q?=E0=B8=A3=E0=B8=B0=E0=B8=9A=E0=B8=9A=E0=B9=82=E0=B8=84=E0=B8=A3?= =?UTF-8?q?=E0=B8=87=E0=B8=AA=E0=B8=A3=E0=B9=89=E0=B8=B2=E0=B8=87=E0=B8=AD?= =?UTF-8?q?=E0=B8=B1=E0=B8=95=E0=B8=A3=E0=B8=B2=E0=B8=81=E0=B8=B3=E0=B8=A5?= =?UTF-8?q?=E0=B8=B1=E0=B8=87=20>>=20=E0=B8=81=E0=B8=A3=E0=B8=93=E0=B8=B5?= =?UTF-8?q?=E0=B8=99=E0=B8=B1=E0=B9=88=E0=B8=87=E0=B8=97=E0=B8=B1=E0=B8=9A?= =?UTF-8?q?=E0=B8=95=E0=B8=B3=E0=B9=81=E0=B8=AB=E0=B8=99=E0=B9=88=E0=B8=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/CommandController.ts | 24 ++++++++++++++--------- src/controllers/OrganizationController.ts | 9 +++++---- src/controllers/PositionController.ts | 13 +++++++----- src/services/rabbitmq.ts | 3 ++- 4 files changed, 30 insertions(+), 19 deletions(-) diff --git a/src/controllers/CommandController.ts b/src/controllers/CommandController.ts index 016b4768..29f6b19c 100644 --- a/src/controllers/CommandController.ts +++ b/src/controllers/CommandController.ts @@ -3699,11 +3699,14 @@ export class CommandController extends Controller { posMasterId: item.posmasterId, }, }); + // ถ้าไม่ใช่ตำแหน่งนั่งทับ (isSit = false) ถึงจะอัพเดทตำแหน่งในทะเบียนประวัติ if (positionNew != null) { positionNew.positionIsSelected = true; - profile.posLevelId = positionNew.posLevelId; - profile.posTypeId = positionNew.posTypeId; - profile.position = positionNew.positionName; + if(!posMaster.isSit){ + profile.posLevelId = positionNew.posLevelId; + profile.posTypeId = positionNew.posTypeId; + profile.position = positionNew.positionName; + } profile.amount = item.amount ?? null; profile.amountSpecial = item.amountSpecial ?? null; await this.profileRepository.save(profile); @@ -6892,14 +6895,17 @@ export class CommandController extends Controller { posMasterId: item.bodyPosition.posmasterId, }, }); + // ถ้าไม่ใช่ตำแหน่งนั่งทับ (isSit = false) ถึงจะอัพเดทตำแหน่งในทะเบียนประวัติ if (positionNew != null) { positionNew.positionIsSelected = true; - profile.posLevelId = positionNew.posLevelId; - profile.posTypeId = positionNew.posTypeId; - profile.position = positionNew.positionName; - // profile.dateStart = new Date(); - await this.profileRepository.save(profile, { data: req }); - setLogDataDiff(req, { before, after: profile }); + if(!posMaster.isSit){ + profile.posLevelId = positionNew.posLevelId; + profile.posTypeId = positionNew.posTypeId; + profile.position = positionNew.positionName; + // profile.dateStart = new Date(); + await this.profileRepository.save(profile, { data: req }); + setLogDataDiff(req, { before, after: profile }); + } await this.positionRepository.save(positionNew, { data: req }); } await CreatePosMasterHistoryOfficer(posMaster.id, req); diff --git a/src/controllers/OrganizationController.ts b/src/controllers/OrganizationController.ts index e1767a43..e5a39411 100644 --- a/src/controllers/OrganizationController.ts +++ b/src/controllers/OrganizationController.ts @@ -8927,16 +8927,17 @@ export class OrganizationController extends Controller { }); } + // Collect history data for the selected position + const draftPosMaster = draftPosMasterMap.get(draftPosMasterId) as any; + // Collect profile update for the selected position - if (nextHolderId != null && draftPos.positionIsSelected) { + // ถ้าไม่ใช่ตำแหน่งนั่งทับ (isSit = false) ถึงจะอัพเดทตำแหน่งในทะเบียนประวัติ + if (nextHolderId != null && draftPos.positionIsSelected && !draftPosMaster?.isSit) { profileUpdates.set(nextHolderId, { position: draftPos.positionName, posTypeId: draftPos.posTypeId, posLevelId: draftPos.posLevelId, }); - - // Collect history data for the selected position - const draftPosMaster = draftPosMasterMap.get(draftPosMasterId) as any; if (draftPosMaster && draftPosMaster.ancestorDNA) { // Find the selected position from draft positions const selectedPos = diff --git a/src/controllers/PositionController.ts b/src/controllers/PositionController.ts index 3fff25c4..e3494349 100644 --- a/src/controllers/PositionController.ts +++ b/src/controllers/PositionController.ts @@ -3826,11 +3826,14 @@ export class PositionController extends Controller { where: { id: requestBody.position, posMasterId: requestBody.posMaster }, }); if (_position) { - _profile.position = _position.positionName; - _profile.posTypeId = _position.posTypeId; - _profile.posLevelId = _position.posLevelId; - await this.profileRepository.save(_profile); - setLogDataDiff(request, { before, after: _profile }); + // ถ้าไม่ใช่ตำแหน่งนั่งทับ (isSit = false) ถึงจะอัพเดทตำแหน่งในทะเบียนประวัติ + if(!dataMaster.isSit){ + _profile.position = _position.positionName; + _profile.posTypeId = _position.posTypeId; + _profile.posLevelId = _position.posLevelId; + await this.profileRepository.save(_profile); + setLogDataDiff(request, { before, after: _profile }); + } } } dataMaster.current_holderId = requestBody.profileId; diff --git a/src/services/rabbitmq.ts b/src/services/rabbitmq.ts index 784f3873..a8011900 100644 --- a/src/services/rabbitmq.ts +++ b/src/services/rabbitmq.ts @@ -651,7 +651,8 @@ async function handler_org(msg: amqp.ConsumeMessage): Promise { await posMasterAssignRepository.save(newAssigns); } - if (item.next_holderId != null) { + // ถ้าไม่ใช่ตำแหน่งนั่งทับ (isSit = false) ถึงจะอัพเดทตำแหน่งในทะเบียนประวัติ + if (item.next_holderId != null && !item.isSit) { const profile = await repoProfile.findOne({ where: { id: item.next_holderId == null ? "" : item.next_holderId }, });