เพิ่ม field /api/v1/org/profile-employee/report
This commit is contained in:
parent
30286317c6
commit
196f13cfbd
1 changed files with 131 additions and 40 deletions
|
|
@ -809,6 +809,111 @@ export class ProfileEmployeeController extends Controller {
|
|||
return new HttpSuccess(historyProfile);
|
||||
}
|
||||
|
||||
/**
|
||||
* API ออกคำสั่งลูกจ้าง
|
||||
*
|
||||
* @summary ORG_038 - ออกคำสั่งลูกจ้าง (ADMIN) #
|
||||
*
|
||||
*/
|
||||
@Get("report")
|
||||
async getReport(@Request() request: RequestWithUser) {
|
||||
const profiles = await this.profileRepo.find({
|
||||
where: { statusTemp: "REPORT", employeeClass: "TEMP" },
|
||||
relations: [
|
||||
"posLevel",
|
||||
"posType",
|
||||
"current_holders",
|
||||
"current_holders.orgChild1",
|
||||
"current_holders.orgChild2",
|
||||
"current_holders.orgChild3",
|
||||
"current_holders.orgChild4"
|
||||
],
|
||||
});
|
||||
|
||||
if (!profiles) {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
}
|
||||
|
||||
const findRevision = await this.orgRevisionRepo.findOne({
|
||||
where: { orgRevisionIsCurrent: true },
|
||||
});
|
||||
if (!findRevision) {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "not found. OrgRevision");
|
||||
}
|
||||
|
||||
const formattedData = profiles.map((profile) => {
|
||||
const fullName = `${profile.prefix} ${profile.firstName} ${profile.lastName}`;
|
||||
const shortName =
|
||||
profile.current_holders.length == 0
|
||||
? null
|
||||
: profile.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null &&
|
||||
profile.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild4 !=
|
||||
null
|
||||
? `${profile.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild4.orgChild4ShortName}${profile.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
||||
: profile.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null &&
|
||||
profile.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild3 !=
|
||||
null
|
||||
? `${profile.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild3.orgChild3ShortName}${profile.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
||||
: profile.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null &&
|
||||
profile.current_holders.find((x) => x.orgRevisionId == findRevision.id)
|
||||
?.orgChild2 != null
|
||||
? `${profile.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild2.orgChild2ShortName}${profile.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
||||
: profile.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null &&
|
||||
profile.current_holders.find((x) => x.orgRevisionId == findRevision.id)
|
||||
?.orgChild1 != null
|
||||
? `${profile.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild1.orgChild1ShortName}${profile.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
||||
: profile.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null &&
|
||||
profile.current_holders.find((x) => x.orgRevisionId == findRevision.id)
|
||||
?.orgRoot != null
|
||||
? `${profile.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgRoot.orgRootShortName}${profile.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
||||
: null;
|
||||
|
||||
const root =
|
||||
profile.current_holders.length == 0 ||
|
||||
(profile.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null &&
|
||||
profile.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgRoot == null)
|
||||
? null
|
||||
: profile.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgRoot;
|
||||
|
||||
return {
|
||||
id: profile.id,
|
||||
prefix: profile.prefix,
|
||||
firstName: profile.firstName,
|
||||
lastName: profile.lastName,
|
||||
fullName: fullName,
|
||||
birthDate: profile.birthDate,
|
||||
rank: profile.rank,
|
||||
citizenId: profile.citizenId,
|
||||
email: profile.email,
|
||||
phone: profile.phone,
|
||||
isProbation: profile.isProbation,
|
||||
isLeave: profile.isLeave,
|
||||
leaveReason: profile.leaveReason,
|
||||
dateLeave: profile.dateLeave,
|
||||
dateRetire: profile.dateRetire,
|
||||
dateRetireLaw: profile.dateRetireLaw,
|
||||
salaryLevel: profile.salaryLevel,
|
||||
group: profile.group,
|
||||
ethnicity: profile.ethnicity,
|
||||
telephoneNumber: profile.telephoneNumber,
|
||||
nationality: profile.nationality,
|
||||
gender: profile.gender,
|
||||
relationship: profile.relationship,
|
||||
religion: profile.religion,
|
||||
bloodGroup: profile.bloodGroup,
|
||||
positionNumber: shortName,
|
||||
organization: root == null ? null : root.orgRootShortName,
|
||||
positionName: profile.position,
|
||||
possitionTypeId: profile.posTypeId,
|
||||
positionType: profile.posType?.posTypeName,
|
||||
positionLevelId: profile.posLevelId,
|
||||
positionLevel: profile.posLevel?.posLevelName,
|
||||
};
|
||||
});
|
||||
|
||||
return new HttpSuccess(formattedData);
|
||||
}
|
||||
|
||||
/**
|
||||
* API รายละเอียดรายการทะเบียนประวัติ
|
||||
*
|
||||
|
|
@ -2853,20 +2958,6 @@ export class ProfileEmployeeController extends Controller {
|
|||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
/**
|
||||
* API ออกคำสั่งลูกจ้าง
|
||||
*
|
||||
* @summary ORG_038 - ออกคำสั่งลูกจ้าง (ADMIN) #
|
||||
*
|
||||
*/
|
||||
@Get("report")
|
||||
async getReport(@Request() request: RequestWithUser) {
|
||||
const profiles = await this.profileRepo.find({
|
||||
where: { statusTemp: "REPORT", employeeClass: "TEMP" },
|
||||
});
|
||||
return new HttpSuccess(profiles);
|
||||
}
|
||||
|
||||
/**
|
||||
* API ออกคำสั่งลูกจ้าง
|
||||
*
|
||||
|
|
@ -2957,38 +3048,38 @@ export class ProfileEmployeeController extends Controller {
|
|||
break;
|
||||
|
||||
case "firstname":
|
||||
[findProfile, total] = await this.profileRepo.findAndCount({
|
||||
where: {
|
||||
keycloak: IsNull(),
|
||||
firstName: Like(`%${body.keyword}%`),
|
||||
},
|
||||
relations: ["posType", "posLevel", "current_holders", "profileSalarys"],
|
||||
skip,
|
||||
take,
|
||||
});
|
||||
[findProfile, total] = await this.profileRepo.findAndCount({
|
||||
where: {
|
||||
keycloak: IsNull(),
|
||||
firstName: Like(`%${body.keyword}%`),
|
||||
},
|
||||
relations: ["posType", "posLevel", "current_holders", "profileSalarys"],
|
||||
skip,
|
||||
take,
|
||||
});
|
||||
break;
|
||||
|
||||
case "lastname":
|
||||
[findProfile, total] = await this.profileRepo.findAndCount({
|
||||
where: {
|
||||
keycloak: IsNull(),
|
||||
lastName: Like(`%${body.keyword}%`),
|
||||
},
|
||||
relations: ["posType", "posLevel", "current_holders", "profileSalarys"],
|
||||
skip,
|
||||
take,
|
||||
});
|
||||
[findProfile, total] = await this.profileRepo.findAndCount({
|
||||
where: {
|
||||
keycloak: IsNull(),
|
||||
lastName: Like(`%${body.keyword}%`),
|
||||
},
|
||||
relations: ["posType", "posLevel", "current_holders", "profileSalarys"],
|
||||
skip,
|
||||
take,
|
||||
});
|
||||
break;
|
||||
|
||||
default:
|
||||
[findProfile, total] = await this.profileRepo.findAndCount({
|
||||
where: {
|
||||
keycloak: IsNull(),
|
||||
},
|
||||
relations: ["posType", "posLevel", "current_holders", "profileSalarys"],
|
||||
skip,
|
||||
take,
|
||||
});
|
||||
[findProfile, total] = await this.profileRepo.findAndCount({
|
||||
where: {
|
||||
keycloak: IsNull(),
|
||||
},
|
||||
relations: ["posType", "posLevel", "current_holders", "profileSalarys"],
|
||||
skip,
|
||||
take,
|
||||
});
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue