From 35eec3a5f5e64fd0703bb822ec8554ba630da0a4 Mon Sep 17 00:00:00 2001 From: Bright Date: Fri, 29 Aug 2025 11:29:31 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B9=80=E0=B8=9E=E0=B8=B4=E0=B9=88=E0=B8=A1?= =?UTF-8?q?=E0=B9=81=E0=B8=99=E0=B8=9A=E0=B9=84=E0=B8=9F=E0=B8=A5=E0=B9=8C?= =?UTF-8?q?=E0=B8=84=E0=B8=B3=E0=B8=AA=E0=B8=B1=E0=B9=88=E0=B8=87=E0=B9=83?= =?UTF-8?q?=E0=B8=99=E0=B8=A3=E0=B8=B2=E0=B8=A2=E0=B8=81=E0=B8=B2=E0=B8=A3?= =?UTF-8?q?=E0=B9=81=E0=B8=88=E0=B9=89=E0=B8=87=E0=B9=80=E0=B8=95=E0=B8=B7?= =?UTF-8?q?=E0=B8=AD=E0=B8=99=20#1784?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/interfaces/utils.ts | 21 +++++++++++++++++++++ src/services/rabbitmq.ts | 6 ++++-- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/src/interfaces/utils.ts b/src/interfaces/utils.ts index 69b31e58..86668e38 100644 --- a/src/interfaces/utils.ts +++ b/src/interfaces/utils.ts @@ -561,6 +561,27 @@ export function chunkArray(array: any, size: number) { return result; } +export async function PayloadSendNoti(commandId: string) { + if (!commandId) + return ""; + const commandRepository = AppDataSource.getRepository(Command); + const _command = await commandRepository.findOne({ + where: { + id: commandId, + }, + relations: ["commandType"], + }); + const _payload = { + name: _command && _command.commandType + ? `คำสั่ง${_command.commandType.name}` + : "", + url: `${process.env.API_URL}/salary/file/ระบบออกคำสั่ง/คำสั่ง/${commandId}/คำสั่ง`, + isReport: true, + isTemplate: false, + } + return JSON.stringify(_payload); +} + export function commandTypePath(commandCode: string): string | null { switch (commandCode) { case "C-PM-01": diff --git a/src/services/rabbitmq.ts b/src/services/rabbitmq.ts index 8c19f8f7..d55667a6 100644 --- a/src/services/rabbitmq.ts +++ b/src/services/rabbitmq.ts @@ -24,6 +24,7 @@ import { PosMasterAct } from "../entities/PosMasterAct"; import { PermissionOrg } from "../entities/PermissionOrg"; import { sendWebSocket } from "./webSocket"; import { CreatePosMasterHistoryOfficer } from "./PositionService"; +import { PayloadSendNoti } from "../interfaces/utils"; export let sendToQueue: (payload: any) => void; export let sendToQueueOrg: (payload: any) => void; @@ -83,7 +84,7 @@ export async function init() { console.log("[AMQ] Listening for message..."); createConsumer(queue, channel, handler), //----> (3) Process Consumer - createConsumer(queue_org, channel, handler_org); + createConsumer(queue_org, channel, handler_org); createConsumer(queue_org_draft, channel, handler_org_draft); createConsumer(queue_command_noti, channel, handler_command_noti); // createConsumer(queue2, channel, handler2); @@ -445,6 +446,7 @@ async function handler_command_noti(msg: amqp.ConsumeMessage): Promise })) : []; + const payloadStr = await PayloadSendNoti(command.id); const profilesSendRequest = new CallAPI() .PostData( { headers: { authorization: token } }, @@ -453,7 +455,7 @@ async function handler_command_noti(msg: amqp.ConsumeMessage): Promise subject: `${command.issue}`, body: `${command.issue}`, receiverUserIds: profilesSend, - payload: "", // แนบไฟล์ (ถ้าจำเป็น) + payload: payloadStr, // แนบไฟล์ (ถ้าจำเป็น) }, false, )