หา สกก1

This commit is contained in:
mamoss 2025-09-15 16:24:07 +07:00
parent 9b785cc119
commit b90e4114a8

View file

@ -163,7 +163,7 @@ export class OrganizationController extends Controller {
await sendToQueueOrgDraft(msg);
return new HttpSuccess("Draft is being created... Processing in the background.");
} catch (error: any) {
throw error;
throw error;
}
}
@ -3203,19 +3203,19 @@ export class OrganizationController extends Controller {
try {
// CheckQueueInProgress
// console.log("🚀 ตรวจสอบว่ามีงานอยู่ในคิว");
const [isBusyDraft, isBusyPublish] = await Promise.all([
checkQueueInProgress(`${process.env.AMQ_QUEUE_ORG_DRAFT}`),
checkQueueInProgress(`${process.env.AMQ_QUEUE_ORG}`),
]);
// console.log("✅ ตรวจสอบแล้ว Draft Busy:", isBusyDraft);
// console.log("✅ ตรวจสอบแล้ว Publish Busy:", isBusyPublish);
if (isBusyDraft || isBusyPublish) {
// console.log("🚫 พบว่ามีงานอยู่ในคิว — error")
throw new HttpError(
HttpStatusCode.CONFLICT,
"ไม่สามารถดำเนินการได้ หากกำลังเผยแพร่หรือสร้างแบบร่างโครงสร้างหน่วยงาน",
);
}
const [isBusyDraft, isBusyPublish] = await Promise.all([
checkQueueInProgress(`${process.env.AMQ_QUEUE_ORG_DRAFT}`),
checkQueueInProgress(`${process.env.AMQ_QUEUE_ORG}`),
]);
// console.log("✅ ตรวจสอบแล้ว Draft Busy:", isBusyDraft);
// console.log("✅ ตรวจสอบแล้ว Publish Busy:", isBusyPublish);
if (isBusyDraft || isBusyPublish) {
// console.log("🚫 พบว่ามีงานอยู่ในคิว — error")
throw new HttpError(
HttpStatusCode.CONFLICT,
"ไม่สามารถดำเนินการได้ หากกำลังเผยแพร่หรือสร้างแบบร่างโครงสร้างหน่วยงาน",
);
}
const today = new Date();
today.setHours(0, 0, 0, 0); // Set time to the beginning of the day
@ -3252,7 +3252,7 @@ export class OrganizationController extends Controller {
await sendToQueueOrg(msg);
return new HttpSuccess();
} catch (error: any) {
throw error;
throw error;
}
}
@ -7723,17 +7723,18 @@ export class OrganizationController extends Controller {
where: {
orgRevision: { orgRevisionIsDraft: false, orgRevisionIsCurrent: true },
orgRoot: { isCommission: true },
orgChild1Id: IsNull(),
isDirector: true,
current_holderId: Not(IsNull()),
posMasterActs: { statusReport: "DONE" },
posMasterActChilds: { statusReport: "DONE" },
// posMasterActs: { statusReport: "DONE" },
// posMasterActChilds: { statusReport: "DONE" },
},
order: { posMasterOrder: "ASC", posMasterActChilds: { posMasterOrder: "ASC" } },
relations: [
"current_holder",
"posMasterActChilds",
"posMasterActChilds.posMasterChild",
"posMasterActChilds.posMasterChild.current_holder",
// "posMasterActChilds",
// "posMasterActChilds.posMasterChild",
// "posMasterActChilds.posMasterChild.current_holder",
],
});
if (posMaster.length <= 0) {
@ -7743,6 +7744,23 @@ export class OrganizationController extends Controller {
});
}
if (posMaster[0].current_holder == null) {
const posMaster = await this.posMasterRepository.find({
where: {
orgRevision: { orgRevisionIsDraft: false, orgRevisionIsCurrent: true },
orgRoot: { isCommission: true },
orgChild1Id: IsNull(),
isDirector: true,
posMasterActs: { statusReport: "DONE" },
posMasterActChilds: { statusReport: "DONE" },
},
order: { posMasterOrder: "ASC", posMasterActChilds: { posMasterOrder: "ASC" } },
relations: [
"current_holder",
"posMasterActChilds",
"posMasterActChilds.posMasterChild",
"posMasterActChilds.posMasterChild.current_holder",
],
});
if (
posMaster[0].posMasterActChilds.length <= 0 ||
posMaster[0].posMasterActChilds[0].posMasterChild == null ||