Fix ออกคำสั่งแต่รูปภาพไม่เพิ่ม + เพิ่มสิทธิ์แสดงรายชื่อลูกจ้างประจำตามสิทธิ์เจ้่าหน้าที่
This commit is contained in:
parent
9cda6e176e
commit
23aeb8864a
3 changed files with 147 additions and 15 deletions
|
|
@ -190,10 +190,103 @@ export class OrganizationDotnetController extends Controller {
|
|||
citizenId?: string | null;
|
||||
firstName?: string | null;
|
||||
lastName?: string | null;
|
||||
role?: string | null;
|
||||
nodeId?: string | null;
|
||||
node?: number | null;
|
||||
},
|
||||
) {
|
||||
const profileRepository = AppDataSource.getRepository(ProfileEmployee);
|
||||
const queryBuilder = profileRepository
|
||||
// const profileRepository = AppDataSource.getRepository(ProfileEmployee);
|
||||
// const queryBuilder = profileRepository
|
||||
// .createQueryBuilder("profile")
|
||||
// .leftJoinAndSelect("profile.posLevel", "posLevel")
|
||||
// .leftJoinAndSelect("profile.posType", "posType")
|
||||
// .leftJoinAndSelect("profile.profileSalary", "profileSalary")
|
||||
// .leftJoinAndSelect("profile.current_holders", "current_holders")
|
||||
// .leftJoinAndSelect("current_holders.orgRoot", "orgRoot")
|
||||
// .leftJoinAndSelect("current_holders.orgChild1", "orgChild1")
|
||||
// .leftJoinAndSelect("current_holders.orgChild2", "orgChild2")
|
||||
// .leftJoinAndSelect("current_holders.orgChild3", "orgChild3")
|
||||
// .leftJoinAndSelect("current_holders.orgChild4", "orgChild4")
|
||||
// .orderBy("profileSalary.order", "DESC");
|
||||
|
||||
// if (body.citizenId || body.firstName || body.lastName) {
|
||||
// queryBuilder.where(
|
||||
// new Brackets((qb) => {
|
||||
// if (body.citizenId) {
|
||||
// qb.orWhere("profile.citizenId LIKE :citizenId", { citizenId: `%${body.citizenId}%` });
|
||||
// }
|
||||
// if (body.firstName) {
|
||||
// qb.orWhere("profile.firstName LIKE :firstName", { firstName: `%${body.firstName}%` });
|
||||
// }
|
||||
// if (body.lastName) {
|
||||
// qb.orWhere("profile.lastName LIKE :lastName", { lastName: `%${body.lastName}%` });
|
||||
// }
|
||||
// }),
|
||||
// );
|
||||
// }
|
||||
|
||||
// const profileEmp = await queryBuilder.getMany();
|
||||
|
||||
let condition = "1=1";
|
||||
let conditionParams = {};
|
||||
if (body.role === "CHILD") {
|
||||
switch (body.node) {
|
||||
case 0:
|
||||
condition = "orgRoot.ancestorDNA = :nodeId";
|
||||
break;
|
||||
case 1:
|
||||
condition = "orgChild1.ancestorDNA = :nodeId";
|
||||
break;
|
||||
case 2:
|
||||
condition = "orgChild2.ancestorDNA = :nodeId";
|
||||
break;
|
||||
case 3:
|
||||
condition = "orgChild3.ancestorDNA = :nodeId";
|
||||
break;
|
||||
case 4:
|
||||
condition = "orgChild4.ancestorDNA = :nodeId";
|
||||
break;
|
||||
default:
|
||||
condition = "1=1";
|
||||
break;
|
||||
}
|
||||
conditionParams = { nodeId: body.nodeId };
|
||||
}
|
||||
else if (body.role === "ROOT") {
|
||||
condition = "orgRoot.ancestorDNA = :nodeId";
|
||||
conditionParams = { nodeId: body.nodeId };
|
||||
}
|
||||
else if (body.role === "NORMAL") {
|
||||
switch (body.node) {
|
||||
case 0:
|
||||
condition = "orgRoot.ancestorDNA = :nodeId AND current_holders.orgChild1 IS NULL";
|
||||
break;
|
||||
case 1:
|
||||
condition = "orgChild1.ancestorDNA = :nodeId AND current_holders.orgChild2 IS NULL";
|
||||
break;
|
||||
case 2:
|
||||
condition = "orgChild2.ancestorDNA = :nodeId AND current_holders.orgChild3 IS NULL";
|
||||
break;
|
||||
case 3:
|
||||
condition = "orgChild3.ancestorDNA = :nodeId AND current_holders.orgChild4 IS NULL";
|
||||
break;
|
||||
case 4:
|
||||
condition = "orgChild4.ancestorDNA = :nodeId";
|
||||
break;
|
||||
default:
|
||||
condition = "1=1";
|
||||
break;
|
||||
}
|
||||
conditionParams = { nodeId: body.nodeId };
|
||||
}
|
||||
|
||||
const findRevision = await this.orgRevisionRepo.findOne({
|
||||
where: { orgRevisionIsCurrent: true },
|
||||
});
|
||||
if (!findRevision) {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "not found. OrgRevision");
|
||||
}
|
||||
const profileEmp = await this.profileEmpRepo
|
||||
.createQueryBuilder("profile")
|
||||
.leftJoinAndSelect("profile.posLevel", "posLevel")
|
||||
.leftJoinAndSelect("profile.posType", "posType")
|
||||
|
|
@ -204,10 +297,8 @@ export class OrganizationDotnetController extends Controller {
|
|||
.leftJoinAndSelect("current_holders.orgChild2", "orgChild2")
|
||||
.leftJoinAndSelect("current_holders.orgChild3", "orgChild3")
|
||||
.leftJoinAndSelect("current_holders.orgChild4", "orgChild4")
|
||||
.orderBy("profileSalary.order", "DESC");
|
||||
|
||||
if (body.citizenId || body.firstName || body.lastName) {
|
||||
queryBuilder.where(
|
||||
.where("current_holders.orgRevisionId = :orgRevisionId", { orgRevisionId: findRevision.id })
|
||||
.andWhere(
|
||||
new Brackets((qb) => {
|
||||
if (body.citizenId) {
|
||||
qb.orWhere("profile.citizenId LIKE :citizenId", { citizenId: `%${body.citizenId}%` });
|
||||
|
|
@ -219,14 +310,10 @@ export class OrganizationDotnetController extends Controller {
|
|||
qb.orWhere("profile.lastName LIKE :lastName", { lastName: `%${body.lastName}%` });
|
||||
}
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
const profileEmp = await queryBuilder.getMany();
|
||||
|
||||
const findRevision = await this.orgRevisionRepo.findOne({
|
||||
where: { orgRevisionIsCurrent: true },
|
||||
});
|
||||
)
|
||||
.andWhere(condition, conditionParams)
|
||||
.orderBy("profileSalary.order", "DESC")
|
||||
.getMany()
|
||||
|
||||
const profileEmp_ = await Promise.all(
|
||||
profileEmp.map((item: ProfileEmployee) => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue