filter รักษาการ
This commit is contained in:
parent
d9a92eda9d
commit
3ae17c23e2
3 changed files with 52 additions and 80 deletions
|
|
@ -23,24 +23,13 @@ import { OrgChild2 } from "../entities/OrgChild2";
|
|||
import { OrgChild3 } from "../entities/OrgChild3";
|
||||
import { OrgChild4 } from "../entities/OrgChild4";
|
||||
import { PosMaster } from "../entities/PosMaster";
|
||||
import { Position } from "../entities/Position";
|
||||
import { Profile } from "../entities/Profile";
|
||||
import { RequestWithUser } from "../middlewares/user";
|
||||
import permission from "../interfaces/permission";
|
||||
import { PermissionOrg } from "../entities/PermissionOrg";
|
||||
import { checkQueueInProgress, setLogDataDiff } from "../interfaces/utils";
|
||||
import { setLogDataDiff } from "../interfaces/utils";
|
||||
import { sendToQueueOrg, sendToQueueOrgDraft } from "../services/rabbitmq";
|
||||
import { PosMasterAssign } from "../entities/PosMasterAssign";
|
||||
import { PosMasterAct } from "../entities/PosMasterAct";
|
||||
import { EmployeePosition } from "../entities/EmployeePosition";
|
||||
import { EmployeePosMaster } from "../entities/EmployeePosMaster";
|
||||
import { EmployeeTempPosMaster } from "../entities/EmployeeTempPosMaster";
|
||||
import { AuthRole } from "../entities/AuthRole";
|
||||
import { PosType } from "../entities/PosType";
|
||||
import { PosLevel } from "../entities/PosLevel";
|
||||
import { promisify } from "util";
|
||||
const REDIS_HOST = process.env.REDIS_HOST;
|
||||
const REDIS_PORT = process.env.REDIS_PORT;
|
||||
|
||||
@Route("api/v1/org")
|
||||
@Tags("Organization")
|
||||
|
|
@ -51,23 +40,15 @@ const REDIS_PORT = process.env.REDIS_PORT;
|
|||
)
|
||||
export class OrganizationController extends Controller {
|
||||
private orgRevisionRepository = AppDataSource.getRepository(OrgRevision);
|
||||
private permissionOrgRepository = AppDataSource.getRepository(PermissionOrg);
|
||||
private orgRootRepository = AppDataSource.getRepository(OrgRoot);
|
||||
private child1Repository = AppDataSource.getRepository(OrgChild1);
|
||||
private child2Repository = AppDataSource.getRepository(OrgChild2);
|
||||
private child3Repository = AppDataSource.getRepository(OrgChild3);
|
||||
private child4Repository = AppDataSource.getRepository(OrgChild4);
|
||||
private posMasterRepository = AppDataSource.getRepository(PosMaster);
|
||||
private posMasterActRepository = AppDataSource.getRepository(PosMasterAct);
|
||||
private posMasterAssignRepository = AppDataSource.getRepository(PosMasterAssign);
|
||||
private positionRepository = AppDataSource.getRepository(Position);
|
||||
private profileRepo = AppDataSource.getRepository(Profile);
|
||||
private employeePosMasterRepository = AppDataSource.getRepository(EmployeePosMaster);
|
||||
private employeePositionRepository = AppDataSource.getRepository(EmployeePosition);
|
||||
private employeeTempPosMasterRepository = AppDataSource.getRepository(EmployeeTempPosMaster);
|
||||
private posTypeRepository = AppDataSource.getRepository(PosType);
|
||||
private posLevelRepository = AppDataSource.getRepository(PosLevel);
|
||||
private redis = require("redis");
|
||||
|
||||
/**
|
||||
* API ล้างข้อมูล
|
||||
|
|
@ -187,7 +168,7 @@ export class OrganizationController extends Controller {
|
|||
}
|
||||
return new HttpError(
|
||||
HttpStatusCode.INTERNAL_SERVER_ERROR,
|
||||
"Failed to process the draft. Please try again later."
|
||||
"Failed to process the draft. Please try again later.",
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -3225,30 +3206,25 @@ export class OrganizationController extends Controller {
|
|||
*/
|
||||
@Get("get/publish")
|
||||
async runPublish(@Request() request: RequestWithUser) {
|
||||
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,
|
||||
// "ไม่สามารถดำเนินการได้ หากกำลังเผยแพร่หรือสร้างแบบร่างโครงสร้างหน่วยงาน",
|
||||
// );
|
||||
// }
|
||||
|
||||
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 today = new Date();
|
||||
today.setHours(0, 0, 0, 0); // Set time to the beginning of the day
|
||||
const orgRevisionPublish = await this.orgRevisionRepository
|
||||
.createQueryBuilder("orgRevision")
|
||||
.where("orgRevision.orgRevisionIsDraft = false")
|
||||
.andWhere("orgRevision.orgRevisionIsCurrent = true")
|
||||
.getOne();
|
||||
|
||||
const orgRevisionDraft = await this.orgRevisionRepository
|
||||
.createQueryBuilder("orgRevision")
|
||||
|
|
@ -3287,7 +3263,7 @@ export class OrganizationController extends Controller {
|
|||
}
|
||||
return new HttpError(
|
||||
HttpStatusCode.INTERNAL_SERVER_ERROR,
|
||||
"Failed to process the publish. Please try again later."
|
||||
"Failed to process the publish. Please try again later.",
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -3301,12 +3277,6 @@ export class OrganizationController extends Controller {
|
|||
const tomorrow = new Date(today);
|
||||
tomorrow.setDate(tomorrow.getDate() + 1);
|
||||
|
||||
const orgRevisionPublish = await this.orgRevisionRepository
|
||||
.createQueryBuilder("orgRevision")
|
||||
.where("orgRevision.orgRevisionIsDraft = false")
|
||||
.andWhere("orgRevision.orgRevisionIsCurrent = true")
|
||||
.getOne();
|
||||
|
||||
const orgRevisionDraft = await this.orgRevisionRepository
|
||||
.createQueryBuilder("orgRevision")
|
||||
.where("orgRevision.orgRevisionIsDraft = true")
|
||||
|
|
@ -7563,6 +7533,8 @@ export class OrganizationController extends Controller {
|
|||
orgRoot: { isCommission: true },
|
||||
isDirector: true,
|
||||
current_holderId: Not(IsNull()),
|
||||
posMasterActs: { statusReport: "DONE" },
|
||||
posMasterActChilds: { statusReport: "DONE" },
|
||||
},
|
||||
order: { posMasterOrder: "ASC", posMasterActChilds: { posMasterOrder: "ASC" } },
|
||||
relations: [
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue