comment total

This commit is contained in:
mamoss 2025-05-22 15:33:38 +07:00
parent fc92c378e8
commit dcbc863f0b

View file

@ -38,6 +38,9 @@ import { EmployeeTempPosMaster } from "../entities/EmployeeTempPosMaster";
import { AuthRole } from "../entities/AuthRole"; import { AuthRole } from "../entities/AuthRole";
import { PosType } from "../entities/PosType"; import { PosType } from "../entities/PosType";
import { PosLevel } from "../entities/PosLevel"; import { PosLevel } from "../entities/PosLevel";
import { promisify } from "util";
const REDIS_HOST = process.env.REDIS_HOST;
const REDIS_PORT = process.env.REDIS_PORT;
@Route("api/v1/org") @Route("api/v1/org")
@Tags("Organization") @Tags("Organization")
@ -64,6 +67,7 @@ export class OrganizationController extends Controller {
private employeeTempPosMasterRepository = AppDataSource.getRepository(EmployeeTempPosMaster); private employeeTempPosMasterRepository = AppDataSource.getRepository(EmployeeTempPosMaster);
private posTypeRepository = AppDataSource.getRepository(PosType); private posTypeRepository = AppDataSource.getRepository(PosType);
private posLevelRepository = AppDataSource.getRepository(PosLevel); private posLevelRepository = AppDataSource.getRepository(PosLevel);
private redis = require("redis");
/** /**
* API * API
@ -6222,6 +6226,7 @@ export class OrganizationController extends Controller {
) { ) {
_data = await new permission().PermissionOrgList(request, system.trim().toUpperCase()); _data = await new permission().PermissionOrgList(request, system.trim().toUpperCase());
} }
const orgRootData = await AppDataSource.getRepository(OrgRoot) const orgRootData = await AppDataSource.getRepository(OrgRoot)
.createQueryBuilder("orgRoot") .createQueryBuilder("orgRoot")
.where("orgRoot.orgRevisionId = :id", { id }) .where("orgRoot.orgRevisionId = :id", { id })
@ -6418,18 +6423,18 @@ export class OrganizationController extends Controller {
// const formattedData = orgRootData.map((orgRoot) => { // const formattedData = orgRootData.map((orgRoot) => {
const formattedData = await Promise.all( const formattedData = await Promise.all(
orgRootData.map(async (orgRoot) => { orgRootData.map(async (orgRoot) => {
const sum0 = await this.posMasterRepository.find({ // const sum0 = await this.posMasterRepository.find({
where: { orgRevisionId: orgRoot.orgRevisionId, orgRootId: orgRoot.id }, // where: { orgRevisionId: orgRoot.orgRevisionId, orgRootId: orgRoot.id },
select: [ // select: [
"current_holderId", // "current_holderId",
"next_holderId", // "next_holderId",
"orgRootId", // "orgRootId",
"orgChild1Id", // "orgChild1Id",
"orgChild2Id", // "orgChild2Id",
"orgChild3Id", // "orgChild3Id",
"orgChild4Id", // "orgChild4Id",
], // ],
}); // });
return { return {
orgTreeId: orgRoot.id, orgTreeId: orgRoot.id,
orgTreeDnaId: orgRoot.ancestorDNA, orgTreeDnaId: orgRoot.ancestorDNA,
@ -6454,82 +6459,82 @@ export class OrganizationController extends Controller {
responsibility: orgRoot.responsibility, responsibility: orgRoot.responsibility,
labelName: labelName:
orgRoot.orgRootName + " " + orgRoot.orgRootCode + "00" + " " + orgRoot.orgRootShortName, orgRoot.orgRootName + " " + orgRoot.orgRootCode + "00" + " " + orgRoot.orgRootShortName,
totalPosition: sum0.length + 1, // totalPosition: sum0.length + 1,
totalPositionCurrentUse: // totalPositionCurrentUse:
sum0.filter((x) => x.current_holderId != null && x.current_holderId != "").length + 1, // sum0.filter((x) => x.current_holderId != null && x.current_holderId != "").length + 1,
totalPositionCurrentVacant: // totalPositionCurrentVacant:
sum0.filter((x) => x.current_holderId == null || x.current_holderId == "").length + 1, // sum0.filter((x) => x.current_holderId == null || x.current_holderId == "").length + 1,
totalPositionNextUse: // totalPositionNextUse:
sum0.filter((x) => x.next_holderId != null && x.next_holderId != "").length + 1, // sum0.filter((x) => x.next_holderId != null && x.next_holderId != "").length + 1,
totalPositionNextVacant: // totalPositionNextVacant:
sum0.filter((x) => x.next_holderId == null || x.next_holderId == "").length + 1, // sum0.filter((x) => x.next_holderId == null || x.next_holderId == "").length + 1,
totalRootPosition: // totalRootPosition:
sum0.filter( // sum0.filter(
(x) => // (x) =>
(x.orgChild1Id == null || x.orgChild1Id == "") && // (x.orgChild1Id == null || x.orgChild1Id == "") &&
(x.orgChild2Id == null || x.orgChild2Id == "") && // (x.orgChild2Id == null || x.orgChild2Id == "") &&
(x.orgChild3Id == null || x.orgChild3Id == "") && // (x.orgChild3Id == null || x.orgChild3Id == "") &&
(x.orgChild4Id == null || x.orgChild4Id == ""), // (x.orgChild4Id == null || x.orgChild4Id == ""),
).length + 1, // ).length + 1,
totalRootPositionCurrentUse: // totalRootPositionCurrentUse:
sum0.filter( // sum0.filter(
(x) => // (x) =>
(x.orgChild1Id == null || x.orgChild1Id == "") && // (x.orgChild1Id == null || x.orgChild1Id == "") &&
(x.orgChild2Id == null || x.orgChild2Id == "") && // (x.orgChild2Id == null || x.orgChild2Id == "") &&
(x.orgChild3Id == null || x.orgChild3Id == "") && // (x.orgChild3Id == null || x.orgChild3Id == "") &&
(x.orgChild4Id == null || x.orgChild4Id == "") && // (x.orgChild4Id == null || x.orgChild4Id == "") &&
x.current_holderId != null && // x.current_holderId != null &&
x.current_holderId != "", // x.current_holderId != "",
).length + 1, // ).length + 1,
totalRootPositionCurrentVacant: // totalRootPositionCurrentVacant:
sum0.filter( // sum0.filter(
(x) => // (x) =>
(x.orgChild1Id == null || x.orgChild1Id == "") && // (x.orgChild1Id == null || x.orgChild1Id == "") &&
(x.orgChild2Id == null || x.orgChild2Id == "") && // (x.orgChild2Id == null || x.orgChild2Id == "") &&
(x.orgChild3Id == null || x.orgChild3Id == "") && // (x.orgChild3Id == null || x.orgChild3Id == "") &&
(x.orgChild4Id == null || x.orgChild4Id == "") && // (x.orgChild4Id == null || x.orgChild4Id == "") &&
(x.current_holderId == null || x.current_holderId == ""), // (x.current_holderId == null || x.current_holderId == ""),
).length + 1, // ).length + 1,
totalRootPositionNextUse: // totalRootPositionNextUse:
sum0.filter( // sum0.filter(
(x) => // (x) =>
(x.orgChild1Id == null || x.orgChild1Id == "") && // (x.orgChild1Id == null || x.orgChild1Id == "") &&
(x.orgChild2Id == null || x.orgChild2Id == "") && // (x.orgChild2Id == null || x.orgChild2Id == "") &&
(x.orgChild3Id == null || x.orgChild3Id == "") && // (x.orgChild3Id == null || x.orgChild3Id == "") &&
(x.orgChild4Id == null || x.orgChild4Id == "") && // (x.orgChild4Id == null || x.orgChild4Id == "") &&
x.next_holderId != null && // x.next_holderId != null &&
x.next_holderId != "", // x.next_holderId != "",
).length + 1, // ).length + 1,
totalRootPositionNextVacant: // totalRootPositionNextVacant:
sum0.filter( // sum0.filter(
(x) => // (x) =>
(x.orgChild1Id == null || x.orgChild1Id == "") && // (x.orgChild1Id == null || x.orgChild1Id == "") &&
(x.orgChild2Id == null || x.orgChild2Id == "") && // (x.orgChild2Id == null || x.orgChild2Id == "") &&
(x.orgChild3Id == null || x.orgChild3Id == "") && // (x.orgChild3Id == null || x.orgChild3Id == "") &&
(x.orgChild4Id == null || x.orgChild4Id == "") && // (x.orgChild4Id == null || x.orgChild4Id == "") &&
(x.next_holderId == null || x.next_holderId == ""), // (x.next_holderId == null || x.next_holderId == ""),
).length + 1, // ).length + 1,
children: await Promise.all( children: await Promise.all(
orgChild1Data orgChild1Data
.filter((orgChild1) => orgChild1.orgRootId === orgRoot.id) .filter((orgChild1) => orgChild1.orgRootId === orgRoot.id)
.map(async (orgChild1) => { .map(async (orgChild1) => {
const sum1 = await this.posMasterRepository.find({ // const sum1 = await this.posMasterRepository.find({
where: { // where: {
orgRevisionId: orgRoot.orgRevisionId, // orgRevisionId: orgRoot.orgRevisionId,
orgRootId: orgRoot.id, // orgRootId: orgRoot.id,
orgChild1Id: orgChild1.id, // orgChild1Id: orgChild1.id,
}, // },
select: [ // select: [
"current_holderId", // "current_holderId",
"next_holderId", // "next_holderId",
"orgRootId", // "orgRootId",
"orgChild1Id", // "orgChild1Id",
"orgChild2Id", // "orgChild2Id",
"orgChild3Id", // "orgChild3Id",
"orgChild4Id", // "orgChild4Id",
], // ],
}); // });
return { return {
orgTreeId: orgChild1.id, orgTreeId: orgChild1.id,
orgTreeDnaId: orgChild1.ancestorDNA, orgTreeDnaId: orgChild1.ancestorDNA,
@ -6569,80 +6574,80 @@ export class OrganizationController extends Controller {
"00" + "00" +
" " + " " +
orgRoot.orgRootShortName, orgRoot.orgRootShortName,
totalPosition: sum1.length + 1, // totalPosition: sum1.length + 1,
totalPositionCurrentUse: // totalPositionCurrentUse:
sum1.filter((x) => x.current_holderId != null && x.current_holderId != "") // sum1.filter((x) => x.current_holderId != null && x.current_holderId != "")
.length + 1, // .length + 1,
totalPositionCurrentVacant: // totalPositionCurrentVacant:
sum1.filter((x) => x.current_holderId == null || x.current_holderId == "") // sum1.filter((x) => x.current_holderId == null || x.current_holderId == "")
.length + 1, // .length + 1,
totalPositionNextUse: // totalPositionNextUse:
sum1.filter((x) => x.next_holderId != null && x.next_holderId != "").length + 1, // sum1.filter((x) => x.next_holderId != null && x.next_holderId != "").length + 1,
totalPositionNextVacant: // totalPositionNextVacant:
sum1.filter((x) => x.next_holderId == null || x.next_holderId == "").length + 1, // sum1.filter((x) => x.next_holderId == null || x.next_holderId == "").length + 1,
totalRootPosition: // totalRootPosition:
sum1.filter( // sum1.filter(
(x) => // (x) =>
(x.orgChild2Id == null || x.orgChild2Id == "") && // (x.orgChild2Id == null || x.orgChild2Id == "") &&
(x.orgChild3Id == null || x.orgChild3Id == "") && // (x.orgChild3Id == null || x.orgChild3Id == "") &&
(x.orgChild4Id == null || x.orgChild4Id == ""), // (x.orgChild4Id == null || x.orgChild4Id == ""),
).length + 1, // ).length + 1,
totalRootPositionCurrentUse: // totalRootPositionCurrentUse:
sum1.filter( // sum1.filter(
(x) => // (x) =>
(x.orgChild2Id == null || x.orgChild2Id == "") && // (x.orgChild2Id == null || x.orgChild2Id == "") &&
(x.orgChild3Id == null || x.orgChild3Id == "") && // (x.orgChild3Id == null || x.orgChild3Id == "") &&
(x.orgChild4Id == null || x.orgChild4Id == "") && // (x.orgChild4Id == null || x.orgChild4Id == "") &&
x.current_holderId != null && // x.current_holderId != null &&
x.current_holderId != "", // x.current_holderId != "",
).length + 1, // ).length + 1,
totalRootPositionCurrentVacant: // totalRootPositionCurrentVacant:
sum1.filter( // sum1.filter(
(x) => // (x) =>
(x.orgChild2Id == null || x.orgChild2Id == "") && // (x.orgChild2Id == null || x.orgChild2Id == "") &&
(x.orgChild3Id == null || x.orgChild3Id == "") && // (x.orgChild3Id == null || x.orgChild3Id == "") &&
(x.orgChild4Id == null || x.orgChild4Id == "") && // (x.orgChild4Id == null || x.orgChild4Id == "") &&
(x.current_holderId == null || x.current_holderId == ""), // (x.current_holderId == null || x.current_holderId == ""),
).length + 1, // ).length + 1,
totalRootPositionNextUse: // totalRootPositionNextUse:
sum1.filter( // sum1.filter(
(x) => // (x) =>
(x.orgChild2Id == null || x.orgChild2Id == "") && // (x.orgChild2Id == null || x.orgChild2Id == "") &&
(x.orgChild3Id == null || x.orgChild3Id == "") && // (x.orgChild3Id == null || x.orgChild3Id == "") &&
(x.orgChild4Id == null || x.orgChild4Id == "") && // (x.orgChild4Id == null || x.orgChild4Id == "") &&
x.next_holderId != null && // x.next_holderId != null &&
x.next_holderId != "", // x.next_holderId != "",
).length + 1, // ).length + 1,
totalRootPositionNextVacant: // totalRootPositionNextVacant:
sum1.filter( // sum1.filter(
(x) => // (x) =>
(x.orgChild2Id == null || x.orgChild2Id == "") && // (x.orgChild2Id == null || x.orgChild2Id == "") &&
(x.orgChild3Id == null || x.orgChild3Id == "") && // (x.orgChild3Id == null || x.orgChild3Id == "") &&
(x.orgChild4Id == null || x.orgChild4Id == "") && // (x.orgChild4Id == null || x.orgChild4Id == "") &&
(x.next_holderId == null || x.next_holderId == ""), // (x.next_holderId == null || x.next_holderId == ""),
).length + 1, // ).length + 1,
children: await Promise.all( children: await Promise.all(
orgChild2Data orgChild2Data
.filter((orgChild2) => orgChild2.orgChild1Id === orgChild1.id) .filter((orgChild2) => orgChild2.orgChild1Id === orgChild1.id)
.map(async (orgChild2) => { .map(async (orgChild2) => {
const sum2 = await this.posMasterRepository.find({ // const sum2 = await this.posMasterRepository.find({
where: { // where: {
orgRevisionId: orgRoot.orgRevisionId, // orgRevisionId: orgRoot.orgRevisionId,
orgRootId: orgRoot.id, // orgRootId: orgRoot.id,
orgChild1Id: orgChild1.id, // orgChild1Id: orgChild1.id,
orgChild2Id: orgChild2.id, // orgChild2Id: orgChild2.id,
}, // },
select: [ // select: [
"current_holderId", // "current_holderId",
"next_holderId", // "next_holderId",
"orgRootId", // "orgRootId",
"orgChild1Id", // "orgChild1Id",
"orgChild2Id", // "orgChild2Id",
"orgChild3Id", // "orgChild3Id",
"orgChild4Id", // "orgChild4Id",
], // ],
}); // });
return { return {
orgTreeId: orgChild2.id, orgTreeId: orgChild2.id,
orgTreeDnaId: orgChild2.ancestorDNA, orgTreeDnaId: orgChild2.ancestorDNA,
@ -6689,80 +6694,80 @@ export class OrganizationController extends Controller {
"00" + "00" +
" " + " " +
orgRoot.orgRootShortName, orgRoot.orgRootShortName,
totalPosition: sum2.length + 1, // totalPosition: sum2.length + 1,
totalPositionCurrentUse: // totalPositionCurrentUse:
sum2.filter( // sum2.filter(
(x) => x.current_holderId != null && x.current_holderId != "", // (x) => x.current_holderId != null && x.current_holderId != "",
).length + 1, // ).length + 1,
totalPositionCurrentVacant: // totalPositionCurrentVacant:
sum2.filter( // sum2.filter(
(x) => x.current_holderId == null || x.current_holderId == "", // (x) => x.current_holderId == null || x.current_holderId == "",
).length + 1, // ).length + 1,
totalPositionNextUse: // totalPositionNextUse:
sum2.filter((x) => x.next_holderId != null && x.next_holderId != "") // sum2.filter((x) => x.next_holderId != null && x.next_holderId != "")
.length + 1, // .length + 1,
totalPositionNextVacant: // totalPositionNextVacant:
sum2.filter((x) => x.next_holderId == null || x.next_holderId == "") // sum2.filter((x) => x.next_holderId == null || x.next_holderId == "")
.length + 1, // .length + 1,
totalRootPosition: // totalRootPosition:
sum2.filter( // sum2.filter(
(x) => // (x) =>
(x.orgChild3Id == null || x.orgChild3Id == "") && // (x.orgChild3Id == null || x.orgChild3Id == "") &&
(x.orgChild4Id == null || x.orgChild4Id == ""), // (x.orgChild4Id == null || x.orgChild4Id == ""),
).length + 1, // ).length + 1,
totalRootPositionCurrentUse: // totalRootPositionCurrentUse:
sum2.filter( // sum2.filter(
(x) => // (x) =>
(x.orgChild3Id == null || x.orgChild3Id == "") && // (x.orgChild3Id == null || x.orgChild3Id == "") &&
(x.orgChild4Id == null || x.orgChild4Id == "") && // (x.orgChild4Id == null || x.orgChild4Id == "") &&
x.current_holderId != null && // x.current_holderId != null &&
x.current_holderId != "", // x.current_holderId != "",
).length + 1, // ).length + 1,
totalRootPositionCurrentVacant: // totalRootPositionCurrentVacant:
sum2.filter( // sum2.filter(
(x) => // (x) =>
(x.orgChild3Id == null || x.orgChild3Id == "") && // (x.orgChild3Id == null || x.orgChild3Id == "") &&
(x.orgChild4Id == null || x.orgChild4Id == "") && // (x.orgChild4Id == null || x.orgChild4Id == "") &&
(x.current_holderId == null || x.current_holderId == ""), // (x.current_holderId == null || x.current_holderId == ""),
).length + 1, // ).length + 1,
totalRootPositionNextUse: // totalRootPositionNextUse:
sum2.filter( // sum2.filter(
(x) => // (x) =>
(x.orgChild3Id == null || x.orgChild3Id == "") && // (x.orgChild3Id == null || x.orgChild3Id == "") &&
(x.orgChild4Id == null || x.orgChild4Id == "") && // (x.orgChild4Id == null || x.orgChild4Id == "") &&
x.next_holderId != null && // x.next_holderId != null &&
x.next_holderId != "", // x.next_holderId != "",
).length + 1, // ).length + 1,
totalRootPositionNextVacant: // totalRootPositionNextVacant:
sum2.filter( // sum2.filter(
(x) => // (x) =>
(x.orgChild3Id == null || x.orgChild3Id == "") && // (x.orgChild3Id == null || x.orgChild3Id == "") &&
(x.orgChild4Id == null || x.orgChild4Id == "") && // (x.orgChild4Id == null || x.orgChild4Id == "") &&
(x.next_holderId == null || x.next_holderId == ""), // (x.next_holderId == null || x.next_holderId == ""),
).length + 1, // ).length + 1,
children: await Promise.all( children: await Promise.all(
orgChild3Data orgChild3Data
.filter((orgChild3) => orgChild3.orgChild2Id === orgChild2.id) .filter((orgChild3) => orgChild3.orgChild2Id === orgChild2.id)
.map(async (orgChild3) => { .map(async (orgChild3) => {
const sum3 = await this.posMasterRepository.find({ // const sum3 = await this.posMasterRepository.find({
where: { // where: {
orgRevisionId: orgRoot.orgRevisionId, // orgRevisionId: orgRoot.orgRevisionId,
orgRootId: orgRoot.id, // orgRootId: orgRoot.id,
orgChild1Id: orgChild1.id, // orgChild1Id: orgChild1.id,
orgChild2Id: orgChild2.id, // orgChild2Id: orgChild2.id,
orgChild3Id: orgChild3.id, // orgChild3Id: orgChild3.id,
}, // },
select: [ // select: [
"current_holderId", // "current_holderId",
"next_holderId", // "next_holderId",
"orgRootId", // "orgRootId",
"orgChild1Id", // "orgChild1Id",
"orgChild2Id", // "orgChild2Id",
"orgChild3Id", // "orgChild3Id",
"orgChild4Id", // "orgChild4Id",
], // ],
}); // });
return { return {
orgTreeId: orgChild3.id, orgTreeId: orgChild3.id,
orgTreeDnaId: orgChild3.ancestorDNA, orgTreeDnaId: orgChild3.ancestorDNA,
@ -6816,76 +6821,76 @@ export class OrganizationController extends Controller {
"00" + "00" +
" " + " " +
orgRoot.orgRootShortName, orgRoot.orgRootShortName,
totalPosition: sum3.length + 1, // totalPosition: sum3.length + 1,
totalPositionCurrentUse: // totalPositionCurrentUse:
sum3.filter( // sum3.filter(
(x) => x.current_holderId != null && x.current_holderId != "", // (x) => x.current_holderId != null && x.current_holderId != "",
).length + 1, // ).length + 1,
totalPositionCurrentVacant: // totalPositionCurrentVacant:
sum3.filter( // sum3.filter(
(x) => x.current_holderId == null || x.current_holderId == "", // (x) => x.current_holderId == null || x.current_holderId == "",
).length + 1, // ).length + 1,
totalPositionNextUse: // totalPositionNextUse:
sum3.filter( // sum3.filter(
(x) => x.next_holderId != null && x.next_holderId != "", // (x) => x.next_holderId != null && x.next_holderId != "",
).length + 1, // ).length + 1,
totalPositionNextVacant: // totalPositionNextVacant:
sum3.filter( // sum3.filter(
(x) => x.next_holderId == null || x.next_holderId == "", // (x) => x.next_holderId == null || x.next_holderId == "",
).length + 1, // ).length + 1,
totalRootPosition: // totalRootPosition:
sum3.filter((x) => x.orgChild4Id == null || x.orgChild4Id == "") // sum3.filter((x) => x.orgChild4Id == null || x.orgChild4Id == "")
.length + 1, // .length + 1,
totalRootPositionCurrentUse: // totalRootPositionCurrentUse:
sum3.filter( // sum3.filter(
(x) => // (x) =>
(x.orgChild4Id == null || x.orgChild4Id == "") && // (x.orgChild4Id == null || x.orgChild4Id == "") &&
x.current_holderId != null && // x.current_holderId != null &&
x.current_holderId != "", // x.current_holderId != "",
).length + 1, // ).length + 1,
totalRootPositionCurrentVacant: // totalRootPositionCurrentVacant:
sum3.filter( // sum3.filter(
(x) => // (x) =>
(x.orgChild4Id == null || x.orgChild4Id == "") && // (x.orgChild4Id == null || x.orgChild4Id == "") &&
(x.current_holderId == null || x.current_holderId == ""), // (x.current_holderId == null || x.current_holderId == ""),
).length + 1, // ).length + 1,
totalRootPositionNextUse: // totalRootPositionNextUse:
sum3.filter( // sum3.filter(
(x) => // (x) =>
(x.orgChild4Id == null || x.orgChild4Id == "") && // (x.orgChild4Id == null || x.orgChild4Id == "") &&
x.next_holderId != null && // x.next_holderId != null &&
x.next_holderId != "", // x.next_holderId != "",
).length + 1, // ).length + 1,
totalRootPositionNextVacant: // totalRootPositionNextVacant:
sum3.filter( // sum3.filter(
(x) => // (x) =>
(x.orgChild4Id == null || x.orgChild4Id == "") && // (x.orgChild4Id == null || x.orgChild4Id == "") &&
(x.next_holderId == null || x.next_holderId == ""), // (x.next_holderId == null || x.next_holderId == ""),
).length + 1, // ).length + 1,
children: await Promise.all( children: await Promise.all(
orgChild4Data orgChild4Data
.filter((orgChild4) => orgChild4.orgChild3Id === orgChild3.id) .filter((orgChild4) => orgChild4.orgChild3Id === orgChild3.id)
.map(async (orgChild4) => { .map(async (orgChild4) => {
const sum4 = await this.posMasterRepository.find({ // const sum4 = await this.posMasterRepository.find({
where: { // where: {
orgRevisionId: orgRoot.orgRevisionId, // orgRevisionId: orgRoot.orgRevisionId,
orgRootId: orgRoot.id, // orgRootId: orgRoot.id,
orgChild1Id: orgChild1.id, // orgChild1Id: orgChild1.id,
orgChild2Id: orgChild2.id, // orgChild2Id: orgChild2.id,
orgChild3Id: orgChild3.id, // orgChild3Id: orgChild3.id,
orgChild4Id: orgChild4.id, // orgChild4Id: orgChild4.id,
}, // },
select: [ // select: [
"current_holderId", // "current_holderId",
"next_holderId", // "next_holderId",
"orgRootId", // "orgRootId",
"orgChild1Id", // "orgChild1Id",
"orgChild2Id", // "orgChild2Id",
"orgChild3Id", // "orgChild3Id",
"orgChild4Id", // "orgChild4Id",
], // ],
}); // });
return { return {
orgTreeId: orgChild4.id, orgTreeId: orgChild4.id,
orgTreeDnaId: orgChild4.ancestorDNA, orgTreeDnaId: orgChild4.ancestorDNA,
@ -6946,52 +6951,52 @@ export class OrganizationController extends Controller {
"00" + "00" +
" " + " " +
orgRoot.orgRootShortName, orgRoot.orgRootShortName,
totalPosition: sum4.length + 1, // totalPosition: sum4.length + 1,
totalPositionCurrentUse: // totalPositionCurrentUse:
sum4.filter( // sum4.filter(
(x) => // (x) =>
x.current_holderId != null && // x.current_holderId != null &&
x.current_holderId != "", // x.current_holderId != "",
).length + 1, // ).length + 1,
totalPositionCurrentVacant: // totalPositionCurrentVacant:
sum4.filter( // sum4.filter(
(x) => // (x) =>
x.current_holderId == null || // x.current_holderId == null ||
x.current_holderId == "", // x.current_holderId == "",
).length + 1, // ).length + 1,
totalPositionNextUse: // totalPositionNextUse:
sum4.filter( // sum4.filter(
(x) => // (x) =>
x.next_holderId != null && x.next_holderId != "", // x.next_holderId != null && x.next_holderId != "",
).length + 1, // ).length + 1,
totalPositionNextVacant: // totalPositionNextVacant:
sum4.filter( // sum4.filter(
(x) => // (x) =>
x.next_holderId == null || x.next_holderId == "", // x.next_holderId == null || x.next_holderId == "",
).length + 1, // ).length + 1,
totalRootPosition: sum4.length + 1, // totalRootPosition: sum4.length + 1,
totalRootPositionCurrentUse: // totalRootPositionCurrentUse:
sum4.filter( // sum4.filter(
(x) => // (x) =>
x.current_holderId != null && // x.current_holderId != null &&
x.current_holderId != "", // x.current_holderId != "",
).length + 1, // ).length + 1,
totalRootPositionCurrentVacant: // totalRootPositionCurrentVacant:
sum4.filter( // sum4.filter(
(x) => // (x) =>
x.current_holderId == null || // x.current_holderId == null ||
x.current_holderId == "", // x.current_holderId == "",
).length + 1, // ).length + 1,
totalRootPositionNextUse: // totalRootPositionNextUse:
sum4.filter( // sum4.filter(
(x) => // (x) =>
x.next_holderId != null && x.next_holderId != "", // x.next_holderId != null && x.next_holderId != "",
).length + 1, // ).length + 1,
totalRootPositionNextVacant: // totalRootPositionNextVacant:
sum4.filter( // sum4.filter(
(x) => // (x) =>
x.next_holderId == null || x.next_holderId == "", // x.next_holderId == null || x.next_holderId == "",
).length + 1, // ).length + 1,
}; };
}), }),
), ),