report kpi

This commit is contained in:
AdisakKanthawilang 2024-06-25 13:55:36 +07:00
parent e304a40015
commit 468d8d8865

View file

@ -35,47 +35,91 @@ export class ReportController extends Controller {
async GetReportAnnouncement( async GetReportAnnouncement(
@Body() @Body()
requestBody: { requestBody: {
root: string; type: string;
periodId: string; root?: string | null;
periodId?: string | null;
filters?: string | null;
keyword?: string | null;
}, },
) { ) {
const getPeriod = await this.kpiPeriodRepository.findOne({ let templateName: any;
where: { id: requestBody.periodId }, let reportName: any;
}); let formattedData: any;
if (!getPeriod) { if (requestBody.type == "KPI1") {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่มีรอบการประเมินนี้อยู่ในระบบ"); templateName = "KPI1";
reportName = "KPI1";
} }
const getEvaluations = await this.kpiUserEvaluationRepository.find({ if (requestBody.type == "KPI2") {
where: { kpiPeriodId: requestBody.periodId }, templateName = "KPI2";
}); reportName = "KPI2";
const getRoot = await this.kpiRoleRepository.findOne({ }
where: { rootId: requestBody.root }, if (requestBody.type == "KPI3") {
}); templateName = "KPI3";
console.log("============Result========", getRoot?.root); reportName = "KPI3";
const officer = getEvaluations.map((evaluation) => ({ }
fullName: getEvaluations if (requestBody.type == "KPI4") {
? `${evaluation.prefix} ${evaluation.firstName} ${evaluation.lastName}` templateName = "KPI4";
: "", reportName = "KPI4";
position: getEvaluations ? evaluation.position : "", //use_filter
posLevel: getEvaluations ? evaluation.posLevelName : "", }
result: "ดีเด่น", if (requestBody.type == "KPI5") {
})); templateName = "KPI5";
reportName = "KPI5";
//use_filter
}
if (requestBody.type == "KPI6") {
templateName = "KPI6";
reportName = "KPI6";
//use_filter
}
if (requestBody.type == "KPI7") {
templateName = "KPI7";
reportName = "KPI7";
}
if (requestBody.type == "KPI8") {
templateName = "KPI8";
reportName = "KPI8";
//use_filter
}
if (requestBody.type == "KPI9") {
templateName = "KPI8";
reportName = "KPI8";
}
// if (requestBody.root && requestBody.periodId) {
const formattedData = { // const getEvaluations = await this.kpiUserEvaluationRepository.find({
periodId: requestBody.periodId, // where: { kpiPeriodId: requestBody.periodId },
authorizedFullName: "นาย สมหมาย นครชัยศรี", // });
authorizedPosition: "ผู้อำนวยการต้น", // const getRoot = await this.kpiRoleRepository.findOne({
announceYear: Extension.ToThaiNumber(getPeriod.year.toString()), // where: { rootId: requestBody.root },
oc: getRoot ? getRoot.root : "", // });
organizationName: "กรุงเทพมหานคร", // const officer = getEvaluations.map((evaluation) => ({
announceDate: "๑๒ สิงหาคม ๒๕๖๔", // fullName: getEvaluations
roundNo: "๑ (๒๕๖๔) ", // ? `${evaluation.prefix} ${evaluation.firstName} ${evaluation.lastName}`
officer: officer, // : "",
}; // position: getEvaluations ? evaluation.position : "",
// posLevel: getEvaluations ? evaluation.posLevelName : "",
// result: "ดีเด่น",
// }));
// const formattedData = {
// periodId: requestBody.periodId,
// authorizedFullName: "นาย สมหมาย นครชัยศรี",
// authorizedPosition: "ผู้อำนวยการต้น",
// announceYear: Extension.ToThaiNumber(getPeriod.year.toString()),
// oc: getRoot ? getRoot.root : "",
// organizationName: "กรุงเทพมหานคร",
// announceDate: "๑๒ สิงหาคม ๒๕๖๔",
// roundNo: "๑ (๒๕๖๔) ",
// officer: officer,
// };
// }
// if (requestBody.filters && requestBody.keyword) {
// }
return new HttpSuccess({ return new HttpSuccess({
template: "announce", template: templateName,
reportName: "announce", reportName: reportName,
data: formattedData, data: formattedData,
}); });
} }