From 129c58efafb9330a0544b22c7057c5c99c686001 Mon Sep 17 00:00:00 2001 From: Kittapath Date: Tue, 6 Feb 2024 15:21:36 +0700 Subject: [PATCH] no message --- src/controllers/OrganizationController.ts | 56 +++++++++++++++++++---- 1 file changed, 46 insertions(+), 10 deletions(-) diff --git a/src/controllers/OrganizationController.ts b/src/controllers/OrganizationController.ts index 4c709294..7183a897 100644 --- a/src/controllers/OrganizationController.ts +++ b/src/controllers/OrganizationController.ts @@ -722,19 +722,35 @@ export class OrganizationController extends Controller { orgRevisionId: orgRoot.orgRevisionId, orgRootName: orgRoot.orgRootName, totalPosition: await this.posMasterRepository.count({ - where: { orgRootId: orgRoot.id }, + where: { orgRevisionId: orgRoot.orgRevisionId, orgRootId: orgRoot.id }, }), totalPositionCurrentUse: await this.posMasterRepository.count({ - where: { orgRootId: orgRoot.id, profileIdCurrentHolder: Not(IsNull()) || Not("") }, + where: { + orgRevisionId: orgRoot.orgRevisionId, + orgRootId: orgRoot.id, + profileIdCurrentHolder: Not(IsNull()) || Not(""), + }, }), totalPositionCurrentVacant: await this.posMasterRepository.count({ - where: { orgRootId: orgRoot.id, profileIdCurrentHolder: IsNull() || "" }, + where: { + orgRevisionId: orgRoot.orgRevisionId, + orgRootId: orgRoot.id, + profileIdCurrentHolder: IsNull() || "", + }, }), totalPositionNextUse: await this.posMasterRepository.count({ - where: { orgRootId: orgRoot.id, profileIdNextHolder: Not(IsNull()) || Not("") }, + where: { + orgRevisionId: orgRoot.orgRevisionId, + orgRootId: orgRoot.id, + profileIdNextHolder: Not(IsNull()) || Not(""), + }, }), totalPositionNextVacant: await this.posMasterRepository.count({ - where: { orgRootId: orgRoot.id, profileIdNextHolder: IsNull() || "" }, + where: { + orgRevisionId: orgRoot.orgRevisionId, + orgRootId: orgRoot.id, + profileIdNextHolder: IsNull() || "", + }, }), children: await Promise.all( @@ -758,25 +774,35 @@ export class OrganizationController extends Controller { orgRevisionId: orgRoot.orgRevisionId, orgRootName: orgRoot.orgRootName, totalPosition: await this.posMasterRepository.count({ - where: { orgChild1Id: orgChild1.id }, + where: { orgRevisionId: orgRoot.orgRevisionId, orgChild1Id: orgChild1.id }, }), totalPositionCurrentUse: await this.posMasterRepository.count({ where: { + orgRevisionId: orgRoot.orgRevisionId, orgChild1Id: orgChild1.id, profileIdCurrentHolder: Not(IsNull()) || Not(""), }, }), totalPositionCurrentVacant: await this.posMasterRepository.count({ - where: { orgChild1Id: orgChild1.id, profileIdCurrentHolder: IsNull() || "" }, + where: { + orgRevisionId: orgRoot.orgRevisionId, + orgChild1Id: orgChild1.id, + profileIdCurrentHolder: IsNull() || "", + }, }), totalPositionNextUse: await this.posMasterRepository.count({ where: { + orgRevisionId: orgRoot.orgRevisionId, orgChild1Id: orgChild1.id, profileIdNextHolder: Not(IsNull()) || Not(""), }, }), totalPositionNextVacant: await this.posMasterRepository.count({ - where: { orgChild1Id: orgChild1.id, profileIdNextHolder: IsNull() || "" }, + where: { + orgRevisionId: orgRoot.orgRevisionId, + orgChild1Id: orgChild1.id, + profileIdNextHolder: IsNull() || "", + }, }), children: await Promise.all( orgChild2Data @@ -799,28 +825,38 @@ export class OrganizationController extends Controller { orgRevisionId: orgRoot.orgRevisionId, orgRootName: orgRoot.orgRootName, totalPosition: await this.posMasterRepository.count({ - where: { orgChild2Id: orgChild2.id }, + where: { + orgRevisionId: orgRoot.orgRevisionId, + orgChild2Id: orgChild2.id, + }, }), totalPositionCurrentUse: await this.posMasterRepository.count({ where: { + orgRevisionId: orgRoot.orgRevisionId, orgChild2Id: orgChild2.id, profileIdCurrentHolder: Not(IsNull()) || Not(""), }, }), totalPositionCurrentVacant: await this.posMasterRepository.count({ where: { + orgRevisionId: orgRoot.orgRevisionId, orgChild2Id: orgChild2.id, profileIdCurrentHolder: IsNull() || "", }, }), totalPositionNextUse: await this.posMasterRepository.count({ where: { + orgRevisionId: orgRoot.orgRevisionId, orgChild2Id: orgChild2.id, profileIdNextHolder: Not(IsNull()) || Not(""), }, }), totalPositionNextVacant: await this.posMasterRepository.count({ - where: { orgChild2Id: orgChild2.id, profileIdNextHolder: IsNull() || "" }, + where: { + orgRevisionId: orgRoot.orgRevisionId, + orgChild2Id: orgChild2.id, + profileIdNextHolder: IsNull() || "", + }, }), children: await Promise.all( orgChild3Data