From a9cfb2d847bb457169cdb4801e2b072d5533ff66 Mon Sep 17 00:00:00 2001 From: Bright Date: Thu, 8 Feb 2024 13:16:43 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B9=80=E0=B8=9E=E0=B8=B4=E0=B9=88=E0=B8=A1?= =?UTF-8?q?=E0=B8=9F=E0=B8=B4=E0=B8=A5=E0=B8=94=E0=B9=8C=20totalRoot?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/OrganizationController.ts | 223 ++++++++++++++++++++++ 1 file changed, 223 insertions(+) diff --git a/src/controllers/OrganizationController.ts b/src/controllers/OrganizationController.ts index 02d4d290..f9683365 100644 --- a/src/controllers/OrganizationController.ts +++ b/src/controllers/OrganizationController.ts @@ -752,6 +752,50 @@ export class OrganizationController extends Controller { next_holderId: IsNull() || "", }, }), + totalRootPosition: await this.posMasterRepository.count({ + where: { + orgRevisionId: orgRoot.orgRevisionId, + orgRootId: orgRoot.id, + orgChild1Id : IsNull() || "", orgChild2Id : IsNull() || "", + orgChild3Id : IsNull() || "", orgChild4Id : IsNull() || "", + }, + }), + totalRootPositionCurrentUse: await this.posMasterRepository.count({ + where: { + orgRevisionId: orgRoot.orgRevisionId, + orgRootId: orgRoot.id, + orgChild1Id : IsNull() || "", orgChild2Id : IsNull() || "", + orgChild3Id : IsNull() || "", orgChild4Id : IsNull() || "", + current_holderId: Not(IsNull()) || Not(""), + }, + }), + totalRootPositionCurrentVacant: await this.posMasterRepository.count({ + where: { + orgRevisionId: orgRoot.orgRevisionId, + orgRootId: orgRoot.id, + orgChild1Id : IsNull() || "", orgChild2Id : IsNull() || "", + orgChild3Id : IsNull() || "", orgChild4Id : IsNull() || "", + current_holderId: IsNull() || "", + }, + }), + totalRootPositionNextUse: await this.posMasterRepository.count({ + where: { + orgRevisionId: orgRoot.orgRevisionId, + orgRootId: orgRoot.id, + orgChild1Id : IsNull() || "", orgChild2Id : IsNull() || "", + orgChild3Id : IsNull() || "", orgChild4Id : IsNull() || "", + next_holderId: Not(IsNull()) || Not(""), + }, + }), + totalRootPositionNextVacant: await this.posMasterRepository.count({ + where: { + orgRevisionId: orgRoot.orgRevisionId, + orgRootId: orgRoot.id, + orgChild1Id : IsNull() || "", orgChild2Id : IsNull() || "", + orgChild3Id : IsNull() || "", orgChild4Id : IsNull() || "", + next_holderId: IsNull() || "", + }, + }), children: await Promise.all( orgChild1Data @@ -804,6 +848,51 @@ export class OrganizationController extends Controller { next_holderId: IsNull() || "", }, }), + totalRootPosition: await this.posMasterRepository.count({ + where: { + orgRevisionId: orgRoot.orgRevisionId, + orgRootId: orgRoot.id, + orgChild1Id : orgChild1.id, orgChild2Id : IsNull() || "", + orgChild3Id : IsNull() || "", orgChild4Id : IsNull() || "", + }, + }), + totalRootPositionCurrentUse: await this.posMasterRepository.count({ + where: { + orgRevisionId: orgRoot.orgRevisionId, + orgRootId: orgRoot.id, + orgChild1Id : orgChild1.id, orgChild2Id : IsNull() || "", + orgChild3Id : IsNull() || "", orgChild4Id : IsNull() || "", + current_holderId: Not(IsNull()) || Not(""), + }, + }), + totalRootPositionCurrentVacant: await this.posMasterRepository.count({ + where: { + orgRevisionId: orgRoot.orgRevisionId, + orgRootId: orgRoot.id, + orgChild1Id : orgChild1.id, orgChild2Id : IsNull() || "", + orgChild3Id : IsNull() || "", orgChild4Id : IsNull() || "", + current_holderId: IsNull() || "", + }, + }), + totalRootPositionNextUse: await this.posMasterRepository.count({ + where: { + orgRevisionId: orgRoot.orgRevisionId, + orgRootId: orgRoot.id, + orgChild1Id : orgChild1.id, orgChild2Id : IsNull() || "", + orgChild3Id : IsNull() || "", orgChild4Id : IsNull() || "", + next_holderId: Not(IsNull()) || Not(""), + }, + }), + totalRootPositionNextVacant: await this.posMasterRepository.count({ + where: { + orgRevisionId: orgRoot.orgRevisionId, + orgRootId: orgRoot.id, + orgChild1Id : orgChild1.id, orgChild2Id : IsNull() || "", + orgChild3Id : IsNull() || "", orgChild4Id : IsNull() || "", + next_holderId: IsNull() || "", + }, + }), + children: await Promise.all( orgChild2Data .filter((orgChild2) => orgChild2.orgChild1Id === orgChild1.id) @@ -858,6 +947,51 @@ export class OrganizationController extends Controller { next_holderId: IsNull() || "", }, }), + totalRootPosition: await this.posMasterRepository.count({ + where: { + orgRevisionId: orgRoot.orgRevisionId, + orgRootId: orgRoot.id, + orgChild1Id : orgChild1.id, orgChild2Id : orgChild2.id, + orgChild3Id : IsNull() || "", orgChild4Id : IsNull() || "", + }, + }), + totalRootPositionCurrentUse: await this.posMasterRepository.count({ + where: { + orgRevisionId: orgRoot.orgRevisionId, + orgRootId: orgRoot.id, + orgChild1Id : orgChild1.id, orgChild2Id : orgChild2.id, + orgChild3Id : IsNull() || "", orgChild4Id : IsNull() || "", + current_holderId: Not(IsNull()) || Not(""), + }, + }), + totalRootPositionCurrentVacant: await this.posMasterRepository.count({ + where: { + orgRevisionId: orgRoot.orgRevisionId, + orgRootId: orgRoot.id, + orgChild1Id : orgChild1.id, orgChild2Id : orgChild2.id, + orgChild3Id : IsNull() || "", orgChild4Id : IsNull() || "", + current_holderId: IsNull() || "", + }, + }), + totalRootPositionNextUse: await this.posMasterRepository.count({ + where: { + orgRevisionId: orgRoot.orgRevisionId, + orgRootId: orgRoot.id, + orgChild1Id : orgChild1.id, orgChild2Id : orgChild2.id, + orgChild3Id : IsNull() || "", orgChild4Id : IsNull() || "", + next_holderId: Not(IsNull()) || Not(""), + }, + }), + totalRootPositionNextVacant: await this.posMasterRepository.count({ + where: { + orgRevisionId: orgRoot.orgRevisionId, + orgRootId: orgRoot.id, + orgChild1Id : orgChild1.id, orgChild2Id : orgChild2.id, + orgChild3Id : IsNull() || "", orgChild4Id : IsNull() || "", + next_holderId: IsNull() || "", + }, + }), + children: await Promise.all( orgChild3Data .filter((orgChild3) => orgChild3.orgChild2Id === orgChild2.id) @@ -912,6 +1046,51 @@ export class OrganizationController extends Controller { next_holderId: IsNull() || "", }, }), + totalRootPosition: await this.posMasterRepository.count({ + where: { + orgRevisionId: orgRoot.orgRevisionId, + orgRootId: orgRoot.id, + orgChild1Id : orgChild1.id, orgChild2Id : orgChild2.id, + orgChild3Id : orgChild3.id, orgChild4Id : IsNull() || "", + }, + }), + totalRootPositionCurrentUse: await this.posMasterRepository.count({ + where: { + orgRevisionId: orgRoot.orgRevisionId, + orgRootId: orgRoot.id, + orgChild1Id : orgChild1.id, orgChild2Id : orgChild2.id, + orgChild3Id : orgChild3.id, orgChild4Id : IsNull() || "", + current_holderId: Not(IsNull()) || Not(""), + }, + }), + totalRootPositionCurrentVacant: await this.posMasterRepository.count({ + where: { + orgRevisionId: orgRoot.orgRevisionId, + orgRootId: orgRoot.id, + orgChild1Id : orgChild1.id, orgChild2Id : orgChild2.id, + orgChild3Id : orgChild3.id, orgChild4Id : IsNull() || "", + current_holderId: IsNull() || "", + }, + }), + totalRootPositionNextUse: await this.posMasterRepository.count({ + where: { + orgRevisionId: orgRoot.orgRevisionId, + orgRootId: orgRoot.id, + orgChild1Id : orgChild1.id, orgChild2Id : orgChild2.id, + orgChild3Id : orgChild3.id, orgChild4Id : IsNull() || "", + next_holderId: Not(IsNull()) || Not(""), + }, + }), + totalRootPositionNextVacant: await this.posMasterRepository.count({ + where: { + orgRevisionId: orgRoot.orgRevisionId, + orgRootId: orgRoot.id, + orgChild1Id : orgChild1.id, orgChild2Id : orgChild2.id, + orgChild3Id : orgChild3.id, orgChild4Id : IsNull() || "", + next_holderId: IsNull() || "", + }, + }), + children: await Promise.all( orgChild4Data .filter((orgChild4) => orgChild4.orgChild3Id === orgChild3.id) @@ -967,6 +1146,50 @@ export class OrganizationController extends Controller { next_holderId: IsNull() || "", }, }), + totalRootPosition: await this.posMasterRepository.count({ + where: { + orgRevisionId: orgRoot.orgRevisionId, + orgRootId: orgRoot.id, + orgChild1Id : orgChild1.id, orgChild2Id : orgChild2.id, + orgChild3Id : orgChild3.id, orgChild4Id : orgChild4.id, + }, + }), + totalRootPositionCurrentUse: await this.posMasterRepository.count({ + where: { + orgRevisionId: orgRoot.orgRevisionId, + orgRootId: orgRoot.id, + orgChild1Id : orgChild1.id, orgChild2Id : orgChild2.id, + orgChild3Id : orgChild3.id, orgChild4Id : orgChild4.id, + current_holderId: Not(IsNull()) || Not(""), + }, + }), + totalRootPositionCurrentVacant: await this.posMasterRepository.count({ + where: { + orgRevisionId: orgRoot.orgRevisionId, + orgRootId: orgRoot.id, + orgChild1Id : orgChild1.id, orgChild2Id : orgChild2.id, + orgChild3Id : orgChild3.id, orgChild4Id : orgChild4.id, + current_holderId: IsNull() || "", + }, + }), + totalRootPositionNextUse: await this.posMasterRepository.count({ + where: { + orgRevisionId: orgRoot.orgRevisionId, + orgRootId: orgRoot.id, + orgChild1Id : orgChild1.id, orgChild2Id : orgChild2.id, + orgChild3Id : orgChild3.id, orgChild4Id : orgChild4.id, + next_holderId: Not(IsNull()) || Not(""), + }, + }), + totalRootPositionNextVacant: await this.posMasterRepository.count({ + where: { + orgRevisionId: orgRoot.orgRevisionId, + orgRootId: orgRoot.id, + orgChild1Id : orgChild1.id, orgChild2Id : orgChild2.id, + orgChild3Id : orgChild3.id, orgChild4Id : orgChild4.id, + next_holderId: IsNull() || "", + }, + }), })), ), })),