From 5af1ef281a958768c2f5d3b52c7fa2bc6bfc848c Mon Sep 17 00:00:00 2001 From: Bright Date: Tue, 5 Mar 2024 18:30:47 +0700 Subject: [PATCH 1/4] =?UTF-8?q?=E0=B8=A3=E0=B8=B2=E0=B8=A2=E0=B8=87?= =?UTF-8?q?=E0=B8=B2=E0=B8=99=E0=B9=81=E0=B8=9A=E0=B8=9A=201=20=E0=B8=81?= =?UTF-8?q?=E0=B8=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/Report_1_Controller.ts | 100 +++++++++++++++++++++++++ 1 file changed, 100 insertions(+) create mode 100644 src/controllers/Report_1_Controller.ts diff --git a/src/controllers/Report_1_Controller.ts b/src/controllers/Report_1_Controller.ts new file mode 100644 index 0000000..e831b58 --- /dev/null +++ b/src/controllers/Report_1_Controller.ts @@ -0,0 +1,100 @@ +import { + Controller, + Get, + Post, + Put, + Delete, + Patch, + Route, + Security, + Tags, + Body, + Path, + Request, + Example, + SuccessResponse, + Response, + Query, +} from "tsoa"; +import { AppDataSource } from "../database/data-source"; +import HttpSuccess from "../interfaces/http-success"; +import HttpStatusCode from "../interfaces/http-status"; +import HttpError from "../interfaces/http-error"; +import { In, IsNull, Not } from "typeorm"; +import { SalaryProfile } from "../entities/SalaryProfile"; +import { SalaryPeriod } from "../entities/SalaryPeriod"; +import { SalaryOrg } from "../entities/SalaryOrg"; +import Extension from "../interfaces/extension"; + +@Route("api/v1/salary/report/1") +@Tags("Report") +// @Security("bearerAuth") +@Response( + HttpStatusCode.INTERNAL_SERVER_ERROR, + "เกิดข้อผิดพลาด ไม่สามารถแสดงรายการได้ กรุณาลองใหม่ในภายหลัง", +) +@SuccessResponse(HttpStatusCode.OK, "สำเร็จ") +export class Report_1_Controller extends Controller { + private salaryPeriodRepository = AppDataSource.getRepository(SalaryPeriod); + private salaryOrgRepository = AppDataSource.getRepository(SalaryOrg); + private salaryProfile = AppDataSource.getRepository(SalaryProfile); + + /** + * API รายงานแบบ 1 กท + * + * @summary รายงานแบบ 1 กท + * + * @param {string} rootId Guid, *Id Root + * @param {string} salaryPeriodId Guid, *Id Period + */ + @Get("{rootId}/{salaryPeriodId}") + async SalaryReport4( + @Path() rootId : string = "c6164a42-539d-401a-b289-653282c08e37", + @Path() salaryPeriodId: string = "31cfc7de-b93b-4998-bbf1-25c21f141ac2", + ) { + const salaryOrg = await this.salaryOrgRepository.findOne({ + where: { + salaryPeriodId: salaryPeriodId, + rootId: rootId, + snapshot: "SNAP2", + }, + order: { + group: "ASC" + } + // relations: ["salaryProfiles"], + }); + if (!salaryOrg) { + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบรอบการขึ้นเงินเดือน"); + } + const salaryPeriod = await this.salaryPeriodRepository.findOne({ + where: { + id: String(salaryOrg.salaryPeriodId), + period: "APR", + isActive: true + }, + }); + + const salaryProfile = await this.salaryProfile.find({ + where: { salaryOrgId: salaryOrg.id}, + select: ["id", "prefix" , "firstName", "lastName", "root", + "position", "posType", "posLevel", "orgShortName", "posMasterNo", "amount", "amountSpecial"] + }); + + const mapData = { + effectiveDate : salaryPeriod?.effectiveDate, + profile: salaryProfile.map((item, index) => ({ + no: index+1, + fullname: item.prefix + item.firstName +" "+ item.lastName, + position: item.position + " / " + item.posType, + posLevel: item.posLevel, + orgShortName: item.orgShortName+item.posMasterNo, + amount: item.amount, + amountSpecial: item.amountSpecial, + root: item.root, + score: null, //สรุปผลการประเมินฯ ระดับและคะแนน + remark: null //หมายเหตุ + })) + } + return mapData + } +} From 3234878df5a29fcd85f5e57eb5f2ec9e4e70a2e8 Mon Sep 17 00:00:00 2001 From: Bright Date: Tue, 5 Mar 2024 18:36:41 +0700 Subject: [PATCH 2/4] no message --- src/controllers/Report_1_Controller.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/controllers/Report_1_Controller.ts b/src/controllers/Report_1_Controller.ts index e831b58..348598a 100644 --- a/src/controllers/Report_1_Controller.ts +++ b/src/controllers/Report_1_Controller.ts @@ -28,7 +28,7 @@ import Extension from "../interfaces/extension"; @Route("api/v1/salary/report/1") @Tags("Report") -// @Security("bearerAuth") +@Security("bearerAuth") @Response( HttpStatusCode.INTERNAL_SERVER_ERROR, "เกิดข้อผิดพลาด ไม่สามารถแสดงรายการได้ กรุณาลองใหม่ในภายหลัง", @@ -82,6 +82,7 @@ export class Report_1_Controller extends Controller { const mapData = { effectiveDate : salaryPeriod?.effectiveDate, + root: salaryProfile[0]?.root, profile: salaryProfile.map((item, index) => ({ no: index+1, fullname: item.prefix + item.firstName +" "+ item.lastName, From eac7a85f0ceb4f08db9a42466577aa47f1ce51a0 Mon Sep 17 00:00:00 2001 From: AdisakKanthawilang Date: Wed, 6 Mar 2024 15:45:12 +0700 Subject: [PATCH 3/4] report checkpoint --- src/controllers/Report2Controller.ts | 100 +++++++++++++++++++++++++++ 1 file changed, 100 insertions(+) create mode 100644 src/controllers/Report2Controller.ts diff --git a/src/controllers/Report2Controller.ts b/src/controllers/Report2Controller.ts new file mode 100644 index 0000000..e3d6465 --- /dev/null +++ b/src/controllers/Report2Controller.ts @@ -0,0 +1,100 @@ +import { + Controller, + Get, + Post, + Put, + Delete, + Patch, + Route, + Security, + Tags, + Body, + Path, + Request, + Example, + SuccessResponse, + Response, + Query, + } from "tsoa"; + import { AppDataSource } from "../database/data-source"; + import HttpSuccess from "../interfaces/http-success"; + import HttpStatusCode from "../interfaces/http-status"; + import HttpError from "../interfaces/http-error"; + import { In, IsNull, Not } from "typeorm"; + import { Salarys } from "../entities/Salarys"; + import { SalaryRanks } from "../entities/SalaryRanks"; + import { PosType } from "../entities/PosType"; + import { PosLevel } from "../entities/PosLevel"; + import Extension from "../interfaces/extension"; + import { SalaryPeriod } from "../entities/SalaryPeriod"; + import { SalaryProfile } from "../entities/SalaryProfile"; + @Route("api/v1/salary/report") + @Tags("Report") + @Security("bearerAuth") + @Response( + HttpStatusCode.INTERNAL_SERVER_ERROR, + "เกิดข้อผิดพลาด ไม่สามารถแสดงรายการได้ กรุณาลองใหม่ในภายหลัง", + ) + @SuccessResponse(HttpStatusCode.OK, "สำเร็จ") + export class Report2Controller extends Controller { + private salaryPeriodRepository = AppDataSource.getRepository(SalaryPeriod); + private salaryProfileRepository = AppDataSource.getRepository(SalaryProfile); + private salaryRepository = AppDataSource.getRepository(Salarys); + private salaryRankRepository = AppDataSource.getRepository(SalaryRanks); + private poTypeRepository = AppDataSource.getRepository(PosType); + private posLevelRepository = AppDataSource.getRepository(PosLevel); + + /** + * API รายชื่อข้าราชการผู้ที่ครองตำแหน่ง + * + * @summary รายชื่อข้าราชการผู้ที่ครองตำแหน่ง + * + */ + @Post("report1") + async report1(@Body() body: { rootId: string; salaryPeriodId: string;}) { + const salaryPeriodAPR = await this.salaryProfileRepository.find({ + relations: ["salaryOrg", "salaryOrg.salaryPeriod"], + where: { + salaryOrg:{ + snapshot:"SNAP1", + rootId:body.rootId, + salaryPeriodId: body.salaryPeriodId, + salaryPeriod:{ + period:"APR" + } + }, + }, + }); + + if (!salaryPeriodAPR) { + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล"); + } + + const agency = salaryPeriodAPR[0]?.root; + + const formattedData = salaryPeriodAPR.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: index + 1, + fullName: fullName?fullName:"", + posLevel: profile?.posLevel?profile?.posLevel:"", + posNumber: profile?.posMasterNo?profile?.posMasterNo:"", + amount: profile?.amount?profile?.amount:"", + reason: null, + }; + }); + + return new HttpSuccess({ agency: agency, data: formattedData }); + } + } + \ No newline at end of file From 18c75fc3cc140597a68b07541b1a4aabb5258d78 Mon Sep 17 00:00:00 2001 From: Bright Date: Wed, 6 Mar 2024 17:03:24 +0700 Subject: [PATCH 4/4] no message --- src/controllers/Report_1_Controller.ts | 228 ++++++++++++++++++++++--- 1 file changed, 203 insertions(+), 25 deletions(-) diff --git a/src/controllers/Report_1_Controller.ts b/src/controllers/Report_1_Controller.ts index 348598a..d4ff762 100644 --- a/src/controllers/Report_1_Controller.ts +++ b/src/controllers/Report_1_Controller.ts @@ -20,7 +20,7 @@ import { AppDataSource } from "../database/data-source"; import HttpSuccess from "../interfaces/http-success"; import HttpStatusCode from "../interfaces/http-status"; import HttpError from "../interfaces/http-error"; -import { In, IsNull, Not } from "typeorm"; +import { In, IsNull, Not, MoreThan } from "typeorm"; import { SalaryProfile } from "../entities/SalaryProfile"; import { SalaryPeriod } from "../entities/SalaryPeriod"; import { SalaryOrg } from "../entities/SalaryOrg"; @@ -40,18 +40,33 @@ export class Report_1_Controller extends Controller { private salaryProfile = AppDataSource.getRepository(SalaryProfile); /** - * API รายงานแบบ 1 กท + * API รายงานแบบ 1 กท รอบเมษายน * - * @summary รายงานแบบ 1 กท + * @summary รายงานแบบ 1 กท รอบเมษายน * * @param {string} rootId Guid, *Id Root * @param {string} salaryPeriodId Guid, *Id Period */ - @Get("{rootId}/{salaryPeriodId}") + @Get("04/{rootId}/{salaryPeriodId}") async SalaryReport4( - @Path() rootId : string = "c6164a42-539d-401a-b289-653282c08e37", - @Path() salaryPeriodId: string = "31cfc7de-b93b-4998-bbf1-25c21f141ac2", + // @Path() rootId : string = "c6164a42-539d-401a-b289-653282c08e37", + // @Path() salaryPeriodId: string = "31cfc7de-b93b-4998-bbf1-25c21f141ac2", + @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, @@ -63,21 +78,14 @@ export class Report_1_Controller extends Controller { } // relations: ["salaryProfiles"], }); - if (!salaryOrg) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบรอบการขึ้นเงินเดือน"); - } - const salaryPeriod = await this.salaryPeriodRepository.findOne({ - where: { - id: String(salaryOrg.salaryPeriodId), - period: "APR", - isActive: true - }, - }); - + const salaryProfile = await this.salaryProfile.find({ - where: { salaryOrgId: salaryOrg.id}, - select: ["id", "prefix" , "firstName", "lastName", "root", - "position", "posType", "posLevel", "orgShortName", "posMasterNo", "amount", "amountSpecial"] + where: { salaryOrgId: salaryOrg?.id}, + select: [ + "id", "prefix" , "firstName", "lastName", "root", + "position", "posType", "posLevel", "orgShortName", + "posMasterNo", "amount", "amountSpecial" + ] }); const mapData = { @@ -86,16 +94,186 @@ export class Report_1_Controller extends Controller { profile: salaryProfile.map((item, index) => ({ no: index+1, fullname: item.prefix + item.firstName +" "+ item.lastName, - position: item.position + " / " + item.posType, + position: item.position + "/" + item.posType, posLevel: item.posLevel, orgShortName: item.orgShortName+item.posMasterNo, - amount: item.amount, - amountSpecial: item.amountSpecial, - root: item.root, + amount: item.amount == null ? 0 : item.amount, + amountSpecial: item.amountSpecial == null ? 0 : item.amountSpecial, score: null, //สรุปผลการประเมินฯ ระดับและคะแนน remark: null //หมายเหตุ })) } return mapData - } + } + + /** + * API รายงานคำสั่งเลื่อนเงินเดือน รอบเมษายน + * + * @summary รายงานคำสั่งเลื่อนเงินเดือน รอบเมษายน + * + * @param {string} rootId Guid, *Id Root + * @param {string} salaryPeriodId Guid, *Id Period + */ + @Get("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, + ) { + 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.salaryProfile.find({ + where: { + salaryOrgId: salaryOrg?.id, + amountSpecial: IsNull() || 0, + amountUse: MoreThan(1), + }, + select: [ + "id", "prefix" , "firstName", "lastName", "root", + "position", "posType", "posLevel", "orgShortName", "posMasterNo", + "amount", "amountUse", "positionSalaryAmount" + ], + order: { + posMasterNo: "ASC" + } + }); + + const mapData = salaryProfile.map((item, index) => ({ + no: index+1, + fullname: item.prefix + item.firstName +" "+ item.lastName, + position: item.position, + posType: item.posType, + posLevel: item.posLevel, + posMasterNo: item.posMasterNo, + amount: item.amount, + positionSalaryAmount: item.positionSalaryAmount, + remark: null + })); + + return mapData; + } + + /** + * API รายงานคำสั่งค่าตอบแทนพิเศษ และผู้ไม่ได้เลื่อน รอบเมษายน + * + * @summary รายงานคำสั่งคำสั่งค่าตอบแทนพิเศษ และผู้ไม่ได้เลื่อน รอบเมษายน + * + * @param {string} rootId Guid, *Id Root + * @param {string} salaryPeriodId Guid, *Id Period + */ + @Get("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, + ) { + 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 salaryProfileSpecial = await this.salaryProfile.find({ + where: { + salaryOrgId: salaryOrg?.id, + amountSpecial: MoreThan(1), + }, + select: [ + "id", "prefix" , "firstName", "lastName", "root", + "position", "posType", "posLevel", "orgShortName", + "posMasterNo", "amount", "amountSpecial", + ], + order: { + posMasterNo: "ASC" + } + }); + + const salaryProfileNoAmount = await this.salaryProfile.find({ + where: { + salaryOrgId: salaryOrg?.id, + amountUse: IsNull() || 0, + positionSalaryAmount: IsNull() || 0, + }, + select: [ + "id", "prefix" , "firstName", "lastName", "root", + "position", "posType", "posLevel", "orgShortName", + "posMasterNo", "amount", + ], + order: { + posMasterNo: "ASC" + } + }); + + + const profileSpecial = salaryProfileSpecial.map((item, index) => ({ + no: index+1, + fullname: item.prefix + item.firstName +" "+ item.lastName, + position: item.position, + posType: item.posType, + posLevel: item.posLevel, + posMasterNo: item.posMasterNo, + amount: item.amount, + amountSpecial: item.amountSpecial, + remark: null + })); + + const profileNoAmount = salaryProfileNoAmount.map((item, index) => ({ + no: index+1, + fullname: item.prefix + item.firstName +" "+ item.lastName, + position: item.position, + posType: item.posType, + posLevel: item.posLevel, + posMasterNo: item.posMasterNo, + amount: item.amount, + remark: null + })); + + const mapData = { + profileSpecial, + profileNoAmount + } + return mapData; + } }