Merge branch 'develop' into dev
All checks were successful
Build & Deploy on Dev / build (push) Successful in 1m3s
All checks were successful
Build & Deploy on Dev / build (push) Successful in 1m3s
* develop: หาคนเกษียณตามปี สิทธิ์ดูโครงสร้าง
This commit is contained in:
commit
ebea25597f
4 changed files with 68 additions and 499 deletions
|
|
@ -42,6 +42,7 @@ import {
|
|||
CreatePosMasterHistoryEmployee,
|
||||
CreatePosMasterHistoryOfficer,
|
||||
} from "../services/PositionService";
|
||||
|
||||
@Route("api/v1/org")
|
||||
@Tags("Organization")
|
||||
@Security("bearerAuth")
|
||||
|
|
@ -1962,34 +1963,41 @@ export class OrganizationController extends Controller {
|
|||
child3: null,
|
||||
child4: null,
|
||||
};
|
||||
let _data1: any = {
|
||||
root: null,
|
||||
};
|
||||
|
||||
const orgRevision = await this.orgRevisionRepository.findOne({ where: { id } });
|
||||
|
||||
if (!orgRevision) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
}
|
||||
let attrOwnership = null;
|
||||
let _privilege = await new permission().PermissionOrgList(request, "SYS_ORG");
|
||||
attrOwnership = _privilege.root == null ? true : false;
|
||||
if (
|
||||
orgRevision.orgRevisionIsDraft == true &&
|
||||
orgRevision.orgRevisionIsCurrent == false &&
|
||||
attrOwnership == false
|
||||
) {
|
||||
const profile = await this.profileRepo.findOne({
|
||||
where: { keycloak: request.user.sub },
|
||||
relations: ["permissionProfiles"],
|
||||
});
|
||||
if (!profile) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ใช้งานในทะเบียนประวัติ");
|
||||
const attrOwnership = _privilege.root === null ? true : false;
|
||||
|
||||
const profile = await this.profileRepo.findOne({
|
||||
where: { keycloak: request.user.sub },
|
||||
relations: ["permissionProfiles", "current_holders", "current_holders.posMasterAssigns"],
|
||||
});
|
||||
if (!profile) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ใช้งานในทะเบียนประวัติ");
|
||||
}
|
||||
let profileAssign = profile.current_holders
|
||||
?.find((x) => x.orgRevisionId === id)
|
||||
?.posMasterAssigns.find((x) => x.assignId === "SYS_ORG");
|
||||
|
||||
if (orgRevision.orgRevisionIsDraft && !orgRevision.orgRevisionIsCurrent && !attrOwnership) {
|
||||
_data.root = profile.permissionProfiles.map((x) => x.orgRootId);
|
||||
}
|
||||
// กำหนดการเข้าถึงข้อมูลตามสถานะและสิทธิ์
|
||||
const isCurrentActive = !orgRevision.orgRevisionIsDraft && orgRevision.orgRevisionIsCurrent;
|
||||
|
||||
if (isCurrentActive) {
|
||||
if (profileAssign) {
|
||||
_data.root = [profile.current_holders.find((x) => x.orgRevisionId === id)?.orgRootId];
|
||||
} else {
|
||||
if (!attrOwnership) _data = _privilege;
|
||||
}
|
||||
_data = {
|
||||
root: profile.permissionProfiles.map((x) => x.orgRootId),
|
||||
child1: null,
|
||||
child2: null,
|
||||
child3: null,
|
||||
child4: null,
|
||||
};
|
||||
}
|
||||
|
||||
const _revision = await this.orgRevisionRepository.findOne({
|
||||
|
|
@ -2001,8 +2009,8 @@ export class OrganizationController extends Controller {
|
|||
.createQueryBuilder("orgRoot")
|
||||
.where("orgRoot.orgRevisionId = :id", { id })
|
||||
.andWhere(
|
||||
_data.root != undefined && _data.root != null
|
||||
? _data.root[0] != null
|
||||
_data.root !== undefined && _data.root !== null
|
||||
? _data.root[0] !== null
|
||||
? `orgRoot.id IN (:...node)`
|
||||
: `orgRoot.id is null`
|
||||
: "1=1",
|
||||
|
|
@ -2040,8 +2048,8 @@ export class OrganizationController extends Controller {
|
|||
.createQueryBuilder("orgChild1")
|
||||
.where("orgChild1.orgRootId IN (:...ids)", { ids: orgRootIds })
|
||||
.andWhere(
|
||||
_data.child1 != undefined && _data.child1 != null
|
||||
? _data.child1[0] != null
|
||||
_data.child1 !== undefined && _data.child1 !== null
|
||||
? _data.child1[0] !== null
|
||||
? `orgChild1.id IN (:...node)`
|
||||
: `orgChild1.id is null`
|
||||
: "1=1",
|
||||
|
|
@ -2081,8 +2089,8 @@ export class OrganizationController extends Controller {
|
|||
.createQueryBuilder("orgChild2")
|
||||
.where("orgChild2.orgChild1Id IN (:...ids)", { ids: orgChild1Ids })
|
||||
.andWhere(
|
||||
_data.child2 != undefined && _data.child2 != null
|
||||
? _data.child2[0] != null
|
||||
_data.child2 !== undefined && _data.child2 !== null
|
||||
? _data.child2[0] !== null
|
||||
? `orgChild2.id IN (:...node)`
|
||||
: `orgChild2.id is null`
|
||||
: "1=1",
|
||||
|
|
@ -2121,8 +2129,8 @@ export class OrganizationController extends Controller {
|
|||
.createQueryBuilder("orgChild3")
|
||||
.where("orgChild3.orgChild2Id IN (:...ids)", { ids: orgChild2Ids })
|
||||
.andWhere(
|
||||
_data.child3 != undefined && _data.child3 != null
|
||||
? _data.child3[0] != null
|
||||
_data.child3 !== undefined && _data.child3 !== null
|
||||
? _data.child3[0] !== null
|
||||
? `orgChild3.id IN (:...node)`
|
||||
: `orgChild3.id is null`
|
||||
: "1=1",
|
||||
|
|
@ -2161,8 +2169,8 @@ export class OrganizationController extends Controller {
|
|||
.createQueryBuilder("orgChild4")
|
||||
.where("orgChild4.orgChild3Id IN (:...ids)", { ids: orgChild3Ids })
|
||||
.andWhere(
|
||||
_data.child4 != undefined && _data.child4 != null
|
||||
? _data.child4[0] != null
|
||||
_data.child4 !== undefined && _data.child4 !== null
|
||||
? _data.child4[0] !== null
|
||||
? `orgChild4.id IN (:...node)`
|
||||
: `orgChild4.id is null`
|
||||
: "1=1",
|
||||
|
|
@ -2194,7 +2202,6 @@ export class OrganizationController extends Controller {
|
|||
.getMany()
|
||||
: [];
|
||||
|
||||
// const formattedData = orgRootData.map((orgRoot) => {
|
||||
const formattedData = await Promise.all(
|
||||
orgRootData.map(async (orgRoot) => {
|
||||
return {
|
||||
|
|
@ -2223,91 +2230,6 @@ export class OrganizationController extends Controller {
|
|||
responsibility: orgRoot.responsibility,
|
||||
labelName:
|
||||
orgRoot.orgRootName + " " + orgRoot.orgRootCode + "00" + " " + orgRoot.orgRootShortName,
|
||||
// totalPosition: await this.posMasterRepository.count({
|
||||
// where: { orgRevisionId: orgRoot.orgRevisionId, orgRootId: orgRoot.id },
|
||||
// }),
|
||||
// totalPositionCurrentUse: await this.posMasterRepository.count({
|
||||
// where: {
|
||||
// orgRevisionId: orgRoot.orgRevisionId,
|
||||
// orgRootId: orgRoot.id,
|
||||
// current_holderId: Not(IsNull()) || Not(""),
|
||||
// },
|
||||
// }),
|
||||
// totalPositionCurrentVacant: await this.posMasterRepository.count({
|
||||
// where: {
|
||||
// orgRevisionId: orgRoot.orgRevisionId,
|
||||
// orgRootId: orgRoot.id,
|
||||
// current_holderId: IsNull() || "",
|
||||
// },
|
||||
// }),
|
||||
// totalPositionNextUse: await this.posMasterRepository.count({
|
||||
// where: {
|
||||
// orgRevisionId: orgRoot.orgRevisionId,
|
||||
// orgRootId: orgRoot.id,
|
||||
// next_holderId: Not(IsNull()) || Not(""),
|
||||
// },
|
||||
// }),
|
||||
// totalPositionNextVacant: await this.posMasterRepository.count({
|
||||
// where: {
|
||||
// orgRevisionId: orgRoot.orgRevisionId,
|
||||
// orgRootId: orgRoot.id,
|
||||
// next_holderId: IsNull() || "",
|
||||
// },
|
||||
// }),
|
||||
// totalRootPosition: await this.posMasterRepository.count({
|
||||
// where: {
|
||||
// orgRevisionId: orgRoot.orgRevisionId,
|
||||
// orgRootId: orgRoot.id,
|
||||
// orgChild1Id: IsNull() || "",
|
||||
// orgChild2Id: IsNull() || "",
|
||||
// orgChild3Id: IsNull() || "",
|
||||
// orgChild4Id: IsNull() || "",
|
||||
// },
|
||||
// }),
|
||||
// totalRootPositionCurrentUse: await this.posMasterRepository.count({
|
||||
// where: {
|
||||
// orgRevisionId: orgRoot.orgRevisionId,
|
||||
// orgRootId: orgRoot.id,
|
||||
// orgChild1Id: IsNull() || "",
|
||||
// orgChild2Id: IsNull() || "",
|
||||
// orgChild3Id: IsNull() || "",
|
||||
// orgChild4Id: IsNull() || "",
|
||||
// current_holderId: Not(IsNull()) || Not(""),
|
||||
// },
|
||||
// }),
|
||||
// totalRootPositionCurrentVacant: await this.posMasterRepository.count({
|
||||
// where: {
|
||||
// orgRevisionId: orgRoot.orgRevisionId,
|
||||
// orgRootId: orgRoot.id,
|
||||
// orgChild1Id: IsNull() || "",
|
||||
// orgChild2Id: IsNull() || "",
|
||||
// orgChild3Id: IsNull() || "",
|
||||
// orgChild4Id: IsNull() || "",
|
||||
// current_holderId: IsNull() || "",
|
||||
// },
|
||||
// }),
|
||||
// totalRootPositionNextUse: await this.posMasterRepository.count({
|
||||
// where: {
|
||||
// orgRevisionId: orgRoot.orgRevisionId,
|
||||
// orgRootId: orgRoot.id,
|
||||
// orgChild1Id: IsNull() || "",
|
||||
// orgChild2Id: IsNull() || "",
|
||||
// orgChild3Id: IsNull() || "",
|
||||
// orgChild4Id: IsNull() || "",
|
||||
// next_holderId: Not(IsNull()) || Not(""),
|
||||
// },
|
||||
// }),
|
||||
// totalRootPositionNextVacant: await this.posMasterRepository.count({
|
||||
// where: {
|
||||
// orgRevisionId: orgRoot.orgRevisionId,
|
||||
// orgRootId: orgRoot.id,
|
||||
// orgChild1Id: IsNull() || "",
|
||||
// orgChild2Id: IsNull() || "",
|
||||
// orgChild3Id: IsNull() || "",
|
||||
// orgChild4Id: IsNull() || "",
|
||||
// next_holderId: IsNull() || "",
|
||||
// },
|
||||
// }),
|
||||
|
||||
children: await Promise.all(
|
||||
orgChild1Data
|
||||
|
|
@ -2352,91 +2274,6 @@ export class OrganizationController extends Controller {
|
|||
"00" +
|
||||
" " +
|
||||
orgRoot.orgRootShortName,
|
||||
// totalPosition: await this.posMasterRepository.count({
|
||||
// where: { orgRevisionId: orgRoot.orgRevisionId, orgChild1Id: orgChild1.id },
|
||||
// }),
|
||||
// totalPositionCurrentUse: await this.posMasterRepository.count({
|
||||
// where: {
|
||||
// orgRevisionId: orgRoot.orgRevisionId,
|
||||
// orgChild1Id: orgChild1.id,
|
||||
// current_holderId: Not(IsNull()) || Not(""),
|
||||
// },
|
||||
// }),
|
||||
// totalPositionCurrentVacant: await this.posMasterRepository.count({
|
||||
// where: {
|
||||
// orgRevisionId: orgRoot.orgRevisionId,
|
||||
// orgChild1Id: orgChild1.id,
|
||||
// current_holderId: IsNull() || "",
|
||||
// },
|
||||
// }),
|
||||
// totalPositionNextUse: await this.posMasterRepository.count({
|
||||
// where: {
|
||||
// orgRevisionId: orgRoot.orgRevisionId,
|
||||
// orgChild1Id: orgChild1.id,
|
||||
// next_holderId: Not(IsNull()) || Not(""),
|
||||
// },
|
||||
// }),
|
||||
// totalPositionNextVacant: await this.posMasterRepository.count({
|
||||
// where: {
|
||||
// orgRevisionId: orgRoot.orgRevisionId,
|
||||
// orgChild1Id: orgChild1.id,
|
||||
// next_holderId: IsNull() || "",
|
||||
// },
|
||||
// }),
|
||||
// totalRootPosition: await this.posMasterRepository.count({
|
||||
// where: {
|
||||
// orgRevisionId: orgRoot.orgRevisionId,
|
||||
// orgRootId: orgRoot.id,
|
||||
// orgChild1Id: orgChild1.id,
|
||||
// orgChild2Id: IsNull() || "",
|
||||
// orgChild3Id: IsNull() || "",
|
||||
// orgChild4Id: IsNull() || "",
|
||||
// },
|
||||
// }),
|
||||
// totalRootPositionCurrentUse: await this.posMasterRepository.count({
|
||||
// where: {
|
||||
// orgRevisionId: orgRoot.orgRevisionId,
|
||||
// orgRootId: orgRoot.id,
|
||||
// orgChild1Id: orgChild1.id,
|
||||
// orgChild2Id: IsNull() || "",
|
||||
// orgChild3Id: IsNull() || "",
|
||||
// orgChild4Id: IsNull() || "",
|
||||
// current_holderId: Not(IsNull()) || Not(""),
|
||||
// },
|
||||
// }),
|
||||
// totalRootPositionCurrentVacant: await this.posMasterRepository.count({
|
||||
// where: {
|
||||
// orgRevisionId: orgRoot.orgRevisionId,
|
||||
// orgRootId: orgRoot.id,
|
||||
// orgChild1Id: orgChild1.id,
|
||||
// orgChild2Id: IsNull() || "",
|
||||
// orgChild3Id: IsNull() || "",
|
||||
// orgChild4Id: IsNull() || "",
|
||||
// current_holderId: IsNull() || "",
|
||||
// },
|
||||
// }),
|
||||
// totalRootPositionNextUse: await this.posMasterRepository.count({
|
||||
// where: {
|
||||
// orgRevisionId: orgRoot.orgRevisionId,
|
||||
// orgRootId: orgRoot.id,
|
||||
// orgChild1Id: orgChild1.id,
|
||||
// orgChild2Id: IsNull() || "",
|
||||
// orgChild3Id: IsNull() || "",
|
||||
// orgChild4Id: IsNull() || "",
|
||||
// next_holderId: Not(IsNull()) || Not(""),
|
||||
// },
|
||||
// }),
|
||||
// totalRootPositionNextVacant: await this.posMasterRepository.count({
|
||||
// where: {
|
||||
// orgRevisionId: orgRoot.orgRevisionId,
|
||||
// orgRootId: orgRoot.id,
|
||||
// orgChild1Id: orgChild1.id,
|
||||
// orgChild2Id: IsNull() || "",
|
||||
// orgChild3Id: IsNull() || "",
|
||||
// orgChild4Id: IsNull() || "",
|
||||
// next_holderId: IsNull() || "",
|
||||
// },
|
||||
// }),
|
||||
|
||||
children: await Promise.all(
|
||||
orgChild2Data
|
||||
|
|
@ -2486,94 +2323,6 @@ export class OrganizationController extends Controller {
|
|||
"00" +
|
||||
" " +
|
||||
orgRoot.orgRootShortName,
|
||||
// totalPosition: await this.posMasterRepository.count({
|
||||
// where: {
|
||||
// orgRevisionId: orgRoot.orgRevisionId,
|
||||
// orgChild2Id: orgChild2.id,
|
||||
// },
|
||||
// }),
|
||||
// totalPositionCurrentUse: await this.posMasterRepository.count({
|
||||
// where: {
|
||||
// orgRevisionId: orgRoot.orgRevisionId,
|
||||
// orgChild2Id: orgChild2.id,
|
||||
// current_holderId: Not(IsNull()) || Not(""),
|
||||
// },
|
||||
// }),
|
||||
// totalPositionCurrentVacant: await this.posMasterRepository.count({
|
||||
// where: {
|
||||
// orgRevisionId: orgRoot.orgRevisionId,
|
||||
// orgChild2Id: orgChild2.id,
|
||||
// current_holderId: IsNull() || "",
|
||||
// },
|
||||
// }),
|
||||
// totalPositionNextUse: await this.posMasterRepository.count({
|
||||
// where: {
|
||||
// orgRevisionId: orgRoot.orgRevisionId,
|
||||
// orgChild2Id: orgChild2.id,
|
||||
// next_holderId: Not(IsNull()) || Not(""),
|
||||
// },
|
||||
// }),
|
||||
// totalPositionNextVacant: await this.posMasterRepository.count({
|
||||
// where: {
|
||||
// orgRevisionId: orgRoot.orgRevisionId,
|
||||
// orgChild2Id: orgChild2.id,
|
||||
// next_holderId: IsNull() || "",
|
||||
// },
|
||||
// }),
|
||||
// totalRootPosition: await this.posMasterRepository.count({
|
||||
// where: {
|
||||
// orgRevisionId: orgRoot.orgRevisionId,
|
||||
// orgRootId: orgRoot.id,
|
||||
// orgChild1Id: orgChild1.id,
|
||||
// orgChild2Id: orgChild2.id,
|
||||
// orgChild3Id: IsNull() || "",
|
||||
// orgChild4Id: IsNull() || "",
|
||||
// },
|
||||
// }),
|
||||
// totalRootPositionCurrentUse: await this.posMasterRepository.count({
|
||||
// where: {
|
||||
// orgRevisionId: orgRoot.orgRevisionId,
|
||||
// orgRootId: orgRoot.id,
|
||||
// orgChild1Id: orgChild1.id,
|
||||
// orgChild2Id: orgChild2.id,
|
||||
// orgChild3Id: IsNull() || "",
|
||||
// orgChild4Id: IsNull() || "",
|
||||
// current_holderId: Not(IsNull()) || Not(""),
|
||||
// },
|
||||
// }),
|
||||
// totalRootPositionCurrentVacant: await this.posMasterRepository.count({
|
||||
// where: {
|
||||
// orgRevisionId: orgRoot.orgRevisionId,
|
||||
// orgRootId: orgRoot.id,
|
||||
// orgChild1Id: orgChild1.id,
|
||||
// orgChild2Id: orgChild2.id,
|
||||
// orgChild3Id: IsNull() || "",
|
||||
// orgChild4Id: IsNull() || "",
|
||||
// current_holderId: IsNull() || "",
|
||||
// },
|
||||
// }),
|
||||
// totalRootPositionNextUse: await this.posMasterRepository.count({
|
||||
// where: {
|
||||
// orgRevisionId: orgRoot.orgRevisionId,
|
||||
// orgRootId: orgRoot.id,
|
||||
// orgChild1Id: orgChild1.id,
|
||||
// orgChild2Id: orgChild2.id,
|
||||
// orgChild3Id: IsNull() || "",
|
||||
// orgChild4Id: IsNull() || "",
|
||||
// next_holderId: Not(IsNull()) || Not(""),
|
||||
// },
|
||||
// }),
|
||||
// totalRootPositionNextVacant: await this.posMasterRepository.count({
|
||||
// where: {
|
||||
// orgRevisionId: orgRoot.orgRevisionId,
|
||||
// orgRootId: orgRoot.id,
|
||||
// orgChild1Id: orgChild1.id,
|
||||
// orgChild2Id: orgChild2.id,
|
||||
// orgChild3Id: IsNull() || "",
|
||||
// orgChild4Id: IsNull() || "",
|
||||
// next_holderId: IsNull() || "",
|
||||
// },
|
||||
// }),
|
||||
|
||||
children: await Promise.all(
|
||||
orgChild3Data
|
||||
|
|
@ -2630,94 +2379,6 @@ export class OrganizationController extends Controller {
|
|||
"00" +
|
||||
" " +
|
||||
orgRoot.orgRootShortName,
|
||||
// totalPosition: await this.posMasterRepository.count({
|
||||
// where: {
|
||||
// orgRevisionId: orgRoot.orgRevisionId,
|
||||
// orgChild3Id: orgChild3.id,
|
||||
// },
|
||||
// }),
|
||||
// totalPositionCurrentUse: await this.posMasterRepository.count({
|
||||
// where: {
|
||||
// orgRevisionId: orgRoot.orgRevisionId,
|
||||
// orgChild3Id: orgChild3.id,
|
||||
// current_holderId: Not(IsNull()) || Not(""),
|
||||
// },
|
||||
// }),
|
||||
// totalPositionCurrentVacant: await this.posMasterRepository.count({
|
||||
// where: {
|
||||
// orgRevisionId: orgRoot.orgRevisionId,
|
||||
// orgChild3Id: orgChild3.id,
|
||||
// current_holderId: IsNull() || "",
|
||||
// },
|
||||
// }),
|
||||
// totalPositionNextUse: await this.posMasterRepository.count({
|
||||
// where: {
|
||||
// orgRevisionId: orgRoot.orgRevisionId,
|
||||
// orgChild3Id: orgChild3.id,
|
||||
// next_holderId: Not(IsNull()) || Not(""),
|
||||
// },
|
||||
// }),
|
||||
// totalPositionNextVacant: await this.posMasterRepository.count({
|
||||
// where: {
|
||||
// orgRevisionId: orgRoot.orgRevisionId,
|
||||
// orgChild3Id: orgChild3.id,
|
||||
// next_holderId: IsNull() || "",
|
||||
// },
|
||||
// }),
|
||||
// totalRootPosition: await this.posMasterRepository.count({
|
||||
// where: {
|
||||
// orgRevisionId: orgRoot.orgRevisionId,
|
||||
// orgRootId: orgRoot.id,
|
||||
// orgChild1Id: orgChild1.id,
|
||||
// orgChild2Id: orgChild2.id,
|
||||
// orgChild3Id: orgChild3.id,
|
||||
// orgChild4Id: IsNull() || "",
|
||||
// },
|
||||
// }),
|
||||
// totalRootPositionCurrentUse: await this.posMasterRepository.count({
|
||||
// where: {
|
||||
// orgRevisionId: orgRoot.orgRevisionId,
|
||||
// orgRootId: orgRoot.id,
|
||||
// orgChild1Id: orgChild1.id,
|
||||
// orgChild2Id: orgChild2.id,
|
||||
// orgChild3Id: orgChild3.id,
|
||||
// orgChild4Id: IsNull() || "",
|
||||
// current_holderId: Not(IsNull()) || Not(""),
|
||||
// },
|
||||
// }),
|
||||
// totalRootPositionCurrentVacant: await this.posMasterRepository.count({
|
||||
// where: {
|
||||
// orgRevisionId: orgRoot.orgRevisionId,
|
||||
// orgRootId: orgRoot.id,
|
||||
// orgChild1Id: orgChild1.id,
|
||||
// orgChild2Id: orgChild2.id,
|
||||
// orgChild3Id: orgChild3.id,
|
||||
// orgChild4Id: IsNull() || "",
|
||||
// current_holderId: IsNull() || "",
|
||||
// },
|
||||
// }),
|
||||
// totalRootPositionNextUse: await this.posMasterRepository.count({
|
||||
// where: {
|
||||
// orgRevisionId: orgRoot.orgRevisionId,
|
||||
// orgRootId: orgRoot.id,
|
||||
// orgChild1Id: orgChild1.id,
|
||||
// orgChild2Id: orgChild2.id,
|
||||
// orgChild3Id: orgChild3.id,
|
||||
// orgChild4Id: IsNull() || "",
|
||||
// next_holderId: Not(IsNull()) || Not(""),
|
||||
// },
|
||||
// }),
|
||||
// totalRootPositionNextVacant: await this.posMasterRepository.count({
|
||||
// where: {
|
||||
// orgRevisionId: orgRoot.orgRevisionId,
|
||||
// orgRootId: orgRoot.id,
|
||||
// orgChild1Id: orgChild1.id,
|
||||
// orgChild2Id: orgChild2.id,
|
||||
// orgChild3Id: orgChild3.id,
|
||||
// orgChild4Id: IsNull() || "",
|
||||
// next_holderId: IsNull() || "",
|
||||
// },
|
||||
// }),
|
||||
|
||||
children: await Promise.all(
|
||||
orgChild4Data
|
||||
|
|
@ -2781,99 +2442,6 @@ export class OrganizationController extends Controller {
|
|||
"00" +
|
||||
" " +
|
||||
orgRoot.orgRootShortName,
|
||||
// totalPosition: await this.posMasterRepository.count({
|
||||
// where: {
|
||||
// orgRevisionId: orgRoot.orgRevisionId,
|
||||
// orgChild4Id: orgChild4.id,
|
||||
// },
|
||||
// }),
|
||||
// totalPositionCurrentUse: await this.posMasterRepository.count({
|
||||
// where: {
|
||||
// orgRevisionId: orgRoot.orgRevisionId,
|
||||
// orgChild4Id: orgChild4.id,
|
||||
// current_holderId: Not(IsNull()) || Not(""),
|
||||
// },
|
||||
// }),
|
||||
// totalPositionCurrentVacant: await this.posMasterRepository.count({
|
||||
// where: {
|
||||
// orgRevisionId: orgRoot.orgRevisionId,
|
||||
// orgChild4Id: orgChild4.id,
|
||||
// current_holderId: IsNull() || "",
|
||||
// },
|
||||
// }),
|
||||
// totalPositionNextUse: await this.posMasterRepository.count({
|
||||
// where: {
|
||||
// orgRevisionId: orgRoot.orgRevisionId,
|
||||
// orgChild4Id: orgChild4.id,
|
||||
// next_holderId: Not(IsNull()) || Not(""),
|
||||
// },
|
||||
// }),
|
||||
// totalPositionNextVacant: await this.posMasterRepository.count({
|
||||
// where: {
|
||||
// orgRevisionId: orgRoot.orgRevisionId,
|
||||
// orgChild4Id: orgChild4.id,
|
||||
// next_holderId: IsNull() || "",
|
||||
// },
|
||||
// }),
|
||||
// totalRootPosition: await this.posMasterRepository.count({
|
||||
// where: {
|
||||
// orgRevisionId: orgRoot.orgRevisionId,
|
||||
// orgRootId: orgRoot.id,
|
||||
// orgChild1Id: orgChild1.id,
|
||||
// orgChild2Id: orgChild2.id,
|
||||
// orgChild3Id: orgChild3.id,
|
||||
// orgChild4Id: orgChild4.id,
|
||||
// },
|
||||
// }),
|
||||
// totalRootPositionCurrentUse: await this.posMasterRepository.count(
|
||||
// {
|
||||
// where: {
|
||||
// orgRevisionId: orgRoot.orgRevisionId,
|
||||
// orgRootId: orgRoot.id,
|
||||
// orgChild1Id: orgChild1.id,
|
||||
// orgChild2Id: orgChild2.id,
|
||||
// orgChild3Id: orgChild3.id,
|
||||
// orgChild4Id: orgChild4.id,
|
||||
// current_holderId: Not(IsNull()) || Not(""),
|
||||
// },
|
||||
// },
|
||||
// ),
|
||||
// totalRootPositionCurrentVacant:
|
||||
// await this.posMasterRepository.count({
|
||||
// where: {
|
||||
// orgRevisionId: orgRoot.orgRevisionId,
|
||||
// orgRootId: orgRoot.id,
|
||||
// orgChild1Id: orgChild1.id,
|
||||
// orgChild2Id: orgChild2.id,
|
||||
// orgChild3Id: orgChild3.id,
|
||||
// orgChild4Id: orgChild4.id,
|
||||
// current_holderId: IsNull() || "",
|
||||
// },
|
||||
// }),
|
||||
// totalRootPositionNextUse: await this.posMasterRepository.count({
|
||||
// where: {
|
||||
// orgRevisionId: orgRoot.orgRevisionId,
|
||||
// orgRootId: orgRoot.id,
|
||||
// orgChild1Id: orgChild1.id,
|
||||
// orgChild2Id: orgChild2.id,
|
||||
// orgChild3Id: orgChild3.id,
|
||||
// orgChild4Id: orgChild4.id,
|
||||
// next_holderId: Not(IsNull()) || Not(""),
|
||||
// },
|
||||
// }),
|
||||
// totalRootPositionNextVacant: await this.posMasterRepository.count(
|
||||
// {
|
||||
// where: {
|
||||
// orgRevisionId: orgRoot.orgRevisionId,
|
||||
// orgRootId: orgRoot.id,
|
||||
// orgChild1Id: orgChild1.id,
|
||||
// orgChild2Id: orgChild2.id,
|
||||
// orgChild3Id: orgChild3.id,
|
||||
// orgChild4Id: orgChild4.id,
|
||||
// next_holderId: IsNull() || "",
|
||||
// },
|
||||
// },
|
||||
// ),
|
||||
})),
|
||||
),
|
||||
})),
|
||||
|
|
@ -2886,6 +2454,7 @@ export class OrganizationController extends Controller {
|
|||
}),
|
||||
);
|
||||
|
||||
// return new HttpSuccess({ remark: _revision.remark, data: formattedData });
|
||||
return new HttpSuccess({ remark: _revision.remark, data: formattedData });
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4975,7 +4975,7 @@ export class ProfileController extends Controller {
|
|||
*
|
||||
*/
|
||||
@Post("cal/retire")
|
||||
async calDateRetire(@Body() body:{birthDate: Date}) {
|
||||
async calDateRetire(@Body() body: { birthDate: Date }) {
|
||||
const retireDate = await calculateRetireDate(body.birthDate);
|
||||
const age = calculateAge(body.birthDate);
|
||||
|
||||
|
|
@ -10436,7 +10436,11 @@ export class ProfileController extends Controller {
|
|||
.leftJoinAndSelect("current_holders.orgChild4", "orgChild4")
|
||||
.leftJoinAndSelect("current_holders.positions", "positions")
|
||||
.leftJoinAndSelect("positions.posExecutive", "posExecutive")
|
||||
.where("YEAR(profile.dateRetire) = :year", { year })
|
||||
// calculate range: start = 2 Oct of (year-1), end = 1 Oct of year (inclusive)
|
||||
.where("profile.dateRetire BETWEEN :start AND :end", {
|
||||
start: `${year - 1}-10-02`,
|
||||
end: `${year}-10-01`,
|
||||
})
|
||||
.getMany();
|
||||
|
||||
if (!profiles || profiles.length === 0) {
|
||||
|
|
|
|||
|
|
@ -5032,7 +5032,11 @@ export class ProfileEmployeeController extends Controller {
|
|||
.leftJoinAndSelect("current_holders.orgChild3", "orgChild3")
|
||||
.leftJoinAndSelect("current_holders.orgChild4", "orgChild4")
|
||||
.leftJoinAndSelect("current_holders.positions", "positions")
|
||||
.where("YEAR(profileEmployee.dateRetire) = :year", { year })
|
||||
// calculate range: start = 2 Oct of (year-1), end = 1 Oct of year (inclusive)
|
||||
.where("profile.dateRetire BETWEEN :start AND :end", {
|
||||
start: `${year - 1}-10-02`,
|
||||
end: `${year}-10-01`,
|
||||
})
|
||||
.getMany();
|
||||
|
||||
if (!profiles || profiles.length === 0) {
|
||||
|
|
|
|||
|
|
@ -1527,7 +1527,7 @@ export class ProfileEmployeeTempController extends Controller {
|
|||
if (!findRevision) {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "not found. OrgRevision");
|
||||
}
|
||||
|
||||
|
||||
let query = await this.profileRepo
|
||||
.createQueryBuilder("profileEmployee")
|
||||
.leftJoinAndSelect("profileEmployee.posLevel", "posLevel")
|
||||
|
|
@ -1640,36 +1640,24 @@ export class ProfileEmployeeTempController extends Controller {
|
|||
}
|
||||
}
|
||||
}),
|
||||
)
|
||||
);
|
||||
|
||||
if (sortBy) {
|
||||
if(sortBy == "posLevel"){
|
||||
query = query.orderBy(
|
||||
`posLevel.posLevelName`,
|
||||
descending ? "DESC" : "ASC"
|
||||
);
|
||||
}else if(sortBy == "posType"){
|
||||
query = query.orderBy(
|
||||
`posType.posTypeName`,
|
||||
descending ? "DESC" : "ASC"
|
||||
);
|
||||
}else if(sortBy == "govAge"){
|
||||
query = query.orderBy(
|
||||
`profileEmployee.dateAppoint`,
|
||||
descending ? "DESC" : "ASC"
|
||||
);
|
||||
}else{
|
||||
query = query.orderBy(
|
||||
`profileEmployee.${sortBy}`,
|
||||
descending ? "DESC" : "ASC"
|
||||
);
|
||||
if (sortBy == "posLevel") {
|
||||
query = query.orderBy(`posLevel.posLevelName`, descending ? "DESC" : "ASC");
|
||||
} else if (sortBy == "posType") {
|
||||
query = query.orderBy(`posType.posTypeName`, descending ? "DESC" : "ASC");
|
||||
} else if (sortBy == "govAge") {
|
||||
query = query.orderBy(`profileEmployee.dateAppoint`, descending ? "DESC" : "ASC");
|
||||
} else {
|
||||
query = query.orderBy(`profileEmployee.${sortBy}`, descending ? "DESC" : "ASC");
|
||||
}
|
||||
}
|
||||
|
||||
const [record, total] = await query
|
||||
.skip((page - 1) * pageSize)
|
||||
.take(pageSize)
|
||||
.getManyAndCount();
|
||||
.skip((page - 1) * pageSize)
|
||||
.take(pageSize)
|
||||
.getManyAndCount();
|
||||
|
||||
const data = await Promise.all(
|
||||
record.map((_data) => {
|
||||
|
|
@ -3241,7 +3229,11 @@ export class ProfileEmployeeTempController extends Controller {
|
|||
.leftJoinAndSelect("current_holders.orgChild4", "orgChild4")
|
||||
.leftJoinAndSelect("current_holders.positions", "positions")
|
||||
// .leftJoinAndSelect("positions.posExecutive", "posExecutive")
|
||||
.where("YEAR(profileEmployee.dateRetire) = :year", { year })
|
||||
// calculate range: start = 2 Oct of (year-1), end = 1 Oct of year (inclusive)
|
||||
.where("profile.dateRetire BETWEEN :start AND :end", {
|
||||
start: `${year - 1}-10-02`,
|
||||
end: `${year}-10-01`,
|
||||
})
|
||||
.getMany();
|
||||
|
||||
if (!profiles || profiles.length === 0) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue