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);