This commit is contained in:
parent
37b324babf
commit
f76911cc26
2 changed files with 14 additions and 5 deletions
|
|
@ -123,12 +123,20 @@ async function handler(msg: amqp.ConsumeMessage): Promise<boolean> {
|
|||
relations: ["commandType", "commandRecives"],
|
||||
});
|
||||
if (!command) return true;
|
||||
let waiting_message = `ระบบทำการออกคำสั่งเลขที่ ${command.commandNo}/${command.commandYear + 543}`;
|
||||
let success_message = `ระบบออกคำสั่งเลขที่ ${command.commandNo}/${command.commandYear + 543} เสร็จสิ้น`;
|
||||
let error_message = `ระบบออกคำสั่งเลขที่ ${command.commandNo}/${command.commandYear + 543} ผิดพลาด`
|
||||
if(command.commandType?.code == "C-PM-47"){
|
||||
waiting_message = `ระบบทำการออกคำสั่งเลขที่ ${command.commandNo}`;
|
||||
success_message = `ระบบออกคำสั่งเลขที่ ${command.commandNo} เสร็จสิ้น`;
|
||||
error_message = `ระบบออกคำสั่งเลขที่ ${command.commandNo} ผิดพลาด`;
|
||||
}
|
||||
if (user) {
|
||||
sendWebSocket(
|
||||
"send-command-notification",
|
||||
{
|
||||
success: true,
|
||||
message: `ระบบทำการออกคำสั่งเลขที่ ${command.commandNo}/${command.commandYear + 543}`,
|
||||
message: waiting_message,
|
||||
payload: command,
|
||||
},
|
||||
{ userId: user?.sub },
|
||||
|
|
@ -137,7 +145,7 @@ async function handler(msg: amqp.ConsumeMessage): Promise<boolean> {
|
|||
const path = commandTypePath(command.commandType.code);
|
||||
if (path == null) throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบประเภทคำสั่งนี้ในระบบ");
|
||||
return await new CallAPI()
|
||||
|
||||
|
||||
.PostData(
|
||||
{
|
||||
headers: { authorization: token },
|
||||
|
|
@ -173,7 +181,7 @@ async function handler(msg: amqp.ConsumeMessage): Promise<boolean> {
|
|||
"send-command-notification",
|
||||
{
|
||||
success: true,
|
||||
message: `ระบบออกคำสั่งเลขที่ ${command.commandNo}/${command.commandYear + 543} เสร็จสิ้น`,
|
||||
message: success_message,
|
||||
payload: command,
|
||||
},
|
||||
{ userId: user?.sub },
|
||||
|
|
@ -188,7 +196,7 @@ async function handler(msg: amqp.ConsumeMessage): Promise<boolean> {
|
|||
"send-command-notification",
|
||||
{
|
||||
success: false,
|
||||
message: `ระบบออกคำสั่งเลขที่ ${command.commandNo}/${command.commandYear + 543} ผิดพลาด`,
|
||||
message: error_message,
|
||||
payload: command,
|
||||
},
|
||||
{ userId: user?.sub },
|
||||
|
|
|
|||
|
|
@ -45,7 +45,8 @@ export async function sendWebSocket(
|
|||
},
|
||||
) {
|
||||
if (!io) initWebSocket();
|
||||
|
||||
// console.log( `🔔 <Message>:`,data.message);
|
||||
|
||||
for (let [id, session] of io.of("/").sockets) {
|
||||
const user: {
|
||||
sub: string;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue