From 07f5b3d570d5013e9eb8b927a5775a168e731569 Mon Sep 17 00:00:00 2001 From: Kittapath Date: Fri, 26 Apr 2024 10:03:29 +0700 Subject: [PATCH] no message --- src/controllers/ReportController.ts | 252 +++++++++++++++++++++++++++- 1 file changed, 247 insertions(+), 5 deletions(-) diff --git a/src/controllers/ReportController.ts b/src/controllers/ReportController.ts index b387a6b..28d1e8f 100644 --- a/src/controllers/ReportController.ts +++ b/src/controllers/ReportController.ts @@ -35,6 +35,7 @@ import { EmployeePosType } from "../entities/EmployeePosType"; import { EmployeePosLevel } from "../entities/EmployeePosLevel"; import { SalaryOrgEmployee } from "../entities/SalaryOrgEmployee"; import { SalaryProfileEmployee } from "../entities/SalaryProfileEmployee"; +import CallAPI from "../interfaces/call-api"; @Route("api/v1/salary/report") @Tags("Report") @Security("bearerAuth") @@ -6278,6 +6279,241 @@ export class ReportController extends Controller { }); } + /** + * API ออกคำสั่ง 33 + * + * @summary ออกคำสั่ง 33 + * + * @param {string} id Guid, *Id ผังเงินเดือน + */ + @Post("command/33/resume") + async SalaryReport33Resume( + @Body() body: { result: { id: string; personId: string }[] }, + @Request() request: { user: Record }, + ) { + await Promise.all( + body.result.map(async (v) => { + const salary = await this.salaryProfileRepository.findOne({ + where: { + id: v.id, + }, + }); + if (salary != null) { + await new CallAPI() + .PostData(request, "org/profile/salary", { + profileId: salary.profileId, + date: new Date(), + amount: salary.positionSalaryAmount, + positionSalaryAmount: null, + mouthSalaryAmount: null, + posNo: salary.orgShortName + salary.posMasterNo, + position: salary.position, + positionLine: null, + positionPathSide: null, + positionExecutive: salary.posExecutive, + positionType: salary.posType, + positionLevel: salary.posLevel, + refCommandNo: null, + templateDoc: null, + }) + .then(async (x) => { + salary.status == "DONE"; + await this.salaryProfileRepository.save(salary); + }); + } + }), + ); + return new HttpSuccess(); + } + + /** + * API ออกคำสั่ง 34 + * + * @summary ออกคำสั่ง 34 + * + * @param {string} id Guid, *Id ผังเงินเดือน + */ + @Post("command/34/resume") + async SalaryReport34Resume( + @Body() body: { result: { id: string; personId: string }[] }, + @Request() request: { user: Record }, + ) { + await Promise.all( + body.result.map(async (v) => { + const salary = await this.salaryProfileRepository.findOne({ + where: { + id: v.id, + }, + }); + if (salary != null) { + await new CallAPI() + .PostData(request, "org/profile/salary", { + profileId: salary.profileId, + date: new Date(), + amount: salary.positionSalaryAmount, + positionSalaryAmount: null, + mouthSalaryAmount: null, + posNo: salary.orgShortName + salary.posMasterNo, + position: salary.position, + positionLine: null, + positionPathSide: null, + positionExecutive: salary.posExecutive, + positionType: salary.posType, + positionLevel: salary.posLevel, + refCommandNo: null, + templateDoc: null, + }) + .then(async (x) => { + salary.status == "DONE"; + await this.salaryProfileRepository.save(salary); + }); + } + }), + ); + return new HttpSuccess(); + } + + /** + * API ออกคำสั่ง 35 + * + * @summary ออกคำสั่ง 35 + * + * @param {string} id Guid, *Id ผังเงินเดือน + */ + @Post("command/35/resume") + async SalaryReport35Resume( + @Body() body: { result: { id: string; personId: string }[] }, + @Request() request: { user: Record }, + ) { + await Promise.all( + body.result.map(async (v) => { + const salary = await this.salaryProfileRepository.findOne({ + where: { + id: v.id, + }, + }); + if (salary != null) { + await new CallAPI() + .PostData(request, "org/profile/salary", { + profileId: salary.profileId, + date: new Date(), + amount: salary.positionSalaryAmount, + positionSalaryAmount: null, + mouthSalaryAmount: null, + posNo: salary.orgShortName + salary.posMasterNo, + position: salary.position, + positionLine: null, + positionPathSide: null, + positionExecutive: salary.posExecutive, + positionType: salary.posType, + positionLevel: salary.posLevel, + refCommandNo: null, + templateDoc: null, + }) + .then(async (x) => { + salary.status == "DONE"; + await this.salaryProfileRepository.save(salary); + }); + } + }), + ); + return new HttpSuccess(); + } + + /** + * API ออกคำสั่ง 36 + * + * @summary ออกคำสั่ง 36 + * + * @param {string} id Guid, *Id ผังเงินเดือน + */ + @Post("command/36/resume") + async SalaryReport36Resume( + @Body() body: { result: { id: string; personId: string }[] }, + @Request() request: { user: Record }, + ) { + await Promise.all( + body.result.map(async (v) => { + const salary = await this.salaryProfileEmployeeRepository.findOne({ + where: { + id: v.id, + }, + }); + if (salary != null) { + // await new CallAPI() + // .PostData(request, "org/profile/salary", { + // profileId: salary.profileId, + // date: new Date(), + // amount: salary.positionSalaryAmount, + // positionSalaryAmount: null, + // mouthSalaryAmount: null, + // posNo: salary.orgShortName + salary.posMasterNo, + // position: salary.position, + // positionLine: null, + // positionPathSide: null, + // positionExecutive: null, + // positionType: salary.posType, + // positionLevel: salary.posLevel, + // refCommandNo: null, + // templateDoc: null, + // }) + // .then(async (x) => { + salary.status == "DONE"; + await this.salaryProfileEmployeeRepository.save(salary); + // }); + } + }), + ); + return new HttpSuccess(); + } + + /** + * API ออกคำสั่ง 37 + * + * @summary ออกคำสั่ง 37 + * + * @param {string} id Guid, *Id ผังเงินเดือน + */ + @Post("command/37/resume") + async SalaryReport37Resume( + @Body() body: { result: { id: string; personId: string }[] }, + @Request() request: { user: Record }, + ) { + await Promise.all( + body.result.map(async (v) => { + const salary = await this.salaryProfileEmployeeRepository.findOne({ + where: { + id: v.id, + }, + }); + if (salary != null) { + // await new CallAPI() + // .PostData(request, "org/profile/salary", { + // profileId: salary.profileId, + // date: new Date(), + // amount: salary.positionSalaryAmount, + // positionSalaryAmount: null, + // mouthSalaryAmount: null, + // posNo: salary.orgShortName + salary.posMasterNo, + // position: salary.position, + // positionLine: null, + // positionPathSide: null, + // positionExecutive: null, + // positionType: salary.posType, + // positionLevel: salary.posLevel, + // refCommandNo: null, + // templateDoc: null, + // }) + // .then(async (x) => { + salary.status == "DONE"; + await this.salaryProfileEmployeeRepository.save(salary); + // }); + } + }), + ); + return new HttpSuccess(); + } + /** * API ออกคำสั่ง 33 * @@ -6294,13 +6530,14 @@ export class ReportController extends Controller { throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการขึ้นเงินเดือน"); } const salaryOrgs = await this.salaryOrgRepository.find({ - where: { id: salary.id }, + where: { salaryPeriodId: salary.id, snapshot: "SNAP2" }, }); const salaryRank = await this.salaryProfileRepository.find({ where: { salaryOrgId: In(salaryOrgs.map((x) => x.id)), type: In(["FULLHAFT", "FULL", "HAFT"]), + status: "PENDING", }, }); @@ -6331,7 +6568,7 @@ export class ReportController extends Controller { throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการขึ้นเงินเดือน"); } const salaryOrgs = await this.salaryOrgRepository.find({ - where: { id: salary.id }, + where: { salaryPeriodId: salary.id, snapshot: "SNAP2" }, }); const salaryRank = await this.salaryProfileRepository.find({ @@ -6339,10 +6576,12 @@ export class ReportController extends Controller { { salaryOrgId: In(salaryOrgs.map((x) => x.id)), amountSpecial: MoreThan(0), + status: "PENDING", }, { salaryOrgId: In(salaryOrgs.map((x) => x.id)), type: "NONE", + status: "PENDING", }, ], }); @@ -6374,13 +6613,14 @@ export class ReportController extends Controller { throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการขึ้นเงินเดือน"); } const salaryOrgs = await this.salaryOrgRepository.find({ - where: { id: salary.id }, + where: { salaryPeriodId: salary.id, snapshot: "SNAP2" }, }); const salaryRank = await this.salaryProfileRepository.find({ where: { salaryOrgId: In(salaryOrgs.map((x) => x.id)), type: In(["FULLHAFT", "FULL", "HAFT"]), + status: "PENDING", isRetired: true, }, }); @@ -6412,13 +6652,14 @@ export class ReportController extends Controller { throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการขึ้นเงินเดือน"); } const salaryOrgs = await this.salaryOrgEmployeeRepository.find({ - where: { id: salary.id }, + where: { salaryPeriodId: salary.id, snapshot: "SNAP2" }, }); const salaryRank = await this.salaryProfileEmployeeRepository.find({ where: { salaryOrgId: In(salaryOrgs.map((x) => x.id)), type: In(["FULLHAFT", "FULL", "HAFT"]), + status: "PENDING", }, }); @@ -6449,13 +6690,14 @@ export class ReportController extends Controller { throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการขึ้นเงินเดือน"); } const salaryOrgs = await this.salaryOrgEmployeeRepository.find({ - where: { id: salary.id }, + where: { salaryPeriodId: salary.id, snapshot: "SNAP2" }, }); const salaryRank = await this.salaryProfileEmployeeRepository.find({ where: { salaryOrgId: In(salaryOrgs.map((x) => x.id)), amountSpecial: MoreThan(0), + status: "PENDING", }, });