diff --git a/src/controllers/CommandController.ts b/src/controllers/CommandController.ts index f780fb12..7977ebcd 100644 --- a/src/controllers/CommandController.ts +++ b/src/controllers/CommandController.ts @@ -1187,7 +1187,7 @@ export class CommandController extends Controller { await new permission().PermissionGet(request, "COMMAND"); const command = await this.commandRepository.findOne({ where: { id }, - relations: ["commandType"], + relations: ["commandType", "commandRecives"], }); if (!command) { throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลคำสั่งนี้"); @@ -1217,7 +1217,19 @@ export class CommandController extends Controller { } } if (issue == null) issue = "..................................."; - const _command = { + + let res: any[] = []; + if(command.commandRecives.length > 0) { + await new CallAPI() + .GetData(request, `/probation/report/command10/appoints/${command.commandRecives[0].refId}`) + .then((x) => { + res = x.data + }) + .catch((x) => { + }); + } + + let _command = { issue: issue, commandNo: command.commandNo == null ? "" : Extension.ToThaiNumber(command.commandNo), commandYear: @@ -1241,7 +1253,20 @@ export class CommandController extends Controller { authorizedUserFullName: "...................................", authorizedPosition: "...................................", commandAffectDate: "...................................", + name1: res && res.length > 0 + ? `${res[0].name}..........................${res[0].role}` + : "", + name2: res && res.length > 1 + ? `${res[1].name}..........................${res[1].role}` + : "", + name3: res && res.length > 2 + ? `${res[2].name}..........................${res[2].role}` + : "", + name4: res && res.length > 3 + ? `${res[3].name}..........................${res[3].role}` + : "", }; + return new HttpSuccess({ template: command.commandType.fileCover, reportName: "docx-report",