From f8672b081f239dd44f828b4dfd26df75f4047344 Mon Sep 17 00:00:00 2001 From: Bright Date: Fri, 8 Nov 2024 14:51:28 +0700 Subject: [PATCH] =?UTF-8?q?fix=20=E0=B8=A3=E0=B8=B2=E0=B8=A2=E0=B8=8A?= =?UTF-8?q?=E0=B8=B7=E0=B9=88=E0=B8=AD=E0=B8=9C=E0=B8=B9=E0=B9=89=E0=B8=A3?= =?UTF-8?q?=E0=B8=B1=E0=B8=9A=E0=B8=AA=E0=B8=B3=E0=B9=80=E0=B8=99=E0=B8=B2?= =?UTF-8?q?=E0=B8=84=E0=B8=B3=E0=B8=AA=E0=B8=B1=E0=B9=88=E0=B8=87=E0=B9=84?= =?UTF-8?q?=E0=B8=A1=E0=B9=88=E0=B9=81=E0=B8=AA=E0=B8=94=E0=B8=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/CommandController.ts | 40 ++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/src/controllers/CommandController.ts b/src/controllers/CommandController.ts index 17937242..d9b07c4b 100644 --- a/src/controllers/CommandController.ts +++ b/src/controllers/CommandController.ts @@ -1520,6 +1520,7 @@ export class CommandController extends Controller { lastName: string | null; remarkVertical?: string | null; remarkHorizontal?: string | null; + rootId?: string | null; }[]; }, @Request() request: RequestWithUser, @@ -1690,6 +1691,45 @@ export class CommandController extends Controller { commandSend.lastUpdateFullName = request.user.name; commandSend.lastUpdatedAt = new Date(); await this.commandSendRepository.save(commandSend); + }), + ); + + const _posMasterNext = await this.posMasterRepository.find({ + where: { + orgRootId: In(requestBody.persons + .filter((x) => x.rootId != undefined && x.rootId != null && x.rootId != "") + .map((x) => x.rootId)), + orgRevision: { orgRevisionIsDraft: false, orgRevisionIsCurrent: true }, + isDirector: true, + current_holderId: Not(IsNull()), + }, + relations: ["current_holder", "orgRoot"], + }); + await Promise.all( + _posMasterNext.map(async (item) => { + const _commandSend = await this.commandSendRepository.findOne({ + where: { + commandId: command.id, + profileId: item.current_holder.id, + }, + }); + 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); }), ); }