diff --git a/src/controllers/CommandController.ts b/src/controllers/CommandController.ts index 56a93020..e8bf6f17 100644 --- a/src/controllers/CommandController.ts +++ b/src/controllers/CommandController.ts @@ -4749,7 +4749,7 @@ export class CommandController extends Controller { const posMaster = await this.employeePosMasterRepository.findOne({ where: { id: profile.posmasterIdTemp }, - relations: ["orgRoot"], + relations: ["orgRoot", "orgChild1", "orgChild2", "orgChild3", "orgChild4"], }); if (posMaster == null) throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลตำแหน่งนี้"); @@ -4863,7 +4863,12 @@ export class CommandController extends Controller { citizenId: profile.citizenId, root: posMaster.orgRoot.orgRootName, rootId: posMaster.orgRootId, - rootShortName: posMaster.orgRoot.orgRootShortName + rootShortName: posMaster.orgRoot.orgRootShortName, + rootDnaId: posMaster.orgRoot.ancestorDNA, + child1DnaId: posMaster.orgChild1.ancestorDNA, + child2DnaId: posMaster.orgChild2.ancestorDNA, + child3DnaId: posMaster.orgChild3.ancestorDNA, + child4DnaId: posMaster.orgChild4.ancestorDNA, }); await this.profileEmployeeRepository.save(profile); await this.employeePositionRepository.save(positionNew); @@ -4871,9 +4876,9 @@ export class CommandController extends Controller { }), ); await new CallAPI() - .PostData(req, - "/placement/appointment/employee-appoint-21/report/excecute", { profileEmps: _reqBody } - ) + .PostData(req, "/placement/appointment/employee-appoint-21/report/excecute", { + profileEmps: _reqBody, + }) .catch((error) => { throw new Error("Failed. Cannot update status. ", error); }); diff --git a/src/controllers/OrganizationController.ts b/src/controllers/OrganizationController.ts index edb35874..57e96829 100644 --- a/src/controllers/OrganizationController.ts +++ b/src/controllers/OrganizationController.ts @@ -5520,45 +5520,275 @@ export class OrganizationController extends Controller { data1 = _data1.map((y) => ({ name: y.orgRootName, rootId: y.id, + rootDnaId: y.ancestorDNA, child1Id: null, + child1DnaId: null, child2Id: null, + child2DnaId: null, child3Id: null, + child3DnaId: null, child4Id: null, + child4DnaId: null, })); data2 = _data2.map((y) => ({ name: y.orgRootName, rootId: y.id, + rootDnaId: y.ancestorDNA, child1Id: null, + child1DnaId: null, child2Id: null, + child2DnaId: null, child3Id: null, + child3DnaId: null, child4Id: null, + child4DnaId: null, + })); + break; + } + case 1: { + const _data1 = await this.child1Repository.find({ + where: { + id: requestBody.nodeId ?? "", + orgRoot: { + orgRootRankSub: In(orgRootRankSub1), + }, + }, + order: { + orgRoot: { orgRootOrder: "ASC" }, + }, + relations: ["orgRoot"], + }); + const _data2 = await this.child1Repository.find({ + where: [ + { + id: requestBody.nodeId ?? "", + orgRoot: { + orgRootRankSub: In(orgRootRankSub2), + }, + }, + { + id: requestBody.nodeId ?? "", + orgRoot: { + orgRootRankSub: IsNull(), + }, + }, + ], + order: { + orgRoot: { orgRootOrder: "ASC" }, + }, + relations: ["orgRoot"], + }); + data1 = _data1.map((y) => ({ + name: y.orgRoot.orgRootName, + rootId: y.orgRoot.id, + rootDnaId: y.orgRoot.ancestorDNA, + child1Id: y.id, + child1DnaId: y.ancestorDNA, + child2Id: null, + child2DnaId: null, + child3Id: null, + child3DnaId: null, + child4Id: null, + child4DnaId: null, + })); + data2 = _data2.map((y) => ({ + name: y.orgRoot.orgRootName, + rootId: y.orgRoot.id, + rootDnaId: y.orgRoot.ancestorDNA, + child1Id: y.id, + child1DnaId: y.ancestorDNA, + child2Id: null, + child2DnaId: null, + child3Id: null, + child3DnaId: null, + child4Id: null, + child4DnaId: null, + })); + break; + } + case 2: { + const _data1 = await this.child2Repository.find({ + where: { + id: requestBody.nodeId ?? "", + orgRoot: { + orgRootRankSub: In(orgRootRankSub1), + }, + }, + order: { + orgRoot: { orgRootOrder: "ASC" }, + }, + relations: ["orgRoot", "orgChild1"], + }); + const _data2 = await this.child2Repository.find({ + where: [ + { + id: requestBody.nodeId ?? "", + orgRoot: { + orgRootRankSub: In(orgRootRankSub2), + }, + }, + { + id: requestBody.nodeId ?? "", + orgRoot: { + orgRootRankSub: IsNull(), + }, + }, + ], + order: { + orgRoot: { orgRootOrder: "ASC" }, + }, + relations: ["orgRoot", "orgChild1"], + }); + data1 = _data1.map((y) => ({ + name: y.orgRoot.orgRootName, + rootId: y.orgRoot.id, + rootDnaId: y.orgRoot.ancestorDNA, + child1Id: y.orgChild1.id, + child1DnaId: y.orgChild1.ancestorDNA, + child2Id: y.id, + child2DnaId: y.ancestorDNA, + child3Id: null, + child3DnaId: null, + child4Id: null, + child4DnaId: null, + })); + data2 = _data2.map((y) => ({ + name: y.orgRoot.orgRootName, + rootId: y.orgRoot.id, + rootDnaId: y.orgRoot.ancestorDNA, + child1Id: y.orgChild1.id, + child1DnaId: y.orgChild1.ancestorDNA, + child2Id: y.id, + child2DnaId: y.ancestorDNA, + child3Id: null, + child3DnaId: null, + child4Id: null, + child4DnaId: null, + })); + break; + } + case 3: { + const _data1 = await this.child3Repository.find({ + where: { + id: requestBody.nodeId ?? "", + orgRoot: { + orgRootRankSub: In(orgRootRankSub1), + }, + }, + order: { + orgRoot: { orgRootOrder: "ASC" }, + }, + relations: ["orgRoot", "orgChild1", "orgChild2"], + }); + const _data2 = await this.child3Repository.find({ + where: [ + { + id: requestBody.nodeId ?? "", + orgRoot: { + orgRootRankSub: In(orgRootRankSub2), + }, + }, + { + id: requestBody.nodeId ?? "", + orgRoot: { + orgRootRankSub: IsNull(), + }, + }, + ], + order: { + orgRoot: { orgRootOrder: "ASC" }, + }, + relations: ["orgRoot", "orgChild1", "orgChild2"], + }); + data1 = _data1.map((y) => ({ + name: y.orgRoot.orgRootName, + rootId: y.orgRoot.id, + rootDnaId: y.orgRoot.ancestorDNA, + child1Id: y.orgChild1.id, + child1DnaId: y.orgChild1.ancestorDNA, + child2Id: y.orgChild2.id, + child2DnaId: y.orgChild2.ancestorDNA, + child3Id: y.id, + child3DnaId: y.ancestorDNA, + child4Id: null, + child4DnaId: null, + })); + data2 = _data2.map((y) => ({ + name: y.orgRoot.orgRootName, + rootId: y.orgRoot.id, + rootDnaId: y.orgRoot.ancestorDNA, + child1Id: y.orgChild1.id, + child1DnaId: y.orgChild1.ancestorDNA, + child2Id: y.orgChild2.id, + child2DnaId: y.orgChild2.ancestorDNA, + child3Id: y.id, + child3DnaId: y.ancestorDNA, + child4Id: null, + child4DnaId: null, + })); + break; + } + case 4: { + const _data1 = await this.child4Repository.find({ + where: { + id: requestBody.nodeId ?? "", + orgRoot: { + orgRootRankSub: In(orgRootRankSub1), + }, + }, + order: { + orgRoot: { orgRootOrder: "ASC" }, + }, + relations: ["orgRoot", "orgChild1", "orgChild2", "orgChild3"], + }); + const _data2 = await this.child4Repository.find({ + where: [ + { + id: requestBody.nodeId ?? "", + orgRoot: { + orgRootRankSub: In(orgRootRankSub2), + }, + }, + { + id: requestBody.nodeId ?? "", + orgRoot: { + orgRootRankSub: IsNull(), + }, + }, + ], + order: { + orgRoot: { orgRootOrder: "ASC" }, + }, + relations: ["orgRoot", "orgChild1", "orgChild2", "orgChild3"], + }); + data1 = _data1.map((y) => ({ + name: y.orgRoot.orgRootName, + rootId: y.orgRoot.id, + rootDnaId: y.orgRoot.ancestorDNA, + child1Id: y.orgChild1.id, + child1DnaId: y.orgChild1.ancestorDNA, + child2Id: y.orgChild2.id, + child2DnaId: y.orgChild2.ancestorDNA, + child3Id: y.orgChild3.id, + child3DnaId: y.orgChild3.ancestorDNA, + child4Id: y.id, + child4DnaId: y.ancestorDNA, + })); + data2 = _data2.map((y) => ({ + name: y.orgRoot.orgRootName, + rootId: y.orgRoot.id, + rootDnaId: y.orgRoot.ancestorDNA, + child1Id: y.orgChild1.id, + child1DnaId: y.orgChild1.ancestorDNA, + child2Id: y.orgChild2.id, + child2DnaId: y.orgChild2.ancestorDNA, + child3Id: y.orgChild3.id, + child3DnaId: y.orgChild3.ancestorDNA, + child4Id: y.id, + child4DnaId: y.ancestorDNA, })); break; } - // case 1: { - // const data = await this.child1Repository.find({ - // where: { id: requestBody.nodeId }, - // }); - // return new HttpSuccess(data); - // } - // case 2: { - // const data = await this.child2Repository.find({ - // where: { id: requestBody.nodeId }, - // }); - // return new HttpSuccess(data); - // } - // case 3: { - // const data = await this.child3Repository.find({ - // where: { id: requestBody.nodeId }, - // }); - // return new HttpSuccess(data); - // } - // case 4: { - // const data = await this.child4Repository.find({ - // where: { id: requestBody.nodeId }, - // }); - // return new HttpSuccess(data); - // } default: { const orgRevision = await this.orgRevisionRepository.findOne({ where: { @@ -5589,6 +5819,7 @@ export class OrganizationController extends Controller { data1 = _data1.map((y) => ({ name: y.orgRootName, rootId: y.id, + rootDnaId: y.ancestorDNA, child1Id: null, child2Id: null, child3Id: null, @@ -5597,6 +5828,7 @@ export class OrganizationController extends Controller { data2 = _data2.map((y) => ({ name: y.orgRootName, rootId: y.id, + rootDnaId: y.ancestorDNA, child1Id: null, child2Id: null, child3Id: null, @@ -5642,7 +5874,7 @@ export class OrganizationController extends Controller { } return new HttpSuccess({ rootId: data.orgRootId, - rootDnaId: data.ancestorDNA, + rootDnaId: data.orgRoot == null ? null : data.orgRoot.ancestorDNA, root: data.orgRoot == null ? null : data.orgRoot.orgRootName, rootShortName: data.orgRoot == null ? null : data.orgRoot.orgRootShortName, child1Id: data.id, @@ -5664,11 +5896,11 @@ export class OrganizationController extends Controller { } return new HttpSuccess({ rootId: data.orgRootId, - rootDnaId: data.ancestorDNA, + rootDnaId: data.orgRoot == null ? null : data.orgRoot.ancestorDNA, root: data.orgRoot == null ? null : data.orgRoot.orgRootName, rootShortName: data.orgRoot == null ? null : data.orgRoot.orgRootShortName, child1Id: data.orgChild1Id, - child1DnaId: data.ancestorDNA, + child1DnaId: data.orgChild1 == null ? null : data.orgChild1.ancestorDNA, child1: data.orgChild1 == null ? null : data.orgChild1.orgChild1Name, child1ShortName: data.orgChild1 == null ? null : data.orgChild1.orgChild1ShortName, child2Id: data.id, @@ -5691,15 +5923,15 @@ export class OrganizationController extends Controller { } return new HttpSuccess({ rootId: data.orgRootId, - rootDnaId: data.ancestorDNA, + rootDnaId: data.orgRoot == null ? null : data.orgRoot.ancestorDNA, root: data.orgRoot == null ? null : data.orgRoot.orgRootName, rootShortName: data.orgRoot == null ? null : data.orgRoot.orgRootShortName, child1Id: data.orgChild1Id, - child1DnaId: data.ancestorDNA, + child1DnaId: data.orgChild1 == null ? null : data.orgChild1.ancestorDNA, child1: data.orgChild1 == null ? null : data.orgChild1.orgChild1Name, child1ShortName: data.orgChild1 == null ? null : data.orgChild1.orgChild1ShortName, child2Id: data.orgChild2Id, - child2DnaId: data.ancestorDNA, + child2DnaId: data.orgChild2 == null ? null : data.orgChild2.ancestorDNA, child2: data.orgChild2 == null ? null : data.orgChild2.orgChild2Name, child2ShortName: data.orgChild2 == null ? null : data.orgChild2.orgChild2ShortName, child3Id: data.id, @@ -5723,19 +5955,19 @@ export class OrganizationController extends Controller { } return new HttpSuccess({ rootId: data.orgRootId, - rootDnaId: data.ancestorDNA, + rootDnaId: data.orgRoot == null ? null : data.orgRoot.ancestorDNA, root: data.orgRoot == null ? null : data.orgRoot.orgRootName, rootShortName: data.orgRoot == null ? null : data.orgRoot.orgRootShortName, child1Id: data.orgChild1Id, - child1DnaId: data.ancestorDNA, + child1DnaId: data.orgChild1 == null ? null : data.orgChild1.ancestorDNA, child1: data.orgChild1 == null ? null : data.orgChild1.orgChild1Name, child1ShortName: data.orgChild1 == null ? null : data.orgChild1.orgChild1ShortName, child2Id: data.orgChild2Id, - child2DnaId: data.ancestorDNA, + child2DnaId: data.orgChild2 == null ? null : data.orgChild2.ancestorDNA, child2: data.orgChild2 == null ? null : data.orgChild2.orgChild2Name, child2ShortName: data.orgChild2 == null ? null : data.orgChild2.orgChild2ShortName, child3Id: data.orgChild3Id, - child3DnaId: data.ancestorDNA, + child3DnaId: data.orgChild3 == null ? null : data.orgChild3.ancestorDNA, child3: data.orgChild3 == null ? null : data.orgChild3.orgChild3Name, child3ShortName: data.orgChild3 == null ? null : data.orgChild3.orgChild3ShortName, child4Id: data.id, diff --git a/src/controllers/OrganizationDotnetController.ts b/src/controllers/OrganizationDotnetController.ts index ed9473f6..e0a4a8e9 100644 --- a/src/controllers/OrganizationDotnetController.ts +++ b/src/controllers/OrganizationDotnetController.ts @@ -1208,6 +1208,36 @@ export class OrganizationDotnetController extends Controller { x.orgRevision?.orgRevisionIsDraft == false && x.orgRevision?.orgRevisionIsCurrent == true, )?.orgChild4Id ?? null, + rootDnaId: + profile?.current_holders?.find( + (x) => + x.orgRevision?.orgRevisionIsDraft == false && + x.orgRevision?.orgRevisionIsCurrent == true, + )?.ancestorDNA ?? null, + child1DnaId: + profile?.current_holders?.find( + (x) => + x.orgRevision?.orgRevisionIsDraft == false && + x.orgRevision?.orgRevisionIsCurrent == true, + )?.ancestorDNA ?? null, + child2DnaId: + profile?.current_holders?.find( + (x) => + x.orgRevision?.orgRevisionIsDraft == false && + x.orgRevision?.orgRevisionIsCurrent == true, + )?.ancestorDNA ?? null, + child3DnaId: + profile?.current_holders?.find( + (x) => + x.orgRevision?.orgRevisionIsDraft == false && + x.orgRevision?.orgRevisionIsCurrent == true, + )?.ancestorDNA ?? null, + child4DnaId: + profile?.current_holders?.find( + (x) => + x.orgRevision?.orgRevisionIsDraft == false && + x.orgRevision?.orgRevisionIsCurrent == true, + )?.ancestorDNA ?? null, commander: fullname, posLevel: profile.posLevel?.posLevelName ?? null, posType: profile.posType?.posTypeName ?? null, @@ -1475,6 +1505,36 @@ export class OrganizationDotnetController extends Controller { x.orgRevision?.orgRevisionIsDraft == false && x.orgRevision?.orgRevisionIsCurrent == true, )?.orgChild4Id ?? null, + rootDnaId: + profile?.current_holders?.find( + (x) => + x.orgRevision?.orgRevisionIsDraft == false && + x.orgRevision?.orgRevisionIsCurrent == true, + )?.ancestorDNA ?? null, + child1DnaId: + profile?.current_holders?.find( + (x) => + x.orgRevision?.orgRevisionIsDraft == false && + x.orgRevision?.orgRevisionIsCurrent == true, + )?.ancestorDNA ?? null, + child2DnaId: + profile?.current_holders?.find( + (x) => + x.orgRevision?.orgRevisionIsDraft == false && + x.orgRevision?.orgRevisionIsCurrent == true, + )?.ancestorDNA ?? null, + child3DnaId: + profile?.current_holders?.find( + (x) => + x.orgRevision?.orgRevisionIsDraft == false && + x.orgRevision?.orgRevisionIsCurrent == true, + )?.ancestorDNA ?? null, + child4DnaId: + profile?.current_holders?.find( + (x) => + x.orgRevision?.orgRevisionIsDraft == false && + x.orgRevision?.orgRevisionIsCurrent == true, + )?.ancestorDNA ?? null, commander: fullname, posLevel: profile.posLevel?.posLevelName ?? null, posType: profile.posType?.posTypeName ?? null, @@ -2211,6 +2271,84 @@ export class OrganizationDotnetController extends Controller { x.orgRevision?.orgRevisionIsDraft == false && x.orgRevision?.orgRevisionIsCurrent == true, )?.orgRootId ?? null, + rootDnaId: + profile?.current_holders?.find( + (x) => + x.orgRevision?.orgRevisionIsDraft == false && + x.orgRevision?.orgRevisionIsCurrent == true, + )?.ancestorDNA ?? null, + child1: + profile?.current_holders?.find( + (x) => + x.orgRevision?.orgRevisionIsDraft == false && + x.orgRevision?.orgRevisionIsCurrent == true, + )?.orgChild1?.orgChild1Name ?? null, + child1Id: + profile?.current_holders?.find( + (x) => + x.orgRevision?.orgRevisionIsDraft == false && + x.orgRevision?.orgRevisionIsCurrent == true, + )?.orgChild1Id ?? null, + child1DnaId: + profile?.current_holders?.find( + (x) => + x.orgRevision?.orgRevisionIsDraft == false && + x.orgRevision?.orgRevisionIsCurrent == true, + )?.ancestorDNA ?? null, + child2: + profile?.current_holders?.find( + (x) => + x.orgRevision?.orgRevisionIsDraft == false && + x.orgRevision?.orgRevisionIsCurrent == true, + )?.orgChild2?.orgChild2Name ?? null, + child2Id: + profile?.current_holders?.find( + (x) => + x.orgRevision?.orgRevisionIsDraft == false && + x.orgRevision?.orgRevisionIsCurrent == true, + )?.orgChild2Id ?? null, + child2DnaId: + profile?.current_holders?.find( + (x) => + x.orgRevision?.orgRevisionIsDraft == false && + x.orgRevision?.orgRevisionIsCurrent == true, + )?.ancestorDNA ?? null, + child3: + profile?.current_holders?.find( + (x) => + x.orgRevision?.orgRevisionIsDraft == false && + x.orgRevision?.orgRevisionIsCurrent == true, + )?.orgChild3?.orgChild3Name ?? null, + child3Id: + profile?.current_holders?.find( + (x) => + x.orgRevision?.orgRevisionIsDraft == false && + x.orgRevision?.orgRevisionIsCurrent == true, + )?.orgChild3Id ?? null, + child3DnaId: + profile?.current_holders?.find( + (x) => + x.orgRevision?.orgRevisionIsDraft == false && + x.orgRevision?.orgRevisionIsCurrent == true, + )?.ancestorDNA ?? null, + child4: + profile?.current_holders?.find( + (x) => + x.orgRevision?.orgRevisionIsDraft == false && + x.orgRevision?.orgRevisionIsCurrent == true, + )?.orgChild4?.orgChild4Name ?? null, + child4Id: + profile?.current_holders?.find( + (x) => + x.orgRevision?.orgRevisionIsDraft == false && + x.orgRevision?.orgRevisionIsCurrent == true, + )?.orgChild4Id ?? null, + child4DnaId: + profile?.current_holders?.find( + (x) => + x.orgRevision?.orgRevisionIsDraft == false && + x.orgRevision?.orgRevisionIsCurrent == true, + )?.ancestorDNA ?? null, posNo: shortName ?? "", }; }); @@ -2500,6 +2638,84 @@ export class OrganizationDotnetController extends Controller { x.orgRevision?.orgRevisionIsDraft == false && x.orgRevision?.orgRevisionIsCurrent == true, )?.orgRootId ?? null, + rootDnaId: + profile?.current_holders?.find( + (x) => + x.orgRevision?.orgRevisionIsDraft == false && + x.orgRevision?.orgRevisionIsCurrent == true, + )?.ancestorDNA ?? null, + child1: + profile?.current_holders?.find( + (x) => + x.orgRevision?.orgRevisionIsDraft == false && + x.orgRevision?.orgRevisionIsCurrent == true, + )?.orgChild1?.orgChild1Name ?? null, + child1Id: + profile?.current_holders?.find( + (x) => + x.orgRevision?.orgRevisionIsDraft == false && + x.orgRevision?.orgRevisionIsCurrent == true, + )?.orgChild1Id ?? null, + child1DnaId: + profile?.current_holders?.find( + (x) => + x.orgRevision?.orgRevisionIsDraft == false && + x.orgRevision?.orgRevisionIsCurrent == true, + )?.ancestorDNA ?? null, + child2: + profile?.current_holders?.find( + (x) => + x.orgRevision?.orgRevisionIsDraft == false && + x.orgRevision?.orgRevisionIsCurrent == true, + )?.orgChild2?.orgChild2Name ?? null, + child2Id: + profile?.current_holders?.find( + (x) => + x.orgRevision?.orgRevisionIsDraft == false && + x.orgRevision?.orgRevisionIsCurrent == true, + )?.orgChild2Id ?? null, + child2DnaId: + profile?.current_holders?.find( + (x) => + x.orgRevision?.orgRevisionIsDraft == false && + x.orgRevision?.orgRevisionIsCurrent == true, + )?.ancestorDNA ?? null, + child3: + profile?.current_holders?.find( + (x) => + x.orgRevision?.orgRevisionIsDraft == false && + x.orgRevision?.orgRevisionIsCurrent == true, + )?.orgChild3?.orgChild3Name ?? null, + child3Id: + profile?.current_holders?.find( + (x) => + x.orgRevision?.orgRevisionIsDraft == false && + x.orgRevision?.orgRevisionIsCurrent == true, + )?.orgChild3Id ?? null, + child3DnaId: + profile?.current_holders?.find( + (x) => + x.orgRevision?.orgRevisionIsDraft == false && + x.orgRevision?.orgRevisionIsCurrent == true, + )?.ancestorDNA ?? null, + child4: + profile?.current_holders?.find( + (x) => + x.orgRevision?.orgRevisionIsDraft == false && + x.orgRevision?.orgRevisionIsCurrent == true, + )?.orgChild4?.orgChild4Name ?? null, + child4Id: + profile?.current_holders?.find( + (x) => + x.orgRevision?.orgRevisionIsDraft == false && + x.orgRevision?.orgRevisionIsCurrent == true, + )?.orgChild4Id ?? null, + child4DnaId: + profile?.current_holders?.find( + (x) => + x.orgRevision?.orgRevisionIsDraft == false && + x.orgRevision?.orgRevisionIsCurrent == true, + )?.ancestorDNA ?? null, posNo: shortName ?? "", }; }); @@ -3078,9 +3294,14 @@ export class OrganizationDotnetController extends Controller { "current_holders.orgChild4", ], }); - if(body.isRetirement){ - profile = await this.profileRepo.find({ - where: { keycloak: Not(IsNull()) || Not(""), isLeave: false, current_holders: typeCondition, isRetirement: true }, + if (body.isRetirement) { + profile = await this.profileRepo.find({ + where: { + keycloak: Not(IsNull()) || Not(""), + isLeave: false, + current_holders: typeCondition, + isRetirement: true, + }, relations: [ "posType", "posLevel", @@ -3093,7 +3314,7 @@ export class OrganizationDotnetController extends Controller { ], }); } - + const findRevision = await this.orgRevisionRepo.findOne({ where: { orgRevisionIsCurrent: true }, }); @@ -3292,7 +3513,9 @@ export class OrganizationDotnetController extends Controller { keycloak: item.keycloak, posNo: shortName, position: item.position, - positionLevel: item.posLevel ? `${item.posType.posTypeShortName} ${item.posLevel.posLevelName}` : "-", + positionLevel: item.posLevel + ? `${item.posType.posTypeShortName} ${item.posLevel.posLevelName}` + : "-", positionType: item.posType?.posTypeName ?? null, oc: Oc, }; diff --git a/src/controllers/ProfileController.ts b/src/controllers/ProfileController.ts index 7418a49e..c6b66f7e 100644 --- a/src/controllers/ProfileController.ts +++ b/src/controllers/ProfileController.ts @@ -6452,18 +6452,23 @@ export class ProfileController extends Controller { posTypeId: profile.posType == null ? null : profile.posType.id, orgRevisionId: root == null ? null : root.orgRevisionId, rootId: root == null ? null : root.id, + rootDnaId: root == null ? null : root.ancestorDNA, root: root == null ? null : root.orgRootName, rootShortName: root == null ? null : root.orgRootShortName, child1Id: child1 == null ? null : child1.id, + child1DnaId: child1 == null ? null : child1.ancestorDNA, child1: child1 == null ? null : child1.orgChild1Name, child1ShortName: child1 == null ? null : child1.orgChild1ShortName, child2Id: child2 == null ? null : child2.id, + child2DnaId: child2 == null ? null : child2.ancestorDNA, child2: child2 == null ? null : child2.orgChild2Name, child2ShortName: child2 == null ? null : child2.orgChild2ShortName, child3Id: child3 == null ? null : child3.id, + child3DnaId: child3 == null ? null : child3.ancestorDNA, child3: child3 == null ? null : child3.orgChild3Name, child3ShortName: child3 == null ? null : child3.orgChild3ShortName, child4Id: child4 == null ? null : child4.id, + child4DnaId: child4 == null ? null : child4.ancestorDNA, child4: child4 == null ? null : child4.orgChild4Name, child4ShortName: child4 == null ? null : child4.orgChild4ShortName, node: null, @@ -6964,18 +6969,23 @@ export class ProfileController extends Controller { salary: item.amount, root: rootHolder?.orgRootName ?? null, rootId: rootHolder?.id ?? null, + rootDnaId: rootHolder?.ancestorDNA ?? null, rootShortName: rootHolder?.orgRootShortName ?? null, child1: child1Holder?.orgChild1Name ?? null, child1Id: child1Holder?.id ?? null, + child1DnaId: child1Holder?.ancestorDNA ?? null, child1ShortName: child1Holder?.orgChild1ShortName ?? null, child2: child2Holder?.orgChild2Name ?? null, child2Id: child2Holder?.id ?? null, + child2DnaId: child2Holder?.ancestorDNA ?? null, child2ShortName: child2Holder?.orgChild2ShortName ?? null, child3: child3Holder?.orgChild3Name ?? null, child3Id: child3Holder?.id ?? null, + child3DnaId: child3Holder?.ancestorDNA ?? null, child3ShortName: child3Holder?.orgChild3ShortName ?? null, child4: child4Holder?.orgChild4Name ?? null, child4Id: child4Holder?.id ?? null, + child4DnaId: child4Holder?.ancestorDNA ?? null, child4ShortName: child4Holder?.orgChild4ShortName ?? null, posMasterNo: posMasterNo ?? null, posTypeId: item.posTypeId, @@ -7518,6 +7528,56 @@ export class ProfileController extends Controller { ? null : item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id) ?.orgChild4?.id, + rootDna: + item.current_holders == null || + item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id) == null || + item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)?.orgRoot == + null || + item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)?.orgRoot + ?.orgRootName == null + ? null + : item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)?.orgRoot + ?.ancestorDNA, + orgChild1Dna: + item.current_holders == null || + item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id) == null || + item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)?.orgChild1 == + null || + item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)?.orgChild1 + ?.orgChild1Name == null + ? null + : item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id) + ?.orgChild1?.ancestorDNA, + orgChild2Dna: + item.current_holders == null || + item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id) == null || + item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)?.orgChild2 == + null || + item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)?.orgChild2 + ?.orgChild2Name == null + ? null + : item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id) + ?.orgChild2?.ancestorDNA, + orgChild3Dna: + item.current_holders == null || + item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id) == null || + item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)?.orgChild3 == + null || + item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)?.orgChild3 + ?.orgChild3Name == null + ? null + : item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id) + ?.orgChild3?.ancestorDNA, + orgChild4Dna: + item.current_holders == null || + item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id) == null || + item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)?.orgChild4 == + null || + item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)?.orgChild4 + ?.orgChild4Name == null + ? null + : item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id) + ?.orgChild4?.ancestorDNA, }; }), ); @@ -8038,6 +8098,12 @@ export class ProfileController extends Controller { profile.current_holders.find((x) => x.orgRevisionId == revisionId)?.orgRoot == null ? null : profile.current_holders.find((x) => x.orgRevisionId == revisionId)?.orgRootId, + rootDnaId: + profile.current_holders == null || + profile.current_holders.find((x) => x.orgRevisionId == revisionId) == null || + profile.current_holders.find((x) => x.orgRevisionId == revisionId)?.orgRoot == null + ? null + : profile.current_holders.find((x) => x.orgRevisionId == revisionId)?.ancestorDNA, root: profile.current_holders == null || profile.current_holders.find((x) => x.orgRevisionId == revisionId) == null || @@ -8050,6 +8116,12 @@ export class ProfileController extends Controller { profile.current_holders.find((x) => x.orgRevisionId == revisionId)?.orgChild1 == null ? null : profile.current_holders.find((x) => x.orgRevisionId == revisionId)?.orgChild1Id, + child1DnaId: + profile.current_holders == null || + profile.current_holders.find((x) => x.orgRevisionId == revisionId) == null || + profile.current_holders.find((x) => x.orgRevisionId == revisionId)?.orgChild1 == null + ? null + : profile.current_holders.find((x) => x.orgRevisionId == revisionId)?.ancestorDNA, child1: profile.current_holders == null || profile.current_holders.find((x) => x.orgRevisionId == revisionId) == null || @@ -8063,6 +8135,12 @@ export class ProfileController extends Controller { profile.current_holders.find((x) => x.orgRevisionId == revisionId)?.orgChild2 == null ? null : profile.current_holders.find((x) => x.orgRevisionId == revisionId)?.orgChild2Id, + child2DnaId: + profile.current_holders == null || + profile.current_holders.find((x) => x.orgRevisionId == revisionId) == null || + profile.current_holders.find((x) => x.orgRevisionId == revisionId)?.orgChild2 == null + ? null + : profile.current_holders.find((x) => x.orgRevisionId == revisionId)?.ancestorDNA, child2: profile.current_holders == null || profile.current_holders.find((x) => x.orgRevisionId == revisionId) == null || @@ -8076,6 +8154,12 @@ export class ProfileController extends Controller { profile.current_holders.find((x) => x.orgRevisionId == revisionId)?.orgChild3 == null ? null : profile.current_holders.find((x) => x.orgRevisionId == revisionId)?.orgChild3Id, + child3DnaId: + profile.current_holders == null || + profile.current_holders.find((x) => x.orgRevisionId == revisionId) == null || + profile.current_holders.find((x) => x.orgRevisionId == revisionId)?.orgChild3 == null + ? null + : profile.current_holders.find((x) => x.orgRevisionId == revisionId)?.ancestorDNA, child3: profile.current_holders == null || profile.current_holders.find((x) => x.orgRevisionId == revisionId) == null || @@ -8089,6 +8173,12 @@ export class ProfileController extends Controller { profile.current_holders.find((x) => x.orgRevisionId == revisionId)?.orgChild4 == null ? null : profile.current_holders.find((x) => x.orgRevisionId == revisionId)?.orgChild4Id, + child4DnaId: + profile.current_holders == null || + profile.current_holders.find((x) => x.orgRevisionId == revisionId) == null || + profile.current_holders.find((x) => x.orgRevisionId == revisionId)?.orgChild4 == null + ? null + : profile.current_holders.find((x) => x.orgRevisionId == revisionId)?.ancestorDNA, child4: profile.current_holders == null || profile.current_holders.find((x) => x.orgRevisionId == revisionId) == null || diff --git a/src/controllers/ProfileEmployeeController.ts b/src/controllers/ProfileEmployeeController.ts index 7631dd4e..553477f4 100644 --- a/src/controllers/ProfileEmployeeController.ts +++ b/src/controllers/ProfileEmployeeController.ts @@ -2242,18 +2242,23 @@ export class ProfileEmployeeController extends Controller { posExecutiveId: position == null || position.posExecutive == null ? null : position.posExecutive.id, rootId: root == null ? null : root.id, + rootDnaId: root == null ? null : root.ancestorDNA, root: root == null ? null : root.orgRootName, rootShortName: root == null ? null : root.orgRootShortName, child1Id: child1 == null ? null : child1.id, + child1DnaId: child1 == null ? null : child1.ancestorDNA, child1: child1 == null ? null : child1.orgChild1Name, child1ShortName: child1 == null ? null : child1.orgChild1ShortName, child2Id: child2 == null ? null : child2.id, + child2DnaId: child2 == null ? null : child2.ancestorDNA, child2: child2 == null ? null : child2.orgChild2Name, child2ShortName: child2 == null ? null : child2.orgChild2ShortName, child3Id: child3 == null ? null : child3.id, + child3DnaId: child3 == null ? null : child3.ancestorDNA, child3: child3 == null ? null : child3.orgChild3Name, child3ShortName: child3 == null ? null : child3.orgChild3ShortName, child4Id: child4 == null ? null : child4.id, + child4DnaId: child4 == null ? null : child4.ancestorDNA, child4: child4 == null ? null : child4.orgChild4Name, child4ShortName: child4 == null ? null : child4.orgChild4ShortName, node: null, @@ -2596,18 +2601,23 @@ export class ProfileEmployeeController extends Controller { salary: item.amount, root: rootHolder?.orgRootName ?? null, rootId: rootHolder?.id ?? null, + rootDnaId: rootHolder?.ancestorDNA ?? null, rootShortName: rootHolder?.orgRootShortName ?? null, child1: child1Holder?.orgChild1Name ?? null, child1Id: child1Holder?.id ?? null, + child1DnaId: child1Holder?.ancestorDNA ?? null, child1ShortName: child1Holder?.orgChild1ShortName ?? null, child2: child2Holder?.orgChild2Name ?? null, child2Id: child2Holder?.id ?? null, + child2DnaId: child2Holder?.ancestorDNA ?? null, child2ShortName: child2Holder?.orgChild2ShortName ?? null, child3: child3Holder?.orgChild3Name ?? null, child3Id: child3Holder?.id ?? null, + child3DnaId: child3Holder?.ancestorDNA ?? null, child3ShortName: child3Holder?.orgChild3ShortName ?? null, child4: child4Holder?.orgChild4Name ?? null, child4Id: child4Holder?.id ?? null, + child4DnaId: child4Holder?.ancestorDNA ?? null, child4ShortName: child4Holder?.orgChild4ShortName ?? null, posMasterNo: posMasterNo ?? null, posTypeId: item.posTypeId, @@ -3607,6 +3617,12 @@ export class ProfileEmployeeController extends Controller { profile.current_holders.find((x) => x.orgRevisionId == revisionId)?.orgRoot == null ? null : profile.current_holders.find((x) => x.orgRevisionId == revisionId)?.orgRootId, + rootDnaId: + profile.current_holders == null || + profile.current_holders.find((x) => x.orgRevisionId == revisionId) == null || + profile.current_holders.find((x) => x.orgRevisionId == revisionId)?.orgRoot == null + ? null + : profile.current_holders.find((x) => x.orgRevisionId == revisionId)?.ancestorDNA, root: profile.current_holders == null || profile.current_holders.find((x) => x.orgRevisionId == revisionId) == null || @@ -3619,6 +3635,12 @@ export class ProfileEmployeeController extends Controller { profile.current_holders.find((x) => x.orgRevisionId == revisionId)?.orgChild1 == null ? null : profile.current_holders.find((x) => x.orgRevisionId == revisionId)?.orgChild1Id, + child1DnaId: + profile.current_holders == null || + profile.current_holders.find((x) => x.orgRevisionId == revisionId) == null || + profile.current_holders.find((x) => x.orgRevisionId == revisionId)?.orgChild1 == null + ? null + : profile.current_holders.find((x) => x.orgRevisionId == revisionId)?.ancestorDNA, child1: profile.current_holders == null || profile.current_holders.find((x) => x.orgRevisionId == revisionId) == null || @@ -3632,6 +3654,12 @@ export class ProfileEmployeeController extends Controller { profile.current_holders.find((x) => x.orgRevisionId == revisionId)?.orgChild2 == null ? null : profile.current_holders.find((x) => x.orgRevisionId == revisionId)?.orgChild2Id, + child2DnaId: + profile.current_holders == null || + profile.current_holders.find((x) => x.orgRevisionId == revisionId) == null || + profile.current_holders.find((x) => x.orgRevisionId == revisionId)?.orgChild2 == null + ? null + : profile.current_holders.find((x) => x.orgRevisionId == revisionId)?.ancestorDNA, child2: profile.current_holders == null || profile.current_holders.find((x) => x.orgRevisionId == revisionId) == null || @@ -3645,6 +3673,12 @@ export class ProfileEmployeeController extends Controller { profile.current_holders.find((x) => x.orgRevisionId == revisionId)?.orgChild3 == null ? null : profile.current_holders.find((x) => x.orgRevisionId == revisionId)?.orgChild3Id, + child3DnaId: + profile.current_holders == null || + profile.current_holders.find((x) => x.orgRevisionId == revisionId) == null || + profile.current_holders.find((x) => x.orgRevisionId == revisionId)?.orgChild3 == null + ? null + : profile.current_holders.find((x) => x.orgRevisionId == revisionId)?.ancestorDNA, child3: profile.current_holders == null || profile.current_holders.find((x) => x.orgRevisionId == revisionId) == null || @@ -3658,6 +3692,12 @@ export class ProfileEmployeeController extends Controller { profile.current_holders.find((x) => x.orgRevisionId == revisionId)?.orgChild4 == null ? null : profile.current_holders.find((x) => x.orgRevisionId == revisionId)?.orgChild4Id, + child4DnaId: + profile.current_holders == null || + profile.current_holders.find((x) => x.orgRevisionId == revisionId) == null || + profile.current_holders.find((x) => x.orgRevisionId == revisionId)?.orgChild4 == null + ? null + : profile.current_holders.find((x) => x.orgRevisionId == revisionId)?.ancestorDNA, child4: profile.current_holders == null || profile.current_holders.find((x) => x.orgRevisionId == revisionId) == null || @@ -4550,18 +4590,23 @@ export class ProfileEmployeeController extends Controller { posTypeId: profile.posType == null ? null : profile.posType.id, // posExecutiveName: "", rootId: root == null ? null : root.id, + rootDnaId: root == null ? null : root.ancestorDNA, root: root == null ? null : root.orgRootName, rootShortName: root == null ? null : root.orgRootShortName, child1Id: child1 == null ? null : child1.id, + child1DnaId: child1 == null ? null : child1.ancestorDNA, child1: child1 == null ? null : child1.orgChild1Name, child1ShortName: child1 == null ? null : child1.orgChild1ShortName, child2Id: child2 == null ? null : child2.id, + child2DnaId: child2 == null ? null : child2.ancestorDNA, child2: child2 == null ? null : child2.orgChild2Name, child2ShortName: child2 == null ? null : child2.orgChild2ShortName, child3Id: child3 == null ? null : child3.id, + child3DnaId: child3 == null ? null : child3.ancestorDNA, child3: child3 == null ? null : child3.orgChild3Name, child3ShortName: child3 == null ? null : child3.orgChild3ShortName, child4Id: child4 == null ? null : child4.id, + child4DnaId: child4 == null ? null : child4.ancestorDNA, child4: child4 == null ? null : child4.orgChild4Name, child4ShortName: child4 == null ? null : child4.orgChild4ShortName, node: null, diff --git a/src/controllers/ProfileEmployeeTempController.ts b/src/controllers/ProfileEmployeeTempController.ts index f4bc3cba..90a77f81 100644 --- a/src/controllers/ProfileEmployeeTempController.ts +++ b/src/controllers/ProfileEmployeeTempController.ts @@ -2163,18 +2163,23 @@ export class ProfileEmployeeTempController extends Controller { salary: item.amount, root: rootHolder?.orgRootName ?? null, rootId: rootHolder?.id ?? null, + rootDnaId: rootHolder?.ancestorDNA ?? null, rootShortName: rootHolder?.orgRootShortName ?? null, child1: child1Holder?.orgChild1Name ?? null, child1Id: child1Holder?.id ?? null, + child1DnaId: child1Holder?.ancestorDNA ?? null, child1ShortName: child1Holder?.orgChild1ShortName ?? null, child2: child2Holder?.orgChild2Name ?? null, child2Id: child2Holder?.id ?? null, + child2DnaId: child2Holder?.ancestorDNA ?? null, child2ShortName: child2Holder?.orgChild2ShortName ?? null, child3: child3Holder?.orgChild3Name ?? null, child3Id: child3Holder?.id ?? null, + child3DnaId: child3Holder?.ancestorDNA ?? null, child3ShortName: child3Holder?.orgChild3ShortName ?? null, child4: child4Holder?.orgChild4Name ?? null, child4Id: child4Holder?.id ?? null, + child4DnaId: child4Holder?.ancestorDNA ?? null, child4ShortName: child4Holder?.orgChild4ShortName ?? null, posMasterNo: posMasterNo ?? null, posTypeId: item.posTypeId, @@ -3814,18 +3819,23 @@ export class ProfileEmployeeTempController extends Controller { posTypeId: profile.posType == null ? null : profile.posType.id, // posExecutiveName: "", rootId: root == null ? null : root.id, + rootDnaId: root == null ? null : root.ancestorDNA, root: root == null ? null : root.orgRootName, rootShortName: root == null ? null : root.orgRootShortName, child1Id: child1 == null ? null : child1.id, + child1DnaId: child1 == null ? null : child1.ancestorDNA, child1: child1 == null ? null : child1.orgChild1Name, child1ShortName: child1 == null ? null : child1.orgChild1ShortName, child2Id: child2 == null ? null : child2.id, + child2DnaId: child2 == null ? null : child2.ancestorDNA, child2: child2 == null ? null : child2.orgChild2Name, child2ShortName: child2 == null ? null : child2.orgChild2ShortName, child3Id: child3 == null ? null : child3.id, + child3DnaId: child3 == null ? null : child3.ancestorDNA, child3: child3 == null ? null : child3.orgChild3Name, child3ShortName: child3 == null ? null : child3.orgChild3ShortName, child4Id: child4 == null ? null : child4.id, + child4DnaId: child4 == null ? null : child4.ancestorDNA, child4: child4 == null ? null : child4.orgChild4Name, child4ShortName: child4 == null ? null : child4.orgChild4ShortName, node: null,