This commit is contained in:
AdisakKanthawilang 2024-06-27 18:14:43 +07:00
parent 88e352cea3
commit dd7c8ea670

View file

@ -22,6 +22,7 @@ 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"; import { KpiRole } from "../entities/kpiRole";
import { KpiPlan } from "../entities/kpiPlan";
@Route("api/v1/kpi/report") @Route("api/v1/kpi/report")
@Tags("Report") @Tags("Report")
@ -30,6 +31,7 @@ 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);
private kpiRoleRepository = AppDataSource.getRepository(KpiRole); private kpiRoleRepository = AppDataSource.getRepository(KpiRole);
private kpiPlanRepository = AppDataSource.getRepository(KpiPlan);
@Post("announcement") @Post("announcement")
async GetReportAnnouncement( async GetReportAnnouncement(
@ -135,15 +137,40 @@ export class ReportController extends Controller {
@Post("kpi9/{periodId}") @Post("kpi9/{periodId}")
async GetReportKpi9( async GetReportKpi9(
@Path() periodId?: string | null, @Path() profileId?: string | null,
) { ) {
let formattedData: any;
if (profileId) {
const kpiUserEvaluation = await this.kpiUserEvaluationRepository.findOne({
relations: ["kpiUserRoles", "kpiUserPlanneds", "kpiUserSpecials", "kpiUserCapacitys"],
where: { profileId: profileId },
});
if (!kpiUserEvaluation)
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ประเมิน");
//period
const period = await this.kpiPeriodRepository.findOneBy({
id: kpiUserEvaluation?.kpiPeriodId,
});
if (!period) throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลงวดการประเมิน");
const kpiRole = await this.kpiRoleRepository.find({
where: { kpiPeriodId: period?.id },
});
const kpiPlan = await this.kpiPlanRepository.find({
where: { kpiPeriodId: period?.id },
});
formattedData = {
};
}
return new HttpSuccess({ return new HttpSuccess({
template: "KPI9", template: "KPI9",
reportName: "KPI9", reportName: "KPI9",
data: {}, data: formattedData,
}); });
} }
} }