no message
This commit is contained in:
parent
28bfc04d64
commit
539f433bd7
4 changed files with 242 additions and 66 deletions
|
|
@ -1213,31 +1213,31 @@ export class OrganizationDotnetController extends Controller {
|
||||||
(x) =>
|
(x) =>
|
||||||
x.orgRevision?.orgRevisionIsDraft == false &&
|
x.orgRevision?.orgRevisionIsDraft == false &&
|
||||||
x.orgRevision?.orgRevisionIsCurrent == true,
|
x.orgRevision?.orgRevisionIsCurrent == true,
|
||||||
)?.orgRoot.ancestorDNA ?? null,
|
)?.orgRoot?.ancestorDNA ?? null,
|
||||||
child1DnaId:
|
child1DnaId:
|
||||||
profile?.current_holders?.find(
|
profile?.current_holders?.find(
|
||||||
(x) =>
|
(x) =>
|
||||||
x.orgRevision?.orgRevisionIsDraft == false &&
|
x.orgRevision?.orgRevisionIsDraft == false &&
|
||||||
x.orgRevision?.orgRevisionIsCurrent == true,
|
x.orgRevision?.orgRevisionIsCurrent == true,
|
||||||
)?.orgChild3.ancestorDNA ?? null,
|
)?.orgChild3?.ancestorDNA ?? null,
|
||||||
child2DnaId:
|
child2DnaId:
|
||||||
profile?.current_holders?.find(
|
profile?.current_holders?.find(
|
||||||
(x) =>
|
(x) =>
|
||||||
x.orgRevision?.orgRevisionIsDraft == false &&
|
x.orgRevision?.orgRevisionIsDraft == false &&
|
||||||
x.orgRevision?.orgRevisionIsCurrent == true,
|
x.orgRevision?.orgRevisionIsCurrent == true,
|
||||||
)?.orgChild2.ancestorDNA ?? null,
|
)?.orgChild2?.ancestorDNA ?? null,
|
||||||
child3DnaId:
|
child3DnaId:
|
||||||
profile?.current_holders?.find(
|
profile?.current_holders?.find(
|
||||||
(x) =>
|
(x) =>
|
||||||
x.orgRevision?.orgRevisionIsDraft == false &&
|
x.orgRevision?.orgRevisionIsDraft == false &&
|
||||||
x.orgRevision?.orgRevisionIsCurrent == true,
|
x.orgRevision?.orgRevisionIsCurrent == true,
|
||||||
)?.orgChild3.ancestorDNA ?? null,
|
)?.orgChild3?.ancestorDNA ?? null,
|
||||||
child4DnaId:
|
child4DnaId:
|
||||||
profile?.current_holders?.find(
|
profile?.current_holders?.find(
|
||||||
(x) =>
|
(x) =>
|
||||||
x.orgRevision?.orgRevisionIsDraft == false &&
|
x.orgRevision?.orgRevisionIsDraft == false &&
|
||||||
x.orgRevision?.orgRevisionIsCurrent == true,
|
x.orgRevision?.orgRevisionIsCurrent == true,
|
||||||
)?.orgChild4.ancestorDNA ?? null,
|
)?.orgChild4?.ancestorDNA ?? null,
|
||||||
commander: fullname,
|
commander: fullname,
|
||||||
posLevel: profile.posLevel?.posLevelName ?? null,
|
posLevel: profile.posLevel?.posLevelName ?? null,
|
||||||
posType: profile.posType?.posTypeName ?? null,
|
posType: profile.posType?.posTypeName ?? null,
|
||||||
|
|
@ -1510,31 +1510,31 @@ export class OrganizationDotnetController extends Controller {
|
||||||
(x) =>
|
(x) =>
|
||||||
x.orgRevision?.orgRevisionIsDraft == false &&
|
x.orgRevision?.orgRevisionIsDraft == false &&
|
||||||
x.orgRevision?.orgRevisionIsCurrent == true,
|
x.orgRevision?.orgRevisionIsCurrent == true,
|
||||||
)?.orgRoot.ancestorDNA ?? null,
|
)?.orgRoot?.ancestorDNA ?? null,
|
||||||
child1DnaId:
|
child1DnaId:
|
||||||
profile?.current_holders?.find(
|
profile?.current_holders?.find(
|
||||||
(x) =>
|
(x) =>
|
||||||
x.orgRevision?.orgRevisionIsDraft == false &&
|
x.orgRevision?.orgRevisionIsDraft == false &&
|
||||||
x.orgRevision?.orgRevisionIsCurrent == true,
|
x.orgRevision?.orgRevisionIsCurrent == true,
|
||||||
)?.orgChild1.ancestorDNA ?? null,
|
)?.orgChild1?.ancestorDNA ?? null,
|
||||||
child2DnaId:
|
child2DnaId:
|
||||||
profile?.current_holders?.find(
|
profile?.current_holders?.find(
|
||||||
(x) =>
|
(x) =>
|
||||||
x.orgRevision?.orgRevisionIsDraft == false &&
|
x.orgRevision?.orgRevisionIsDraft == false &&
|
||||||
x.orgRevision?.orgRevisionIsCurrent == true,
|
x.orgRevision?.orgRevisionIsCurrent == true,
|
||||||
)?.orgChild2.ancestorDNA ?? null,
|
)?.orgChild2?.ancestorDNA ?? null,
|
||||||
child3DnaId:
|
child3DnaId:
|
||||||
profile?.current_holders?.find(
|
profile?.current_holders?.find(
|
||||||
(x) =>
|
(x) =>
|
||||||
x.orgRevision?.orgRevisionIsDraft == false &&
|
x.orgRevision?.orgRevisionIsDraft == false &&
|
||||||
x.orgRevision?.orgRevisionIsCurrent == true,
|
x.orgRevision?.orgRevisionIsCurrent == true,
|
||||||
)?.orgChild3.ancestorDNA ?? null,
|
)?.orgChild3?.ancestorDNA ?? null,
|
||||||
child4DnaId:
|
child4DnaId:
|
||||||
profile?.current_holders?.find(
|
profile?.current_holders?.find(
|
||||||
(x) =>
|
(x) =>
|
||||||
x.orgRevision?.orgRevisionIsDraft == false &&
|
x.orgRevision?.orgRevisionIsDraft == false &&
|
||||||
x.orgRevision?.orgRevisionIsCurrent == true,
|
x.orgRevision?.orgRevisionIsCurrent == true,
|
||||||
)?.orgChild4.ancestorDNA ?? null,
|
)?.orgChild4?.ancestorDNA ?? null,
|
||||||
commander: fullname,
|
commander: fullname,
|
||||||
posLevel: profile.posLevel?.posLevelName ?? null,
|
posLevel: profile.posLevel?.posLevelName ?? null,
|
||||||
posType: profile.posType?.posTypeName ?? null,
|
posType: profile.posType?.posTypeName ?? null,
|
||||||
|
|
@ -2276,7 +2276,7 @@ export class OrganizationDotnetController extends Controller {
|
||||||
(x) =>
|
(x) =>
|
||||||
x.orgRevision?.orgRevisionIsDraft == false &&
|
x.orgRevision?.orgRevisionIsDraft == false &&
|
||||||
x.orgRevision?.orgRevisionIsCurrent == true,
|
x.orgRevision?.orgRevisionIsCurrent == true,
|
||||||
)?.orgRoot.ancestorDNA ?? null,
|
)?.orgRoot?.ancestorDNA ?? null,
|
||||||
child1:
|
child1:
|
||||||
profile?.current_holders?.find(
|
profile?.current_holders?.find(
|
||||||
(x) =>
|
(x) =>
|
||||||
|
|
@ -2294,7 +2294,7 @@ export class OrganizationDotnetController extends Controller {
|
||||||
(x) =>
|
(x) =>
|
||||||
x.orgRevision?.orgRevisionIsDraft == false &&
|
x.orgRevision?.orgRevisionIsDraft == false &&
|
||||||
x.orgRevision?.orgRevisionIsCurrent == true,
|
x.orgRevision?.orgRevisionIsCurrent == true,
|
||||||
)?.orgChild1.ancestorDNA ?? null,
|
)?.orgChild1?.ancestorDNA ?? null,
|
||||||
child2:
|
child2:
|
||||||
profile?.current_holders?.find(
|
profile?.current_holders?.find(
|
||||||
(x) =>
|
(x) =>
|
||||||
|
|
@ -2312,7 +2312,7 @@ export class OrganizationDotnetController extends Controller {
|
||||||
(x) =>
|
(x) =>
|
||||||
x.orgRevision?.orgRevisionIsDraft == false &&
|
x.orgRevision?.orgRevisionIsDraft == false &&
|
||||||
x.orgRevision?.orgRevisionIsCurrent == true,
|
x.orgRevision?.orgRevisionIsCurrent == true,
|
||||||
)?.orgChild2.ancestorDNA ?? null,
|
)?.orgChild2?.ancestorDNA ?? null,
|
||||||
child3:
|
child3:
|
||||||
profile?.current_holders?.find(
|
profile?.current_holders?.find(
|
||||||
(x) =>
|
(x) =>
|
||||||
|
|
@ -2330,7 +2330,7 @@ export class OrganizationDotnetController extends Controller {
|
||||||
(x) =>
|
(x) =>
|
||||||
x.orgRevision?.orgRevisionIsDraft == false &&
|
x.orgRevision?.orgRevisionIsDraft == false &&
|
||||||
x.orgRevision?.orgRevisionIsCurrent == true,
|
x.orgRevision?.orgRevisionIsCurrent == true,
|
||||||
)?.orgChild3.ancestorDNA ?? null,
|
)?.orgChild3?.ancestorDNA ?? null,
|
||||||
child4:
|
child4:
|
||||||
profile?.current_holders?.find(
|
profile?.current_holders?.find(
|
||||||
(x) =>
|
(x) =>
|
||||||
|
|
@ -2348,7 +2348,7 @@ export class OrganizationDotnetController extends Controller {
|
||||||
(x) =>
|
(x) =>
|
||||||
x.orgRevision?.orgRevisionIsDraft == false &&
|
x.orgRevision?.orgRevisionIsDraft == false &&
|
||||||
x.orgRevision?.orgRevisionIsCurrent == true,
|
x.orgRevision?.orgRevisionIsCurrent == true,
|
||||||
)?.orgChild4.ancestorDNA ?? null,
|
)?.orgChild4?.ancestorDNA ?? null,
|
||||||
posNo: shortName ?? "",
|
posNo: shortName ?? "",
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
@ -2643,7 +2643,7 @@ export class OrganizationDotnetController extends Controller {
|
||||||
(x) =>
|
(x) =>
|
||||||
x.orgRevision?.orgRevisionIsDraft == false &&
|
x.orgRevision?.orgRevisionIsDraft == false &&
|
||||||
x.orgRevision?.orgRevisionIsCurrent == true,
|
x.orgRevision?.orgRevisionIsCurrent == true,
|
||||||
)?.orgRoot.ancestorDNA ?? null,
|
)?.orgRoot?.ancestorDNA ?? null,
|
||||||
child1:
|
child1:
|
||||||
profile?.current_holders?.find(
|
profile?.current_holders?.find(
|
||||||
(x) =>
|
(x) =>
|
||||||
|
|
@ -2661,7 +2661,7 @@ export class OrganizationDotnetController extends Controller {
|
||||||
(x) =>
|
(x) =>
|
||||||
x.orgRevision?.orgRevisionIsDraft == false &&
|
x.orgRevision?.orgRevisionIsDraft == false &&
|
||||||
x.orgRevision?.orgRevisionIsCurrent == true,
|
x.orgRevision?.orgRevisionIsCurrent == true,
|
||||||
)?.orgChild1.ancestorDNA ?? null,
|
)?.orgChild1?.ancestorDNA ?? null,
|
||||||
child2:
|
child2:
|
||||||
profile?.current_holders?.find(
|
profile?.current_holders?.find(
|
||||||
(x) =>
|
(x) =>
|
||||||
|
|
@ -2679,7 +2679,7 @@ export class OrganizationDotnetController extends Controller {
|
||||||
(x) =>
|
(x) =>
|
||||||
x.orgRevision?.orgRevisionIsDraft == false &&
|
x.orgRevision?.orgRevisionIsDraft == false &&
|
||||||
x.orgRevision?.orgRevisionIsCurrent == true,
|
x.orgRevision?.orgRevisionIsCurrent == true,
|
||||||
)?.orgChild2.ancestorDNA ?? null,
|
)?.orgChild2?.ancestorDNA ?? null,
|
||||||
child3:
|
child3:
|
||||||
profile?.current_holders?.find(
|
profile?.current_holders?.find(
|
||||||
(x) =>
|
(x) =>
|
||||||
|
|
@ -2697,7 +2697,7 @@ export class OrganizationDotnetController extends Controller {
|
||||||
(x) =>
|
(x) =>
|
||||||
x.orgRevision?.orgRevisionIsDraft == false &&
|
x.orgRevision?.orgRevisionIsDraft == false &&
|
||||||
x.orgRevision?.orgRevisionIsCurrent == true,
|
x.orgRevision?.orgRevisionIsCurrent == true,
|
||||||
)?.orgChild3.ancestorDNA ?? null,
|
)?.orgChild3?.ancestorDNA ?? null,
|
||||||
child4:
|
child4:
|
||||||
profile?.current_holders?.find(
|
profile?.current_holders?.find(
|
||||||
(x) =>
|
(x) =>
|
||||||
|
|
@ -2715,7 +2715,7 @@ export class OrganizationDotnetController extends Controller {
|
||||||
(x) =>
|
(x) =>
|
||||||
x.orgRevision?.orgRevisionIsDraft == false &&
|
x.orgRevision?.orgRevisionIsDraft == false &&
|
||||||
x.orgRevision?.orgRevisionIsCurrent == true,
|
x.orgRevision?.orgRevisionIsCurrent == true,
|
||||||
)?.orgChild4.ancestorDNA ?? null,
|
)?.orgChild4?.ancestorDNA ?? null,
|
||||||
posNo: shortName ?? "",
|
posNo: shortName ?? "",
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -4386,9 +4386,6 @@ export class ProfileController extends Controller {
|
||||||
.andWhere(nodeCondition, {
|
.andWhere(nodeCondition, {
|
||||||
nodeId: nodeId,
|
nodeId: nodeId,
|
||||||
})
|
})
|
||||||
// .andWhere(`current_holders.orgRevisionId LIKE :orgRevisionId`, {
|
|
||||||
// orgRevisionId: revisionId,
|
|
||||||
// })
|
|
||||||
.orderBy("current_holders.posMasterNo", "ASC")
|
.orderBy("current_holders.posMasterNo", "ASC")
|
||||||
.skip((page - 1) * pageSize)
|
.skip((page - 1) * pageSize)
|
||||||
.take(pageSize)
|
.take(pageSize)
|
||||||
|
|
@ -7303,6 +7300,7 @@ export class ProfileController extends Controller {
|
||||||
.leftJoinAndSelect("current_holders.orgChild4", "orgChild4")
|
.leftJoinAndSelect("current_holders.orgChild4", "orgChild4")
|
||||||
.leftJoinAndSelect("current_holders.positions", "positions")
|
.leftJoinAndSelect("current_holders.positions", "positions")
|
||||||
.leftJoinAndSelect("positions.posExecutive", "posExecutive")
|
.leftJoinAndSelect("positions.posExecutive", "posExecutive")
|
||||||
|
.andWhere("profile.isLeave = false")
|
||||||
.andWhere(
|
.andWhere(
|
||||||
_data.root != undefined && _data.root != null
|
_data.root != undefined && _data.root != null
|
||||||
? _data.root[0] != null
|
? _data.root[0] != null
|
||||||
|
|
|
||||||
|
|
@ -67,6 +67,7 @@ import { ProfileLeave } from "../entities/ProfileLeave";
|
||||||
import permission from "../interfaces/permission";
|
import permission from "../interfaces/permission";
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import { Position } from "../entities/Position";
|
import { Position } from "../entities/Position";
|
||||||
|
import { EmployeePosition } from "../entities/EmployeePosition";
|
||||||
@Route("api/v1/org/profile-employee")
|
@Route("api/v1/org/profile-employee")
|
||||||
@Tags("ProfileEmployee")
|
@Tags("ProfileEmployee")
|
||||||
@Security("bearerAuth")
|
@Security("bearerAuth")
|
||||||
|
|
@ -108,6 +109,7 @@ export class ProfileEmployeeController extends Controller {
|
||||||
private profileInsigniaRepo = AppDataSource.getRepository(ProfileInsignia);
|
private profileInsigniaRepo = AppDataSource.getRepository(ProfileInsignia);
|
||||||
private profileLeaveRepository = AppDataSource.getRepository(ProfileLeave);
|
private profileLeaveRepository = AppDataSource.getRepository(ProfileLeave);
|
||||||
private positionRepository = AppDataSource.getRepository(Position);
|
private positionRepository = AppDataSource.getRepository(Position);
|
||||||
|
private employeePositionRepository = AppDataSource.getRepository(EmployeePosition);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* report ประวัติแบบย่อ ลูกจ้าง
|
* report ประวัติแบบย่อ ลูกจ้าง
|
||||||
|
|
@ -1399,6 +1401,219 @@ export class ProfileEmployeeController extends Controller {
|
||||||
return new HttpSuccess(formattedData);
|
return new HttpSuccess(formattedData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* API รายการทะเบียนประวัติในระบบอื่น
|
||||||
|
*
|
||||||
|
* @summary ORG_065 - รายการทะเบียนประวัติในระบบอื่น
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@Get("otherSystem")
|
||||||
|
async listProfileNoPermission(
|
||||||
|
@Request() request: RequestWithUser,
|
||||||
|
@Query("page") page: number = 1,
|
||||||
|
@Query("pageSize") pageSize: number = 10,
|
||||||
|
@Query()
|
||||||
|
searchField?: "firstName" | "lastName" | "fullName" | "citizenId" | "position" | "posNo",
|
||||||
|
@Query() searchKeyword: string = "",
|
||||||
|
@Query() posType?: string,
|
||||||
|
@Query() posLevel?: string,
|
||||||
|
@Query() yearLeave?: number,
|
||||||
|
@Query() isProbation?: boolean,
|
||||||
|
@Query() isRetire?: boolean,
|
||||||
|
@Query() nodeId?: string,
|
||||||
|
) {
|
||||||
|
let queryLike =
|
||||||
|
"CONCAT(profileEmployee.prefix, profileEmployee.firstName, ' ', profileEmployee.lastName) LIKE :keyword";
|
||||||
|
if (searchField == "citizenId") {
|
||||||
|
queryLike = "profileEmployee.citizenId LIKE :keyword";
|
||||||
|
} else if (searchField == "position") {
|
||||||
|
queryLike = "profileEmployee.position LIKE :keyword";
|
||||||
|
} else if (searchField == "posNo") {
|
||||||
|
queryLike = `
|
||||||
|
CASE
|
||||||
|
WHEN current_holders.orgChild4Id IS NOT NULL THEN CONCAT(orgChild4.orgChild4ShortName, current_holders.posMasterNo)
|
||||||
|
WHEN current_holders.orgChild3Id IS NOT NULL THEN CONCAT(orgChild3.orgChild3ShortName, current_holders.posMasterNo)
|
||||||
|
WHEN current_holders.orgChild2Id IS NOT NULL THEN CONCAT(orgChild2.orgChild2ShortName, current_holders.posMasterNo)
|
||||||
|
WHEN current_holders.orgChild1Id IS NOT NULL THEN CONCAT(orgChild1.orgChild1ShortName, current_holders.posMasterNo)
|
||||||
|
ELSE CONCAT(orgRoot.orgRootShortName, current_holders.posMasterNo)
|
||||||
|
END LIKE :keyword
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
let posMaster = await this.posMasterRepo.findOne({
|
||||||
|
where: {
|
||||||
|
current_holder: { keycloak: request.user.sub },
|
||||||
|
orgRevision: { orgRevisionIsDraft: false, orgRevisionIsCurrent: true },
|
||||||
|
},
|
||||||
|
});
|
||||||
|
let revisionId = "";
|
||||||
|
if (nodeId == null) {
|
||||||
|
const findRevision = await this.orgRevisionRepo.findOne({
|
||||||
|
where: { orgRevisionIsCurrent: true },
|
||||||
|
});
|
||||||
|
if (!findRevision) {
|
||||||
|
throw new HttpError(HttpStatus.NOT_FOUND, "not found. OrgRevision");
|
||||||
|
}
|
||||||
|
revisionId = findRevision.id;
|
||||||
|
if (posMaster != null) nodeId = posMaster.orgRootId ?? "";
|
||||||
|
} else {
|
||||||
|
const findRoot = await this.orgRootRepository.findOne({
|
||||||
|
where: { id: nodeId },
|
||||||
|
});
|
||||||
|
if (!findRoot) {
|
||||||
|
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบสำนักงานนี้ในระบบ");
|
||||||
|
}
|
||||||
|
revisionId = findRoot.orgRevisionId;
|
||||||
|
}
|
||||||
|
let nodeCondition = "current_holders.orgRootId = :nodeId";
|
||||||
|
const [record, total] = await this.profileRepo
|
||||||
|
.createQueryBuilder("profileEmployee")
|
||||||
|
.leftJoinAndSelect("profileEmployee.posLevel", "posLevel")
|
||||||
|
.leftJoinAndSelect("profileEmployee.posType", "posType")
|
||||||
|
.leftJoinAndSelect("profileEmployee.current_holders", "current_holders")
|
||||||
|
.leftJoinAndSelect("current_holders.positions", "positions")
|
||||||
|
.leftJoinAndSelect("current_holders.orgRevision", "orgRevision")
|
||||||
|
.leftJoinAndSelect("current_holders.orgRoot", "orgRoot")
|
||||||
|
.leftJoinAndSelect("current_holders.orgChild1", "orgChild1")
|
||||||
|
.leftJoinAndSelect("current_holders.orgChild2", "orgChild2")
|
||||||
|
.leftJoinAndSelect("current_holders.orgChild3", "orgChild3")
|
||||||
|
.leftJoinAndSelect("current_holders.orgChild4", "orgChild4")
|
||||||
|
.where("current_holders.orgRevisionId = :orgRevisionId", { orgRevisionId: revisionId })
|
||||||
|
.andWhere(
|
||||||
|
posType != undefined && posType != null && posType != ""
|
||||||
|
? "posType.posTypeName LIKE :keyword1"
|
||||||
|
: "1=1",
|
||||||
|
{
|
||||||
|
keyword1: `${posType}`,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
.andWhere(
|
||||||
|
posLevel != undefined && posLevel != null && posLevel != ""
|
||||||
|
? "posLevel.posLevelName LIKE :keyword2"
|
||||||
|
: "1=1",
|
||||||
|
{
|
||||||
|
keyword2: `${posLevel}`,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
.andWhere(
|
||||||
|
isProbation != undefined && isProbation != null
|
||||||
|
? `profile.isProbation = ${isProbation}`
|
||||||
|
: "1=1",
|
||||||
|
)
|
||||||
|
.andWhere(
|
||||||
|
isRetire != undefined && isRetire != null
|
||||||
|
? isRetire == false
|
||||||
|
? `profile.dateLeave IS null`
|
||||||
|
: `profile.dateLeave IS NOT NULL`
|
||||||
|
: "1=1",
|
||||||
|
)
|
||||||
|
.andWhere(
|
||||||
|
searchKeyword != undefined && searchKeyword != null && searchKeyword != ""
|
||||||
|
? queryLike
|
||||||
|
: "1=1",
|
||||||
|
{
|
||||||
|
keyword: `%${searchKeyword}%`,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
.andWhere(nodeCondition, {
|
||||||
|
nodeId: nodeId,
|
||||||
|
})
|
||||||
|
.orderBy("current_holders.posMasterNo", "ASC")
|
||||||
|
.skip((page - 1) * pageSize)
|
||||||
|
.take(pageSize)
|
||||||
|
.getManyAndCount();
|
||||||
|
|
||||||
|
const data = await Promise.all(
|
||||||
|
record.map((_data) => {
|
||||||
|
const shortName =
|
||||||
|
_data.current_holders.length == 0
|
||||||
|
? null
|
||||||
|
: _data.current_holders.find((x) => x.orgRevisionId == revisionId) != null &&
|
||||||
|
_data.current_holders.find((x) => x.orgRevisionId == revisionId)?.orgChild4 != null
|
||||||
|
? `${_data.current_holders.find((x) => x.orgRevisionId == revisionId)?.orgChild4.orgChild4ShortName}${_data.current_holders.find((x) => x.orgRevisionId == revisionId)?.posMasterNo}`
|
||||||
|
: _data.current_holders.find((x) => x.orgRevisionId == revisionId) != null &&
|
||||||
|
_data.current_holders.find((x) => x.orgRevisionId == revisionId)?.orgChild3 !=
|
||||||
|
null
|
||||||
|
? `${_data.current_holders.find((x) => x.orgRevisionId == revisionId)?.orgChild3.orgChild3ShortName}${_data.current_holders.find((x) => x.orgRevisionId == revisionId)?.posMasterNo}`
|
||||||
|
: _data.current_holders.find((x) => x.orgRevisionId == revisionId) != null &&
|
||||||
|
_data.current_holders.find((x) => x.orgRevisionId == revisionId)?.orgChild2 !=
|
||||||
|
null
|
||||||
|
? `${_data.current_holders.find((x) => x.orgRevisionId == revisionId)?.orgChild2.orgChild2ShortName}${_data.current_holders.find((x) => x.orgRevisionId == revisionId)?.posMasterNo}`
|
||||||
|
: _data.current_holders.find((x) => x.orgRevisionId == revisionId) != null &&
|
||||||
|
_data.current_holders.find((x) => x.orgRevisionId == revisionId)?.orgChild1 !=
|
||||||
|
null
|
||||||
|
? `${_data.current_holders.find((x) => x.orgRevisionId == revisionId)?.orgChild1.orgChild1ShortName}${_data.current_holders.find((x) => x.orgRevisionId == revisionId)?.posMasterNo}`
|
||||||
|
: _data.current_holders.find((x) => x.orgRevisionId == revisionId) != null &&
|
||||||
|
_data.current_holders.find((x) => x.orgRevisionId == revisionId)?.orgRoot !=
|
||||||
|
null
|
||||||
|
? `${_data.current_holders.find((x) => x.orgRevisionId == revisionId)?.orgRoot.orgRootShortName}${_data.current_holders.find((x) => x.orgRevisionId == revisionId)?.posMasterNo}`
|
||||||
|
: null;
|
||||||
|
const root =
|
||||||
|
_data.current_holders.length == 0 ||
|
||||||
|
(_data.current_holders.find((x) => x.orgRevisionId == revisionId) != null &&
|
||||||
|
_data.current_holders.find((x) => x.orgRevisionId == revisionId)?.orgRoot == null)
|
||||||
|
? null
|
||||||
|
: _data.current_holders.find((x) => x.orgRevisionId == revisionId)?.orgRoot;
|
||||||
|
|
||||||
|
const child1 =
|
||||||
|
_data.current_holders == null ||
|
||||||
|
_data.current_holders.length == 0 ||
|
||||||
|
_data.current_holders.find((x) => x.orgRevisionId == revisionId) == null
|
||||||
|
? null
|
||||||
|
: _data.current_holders.find((x) => x.orgRevisionId == revisionId)?.orgChild1;
|
||||||
|
|
||||||
|
const child2 =
|
||||||
|
_data.current_holders == null ||
|
||||||
|
_data.current_holders.length == 0 ||
|
||||||
|
_data.current_holders.find((x) => x.orgRevisionId == revisionId) == null
|
||||||
|
? null
|
||||||
|
: _data.current_holders.find((x) => x.orgRevisionId == revisionId)?.orgChild2;
|
||||||
|
|
||||||
|
const child3 =
|
||||||
|
_data.current_holders == null ||
|
||||||
|
_data.current_holders.length == 0 ||
|
||||||
|
_data.current_holders.find((x) => x.orgRevisionId == revisionId) == null
|
||||||
|
? null
|
||||||
|
: _data.current_holders.find((x) => x.orgRevisionId == revisionId)?.orgChild3;
|
||||||
|
|
||||||
|
const child4 =
|
||||||
|
_data.current_holders == null ||
|
||||||
|
_data.current_holders.length == 0 ||
|
||||||
|
_data.current_holders.find((x) => x.orgRevisionId == revisionId) == null
|
||||||
|
? null
|
||||||
|
: _data.current_holders.find((x) => x.orgRevisionId == revisionId)?.orgChild4;
|
||||||
|
|
||||||
|
let _child1 = child1 == null ? "" : `${child1.orgChild1Name}/`;
|
||||||
|
let _child2 = child2 == null ? "" : `${child2.orgChild2Name}/`;
|
||||||
|
let _child3 = child3 == null ? "" : `${child3.orgChild3Name}/`;
|
||||||
|
let _child4 = child4 == null ? "" : `${child4.orgChild4Name}/`;
|
||||||
|
|
||||||
|
return {
|
||||||
|
id: _data.id,
|
||||||
|
avatar: _data.avatar,
|
||||||
|
avatarName: _data.avatarName,
|
||||||
|
prefix: _data.prefix,
|
||||||
|
rank: _data.rank,
|
||||||
|
firstName: _data.firstName,
|
||||||
|
lastName: _data.lastName,
|
||||||
|
citizenId: _data.citizenId,
|
||||||
|
posLevel: _data.posLevel == null ? null : _data.posLevel.posLevelName,
|
||||||
|
posType: _data.posType == null ? null : _data.posType.posTypeName,
|
||||||
|
posLevelId: _data.posLevel == null ? null : _data.posLevel.id,
|
||||||
|
posTypeId: _data.posType == null ? null : _data.posType.id,
|
||||||
|
position: _data.position,
|
||||||
|
posNo: shortName,
|
||||||
|
rootId: root == null ? null : root.id,
|
||||||
|
root: root == null ? null : root.orgRootName,
|
||||||
|
orgRootShortName: root == null ? null : root.orgRootShortName,
|
||||||
|
orgRevisionId: root == null ? null : root.orgRevisionId,
|
||||||
|
org: `${_child4}${_child3}${_child2}${_child1}${root?.orgRootName ?? ""}`,
|
||||||
|
};
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
|
return new HttpSuccess({ data: data, total });
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* API Update amount
|
* API Update amount
|
||||||
*
|
*
|
||||||
|
|
@ -2201,8 +2416,7 @@ export class ProfileEmployeeController extends Controller {
|
||||||
? null
|
? null
|
||||||
: profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgChild4;
|
: profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgChild4;
|
||||||
|
|
||||||
const position = await this.positionRepository.findOne({
|
const position = await this.employeePositionRepository.findOne({
|
||||||
relations: ["posExecutive"],
|
|
||||||
where: {
|
where: {
|
||||||
posMasterId: posMaster?.id,
|
posMasterId: posMaster?.id,
|
||||||
},
|
},
|
||||||
|
|
@ -2231,16 +2445,9 @@ export class ProfileEmployeeController extends Controller {
|
||||||
posTypeName: profile.posType == null ? null : profile.posType.posTypeName,
|
posTypeName: profile.posType == null ? null : profile.posType.posTypeName,
|
||||||
posTypeRank: profile.posType == null ? null : profile.posType.posTypeRank,
|
posTypeRank: profile.posType == null ? null : profile.posType.posTypeRank,
|
||||||
posTypeId: profile.posType == null ? null : profile.posType.id,
|
posTypeId: profile.posType == null ? null : profile.posType.id,
|
||||||
posExecutiveName:
|
posExecutiveName: null,
|
||||||
position == null || position.posExecutive == null
|
posExecutivePriority: null,
|
||||||
? null
|
posExecutiveId: null,
|
||||||
: position.posExecutive.posExecutiveName,
|
|
||||||
posExecutivePriority:
|
|
||||||
position == null || position.posExecutive == null
|
|
||||||
? null
|
|
||||||
: position.posExecutive.posExecutivePriority,
|
|
||||||
posExecutiveId:
|
|
||||||
position == null || position.posExecutive == null ? null : position.posExecutive.id,
|
|
||||||
rootId: root == null ? null : root.id,
|
rootId: root == null ? null : root.id,
|
||||||
rootDnaId: root == null ? null : root.ancestorDNA,
|
rootDnaId: root == null ? null : root.ancestorDNA,
|
||||||
root: root == null ? null : root.orgRootName,
|
root: root == null ? null : root.orgRootName,
|
||||||
|
|
@ -3015,6 +3222,7 @@ export class ProfileEmployeeController extends Controller {
|
||||||
.leftJoinAndSelect("current_holders.orgChild2", "orgChild2")
|
.leftJoinAndSelect("current_holders.orgChild2", "orgChild2")
|
||||||
.leftJoinAndSelect("current_holders.orgChild3", "orgChild3")
|
.leftJoinAndSelect("current_holders.orgChild3", "orgChild3")
|
||||||
.leftJoinAndSelect("current_holders.orgChild4", "orgChild4")
|
.leftJoinAndSelect("current_holders.orgChild4", "orgChild4")
|
||||||
|
.andWhere("profile.isLeave = false")
|
||||||
.andWhere(
|
.andWhere(
|
||||||
_data.root != undefined && _data.root != null
|
_data.root != undefined && _data.root != null
|
||||||
? _data.root[0] != null
|
? _data.root[0] != null
|
||||||
|
|
@ -3279,10 +3487,6 @@ export class ProfileEmployeeController extends Controller {
|
||||||
posLevelName: item.posLevel == null ? null : item.posLevel.posLevelName,
|
posLevelName: item.posLevel == null ? null : item.posLevel.posLevelName,
|
||||||
posTypeName: item.posType == null ? null : item.posType.posTypeName,
|
posTypeName: item.posType == null ? null : item.posType.posTypeName,
|
||||||
posNo: `${posMaster == null ? null : posMaster.posMasterNo}${shortName}`,
|
posNo: `${posMaster == null ? null : posMaster.posMasterNo}${shortName}`,
|
||||||
// positionField: position == null ? null : position.positionField,
|
|
||||||
// positionArea: position == null ? null : position.positionArea,
|
|
||||||
// posExecutiveName: posExecutive,
|
|
||||||
// positionExecutiveField: position == null ? null : position.positionExecutiveField,
|
|
||||||
isProbation: item.isProbation,
|
isProbation: item.isProbation,
|
||||||
orgRootName:
|
orgRootName:
|
||||||
item.current_holders == null ||
|
item.current_holders == null ||
|
||||||
|
|
@ -3729,7 +3933,6 @@ export class ProfileEmployeeController extends Controller {
|
||||||
.leftJoinAndSelect("current_holders.orgChild3", "orgChild3")
|
.leftJoinAndSelect("current_holders.orgChild3", "orgChild3")
|
||||||
.leftJoinAndSelect("current_holders.orgChild4", "orgChild4")
|
.leftJoinAndSelect("current_holders.orgChild4", "orgChild4")
|
||||||
.leftJoinAndSelect("current_holders.positions", "positions")
|
.leftJoinAndSelect("current_holders.positions", "positions")
|
||||||
// .leftJoinAndSelect("positions.posExecutive", "posExecutive")
|
|
||||||
.where("YEAR(profileEmployee.dateRetire) = :year", { year })
|
.where("YEAR(profileEmployee.dateRetire) = :year", { year })
|
||||||
.getMany();
|
.getMany();
|
||||||
|
|
||||||
|
|
@ -3750,23 +3953,6 @@ export class ProfileEmployeeController extends Controller {
|
||||||
item.current_holders.find((x) => x.orgRevisionId == findRevision.id) == null
|
item.current_holders.find((x) => x.orgRevisionId == findRevision.id) == null
|
||||||
? null
|
? null
|
||||||
: item.current_holders.find((x) => x.orgRevisionId == findRevision.id);
|
: item.current_holders.find((x) => x.orgRevisionId == findRevision.id);
|
||||||
// const posExecutive =
|
|
||||||
// position == null ||
|
|
||||||
// item.current_holders
|
|
||||||
// .find((x) => x.orgRevisionId == findRevision.id)
|
|
||||||
// ?.positions?.find((position) => position.positionIsSelected == true)?.posExecutive ==
|
|
||||||
// null ||
|
|
||||||
// item.current_holders
|
|
||||||
// .find((x) => x.orgRevisionId == findRevision.id)
|
|
||||||
// ?.positions?.find((position) => position.positionIsSelected == true)?.posExecutive
|
|
||||||
// ?.posExecutiveName == null
|
|
||||||
// ? null
|
|
||||||
// : item.current_holders
|
|
||||||
// .find((x) => x.orgRevisionId == findRevision.id)
|
|
||||||
// ?.positions?.find((position) => position.positionIsSelected == true)?.posExecutive
|
|
||||||
// .posExecutiveName;
|
|
||||||
// const posExecutiveId =
|
|
||||||
// position == null || position.posExecutive == null ? null : position.posExecutive.id;
|
|
||||||
|
|
||||||
const shortName =
|
const shortName =
|
||||||
item.current_holders.length == 0
|
item.current_holders.length == 0
|
||||||
|
|
@ -3880,8 +4066,6 @@ export class ProfileEmployeeController extends Controller {
|
||||||
posNo: shortName,
|
posNo: shortName,
|
||||||
posMasterNo: posMaster == null ? null : posMaster.posMasterNo,
|
posMasterNo: posMaster == null ? null : posMaster.posMasterNo,
|
||||||
position: item.position,
|
position: item.position,
|
||||||
// posExecutiveId: posExecutiveId,
|
|
||||||
// posExecutiveName: posExecutive,
|
|
||||||
node: node,
|
node: node,
|
||||||
nodeId: nodeId,
|
nodeId: nodeId,
|
||||||
nodeShortName: nodeShortName,
|
nodeShortName: nodeShortName,
|
||||||
|
|
@ -4536,12 +4720,6 @@ export class ProfileEmployeeController extends Controller {
|
||||||
null
|
null
|
||||||
? null
|
? null
|
||||||
: profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgChild4;
|
: profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgChild4;
|
||||||
// const position = await this.positionRepository.findOne({
|
|
||||||
// relations: ["posExecutive"],
|
|
||||||
// where: {
|
|
||||||
// posMasterId: posMaster?.id,
|
|
||||||
// },
|
|
||||||
// });
|
|
||||||
const shortName =
|
const shortName =
|
||||||
profile.current_holders.length == 0
|
profile.current_holders.length == 0
|
||||||
? null
|
? null
|
||||||
|
|
@ -4588,7 +4766,6 @@ export class ProfileEmployeeController extends Controller {
|
||||||
posTypeRank: profile.posType == null ? null : profile.posType.posTypeRank,
|
posTypeRank: profile.posType == null ? null : profile.posType.posTypeRank,
|
||||||
posTypeShortName: profile.posType == null ? null : profile.posType.posTypeShortName,
|
posTypeShortName: profile.posType == null ? null : profile.posType.posTypeShortName,
|
||||||
posTypeId: profile.posType == null ? null : profile.posType.id,
|
posTypeId: profile.posType == null ? null : profile.posType.id,
|
||||||
// posExecutiveName: "",
|
|
||||||
rootId: root == null ? null : root.id,
|
rootId: root == null ? null : root.id,
|
||||||
rootDnaId: root == null ? null : root.ancestorDNA,
|
rootDnaId: root == null ? null : root.ancestorDNA,
|
||||||
root: root == null ? null : root.orgRootName,
|
root: root == null ? null : root.orgRootName,
|
||||||
|
|
|
||||||
|
|
@ -2565,6 +2565,7 @@ export class ProfileEmployeeTempController extends Controller {
|
||||||
.leftJoinAndSelect("current_holders.orgChild2", "orgChild2")
|
.leftJoinAndSelect("current_holders.orgChild2", "orgChild2")
|
||||||
.leftJoinAndSelect("current_holders.orgChild3", "orgChild3")
|
.leftJoinAndSelect("current_holders.orgChild3", "orgChild3")
|
||||||
.leftJoinAndSelect("current_holders.orgChild4", "orgChild4")
|
.leftJoinAndSelect("current_holders.orgChild4", "orgChild4")
|
||||||
|
.andWhere("profile.isLeave = false")
|
||||||
.where("CONCAT(profile.prefix, profile.firstName, ' ', profile.lastName) LIKE :keyword", {
|
.where("CONCAT(profile.prefix, profile.firstName, ' ', profile.lastName) LIKE :keyword", {
|
||||||
keyword: `%${body.keyword}%`,
|
keyword: `%${body.keyword}%`,
|
||||||
})
|
})
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue