test เผยแพร่ (2)

This commit is contained in:
Adisak 2026-06-15 11:32:01 +07:00
parent bc8fbf4cf8
commit 82c94073ff

View file

@ -695,7 +695,19 @@ async function handler_org(msg: amqp.ConsumeMessage): Promise<boolean> {
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<boolean> {
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)