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