From 709a4e1ac6229589ece7a2dc384f11d885e5826e Mon Sep 17 00:00:00 2001 From: Adisak Date: Wed, 14 Jan 2026 15:41:10 +0700 Subject: [PATCH] fix: trim() --- src/services/rabbitmq.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/services/rabbitmq.ts b/src/services/rabbitmq.ts index e1af0adb..aa02f882 100644 --- a/src/services/rabbitmq.ts +++ b/src/services/rabbitmq.ts @@ -598,8 +598,8 @@ async function handler_org(msg: amqp.ConsumeMessage): Promise { const posMasterActMap = new Map(); for (const act of oldposMasterAct) { - const parentDNA = act.posMaster.ancestorDNA.trim(); - const childDNA = act.posMasterChild.ancestorDNA.trim(); + const parentDNA = act.posMaster?.ancestorDNA?.trim() ?? ''; + const childDNA = act.posMasterChild?.ancestorDNA?.trim() ?? ''; const key = `${parentDNA}|${childDNA}`; if (!posMasterActMap.has(key)) { @@ -610,7 +610,7 @@ async function handler_org(msg: amqp.ConsumeMessage): Promise { const posMasterIdMap = new Map(); for (const pm of posMaster) { - posMasterIdMap.set(pm.ancestorDNA.trim(), pm.id); + posMasterIdMap.set(pm.ancestorDNA?.trim() ?? '', pm.id); } const _null: any = null; @@ -666,8 +666,8 @@ async function handler_org(msg: amqp.ConsumeMessage): Promise { } for (const act of oldposMasterAct) { - const parentDNA = act.posMaster.ancestorDNA.trim().toLowerCase(); - const childDNA = act.posMasterChild.ancestorDNA.trim().toLowerCase(); + const parentDNA = act.posMaster?.ancestorDNA?.trim()?.toLowerCase() ?? ''; + const childDNA = act.posMasterChild?.ancestorDNA?.trim()?.toLowerCase() ?? ''; const newParentId = posMasterIdMap.get(parentDNA); const newChildId = posMasterIdMap.get(childDNA);