From 93940017f997c68c98a1851690e41d2d406298a4 Mon Sep 17 00:00:00 2001 From: AdisakKanthawilang Date: Fri, 5 Jul 2024 11:25:35 +0700 Subject: [PATCH] fitered group salary report --- src/controllers/ReportController.ts | 146 ++++++++++++++++++---------- src/entities/SalaryProfile.ts | 6 +- 2 files changed, 97 insertions(+), 55 deletions(-) diff --git a/src/controllers/ReportController.ts b/src/controllers/ReportController.ts index 16663b1..cc4f760 100644 --- a/src/controllers/ReportController.ts +++ b/src/controllers/ReportController.ts @@ -216,8 +216,12 @@ export class ReportController extends Controller { * @summary รายชื่อข้าราชการผู้ที่ครองตำแหน่ง ณ วันที่ 1 มีนาคม(รอบเมษายน) และ ณ วันที่ 1 กันยายน(รอบตุลาคม) * */ - @Get("gov-01/{rootId}/{salaryPeriodId}") - async SalaryReport1(@Path() rootId: string, @Path() salaryPeriodId: string) { + @Get("gov-01/{rootId}/{salaryPeriodId}/{group}") + async SalaryReport1( + @Path() rootId: string, + @Path() salaryPeriodId: string, + @Path() group: string, + ) { const salaryPeriod = await this.salaryPeriodRepository.findOne({ where: { id: salaryPeriodId, @@ -226,12 +230,14 @@ export class ReportController extends Controller { if (!salaryPeriod) { throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการขึ้นเงินเดือน"); } + const convertGroup = group.toUpperCase(); const _salaryPeriod = await this.salaryProfileRepository.find({ relations: ["salaryOrg", "salaryOrg.salaryPeriod"], where: { salaryOrg: { snapshot: "SNAP1", rootId: rootId, + group: convertGroup, salaryPeriodId: salaryPeriodId, }, }, @@ -363,16 +369,17 @@ export class ReportController extends Controller { profile.child2, profile.child1, profile.root, - `${profile.prefix}${profile.firstName} ${profile.lastName}`, ]; - const fullName = fullNameParts + const affiliation = fullNameParts .filter((part) => part !== undefined && part !== null) .join("/"); + const fullName = `${profile.prefix}${profile.firstName} ${profile.lastName}`; return { no: Extension.ToThaiNumber((index + 1).toLocaleString()), fullName: fullName, + affiliation: affiliation, posLevel: profile.posLevel, posNumber: Extension.ToThaiNumber(profile.orgShortName) + @@ -1255,17 +1262,14 @@ export class ReportController extends Controller { profile: salaryProfileGroup1 ? salaryProfileGroup1.map((item: any, index: any) => ({ no: Extension.ToThaiNumber(String(index + 1)), - fullname: + affiliation: (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) + - "/" + - item.prefix + - item.firstName + - " " + - item.lastName, // สังกัด/ชื่อ-นามสกุล + (item.root == undefined && item.root == null ? "" : item.root), + // สังกัด + fullName: item.prefix + item.firstName + " " + item.lastName, posLevel: item.posLevel, posMasterNo: Extension.ToThaiNumber(item.orgShortName) + @@ -1309,17 +1313,14 @@ export class ReportController extends Controller { profileGroup2: salaryProfileGroup2 ? salaryProfileGroup2.map((item: any, index: any) => ({ no: Extension.ToThaiNumber(String(index + 1)), - fullname: + affiliation: (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) + - "/" + - item.prefix + - item.firstName + - " " + - item.lastName, // สังกัด/ชื่อ-นามสกุล + (item.root == undefined && item.root == null ? "" : item.root), + // สังกัด/ชื่อ-นามสกุล + fullName: item.prefix + item.firstName + " " + item.lastName, posLevel: item.posLevel, posMasterNo: Extension.ToThaiNumber(item.orgShortName) + @@ -1741,8 +1742,12 @@ export class ReportController extends Controller { * @param {string} rootId Guid, *Id Root * @param {string} salaryPeriodId Guid, *Id Period */ - @Get("gov-04/{rootId}/{salaryPeriodId}") - async SalaryReport4(@Path() rootId: string, @Path() salaryPeriodId: string) { + @Get("gov-04/{rootId}/{salaryPeriodId}/{group}") + async SalaryReport4( + @Path() rootId: string, + @Path() salaryPeriodId: string, + @Path() group: string, + ) { const salaryPeriod = await this.salaryPeriodRepository.findOne({ where: { id: salaryPeriodId, @@ -1752,13 +1757,14 @@ export class ReportController extends Controller { if (!salaryPeriod) { throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบรอบการขึ้นเงินเดือน"); } - + const convertGroup = group.toUpperCase(); const _salaryPeriod = await this.salaryProfileRepository.find({ relations: ["salaryOrg", "salaryOrg.salaryPeriod"], where: { salaryOrg: { snapshot: "SNAP2", rootId: rootId, + group: convertGroup, salaryPeriodId: salaryPeriodId, }, type: In(["HAFT", "FULL", "FULLHAFT"]), @@ -1789,9 +1795,16 @@ export class ReportController extends Controller { log_group: profile.salaryOrg.group, log_type: profile.type, log_isNext: profile.isNext, - position: - profile.position + - "/" + + // 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), + position: profile.position, + affiliation: (profile.child4 == undefined && profile.child4 == null ? "" : profile.child4 + "/") + (profile.child3 == undefined && profile.child3 == null ? "" : profile.child3 + "/") + (profile.child2 == undefined && profile.child2 == null ? "" : profile.child2 + "/") + @@ -1845,8 +1858,8 @@ export class ReportController extends Controller { * @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) { + @Get("gov-04-01/{rootId}/{salaryPeriodId}/{group}") + async SalaryReport4Retire(@Path() rootId: string, @Path() salaryPeriodId: string, @Path() group: string) { const salaryPeriod = await this.salaryPeriodRepository.findOne({ where: { id: salaryPeriodId, @@ -1856,13 +1869,14 @@ export class ReportController extends Controller { if (!salaryPeriod) { throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบรอบการขึ้นเงินเดือน"); } - + const convertGroup = group.toUpperCase(); const _salaryPeriod = await this.salaryProfileRepository.find({ relations: ["salaryOrg", "salaryOrg.salaryPeriod"], where: { salaryOrg: { snapshot: "SNAP2", rootId: rootId, + group: convertGroup, salaryPeriodId: salaryPeriodId, }, type: In(["HAFT", "FULL", "FULLHAFT"]), @@ -1880,6 +1894,7 @@ export class ReportController extends Controller { const _root = await this.salaryOrgRepository.findOne({ where: { rootId: rootId, + group: convertGroup, salaryPeriodId: salaryPeriodId, }, }); @@ -1893,9 +1908,8 @@ export class ReportController extends Controller { log_group: profile.salaryOrg.group, log_type: profile.type, log_isNext: profile.isNext, - position: - profile.position + - "/" + + position: profile.position, + affiliation: (profile.child4 == undefined && profile.child4 == null ? "" : profile.child4 + "/") + (profile.child3 == undefined && profile.child3 == null ? "" : profile.child3 + "/") + (profile.child2 == undefined && profile.child2 == null ? "" : profile.child2 + "/") + @@ -1949,8 +1963,12 @@ export class ReportController extends Controller { * @param {string} rootId Guid, *Id Root * @param {string} salaryPeriodId Guid, *Id Period */ - @Get("gov-05/{rootId}/{salaryPeriodId}") - async SalaryReport5(@Path() rootId: string, @Path() salaryPeriodId: string) { + @Get("gov-05/{rootId}/{salaryPeriodId}/{group}") + async SalaryReport5( + @Path() rootId: string, + @Path() salaryPeriodId: string, + @Path() group: string, + ) { const salaryPeriod = await this.salaryPeriodRepository.findOne({ where: { id: salaryPeriodId, @@ -1960,13 +1978,14 @@ export class ReportController extends Controller { if (!salaryPeriod) { throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบรอบการขึ้นเงินเดือน"); } - + const convertGroup = group.toUpperCase(); const _salaryPeriod = await this.salaryProfileRepository.find({ relations: ["salaryOrg", "salaryOrg.salaryPeriod"], where: { salaryOrg: { snapshot: "SNAP2", rootId: rootId, + group: convertGroup, salaryPeriodId: salaryPeriodId, }, type: "NONE", //ไม่ได้เลื่อน @@ -1983,6 +2002,7 @@ export class ReportController extends Controller { const _root = await this.salaryOrgRepository.findOne({ where: { rootId: rootId, + group: convertGroup, salaryPeriodId: salaryPeriodId, }, }); @@ -1991,7 +2011,6 @@ export class ReportController extends Controller { const formattedData = _salaryPeriod.map((profile, index) => { const fullNameParts = [ - profile.position, profile.child4, profile.child3, profile.child2, @@ -1999,14 +2018,15 @@ export class ReportController extends Controller { profile.root, ]; - const position = fullNameParts + const affiliation = fullNameParts .filter((part) => part !== undefined && part !== null) .join("/"); - + const position = profile.position; return { no: Extension.ToThaiNumber((index + 1).toLocaleString()), fullname: profile.prefix + profile.firstName + " " + profile.lastName, position: position, + affiliation: affiliation, posLevel: profile.posLevel, posNumber: Extension.ToThaiNumber(profile.orgShortName) + @@ -2037,8 +2057,8 @@ export class ReportController extends Controller { * @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) { + @Get("gov-05-01/{rootId}/{salaryPeriodId}/{group}") + async SalaryReport5retire(@Path() rootId: string, @Path() salaryPeriodId: string, @Path() group: string) { const salaryPeriod = await this.salaryPeriodRepository.findOne({ where: { id: salaryPeriodId, @@ -2049,12 +2069,14 @@ export class ReportController extends Controller { throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบรอบการขึ้นเงินเดือน"); } + const convertGroup = group.toUpperCase(); const _salaryPeriod = await this.salaryProfileRepository.find({ relations: ["salaryOrg", "salaryOrg.salaryPeriod"], where: { salaryOrg: { snapshot: "SNAP2", rootId: rootId, + group: convertGroup, salaryPeriodId: salaryPeriodId, }, type: "NONE", //ไม่ได้เลื่อน @@ -2071,6 +2093,7 @@ export class ReportController extends Controller { const _root = await this.salaryOrgRepository.findOne({ where: { rootId: rootId, + group: convertGroup, salaryPeriodId: salaryPeriodId, }, }); @@ -2079,7 +2102,6 @@ export class ReportController extends Controller { const formattedData = _salaryPeriod.map((profile, index) => { const fullNameParts = [ - profile.position, profile.child4, profile.child3, profile.child2, @@ -2087,14 +2109,15 @@ export class ReportController extends Controller { profile.root, ]; - const position = fullNameParts + const affiliation = fullNameParts .filter((part) => part !== undefined && part !== null) .join("/"); - + const position = profile.position; return { no: Extension.ToThaiNumber((index + 1).toLocaleString()), fullname: profile.prefix + profile.firstName + " " + profile.lastName, position: position, + affiliation: affiliation, posLevel: profile.posLevel, posNumber: Extension.ToThaiNumber(profile.orgShortName) + @@ -2137,8 +2160,12 @@ export class ReportController extends Controller { * @param {string} rootId Guid, *Id Root * @param {string} salaryPeriodId Guid, *Id Period */ - @Get("gov-07/{rootId}/{salaryPeriodId}") - async SalaryReport7(@Path() rootId: string, @Path() salaryPeriodId: string) { + @Get("gov-07/{rootId}/{salaryPeriodId}/{group}") + async SalaryReport7( + @Path() rootId: string, + @Path() salaryPeriodId: string, + @Path() group: string, + ) { const salaryPeriod = await this.salaryPeriodRepository.findOne({ where: { id: salaryPeriodId, @@ -2150,11 +2177,13 @@ export class ReportController extends Controller { throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบรอบการขึ้นเงินเดือน"); } + const convertGroup = group.toUpperCase(); const salaryProfile = await this.salaryProfileRepository.find({ where: { salaryOrg: { snapshot: "SNAP2", rootId: rootId, + group: convertGroup, salaryPeriodId: salaryPeriodId, salaryPeriod: { period: salaryPeriod.period === "APR" ? "APR" : "OCT", @@ -2170,6 +2199,7 @@ export class ReportController extends Controller { const _root = await this.salaryOrgRepository.findOne({ where: { rootId: rootId, + group: convertGroup, salaryPeriodId: salaryPeriodId, }, }); @@ -2179,9 +2209,8 @@ export class ReportController extends Controller { const formattedData = salaryProfile.map((item, index) => ({ no: Extension.ToThaiNumber(String(index + 1)), fullname: item.prefix + item.firstName + " " + item.lastName, - position: - item.position + - "/" + + position: item.position, + affiliation: (item.child4 == undefined && item.child4 == null ? "" : item.child4 + "/") + (item.child3 == undefined && item.child3 == null ? "" : item.child3 + "/") + (item.child2 == undefined && item.child2 == null ? "" : item.child2 + "/") + @@ -2238,8 +2267,8 @@ export class ReportController extends Controller { * @param {string} rootId Guid, *Id Root * @param {string} salaryPeriodId Guid, *Id Period */ - @Get("gov-07-01/{rootId}/{salaryPeriodId}") - async SalaryReport7retire(@Path() rootId: string, @Path() salaryPeriodId: string) { + @Get("gov-07-01/{rootId}/{salaryPeriodId}/{group}") + async SalaryReport7retire(@Path() rootId: string, @Path() salaryPeriodId: string, @Path() group: string) { const salaryPeriod = await this.salaryPeriodRepository.findOne({ where: { id: salaryPeriodId, @@ -2251,12 +2280,13 @@ export class ReportController extends Controller { if (!salaryPeriod) { throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบรอบการขึ้นเงินเดือน"); } - + const convertGroup = group.toUpperCase(); const salaryProfile = await this.salaryProfileRepository.find({ where: { salaryOrg: { snapshot: "SNAP2", rootId: rootId, + group: convertGroup, salaryPeriodId: salaryPeriodId, salaryPeriod: { period: salaryPeriod.period, @@ -2273,6 +2303,7 @@ export class ReportController extends Controller { const _root = await this.salaryOrgRepository.findOne({ where: { rootId: rootId, + group: convertGroup, salaryPeriodId: salaryPeriodId, }, }); @@ -2281,9 +2312,8 @@ export class ReportController extends Controller { const formattedData = salaryProfile.map((item, index) => ({ no: Extension.ToThaiNumber(String(index + 1)), fullname: item.prefix + item.firstName + " " + item.lastName, - position: - item.position + - "/" + + position: item.position, + affiliation: (item.child4 == undefined && item.child4 == null ? "" : item.child4 + "/") + (item.child3 == undefined && item.child3 == null ? "" : item.child3 + "/") + (item.child2 == undefined && item.child2 == null ? "" : item.child2 + "/") + @@ -2429,6 +2459,12 @@ export class ReportController extends Controller { no: Extension.ToThaiNumber(String(index + 1)), fullname: item.prefix + item.firstName + " " + item.lastName, position: item.position, + affiliation: + (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), posType: item.posType, posLevel: item.posLevel, posMasterNo: @@ -2449,6 +2485,12 @@ export class ReportController extends Controller { no: Extension.ToThaiNumber(String(index + 1)), fullname: item.prefix + item.firstName + " " + item.lastName, position: item.position, + affiliation: + (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), posType: item.posType, posLevel: item.posLevel, posMasterNo: diff --git a/src/entities/SalaryProfile.ts b/src/entities/SalaryProfile.ts index 2783222..60def05 100644 --- a/src/entities/SalaryProfile.ts +++ b/src/entities/SalaryProfile.ts @@ -248,12 +248,12 @@ export class SalaryProfile extends EntityBase { child4: string; @Column({ - type: "double", nullable: true, default: null, - comment: "ผลการประเมินผลการปฏิบัติราชการ", + length: 255, + comment: "ผลการประเมินผลการปฏิบัติราชการ",//คะแนนประเมิน }) - result: number; + result: string; @Column({ nullable: true,