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