From ee3975c93485f0c92609691ada15b681a26c7e8e Mon Sep 17 00:00:00 2001 From: kittapath Date: Thu, 10 Oct 2024 17:42:20 +0700 Subject: [PATCH] no message --- src/controllers/CommandController.ts | 68 +++++++++++++++++++++++++--- 1 file changed, 62 insertions(+), 6 deletions(-) diff --git a/src/controllers/CommandController.ts b/src/controllers/CommandController.ts index d3d312e4..3da04c79 100644 --- a/src/controllers/CommandController.ts +++ b/src/controllers/CommandController.ts @@ -89,6 +89,7 @@ export class CommandController extends Controller { private profileEducationHistoryRepo = AppDataSource.getRepository(ProfileEducationHistory); private certificateRepo = AppDataSource.getRepository(ProfileCertificate); private certificateHistoryRepo = AppDataSource.getRepository(ProfileCertificateHistory); + private orgRevisionRepository = AppDataSource.getRepository(OrgRevision); /** * API list รายการคำสั่ง @@ -367,7 +368,6 @@ export class CommandController extends Controller { commandAffectDate: Date | null; commandExcecuteDate: Date | null; isBangkok: string | null; - isAttachment: boolean | null; }, @Request() request: RequestWithUser, ) { @@ -1085,9 +1085,33 @@ export class CommandController extends Controller { if (!command) { throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลคำสั่งนี้"); } - + let issue = + command.isBangkok == "OFFICE" + ? "สำนักปลัดกรุงเทพมหานคร" + : command.isBangkok == "BANGKOK" + ? "กรุงเทพมหานคร" + : null; + if (issue == null) { + const orgRevisionActive = await this.orgRevisionRepository.findOne({ + where: { orgRevisionIsCurrent: false, orgRevisionIsDraft: true }, + relations: ["posMasters", "posMasters.orgRoot"], + }); + if (orgRevisionActive != null) { + const profile = await this.profileRepository.findOne({ + where: { + keycloak: command.createdUserId.toString(), + }, + }); + if (profile != null) { + issue = + orgRevisionActive?.posMasters?.filter((x) => x.next_holderId == profile.id)[0]?.orgRoot + ?.orgRootName || null; + } + } + } + if (issue == null) issue = "..................................."; const _command = { - issue: "...................................", + issue: issue, commandNo: command.commandNo, commandYear: command.commandYear, commandTitle: command.issue, @@ -1104,6 +1128,9 @@ export class CommandController extends Controller { : Extension.ToThaiNumber(Extension.ToThaiFullDate2(command.commandExcecuteDate)), name: "...................................", position: "...................................", + authorizedUserFullName: "...................................", + authorizedPosition: "...................................", + commandAffectDate: "...................................", }; return new HttpSuccess({ template: command.commandType.fileCover, @@ -1132,7 +1159,24 @@ export class CommandController extends Controller { let _command: any = []; const path = this.commandTypePath(command.commandType.code); if (path == null) throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบประเภทคำสั่งนี้ในระบบ"); - + console.log( + command.commandRecives + .filter((x) => x.refId != null) + .map((x) => ({ + refId: x.refId, + Sequence: x.order, + CitizenId: x.citizenId, + Prefix: x.prefix, + FirstName: x.firstName, + LastName: x.lastName, + Amount: x.amount, + PositionSalaryAmount: x.positionSalaryAmount, + MouthSalaryAmount: x.mouthSalaryAmount, + RemarkHorizontal: x.remarkHorizontal, + RemarkVertical: x.remarkVertical, + CommandYear: command.commandYear, + })), + ); await new CallAPI() .PostData(request, path + "/attachment", { refIds: command.commandRecives @@ -1160,7 +1204,7 @@ export class CommandController extends Controller { return new HttpSuccess({ template: command.commandType.fileAttachment, reportName: "xlsx-report", - data: _command, + data: { data: _command }, }); } @@ -2446,6 +2490,12 @@ export class CommandController extends Controller { refIds: string[]; }, ) { + const profile = await this.profileEmployeeRepository.find({ where: { id: In(body.refIds) } }); + const data = profile.map((_data) => ({ + ..._data, + statusTemp: "REPORT", + })); + await this.profileEmployeeRepository.save(data); return new HttpSuccess(); } @@ -2476,6 +2526,12 @@ export class CommandController extends Controller { refIds: string[]; }, ) { + const profile = await this.profileEmployeeRepository.find({ where: { id: In(body.refIds) } }); + const data = profile.map((_data) => ({ + ..._data, + statusTemp: "DONE", + })); + await this.profileEmployeeRepository.save(data); return new HttpSuccess(); } @Post("command40/officer/report/attachment") @@ -2624,7 +2680,7 @@ export class CommandController extends Controller { case "C-PM-13": return "/placement/transfer/command/report"; case "C-PM-14": - return "/placement/Receive/command/report"; + return "/placement/receive/command/report"; case "C-PM-15": return "/placement/officer/command/report"; case "C-PM-16":