From fc9e1fe6e3bd0ec4ac2ee9cebd834c857d16c8fc Mon Sep 17 00:00:00 2001 From: AdisakKanthawilang Date: Mon, 23 Jun 2025 16:48:05 +0700 Subject: [PATCH] #1373 --- src/controllers/PositionController.ts | 3 +++ src/services/rabbitmq.ts | 21 ++++++++++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/controllers/PositionController.ts b/src/controllers/PositionController.ts index d15450b3..035b3551 100644 --- a/src/controllers/PositionController.ts +++ b/src/controllers/PositionController.ts @@ -3512,9 +3512,12 @@ export class PositionController extends Controller { } await this.positionRepository.save(position); }); + const _null: any = null; const before = null; dataMaster.isSit = requestBody.isSit; dataMaster.next_holderId = requestBody.profileId; + //add on + dataMaster.conditionReason = _null; await this.posMasterRepository.save(dataMaster, { data: request }); setLogDataDiff(request, { before, after: dataMaster }); diff --git a/src/services/rabbitmq.ts b/src/services/rabbitmq.ts index 6512ccea..ebeef173 100644 --- a/src/services/rabbitmq.ts +++ b/src/services/rabbitmq.ts @@ -434,13 +434,13 @@ async function handler_org(msg: amqp.ConsumeMessage): Promise { "positions.posExecutive", ], }); + const _null: any = null; for (const item of posMaster) { if (item.next_holderId != null) { const profile = await repoProfile.findOne({ where: { id: item.next_holderId == null ? "" : item.next_holderId }, }); const position = await item.positions.find((x) => x.positionIsSelected == true); - const _null: any = null; if (profile != null) { profile.posLevelId = position?.posLevelId ?? _null; profile.posTypeId = position?.posTypeId ?? _null; @@ -449,6 +449,9 @@ async function handler_org(msg: amqp.ConsumeMessage): Promise { } } item.current_holderId = item.next_holderId; + if(item.current_holderId){ + item.conditionReason = _null; + } item.next_holderId = null; item.lastUpdateUserId = lastUpdateUserId; item.lastUpdateFullName = lastUpdateFullName; @@ -1518,6 +1521,7 @@ async function handler_org_draft(msg: amqp.ConsumeMessage): Promise { // Create org for await (const x0 of _orgRoot) { var dataId = x0.id; + var _null: any = null; // console.log(`ch0 ${x0.orgRootOrder}`); // console.log(dataId); delete x0.id; @@ -1556,6 +1560,9 @@ async function handler_org_draft(msg: amqp.ConsumeMessage): Promise { ) ) { posMaster.next_holderId = item.current_holderId; + if(posMaster.next_holderId){ + posMaster.conditionReason = _null; + } } else { posMaster.next_holderId = null; posMaster.isSit = false; @@ -1648,6 +1655,9 @@ async function handler_org_draft(msg: amqp.ConsumeMessage): Promise { ) ) { posMaster.next_holderId = item.current_holderId; + if(posMaster.next_holderId){ + posMaster.conditionReason = _null; + } } else { posMaster.next_holderId = null; posMaster.isSit = false; @@ -1742,6 +1752,9 @@ async function handler_org_draft(msg: amqp.ConsumeMessage): Promise { ) ) { posMaster.next_holderId = item.current_holderId; + if(posMaster.next_holderId){ + posMaster.conditionReason = _null; + } } else { posMaster.next_holderId = null; posMaster.isSit = false; @@ -1838,6 +1851,9 @@ async function handler_org_draft(msg: amqp.ConsumeMessage): Promise { ) ) { posMaster.next_holderId = item.current_holderId; + if(posMaster.next_holderId){ + posMaster.conditionReason = _null; + } } else { posMaster.next_holderId = null; posMaster.isSit = false; @@ -1937,6 +1953,9 @@ async function handler_org_draft(msg: amqp.ConsumeMessage): Promise { ) ) { posMaster.next_holderId = item.current_holderId; + if(posMaster.next_holderId){ + posMaster.conditionReason = _null; + } } else { posMaster.next_holderId = null; posMaster.isSit = false;