From fd0c421dd9ec61d180271028f1344f78d7fa46bb Mon Sep 17 00:00:00 2001 From: kittapath Date: Thu, 10 Oct 2024 20:05:25 +0700 Subject: [PATCH] no message --- src/controllers/CommandController.ts | 66 ++++++++++++++++++---------- 1 file changed, 42 insertions(+), 24 deletions(-) diff --git a/src/controllers/CommandController.ts b/src/controllers/CommandController.ts index 3da04c79..7888c0f4 100644 --- a/src/controllers/CommandController.ts +++ b/src/controllers/CommandController.ts @@ -1093,7 +1093,7 @@ export class CommandController extends Controller { : null; if (issue == null) { const orgRevisionActive = await this.orgRevisionRepository.findOne({ - where: { orgRevisionIsCurrent: false, orgRevisionIsDraft: true }, + where: { orgRevisionIsCurrent: true, orgRevisionIsDraft: false }, relations: ["posMasters", "posMasters.orgRoot"], }); if (orgRevisionActive != null) { @@ -1104,8 +1104,8 @@ export class CommandController extends Controller { }); if (profile != null) { issue = - orgRevisionActive?.posMasters?.filter((x) => x.next_holderId == profile.id)[0]?.orgRoot - ?.orgRootName || null; + orgRevisionActive?.posMasters?.filter((x) => x.current_holderId == profile.id)[0] + ?.orgRoot?.orgRootName || null; } } } @@ -1159,24 +1159,6 @@ 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 @@ -1201,10 +1183,47 @@ export class CommandController extends Controller { }) .catch(() => {}); + let issue = + command.isBangkok == "OFFICE" + ? "สำนักปลัดกรุงเทพมหานคร" + : command.isBangkok == "BANGKOK" + ? "กรุงเทพมหานคร" + : null; + if (issue == null) { + const orgRevisionActive = await this.orgRevisionRepository.findOne({ + where: { orgRevisionIsCurrent: true, orgRevisionIsDraft: false }, + 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.current_holderId == profile.id)[0] + ?.orgRoot?.orgRootName || null; + } + } + } + if (issue == null) issue = "..................................."; return new HttpSuccess({ template: command.commandType.fileAttachment, reportName: "xlsx-report", - data: { data: _command }, + data: { + data: _command, + issuerOrganizationName: issue, + commandNo: command.commandNo == null ? "" : Extension.ToThaiNumber(command.commandNo), + commandYear: + command.commandYear == null + ? "" + : Extension.ToThaiNumber(Extension.ToThaiYear(command.commandYear).toString()), + commandExcecuteDate: + command.commandExcecuteDate == null + ? "" + : Extension.ToThaiNumber(Extension.ToThaiFullDate2(command.commandExcecuteDate)), + }, }); } @@ -2602,8 +2621,7 @@ export class CommandController extends Controller { "" + posMasterAct.posMasterChild?.current_holder?.firstName ?? "" + " " + posMasterAct.posMasterChild?.current_holder?.lastName ?? null, - organization: _organization, - position: posMasterAct.posMasterChild?.current_holder?.position ?? null, + oc: (posMasterAct.posMasterChild?.current_holder?.position ?? null) + "/" + _organization, postype: posMasterAct.posMasterChild?.current_holder?.posType?.posTypeName ?? null, poslevel: posMasterAct.posMasterChild?.current_holder?.posLevel?.posLevelName ?? null, organizationNew: _organizationNew,