เพิ่มreport

This commit is contained in:
kittapath 2024-09-26 16:05:59 +07:00
parent 76e2de989e
commit e340b6d8a8

View file

@ -29,6 +29,7 @@ import { CommandSendCC } from "../entities/CommandSendCC";
import { CommandSalary } from "../entities/CommandSalary";
import { CommandRecive } from "../entities/CommandRecive";
import HttpStatus from "../interfaces/http-status";
import Extension from "../interfaces/extension";
@Route("api/v1/org/command")
@Tags("Command")
@ -697,6 +698,9 @@ export class CommandController extends Controller {
if (!command) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลคำสั่งนี้");
}
await this.commandSendCCRepository.delete({ commandSend: { commandId: command.id } });
await this.commandReciveRepository.delete({ commandId: command.id });
await this.commandSendRepository.delete({ commandId: command.id });
await this.commandRepository.delete(command.id);
return new HttpSuccess();
}
@ -838,4 +842,82 @@ export class CommandController extends Controller {
await this.commandRepository.save(command);
return new HttpSuccess();
}
/**
* API tab4
*
* @summary API tab4
*
* @param {string} id Id
*/
@Get("tab4/cover/{id}")
async GetByIdTab4Cover(@Path() id: string) {
const command = await this.commandRepository.findOne({
where: { id },
relations: ["commandType"],
});
if (!command) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลคำสั่งนี้");
}
const _command = {
issue: "...................................",
commandNo: command.commandNo,
commandYear: command.commandYear,
commandTitle: command.issue,
detailHeader: command.detailHeader,
detailBody: command.detailBody,
detailFooter: command.detailFooter,
commandDate: Extension.ToThaiNumber(Extension.ToThaiFullDate2(command.commandAffectDate)),
commandExcecuteDate: Extension.ToThaiNumber(
Extension.ToThaiFullDate2(command.commandExcecuteDate),
),
name: "...................................",
position: "...................................",
};
return new HttpSuccess({
template: command.commandType.fileCover,
reportName: "docx-report",
data: { _command },
});
}
/**
* API tab4
*
* @summary API tab4
*
* @param {string} id Id
*/
@Get("tab4/attachment/{id}")
async GetByIdTab4Attachment(@Path() id: string) {
const command = await this.commandRepository.findOne({
where: { id },
relations: ["commandType"],
});
if (!command) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลคำสั่งนี้");
}
const _command = {
issue: "...................................",
commandNo: command.commandNo,
commandYear: command.commandYear,
commandTitle: command.issue,
detailHeader: command.detailHeader,
detailBody: command.detailBody,
detailFooter: command.detailFooter,
commandDate: Extension.ToThaiNumber(Extension.ToThaiFullDate2(command.commandAffectDate)),
commandExcecuteDate: Extension.ToThaiNumber(
Extension.ToThaiFullDate2(command.commandExcecuteDate),
),
name: "...................................",
position: "...................................",
};
return new HttpSuccess({
template: command.commandType.fileAttachment,
reportName: "xlsx-report",
data: { _command },
});
}
}