2024-06-13 11:34:25 +07:00
|
|
|
import {
|
|
|
|
|
Controller,
|
|
|
|
|
Get,
|
|
|
|
|
Post,
|
|
|
|
|
Put,
|
|
|
|
|
Delete,
|
|
|
|
|
Route,
|
|
|
|
|
Security,
|
|
|
|
|
Tags,
|
|
|
|
|
Body,
|
|
|
|
|
Path,
|
|
|
|
|
Request,
|
|
|
|
|
Query,
|
|
|
|
|
} from "tsoa";
|
|
|
|
|
import { AppDataSource } from "../database/data-source";
|
|
|
|
|
import { Brackets, Not } from "typeorm";
|
|
|
|
|
import HttpSuccess from "../interfaces/http-success";
|
|
|
|
|
import HttpError from "../interfaces/http-error";
|
|
|
|
|
import HttpStatusCode from "../interfaces/http-status";
|
2024-06-14 11:01:34 +07:00
|
|
|
import { KpiPeriod } from "../entities/kpiPeriod";
|
|
|
|
|
import { KpiUserEvaluation } from "../entities/kpiUserEvaluation";
|
2024-06-14 14:15:30 +07:00
|
|
|
import { off } from "process";
|
|
|
|
|
import Extension from "../interfaces/extension";
|
2024-06-14 15:33:35 +07:00
|
|
|
import { KpiRole } from "../entities/kpiRole";
|
2024-06-14 14:15:30 +07:00
|
|
|
|
2024-06-13 11:34:25 +07:00
|
|
|
@Route("api/v1/kpi/report")
|
|
|
|
|
@Tags("Report")
|
|
|
|
|
@Security("bearerAuth")
|
|
|
|
|
export class ReportController extends Controller {
|
2024-06-14 11:01:34 +07:00
|
|
|
private kpiPeriodRepository = AppDataSource.getRepository(KpiPeriod);
|
|
|
|
|
private kpiUserEvaluationRepository = AppDataSource.getRepository(KpiUserEvaluation);
|
2024-06-14 15:33:35 +07:00
|
|
|
private kpiRoleRepository = AppDataSource.getRepository(KpiRole);
|
|
|
|
|
|
|
|
|
|
@Post("announcement")
|
2024-06-14 11:01:34 +07:00
|
|
|
async GetReportAnnouncement(
|
|
|
|
|
@Body()
|
2024-06-14 15:33:35 +07:00
|
|
|
requestBody: {
|
2024-06-25 13:55:36 +07:00
|
|
|
type: string;
|
|
|
|
|
root?: string | null;
|
|
|
|
|
periodId?: string | null;
|
|
|
|
|
filters?: string | null;
|
|
|
|
|
keyword?: string | null;
|
2024-06-14 15:33:35 +07:00
|
|
|
},
|
2024-06-14 11:01:34 +07:00
|
|
|
) {
|
2024-06-25 13:55:36 +07:00
|
|
|
let templateName: any;
|
|
|
|
|
let reportName: any;
|
|
|
|
|
let formattedData: any;
|
|
|
|
|
if (requestBody.type == "KPI1") {
|
|
|
|
|
templateName = "KPI1";
|
|
|
|
|
reportName = "KPI1";
|
2024-06-14 11:01:34 +07:00
|
|
|
}
|
2024-06-25 13:55:36 +07:00
|
|
|
if (requestBody.type == "KPI2") {
|
|
|
|
|
templateName = "KPI2";
|
|
|
|
|
reportName = "KPI2";
|
|
|
|
|
}
|
|
|
|
|
if (requestBody.type == "KPI3") {
|
|
|
|
|
templateName = "KPI3";
|
|
|
|
|
reportName = "KPI3";
|
|
|
|
|
}
|
|
|
|
|
if (requestBody.type == "KPI4") {
|
|
|
|
|
templateName = "KPI4";
|
|
|
|
|
reportName = "KPI4";
|
|
|
|
|
//use_filter
|
|
|
|
|
}
|
|
|
|
|
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 getEvaluations = await this.kpiUserEvaluationRepository.find({
|
|
|
|
|
// where: { kpiPeriodId: requestBody.periodId },
|
|
|
|
|
// });
|
|
|
|
|
// const getRoot = await this.kpiRoleRepository.findOne({
|
|
|
|
|
// where: { rootId: requestBody.root },
|
|
|
|
|
// });
|
|
|
|
|
// const officer = getEvaluations.map((evaluation) => ({
|
|
|
|
|
// fullName: getEvaluations
|
|
|
|
|
// ? `${evaluation.prefix} ${evaluation.firstName} ${evaluation.lastName}`
|
|
|
|
|
// : "",
|
|
|
|
|
// position: getEvaluations ? evaluation.position : "",
|
|
|
|
|
// posLevel: getEvaluations ? evaluation.posLevelName : "",
|
|
|
|
|
// result: "ดีเด่น",
|
|
|
|
|
// }));
|
2024-06-14 14:15:30 +07:00
|
|
|
|
2024-06-25 13:55:36 +07:00
|
|
|
// const formattedData = {
|
|
|
|
|
// periodId: requestBody.periodId,
|
|
|
|
|
// authorizedFullName: "นาย สมหมาย นครชัยศรี",
|
|
|
|
|
// authorizedPosition: "ผู้อำนวยการต้น",
|
|
|
|
|
// announceYear: Extension.ToThaiNumber(getPeriod.year.toString()),
|
|
|
|
|
// oc: getRoot ? getRoot.root : "",
|
|
|
|
|
// organizationName: "กรุงเทพมหานคร",
|
|
|
|
|
// announceDate: "๑๒ สิงหาคม ๒๕๖๔",
|
|
|
|
|
// roundNo: "๑ (๒๕๖๔) ",
|
|
|
|
|
// officer: officer,
|
|
|
|
|
// };
|
2024-06-13 11:34:25 +07:00
|
|
|
|
2024-06-25 13:55:36 +07:00
|
|
|
// }
|
|
|
|
|
// if (requestBody.filters && requestBody.keyword) {
|
|
|
|
|
// }
|
2024-06-13 11:34:25 +07:00
|
|
|
return new HttpSuccess({
|
2024-06-25 13:55:36 +07:00
|
|
|
template: templateName,
|
|
|
|
|
reportName: reportName,
|
2024-06-13 11:34:25 +07:00
|
|
|
data: formattedData,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|