From 478cd7f083ad1d983a12fa12f528527882a57166 Mon Sep 17 00:00:00 2001 From: Bright Date: Wed, 27 Mar 2024 15:30:41 +0700 Subject: [PATCH] =?UTF-8?q?gov-(04-05)=20=E0=B8=81=E0=B8=A3=E0=B8=AD?= =?UTF-8?q?=E0=B8=87=E0=B9=80=E0=B8=81=E0=B8=A9=E0=B8=B5=E0=B8=A2=E0=B8=93?= =?UTF-8?q?=E0=B9=81=E0=B8=A5=E0=B8=B0=E0=B9=84=E0=B8=A1=E0=B9=88=E0=B9=80?= =?UTF-8?q?=E0=B8=81=E0=B8=A9=E0=B8=B5=E0=B8=A2=E0=B8=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/ReportController.ts | 186 +++++++++++++++++++++++++++- 1 file changed, 182 insertions(+), 4 deletions(-) diff --git a/src/controllers/ReportController.ts b/src/controllers/ReportController.ts index 6954e00..5b3b310 100644 --- a/src/controllers/ReportController.ts +++ b/src/controllers/ReportController.ts @@ -1529,9 +1529,9 @@ export class ReportController extends Controller { } /** - * API แบบ 1 กท บัญชีรายชื่อผู้สมควรได้เลื่อนเงินเดือน รอบเมษายน + * API แบบ 1 กท บัญชีรายชื่อผู้สมควรได้เลื่อนเงินเดือน รอบเมษายน และ ตุลาคม * - * @summary แบบ 1 กท บัญชีรายชื่อผู้สมควรได้เลื่อนเงินเดือน รอบเมษายน + * @summary แบบ 1 กท บัญชีรายชื่อผู้สมควรได้เลื่อนเงินเดือน รอบเมษายน และ ตุลาคม * * @param {string} rootId Guid, *Id Root * @param {string} salaryPeriodId Guid, *Id Period @@ -1557,6 +1557,7 @@ export class ReportController extends Controller { salaryPeriodId: salaryPeriodId, }, type: "NONE", //ไม่ได้เลื่อน + isReserve: false //กรองเฉพาะคนที่ไม่เกษียณ }, order: { salaryOrg: { @@ -1624,9 +1625,105 @@ export class ReportController extends Controller { } /** - * API แบบ 2 กท บัญชีรายชื่อผู้ไม่สมควรได้เลื่อนเงินเดือน รอบเมษายน + * API แบบ 1 กท บัญชีรายชื่อผู้สมควรได้เลื่อนเงินเดือน รอบเมษายน และ ตุลาคม (เกษียณอายุราชการ) * - * @summary แบบ 2 กท บัญชีรายชื่อผู้ไม่สมควรได้เลื่อนเงินเดือน รอบเมษายน + * @summary แบบ 1 กท บัญชีรายชื่อผู้สมควรได้เลื่อนเงินเดือน รอบเมษายน และ ตุลาคม (เกษียณอายุราชการ) + * + * @param {string} rootId Guid, *Id Root + * @param {string} salaryPeriodId Guid, *Id Period + */ + @Get("gov-04-01/{rootId}/{salaryPeriodId}") + async SalaryReport4Retire(@Path() rootId: string, @Path() salaryPeriodId: string) { + const salaryPeriod = await this.salaryPeriodRepository.findOne({ + where: { + id: salaryPeriodId, + }, + }); + + if (!salaryPeriod) { + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบรอบการขึ้นเงินเดือน"); + } + + const _salaryPeriod = await this.salaryProfileRepository.find({ + relations: ["salaryOrg", "salaryOrg.salaryPeriod"], + where: { + salaryOrg: { + snapshot: "SNAP2", + rootId: rootId, + salaryPeriodId: salaryPeriodId, + }, + type: "NONE", //ไม่ได้เลื่อน + isReserve: true //กรองเฉพาะคนที่เกษียณ + }, + order: { + salaryOrg: { + group: "ASC", + }, + type: "DESC", + orgShortName: "ASC", + posMasterNo: "ASC", + }, + }); + + const agency = _salaryPeriod[0] == null ? "" : _salaryPeriod[0].root; + + const formattedData = _salaryPeriod.map((profile, index) => { + return { + no: Extension.ToThaiNumber(String(index + 1)), + fullname: profile.prefix + profile.firstName + " " + profile.lastName, + log_group: profile.salaryOrg.group, + log_type: profile.type, + log_isNext: profile.isNext, + position: + profile.position + + "/" + + (profile.child4 == undefined && profile.child4 == null ? "" : profile.child4 + "/") + + (profile.child3 == undefined && profile.child3 == null ? "" : profile.child3 + "/") + + (profile.child2 == undefined && profile.child2 == null ? "" : profile.child2 + "/") + + (profile.child1 == undefined && profile.child1 == null ? "" : profile.child1 + "/") + + (profile.root == undefined && profile.root == null ? "" : profile.root), + posLevel: profile.posLevel, + orgShortName: profile.orgShortName + Extension.ToThaiNumber(String(profile.posMasterNo)), + amount: + profile.amount == undefined || profile.amount == null || profile.amount == 0 + ? "" + : Extension.ToThaiNumber(String(profile.amount)), + amountSpecial: + (profile.positionSalaryAmount == undefined || + profile.positionSalaryAmount == null || + profile.positionSalaryAmount == 0 + ? "" + : Extension.ToThaiNumber(String(profile.positionSalaryAmount))) + + (profile.amountSpecial == undefined || + profile.amountSpecial == null || + profile.amountSpecial == 0 + ? "" + : `(${Extension.ToThaiNumber(String(profile.amountSpecial))})`), + score: null, //สรุปผลการประเมินฯ ระดับและคะแนน + remark: + `${profile.type === "FULL" ? "หนึ่งขั้น" : ""}\n` + + `${profile.type === "FULLHAFT" ? "หนึ่งขั้นครึ่ง" : ""}\n` + + `${profile.amountSpecial > 0 ? "ได้รับค่าตอบแทนพิเศษ\n" : ""}` + + `${profile.isNext === true ? "(ได้รับเงินเดือนสูงกว่าขั้นสูงฯ)" : ""}`, // หมายเหตุ + }; + }); + + return new HttpSuccess({ + template: salaryPeriod.period == "APR" ? "gov1-04" : "gov2-04", + reportName: salaryPeriod.period == "APR" ? "gov1-04" : "gov2-04", + data: { + year: Extension.ToThaiNumber(String(Extension.ToThaiYear(salaryPeriod.year))), + effectiveDate: salaryPeriod.effectiveDate, + root: agency, + profile: formattedData, + }, + }); + } + + /** + * API แบบ 2 กท บัญชีรายชื่อผู้ไม่สมควรได้เลื่อนเงินเดือน รอบเมษายน และ ตุลาคม + * + * @summary แบบ 2 กท บัญชีรายชื่อผู้ไม่สมควรได้เลื่อนเงินเดือน รอบเมษายน และ ตุลาคม * * @param {string} rootId Guid, *Id Root * @param {string} salaryPeriodId Guid, *Id Period @@ -1652,6 +1749,87 @@ export class ReportController extends Controller { salaryPeriodId: salaryPeriodId, }, type: "NONE", //ไม่ได้เลื่อน + isReserve: false //กรองเฉพาะคนที่ไม่เกษียณ + }, + order: { + salaryOrg: { + group: "ASC", + }, + orgShortName: "ASC", + posMasterNo: "ASC", + }, + }); + + const agency = _salaryPeriod[0] == null ? "" : _salaryPeriod[0].root; + + const formattedData = _salaryPeriod.map((profile, index) => { + const fullNameParts = [ + profile.position, + profile.child4, + profile.child3, + profile.child2, + profile.child1, + profile.root, + ]; + + const position = fullNameParts + .filter((part) => part !== undefined && part !== null) + .join("/"); + + return { + no: Extension.ToThaiNumber((index + 1).toLocaleString()), + fullname: profile.prefix + profile.firstName + " " + profile.lastName, + position: position, + posLevel: profile.posLevel, + posNumber: + profile.orgShortName + Extension.ToThaiNumber(profile.posMasterNo.toLocaleString()), + amount: profile.amount ? Extension.ToThaiNumber(profile.amount.toLocaleString()) : null, + score: null, //สรุปผลการประเมินฯ ระดับและคะแนน + reason: null, + }; + }); + + return new HttpSuccess({ + template: salaryPeriod.period == "APR" ? "gov1-05" : "gov2-05", + reportName: salaryPeriod.period == "APR" ? "gov1-05" : "gov2-05", + data: { + year: Extension.ToThaiNumber(String(Extension.ToThaiYear(salaryPeriod.year))), + agency: agency, + data: formattedData, + }, + }); + } + + /** + * API แบบ 2 กท บัญชีรายชื่อผู้ไม่สมควรได้เลื่อนเงินเดือน รอบเมษายน และ ตุลาคม (เกษียณอายุราชการ) + * + * @summary แบบ 2 กท บัญชีรายชื่อผู้ไม่สมควรได้เลื่อนเงินเดือน รอบเมษายน และ ตุลาคม (เกษียณอายุราชการ) + * + * @param {string} rootId Guid, *Id Root + * @param {string} salaryPeriodId Guid, *Id Period + */ + @Get("gov-05-01/{rootId}/{salaryPeriodId}") + async SalaryReport5retire(@Path() rootId: string, @Path() salaryPeriodId: string) { + const salaryPeriod = await this.salaryPeriodRepository.findOne({ + where: { + id: salaryPeriodId, + }, + }); + + if (!salaryPeriod) { + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบรอบการขึ้นเงินเดือน"); + } + + const _salaryPeriod = await this.salaryProfileRepository.find({ + relations: ["salaryOrg", "salaryOrg.salaryPeriod"], + where: { + salaryOrg: { + snapshot: "SNAP2", + rootId: rootId, + salaryPeriodId: salaryPeriodId, + }, + type: "NONE", //ไม่ได้เลื่อน + isReserve: true //กรองเฉพาะคนที่เกษียณ }, order: { salaryOrg: {