From c7920c26574ba3802348e34f1efb296d5a75f442 Mon Sep 17 00:00:00 2001 From: Kittapath Date: Wed, 7 Aug 2024 16:54:33 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B8=84=E0=B8=B3=E0=B8=AA=E0=B8=B1=E0=B9=88?= =?UTF-8?q?=E0=B8=87=E0=B8=A5=E0=B8=B9=E0=B8=81=E0=B8=88=E0=B9=89=E0=B8=B2?= =?UTF-8?q?=E0=B8=87=20list=20=E0=B8=A3=E0=B8=B2=E0=B8=A2=E0=B8=81?= =?UTF-8?q?=E0=B8=B2=E0=B8=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/ProfileEmployeeController.ts | 57 +++++++++++++++++++- 1 file changed, 56 insertions(+), 1 deletion(-) 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);