Merge branch 'develop' of github.com:Frappet/hrms-api-org into develop
This commit is contained in:
commit
0b754da4b4
5 changed files with 458 additions and 624 deletions
|
|
@ -6151,12 +6151,16 @@ export class ProfileController extends Controller {
|
||||||
"orgRoot.orgRootShortName",
|
"orgRoot.orgRootShortName",
|
||||||
"orgRoot.orgRootOrder",
|
"orgRoot.orgRootOrder",
|
||||||
"orgChild1.orgChild1Name",
|
"orgChild1.orgChild1Name",
|
||||||
|
"orgChild1.orgChild1ShortName",
|
||||||
"orgChild1.orgChild1Order",
|
"orgChild1.orgChild1Order",
|
||||||
"orgChild2.orgChild2Name",
|
"orgChild2.orgChild2Name",
|
||||||
|
"orgChild2.orgChild2ShortName",
|
||||||
"orgChild2.orgChild2Order",
|
"orgChild2.orgChild2Order",
|
||||||
"orgChild3.orgChild3Name",
|
"orgChild3.orgChild3Name",
|
||||||
|
"orgChild3.orgChild3ShortName",
|
||||||
"orgChild3.orgChild3Order",
|
"orgChild3.orgChild3Order",
|
||||||
"orgChild4.orgChild4Name",
|
"orgChild4.orgChild4Name",
|
||||||
|
"orgChild4.orgChild4ShortName",
|
||||||
"orgChild4.orgChild4Order",
|
"orgChild4.orgChild4Order",
|
||||||
])
|
])
|
||||||
.where(node && nodeId ? "current_holders.orgRevisionId = :orgRevisionId" : "1=1", {
|
.where(node && nodeId ? "current_holders.orgRevisionId = :orgRevisionId" : "1=1", {
|
||||||
|
|
@ -6253,6 +6257,21 @@ export class ProfileController extends Controller {
|
||||||
]
|
]
|
||||||
.filter(Boolean)
|
.filter(Boolean)
|
||||||
.join("\n");
|
.join("\n");
|
||||||
|
|
||||||
|
const shortName =
|
||||||
|
!holder
|
||||||
|
? null
|
||||||
|
: holder.orgChild4 != null
|
||||||
|
? `${holder.orgChild4.orgChild4ShortName} ${holder.posMasterNo}`
|
||||||
|
: holder.orgChild3 != null
|
||||||
|
? `${holder.orgChild3.orgChild3ShortName} ${holder.posMasterNo}`
|
||||||
|
: holder.orgChild2 != null
|
||||||
|
? `${holder.orgChild2.orgChild2ShortName} ${holder.posMasterNo}`
|
||||||
|
: holder.orgChild1 != null
|
||||||
|
? `${holder.orgChild1.orgChild1ShortName} ${holder.posMasterNo}`
|
||||||
|
: holder.orgRoot != null
|
||||||
|
? `${holder.orgRoot.orgRootShortName} ${holder.posMasterNo}`
|
||||||
|
: null;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
id: _data.id,
|
id: _data.id,
|
||||||
|
|
@ -6269,7 +6288,7 @@ export class ProfileController extends Controller {
|
||||||
posLevelId: _data.posLevel?.id ?? null,
|
posLevelId: _data.posLevel?.id ?? null,
|
||||||
posTypeId: _data.posType?.id ?? null,
|
posTypeId: _data.posType?.id ?? null,
|
||||||
position: _data.position,
|
position: _data.position,
|
||||||
posNo: holder?.posMasterNo ?? null,
|
posNo: shortName ?? null,
|
||||||
rootId: holder?.orgRoot?.id ?? null,
|
rootId: holder?.orgRoot?.id ?? null,
|
||||||
root: holder?.orgRoot?.orgRootName ?? null,
|
root: holder?.orgRoot?.orgRootName ?? null,
|
||||||
orgRootShortName: holder?.orgRoot?.orgRootShortName ?? null,
|
orgRootShortName: holder?.orgRoot?.orgRootShortName ?? null,
|
||||||
|
|
@ -8245,237 +8264,150 @@ export class ProfileController extends Controller {
|
||||||
*/
|
*/
|
||||||
@Post("search-personal")
|
@Post("search-personal")
|
||||||
async getProfileBySearchKeyword(
|
async getProfileBySearchKeyword(
|
||||||
|
@Request() request: RequestWithUser,
|
||||||
@Query("page") page: number = 1,
|
@Query("page") page: number = 1,
|
||||||
@Query("pageSize") pageSize: number = 10,
|
@Query("pageSize") pageSize: number = 10,
|
||||||
@Body()
|
@Body()
|
||||||
body: {
|
body: {
|
||||||
fieldName?: string | null;
|
fieldName?: string | null;
|
||||||
keyword?: string;
|
keyword?: string;
|
||||||
|
system?: string;
|
||||||
},
|
},
|
||||||
) {
|
) {
|
||||||
let findProfile: any;
|
// ค้นหารายชื่อถ้าไม่ส่ง system มาให้ default ตามทะเบียนประวัติ
|
||||||
let total: any;
|
let _system:string ="SYS_REGISTRY_OFFICER";
|
||||||
let revision = await this.orgRevisionRepo.findOne({ where: { orgRevisionIsCurrent: true } });
|
if(body.system)
|
||||||
const skip = (page - 1) * pageSize;
|
_system = body.system;
|
||||||
const take = pageSize;
|
let _data = await new permission().PermissionOrgList(request, _system);
|
||||||
let queryLike = `CONCAT(
|
const findRevision = await this.orgRevisionRepo.findOne({ where: { orgRevisionIsCurrent: true } });
|
||||||
IFNULL(orgChild4.orgChild4ShortName, '')," ",
|
|
||||||
IFNULL(current_holders.posMasterNo , '')
|
|
||||||
) LIKE :keyword OR CONCAT(
|
|
||||||
IFNULL(orgChild3.orgChild3ShortName, '')," ",
|
|
||||||
IFNULL(current_holders.posMasterNo , '')
|
|
||||||
) LIKE :keyword OR CONCAT(
|
|
||||||
IFNULL(orgChild2.orgChild2ShortName, '')," ",
|
|
||||||
IFNULL(current_holders.posMasterNo , '')
|
|
||||||
) LIKE :keyword OR CONCAT(
|
|
||||||
IFNULL(orgChild1.orgChild1ShortName, '')," ",
|
|
||||||
IFNULL(current_holders.posMasterNo , '')
|
|
||||||
) LIKE :keyword OR CONCAT(
|
|
||||||
IFNULL(orgRoot.orgRootShortName, '')," ",
|
|
||||||
IFNULL(current_holders.posMasterNo , '')
|
|
||||||
) LIKE :keyword`;
|
|
||||||
|
|
||||||
switch (body.fieldName) {
|
|
||||||
case "citizenId":
|
|
||||||
[findProfile, total] = await this.profileRepo.findAndCount({
|
|
||||||
where: {
|
|
||||||
citizenId: Like(`%${body.keyword}%`),
|
|
||||||
current_holders: {
|
|
||||||
orgRevisionId: revision?.id,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
relations: [
|
|
||||||
"posType",
|
|
||||||
"posLevel",
|
|
||||||
"current_holders",
|
|
||||||
"current_holders.orgRoot",
|
|
||||||
"current_holders.orgChild1",
|
|
||||||
"current_holders.orgChild2",
|
|
||||||
"current_holders.orgChild3",
|
|
||||||
"current_holders.orgChild4",
|
|
||||||
],
|
|
||||||
skip,
|
|
||||||
take,
|
|
||||||
});
|
|
||||||
break;
|
|
||||||
|
|
||||||
case "fullName":
|
|
||||||
[findProfile, total] = await this.profileRepo
|
|
||||||
.createQueryBuilder("profile")
|
|
||||||
.leftJoinAndSelect("profile.posType", "posType")
|
|
||||||
.leftJoinAndSelect("profile.posLevel", "posLevel")
|
|
||||||
.leftJoinAndSelect("profile.current_holders", "current_holders")
|
|
||||||
.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.orgRevision = :revisionId", { revisionId: revision?.id })
|
|
||||||
.andWhere(
|
|
||||||
"CONCAT(profile.prefix, profile.firstName, ' ', profile.lastName) LIKE :keyword",
|
|
||||||
{ keyword: `%${body.keyword}%` },
|
|
||||||
)
|
|
||||||
.skip(skip)
|
|
||||||
.take(take)
|
|
||||||
.getManyAndCount();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case "position":
|
|
||||||
[findProfile, total] = await this.profileRepo.findAndCount({
|
|
||||||
where: {
|
|
||||||
position: Like(`%${body.keyword}%`),
|
|
||||||
current_holders: {
|
|
||||||
orgRevisionId: revision?.id,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
relations: [
|
|
||||||
"posType",
|
|
||||||
"posLevel",
|
|
||||||
"current_holders",
|
|
||||||
"current_holders.orgRoot",
|
|
||||||
"current_holders.orgChild1",
|
|
||||||
"current_holders.orgChild2",
|
|
||||||
"current_holders.orgChild3",
|
|
||||||
"current_holders.orgChild4",
|
|
||||||
],
|
|
||||||
skip,
|
|
||||||
take,
|
|
||||||
});
|
|
||||||
break;
|
|
||||||
|
|
||||||
case "posNo":
|
|
||||||
[findProfile, total] = await this.profileRepo
|
|
||||||
.createQueryBuilder("profile")
|
|
||||||
.leftJoinAndSelect("profile.posType", "posType")
|
|
||||||
.leftJoinAndSelect("profile.posLevel", "posLevel")
|
|
||||||
.leftJoinAndSelect("profile.current_holders", "current_holders")
|
|
||||||
.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.orgRevision = :revisionId", { revisionId: revision?.id })
|
|
||||||
.andWhere(
|
|
||||||
new Brackets((qb) => {
|
|
||||||
qb.orWhere(
|
|
||||||
body.keyword != undefined && body.keyword != null && body.keyword != ""
|
|
||||||
? queryLike
|
|
||||||
: "1=1",
|
|
||||||
{
|
|
||||||
keyword: `%${body.keyword}%`,
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}),
|
|
||||||
)
|
|
||||||
.skip(skip)
|
|
||||||
.take(take)
|
|
||||||
.getManyAndCount();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case "posType":
|
|
||||||
[findProfile, total] = await this.profileRepo.findAndCount({
|
|
||||||
where: {
|
|
||||||
posType: {
|
|
||||||
posTypeName: Like(`%${body.keyword}%`),
|
|
||||||
},
|
|
||||||
current_holders: {
|
|
||||||
orgRevisionId: revision?.id,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
relations: [
|
|
||||||
"posType",
|
|
||||||
"posLevel",
|
|
||||||
"current_holders",
|
|
||||||
"current_holders.orgRoot",
|
|
||||||
"current_holders.orgChild1",
|
|
||||||
"current_holders.orgChild2",
|
|
||||||
"current_holders.orgChild3",
|
|
||||||
"current_holders.orgChild4",
|
|
||||||
],
|
|
||||||
skip,
|
|
||||||
take,
|
|
||||||
});
|
|
||||||
break;
|
|
||||||
|
|
||||||
case "posLevel":
|
|
||||||
[findProfile, total] = await this.profileRepo.findAndCount({
|
|
||||||
where: {
|
|
||||||
posLevel: {
|
|
||||||
posLevelName: Like(`%${body.keyword}%`),
|
|
||||||
},
|
|
||||||
current_holders: {
|
|
||||||
orgRevisionId: revision?.id,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
relations: [
|
|
||||||
"posType",
|
|
||||||
"posLevel",
|
|
||||||
"current_holders",
|
|
||||||
"current_holders.orgRoot",
|
|
||||||
"current_holders.orgChild1",
|
|
||||||
"current_holders.orgChild2",
|
|
||||||
"current_holders.orgChild3",
|
|
||||||
"current_holders.orgChild4",
|
|
||||||
],
|
|
||||||
skip,
|
|
||||||
take,
|
|
||||||
});
|
|
||||||
break;
|
|
||||||
|
|
||||||
case "organization":
|
|
||||||
[findProfile, total] = await this.profileRepo.findAndCount({
|
|
||||||
where: {
|
|
||||||
current_holders: {
|
|
||||||
orgRevisionId: revision?.id,
|
|
||||||
orgRoot: {
|
|
||||||
orgRootName: Like(`%${body.keyword}%`),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
relations: [
|
|
||||||
"posType",
|
|
||||||
"posLevel",
|
|
||||||
"current_holders",
|
|
||||||
"current_holders.orgRoot",
|
|
||||||
"current_holders.orgChild1",
|
|
||||||
"current_holders.orgChild2",
|
|
||||||
"current_holders.orgChild3",
|
|
||||||
"current_holders.orgChild4",
|
|
||||||
],
|
|
||||||
skip,
|
|
||||||
take,
|
|
||||||
});
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
[findProfile, total] = await this.profileRepo.findAndCount({
|
|
||||||
where: {
|
|
||||||
current_holders: {
|
|
||||||
orgRevisionId: revision?.id,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
relations: [
|
|
||||||
"posType",
|
|
||||||
"posLevel",
|
|
||||||
"current_holders",
|
|
||||||
"current_holders.orgRoot",
|
|
||||||
"current_holders.orgChild1",
|
|
||||||
"current_holders.orgChild2",
|
|
||||||
"current_holders.orgChild3",
|
|
||||||
"current_holders.orgChild4",
|
|
||||||
],
|
|
||||||
skip,
|
|
||||||
take,
|
|
||||||
});
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
const findRevision = await this.orgRevisionRepo.findOne({
|
|
||||||
where: { orgRevisionIsCurrent: true },
|
|
||||||
});
|
|
||||||
if (!findRevision) {
|
if (!findRevision) {
|
||||||
throw new HttpError(HttpStatus.NOT_FOUND, "not found. OrgRevision");
|
throw new HttpError(HttpStatus.NOT_FOUND, "not found. OrgRevision");
|
||||||
}
|
}
|
||||||
|
// let queryLike = `CONCAT(
|
||||||
|
// IFNULL(orgChild4.orgChild4ShortName, '')," ",
|
||||||
|
// IFNULL(current_holders.posMasterNo , '')
|
||||||
|
// ) LIKE :keyword OR CONCAT(
|
||||||
|
// IFNULL(orgChild3.orgChild3ShortName, '')," ",
|
||||||
|
// IFNULL(current_holders.posMasterNo , '')
|
||||||
|
// ) LIKE :keyword OR CONCAT(
|
||||||
|
// IFNULL(orgChild2.orgChild2ShortName, '')," ",
|
||||||
|
// IFNULL(current_holders.posMasterNo , '')
|
||||||
|
// ) LIKE :keyword OR CONCAT(
|
||||||
|
// IFNULL(orgChild1.orgChild1ShortName, '')," ",
|
||||||
|
// IFNULL(current_holders.posMasterNo , '')
|
||||||
|
// ) LIKE :keyword OR CONCAT(
|
||||||
|
// IFNULL(orgRoot.orgRootShortName, '')," ",
|
||||||
|
// IFNULL(current_holders.posMasterNo , '')
|
||||||
|
// ) LIKE :keyword`;
|
||||||
|
let queryLike = "1=1"
|
||||||
|
switch (body.fieldName) {
|
||||||
|
case "citizenId":
|
||||||
|
queryLike = "profile.citizenId LIKE :keyword";
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "fullName":
|
||||||
|
queryLike = "CONCAT(profile.prefix, profile.firstName, ' ', profile.lastName) LIKE :keyword";
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "position":
|
||||||
|
queryLike = "profile.position LIKE :keyword";
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "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
|
||||||
|
`;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "posType":
|
||||||
|
queryLike = "posType.posTypeName LIKE :keyword";
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "posLevel":
|
||||||
|
queryLike = "posLevel.posLevelName LIKE :keyword";
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "organization":
|
||||||
|
queryLike = "orgRoot.orgRootName LIKE :keyword";
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
queryLike = "1=1"
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
const [findProfile, total] = await this.profileRepo
|
||||||
|
.createQueryBuilder("profile")
|
||||||
|
.leftJoinAndSelect("profile.posType", "posType")
|
||||||
|
.leftJoinAndSelect("profile.posLevel", "posLevel")
|
||||||
|
.leftJoinAndSelect("profile.current_holders", "current_holders")
|
||||||
|
.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.orgRevision = :revisionId", { revisionId: findRevision?.id })
|
||||||
|
.andWhere(
|
||||||
|
_data.root != undefined && _data.root != null
|
||||||
|
? _data.root[0] != null
|
||||||
|
? `current_holders.orgRootId IN (:...root)`
|
||||||
|
: `current_holders.orgRootId is null`
|
||||||
|
: "1=1",
|
||||||
|
{ root: _data.root },
|
||||||
|
)
|
||||||
|
.andWhere(
|
||||||
|
_data.child1 != undefined && _data.child1 != null
|
||||||
|
? _data.child1[0] != null
|
||||||
|
? `current_holders.orgChild1Id IN (:...child1)`
|
||||||
|
: `current_holders.orgChild1Id is null`
|
||||||
|
: "1=1",
|
||||||
|
{ child1: _data.child1 },
|
||||||
|
)
|
||||||
|
.andWhere(
|
||||||
|
_data.child2 != undefined && _data.child2 != null
|
||||||
|
? _data.child2[0] != null
|
||||||
|
? `current_holders.orgChild2Id IN (:...child2)`
|
||||||
|
: `current_holders.orgChild2Id is null`
|
||||||
|
: "1=1",
|
||||||
|
{ child2: _data.child2 },
|
||||||
|
)
|
||||||
|
.andWhere(
|
||||||
|
_data.child3 != undefined && _data.child3 != null
|
||||||
|
? _data.child3[0] != null
|
||||||
|
? `current_holders.orgChild3Id IN (:...child3)`
|
||||||
|
: `current_holders.orgChild3Id is null`
|
||||||
|
: "1=1",
|
||||||
|
{ child3: _data.child3 },
|
||||||
|
)
|
||||||
|
.andWhere(
|
||||||
|
_data.child4 != undefined && _data.child4 != null
|
||||||
|
? _data.child4[0] != null
|
||||||
|
? `current_holders.orgChild4Id IN (:...child4)`
|
||||||
|
: `current_holders.orgChild4Id is null`
|
||||||
|
: "1=1",
|
||||||
|
{ child4: _data.child4 },
|
||||||
|
)
|
||||||
|
.andWhere(
|
||||||
|
new Brackets((qb) => {
|
||||||
|
qb.orWhere(body.keyword ? queryLike : "1=1", { keyword: `%${body.keyword}%` });
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
.skip((page - 1) * pageSize)
|
||||||
|
.take(pageSize)
|
||||||
|
.getManyAndCount();
|
||||||
|
|
||||||
|
// const findRevision = await this.orgRevisionRepo.findOne({
|
||||||
|
// where: { orgRevisionIsCurrent: true },
|
||||||
|
// });
|
||||||
|
// if (!findRevision) {
|
||||||
|
// throw new HttpError(HttpStatus.NOT_FOUND, "not found. OrgRevision");
|
||||||
|
// }
|
||||||
|
|
||||||
const mapDataProfile = await Promise.all(
|
const mapDataProfile = await Promise.all(
|
||||||
findProfile.map(async (item: Profile) => {
|
findProfile.map(async (item: Profile) => {
|
||||||
|
|
|
||||||
|
|
@ -4010,243 +4010,127 @@ export class ProfileEmployeeController extends Controller {
|
||||||
*/
|
*/
|
||||||
@Post("search-personal")
|
@Post("search-personal")
|
||||||
async getProfileBySearchKeyword(
|
async getProfileBySearchKeyword(
|
||||||
|
@Request() request: RequestWithUser,
|
||||||
@Query("page") page: number = 1,
|
@Query("page") page: number = 1,
|
||||||
@Query("pageSize") pageSize: number = 10,
|
@Query("pageSize") pageSize: number = 10,
|
||||||
@Body()
|
@Body()
|
||||||
body: {
|
body: {
|
||||||
fieldName: string;
|
fieldName: string;
|
||||||
keyword?: string;
|
keyword?: string;
|
||||||
|
system?: string;
|
||||||
},
|
},
|
||||||
) {
|
) {
|
||||||
let findProfile: any;
|
// ค้นหารายชื่อถ้าไม่ส่ง system มาให้ default ตามทะเบียนประวัติ
|
||||||
let total: any;
|
let _system:string ="SYS_REGISTRY_EMP";
|
||||||
let revision = await this.orgRevisionRepo.findOne({ where: { orgRevisionIsCurrent: true } });
|
if(body.system)
|
||||||
const skip = (page - 1) * pageSize;
|
_system = body.system;
|
||||||
const take = pageSize;
|
let _data = await new permission().PermissionOrgList(request, _system);
|
||||||
let queryLike = `CONCAT(
|
const findRevision = await this.orgRevisionRepo.findOne({ where: { orgRevisionIsCurrent: true } });
|
||||||
IFNULL(orgChild4.orgChild4ShortName, ''), " ",
|
|
||||||
IFNULL(current_holders.posMasterNo , '')
|
|
||||||
) LIKE :keyword OR CONCAT(
|
|
||||||
IFNULL(orgChild3.orgChild3ShortName, ''), " ",
|
|
||||||
IFNULL(current_holders.posMasterNo , '')
|
|
||||||
) LIKE :keyword OR CONCAT(
|
|
||||||
IFNULL(orgChild2.orgChild2ShortName, ''), " ",
|
|
||||||
IFNULL(current_holders.posMasterNo , '')
|
|
||||||
) LIKE :keyword OR CONCAT(
|
|
||||||
IFNULL(orgChild1.orgChild1ShortName, ''), " ",
|
|
||||||
IFNULL(current_holders.posMasterNo , '')
|
|
||||||
) LIKE :keyword OR CONCAT(
|
|
||||||
IFNULL(orgRoot.orgRootShortName, ''), " ",
|
|
||||||
IFNULL(current_holders.posMasterNo , '')
|
|
||||||
) LIKE :keyword`;
|
|
||||||
|
|
||||||
switch (body.fieldName) {
|
|
||||||
case "citizenId":
|
|
||||||
[findProfile, total] = await this.profileRepo.findAndCount({
|
|
||||||
where: {
|
|
||||||
citizenId: Like(`%${body.keyword}%`),
|
|
||||||
current_holders: {
|
|
||||||
orgRevisionId: revision?.id,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
relations: [
|
|
||||||
"posType",
|
|
||||||
"posLevel",
|
|
||||||
"current_holders",
|
|
||||||
"profileSalary",
|
|
||||||
"current_holders.orgRoot",
|
|
||||||
"current_holders.orgChild1",
|
|
||||||
"current_holders.orgChild2",
|
|
||||||
"current_holders.orgChild3",
|
|
||||||
"current_holders.orgChild4",
|
|
||||||
],
|
|
||||||
skip,
|
|
||||||
take,
|
|
||||||
});
|
|
||||||
break;
|
|
||||||
|
|
||||||
case "fullName":
|
|
||||||
[findProfile, total] = await this.profileRepo
|
|
||||||
.createQueryBuilder("profile")
|
|
||||||
.leftJoinAndSelect("profile.posType", "posType")
|
|
||||||
.leftJoinAndSelect("profile.posLevel", "posLevel")
|
|
||||||
.leftJoinAndSelect("profile.current_holders", "current_holders")
|
|
||||||
.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.orgRevision = :revisionId", { revisionId: revision?.id })
|
|
||||||
.andWhere(
|
|
||||||
"CONCAT(profile.prefix, profile.firstName, ' ', profile.lastName) LIKE :keyword",
|
|
||||||
{ keyword: `%${body.keyword}%` },
|
|
||||||
)
|
|
||||||
.skip(skip)
|
|
||||||
.take(take)
|
|
||||||
.getManyAndCount();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case "position":
|
|
||||||
[findProfile, total] = await this.profileRepo.findAndCount({
|
|
||||||
where: {
|
|
||||||
position: Like(`%${body.keyword}%`),
|
|
||||||
current_holders: {
|
|
||||||
orgRevisionId: revision?.id,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
relations: [
|
|
||||||
"posType",
|
|
||||||
"posLevel",
|
|
||||||
"current_holders",
|
|
||||||
"profileSalary",
|
|
||||||
"current_holders.orgRoot",
|
|
||||||
"current_holders.orgChild1",
|
|
||||||
"current_holders.orgChild2",
|
|
||||||
"current_holders.orgChild3",
|
|
||||||
"current_holders.orgChild4",
|
|
||||||
],
|
|
||||||
skip,
|
|
||||||
take,
|
|
||||||
});
|
|
||||||
break;
|
|
||||||
|
|
||||||
case "posNo":
|
|
||||||
[findProfile, total] = await this.profileRepo
|
|
||||||
.createQueryBuilder("profile")
|
|
||||||
.leftJoinAndSelect("profile.posType", "posType")
|
|
||||||
.leftJoinAndSelect("profile.posLevel", "posLevel")
|
|
||||||
.leftJoinAndSelect("profile.current_holders", "current_holders")
|
|
||||||
.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.orgRevision = :revisionId", { revisionId: revision?.id })
|
|
||||||
.andWhere(
|
|
||||||
new Brackets((qb) => {
|
|
||||||
qb.orWhere(
|
|
||||||
body.keyword != undefined && body.keyword != null && body.keyword != ""
|
|
||||||
? queryLike
|
|
||||||
: "1=1",
|
|
||||||
{
|
|
||||||
keyword: `%${body.keyword}%`,
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}),
|
|
||||||
)
|
|
||||||
.skip(skip)
|
|
||||||
.take(take)
|
|
||||||
.getManyAndCount();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case "posType":
|
|
||||||
[findProfile, total] = await this.profileRepo.findAndCount({
|
|
||||||
where: {
|
|
||||||
posType: {
|
|
||||||
posTypeName: Like(`%${body.keyword}%`),
|
|
||||||
},
|
|
||||||
current_holders: {
|
|
||||||
orgRevisionId: revision?.id,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
relations: [
|
|
||||||
"posType",
|
|
||||||
"posLevel",
|
|
||||||
"current_holders",
|
|
||||||
"profileSalary",
|
|
||||||
"current_holders.orgRoot",
|
|
||||||
"current_holders.orgChild1",
|
|
||||||
"current_holders.orgChild2",
|
|
||||||
"current_holders.orgChild3",
|
|
||||||
"current_holders.orgChild4",
|
|
||||||
],
|
|
||||||
skip,
|
|
||||||
take,
|
|
||||||
});
|
|
||||||
break;
|
|
||||||
|
|
||||||
// case "posLevel":
|
|
||||||
// [findProfile, total] = await this.profileRepo.findAndCount({
|
|
||||||
// where: {
|
|
||||||
// posLevel: {
|
|
||||||
// posLevelName: Like(`%${body.keyword}%`),
|
|
||||||
// },
|
|
||||||
// current_holders: {
|
|
||||||
// orgRevisionId: revision?.id,
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
// relations: [
|
|
||||||
// "posType",
|
|
||||||
// "posLevel",
|
|
||||||
// "current_holders",
|
|
||||||
// "profileSalary",
|
|
||||||
// "current_holders.orgRoot",
|
|
||||||
// "current_holders.orgChild1",
|
|
||||||
// "current_holders.orgChild2",
|
|
||||||
// "current_holders.orgChild3",
|
|
||||||
// "current_holders.orgChild4",
|
|
||||||
// ],
|
|
||||||
// skip,
|
|
||||||
// take,
|
|
||||||
// });
|
|
||||||
// break;
|
|
||||||
|
|
||||||
case "organization":
|
|
||||||
[findProfile, total] = await this.profileRepo.findAndCount({
|
|
||||||
where: {
|
|
||||||
current_holders: {
|
|
||||||
orgRevisionId: revision?.id,
|
|
||||||
orgRoot: {
|
|
||||||
orgRootName: Like(`%${body.keyword}%`),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
relations: [
|
|
||||||
"posType",
|
|
||||||
"posLevel",
|
|
||||||
"current_holders",
|
|
||||||
"profileSalary",
|
|
||||||
"current_holders.orgRoot",
|
|
||||||
"current_holders.orgChild1",
|
|
||||||
"current_holders.orgChild2",
|
|
||||||
"current_holders.orgChild3",
|
|
||||||
"current_holders.orgChild4",
|
|
||||||
],
|
|
||||||
skip,
|
|
||||||
take,
|
|
||||||
});
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
[findProfile, total] = await this.profileRepo.findAndCount({
|
|
||||||
where: {
|
|
||||||
current_holders: {
|
|
||||||
orgRevisionId: revision?.id,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
relations: [
|
|
||||||
"posType",
|
|
||||||
"posLevel",
|
|
||||||
"current_holders",
|
|
||||||
"profileSalary",
|
|
||||||
"current_holders.orgRoot",
|
|
||||||
"current_holders.orgChild1",
|
|
||||||
"current_holders.orgChild2",
|
|
||||||
"current_holders.orgChild3",
|
|
||||||
"current_holders.orgChild4",
|
|
||||||
],
|
|
||||||
skip,
|
|
||||||
take,
|
|
||||||
});
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
const findRevision = await this.orgRevisionRepo.findOne({
|
|
||||||
where: { orgRevisionIsCurrent: true },
|
|
||||||
});
|
|
||||||
if (!findRevision) {
|
if (!findRevision) {
|
||||||
throw new HttpError(HttpStatus.NOT_FOUND, "not found. OrgRevision");
|
throw new HttpError(HttpStatus.NOT_FOUND, "not found. OrgRevision");
|
||||||
}
|
}
|
||||||
|
let queryLike = "1=1"
|
||||||
|
switch (body.fieldName) {
|
||||||
|
case "citizenId":
|
||||||
|
queryLike = "profile.citizenId LIKE :keyword";
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "fullName":
|
||||||
|
queryLike = "CONCAT(profile.prefix, profile.firstName, ' ', profile.lastName) LIKE :keyword";
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "position":
|
||||||
|
queryLike = "profile.position LIKE :keyword";
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "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
|
||||||
|
`;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "posType":
|
||||||
|
queryLike = "posType.posTypeName LIKE :keyword";
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "posLevel":
|
||||||
|
queryLike = "posLevel.posLevelName LIKE :keyword";
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "organization":
|
||||||
|
queryLike = "orgRoot.orgRootName LIKE :keyword";
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
queryLike = "1=1"
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
const [findProfile, total] = await this.profileRepo
|
||||||
|
.createQueryBuilder("profile")
|
||||||
|
.leftJoinAndSelect("profile.posType", "posType")
|
||||||
|
.leftJoinAndSelect("profile.posLevel", "posLevel")
|
||||||
|
.leftJoinAndSelect("profile.current_holders", "current_holders")
|
||||||
|
.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.orgRevision = :revisionId", { revisionId: findRevision?.id })
|
||||||
|
.andWhere(
|
||||||
|
_data.root != undefined && _data.root != null
|
||||||
|
? _data.root[0] != null
|
||||||
|
? `current_holders.orgRootId IN (:...root)`
|
||||||
|
: `current_holders.orgRootId is null`
|
||||||
|
: "1=1",
|
||||||
|
{ root: _data.root },
|
||||||
|
)
|
||||||
|
.andWhere(
|
||||||
|
_data.child1 != undefined && _data.child1 != null
|
||||||
|
? _data.child1[0] != null
|
||||||
|
? `current_holders.orgChild1Id IN (:...child1)`
|
||||||
|
: `current_holders.orgChild1Id is null`
|
||||||
|
: "1=1",
|
||||||
|
{ child1: _data.child1 },
|
||||||
|
)
|
||||||
|
.andWhere(
|
||||||
|
_data.child2 != undefined && _data.child2 != null
|
||||||
|
? _data.child2[0] != null
|
||||||
|
? `current_holders.orgChild2Id IN (:...child2)`
|
||||||
|
: `current_holders.orgChild2Id is null`
|
||||||
|
: "1=1",
|
||||||
|
{ child2: _data.child2 },
|
||||||
|
)
|
||||||
|
.andWhere(
|
||||||
|
_data.child3 != undefined && _data.child3 != null
|
||||||
|
? _data.child3[0] != null
|
||||||
|
? `current_holders.orgChild3Id IN (:...child3)`
|
||||||
|
: `current_holders.orgChild3Id is null`
|
||||||
|
: "1=1",
|
||||||
|
{ child3: _data.child3 },
|
||||||
|
)
|
||||||
|
.andWhere(
|
||||||
|
_data.child4 != undefined && _data.child4 != null
|
||||||
|
? _data.child4[0] != null
|
||||||
|
? `current_holders.orgChild4Id IN (:...child4)`
|
||||||
|
: `current_holders.orgChild4Id is null`
|
||||||
|
: "1=1",
|
||||||
|
{ child4: _data.child4 },
|
||||||
|
)
|
||||||
|
.andWhere(
|
||||||
|
new Brackets((qb) => {
|
||||||
|
qb.orWhere(body.keyword ? queryLike : "1=1", { keyword: `%${body.keyword}%` });
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
.skip((page - 1) * pageSize)
|
||||||
|
.take(pageSize)
|
||||||
|
.getManyAndCount();
|
||||||
|
|
||||||
const mapDataProfile = await Promise.all(
|
const mapDataProfile = await Promise.all(
|
||||||
findProfile.map(async (item: ProfileEmployee) => {
|
findProfile.map(async (item: ProfileEmployee) => {
|
||||||
|
|
|
||||||
|
|
@ -2174,150 +2174,162 @@ export class ProfileEmployeeTempController extends Controller {
|
||||||
*/
|
*/
|
||||||
@Post("search-personal")
|
@Post("search-personal")
|
||||||
async getProfileBySearchKeyword(
|
async getProfileBySearchKeyword(
|
||||||
|
@Request() request: RequestWithUser,
|
||||||
@Query("page") page: number = 1,
|
@Query("page") page: number = 1,
|
||||||
@Query("pageSize") pageSize: number = 10,
|
@Query("pageSize") pageSize: number = 10,
|
||||||
@Body()
|
@Body()
|
||||||
body: {
|
body: {
|
||||||
fieldName: string;
|
fieldName: string;
|
||||||
keyword?: string;
|
keyword?: string;
|
||||||
|
system?: string;
|
||||||
},
|
},
|
||||||
) {
|
) {
|
||||||
let findProfile: any;
|
// ค้นหารายชื่อถ้าไม่ส่ง system มาให้ default ตามทะเบียนประวัติ
|
||||||
let total: any;
|
let _system:string ="SYS_REGISTRY_TEMP";
|
||||||
const skip = (page - 1) * pageSize;
|
if(body.system)
|
||||||
const take = pageSize;
|
_system = body.system;
|
||||||
switch (body.fieldName) {
|
let _data = await new permission().PermissionOrgList(request, _system);
|
||||||
case "citizenId":
|
const findRevision = await this.orgRevisionRepo.findOne({ where: { orgRevisionIsCurrent: true } });
|
||||||
[findProfile, total] = await this.profileRepo.findAndCount({
|
|
||||||
where: { citizenId: Like(`%${body.keyword}%`) },
|
|
||||||
relations: [
|
|
||||||
"posType",
|
|
||||||
"posLevel",
|
|
||||||
"current_holders",
|
|
||||||
"current_holders.orgRoot",
|
|
||||||
"current_holders.orgChild1",
|
|
||||||
"current_holders.orgChild2",
|
|
||||||
"current_holders.orgChild3",
|
|
||||||
"current_holders.orgChild4",
|
|
||||||
],
|
|
||||||
skip,
|
|
||||||
take,
|
|
||||||
});
|
|
||||||
break;
|
|
||||||
|
|
||||||
case "firstname":
|
|
||||||
[findProfile, total] = await this.profileRepo.findAndCount({
|
|
||||||
where: { firstName: Like(`%${body.keyword}%`) },
|
|
||||||
relations: [
|
|
||||||
"posType",
|
|
||||||
"posLevel",
|
|
||||||
"current_holders",
|
|
||||||
"current_holders.orgRoot",
|
|
||||||
"current_holders.orgChild1",
|
|
||||||
"current_holders.orgChild2",
|
|
||||||
"current_holders.orgChild3",
|
|
||||||
"current_holders.orgChild4",
|
|
||||||
],
|
|
||||||
skip,
|
|
||||||
take,
|
|
||||||
});
|
|
||||||
break;
|
|
||||||
|
|
||||||
case "lastname":
|
|
||||||
[findProfile, total] = await this.profileRepo.findAndCount({
|
|
||||||
where: { lastName: Like(`%${body.keyword}%`) },
|
|
||||||
relations: [
|
|
||||||
"posType",
|
|
||||||
"posLevel",
|
|
||||||
"current_holders",
|
|
||||||
"current_holders.orgRoot",
|
|
||||||
"current_holders.orgChild1",
|
|
||||||
"current_holders.orgChild2",
|
|
||||||
"current_holders.orgChild3",
|
|
||||||
"current_holders.orgChild4",
|
|
||||||
],
|
|
||||||
skip,
|
|
||||||
take,
|
|
||||||
});
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
[findProfile, total] = await this.profileRepo.findAndCount({
|
|
||||||
relations: [
|
|
||||||
"posType",
|
|
||||||
"posLevel",
|
|
||||||
"current_holders",
|
|
||||||
"current_holders.orgRoot",
|
|
||||||
"current_holders.orgChild1",
|
|
||||||
"current_holders.orgChild2",
|
|
||||||
"current_holders.orgChild3",
|
|
||||||
"current_holders.orgChild4",
|
|
||||||
],
|
|
||||||
skip,
|
|
||||||
take,
|
|
||||||
});
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
const findRevision = await this.orgRevisionRepo.findOne({
|
|
||||||
where: { orgRevisionIsCurrent: true },
|
|
||||||
});
|
|
||||||
if (!findRevision) {
|
if (!findRevision) {
|
||||||
throw new HttpError(HttpStatus.NOT_FOUND, "not found. OrgRevision");
|
throw new HttpError(HttpStatus.NOT_FOUND, "not found. OrgRevision");
|
||||||
}
|
}
|
||||||
|
let queryLike = "1=1"
|
||||||
|
switch (body.fieldName) {
|
||||||
|
case "citizenId":
|
||||||
|
queryLike = "profile.citizenId LIKE :keyword";
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "firstname":
|
||||||
|
queryLike = "profile.firstName LIKE :keyword";
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "lastname":
|
||||||
|
queryLike = "profile.lastName LIKE :keyword";
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "fullName":
|
||||||
|
queryLike = "CONCAT(profile.prefix, profile.firstName, ' ', profile.lastName) LIKE :keyword";
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
queryLike = "1=1"
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
const [findProfile, total] = await this.profileRepo
|
||||||
|
.createQueryBuilder("profile")
|
||||||
|
.leftJoinAndSelect("profile.posType", "posType")
|
||||||
|
.leftJoinAndSelect("profile.posLevel", "posLevel")
|
||||||
|
// .leftJoinAndSelect("profile.current_holders", "current_holders")
|
||||||
|
.leftJoinAndSelect("profile.current_holderTemps", "current_holderTemps")
|
||||||
|
.leftJoinAndSelect("current_holderTemps.orgRoot", "orgRoot")
|
||||||
|
.leftJoinAndSelect("current_holderTemps.orgChild1", "orgChild1")
|
||||||
|
.leftJoinAndSelect("current_holderTemps.orgChild2", "orgChild2")
|
||||||
|
.leftJoinAndSelect("current_holderTemps.orgChild3", "orgChild3")
|
||||||
|
.leftJoinAndSelect("current_holderTemps.orgChild4", "orgChild4")
|
||||||
|
.where("current_holderTemps.orgRevision = :revisionId", { revisionId: findRevision?.id })
|
||||||
|
.andWhere("profile.employeeClass = :employeeClass", { employeeClass: "TEMP" })
|
||||||
|
.andWhere(
|
||||||
|
_data.root != undefined && _data.root != null
|
||||||
|
? _data.root[0] != null
|
||||||
|
? `current_holderTemps.orgRootId IN (:...root)`
|
||||||
|
: `current_holderTemps.orgRootId is null`
|
||||||
|
: "1=1",
|
||||||
|
{ root: _data.root },
|
||||||
|
)
|
||||||
|
.andWhere(
|
||||||
|
_data.child1 != undefined && _data.child1 != null
|
||||||
|
? _data.child1[0] != null
|
||||||
|
? `current_holderTemps.orgChild1Id IN (:...child1)`
|
||||||
|
: `current_holderTemps.orgChild1Id is null`
|
||||||
|
: "1=1",
|
||||||
|
{ child1: _data.child1 },
|
||||||
|
)
|
||||||
|
.andWhere(
|
||||||
|
_data.child2 != undefined && _data.child2 != null
|
||||||
|
? _data.child2[0] != null
|
||||||
|
? `current_holderTemps.orgChild2Id IN (:...child2)`
|
||||||
|
: `current_holderTemps.orgChild2Id is null`
|
||||||
|
: "1=1",
|
||||||
|
{ child2: _data.child2 },
|
||||||
|
)
|
||||||
|
.andWhere(
|
||||||
|
_data.child3 != undefined && _data.child3 != null
|
||||||
|
? _data.child3[0] != null
|
||||||
|
? `current_holderTemps.orgChild3Id IN (:...child3)`
|
||||||
|
: `current_holderTemps.orgChild3Id is null`
|
||||||
|
: "1=1",
|
||||||
|
{ child3: _data.child3 },
|
||||||
|
)
|
||||||
|
.andWhere(
|
||||||
|
_data.child4 != undefined && _data.child4 != null
|
||||||
|
? _data.child4[0] != null
|
||||||
|
? `current_holderTemps.orgChild4Id IN (:...child4)`
|
||||||
|
: `current_holderTemps.orgChild4Id is null`
|
||||||
|
: "1=1",
|
||||||
|
{ child4: _data.child4 },
|
||||||
|
)
|
||||||
|
.andWhere(
|
||||||
|
new Brackets((qb) => {
|
||||||
|
qb.orWhere(body.keyword ? queryLike : "1=1", { keyword: `%${body.keyword}%` });
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
.skip((page - 1) * pageSize)
|
||||||
|
.take(pageSize)
|
||||||
|
.getManyAndCount();
|
||||||
|
|
||||||
const mapDataProfile = await Promise.all(
|
const mapDataProfile = await Promise.all(
|
||||||
findProfile.map(async (item: ProfileEmployee) => {
|
findProfile.map(async (item: ProfileEmployee) => {
|
||||||
const fullName = `${item.prefix} ${item.firstName} ${item.lastName}`;
|
const fullName = `${item.prefix} ${item.firstName} ${item.lastName}`;
|
||||||
const shortName =
|
const shortName =
|
||||||
item.current_holders.length == 0
|
item.current_holderTemps.length == 0
|
||||||
? null
|
? null
|
||||||
: item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null &&
|
: item.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id) != null &&
|
||||||
item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild4 !=
|
item.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id)?.orgChild4 !=
|
||||||
null
|
null
|
||||||
? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild4.orgChild4ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
? `${item.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id)?.orgChild4.orgChild4ShortName} ${item.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
||||||
: item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null &&
|
: item.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id) != null &&
|
||||||
item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild3 !=
|
item.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id)?.orgChild3 !=
|
||||||
null
|
null
|
||||||
? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild3.orgChild3ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
? `${item.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id)?.orgChild3.orgChild3ShortName} ${item.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
||||||
: item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null &&
|
: item.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id) != null &&
|
||||||
item.current_holders.find((x) => x.orgRevisionId == findRevision.id)
|
item.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id)
|
||||||
?.orgChild2 != null
|
?.orgChild2 != null
|
||||||
? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild2.orgChild2ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
? `${item.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id)?.orgChild2.orgChild2ShortName} ${item.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
||||||
: item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null &&
|
: item.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id) != null &&
|
||||||
item.current_holders.find((x) => x.orgRevisionId == findRevision.id)
|
item.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id)
|
||||||
?.orgChild1 != null
|
?.orgChild1 != null
|
||||||
? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild1.orgChild1ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
? `${item.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id)?.orgChild1.orgChild1ShortName} ${item.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
||||||
: item.current_holders.find((x) => x.orgRevisionId == findRevision.id) !=
|
: item.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id) !=
|
||||||
null &&
|
null &&
|
||||||
item.current_holders.find((x) => x.orgRevisionId == findRevision.id)
|
item.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id)
|
||||||
?.orgRoot != null
|
?.orgRoot != null
|
||||||
? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgRoot.orgRootShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
? `${item.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id)?.orgRoot.orgRootShortName} ${item.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
||||||
: null;
|
: null;
|
||||||
|
|
||||||
const root =
|
const root =
|
||||||
item.current_holders.length == 0 ||
|
item.current_holderTemps.length == 0 ||
|
||||||
(item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null &&
|
(item.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id) != null &&
|
||||||
item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgRoot == null)
|
item.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id)?.orgRoot == null)
|
||||||
? null
|
? null
|
||||||
: item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgRoot;
|
: item.current_holderTemps.find((x) => x.orgRevisionId == findRevision.id)?.orgRoot;
|
||||||
|
|
||||||
const rootHolder = item.current_holders?.find(
|
const rootHolder = item.current_holderTemps?.find(
|
||||||
(x) => x.orgRevisionId == findRevision.id,
|
(x) => x.orgRevisionId == findRevision.id,
|
||||||
)?.orgRoot;
|
)?.orgRoot;
|
||||||
const child1Holder = item.current_holders?.find(
|
const child1Holder = item.current_holderTemps?.find(
|
||||||
(x) => x.orgRevisionId == findRevision.id,
|
(x) => x.orgRevisionId == findRevision.id,
|
||||||
)?.orgChild1;
|
)?.orgChild1;
|
||||||
const child2Holder = item.current_holders?.find(
|
const child2Holder = item.current_holderTemps?.find(
|
||||||
(x) => x.orgRevisionId == findRevision.id,
|
(x) => x.orgRevisionId == findRevision.id,
|
||||||
)?.orgChild2;
|
)?.orgChild2;
|
||||||
const child3Holder = item.current_holders?.find(
|
const child3Holder = item.current_holderTemps?.find(
|
||||||
(x) => x.orgRevisionId == findRevision.id,
|
(x) => x.orgRevisionId == findRevision.id,
|
||||||
)?.orgChild3;
|
)?.orgChild3;
|
||||||
const child4Holder = item.current_holders?.find(
|
const child4Holder = item.current_holderTemps?.find(
|
||||||
(x) => x.orgRevisionId == findRevision.id,
|
(x) => x.orgRevisionId == findRevision.id,
|
||||||
)?.orgChild4;
|
)?.orgChild4;
|
||||||
const posMasterNo = item.current_holders?.find(
|
const posMasterNo = item.current_holderTemps?.find(
|
||||||
(x) => x.orgRevisionId == findRevision.id,
|
(x) => x.orgRevisionId == findRevision.id,
|
||||||
)?.posMasterNo;
|
)?.posMasterNo;
|
||||||
|
|
||||||
|
|
@ -2369,7 +2381,10 @@ export class ProfileEmployeeTempController extends Controller {
|
||||||
posTypeId: item.posTypeId,
|
posTypeId: item.posTypeId,
|
||||||
posTypeName: item.posType?.posTypeName,
|
posTypeName: item.posType?.posTypeName,
|
||||||
posLevelId: item.posLevelId,
|
posLevelId: item.posLevelId,
|
||||||
posLevelName: item.posLevel?.posLevelName,
|
posLevelName:
|
||||||
|
item.posLevel == null && item.posType == null
|
||||||
|
? null
|
||||||
|
: `${item.posType?.posTypeShortName} ${item.posLevel?.posLevelName}`,
|
||||||
educationDegree:
|
educationDegree:
|
||||||
latestProfileEducation != null && latestProfileEducation.educationLevel != null
|
latestProfileEducation != null && latestProfileEducation.educationLevel != null
|
||||||
? latestProfileEducation.educationLevel
|
? latestProfileEducation.educationLevel
|
||||||
|
|
@ -3972,7 +3987,10 @@ export class ProfileEmployeeTempController extends Controller {
|
||||||
posTypeId: item.posTypeId,
|
posTypeId: item.posTypeId,
|
||||||
posTypeName: item.posType?.posTypeName,
|
posTypeName: item.posType?.posTypeName,
|
||||||
posLevelId: item.posLevelId,
|
posLevelId: item.posLevelId,
|
||||||
posLevelName: item.posLevel?.posLevelName,
|
posLevelName:
|
||||||
|
item.posLevel == null && item.posType == null
|
||||||
|
? null
|
||||||
|
: `${item.posType?.posTypeShortName} ${item.posLevel?.posLevelName}`,
|
||||||
educationDegree:
|
educationDegree:
|
||||||
latestProfileEducation != null && latestProfileEducation.educationLevel != null
|
latestProfileEducation != null && latestProfileEducation.educationLevel != null
|
||||||
? latestProfileEducation.educationLevel
|
? latestProfileEducation.educationLevel
|
||||||
|
|
|
||||||
|
|
@ -213,7 +213,7 @@ export class ProfileGovernmentHistoryController extends Controller {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
// if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||||
const fullNameParts = [
|
const fullNameParts = [
|
||||||
posMaster == null || posMaster.orgChild4 == null ? null : posMaster.orgChild4.orgChild4Name,
|
posMaster == null || posMaster.orgChild4 == null ? null : posMaster.orgChild4.orgChild4Name,
|
||||||
posMaster == null || posMaster.orgChild3 == null ? null : posMaster.orgChild3.orgChild3Name,
|
posMaster == null || posMaster.orgChild3 == null ? null : posMaster.orgChild3.orgChild3Name,
|
||||||
|
|
@ -248,31 +248,31 @@ export class ProfileGovernmentHistoryController extends Controller {
|
||||||
}
|
}
|
||||||
const orgLeave = _OrgLeave.filter((x:any) => x !== undefined && x !== null).join("\n");
|
const orgLeave = _OrgLeave.filter((x:any) => x !== undefined && x !== null).join("\n");
|
||||||
const data = {
|
const data = {
|
||||||
org: record.isLeave == false ? org : orgLeave, //สังกัด
|
org: record?.isLeave == false ? org : orgLeave, //สังกัด
|
||||||
positionField: position == null ? null : position.positionField, //สายงาน
|
positionField: position == null ? null : position.positionField, //สายงาน
|
||||||
position: record.position, //ตำแหน่ง
|
position: record?.position, //ตำแหน่ง
|
||||||
posLevel: record.posLevel == null ? null : record.posLevel.posLevelName, //ระดับ
|
posLevel: record?.posLevel == null ? null : record?.posLevel.posLevelName, //ระดับ
|
||||||
posMasterNo: record.isLeave == false
|
posMasterNo: record?.isLeave == false
|
||||||
? posMaster == null ? null : `${orgShortName} ${posMaster.posMasterNo}`
|
? posMaster == null ? null : `${orgShortName} ${posMaster.posMasterNo}`
|
||||||
: record.profileSalary.length > 0
|
: record && record?.profileSalary.length > 0
|
||||||
? `${record.profileSalary[0].posNoAbb} ${record.profileSalary[0].posNo}`
|
? `${record?.profileSalary[0].posNoAbb} ${record?.profileSalary[0].posNo}`
|
||||||
: null, //เลขที่ตำแหน่ง
|
: null, //เลขที่ตำแหน่ง
|
||||||
posType: record.posType == null ? null : record.posType.posTypeName, //ประเภท
|
posType: record?.posType == null ? null : record?.posType.posTypeName, //ประเภท
|
||||||
posExecutive:
|
posExecutive:
|
||||||
position == null || position.posExecutive == null
|
position == null || position.posExecutive == null
|
||||||
? null
|
? null
|
||||||
: position.posExecutive.posExecutiveName, //ตำแหน่งทางการบริหาร
|
: position.posExecutive.posExecutiveName, //ตำแหน่งทางการบริหาร
|
||||||
positionArea: position == null ? null : position.positionArea, //ด้าน/สาขา
|
positionArea: position == null ? null : position.positionArea, //ด้าน/สาขา
|
||||||
positionExecutiveField: position == null ? null : position.positionExecutiveField, //ด้านทางการบริหาร
|
positionExecutiveField: position == null ? null : position.positionExecutiveField, //ด้านทางการบริหาร
|
||||||
dateLeave: record.birthDate == null ? null : calculateRetireDate(record.birthDate),
|
dateLeave: record?.birthDate == null ? null : calculateRetireDate(record?.birthDate),
|
||||||
dateRetireLaw: record.dateRetireLaw ?? null,
|
dateRetireLaw: record?.dateRetireLaw ?? null,
|
||||||
// govAge: record.dateStart == null ? null : calculateAge(record.dateStart),
|
// govAge: record?.dateStart == null ? null : calculateAge(record?.dateStart),
|
||||||
govAge: await calculateGovAge(profileId, "OFFICER"),
|
govAge: await calculateGovAge(profileId, "OFFICER"),
|
||||||
dateAppoint: record.dateAppoint,
|
dateAppoint: record?.dateAppoint,
|
||||||
dateStart: record.dateStart,
|
dateStart: record?.dateStart,
|
||||||
govAgeAbsent: record.govAgeAbsent,
|
govAgeAbsent: record?.govAgeAbsent,
|
||||||
govAgePlus: record.govAgePlus,
|
govAgePlus: record?.govAgePlus,
|
||||||
reasonSameDate: record.reasonSameDate,
|
reasonSameDate: record?.reasonSameDate,
|
||||||
};
|
};
|
||||||
|
|
||||||
return new HttpSuccess(data);
|
return new HttpSuccess(data);
|
||||||
|
|
@ -349,7 +349,7 @@ export class ProfileGovernmentHistoryController extends Controller {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
// if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||||
const fullNameParts = [
|
const fullNameParts = [
|
||||||
posMaster == null || posMaster.orgChild4 == null ? null : posMaster.orgChild4.orgChild4Name,
|
posMaster == null || posMaster.orgChild4 == null ? null : posMaster.orgChild4.orgChild4Name,
|
||||||
posMaster == null || posMaster.orgChild3 == null ? null : posMaster.orgChild3.orgChild3Name,
|
posMaster == null || posMaster.orgChild3 == null ? null : posMaster.orgChild3.orgChild3Name,
|
||||||
|
|
@ -384,35 +384,35 @@ export class ProfileGovernmentHistoryController extends Controller {
|
||||||
}
|
}
|
||||||
const orgLeave = _OrgLeave.filter((x:any) => x !== undefined && x !== null).join("\n");
|
const orgLeave = _OrgLeave.filter((x:any) => x !== undefined && x !== null).join("\n");
|
||||||
const data = {
|
const data = {
|
||||||
org: record.isLeave == false ? org : orgLeave, //สังกัด
|
org: record?.isLeave == false ? org : orgLeave, //สังกัด
|
||||||
positionField: position == null ? null : position.positionField, //สายงาน
|
positionField: position == null ? null : position.positionField, //สายงาน
|
||||||
position: record.position, //ตำแหน่ง
|
position: record?.position, //ตำแหน่ง
|
||||||
posLevel: record.posLevel == null ? null : record.posLevel.posLevelName, //ระดับ
|
posLevel: record?.posLevel == null ? null : record?.posLevel.posLevelName, //ระดับ
|
||||||
posMasterNo:
|
posMasterNo:
|
||||||
record.isLeave == false
|
record?.isLeave == false
|
||||||
? posMaster == null
|
? posMaster == null
|
||||||
? null
|
? null
|
||||||
: `${orgShortName} ${posMaster.posMasterNo}`
|
: `${orgShortName} ${posMaster.posMasterNo}`
|
||||||
: record?.profileSalary.length > 0
|
: record && record.profileSalary.length > 0
|
||||||
? `${record.profileSalary[0].posNoAbb} ${record.profileSalary[0].posNo}`
|
? `${record?.profileSalary[0].posNoAbb} ${record?.profileSalary[0].posNo}`
|
||||||
: null, //เลขที่ตำแหน่ง
|
: null, //เลขที่ตำแหน่ง
|
||||||
posType: record.posType == null ? null : record.posType.posTypeName, //ประเภท
|
posType: record?.posType == null ? null : record?.posType.posTypeName, //ประเภท
|
||||||
posExecutive:
|
posExecutive:
|
||||||
position == null || position.posExecutive == null
|
position == null || position.posExecutive == null
|
||||||
? null
|
? null
|
||||||
: position.posExecutive.posExecutiveName, //ตำแหน่งทางการบริหาร
|
: position.posExecutive.posExecutiveName, //ตำแหน่งทางการบริหาร
|
||||||
positionArea: position == null ? null : position.positionArea, //ด้าน/สาขา
|
positionArea: position == null ? null : position.positionArea, //ด้าน/สาขา
|
||||||
positionExecutiveField: position == null ? null : position.positionExecutiveField, //ด้านทางการบริหาร
|
positionExecutiveField: position == null ? null : position.positionExecutiveField, //ด้านทางการบริหาร
|
||||||
dateLeave: record.birthDate == null ? null : calculateRetireDate(record.birthDate),
|
dateLeave: record?.birthDate == null ? null : calculateRetireDate(record?.birthDate),
|
||||||
dateRetireLaw: record.dateRetireLaw ?? null,
|
dateRetireLaw: record?.dateRetireLaw ?? null,
|
||||||
// govAge: record.dateStart == null ? null : calculateAge(record.dateStart),
|
// govAge: record?.dateStart == null ? null : calculateAge(record?.dateStart),
|
||||||
govAge: await calculateGovAge(profileId, "OFFICER"),
|
govAge: await calculateGovAge(profileId, "OFFICER"),
|
||||||
dateAppoint: record.dateAppoint,
|
dateAppoint: record?.dateAppoint,
|
||||||
dateStart: record.dateStart,
|
dateStart: record?.dateStart,
|
||||||
govAgeAbsent: record.govAgeAbsent,
|
govAgeAbsent: record?.govAgeAbsent,
|
||||||
govAgePlus: record.govAgePlus,
|
govAgePlus: record?.govAgePlus,
|
||||||
reasonSameDate: record.reasonSameDate,
|
reasonSameDate: record?.reasonSameDate,
|
||||||
isLeave: record.isLeave
|
isLeave: record?.isLeave
|
||||||
};
|
};
|
||||||
|
|
||||||
return new HttpSuccess(data);
|
return new HttpSuccess(data);
|
||||||
|
|
|
||||||
|
|
@ -192,7 +192,7 @@ export class ProfileGovernmentEmployeeController extends Controller {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
// if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||||
const fullNameParts = [
|
const fullNameParts = [
|
||||||
posMaster == null || posMaster.orgChild4 == null ? null : posMaster.orgChild4.orgChild4Name,
|
posMaster == null || posMaster.orgChild4 == null ? null : posMaster.orgChild4.orgChild4Name,
|
||||||
posMaster == null || posMaster.orgChild3 == null ? null : posMaster.orgChild3.orgChild3Name,
|
posMaster == null || posMaster.orgChild3 == null ? null : posMaster.orgChild3.orgChild3Name,
|
||||||
|
|
@ -227,28 +227,28 @@ export class ProfileGovernmentEmployeeController extends Controller {
|
||||||
}
|
}
|
||||||
const orgLeave = _OrgLeave.filter((x:any) => x !== undefined && x !== null).join("\n");
|
const orgLeave = _OrgLeave.filter((x:any) => x !== undefined && x !== null).join("\n");
|
||||||
const data = {
|
const data = {
|
||||||
org: record.isLeave == false ? org : orgLeave, //สังกัด
|
org: record?.isLeave == false ? org : orgLeave, //สังกัด
|
||||||
position: record.position, //ตำแหน่ง
|
position: record?.position, //ตำแหน่ง
|
||||||
posLevel:
|
posLevel:
|
||||||
record.posLevel == null
|
record?.posLevel == null
|
||||||
? null
|
? null
|
||||||
: `${record?.posType?.posTypeShortName ?? ""} ${record?.posLevel?.posLevelName ?? ""}`, //ระดับ
|
: `${record?.posType?.posTypeShortName ?? ""} ${record?.posLevel?.posLevelName ?? ""}`, //ระดับ
|
||||||
posMasterNo: record.isLeave == false
|
posMasterNo: record?.isLeave == false
|
||||||
? posMaster == null ? null : `${orgShortName} ${posMaster.posMasterNo}`
|
? posMaster == null ? null : `${orgShortName} ${posMaster.posMasterNo}`
|
||||||
: record.profileSalary.length > 0
|
: record && record?.profileSalary.length > 0
|
||||||
? `${record.profileSalary[0].posNoAbb} ${record.profileSalary[0].posNo}`
|
? `${record?.profileSalary[0].posNoAbb} ${record?.profileSalary[0].posNo}`
|
||||||
: null, //เลขที่ตำแหน่ง
|
: null, //เลขที่ตำแหน่ง
|
||||||
posType: record.posType == null ? null : record.posType.posTypeName, //ประเภท
|
posType: record?.posType == null ? null : record?.posType.posTypeName, //ประเภท
|
||||||
dateLeave: record.birthDate == null ? null : calculateRetireDate(record.birthDate), //วันเกษียณ
|
dateLeave: record?.birthDate == null ? null : calculateRetireDate(record?.birthDate), //วันเกษียณ
|
||||||
dateAppoint: record.dateAppoint, //วันที่สั่งบรรจุ
|
dateAppoint: record?.dateAppoint, //วันที่สั่งบรรจุ
|
||||||
dateStart: record.dateStart, //วันที่เริ่มปฎิบัติงานราชการ
|
dateStart: record?.dateStart, //วันที่เริ่มปฎิบัติงานราชการ
|
||||||
reasonSameDate: record.reasonSameDate, //เหตุผลที่วันที่ไม่ตรงกัน
|
reasonSameDate: record?.reasonSameDate, //เหตุผลที่วันที่ไม่ตรงกัน
|
||||||
dateRetire: record.dateRetire ?? null, //วันครบเกษียณอายุ
|
dateRetire: record?.dateRetire ?? null, //วันครบเกษียณอายุ
|
||||||
// govAge: record.dateStart == null ? null : calculateAge(record.dateStart), //อายุราชการ
|
// govAge: record?.dateStart == null ? null : calculateAge(record?.dateStart), //อายุราชการ
|
||||||
govAge: await calculateGovAge(profileEmployeeId, "EMPLOYEE"),
|
govAge: await calculateGovAge(profileEmployeeId, "EMPLOYEE"),
|
||||||
govAgeAbsent: record.govAgeAbsent ?? null, // ขาดราชการ
|
govAgeAbsent: record?.govAgeAbsent ?? null, // ขาดราชการ
|
||||||
govAgePlus: record.govAgePlus, // อายุราชการเกื้อกูล
|
govAgePlus: record?.govAgePlus, // อายุราชการเกื้อกูล
|
||||||
dateRetireLaw: record.dateRetireLaw ?? null, // วันที่เกษียฯอายุราชการตามกฎหมาย
|
dateRetireLaw: record?.dateRetireLaw ?? null, // วันที่เกษียฯอายุราชการตามกฎหมาย
|
||||||
};
|
};
|
||||||
return new HttpSuccess(data);
|
return new HttpSuccess(data);
|
||||||
}
|
}
|
||||||
|
|
@ -305,7 +305,7 @@ export class ProfileGovernmentEmployeeController extends Controller {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
// if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||||
const fullNameParts = [
|
const fullNameParts = [
|
||||||
posMaster == null || posMaster.orgChild4 == null ? null : posMaster.orgChild4.orgChild4Name,
|
posMaster == null || posMaster.orgChild4 == null ? null : posMaster.orgChild4.orgChild4Name,
|
||||||
posMaster == null || posMaster.orgChild3 == null ? null : posMaster.orgChild3.orgChild3Name,
|
posMaster == null || posMaster.orgChild3 == null ? null : posMaster.orgChild3.orgChild3Name,
|
||||||
|
|
@ -340,31 +340,31 @@ export class ProfileGovernmentEmployeeController extends Controller {
|
||||||
}
|
}
|
||||||
const orgLeave = _OrgLeave.filter((x:any) => x !== undefined && x !== null).join("\n");
|
const orgLeave = _OrgLeave.filter((x:any) => x !== undefined && x !== null).join("\n");
|
||||||
const data = {
|
const data = {
|
||||||
org: record.isLeave == false ? org : orgLeave, //สังกัด
|
org: record?.isLeave == false ? org : orgLeave, //สังกัด
|
||||||
position: record.position, //ตำแหน่ง
|
position: record?.position, //ตำแหน่ง
|
||||||
posLevel: record.posLevel == null && record.posType == null
|
posLevel: record?.posLevel == null && record?.posType == null
|
||||||
? null
|
? null
|
||||||
: `${record.posType.posTypeShortName} ${record.posLevel.posLevelName}`, //ระดับ
|
: `${record?.posType.posTypeShortName} ${record?.posLevel.posLevelName}`, //ระดับ
|
||||||
posMasterNo:
|
posMasterNo:
|
||||||
record.isLeave == false
|
record?.isLeave == false
|
||||||
? posMaster == null
|
? posMaster == null
|
||||||
? null
|
? null
|
||||||
: `${orgShortName} ${posMaster.posMasterNo}`
|
: `${orgShortName} ${posMaster.posMasterNo}`
|
||||||
: record?.profileSalary.length > 0
|
: record && record.profileSalary.length > 0
|
||||||
? `${record.profileSalary[0].posNoAbb} ${record.profileSalary[0].posNo}`
|
? `${record?.profileSalary[0].posNoAbb} ${record?.profileSalary[0].posNo}`
|
||||||
: null, //เลขที่ตำแหน่ง
|
: null, //เลขที่ตำแหน่ง
|
||||||
posType: record.posType == null ? null : record.posType.posTypeName, //ประเภท
|
posType: record?.posType == null ? null : record?.posType.posTypeName, //ประเภท
|
||||||
dateLeave: record.birthDate == null ? null : calculateRetireDate(record.birthDate), //วันเกษียณ
|
dateLeave: record?.birthDate == null ? null : calculateRetireDate(record?.birthDate), //วันเกษียณ
|
||||||
dateAppoint: record.dateAppoint, //วันที่สั่งบรรจุ
|
dateAppoint: record?.dateAppoint, //วันที่สั่งบรรจุ
|
||||||
dateStart: record.dateStart, //วันที่เริ่มปฎิบัติงานราชการ
|
dateStart: record?.dateStart, //วันที่เริ่มปฎิบัติงานราชการ
|
||||||
reasonSameDate: record.reasonSameDate, //เหตุผลที่วันที่ไม่ตรงกัน
|
reasonSameDate: record?.reasonSameDate, //เหตุผลที่วันที่ไม่ตรงกัน
|
||||||
dateRetire: record.dateRetire ?? null, //วันครบเกษียณอายุ
|
dateRetire: record?.dateRetire ?? null, //วันครบเกษียณอายุ
|
||||||
// govAge: record.dateStart == null ? null : calculateAge(record.dateStart), //อายุราชการ
|
// govAge: record?.dateStart == null ? null : calculateAge(record?.dateStart), //อายุราชการ
|
||||||
govAge: await calculateGovAge(profileEmployeeId, "EMPLOYEE"),
|
govAge: await calculateGovAge(profileEmployeeId, "EMPLOYEE"),
|
||||||
govAgeAbsent: record.govAgeAbsent ?? null, // ขาดราชการ
|
govAgeAbsent: record?.govAgeAbsent ?? null, // ขาดราชการ
|
||||||
govAgePlus: record.govAgePlus, // อายุราชการเกื้อกูล
|
govAgePlus: record?.govAgePlus, // อายุราชการเกื้อกูล
|
||||||
dateRetireLaw: record.dateRetireLaw ?? null, // วันที่เกษียฯอายุราชการตามกฎหมาย
|
dateRetireLaw: record?.dateRetireLaw ?? null, // วันที่เกษียฯอายุราชการตามกฎหมาย
|
||||||
isLeave: record.isLeave
|
isLeave: record?.isLeave
|
||||||
};
|
};
|
||||||
return new HttpSuccess(data);
|
return new HttpSuccess(data);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue