From e28f5542756cfe8bc6ee2d54c012d21dc7858c9c Mon Sep 17 00:00:00 2001 From: mamoss <> Date: Tue, 29 Jul 2025 22:31:22 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B8=AA=E0=B9=88=E0=B8=87=E0=B8=AA=E0=B8=B3?= =?UTF-8?q?=E0=B9=80=E0=B8=99=E0=B8=B2=E0=B8=AB=E0=B9=89=E0=B8=B2=E0=B8=A1?= =?UTF-8?q?=E0=B8=8B=E0=B9=89=E0=B8=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/CommandController.ts | 79 ++++++++++++++-------------- 1 file changed, 40 insertions(+), 39 deletions(-) diff --git a/src/controllers/CommandController.ts b/src/controllers/CommandController.ts index 0292cffc..3e21ae8b 100644 --- a/src/controllers/CommandController.ts +++ b/src/controllers/CommandController.ts @@ -2327,7 +2327,7 @@ export class CommandController extends Controller { let _commandSend = await this.commandSendRepository.findOne({ where: { commandId: command.id, - profileId: _posMasterCommission?.current_holder.id ?? _null, + profileId: _posMasterCommission?.current_holderId ?? _null, }, }); if (!_commandSend && _posMasterCommission != null) { @@ -2384,7 +2384,7 @@ export class CommandController extends Controller { _commandSend = await this.commandSendRepository.findOne({ where: { commandId: command.id, - profileId: _posMasterInformation?.current_holder.id ?? _null, + profileId: _posMasterInformation?.current_holderId ?? _null, }, }); if (!_commandSend && _posMasterInformation != null) { @@ -2441,7 +2441,7 @@ export class CommandController extends Controller { _commandSend = await this.commandSendRepository.findOne({ where: { commandId: command.id, - profileId: _posMasterOfficer?.current_holder.id ?? _null, + profileId: _posMasterOfficer?.current_holderId ?? _null, }, }); if (!_commandSend && _posMasterOfficer != null) { @@ -2626,42 +2626,43 @@ export class CommandController extends Controller { const _commandSend = await this.commandSendRepository.findOne({ where: { commandId: command.id, - profileId: item.current_holder.id, + profileId: item.current_holderId, }, }); - if (_commandSend) return; - let commandSend = new CommandSend(); - commandSend.citizenId = item.current_holder.citizenId; - commandSend.prefix = item.current_holder.prefix; - commandSend.firstName = item.current_holder.firstName; - commandSend.lastName = item.current_holder.lastName; - commandSend.position = item.current_holder.position; - commandSend.org = item.orgRoot.orgRootName; - commandSend.profileId = item.current_holder.id; - commandSend.commandId = command.id; - commandSend.createdUserId = request.user.sub; - commandSend.createdFullName = request.user.name; - commandSend.createdAt = new Date(); - commandSend.lastUpdateUserId = request.user.sub; - commandSend.lastUpdateFullName = request.user.name; - commandSend.lastUpdatedAt = new Date(); - await this.commandSendRepository.save(commandSend); - if (commandSend && commandSend.id) { - let _ccName = new Array("EMAIL", "INBOX"); - let _dataSendCC = new Array(); - for (let i = 0; i < _ccName.length; i++) { - _dataSendCC.push({ - commandSendId: commandSend.id, - name: _ccName[i], - createdUserId: request.user.sub, - createdFullName: request.user.name, - createdAt: new Date(), - lastUpdateUserId: request.user.sub, - lastUpdateFullName: request.user.name, - lastUpdatedAt: new Date(), - }); + if (!_commandSend) { + let commandSend = new CommandSend(); + commandSend.citizenId = item.current_holder.citizenId; + commandSend.prefix = item.current_holder.prefix; + commandSend.firstName = item.current_holder.firstName; + commandSend.lastName = item.current_holder.lastName; + commandSend.position = item.current_holder.position; + commandSend.org = item.orgRoot.orgRootName; + commandSend.profileId = item.current_holderId; + commandSend.commandId = command.id; + commandSend.createdUserId = request.user.sub; + commandSend.createdFullName = request.user.name; + commandSend.createdAt = new Date(); + commandSend.lastUpdateUserId = request.user.sub; + commandSend.lastUpdateFullName = request.user.name; + commandSend.lastUpdatedAt = new Date(); + await this.commandSendRepository.save(commandSend); + if (commandSend && commandSend.id) { + let _ccName = new Array("EMAIL", "INBOX"); + let _dataSendCC = new Array(); + for (let i = 0; i < _ccName.length; i++) { + _dataSendCC.push({ + commandSendId: commandSend.id, + name: _ccName[i], + createdUserId: request.user.sub, + createdFullName: request.user.name, + createdAt: new Date(), + lastUpdateUserId: request.user.sub, + lastUpdateFullName: request.user.name, + lastUpdatedAt: new Date(), + }); + } + await this.commandSendCCRepository.save(_dataSendCC); } - await this.commandSendCCRepository.save(_dataSendCC); } }), ); @@ -2681,11 +2682,11 @@ export class CommandController extends Controller { relations: ["current_holder", "orgRoot"], }); await Promise.all( - _posMasterNext.map(async (item) => { + _posMasterNext.map(async (item: any) => { const _commandSend = await this.commandSendRepository.findOne({ where: { commandId: command.id, - profileId: item.current_holder.id, + profileId: item.current_holderId, }, }); // if (_commandSend) return; @@ -2697,7 +2698,7 @@ export class CommandController extends Controller { commandSend.lastName = item.current_holder.lastName; commandSend.position = item.current_holder.position; commandSend.org = item.orgRoot.orgRootName; - commandSend.profileId = item.current_holder.id; + commandSend.profileId = item.current_holderId; commandSend.commandId = command.id; commandSend.createdUserId = request.user.sub; commandSend.createdFullName = request.user.name;