diff --git a/src/controllers/ReportController.ts b/src/controllers/ReportController.ts index a61151e..0dd3677 100644 --- a/src/controllers/ReportController.ts +++ b/src/controllers/ReportController.ts @@ -130,8 +130,10 @@ export class ReportController extends Controller { * @summary รายชื่อข้าราชการผู้ที่ครองตำแหน่ง ณ วันที่ 1 มีนาคม * */ - @Get("1/1/{rootId}/{salaryPeriodId}") - async SalaryReport1(@Path() rootId: string, @Path() salaryPeriodId: string) { + @Get("gov1-01/{rootId}/{salaryPeriodId}") + async SalaryReport1( + @Path() rootId: string, + @Path() salaryPeriodId: string) { const salaryPeriodAPR = await this.salaryProfileRepository.find({ relations: ["salaryOrg", "salaryOrg.salaryPeriod"], where: { @@ -192,17 +194,17 @@ export class ReportController extends Controller { * @summary บัญชีการคำนวณโควตาเลื่อนเงินเดือน รอบเมษายน * */ - @Get("1/2/{rootId}/{salaryPeriodId}/{salaryOrgId}") + @Get("gov1-02/{rootId}/{salaryPeriodId}") async SalaryReport2( @Path() rootId: string, @Path() salaryPeriodId: string, - @Path() salaryOrgId: string, + // @Path() salaryOrgId: string, ) { const statistics = await this.salaryProfileRepository.find({ relations: ["salaryOrg", "salaryOrg.salaryPeriod"], where: { salaryOrg: { - id: salaryOrgId, + // id: salaryOrgId, snapshot: "SNAP1", group: "GROUP2", rootId: rootId, @@ -240,10 +242,8 @@ export class ReportController extends Controller { * @param {string} rootId Guid, *Id Root * @param {string} salaryPeriodId Guid, *Id Period */ - @Get("1/3/{rootId}/{salaryPeriodId}") + @Get("gov1-03/{rootId}/{salaryPeriodId}") async SalaryReport3( - // @Path() rootId : string = "c6164a42-539d-401a-b289-653282c08e37", - // @Path() salaryPeriodId: string = "31cfc7de-b93b-4998-bbf1-25c21f141ac2", @Path() rootId: string, @Path() salaryPeriodId: string, ) { @@ -327,10 +327,8 @@ export class ReportController extends Controller { * @param {string} rootId Guid, *Id Root * @param {string} salaryPeriodId Guid, *Id Period */ - @Get("1/4/{rootId}/{salaryPeriodId}") + @Get("gov1-04/{rootId}/{salaryPeriodId}") async SalaryReport4( - // @Path() rootId : string = "c6164a42-539d-401a-b289-653282c08e37", - // @Path() salaryPeriodId: string = "31cfc7de-b93b-4998-bbf1-25c21f141ac2", @Path() rootId: string, @Path() salaryPeriodId: string, ) { @@ -359,7 +357,10 @@ export class ReportController extends Controller { }); const salaryProfile = await this.salaryProfileRepository.find({ - where: { salaryOrgId: salaryOrg?.id }, + where: { + salaryOrgId: salaryOrg?.id, + type: Not("NONE") //ทุก Type ยกเว้นไม่ได้เลื่อน + }, select: [ "id", "prefix", @@ -407,6 +408,107 @@ export class ReportController extends Controller { return mapData; } + /** + * API แบบ 2 กท บัญชีรายชื่อผู้ไม่สมควรได้เลื่อนเงินเดือน รอบเมษายน + * + * @summary แบบ 2 กท บัญชีรายชื่อผู้ไม่สมควรได้เลื่อนเงินเดือน รอบเมษายน + * + * @param {string} rootId Guid, *Id Root + * @param {string} salaryPeriodId Guid, *Id Period + */ + @Get("gov1-05/{rootId}/{salaryPeriodId}") + async SalaryReport5( + @Path() rootId: string, + @Path() salaryPeriodId: string, + ){ + const salaryPeriod = await this.salaryPeriodRepository.findOne({ + where: { + id: salaryPeriodId, + period: "APR", + isActive: true, + }, + }); + + if (!salaryPeriod) { + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบรอบการขึ้นเงินเดือน"); + } + + const salaryOrg = await this.salaryOrgRepository.findOne({ + where: { + salaryPeriodId: salaryPeriodId, + rootId: rootId, + snapshot: "SNAP2", + }, + order: { + group: "ASC", + }, + relations: ["salaryProfiles"], + }); + + const salaryProfile = await this.salaryProfileRepository.find({ + where: { + salaryOrgId: salaryOrg?.id, + type: "NONE" //ไม่ได้เลื่อน + }, + select: [ + "id", + "prefix", + "firstName", + "lastName", + "root", + "position", + "posType", + "posLevel", + "orgShortName", + "posMasterNo", + "amount", + "amountSpecial", + ], + }); + + const mapData = { + effectiveDate: salaryPeriod?.effectiveDate, + root: salaryProfile[0]?.root, + profile: salaryProfile.map((item, index) => ({ + no: Extension.ToThaiNumber(String(index + 1)), + fullname: item.prefix + item.firstName + " " + item.lastName, + position: + item.position + + "/" + + (item.child4 == undefined && item.child4 == null ? "" : item.child4 + "/") + + (item.child3 == undefined && item.child3 == null ? "" : item.child3 + "/") + + (item.child2 == undefined && item.child2 == null ? "" : item.child2 + "/") + + (item.child1 == undefined && item.child1 == null ? "" : item.child1 + "/") + + (item.root == undefined && item.root == null ? "" : item.root), + posLevel: item.posLevel, + orgShortName: item.orgShortName + Extension.ToThaiNumber(String(item.posMasterNo)), + amount: + item.amount == undefined || item.amount == null + ? "๐" + : Extension.ToThaiNumber(String(item.amount)), + amountSpecial: + item.amountSpecial == undefined || item.amountSpecial == null + ? "๐" + : Extension.ToThaiNumber(String(item.amountSpecial)), + score: null, //สรุปผลการประเมินฯ ระดับและคะแนน + remark: null, //หมายเหตุ + })), + }; + return mapData; + } + +// /* API แบบ 3 กท บัญชีแสดงวันลาครึ่งปี ขรก +// * +// * @summary แบบ 3 กท บัญชีแสดงวันลาครึ่งปี ขรก +// * +// * @param {string} rootId Guid, *Id Root +// * @param {string} salaryPeriodId Guid, *Id Period +// */ +// @Get("gov1-06/{rootId}/{salaryPeriodId}") +// async SalaryReport6(){ + +// } + /** * API คำสั่งเลื่อนเงินเดือน รอบเมษายน * @@ -415,10 +517,8 @@ export class ReportController extends Controller { * @param {string} rootId Guid, *Id Root * @param {string} salaryPeriodId Guid, *Id Period */ - @Get("1/7/{rootId}/{salaryPeriodId}") + @Get("gov1-07/{rootId}/{salaryPeriodId}") async SalaryReport7( - // @Path() rootId : string = "c6164a42-539d-401a-b289-653282c08e37", - // @Path() salaryPeriodId: string = "31cfc7de-b93b-4998-bbf1-25c21f141ac2", @Path() rootId: string, @Path() salaryPeriodId: string, ) { @@ -501,10 +601,8 @@ export class ReportController extends Controller { * @param {string} rootId Guid, *Id Root * @param {string} salaryPeriodId Guid, *Id Period */ - @Get("1/8/{rootId}/{salaryPeriodId}") + @Get("gov1-08/{rootId}/{salaryPeriodId}") async SalaryReport8( - // @Path() rootId : string = "c6164a42-539d-401a-b289-653282c08e37", - // @Path() salaryPeriodId: string = "31cfc7de-b93b-4998-bbf1-25c21f141ac2", @Path() rootId: string, @Path() salaryPeriodId: string, ) { diff --git a/tsoa.json b/tsoa.json index 8ff04a3..9e5a25c 100644 --- a/tsoa.json +++ b/tsoa.json @@ -36,7 +36,7 @@ "name": "SalaryRank", "description": "อัตราเงินเดือน" }, { - "name": "Report", "description": "รายงานเงินเดือนข้าราชการ รอบเดือนเมษายน" + "name": "Report", "description": "รายงานเงินเดือนข้าราชการ" } ] },