Merge branch 'develop' of github.com:Frappet/bma-ehr-organization into develop
This commit is contained in:
commit
3c9698f606
3 changed files with 10 additions and 23 deletions
|
|
@ -5782,6 +5782,7 @@ export class ProfileController extends Controller {
|
|||
child4ShortName: child4 == null ? null : child4.orgChild4ShortName,
|
||||
node: null,
|
||||
nodeId: null,
|
||||
salary: profile.amount,
|
||||
education:
|
||||
profile && profile.profileEducations.length > 0
|
||||
? `${profile.profileEducations[0].degree ?? ""}/${profile.profileEducations[0].field ?? ""}`
|
||||
|
|
|
|||
|
|
@ -3758,6 +3758,7 @@ export class ProfileEmployeeTempController extends Controller {
|
|||
node: null,
|
||||
nodeId: null,
|
||||
posNo: shortName,
|
||||
salary: profile.amount,
|
||||
education:
|
||||
profile && profile.profileEducations.length > 0
|
||||
? `${profile.profileEducations[0].degree ?? ""}/${profile.profileEducations[0].field ?? ""}`
|
||||
|
|
|
|||
|
|
@ -19,15 +19,15 @@ export async function init() {
|
|||
|
||||
const connection = await amqp.connect(url); //----> (1.3) set up url with amqp protocol
|
||||
|
||||
console.log(connection ? "[AMQ] connection success" : "[AMQ] connection failed");
|
||||
console.log(connection ? "[AMQ] Connection success" : "[AMQ] Connection failed");
|
||||
|
||||
const channel = await connection.createChannel(); //----> (1.4) create Channel
|
||||
|
||||
console.log(channel ? "[AMQ] create channel success" : "[AMQ] create channel failed");
|
||||
console.log(channel ? "[AMQ] Create channel success" : "[AMQ] Create channel failed");
|
||||
|
||||
channel.assertQueue(queue, { durable: true }); //----> (1.5) assert queue and set durable (if "true" save to disk on RabbitMQ)
|
||||
channel.assertQueue(queue_org, { durable: true });
|
||||
channel.prefetch(1);
|
||||
channel.prefetch(1);
|
||||
|
||||
sendToQueue = (payload: any, persistent = true) => {
|
||||
//----> (2) sendQueue To RabbitMQ and set persistent (if "true" redo the failed queue when server run again)
|
||||
|
|
@ -42,8 +42,8 @@ export async function init() {
|
|||
|
||||
console.log("[AMQ] Listening for message...");
|
||||
|
||||
createConsumer(queue, channel, handler); //----> (3) Process Consumer
|
||||
createConsumer(queue_org, channel, handler_org);
|
||||
await createConsumer(queue, channel, handler); //----> (3) Process Consumer
|
||||
await createConsumer(queue_org, channel, handler_org);
|
||||
// createConsumer(queue2, channel, handler2);
|
||||
}
|
||||
|
||||
|
|
@ -58,14 +58,12 @@ function createConsumer( //----> consumer
|
|||
queue,
|
||||
async (msg) => {
|
||||
if (!msg) return;
|
||||
console.log("[AMQ] on on create consumer");
|
||||
|
||||
if ((await handler(msg)) || retries++ >= 3) {
|
||||
retries = 0;
|
||||
console.log("[AMQ] process consumer success");
|
||||
console.log("[AMQ] Process consumer success");
|
||||
return channel.ack(msg);
|
||||
}
|
||||
console.log("[AMQ] process consumer fail");
|
||||
console.log("[AMQ] Process consumer fail");
|
||||
return await new Promise((resolve) => setTimeout(() => resolve(channel.nack(msg)), 3000));
|
||||
},
|
||||
{ noAck: false },
|
||||
|
|
@ -73,31 +71,18 @@ function createConsumer( //----> consumer
|
|||
}
|
||||
|
||||
async function handler(msg: amqp.ConsumeMessage): Promise<boolean> {
|
||||
console.log(msg ? "[AMQ] on handler" : "[AMQ] don't handler");
|
||||
console.log(msg ? "[AMQ] On handler" : "[AMQ] Not handler");
|
||||
//----> condition before process consumer
|
||||
const repo = AppDataSource.getRepository(Command);
|
||||
const { data, token, user } = JSON.parse(msg.content.toString());
|
||||
|
||||
console.log(repo ? "[AMQ] have repo" : "[AMQ] don't have repo");
|
||||
|
||||
const { id, status, lastUpdateUserId, lastUpdateFullName, lastUpdatedAt } = data;
|
||||
|
||||
console.log(data ? "[AMQ] have data" : "[AMQ] don't have data");
|
||||
|
||||
const command = await repo.findOne({
|
||||
where: { id: id },
|
||||
relations: ["commandType", "commandRecives"],
|
||||
});
|
||||
|
||||
console.log(command ? "[AMQ] have command" : "[AMQ] don't have command");
|
||||
|
||||
if (!command) return true;
|
||||
|
||||
const path = commandTypePath(command.commandType.code);
|
||||
if (path == null) throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบประเภทคำสั่งนี้ในระบบ");
|
||||
|
||||
console.log(path ? "[AMQ] have path" : "[AMQ] don't have path");
|
||||
|
||||
return await new CallAPI()
|
||||
.PostData(
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue