From 23441410162005295fb5f170b9e862260aa58302 Mon Sep 17 00:00:00 2001 From: kittapath Date: Thu, 24 Oct 2024 09:30:45 +0700 Subject: [PATCH 1/3] =?UTF-8?q?=E0=B8=AD=E0=B8=AD=E0=B8=81=E0=B8=84?= =?UTF-8?q?=E0=B8=B3=E0=B8=AA=E0=B8=B1=E0=B9=88=E0=B8=87=E0=B9=80=E0=B8=87?= =?UTF-8?q?=E0=B8=B4=E0=B8=99=E0=B9=80=E0=B8=94=E0=B8=B7=E0=B8=AD=E0=B8=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/ReportController.ts | 106 +++++++++++++++++++++++++--- 1 file changed, 96 insertions(+), 10 deletions(-) diff --git a/src/controllers/ReportController.ts b/src/controllers/ReportController.ts index 94d128b..ded0593 100644 --- a/src/controllers/ReportController.ts +++ b/src/controllers/ReportController.ts @@ -6553,11 +6553,15 @@ export class ReportController extends Controller { const _salaryRank = salaryRank.map((item) => ({ id: item.id, - citizenId: item.citizenId, + posMasterNo: `${item.orgShortName}${item.posMasterNo}`, + positionName: item.position, + posType: item.posType, + posLevel: item.posLevel, + profileId: item.profileId, prefix: item.prefix, firstName: item.firstName, lastName: item.lastName, - profileId: item.profileId, + citizenId: item.citizenId, })); return new HttpSuccess(_salaryRank); @@ -6599,11 +6603,15 @@ export class ReportController extends Controller { const _salaryRank = salaryRank.map((item) => ({ id: item.id, - citizenId: item.citizenId, + posMasterNo: `${item.orgShortName}${item.posMasterNo}`, + positionName: item.position, + posType: item.posType, + posLevel: item.posLevel, + profileId: item.profileId, prefix: item.prefix, firstName: item.firstName, lastName: item.lastName, - profileId: item.profileId, + citizenId: item.citizenId, })); return new HttpSuccess(_salaryRank); @@ -6639,11 +6647,15 @@ export class ReportController extends Controller { const _salaryRank = salaryRank.map((item) => ({ id: item.id, - citizenId: item.citizenId, + posMasterNo: `${item.orgShortName}${item.posMasterNo}`, + positionName: item.position, + posType: item.posType, + posLevel: item.posLevel, + profileId: item.profileId, prefix: item.prefix, firstName: item.firstName, lastName: item.lastName, - profileId: item.profileId, + citizenId: item.citizenId, })); return new HttpSuccess(_salaryRank); @@ -6678,11 +6690,15 @@ export class ReportController extends Controller { const _salaryRank = salaryRank.map((item) => ({ id: item.id, - citizenId: item.citizenId, + posMasterNo: `${item.orgShortName}${item.posMasterNo}`, + positionName: item.position, + posType: item.posType, + posLevel: `${item.posTypeShort}${item.posLevel}`, + profileId: item.profileId, prefix: item.prefix, firstName: item.firstName, lastName: item.lastName, - profileId: item.profileId, + citizenId: item.citizenId, })); return new HttpSuccess(_salaryRank); @@ -6717,11 +6733,15 @@ export class ReportController extends Controller { const _salaryRank = salaryRank.map((item) => ({ id: item.id, - citizenId: item.citizenId, + posMasterNo: `${item.orgShortName}${item.posMasterNo}`, + positionName: item.position, + posType: item.posType, + posLevel: `${item.posTypeShort}${item.posLevel}`, + profileId: item.profileId, prefix: item.prefix, firstName: item.firstName, lastName: item.lastName, - profileId: item.profileId, + citizenId: item.citizenId, })); return new HttpSuccess(_salaryRank); @@ -6871,6 +6891,14 @@ export class ReportController extends Controller { }, @Request() request: RequestWithUser, ) { + const salaryProfile = await this.salaryProfileRepository.find({ + where: { id: In(body.refIds) }, + }); + const data = salaryProfile.map((_data) => ({ + ..._data, + status: "REPORT", + })); + await this.salaryProfileRepository.save(data); return new HttpSuccess(); } /** @@ -6888,6 +6916,64 @@ export class ReportController extends Controller { }, @Request() request: RequestWithUser, ) { + const salaryProfile = await this.salaryProfileEmployeeRepository.find({ + where: { id: In(body.refIds) }, + }); + const data = salaryProfile.map((_data) => ({ + ..._data, + status: "REPORT", + })); + await this.salaryProfileEmployeeRepository.save(data); + return new HttpSuccess(); + } + /** + * API ออกคำสั่ง + * + * @summary ออกคำสั่ง + * + * @param {string} id Guid, *Id ผังเงินเดือน + */ + @Post("command/officer/report/delete") + async SalaryOfficerReportCommandDelete( + @Body() + body: { + refIds: string[]; + }, + @Request() request: RequestWithUser, + ) { + const salaryProfile = await this.salaryProfileRepository.find({ + where: { id: In(body.refIds) }, + }); + const data = salaryProfile.map((_data) => ({ + ..._data, + status: "PENDING", + })); + await this.salaryProfileRepository.save(data); + return new HttpSuccess(); + } + /** + * API ออกคำสั่ง + * + * @summary ออกคำสั่ง + * + * @param {string} id Guid, *Id ผังเงินเดือน + */ + @Post("command/employee/report/delete") + async SalaryEmployeeReportCommandDelete( + @Body() + body: { + refIds: string[]; + }, + @Request() request: RequestWithUser, + ) { + const salaryProfile = await this.salaryProfileEmployeeRepository.find({ + where: { id: In(body.refIds) }, + }); + const data = salaryProfile.map((_data) => ({ + ..._data, + status: "PENDING", + })); + await this.salaryProfileEmployeeRepository.save(data); return new HttpSuccess(); } } From 6d1b908c8cd5e3cb8908b217a370d98f4f2781bb Mon Sep 17 00:00:00 2001 From: kittapath Date: Thu, 24 Oct 2024 10:48:41 +0700 Subject: [PATCH 2/3] no message --- src/controllers/ReportController.ts | 441 +++++++++++++++++++++++++++- 1 file changed, 440 insertions(+), 1 deletion(-) diff --git a/src/controllers/ReportController.ts b/src/controllers/ReportController.ts index ded0593..92d6806 100644 --- a/src/controllers/ReportController.ts +++ b/src/controllers/ReportController.ts @@ -15,7 +15,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, Not, IsNull, MoreThan, Double } from "typeorm"; +import { In, Not, IsNull, MoreThan, Double, Brackets } from "typeorm"; import { Salarys } from "../entities/Salarys"; import { SalaryRanks } from "../entities/SalaryRanks"; import { PosType } from "../entities/PosType"; @@ -6747,6 +6747,445 @@ export class ReportController extends Controller { return new HttpSuccess(_salaryRank); } + /** + * API ออกคำสั่ง 33 + * + * @summary ออกคำสั่ง 33 + * + * @param {string} id Guid, *Id ผังเงินเดือน + */ + @Post("command/33/{id}") + async SalaryReport33Command( + @Path() id: string, + @Body() + body: { + type: string; + rootId: string; + }, + ) { + let conditionGroup = ""; + if (body.type.trim().toUpperCase() == "GROUP1.1") { + conditionGroup = + "(salaryProfile.posType = 'ทั่วไป' AND salaryProfile.posLevel = 'ชำนาญงาน') OR (salaryProfile.posType = 'ทั่วไป' AND salaryProfile.posLevel = 'ปฏิบัติงาน') OR (salaryProfile.posType = 'วิชาการ' AND salaryProfile.posLevel = 'ปฏิบัติการ') OR (salaryProfile.posType = 'วิชาการ' AND salaryProfile.posLevel = 'ชำนาญการ')"; + } else if (body.type.trim().toUpperCase() == "GROUP1.2") { + conditionGroup = + "(salaryProfile.posType = 'ทั่วไป' AND salaryProfile.posLevel = 'อาวุโส') OR (salaryProfile.posType = 'วิชาการ' AND salaryProfile.posLevel = 'ชำนาญการพิเศษ') OR (salaryProfile.posType = 'อำนวยการ' AND salaryProfile.posLevel = 'ต้น')"; + } else if (body.type.trim().toUpperCase() == "GROUP2") { + conditionGroup = + "(salaryProfile.posType = 'ทั่วไป' AND salaryProfile.posLevel = 'ทักษะพิเศษ') OR (salaryProfile.posType = 'วิชาการ' AND salaryProfile.posLevel = 'เชี่ยวชาญ') OR (salaryProfile.posType = 'วิชาการ' AND salaryProfile.posLevel = 'ทรงคุณวุฒิ') OR (salaryProfile.posType = 'อำนวยการ' AND salaryProfile.posLevel = 'สูง') OR (salaryProfile.posType = 'บริหาร' AND salaryProfile.posLevel = 'ต้น') OR (salaryProfile.posType = 'บริหาร' AND salaryProfile.posLevel = 'สูง')"; + } else { + throw new HttpError(HttpStatusCode.NOT_FOUND, "กลุ่มเป้าหมายไม่ถูกต้อง"); + } + const salary = await this.salaryPeriodRepository.findOne({ + where: { id: id }, + }); + if (!salary) { + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการขึ้นเงินเดือน"); + } + const salaryOrgs = await this.salaryOrgRepository.find({ + where: { salaryPeriodId: salary.id, snapshot: "SNAP2" }, + }); + + let salaryRank = await AppDataSource.getRepository(SalaryProfile) + .createQueryBuilder("salaryProfile") + .andWhere("salaryProfile.rootId LIKE :rootId", { + rootId: body.type.trim().toUpperCase() == "GROUP1.1" ? body.rootId : `%%`, + }) + .andWhere({ + salaryOrgId: In(salaryOrgs.map((x) => x.id)), + type: In(["FULLHAFT", "FULL", "HAFT"]), + status: "PENDING", + }) + .andWhere( + new Brackets((qb) => { + qb.andWhere(conditionGroup); + }), + ) + .andWhere("salaryProfile.status = :status", { status: "PENDING" }) + .select([ + "salaryProfile.id", + "salaryProfile.orgShortName", + "salaryProfile.posMasterNo", + "salaryProfile.position", + "salaryProfile.posType", + "salaryProfile.posLevel", + "salaryProfile.profileId", + "salaryProfile.prefix", + "salaryProfile.firstName", + "salaryProfile.lastName", + "salaryProfile.citizenId", + ]) + .getMany(); + + const _salaryRank = salaryRank.map((item) => ({ + id: item.id, + posMasterNo: `${item.orgShortName}${item.posMasterNo}`, + positionName: item.position, + posType: item.posType, + posLevel: item.posLevel, + profileId: item.profileId, + prefix: item.prefix, + firstName: item.firstName, + lastName: item.lastName, + citizenId: item.citizenId, + })); + + return new HttpSuccess(_salaryRank); + } + + /** + * API ออกคำสั่ง 34 + * + * @summary ออกคำสั่ง 34 + * + * @param {string} id Guid, *Id ผังเงินเดือน + */ + @Post("command/34/{id}") + async SalaryReport34Command( + @Path() id: string, + @Body() + body: { + type: string; + rootId: string; + }, + ) { + let conditionGroup = ""; + if (body.type.trim().toUpperCase() == "GROUP1.1") { + conditionGroup = + "(salaryProfile.posType = 'ทั่วไป' AND salaryProfile.posLevel = 'ชำนาญงาน') OR (salaryProfile.posType = 'ทั่วไป' AND salaryProfile.posLevel = 'ปฏิบัติงาน') OR (salaryProfile.posType = 'วิชาการ' AND salaryProfile.posLevel = 'ปฏิบัติการ') OR (salaryProfile.posType = 'วิชาการ' AND salaryProfile.posLevel = 'ชำนาญการ')"; + } else if (body.type.trim().toUpperCase() == "GROUP1.2") { + conditionGroup = + "(salaryProfile.posType = 'ทั่วไป' AND salaryProfile.posLevel = 'อาวุโส') OR (salaryProfile.posType = 'วิชาการ' AND salaryProfile.posLevel = 'ชำนาญการพิเศษ') OR (salaryProfile.posType = 'อำนวยการ' AND salaryProfile.posLevel = 'ต้น')"; + } else if (body.type.trim().toUpperCase() == "GROUP2") { + conditionGroup = + "(salaryProfile.posType = 'ทั่วไป' AND salaryProfile.posLevel = 'ทักษะพิเศษ') OR (salaryProfile.posType = 'วิชาการ' AND salaryProfile.posLevel = 'เชี่ยวชาญ') OR (salaryProfile.posType = 'วิชาการ' AND salaryProfile.posLevel = 'ทรงคุณวุฒิ') OR (salaryProfile.posType = 'อำนวยการ' AND salaryProfile.posLevel = 'สูง') OR (salaryProfile.posType = 'บริหาร' AND salaryProfile.posLevel = 'ต้น') OR (salaryProfile.posType = 'บริหาร' AND salaryProfile.posLevel = 'สูง')"; + } else { + throw new HttpError(HttpStatusCode.NOT_FOUND, "กลุ่มเป้าหมายไม่ถูกต้อง"); + } + const salary = await this.salaryPeriodRepository.findOne({ + where: { id: id }, + }); + if (!salary) { + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการขึ้นเงินเดือน"); + } + const salaryOrgs = await this.salaryOrgRepository.find({ + where: { salaryPeriodId: salary.id, snapshot: "SNAP2" }, + }); + + let salaryRank = await AppDataSource.getRepository(SalaryProfile) + .createQueryBuilder("salaryProfile") + .andWhere("salaryProfile.rootId LIKE :rootId", { + rootId: body.type.trim().toUpperCase() == "GROUP1.1" ? body.rootId : `%%`, + }) + .andWhere( + new Brackets((qb) => { + qb.orWhere({ + salaryOrgId: In(salaryOrgs.map((x) => x.id)), + amountSpecial: MoreThan(0), + status: "PENDING", + }).orWhere({ + salaryOrgId: In(salaryOrgs.map((x) => x.id)), + type: "NONE", + status: "PENDING", + }); + }), + ) + .andWhere( + new Brackets((qb) => { + qb.andWhere(conditionGroup); + }), + ) + .andWhere("salaryProfile.status = :status", { status: "PENDING" }) + .select([ + "salaryProfile.id", + "salaryProfile.orgShortName", + "salaryProfile.posMasterNo", + "salaryProfile.position", + "salaryProfile.posType", + "salaryProfile.posLevel", + "salaryProfile.profileId", + "salaryProfile.prefix", + "salaryProfile.firstName", + "salaryProfile.lastName", + "salaryProfile.citizenId", + ]) + .getMany(); + + const _salaryRank = salaryRank.map((item) => ({ + id: item.id, + posMasterNo: `${item.orgShortName}${item.posMasterNo}`, + positionName: item.position, + posType: item.posType, + posLevel: item.posLevel, + profileId: item.profileId, + prefix: item.prefix, + firstName: item.firstName, + lastName: item.lastName, + citizenId: item.citizenId, + })); + + return new HttpSuccess(_salaryRank); + } + + /** + * API ออกคำสั่ง 35 + * + * @summary ออกคำสั่ง 35 + * + * @param {string} id Guid, *Id ผังเงินเดือน + */ + @Post("command/35/{id}") + async SalaryReport35Command( + @Path() id: string, + @Body() + body: { + type: string; + rootId: string; + }, + ) { + let conditionGroup = ""; + if (body.type.trim().toUpperCase() == "GROUP1.1") { + conditionGroup = + "(salaryProfile.posType = 'ทั่วไป' AND salaryProfile.posLevel = 'ชำนาญงาน') OR (salaryProfile.posType = 'ทั่วไป' AND salaryProfile.posLevel = 'ปฏิบัติงาน') OR (salaryProfile.posType = 'วิชาการ' AND salaryProfile.posLevel = 'ปฏิบัติการ') OR (salaryProfile.posType = 'วิชาการ' AND salaryProfile.posLevel = 'ชำนาญการ')"; + } else if (body.type.trim().toUpperCase() == "GROUP1.2") { + conditionGroup = + "(salaryProfile.posType = 'ทั่วไป' AND salaryProfile.posLevel = 'อาวุโส') OR (salaryProfile.posType = 'วิชาการ' AND salaryProfile.posLevel = 'ชำนาญการพิเศษ') OR (salaryProfile.posType = 'อำนวยการ' AND salaryProfile.posLevel = 'ต้น')"; + } else if (body.type.trim().toUpperCase() == "GROUP2") { + conditionGroup = + "(salaryProfile.posType = 'ทั่วไป' AND salaryProfile.posLevel = 'ทักษะพิเศษ') OR (salaryProfile.posType = 'วิชาการ' AND salaryProfile.posLevel = 'เชี่ยวชาญ') OR (salaryProfile.posType = 'วิชาการ' AND salaryProfile.posLevel = 'ทรงคุณวุฒิ') OR (salaryProfile.posType = 'อำนวยการ' AND salaryProfile.posLevel = 'สูง') OR (salaryProfile.posType = 'บริหาร' AND salaryProfile.posLevel = 'ต้น') OR (salaryProfile.posType = 'บริหาร' AND salaryProfile.posLevel = 'สูง')"; + } else { + throw new HttpError(HttpStatusCode.NOT_FOUND, "กลุ่มเป้าหมายไม่ถูกต้อง"); + } + const salary = await this.salaryPeriodRepository.findOne({ + where: { id: id }, + }); + if (!salary) { + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการขึ้นเงินเดือน"); + } + const salaryOrgs = await this.salaryOrgRepository.find({ + where: { salaryPeriodId: salary.id, snapshot: "SNAP2" }, + }); + + let salaryRank = await AppDataSource.getRepository(SalaryProfile) + .createQueryBuilder("salaryProfile") + .andWhere("salaryProfile.rootId LIKE :rootId", { + rootId: body.type.trim().toUpperCase() == "GROUP1.1" ? body.rootId : `%%`, + }) + .andWhere({ + salaryOrgId: In(salaryOrgs.map((x) => x.id)), + type: In(["FULLHAFT", "FULL", "HAFT"]), + status: "PENDING", + isRetired: true, + }) + .andWhere( + new Brackets((qb) => { + qb.andWhere(conditionGroup); + }), + ) + .andWhere("salaryProfile.status = :status", { status: "PENDING" }) + .select([ + "salaryProfile.id", + "salaryProfile.orgShortName", + "salaryProfile.posMasterNo", + "salaryProfile.position", + "salaryProfile.posType", + "salaryProfile.posLevel", + "salaryProfile.profileId", + "salaryProfile.prefix", + "salaryProfile.firstName", + "salaryProfile.lastName", + "salaryProfile.citizenId", + ]) + .getMany(); + + const _salaryRank = salaryRank.map((item) => ({ + id: item.id, + posMasterNo: `${item.orgShortName}${item.posMasterNo}`, + positionName: item.position, + posType: item.posType, + posLevel: item.posLevel, + profileId: item.profileId, + prefix: item.prefix, + firstName: item.firstName, + lastName: item.lastName, + citizenId: item.citizenId, + })); + + return new HttpSuccess(_salaryRank); + } + + /** + * API ออกคำสั่ง 36 + * + * @summary ออกคำสั่ง 36 + * + * @param {string} id Guid, *Id ผังเงินเดือน + */ + @Post("command/36/{id}") + async SalaryReport36Command( + @Path() id: string, + @Body() + body: { + type: string; + rootId: string; + }, + ) { + // let conditionGroup = ""; + // if (body.type.trim().toUpperCase() == "GROUP1.1") { + // conditionGroup = + // "(salaryProfileEmployee.posType = 'ทั่วไป' AND salaryProfileEmployee.posLevel = 'ชำนาญงาน') OR (salaryProfileEmployee.posType = 'ทั่วไป' AND salaryProfileEmployee.posLevel = 'ปฏิบัติงาน') OR (salaryProfileEmployee.posType = 'วิชาการ' AND salaryProfileEmployee.posLevel = 'ปฏิบัติการ') OR (salaryProfileEmployee.posType = 'วิชาการ' AND salaryProfileEmployee.posLevel = 'ชำนาญการ')"; + // } else if (body.type.trim().toUpperCase() == "GROUP1.2") { + // conditionGroup = + // "(salaryProfileEmployee.posType = 'ทั่วไป' AND salaryProfileEmployee.posLevel = 'อาวุโส') OR (salaryProfileEmployee.posType = 'วิชาการ' AND salaryProfileEmployee.posLevel = 'ชำนาญการพิเศษ') OR (salaryProfileEmployee.posType = 'อำนวยการ' AND salaryProfileEmployee.posLevel = 'ต้น')"; + // } else if (body.type.trim().toUpperCase() == "GROUP2") { + // conditionGroup = + // "(salaryProfileEmployee.posType = 'ทั่วไป' AND salaryProfileEmployee.posLevel = 'ทักษะพิเศษ') OR (salaryProfileEmployee.posType = 'วิชาการ' AND salaryProfileEmployee.posLevel = 'เชี่ยวชาญ') OR (salaryProfileEmployee.posType = 'วิชาการ' AND salaryProfileEmployee.posLevel = 'ทรงคุณวุฒิ') OR (salaryProfileEmployee.posType = 'อำนวยการ' AND salaryProfileEmployee.posLevel = 'สูง') OR (salaryProfileEmployee.posType = 'บริหาร' AND salaryProfileEmployee.posLevel = 'ต้น') OR (salaryProfileEmployee.posType = 'บริหาร' AND salaryProfileEmployee.posLevel = 'สูง')"; + // } else { + // throw new HttpError(HttpStatusCode.NOT_FOUND, "กลุ่มเป้าหมายไม่ถูกต้อง"); + // } + const salary = await this.salaryPeriodRepository.findOne({ + where: { id: id }, + }); + if (!salary) { + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการขึ้นเงินเดือน"); + } + const salaryOrgs = await this.salaryOrgEmployeeRepository.find({ + where: { salaryPeriodId: salary.id, snapshot: "SNAP2" }, + }); + + let salaryRank = await AppDataSource.getRepository(SalaryProfileEmployee) + .createQueryBuilder("salaryProfileEmployee") + // .andWhere("salaryProfileEmployee.rootId LIKE :rootId", { + // rootId: body.type.trim().toUpperCase() == "GROUP1.1" ? body.rootId : `%%`, + // }) + .andWhere({ + salaryOrgId: In(salaryOrgs.map((x) => x.id)), + type: In(["FULLHAFT", "FULL", "HAFT"]), + status: "PENDING", + }) + // .andWhere( + // new Brackets((qb) => { + // qb.andWhere(conditionGroup); + // }), + // ) + .andWhere("salaryProfileEmployee.status = :status", { status: "PENDING" }) + .select([ + "salaryProfileEmployee.id", + "salaryProfileEmployee.orgShortName", + "salaryProfileEmployee.posMasterNo", + "salaryProfileEmployee.position", + "salaryProfileEmployee.posType", + "salaryProfileEmployee.posLevel", + "salaryProfileEmployee.profileId", + "salaryProfileEmployee.prefix", + "salaryProfileEmployee.firstName", + "salaryProfileEmployee.lastName", + "salaryProfileEmployee.citizenId", + ]) + .getMany(); + + const _salaryRank = salaryRank.map((item) => ({ + id: item.id, + posMasterNo: `${item.orgShortName}${item.posMasterNo}`, + positionName: item.position, + posType: item.posType, + posLevel: `${item.posTypeShort}${item.posLevel}`, + profileId: item.profileId, + prefix: item.prefix, + firstName: item.firstName, + lastName: item.lastName, + citizenId: item.citizenId, + })); + + return new HttpSuccess(_salaryRank); + } + + /** + * API ออกคำสั่ง 37 + * + * @summary ออกคำสั่ง 37 + * + * @param {string} id Guid, *Id ผังเงินเดือน + */ + @Post("command/37/{id}") + async SalaryReport37Command( + @Path() id: string, + @Body() + body: { + type: string; + rootId: string; + }, + ) { + // let conditionGroup = ""; + // if (body.type.trim().toUpperCase() == "GROUP1.1") { + // conditionGroup = + // "(salaryProfileEmployee.posType = 'ทั่วไป' AND salaryProfileEmployee.posLevel = 'ชำนาญงาน') OR (salaryProfileEmployee.posType = 'ทั่วไป' AND salaryProfileEmployee.posLevel = 'ปฏิบัติงาน') OR (salaryProfileEmployee.posType = 'วิชาการ' AND salaryProfileEmployee.posLevel = 'ปฏิบัติการ') OR (salaryProfileEmployee.posType = 'วิชาการ' AND salaryProfileEmployee.posLevel = 'ชำนาญการ')"; + // } else if (body.type.trim().toUpperCase() == "GROUP1.2") { + // conditionGroup = + // "(salaryProfileEmployee.posType = 'ทั่วไป' AND salaryProfileEmployee.posLevel = 'อาวุโส') OR (salaryProfileEmployee.posType = 'วิชาการ' AND salaryProfileEmployee.posLevel = 'ชำนาญการพิเศษ') OR (salaryProfileEmployee.posType = 'อำนวยการ' AND salaryProfileEmployee.posLevel = 'ต้น')"; + // } else if (body.type.trim().toUpperCase() == "GROUP2") { + // conditionGroup = + // "(salaryProfileEmployee.posType = 'ทั่วไป' AND salaryProfileEmployee.posLevel = 'ทักษะพิเศษ') OR (salaryProfileEmployee.posType = 'วิชาการ' AND salaryProfileEmployee.posLevel = 'เชี่ยวชาญ') OR (salaryProfileEmployee.posType = 'วิชาการ' AND salaryProfileEmployee.posLevel = 'ทรงคุณวุฒิ') OR (salaryProfileEmployee.posType = 'อำนวยการ' AND salaryProfileEmployee.posLevel = 'สูง') OR (salaryProfileEmployee.posType = 'บริหาร' AND salaryProfileEmployee.posLevel = 'ต้น') OR (salaryProfileEmployee.posType = 'บริหาร' AND salaryProfileEmployee.posLevel = 'สูง')"; + // } else { + // throw new HttpError(HttpStatusCode.NOT_FOUND, "กลุ่มเป้าหมายไม่ถูกต้อง"); + // } + const salary = await this.salaryPeriodRepository.findOne({ + where: { id: id }, + }); + if (!salary) { + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการขึ้นเงินเดือน"); + } + const salaryOrgs = await this.salaryOrgEmployeeRepository.find({ + where: { salaryPeriodId: salary.id, snapshot: "SNAP2" }, + }); + + let salaryRank = await AppDataSource.getRepository(SalaryProfileEmployee) + .createQueryBuilder("salaryProfileEmployee") + // .andWhere("salaryProfileEmployee.rootId LIKE :rootId", { + // rootId: body.type.trim().toUpperCase() == "GROUP1.1" ? body.rootId : `%%`, + // }) + .andWhere({ + salaryOrgId: In(salaryOrgs.map((x) => x.id)), + amountSpecial: MoreThan(0), + status: "PENDING", + }) + // .andWhere( + // new Brackets((qb) => { + // qb.andWhere(conditionGroup); + // }), + // ) + .andWhere("salaryProfileEmployee.status = :status", { status: "PENDING" }) + .select([ + "salaryProfileEmployee.id", + "salaryProfileEmployee.orgShortName", + "salaryProfileEmployee.posMasterNo", + "salaryProfileEmployee.position", + "salaryProfileEmployee.posType", + "salaryProfileEmployee.posLevel", + "salaryProfileEmployee.profileId", + "salaryProfileEmployee.prefix", + "salaryProfileEmployee.firstName", + "salaryProfileEmployee.lastName", + "salaryProfileEmployee.citizenId", + ]) + .getMany(); + + const _salaryRank = salaryRank.map((item) => ({ + id: item.id, + posMasterNo: `${item.orgShortName}${item.posMasterNo}`, + positionName: item.position, + posType: item.posType, + posLevel: `${item.posTypeShort}${item.posLevel}`, + profileId: item.profileId, + prefix: item.prefix, + firstName: item.firstName, + lastName: item.lastName, + citizenId: item.citizenId, + })); + + return new HttpSuccess(_salaryRank); + } + /** * API ออกคำสั่ง * From 1572c5206c5f3730a4ceffd9d9e6f730413841b2 Mon Sep 17 00:00:00 2001 From: kittapath Date: Thu, 24 Oct 2024 10:55:58 +0700 Subject: [PATCH 3/3] no message --- src/controllers/ReportController.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/controllers/ReportController.ts b/src/controllers/ReportController.ts index 92d6806..89b2e0a 100644 --- a/src/controllers/ReportController.ts +++ b/src/controllers/ReportController.ts @@ -6754,7 +6754,7 @@ export class ReportController extends Controller { * * @param {string} id Guid, *Id ผังเงินเดือน */ - @Post("command/33/{id}") + @Post("command/C-PM-33/{id}") async SalaryReport33Command( @Path() id: string, @Body() @@ -6840,7 +6840,7 @@ export class ReportController extends Controller { * * @param {string} id Guid, *Id ผังเงินเดือน */ - @Post("command/34/{id}") + @Post("command/C-PM-34/{id}") async SalaryReport34Command( @Path() id: string, @Body() @@ -6934,7 +6934,7 @@ export class ReportController extends Controller { * * @param {string} id Guid, *Id ผังเงินเดือน */ - @Post("command/35/{id}") + @Post("command/C-PM-35/{id}") async SalaryReport35Command( @Path() id: string, @Body() @@ -7021,7 +7021,7 @@ export class ReportController extends Controller { * * @param {string} id Guid, *Id ผังเงินเดือน */ - @Post("command/36/{id}") + @Post("command/C-PM-36/{id}") async SalaryReport36Command( @Path() id: string, @Body() @@ -7107,7 +7107,7 @@ export class ReportController extends Controller { * * @param {string} id Guid, *Id ผังเงินเดือน */ - @Post("command/37/{id}") + @Post("command/C-PM-37/{id}") async SalaryReport37Command( @Path() id: string, @Body()