แก้ไข report เพิ่ม extension
This commit is contained in:
parent
830a6ab307
commit
1c09bd6f8d
2 changed files with 265 additions and 13 deletions
|
|
@ -19,6 +19,9 @@ import HttpError from "../interfaces/http-error";
|
|||
import HttpStatusCode from "../interfaces/http-status";
|
||||
import { KpiPeriod } from "../entities/kpiPeriod";
|
||||
import { KpiUserEvaluation } from "../entities/kpiUserEvaluation";
|
||||
import { off } from "process";
|
||||
import Extension from "../interfaces/extension";
|
||||
|
||||
@Route("api/v1/kpi/report")
|
||||
@Tags("Report")
|
||||
@Security("bearerAuth")
|
||||
|
|
@ -37,27 +40,28 @@ export class ReportController extends Controller {
|
|||
const getPeriod = await this.kpiPeriodRepository.findOne({
|
||||
where: { id: id },
|
||||
});
|
||||
if (!getEvaluations || getEvaluations.length === 0) {
|
||||
console.log("No evaluations found for the given kpiPeriodId: ", id);
|
||||
return;
|
||||
}
|
||||
if (!getPeriod) {
|
||||
console.log("No period data found for the given id: ", id);
|
||||
return;
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่มีรอบการประเมินนี้อยู่ในระบบ");
|
||||
}
|
||||
const formattedData = getEvaluations.map((evaluation) => ({
|
||||
periodId: requestBody.periodId,
|
||||
root: requestBody.root,
|
||||
const officer = getEvaluations.map((evaluation) => ({
|
||||
fullName: `${evaluation.prefix} ${evaluation.firstName} ${evaluation.lastName}`,
|
||||
position: evaluation.position,
|
||||
posLevel: evaluation.posLevelName,
|
||||
announceYear: getPeriod.year,
|
||||
result: "ดีเด่น",
|
||||
}));
|
||||
|
||||
const formattedData = {
|
||||
periodId: requestBody.periodId,
|
||||
root: requestBody.root,
|
||||
authorizedFullName: "นาย สมหมาย นครชัยศรี",
|
||||
authorizedPosition: "เจ้าหน้าที่พิเศษ",
|
||||
announceYear: Extension.ToThaiNumber(getPeriod.year.toString()),
|
||||
oc: "test",
|
||||
organizationName: "test",
|
||||
announceDate: "testDATE",
|
||||
roundNo: "1",
|
||||
}));
|
||||
announceDate: "๑๒ สิงหาคม ๒๕๖๔",
|
||||
roundNo: "๑ (๒๕๖๔) ",
|
||||
officer: officer,
|
||||
};
|
||||
|
||||
return new HttpSuccess({
|
||||
template: "announce",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue