2024-04-09 11:38:13 +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";
|
|
|
|
|
import { Development } from "../entities/Development";
|
|
|
|
|
import {
|
|
|
|
|
CreateDevelopmentHistory,
|
|
|
|
|
DevelopmentHistory,
|
|
|
|
|
UpdateDevelopmentHistory,
|
|
|
|
|
} from "../entities/DevelopmentHistory";
|
|
|
|
|
import { PosType } from "../entities/PosType";
|
|
|
|
|
import { PosLevel } from "../entities/PosLevel";
|
2024-04-11 18:02:03 +07:00
|
|
|
import Extension from "../interfaces/extension";
|
2024-04-09 11:38:13 +07:00
|
|
|
@Route("api/v1/development/report")
|
|
|
|
|
@Tags("Report")
|
|
|
|
|
@Security("bearerAuth")
|
|
|
|
|
export class ReportController extends Controller {
|
|
|
|
|
private developmentHistoryRepository = AppDataSource.getRepository(DevelopmentHistory);
|
|
|
|
|
private developmentRepository = AppDataSource.getRepository(Development);
|
|
|
|
|
private posTypeRepository = AppDataSource.getRepository(PosType);
|
|
|
|
|
private posLevelRepository = AppDataSource.getRepository(PosLevel);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* API Report รายการโครงการ/หลักสูตรการฝึกอบรมที่หน่วยงานของกรุงเทพมหานครเป็นผู้จัด
|
|
|
|
|
*
|
|
|
|
|
* @summary DEV_0xx - Report รายการโครงการ/หลักสูตรการฝึกอบรมที่หน่วยงานของกรุงเทพมหานครเป็นผู้จัด #xx
|
|
|
|
|
*
|
|
|
|
|
* @param {string} type type ประเภท report
|
|
|
|
|
*/
|
|
|
|
|
@Get("main/{type}")
|
|
|
|
|
async GetReportDevelopemtMain(@Path() type: string) {
|
|
|
|
|
const _type = type.trim().toUpperCase();
|
|
|
|
|
const formattedData = {
|
|
|
|
|
org: _type,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return new HttpSuccess({
|
|
|
|
|
template: "development",
|
|
|
|
|
reportName: "development",
|
|
|
|
|
data: {
|
|
|
|
|
data: formattedData,
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* API Report รายการประวัติการฝึกอบรม/ดูงานของข้าราชการกรุงเทพมหานครสามัญ
|
|
|
|
|
*
|
|
|
|
|
* @summary DEV_0xx - Report รายการประวัติการฝึกอบรม/ดูงานของข้าราชการกรุงเทพมหานครสามัญ #xx
|
|
|
|
|
*
|
|
|
|
|
*/
|
2024-04-11 18:02:03 +07:00
|
|
|
@Get("history-officer/{year}")
|
|
|
|
|
async GetReportDevelopemtHistoryOfficer(@Query("year") year: number) {
|
|
|
|
|
const type = "OFFICER";
|
|
|
|
|
const development = await AppDataSource.getRepository(DevelopmentHistory)
|
|
|
|
|
.createQueryBuilder("developmentHistory")
|
|
|
|
|
.leftJoinAndSelect("developmentHistory.posLevel", "posLevel")
|
|
|
|
|
.leftJoinAndSelect("developmentHistory.posType", "posType")
|
|
|
|
|
.leftJoinAndSelect("developmentHistory.development", "development")
|
|
|
|
|
.andWhere(
|
|
|
|
|
year != 0 && year != null && year != undefined ? "development.year = :year" : "1=1",
|
|
|
|
|
{ year: year },
|
|
|
|
|
)
|
|
|
|
|
.andWhere("developmentHistory.type = :type", { type: type })
|
|
|
|
|
.select([
|
|
|
|
|
"developmentHistory.citizenId",
|
|
|
|
|
"developmentHistory.rank",
|
|
|
|
|
"developmentHistory.position",
|
|
|
|
|
"developmentHistory.posExecutive",
|
|
|
|
|
"developmentHistory.developmentId",
|
|
|
|
|
"developmentHistory.prefix",
|
|
|
|
|
"developmentHistory.firstName",
|
|
|
|
|
"developmentHistory.lastName",
|
|
|
|
|
"posLevel.posLevelName",
|
|
|
|
|
"posType.posTypeName",
|
|
|
|
|
"development.projectName",
|
|
|
|
|
])
|
|
|
|
|
.getMany();
|
|
|
|
|
|
|
|
|
|
const formattedData = development.map((item) => ({
|
|
|
|
|
id: item.id,
|
|
|
|
|
citizenId: Extension.ToThaiNumber(item.citizenId.toString()),
|
|
|
|
|
fullName: item.prefix + item.firstName + " " + item.lastName,
|
|
|
|
|
position: item.position,
|
|
|
|
|
posType: item.posType ? item.posType.posTypeName : null,
|
|
|
|
|
posLevel: item.posLevel ? item.posLevel.posLevelName : null,
|
|
|
|
|
posExecutive: item.posExecutive,
|
|
|
|
|
projectName: item.development ? item.development.projectName : null,
|
|
|
|
|
}));
|
2024-04-09 11:38:13 +07:00
|
|
|
|
|
|
|
|
return new HttpSuccess({
|
2024-04-11 18:02:03 +07:00
|
|
|
template: "developmentHistoryOfficer",
|
|
|
|
|
reportName: "developmentHistoryOfficer",
|
2024-04-09 11:38:13 +07:00
|
|
|
data: {
|
|
|
|
|
data: formattedData,
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* API Report รายการประวัติฝึกอบรม/ดูงานลูกจ้าง
|
|
|
|
|
*
|
|
|
|
|
* @summary DEV_0xx - Report รายการประวัติฝึกอบรม/ดูงานลูกจ้าง #xx
|
|
|
|
|
*
|
2024-04-11 18:02:03 +07:00
|
|
|
* @param {number} year year ปี report
|
2024-04-09 11:38:13 +07:00
|
|
|
*/
|
2024-04-11 18:02:03 +07:00
|
|
|
@Get("history-employee/{year}")
|
|
|
|
|
async GetReportDevelopemtHistoryEmployee(@Query("year") year: number = 2024) {
|
|
|
|
|
const type = "EMPLOYEE";
|
|
|
|
|
const development = await AppDataSource.getRepository(DevelopmentHistory)
|
|
|
|
|
.createQueryBuilder("developmentHistory")
|
|
|
|
|
.leftJoinAndSelect("developmentHistory.employeePosLevel", "employeePosLevel")
|
|
|
|
|
.leftJoinAndSelect("developmentHistory.employeePosType", "employeePosType")
|
|
|
|
|
.leftJoinAndSelect("developmentHistory.development", "development")
|
|
|
|
|
.where("development.year = :year", { year })
|
|
|
|
|
.andWhere("developmentHistory.type = :type", { type: type })
|
|
|
|
|
.select([
|
|
|
|
|
"developmentHistory.citizenId",
|
|
|
|
|
"developmentHistory.position",
|
|
|
|
|
"developmentHistory.developmentId",
|
|
|
|
|
"developmentHistory.prefix",
|
|
|
|
|
"developmentHistory.firstName",
|
|
|
|
|
"developmentHistory.lastName",
|
|
|
|
|
"employeePosLevel.posLevelName",
|
|
|
|
|
"employeePosType.posTypeName",
|
|
|
|
|
"employeePosType.posTypeShortName",
|
|
|
|
|
"development.projectName",
|
|
|
|
|
])
|
|
|
|
|
.getMany();
|
|
|
|
|
|
|
|
|
|
const formattedData = development.map((item) => ({
|
|
|
|
|
id: item.id,
|
|
|
|
|
citizenId: Extension.ToThaiNumber(item.citizenId.toString()),
|
|
|
|
|
fullName: item.prefix + item.firstName + " " + item.lastName,
|
|
|
|
|
position: item.position,
|
|
|
|
|
employeePosType: item.employeePosType ? item.employeePosType.posTypeName : null,
|
|
|
|
|
employeePosLevel:
|
|
|
|
|
item.employeePosType.posTypeShortName +
|
|
|
|
|
" " +
|
|
|
|
|
Extension.ToThaiNumber(item.employeePosLevel.posLevelName.toString()),
|
|
|
|
|
projectName: item.development ? item.development.projectName : null,
|
|
|
|
|
}));
|
2024-04-09 11:38:13 +07:00
|
|
|
|
|
|
|
|
return new HttpSuccess({
|
2024-04-11 18:02:03 +07:00
|
|
|
template: "developmentHistoryEmployee",
|
|
|
|
|
reportName: "developmentHistoryEmployee",
|
2024-04-09 11:38:13 +07:00
|
|
|
data: {
|
|
|
|
|
data: formattedData,
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* API Report รายการข้าราชการฯที่ได้รับทุนการศึกษา/ฝึกอบรม
|
|
|
|
|
*
|
|
|
|
|
* @summary DEV_0xx - Report รายการข้าราชการฯที่ได้รับทุนการศึกษา/ฝึกอบรม #xx
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
@Get("scholarship")
|
|
|
|
|
async GetReportDevelopemtScholarship() {
|
|
|
|
|
const formattedData = {
|
|
|
|
|
org: "_type",
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return new HttpSuccess({
|
|
|
|
|
template: "development",
|
|
|
|
|
reportName: "development",
|
|
|
|
|
data: {
|
|
|
|
|
data: formattedData,
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|