comment total
This commit is contained in:
parent
fc92c378e8
commit
dcbc863f0b
1 changed files with 337 additions and 332 deletions
|
|
@ -38,6 +38,9 @@ import { EmployeeTempPosMaster } from "../entities/EmployeeTempPosMaster";
|
|||
import { AuthRole } from "../entities/AuthRole";
|
||||
import { PosType } from "../entities/PosType";
|
||||
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")
|
||||
@Tags("Organization")
|
||||
|
|
@ -64,6 +67,7 @@ export class OrganizationController extends Controller {
|
|||
private employeeTempPosMasterRepository = AppDataSource.getRepository(EmployeeTempPosMaster);
|
||||
private posTypeRepository = AppDataSource.getRepository(PosType);
|
||||
private posLevelRepository = AppDataSource.getRepository(PosLevel);
|
||||
private redis = require("redis");
|
||||
|
||||
/**
|
||||
* API ล้างข้อมูล
|
||||
|
|
@ -6222,6 +6226,7 @@ export class OrganizationController extends Controller {
|
|||
) {
|
||||
_data = await new permission().PermissionOrgList(request, system.trim().toUpperCase());
|
||||
}
|
||||
|
||||
const orgRootData = await AppDataSource.getRepository(OrgRoot)
|
||||
.createQueryBuilder("orgRoot")
|
||||
.where("orgRoot.orgRevisionId = :id", { id })
|
||||
|
|
@ -6418,18 +6423,18 @@ export class OrganizationController extends Controller {
|
|||
// const formattedData = orgRootData.map((orgRoot) => {
|
||||
const formattedData = await Promise.all(
|
||||
orgRootData.map(async (orgRoot) => {
|
||||
const sum0 = await this.posMasterRepository.find({
|
||||
where: { orgRevisionId: orgRoot.orgRevisionId, orgRootId: orgRoot.id },
|
||||
select: [
|
||||
"current_holderId",
|
||||
"next_holderId",
|
||||
"orgRootId",
|
||||
"orgChild1Id",
|
||||
"orgChild2Id",
|
||||
"orgChild3Id",
|
||||
"orgChild4Id",
|
||||
],
|
||||
});
|
||||
// const sum0 = await this.posMasterRepository.find({
|
||||
// where: { orgRevisionId: orgRoot.orgRevisionId, orgRootId: orgRoot.id },
|
||||
// select: [
|
||||
// "current_holderId",
|
||||
// "next_holderId",
|
||||
// "orgRootId",
|
||||
// "orgChild1Id",
|
||||
// "orgChild2Id",
|
||||
// "orgChild3Id",
|
||||
// "orgChild4Id",
|
||||
// ],
|
||||
// });
|
||||
return {
|
||||
orgTreeId: orgRoot.id,
|
||||
orgTreeDnaId: orgRoot.ancestorDNA,
|
||||
|
|
@ -6454,82 +6459,82 @@ export class OrganizationController extends Controller {
|
|||
responsibility: orgRoot.responsibility,
|
||||
labelName:
|
||||
orgRoot.orgRootName + " " + orgRoot.orgRootCode + "00" + " " + orgRoot.orgRootShortName,
|
||||
totalPosition: sum0.length + 1,
|
||||
totalPositionCurrentUse:
|
||||
sum0.filter((x) => x.current_holderId != null && x.current_holderId != "").length + 1,
|
||||
totalPositionCurrentVacant:
|
||||
sum0.filter((x) => x.current_holderId == null || x.current_holderId == "").length + 1,
|
||||
totalPositionNextUse:
|
||||
sum0.filter((x) => x.next_holderId != null && x.next_holderId != "").length + 1,
|
||||
totalPositionNextVacant:
|
||||
sum0.filter((x) => x.next_holderId == null || x.next_holderId == "").length + 1,
|
||||
totalRootPosition:
|
||||
sum0.filter(
|
||||
(x) =>
|
||||
(x.orgChild1Id == null || x.orgChild1Id == "") &&
|
||||
(x.orgChild2Id == null || x.orgChild2Id == "") &&
|
||||
(x.orgChild3Id == null || x.orgChild3Id == "") &&
|
||||
(x.orgChild4Id == null || x.orgChild4Id == ""),
|
||||
).length + 1,
|
||||
totalRootPositionCurrentUse:
|
||||
sum0.filter(
|
||||
(x) =>
|
||||
(x.orgChild1Id == null || x.orgChild1Id == "") &&
|
||||
(x.orgChild2Id == null || x.orgChild2Id == "") &&
|
||||
(x.orgChild3Id == null || x.orgChild3Id == "") &&
|
||||
(x.orgChild4Id == null || x.orgChild4Id == "") &&
|
||||
x.current_holderId != null &&
|
||||
x.current_holderId != "",
|
||||
).length + 1,
|
||||
totalRootPositionCurrentVacant:
|
||||
sum0.filter(
|
||||
(x) =>
|
||||
(x.orgChild1Id == null || x.orgChild1Id == "") &&
|
||||
(x.orgChild2Id == null || x.orgChild2Id == "") &&
|
||||
(x.orgChild3Id == null || x.orgChild3Id == "") &&
|
||||
(x.orgChild4Id == null || x.orgChild4Id == "") &&
|
||||
(x.current_holderId == null || x.current_holderId == ""),
|
||||
).length + 1,
|
||||
totalRootPositionNextUse:
|
||||
sum0.filter(
|
||||
(x) =>
|
||||
(x.orgChild1Id == null || x.orgChild1Id == "") &&
|
||||
(x.orgChild2Id == null || x.orgChild2Id == "") &&
|
||||
(x.orgChild3Id == null || x.orgChild3Id == "") &&
|
||||
(x.orgChild4Id == null || x.orgChild4Id == "") &&
|
||||
x.next_holderId != null &&
|
||||
x.next_holderId != "",
|
||||
).length + 1,
|
||||
totalRootPositionNextVacant:
|
||||
sum0.filter(
|
||||
(x) =>
|
||||
(x.orgChild1Id == null || x.orgChild1Id == "") &&
|
||||
(x.orgChild2Id == null || x.orgChild2Id == "") &&
|
||||
(x.orgChild3Id == null || x.orgChild3Id == "") &&
|
||||
(x.orgChild4Id == null || x.orgChild4Id == "") &&
|
||||
(x.next_holderId == null || x.next_holderId == ""),
|
||||
).length + 1,
|
||||
// totalPosition: sum0.length + 1,
|
||||
// totalPositionCurrentUse:
|
||||
// sum0.filter((x) => x.current_holderId != null && x.current_holderId != "").length + 1,
|
||||
// totalPositionCurrentVacant:
|
||||
// sum0.filter((x) => x.current_holderId == null || x.current_holderId == "").length + 1,
|
||||
// totalPositionNextUse:
|
||||
// sum0.filter((x) => x.next_holderId != null && x.next_holderId != "").length + 1,
|
||||
// totalPositionNextVacant:
|
||||
// sum0.filter((x) => x.next_holderId == null || x.next_holderId == "").length + 1,
|
||||
// totalRootPosition:
|
||||
// sum0.filter(
|
||||
// (x) =>
|
||||
// (x.orgChild1Id == null || x.orgChild1Id == "") &&
|
||||
// (x.orgChild2Id == null || x.orgChild2Id == "") &&
|
||||
// (x.orgChild3Id == null || x.orgChild3Id == "") &&
|
||||
// (x.orgChild4Id == null || x.orgChild4Id == ""),
|
||||
// ).length + 1,
|
||||
// totalRootPositionCurrentUse:
|
||||
// sum0.filter(
|
||||
// (x) =>
|
||||
// (x.orgChild1Id == null || x.orgChild1Id == "") &&
|
||||
// (x.orgChild2Id == null || x.orgChild2Id == "") &&
|
||||
// (x.orgChild3Id == null || x.orgChild3Id == "") &&
|
||||
// (x.orgChild4Id == null || x.orgChild4Id == "") &&
|
||||
// x.current_holderId != null &&
|
||||
// x.current_holderId != "",
|
||||
// ).length + 1,
|
||||
// totalRootPositionCurrentVacant:
|
||||
// sum0.filter(
|
||||
// (x) =>
|
||||
// (x.orgChild1Id == null || x.orgChild1Id == "") &&
|
||||
// (x.orgChild2Id == null || x.orgChild2Id == "") &&
|
||||
// (x.orgChild3Id == null || x.orgChild3Id == "") &&
|
||||
// (x.orgChild4Id == null || x.orgChild4Id == "") &&
|
||||
// (x.current_holderId == null || x.current_holderId == ""),
|
||||
// ).length + 1,
|
||||
// totalRootPositionNextUse:
|
||||
// sum0.filter(
|
||||
// (x) =>
|
||||
// (x.orgChild1Id == null || x.orgChild1Id == "") &&
|
||||
// (x.orgChild2Id == null || x.orgChild2Id == "") &&
|
||||
// (x.orgChild3Id == null || x.orgChild3Id == "") &&
|
||||
// (x.orgChild4Id == null || x.orgChild4Id == "") &&
|
||||
// x.next_holderId != null &&
|
||||
// x.next_holderId != "",
|
||||
// ).length + 1,
|
||||
// totalRootPositionNextVacant:
|
||||
// sum0.filter(
|
||||
// (x) =>
|
||||
// (x.orgChild1Id == null || x.orgChild1Id == "") &&
|
||||
// (x.orgChild2Id == null || x.orgChild2Id == "") &&
|
||||
// (x.orgChild3Id == null || x.orgChild3Id == "") &&
|
||||
// (x.orgChild4Id == null || x.orgChild4Id == "") &&
|
||||
// (x.next_holderId == null || x.next_holderId == ""),
|
||||
// ).length + 1,
|
||||
|
||||
children: await Promise.all(
|
||||
orgChild1Data
|
||||
.filter((orgChild1) => orgChild1.orgRootId === orgRoot.id)
|
||||
.map(async (orgChild1) => {
|
||||
const sum1 = await this.posMasterRepository.find({
|
||||
where: {
|
||||
orgRevisionId: orgRoot.orgRevisionId,
|
||||
orgRootId: orgRoot.id,
|
||||
orgChild1Id: orgChild1.id,
|
||||
},
|
||||
select: [
|
||||
"current_holderId",
|
||||
"next_holderId",
|
||||
"orgRootId",
|
||||
"orgChild1Id",
|
||||
"orgChild2Id",
|
||||
"orgChild3Id",
|
||||
"orgChild4Id",
|
||||
],
|
||||
});
|
||||
// const sum1 = await this.posMasterRepository.find({
|
||||
// where: {
|
||||
// orgRevisionId: orgRoot.orgRevisionId,
|
||||
// orgRootId: orgRoot.id,
|
||||
// orgChild1Id: orgChild1.id,
|
||||
// },
|
||||
// select: [
|
||||
// "current_holderId",
|
||||
// "next_holderId",
|
||||
// "orgRootId",
|
||||
// "orgChild1Id",
|
||||
// "orgChild2Id",
|
||||
// "orgChild3Id",
|
||||
// "orgChild4Id",
|
||||
// ],
|
||||
// });
|
||||
return {
|
||||
orgTreeId: orgChild1.id,
|
||||
orgTreeDnaId: orgChild1.ancestorDNA,
|
||||
|
|
@ -6569,80 +6574,80 @@ export class OrganizationController extends Controller {
|
|||
"00" +
|
||||
" " +
|
||||
orgRoot.orgRootShortName,
|
||||
totalPosition: sum1.length + 1,
|
||||
totalPositionCurrentUse:
|
||||
sum1.filter((x) => x.current_holderId != null && x.current_holderId != "")
|
||||
.length + 1,
|
||||
totalPositionCurrentVacant:
|
||||
sum1.filter((x) => x.current_holderId == null || x.current_holderId == "")
|
||||
.length + 1,
|
||||
totalPositionNextUse:
|
||||
sum1.filter((x) => x.next_holderId != null && x.next_holderId != "").length + 1,
|
||||
totalPositionNextVacant:
|
||||
sum1.filter((x) => x.next_holderId == null || x.next_holderId == "").length + 1,
|
||||
totalRootPosition:
|
||||
sum1.filter(
|
||||
(x) =>
|
||||
(x.orgChild2Id == null || x.orgChild2Id == "") &&
|
||||
(x.orgChild3Id == null || x.orgChild3Id == "") &&
|
||||
(x.orgChild4Id == null || x.orgChild4Id == ""),
|
||||
).length + 1,
|
||||
totalRootPositionCurrentUse:
|
||||
sum1.filter(
|
||||
(x) =>
|
||||
(x.orgChild2Id == null || x.orgChild2Id == "") &&
|
||||
(x.orgChild3Id == null || x.orgChild3Id == "") &&
|
||||
(x.orgChild4Id == null || x.orgChild4Id == "") &&
|
||||
x.current_holderId != null &&
|
||||
x.current_holderId != "",
|
||||
).length + 1,
|
||||
totalRootPositionCurrentVacant:
|
||||
sum1.filter(
|
||||
(x) =>
|
||||
(x.orgChild2Id == null || x.orgChild2Id == "") &&
|
||||
(x.orgChild3Id == null || x.orgChild3Id == "") &&
|
||||
(x.orgChild4Id == null || x.orgChild4Id == "") &&
|
||||
(x.current_holderId == null || x.current_holderId == ""),
|
||||
).length + 1,
|
||||
totalRootPositionNextUse:
|
||||
sum1.filter(
|
||||
(x) =>
|
||||
(x.orgChild2Id == null || x.orgChild2Id == "") &&
|
||||
(x.orgChild3Id == null || x.orgChild3Id == "") &&
|
||||
(x.orgChild4Id == null || x.orgChild4Id == "") &&
|
||||
x.next_holderId != null &&
|
||||
x.next_holderId != "",
|
||||
).length + 1,
|
||||
totalRootPositionNextVacant:
|
||||
sum1.filter(
|
||||
(x) =>
|
||||
(x.orgChild2Id == null || x.orgChild2Id == "") &&
|
||||
(x.orgChild3Id == null || x.orgChild3Id == "") &&
|
||||
(x.orgChild4Id == null || x.orgChild4Id == "") &&
|
||||
(x.next_holderId == null || x.next_holderId == ""),
|
||||
).length + 1,
|
||||
// totalPosition: sum1.length + 1,
|
||||
// totalPositionCurrentUse:
|
||||
// sum1.filter((x) => x.current_holderId != null && x.current_holderId != "")
|
||||
// .length + 1,
|
||||
// totalPositionCurrentVacant:
|
||||
// sum1.filter((x) => x.current_holderId == null || x.current_holderId == "")
|
||||
// .length + 1,
|
||||
// totalPositionNextUse:
|
||||
// sum1.filter((x) => x.next_holderId != null && x.next_holderId != "").length + 1,
|
||||
// totalPositionNextVacant:
|
||||
// sum1.filter((x) => x.next_holderId == null || x.next_holderId == "").length + 1,
|
||||
// totalRootPosition:
|
||||
// sum1.filter(
|
||||
// (x) =>
|
||||
// (x.orgChild2Id == null || x.orgChild2Id == "") &&
|
||||
// (x.orgChild3Id == null || x.orgChild3Id == "") &&
|
||||
// (x.orgChild4Id == null || x.orgChild4Id == ""),
|
||||
// ).length + 1,
|
||||
// totalRootPositionCurrentUse:
|
||||
// sum1.filter(
|
||||
// (x) =>
|
||||
// (x.orgChild2Id == null || x.orgChild2Id == "") &&
|
||||
// (x.orgChild3Id == null || x.orgChild3Id == "") &&
|
||||
// (x.orgChild4Id == null || x.orgChild4Id == "") &&
|
||||
// x.current_holderId != null &&
|
||||
// x.current_holderId != "",
|
||||
// ).length + 1,
|
||||
// totalRootPositionCurrentVacant:
|
||||
// sum1.filter(
|
||||
// (x) =>
|
||||
// (x.orgChild2Id == null || x.orgChild2Id == "") &&
|
||||
// (x.orgChild3Id == null || x.orgChild3Id == "") &&
|
||||
// (x.orgChild4Id == null || x.orgChild4Id == "") &&
|
||||
// (x.current_holderId == null || x.current_holderId == ""),
|
||||
// ).length + 1,
|
||||
// totalRootPositionNextUse:
|
||||
// sum1.filter(
|
||||
// (x) =>
|
||||
// (x.orgChild2Id == null || x.orgChild2Id == "") &&
|
||||
// (x.orgChild3Id == null || x.orgChild3Id == "") &&
|
||||
// (x.orgChild4Id == null || x.orgChild4Id == "") &&
|
||||
// x.next_holderId != null &&
|
||||
// x.next_holderId != "",
|
||||
// ).length + 1,
|
||||
// totalRootPositionNextVacant:
|
||||
// sum1.filter(
|
||||
// (x) =>
|
||||
// (x.orgChild2Id == null || x.orgChild2Id == "") &&
|
||||
// (x.orgChild3Id == null || x.orgChild3Id == "") &&
|
||||
// (x.orgChild4Id == null || x.orgChild4Id == "") &&
|
||||
// (x.next_holderId == null || x.next_holderId == ""),
|
||||
// ).length + 1,
|
||||
|
||||
children: await Promise.all(
|
||||
orgChild2Data
|
||||
.filter((orgChild2) => orgChild2.orgChild1Id === orgChild1.id)
|
||||
.map(async (orgChild2) => {
|
||||
const sum2 = await this.posMasterRepository.find({
|
||||
where: {
|
||||
orgRevisionId: orgRoot.orgRevisionId,
|
||||
orgRootId: orgRoot.id,
|
||||
orgChild1Id: orgChild1.id,
|
||||
orgChild2Id: orgChild2.id,
|
||||
},
|
||||
select: [
|
||||
"current_holderId",
|
||||
"next_holderId",
|
||||
"orgRootId",
|
||||
"orgChild1Id",
|
||||
"orgChild2Id",
|
||||
"orgChild3Id",
|
||||
"orgChild4Id",
|
||||
],
|
||||
});
|
||||
// const sum2 = await this.posMasterRepository.find({
|
||||
// where: {
|
||||
// orgRevisionId: orgRoot.orgRevisionId,
|
||||
// orgRootId: orgRoot.id,
|
||||
// orgChild1Id: orgChild1.id,
|
||||
// orgChild2Id: orgChild2.id,
|
||||
// },
|
||||
// select: [
|
||||
// "current_holderId",
|
||||
// "next_holderId",
|
||||
// "orgRootId",
|
||||
// "orgChild1Id",
|
||||
// "orgChild2Id",
|
||||
// "orgChild3Id",
|
||||
// "orgChild4Id",
|
||||
// ],
|
||||
// });
|
||||
return {
|
||||
orgTreeId: orgChild2.id,
|
||||
orgTreeDnaId: orgChild2.ancestorDNA,
|
||||
|
|
@ -6689,80 +6694,80 @@ export class OrganizationController extends Controller {
|
|||
"00" +
|
||||
" " +
|
||||
orgRoot.orgRootShortName,
|
||||
totalPosition: sum2.length + 1,
|
||||
totalPositionCurrentUse:
|
||||
sum2.filter(
|
||||
(x) => x.current_holderId != null && x.current_holderId != "",
|
||||
).length + 1,
|
||||
totalPositionCurrentVacant:
|
||||
sum2.filter(
|
||||
(x) => x.current_holderId == null || x.current_holderId == "",
|
||||
).length + 1,
|
||||
totalPositionNextUse:
|
||||
sum2.filter((x) => x.next_holderId != null && x.next_holderId != "")
|
||||
.length + 1,
|
||||
totalPositionNextVacant:
|
||||
sum2.filter((x) => x.next_holderId == null || x.next_holderId == "")
|
||||
.length + 1,
|
||||
totalRootPosition:
|
||||
sum2.filter(
|
||||
(x) =>
|
||||
(x.orgChild3Id == null || x.orgChild3Id == "") &&
|
||||
(x.orgChild4Id == null || x.orgChild4Id == ""),
|
||||
).length + 1,
|
||||
totalRootPositionCurrentUse:
|
||||
sum2.filter(
|
||||
(x) =>
|
||||
(x.orgChild3Id == null || x.orgChild3Id == "") &&
|
||||
(x.orgChild4Id == null || x.orgChild4Id == "") &&
|
||||
x.current_holderId != null &&
|
||||
x.current_holderId != "",
|
||||
).length + 1,
|
||||
totalRootPositionCurrentVacant:
|
||||
sum2.filter(
|
||||
(x) =>
|
||||
(x.orgChild3Id == null || x.orgChild3Id == "") &&
|
||||
(x.orgChild4Id == null || x.orgChild4Id == "") &&
|
||||
(x.current_holderId == null || x.current_holderId == ""),
|
||||
).length + 1,
|
||||
totalRootPositionNextUse:
|
||||
sum2.filter(
|
||||
(x) =>
|
||||
(x.orgChild3Id == null || x.orgChild3Id == "") &&
|
||||
(x.orgChild4Id == null || x.orgChild4Id == "") &&
|
||||
x.next_holderId != null &&
|
||||
x.next_holderId != "",
|
||||
).length + 1,
|
||||
totalRootPositionNextVacant:
|
||||
sum2.filter(
|
||||
(x) =>
|
||||
(x.orgChild3Id == null || x.orgChild3Id == "") &&
|
||||
(x.orgChild4Id == null || x.orgChild4Id == "") &&
|
||||
(x.next_holderId == null || x.next_holderId == ""),
|
||||
).length + 1,
|
||||
// totalPosition: sum2.length + 1,
|
||||
// totalPositionCurrentUse:
|
||||
// sum2.filter(
|
||||
// (x) => x.current_holderId != null && x.current_holderId != "",
|
||||
// ).length + 1,
|
||||
// totalPositionCurrentVacant:
|
||||
// sum2.filter(
|
||||
// (x) => x.current_holderId == null || x.current_holderId == "",
|
||||
// ).length + 1,
|
||||
// totalPositionNextUse:
|
||||
// sum2.filter((x) => x.next_holderId != null && x.next_holderId != "")
|
||||
// .length + 1,
|
||||
// totalPositionNextVacant:
|
||||
// sum2.filter((x) => x.next_holderId == null || x.next_holderId == "")
|
||||
// .length + 1,
|
||||
// totalRootPosition:
|
||||
// sum2.filter(
|
||||
// (x) =>
|
||||
// (x.orgChild3Id == null || x.orgChild3Id == "") &&
|
||||
// (x.orgChild4Id == null || x.orgChild4Id == ""),
|
||||
// ).length + 1,
|
||||
// totalRootPositionCurrentUse:
|
||||
// sum2.filter(
|
||||
// (x) =>
|
||||
// (x.orgChild3Id == null || x.orgChild3Id == "") &&
|
||||
// (x.orgChild4Id == null || x.orgChild4Id == "") &&
|
||||
// x.current_holderId != null &&
|
||||
// x.current_holderId != "",
|
||||
// ).length + 1,
|
||||
// totalRootPositionCurrentVacant:
|
||||
// sum2.filter(
|
||||
// (x) =>
|
||||
// (x.orgChild3Id == null || x.orgChild3Id == "") &&
|
||||
// (x.orgChild4Id == null || x.orgChild4Id == "") &&
|
||||
// (x.current_holderId == null || x.current_holderId == ""),
|
||||
// ).length + 1,
|
||||
// totalRootPositionNextUse:
|
||||
// sum2.filter(
|
||||
// (x) =>
|
||||
// (x.orgChild3Id == null || x.orgChild3Id == "") &&
|
||||
// (x.orgChild4Id == null || x.orgChild4Id == "") &&
|
||||
// x.next_holderId != null &&
|
||||
// x.next_holderId != "",
|
||||
// ).length + 1,
|
||||
// totalRootPositionNextVacant:
|
||||
// sum2.filter(
|
||||
// (x) =>
|
||||
// (x.orgChild3Id == null || x.orgChild3Id == "") &&
|
||||
// (x.orgChild4Id == null || x.orgChild4Id == "") &&
|
||||
// (x.next_holderId == null || x.next_holderId == ""),
|
||||
// ).length + 1,
|
||||
|
||||
children: await Promise.all(
|
||||
orgChild3Data
|
||||
.filter((orgChild3) => orgChild3.orgChild2Id === orgChild2.id)
|
||||
.map(async (orgChild3) => {
|
||||
const sum3 = await this.posMasterRepository.find({
|
||||
where: {
|
||||
orgRevisionId: orgRoot.orgRevisionId,
|
||||
orgRootId: orgRoot.id,
|
||||
orgChild1Id: orgChild1.id,
|
||||
orgChild2Id: orgChild2.id,
|
||||
orgChild3Id: orgChild3.id,
|
||||
},
|
||||
select: [
|
||||
"current_holderId",
|
||||
"next_holderId",
|
||||
"orgRootId",
|
||||
"orgChild1Id",
|
||||
"orgChild2Id",
|
||||
"orgChild3Id",
|
||||
"orgChild4Id",
|
||||
],
|
||||
});
|
||||
// const sum3 = await this.posMasterRepository.find({
|
||||
// where: {
|
||||
// orgRevisionId: orgRoot.orgRevisionId,
|
||||
// orgRootId: orgRoot.id,
|
||||
// orgChild1Id: orgChild1.id,
|
||||
// orgChild2Id: orgChild2.id,
|
||||
// orgChild3Id: orgChild3.id,
|
||||
// },
|
||||
// select: [
|
||||
// "current_holderId",
|
||||
// "next_holderId",
|
||||
// "orgRootId",
|
||||
// "orgChild1Id",
|
||||
// "orgChild2Id",
|
||||
// "orgChild3Id",
|
||||
// "orgChild4Id",
|
||||
// ],
|
||||
// });
|
||||
return {
|
||||
orgTreeId: orgChild3.id,
|
||||
orgTreeDnaId: orgChild3.ancestorDNA,
|
||||
|
|
@ -6816,76 +6821,76 @@ export class OrganizationController extends Controller {
|
|||
"00" +
|
||||
" " +
|
||||
orgRoot.orgRootShortName,
|
||||
totalPosition: sum3.length + 1,
|
||||
totalPositionCurrentUse:
|
||||
sum3.filter(
|
||||
(x) => x.current_holderId != null && x.current_holderId != "",
|
||||
).length + 1,
|
||||
totalPositionCurrentVacant:
|
||||
sum3.filter(
|
||||
(x) => x.current_holderId == null || x.current_holderId == "",
|
||||
).length + 1,
|
||||
totalPositionNextUse:
|
||||
sum3.filter(
|
||||
(x) => x.next_holderId != null && x.next_holderId != "",
|
||||
).length + 1,
|
||||
totalPositionNextVacant:
|
||||
sum3.filter(
|
||||
(x) => x.next_holderId == null || x.next_holderId == "",
|
||||
).length + 1,
|
||||
totalRootPosition:
|
||||
sum3.filter((x) => x.orgChild4Id == null || x.orgChild4Id == "")
|
||||
.length + 1,
|
||||
totalRootPositionCurrentUse:
|
||||
sum3.filter(
|
||||
(x) =>
|
||||
(x.orgChild4Id == null || x.orgChild4Id == "") &&
|
||||
x.current_holderId != null &&
|
||||
x.current_holderId != "",
|
||||
).length + 1,
|
||||
totalRootPositionCurrentVacant:
|
||||
sum3.filter(
|
||||
(x) =>
|
||||
(x.orgChild4Id == null || x.orgChild4Id == "") &&
|
||||
(x.current_holderId == null || x.current_holderId == ""),
|
||||
).length + 1,
|
||||
totalRootPositionNextUse:
|
||||
sum3.filter(
|
||||
(x) =>
|
||||
(x.orgChild4Id == null || x.orgChild4Id == "") &&
|
||||
x.next_holderId != null &&
|
||||
x.next_holderId != "",
|
||||
).length + 1,
|
||||
totalRootPositionNextVacant:
|
||||
sum3.filter(
|
||||
(x) =>
|
||||
(x.orgChild4Id == null || x.orgChild4Id == "") &&
|
||||
(x.next_holderId == null || x.next_holderId == ""),
|
||||
).length + 1,
|
||||
// totalPosition: sum3.length + 1,
|
||||
// totalPositionCurrentUse:
|
||||
// sum3.filter(
|
||||
// (x) => x.current_holderId != null && x.current_holderId != "",
|
||||
// ).length + 1,
|
||||
// totalPositionCurrentVacant:
|
||||
// sum3.filter(
|
||||
// (x) => x.current_holderId == null || x.current_holderId == "",
|
||||
// ).length + 1,
|
||||
// totalPositionNextUse:
|
||||
// sum3.filter(
|
||||
// (x) => x.next_holderId != null && x.next_holderId != "",
|
||||
// ).length + 1,
|
||||
// totalPositionNextVacant:
|
||||
// sum3.filter(
|
||||
// (x) => x.next_holderId == null || x.next_holderId == "",
|
||||
// ).length + 1,
|
||||
// totalRootPosition:
|
||||
// sum3.filter((x) => x.orgChild4Id == null || x.orgChild4Id == "")
|
||||
// .length + 1,
|
||||
// totalRootPositionCurrentUse:
|
||||
// sum3.filter(
|
||||
// (x) =>
|
||||
// (x.orgChild4Id == null || x.orgChild4Id == "") &&
|
||||
// x.current_holderId != null &&
|
||||
// x.current_holderId != "",
|
||||
// ).length + 1,
|
||||
// totalRootPositionCurrentVacant:
|
||||
// sum3.filter(
|
||||
// (x) =>
|
||||
// (x.orgChild4Id == null || x.orgChild4Id == "") &&
|
||||
// (x.current_holderId == null || x.current_holderId == ""),
|
||||
// ).length + 1,
|
||||
// totalRootPositionNextUse:
|
||||
// sum3.filter(
|
||||
// (x) =>
|
||||
// (x.orgChild4Id == null || x.orgChild4Id == "") &&
|
||||
// x.next_holderId != null &&
|
||||
// x.next_holderId != "",
|
||||
// ).length + 1,
|
||||
// totalRootPositionNextVacant:
|
||||
// sum3.filter(
|
||||
// (x) =>
|
||||
// (x.orgChild4Id == null || x.orgChild4Id == "") &&
|
||||
// (x.next_holderId == null || x.next_holderId == ""),
|
||||
// ).length + 1,
|
||||
|
||||
children: await Promise.all(
|
||||
orgChild4Data
|
||||
.filter((orgChild4) => orgChild4.orgChild3Id === orgChild3.id)
|
||||
.map(async (orgChild4) => {
|
||||
const sum4 = await this.posMasterRepository.find({
|
||||
where: {
|
||||
orgRevisionId: orgRoot.orgRevisionId,
|
||||
orgRootId: orgRoot.id,
|
||||
orgChild1Id: orgChild1.id,
|
||||
orgChild2Id: orgChild2.id,
|
||||
orgChild3Id: orgChild3.id,
|
||||
orgChild4Id: orgChild4.id,
|
||||
},
|
||||
select: [
|
||||
"current_holderId",
|
||||
"next_holderId",
|
||||
"orgRootId",
|
||||
"orgChild1Id",
|
||||
"orgChild2Id",
|
||||
"orgChild3Id",
|
||||
"orgChild4Id",
|
||||
],
|
||||
});
|
||||
// const sum4 = await this.posMasterRepository.find({
|
||||
// where: {
|
||||
// orgRevisionId: orgRoot.orgRevisionId,
|
||||
// orgRootId: orgRoot.id,
|
||||
// orgChild1Id: orgChild1.id,
|
||||
// orgChild2Id: orgChild2.id,
|
||||
// orgChild3Id: orgChild3.id,
|
||||
// orgChild4Id: orgChild4.id,
|
||||
// },
|
||||
// select: [
|
||||
// "current_holderId",
|
||||
// "next_holderId",
|
||||
// "orgRootId",
|
||||
// "orgChild1Id",
|
||||
// "orgChild2Id",
|
||||
// "orgChild3Id",
|
||||
// "orgChild4Id",
|
||||
// ],
|
||||
// });
|
||||
return {
|
||||
orgTreeId: orgChild4.id,
|
||||
orgTreeDnaId: orgChild4.ancestorDNA,
|
||||
|
|
@ -6946,52 +6951,52 @@ export class OrganizationController extends Controller {
|
|||
"00" +
|
||||
" " +
|
||||
orgRoot.orgRootShortName,
|
||||
totalPosition: sum4.length + 1,
|
||||
totalPositionCurrentUse:
|
||||
sum4.filter(
|
||||
(x) =>
|
||||
x.current_holderId != null &&
|
||||
x.current_holderId != "",
|
||||
).length + 1,
|
||||
totalPositionCurrentVacant:
|
||||
sum4.filter(
|
||||
(x) =>
|
||||
x.current_holderId == null ||
|
||||
x.current_holderId == "",
|
||||
).length + 1,
|
||||
totalPositionNextUse:
|
||||
sum4.filter(
|
||||
(x) =>
|
||||
x.next_holderId != null && x.next_holderId != "",
|
||||
).length + 1,
|
||||
totalPositionNextVacant:
|
||||
sum4.filter(
|
||||
(x) =>
|
||||
x.next_holderId == null || x.next_holderId == "",
|
||||
).length + 1,
|
||||
totalRootPosition: sum4.length + 1,
|
||||
totalRootPositionCurrentUse:
|
||||
sum4.filter(
|
||||
(x) =>
|
||||
x.current_holderId != null &&
|
||||
x.current_holderId != "",
|
||||
).length + 1,
|
||||
totalRootPositionCurrentVacant:
|
||||
sum4.filter(
|
||||
(x) =>
|
||||
x.current_holderId == null ||
|
||||
x.current_holderId == "",
|
||||
).length + 1,
|
||||
totalRootPositionNextUse:
|
||||
sum4.filter(
|
||||
(x) =>
|
||||
x.next_holderId != null && x.next_holderId != "",
|
||||
).length + 1,
|
||||
totalRootPositionNextVacant:
|
||||
sum4.filter(
|
||||
(x) =>
|
||||
x.next_holderId == null || x.next_holderId == "",
|
||||
).length + 1,
|
||||
// totalPosition: sum4.length + 1,
|
||||
// totalPositionCurrentUse:
|
||||
// sum4.filter(
|
||||
// (x) =>
|
||||
// x.current_holderId != null &&
|
||||
// x.current_holderId != "",
|
||||
// ).length + 1,
|
||||
// totalPositionCurrentVacant:
|
||||
// sum4.filter(
|
||||
// (x) =>
|
||||
// x.current_holderId == null ||
|
||||
// x.current_holderId == "",
|
||||
// ).length + 1,
|
||||
// totalPositionNextUse:
|
||||
// sum4.filter(
|
||||
// (x) =>
|
||||
// x.next_holderId != null && x.next_holderId != "",
|
||||
// ).length + 1,
|
||||
// totalPositionNextVacant:
|
||||
// sum4.filter(
|
||||
// (x) =>
|
||||
// x.next_holderId == null || x.next_holderId == "",
|
||||
// ).length + 1,
|
||||
// totalRootPosition: sum4.length + 1,
|
||||
// totalRootPositionCurrentUse:
|
||||
// sum4.filter(
|
||||
// (x) =>
|
||||
// x.current_holderId != null &&
|
||||
// x.current_holderId != "",
|
||||
// ).length + 1,
|
||||
// totalRootPositionCurrentVacant:
|
||||
// sum4.filter(
|
||||
// (x) =>
|
||||
// x.current_holderId == null ||
|
||||
// x.current_holderId == "",
|
||||
// ).length + 1,
|
||||
// totalRootPositionNextUse:
|
||||
// sum4.filter(
|
||||
// (x) =>
|
||||
// x.next_holderId != null && x.next_holderId != "",
|
||||
// ).length + 1,
|
||||
// totalRootPositionNextVacant:
|
||||
// sum4.filter(
|
||||
// (x) =>
|
||||
// x.next_holderId == null || x.next_holderId == "",
|
||||
// ).length + 1,
|
||||
};
|
||||
}),
|
||||
),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue