From cfe1eba3b0f0c8911127fcf5146fbdd9f10e50f8 Mon Sep 17 00:00:00 2001 From: Bright Date: Tue, 18 Jun 2024 13:26:55 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B8=AD=E0=B8=AD=E0=B8=81=E0=B8=84=E0=B8=B3?= =?UTF-8?q?=E0=B8=AA=E0=B8=B1=E0=B9=88=E0=B8=87=20C-PM-11,=20C-PM-12?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/ProfileController.ts | 162 ++++++++++++++++++- src/controllers/ProfileEmployeeController.ts | 2 +- 2 files changed, 160 insertions(+), 4 deletions(-) diff --git a/src/controllers/ProfileController.ts b/src/controllers/ProfileController.ts index 5fc6129b..080cafd2 100644 --- a/src/controllers/ProfileController.ts +++ b/src/controllers/ProfileController.ts @@ -460,13 +460,12 @@ export class ProfileController extends Controller { }); const Salary = salarys.map((item) => ({ - SalaryDate: Extension.ToThaiNumber(Extension.ToThaiShortDate_noPrefix(item.date)) ?? null, + SalaryDate: item.date ? Extension.ToThaiNumber(Extension.ToThaiShortDate_noPrefix(item.date)) : null, Position: item.position ?? null, PosNo: item.posNo ?? null, Salary: item.amount ?? null, Rank: item.positionLevel ?? null, - RefAll: Extension.ToThaiNumber(item.templateDoc) ?? null, - PositionType: item.positionType ?? null, + RefAll: item.templateDoc ? Extension.ToThaiNumber(item.templateDoc) : null, PositionLevel: item.positionLevel ?? null, PositionAmount: item.positionSalaryAmount == null @@ -746,6 +745,163 @@ export class ProfileController extends Controller { return new HttpSuccess(profile.id); } + /** + * API ออกคำสั่ง คำสั่งให้ข้าราชการที่มีผลการทดลองปฏิบัติหน้าที่ราชการไม่ต่ำกว่ามาตรฐานที่กำหนดรับราชการต่อไป + * + * @summary API ออกคำสั่ง คำสั่งให้ข้าราชการที่มีผลการทดลองปฏิบัติหน้าที่ราชการไม่ต่ำกว่ามาตรฐานที่กำหนดรับราชการต่อไป (ADMIN) + * + */ + @Post("command11/{profileId}") + async ExecuteCommand11Async( + @Request() req: RequestWithUser, + @Body() body: { + profileId: string, + date: Date | null, + refCommandNo: string | null, + salaryRef: string | null + } + ) { + const profile = await this.profileRepo.findOne({ + relations: ['profileSalary'], + where: { id: body.profileId } + }); + if (!profile) { + throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลโปรไฟล์"); + } + // const posType = await this.posTypeRepo.findOneBy({ id: String(profile.posTypeId) }) + // const posLevel = await this.posLevelRepo.findOneBy({ id: String(profile.posLevelId) }) + + if(profile.isProbation != false) { + profile.isProbation = false; + profile.lastUpdateUserId = req.user.sub; + profile.lastUpdateFullName = req.user.name; + const profileSalary: ProfileSalary = Object.assign(new ProfileSalary(), { + profileId: body.profileId, + date: body.date, + refCommandNo: body.refCommandNo, + templateDoc: body.salaryRef, + position: profile.position, + positionType: profile.profileSalary.length > 0 + ? profile.profileSalary[profile.profileSalary.length-1].positionType + : null, + positionLevel: profile.profileSalary.length > 0 + ? profile.profileSalary[profile.profileSalary.length-1].positionLevel + : null, + posNo: profile.profileSalary.length > 0 + ? profile.profileSalary[profile.profileSalary.length-1].posNo + : null, + positionLine: profile.profileSalary.length > 0 + ? profile.profileSalary[profile.profileSalary.length-1].positionLine + : null, + positionPathSide: profile.profileSalary.length > 0 + ? profile.profileSalary[profile.profileSalary.length-1].positionPathSide + : null, + positionExecutive: profile.profileSalary.length > 0 + ? profile.profileSalary[profile.profileSalary.length-1].positionExecutive + : null, + amount: profile.profileSalary.length > 0 + ? profile.profileSalary[profile.profileSalary.length-1].amount + : null, + positionSalaryAmount: profile.profileSalary.length > 0 + ? profile.profileSalary[profile.profileSalary.length-1].positionSalaryAmount + : null, + mouthSalaryAmount: profile.profileSalary.length > 0 + ? profile.profileSalary[profile.profileSalary.length-1].mouthSalaryAmount + : null, + order: profile.profileSalary.length >= 0 + ? profile.profileSalary.length > 0 ? profile.profileSalary[profile.profileSalary.length-1].order + 1 : 1 + : null, + createdUserId: req.user.sub, + createdFullName: req.user.name, + lastUpdateUserId: req.user.sub, + lastUpdateFullName: req.user.name, + }); + await Promise.all([ + this.profileRepo.save(profile), + this.salaryRepository.save(profileSalary), + ]); + } + return new HttpSuccess(); + } + + /** + * API ออกคำสั่ง คำสั่งให้ข้าราชการออกจากราชการเพราะผลการทดลองปฏิบัติหน้าที่ราชการต่ำกว่ามาตรฐานที่กำหนด + * + * @summary API ออกคำสั่ง คำสั่งให้ข้าราชการออกจากราชการเพราะผลการทดลองปฏิบัติหน้าที่ราชการต่ำกว่ามาตรฐานที่กำหนด (ADMIN) + * + */ + @Post("command12/{profileId}") + async ExecuteCommand12Async( + @Request() req: RequestWithUser, + @Body() body: { + profileId: string, + date: Date | null, + refCommandNo: string | null, + salaryRef: string | null + } + ) { + const profile = await this.profileRepo.findOne({ + relations: ['profileSalary'], + where: { id: body.profileId } + }); + if (!profile) { + throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลโปรไฟล์"); + } + let dateLeave_: any = body.date + profile.isLeave = true; + profile.leaveReason = "คำสั่งให้ข้าราชการออกจากราชการเพราะผลการทดลองปฏิบัติหน้าที่ราชการต่ำกว่ามาตรฐานที่กำหนด"; + profile.dateLeave = dateLeave_; + profile.lastUpdateUserId = req.user.sub; + profile.lastUpdateFullName = req.user.name; + const profileSalary: ProfileSalary = Object.assign(new ProfileSalary(), { + profileId: body.profileId, + date: body.date, + refCommandNo: body.refCommandNo, + templateDoc: body.salaryRef, + position: profile.position, + positionType: profile.profileSalary.length > 0 + ? profile.profileSalary[profile.profileSalary.length-1].positionType + : null, + positionLevel: profile.profileSalary.length > 0 + ? profile.profileSalary[profile.profileSalary.length-1].positionLevel + : null, + posNo: profile.profileSalary.length > 0 + ? profile.profileSalary[profile.profileSalary.length-1].posNo + : null, + positionLine: profile.profileSalary.length > 0 + ? profile.profileSalary[profile.profileSalary.length-1].positionLine + : null, + positionPathSide: profile.profileSalary.length > 0 + ? profile.profileSalary[profile.profileSalary.length-1].positionPathSide + : null, + positionExecutive: profile.profileSalary.length > 0 + ? profile.profileSalary[profile.profileSalary.length-1].positionExecutive + : null, + amount: profile.profileSalary.length > 0 + ? profile.profileSalary[profile.profileSalary.length-1].amount + : null, + positionSalaryAmount: profile.profileSalary.length > 0 + ? profile.profileSalary[profile.profileSalary.length-1].positionSalaryAmount + : null, + mouthSalaryAmount: profile.profileSalary.length > 0 + ? profile.profileSalary[profile.profileSalary.length-1].mouthSalaryAmount + : null, + order: profile.profileSalary.length >= 0 + ? profile.profileSalary.length > 0 ? profile.profileSalary[profile.profileSalary.length-1].order + 1 : 1 + : null, + createdUserId: req.user.sub, + createdFullName: req.user.name, + lastUpdateUserId: req.user.sub, + lastUpdateFullName: req.user.name, + }); + await Promise.all([ + this.profileRepo.save(profile), + this.salaryRepository.save(profileSalary), + ]); + + return new HttpSuccess(); + } + /** * API คำนวนวันเกษียณ * diff --git a/src/controllers/ProfileEmployeeController.ts b/src/controllers/ProfileEmployeeController.ts index 7ad0b1d8..678b512d 100644 --- a/src/controllers/ProfileEmployeeController.ts +++ b/src/controllers/ProfileEmployeeController.ts @@ -481,7 +481,7 @@ export class ProfileEmployeeController extends Controller { }); const Salary = salarys.map((item) => ({ - SalaryDate: Extension.ToThaiShortDate(item.date) ?? null, + SalaryDate: item.date ? Extension.ToThaiShortDate(item.date) : null, Position: item.position ?? null, PosNo: item.posNo ?? null, Salary: "",