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: [
|
||||
|
|
|
|||
|
|
@ -4554,7 +4554,7 @@ export class PositionController extends Controller {
|
|||
) {
|
||||
await new permission().PermissionGet(request, "SYS_ACTING");
|
||||
const posMasterMain = await this.posMasterRepository.findOne({
|
||||
where: { id: body.posmasterId },
|
||||
where: { id: body.posmasterId, posMasterActs: { statusReport: "DONE" } },
|
||||
relations: ["posMasterActs"],
|
||||
});
|
||||
if (posMasterMain == null) {
|
||||
|
|
@ -5050,19 +5050,21 @@ export class PositionController extends Controller {
|
|||
: `CASE WHEN posMaster.orgChild1 is null THEN ${searchShortName0} WHEN posMaster.orgChild2 is null THEN ${searchShortName1} WHEN posMaster.orgChild3 is null THEN ${searchShortName2} WHEN posMaster.orgChild4 is null THEN ${searchShortName3} ELSE ${searchShortName4} END LIKE '%${body.keyword}%'`
|
||||
: "1=1",
|
||||
)
|
||||
.andWhere(checkChildConditions)
|
||||
.andWhere(typeCondition)
|
||||
.andWhere(revisionCondition)
|
||||
.andWhere({ current_holderId: IsNull() });
|
||||
.andWhere(checkChildConditions)
|
||||
.andWhere(typeCondition)
|
||||
.andWhere(revisionCondition)
|
||||
.andWhere({ current_holderId: IsNull() });
|
||||
}),
|
||||
)
|
||||
.orWhere(
|
||||
new Brackets((qb) => {
|
||||
qb.andWhere(`posMaster.conditionReason LIKE '%${body.keyword}%' AND posMaster.conditionReason IS NOT NULL`)
|
||||
.andWhere(checkChildConditions)
|
||||
.andWhere(typeCondition)
|
||||
.andWhere(revisionCondition)
|
||||
.andWhere({ current_holderId: IsNull() });
|
||||
qb.andWhere(
|
||||
`posMaster.conditionReason LIKE '%${body.keyword}%' AND posMaster.conditionReason IS NOT NULL`,
|
||||
)
|
||||
.andWhere(checkChildConditions)
|
||||
.andWhere(typeCondition)
|
||||
.andWhere(revisionCondition)
|
||||
.andWhere({ current_holderId: IsNull() });
|
||||
}),
|
||||
)
|
||||
.orderBy("orgRoot.orgRootOrder", "ASC")
|
||||
|
|
|
|||
|
|
@ -1178,7 +1178,9 @@ export class ProfileController extends Controller {
|
|||
salary:
|
||||
item.amount != null ? Extension.ToThaiNumber(item.amount.toLocaleString()) : null,
|
||||
special:
|
||||
item.amountSpecial != null ? Extension.ToThaiNumber(item.amountSpecial.toLocaleString()) : null,
|
||||
item.amountSpecial != null
|
||||
? Extension.ToThaiNumber(item.amountSpecial.toLocaleString())
|
||||
: null,
|
||||
rank: item.positionLevel != null ? Extension.ToThaiNumber(item.positionLevel) : null,
|
||||
refAll: item.remark ? Extension.ToThaiNumber(item.remark) : null,
|
||||
positionLevel: item.positionLevel
|
||||
|
|
@ -7667,7 +7669,7 @@ export class ProfileController extends Controller {
|
|||
"current_holders.orgChild4",
|
||||
"profileSalary",
|
||||
"profileEducations",
|
||||
"profileActpositions"
|
||||
"profileActpositions",
|
||||
],
|
||||
order: {
|
||||
// profileSalary: {
|
||||
|
|
@ -7677,8 +7679,8 @@ export class ProfileController extends Controller {
|
|||
level: "ASC",
|
||||
},
|
||||
profileActpositions: {
|
||||
createdAt: "ASC"
|
||||
}
|
||||
createdAt: "ASC",
|
||||
},
|
||||
},
|
||||
});
|
||||
if (!profile) {
|
||||
|
|
@ -7816,30 +7818,25 @@ export class ProfileController extends Controller {
|
|||
// );
|
||||
const data = await Promise.all(
|
||||
profile.profileActpositions
|
||||
.filter(x => x.status)
|
||||
.filter((x) => x.status)
|
||||
.map(async (item) => {
|
||||
const commandRef = await this.commandReciveRepository.findOne({
|
||||
where: { commandId: item.commandId }
|
||||
where: { commandId: item.commandId },
|
||||
});
|
||||
const posMasterActs = await this.posMasterActRepository.findOne({
|
||||
where: {
|
||||
where: {
|
||||
id: commandRef?.refId,
|
||||
posMaster: {
|
||||
orgRevisionId: orgRevisionPublish.id,
|
||||
}
|
||||
},
|
||||
statusReport: "DONE",
|
||||
},
|
||||
relations: [
|
||||
"posMaster",
|
||||
"posMaster.current_holder"
|
||||
],
|
||||
relations: ["posMaster", "posMaster.current_holder"],
|
||||
});
|
||||
const _profileAct = await this.profileRepo.findOne({
|
||||
where: { id: posMasterActs?.posMaster.current_holderId ?? "" },
|
||||
relations: [
|
||||
"posLevel",
|
||||
"posType"
|
||||
]
|
||||
})
|
||||
relations: ["posLevel", "posType"],
|
||||
});
|
||||
return {
|
||||
id: item.id,
|
||||
posMasterOrder: posMasterActs?.posMasterOrder,
|
||||
|
|
@ -7852,8 +7849,8 @@ export class ProfileController extends Controller {
|
|||
posType: _profileAct?.posType.posTypeName ?? null,
|
||||
position: item.position ?? null,
|
||||
posNo: item.posNo ?? null,
|
||||
}
|
||||
})
|
||||
};
|
||||
}),
|
||||
);
|
||||
const permissionProflile = await this.permissionProflileRepository.findOne({
|
||||
relations: ["orgRootTree"],
|
||||
|
|
@ -8122,7 +8119,8 @@ export class ProfileController extends Controller {
|
|||
? `${profile.profileEducations[0].degree ?? ""} ${profile.profileEducations[0].field ?? ""}`
|
||||
: "",
|
||||
dateAppoint: profile.dateAppoint,
|
||||
avatarUrl: profile.avatar && profile.avatarName ? `${profile.avatar}/${profile.avatarName}` : null
|
||||
avatarUrl:
|
||||
profile.avatar && profile.avatarName ? `${profile.avatar}/${profile.avatarName}` : null,
|
||||
};
|
||||
|
||||
if (_profile.child4Id != null) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue