ค้นหาลุกจ้างประจำ
This commit is contained in:
parent
c6ed6e72b9
commit
1d0b35983b
1 changed files with 91 additions and 0 deletions
|
|
@ -845,6 +845,97 @@ export class OrganizationUnauthorizeController extends Controller {
|
||||||
posTypeId: findProfile.posTypeId,
|
posTypeId: findProfile.posTypeId,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* API หา user profile employee
|
||||||
|
*
|
||||||
|
* @summary หา user profile employee
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@Get("employee-prem/citizen/{id}")
|
||||||
|
async GetProfileEmployeePremByCitizenId(@Path() id: string) {
|
||||||
|
const findRevision = await this.orgRevisionRepository.findOne({
|
||||||
|
where: { orgRevisionIsCurrent: true },
|
||||||
|
});
|
||||||
|
if (!findRevision) {
|
||||||
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "not found. OrgRevision");
|
||||||
|
}
|
||||||
|
|
||||||
|
const findProfile = await AppDataSource.getRepository(ProfileEmployee)
|
||||||
|
.createQueryBuilder("profile")
|
||||||
|
.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")
|
||||||
|
.leftJoinAndSelect("current_holders.positions", "positions")
|
||||||
|
// .leftJoinAndSelect("positions.posExecutive", "posExecutive")
|
||||||
|
.where({ citizenId: id, employeeclass: "PREM" })
|
||||||
|
.getOne();
|
||||||
|
if (!findProfile) {
|
||||||
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "not found Profile");
|
||||||
|
}
|
||||||
|
|
||||||
|
const root =
|
||||||
|
findProfile.current_holders == null ||
|
||||||
|
findProfile.current_holders.length == 0 ||
|
||||||
|
findProfile.current_holders.find((x) => x.orgRevisionId == findRevision.id) == null
|
||||||
|
? null
|
||||||
|
: findProfile.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgRoot;
|
||||||
|
|
||||||
|
const child1 =
|
||||||
|
findProfile.current_holders == null ||
|
||||||
|
findProfile.current_holders.length == 0 ||
|
||||||
|
findProfile.current_holders.find((x) => x.orgRevisionId == findRevision.id) == null
|
||||||
|
? null
|
||||||
|
: findProfile.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild1;
|
||||||
|
|
||||||
|
const child2 =
|
||||||
|
findProfile.current_holders == null ||
|
||||||
|
findProfile.current_holders.length == 0 ||
|
||||||
|
findProfile.current_holders.find((x) => x.orgRevisionId == findRevision.id) == null
|
||||||
|
? null
|
||||||
|
: findProfile.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild2;
|
||||||
|
|
||||||
|
const child3 =
|
||||||
|
findProfile.current_holders == null ||
|
||||||
|
findProfile.current_holders.length == 0 ||
|
||||||
|
findProfile.current_holders.find((x) => x.orgRevisionId == findRevision.id) == null
|
||||||
|
? null
|
||||||
|
: findProfile.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild3;
|
||||||
|
|
||||||
|
const child4 =
|
||||||
|
findProfile.current_holders == null ||
|
||||||
|
findProfile.current_holders.length == 0 ||
|
||||||
|
findProfile.current_holders.find((x) => x.orgRevisionId == findRevision.id) == null
|
||||||
|
? null
|
||||||
|
: findProfile.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.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}/`;
|
||||||
|
let _root = root == null ? "" : `${root.orgRootName}`;
|
||||||
|
|
||||||
|
return new HttpSuccess({
|
||||||
|
rootId: root == null ? null : root.id,
|
||||||
|
root: root == null ? null : root.orgRootName,
|
||||||
|
orgRootShortName: root == null ? null : root.orgRootShortName,
|
||||||
|
orgRevisionId: findRevision.id,
|
||||||
|
profileId: findProfile.id,
|
||||||
|
org: `${_child4}${_child3}${_child2}${_child1}${_root}`,
|
||||||
|
type: "EMPLOYEE",
|
||||||
|
rank: findProfile.rank,
|
||||||
|
prefix: findProfile.prefix,
|
||||||
|
firstName: findProfile.firstName,
|
||||||
|
lastName: findProfile.lastName,
|
||||||
|
citizenId: findProfile.citizenId,
|
||||||
|
position: findProfile.position,
|
||||||
|
posLevelId: findProfile.posLevelId,
|
||||||
|
posTypeId: findProfile.posTypeId,
|
||||||
|
});
|
||||||
|
}
|
||||||
textPointSummaryKpi(val: number | undefined) {
|
textPointSummaryKpi(val: number | undefined) {
|
||||||
if (val == undefined || val == null) val = -1;
|
if (val == undefined || val == null) val = -1;
|
||||||
if (val >= 0 && val <= 60) return "ต้องปรับปรุง";
|
if (val >= 0 && val <= 60) return "ต้องปรับปรุง";
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue