fixed performance function GetOfficersByAdminRoleV3
All checks were successful
Build & Deploy on Dev / build (push) Successful in 1m6s
All checks were successful
Build & Deploy on Dev / build (push) Successful in 1m6s
This commit is contained in:
parent
362515a7ca
commit
0ba5e36a4f
1 changed files with 53 additions and 32 deletions
|
|
@ -8593,13 +8593,29 @@ export class OrganizationDotnetController extends Controller {
|
||||||
where: {
|
where: {
|
||||||
...typeCondition,
|
...typeCondition,
|
||||||
createdAt: LessThanOrEqual(date),
|
createdAt: LessThanOrEqual(date),
|
||||||
// firstName: Not("") && Not(IsNull()),
|
|
||||||
// lastName: Not("") && Not(IsNull()),
|
|
||||||
},
|
},
|
||||||
|
select: [
|
||||||
|
"profileId",
|
||||||
|
"prefix",
|
||||||
|
"firstName",
|
||||||
|
"lastName",
|
||||||
|
"shortName",
|
||||||
|
"posMasterNo",
|
||||||
|
"position",
|
||||||
|
"posType",
|
||||||
|
"posLevel",
|
||||||
|
"ancestorDNA",
|
||||||
|
"rootDnaId",
|
||||||
|
"child1DnaId",
|
||||||
|
"child2DnaId",
|
||||||
|
"child3DnaId",
|
||||||
|
"child4DnaId",
|
||||||
|
"createdAt",
|
||||||
|
],
|
||||||
order: {
|
order: {
|
||||||
firstName: "ASC",
|
firstName: "ASC",
|
||||||
lastName: "ASC",
|
lastName: "ASC",
|
||||||
createdAt: "DESC", // ให้ createdAt ล่าสุดอยู่ข้างบน
|
createdAt: "DESC",
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -8646,36 +8662,41 @@ export class OrganizationDotnetController extends Controller {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const profile_ = await Promise.all(
|
const profileIds = Array.from(grouped3.values())
|
||||||
Array.from(grouped3.values())
|
.filter((x) => x.profileId != null)
|
||||||
.filter((x) => x.profileId != null)
|
.map((x) => x.profileId);
|
||||||
.map(async (item: PosMasterHistory) => {
|
|
||||||
let profile = await this.profileRepo.findOne({
|
|
||||||
where: { id: item.profileId },
|
|
||||||
});
|
|
||||||
|
|
||||||
return {
|
const profiles = await this.profileRepo.find({
|
||||||
id: item.profileId,
|
where: { id: In(profileIds) },
|
||||||
prefix: item.prefix,
|
select: ["id", "citizenId", "dateStart", "dateAppoint", "keycloak"],
|
||||||
firstName: item.firstName,
|
});
|
||||||
lastName: item.lastName,
|
|
||||||
citizenId: profile?.citizenId ?? null,
|
const profileMap = new Map(profiles.map((p) => [p.id, p]));
|
||||||
dateStart: profile?.dateStart ?? null,
|
|
||||||
dateAppoint: profile?.dateAppoint ?? null,
|
const profile_ = Array.from(grouped3.values())
|
||||||
keycloak: profile?.keycloak ?? null,
|
.filter((x) => x.profileId != null)
|
||||||
posNo: `${item.shortName} ${item.posMasterNo}`,
|
.map((item: PosMasterHistory) => {
|
||||||
position: item.position,
|
const profile = profileMap.get(item.profileId);
|
||||||
positionLevel: item.posLevel,
|
return {
|
||||||
positionType: item.posType,
|
id: item.profileId,
|
||||||
// oc: Oc,
|
prefix: item.prefix,
|
||||||
orgRootId: item.rootDnaId,
|
firstName: item.firstName,
|
||||||
orgChild1Id: item.child1DnaId,
|
lastName: item.lastName,
|
||||||
orgChild2Id: item.child2DnaId,
|
citizenId: profile?.citizenId ?? null,
|
||||||
orgChild3Id: item.child3DnaId,
|
dateStart: profile?.dateStart ?? null,
|
||||||
orgChild4Id: item.child4DnaId,
|
dateAppoint: profile?.dateAppoint ?? null,
|
||||||
};
|
keycloak: profile?.keycloak ?? null,
|
||||||
}),
|
posNo: `${item.shortName} ${item.posMasterNo}`,
|
||||||
);
|
position: item.position,
|
||||||
|
positionLevel: item.posLevel,
|
||||||
|
positionType: item.posType,
|
||||||
|
orgRootId: item.rootDnaId,
|
||||||
|
orgChild1Id: item.child1DnaId,
|
||||||
|
orgChild2Id: item.child2DnaId,
|
||||||
|
orgChild3Id: item.child3DnaId,
|
||||||
|
orgChild4Id: item.child4DnaId,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
return new HttpSuccess(
|
return new HttpSuccess(
|
||||||
(profile_ ?? []).sort((a, b) => a.posNo.localeCompare(b.posNo, undefined, { numeric: true })),
|
(profile_ ?? []).sort((a, b) => a.posNo.localeCompare(b.posNo, undefined, { numeric: true })),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue