แก้ไข report
This commit is contained in:
parent
1c09bd6f8d
commit
fd3e472658
1 changed files with 24 additions and 14 deletions
|
|
@ -21,6 +21,7 @@ import { KpiPeriod } from "../entities/kpiPeriod";
|
|||
import { KpiUserEvaluation } from "../entities/kpiUserEvaluation";
|
||||
import { off } from "process";
|
||||
import Extension from "../interfaces/extension";
|
||||
import { KpiRole } from "../entities/kpiRole";
|
||||
|
||||
@Route("api/v1/kpi/report")
|
||||
@Tags("Report")
|
||||
|
|
@ -28,36 +29,45 @@ import Extension from "../interfaces/extension";
|
|||
export class ReportController extends Controller {
|
||||
private kpiPeriodRepository = AppDataSource.getRepository(KpiPeriod);
|
||||
private kpiUserEvaluationRepository = AppDataSource.getRepository(KpiUserEvaluation);
|
||||
@Post("announcement/{id}")
|
||||
private kpiRoleRepository = AppDataSource.getRepository(KpiRole);
|
||||
|
||||
@Post("announcement")
|
||||
async GetReportAnnouncement(
|
||||
@Path() id: string,
|
||||
@Body()
|
||||
requestBody: { root: string; periodId: string },
|
||||
requestBody: {
|
||||
root: string;
|
||||
periodId: string;
|
||||
},
|
||||
) {
|
||||
const getEvaluations = await this.kpiUserEvaluationRepository.find({
|
||||
where: { kpiPeriodId: id },
|
||||
});
|
||||
const getPeriod = await this.kpiPeriodRepository.findOne({
|
||||
where: { id: id },
|
||||
where: { id: requestBody.periodId },
|
||||
});
|
||||
if (!getPeriod) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่มีรอบการประเมินนี้อยู่ในระบบ");
|
||||
}
|
||||
const getEvaluations = await this.kpiUserEvaluationRepository.find({
|
||||
where: { kpiPeriodId: requestBody.periodId },
|
||||
});
|
||||
const getRoot = await this.kpiRoleRepository.findOne({
|
||||
where: { rootId: requestBody.root },
|
||||
});
|
||||
console.log("============Result========", getRoot?.root);
|
||||
const officer = getEvaluations.map((evaluation) => ({
|
||||
fullName: `${evaluation.prefix} ${evaluation.firstName} ${evaluation.lastName}`,
|
||||
position: evaluation.position,
|
||||
posLevel: evaluation.posLevelName,
|
||||
fullName: getEvaluations
|
||||
? `${evaluation.prefix} ${evaluation.firstName} ${evaluation.lastName}`
|
||||
: "",
|
||||
position: getEvaluations ? evaluation.position : "",
|
||||
posLevel: getEvaluations ? evaluation.posLevelName : "",
|
||||
result: "ดีเด่น",
|
||||
}));
|
||||
|
||||
const formattedData = {
|
||||
periodId: requestBody.periodId,
|
||||
root: requestBody.root,
|
||||
authorizedFullName: "นาย สมหมาย นครชัยศรี",
|
||||
authorizedPosition: "เจ้าหน้าที่พิเศษ",
|
||||
authorizedPosition: "ผู้อำนวยการต้น",
|
||||
announceYear: Extension.ToThaiNumber(getPeriod.year.toString()),
|
||||
oc: "test",
|
||||
organizationName: "test",
|
||||
oc: getRoot ? getRoot.root : "",
|
||||
organizationName: "กรุงเทพมหานคร",
|
||||
announceDate: "๑๒ สิงหาคม ๒๕๖๔",
|
||||
roundNo: "๑ (๒๕๖๔) ",
|
||||
officer: officer,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue