From ff63e650fbe16d3d241e564db891d60a269c7c72 Mon Sep 17 00:00:00 2001 From: Bright Date: Mon, 1 Apr 2024 17:19:32 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B8=9B=E0=B8=A3=E0=B8=B1=E0=B8=9A=20endpont?= =?UTF-8?q?=20+=20emp-10?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/ReportController.ts | 118 ++++++++++++++++++++-------- 1 file changed, 85 insertions(+), 33 deletions(-) diff --git a/src/controllers/ReportController.ts b/src/controllers/ReportController.ts index cb8a563..51bffd8 100644 --- a/src/controllers/ReportController.ts +++ b/src/controllers/ReportController.ts @@ -2117,7 +2117,7 @@ export class ReportController extends Controller { * @summary 01-บัญชีคำนวณโควตา * */ - @Get("emp1-01/{rootId}/{salaryPeriodId}") + @Get("emp-01/{rootId}/{salaryPeriodId}") async SalaryReportEmp1_1(@Path() rootId: string, @Path() salaryPeriodId: string) { const salaryPeriod = await this.salaryPeriodRepository.findOne({ where: { @@ -2180,7 +2180,7 @@ export class ReportController extends Controller { * @summary 02-รายชื่อลูกจ้างประจำผู้ครองตำแหน่ง ณ วันที่ 1 มีนาคม * */ - @Get("emp1-02/{rootId}/{salaryPeriodId}") + @Get("emp-02/{rootId}/{salaryPeriodId}") async SalaryReportEmp1_2(@Path() rootId: string, @Path() salaryPeriodId: string) { const salaryPeriod = await this.salaryPeriodRepository.findOne({ where: { @@ -2252,7 +2252,7 @@ export class ReportController extends Controller { * @summary 03-รายชื่อลูกจ้างประจำที่ได้รับการเสนอขอเลื่อนขั้นค่าจ้างหนึ่งขั้น * */ - @Get("emp1-03/{rootId}/{salaryPeriodId}") + @Get("emp-03/{rootId}/{salaryPeriodId}") async SalaryReportEmp1_3(@Path() rootId: string, @Path() salaryPeriodId: string) { const salaryPeriod = await this.salaryPeriodRepository.findOne({ where: { @@ -2341,7 +2341,7 @@ export class ReportController extends Controller { * @summary 04-แบบ ลจ.กทม.1-รายชื่อลูกจ้างผู้สมควรได้เลื่อนขั้นค่าจ้าง * */ - @Get("emp1-04/{rootId}/{salaryPeriodId}") + @Get("emp-04/{rootId}/{salaryPeriodId}") async SalaryReportEmp1_4(@Path() rootId: string, @Path() salaryPeriodId: string) { const salaryPeriod = await this.salaryPeriodRepository.findOne({ where: { @@ -2419,7 +2419,7 @@ export class ReportController extends Controller { * @summary 05-แบบ ลจ.กทม.1-1-รายชื่อลูกจ้างผู้สมควรได้รับค่าตอบแทนพิเศษ * */ - @Get("emp1-05/{rootId}/{salaryPeriodId}") + @Get("emp-05/{rootId}/{salaryPeriodId}") async SalaryReportEmp1_5(@Path() rootId: string, @Path() salaryPeriodId: string) { const salaryPeriod = await this.salaryPeriodRepository.findOne({ where: { @@ -2501,7 +2501,7 @@ export class ReportController extends Controller { * @summary 06-แบบ ลจ.กทม.2-รายชื่อลูกจ้างผู้ไม่สมควรเลื่อนขั้นค่าจ้าง * */ - @Get("emp1-06/{rootId}/{salaryPeriodId}") + @Get("emp-06/{rootId}/{salaryPeriodId}") async SalaryReportEmp1_6(@Path() rootId: string, @Path() salaryPeriodId: string) { const salaryPeriod = await this.salaryPeriodRepository.findOne({ where: { @@ -2578,7 +2578,7 @@ export class ReportController extends Controller { * @summary 07-แบบ ลจ.กทม.2-1-รายชื่อลูกจ้างผู้ไม่สมควรได้รับค่าตอบแทนพิเศษ * */ - @Get("emp1-07/{rootId}/{salaryPeriodId}") + @Get("emp-07/{rootId}/{salaryPeriodId}") async SalaryReportEmp1_7(@Path() rootId: string, @Path() salaryPeriodId: string) { const salaryPeriod = await this.salaryPeriodRepository.findOne({ where: { @@ -2672,7 +2672,7 @@ export class ReportController extends Controller { * @summary 09-บัญชีรายชื่อลูกจ้างประจำผู้ไม่ได้รับเลื่อนขั้นค่าจ้างในวันที่ 1 เมษา ย้อนหลัง 3 ครั้ง * */ - @Get("emp1-09/{rootId}/{salaryPeriodId}") + @Get("emp-09/{rootId}/{salaryPeriodId}") async SalaryReportEmp1_9(@Path() rootId: string, @Path() salaryPeriodId: string) { const salaryPeriod = await this.salaryPeriodRepository.findOne({ where: { @@ -2846,30 +2846,82 @@ export class ReportController extends Controller { }); } - // /** - // * API 10-รายชื่อลูกจ้างประจำผู้มีผลการประเมินดีเด่น - // * - // * @summary 10-รายชื่อลูกจ้างประจำผู้มีผลการประเมินดีเด่น - // * - // */ - // @Get("emp-10/{rootId}/{salaryPeriodId}") - // async SalaryReportEmp1_10(@Path() rootId: string, @Path() salaryPeriodId: string) { - // const salaryPeriod = await this.salaryPeriodRepository.findOne({ - // where: { - // id: salaryPeriodId, - // }, - // }); - // if (!salaryPeriod) { - // throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการขึ้นเงินเดือน"); - // } - // } + /** + * API 10-รายชื่อลูกจ้างประจำผู้มีผลการประเมินดีเด่น + * + * @summary 10-รายชื่อลูกจ้างประจำผู้มีผลการประเมินดีเด่น + * + */ + @Get("emp-10/{rootId}/{salaryPeriodId}") + async SalaryReportEmp1_10(@Path() rootId: string, @Path() salaryPeriodId: string) { + const salaryPeriod = await this.salaryPeriodRepository.findOne({ + where: { + id: salaryPeriodId, + isActive: true + }, + }); + if (!salaryPeriod) { + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการขึ้นเงินเดือน"); + } + const salaryProfileEmp = await this.salaryProfileEmployeeRepository.find({ + relations: ["salaryOrg"], + where: { + salaryOrg: { + snapshot: "SNAP2", + rootId: rootId, + salaryPeriodId: salaryPeriodId, + }, + type: Not("NONE"), + }, + order: { + orgShortName: "ASC", + posMasterNo: "ASC", + }, + }); + if (!salaryProfileEmp) { + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล"); + } + const agency = salaryProfileEmp[0] == null ? "" : salaryProfileEmp[0].root; + const formattedData = salaryProfileEmp.map((profile, index) => { + const fullNameParts = [ + profile.child4, + profile.child3, + profile.child2, + profile.child1, + profile.root, + `${profile.prefix}${profile.firstName} ${profile.lastName}`, + ]; + + const fullName = fullNameParts + .filter((part) => part !== undefined && part !== null) + .join("/"); + + return { + no: Extension.ToThaiNumber((index + 1).toLocaleString()), + fullName: fullName, + position: profile.position, + posLevel: profile.posLevel, + } + }); + + return new HttpSuccess({ + template: "emp1-10", + reportName: "emp1-10", + data: { + year: Extension.ToThaiNumber(String(Extension.ToThaiYear(salaryPeriod.year))), + agency: agency, + data: formattedData, + }, + }); + } + /** * API 11-คำสั่ง * * @summary 11-คำสั่ง * */ - @Get("emp1-11/{rootId}/{salaryPeriodId}") + @Get("emp-11/{rootId}/{salaryPeriodId}") async SalaryReportEmp1_11(@Path() rootId: string, @Path() salaryPeriodId: string) { const salaryPeriod = await this.salaryPeriodRepository.findOne({ where: { @@ -2941,7 +2993,7 @@ export class ReportController extends Controller { * @summary 12-บัญชีรายละเอียดผู้ได้รับอัตราค่าจ้างสูงกว่าขั้นสูง (แนบท้ายคำสั่ง) * */ - @Get("emp1-12/{rootId}/{salaryPeriodId}") + @Get("emp-12/{rootId}/{salaryPeriodId}") async SalaryReportEmp1_12(@Path() rootId: string, @Path() salaryPeriodId: string) { const salaryPeriod = await this.salaryPeriodRepository.findOne({ where: { @@ -3023,7 +3075,7 @@ export class ReportController extends Controller { * @summary 13-บัญชีรายชื่อลูกจ้างประจำผู้ไม่ได้รับการเลื่อนขั้นค่าจ้าง * */ - @Get("emp1-13/{rootId}/{salaryPeriodId}") + @Get("emp-13/{rootId}/{salaryPeriodId}") async SalaryReportEmp1_13(@Path() rootId: string, @Path() salaryPeriodId: string) { const salaryPeriod = await this.salaryPeriodRepository.findOne({ where: { @@ -3097,7 +3149,7 @@ export class ReportController extends Controller { * @summary 14-คำสั่ง * */ - @Get("emp1-14/{rootId}/{salaryPeriodId}") + @Get("emp-14/{rootId}/{salaryPeriodId}") async SalaryReportEmp1_14(@Path() rootId: string, @Path() salaryPeriodId: string) { const salaryPeriod = await this.salaryPeriodRepository.findOne({ where: { @@ -3178,7 +3230,7 @@ export class ReportController extends Controller { * @summary 15-บัญชีรายละเอียดลูกจ้างประจำที่ได้รับค่าตอบแทนพิเศษ(แนบท้ายคำสั่ง) * */ - @Get("emp1-15/{rootId}/{salaryPeriodId}") + @Get("emp-15/{rootId}/{salaryPeriodId}") async SalaryReportEmp1_15(@Path() rootId: string, @Path() salaryPeriodId: string) { const salaryPeriod = await this.salaryPeriodRepository.findOne({ where: { @@ -3261,7 +3313,7 @@ export class ReportController extends Controller { * @summary 16-บัญชีรายชื่อลูกจ้างประจำผู้ไม่ได้รับค่าตอบแทนพิเศษ * */ - @Get("emp1-16/{rootId}/{salaryPeriodId}") + @Get("emp-16/{rootId}/{salaryPeriodId}") async SalaryReportEmp1_16(@Path() rootId: string, @Path() salaryPeriodId: string) { const salaryPeriod = await this.salaryPeriodRepository.findOne({ where: { @@ -3334,7 +3386,7 @@ export class ReportController extends Controller { * @summary 17-คำสั่ง * */ - @Get("emp1-17/{rootId}/{salaryPeriodId}") + @Get("emp-17/{rootId}/{salaryPeriodId}") async SalaryReportEmp1_17(@Path() rootId: string, @Path() salaryPeriodId: string) { const salaryPeriod = await this.salaryPeriodRepository.findOne({ where: { @@ -3406,7 +3458,7 @@ export class ReportController extends Controller { * @summary 18-คำสั่ง * */ - @Get("emp1-18/{rootId}/{salaryPeriodId}") + @Get("emp-18/{rootId}/{salaryPeriodId}") async SalaryReportEmp1_18(@Path() rootId: string, @Path() salaryPeriodId: string) { const salaryPeriod = await this.salaryPeriodRepository.findOne({ where: {