add search person in retirement
This commit is contained in:
parent
4f8bc677a0
commit
83b407fe2f
1 changed files with 196 additions and 0 deletions
|
|
@ -3992,6 +3992,202 @@ export class ProfileController extends Controller {
|
|||
return new HttpSuccess({ data: mapDataProfile, total });
|
||||
}
|
||||
|
||||
/**
|
||||
* API ค้นหาข้อมูลทะเบียนประวัติ เกษียณข้าราชการ
|
||||
*
|
||||
* @summary ค้นหาข้อมูลทะเบียนประวัติ เกษียณข้าราชการ (ADMIN)
|
||||
*
|
||||
*/
|
||||
@Post("retire")
|
||||
async getProfileBySearchKeywordRetire(
|
||||
@Body()
|
||||
body: {
|
||||
page: number;
|
||||
pageSize: number;
|
||||
keyword?: string;
|
||||
},
|
||||
) {
|
||||
const [findProfile, total] = await AppDataSource.getRepository(Profile)
|
||||
.createQueryBuilder("profile")
|
||||
.leftJoinAndSelect("profile.posLevel", "posLevel")
|
||||
.leftJoinAndSelect("profile.posType", "posType")
|
||||
.leftJoinAndSelect("profile.current_holders", "current_holders")
|
||||
.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")
|
||||
.leftJoinAndSelect("current_holders.positions", "positions")
|
||||
.leftJoinAndSelect("positions.posExecutive", "posExecutive")
|
||||
.where(`profile.prefix LIKE :keyword`, {
|
||||
keyword: `%${body.keyword}%`,
|
||||
})
|
||||
.orWhere(`profile.firstName LIKE :keyword`, {
|
||||
keyword: `%${body.keyword}%`,
|
||||
})
|
||||
.orWhere(`profile.lastName LIKE :keyword`, {
|
||||
keyword: `%${body.keyword}%`,
|
||||
})
|
||||
.orWhere(`profile.position LIKE :keyword`, {
|
||||
keyword: `%${body.keyword}%`,
|
||||
})
|
||||
.orWhere(`posLevel.posLevelName LIKE :keyword`, {
|
||||
keyword: `%${body.keyword}%`,
|
||||
})
|
||||
.orWhere(`posType.posTypeName LIKE :keyword`, {
|
||||
keyword: `%${body.keyword}%`,
|
||||
})
|
||||
.orderBy("profile.citizenId", "ASC")
|
||||
.skip((body.page - 1) * body.pageSize)
|
||||
.take(body.pageSize)
|
||||
.getManyAndCount();
|
||||
|
||||
const orgRevisionActive = await this.orgRevisionRepo.findOne({
|
||||
where: { orgRevisionIsCurrent: true, orgRevisionIsDraft: false },
|
||||
});
|
||||
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(
|
||||
findProfile.map(async (item: Profile) => {
|
||||
const posMaster =
|
||||
item.current_holders == null ||
|
||||
item.current_holders.length == 0 ||
|
||||
item.current_holders.find((x) => x.orgRevisionId == findRevision.id) == null
|
||||
? null
|
||||
: item.current_holders.find((x) => x.orgRevisionId == findRevision.id);
|
||||
const position =
|
||||
posMaster == null ||
|
||||
item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.positions == null ||
|
||||
item.current_holders?.find((x) => x.orgRevisionId == findRevision.id)?.positions.length ==
|
||||
0 ||
|
||||
item.current_holders
|
||||
.find((x) => x.orgRevisionId == findRevision.id)
|
||||
?.positions?.find((position) => position.positionIsSelected == true) == null
|
||||
? null
|
||||
: item.current_holders
|
||||
.find((x) => x.orgRevisionId == findRevision.id)
|
||||
?.positions?.find((position) => position.positionIsSelected == true);
|
||||
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 shortName =
|
||||
item.current_holders.length == 0
|
||||
? null
|
||||
: item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null &&
|
||||
item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild4 !=
|
||||
null
|
||||
? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild4.orgChild4ShortName}${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
||||
: item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null &&
|
||||
item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild3 !=
|
||||
null
|
||||
? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild3.orgChild3ShortName}${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
||||
: item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null &&
|
||||
item.current_holders.find((x) => x.orgRevisionId == findRevision.id)
|
||||
?.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_holders.find((x) => x.orgRevisionId == findRevision.id) != null &&
|
||||
item.current_holders.find((x) => x.orgRevisionId == findRevision.id)
|
||||
?.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_holders.find((x) => x.orgRevisionId == findRevision.id) !=
|
||||
null &&
|
||||
item.current_holders.find((x) => x.orgRevisionId == findRevision.id)
|
||||
?.orgRoot != null
|
||||
? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgRoot.orgRootShortName}${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
||||
: null;
|
||||
|
||||
return {
|
||||
id: item.id,
|
||||
prefix: item.prefix,
|
||||
rank: item.rank,
|
||||
firstName: item.firstName,
|
||||
lastName: item.lastName,
|
||||
position: item.position,
|
||||
idcard: item.citizenId,
|
||||
posLevelName: item.posLevel == null ? null : item.posLevel.posLevelName,
|
||||
posTypeName: item.posType == null ? null : item.posType.posTypeName,
|
||||
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,
|
||||
orgRootName:
|
||||
item.current_holders == null ||
|
||||
item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id) == null ||
|
||||
item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)?.orgRoot ==
|
||||
null ||
|
||||
item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)?.orgRoot
|
||||
?.orgRootName == null
|
||||
? null
|
||||
: item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)?.orgRoot
|
||||
?.orgRootName,
|
||||
orgChild1Name:
|
||||
item.current_holders == null ||
|
||||
item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id) == null ||
|
||||
item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)?.orgChild1 ==
|
||||
null ||
|
||||
item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)?.orgChild1
|
||||
?.orgChild1Name == null
|
||||
? null
|
||||
: item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)
|
||||
?.orgChild1?.orgChild1Name,
|
||||
orgChild2Name:
|
||||
item.current_holders == null ||
|
||||
item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id) == null ||
|
||||
item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)?.orgChild2 ==
|
||||
null ||
|
||||
item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)?.orgChild2
|
||||
?.orgChild2Name == null
|
||||
? null
|
||||
: item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)
|
||||
?.orgChild2?.orgChild2Name,
|
||||
orgChild3Name:
|
||||
item.current_holders == null ||
|
||||
item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id) == null ||
|
||||
item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)?.orgChild3 ==
|
||||
null ||
|
||||
item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)?.orgChild3
|
||||
?.orgChild3Name == null
|
||||
? null
|
||||
: item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)
|
||||
?.orgChild3?.orgChild3Name,
|
||||
orgChild4Name:
|
||||
item.current_holders == null ||
|
||||
item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id) == null ||
|
||||
item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)?.orgChild4 ==
|
||||
null ||
|
||||
item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)?.orgChild4
|
||||
?.orgChild4Name == null
|
||||
? null
|
||||
: item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive?.id)
|
||||
?.orgChild4?.orgChild4Name,
|
||||
};
|
||||
}),
|
||||
);
|
||||
|
||||
return new HttpSuccess({ data: mapDataProfile, total });
|
||||
}
|
||||
|
||||
/**
|
||||
* API รายชื่อราชการที่เลื่อนเงินเดือน
|
||||
*
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue