fix rabbit
This commit is contained in:
parent
0ac62329d9
commit
384d637610
1 changed files with 33 additions and 29 deletions
|
|
@ -123,15 +123,17 @@ async function handler(msg: amqp.ConsumeMessage): Promise<boolean> {
|
|||
relations: ["commandType", "commandRecives"],
|
||||
});
|
||||
if (!command) return true;
|
||||
sendWebSocket(
|
||||
"send-command-notification",
|
||||
{
|
||||
success: true,
|
||||
message: `ระบบทำการออกคำสั่งเลขที่ ${command.commandNo}/${command.commandYear + 543}`,
|
||||
payload: command,
|
||||
},
|
||||
{ userId: user.sub ?? "" },
|
||||
).catch(console.error);
|
||||
if (user) {
|
||||
sendWebSocket(
|
||||
"send-command-notification",
|
||||
{
|
||||
success: true,
|
||||
message: `ระบบทำการออกคำสั่งเลขที่ ${command.commandNo}/${command.commandYear + 543}`,
|
||||
payload: command,
|
||||
},
|
||||
{ userId: user?.sub },
|
||||
).catch(console.error);
|
||||
}
|
||||
const path = commandTypePath(command.commandType.code);
|
||||
if (path == null) throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบประเภทคำสั่งนี้ในระบบ");
|
||||
return await new CallAPI()
|
||||
|
|
@ -166,30 +168,32 @@ async function handler(msg: amqp.ConsumeMessage): Promise<boolean> {
|
|||
console.log("[AMQ] Excecute Command Success");
|
||||
Object.assign(command, { status, lastUpdateUserId, lastUpdateFullName, lastUpdatedAt });
|
||||
const result = await repo.save(command).catch((e) => console.log(e));
|
||||
|
||||
sendWebSocket(
|
||||
"send-command-notification",
|
||||
{
|
||||
success: true,
|
||||
message: `ระบบออกคำสั่งเลขที่ ${command.commandNo}/${command.commandYear + 543} เสร็จสิ้น`,
|
||||
payload: command,
|
||||
},
|
||||
{ userId: user.sub ?? "" },
|
||||
).catch(console.error);
|
||||
|
||||
if(user){
|
||||
sendWebSocket(
|
||||
"send-command-notification",
|
||||
{
|
||||
success: true,
|
||||
message: `ระบบออกคำสั่งเลขที่ ${command.commandNo}/${command.commandYear + 543} เสร็จสิ้น`,
|
||||
payload: command,
|
||||
},
|
||||
{ userId: user?.sub},
|
||||
).catch(console.error);
|
||||
}
|
||||
return !!result;
|
||||
})
|
||||
.catch((e) => {
|
||||
console.error(e);
|
||||
sendWebSocket(
|
||||
"send-command-notification",
|
||||
{
|
||||
success: false,
|
||||
message: `ระบบออกคำสั่งเลขที่ ${command.commandNo}/${command.commandYear + 543} ผิดพลาด`,
|
||||
payload: command,
|
||||
},
|
||||
{ userId: user.sub ?? "" },
|
||||
).catch(console.error);
|
||||
if(user){
|
||||
sendWebSocket(
|
||||
"send-command-notification",
|
||||
{
|
||||
success: false,
|
||||
message: `ระบบออกคำสั่งเลขที่ ${command.commandNo}/${command.commandYear + 543} ผิดพลาด`,
|
||||
payload: command,
|
||||
},
|
||||
{ userId: user?.sub},
|
||||
).catch(console.error);
|
||||
}
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue