diff --git a/src/controllers/ProfileEmployeeController.ts b/src/controllers/ProfileEmployeeController.ts index e5fae7ab..2ab1a147 100644 --- a/src/controllers/ProfileEmployeeController.ts +++ b/src/controllers/ProfileEmployeeController.ts @@ -989,6 +989,61 @@ export class ProfileEmployeeController extends Controller { return new HttpSuccess(formattedData); } + /** + * API ออกคำสั่งลูกจ้าง + * + * @summary ORG_038 - ออกคำสั่งลูกจ้าง (ADMIN) # + * + */ + @Get("report-temp") + async getReportTemp(@Request() request: RequestWithUser) { + const profiles = await this.profileRepo.find({ + where: { statusTemp: "REPORT", employeeClass: "TEMP" }, + }); + + 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 shortName = + profile.child4Temp != null + ? `${profile.child4ShortNameTemp}${profile.posMasterNoTemp}` + : profile.child3Temp != null + ? `${profile.child3ShortNameTemp}${profile.posMasterNoTemp}` + : profile.child2Temp != null + ? `${profile.child2ShortNameTemp}${profile.posMasterNoTemp}` + : profile.child1Temp != null + ? `${profile.child1ShortNameTemp}${profile.posMasterNoTemp}` + : profile.rootIdTemp != null + ? `${profile.rootShortNameTemp}${profile.posMasterNoTemp}` + : null; + + return { + id: profile.id, + citizenId: profile.citizenId, + prefix: profile.prefix, + firstName: profile.firstName, + lastName: profile.lastName, + organization: profile.rootTemp, + positionName: profile.positionTemp, + positionType: profile.posTypeNameTemp, + positionLevel: profile.posLevelNameTemp, + positionNumber: shortName, + birthDate: profile.birthDate, + }; + }); + + return new HttpSuccess(formattedData); + } + /** * API รายละเอียดรายการทะเบียนประวัติ * @@ -2760,7 +2815,7 @@ export class ProfileEmployeeController extends Controller { profile.leaveReason = requestBody.leaveReason; profile.dateLeave = requestBody.dateLeave; if (requestBody.isLeave == true) { - await removeProfileInOrganize(profile.id,"EMPLOYEE"); + await removeProfileInOrganize(profile.id, "EMPLOYEE"); } await this.profileRepo.save(profile);