2024-02-02 15:49:08 +07:00
|
|
|
import {
|
|
|
|
|
Controller,
|
|
|
|
|
Get,
|
|
|
|
|
Post,
|
|
|
|
|
Put,
|
|
|
|
|
Delete,
|
|
|
|
|
Patch,
|
|
|
|
|
Route,
|
|
|
|
|
Security,
|
|
|
|
|
Tags,
|
|
|
|
|
Body,
|
|
|
|
|
Path,
|
|
|
|
|
Request,
|
|
|
|
|
Example,
|
|
|
|
|
SuccessResponse,
|
|
|
|
|
Response,
|
|
|
|
|
Query,
|
|
|
|
|
} from "tsoa";
|
|
|
|
|
import { AppDataSource } from "../database/data-source";
|
|
|
|
|
import HttpSuccess from "../interfaces/http-success";
|
|
|
|
|
import HttpStatusCode from "../interfaces/http-status";
|
|
|
|
|
import HttpError from "../interfaces/http-error";
|
2024-02-07 21:20:04 +07:00
|
|
|
import { In } from "typeorm";
|
2024-02-02 15:49:08 +07:00
|
|
|
import { OrgRevision } from "../entities/OrgRevision";
|
|
|
|
|
import { OrgRoot } from "../entities/OrgRoot";
|
|
|
|
|
import { OrgChild1 } from "../entities/OrgChild1";
|
|
|
|
|
import { OrgChild2 } from "../entities/OrgChild2";
|
|
|
|
|
import { OrgChild3 } from "../entities/OrgChild3";
|
|
|
|
|
import { OrgChild4 } from "../entities/OrgChild4";
|
2024-04-09 12:18:52 +07:00
|
|
|
import Extension from "../interfaces/extension";
|
2024-02-02 15:49:08 +07:00
|
|
|
@Route("api/v1/org/report")
|
2024-02-07 21:20:04 +07:00
|
|
|
@Tags("Report")
|
2024-02-12 17:06:31 +07:00
|
|
|
@Security("bearerAuth")
|
2024-02-02 15:49:08 +07:00
|
|
|
@Response(
|
|
|
|
|
HttpStatusCode.INTERNAL_SERVER_ERROR,
|
|
|
|
|
"เกิดข้อผิดพลาด ไม่สามารถแสดงรายการได้ กรุณาลองใหม่ในภายหลัง",
|
|
|
|
|
)
|
|
|
|
|
@SuccessResponse(HttpStatusCode.OK, "สำเร็จ")
|
|
|
|
|
export class ReportController extends Controller {
|
|
|
|
|
private orgRevisionRepository = AppDataSource.getRepository(OrgRevision);
|
|
|
|
|
private orgRootRepository = AppDataSource.getRepository(OrgRoot);
|
|
|
|
|
private child1Repository = AppDataSource.getRepository(OrgChild1);
|
|
|
|
|
private child2Repository = AppDataSource.getRepository(OrgChild2);
|
|
|
|
|
private child3Repository = AppDataSource.getRepository(OrgChild3);
|
|
|
|
|
private child4Repository = AppDataSource.getRepository(OrgChild4);
|
|
|
|
|
|
|
|
|
|
/**
|
2024-02-12 14:43:38 +07:00
|
|
|
* API Report1
|
2024-02-02 15:49:08 +07:00
|
|
|
*
|
2024-02-12 14:43:38 +07:00
|
|
|
* @summary Report1
|
2024-02-02 15:49:08 +07:00
|
|
|
*
|
|
|
|
|
*/
|
2024-02-12 14:43:38 +07:00
|
|
|
@Get("report1")
|
|
|
|
|
async findReport1() {
|
2024-04-02 09:51:29 +07:00
|
|
|
const orgRevision = await this.orgRevisionRepository.findOne({
|
|
|
|
|
where: { orgRevisionIsDraft: true, orgRevisionIsCurrent: false },
|
|
|
|
|
relations: ["orgRoots"],
|
|
|
|
|
});
|
|
|
|
|
if (!orgRevision) {
|
|
|
|
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
|
|
|
|
}
|
2024-02-02 15:49:08 +07:00
|
|
|
|
2024-04-02 09:51:29 +07:00
|
|
|
const orgRootData = await this.orgRootRepository.find({
|
|
|
|
|
where: {
|
|
|
|
|
orgRevisionId: orgRevision.id,
|
|
|
|
|
},
|
|
|
|
|
order: { orgRootOrder: "ASC" },
|
|
|
|
|
relations: [
|
|
|
|
|
"posMasters",
|
|
|
|
|
"posMasters.positions",
|
|
|
|
|
"posMasters.positions.posLevel",
|
|
|
|
|
"posMasters.positions.posType",
|
|
|
|
|
"posMasters.positions.posExecutive",
|
|
|
|
|
],
|
|
|
|
|
});
|
2024-02-02 15:49:08 +07:00
|
|
|
|
2024-04-02 09:51:29 +07:00
|
|
|
const orgRootIds = orgRootData.map((orgRoot) => orgRoot.id) || null;
|
|
|
|
|
const orgChild1Data = await this.child1Repository.find({
|
|
|
|
|
where: {
|
|
|
|
|
orgRootId: In(orgRootIds),
|
|
|
|
|
},
|
|
|
|
|
order: { orgChild1Order: "ASC" },
|
|
|
|
|
relations: [
|
|
|
|
|
"posMasters",
|
|
|
|
|
"posMasters.positions",
|
|
|
|
|
"posMasters.positions.posLevel",
|
|
|
|
|
"posMasters.positions.posType",
|
|
|
|
|
"posMasters.positions.posExecutive",
|
|
|
|
|
],
|
|
|
|
|
});
|
2024-02-03 13:09:44 +07:00
|
|
|
|
2024-04-02 09:51:29 +07:00
|
|
|
const orgChild1Ids = orgChild1Data.map((orgChild1) => orgChild1.id) || null;
|
|
|
|
|
const orgChild2Data = await this.child2Repository.find({
|
|
|
|
|
where: {
|
|
|
|
|
orgChild1: In(orgChild1Ids),
|
|
|
|
|
},
|
|
|
|
|
order: { orgChild2Order: "ASC" },
|
|
|
|
|
relations: [
|
|
|
|
|
"posMasters",
|
|
|
|
|
"posMasters.positions",
|
|
|
|
|
"posMasters.positions.posLevel",
|
|
|
|
|
"posMasters.positions.posType",
|
|
|
|
|
"posMasters.positions.posExecutive",
|
|
|
|
|
],
|
|
|
|
|
});
|
2024-02-03 13:09:44 +07:00
|
|
|
|
2024-04-02 09:51:29 +07:00
|
|
|
const orgChild2Ids = orgChild2Data.map((orgChild2) => orgChild2.id) || null;
|
|
|
|
|
const orgChild3Data = await this.child3Repository.find({
|
|
|
|
|
where: {
|
|
|
|
|
orgChild2: In(orgChild2Ids),
|
|
|
|
|
},
|
|
|
|
|
order: { orgChild3Order: "ASC" },
|
|
|
|
|
relations: [
|
|
|
|
|
"posMasters",
|
|
|
|
|
"posMasters.positions",
|
|
|
|
|
"posMasters.positions.posLevel",
|
|
|
|
|
"posMasters.positions.posType",
|
|
|
|
|
"posMasters.positions.posExecutive",
|
|
|
|
|
],
|
|
|
|
|
});
|
2024-02-06 15:00:59 +07:00
|
|
|
|
2024-04-02 09:51:29 +07:00
|
|
|
const orgChild3Ids = orgChild3Data.map((orgChild3) => orgChild3.id) || null;
|
|
|
|
|
const orgChild4Data = await this.child4Repository.find({
|
|
|
|
|
where: {
|
|
|
|
|
orgChild3: In(orgChild3Ids),
|
|
|
|
|
},
|
|
|
|
|
order: { orgChild4Order: "ASC" },
|
|
|
|
|
relations: [
|
|
|
|
|
"posMasters",
|
|
|
|
|
"posMasters.positions",
|
|
|
|
|
"posMasters.positions.posLevel",
|
|
|
|
|
"posMasters.positions.posType",
|
|
|
|
|
"posMasters.positions.posExecutive",
|
|
|
|
|
],
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
let data = new Array();
|
|
|
|
|
let _node: any;
|
|
|
|
|
let no = 1;
|
|
|
|
|
for (let orgRoot of orgRootData) {
|
|
|
|
|
await Promise.all(
|
|
|
|
|
orgRoot.posMasters
|
|
|
|
|
.filter((x) => x.orgChild1Id == null)
|
|
|
|
|
.sort((a, b) => a.posMasterOrder - b.posMasterOrder)
|
|
|
|
|
.map(async (posMaster) => {
|
|
|
|
|
if (posMaster.orgChild1Id == null) {
|
|
|
|
|
const positionName = [...new Set(posMaster.positions.map((x) => x.positionName))];
|
|
|
|
|
const posType = [
|
|
|
|
|
...new Set(
|
|
|
|
|
posMaster.positions
|
|
|
|
|
.filter((x: any) => x.posType != null)
|
|
|
|
|
.map((x) => x.posType.posTypeName),
|
|
|
|
|
),
|
|
|
|
|
];
|
|
|
|
|
const posLevel = [
|
|
|
|
|
...new Set(
|
|
|
|
|
posMaster.positions
|
|
|
|
|
.filter((x: any) => x.posLevel != null)
|
|
|
|
|
.map((x) => x.posLevel.posLevelName),
|
|
|
|
|
),
|
|
|
|
|
];
|
|
|
|
|
const posExecutive = [
|
|
|
|
|
...new Set(
|
|
|
|
|
posMaster.positions
|
|
|
|
|
.filter((x: any) => x.posExecutive != null)
|
|
|
|
|
.map((x) => x.posExecutive.posExecutiveName),
|
|
|
|
|
),
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
let node = {
|
|
|
|
|
orgTreeName: orgRoot.orgRootName,
|
|
|
|
|
orgTreeShortName: orgRoot.orgRootShortName,
|
|
|
|
|
posMasterNo: posMaster.posMasterNo,
|
|
|
|
|
positionName: positionName.join(" หรือ "),
|
|
|
|
|
posType: posType.join(" หรือ "),
|
|
|
|
|
posLevel: posLevel.join(" หรือ "),
|
|
|
|
|
posExecutive: posExecutive.join(" หรือ "),
|
2024-04-09 14:32:30 +07:00
|
|
|
reason: posMaster.reason == null ? "" : posMaster.reason,
|
2024-04-02 09:51:29 +07:00
|
|
|
};
|
|
|
|
|
if (_node == null) {
|
|
|
|
|
const head = {
|
2024-06-07 15:40:33 +07:00
|
|
|
posMasterNo: Extension.ToThaiNumber(node.orgTreeShortName.toString()),
|
|
|
|
|
posExecutive: Extension.ToThaiNumber(node.orgTreeName.toString()),
|
2024-04-02 09:51:29 +07:00
|
|
|
positionName: "",
|
|
|
|
|
posType: "",
|
|
|
|
|
posLevel: "",
|
|
|
|
|
reason: "",
|
|
|
|
|
};
|
|
|
|
|
data.push(head);
|
|
|
|
|
const _head = {
|
2024-04-09 14:32:30 +07:00
|
|
|
no: Extension.ToThaiNumber(no.toString()),
|
2024-04-09 12:18:52 +07:00
|
|
|
posMasterNo:
|
|
|
|
|
node.posMasterNo == null
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.posMasterNo.toString()),
|
2024-06-07 15:40:33 +07:00
|
|
|
posExecutive: Extension.ToThaiNumber(node.posExecutive.toString()),
|
|
|
|
|
positionName: Extension.ToThaiNumber(node.positionName.toString()),
|
|
|
|
|
posType: Extension.ToThaiNumber(node.posType.toString()),
|
|
|
|
|
posLevel: Extension.ToThaiNumber(node.posLevel.toString()),
|
|
|
|
|
reason: Extension.ToThaiNumber(node.reason.toString()),
|
2024-04-02 09:51:29 +07:00
|
|
|
};
|
|
|
|
|
data.push(_head);
|
|
|
|
|
} else {
|
|
|
|
|
if (
|
|
|
|
|
node.orgTreeShortName != _node.orgTreeShortName ||
|
|
|
|
|
node.orgTreeName != _node.orgTreeName
|
|
|
|
|
) {
|
|
|
|
|
const head = {
|
|
|
|
|
posMasterNo:
|
|
|
|
|
node.orgTreeShortName == _node.orgTreeShortName ? "" : node.orgTreeShortName,
|
2024-06-07 15:40:33 +07:00
|
|
|
posExecutive:
|
|
|
|
|
node.orgTreeName == _node.orgTreeName
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.orgTreeName.toString()),
|
2024-04-02 09:51:29 +07:00
|
|
|
positionName: "",
|
|
|
|
|
posType: "",
|
|
|
|
|
posLevel: "",
|
|
|
|
|
reason: "",
|
|
|
|
|
};
|
|
|
|
|
data.push(head);
|
|
|
|
|
_node == null;
|
|
|
|
|
}
|
|
|
|
|
const head = {
|
2024-04-09 14:32:30 +07:00
|
|
|
no: Extension.ToThaiNumber(no.toString()),
|
2024-04-09 12:18:52 +07:00
|
|
|
posMasterNo:
|
|
|
|
|
node.posMasterNo == null
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.posMasterNo.toString()),
|
2024-06-07 15:40:33 +07:00
|
|
|
posExecutive:
|
|
|
|
|
node.posExecutive == _node.posExecutive
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.posExecutive.toString()),
|
|
|
|
|
positionName: Extension.ToThaiNumber(node.positionName.toString()),
|
|
|
|
|
posType: Extension.ToThaiNumber(node.posType.toString()),
|
|
|
|
|
posLevel: Extension.ToThaiNumber(node.posLevel.toString()),
|
|
|
|
|
reason: Extension.ToThaiNumber(node.reason.toString()),
|
2024-04-02 09:51:29 +07:00
|
|
|
};
|
|
|
|
|
data.push(head);
|
|
|
|
|
}
|
|
|
|
|
no += 1;
|
|
|
|
|
_node = node;
|
|
|
|
|
}
|
|
|
|
|
}),
|
|
|
|
|
);
|
|
|
|
|
_node = null;
|
2024-02-03 13:09:44 +07:00
|
|
|
|
2024-04-02 09:51:29 +07:00
|
|
|
for (let orgChild1 of orgChild1Data.filter(
|
|
|
|
|
(orgChild1) => orgChild1.orgRootId === orgRoot.id,
|
|
|
|
|
)) {
|
2024-02-07 21:20:04 +07:00
|
|
|
await Promise.all(
|
2024-04-02 09:51:29 +07:00
|
|
|
orgChild1.posMasters
|
|
|
|
|
.filter((x) => x.orgChild2Id == null)
|
2024-02-07 21:20:04 +07:00
|
|
|
.sort((a, b) => a.posMasterOrder - b.posMasterOrder)
|
|
|
|
|
.map(async (posMaster) => {
|
2024-04-02 09:51:29 +07:00
|
|
|
if (posMaster.orgChild2Id == null) {
|
2024-02-07 14:01:39 +07:00
|
|
|
const positionName = [...new Set(posMaster.positions.map((x) => x.positionName))];
|
2024-02-11 22:30:12 +07:00
|
|
|
const posType = [
|
|
|
|
|
...new Set(
|
|
|
|
|
posMaster.positions
|
|
|
|
|
.filter((x: any) => x.posType != null)
|
|
|
|
|
.map((x) => x.posType.posTypeName),
|
|
|
|
|
),
|
|
|
|
|
];
|
2024-02-07 14:01:39 +07:00
|
|
|
const posLevel = [
|
2024-02-11 22:30:12 +07:00
|
|
|
...new Set(
|
|
|
|
|
posMaster.positions
|
|
|
|
|
.filter((x: any) => x.posLevel != null)
|
|
|
|
|
.map((x) => x.posLevel.posLevelName),
|
|
|
|
|
),
|
2024-02-07 14:01:39 +07:00
|
|
|
];
|
2024-02-07 18:53:15 +07:00
|
|
|
const posExecutive = [
|
2024-02-11 22:30:12 +07:00
|
|
|
...new Set(
|
|
|
|
|
posMaster.positions
|
|
|
|
|
.filter((x: any) => x.posExecutive != null)
|
|
|
|
|
.map((x) => x.posExecutive.posExecutiveName),
|
|
|
|
|
),
|
2024-02-07 18:53:15 +07:00
|
|
|
];
|
2024-02-12 14:43:38 +07:00
|
|
|
|
|
|
|
|
let node = {
|
2024-04-02 09:51:29 +07:00
|
|
|
orgTreeName: orgChild1.orgChild1Name,
|
|
|
|
|
orgTreeShortName: orgChild1.orgChild1ShortName,
|
2024-02-12 14:43:38 +07:00
|
|
|
posMasterNo: posMaster.posMasterNo,
|
|
|
|
|
positionName: positionName.join(" หรือ "),
|
|
|
|
|
posType: posType.join(" หรือ "),
|
|
|
|
|
posLevel: posLevel.join(" หรือ "),
|
|
|
|
|
posExecutive: posExecutive.join(" หรือ "),
|
2024-04-09 14:32:30 +07:00
|
|
|
reason: posMaster.reason == null ? "" : posMaster.reason,
|
2024-02-12 14:43:38 +07:00
|
|
|
};
|
|
|
|
|
if (_node == null) {
|
|
|
|
|
const head = {
|
2024-06-07 15:40:33 +07:00
|
|
|
posMasterNo: Extension.ToThaiNumber(node.orgTreeShortName.toString()),
|
|
|
|
|
posExecutive: Extension.ToThaiNumber(node.orgTreeName.toString()),
|
2024-02-12 14:43:38 +07:00
|
|
|
positionName: "",
|
|
|
|
|
posType: "",
|
|
|
|
|
posLevel: "",
|
2024-02-13 09:59:10 +07:00
|
|
|
reason: "",
|
2024-02-12 14:43:38 +07:00
|
|
|
};
|
|
|
|
|
data.push(head);
|
|
|
|
|
const _head = {
|
2024-04-09 14:32:30 +07:00
|
|
|
no: Extension.ToThaiNumber(no.toString()),
|
2024-04-09 12:18:52 +07:00
|
|
|
posMasterNo:
|
|
|
|
|
node.posMasterNo == null
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.posMasterNo.toString()),
|
2024-06-07 15:40:33 +07:00
|
|
|
posExecutive: Extension.ToThaiNumber(node.posExecutive.toString()),
|
|
|
|
|
positionName: Extension.ToThaiNumber(node.positionName.toString()),
|
|
|
|
|
posType: Extension.ToThaiNumber(node.posType.toString()),
|
|
|
|
|
posLevel: Extension.ToThaiNumber(node.posLevel.toString()),
|
|
|
|
|
reason: Extension.ToThaiNumber(node.reason.toString()),
|
2024-02-12 14:43:38 +07:00
|
|
|
};
|
|
|
|
|
data.push(_head);
|
|
|
|
|
} else {
|
|
|
|
|
if (
|
|
|
|
|
node.orgTreeShortName != _node.orgTreeShortName ||
|
|
|
|
|
node.orgTreeName != _node.orgTreeName
|
|
|
|
|
) {
|
|
|
|
|
const head = {
|
|
|
|
|
posMasterNo:
|
|
|
|
|
node.orgTreeShortName == _node.orgTreeShortName
|
|
|
|
|
? ""
|
|
|
|
|
: node.orgTreeShortName,
|
2024-06-07 15:40:33 +07:00
|
|
|
posExecutive:
|
|
|
|
|
node.orgTreeName == _node.orgTreeName
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.orgTreeName.toString()),
|
2024-02-12 14:43:38 +07:00
|
|
|
positionName: "",
|
|
|
|
|
posType: "",
|
|
|
|
|
posLevel: "",
|
2024-02-13 09:59:10 +07:00
|
|
|
reason: "",
|
2024-02-12 14:43:38 +07:00
|
|
|
};
|
|
|
|
|
data.push(head);
|
|
|
|
|
_node == null;
|
|
|
|
|
}
|
|
|
|
|
const head = {
|
2024-04-09 14:32:30 +07:00
|
|
|
no: Extension.ToThaiNumber(no.toString()),
|
2024-04-09 12:18:52 +07:00
|
|
|
posMasterNo:
|
|
|
|
|
node.posMasterNo == null
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.posMasterNo.toString()),
|
2024-06-07 15:40:33 +07:00
|
|
|
posExecutive:
|
|
|
|
|
node.posExecutive == _node.posExecutive
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.posExecutive.toString()),
|
|
|
|
|
positionName: Extension.ToThaiNumber(node.positionName.toString()),
|
|
|
|
|
posType: Extension.ToThaiNumber(node.posType.toString()),
|
|
|
|
|
posLevel: Extension.ToThaiNumber(node.posLevel.toString()),
|
|
|
|
|
reason: Extension.ToThaiNumber(node.reason.toString()),
|
2024-02-12 14:43:38 +07:00
|
|
|
};
|
|
|
|
|
data.push(head);
|
2024-02-07 14:01:39 +07:00
|
|
|
}
|
2024-02-12 14:43:38 +07:00
|
|
|
no += 1;
|
|
|
|
|
_node = node;
|
|
|
|
|
}
|
|
|
|
|
}),
|
|
|
|
|
);
|
|
|
|
|
_node = null;
|
2024-02-07 14:01:39 +07:00
|
|
|
|
2024-04-02 09:51:29 +07:00
|
|
|
for (let orgChild2 of orgChild2Data.filter(
|
|
|
|
|
(orgChild2) => orgChild2.orgChild1Id === orgChild1.id,
|
2024-02-12 14:43:38 +07:00
|
|
|
)) {
|
|
|
|
|
await Promise.all(
|
2024-04-02 09:51:29 +07:00
|
|
|
orgChild2.posMasters
|
|
|
|
|
.filter((x) => x.orgChild3Id == null)
|
2024-02-12 14:43:38 +07:00
|
|
|
.sort((a, b) => a.posMasterOrder - b.posMasterOrder)
|
|
|
|
|
.map(async (posMaster) => {
|
2024-04-02 09:51:29 +07:00
|
|
|
if (posMaster.orgChild3Id == null) {
|
2024-02-12 14:43:38 +07:00
|
|
|
const positionName = [...new Set(posMaster.positions.map((x) => x.positionName))];
|
|
|
|
|
const posType = [
|
2024-02-11 22:30:12 +07:00
|
|
|
...new Set(
|
2024-02-12 14:43:38 +07:00
|
|
|
posMaster.positions
|
2024-02-11 22:30:12 +07:00
|
|
|
.filter((x: any) => x.posType != null)
|
2024-02-12 14:43:38 +07:00
|
|
|
.map((x) => x.posType.posTypeName),
|
2024-02-11 22:30:12 +07:00
|
|
|
),
|
2024-02-07 14:01:39 +07:00
|
|
|
];
|
2024-02-12 14:43:38 +07:00
|
|
|
const posLevel = [
|
2024-02-07 14:01:39 +07:00
|
|
|
...new Set(
|
2024-02-12 14:43:38 +07:00
|
|
|
posMaster.positions
|
2024-02-11 22:30:12 +07:00
|
|
|
.filter((x: any) => x.posLevel != null)
|
2024-02-12 14:43:38 +07:00
|
|
|
.map((x) => x.posLevel.posLevelName),
|
2024-02-07 14:01:39 +07:00
|
|
|
),
|
|
|
|
|
];
|
2024-02-12 14:43:38 +07:00
|
|
|
const posExecutive = [
|
2024-02-07 18:53:15 +07:00
|
|
|
...new Set(
|
2024-02-12 14:43:38 +07:00
|
|
|
posMaster.positions
|
2024-02-11 22:30:12 +07:00
|
|
|
.filter((x: any) => x.posExecutive != null)
|
2024-02-12 14:43:38 +07:00
|
|
|
.map((x) => x.posExecutive.posExecutiveName),
|
2024-02-07 18:53:15 +07:00
|
|
|
),
|
|
|
|
|
];
|
|
|
|
|
|
2024-02-12 14:43:38 +07:00
|
|
|
let node = {
|
2024-04-02 09:51:29 +07:00
|
|
|
orgTreeName: orgChild2.orgChild2Name,
|
|
|
|
|
orgTreeShortName: orgChild2.orgChild2ShortName,
|
2024-02-12 14:43:38 +07:00
|
|
|
posMasterNo: posMaster.posMasterNo,
|
2024-04-02 09:51:29 +07:00
|
|
|
posExecutive: posExecutive.join(" หรือ "),
|
2024-02-12 14:43:38 +07:00
|
|
|
positionName: positionName.join(" หรือ "),
|
|
|
|
|
posType: posType.join(" หรือ "),
|
|
|
|
|
posLevel: posLevel.join(" หรือ "),
|
2024-04-09 14:32:30 +07:00
|
|
|
reason: posMaster.reason == null ? "" : posMaster.reason,
|
2024-02-08 18:04:54 +07:00
|
|
|
};
|
2024-02-12 14:43:38 +07:00
|
|
|
if (_node == null) {
|
2024-02-08 18:04:54 +07:00
|
|
|
const head = {
|
2024-06-07 15:40:33 +07:00
|
|
|
posMasterNo: Extension.ToThaiNumber(node.orgTreeShortName.toString()),
|
|
|
|
|
posExecutive: Extension.ToThaiNumber(node.orgTreeName.toString()),
|
2024-02-08 18:04:54 +07:00
|
|
|
positionName: "",
|
|
|
|
|
posType: "",
|
|
|
|
|
posLevel: "",
|
2024-02-13 09:59:10 +07:00
|
|
|
reason: "",
|
2024-02-08 18:04:54 +07:00
|
|
|
};
|
|
|
|
|
data.push(head);
|
2024-02-12 14:43:38 +07:00
|
|
|
const _head = {
|
2024-04-09 14:32:30 +07:00
|
|
|
no: Extension.ToThaiNumber(no.toString()),
|
2024-04-09 12:18:52 +07:00
|
|
|
posMasterNo:
|
|
|
|
|
node.posMasterNo == null
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.posMasterNo.toString()),
|
2024-06-07 15:40:33 +07:00
|
|
|
posExecutive: Extension.ToThaiNumber(node.posExecutive.toString()),
|
|
|
|
|
positionName: Extension.ToThaiNumber(node.positionName.toString()),
|
|
|
|
|
posType: Extension.ToThaiNumber(node.posType.toString()),
|
|
|
|
|
posLevel: Extension.ToThaiNumber(node.posLevel.toString()),
|
|
|
|
|
reason: Extension.ToThaiNumber(node.reason.toString()),
|
2024-02-12 14:43:38 +07:00
|
|
|
};
|
|
|
|
|
data.push(_head);
|
|
|
|
|
} else {
|
|
|
|
|
if (
|
|
|
|
|
node.orgTreeShortName != _node.orgTreeShortName ||
|
|
|
|
|
node.orgTreeName != _node.orgTreeName
|
|
|
|
|
) {
|
|
|
|
|
const head = {
|
|
|
|
|
posMasterNo:
|
|
|
|
|
node.orgTreeShortName == _node.orgTreeShortName
|
|
|
|
|
? ""
|
|
|
|
|
: node.orgTreeShortName,
|
|
|
|
|
posExecutive: node.orgTreeName == _node.orgTreeName ? "" : node.orgTreeName,
|
|
|
|
|
positionName: "",
|
|
|
|
|
posType: "",
|
|
|
|
|
posLevel: "",
|
2024-02-13 09:59:10 +07:00
|
|
|
reason: "",
|
2024-02-12 14:43:38 +07:00
|
|
|
};
|
|
|
|
|
data.push(head);
|
|
|
|
|
_node == null;
|
|
|
|
|
}
|
|
|
|
|
const head = {
|
2024-04-09 14:32:30 +07:00
|
|
|
no: Extension.ToThaiNumber(no.toString()),
|
2024-04-09 12:18:52 +07:00
|
|
|
posMasterNo:
|
|
|
|
|
node.posMasterNo == null
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.posMasterNo.toString()),
|
2024-02-12 14:43:38 +07:00
|
|
|
posExecutive:
|
2024-06-07 15:40:33 +07:00
|
|
|
node.posExecutive == _node.posExecutive
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.posExecutive.toString()),
|
|
|
|
|
positionName: Extension.ToThaiNumber(node.positionName.toString()),
|
|
|
|
|
posType: Extension.ToThaiNumber(node.posType.toString()),
|
|
|
|
|
posLevel: Extension.ToThaiNumber(node.posLevel.toString()),
|
|
|
|
|
reason: Extension.ToThaiNumber(node.reason.toString()),
|
2024-02-12 14:43:38 +07:00
|
|
|
};
|
|
|
|
|
data.push(head);
|
2024-02-08 18:04:54 +07:00
|
|
|
}
|
2024-02-12 14:43:38 +07:00
|
|
|
no += 1;
|
|
|
|
|
_node = node;
|
2024-02-07 21:20:04 +07:00
|
|
|
}
|
2024-02-12 14:43:38 +07:00
|
|
|
}),
|
|
|
|
|
);
|
|
|
|
|
_node = null;
|
2024-02-07 21:20:04 +07:00
|
|
|
|
2024-04-02 09:51:29 +07:00
|
|
|
for (let orgChild3 of orgChild3Data.filter(
|
|
|
|
|
(orgChild3) => orgChild3.orgChild2Id === orgChild2.id,
|
2024-02-07 21:20:04 +07:00
|
|
|
)) {
|
|
|
|
|
await Promise.all(
|
2024-04-02 09:51:29 +07:00
|
|
|
orgChild3.posMasters
|
|
|
|
|
.filter((x) => x.orgChild4Id == null)
|
2024-02-07 21:20:04 +07:00
|
|
|
.sort((a, b) => a.posMasterOrder - b.posMasterOrder)
|
|
|
|
|
.map(async (posMaster) => {
|
2024-04-02 09:51:29 +07:00
|
|
|
if (posMaster.orgChild4Id == null) {
|
2024-02-08 19:46:18 +07:00
|
|
|
const positionName = [
|
|
|
|
|
...new Set(posMaster.positions.map((x) => x.positionName)),
|
2024-02-07 21:20:04 +07:00
|
|
|
];
|
2024-02-08 19:46:18 +07:00
|
|
|
const posType = [
|
2024-02-11 22:30:12 +07:00
|
|
|
...new Set(
|
|
|
|
|
posMaster.positions
|
|
|
|
|
.filter((x: any) => x.posType != null)
|
|
|
|
|
.map((x) => x.posType.posTypeName),
|
|
|
|
|
),
|
2024-02-07 21:20:04 +07:00
|
|
|
];
|
2024-02-08 19:46:18 +07:00
|
|
|
const posLevel = [
|
2024-02-11 22:30:12 +07:00
|
|
|
...new Set(
|
|
|
|
|
posMaster.positions
|
|
|
|
|
.filter((x: any) => x.posLevel != null)
|
|
|
|
|
.map((x) => x.posLevel.posLevelName),
|
|
|
|
|
),
|
2024-02-07 21:20:04 +07:00
|
|
|
];
|
2024-02-08 19:46:18 +07:00
|
|
|
const posExecutive = [
|
2024-02-11 22:30:12 +07:00
|
|
|
...new Set(
|
|
|
|
|
posMaster.positions
|
|
|
|
|
.filter((x: any) => x.posExecutive != null)
|
|
|
|
|
.map((x) => x.posExecutive.posExecutiveName),
|
|
|
|
|
),
|
2024-02-07 21:20:04 +07:00
|
|
|
];
|
2024-02-08 19:46:18 +07:00
|
|
|
|
|
|
|
|
let node = {
|
2024-04-02 09:51:29 +07:00
|
|
|
orgTreeName: orgChild3.orgChild3Name,
|
|
|
|
|
orgTreeShortName: orgChild3.orgChild3ShortName,
|
2024-02-08 19:46:18 +07:00
|
|
|
posMasterNo: posMaster.posMasterNo,
|
2024-02-12 14:43:38 +07:00
|
|
|
positionName: positionName.join(" หรือ "),
|
|
|
|
|
posType: posType.join(" หรือ "),
|
|
|
|
|
posLevel: posLevel.join(" หรือ "),
|
2024-04-02 09:51:29 +07:00
|
|
|
posExecutive: posExecutive.join(" หรือ "),
|
2024-04-09 14:32:30 +07:00
|
|
|
reason: posMaster.reason == null ? "" : posMaster.reason,
|
2024-02-08 18:04:54 +07:00
|
|
|
};
|
2024-02-08 19:46:18 +07:00
|
|
|
if (_node == null) {
|
2024-02-08 18:04:54 +07:00
|
|
|
const head = {
|
2024-06-07 15:40:33 +07:00
|
|
|
posMasterNo: Extension.ToThaiNumber(node.orgTreeShortName.toString()),
|
|
|
|
|
posExecutive: Extension.ToThaiNumber(node.orgTreeName.toString()),
|
2024-02-08 18:04:54 +07:00
|
|
|
positionName: "",
|
|
|
|
|
posType: "",
|
|
|
|
|
posLevel: "",
|
2024-02-13 09:59:10 +07:00
|
|
|
reason: "",
|
2024-02-08 18:04:54 +07:00
|
|
|
};
|
|
|
|
|
data.push(head);
|
2024-02-08 19:46:18 +07:00
|
|
|
const _head = {
|
2024-04-09 14:32:30 +07:00
|
|
|
no: Extension.ToThaiNumber(no.toString()),
|
2024-04-09 12:18:52 +07:00
|
|
|
posMasterNo:
|
|
|
|
|
node.posMasterNo == null
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.posMasterNo.toString()),
|
2024-06-07 15:40:33 +07:00
|
|
|
posExecutive: Extension.ToThaiNumber(node.posExecutive.toString()),
|
|
|
|
|
positionName: Extension.ToThaiNumber(node.positionName.toString()),
|
|
|
|
|
posType: Extension.ToThaiNumber(node.posType.toString()),
|
|
|
|
|
posLevel: Extension.ToThaiNumber(node.posLevel.toString()),
|
|
|
|
|
reason: Extension.ToThaiNumber(node.reason.toString()),
|
2024-02-08 19:46:18 +07:00
|
|
|
};
|
|
|
|
|
data.push(_head);
|
|
|
|
|
} else {
|
|
|
|
|
if (
|
|
|
|
|
node.orgTreeShortName != _node.orgTreeShortName ||
|
2024-02-12 14:43:38 +07:00
|
|
|
node.orgTreeName != _node.orgTreeName
|
2024-02-08 19:46:18 +07:00
|
|
|
) {
|
|
|
|
|
const head = {
|
|
|
|
|
posMasterNo:
|
|
|
|
|
node.orgTreeShortName == _node.orgTreeShortName
|
|
|
|
|
? ""
|
|
|
|
|
: node.orgTreeShortName,
|
|
|
|
|
posExecutive:
|
|
|
|
|
node.orgTreeName == _node.orgTreeName ? "" : node.orgTreeName,
|
|
|
|
|
positionName: "",
|
|
|
|
|
posType: "",
|
|
|
|
|
posLevel: "",
|
2024-02-13 09:59:10 +07:00
|
|
|
reason: "",
|
2024-02-08 19:46:18 +07:00
|
|
|
};
|
|
|
|
|
data.push(head);
|
|
|
|
|
_node == null;
|
|
|
|
|
}
|
|
|
|
|
const head = {
|
2024-04-09 14:32:30 +07:00
|
|
|
no: Extension.ToThaiNumber(no.toString()),
|
2024-04-09 12:18:52 +07:00
|
|
|
posMasterNo:
|
|
|
|
|
node.posMasterNo == null
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.posMasterNo.toString()),
|
2024-02-08 19:46:18 +07:00
|
|
|
posExecutive:
|
2024-06-07 15:40:33 +07:00
|
|
|
node.posExecutive == _node.posExecutive
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.posExecutive.toString()),
|
|
|
|
|
positionName: Extension.ToThaiNumber(node.positionName.toString()),
|
|
|
|
|
posType: Extension.ToThaiNumber(node.posType.toString()),
|
|
|
|
|
posLevel: Extension.ToThaiNumber(node.posLevel.toString()),
|
|
|
|
|
reason: Extension.ToThaiNumber(node.reason.toString()),
|
2024-02-08 19:46:18 +07:00
|
|
|
};
|
|
|
|
|
data.push(head);
|
2024-02-08 18:04:54 +07:00
|
|
|
}
|
2024-02-08 19:46:18 +07:00
|
|
|
no += 1;
|
|
|
|
|
_node = node;
|
2024-02-07 21:20:04 +07:00
|
|
|
}
|
|
|
|
|
}),
|
|
|
|
|
);
|
|
|
|
|
_node = null;
|
|
|
|
|
|
2024-04-02 09:51:29 +07:00
|
|
|
for (let orgChild4 of orgChild4Data.filter(
|
|
|
|
|
(orgChild4) => orgChild4.orgChild3Id === orgChild3.id,
|
2024-02-07 21:20:04 +07:00
|
|
|
)) {
|
|
|
|
|
await Promise.all(
|
2024-04-02 09:51:29 +07:00
|
|
|
orgChild4.posMasters
|
2024-02-07 21:20:04 +07:00
|
|
|
.sort((a, b) => a.posMasterOrder - b.posMasterOrder)
|
|
|
|
|
.map(async (posMaster) => {
|
2024-04-02 09:51:29 +07:00
|
|
|
const positionName = [
|
|
|
|
|
...new Set(posMaster.positions.map((x) => x.positionName)),
|
|
|
|
|
];
|
|
|
|
|
const posType = [
|
|
|
|
|
...new Set(
|
|
|
|
|
posMaster.positions
|
|
|
|
|
.filter((x: any) => x.posType != null)
|
|
|
|
|
.map((x) => x.posType.posTypeName),
|
|
|
|
|
),
|
|
|
|
|
];
|
|
|
|
|
const posLevel = [
|
|
|
|
|
...new Set(
|
|
|
|
|
posMaster.positions
|
|
|
|
|
.filter((x: any) => x.posLevel != null)
|
|
|
|
|
.map((x) => x.posLevel.posLevelName),
|
|
|
|
|
),
|
|
|
|
|
];
|
|
|
|
|
const posExecutive = [
|
|
|
|
|
...new Set(
|
|
|
|
|
posMaster.positions
|
|
|
|
|
.filter((x: any) => x.posExecutive != null)
|
|
|
|
|
.map((x) => x.posExecutive.posExecutiveName),
|
|
|
|
|
),
|
|
|
|
|
];
|
2024-02-08 19:46:18 +07:00
|
|
|
|
2024-04-02 09:51:29 +07:00
|
|
|
let node = {
|
|
|
|
|
orgTreeName: orgChild4.orgChild4Name,
|
|
|
|
|
orgTreeShortName: orgChild4.orgChild4ShortName,
|
|
|
|
|
posMasterNo: posMaster.posMasterNo,
|
|
|
|
|
positionName: positionName.join(" หรือ "),
|
|
|
|
|
posType: posType.join(" หรือ "),
|
|
|
|
|
posLevel: posLevel.join(" หรือ "),
|
|
|
|
|
posExecutive: posExecutive.join(" หรือ "),
|
2024-04-09 14:32:30 +07:00
|
|
|
reason: posMaster.reason == null ? "" : posMaster.reason,
|
2024-04-02 09:51:29 +07:00
|
|
|
};
|
|
|
|
|
if (_node == null) {
|
|
|
|
|
const head = {
|
2024-06-07 15:40:33 +07:00
|
|
|
posMasterNo: Extension.ToThaiNumber(node.orgTreeShortName.toString()),
|
|
|
|
|
posExecutive: Extension.ToThaiNumber(node.orgTreeName.toString()),
|
2024-04-02 09:51:29 +07:00
|
|
|
positionName: "",
|
|
|
|
|
posType: "",
|
|
|
|
|
posLevel: "",
|
2024-02-13 09:59:10 +07:00
|
|
|
reason: "",
|
2024-02-08 18:04:54 +07:00
|
|
|
};
|
2024-04-02 09:51:29 +07:00
|
|
|
data.push(head);
|
|
|
|
|
const _head = {
|
2024-04-09 14:32:30 +07:00
|
|
|
no: Extension.ToThaiNumber(no.toString()),
|
2024-04-09 12:18:52 +07:00
|
|
|
posMasterNo:
|
|
|
|
|
node.posMasterNo == null
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.posMasterNo.toString()),
|
2024-06-07 15:40:33 +07:00
|
|
|
posExecutive: Extension.ToThaiNumber(node.posExecutive.toString()),
|
|
|
|
|
positionName: Extension.ToThaiNumber(node.positionName.toString()),
|
|
|
|
|
posType: Extension.ToThaiNumber(node.posType.toString()),
|
|
|
|
|
posLevel: Extension.ToThaiNumber(node.posLevel.toString()),
|
|
|
|
|
reason: Extension.ToThaiNumber(node.reason.toString()),
|
2024-04-02 09:51:29 +07:00
|
|
|
};
|
|
|
|
|
data.push(_head);
|
|
|
|
|
} else {
|
|
|
|
|
if (
|
|
|
|
|
node.orgTreeShortName != _node.orgTreeShortName ||
|
|
|
|
|
node.orgTreeName != _node.orgTreeName
|
|
|
|
|
) {
|
2024-02-08 18:04:54 +07:00
|
|
|
const head = {
|
2024-04-02 09:51:29 +07:00
|
|
|
posMasterNo:
|
|
|
|
|
node.orgTreeShortName == _node.orgTreeShortName
|
|
|
|
|
? ""
|
|
|
|
|
: node.orgTreeShortName,
|
|
|
|
|
posExecutive:
|
|
|
|
|
node.orgTreeName == _node.orgTreeName ? "" : node.orgTreeName,
|
2024-02-08 18:04:54 +07:00
|
|
|
positionName: "",
|
|
|
|
|
posType: "",
|
|
|
|
|
posLevel: "",
|
2024-02-13 09:59:10 +07:00
|
|
|
reason: "",
|
2024-02-08 18:04:54 +07:00
|
|
|
};
|
|
|
|
|
data.push(head);
|
2024-04-02 09:51:29 +07:00
|
|
|
_node == null;
|
2024-02-08 18:04:54 +07:00
|
|
|
}
|
2024-04-02 09:51:29 +07:00
|
|
|
const head = {
|
2024-04-09 14:32:30 +07:00
|
|
|
no: Extension.ToThaiNumber(no.toString()),
|
2024-04-09 12:18:52 +07:00
|
|
|
posMasterNo:
|
|
|
|
|
node.posMasterNo == null
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.posMasterNo.toString()),
|
2024-04-02 09:51:29 +07:00
|
|
|
posExecutive:
|
2024-06-07 15:40:33 +07:00
|
|
|
node.posExecutive == _node.posExecutive
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.posExecutive.toString()),
|
|
|
|
|
positionName:
|
|
|
|
|
node.positionName == null
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.positionName.toString()),
|
|
|
|
|
posType: Extension.ToThaiNumber(node.posType.toString()),
|
|
|
|
|
posLevel: Extension.ToThaiNumber(node.posLevel.toString()),
|
|
|
|
|
reason: Extension.ToThaiNumber(node.reason.toString()),
|
2024-04-02 09:51:29 +07:00
|
|
|
};
|
|
|
|
|
data.push(head);
|
2024-02-07 21:20:04 +07:00
|
|
|
}
|
2024-04-02 09:51:29 +07:00
|
|
|
no += 1;
|
|
|
|
|
_node = node;
|
2024-02-07 21:20:04 +07:00
|
|
|
}),
|
|
|
|
|
);
|
|
|
|
|
_node = null;
|
2024-04-02 09:51:29 +07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-06-07 15:40:33 +07:00
|
|
|
console.log(data);
|
2024-04-02 09:51:29 +07:00
|
|
|
return new HttpSuccess({ template: "report1", reportName: "report1", data: { data } });
|
|
|
|
|
}
|
2024-02-07 21:20:04 +07:00
|
|
|
|
2024-04-02 09:51:29 +07:00
|
|
|
/**
|
|
|
|
|
* API Report2
|
|
|
|
|
*
|
|
|
|
|
* @summary Report2
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
@Get("report2")
|
|
|
|
|
async findReport2() {
|
|
|
|
|
const orgRevision = await this.orgRevisionRepository.findOne({
|
|
|
|
|
where: { orgRevisionIsDraft: true, orgRevisionIsCurrent: false },
|
|
|
|
|
relations: ["orgRoots"],
|
|
|
|
|
});
|
|
|
|
|
if (!orgRevision) {
|
|
|
|
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
|
|
|
|
}
|
2024-02-12 14:43:38 +07:00
|
|
|
|
2024-04-02 09:51:29 +07:00
|
|
|
const orgRootData = await this.orgRootRepository.find({
|
|
|
|
|
where: {
|
|
|
|
|
orgRevisionId: orgRevision.id,
|
|
|
|
|
},
|
|
|
|
|
order: { orgRootOrder: "ASC" },
|
|
|
|
|
relations: [
|
|
|
|
|
"posMasters",
|
|
|
|
|
"posMasters.orgRoot",
|
|
|
|
|
"posMasters.orgChild1",
|
|
|
|
|
"posMasters.orgChild2",
|
|
|
|
|
"posMasters.orgChild3",
|
|
|
|
|
"posMasters.orgChild4",
|
|
|
|
|
"posMasters.next_holder",
|
|
|
|
|
"posMasters.next_holder",
|
|
|
|
|
"posMasters.next_holder",
|
|
|
|
|
"posMasters.next_holder.posLevel",
|
|
|
|
|
"posMasters.next_holder.posType",
|
2024-04-09 14:32:30 +07:00
|
|
|
"posMasters.next_holder.profileSalary",
|
|
|
|
|
"posMasters.next_holder.profileEducations",
|
2024-04-02 09:51:29 +07:00
|
|
|
"posMasters.next_holder.current_holders",
|
|
|
|
|
"posMasters.next_holder.current_holders.positions",
|
|
|
|
|
"posMasters.next_holder.current_holders.orgRoot",
|
|
|
|
|
"posMasters.next_holder.current_holders.orgChild1",
|
|
|
|
|
"posMasters.next_holder.current_holders.orgChild2",
|
|
|
|
|
"posMasters.next_holder.current_holders.orgChild3",
|
|
|
|
|
"posMasters.next_holder.current_holders.orgChild4",
|
|
|
|
|
"posMasters.positions",
|
|
|
|
|
"posMasters.positions.posLevel",
|
|
|
|
|
"posMasters.positions.posType",
|
|
|
|
|
"posMasters.positions.posExecutive",
|
|
|
|
|
],
|
|
|
|
|
});
|
2024-02-12 14:43:38 +07:00
|
|
|
|
2024-04-02 09:51:29 +07:00
|
|
|
const orgRootIds = orgRootData.map((orgRoot) => orgRoot.id) || null;
|
|
|
|
|
const orgChild1Data = await this.child1Repository.find({
|
|
|
|
|
where: {
|
|
|
|
|
orgRootId: In(orgRootIds),
|
|
|
|
|
},
|
|
|
|
|
order: { orgChild1Order: "ASC" },
|
|
|
|
|
relations: [
|
|
|
|
|
"posMasters",
|
|
|
|
|
"posMasters.orgRoot",
|
|
|
|
|
"posMasters.orgChild1",
|
|
|
|
|
"posMasters.orgChild2",
|
|
|
|
|
"posMasters.orgChild3",
|
|
|
|
|
"posMasters.orgChild4",
|
|
|
|
|
"posMasters.next_holder",
|
|
|
|
|
"posMasters.next_holder.posLevel",
|
|
|
|
|
"posMasters.next_holder.posType",
|
2024-04-09 14:32:30 +07:00
|
|
|
"posMasters.next_holder.profileSalary",
|
|
|
|
|
"posMasters.next_holder.profileEducations",
|
2024-04-02 09:51:29 +07:00
|
|
|
"posMasters.next_holder.current_holders",
|
|
|
|
|
"posMasters.next_holder.current_holders.positions",
|
|
|
|
|
"posMasters.next_holder.current_holders.orgRoot",
|
|
|
|
|
"posMasters.next_holder.current_holders.orgChild1",
|
|
|
|
|
"posMasters.next_holder.current_holders.orgChild2",
|
|
|
|
|
"posMasters.next_holder.current_holders.orgChild3",
|
|
|
|
|
"posMasters.next_holder.current_holders.orgChild4",
|
|
|
|
|
"posMasters.positions",
|
|
|
|
|
"posMasters.positions.posLevel",
|
|
|
|
|
"posMasters.positions.posType",
|
|
|
|
|
"posMasters.positions.posExecutive",
|
|
|
|
|
],
|
|
|
|
|
});
|
2024-02-12 14:43:38 +07:00
|
|
|
|
2024-04-02 09:51:29 +07:00
|
|
|
const orgChild1Ids = orgChild1Data.map((orgChild1) => orgChild1.id) || null;
|
|
|
|
|
const orgChild2Data = await this.child2Repository.find({
|
|
|
|
|
where: {
|
|
|
|
|
orgChild1: In(orgChild1Ids),
|
|
|
|
|
},
|
|
|
|
|
order: { orgChild2Order: "ASC" },
|
|
|
|
|
relations: [
|
|
|
|
|
"posMasters",
|
|
|
|
|
"posMasters.orgRoot",
|
|
|
|
|
"posMasters.orgChild1",
|
|
|
|
|
"posMasters.orgChild2",
|
|
|
|
|
"posMasters.orgChild3",
|
|
|
|
|
"posMasters.orgChild4",
|
|
|
|
|
"posMasters.next_holder",
|
|
|
|
|
"posMasters.next_holder.posLevel",
|
|
|
|
|
"posMasters.next_holder.posType",
|
2024-04-09 14:32:30 +07:00
|
|
|
"posMasters.next_holder.profileSalary",
|
|
|
|
|
"posMasters.next_holder.profileEducations",
|
2024-04-02 09:51:29 +07:00
|
|
|
"posMasters.next_holder.current_holders",
|
|
|
|
|
"posMasters.next_holder.current_holders.positions",
|
|
|
|
|
"posMasters.next_holder.current_holders.orgRoot",
|
|
|
|
|
"posMasters.next_holder.current_holders.orgChild1",
|
|
|
|
|
"posMasters.next_holder.current_holders.orgChild2",
|
|
|
|
|
"posMasters.next_holder.current_holders.orgChild3",
|
|
|
|
|
"posMasters.next_holder.current_holders.orgChild4",
|
|
|
|
|
"posMasters.positions",
|
|
|
|
|
"posMasters.positions.posLevel",
|
|
|
|
|
"posMasters.positions.posType",
|
|
|
|
|
"posMasters.positions.posExecutive",
|
|
|
|
|
],
|
|
|
|
|
});
|
2024-02-12 14:43:38 +07:00
|
|
|
|
2024-04-02 09:51:29 +07:00
|
|
|
const orgChild2Ids = orgChild2Data.map((orgChild2) => orgChild2.id) || null;
|
|
|
|
|
const orgChild3Data = await this.child3Repository.find({
|
|
|
|
|
where: {
|
|
|
|
|
orgChild2: In(orgChild2Ids),
|
|
|
|
|
},
|
|
|
|
|
order: { orgChild3Order: "ASC" },
|
|
|
|
|
relations: [
|
|
|
|
|
"posMasters",
|
|
|
|
|
"posMasters.orgRoot",
|
|
|
|
|
"posMasters.orgChild1",
|
|
|
|
|
"posMasters.orgChild2",
|
|
|
|
|
"posMasters.orgChild3",
|
|
|
|
|
"posMasters.orgChild4",
|
|
|
|
|
"posMasters.next_holder",
|
|
|
|
|
"posMasters.next_holder.posLevel",
|
|
|
|
|
"posMasters.next_holder.posType",
|
2024-04-09 14:32:30 +07:00
|
|
|
"posMasters.next_holder.profileSalary",
|
|
|
|
|
"posMasters.next_holder.profileEducations",
|
2024-04-02 09:51:29 +07:00
|
|
|
"posMasters.next_holder.current_holders",
|
|
|
|
|
"posMasters.next_holder.current_holders.positions",
|
|
|
|
|
"posMasters.next_holder.current_holders.orgRoot",
|
|
|
|
|
"posMasters.next_holder.current_holders.orgChild1",
|
|
|
|
|
"posMasters.next_holder.current_holders.orgChild2",
|
|
|
|
|
"posMasters.next_holder.current_holders.orgChild3",
|
|
|
|
|
"posMasters.next_holder.current_holders.orgChild4",
|
2024-04-09 14:32:30 +07:00
|
|
|
"posMasters.next_holder.current_holders.orgChild4",
|
2024-04-02 09:51:29 +07:00
|
|
|
"posMasters.positions",
|
|
|
|
|
"posMasters.positions.posLevel",
|
|
|
|
|
"posMasters.positions.posType",
|
|
|
|
|
"posMasters.positions.posExecutive",
|
|
|
|
|
],
|
|
|
|
|
});
|
2024-02-12 14:43:38 +07:00
|
|
|
|
2024-04-02 09:51:29 +07:00
|
|
|
const orgChild3Ids = orgChild3Data.map((orgChild3) => orgChild3.id) || null;
|
|
|
|
|
const orgChild4Data = await this.child4Repository.find({
|
|
|
|
|
where: {
|
|
|
|
|
orgChild3: In(orgChild3Ids),
|
|
|
|
|
},
|
|
|
|
|
order: { orgChild4Order: "ASC" },
|
|
|
|
|
relations: [
|
|
|
|
|
"posMasters",
|
|
|
|
|
"posMasters.orgRoot",
|
|
|
|
|
"posMasters.orgChild1",
|
|
|
|
|
"posMasters.orgChild2",
|
|
|
|
|
"posMasters.orgChild3",
|
|
|
|
|
"posMasters.orgChild4",
|
|
|
|
|
"posMasters.next_holder",
|
|
|
|
|
"posMasters.next_holder.posLevel",
|
|
|
|
|
"posMasters.next_holder.posType",
|
2024-04-09 14:32:30 +07:00
|
|
|
"posMasters.next_holder.profileSalary",
|
|
|
|
|
"posMasters.next_holder.profileEducations",
|
2024-04-02 09:51:29 +07:00
|
|
|
"posMasters.next_holder.current_holders",
|
|
|
|
|
"posMasters.next_holder.current_holders.positions",
|
|
|
|
|
"posMasters.next_holder.current_holders.orgRoot",
|
|
|
|
|
"posMasters.next_holder.current_holders.orgChild1",
|
|
|
|
|
"posMasters.next_holder.current_holders.orgChild2",
|
|
|
|
|
"posMasters.next_holder.current_holders.orgChild3",
|
|
|
|
|
"posMasters.next_holder.current_holders.orgChild4",
|
|
|
|
|
"posMasters.positions",
|
|
|
|
|
"posMasters.positions.posLevel",
|
|
|
|
|
"posMasters.positions.posType",
|
|
|
|
|
"posMasters.positions.posExecutive",
|
|
|
|
|
],
|
|
|
|
|
});
|
2024-02-12 14:43:38 +07:00
|
|
|
|
2024-04-02 09:51:29 +07:00
|
|
|
let orgRevisionActive: any = await this.orgRevisionRepository.findOne({
|
|
|
|
|
where: { orgRevisionIsCurrent: true, orgRevisionIsDraft: false },
|
|
|
|
|
relations: [
|
|
|
|
|
"posMasters",
|
|
|
|
|
"posMasters.positions",
|
|
|
|
|
"posMasters.positions.posLevel",
|
|
|
|
|
"posMasters.positions.posType",
|
|
|
|
|
"posMasters.positions.posExecutive",
|
|
|
|
|
],
|
|
|
|
|
});
|
|
|
|
|
if (orgRevisionActive == null) {
|
|
|
|
|
const _orgRevisionActive = await this.orgRevisionRepository.find({
|
|
|
|
|
order: { orgRevisionCreatedAt: "DESC" },
|
|
|
|
|
skip: 1,
|
2024-02-12 14:43:38 +07:00
|
|
|
relations: [
|
|
|
|
|
"posMasters",
|
|
|
|
|
"posMasters.positions",
|
|
|
|
|
"posMasters.positions.posLevel",
|
|
|
|
|
"posMasters.positions.posType",
|
|
|
|
|
"posMasters.positions.posExecutive",
|
|
|
|
|
],
|
|
|
|
|
});
|
2024-04-02 09:51:29 +07:00
|
|
|
if (_orgRevisionActive.length > 0) orgRevisionActive = _orgRevisionActive[0];
|
|
|
|
|
}
|
2024-02-12 14:43:38 +07:00
|
|
|
|
2024-04-02 09:51:29 +07:00
|
|
|
let data = new Array();
|
|
|
|
|
let _node: any;
|
|
|
|
|
let no = 1;
|
|
|
|
|
for (let orgRoot of orgRootData) {
|
|
|
|
|
await Promise.all(
|
|
|
|
|
orgRoot.posMasters
|
|
|
|
|
.sort((a, b) => a.posMasterOrder - b.posMasterOrder)
|
|
|
|
|
.map(async (posMaster) => {
|
|
|
|
|
if (posMaster.orgChild1Id == null) {
|
|
|
|
|
const positionName = [...new Set(posMaster.positions.map((x) => x.positionName))];
|
|
|
|
|
const posType = [
|
|
|
|
|
...new Set(
|
|
|
|
|
posMaster.positions
|
|
|
|
|
.filter((x: any) => x.posType != null)
|
|
|
|
|
.map((x) => x.posType.posTypeName),
|
|
|
|
|
),
|
|
|
|
|
];
|
|
|
|
|
const posLevel = [
|
|
|
|
|
...new Set(
|
|
|
|
|
posMaster.positions
|
|
|
|
|
.filter((x: any) => x.posLevel != null)
|
|
|
|
|
.map((x) => x.posLevel.posLevelName),
|
|
|
|
|
),
|
|
|
|
|
];
|
|
|
|
|
const posExecutive = [
|
|
|
|
|
...new Set(
|
|
|
|
|
posMaster.positions
|
|
|
|
|
.filter((x: any) => x.posExecutive != null)
|
|
|
|
|
.map((x) => x.posExecutive.posExecutiveName),
|
|
|
|
|
),
|
|
|
|
|
];
|
|
|
|
|
let positionMasterProfileOld: any = null;
|
|
|
|
|
if (posMaster.next_holder != null) {
|
|
|
|
|
positionMasterProfileOld = posMaster.next_holder.current_holders.find(
|
|
|
|
|
(x) => x.orgRevisionId == orgRevisionActive.id,
|
|
|
|
|
);
|
|
|
|
|
}
|
2024-02-12 14:43:38 +07:00
|
|
|
|
2024-04-02 09:51:29 +07:00
|
|
|
let positionMasterOld: any = null;
|
|
|
|
|
let profilePositionName: any = [];
|
|
|
|
|
let profilePosType: any = [];
|
|
|
|
|
let profilePosLevel: any = [];
|
|
|
|
|
let profilePosExecutive: any = [];
|
|
|
|
|
if (posMaster.ancestorDNA != null && posMaster.ancestorDNA != "") {
|
|
|
|
|
positionMasterOld = orgRevisionActive.posMasters.find(
|
|
|
|
|
(x: any) =>
|
|
|
|
|
x.orgRevisionId == orgRevisionActive.id &&
|
|
|
|
|
x.ancestorDNA == posMaster.ancestorDNA,
|
|
|
|
|
);
|
|
|
|
|
profilePositionName = [
|
|
|
|
|
...new Set(positionMasterOld.positions.map((x: any) => x.positionName)),
|
|
|
|
|
];
|
|
|
|
|
profilePosType = [
|
|
|
|
|
...new Set(
|
|
|
|
|
positionMasterOld.positions
|
|
|
|
|
.filter((x: any) => x.posType != null)
|
|
|
|
|
.map((x: any) => x.posType.posTypeName),
|
|
|
|
|
),
|
|
|
|
|
];
|
|
|
|
|
profilePosLevel = [
|
|
|
|
|
...new Set(
|
|
|
|
|
positionMasterOld.positions
|
|
|
|
|
.filter((x: any) => x.posLevel != null)
|
|
|
|
|
.map((x: any) => x.posLevel.posLevelName),
|
|
|
|
|
),
|
|
|
|
|
];
|
|
|
|
|
profilePosExecutive = [
|
|
|
|
|
...new Set(
|
|
|
|
|
positionMasterOld.positions
|
|
|
|
|
.filter((x: any) => x.posExecutive != null)
|
|
|
|
|
.map((x: any) => x.posExecutive.posExecutiveName),
|
|
|
|
|
),
|
|
|
|
|
];
|
|
|
|
|
}
|
2024-04-09 14:32:30 +07:00
|
|
|
let education: any = "";
|
|
|
|
|
if (
|
|
|
|
|
posMaster.next_holder != null &&
|
|
|
|
|
posMaster.next_holder.profileEducations != null &&
|
|
|
|
|
posMaster.next_holder.profileEducations.length > 0
|
|
|
|
|
) {
|
|
|
|
|
let _education: any = posMaster.next_holder.profileEducations.sort(
|
2024-04-11 16:33:06 +07:00
|
|
|
(a, b) =>
|
|
|
|
|
(b.finishDate == null ? 0 : b.finishDate.getTime()) -
|
|
|
|
|
(a.finishDate == null ? 0 : a.finishDate.getTime()),
|
2024-04-09 14:32:30 +07:00
|
|
|
);
|
|
|
|
|
if (_education.length > 0) {
|
|
|
|
|
education = _education[0];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
let salary: any = "";
|
|
|
|
|
if (
|
|
|
|
|
posMaster.next_holder != null &&
|
|
|
|
|
posMaster.next_holder.profileSalary != null &&
|
|
|
|
|
posMaster.next_holder.profileSalary.length > 0
|
|
|
|
|
) {
|
|
|
|
|
let _salary: any = posMaster.next_holder.profileSalary.sort(
|
2024-04-11 16:33:06 +07:00
|
|
|
(a, b) =>
|
|
|
|
|
(b.date == null ? 0 : b.date.getTime()) -
|
|
|
|
|
(a.date == null ? 0 : a.date.getTime()),
|
2024-04-09 14:32:30 +07:00
|
|
|
);
|
|
|
|
|
if (_salary.length > 0) {
|
|
|
|
|
salary = _salary[0];
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-04-02 09:51:29 +07:00
|
|
|
|
|
|
|
|
let node = {
|
|
|
|
|
posMasterOrder: posMaster.posMasterOrder, //
|
|
|
|
|
isSit: posMaster.isSit, //
|
|
|
|
|
orgTreeName: orgRoot.orgRootName,
|
|
|
|
|
orgTreeShortName: orgRoot.orgRootShortName,
|
|
|
|
|
posMasterNo: posMaster.posMasterNo,
|
|
|
|
|
positionName:
|
|
|
|
|
posMaster.next_holder == null
|
|
|
|
|
? positionName.join(" หรือ ")
|
|
|
|
|
: posMaster.isSit == false
|
|
|
|
|
? posMaster.positions.find((x: any) => x.positionIsSelected == true)
|
|
|
|
|
?.positionName
|
|
|
|
|
: posMaster.next_holder.position,
|
|
|
|
|
posType:
|
|
|
|
|
posMaster.next_holder == null
|
|
|
|
|
? posType.join(" หรือ ")
|
|
|
|
|
: posMaster.isSit == false
|
|
|
|
|
? posMaster.positions.find((x: any) => x.positionIsSelected == true)?.posType
|
|
|
|
|
?.posTypeName
|
|
|
|
|
: posMaster.next_holder.posType == null
|
|
|
|
|
? "-"
|
|
|
|
|
: posMaster.next_holder.posType.posTypeName,
|
|
|
|
|
posLevel:
|
|
|
|
|
posMaster.next_holder == null
|
|
|
|
|
? posLevel.join(" หรือ ")
|
|
|
|
|
: posMaster.isSit == false
|
|
|
|
|
? posMaster.positions.find((x: any) => x.positionIsSelected == true)?.posLevel
|
|
|
|
|
?.posLevelName
|
|
|
|
|
: posMaster.next_holder.posLevel == null
|
|
|
|
|
? "-"
|
|
|
|
|
: posMaster.next_holder.posLevel.posLevelName,
|
|
|
|
|
posExecutive:
|
|
|
|
|
posMaster.next_holder == null
|
|
|
|
|
? posExecutive.join(" หรือ ")
|
|
|
|
|
: posMaster.isSit == false
|
|
|
|
|
? posMaster.positions.find((x: any) => x.positionIsSelected == true)
|
|
|
|
|
?.posExecutive?.posExecutiveName
|
|
|
|
|
: positionMasterProfileOld == null
|
|
|
|
|
? "-"
|
|
|
|
|
: positionMasterProfileOld.positions.find(
|
|
|
|
|
(x: any) => x.positionIsSelected == true,
|
|
|
|
|
)?.posExecutive?.posExecutiveName,
|
|
|
|
|
|
|
|
|
|
profileOrgName:
|
|
|
|
|
posMaster.next_holder == null
|
|
|
|
|
? orgRoot.orgRootName
|
|
|
|
|
: positionMasterProfileOld == null
|
|
|
|
|
? "-"
|
|
|
|
|
: positionMasterProfileOld.orgChild4 != null
|
|
|
|
|
? positionMasterProfileOld.orgChild4.orgChild4Name
|
|
|
|
|
: positionMasterProfileOld.orgChild3 != null
|
|
|
|
|
? positionMasterProfileOld.orgChild3.orgChild3Name
|
|
|
|
|
: positionMasterProfileOld.orgChild2 != null
|
|
|
|
|
? positionMasterProfileOld.orgChild2.orgChild2Name
|
|
|
|
|
: positionMasterProfileOld.orgChild1 != null
|
|
|
|
|
? positionMasterProfileOld.orgChild1.orgChild1Name
|
|
|
|
|
: positionMasterProfileOld.orgRoot != null
|
|
|
|
|
? positionMasterProfileOld.orgRoot.orgRootName
|
|
|
|
|
: "-",
|
|
|
|
|
profileOrgShortName:
|
|
|
|
|
posMaster.next_holder == null
|
|
|
|
|
? orgRoot.orgRootShortName
|
|
|
|
|
: positionMasterProfileOld == null
|
|
|
|
|
? "-"
|
|
|
|
|
: positionMasterProfileOld.orgChild4 != null
|
|
|
|
|
? positionMasterProfileOld.orgChild4.orgChild4ShortName
|
|
|
|
|
: positionMasterProfileOld.orgChild3 != null
|
|
|
|
|
? positionMasterProfileOld.orgChild3.orgChild3ShortName
|
|
|
|
|
: positionMasterProfileOld.orgChild2 != null
|
|
|
|
|
? positionMasterProfileOld.orgChild2.orgChild2ShortName
|
|
|
|
|
: positionMasterProfileOld.orgChild1 != null
|
|
|
|
|
? positionMasterProfileOld.orgChild1.orgChild1ShortName
|
|
|
|
|
: positionMasterProfileOld.orgRoot != null
|
|
|
|
|
? positionMasterProfileOld.orgRoot.orgRootShortName
|
|
|
|
|
: "-",
|
|
|
|
|
profileFullname:
|
|
|
|
|
posMaster.next_holder == null
|
|
|
|
|
? "- ว่าง -"
|
|
|
|
|
: `${posMaster.next_holder.prefix}${posMaster.next_holder.firstName} ${posMaster.next_holder.lastName}`,
|
|
|
|
|
profilePosMasterNo:
|
|
|
|
|
posMaster.next_holder == null
|
|
|
|
|
? positionMasterOld == null
|
|
|
|
|
? "-"
|
|
|
|
|
: positionMasterOld.posMasterNo
|
|
|
|
|
: positionMasterProfileOld == null
|
|
|
|
|
? "-"
|
|
|
|
|
: positionMasterProfileOld.posMasterNo,
|
|
|
|
|
profilePositionName:
|
|
|
|
|
posMaster.next_holder == null
|
|
|
|
|
? positionMasterOld == null
|
|
|
|
|
? positionName.join(" หรือ ")
|
|
|
|
|
: profilePositionName.join(" หรือ ")
|
|
|
|
|
: posMaster.next_holder.position,
|
|
|
|
|
profilePosType:
|
|
|
|
|
posMaster.next_holder == null
|
|
|
|
|
? positionMasterOld == null
|
|
|
|
|
? posType.join(" หรือ ")
|
|
|
|
|
: profilePosType.join(" หรือ ")
|
|
|
|
|
: posMaster.next_holder.posType == null
|
|
|
|
|
? "-"
|
|
|
|
|
: posMaster.next_holder.posType.posTypeName,
|
|
|
|
|
profilePosLevel:
|
|
|
|
|
posMaster.next_holder == null
|
|
|
|
|
? positionMasterOld == null
|
|
|
|
|
? posLevel.join(" หรือ ")
|
|
|
|
|
: profilePosLevel.join(" หรือ ")
|
|
|
|
|
: posMaster.next_holder.posLevel == null
|
|
|
|
|
? "-"
|
|
|
|
|
: posMaster.next_holder.posLevel.posLevelName,
|
|
|
|
|
profilePosExecutive:
|
|
|
|
|
posMaster.next_holder == null
|
|
|
|
|
? positionMasterOld == null
|
|
|
|
|
? posExecutive.join(" หรือ ")
|
|
|
|
|
: profilePosExecutive.join(" หรือ ")
|
|
|
|
|
: positionMasterProfileOld == null
|
|
|
|
|
? "-"
|
|
|
|
|
: positionMasterProfileOld.positions.find(
|
|
|
|
|
(x: any) => x.positionIsSelected == true,
|
|
|
|
|
)?.posExecutive?.posExecutiveName,
|
2024-04-09 14:32:30 +07:00
|
|
|
education: education == "" ? "" : education.degree,
|
|
|
|
|
salary: salary == "" ? "" : salary.amount,
|
2024-07-04 00:11:06 +07:00
|
|
|
reason: posMaster.reason,
|
2024-04-02 09:51:29 +07:00
|
|
|
};
|
|
|
|
|
if (_node == null) {
|
|
|
|
|
const head = {
|
2024-06-07 15:40:33 +07:00
|
|
|
posMasterNo: Extension.ToThaiNumber(node.orgTreeShortName.toString()),
|
|
|
|
|
profileFullname: Extension.ToThaiNumber(node.profileOrgName.toString()),
|
|
|
|
|
posExecutive: Extension.ToThaiNumber(node.orgTreeName.toString()),
|
2024-04-02 09:51:29 +07:00
|
|
|
positionName: "",
|
|
|
|
|
posType: "",
|
|
|
|
|
posLevel: "",
|
2024-06-07 15:40:33 +07:00
|
|
|
profilePosMasterNo: Extension.ToThaiNumber(node.profileOrgShortName.toString()),
|
2024-04-02 09:51:29 +07:00
|
|
|
profilePosExecutive: "",
|
|
|
|
|
profilePositionName: "",
|
|
|
|
|
profilePosType: "",
|
|
|
|
|
profilePosLevel: "",
|
|
|
|
|
education: "",
|
|
|
|
|
salary: "",
|
2024-07-04 00:11:06 +07:00
|
|
|
reason: "",
|
2024-04-02 09:51:29 +07:00
|
|
|
};
|
|
|
|
|
data.push(head);
|
|
|
|
|
const _head = {
|
2024-04-09 14:32:30 +07:00
|
|
|
no: Extension.ToThaiNumber(no.toString()),
|
2024-04-09 12:18:52 +07:00
|
|
|
posMasterNo:
|
|
|
|
|
node.posMasterNo == null
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.posMasterNo.toString()),
|
2024-06-07 15:40:33 +07:00
|
|
|
profileFullname:
|
|
|
|
|
node.profileFullname == null
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.profileFullname.toString()),
|
|
|
|
|
posExecutive:
|
|
|
|
|
node.posExecutive == null
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.posExecutive.toString()),
|
|
|
|
|
positionName:
|
|
|
|
|
node.positionName == null
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.positionName.toString()),
|
|
|
|
|
posType:
|
|
|
|
|
node.posType == null ? "" : Extension.ToThaiNumber(node.posType.toString()),
|
|
|
|
|
posLevel:
|
|
|
|
|
node.posLevel == null ? "" : Extension.ToThaiNumber(node.posLevel.toString()),
|
2024-04-09 12:18:52 +07:00
|
|
|
profilePosMasterNo: Extension.ToThaiNumber(node.profilePosMasterNo.toString()),
|
2024-06-07 15:40:33 +07:00
|
|
|
profilePosExecutive:
|
|
|
|
|
node.profilePosExecutive == null
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.profilePosExecutive.toString()),
|
|
|
|
|
profilePositionName:
|
|
|
|
|
node.profilePositionName == null
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.profilePositionName.toString()),
|
|
|
|
|
profilePosType:
|
|
|
|
|
node.profilePosType == null
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.profilePosType.toString()),
|
|
|
|
|
profilePosLevel:
|
|
|
|
|
node.profilePosLevel == null
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.profilePosLevel.toString()),
|
|
|
|
|
education:
|
|
|
|
|
node.education == null ? "" : Extension.ToThaiNumber(node.education.toString()),
|
2024-06-25 10:20:09 +07:00
|
|
|
salary: node.salary ? Extension.ToThaiNumber(node.salary.toLocaleString()) : "",
|
2024-07-04 00:11:06 +07:00
|
|
|
reason: node.reason == null ? "" : Extension.ToThaiNumber(node.reason.toString()),
|
2024-04-02 09:51:29 +07:00
|
|
|
};
|
|
|
|
|
data.push(_head);
|
|
|
|
|
} else {
|
|
|
|
|
if (
|
|
|
|
|
node.orgTreeShortName != _node.orgTreeShortName ||
|
|
|
|
|
node.orgTreeName != _node.orgTreeName ||
|
|
|
|
|
node.profileOrgShortName != _node.profileOrgShortName ||
|
|
|
|
|
node.profileOrgName != _node.profileOrgName
|
|
|
|
|
) {
|
|
|
|
|
const head = {
|
|
|
|
|
posMasterNo:
|
|
|
|
|
node.orgTreeShortName == _node.orgTreeShortName ? "" : node.orgTreeShortName,
|
|
|
|
|
profileFullname:
|
|
|
|
|
node.profileOrgName == _node.profileOrgName ? "" : node.profileOrgName,
|
|
|
|
|
posExecutive: node.orgTreeName == _node.orgTreeName ? "" : node.orgTreeName,
|
|
|
|
|
positionName: "",
|
|
|
|
|
posType: "",
|
|
|
|
|
posLevel: "",
|
|
|
|
|
profilePosMasterNo:
|
|
|
|
|
node.profileOrgShortName == _node.profileOrgShortName
|
|
|
|
|
? ""
|
|
|
|
|
: node.profileOrgShortName,
|
|
|
|
|
profilePosExecutive: "",
|
|
|
|
|
profilePositionName: "",
|
|
|
|
|
profilePosType: "",
|
|
|
|
|
profilePosLevel: "",
|
|
|
|
|
education: "",
|
|
|
|
|
salary: "",
|
2024-07-04 00:11:06 +07:00
|
|
|
reason: "",
|
2024-04-02 09:51:29 +07:00
|
|
|
};
|
|
|
|
|
data.push(head);
|
|
|
|
|
_node == null;
|
|
|
|
|
}
|
|
|
|
|
const head = {
|
2024-04-09 14:32:30 +07:00
|
|
|
no: Extension.ToThaiNumber(no.toString()),
|
2024-04-09 12:18:52 +07:00
|
|
|
posMasterNo:
|
|
|
|
|
node.posMasterNo == null
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.posMasterNo.toString()),
|
2024-06-07 15:40:33 +07:00
|
|
|
profileFullname:
|
|
|
|
|
node.profileFullname == null
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.profileFullname.toString()),
|
|
|
|
|
posExecutive:
|
|
|
|
|
node.posExecutive == null
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.posExecutive.toString()),
|
|
|
|
|
positionName:
|
|
|
|
|
node.positionName == null
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.positionName.toString()),
|
|
|
|
|
posType:
|
|
|
|
|
node.posType == null ? "" : Extension.ToThaiNumber(node.posType.toString()),
|
|
|
|
|
posLevel:
|
|
|
|
|
node.posLevel == null ? "" : Extension.ToThaiNumber(node.posLevel.toString()),
|
2024-04-09 12:18:52 +07:00
|
|
|
profilePosMasterNo: Extension.ToThaiNumber(node.profilePosMasterNo.toString()),
|
2024-04-02 09:51:29 +07:00
|
|
|
profilePosExecutive:
|
2024-06-07 15:40:33 +07:00
|
|
|
node.profilePosExecutive == null
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.profilePosExecutive.toString()),
|
|
|
|
|
profilePositionName:
|
|
|
|
|
node.profilePositionName == null
|
2024-04-02 09:51:29 +07:00
|
|
|
? ""
|
2024-06-07 15:40:33 +07:00
|
|
|
: Extension.ToThaiNumber(node.profilePositionName.toString()),
|
|
|
|
|
profilePosType:
|
|
|
|
|
node.profilePosType == null
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.profilePosType.toString()),
|
|
|
|
|
profilePosLevel:
|
|
|
|
|
node.profilePosLevel == null
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.profilePosLevel.toString()),
|
|
|
|
|
education:
|
|
|
|
|
node.education == null ? "" : Extension.ToThaiNumber(node.education.toString()),
|
2024-06-25 10:20:09 +07:00
|
|
|
salary: node.salary ? Extension.ToThaiNumber(node.salary.toLocaleString()) : "",
|
2024-07-04 00:11:06 +07:00
|
|
|
reason: node.reason == null ? "" : Extension.ToThaiNumber(node.reason.toString()),
|
2024-04-02 09:51:29 +07:00
|
|
|
};
|
|
|
|
|
data.push(head);
|
|
|
|
|
}
|
|
|
|
|
no += 1;
|
|
|
|
|
_node = node;
|
|
|
|
|
}
|
|
|
|
|
}),
|
|
|
|
|
);
|
|
|
|
|
_node = null;
|
2024-02-12 14:43:38 +07:00
|
|
|
|
2024-04-02 09:51:29 +07:00
|
|
|
for (let orgChild1 of orgChild1Data.filter(
|
|
|
|
|
(orgChild1) => orgChild1.orgRootId === orgRoot.id,
|
|
|
|
|
)) {
|
2024-02-12 14:43:38 +07:00
|
|
|
await Promise.all(
|
2024-04-02 09:51:29 +07:00
|
|
|
orgChild1.posMasters
|
2024-02-12 14:43:38 +07:00
|
|
|
.sort((a, b) => a.posMasterOrder - b.posMasterOrder)
|
|
|
|
|
.map(async (posMaster) => {
|
2024-04-02 09:51:29 +07:00
|
|
|
if (posMaster.orgChild2Id == null) {
|
2024-02-12 14:43:38 +07:00
|
|
|
const positionName = [...new Set(posMaster.positions.map((x) => x.positionName))];
|
|
|
|
|
const posType = [
|
|
|
|
|
...new Set(
|
|
|
|
|
posMaster.positions
|
|
|
|
|
.filter((x: any) => x.posType != null)
|
|
|
|
|
.map((x) => x.posType.posTypeName),
|
|
|
|
|
),
|
|
|
|
|
];
|
|
|
|
|
const posLevel = [
|
|
|
|
|
...new Set(
|
|
|
|
|
posMaster.positions
|
|
|
|
|
.filter((x: any) => x.posLevel != null)
|
|
|
|
|
.map((x) => x.posLevel.posLevelName),
|
|
|
|
|
),
|
|
|
|
|
];
|
|
|
|
|
const posExecutive = [
|
|
|
|
|
...new Set(
|
|
|
|
|
posMaster.positions
|
|
|
|
|
.filter((x: any) => x.posExecutive != null)
|
|
|
|
|
.map((x) => x.posExecutive.posExecutiveName),
|
|
|
|
|
),
|
|
|
|
|
];
|
|
|
|
|
let positionMasterProfileOld: any = null;
|
|
|
|
|
if (posMaster.next_holder != null) {
|
|
|
|
|
positionMasterProfileOld = posMaster.next_holder.current_holders.find(
|
|
|
|
|
(x) => x.orgRevisionId == orgRevisionActive.id,
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let positionMasterOld: any = null;
|
|
|
|
|
let profilePositionName: any = [];
|
|
|
|
|
let profilePosType: any = [];
|
|
|
|
|
let profilePosLevel: any = [];
|
|
|
|
|
let profilePosExecutive: any = [];
|
2024-04-02 09:51:29 +07:00
|
|
|
if (posMaster.ancestorDNA != null && posMaster.ancestorDNA != "") {
|
2024-02-12 14:43:38 +07:00
|
|
|
positionMasterOld = orgRevisionActive.posMasters.find(
|
|
|
|
|
(x: any) =>
|
|
|
|
|
x.orgRevisionId == orgRevisionActive.id &&
|
|
|
|
|
x.ancestorDNA == posMaster.ancestorDNA,
|
|
|
|
|
);
|
|
|
|
|
profilePositionName = [
|
|
|
|
|
...new Set(positionMasterOld.positions.map((x: any) => x.positionName)),
|
|
|
|
|
];
|
|
|
|
|
profilePosType = [
|
|
|
|
|
...new Set(
|
|
|
|
|
positionMasterOld.positions
|
|
|
|
|
.filter((x: any) => x.posType != null)
|
|
|
|
|
.map((x: any) => x.posType.posTypeName),
|
|
|
|
|
),
|
|
|
|
|
];
|
|
|
|
|
profilePosLevel = [
|
|
|
|
|
...new Set(
|
|
|
|
|
positionMasterOld.positions
|
|
|
|
|
.filter((x: any) => x.posLevel != null)
|
|
|
|
|
.map((x: any) => x.posLevel.posLevelName),
|
|
|
|
|
),
|
|
|
|
|
];
|
|
|
|
|
profilePosExecutive = [
|
|
|
|
|
...new Set(
|
|
|
|
|
positionMasterOld.positions
|
|
|
|
|
.filter((x: any) => x.posExecutive != null)
|
|
|
|
|
.map((x: any) => x.posExecutive.posExecutiveName),
|
|
|
|
|
),
|
|
|
|
|
];
|
|
|
|
|
}
|
2024-04-09 14:32:30 +07:00
|
|
|
let education: any = "";
|
|
|
|
|
if (
|
|
|
|
|
posMaster.next_holder != null &&
|
|
|
|
|
posMaster.next_holder.profileEducations != null &&
|
|
|
|
|
posMaster.next_holder.profileEducations.length > 0
|
|
|
|
|
) {
|
|
|
|
|
let _education: any = posMaster.next_holder.profileEducations.sort(
|
2024-04-11 16:33:06 +07:00
|
|
|
(a, b) =>
|
|
|
|
|
(b.finishDate == null ? 0 : b.finishDate.getTime()) -
|
|
|
|
|
(a.finishDate == null ? 0 : a.finishDate.getTime()),
|
2024-04-09 14:32:30 +07:00
|
|
|
);
|
|
|
|
|
if (_education.length > 0) {
|
|
|
|
|
education = _education[0];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
let salary: any = "";
|
|
|
|
|
if (
|
|
|
|
|
posMaster.next_holder != null &&
|
|
|
|
|
posMaster.next_holder.profileSalary != null &&
|
|
|
|
|
posMaster.next_holder.profileSalary.length > 0
|
|
|
|
|
) {
|
|
|
|
|
let _salary: any = posMaster.next_holder.profileSalary.sort(
|
2024-04-11 16:33:06 +07:00
|
|
|
(a, b) =>
|
|
|
|
|
(b.date == null ? 0 : b.date.getTime()) -
|
|
|
|
|
(a.date == null ? 0 : a.date.getTime()),
|
2024-04-09 14:32:30 +07:00
|
|
|
);
|
|
|
|
|
if (_salary.length > 0) {
|
|
|
|
|
salary = _salary[0];
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-02-12 14:43:38 +07:00
|
|
|
|
|
|
|
|
let node = {
|
|
|
|
|
posMasterOrder: posMaster.posMasterOrder, //
|
|
|
|
|
isSit: posMaster.isSit, //
|
2024-04-02 09:51:29 +07:00
|
|
|
orgTreeName: orgChild1.orgChild1Name,
|
|
|
|
|
orgTreeShortName: orgChild1.orgChild1ShortName,
|
2024-02-12 14:43:38 +07:00
|
|
|
posMasterNo: posMaster.posMasterNo,
|
|
|
|
|
positionName:
|
|
|
|
|
posMaster.next_holder == null
|
|
|
|
|
? positionName.join(" หรือ ")
|
|
|
|
|
: posMaster.isSit == false
|
|
|
|
|
? posMaster.positions.find((x: any) => x.positionIsSelected == true)
|
|
|
|
|
?.positionName
|
|
|
|
|
: posMaster.next_holder.position,
|
|
|
|
|
posType:
|
|
|
|
|
posMaster.next_holder == null
|
|
|
|
|
? posType.join(" หรือ ")
|
|
|
|
|
: posMaster.isSit == false
|
|
|
|
|
? posMaster.positions.find((x: any) => x.positionIsSelected == true)
|
|
|
|
|
?.posType?.posTypeName
|
|
|
|
|
: posMaster.next_holder.posType == null
|
|
|
|
|
? "-"
|
|
|
|
|
: posMaster.next_holder.posType.posTypeName,
|
|
|
|
|
posLevel:
|
|
|
|
|
posMaster.next_holder == null
|
|
|
|
|
? posLevel.join(" หรือ ")
|
|
|
|
|
: posMaster.isSit == false
|
|
|
|
|
? posMaster.positions.find((x: any) => x.positionIsSelected == true)
|
|
|
|
|
?.posLevel?.posLevelName
|
|
|
|
|
: posMaster.next_holder.posLevel == null
|
|
|
|
|
? "-"
|
|
|
|
|
: posMaster.next_holder.posLevel.posLevelName,
|
|
|
|
|
posExecutive:
|
|
|
|
|
posMaster.next_holder == null
|
|
|
|
|
? posExecutive.join(" หรือ ")
|
|
|
|
|
: posMaster.isSit == false
|
|
|
|
|
? posMaster.positions.find((x: any) => x.positionIsSelected == true)
|
|
|
|
|
?.posExecutive?.posExecutiveName
|
|
|
|
|
: positionMasterProfileOld == null
|
|
|
|
|
? "-"
|
|
|
|
|
: positionMasterProfileOld.positions.find(
|
|
|
|
|
(x: any) => x.positionIsSelected == true,
|
|
|
|
|
)?.posExecutive?.posExecutiveName,
|
|
|
|
|
|
|
|
|
|
profileOrgName:
|
|
|
|
|
posMaster.next_holder == null
|
2024-04-02 09:51:29 +07:00
|
|
|
? orgChild1.orgChild1Name
|
2024-02-12 14:43:38 +07:00
|
|
|
: positionMasterProfileOld == null
|
|
|
|
|
? "-"
|
|
|
|
|
: positionMasterProfileOld.orgChild4 != null
|
|
|
|
|
? positionMasterProfileOld.orgChild4.orgChild4Name
|
|
|
|
|
: positionMasterProfileOld.orgChild3 != null
|
|
|
|
|
? positionMasterProfileOld.orgChild3.orgChild3Name
|
|
|
|
|
: positionMasterProfileOld.orgChild2 != null
|
|
|
|
|
? positionMasterProfileOld.orgChild2.orgChild2Name
|
|
|
|
|
: positionMasterProfileOld.orgChild1 != null
|
|
|
|
|
? positionMasterProfileOld.orgChild1.orgChild1Name
|
|
|
|
|
: positionMasterProfileOld.orgRoot != null
|
|
|
|
|
? positionMasterProfileOld.orgRoot.orgRootName
|
|
|
|
|
: "-",
|
|
|
|
|
profileOrgShortName:
|
|
|
|
|
posMaster.next_holder == null
|
2024-04-02 09:51:29 +07:00
|
|
|
? orgChild1.orgChild1ShortName
|
2024-02-12 14:43:38 +07:00
|
|
|
: positionMasterProfileOld == null
|
|
|
|
|
? "-"
|
|
|
|
|
: positionMasterProfileOld.orgChild4 != null
|
|
|
|
|
? positionMasterProfileOld.orgChild4.orgChild4ShortName
|
|
|
|
|
: positionMasterProfileOld.orgChild3 != null
|
|
|
|
|
? positionMasterProfileOld.orgChild3.orgChild3ShortName
|
|
|
|
|
: positionMasterProfileOld.orgChild2 != null
|
|
|
|
|
? positionMasterProfileOld.orgChild2.orgChild2ShortName
|
|
|
|
|
: positionMasterProfileOld.orgChild1 != null
|
|
|
|
|
? positionMasterProfileOld.orgChild1.orgChild1ShortName
|
|
|
|
|
: positionMasterProfileOld.orgRoot != null
|
|
|
|
|
? positionMasterProfileOld.orgRoot.orgRootShortName
|
|
|
|
|
: "-",
|
|
|
|
|
profileFullname:
|
|
|
|
|
posMaster.next_holder == null
|
|
|
|
|
? "- ว่าง -"
|
|
|
|
|
: `${posMaster.next_holder.prefix}${posMaster.next_holder.firstName} ${posMaster.next_holder.lastName}`,
|
|
|
|
|
profilePosMasterNo:
|
|
|
|
|
posMaster.next_holder == null
|
|
|
|
|
? positionMasterOld == null
|
|
|
|
|
? "-"
|
|
|
|
|
: positionMasterOld.posMasterNo
|
|
|
|
|
: positionMasterProfileOld == null
|
|
|
|
|
? "-"
|
|
|
|
|
: positionMasterProfileOld.posMasterNo,
|
|
|
|
|
profilePositionName:
|
|
|
|
|
posMaster.next_holder == null
|
|
|
|
|
? positionMasterOld == null
|
|
|
|
|
? positionName.join(" หรือ ")
|
|
|
|
|
: profilePositionName.join(" หรือ ")
|
|
|
|
|
: posMaster.next_holder.position,
|
|
|
|
|
profilePosType:
|
|
|
|
|
posMaster.next_holder == null
|
|
|
|
|
? positionMasterOld == null
|
|
|
|
|
? posType.join(" หรือ ")
|
|
|
|
|
: profilePosType.join(" หรือ ")
|
|
|
|
|
: posMaster.next_holder.posType == null
|
|
|
|
|
? "-"
|
|
|
|
|
: posMaster.next_holder.posType.posTypeName,
|
|
|
|
|
profilePosLevel:
|
|
|
|
|
posMaster.next_holder == null
|
|
|
|
|
? positionMasterOld == null
|
|
|
|
|
? posLevel.join(" หรือ ")
|
|
|
|
|
: profilePosLevel.join(" หรือ ")
|
|
|
|
|
: posMaster.next_holder.posLevel == null
|
|
|
|
|
? "-"
|
|
|
|
|
: posMaster.next_holder.posLevel.posLevelName,
|
|
|
|
|
profilePosExecutive:
|
|
|
|
|
posMaster.next_holder == null
|
|
|
|
|
? positionMasterOld == null
|
|
|
|
|
? posExecutive.join(" หรือ ")
|
|
|
|
|
: profilePosExecutive.join(" หรือ ")
|
|
|
|
|
: positionMasterProfileOld == null
|
|
|
|
|
? "-"
|
|
|
|
|
: positionMasterProfileOld.positions.find(
|
|
|
|
|
(x: any) => x.positionIsSelected == true,
|
|
|
|
|
)?.posExecutive?.posExecutiveName,
|
2024-04-09 14:32:30 +07:00
|
|
|
education: education == "" ? "" : education.degree,
|
|
|
|
|
salary: salary == "" ? "" : salary.amount,
|
2024-07-04 00:11:06 +07:00
|
|
|
reason: posMaster.reason,
|
2024-02-12 14:43:38 +07:00
|
|
|
};
|
|
|
|
|
if (_node == null) {
|
|
|
|
|
const head = {
|
2024-06-07 15:40:33 +07:00
|
|
|
posMasterNo: Extension.ToThaiNumber(node.orgTreeShortName.toString()),
|
|
|
|
|
profileFullname: Extension.ToThaiNumber(node.profileOrgName.toString()),
|
|
|
|
|
posExecutive: Extension.ToThaiNumber(node.orgTreeName.toString()),
|
2024-02-12 14:43:38 +07:00
|
|
|
positionName: "",
|
|
|
|
|
posType: "",
|
|
|
|
|
posLevel: "",
|
2024-06-07 15:40:33 +07:00
|
|
|
profilePosMasterNo: Extension.ToThaiNumber(node.profileOrgShortName.toString()),
|
2024-02-12 14:43:38 +07:00
|
|
|
profilePosExecutive: "",
|
|
|
|
|
profilePositionName: "",
|
|
|
|
|
profilePosType: "",
|
|
|
|
|
profilePosLevel: "",
|
2024-02-13 09:59:10 +07:00
|
|
|
education: "",
|
|
|
|
|
salary: "",
|
2024-07-04 00:11:06 +07:00
|
|
|
reason: "",
|
2024-02-12 14:43:38 +07:00
|
|
|
};
|
|
|
|
|
data.push(head);
|
|
|
|
|
const _head = {
|
2024-04-09 14:32:30 +07:00
|
|
|
no: Extension.ToThaiNumber(no.toString()),
|
2024-04-09 12:18:52 +07:00
|
|
|
posMasterNo:
|
|
|
|
|
node.posMasterNo == null
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.posMasterNo.toString()),
|
2024-06-07 15:40:33 +07:00
|
|
|
profileFullname:
|
|
|
|
|
node.profileFullname == null
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.profileFullname.toString()),
|
|
|
|
|
posExecutive:
|
|
|
|
|
node.posExecutive == null
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.posExecutive.toString()),
|
|
|
|
|
positionName:
|
|
|
|
|
node.positionName == null
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.positionName.toString()),
|
|
|
|
|
posType:
|
|
|
|
|
node.posType == null ? "" : Extension.ToThaiNumber(node.posType.toString()),
|
|
|
|
|
posLevel:
|
|
|
|
|
node.posLevel == null ? "" : Extension.ToThaiNumber(node.posLevel.toString()),
|
2024-04-09 12:18:52 +07:00
|
|
|
profilePosMasterNo: Extension.ToThaiNumber(node.profilePosMasterNo.toString()),
|
2024-06-07 15:40:33 +07:00
|
|
|
profilePosExecutive:
|
|
|
|
|
node.profilePosExecutive == null
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.profilePosExecutive.toString()),
|
|
|
|
|
profilePositionName:
|
|
|
|
|
node.profilePositionName == null
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.profilePositionName.toString()),
|
|
|
|
|
profilePosType:
|
|
|
|
|
node.profilePosType == null
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.profilePosType.toString()),
|
|
|
|
|
profilePosLevel:
|
|
|
|
|
node.profilePosLevel == null
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.profilePosLevel.toString()),
|
|
|
|
|
education:
|
|
|
|
|
node.education == null
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.education.toString()),
|
2024-06-25 10:20:09 +07:00
|
|
|
salary: node.salary ? Extension.ToThaiNumber(node.salary.toLocaleString()) : "",
|
2024-07-04 00:11:06 +07:00
|
|
|
reason:
|
|
|
|
|
node.reason == null ? "" : Extension.ToThaiNumber(node.reason.toString()),
|
2024-02-12 14:43:38 +07:00
|
|
|
};
|
|
|
|
|
data.push(_head);
|
|
|
|
|
} else {
|
|
|
|
|
if (
|
|
|
|
|
node.orgTreeShortName != _node.orgTreeShortName ||
|
|
|
|
|
node.orgTreeName != _node.orgTreeName ||
|
|
|
|
|
node.profileOrgShortName != _node.profileOrgShortName ||
|
|
|
|
|
node.profileOrgName != _node.profileOrgName
|
|
|
|
|
) {
|
|
|
|
|
const head = {
|
|
|
|
|
posMasterNo:
|
|
|
|
|
node.orgTreeShortName == _node.orgTreeShortName
|
|
|
|
|
? ""
|
|
|
|
|
: node.orgTreeShortName,
|
|
|
|
|
profileFullname:
|
|
|
|
|
node.profileOrgName == _node.profileOrgName ? "" : node.profileOrgName,
|
|
|
|
|
posExecutive: node.orgTreeName == _node.orgTreeName ? "" : node.orgTreeName,
|
|
|
|
|
positionName: "",
|
|
|
|
|
posType: "",
|
|
|
|
|
posLevel: "",
|
|
|
|
|
profilePosMasterNo:
|
|
|
|
|
node.profileOrgShortName == _node.profileOrgShortName
|
|
|
|
|
? ""
|
|
|
|
|
: node.profileOrgShortName,
|
|
|
|
|
profilePosExecutive: "",
|
|
|
|
|
profilePositionName: "",
|
|
|
|
|
profilePosType: "",
|
|
|
|
|
profilePosLevel: "",
|
2024-02-13 09:59:10 +07:00
|
|
|
education: "",
|
|
|
|
|
salary: "",
|
2024-07-04 00:11:06 +07:00
|
|
|
reason: "",
|
2024-02-12 14:43:38 +07:00
|
|
|
};
|
|
|
|
|
data.push(head);
|
|
|
|
|
_node == null;
|
|
|
|
|
}
|
|
|
|
|
const head = {
|
2024-04-09 14:32:30 +07:00
|
|
|
no: Extension.ToThaiNumber(no.toString()),
|
2024-04-09 12:18:52 +07:00
|
|
|
posMasterNo:
|
|
|
|
|
node.posMasterNo == null
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.posMasterNo.toString()),
|
2024-06-07 15:40:33 +07:00
|
|
|
profileFullname:
|
|
|
|
|
node.profileFullname == null
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.profileFullname.toString()),
|
|
|
|
|
posExecutive:
|
|
|
|
|
node.posExecutive == null
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.posExecutive.toString()),
|
|
|
|
|
positionName:
|
|
|
|
|
node.positionName == null
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.positionName.toString()),
|
|
|
|
|
posType:
|
|
|
|
|
node.posType == null ? "" : Extension.ToThaiNumber(node.posType.toString()),
|
|
|
|
|
posLevel:
|
|
|
|
|
node.posLevel == null ? "" : Extension.ToThaiNumber(node.posLevel.toString()),
|
2024-04-09 12:18:52 +07:00
|
|
|
profilePosMasterNo: Extension.ToThaiNumber(node.profilePosMasterNo.toString()),
|
2024-02-12 14:43:38 +07:00
|
|
|
profilePosExecutive:
|
2024-06-07 15:40:33 +07:00
|
|
|
node.profilePosExecutive == null
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.profilePosExecutive.toString()),
|
|
|
|
|
profilePositionName:
|
|
|
|
|
node.profilePositionName == null
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.profilePositionName.toString()),
|
|
|
|
|
profilePosType:
|
|
|
|
|
node.profilePosType == null
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.profilePosType.toString()),
|
|
|
|
|
profilePosLevel:
|
|
|
|
|
node.profilePosLevel == null
|
2024-02-12 14:43:38 +07:00
|
|
|
? ""
|
2024-06-07 15:40:33 +07:00
|
|
|
: Extension.ToThaiNumber(node.profilePosLevel.toString()),
|
|
|
|
|
education:
|
|
|
|
|
node.education == null
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.education.toString()),
|
2024-06-25 10:20:09 +07:00
|
|
|
salary: node.salary ? Extension.ToThaiNumber(node.salary.toLocaleString()) : "",
|
2024-07-04 00:11:06 +07:00
|
|
|
reason:
|
|
|
|
|
node.reason == null ? "" : Extension.ToThaiNumber(node.reason.toString()),
|
2024-02-12 14:43:38 +07:00
|
|
|
};
|
|
|
|
|
data.push(head);
|
|
|
|
|
}
|
|
|
|
|
no += 1;
|
|
|
|
|
_node = node;
|
|
|
|
|
}
|
|
|
|
|
}),
|
|
|
|
|
);
|
|
|
|
|
_node = null;
|
|
|
|
|
|
2024-04-02 09:51:29 +07:00
|
|
|
for (let orgChild2 of orgChild2Data.filter(
|
|
|
|
|
(orgChild2) => orgChild2.orgChild1Id === orgChild1.id,
|
2024-02-12 14:43:38 +07:00
|
|
|
)) {
|
|
|
|
|
await Promise.all(
|
2024-04-02 09:51:29 +07:00
|
|
|
orgChild2.posMasters
|
2024-02-12 14:43:38 +07:00
|
|
|
.sort((a, b) => a.posMasterOrder - b.posMasterOrder)
|
|
|
|
|
.map(async (posMaster) => {
|
2024-04-02 09:51:29 +07:00
|
|
|
if (posMaster.orgChild3Id == null) {
|
2024-02-12 14:43:38 +07:00
|
|
|
const positionName = [...new Set(posMaster.positions.map((x) => x.positionName))];
|
|
|
|
|
const posType = [
|
|
|
|
|
...new Set(
|
|
|
|
|
posMaster.positions
|
|
|
|
|
.filter((x: any) => x.posType != null)
|
|
|
|
|
.map((x) => x.posType.posTypeName),
|
|
|
|
|
),
|
|
|
|
|
];
|
|
|
|
|
const posLevel = [
|
|
|
|
|
...new Set(
|
|
|
|
|
posMaster.positions
|
|
|
|
|
.filter((x: any) => x.posLevel != null)
|
|
|
|
|
.map((x) => x.posLevel.posLevelName),
|
|
|
|
|
),
|
|
|
|
|
];
|
|
|
|
|
const posExecutive = [
|
|
|
|
|
...new Set(
|
|
|
|
|
posMaster.positions
|
|
|
|
|
.filter((x: any) => x.posExecutive != null)
|
|
|
|
|
.map((x) => x.posExecutive.posExecutiveName),
|
|
|
|
|
),
|
|
|
|
|
];
|
|
|
|
|
let positionMasterProfileOld: any = null;
|
|
|
|
|
if (posMaster.next_holder != null) {
|
|
|
|
|
positionMasterProfileOld = posMaster.next_holder.current_holders.find(
|
|
|
|
|
(x) => x.orgRevisionId == orgRevisionActive.id,
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let positionMasterOld: any = null;
|
|
|
|
|
let profilePositionName: any = [];
|
|
|
|
|
let profilePosType: any = [];
|
|
|
|
|
let profilePosLevel: any = [];
|
|
|
|
|
let profilePosExecutive: any = [];
|
2024-04-02 09:51:29 +07:00
|
|
|
if (posMaster.ancestorDNA != null && posMaster.ancestorDNA != "") {
|
2024-02-12 14:43:38 +07:00
|
|
|
positionMasterOld = orgRevisionActive.posMasters.find(
|
|
|
|
|
(x: any) =>
|
|
|
|
|
x.orgRevisionId == orgRevisionActive.id &&
|
|
|
|
|
x.ancestorDNA == posMaster.ancestorDNA,
|
|
|
|
|
);
|
|
|
|
|
profilePositionName = [
|
|
|
|
|
...new Set(positionMasterOld.positions.map((x: any) => x.positionName)),
|
|
|
|
|
];
|
|
|
|
|
profilePosType = [
|
|
|
|
|
...new Set(
|
|
|
|
|
positionMasterOld.positions
|
|
|
|
|
.filter((x: any) => x.posType != null)
|
|
|
|
|
.map((x: any) => x.posType.posTypeName),
|
|
|
|
|
),
|
|
|
|
|
];
|
|
|
|
|
profilePosLevel = [
|
|
|
|
|
...new Set(
|
|
|
|
|
positionMasterOld.positions
|
|
|
|
|
.filter((x: any) => x.posLevel != null)
|
|
|
|
|
.map((x: any) => x.posLevel.posLevelName),
|
|
|
|
|
),
|
|
|
|
|
];
|
|
|
|
|
profilePosExecutive = [
|
|
|
|
|
...new Set(
|
|
|
|
|
positionMasterOld.positions
|
|
|
|
|
.filter((x: any) => x.posExecutive != null)
|
|
|
|
|
.map((x: any) => x.posExecutive.posExecutiveName),
|
|
|
|
|
),
|
|
|
|
|
];
|
|
|
|
|
}
|
2024-04-09 14:32:30 +07:00
|
|
|
let education: any = "";
|
|
|
|
|
if (
|
|
|
|
|
posMaster.next_holder != null &&
|
|
|
|
|
posMaster.next_holder.profileEducations != null &&
|
|
|
|
|
posMaster.next_holder.profileEducations.length > 0
|
|
|
|
|
) {
|
|
|
|
|
let _education: any = posMaster.next_holder.profileEducations.sort(
|
2024-04-11 16:33:06 +07:00
|
|
|
(a, b) =>
|
|
|
|
|
(b.finishDate == null ? 0 : b.finishDate.getTime()) -
|
|
|
|
|
(a.finishDate == null ? 0 : a.finishDate.getTime()),
|
2024-04-09 14:32:30 +07:00
|
|
|
);
|
|
|
|
|
if (_education.length > 0) {
|
|
|
|
|
education = _education[0];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
let salary: any = "";
|
|
|
|
|
if (
|
|
|
|
|
posMaster.next_holder != null &&
|
|
|
|
|
posMaster.next_holder.profileSalary != null &&
|
|
|
|
|
posMaster.next_holder.profileSalary.length > 0
|
|
|
|
|
) {
|
|
|
|
|
let _salary: any = posMaster.next_holder.profileSalary.sort(
|
2024-04-11 16:33:06 +07:00
|
|
|
(a, b) =>
|
|
|
|
|
(b.date == null ? 0 : b.date.getTime()) -
|
|
|
|
|
(a.date == null ? 0 : a.date.getTime()),
|
2024-04-09 14:32:30 +07:00
|
|
|
);
|
|
|
|
|
if (_salary.length > 0) {
|
|
|
|
|
salary = _salary[0];
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-02-12 14:43:38 +07:00
|
|
|
|
|
|
|
|
let node = {
|
|
|
|
|
posMasterOrder: posMaster.posMasterOrder, //
|
|
|
|
|
isSit: posMaster.isSit, //
|
2024-04-02 09:51:29 +07:00
|
|
|
orgTreeName: orgChild2.orgChild2Name,
|
|
|
|
|
orgTreeShortName: orgChild2.orgChild2ShortName,
|
2024-02-12 14:43:38 +07:00
|
|
|
posMasterNo: posMaster.posMasterNo,
|
|
|
|
|
positionName:
|
|
|
|
|
posMaster.next_holder == null
|
|
|
|
|
? positionName.join(" หรือ ")
|
|
|
|
|
: posMaster.isSit == false
|
|
|
|
|
? posMaster.positions.find((x: any) => x.positionIsSelected == true)
|
|
|
|
|
?.positionName
|
|
|
|
|
: posMaster.next_holder.position,
|
|
|
|
|
posType:
|
|
|
|
|
posMaster.next_holder == null
|
|
|
|
|
? posType.join(" หรือ ")
|
|
|
|
|
: posMaster.isSit == false
|
|
|
|
|
? posMaster.positions.find((x: any) => x.positionIsSelected == true)
|
|
|
|
|
?.posType?.posTypeName
|
|
|
|
|
: posMaster.next_holder.posType == null
|
|
|
|
|
? "-"
|
|
|
|
|
: posMaster.next_holder.posType.posTypeName,
|
|
|
|
|
posLevel:
|
|
|
|
|
posMaster.next_holder == null
|
|
|
|
|
? posLevel.join(" หรือ ")
|
|
|
|
|
: posMaster.isSit == false
|
|
|
|
|
? posMaster.positions.find((x: any) => x.positionIsSelected == true)
|
|
|
|
|
?.posLevel?.posLevelName
|
|
|
|
|
: posMaster.next_holder.posLevel == null
|
|
|
|
|
? "-"
|
|
|
|
|
: posMaster.next_holder.posLevel.posLevelName,
|
|
|
|
|
posExecutive:
|
|
|
|
|
posMaster.next_holder == null
|
|
|
|
|
? posExecutive.join(" หรือ ")
|
|
|
|
|
: posMaster.isSit == false
|
|
|
|
|
? posMaster.positions.find((x: any) => x.positionIsSelected == true)
|
|
|
|
|
?.posExecutive?.posExecutiveName
|
|
|
|
|
: positionMasterProfileOld == null
|
|
|
|
|
? "-"
|
|
|
|
|
: positionMasterProfileOld.positions.find(
|
|
|
|
|
(x: any) => x.positionIsSelected == true,
|
|
|
|
|
)?.posExecutive?.posExecutiveName,
|
|
|
|
|
|
|
|
|
|
profileOrgName:
|
|
|
|
|
posMaster.next_holder == null
|
2024-04-02 09:51:29 +07:00
|
|
|
? orgChild2.orgChild2Name
|
2024-02-12 14:43:38 +07:00
|
|
|
: positionMasterProfileOld == null
|
|
|
|
|
? "-"
|
|
|
|
|
: positionMasterProfileOld.orgChild4 != null
|
|
|
|
|
? positionMasterProfileOld.orgChild4.orgChild4Name
|
|
|
|
|
: positionMasterProfileOld.orgChild3 != null
|
|
|
|
|
? positionMasterProfileOld.orgChild3.orgChild3Name
|
|
|
|
|
: positionMasterProfileOld.orgChild2 != null
|
|
|
|
|
? positionMasterProfileOld.orgChild2.orgChild2Name
|
|
|
|
|
: positionMasterProfileOld.orgChild1 != null
|
|
|
|
|
? positionMasterProfileOld.orgChild1.orgChild1Name
|
|
|
|
|
: positionMasterProfileOld.orgRoot != null
|
|
|
|
|
? positionMasterProfileOld.orgRoot.orgRootName
|
|
|
|
|
: "-",
|
|
|
|
|
profileOrgShortName:
|
|
|
|
|
posMaster.next_holder == null
|
2024-04-02 09:51:29 +07:00
|
|
|
? orgChild2.orgChild2ShortName
|
2024-02-12 14:43:38 +07:00
|
|
|
: positionMasterProfileOld == null
|
|
|
|
|
? "-"
|
|
|
|
|
: positionMasterProfileOld.orgChild4 != null
|
|
|
|
|
? positionMasterProfileOld.orgChild4.orgChild4ShortName
|
|
|
|
|
: positionMasterProfileOld.orgChild3 != null
|
|
|
|
|
? positionMasterProfileOld.orgChild3.orgChild3ShortName
|
|
|
|
|
: positionMasterProfileOld.orgChild2 != null
|
|
|
|
|
? positionMasterProfileOld.orgChild2.orgChild2ShortName
|
|
|
|
|
: positionMasterProfileOld.orgChild1 != null
|
|
|
|
|
? positionMasterProfileOld.orgChild1.orgChild1ShortName
|
|
|
|
|
: positionMasterProfileOld.orgRoot != null
|
|
|
|
|
? positionMasterProfileOld.orgRoot.orgRootShortName
|
|
|
|
|
: "-",
|
|
|
|
|
profileFullname:
|
|
|
|
|
posMaster.next_holder == null
|
|
|
|
|
? "- ว่าง -"
|
|
|
|
|
: `${posMaster.next_holder.prefix}${posMaster.next_holder.firstName} ${posMaster.next_holder.lastName}`,
|
|
|
|
|
profilePosMasterNo:
|
|
|
|
|
posMaster.next_holder == null
|
|
|
|
|
? positionMasterOld == null
|
|
|
|
|
? "-"
|
|
|
|
|
: positionMasterOld.posMasterNo
|
|
|
|
|
: positionMasterProfileOld == null
|
|
|
|
|
? "-"
|
|
|
|
|
: positionMasterProfileOld.posMasterNo,
|
|
|
|
|
profilePositionName:
|
|
|
|
|
posMaster.next_holder == null
|
|
|
|
|
? positionMasterOld == null
|
|
|
|
|
? positionName.join(" หรือ ")
|
|
|
|
|
: profilePositionName.join(" หรือ ")
|
|
|
|
|
: posMaster.next_holder.position,
|
|
|
|
|
profilePosType:
|
|
|
|
|
posMaster.next_holder == null
|
|
|
|
|
? positionMasterOld == null
|
|
|
|
|
? posType.join(" หรือ ")
|
|
|
|
|
: profilePosType.join(" หรือ ")
|
|
|
|
|
: posMaster.next_holder.posType == null
|
|
|
|
|
? "-"
|
|
|
|
|
: posMaster.next_holder.posType.posTypeName,
|
|
|
|
|
profilePosLevel:
|
|
|
|
|
posMaster.next_holder == null
|
|
|
|
|
? positionMasterOld == null
|
|
|
|
|
? posLevel.join(" หรือ ")
|
|
|
|
|
: profilePosLevel.join(" หรือ ")
|
|
|
|
|
: posMaster.next_holder.posLevel == null
|
|
|
|
|
? "-"
|
|
|
|
|
: posMaster.next_holder.posLevel.posLevelName,
|
|
|
|
|
profilePosExecutive:
|
|
|
|
|
posMaster.next_holder == null
|
|
|
|
|
? positionMasterOld == null
|
|
|
|
|
? posExecutive.join(" หรือ ")
|
|
|
|
|
: profilePosExecutive.join(" หรือ ")
|
|
|
|
|
: positionMasterProfileOld == null
|
|
|
|
|
? "-"
|
|
|
|
|
: positionMasterProfileOld.positions.find(
|
|
|
|
|
(x: any) => x.positionIsSelected == true,
|
|
|
|
|
)?.posExecutive?.posExecutiveName,
|
2024-04-09 14:32:30 +07:00
|
|
|
education: education == "" ? "" : education.degree,
|
|
|
|
|
salary: salary == "" ? "" : salary.amount,
|
2024-07-04 00:11:06 +07:00
|
|
|
reason: posMaster.reason,
|
2024-02-12 14:43:38 +07:00
|
|
|
};
|
|
|
|
|
if (_node == null) {
|
|
|
|
|
const head = {
|
2024-06-07 15:40:33 +07:00
|
|
|
posMasterNo: Extension.ToThaiNumber(node.orgTreeShortName.toString()),
|
|
|
|
|
profileFullname: Extension.ToThaiNumber(node.profileOrgName.toString()),
|
|
|
|
|
posExecutive: Extension.ToThaiNumber(node.orgTreeName.toString()),
|
2024-02-12 14:43:38 +07:00
|
|
|
positionName: "",
|
|
|
|
|
posType: "",
|
|
|
|
|
posLevel: "",
|
2024-06-07 15:40:33 +07:00
|
|
|
profilePosMasterNo: Extension.ToThaiNumber(
|
|
|
|
|
node.profileOrgShortName.toString(),
|
|
|
|
|
),
|
2024-02-12 14:43:38 +07:00
|
|
|
profilePosExecutive: "",
|
|
|
|
|
profilePositionName: "",
|
|
|
|
|
profilePosType: "",
|
|
|
|
|
profilePosLevel: "",
|
2024-02-13 09:59:10 +07:00
|
|
|
education: "",
|
|
|
|
|
salary: "",
|
2024-07-04 00:11:06 +07:00
|
|
|
reason: "",
|
2024-02-12 14:43:38 +07:00
|
|
|
};
|
|
|
|
|
data.push(head);
|
|
|
|
|
const _head = {
|
2024-04-09 14:32:30 +07:00
|
|
|
no: Extension.ToThaiNumber(no.toString()),
|
2024-04-09 12:18:52 +07:00
|
|
|
posMasterNo:
|
|
|
|
|
node.posMasterNo == null
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.posMasterNo.toString()),
|
2024-06-07 15:40:33 +07:00
|
|
|
profileFullname:
|
|
|
|
|
node.profileFullname == null
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.profileFullname.toString()),
|
|
|
|
|
posExecutive:
|
|
|
|
|
node.posExecutive == null
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.posExecutive.toString()),
|
|
|
|
|
positionName:
|
|
|
|
|
node.positionName == null
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.positionName.toString()),
|
|
|
|
|
posType:
|
|
|
|
|
node.posType == null ? "" : Extension.ToThaiNumber(node.posType.toString()),
|
|
|
|
|
posLevel:
|
|
|
|
|
node.posLevel == null
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.posLevel.toString()),
|
|
|
|
|
profilePosMasterNo: Extension.ToThaiNumber(
|
|
|
|
|
node.profilePosMasterNo.toString(),
|
|
|
|
|
),
|
|
|
|
|
profilePosExecutive:
|
|
|
|
|
node.profilePosExecutive == null
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.profilePosExecutive.toString()),
|
|
|
|
|
profilePositionName:
|
|
|
|
|
node.profilePositionName == null
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.profilePositionName.toString()),
|
|
|
|
|
profilePosType:
|
|
|
|
|
node.profilePosType == null
|
2024-04-09 12:18:52 +07:00
|
|
|
? ""
|
2024-06-07 15:40:33 +07:00
|
|
|
: Extension.ToThaiNumber(node.profilePosType.toString()),
|
|
|
|
|
profilePosLevel:
|
|
|
|
|
node.profilePosLevel == null
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.profilePosLevel.toString()),
|
|
|
|
|
education:
|
|
|
|
|
node.education == null
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.education.toString()),
|
2024-07-04 00:11:06 +07:00
|
|
|
salary: node.salary
|
|
|
|
|
? Extension.ToThaiNumber(node.salary.toLocaleString())
|
|
|
|
|
: "",
|
|
|
|
|
reason:
|
|
|
|
|
node.reason == null ? "" : Extension.ToThaiNumber(node.reason.toString()),
|
2024-02-12 14:43:38 +07:00
|
|
|
};
|
|
|
|
|
data.push(_head);
|
|
|
|
|
} else {
|
|
|
|
|
if (
|
|
|
|
|
node.orgTreeShortName != _node.orgTreeShortName ||
|
|
|
|
|
node.orgTreeName != _node.orgTreeName ||
|
|
|
|
|
node.profileOrgShortName != _node.profileOrgShortName ||
|
|
|
|
|
node.profileOrgName != _node.profileOrgName
|
|
|
|
|
) {
|
|
|
|
|
const head = {
|
|
|
|
|
posMasterNo:
|
|
|
|
|
node.orgTreeShortName == _node.orgTreeShortName
|
|
|
|
|
? ""
|
|
|
|
|
: node.orgTreeShortName,
|
|
|
|
|
profileFullname:
|
|
|
|
|
node.profileOrgName == _node.profileOrgName ? "" : node.profileOrgName,
|
|
|
|
|
posExecutive: node.orgTreeName == _node.orgTreeName ? "" : node.orgTreeName,
|
|
|
|
|
positionName: "",
|
|
|
|
|
posType: "",
|
|
|
|
|
posLevel: "",
|
|
|
|
|
profilePosMasterNo:
|
|
|
|
|
node.profileOrgShortName == _node.profileOrgShortName
|
|
|
|
|
? ""
|
|
|
|
|
: node.profileOrgShortName,
|
|
|
|
|
profilePosExecutive: "",
|
|
|
|
|
profilePositionName: "",
|
|
|
|
|
profilePosType: "",
|
|
|
|
|
profilePosLevel: "",
|
2024-02-13 09:59:10 +07:00
|
|
|
education: "",
|
|
|
|
|
salary: "",
|
2024-07-04 00:11:06 +07:00
|
|
|
reason: "",
|
2024-02-12 14:43:38 +07:00
|
|
|
};
|
|
|
|
|
data.push(head);
|
|
|
|
|
_node == null;
|
|
|
|
|
}
|
|
|
|
|
const head = {
|
2024-04-09 14:32:30 +07:00
|
|
|
no: Extension.ToThaiNumber(no.toString()),
|
2024-04-09 12:18:52 +07:00
|
|
|
posMasterNo:
|
|
|
|
|
node.posMasterNo == null
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.posMasterNo.toString()),
|
2024-06-07 15:40:33 +07:00
|
|
|
profileFullname:
|
|
|
|
|
node.profileFullname == null
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.profileFullname.toString()),
|
2024-02-12 14:43:38 +07:00
|
|
|
posExecutive:
|
2024-06-07 15:40:33 +07:00
|
|
|
node.posExecutive == null
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.posExecutive.toString()),
|
|
|
|
|
positionName:
|
|
|
|
|
node.positionName == null
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.positionName.toString()),
|
|
|
|
|
posType:
|
|
|
|
|
node.posType == null ? "" : Extension.ToThaiNumber(node.posType.toString()),
|
|
|
|
|
posLevel:
|
|
|
|
|
node.posLevel == null
|
2024-04-09 12:18:52 +07:00
|
|
|
? ""
|
2024-06-07 15:40:33 +07:00
|
|
|
: Extension.ToThaiNumber(node.posLevel.toString()),
|
|
|
|
|
profilePosMasterNo: Extension.ToThaiNumber(
|
|
|
|
|
node.profilePosMasterNo.toString(),
|
|
|
|
|
),
|
2024-02-12 14:43:38 +07:00
|
|
|
profilePosExecutive:
|
2024-06-07 15:40:33 +07:00
|
|
|
node.profilePosExecutive == null
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.profilePosExecutive.toString()),
|
|
|
|
|
profilePositionName:
|
|
|
|
|
node.profilePositionName == null
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.profilePositionName.toString()),
|
|
|
|
|
profilePosType:
|
|
|
|
|
node.profilePosType == null
|
2024-02-12 14:43:38 +07:00
|
|
|
? ""
|
2024-06-07 15:40:33 +07:00
|
|
|
: Extension.ToThaiNumber(node.profilePosType.toString()),
|
|
|
|
|
profilePosLevel:
|
|
|
|
|
node.profilePosLevel == null
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.profilePosLevel.toString()),
|
|
|
|
|
education:
|
|
|
|
|
node.education == null
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.education.toString()),
|
2024-07-04 00:11:06 +07:00
|
|
|
salary: node.salary
|
|
|
|
|
? Extension.ToThaiNumber(node.salary.toLocaleString())
|
|
|
|
|
: "",
|
|
|
|
|
reason:
|
|
|
|
|
node.reason == null ? "" : Extension.ToThaiNumber(node.reason.toString()),
|
2024-02-12 14:43:38 +07:00
|
|
|
};
|
|
|
|
|
data.push(head);
|
|
|
|
|
}
|
|
|
|
|
no += 1;
|
|
|
|
|
_node = node;
|
|
|
|
|
}
|
|
|
|
|
}),
|
|
|
|
|
);
|
|
|
|
|
_node = null;
|
|
|
|
|
|
2024-04-02 09:51:29 +07:00
|
|
|
for (let orgChild3 of orgChild3Data.filter(
|
|
|
|
|
(orgChild3) => orgChild3.orgChild2Id === orgChild2.id,
|
2024-02-12 14:43:38 +07:00
|
|
|
)) {
|
|
|
|
|
await Promise.all(
|
2024-04-02 09:51:29 +07:00
|
|
|
orgChild3.posMasters
|
2024-02-12 14:43:38 +07:00
|
|
|
.sort((a, b) => a.posMasterOrder - b.posMasterOrder)
|
|
|
|
|
.map(async (posMaster) => {
|
2024-04-02 09:51:29 +07:00
|
|
|
if (posMaster.orgChild4Id == null) {
|
2024-02-12 14:43:38 +07:00
|
|
|
const positionName = [
|
|
|
|
|
...new Set(posMaster.positions.map((x) => x.positionName)),
|
|
|
|
|
];
|
|
|
|
|
const posType = [
|
|
|
|
|
...new Set(
|
|
|
|
|
posMaster.positions
|
|
|
|
|
.filter((x: any) => x.posType != null)
|
|
|
|
|
.map((x) => x.posType.posTypeName),
|
|
|
|
|
),
|
|
|
|
|
];
|
|
|
|
|
const posLevel = [
|
|
|
|
|
...new Set(
|
|
|
|
|
posMaster.positions
|
|
|
|
|
.filter((x: any) => x.posLevel != null)
|
|
|
|
|
.map((x) => x.posLevel.posLevelName),
|
|
|
|
|
),
|
|
|
|
|
];
|
|
|
|
|
const posExecutive = [
|
|
|
|
|
...new Set(
|
|
|
|
|
posMaster.positions
|
|
|
|
|
.filter((x: any) => x.posExecutive != null)
|
|
|
|
|
.map((x) => x.posExecutive.posExecutiveName),
|
|
|
|
|
),
|
|
|
|
|
];
|
|
|
|
|
let positionMasterProfileOld: any = null;
|
|
|
|
|
if (posMaster.next_holder != null) {
|
|
|
|
|
positionMasterProfileOld = posMaster.next_holder.current_holders.find(
|
|
|
|
|
(x) => x.orgRevisionId == orgRevisionActive.id,
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let positionMasterOld: any = null;
|
|
|
|
|
let profilePositionName: any = [];
|
|
|
|
|
let profilePosType: any = [];
|
|
|
|
|
let profilePosLevel: any = [];
|
|
|
|
|
let profilePosExecutive: any = [];
|
2024-04-02 09:51:29 +07:00
|
|
|
if (posMaster.ancestorDNA != null && posMaster.ancestorDNA != "") {
|
2024-02-12 14:43:38 +07:00
|
|
|
positionMasterOld = orgRevisionActive.posMasters.find(
|
|
|
|
|
(x: any) =>
|
|
|
|
|
x.orgRevisionId == orgRevisionActive.id &&
|
|
|
|
|
x.ancestorDNA == posMaster.ancestorDNA,
|
|
|
|
|
);
|
|
|
|
|
profilePositionName = [
|
|
|
|
|
...new Set(positionMasterOld.positions.map((x: any) => x.positionName)),
|
|
|
|
|
];
|
|
|
|
|
profilePosType = [
|
|
|
|
|
...new Set(
|
|
|
|
|
positionMasterOld.positions
|
|
|
|
|
.filter((x: any) => x.posType != null)
|
|
|
|
|
.map((x: any) => x.posType.posTypeName),
|
|
|
|
|
),
|
|
|
|
|
];
|
|
|
|
|
profilePosLevel = [
|
|
|
|
|
...new Set(
|
|
|
|
|
positionMasterOld.positions
|
|
|
|
|
.filter((x: any) => x.posLevel != null)
|
|
|
|
|
.map((x: any) => x.posLevel.posLevelName),
|
|
|
|
|
),
|
|
|
|
|
];
|
|
|
|
|
profilePosExecutive = [
|
|
|
|
|
...new Set(
|
|
|
|
|
positionMasterOld.positions
|
|
|
|
|
.filter((x: any) => x.posExecutive != null)
|
|
|
|
|
.map((x: any) => x.posExecutive.posExecutiveName),
|
|
|
|
|
),
|
|
|
|
|
];
|
|
|
|
|
}
|
2024-04-09 14:32:30 +07:00
|
|
|
let education: any = "";
|
|
|
|
|
if (
|
|
|
|
|
posMaster.next_holder != null &&
|
|
|
|
|
posMaster.next_holder.profileEducations != null &&
|
|
|
|
|
posMaster.next_holder.profileEducations.length > 0
|
|
|
|
|
) {
|
|
|
|
|
let _education: any = posMaster.next_holder.profileEducations.sort(
|
2024-04-11 16:33:06 +07:00
|
|
|
(a, b) =>
|
|
|
|
|
(b.finishDate == null ? 0 : b.finishDate.getTime()) -
|
|
|
|
|
(a.finishDate == null ? 0 : a.finishDate.getTime()),
|
2024-04-09 14:32:30 +07:00
|
|
|
);
|
|
|
|
|
if (_education.length > 0) {
|
|
|
|
|
education = _education[0];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
let salary: any = "";
|
|
|
|
|
if (
|
|
|
|
|
posMaster.next_holder != null &&
|
|
|
|
|
posMaster.next_holder.profileSalary != null &&
|
|
|
|
|
posMaster.next_holder.profileSalary.length > 0
|
|
|
|
|
) {
|
|
|
|
|
let _salary: any = posMaster.next_holder.profileSalary.sort(
|
2024-04-11 16:33:06 +07:00
|
|
|
(a, b) =>
|
|
|
|
|
(b.date == null ? 0 : b.date.getTime()) -
|
|
|
|
|
(a.date == null ? 0 : a.date.getTime()),
|
2024-04-09 14:32:30 +07:00
|
|
|
);
|
|
|
|
|
if (_salary.length > 0) {
|
|
|
|
|
salary = _salary[0];
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-02-12 14:43:38 +07:00
|
|
|
|
|
|
|
|
let node = {
|
|
|
|
|
posMasterOrder: posMaster.posMasterOrder, //
|
|
|
|
|
isSit: posMaster.isSit, //
|
2024-04-02 09:51:29 +07:00
|
|
|
orgTreeName: orgChild3.orgChild3Name,
|
|
|
|
|
orgTreeShortName: orgChild3.orgChild3ShortName,
|
2024-02-12 14:43:38 +07:00
|
|
|
posMasterNo: posMaster.posMasterNo,
|
|
|
|
|
positionName:
|
|
|
|
|
posMaster.next_holder == null
|
|
|
|
|
? positionName.join(" หรือ ")
|
|
|
|
|
: posMaster.isSit == false
|
|
|
|
|
? posMaster.positions.find((x: any) => x.positionIsSelected == true)
|
|
|
|
|
?.positionName
|
|
|
|
|
: posMaster.next_holder.position,
|
|
|
|
|
posType:
|
|
|
|
|
posMaster.next_holder == null
|
|
|
|
|
? posType.join(" หรือ ")
|
|
|
|
|
: posMaster.isSit == false
|
|
|
|
|
? posMaster.positions.find((x: any) => x.positionIsSelected == true)
|
|
|
|
|
?.posType?.posTypeName
|
|
|
|
|
: posMaster.next_holder.posType == null
|
|
|
|
|
? "-"
|
|
|
|
|
: posMaster.next_holder.posType.posTypeName,
|
|
|
|
|
posLevel:
|
|
|
|
|
posMaster.next_holder == null
|
|
|
|
|
? posLevel.join(" หรือ ")
|
|
|
|
|
: posMaster.isSit == false
|
|
|
|
|
? posMaster.positions.find((x: any) => x.positionIsSelected == true)
|
|
|
|
|
?.posLevel?.posLevelName
|
|
|
|
|
: posMaster.next_holder.posLevel == null
|
|
|
|
|
? "-"
|
|
|
|
|
: posMaster.next_holder.posLevel.posLevelName,
|
|
|
|
|
posExecutive:
|
|
|
|
|
posMaster.next_holder == null
|
|
|
|
|
? posExecutive.join(" หรือ ")
|
|
|
|
|
: posMaster.isSit == false
|
|
|
|
|
? posMaster.positions.find((x: any) => x.positionIsSelected == true)
|
|
|
|
|
?.posExecutive?.posExecutiveName
|
|
|
|
|
: positionMasterProfileOld == null
|
|
|
|
|
? "-"
|
|
|
|
|
: positionMasterProfileOld.positions.find(
|
|
|
|
|
(x: any) => x.positionIsSelected == true,
|
|
|
|
|
)?.posExecutive?.posExecutiveName,
|
|
|
|
|
|
|
|
|
|
profileOrgName:
|
|
|
|
|
posMaster.next_holder == null
|
2024-04-02 09:51:29 +07:00
|
|
|
? orgChild3.orgChild3Name
|
2024-02-12 14:43:38 +07:00
|
|
|
: positionMasterProfileOld == null
|
|
|
|
|
? "-"
|
|
|
|
|
: positionMasterProfileOld.orgChild4 != null
|
|
|
|
|
? positionMasterProfileOld.orgChild4.orgChild4Name
|
|
|
|
|
: positionMasterProfileOld.orgChild3 != null
|
|
|
|
|
? positionMasterProfileOld.orgChild3.orgChild3Name
|
|
|
|
|
: positionMasterProfileOld.orgChild2 != null
|
|
|
|
|
? positionMasterProfileOld.orgChild2.orgChild2Name
|
|
|
|
|
: positionMasterProfileOld.orgChild1 != null
|
|
|
|
|
? positionMasterProfileOld.orgChild1.orgChild1Name
|
|
|
|
|
: positionMasterProfileOld.orgRoot != null
|
|
|
|
|
? positionMasterProfileOld.orgRoot.orgRootName
|
|
|
|
|
: "-",
|
|
|
|
|
profileOrgShortName:
|
|
|
|
|
posMaster.next_holder == null
|
2024-04-02 09:51:29 +07:00
|
|
|
? orgChild3.orgChild3ShortName
|
2024-02-12 14:43:38 +07:00
|
|
|
: positionMasterProfileOld == null
|
|
|
|
|
? "-"
|
|
|
|
|
: positionMasterProfileOld.orgChild4 != null
|
|
|
|
|
? positionMasterProfileOld.orgChild4.orgChild4ShortName
|
|
|
|
|
: positionMasterProfileOld.orgChild3 != null
|
|
|
|
|
? positionMasterProfileOld.orgChild3.orgChild3ShortName
|
|
|
|
|
: positionMasterProfileOld.orgChild2 != null
|
|
|
|
|
? positionMasterProfileOld.orgChild2.orgChild2ShortName
|
|
|
|
|
: positionMasterProfileOld.orgChild1 != null
|
|
|
|
|
? positionMasterProfileOld.orgChild1.orgChild1ShortName
|
|
|
|
|
: positionMasterProfileOld.orgRoot != null
|
|
|
|
|
? positionMasterProfileOld.orgRoot.orgRootShortName
|
|
|
|
|
: "-",
|
|
|
|
|
profileFullname:
|
|
|
|
|
posMaster.next_holder == null
|
|
|
|
|
? "- ว่าง -"
|
|
|
|
|
: `${posMaster.next_holder.prefix}${posMaster.next_holder.firstName} ${posMaster.next_holder.lastName}`,
|
|
|
|
|
profilePosMasterNo:
|
|
|
|
|
posMaster.next_holder == null
|
|
|
|
|
? positionMasterOld == null
|
|
|
|
|
? "-"
|
|
|
|
|
: positionMasterOld.posMasterNo
|
|
|
|
|
: positionMasterProfileOld == null
|
|
|
|
|
? "-"
|
|
|
|
|
: positionMasterProfileOld.posMasterNo,
|
|
|
|
|
profilePositionName:
|
|
|
|
|
posMaster.next_holder == null
|
|
|
|
|
? positionMasterOld == null
|
|
|
|
|
? positionName.join(" หรือ ")
|
|
|
|
|
: profilePositionName.join(" หรือ ")
|
|
|
|
|
: posMaster.next_holder.position,
|
|
|
|
|
profilePosType:
|
|
|
|
|
posMaster.next_holder == null
|
|
|
|
|
? positionMasterOld == null
|
|
|
|
|
? posType.join(" หรือ ")
|
|
|
|
|
: profilePosType.join(" หรือ ")
|
|
|
|
|
: posMaster.next_holder.posType == null
|
|
|
|
|
? "-"
|
|
|
|
|
: posMaster.next_holder.posType.posTypeName,
|
|
|
|
|
profilePosLevel:
|
|
|
|
|
posMaster.next_holder == null
|
|
|
|
|
? positionMasterOld == null
|
|
|
|
|
? posLevel.join(" หรือ ")
|
|
|
|
|
: profilePosLevel.join(" หรือ ")
|
|
|
|
|
: posMaster.next_holder.posLevel == null
|
|
|
|
|
? "-"
|
|
|
|
|
: posMaster.next_holder.posLevel.posLevelName,
|
|
|
|
|
profilePosExecutive:
|
|
|
|
|
posMaster.next_holder == null
|
|
|
|
|
? positionMasterOld == null
|
|
|
|
|
? posExecutive.join(" หรือ ")
|
|
|
|
|
: profilePosExecutive.join(" หรือ ")
|
|
|
|
|
: positionMasterProfileOld == null
|
|
|
|
|
? "-"
|
|
|
|
|
: positionMasterProfileOld.positions.find(
|
|
|
|
|
(x: any) => x.positionIsSelected == true,
|
|
|
|
|
)?.posExecutive?.posExecutiveName,
|
2024-04-09 14:32:30 +07:00
|
|
|
education: education == "" ? "" : education.degree,
|
|
|
|
|
salary: salary == "" ? "" : salary.amount,
|
2024-07-04 00:11:06 +07:00
|
|
|
reason: posMaster.reason,
|
2024-02-12 14:43:38 +07:00
|
|
|
};
|
|
|
|
|
if (_node == null) {
|
|
|
|
|
const head = {
|
2024-06-07 15:40:33 +07:00
|
|
|
posMasterNo: Extension.ToThaiNumber(node.orgTreeShortName.toString()),
|
|
|
|
|
profileFullname: Extension.ToThaiNumber(node.profileOrgName.toString()),
|
|
|
|
|
posExecutive: Extension.ToThaiNumber(node.orgTreeName.toString()),
|
2024-02-12 14:43:38 +07:00
|
|
|
positionName: "",
|
|
|
|
|
posType: "",
|
|
|
|
|
posLevel: "",
|
2024-06-07 15:40:33 +07:00
|
|
|
profilePosMasterNo: Extension.ToThaiNumber(
|
|
|
|
|
node.profileOrgShortName.toString(),
|
|
|
|
|
),
|
2024-02-12 14:43:38 +07:00
|
|
|
profilePosExecutive: "",
|
|
|
|
|
profilePositionName: "",
|
|
|
|
|
profilePosType: "",
|
|
|
|
|
profilePosLevel: "",
|
2024-02-13 09:59:10 +07:00
|
|
|
education: "",
|
|
|
|
|
salary: "",
|
2024-07-04 00:11:06 +07:00
|
|
|
reason: "",
|
2024-02-12 14:43:38 +07:00
|
|
|
};
|
|
|
|
|
data.push(head);
|
|
|
|
|
const _head = {
|
2024-04-09 14:32:30 +07:00
|
|
|
no: Extension.ToThaiNumber(no.toString()),
|
2024-04-09 12:18:52 +07:00
|
|
|
posMasterNo:
|
|
|
|
|
node.posMasterNo == null
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.posMasterNo.toString()),
|
2024-06-07 15:40:33 +07:00
|
|
|
profileFullname:
|
|
|
|
|
node.profileFullname == null
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.profileFullname.toString()),
|
|
|
|
|
posExecutive:
|
|
|
|
|
node.posExecutive == null
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.posExecutive.toString()),
|
|
|
|
|
positionName:
|
|
|
|
|
node.positionName == null
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.positionName.toString()),
|
|
|
|
|
posType:
|
|
|
|
|
node.posType == null
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.posType.toString()),
|
|
|
|
|
posLevel:
|
|
|
|
|
node.posLevel == null
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.posLevel.toString()),
|
|
|
|
|
profilePosMasterNo: Extension.ToThaiNumber(
|
|
|
|
|
node.profilePosMasterNo.toString(),
|
|
|
|
|
),
|
|
|
|
|
profilePosExecutive:
|
|
|
|
|
node.profilePosExecutive == null
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.profilePosExecutive.toString()),
|
|
|
|
|
profilePositionName:
|
|
|
|
|
node.profilePositionName == null
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.profilePositionName.toString()),
|
|
|
|
|
profilePosType:
|
|
|
|
|
node.profilePosType == null
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.profilePosType.toString()),
|
|
|
|
|
profilePosLevel:
|
|
|
|
|
node.profilePosLevel == null
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.profilePosLevel.toString()),
|
|
|
|
|
education:
|
|
|
|
|
node.education == null
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.education.toString()),
|
2024-07-04 00:11:06 +07:00
|
|
|
salary: node.salary
|
|
|
|
|
? Extension.ToThaiNumber(node.salary.toLocaleString())
|
|
|
|
|
: "",
|
|
|
|
|
reason:
|
|
|
|
|
node.reason == null ? "" : Extension.ToThaiNumber(node.reason.toString()),
|
2024-02-12 14:43:38 +07:00
|
|
|
};
|
|
|
|
|
data.push(_head);
|
|
|
|
|
} else {
|
|
|
|
|
if (
|
|
|
|
|
node.orgTreeShortName != _node.orgTreeShortName ||
|
|
|
|
|
node.orgTreeName != _node.orgTreeName ||
|
|
|
|
|
node.profileOrgShortName != _node.profileOrgShortName ||
|
|
|
|
|
node.profileOrgName != _node.profileOrgName
|
|
|
|
|
) {
|
|
|
|
|
const head = {
|
|
|
|
|
posMasterNo:
|
|
|
|
|
node.orgTreeShortName == _node.orgTreeShortName
|
|
|
|
|
? ""
|
|
|
|
|
: node.orgTreeShortName,
|
|
|
|
|
profileFullname:
|
|
|
|
|
node.profileOrgName == _node.profileOrgName ? "" : node.profileOrgName,
|
|
|
|
|
posExecutive:
|
|
|
|
|
node.orgTreeName == _node.orgTreeName ? "" : node.orgTreeName,
|
|
|
|
|
positionName: "",
|
|
|
|
|
posType: "",
|
|
|
|
|
posLevel: "",
|
|
|
|
|
profilePosMasterNo:
|
|
|
|
|
node.profileOrgShortName == _node.profileOrgShortName
|
|
|
|
|
? ""
|
|
|
|
|
: node.profileOrgShortName,
|
|
|
|
|
profilePosExecutive: "",
|
|
|
|
|
profilePositionName: "",
|
|
|
|
|
profilePosType: "",
|
|
|
|
|
profilePosLevel: "",
|
2024-02-13 09:59:10 +07:00
|
|
|
education: "",
|
|
|
|
|
salary: "",
|
2024-07-04 00:11:06 +07:00
|
|
|
reason: "",
|
2024-02-12 14:43:38 +07:00
|
|
|
};
|
|
|
|
|
data.push(head);
|
|
|
|
|
_node == null;
|
|
|
|
|
}
|
|
|
|
|
const head = {
|
2024-04-09 14:32:30 +07:00
|
|
|
no: Extension.ToThaiNumber(no.toString()),
|
2024-04-09 12:18:52 +07:00
|
|
|
posMasterNo:
|
|
|
|
|
node.posMasterNo == null
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.posMasterNo.toString()),
|
2024-06-07 15:40:33 +07:00
|
|
|
profileFullname:
|
|
|
|
|
node.profileFullname == null
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.profileFullname.toString()),
|
2024-02-12 14:43:38 +07:00
|
|
|
posExecutive:
|
2024-06-07 15:40:33 +07:00
|
|
|
node.posExecutive == null
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.posExecutive.toString()),
|
|
|
|
|
positionName:
|
|
|
|
|
node.positionName == null
|
2024-04-09 12:18:52 +07:00
|
|
|
? ""
|
2024-06-07 15:40:33 +07:00
|
|
|
: Extension.ToThaiNumber(node.positionName.toString()),
|
|
|
|
|
posType:
|
|
|
|
|
node.posType == null
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.posType.toString()),
|
|
|
|
|
posLevel:
|
|
|
|
|
node.posLevel == null
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.posLevel.toString()),
|
|
|
|
|
profilePosMasterNo: Extension.ToThaiNumber(
|
|
|
|
|
node.profilePosMasterNo.toString(),
|
|
|
|
|
),
|
2024-02-12 14:43:38 +07:00
|
|
|
profilePosExecutive:
|
2024-06-07 15:40:33 +07:00
|
|
|
node.profilePosExecutive == null
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.profilePosExecutive.toString()),
|
|
|
|
|
profilePositionName:
|
|
|
|
|
node.profilePositionName == null
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.profilePositionName.toString()),
|
|
|
|
|
profilePosType:
|
|
|
|
|
node.profilePosType == null
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.profilePosType.toString()),
|
|
|
|
|
profilePosLevel:
|
|
|
|
|
node.profilePosLevel == null
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.profilePosLevel.toString()),
|
|
|
|
|
education:
|
|
|
|
|
node.education == null
|
2024-02-12 14:43:38 +07:00
|
|
|
? ""
|
2024-06-07 15:40:33 +07:00
|
|
|
: Extension.ToThaiNumber(node.education.toString()),
|
2024-07-04 00:11:06 +07:00
|
|
|
salary: node.salary
|
|
|
|
|
? Extension.ToThaiNumber(node.salary.toLocaleString())
|
|
|
|
|
: "",
|
|
|
|
|
reason:
|
|
|
|
|
node.reason == null ? "" : Extension.ToThaiNumber(node.reason.toString()),
|
2024-02-12 14:43:38 +07:00
|
|
|
};
|
|
|
|
|
data.push(head);
|
|
|
|
|
}
|
|
|
|
|
no += 1;
|
|
|
|
|
_node = node;
|
|
|
|
|
}
|
|
|
|
|
}),
|
|
|
|
|
);
|
|
|
|
|
_node = null;
|
|
|
|
|
|
2024-04-02 09:51:29 +07:00
|
|
|
for (let orgChild4 of orgChild4Data.filter(
|
|
|
|
|
(orgChild4) => orgChild4.orgChild3Id === orgChild3.id,
|
2024-02-12 14:43:38 +07:00
|
|
|
)) {
|
|
|
|
|
await Promise.all(
|
2024-04-02 09:51:29 +07:00
|
|
|
orgChild4.posMasters
|
2024-02-12 14:43:38 +07:00
|
|
|
.sort((a, b) => a.posMasterOrder - b.posMasterOrder)
|
|
|
|
|
.map(async (posMaster) => {
|
2024-04-02 09:51:29 +07:00
|
|
|
const positionName = [
|
|
|
|
|
...new Set(posMaster.positions.map((x) => x.positionName)),
|
|
|
|
|
];
|
|
|
|
|
const posType = [
|
|
|
|
|
...new Set(
|
|
|
|
|
posMaster.positions
|
|
|
|
|
.filter((x: any) => x.posType != null)
|
|
|
|
|
.map((x) => x.posType.posTypeName),
|
|
|
|
|
),
|
|
|
|
|
];
|
|
|
|
|
const posLevel = [
|
|
|
|
|
...new Set(
|
|
|
|
|
posMaster.positions
|
|
|
|
|
.filter((x: any) => x.posLevel != null)
|
|
|
|
|
.map((x) => x.posLevel.posLevelName),
|
|
|
|
|
),
|
|
|
|
|
];
|
|
|
|
|
const posExecutive = [
|
|
|
|
|
...new Set(
|
|
|
|
|
posMaster.positions
|
|
|
|
|
.filter((x: any) => x.posExecutive != null)
|
|
|
|
|
.map((x) => x.posExecutive.posExecutiveName),
|
|
|
|
|
),
|
|
|
|
|
];
|
|
|
|
|
let positionMasterProfileOld: any = null;
|
|
|
|
|
if (posMaster.next_holder != null) {
|
|
|
|
|
positionMasterProfileOld = posMaster.next_holder.current_holders.find(
|
|
|
|
|
(x) => x.orgRevisionId == orgRevisionActive.id,
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let positionMasterOld: any = null;
|
|
|
|
|
let profilePositionName: any = [];
|
|
|
|
|
let profilePosType: any = [];
|
|
|
|
|
let profilePosLevel: any = [];
|
|
|
|
|
let profilePosExecutive: any = [];
|
|
|
|
|
if (posMaster.ancestorDNA != null && posMaster.ancestorDNA != "") {
|
|
|
|
|
positionMasterOld = orgRevisionActive.posMasters.find(
|
|
|
|
|
(x: any) =>
|
|
|
|
|
x.orgRevisionId == orgRevisionActive.id &&
|
|
|
|
|
x.ancestorDNA == posMaster.ancestorDNA,
|
|
|
|
|
);
|
|
|
|
|
profilePositionName = [
|
|
|
|
|
...new Set(positionMasterOld.positions.map((x: any) => x.positionName)),
|
2024-02-12 14:43:38 +07:00
|
|
|
];
|
2024-04-02 09:51:29 +07:00
|
|
|
profilePosType = [
|
2024-02-12 14:43:38 +07:00
|
|
|
...new Set(
|
2024-04-02 09:51:29 +07:00
|
|
|
positionMasterOld.positions
|
2024-02-12 14:43:38 +07:00
|
|
|
.filter((x: any) => x.posType != null)
|
2024-04-02 09:51:29 +07:00
|
|
|
.map((x: any) => x.posType.posTypeName),
|
2024-02-12 14:43:38 +07:00
|
|
|
),
|
|
|
|
|
];
|
2024-04-02 09:51:29 +07:00
|
|
|
profilePosLevel = [
|
2024-02-12 14:43:38 +07:00
|
|
|
...new Set(
|
2024-04-02 09:51:29 +07:00
|
|
|
positionMasterOld.positions
|
2024-02-12 14:43:38 +07:00
|
|
|
.filter((x: any) => x.posLevel != null)
|
2024-04-02 09:51:29 +07:00
|
|
|
.map((x: any) => x.posLevel.posLevelName),
|
2024-02-12 14:43:38 +07:00
|
|
|
),
|
|
|
|
|
];
|
2024-04-02 09:51:29 +07:00
|
|
|
profilePosExecutive = [
|
2024-02-12 14:43:38 +07:00
|
|
|
...new Set(
|
2024-04-02 09:51:29 +07:00
|
|
|
positionMasterOld.positions
|
2024-02-12 14:43:38 +07:00
|
|
|
.filter((x: any) => x.posExecutive != null)
|
2024-04-02 09:51:29 +07:00
|
|
|
.map((x: any) => x.posExecutive.posExecutiveName),
|
2024-02-12 14:43:38 +07:00
|
|
|
),
|
|
|
|
|
];
|
2024-04-02 09:51:29 +07:00
|
|
|
}
|
2024-04-09 14:32:30 +07:00
|
|
|
let education: any = "";
|
|
|
|
|
if (
|
|
|
|
|
posMaster.next_holder != null &&
|
|
|
|
|
posMaster.next_holder.profileEducations != null &&
|
|
|
|
|
posMaster.next_holder.profileEducations.length > 0
|
|
|
|
|
) {
|
|
|
|
|
let _education: any = posMaster.next_holder.profileEducations.sort(
|
2024-04-11 16:33:06 +07:00
|
|
|
(a, b) =>
|
|
|
|
|
(b.finishDate == null ? 0 : b.finishDate.getTime()) -
|
|
|
|
|
(a.finishDate == null ? 0 : a.finishDate.getTime()),
|
2024-04-09 14:32:30 +07:00
|
|
|
);
|
|
|
|
|
if (_education.length > 0) {
|
|
|
|
|
education = _education[0];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
let salary: any = "";
|
|
|
|
|
if (
|
|
|
|
|
posMaster.next_holder != null &&
|
|
|
|
|
posMaster.next_holder.profileSalary != null &&
|
|
|
|
|
posMaster.next_holder.profileSalary.length > 0
|
|
|
|
|
) {
|
|
|
|
|
let _salary: any = posMaster.next_holder.profileSalary.sort(
|
2024-04-11 16:33:06 +07:00
|
|
|
(a, b) =>
|
|
|
|
|
(b.date == null ? 0 : b.date.getTime()) -
|
|
|
|
|
(a.date == null ? 0 : a.date.getTime()),
|
2024-04-09 14:32:30 +07:00
|
|
|
);
|
|
|
|
|
if (_salary.length > 0) {
|
|
|
|
|
salary = _salary[0];
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-02-12 14:43:38 +07:00
|
|
|
|
2024-04-02 09:51:29 +07:00
|
|
|
let node = {
|
|
|
|
|
posMasterOrder: posMaster.posMasterOrder, //
|
|
|
|
|
isSit: posMaster.isSit, //
|
|
|
|
|
orgTreeName: orgChild4.orgChild4Name,
|
|
|
|
|
orgTreeShortName: orgChild4.orgChild4ShortName,
|
|
|
|
|
posMasterNo: posMaster.posMasterNo,
|
|
|
|
|
positionName:
|
|
|
|
|
posMaster.next_holder == null
|
|
|
|
|
? positionName.join(" หรือ ")
|
|
|
|
|
: posMaster.isSit == false
|
|
|
|
|
? posMaster.positions.find((x: any) => x.positionIsSelected == true)
|
|
|
|
|
?.positionName
|
2024-02-12 14:43:38 +07:00
|
|
|
: posMaster.next_holder.position,
|
2024-04-02 09:51:29 +07:00
|
|
|
posType:
|
|
|
|
|
posMaster.next_holder == null
|
|
|
|
|
? posType.join(" หรือ ")
|
|
|
|
|
: posMaster.isSit == false
|
|
|
|
|
? posMaster.positions.find((x: any) => x.positionIsSelected == true)
|
|
|
|
|
?.posType?.posTypeName
|
2024-02-12 14:43:38 +07:00
|
|
|
: posMaster.next_holder.posType == null
|
|
|
|
|
? "-"
|
|
|
|
|
: posMaster.next_holder.posType.posTypeName,
|
2024-04-02 09:51:29 +07:00
|
|
|
posLevel:
|
|
|
|
|
posMaster.next_holder == null
|
|
|
|
|
? posLevel.join(" หรือ ")
|
|
|
|
|
: posMaster.isSit == false
|
|
|
|
|
? posMaster.positions.find((x: any) => x.positionIsSelected == true)
|
|
|
|
|
?.posLevel?.posLevelName
|
2024-02-12 14:43:38 +07:00
|
|
|
: posMaster.next_holder.posLevel == null
|
|
|
|
|
? "-"
|
|
|
|
|
: posMaster.next_holder.posLevel.posLevelName,
|
2024-04-02 09:51:29 +07:00
|
|
|
posExecutive:
|
|
|
|
|
posMaster.next_holder == null
|
|
|
|
|
? posExecutive.join(" หรือ ")
|
|
|
|
|
: posMaster.isSit == false
|
|
|
|
|
? posMaster.positions.find((x: any) => x.positionIsSelected == true)
|
|
|
|
|
?.posExecutive?.posExecutiveName
|
2024-02-12 14:43:38 +07:00
|
|
|
: positionMasterProfileOld == null
|
|
|
|
|
? "-"
|
|
|
|
|
: positionMasterProfileOld.positions.find(
|
|
|
|
|
(x: any) => x.positionIsSelected == true,
|
|
|
|
|
)?.posExecutive?.posExecutiveName,
|
|
|
|
|
|
2024-04-02 09:51:29 +07:00
|
|
|
profileOrgName:
|
|
|
|
|
posMaster.next_holder == null
|
|
|
|
|
? orgChild4.orgChild4Name
|
|
|
|
|
: positionMasterProfileOld == null
|
|
|
|
|
? "-"
|
|
|
|
|
: positionMasterProfileOld.orgChild4 != null
|
|
|
|
|
? positionMasterProfileOld.orgChild4.orgChild4Name
|
|
|
|
|
: positionMasterProfileOld.orgChild3 != null
|
|
|
|
|
? positionMasterProfileOld.orgChild3.orgChild3Name
|
|
|
|
|
: positionMasterProfileOld.orgChild2 != null
|
|
|
|
|
? positionMasterProfileOld.orgChild2.orgChild2Name
|
|
|
|
|
: positionMasterProfileOld.orgChild1 != null
|
|
|
|
|
? positionMasterProfileOld.orgChild1.orgChild1Name
|
|
|
|
|
: positionMasterProfileOld.orgRoot != null
|
|
|
|
|
? positionMasterProfileOld.orgRoot.orgRootName
|
|
|
|
|
: "-",
|
|
|
|
|
profileOrgShortName:
|
|
|
|
|
posMaster.next_holder == null
|
|
|
|
|
? orgChild4.orgChild4ShortName
|
|
|
|
|
: positionMasterProfileOld == null
|
|
|
|
|
? "-"
|
|
|
|
|
: positionMasterProfileOld.orgChild4 != null
|
|
|
|
|
? positionMasterProfileOld.orgChild4.orgChild4ShortName
|
|
|
|
|
: positionMasterProfileOld.orgChild3 != null
|
|
|
|
|
? positionMasterProfileOld.orgChild3.orgChild3ShortName
|
|
|
|
|
: positionMasterProfileOld.orgChild2 != null
|
|
|
|
|
? positionMasterProfileOld.orgChild2.orgChild2ShortName
|
|
|
|
|
: positionMasterProfileOld.orgChild1 != null
|
|
|
|
|
? positionMasterProfileOld.orgChild1.orgChild1ShortName
|
|
|
|
|
: positionMasterProfileOld.orgRoot != null
|
|
|
|
|
? positionMasterProfileOld.orgRoot.orgRootShortName
|
|
|
|
|
: "-",
|
|
|
|
|
profileFullname:
|
|
|
|
|
posMaster.next_holder == null
|
|
|
|
|
? "- ว่าง -"
|
|
|
|
|
: `${posMaster.next_holder.prefix}${posMaster.next_holder.firstName} ${posMaster.next_holder.lastName}`,
|
|
|
|
|
profilePosMasterNo:
|
|
|
|
|
posMaster.next_holder == null
|
|
|
|
|
? positionMasterOld == null
|
|
|
|
|
? "-"
|
|
|
|
|
: positionMasterOld.posMasterNo
|
|
|
|
|
: positionMasterProfileOld == null
|
|
|
|
|
? "-"
|
|
|
|
|
: positionMasterProfileOld.posMasterNo,
|
|
|
|
|
profilePositionName:
|
|
|
|
|
posMaster.next_holder == null
|
|
|
|
|
? positionMasterOld == null
|
2024-02-12 14:43:38 +07:00
|
|
|
? positionName.join(" หรือ ")
|
2024-04-02 09:51:29 +07:00
|
|
|
: profilePositionName.join(" หรือ ")
|
|
|
|
|
: posMaster.next_holder.position,
|
|
|
|
|
profilePosType:
|
|
|
|
|
posMaster.next_holder == null
|
|
|
|
|
? positionMasterOld == null
|
2024-02-12 14:43:38 +07:00
|
|
|
? posType.join(" หรือ ")
|
2024-04-02 09:51:29 +07:00
|
|
|
: profilePosType.join(" หรือ ")
|
|
|
|
|
: posMaster.next_holder.posType == null
|
|
|
|
|
? "-"
|
|
|
|
|
: posMaster.next_holder.posType.posTypeName,
|
|
|
|
|
profilePosLevel:
|
|
|
|
|
posMaster.next_holder == null
|
|
|
|
|
? positionMasterOld == null
|
2024-02-12 14:43:38 +07:00
|
|
|
? posLevel.join(" หรือ ")
|
2024-04-02 09:51:29 +07:00
|
|
|
: profilePosLevel.join(" หรือ ")
|
|
|
|
|
: posMaster.next_holder.posLevel == null
|
|
|
|
|
? "-"
|
|
|
|
|
: posMaster.next_holder.posLevel.posLevelName,
|
|
|
|
|
profilePosExecutive:
|
|
|
|
|
posMaster.next_holder == null
|
|
|
|
|
? positionMasterOld == null
|
2024-02-12 14:43:38 +07:00
|
|
|
? posExecutive.join(" หรือ ")
|
2024-04-02 09:51:29 +07:00
|
|
|
: profilePosExecutive.join(" หรือ ")
|
|
|
|
|
: positionMasterProfileOld == null
|
|
|
|
|
? "-"
|
|
|
|
|
: positionMasterProfileOld.positions.find(
|
|
|
|
|
(x: any) => x.positionIsSelected == true,
|
|
|
|
|
)?.posExecutive?.posExecutiveName,
|
2024-04-09 14:32:30 +07:00
|
|
|
education: education == "" ? "" : education.degree,
|
|
|
|
|
salary: salary == "" ? "" : salary.amount,
|
2024-07-04 00:11:06 +07:00
|
|
|
reason: posMaster.reason,
|
2024-04-02 09:51:29 +07:00
|
|
|
};
|
|
|
|
|
if (_node == null) {
|
|
|
|
|
const head = {
|
2024-06-07 15:40:33 +07:00
|
|
|
posMasterNo: Extension.ToThaiNumber(node.orgTreeShortName.toString()),
|
|
|
|
|
profileFullname: Extension.ToThaiNumber(node.profileOrgName.toString()),
|
|
|
|
|
posExecutive: Extension.ToThaiNumber(node.orgTreeName.toString()),
|
2024-04-02 09:51:29 +07:00
|
|
|
positionName: "",
|
|
|
|
|
posType: "",
|
|
|
|
|
posLevel: "",
|
2024-06-07 15:40:33 +07:00
|
|
|
profilePosMasterNo: Extension.ToThaiNumber(
|
|
|
|
|
node.profileOrgShortName.toString(),
|
|
|
|
|
),
|
2024-04-02 09:51:29 +07:00
|
|
|
profilePosExecutive: "",
|
|
|
|
|
profilePositionName: "",
|
|
|
|
|
profilePosType: "",
|
|
|
|
|
profilePosLevel: "",
|
2024-02-13 09:59:10 +07:00
|
|
|
education: "",
|
|
|
|
|
salary: "",
|
2024-07-04 00:11:06 +07:00
|
|
|
reason: "",
|
2024-02-12 14:43:38 +07:00
|
|
|
};
|
2024-04-02 09:51:29 +07:00
|
|
|
data.push(head);
|
|
|
|
|
const _head = {
|
2024-04-09 14:32:30 +07:00
|
|
|
no: Extension.ToThaiNumber(no.toString()),
|
2024-04-09 12:18:52 +07:00
|
|
|
posMasterNo:
|
|
|
|
|
node.posMasterNo == null
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.posMasterNo.toString()),
|
2024-06-07 15:40:33 +07:00
|
|
|
profileFullname:
|
|
|
|
|
node.profileFullname == null
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.profileFullname.toString()),
|
|
|
|
|
posExecutive:
|
|
|
|
|
node.posExecutive == null
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.posExecutive.toString()),
|
|
|
|
|
positionName:
|
|
|
|
|
node.positionName == null
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.positionName.toString()),
|
|
|
|
|
posType:
|
|
|
|
|
node.posType == null
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.posType.toString()),
|
|
|
|
|
posLevel:
|
|
|
|
|
node.posLevel == null
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.posLevel.toString()),
|
|
|
|
|
profilePosMasterNo: Extension.ToThaiNumber(
|
|
|
|
|
node.profilePosMasterNo.toString(),
|
|
|
|
|
),
|
|
|
|
|
profilePosExecutive:
|
|
|
|
|
node.profilePosExecutive == null
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.profilePosExecutive.toString()),
|
|
|
|
|
profilePositionName:
|
|
|
|
|
node.profilePositionName == null
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.profilePositionName.toString()),
|
|
|
|
|
profilePosType:
|
|
|
|
|
node.profilePosType == null
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.profilePosType.toString()),
|
|
|
|
|
profilePosLevel:
|
|
|
|
|
node.profilePosLevel == null
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.profilePosLevel.toString()),
|
|
|
|
|
education:
|
|
|
|
|
node.education == null
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.education.toString()),
|
2024-07-04 00:11:06 +07:00
|
|
|
salary: node.salary
|
|
|
|
|
? Extension.ToThaiNumber(node.salary.toLocaleString())
|
|
|
|
|
: "",
|
|
|
|
|
reason:
|
|
|
|
|
node.reason == null ? "" : Extension.ToThaiNumber(node.reason.toString()),
|
2024-04-02 09:51:29 +07:00
|
|
|
};
|
|
|
|
|
data.push(_head);
|
|
|
|
|
} else {
|
|
|
|
|
if (
|
|
|
|
|
node.orgTreeShortName != _node.orgTreeShortName ||
|
|
|
|
|
node.orgTreeName != _node.orgTreeName ||
|
|
|
|
|
node.profileOrgShortName != _node.profileOrgShortName ||
|
|
|
|
|
node.profileOrgName != _node.profileOrgName
|
|
|
|
|
) {
|
2024-02-12 14:43:38 +07:00
|
|
|
const head = {
|
2024-04-02 09:51:29 +07:00
|
|
|
posMasterNo:
|
|
|
|
|
node.orgTreeShortName == _node.orgTreeShortName
|
|
|
|
|
? ""
|
|
|
|
|
: node.orgTreeShortName,
|
|
|
|
|
profileFullname:
|
|
|
|
|
node.profileOrgName == _node.profileOrgName ? "" : node.profileOrgName,
|
|
|
|
|
posExecutive:
|
|
|
|
|
node.orgTreeName == _node.orgTreeName ? "" : node.orgTreeName,
|
2024-02-12 14:43:38 +07:00
|
|
|
positionName: "",
|
|
|
|
|
posType: "",
|
|
|
|
|
posLevel: "",
|
2024-04-02 09:51:29 +07:00
|
|
|
profilePosMasterNo:
|
|
|
|
|
node.profileOrgShortName == _node.profileOrgShortName
|
|
|
|
|
? ""
|
|
|
|
|
: node.profileOrgShortName,
|
2024-02-12 14:43:38 +07:00
|
|
|
profilePosExecutive: "",
|
|
|
|
|
profilePositionName: "",
|
|
|
|
|
profilePosType: "",
|
|
|
|
|
profilePosLevel: "",
|
2024-02-13 09:59:10 +07:00
|
|
|
education: "",
|
|
|
|
|
salary: "",
|
2024-07-04 00:11:06 +07:00
|
|
|
reason: "",
|
2024-02-12 14:43:38 +07:00
|
|
|
};
|
|
|
|
|
data.push(head);
|
2024-04-02 09:51:29 +07:00
|
|
|
_node == null;
|
2024-02-12 14:43:38 +07:00
|
|
|
}
|
2024-04-02 09:51:29 +07:00
|
|
|
const head = {
|
2024-04-09 14:32:30 +07:00
|
|
|
no: Extension.ToThaiNumber(no.toString()),
|
2024-04-09 12:18:52 +07:00
|
|
|
posMasterNo:
|
|
|
|
|
node.posMasterNo == null
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.posMasterNo.toString()),
|
2024-06-07 15:40:33 +07:00
|
|
|
profileFullname:
|
|
|
|
|
node.profileFullname == null
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.profileFullname.toString()),
|
2024-04-02 09:51:29 +07:00
|
|
|
posExecutive:
|
2024-06-07 15:40:33 +07:00
|
|
|
node.posExecutive == null
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.posExecutive.toString()),
|
|
|
|
|
positionName:
|
|
|
|
|
node.positionName == null
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.positionName.toString()),
|
|
|
|
|
posType:
|
|
|
|
|
node.posType == null
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.posType.toString()),
|
|
|
|
|
posLevel:
|
|
|
|
|
node.posLevel == null
|
2024-04-09 12:18:52 +07:00
|
|
|
? ""
|
2024-06-07 15:40:33 +07:00
|
|
|
: Extension.ToThaiNumber(node.posLevel.toString()),
|
|
|
|
|
profilePosMasterNo: Extension.ToThaiNumber(
|
|
|
|
|
node.profilePosMasterNo.toString(),
|
|
|
|
|
),
|
2024-04-02 09:51:29 +07:00
|
|
|
profilePosExecutive:
|
2024-06-07 15:40:33 +07:00
|
|
|
node.profilePosExecutive == null
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.profilePosExecutive.toString()),
|
|
|
|
|
profilePositionName:
|
|
|
|
|
node.profilePositionName == null
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.profilePositionName.toString()),
|
|
|
|
|
profilePosType:
|
|
|
|
|
node.profilePosType == null
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.profilePosType.toString()),
|
|
|
|
|
profilePosLevel:
|
|
|
|
|
node.profilePosLevel == null
|
2024-04-02 09:51:29 +07:00
|
|
|
? ""
|
2024-06-07 15:40:33 +07:00
|
|
|
: Extension.ToThaiNumber(node.profilePosLevel.toString()),
|
|
|
|
|
education:
|
|
|
|
|
node.education == null
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.education.toString()),
|
2024-07-04 00:11:06 +07:00
|
|
|
salary: node.salary
|
|
|
|
|
? Extension.ToThaiNumber(node.salary.toLocaleString())
|
|
|
|
|
: "",
|
|
|
|
|
reason:
|
|
|
|
|
node.reason == null ? "" : Extension.ToThaiNumber(node.reason.toString()),
|
2024-04-02 09:51:29 +07:00
|
|
|
};
|
|
|
|
|
data.push(head);
|
|
|
|
|
}
|
|
|
|
|
no += 1;
|
|
|
|
|
_node = node;
|
|
|
|
|
}),
|
|
|
|
|
);
|
|
|
|
|
_node = null;
|
2024-02-12 14:43:38 +07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-04-02 09:51:29 +07:00
|
|
|
}
|
|
|
|
|
return new HttpSuccess({ template: "report2", reportName: "report2", data: { data } });
|
2024-02-12 14:43:38 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* API Report3
|
|
|
|
|
*
|
|
|
|
|
* @summary Report3
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
@Get("report3")
|
|
|
|
|
async findReport3() {
|
2024-04-02 09:51:29 +07:00
|
|
|
const orgRevision = await this.orgRevisionRepository.findOne({
|
|
|
|
|
where: { orgRevisionIsDraft: true, orgRevisionIsCurrent: false },
|
|
|
|
|
relations: ["orgRoots"],
|
|
|
|
|
});
|
|
|
|
|
if (!orgRevision) {
|
|
|
|
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
|
|
|
|
}
|
2024-02-12 14:43:38 +07:00
|
|
|
|
2024-04-02 09:51:29 +07:00
|
|
|
const orgRootData = await this.orgRootRepository.find({
|
|
|
|
|
where: {
|
|
|
|
|
orgRevisionId: orgRevision.id,
|
|
|
|
|
},
|
|
|
|
|
order: { orgRootOrder: "ASC" },
|
|
|
|
|
relations: [
|
|
|
|
|
"posMasters",
|
|
|
|
|
"posMasters.orgRoot",
|
|
|
|
|
"posMasters.orgChild1",
|
|
|
|
|
"posMasters.orgChild2",
|
|
|
|
|
"posMasters.orgChild3",
|
|
|
|
|
"posMasters.orgChild4",
|
|
|
|
|
"posMasters.next_holder",
|
|
|
|
|
"posMasters.next_holder",
|
|
|
|
|
"posMasters.next_holder",
|
|
|
|
|
"posMasters.next_holder.posLevel",
|
|
|
|
|
"posMasters.next_holder.posType",
|
2024-04-09 14:32:30 +07:00
|
|
|
"posMasters.next_holder.profileSalary",
|
|
|
|
|
"posMasters.next_holder.profileEducations",
|
2024-04-02 09:51:29 +07:00
|
|
|
"posMasters.next_holder.current_holders",
|
|
|
|
|
"posMasters.next_holder.current_holders.positions",
|
|
|
|
|
"posMasters.next_holder.current_holders.orgRoot",
|
|
|
|
|
"posMasters.next_holder.current_holders.orgChild1",
|
|
|
|
|
"posMasters.next_holder.current_holders.orgChild2",
|
|
|
|
|
"posMasters.next_holder.current_holders.orgChild3",
|
|
|
|
|
"posMasters.next_holder.current_holders.orgChild4",
|
|
|
|
|
"posMasters.positions",
|
|
|
|
|
"posMasters.positions.posLevel",
|
|
|
|
|
"posMasters.positions.posType",
|
|
|
|
|
"posMasters.positions.posExecutive",
|
|
|
|
|
],
|
|
|
|
|
});
|
2024-02-12 14:43:38 +07:00
|
|
|
|
2024-04-02 09:51:29 +07:00
|
|
|
const orgRootIds = orgRootData.map((orgRoot) => orgRoot.id) || null;
|
|
|
|
|
const orgChild1Data = await this.child1Repository.find({
|
|
|
|
|
where: {
|
|
|
|
|
orgRootId: In(orgRootIds),
|
|
|
|
|
},
|
|
|
|
|
order: { orgChild1Order: "ASC" },
|
|
|
|
|
relations: [
|
|
|
|
|
"posMasters",
|
|
|
|
|
"posMasters.orgRoot",
|
|
|
|
|
"posMasters.orgChild1",
|
|
|
|
|
"posMasters.orgChild2",
|
|
|
|
|
"posMasters.orgChild3",
|
|
|
|
|
"posMasters.orgChild4",
|
|
|
|
|
"posMasters.next_holder",
|
|
|
|
|
"posMasters.next_holder.posLevel",
|
|
|
|
|
"posMasters.next_holder.posType",
|
2024-04-09 14:32:30 +07:00
|
|
|
"posMasters.next_holder.profileSalary",
|
|
|
|
|
"posMasters.next_holder.profileEducations",
|
2024-04-02 09:51:29 +07:00
|
|
|
"posMasters.next_holder.current_holders",
|
|
|
|
|
"posMasters.next_holder.current_holders.positions",
|
|
|
|
|
"posMasters.next_holder.current_holders.orgRoot",
|
|
|
|
|
"posMasters.next_holder.current_holders.orgChild1",
|
|
|
|
|
"posMasters.next_holder.current_holders.orgChild2",
|
|
|
|
|
"posMasters.next_holder.current_holders.orgChild3",
|
|
|
|
|
"posMasters.next_holder.current_holders.orgChild4",
|
|
|
|
|
"posMasters.positions",
|
|
|
|
|
"posMasters.positions.posLevel",
|
|
|
|
|
"posMasters.positions.posType",
|
|
|
|
|
"posMasters.positions.posExecutive",
|
|
|
|
|
],
|
|
|
|
|
});
|
2024-02-12 14:43:38 +07:00
|
|
|
|
2024-04-02 09:51:29 +07:00
|
|
|
const orgChild1Ids = orgChild1Data.map((orgChild1) => orgChild1.id) || null;
|
|
|
|
|
const orgChild2Data = await this.child2Repository.find({
|
|
|
|
|
where: {
|
|
|
|
|
orgChild1: In(orgChild1Ids),
|
|
|
|
|
},
|
|
|
|
|
order: { orgChild2Order: "ASC" },
|
|
|
|
|
relations: [
|
|
|
|
|
"posMasters",
|
|
|
|
|
"posMasters.orgRoot",
|
|
|
|
|
"posMasters.orgChild1",
|
|
|
|
|
"posMasters.orgChild2",
|
|
|
|
|
"posMasters.orgChild3",
|
|
|
|
|
"posMasters.orgChild4",
|
|
|
|
|
"posMasters.next_holder",
|
|
|
|
|
"posMasters.next_holder.posLevel",
|
|
|
|
|
"posMasters.next_holder.posType",
|
2024-04-09 14:32:30 +07:00
|
|
|
"posMasters.next_holder.profileSalary",
|
|
|
|
|
"posMasters.next_holder.profileEducations",
|
2024-04-02 09:51:29 +07:00
|
|
|
"posMasters.next_holder.current_holders",
|
|
|
|
|
"posMasters.next_holder.current_holders.positions",
|
|
|
|
|
"posMasters.next_holder.current_holders.orgRoot",
|
|
|
|
|
"posMasters.next_holder.current_holders.orgChild1",
|
|
|
|
|
"posMasters.next_holder.current_holders.orgChild2",
|
|
|
|
|
"posMasters.next_holder.current_holders.orgChild3",
|
|
|
|
|
"posMasters.next_holder.current_holders.orgChild4",
|
|
|
|
|
"posMasters.positions",
|
|
|
|
|
"posMasters.positions.posLevel",
|
|
|
|
|
"posMasters.positions.posType",
|
|
|
|
|
"posMasters.positions.posExecutive",
|
|
|
|
|
],
|
|
|
|
|
});
|
2024-02-12 14:43:38 +07:00
|
|
|
|
2024-04-02 09:51:29 +07:00
|
|
|
const orgChild2Ids = orgChild2Data.map((orgChild2) => orgChild2.id) || null;
|
|
|
|
|
const orgChild3Data = await this.child3Repository.find({
|
|
|
|
|
where: {
|
|
|
|
|
orgChild2: In(orgChild2Ids),
|
|
|
|
|
},
|
|
|
|
|
order: { orgChild3Order: "ASC" },
|
|
|
|
|
relations: [
|
|
|
|
|
"posMasters",
|
|
|
|
|
"posMasters.orgRoot",
|
|
|
|
|
"posMasters.orgChild1",
|
|
|
|
|
"posMasters.orgChild2",
|
|
|
|
|
"posMasters.orgChild3",
|
|
|
|
|
"posMasters.orgChild4",
|
|
|
|
|
"posMasters.next_holder",
|
|
|
|
|
"posMasters.next_holder.posLevel",
|
|
|
|
|
"posMasters.next_holder.posType",
|
2024-04-09 14:32:30 +07:00
|
|
|
"posMasters.next_holder.profileSalary",
|
|
|
|
|
"posMasters.next_holder.profileEducations",
|
2024-04-02 09:51:29 +07:00
|
|
|
"posMasters.next_holder.current_holders",
|
|
|
|
|
"posMasters.next_holder.current_holders.positions",
|
|
|
|
|
"posMasters.next_holder.current_holders.orgRoot",
|
|
|
|
|
"posMasters.next_holder.current_holders.orgChild1",
|
|
|
|
|
"posMasters.next_holder.current_holders.orgChild2",
|
|
|
|
|
"posMasters.next_holder.current_holders.orgChild3",
|
|
|
|
|
"posMasters.next_holder.current_holders.orgChild4",
|
|
|
|
|
"posMasters.positions",
|
|
|
|
|
"posMasters.positions.posLevel",
|
|
|
|
|
"posMasters.positions.posType",
|
|
|
|
|
"posMasters.positions.posExecutive",
|
|
|
|
|
],
|
|
|
|
|
});
|
2024-02-12 14:43:38 +07:00
|
|
|
|
2024-04-02 09:51:29 +07:00
|
|
|
const orgChild3Ids = orgChild3Data.map((orgChild3) => orgChild3.id) || null;
|
|
|
|
|
const orgChild4Data = await this.child4Repository.find({
|
|
|
|
|
where: {
|
|
|
|
|
orgChild3: In(orgChild3Ids),
|
|
|
|
|
},
|
|
|
|
|
order: { orgChild4Order: "ASC" },
|
|
|
|
|
relations: [
|
|
|
|
|
"posMasters",
|
|
|
|
|
"posMasters.orgRoot",
|
|
|
|
|
"posMasters.orgChild1",
|
|
|
|
|
"posMasters.orgChild2",
|
|
|
|
|
"posMasters.orgChild3",
|
|
|
|
|
"posMasters.orgChild4",
|
|
|
|
|
"posMasters.next_holder",
|
|
|
|
|
"posMasters.next_holder.posLevel",
|
|
|
|
|
"posMasters.next_holder.posType",
|
2024-04-09 14:32:30 +07:00
|
|
|
"posMasters.next_holder.profileSalary",
|
|
|
|
|
"posMasters.next_holder.profileEducations",
|
2024-04-02 09:51:29 +07:00
|
|
|
"posMasters.next_holder.current_holders",
|
|
|
|
|
"posMasters.next_holder.current_holders.positions",
|
|
|
|
|
"posMasters.next_holder.current_holders.orgRoot",
|
|
|
|
|
"posMasters.next_holder.current_holders.orgChild1",
|
|
|
|
|
"posMasters.next_holder.current_holders.orgChild2",
|
|
|
|
|
"posMasters.next_holder.current_holders.orgChild3",
|
|
|
|
|
"posMasters.next_holder.current_holders.orgChild4",
|
|
|
|
|
"posMasters.positions",
|
|
|
|
|
"posMasters.positions.posLevel",
|
|
|
|
|
"posMasters.positions.posType",
|
|
|
|
|
"posMasters.positions.posExecutive",
|
|
|
|
|
],
|
|
|
|
|
});
|
2024-02-12 14:43:38 +07:00
|
|
|
|
2024-04-02 09:51:29 +07:00
|
|
|
let orgRevisionActive: any = await this.orgRevisionRepository.findOne({
|
|
|
|
|
where: { orgRevisionIsCurrent: true, orgRevisionIsDraft: false },
|
|
|
|
|
relations: [
|
|
|
|
|
"posMasters",
|
|
|
|
|
"posMasters.positions",
|
|
|
|
|
"posMasters.positions.posLevel",
|
|
|
|
|
"posMasters.positions.posType",
|
|
|
|
|
"posMasters.positions.posExecutive",
|
|
|
|
|
],
|
|
|
|
|
});
|
|
|
|
|
if (orgRevisionActive == null) {
|
|
|
|
|
const _orgRevisionActive = await this.orgRevisionRepository.find({
|
|
|
|
|
order: { orgRevisionCreatedAt: "DESC" },
|
|
|
|
|
skip: 1,
|
2024-02-12 14:43:38 +07:00
|
|
|
relations: [
|
|
|
|
|
"posMasters",
|
|
|
|
|
"posMasters.positions",
|
|
|
|
|
"posMasters.positions.posLevel",
|
|
|
|
|
"posMasters.positions.posType",
|
|
|
|
|
"posMasters.positions.posExecutive",
|
|
|
|
|
],
|
|
|
|
|
});
|
2024-04-02 09:51:29 +07:00
|
|
|
if (_orgRevisionActive.length > 0) orgRevisionActive = _orgRevisionActive[0];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let data = new Array();
|
|
|
|
|
let _node: any;
|
|
|
|
|
let no = 1;
|
|
|
|
|
for (let orgRoot of orgRootData) {
|
|
|
|
|
await Promise.all(
|
|
|
|
|
orgRoot.posMasters
|
|
|
|
|
.sort((a, b) => a.posMasterOrder - b.posMasterOrder)
|
|
|
|
|
.map(async (posMaster) => {
|
|
|
|
|
if (posMaster.orgChild1Id == null && posMaster.next_holder != null) {
|
|
|
|
|
let positionMasterProfileOld: any = null;
|
|
|
|
|
if (posMaster.next_holder != null) {
|
|
|
|
|
positionMasterProfileOld = posMaster.next_holder.current_holders.find(
|
|
|
|
|
(x) => x.orgRevisionId == orgRevisionActive.id,
|
|
|
|
|
);
|
|
|
|
|
}
|
2024-04-09 14:32:30 +07:00
|
|
|
let education: any = "";
|
|
|
|
|
if (
|
|
|
|
|
posMaster.next_holder != null &&
|
|
|
|
|
posMaster.next_holder.profileEducations != null &&
|
|
|
|
|
posMaster.next_holder.profileEducations.length > 0
|
|
|
|
|
) {
|
|
|
|
|
let _education: any = posMaster.next_holder.profileEducations.sort(
|
2024-04-11 16:33:06 +07:00
|
|
|
(a, b) =>
|
|
|
|
|
(b.finishDate == null ? 0 : b.finishDate.getTime()) -
|
|
|
|
|
(a.finishDate == null ? 0 : a.finishDate.getTime()),
|
2024-04-09 14:32:30 +07:00
|
|
|
);
|
|
|
|
|
if (_education.length > 0) {
|
|
|
|
|
education = _education[0];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
let salary: any = "";
|
|
|
|
|
if (
|
|
|
|
|
posMaster.next_holder != null &&
|
|
|
|
|
posMaster.next_holder.profileSalary != null &&
|
|
|
|
|
posMaster.next_holder.profileSalary.length > 0
|
|
|
|
|
) {
|
|
|
|
|
let _salary: any = posMaster.next_holder.profileSalary.sort(
|
2024-04-11 16:33:06 +07:00
|
|
|
(a, b) =>
|
|
|
|
|
(b.date == null ? 0 : b.date.getTime()) -
|
|
|
|
|
(a.date == null ? 0 : a.date.getTime()),
|
2024-04-09 14:32:30 +07:00
|
|
|
);
|
|
|
|
|
if (_salary.length > 0) {
|
|
|
|
|
salary = _salary[0];
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-04-02 09:51:29 +07:00
|
|
|
|
|
|
|
|
let node = {
|
|
|
|
|
orgTreeName: orgRoot.orgRootName,
|
|
|
|
|
orgTreeShortName: orgRoot.orgRootShortName,
|
|
|
|
|
posMasterNo: posMaster.posMasterNo,
|
|
|
|
|
positionName:
|
|
|
|
|
posMaster.isSit == false
|
|
|
|
|
? posMaster.positions.find((x: any) => x.positionIsSelected == true)
|
|
|
|
|
?.positionName
|
|
|
|
|
: posMaster.next_holder.position,
|
|
|
|
|
posType:
|
|
|
|
|
posMaster.isSit == false
|
|
|
|
|
? posMaster.positions.find((x: any) => x.positionIsSelected == true)?.posType
|
|
|
|
|
?.posTypeName
|
|
|
|
|
: posMaster.next_holder.posType == null
|
|
|
|
|
? "-"
|
|
|
|
|
: posMaster.next_holder.posType.posTypeName,
|
|
|
|
|
posLevel:
|
|
|
|
|
posMaster.isSit == false
|
|
|
|
|
? posMaster.positions.find((x: any) => x.positionIsSelected == true)?.posLevel
|
|
|
|
|
?.posLevelName
|
|
|
|
|
: posMaster.next_holder.posLevel == null
|
|
|
|
|
? "-"
|
|
|
|
|
: posMaster.next_holder.posLevel.posLevelName,
|
|
|
|
|
posExecutive:
|
|
|
|
|
posMaster.isSit == false
|
|
|
|
|
? posMaster.positions.find((x: any) => x.positionIsSelected == true)
|
|
|
|
|
?.posExecutive?.posExecutiveName
|
|
|
|
|
: positionMasterProfileOld == null
|
|
|
|
|
? "-"
|
|
|
|
|
: positionMasterProfileOld.positions.find(
|
|
|
|
|
(x: any) => x.positionIsSelected == true,
|
|
|
|
|
)?.posExecutive?.posExecutiveName,
|
|
|
|
|
|
|
|
|
|
profileFullname: `${posMaster.next_holder.prefix}${posMaster.next_holder.firstName} ${posMaster.next_holder.lastName}`,
|
2024-04-09 14:32:30 +07:00
|
|
|
education: education == "" ? "" : education.degree,
|
|
|
|
|
salary: salary == "" ? "" : salary.amount,
|
|
|
|
|
positionSalaryAmount: salary == "" ? "" : salary.positionSalaryAmount,
|
|
|
|
|
mouthSalaryAmount: salary == "" ? "" : salary.mouthSalaryAmount,
|
|
|
|
|
reason: posMaster.reason == null ? "" : posMaster.reason,
|
2024-04-02 09:51:29 +07:00
|
|
|
};
|
|
|
|
|
if (_node == null) {
|
|
|
|
|
const head = {
|
2024-06-07 15:40:33 +07:00
|
|
|
posMasterNo: Extension.ToThaiNumber(node.orgTreeShortName.toString()),
|
2024-04-02 09:51:29 +07:00
|
|
|
profileFullname: "",
|
2024-06-07 15:40:33 +07:00
|
|
|
posExecutive: Extension.ToThaiNumber(node.orgTreeName.toString()),
|
2024-04-02 09:51:29 +07:00
|
|
|
positionName: "",
|
|
|
|
|
posType: "",
|
|
|
|
|
posLevel: "",
|
|
|
|
|
education: "",
|
|
|
|
|
salary: "",
|
|
|
|
|
positionSalaryAmount: "",
|
|
|
|
|
mouthSalaryAmount: "",
|
|
|
|
|
reason: "",
|
|
|
|
|
};
|
|
|
|
|
data.push(head);
|
|
|
|
|
const _head = {
|
2024-04-09 14:32:30 +07:00
|
|
|
no: Extension.ToThaiNumber(no.toString()),
|
2024-04-09 12:18:52 +07:00
|
|
|
posMasterNo:
|
|
|
|
|
node.posMasterNo == null
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.posMasterNo.toString()),
|
2024-06-07 15:40:33 +07:00
|
|
|
profileFullname:
|
|
|
|
|
node.profileFullname == null
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.profileFullname.toString()),
|
2024-04-02 09:51:29 +07:00
|
|
|
posExecutive: node.posExecutive == undefined ? "" : node.posExecutive,
|
2024-06-07 15:40:33 +07:00
|
|
|
positionName:
|
|
|
|
|
node.positionName == null
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.positionName.toString()),
|
|
|
|
|
posType:
|
|
|
|
|
node.posType == null ? "" : Extension.ToThaiNumber(node.posType.toString()),
|
|
|
|
|
posLevel:
|
|
|
|
|
node.posLevel == null ? "" : Extension.ToThaiNumber(node.posLevel.toString()),
|
|
|
|
|
education:
|
|
|
|
|
node.education == null ? "" : Extension.ToThaiNumber(node.education.toString()),
|
2024-06-25 10:20:09 +07:00
|
|
|
salary: node.salary ? Extension.ToThaiNumber(node.salary.toLocaleString()) : "",
|
2024-07-04 00:11:06 +07:00
|
|
|
positionSalaryAmount: node.positionSalaryAmount
|
|
|
|
|
? Extension.ToThaiNumber(node.positionSalaryAmount.toLocaleString())
|
|
|
|
|
: "",
|
|
|
|
|
mouthSalaryAmount: node.mouthSalaryAmount
|
|
|
|
|
? Extension.ToThaiNumber(node.mouthSalaryAmount.toLocaleString())
|
|
|
|
|
: "",
|
2024-06-07 15:40:33 +07:00
|
|
|
reason: node.reason == null ? "" : Extension.ToThaiNumber(node.reason.toString()),
|
2024-04-02 09:51:29 +07:00
|
|
|
};
|
|
|
|
|
data.push(_head);
|
|
|
|
|
} else {
|
|
|
|
|
if (
|
|
|
|
|
node.orgTreeShortName != _node.orgTreeShortName ||
|
|
|
|
|
node.orgTreeName != _node.orgTreeName
|
|
|
|
|
) {
|
|
|
|
|
const head = {
|
|
|
|
|
posMasterNo:
|
|
|
|
|
node.orgTreeShortName == _node.orgTreeShortName ? "" : node.orgTreeShortName,
|
|
|
|
|
profileFullname: "",
|
|
|
|
|
posExecutive: node.orgTreeName == _node.orgTreeName ? "" : node.orgTreeName,
|
|
|
|
|
positionName: "",
|
|
|
|
|
posType: "",
|
|
|
|
|
posLevel: "",
|
|
|
|
|
education: "",
|
|
|
|
|
salary: "",
|
|
|
|
|
positionSalaryAmount: "",
|
|
|
|
|
mouthSalaryAmount: "",
|
|
|
|
|
reason: "",
|
|
|
|
|
};
|
|
|
|
|
data.push(head);
|
|
|
|
|
_node == null;
|
|
|
|
|
}
|
|
|
|
|
const head = {
|
2024-04-09 14:32:30 +07:00
|
|
|
no: Extension.ToThaiNumber(no.toString()),
|
2024-04-09 12:18:52 +07:00
|
|
|
posMasterNo:
|
|
|
|
|
node.posMasterNo == null
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.posMasterNo.toString()),
|
2024-06-07 15:40:33 +07:00
|
|
|
profileFullname:
|
|
|
|
|
node.profileFullname == null
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.profileFullname.toString()),
|
2024-04-02 09:51:29 +07:00
|
|
|
posExecutive: node.posExecutive == _node.posExecutive ? "" : node.posExecutive,
|
2024-06-07 15:40:33 +07:00
|
|
|
positionName:
|
|
|
|
|
node.positionName == null
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.positionName.toString()),
|
|
|
|
|
posType:
|
|
|
|
|
node.posType == null ? "" : Extension.ToThaiNumber(node.posType.toString()),
|
|
|
|
|
posLevel:
|
|
|
|
|
node.posLevel == null ? "" : Extension.ToThaiNumber(node.posLevel.toString()),
|
|
|
|
|
education:
|
|
|
|
|
node.education == null ? "" : Extension.ToThaiNumber(node.education.toString()),
|
2024-06-25 10:20:09 +07:00
|
|
|
salary: node.salary ? Extension.ToThaiNumber(node.salary.toLocaleString()) : "",
|
2024-07-04 00:11:06 +07:00
|
|
|
positionSalaryAmount: node.positionSalaryAmount
|
|
|
|
|
? Extension.ToThaiNumber(node.positionSalaryAmount.toLocaleString())
|
|
|
|
|
: "",
|
|
|
|
|
mouthSalaryAmount: node.mouthSalaryAmount
|
|
|
|
|
? Extension.ToThaiNumber(node.mouthSalaryAmount.toLocaleString())
|
|
|
|
|
: "",
|
2024-06-07 15:40:33 +07:00
|
|
|
reason: node.reason == null ? "" : Extension.ToThaiNumber(node.reason.toString()),
|
2024-04-02 09:51:29 +07:00
|
|
|
};
|
|
|
|
|
data.push(head);
|
|
|
|
|
}
|
|
|
|
|
no += 1;
|
|
|
|
|
_node = node;
|
|
|
|
|
}
|
|
|
|
|
}),
|
|
|
|
|
);
|
|
|
|
|
_node = null;
|
2024-02-12 14:43:38 +07:00
|
|
|
|
2024-04-02 09:51:29 +07:00
|
|
|
for (let orgChild1 of orgChild1Data.filter(
|
|
|
|
|
(orgChild1) => orgChild1.orgRootId === orgRoot.id,
|
|
|
|
|
)) {
|
2024-02-12 14:43:38 +07:00
|
|
|
await Promise.all(
|
2024-04-02 09:51:29 +07:00
|
|
|
orgChild1.posMasters
|
2024-02-12 14:43:38 +07:00
|
|
|
.sort((a, b) => a.posMasterOrder - b.posMasterOrder)
|
|
|
|
|
.map(async (posMaster) => {
|
2024-04-02 09:51:29 +07:00
|
|
|
if (posMaster.orgChild2Id == null && posMaster.next_holder != null) {
|
2024-02-12 14:43:38 +07:00
|
|
|
let positionMasterProfileOld: any = null;
|
|
|
|
|
if (posMaster.next_holder != null) {
|
|
|
|
|
positionMasterProfileOld = posMaster.next_holder.current_holders.find(
|
|
|
|
|
(x) => x.orgRevisionId == orgRevisionActive.id,
|
|
|
|
|
);
|
|
|
|
|
}
|
2024-04-09 14:32:30 +07:00
|
|
|
let education: any = "";
|
|
|
|
|
if (
|
|
|
|
|
posMaster.next_holder != null &&
|
|
|
|
|
posMaster.next_holder.profileEducations != null &&
|
|
|
|
|
posMaster.next_holder.profileEducations.length > 0
|
|
|
|
|
) {
|
|
|
|
|
let _education: any = posMaster.next_holder.profileEducations.sort(
|
2024-04-11 16:33:06 +07:00
|
|
|
(a, b) =>
|
|
|
|
|
(b.finishDate == null ? 0 : b.finishDate.getTime()) -
|
|
|
|
|
(a.finishDate == null ? 0 : a.finishDate.getTime()),
|
2024-04-09 14:32:30 +07:00
|
|
|
);
|
|
|
|
|
if (_education.length > 0) {
|
|
|
|
|
education = _education[0];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
let salary: any = "";
|
|
|
|
|
if (
|
|
|
|
|
posMaster.next_holder != null &&
|
|
|
|
|
posMaster.next_holder.profileSalary != null &&
|
|
|
|
|
posMaster.next_holder.profileSalary.length > 0
|
|
|
|
|
) {
|
|
|
|
|
let _salary: any = posMaster.next_holder.profileSalary.sort(
|
2024-04-11 16:33:06 +07:00
|
|
|
(a, b) =>
|
|
|
|
|
(b.date == null ? 0 : b.date.getTime()) -
|
|
|
|
|
(a.date == null ? 0 : a.date.getTime()),
|
2024-04-09 14:32:30 +07:00
|
|
|
);
|
|
|
|
|
if (_salary.length > 0) {
|
|
|
|
|
salary = _salary[0];
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-02-12 14:43:38 +07:00
|
|
|
|
|
|
|
|
let node = {
|
2024-04-02 09:51:29 +07:00
|
|
|
orgTreeName: orgChild1.orgChild1Name,
|
|
|
|
|
orgTreeShortName: orgChild1.orgChild1ShortName,
|
2024-02-12 14:43:38 +07:00
|
|
|
posMasterNo: posMaster.posMasterNo,
|
|
|
|
|
positionName:
|
|
|
|
|
posMaster.isSit == false
|
|
|
|
|
? posMaster.positions.find((x: any) => x.positionIsSelected == true)
|
|
|
|
|
?.positionName
|
|
|
|
|
: posMaster.next_holder.position,
|
|
|
|
|
posType:
|
|
|
|
|
posMaster.isSit == false
|
|
|
|
|
? posMaster.positions.find((x: any) => x.positionIsSelected == true)?.posType
|
|
|
|
|
?.posTypeName
|
|
|
|
|
: posMaster.next_holder.posType == null
|
|
|
|
|
? "-"
|
|
|
|
|
: posMaster.next_holder.posType.posTypeName,
|
|
|
|
|
posLevel:
|
|
|
|
|
posMaster.isSit == false
|
|
|
|
|
? posMaster.positions.find((x: any) => x.positionIsSelected == true)?.posLevel
|
|
|
|
|
?.posLevelName
|
|
|
|
|
: posMaster.next_holder.posLevel == null
|
|
|
|
|
? "-"
|
|
|
|
|
: posMaster.next_holder.posLevel.posLevelName,
|
|
|
|
|
posExecutive:
|
|
|
|
|
posMaster.isSit == false
|
|
|
|
|
? posMaster.positions.find((x: any) => x.positionIsSelected == true)
|
|
|
|
|
?.posExecutive?.posExecutiveName
|
|
|
|
|
: positionMasterProfileOld == null
|
|
|
|
|
? "-"
|
|
|
|
|
: positionMasterProfileOld.positions.find(
|
|
|
|
|
(x: any) => x.positionIsSelected == true,
|
|
|
|
|
)?.posExecutive?.posExecutiveName,
|
2024-02-12 15:18:09 +07:00
|
|
|
|
2024-02-12 14:43:38 +07:00
|
|
|
profileFullname: `${posMaster.next_holder.prefix}${posMaster.next_holder.firstName} ${posMaster.next_holder.lastName}`,
|
2024-04-09 14:32:30 +07:00
|
|
|
education: education == "" ? "" : education.degree,
|
|
|
|
|
salary: salary == "" ? "" : salary.amount,
|
|
|
|
|
positionSalaryAmount: salary == "" ? "" : salary.positionSalaryAmount,
|
|
|
|
|
mouthSalaryAmount: salary == "" ? "" : salary.mouthSalaryAmount,
|
|
|
|
|
reason: posMaster.reason == null ? "" : posMaster.reason,
|
2024-02-12 14:43:38 +07:00
|
|
|
};
|
|
|
|
|
if (_node == null) {
|
|
|
|
|
const head = {
|
2024-06-07 15:40:33 +07:00
|
|
|
posMasterNo: Extension.ToThaiNumber(node.orgTreeShortName.toString()),
|
2024-02-12 14:43:38 +07:00
|
|
|
profileFullname: "",
|
2024-06-07 15:40:33 +07:00
|
|
|
posExecutive: Extension.ToThaiNumber(node.orgTreeName.toString()),
|
2024-02-12 14:43:38 +07:00
|
|
|
positionName: "",
|
|
|
|
|
posType: "",
|
|
|
|
|
posLevel: "",
|
2024-02-13 09:59:10 +07:00
|
|
|
education: "",
|
|
|
|
|
salary: "",
|
|
|
|
|
positionSalaryAmount: "",
|
|
|
|
|
mouthSalaryAmount: "",
|
|
|
|
|
reason: "",
|
2024-02-12 14:43:38 +07:00
|
|
|
};
|
|
|
|
|
data.push(head);
|
|
|
|
|
const _head = {
|
2024-04-09 14:32:30 +07:00
|
|
|
no: Extension.ToThaiNumber(no.toString()),
|
2024-04-09 12:18:52 +07:00
|
|
|
posMasterNo:
|
|
|
|
|
node.posMasterNo == null
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.posMasterNo.toString()),
|
2024-06-07 15:40:33 +07:00
|
|
|
profileFullname:
|
|
|
|
|
node.profileFullname == null
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.profileFullname.toString()),
|
2024-04-02 09:51:29 +07:00
|
|
|
posExecutive: node.posExecutive,
|
2024-06-07 15:40:33 +07:00
|
|
|
positionName:
|
|
|
|
|
node.positionName == null
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.positionName.toString()),
|
|
|
|
|
posType:
|
|
|
|
|
node.posType == null ? "" : Extension.ToThaiNumber(node.posType.toString()),
|
|
|
|
|
posLevel:
|
|
|
|
|
node.posLevel == null ? "" : Extension.ToThaiNumber(node.posLevel.toString()),
|
|
|
|
|
education:
|
|
|
|
|
node.education == null
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.education.toString()),
|
2024-06-25 10:20:09 +07:00
|
|
|
salary: node.salary ? Extension.ToThaiNumber(node.salary.toLocaleString()) : "",
|
2024-07-04 00:11:06 +07:00
|
|
|
positionSalaryAmount: node.positionSalaryAmount
|
|
|
|
|
? Extension.ToThaiNumber(node.positionSalaryAmount.toLocaleString())
|
|
|
|
|
: "",
|
|
|
|
|
mouthSalaryAmount: node.mouthSalaryAmount
|
|
|
|
|
? Extension.ToThaiNumber(node.mouthSalaryAmount.toLocaleString())
|
|
|
|
|
: "",
|
2024-06-07 15:40:33 +07:00
|
|
|
reason:
|
|
|
|
|
node.reason == null ? "" : Extension.ToThaiNumber(node.reason.toString()),
|
2024-02-12 14:43:38 +07:00
|
|
|
};
|
|
|
|
|
data.push(_head);
|
|
|
|
|
} else {
|
|
|
|
|
if (
|
|
|
|
|
node.orgTreeShortName != _node.orgTreeShortName ||
|
|
|
|
|
node.orgTreeName != _node.orgTreeName
|
|
|
|
|
) {
|
|
|
|
|
const head = {
|
|
|
|
|
posMasterNo:
|
|
|
|
|
node.orgTreeShortName == _node.orgTreeShortName
|
|
|
|
|
? ""
|
|
|
|
|
: node.orgTreeShortName,
|
|
|
|
|
profileFullname: "",
|
|
|
|
|
posExecutive: node.orgTreeName == _node.orgTreeName ? "" : node.orgTreeName,
|
|
|
|
|
positionName: "",
|
|
|
|
|
posType: "",
|
|
|
|
|
posLevel: "",
|
2024-02-13 09:59:10 +07:00
|
|
|
education: "",
|
|
|
|
|
salary: "",
|
|
|
|
|
positionSalaryAmount: "",
|
|
|
|
|
mouthSalaryAmount: "",
|
|
|
|
|
reason: "",
|
2024-02-12 14:43:38 +07:00
|
|
|
};
|
|
|
|
|
data.push(head);
|
|
|
|
|
_node == null;
|
|
|
|
|
}
|
|
|
|
|
const head = {
|
2024-04-09 14:32:30 +07:00
|
|
|
no: Extension.ToThaiNumber(no.toString()),
|
2024-04-09 12:18:52 +07:00
|
|
|
posMasterNo:
|
|
|
|
|
node.posMasterNo == null
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.posMasterNo.toString()),
|
2024-06-07 15:40:33 +07:00
|
|
|
profileFullname:
|
|
|
|
|
node.profileFullname == null
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.profileFullname.toString()),
|
2024-02-12 14:43:38 +07:00
|
|
|
posExecutive: node.posExecutive == _node.posExecutive ? "" : node.posExecutive,
|
2024-06-07 15:40:33 +07:00
|
|
|
positionName:
|
|
|
|
|
node.positionName == null
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.positionName.toString()),
|
|
|
|
|
posType:
|
|
|
|
|
node.posType == null ? "" : Extension.ToThaiNumber(node.posType.toString()),
|
|
|
|
|
posLevel:
|
|
|
|
|
node.posLevel == null ? "" : Extension.ToThaiNumber(node.posLevel.toString()),
|
|
|
|
|
education:
|
|
|
|
|
node.education == null
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.education.toString()),
|
2024-06-25 10:20:09 +07:00
|
|
|
salary: node.salary ? Extension.ToThaiNumber(node.salary.toLocaleString()) : "",
|
2024-07-04 00:11:06 +07:00
|
|
|
positionSalaryAmount: node.positionSalaryAmount
|
|
|
|
|
? Extension.ToThaiNumber(node.positionSalaryAmount.toLocaleString())
|
|
|
|
|
: "",
|
|
|
|
|
mouthSalaryAmount: node.mouthSalaryAmount
|
|
|
|
|
? Extension.ToThaiNumber(node.mouthSalaryAmount.toLocaleString())
|
|
|
|
|
: "",
|
2024-06-07 15:40:33 +07:00
|
|
|
reason:
|
|
|
|
|
node.reason == null ? "" : Extension.ToThaiNumber(node.reason.toString()),
|
2024-02-12 14:43:38 +07:00
|
|
|
};
|
|
|
|
|
data.push(head);
|
|
|
|
|
}
|
|
|
|
|
no += 1;
|
|
|
|
|
_node = node;
|
|
|
|
|
}
|
|
|
|
|
}),
|
|
|
|
|
);
|
|
|
|
|
_node = null;
|
|
|
|
|
|
2024-04-02 09:51:29 +07:00
|
|
|
for (let orgChild2 of orgChild2Data.filter(
|
|
|
|
|
(orgChild2) => orgChild2.orgChild1Id === orgChild1.id,
|
2024-02-12 14:43:38 +07:00
|
|
|
)) {
|
|
|
|
|
await Promise.all(
|
2024-04-02 09:51:29 +07:00
|
|
|
orgChild2.posMasters
|
2024-02-12 14:43:38 +07:00
|
|
|
.sort((a, b) => a.posMasterOrder - b.posMasterOrder)
|
|
|
|
|
.map(async (posMaster) => {
|
2024-04-02 09:51:29 +07:00
|
|
|
if (posMaster.orgChild3Id == null && posMaster.next_holder != null) {
|
2024-02-12 14:43:38 +07:00
|
|
|
let positionMasterProfileOld: any = null;
|
|
|
|
|
if (posMaster.next_holder != null) {
|
|
|
|
|
positionMasterProfileOld = posMaster.next_holder.current_holders.find(
|
|
|
|
|
(x) => x.orgRevisionId == orgRevisionActive.id,
|
|
|
|
|
);
|
|
|
|
|
}
|
2024-04-09 14:32:30 +07:00
|
|
|
let education: any = "";
|
|
|
|
|
if (
|
|
|
|
|
posMaster.next_holder != null &&
|
|
|
|
|
posMaster.next_holder.profileEducations != null &&
|
|
|
|
|
posMaster.next_holder.profileEducations.length > 0
|
|
|
|
|
) {
|
|
|
|
|
let _education: any = posMaster.next_holder.profileEducations.sort(
|
2024-04-11 16:33:06 +07:00
|
|
|
(a, b) =>
|
|
|
|
|
(b.finishDate == null ? 0 : b.finishDate.getTime()) -
|
|
|
|
|
(a.finishDate == null ? 0 : a.finishDate.getTime()),
|
2024-04-09 14:32:30 +07:00
|
|
|
);
|
|
|
|
|
if (_education.length > 0) {
|
|
|
|
|
education = _education[0];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
let salary: any = "";
|
|
|
|
|
if (
|
|
|
|
|
posMaster.next_holder != null &&
|
|
|
|
|
posMaster.next_holder.profileSalary != null &&
|
|
|
|
|
posMaster.next_holder.profileSalary.length > 0
|
|
|
|
|
) {
|
|
|
|
|
let _salary: any = posMaster.next_holder.profileSalary.sort(
|
2024-04-11 16:33:06 +07:00
|
|
|
(a, b) =>
|
|
|
|
|
(b.date == null ? 0 : b.date.getTime()) -
|
|
|
|
|
(a.date == null ? 0 : a.date.getTime()),
|
2024-04-09 14:32:30 +07:00
|
|
|
);
|
|
|
|
|
if (_salary.length > 0) {
|
|
|
|
|
salary = _salary[0];
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-02-12 14:43:38 +07:00
|
|
|
|
|
|
|
|
let node = {
|
2024-04-02 09:51:29 +07:00
|
|
|
orgTreeName: orgChild2.orgChild2Name,
|
|
|
|
|
orgTreeShortName: orgChild2.orgChild2ShortName,
|
2024-02-12 14:43:38 +07:00
|
|
|
posMasterNo: posMaster.posMasterNo,
|
|
|
|
|
positionName:
|
|
|
|
|
posMaster.isSit == false
|
|
|
|
|
? posMaster.positions.find((x: any) => x.positionIsSelected == true)
|
|
|
|
|
?.positionName
|
|
|
|
|
: posMaster.next_holder.position,
|
|
|
|
|
posType:
|
|
|
|
|
posMaster.isSit == false
|
|
|
|
|
? posMaster.positions.find((x: any) => x.positionIsSelected == true)
|
|
|
|
|
?.posType?.posTypeName
|
|
|
|
|
: posMaster.next_holder.posType == null
|
|
|
|
|
? "-"
|
|
|
|
|
: posMaster.next_holder.posType.posTypeName,
|
|
|
|
|
posLevel:
|
|
|
|
|
posMaster.isSit == false
|
|
|
|
|
? posMaster.positions.find((x: any) => x.positionIsSelected == true)
|
|
|
|
|
?.posLevel?.posLevelName
|
|
|
|
|
: posMaster.next_holder.posLevel == null
|
|
|
|
|
? "-"
|
|
|
|
|
: posMaster.next_holder.posLevel.posLevelName,
|
|
|
|
|
posExecutive:
|
|
|
|
|
posMaster.isSit == false
|
|
|
|
|
? posMaster.positions.find((x: any) => x.positionIsSelected == true)
|
|
|
|
|
?.posExecutive?.posExecutiveName
|
|
|
|
|
: positionMasterProfileOld == null
|
|
|
|
|
? "-"
|
|
|
|
|
: positionMasterProfileOld.positions.find(
|
|
|
|
|
(x: any) => x.positionIsSelected == true,
|
|
|
|
|
)?.posExecutive?.posExecutiveName,
|
|
|
|
|
profileFullname: `${posMaster.next_holder.prefix}${posMaster.next_holder.firstName} ${posMaster.next_holder.lastName}`,
|
2024-04-09 14:32:30 +07:00
|
|
|
education: education == "" ? "" : education.degree,
|
|
|
|
|
salary: salary == "" ? "" : salary.amount,
|
|
|
|
|
positionSalaryAmount: salary == "" ? "" : salary.positionSalaryAmount,
|
|
|
|
|
mouthSalaryAmount: salary == "" ? "" : salary.mouthSalaryAmount,
|
|
|
|
|
reason: posMaster.reason == null ? "" : posMaster.reason,
|
2024-02-12 14:43:38 +07:00
|
|
|
};
|
|
|
|
|
if (_node == null) {
|
|
|
|
|
const head = {
|
2024-06-07 15:40:33 +07:00
|
|
|
posMasterNo: Extension.ToThaiNumber(node.orgTreeShortName.toString()),
|
2024-02-12 14:43:38 +07:00
|
|
|
profileFullname: "",
|
2024-06-07 15:40:33 +07:00
|
|
|
posExecutive: Extension.ToThaiNumber(node.orgTreeName.toString()),
|
2024-02-12 14:43:38 +07:00
|
|
|
positionName: "",
|
|
|
|
|
posType: "",
|
|
|
|
|
posLevel: "",
|
2024-02-13 09:59:10 +07:00
|
|
|
education: "",
|
|
|
|
|
salary: "",
|
|
|
|
|
positionSalaryAmount: "",
|
|
|
|
|
mouthSalaryAmount: "",
|
|
|
|
|
reason: "",
|
2024-02-12 14:43:38 +07:00
|
|
|
};
|
|
|
|
|
data.push(head);
|
|
|
|
|
const _head = {
|
2024-04-09 14:32:30 +07:00
|
|
|
no: Extension.ToThaiNumber(no.toString()),
|
2024-04-09 12:18:52 +07:00
|
|
|
posMasterNo:
|
|
|
|
|
node.posMasterNo == null
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.posMasterNo.toString()),
|
2024-06-07 15:40:33 +07:00
|
|
|
profileFullname:
|
|
|
|
|
node.profileFullname == null
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.profileFullname.toString()),
|
2024-02-12 14:43:38 +07:00
|
|
|
posExecutive: node.posExecutive,
|
2024-06-07 15:40:33 +07:00
|
|
|
positionName:
|
|
|
|
|
node.positionName == null
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.positionName.toString()),
|
|
|
|
|
posType:
|
|
|
|
|
node.posType == null ? "" : Extension.ToThaiNumber(node.posType.toString()),
|
|
|
|
|
posLevel:
|
|
|
|
|
node.posLevel == null
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.posLevel.toString()),
|
|
|
|
|
education:
|
|
|
|
|
node.education == null
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.education.toString()),
|
2024-07-04 00:11:06 +07:00
|
|
|
salary: node.salary
|
|
|
|
|
? Extension.ToThaiNumber(node.salary.toLocaleString())
|
|
|
|
|
: "",
|
|
|
|
|
positionSalaryAmount: node.positionSalaryAmount
|
|
|
|
|
? Extension.ToThaiNumber(node.positionSalaryAmount.toLocaleString())
|
|
|
|
|
: "",
|
|
|
|
|
mouthSalaryAmount: node.mouthSalaryAmount
|
|
|
|
|
? Extension.ToThaiNumber(node.mouthSalaryAmount.toLocaleString())
|
|
|
|
|
: "",
|
2024-06-07 15:40:33 +07:00
|
|
|
reason:
|
|
|
|
|
node.reason == null ? "" : Extension.ToThaiNumber(node.reason.toString()),
|
2024-02-12 14:43:38 +07:00
|
|
|
};
|
|
|
|
|
data.push(_head);
|
|
|
|
|
} else {
|
|
|
|
|
if (
|
|
|
|
|
node.orgTreeShortName != _node.orgTreeShortName ||
|
|
|
|
|
node.orgTreeName != _node.orgTreeName
|
|
|
|
|
) {
|
|
|
|
|
const head = {
|
|
|
|
|
posMasterNo:
|
|
|
|
|
node.orgTreeShortName == _node.orgTreeShortName
|
|
|
|
|
? ""
|
|
|
|
|
: node.orgTreeShortName,
|
|
|
|
|
profileFullname: "",
|
|
|
|
|
posExecutive: node.orgTreeName == _node.orgTreeName ? "" : node.orgTreeName,
|
|
|
|
|
positionName: "",
|
|
|
|
|
posType: "",
|
|
|
|
|
posLevel: "",
|
2024-02-13 09:59:10 +07:00
|
|
|
education: "",
|
|
|
|
|
salary: "",
|
|
|
|
|
positionSalaryAmount: "",
|
|
|
|
|
mouthSalaryAmount: "",
|
|
|
|
|
reason: "",
|
2024-02-12 14:43:38 +07:00
|
|
|
};
|
|
|
|
|
data.push(head);
|
|
|
|
|
_node == null;
|
|
|
|
|
}
|
|
|
|
|
const head = {
|
2024-04-09 14:32:30 +07:00
|
|
|
no: Extension.ToThaiNumber(no.toString()),
|
2024-04-09 12:18:52 +07:00
|
|
|
posMasterNo:
|
|
|
|
|
node.posMasterNo == null
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.posMasterNo.toString()),
|
2024-06-07 15:40:33 +07:00
|
|
|
profileFullname:
|
|
|
|
|
node.profileFullname == null
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.profileFullname.toString()),
|
2024-02-12 14:43:38 +07:00
|
|
|
posExecutive:
|
|
|
|
|
node.posExecutive == _node.posExecutive ? "" : node.posExecutive,
|
2024-06-07 15:40:33 +07:00
|
|
|
positionName:
|
|
|
|
|
node.positionName == null
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.positionName.toString()),
|
|
|
|
|
posType:
|
|
|
|
|
node.posType == null ? "" : Extension.ToThaiNumber(node.posType.toString()),
|
|
|
|
|
posLevel:
|
|
|
|
|
node.posLevel == null
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.posLevel.toString()),
|
|
|
|
|
education:
|
|
|
|
|
node.education == null
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.education.toString()),
|
2024-07-04 00:11:06 +07:00
|
|
|
salary: node.salary
|
|
|
|
|
? Extension.ToThaiNumber(node.salary.toLocaleString())
|
|
|
|
|
: "",
|
|
|
|
|
positionSalaryAmount: node.positionSalaryAmount
|
|
|
|
|
? Extension.ToThaiNumber(node.positionSalaryAmount.toLocaleString())
|
|
|
|
|
: "",
|
|
|
|
|
mouthSalaryAmount: node.mouthSalaryAmount
|
|
|
|
|
? Extension.ToThaiNumber(node.mouthSalaryAmount.toLocaleString())
|
|
|
|
|
: "",
|
2024-06-07 15:40:33 +07:00
|
|
|
reason:
|
|
|
|
|
node.reason == null ? "" : Extension.ToThaiNumber(node.reason.toString()),
|
2024-02-12 14:43:38 +07:00
|
|
|
};
|
|
|
|
|
data.push(head);
|
|
|
|
|
}
|
|
|
|
|
no += 1;
|
|
|
|
|
_node = node;
|
|
|
|
|
}
|
|
|
|
|
}),
|
|
|
|
|
);
|
|
|
|
|
_node = null;
|
|
|
|
|
|
2024-04-02 09:51:29 +07:00
|
|
|
for (let orgChild3 of orgChild3Data.filter(
|
|
|
|
|
(orgChild3) => orgChild3.orgChild2Id === orgChild2.id,
|
2024-02-12 14:43:38 +07:00
|
|
|
)) {
|
|
|
|
|
await Promise.all(
|
2024-04-02 09:51:29 +07:00
|
|
|
orgChild3.posMasters
|
2024-02-12 14:43:38 +07:00
|
|
|
.sort((a, b) => a.posMasterOrder - b.posMasterOrder)
|
|
|
|
|
.map(async (posMaster) => {
|
2024-04-02 09:51:29 +07:00
|
|
|
if (posMaster.orgChild4Id == null && posMaster.next_holder != null) {
|
2024-02-12 14:43:38 +07:00
|
|
|
let positionMasterProfileOld: any = null;
|
|
|
|
|
if (posMaster.next_holder != null) {
|
|
|
|
|
positionMasterProfileOld = posMaster.next_holder.current_holders.find(
|
|
|
|
|
(x) => x.orgRevisionId == orgRevisionActive.id,
|
|
|
|
|
);
|
|
|
|
|
}
|
2024-04-09 14:32:30 +07:00
|
|
|
let education: any = "";
|
|
|
|
|
if (
|
|
|
|
|
posMaster.next_holder != null &&
|
|
|
|
|
posMaster.next_holder.profileEducations != null &&
|
|
|
|
|
posMaster.next_holder.profileEducations.length > 0
|
|
|
|
|
) {
|
|
|
|
|
let _education: any = posMaster.next_holder.profileEducations.sort(
|
2024-04-11 16:33:06 +07:00
|
|
|
(a, b) =>
|
|
|
|
|
(b.finishDate == null ? 0 : b.finishDate.getTime()) -
|
|
|
|
|
(a.finishDate == null ? 0 : a.finishDate.getTime()),
|
2024-04-09 14:32:30 +07:00
|
|
|
);
|
|
|
|
|
if (_education.length > 0) {
|
|
|
|
|
education = _education[0];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
let salary: any = "";
|
|
|
|
|
if (
|
|
|
|
|
posMaster.next_holder != null &&
|
|
|
|
|
posMaster.next_holder.profileSalary != null &&
|
|
|
|
|
posMaster.next_holder.profileSalary.length > 0
|
|
|
|
|
) {
|
|
|
|
|
let _salary: any = posMaster.next_holder.profileSalary.sort(
|
2024-04-11 16:33:06 +07:00
|
|
|
(a, b) =>
|
|
|
|
|
(b.date == null ? 0 : b.date.getTime()) -
|
|
|
|
|
(a.date == null ? 0 : a.date.getTime()),
|
2024-04-09 14:32:30 +07:00
|
|
|
);
|
|
|
|
|
if (_salary.length > 0) {
|
|
|
|
|
salary = _salary[0];
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-02-12 14:43:38 +07:00
|
|
|
|
|
|
|
|
let node = {
|
2024-04-02 09:51:29 +07:00
|
|
|
orgTreeName: orgChild3.orgChild3Name,
|
|
|
|
|
orgTreeShortName: orgChild3.orgChild3ShortName,
|
2024-02-12 14:43:38 +07:00
|
|
|
posMasterNo: posMaster.posMasterNo,
|
|
|
|
|
positionName:
|
|
|
|
|
posMaster.isSit == false
|
|
|
|
|
? posMaster.positions.find((x: any) => x.positionIsSelected == true)
|
|
|
|
|
?.positionName
|
|
|
|
|
: posMaster.next_holder.position,
|
|
|
|
|
posType:
|
|
|
|
|
posMaster.isSit == false
|
|
|
|
|
? posMaster.positions.find((x: any) => x.positionIsSelected == true)
|
|
|
|
|
?.posType?.posTypeName
|
|
|
|
|
: posMaster.next_holder.posType == null
|
|
|
|
|
? "-"
|
|
|
|
|
: posMaster.next_holder.posType.posTypeName,
|
|
|
|
|
posLevel:
|
|
|
|
|
posMaster.isSit == false
|
|
|
|
|
? posMaster.positions.find((x: any) => x.positionIsSelected == true)
|
|
|
|
|
?.posLevel?.posLevelName
|
|
|
|
|
: posMaster.next_holder.posLevel == null
|
|
|
|
|
? "-"
|
|
|
|
|
: posMaster.next_holder.posLevel.posLevelName,
|
|
|
|
|
posExecutive:
|
|
|
|
|
posMaster.isSit == false
|
|
|
|
|
? posMaster.positions.find((x: any) => x.positionIsSelected == true)
|
|
|
|
|
?.posExecutive?.posExecutiveName
|
|
|
|
|
: positionMasterProfileOld == null
|
|
|
|
|
? "-"
|
|
|
|
|
: positionMasterProfileOld.positions.find(
|
|
|
|
|
(x: any) => x.positionIsSelected == true,
|
|
|
|
|
)?.posExecutive?.posExecutiveName,
|
|
|
|
|
profileFullname: `${posMaster.next_holder.prefix}${posMaster.next_holder.firstName} ${posMaster.next_holder.lastName}`,
|
2024-04-09 14:32:30 +07:00
|
|
|
education: education == "" ? "" : education.degree,
|
|
|
|
|
salary: salary == "" ? "" : salary.amount,
|
|
|
|
|
positionSalaryAmount: salary == "" ? "" : salary.positionSalaryAmount,
|
|
|
|
|
mouthSalaryAmount: salary == "" ? "" : salary.mouthSalaryAmount,
|
|
|
|
|
reason: posMaster.reason == null ? "" : posMaster.reason,
|
2024-02-12 14:43:38 +07:00
|
|
|
};
|
|
|
|
|
if (_node == null) {
|
|
|
|
|
const head = {
|
2024-06-07 15:40:33 +07:00
|
|
|
posMasterNo: Extension.ToThaiNumber(node.orgTreeShortName.toString()),
|
2024-02-12 14:43:38 +07:00
|
|
|
profileFullname: "",
|
2024-06-07 15:40:33 +07:00
|
|
|
posExecutive: Extension.ToThaiNumber(node.orgTreeName.toString()),
|
2024-02-12 14:43:38 +07:00
|
|
|
positionName: "",
|
|
|
|
|
posType: "",
|
|
|
|
|
posLevel: "",
|
2024-02-13 09:59:10 +07:00
|
|
|
education: "",
|
|
|
|
|
salary: "",
|
|
|
|
|
positionSalaryAmount: "",
|
|
|
|
|
mouthSalaryAmount: "",
|
|
|
|
|
reason: "",
|
2024-02-12 14:43:38 +07:00
|
|
|
};
|
|
|
|
|
data.push(head);
|
|
|
|
|
const _head = {
|
2024-04-09 14:32:30 +07:00
|
|
|
no: Extension.ToThaiNumber(no.toString()),
|
2024-04-09 12:18:52 +07:00
|
|
|
posMasterNo:
|
|
|
|
|
node.posMasterNo == null
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.posMasterNo.toString()),
|
2024-06-07 15:40:33 +07:00
|
|
|
profileFullname:
|
|
|
|
|
node.profileFullname == null
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.profileFullname.toString()),
|
2024-02-12 14:43:38 +07:00
|
|
|
posExecutive: node.posExecutive,
|
2024-06-07 15:40:33 +07:00
|
|
|
positionName:
|
|
|
|
|
node.positionName == null
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.positionName.toString()),
|
|
|
|
|
posType:
|
|
|
|
|
node.posType == null
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.posType.toString()),
|
|
|
|
|
posLevel:
|
|
|
|
|
node.posLevel == null
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.posLevel.toString()),
|
|
|
|
|
education:
|
|
|
|
|
node.education == null
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.education.toString()),
|
2024-07-04 00:11:06 +07:00
|
|
|
salary: node.salary
|
|
|
|
|
? Extension.ToThaiNumber(node.salary.toLocaleString())
|
|
|
|
|
: "",
|
|
|
|
|
positionSalaryAmount: node.positionSalaryAmount
|
|
|
|
|
? Extension.ToThaiNumber(node.positionSalaryAmount.toLocaleString())
|
|
|
|
|
: "",
|
|
|
|
|
mouthSalaryAmount: node.mouthSalaryAmount
|
|
|
|
|
? Extension.ToThaiNumber(node.mouthSalaryAmount.toLocaleString())
|
|
|
|
|
: "",
|
2024-06-07 15:40:33 +07:00
|
|
|
reason:
|
|
|
|
|
node.reason == null ? "" : Extension.ToThaiNumber(node.reason.toString()),
|
2024-02-12 14:43:38 +07:00
|
|
|
};
|
|
|
|
|
data.push(_head);
|
|
|
|
|
} else {
|
|
|
|
|
if (
|
|
|
|
|
node.orgTreeShortName != _node.orgTreeShortName ||
|
|
|
|
|
node.orgTreeName != _node.orgTreeName
|
|
|
|
|
) {
|
|
|
|
|
const head = {
|
|
|
|
|
posMasterNo:
|
|
|
|
|
node.orgTreeShortName == _node.orgTreeShortName
|
|
|
|
|
? ""
|
|
|
|
|
: node.orgTreeShortName,
|
|
|
|
|
profileFullname: "",
|
|
|
|
|
posExecutive:
|
|
|
|
|
node.orgTreeName == _node.orgTreeName ? "" : node.orgTreeName,
|
|
|
|
|
positionName: "",
|
|
|
|
|
posType: "",
|
|
|
|
|
posLevel: "",
|
2024-02-13 09:59:10 +07:00
|
|
|
education: "",
|
|
|
|
|
salary: "",
|
|
|
|
|
positionSalaryAmount: "",
|
|
|
|
|
mouthSalaryAmount: "",
|
|
|
|
|
reason: "",
|
2024-02-12 14:43:38 +07:00
|
|
|
};
|
|
|
|
|
data.push(head);
|
|
|
|
|
_node == null;
|
|
|
|
|
}
|
|
|
|
|
const head = {
|
2024-04-09 14:32:30 +07:00
|
|
|
no: Extension.ToThaiNumber(no.toString()),
|
2024-04-09 12:18:52 +07:00
|
|
|
posMasterNo:
|
|
|
|
|
node.posMasterNo == null
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.posMasterNo.toString()),
|
2024-06-07 15:40:33 +07:00
|
|
|
profileFullname:
|
|
|
|
|
node.profileFullname == null
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.profileFullname.toString()),
|
2024-02-12 14:43:38 +07:00
|
|
|
posExecutive:
|
|
|
|
|
node.posExecutive == _node.posExecutive ? "" : node.posExecutive,
|
2024-06-07 15:40:33 +07:00
|
|
|
positionName:
|
|
|
|
|
node.positionName == null
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.positionName.toString()),
|
|
|
|
|
posType:
|
|
|
|
|
node.posType == null
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.posType.toString()),
|
|
|
|
|
posLevel:
|
|
|
|
|
node.posLevel == null
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.posLevel.toString()),
|
|
|
|
|
education:
|
|
|
|
|
node.education == null
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.education.toString()),
|
2024-07-04 00:11:06 +07:00
|
|
|
salary: node.salary
|
|
|
|
|
? Extension.ToThaiNumber(node.salary.toLocaleString())
|
|
|
|
|
: "",
|
|
|
|
|
positionSalaryAmount: node.positionSalaryAmount
|
|
|
|
|
? Extension.ToThaiNumber(node.positionSalaryAmount.toLocaleString())
|
|
|
|
|
: "",
|
|
|
|
|
mouthSalaryAmount: node.mouthSalaryAmount
|
|
|
|
|
? Extension.ToThaiNumber(node.mouthSalaryAmount.toLocaleString())
|
|
|
|
|
: "",
|
2024-06-07 15:40:33 +07:00
|
|
|
reason:
|
|
|
|
|
node.reason == null ? "" : Extension.ToThaiNumber(node.reason.toString()),
|
2024-02-12 14:43:38 +07:00
|
|
|
};
|
|
|
|
|
data.push(head);
|
|
|
|
|
}
|
|
|
|
|
no += 1;
|
|
|
|
|
_node = node;
|
|
|
|
|
}
|
|
|
|
|
}),
|
|
|
|
|
);
|
|
|
|
|
_node = null;
|
|
|
|
|
|
2024-04-02 09:51:29 +07:00
|
|
|
for (let orgChild4 of orgChild4Data.filter(
|
|
|
|
|
(orgChild4) => orgChild4.orgChild3Id === orgChild3.id,
|
2024-02-12 14:43:38 +07:00
|
|
|
)) {
|
|
|
|
|
await Promise.all(
|
2024-04-02 09:51:29 +07:00
|
|
|
orgChild4.posMasters
|
2024-02-12 14:43:38 +07:00
|
|
|
.sort((a, b) => a.posMasterOrder - b.posMasterOrder)
|
|
|
|
|
.map(async (posMaster) => {
|
2024-04-02 09:51:29 +07:00
|
|
|
if (posMaster.next_holder != null) {
|
2024-02-07 21:20:04 +07:00
|
|
|
let positionMasterProfileOld: any = null;
|
|
|
|
|
if (posMaster.next_holder != null) {
|
|
|
|
|
positionMasterProfileOld = posMaster.next_holder.current_holders.find(
|
|
|
|
|
(x) => x.orgRevisionId == orgRevisionActive.id,
|
|
|
|
|
);
|
|
|
|
|
}
|
2024-04-09 14:32:30 +07:00
|
|
|
let education: any = "";
|
|
|
|
|
if (
|
|
|
|
|
posMaster.next_holder != null &&
|
|
|
|
|
posMaster.next_holder.profileEducations != null &&
|
|
|
|
|
posMaster.next_holder.profileEducations.length > 0
|
|
|
|
|
) {
|
|
|
|
|
let _education: any = posMaster.next_holder.profileEducations.sort(
|
2024-04-11 16:33:06 +07:00
|
|
|
(a, b) =>
|
|
|
|
|
b.finishDate == null
|
|
|
|
|
? 0
|
|
|
|
|
: (b.finishDate == null ? 0 : b.finishDate.getTime()) -
|
|
|
|
|
(a.finishDate == null ? 0 : a.finishDate.getTime()),
|
2024-04-09 14:32:30 +07:00
|
|
|
);
|
|
|
|
|
if (_education.length > 0) {
|
|
|
|
|
education = _education[0];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
let salary: any = "";
|
|
|
|
|
if (
|
|
|
|
|
posMaster.next_holder != null &&
|
|
|
|
|
posMaster.next_holder.profileSalary != null &&
|
|
|
|
|
posMaster.next_holder.profileSalary.length > 0
|
|
|
|
|
) {
|
|
|
|
|
let _salary: any = posMaster.next_holder.profileSalary.sort(
|
2024-04-11 16:33:06 +07:00
|
|
|
(a, b) =>
|
|
|
|
|
(b.date == null ? 0 : b.date.getTime()) -
|
|
|
|
|
(a.date == null ? 0 : a.date.getTime()),
|
2024-04-09 14:32:30 +07:00
|
|
|
);
|
|
|
|
|
if (_salary.length > 0) {
|
|
|
|
|
salary = _salary[0];
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-02-07 21:20:04 +07:00
|
|
|
|
|
|
|
|
let node = {
|
2024-04-02 09:51:29 +07:00
|
|
|
orgTreeName: orgChild4.orgChild4Name,
|
|
|
|
|
orgTreeShortName: orgChild4.orgChild4ShortName,
|
2024-02-07 21:20:04 +07:00
|
|
|
posMasterNo: posMaster.posMasterNo,
|
|
|
|
|
positionName:
|
2024-02-12 14:43:38 +07:00
|
|
|
posMaster.isSit == false
|
|
|
|
|
? posMaster.positions.find((x: any) => x.positionIsSelected == true)
|
|
|
|
|
?.positionName
|
2024-02-07 21:20:04 +07:00
|
|
|
: posMaster.next_holder.position,
|
2024-02-12 14:43:38 +07:00
|
|
|
posType:
|
|
|
|
|
posMaster.isSit == false
|
|
|
|
|
? posMaster.positions.find((x: any) => x.positionIsSelected == true)
|
|
|
|
|
?.posType?.posTypeName
|
2024-02-07 21:20:04 +07:00
|
|
|
: posMaster.next_holder.posType == null
|
2024-02-08 19:46:18 +07:00
|
|
|
? "-"
|
2024-02-07 21:20:04 +07:00
|
|
|
: posMaster.next_holder.posType.posTypeName,
|
2024-02-12 14:43:38 +07:00
|
|
|
posLevel:
|
|
|
|
|
posMaster.isSit == false
|
|
|
|
|
? posMaster.positions.find((x: any) => x.positionIsSelected == true)
|
|
|
|
|
?.posLevel?.posLevelName
|
2024-02-07 21:20:04 +07:00
|
|
|
: posMaster.next_holder.posLevel == null
|
2024-02-08 19:46:18 +07:00
|
|
|
? "-"
|
2024-02-07 21:20:04 +07:00
|
|
|
: posMaster.next_holder.posLevel.posLevelName,
|
2024-02-12 14:43:38 +07:00
|
|
|
posExecutive:
|
|
|
|
|
posMaster.isSit == false
|
|
|
|
|
? posMaster.positions.find((x: any) => x.positionIsSelected == true)
|
|
|
|
|
?.posExecutive?.posExecutiveName
|
2024-02-07 21:20:04 +07:00
|
|
|
: positionMasterProfileOld == null
|
2024-02-08 19:46:18 +07:00
|
|
|
? "-"
|
2024-02-07 21:20:04 +07:00
|
|
|
: positionMasterProfileOld.positions.find(
|
2024-02-11 22:30:12 +07:00
|
|
|
(x: any) => x.positionIsSelected == true,
|
2024-02-07 21:20:04 +07:00
|
|
|
)?.posExecutive?.posExecutiveName,
|
2024-02-12 14:43:38 +07:00
|
|
|
profileFullname: `${posMaster.next_holder.prefix}${posMaster.next_holder.firstName} ${posMaster.next_holder.lastName}`,
|
2024-04-09 14:32:30 +07:00
|
|
|
education: education == "" ? "" : education.degree,
|
|
|
|
|
salary: salary == "" ? "" : salary.amount,
|
|
|
|
|
positionSalaryAmount: salary == "" ? "" : salary.positionSalaryAmount,
|
|
|
|
|
mouthSalaryAmount: salary == "" ? "" : salary.mouthSalaryAmount,
|
|
|
|
|
reason: posMaster.reason == null ? "" : posMaster.reason,
|
2024-02-07 21:20:04 +07:00
|
|
|
};
|
2024-02-08 18:04:54 +07:00
|
|
|
if (_node == null) {
|
|
|
|
|
const head = {
|
2024-06-07 15:40:33 +07:00
|
|
|
posMasterNo: Extension.ToThaiNumber(node.orgTreeShortName.toString()),
|
2024-02-12 14:43:38 +07:00
|
|
|
profileFullname: "",
|
2024-06-07 15:40:33 +07:00
|
|
|
posExecutive: Extension.ToThaiNumber(node.orgTreeName.toString()),
|
2024-02-08 18:04:54 +07:00
|
|
|
positionName: "",
|
|
|
|
|
posType: "",
|
|
|
|
|
posLevel: "",
|
2024-02-13 09:59:10 +07:00
|
|
|
education: "",
|
|
|
|
|
salary: "",
|
|
|
|
|
positionSalaryAmount: "",
|
|
|
|
|
mouthSalaryAmount: "",
|
|
|
|
|
reason: "",
|
2024-02-08 18:04:54 +07:00
|
|
|
};
|
|
|
|
|
data.push(head);
|
|
|
|
|
const _head = {
|
2024-04-09 14:32:30 +07:00
|
|
|
no: Extension.ToThaiNumber(no.toString()),
|
2024-04-09 12:18:52 +07:00
|
|
|
posMasterNo:
|
|
|
|
|
node.posMasterNo == null
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.posMasterNo.toString()),
|
2024-06-07 15:40:33 +07:00
|
|
|
profileFullname:
|
|
|
|
|
node.profileFullname == null
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.profileFullname.toString()),
|
2024-02-08 18:04:54 +07:00
|
|
|
posExecutive: node.posExecutive,
|
2024-06-07 15:40:33 +07:00
|
|
|
positionName:
|
|
|
|
|
node.positionName == null
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.positionName.toString()),
|
|
|
|
|
posType:
|
|
|
|
|
node.posType == null
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.posType.toString()),
|
|
|
|
|
posLevel:
|
|
|
|
|
node.posLevel == null
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.posLevel.toString()),
|
|
|
|
|
education:
|
|
|
|
|
node.education == null
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.education.toString()),
|
2024-07-04 00:11:06 +07:00
|
|
|
salary: node.salary
|
|
|
|
|
? Extension.ToThaiNumber(node.salary.toLocaleString())
|
|
|
|
|
: "",
|
|
|
|
|
positionSalaryAmount: node.positionSalaryAmount
|
|
|
|
|
? Extension.ToThaiNumber(node.positionSalaryAmount.toLocaleString())
|
|
|
|
|
: "",
|
|
|
|
|
mouthSalaryAmount: node.mouthSalaryAmount
|
|
|
|
|
? Extension.ToThaiNumber(node.mouthSalaryAmount.toLocaleString())
|
|
|
|
|
: "",
|
2024-06-07 15:40:33 +07:00
|
|
|
reason:
|
|
|
|
|
node.reason == null
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.reason.toString()),
|
2024-02-08 18:04:54 +07:00
|
|
|
};
|
|
|
|
|
data.push(_head);
|
|
|
|
|
} else {
|
|
|
|
|
if (
|
2024-02-08 19:46:18 +07:00
|
|
|
node.orgTreeShortName != _node.orgTreeShortName ||
|
2024-02-12 14:43:38 +07:00
|
|
|
node.orgTreeName != _node.orgTreeName
|
2024-02-08 18:04:54 +07:00
|
|
|
) {
|
|
|
|
|
const head = {
|
|
|
|
|
posMasterNo:
|
|
|
|
|
node.orgTreeShortName == _node.orgTreeShortName
|
|
|
|
|
? ""
|
|
|
|
|
: node.orgTreeShortName,
|
2024-02-12 14:43:38 +07:00
|
|
|
profileFullname: "",
|
2024-02-08 19:46:18 +07:00
|
|
|
posExecutive:
|
2024-02-08 18:04:54 +07:00
|
|
|
node.orgTreeName == _node.orgTreeName ? "" : node.orgTreeName,
|
|
|
|
|
positionName: "",
|
|
|
|
|
posType: "",
|
|
|
|
|
posLevel: "",
|
2024-02-13 09:59:10 +07:00
|
|
|
education: "",
|
|
|
|
|
salary: "",
|
|
|
|
|
positionSalaryAmount: "",
|
|
|
|
|
mouthSalaryAmount: "",
|
|
|
|
|
reason: "",
|
2024-02-08 18:04:54 +07:00
|
|
|
};
|
|
|
|
|
data.push(head);
|
|
|
|
|
_node == null;
|
|
|
|
|
}
|
|
|
|
|
const head = {
|
2024-04-09 14:32:30 +07:00
|
|
|
no: Extension.ToThaiNumber(no.toString()),
|
2024-04-09 12:18:52 +07:00
|
|
|
posMasterNo:
|
|
|
|
|
node.posMasterNo == null
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.posMasterNo.toString()),
|
2024-06-07 15:40:33 +07:00
|
|
|
profileFullname:
|
|
|
|
|
node.profileFullname == null
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.profileFullname.toString()),
|
2024-02-08 18:04:54 +07:00
|
|
|
posExecutive:
|
|
|
|
|
node.posExecutive == _node.posExecutive ? "" : node.posExecutive,
|
2024-06-07 15:40:33 +07:00
|
|
|
positionName:
|
|
|
|
|
node.positionName == null
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.positionName.toString()),
|
|
|
|
|
posType:
|
|
|
|
|
node.posType == null
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.posType.toString()),
|
|
|
|
|
posLevel:
|
|
|
|
|
node.posLevel == null
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.posLevel.toString()),
|
|
|
|
|
education:
|
|
|
|
|
node.education == null
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.education.toString()),
|
2024-07-04 00:11:06 +07:00
|
|
|
salary: node.salary
|
|
|
|
|
? Extension.ToThaiNumber(node.salary.toLocaleString())
|
|
|
|
|
: "",
|
|
|
|
|
positionSalaryAmount: node.positionSalaryAmount
|
|
|
|
|
? Extension.ToThaiNumber(node.positionSalaryAmount.toLocaleString())
|
|
|
|
|
: "",
|
|
|
|
|
mouthSalaryAmount: node.mouthSalaryAmount
|
|
|
|
|
? Extension.ToThaiNumber(node.mouthSalaryAmount.toLocaleString())
|
|
|
|
|
: "",
|
2024-06-07 15:40:33 +07:00
|
|
|
reason:
|
|
|
|
|
node.reason == null
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(node.reason.toString()),
|
2024-02-08 18:04:54 +07:00
|
|
|
};
|
|
|
|
|
data.push(head);
|
2024-02-07 21:20:04 +07:00
|
|
|
}
|
2024-02-08 19:46:18 +07:00
|
|
|
no += 1;
|
2024-02-07 21:20:04 +07:00
|
|
|
_node = node;
|
2024-02-12 14:43:38 +07:00
|
|
|
}
|
|
|
|
|
}),
|
|
|
|
|
);
|
|
|
|
|
_node = null;
|
2024-02-07 21:20:04 +07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-02-07 11:08:55 +07:00
|
|
|
}
|
2024-04-02 09:51:29 +07:00
|
|
|
}
|
|
|
|
|
return new HttpSuccess({ template: "report3", reportName: "report3", data: { data } });
|
2024-02-02 15:49:08 +07:00
|
|
|
}
|
|
|
|
|
}
|