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