From 82c94073ffb47a78ebd72c7cb0130a41d835e439 Mon Sep 17 00:00:00 2001 From: Adisak Date: Mon, 15 Jun 2026 11:32:01 +0700 Subject: [PATCH] =?UTF-8?q?test=20=E0=B9=80=E0=B8=9C=E0=B8=A2=E0=B9=81?= =?UTF-8?q?=E0=B8=9E=E0=B8=A3=E0=B9=88=20(2)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/services/rabbitmq.ts | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/src/services/rabbitmq.ts b/src/services/rabbitmq.ts index b941ad13..7705593b 100644 --- a/src/services/rabbitmq.ts +++ b/src/services/rabbitmq.ts @@ -695,7 +695,19 @@ async function handler_org(msg: amqp.ConsumeMessage): Promise { where: { orgRevisionId: orgRevisionPublish.id, }, - select: ["id", "current_holderId", "ancestorDNA"], + select: [ + "id", + "current_holderId", + "ancestorDNA", + "posMasterNo", + "posMasterNoPrefix", + "posMasterNoSuffix", + "orgRootId", + "orgChild1Id", + "orgChild2Id", + "orgChild3Id", + "orgChild4Id", + ], }); // Task #2160 ดึง posMasterAssign ของ revision เดิม @@ -861,7 +873,21 @@ async function handler_org(msg: amqp.ConsumeMessage): Promise { const newHolderId = item?.next_holderId; const isHolderChanged = oldHolderId !== newHolderId; - if (isHolderChanged) { + // เช็คว่า holder เดิม แต่ตำแหน่งเปลี่ยน + const isSameHolder = oldHolderId === newHolderId && oldHolderId != null && newHolderId != null; + const isPositionChanged = + isSameHolder && + oldPm && + (oldPm.posMasterNo !== item.posMasterNo || + oldPm.posMasterNoPrefix !== item.posMasterNoPrefix || + oldPm.posMasterNoSuffix !== item.posMasterNoSuffix || + oldPm.orgRootId !== item.orgRoot?.id || + oldPm.orgChild1Id !== item.orgChild1?.id || + oldPm.orgChild2Id !== item.orgChild2?.id || + oldPm.orgChild3Id !== item.orgChild3?.id || + oldPm.orgChild4Id !== item.orgChild4?.id); + + if (isHolderChanged || isPositionChanged) { const nextHolderProfile = item.next_holderId != null && item.next_holderId !== "" ? profilesMap.get(item.next_holderId)