From 0d9a5d69796bd69150706c2d417b9f7544583315 Mon Sep 17 00:00:00 2001 From: Bright Date: Wed, 19 Mar 2025 12:03:25 +0700 Subject: [PATCH] =?UTF-8?q?Issue=20#976=20=E0=B9=81=E0=B8=A2=E0=B8=81?= =?UTF-8?q?=E0=B8=AD=E0=B8=AD=E0=B8=81=E0=B8=84=E0=B8=B3=E0=B8=AA=E0=B8=B1?= =?UTF-8?q?=E0=B9=88=E0=B8=87=2033,34,35,36,37?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/ReportController.ts | 911 ++++++++++++++++++++++++++-- 1 file changed, 853 insertions(+), 58 deletions(-) diff --git a/src/controllers/ReportController.ts b/src/controllers/ReportController.ts index fd8c49f..1d23d1a 100644 --- a/src/controllers/ReportController.ts +++ b/src/controllers/ReportController.ts @@ -7134,9 +7134,9 @@ export class ReportController extends Controller { } /** - * API ออกคำสั่ง 33 + * API ออกคำสั่ง C-PM-33 * - * @summary ออกคำสั่ง 33 + * @summary ออกคำสั่ง C-PM-33 * * @param {string} id Guid, *Id ผังเงินเดือน */ @@ -7180,14 +7180,14 @@ export class ReportController extends Controller { .andWhere({ salaryOrgId: In(salaryOrgs.map((x) => x.id)), type: In(["FULLHAFT", "FULL", "HAFT"]), - status: "PENDING", + // status: "PENDING", }) .andWhere( new Brackets((qb) => { qb.andWhere(conditionGroup); }), ) - .andWhere("salaryProfile.status = :status", { status: "PENDING" }) + .andWhere("salaryProfile.status33 = :status", { status: "PENDING" }) .select([ "salaryProfile.id", "salaryProfile.orgShortName", @@ -7228,9 +7228,9 @@ export class ReportController extends Controller { } /** - * API ออกคำสั่ง 34 + * API รายชื่อออกคำสั่ง C-PM-34 * - * @summary ออกคำสั่ง 34 + * @summary ออกคำสั่ง C-PM-34 * * @param {string} id Guid, *Id ผังเงินเดือน */ @@ -7277,7 +7277,7 @@ export class ReportController extends Controller { salaryOrgId: In(salaryOrgs.map((x) => x.id)), amountSpecial: MoreThan(0), type: Not("NONE"), - status: "PENDING", + // status: "PENDING", }); /*.orWhere({ salaryOrgId: In(salaryOrgs.map((x) => x.id)), type: "NONE", @@ -7290,7 +7290,7 @@ export class ReportController extends Controller { qb.andWhere(conditionGroup); }), ) - .andWhere("salaryProfile.status = :status", { status: "PENDING" }) + .andWhere("salaryProfile.status34 = :status", { status: "PENDING" }) .select([ "salaryProfile.id", "salaryProfile.orgShortName", @@ -7331,9 +7331,9 @@ export class ReportController extends Controller { } /** - * API ออกคำสั่ง 35 + * API ออกคำสั่ง C-PM-35 * - * @summary ออกคำสั่ง 35 + * @summary ออกคำสั่ง C-PM-35 * * @param {string} id Guid, *Id ผังเงินเดือน */ @@ -7377,7 +7377,7 @@ export class ReportController extends Controller { .andWhere({ salaryOrgId: In(salaryOrgs.map((x) => x.id)), type: In(["FULLHAFT", "FULL", "HAFT"]), - status: "PENDING", + // status: "PENDING", isRetired: true, }) .andWhere( @@ -7385,7 +7385,7 @@ export class ReportController extends Controller { qb.andWhere(conditionGroup); }), ) - .andWhere("salaryProfile.status = :status", { status: "PENDING" }) + .andWhere("salaryProfile.status35 = :status", { status: "PENDING" }) .select([ "salaryProfile.id", "salaryProfile.orgShortName", @@ -7426,9 +7426,9 @@ export class ReportController extends Controller { } /** - * API ออกคำสั่ง 36 + * API ออกคำสั่ง C-PM-36 * - * @summary ออกคำสั่ง 36 + * @summary ออกคำสั่ง C-PM-36 * * @param {string} id Guid, *Id ผังเงินเดือน */ @@ -7472,14 +7472,14 @@ export class ReportController extends Controller { .andWhere({ salaryOrgId: In(salaryOrgs.map((x) => x.id)), type: In(["FULLHAFT", "FULL", "HAFT"]), - status: "PENDING", + // status: "PENDING", }) // .andWhere( // new Brackets((qb) => { // qb.andWhere(conditionGroup); // }), // ) - .andWhere("salaryProfileEmployee.status = :status", { status: "PENDING" }) + .andWhere("salaryProfileEmployee.status36 = :status", { status: "PENDING" }) .select([ "salaryProfileEmployee.id", "salaryProfileEmployee.orgShortName", @@ -7521,9 +7521,9 @@ export class ReportController extends Controller { } /** - * API ออกคำสั่ง 37 + * API ออกคำสั่ง C-PM-37 * - * @summary ออกคำสั่ง 37 + * @summary ออกคำสั่ง C-PM-37 * * @param {string} id Guid, *Id ผังเงินเดือน */ @@ -7567,14 +7567,14 @@ export class ReportController extends Controller { .andWhere({ salaryOrgId: In(salaryOrgs.map((x) => x.id)), amountSpecial: MoreThan(0), - status: "PENDING", + // status: "PENDING", }) // .andWhere( // new Brackets((qb) => { // qb.andWhere(conditionGroup); // }), // ) - .andWhere("salaryProfileEmployee.status = :status", { status: "PENDING" }) + .andWhere("salaryProfileEmployee.status37 = :status", { status: "PENDING" }) .select([ "salaryProfileEmployee.id", "salaryProfileEmployee.orgShortName", @@ -7616,14 +7616,14 @@ export class ReportController extends Controller { } /** - * API ออกคำสั่ง + * API ออกคำสั่ง C-PM-33 * - * @summary ออกคำสั่ง + * @summary ออกคำสั่ง C-PM-33 * * @param {string} id Guid, *Id ผังเงินเดือน */ - @Post("command/officer/report") - async SalaryOfficerReportCommand( + @Post("command33/officer/report") + async SalaryOfficerReportCommand33( @Body() body: { refIds: string[]; @@ -7635,21 +7635,74 @@ export class ReportController extends Controller { }); const data = salaryProfile.map((_data) => ({ ..._data, - status: "REPORT", + status33: "REPORT", })); await this.salaryProfileRepository.save(data); return new HttpSuccess(); } + /** - * API ออกคำสั่ง + * API ออกคำสั่ง C-PM-34 * - * @summary ออกคำสั่ง + * @summary ออกคำสั่ง C-PM-34 + * + * @param {string} id Guid, *Id ผังเงินเดือน + */ + @Post("command34/officer/report") + async SalaryOfficerReportCommand34( + @Body() + body: { + refIds: string[]; + }, + @Request() request: RequestWithUser, + ) { + const salaryProfile = await this.salaryProfileRepository.find({ + where: { id: In(body.refIds) }, + }); + const data = salaryProfile.map((_data) => ({ + ..._data, + status34: "REPORT", + })); + await this.salaryProfileRepository.save(data); + return new HttpSuccess(); + } + + /** + * API ออกคำสั่ง C-PM-35 + * + * @summary ออกคำสั่ง C-PM-35 + * + * @param {string} id Guid, *Id ผังเงินเดือน + */ + @Post("command35/officer/report") + async SalaryOfficerReportCommand35( + @Body() + body: { + refIds: string[]; + }, + @Request() request: RequestWithUser, + ) { + const salaryProfile = await this.salaryProfileRepository.find({ + where: { id: In(body.refIds) }, + }); + const data = salaryProfile.map((_data) => ({ + ..._data, + status35: "REPORT", + })); + await this.salaryProfileRepository.save(data); + return new HttpSuccess(); + } + + /** + * API ออกคำสั่ง C-PM-36 + * + * @summary ออกคำสั่ง C-PM-36 * * @param {string} id Guid, *Id ผังเงินเดือน */ - @Post("command/employee/report") - async SalaryEmployeeReportCommand( + @Post("command36/employee/report") + async SalaryEmployeeReportCommand36( @Body() body: { refIds: string[]; @@ -7661,20 +7714,47 @@ export class ReportController extends Controller { }); const data = salaryProfile.map((_data) => ({ ..._data, - status: "REPORT", + status36: "REPORT", })); await this.salaryProfileEmployeeRepository.save(data); return new HttpSuccess(); } /** - * เอกสารแนบท้าย ขรก. + * API ออกคำสั่ง C-PM-37 * - * @summary เอกสารแนบท้าย ขรก. + * @summary ออกคำสั่ง C-PM-37 + * + * @param {string} id Guid, *Id ผังเงินเดือน + */ + + @Post("command37/employee/report") + async SalaryEmployeeReportCommand37( + @Body() + body: { + refIds: string[]; + }, + @Request() request: RequestWithUser, + ) { + const salaryProfile = await this.salaryProfileEmployeeRepository.find({ + where: { id: In(body.refIds) }, + }); + const data = salaryProfile.map((_data) => ({ + ..._data, + status37: "REPORT", + })); + await this.salaryProfileEmployeeRepository.save(data); + return new HttpSuccess(); + } + + /** + * เอกสารแนบท้าย ขรก. C-PM-33 + * + * @summary เอกสารแนบท้าย ขรก. C-PM-33 * */ - @Post("command/officer/report/attachment") - async SalaryReportAttachment( + @Post("command33/officer/report/attachment") + async SalaryReportAttachment33( @Body() body: { refIds: { @@ -7798,13 +7878,273 @@ export class ReportController extends Controller { } /** - * เอกสารแนบท้าย ลูกจ้าง + * เอกสารแนบท้าย ขรก. C-PM-34 * - * @summary เอกสารแนบท้าย ลูกจ้าง + * @summary เอกสารแนบท้าย ขรก. C-PM34 * */ - @Post("command/employee/report/attachment") - async SalaryEmployeeReportAttachment( + @Post("command34/officer/report/attachment") + async SalaryReportAttachment34( + @Body() + body: { + refIds: { + refId?: string; + Sequence?: any | null; + CitizenId?: any | null; + Prefix?: any | null; + FirstName?: any | null; + LastName?: any | null; + Amount?: any | null; + PositionSalaryAmount?: any | null; + MouthSalaryAmount?: any | null; + RemarkHorizontal?: any | null; + RemarkVertical?: any | null; + CommandYear?: any | null; + }[]; + }, + @Request() request: RequestWithUser, + ) { + let data = new Array(); + await Promise.all( + body.refIds.map(async (v) => { + const salary = await this.salaryProfileRepository.findOne({ + where: { + id: v.refId, + }, + }); + + if (salary != null) { + const _data = { + no: Extension.ToThaiNumber((data.length + 1).toString()), + fullName: `${v.Prefix}${v.FirstName} ${v.LastName}`, + oc: + salary.rootId == null + ? salary.position == null + ? "-" + : salary.position + : salary.child4 != null + ? salary.position == null + ? salary.child4 + + "/" + + salary.child3 + + "/" + + salary.child2 + + "/" + + salary.child1 + + "/" + + salary.root + : salary.position + + "/" + + salary.child4 + + "/" + + salary.child3 + + "/" + + salary.child2 + + "/" + + salary.child1 + + "/" + + salary.root + : salary.child3 != null + ? salary.position == null + ? salary.child3 + + "/" + + salary.child2 + + "/" + + salary.child1 + + "/" + + salary.root + : salary.position + + "/" + + salary.child3 + + "/" + + salary.child2 + + "/" + + salary.child1 + + "/" + + salary.root + : salary.child2 != null + ? salary.position == null + ? salary.child2 + "/" + salary.child1 + "/" + salary.root + : salary.position + + "/" + + salary.child2 + + "/" + + salary.child1 + + "/" + + salary.root + : salary.child1 != null + ? salary.position == null + ? salary.child1 + "/" + salary.root + : salary.position + "/" + salary.child1 + "/" + salary.root + : salary.root != null + ? salary.position == null + ? salary.root + : salary.position + "/" + salary.root + : "-", + positionType: salary.posType ? salary.posType : "-", + positionLevel: salary.posLevel + ? Extension.ToThaiNumber(salary.posLevel.toString()) + : "-", + positionNumber: + salary.orgShortName != null && salary.posMasterNo != null + ? Extension.ToThaiNumber(salary.orgShortName + salary.posMasterNo) + : "-", + amount: salary.amount ? Extension.ToThaiNumber(salary.amount.toLocaleString()) : "-", + positionSalaryAmount: salary.positionSalaryAmount + ? Extension.ToThaiNumber(salary.positionSalaryAmount.toLocaleString()) + : "-", + amountSpecial: salary.amountSpecial + ? Extension.ToThaiNumber(salary.amountSpecial.toLocaleString()) + : "-", + remark: salary.remark ? salary.remark : "-", + remarkVertical: v.RemarkVertical, + remarkHorizontal: v.RemarkHorizontal, + }; + data.push(_data); + } + }), + ); + return new HttpSuccess(data); + } + + /** + * เอกสารแนบท้าย ขรก. C-PM-35 + * + * @summary เอกสารแนบท้าย ขรก. C-PM-35 + * + */ + @Post("command35/officer/report/attachment") + async SalaryReportAttachment35( + @Body() + body: { + refIds: { + refId?: string; + Sequence?: any | null; + CitizenId?: any | null; + Prefix?: any | null; + FirstName?: any | null; + LastName?: any | null; + Amount?: any | null; + PositionSalaryAmount?: any | null; + MouthSalaryAmount?: any | null; + RemarkHorizontal?: any | null; + RemarkVertical?: any | null; + CommandYear?: any | null; + }[]; + }, + @Request() request: RequestWithUser, + ) { + let data = new Array(); + await Promise.all( + body.refIds.map(async (v) => { + const salary = await this.salaryProfileRepository.findOne({ + where: { + id: v.refId, + }, + }); + + if (salary != null) { + const _data = { + no: Extension.ToThaiNumber((data.length + 1).toString()), + fullName: `${v.Prefix}${v.FirstName} ${v.LastName}`, + oc: + salary.rootId == null + ? salary.position == null + ? "-" + : salary.position + : salary.child4 != null + ? salary.position == null + ? salary.child4 + + "/" + + salary.child3 + + "/" + + salary.child2 + + "/" + + salary.child1 + + "/" + + salary.root + : salary.position + + "/" + + salary.child4 + + "/" + + salary.child3 + + "/" + + salary.child2 + + "/" + + salary.child1 + + "/" + + salary.root + : salary.child3 != null + ? salary.position == null + ? salary.child3 + + "/" + + salary.child2 + + "/" + + salary.child1 + + "/" + + salary.root + : salary.position + + "/" + + salary.child3 + + "/" + + salary.child2 + + "/" + + salary.child1 + + "/" + + salary.root + : salary.child2 != null + ? salary.position == null + ? salary.child2 + "/" + salary.child1 + "/" + salary.root + : salary.position + + "/" + + salary.child2 + + "/" + + salary.child1 + + "/" + + salary.root + : salary.child1 != null + ? salary.position == null + ? salary.child1 + "/" + salary.root + : salary.position + "/" + salary.child1 + "/" + salary.root + : salary.root != null + ? salary.position == null + ? salary.root + : salary.position + "/" + salary.root + : "-", + positionType: salary.posType ? salary.posType : "-", + positionLevel: salary.posLevel + ? Extension.ToThaiNumber(salary.posLevel.toString()) + : "-", + positionNumber: + salary.orgShortName != null && salary.posMasterNo != null + ? Extension.ToThaiNumber(salary.orgShortName + salary.posMasterNo) + : "-", + amount: salary.amount ? Extension.ToThaiNumber(salary.amount.toLocaleString()) : "-", + positionSalaryAmount: salary.positionSalaryAmount + ? Extension.ToThaiNumber(salary.positionSalaryAmount.toLocaleString()) + : "-", + amountSpecial: salary.amountSpecial + ? Extension.ToThaiNumber(salary.amountSpecial.toLocaleString()) + : "-", + remark: salary.remark ? salary.remark : "-", + remarkVertical: v.RemarkVertical, + remarkHorizontal: v.RemarkHorizontal, + }; + data.push(_data); + } + }), + ); + return new HttpSuccess(data); + } + + /** + * เอกสารแนบท้าย ลูกจ้าง C-PM-36 + * + * @summary เอกสารแนบท้าย ลูกจ้าง C-PM-36 + * + */ + @Post("command36/employee/report/attachment") + async SalaryEmployeeReportAttachment36( @Body() body: { refIds: { @@ -7928,14 +8268,144 @@ export class ReportController extends Controller { } /** - * API ออกคำสั่ง + * เอกสารแนบท้าย ลูกจ้าง C-PM-37 * - * @summary ออกคำสั่ง + * @summary เอกสารแนบท้าย ลูกจ้าง C-PM-37 + * + */ + @Post("command37/employee/report/attachment") + async SalaryEmployeeReportAttachment37( + @Body() + body: { + refIds: { + refId?: string; + Sequence?: any | null; + CitizenId?: any | null; + Prefix?: any | null; + FirstName?: any | null; + LastName?: any | null; + Amount?: any | null; + PositionSalaryAmount?: any | null; + MouthSalaryAmount?: any | null; + RemarkHorizontal?: any | null; + RemarkVertical?: any | null; + CommandYear?: any | null; + }[]; + }, + @Request() request: RequestWithUser, + ) { + let data = new Array(); + await Promise.all( + body.refIds.map(async (v) => { + const salary = await this.salaryProfileEmployeeRepository.findOne({ + where: { + id: v.refId, + }, + }); + + if (salary != null) { + const _data = { + no: Extension.ToThaiNumber((data.length + 1).toString()), + fullName: `${v.Prefix}${v.FirstName} ${v.LastName}`, + oc: + salary.rootId == null + ? salary.position == null + ? "-" + : salary.position + : salary.child4 != null + ? salary.position == null + ? salary.child4 + + "/" + + salary.child3 + + "/" + + salary.child2 + + "/" + + salary.child1 + + "/" + + salary.root + : salary.position + + "/" + + salary.child4 + + "/" + + salary.child3 + + "/" + + salary.child2 + + "/" + + salary.child1 + + "/" + + salary.root + : salary.child3 != null + ? salary.position == null + ? salary.child3 + + "/" + + salary.child2 + + "/" + + salary.child1 + + "/" + + salary.root + : salary.position + + "/" + + salary.child3 + + "/" + + salary.child2 + + "/" + + salary.child1 + + "/" + + salary.root + : salary.child2 != null + ? salary.position == null + ? salary.child2 + "/" + salary.child1 + "/" + salary.root + : salary.position + + "/" + + salary.child2 + + "/" + + salary.child1 + + "/" + + salary.root + : salary.child1 != null + ? salary.position == null + ? salary.child1 + "/" + salary.root + : salary.position + "/" + salary.child1 + "/" + salary.root + : salary.root != null + ? salary.position == null + ? salary.root + : salary.position + "/" + salary.root + : "-", + positionType: salary.posType ? salary.posType : "-", + positionLevel: salary.posLevel + ? Extension.ToThaiNumber(salary.posLevel.toString()) + : "-", + positionNumber: + salary.orgShortName != null && salary.posMasterNo != null + ? Extension.ToThaiNumber(salary.orgShortName + salary.posMasterNo) + : "-", + amount: salary.amount ? Extension.ToThaiNumber(salary.amount.toLocaleString()) : "-", + positionSalaryAmount: salary.positionSalaryAmount + ? Extension.ToThaiNumber(salary.positionSalaryAmount.toLocaleString()) + : "-", + amountSpecial: salary.amountSpecial + ? Extension.ToThaiNumber(salary.amountSpecial.toLocaleString()) + : "-", + remark: salary.remark ? salary.remark : "-", + remarkVertical: v.RemarkVertical, + remarkHorizontal: v.RemarkHorizontal, + }; + data.push(_data); + } + }), + ); + return new HttpSuccess(data); + } + + /** + * API ออกคำสั่ง C-PM-33 + * + * @summary ออกคำสั่ง C-PM-33 * * @param {string} id Guid, *Id ผังเงินเดือน */ - @Post("command/officer/report/excecute") - async SalaryReportExcecute( + @Post("command33/officer/report/excecute") + async SalaryReportExcecute33( @Body() body: { refIds: { @@ -7995,7 +8465,7 @@ export class ReportController extends Controller { }) .then(async () => { const before = null; - salary.status = "DONE"; + salary.status33 = "DONE"; salary.lastUpdateUserId = request.user.sub; salary.lastUpdateFullName = request.user.name; salary.lastUpdatedAt = new Date(); @@ -8009,14 +8479,176 @@ export class ReportController extends Controller { } /** - * API ออกคำสั่ง + * API ออกคำสั่ง C-PM-34 * - * @summary ออกคำสั่ง + * @summary ออกคำสั่ง C-PM-34 * * @param {string} id Guid, *Id ผังเงินเดือน */ - @Post("command/employee/report/excecute") - async SalaryEmployeeReportExcecute( + @Post("command34/officer/report/excecute") + async SalaryReportExcecute34( + @Body() + body: { + refIds: { + refId: string; + // commandAffectDate: Date | null;//เก่า + commandDateAffect: Date | null; //ใหม่ (ปรับตาม rabbitMQ ORG) + commandNo: string | null; + commandYear: number | null; + commandId: string | null; + remark: string | null; + amount: Double | null; + amountSpecial?: Double | null; + positionSalaryAmount: Double | null; + mouthSalaryAmount: Double | null; + commandCode?: string | null; + commandName?: string | null; + commandDateSign: Date | null; + }[]; + }, + @Request() request: RequestWithUser, + ) { + await Promise.all( + body.refIds.map(async (v) => { + const salary = await this.salaryProfileRepository.findOne({ + where: { + id: v.refId, + }, + }); + + if (salary != null) { + await new CallAPI() + .PostData(request, "/org/profile/salary/update", { + profileId: salary.profileId, + commandDateAffect: v.commandDateAffect, + commandDateSign: v.commandDateSign, + amount: v.amount, + amountSpecial: v.amountSpecial, + positionSalaryAmount: v.positionSalaryAmount, + mouthSalaryAmount: v.mouthSalaryAmount, + posNo: salary.posMasterNo.toString(), + posNoAbb: salary.orgShortName, + positionName: salary.position, + positionExecutive: salary.posExecutive, + positionType: salary.posType, + positionLevel: salary.posLevel, + commandId: v.commandId, + remark: v.remark, + orgRoot: salary.root, + orgChild1: salary.child1, + orgChild2: salary.child2, + orgChild3: salary.child3, + orgChild4: salary.child4, + commandCode: v.commandCode, + commandName: v.commandName, + commandNo: v.commandNo, + commandYear: v.commandYear, + }) + .then(async () => { + const before = null; + salary.status34 = "DONE"; + salary.lastUpdateUserId = request.user.sub; + salary.lastUpdateFullName = request.user.name; + salary.lastUpdatedAt = new Date(); + await this.salaryProfileRepository.save(salary, { data: request }); + setLogDataDiff(request, { before, after: salary }); + }); + } + }), + ); + return new HttpSuccess(); + } + + /** + * API ออกคำสั่ง C-PM-35 + * + * @summary ออกคำสั่ง C-PM-35 + * + * @param {string} id Guid, *Id ผังเงินเดือน + */ + @Post("command35/officer/report/excecute") + async SalaryReportExcecute35( + @Body() + body: { + refIds: { + refId: string; + // commandAffectDate: Date | null;//เก่า + commandDateAffect: Date | null; //ใหม่ (ปรับตาม rabbitMQ ORG) + commandNo: string | null; + commandYear: number | null; + commandId: string | null; + remark: string | null; + amount: Double | null; + amountSpecial?: Double | null; + positionSalaryAmount: Double | null; + mouthSalaryAmount: Double | null; + commandCode?: string | null; + commandName?: string | null; + commandDateSign: Date | null; + }[]; + }, + @Request() request: RequestWithUser, + ) { + await Promise.all( + body.refIds.map(async (v) => { + const salary = await this.salaryProfileRepository.findOne({ + where: { + id: v.refId, + }, + }); + + if (salary != null) { + await new CallAPI() + .PostData(request, "/org/profile/salary/update", { + profileId: salary.profileId, + commandDateAffect: v.commandDateAffect, + commandDateSign: v.commandDateSign, + amount: v.amount, + amountSpecial: v.amountSpecial, + positionSalaryAmount: v.positionSalaryAmount, + mouthSalaryAmount: v.mouthSalaryAmount, + posNo: salary.posMasterNo.toString(), + posNoAbb: salary.orgShortName, + positionName: salary.position, + positionExecutive: salary.posExecutive, + positionType: salary.posType, + positionLevel: salary.posLevel, + commandId: v.commandId, + remark: v.remark, + orgRoot: salary.root, + orgChild1: salary.child1, + orgChild2: salary.child2, + orgChild3: salary.child3, + orgChild4: salary.child4, + commandCode: v.commandCode, + commandName: v.commandName, + commandNo: v.commandNo, + commandYear: v.commandYear, + }) + .then(async () => { + const before = null; + salary.status35 = "DONE"; + salary.lastUpdateUserId = request.user.sub; + salary.lastUpdateFullName = request.user.name; + salary.lastUpdatedAt = new Date(); + await this.salaryProfileRepository.save(salary, { data: request }); + setLogDataDiff(request, { before, after: salary }); + }); + } + }), + ); + return new HttpSuccess(); + } + + /** + * API ออกคำสั่ง C-PM-36 + * + * @summary ออกคำสั่ง C-PM-36 + * + * @param {string} id Guid, *Id ผังเงินเดือน + */ + @Post("command36/employee/report/excecute") + async SalaryEmployeeReportExcecute36( @Body() body: { refIds: { @@ -8079,7 +8711,7 @@ export class ReportController extends Controller { }) .then(async () => { const before = null; - salary.status = "DONE"; + salary.status36 = "DONE"; salary.lastUpdateUserId = request.user.sub; salary.lastUpdateFullName = request.user.name; salary.lastUpdatedAt = new Date(); @@ -8093,14 +8725,98 @@ export class ReportController extends Controller { } /** - * API ออกคำสั่ง + * API ออกคำสั่ง C-PM-37 * - * @summary ออกคำสั่ง + * @summary ออกคำสั่ง C-PM-37 * * @param {string} id Guid, *Id ผังเงินเดือน */ - @Post("command/officer/report/delete") - async SalaryOfficerReportCommandDelete( + @Post("command37/employee/report/excecute") + async SalaryEmployeeReportExcecute37( + @Body() + body: { + refIds: { + refId: string; + // commandAffectDate: Date | null;//เก่า + commandDateAffect: Date | null; //ใหม่ (ปรับตาม rabbitMQ ORG) + commandDateSign?: Date | null; + commandNo: string | null; + commandYear: number | null; + commandId: string | null; + commandCode?: string | null; + commandName?: string | null; + templateDoc?: string | null; + amount: Double | null; + amountSpecial?: Double | null; + positionSalaryAmount: Double | null; + mouthSalaryAmount: Double | null; + mpCee?: string | null; + refCommandCode?: string | null; + refCommandName?: string | null; + remark?: string | null; + }[]; + }, + @Request() request: RequestWithUser, + ) { + await Promise.all( + body.refIds.map(async (v) => { + const salary = await this.salaryProfileEmployeeRepository.findOne({ + where: { + id: v.refId, + }, + }); + + if (salary != null) { + await new CallAPI() + .PostData(request, "/org/profile-employee/salary/update", { + profileEmployeeId: salary.profileId, + commandDateAffect: v.commandDateAffect, + commandDateSign: v.commandDateSign, + amount: v.amount, + amountSpecial: v.amountSpecial, + positionSalaryAmount: v.positionSalaryAmount, + mouthSalaryAmount: v.mouthSalaryAmount, + posNo: salary.posMasterNo != null ? salary.posMasterNo.toString() : null, + posNoAbb: salary.orgShortName, + positionName: salary.position, + positionType: salary.posType, + positionLevel: salary.posLevel != null ? salary.posLevel.toString() : null, + remark: v.remark, + orgRoot: salary.root, + orgChild1: salary.child1, + orgChild2: salary.child2, + orgChild3: salary.child3, + orgChild4: salary.child4, + commandCode: v.commandCode, + commandName: v.commandName, + commandNo: v.commandNo, + commandYear: v.commandYear, + commandId: v.commandId, + }) + .then(async () => { + const before = null; + salary.status37 = "DONE"; + salary.lastUpdateUserId = request.user.sub; + salary.lastUpdateFullName = request.user.name; + salary.lastUpdatedAt = new Date(); + await this.salaryProfileEmployeeRepository.save(salary, { data: request }); + setLogDataDiff(request, { before, after: salary }); + }); + } + }), + ); + return new HttpSuccess(); + } + + /** + * API ออกคำสั่ง C-PM-33 + * + * @summary ออกคำสั่ง C-PM-33 + * + * @param {string} id Guid, *Id ผังเงินเดือน + */ + @Post("command33/officer/report/delete") + async SalaryOfficerReportCommandDelete33( @Body() body: { refIds: string[]; @@ -8112,21 +8828,73 @@ export class ReportController extends Controller { }); const data = salaryProfile.map((_data) => ({ ..._data, - status: "PENDING", + status33: "PENDING", })); await this.salaryProfileRepository.save(data); return new HttpSuccess(); } /** - * API ออกคำสั่ง + * API ออกคำสั่ง C-PM-34 * - * @summary ออกคำสั่ง + * @summary ออกคำสั่ง C-PM-34 * * @param {string} id Guid, *Id ผังเงินเดือน */ - @Post("command/employee/report/delete") - async SalaryEmployeeReportCommandDelete( + @Post("command34/officer/report/delete") + async SalaryOfficerReportCommandDelete34( + @Body() + body: { + refIds: string[]; + }, + @Request() request: RequestWithUser, + ) { + const salaryProfile = await this.salaryProfileRepository.find({ + where: { id: In(body.refIds) }, + }); + const data = salaryProfile.map((_data) => ({ + ..._data, + status34: "PENDING", + })); + await this.salaryProfileRepository.save(data); + return new HttpSuccess(); + } + + /** + * API ออกคำสั่ง C-PM-35 + * + * @summary ออกคำสั่ง C-PM-35 + * + * @param {string} id Guid, *Id ผังเงินเดือน + */ + @Post("command35/officer/report/delete") + async SalaryOfficerReportCommandDelete35( + @Body() + body: { + refIds: string[]; + }, + @Request() request: RequestWithUser, + ) { + const salaryProfile = await this.salaryProfileRepository.find({ + where: { id: In(body.refIds) }, + }); + const data = salaryProfile.map((_data) => ({ + ..._data, + status35: "PENDING", + })); + await this.salaryProfileRepository.save(data); + return new HttpSuccess(); + } + + /** + * API ออกคำสั่ง C-PM-36 + * + * @summary ออกคำสั่ง C-PM-36 + * + * @param {string} id Guid, *Id ผังเงินเดือน + */ + @Post("command36/employee/report/delete") + async SalaryEmployeeReportCommandDelete36( @Body() body: { refIds: string[]; @@ -8138,9 +8906,36 @@ export class ReportController extends Controller { }); const data = salaryProfile.map((_data) => ({ ..._data, - status: "PENDING", + status36: "PENDING", })); await this.salaryProfileEmployeeRepository.save(data); return new HttpSuccess(); } + + /** + * API ออกคำสั่ง C-PM-37 + * + * @summary ออกคำสั่ง C-PM-37 + * + * @param {string} id Guid, *Id ผังเงินเดือน + */ + @Post("command37/employee/report/delete") + async SalaryEmployeeReportCommandDelete37( + @Body() + body: { + refIds: string[]; + }, + @Request() request: RequestWithUser, + ) { + const salaryProfile = await this.salaryProfileEmployeeRepository.find({ + where: { id: In(body.refIds) }, + }); + const data = salaryProfile.map((_data) => ({ + ..._data, + status37: "PENDING", + })); + await this.salaryProfileEmployeeRepository.save(data); + return new HttpSuccess(); + } + }