From 3ac035d5e0caf342b8651da21f13edb4ee1fa43d Mon Sep 17 00:00:00 2001 From: Bright Date: Thu, 19 Jun 2025 12:10:05 +0700 Subject: [PATCH] =?UTF-8?q?Fix=20[Invalid=20KPI]=20=E0=B8=94=E0=B8=B6?= =?UTF-8?q?=E0=B8=87=E0=B8=82=E0=B9=89=E0=B8=AD=E0=B8=A1=E0=B8=B9=E0=B8=A5?= =?UTF-8?q?=E0=B8=81=E0=B8=B2=E0=B8=A3=E0=B8=A3=E0=B8=B1=E0=B8=81=E0=B8=A9?= =?UTF-8?q?=E0=B8=B2=E0=B8=81=E0=B8=B2=E0=B8=A3=20=E0=B8=95=E0=B9=89?= =?UTF-8?q?=E0=B8=AD=E0=B8=87=E0=B8=94=E0=B8=B6=E0=B8=87=E0=B8=A1=E0=B8=B2?= =?UTF-8?q?=E0=B8=88=E0=B8=B2=E0=B8=81=E0=B9=83=E0=B8=99=E0=B8=A3=E0=B8=B2?= =?UTF-8?q?=E0=B8=A2=E0=B8=81=E0=B8=B2=E0=B8=A3=E0=B8=A3=E0=B8=B1=E0=B8=81?= =?UTF-8?q?=E0=B8=A9=E0=B8=B2=E0=B8=81=E0=B8=B2=E0=B8=A3=E0=B9=83=E0=B8=99?= =?UTF-8?q?=20=E0=B8=97=E0=B8=B0=E0=B9=80=E0=B8=9A=E0=B8=B5=E0=B8=A2?= =?UTF-8?q?=E0=B8=99=E0=B8=9B=E0=B8=A3=E0=B8=B0=E0=B8=A7=E0=B8=B1=E0=B8=95?= =?UTF-8?q?=E0=B8=B4=E0=B8=97=E0=B8=B5=E0=B9=88=E0=B9=83=E0=B8=8A=E0=B9=89?= =?UTF-8?q?=E0=B8=87=E0=B8=B2=E0=B8=99=E0=B8=AD=E0=B8=A2=E0=B8=B9=E0=B9=88?= =?UTF-8?q?=20#132?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/ProfileController.ts | 119 ++++++++++++++++----------- 1 file changed, 71 insertions(+), 48 deletions(-) diff --git a/src/controllers/ProfileController.ts b/src/controllers/ProfileController.ts index 0f775d6f..780b2153 100644 --- a/src/controllers/ProfileController.ts +++ b/src/controllers/ProfileController.ts @@ -7649,6 +7649,7 @@ export class ProfileController extends Controller { "current_holders.orgChild4", "profileSalary", "profileEducations", + "profileActpositions" ], order: { // profileSalary: { @@ -7657,6 +7658,9 @@ export class ProfileController extends Controller { profileEducations: { level: "ASC", }, + profileActpositions: { + createdAt: "ASC" + } }, }); if (!profile) { @@ -7740,57 +7744,76 @@ export class ProfileController extends Controller { ?.orgRoot != null ? `${profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgRoot.orgRootShortName} ${profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.posMasterNo}` : null; - const posMasterActs = await this.posMasterActRepository.find({ - relations: [ - "posMaster", - "posMaster.orgRoot", - "posMaster.orgChild1", - "posMaster.orgChild2", - "posMaster.orgChild3", - "posMaster.orgChild4", - "posMaster.current_holder", - "posMaster.current_holder.posLevel", - "posMaster.current_holder.posType", - ], - where: { - posMaster: { - orgRevisionId: orgRevisionPublish.id, - }, - posMasterChild: { - current_holderId: profile.id, - }, - }, - }); + // const posMasterActs = await this.posMasterActRepository.find({ + // relations: [ + // "posMaster", + // "posMaster.orgRoot", + // "posMaster.orgChild1", + // "posMaster.orgChild2", + // "posMaster.orgChild3", + // "posMaster.orgChild4", + // "posMaster.current_holder", + // "posMaster.current_holder.posLevel", + // "posMaster.current_holder.posType", + // ], + // where: { + // posMaster: { + // orgRevisionId: orgRevisionPublish.id, + // }, + // posMasterChild: { + // current_holderId: profile.id, + // }, + // }, + // }); + // const data = await Promise.all( + // posMasterActs + // .sort((a, b) => a.posMaster.posMasterOrder - b.posMaster.posMasterOrder) + // .map((item) => { + // const shortName = + // item.posMaster != null && item.posMaster.orgChild4 != null + // ? `${item.posMaster.orgChild4.orgChild4ShortName} ${item.posMaster.posMasterNo}` + // : item.posMaster != null && item.posMaster?.orgChild3 != null + // ? `${item.posMaster.orgChild3.orgChild3ShortName} ${item.posMaster.posMasterNo}` + // : item.posMaster != null && item.posMaster?.orgChild2 != null + // ? `${item.posMaster.orgChild2.orgChild2ShortName} ${item.posMaster.posMasterNo}` + // : item.posMaster != null && item.posMaster?.orgChild1 != null + // ? `${item.posMaster.orgChild1.orgChild1ShortName} ${item.posMaster.posMasterNo}` + // : item.posMaster != null && item.posMaster?.orgRoot != null + // ? `${item.posMaster.orgRoot.orgRootShortName} ${item.posMaster.posMasterNo}` + // : null; + // return { + // id: item.id, + // posMasterOrder: item.posMasterOrder, + // profileId: item.posMaster?.current_holder?.id ?? null, + // citizenId: item.posMaster?.current_holder?.citizenId ?? null, + // prefix: item.posMaster?.current_holder?.prefix ?? null, + // firstName: item.posMaster?.current_holder?.firstName ?? null, + // lastName: item.posMaster?.current_holder?.lastName ?? null, + // posLevel: item.posMaster?.current_holder?.posLevel?.posLevelName ?? null, + // posType: item.posMaster?.current_holder?.posType?.posTypeName ?? null, + // position: item.posMaster?.current_holder?.position ?? null, + // posNo: shortName, + // }; + // }), + // ); const data = await Promise.all( - posMasterActs - .sort((a, b) => a.posMaster.posMasterOrder - b.posMaster.posMasterOrder) - .map((item) => { - const shortName = - item.posMaster != null && item.posMaster.orgChild4 != null - ? `${item.posMaster.orgChild4.orgChild4ShortName} ${item.posMaster.posMasterNo}` - : item.posMaster != null && item.posMaster?.orgChild3 != null - ? `${item.posMaster.orgChild3.orgChild3ShortName} ${item.posMaster.posMasterNo}` - : item.posMaster != null && item.posMaster?.orgChild2 != null - ? `${item.posMaster.orgChild2.orgChild2ShortName} ${item.posMaster.posMasterNo}` - : item.posMaster != null && item.posMaster?.orgChild1 != null - ? `${item.posMaster.orgChild1.orgChild1ShortName} ${item.posMaster.posMasterNo}` - : item.posMaster != null && item.posMaster?.orgRoot != null - ? `${item.posMaster.orgRoot.orgRootShortName} ${item.posMaster.posMasterNo}` - : null; + profile.profileActpositions + .filter(x => x.status) + .map((item, idx) => { return { id: item.id, - posMasterOrder: item.posMasterOrder, - profileId: item.posMaster?.current_holder?.id ?? null, - citizenId: item.posMaster?.current_holder?.citizenId ?? null, - prefix: item.posMaster?.current_holder?.prefix ?? null, - firstName: item.posMaster?.current_holder?.firstName ?? null, - lastName: item.posMaster?.current_holder?.lastName ?? null, - posLevel: item.posMaster?.current_holder?.posLevel?.posLevelName ?? null, - posType: item.posMaster?.current_holder?.posType?.posTypeName ?? null, - position: item.posMaster?.current_holder?.position ?? null, - posNo: shortName, - }; - }), + posMasterOrder: idx+1, + profileId: item.profileId ?? null, + citizenId: profile.citizenId ?? null, + prefix: profile.prefix ?? null, + firstName: profile.firstName ?? null, + lastName: profile.lastName ?? null, + posLevel: profile.posLevel.posLevelName ?? null, + posType: profile.posType.posTypeName ?? null, + position: item.position ?? null, + posNo: item.posNo ?? null, + } + }) ); const permissionProflile = await this.permissionProflileRepository.findOne({ relations: ["orgRootTree"],