diff --git a/src/controllers/OrganizationController.ts b/src/controllers/OrganizationController.ts index b1eb4544..37afc239 100644 --- a/src/controllers/OrganizationController.ts +++ b/src/controllers/OrganizationController.ts @@ -61,14 +61,8 @@ export class OrganizationController extends Controller { @Get("history") async GetHistory() { const orgRevision = await this.orgRevisionRepository.find({ - select: [ - "id", - "orgRevisionName", - "orgRevisionIsCurrent", - "orgRevisionCreatedAt", - "orgRevisionIsDraft", - ], - order: { orgRevisionCreatedAt: "DESC" }, + select: ["id", "orgRevisionName", "orgRevisionIsCurrent", "createdAt", "orgRevisionIsDraft"], + order: { createdAt: "ASC" }, }); // if (!orgRevision) { // return new HttpSuccess([]); @@ -77,7 +71,7 @@ export class OrganizationController extends Controller { orgRevisionId: revision.id, orgRevisionName: revision.orgRevisionName, orgRevisionIsCurrent: revision.orgRevisionIsCurrent, - orgRevisionCreatedAt: revision.orgRevisionCreatedAt, + orgRevisionCreatedAt: revision.createdAt, orgRevisionIsDraft: revision.orgRevisionIsDraft, })); diff --git a/src/controllers/OrganizationDotnetController.ts b/src/controllers/OrganizationDotnetController.ts index 440f230b..61836205 100644 --- a/src/controllers/OrganizationDotnetController.ts +++ b/src/controllers/OrganizationDotnetController.ts @@ -269,12 +269,19 @@ export class OrganizationDotnetController extends Controller { @Get("keycloak/{keycloakId}") async GetProfileByKeycloakIdAsync(@Path() keycloakId: string) { const profile = await this.profileRepo.findOne({ - relations: { - posLevel: true, - posType: true, - profileSalary: true, - profileInsignias: true, - }, + relations: [ + "posLevel", + "posType", + "profileSalary", + "profileInsignias", + "current_holders", + "current_holders.orgRevision", + "current_holders.orgRoot", + "current_holders.orgChild1", + "current_holders.orgChild2", + "current_holders.orgChild3", + "current_holders.orgChild4", + ], where: { keycloak: keycloakId }, order: { profileSalary: { @@ -287,12 +294,19 @@ export class OrganizationDotnetController extends Controller { }); if (!profile) { const profile = await this.profileEmpRepo.findOne({ - relations: { - posLevel: true, - posType: true, - profileSalary: true, - profileInsignias: true, - }, + relations: [ + "posLevel", + "posType", + "profileSalary", + "profileInsignias", + "current_holders", + "current_holders.orgRevision", + "current_holders.orgRoot", + "current_holders.orgChild1", + "current_holders.orgChild2", + "current_holders.orgChild3", + "current_holders.orgChild4", + ], where: { keycloak: keycloakId }, order: { profileSalary: { @@ -347,6 +361,36 @@ export class OrganizationDotnetController extends Controller { currentZipCode: profile.currentZipCode, dutyTimeId: profile.dutyTimeId, dutyTimeEffectiveDate: profile.dutyTimeEffectiveDate, + root: + profile?.current_holders?.find( + (x) => + x.orgRevision?.orgRevisionIsDraft == false && + x.orgRevision?.orgRevisionIsCurrent == true, + )?.orgRoot?.orgRootName ?? null, + child1: + profile?.current_holders?.find( + (x) => + x.orgRevision?.orgRevisionIsDraft == false && + x.orgRevision?.orgRevisionIsCurrent == true, + )?.orgChild1?.orgChild1Name ?? null, + child2: + profile?.current_holders?.find( + (x) => + x.orgRevision?.orgRevisionIsDraft == false && + x.orgRevision?.orgRevisionIsCurrent == true, + )?.orgChild2?.orgChild2Name ?? null, + child3: + profile?.current_holders?.find( + (x) => + x.orgRevision?.orgRevisionIsDraft == false && + x.orgRevision?.orgRevisionIsCurrent == true, + )?.orgChild3?.orgChild3Name ?? null, + child4: + profile?.current_holders?.find( + (x) => + x.orgRevision?.orgRevisionIsDraft == false && + x.orgRevision?.orgRevisionIsCurrent == true, + )?.orgChild4?.orgChild4Name ?? null, posLevel: profile.posLevel ? profile.posLevel : null, posType: profile.posType ? profile.posType : null, profileSalary: profile.profileSalary.length > 0 ? profile.profileSalary[0] : null, @@ -398,6 +442,36 @@ export class OrganizationDotnetController extends Controller { currentZipCode: profile.currentZipCode, dutyTimeId: profile.dutyTimeId, dutyTimeEffectiveDate: profile.dutyTimeEffectiveDate, + root: + profile?.current_holders?.find( + (x) => + x.orgRevision?.orgRevisionIsDraft == false && + x.orgRevision?.orgRevisionIsCurrent == true, + )?.orgRoot?.orgRootName ?? null, + child1: + profile?.current_holders?.find( + (x) => + x.orgRevision?.orgRevisionIsDraft == false && + x.orgRevision?.orgRevisionIsCurrent == true, + )?.orgChild1?.orgChild1Name ?? null, + child2: + profile?.current_holders?.find( + (x) => + x.orgRevision?.orgRevisionIsDraft == false && + x.orgRevision?.orgRevisionIsCurrent == true, + )?.orgChild2?.orgChild2Name ?? null, + child3: + profile?.current_holders?.find( + (x) => + x.orgRevision?.orgRevisionIsDraft == false && + x.orgRevision?.orgRevisionIsCurrent == true, + )?.orgChild3?.orgChild3Name ?? null, + child4: + profile?.current_holders?.find( + (x) => + x.orgRevision?.orgRevisionIsDraft == false && + x.orgRevision?.orgRevisionIsCurrent == true, + )?.orgChild4?.orgChild4Name ?? null, posLevel: profile.posLevel ? profile.posLevel : null, posType: profile.posType ? profile.posType : null, profileSalary: profile.profileSalary.length > 0 ? profile.profileSalary[0] : null, diff --git a/src/controllers/ReportController.ts b/src/controllers/ReportController.ts index 65cdc21d..354df3f3 100644 --- a/src/controllers/ReportController.ts +++ b/src/controllers/ReportController.ts @@ -866,7 +866,7 @@ export class ReportController extends Controller { }); if (orgRevisionActive == null) { const _orgRevisionActive = await this.orgRevisionRepository.find({ - order: { orgRevisionCreatedAt: "DESC" }, + order: { createdAt: "DESC" }, skip: 1, relations: [ "posMasters", @@ -3033,7 +3033,7 @@ export class ReportController extends Controller { }); if (orgRevisionActive == null) { const _orgRevisionActive = await this.orgRevisionRepository.find({ - order: { orgRevisionCreatedAt: "DESC" }, + order: { createdAt: "DESC" }, skip: 1, relations: [ "posMasters",