โครงการเพิ่มบันทึกยุทธศาสตร์
This commit is contained in:
parent
650c6fe3e3
commit
be703f8e3b
16 changed files with 930 additions and 84 deletions
|
|
@ -26,6 +26,7 @@ import {
|
|||
import { PosType } from "../entities/PosType";
|
||||
import { PosLevel } from "../entities/PosLevel";
|
||||
import Extension from "../interfaces/extension";
|
||||
import { DevelopmentScholarship } from "../entities/DevelopmentScholarship";
|
||||
@Route("api/v1/development/report")
|
||||
@Tags("Report")
|
||||
@Security("bearerAuth")
|
||||
|
|
@ -34,6 +35,7 @@ export class ReportController extends Controller {
|
|||
private developmentRepository = AppDataSource.getRepository(Development);
|
||||
private posTypeRepository = AppDataSource.getRepository(PosType);
|
||||
private posLevelRepository = AppDataSource.getRepository(PosLevel);
|
||||
private developmentScholarshipRepository = AppDataSource.getRepository(DevelopmentScholarship);
|
||||
|
||||
/**
|
||||
* API Report รายการโครงการ/หลักสูตรการฝึกอบรมที่หน่วยงานของกรุงเทพมหานครเป็นผู้จัด
|
||||
|
|
@ -64,19 +66,26 @@ export class ReportController extends Controller {
|
|||
* @summary DEV_0xx - Report รายการประวัติการฝึกอบรม/ดูงานของข้าราชการกรุงเทพมหานครสามัญ #xx
|
||||
*
|
||||
*/
|
||||
@Get("history-officer/{year}")
|
||||
async GetReportDevelopemtHistoryOfficer(@Query("year") year: number) {
|
||||
const type = "OFFICER";
|
||||
@Post("history-officer")
|
||||
async PostReportDevelopemtHistoryOfficer(
|
||||
@Body()
|
||||
body: {
|
||||
year: number;
|
||||
root: string;
|
||||
},
|
||||
) {
|
||||
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 })
|
||||
.andWhere(body.year != 0 && body.year != null ? "development.year = :year" : "1=1", {
|
||||
year: body.year,
|
||||
})
|
||||
.andWhere(body.root != null ? "development.root = :root" : "1=1", {
|
||||
root: body.root,
|
||||
})
|
||||
.andWhere("developmentHistory.type = :type", { type: "OFFICER" })
|
||||
.select([
|
||||
"developmentHistory.citizenId",
|
||||
"developmentHistory.rank",
|
||||
|
|
@ -89,6 +98,7 @@ export class ReportController extends Controller {
|
|||
"posLevel.posLevelName",
|
||||
"posType.posTypeName",
|
||||
"development.projectName",
|
||||
"development.root",
|
||||
])
|
||||
.getMany();
|
||||
|
||||
|
|
@ -101,6 +111,7 @@ export class ReportController extends Controller {
|
|||
posLevel: item.posLevel ? item.posLevel.posLevelName : null,
|
||||
posExecutive: item.posExecutive,
|
||||
projectName: item.development ? item.development.projectName : null,
|
||||
root: item.root,
|
||||
}));
|
||||
|
||||
return new HttpSuccess({
|
||||
|
|
@ -119,16 +130,26 @@ export class ReportController extends Controller {
|
|||
*
|
||||
* @param {number} year year ปี report
|
||||
*/
|
||||
@Get("history-employee/{year}")
|
||||
async GetReportDevelopemtHistoryEmployee(@Query("year") year: number = 2024) {
|
||||
const type = "EMPLOYEE";
|
||||
@Post("history-employee")
|
||||
async PostReportDevelopemtHistoryEmployee(
|
||||
@Body()
|
||||
body: {
|
||||
year: number;
|
||||
root: string;
|
||||
},
|
||||
) {
|
||||
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 })
|
||||
.andWhere(body.year != 0 && body.year != null ? "development.year = :year" : "1=1", {
|
||||
year: body.year,
|
||||
})
|
||||
.andWhere(body.root != null ? "development.root = :root" : "1=1", {
|
||||
root: body.root,
|
||||
})
|
||||
.andWhere("developmentHistory.type = :type", { type: "EMPLOYEE" })
|
||||
.select([
|
||||
"developmentHistory.citizenId",
|
||||
"developmentHistory.position",
|
||||
|
|
@ -140,6 +161,7 @@ export class ReportController extends Controller {
|
|||
"employeePosType.posTypeName",
|
||||
"employeePosType.posTypeShortName",
|
||||
"development.projectName",
|
||||
"development.root",
|
||||
])
|
||||
.getMany();
|
||||
|
||||
|
|
@ -154,6 +176,7 @@ export class ReportController extends Controller {
|
|||
" " +
|
||||
Extension.ToThaiNumber(item.employeePosLevel.posLevelName.toString()),
|
||||
projectName: item.development ? item.development.projectName : null,
|
||||
root: item.root,
|
||||
}));
|
||||
|
||||
return new HttpSuccess({
|
||||
|
|
@ -185,4 +208,86 @@ export class ReportController extends Controller {
|
|||
},
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* API Report ข้าราชการฯที่ได้รับทุนการศึกษา/ฝึกอบรมใน detail
|
||||
*
|
||||
* @summary DEV_0xx - Report ข้าราชการฯที่ได้รับทุนการศึกษา/ฝึกอบรมใน detail #xx
|
||||
*
|
||||
* @param {string} id Id scholarship
|
||||
*/
|
||||
@Get("scholarship/{id}")
|
||||
async GetReportDevelopemtScholarshipDetail(@Path() id: string) {
|
||||
const getDevelopment = await this.developmentScholarshipRepository.findOne({
|
||||
where: { id: id },
|
||||
});
|
||||
if (!getDevelopment) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลทุนการศึกษา/ฝึกอบรมนี้");
|
||||
}
|
||||
if (getDevelopment.scholarshipType != null) {
|
||||
switch (getDevelopment.scholarshipType.trim().toUpperCase()) {
|
||||
case "DOMESTICE":
|
||||
getDevelopment.scholarshipType = "การศึกษาในประเทศ";
|
||||
break;
|
||||
case "NOABROAD":
|
||||
getDevelopment.scholarshipType =
|
||||
"ฝึกอบรมในประเทศที่ส่งไปพัฒนากับหน่วยวงานภายนอก (หลักสูตรที่ไม่มีการไปต่างประเทศ)";
|
||||
break;
|
||||
case "ABROAD":
|
||||
getDevelopment.scholarshipType =
|
||||
"ฝึกอบรมในประเทศที่ส่งไปพัฒนากับหน่วยวงานภายนอก (หลักสูตรที่มีการไปต่างประเทศ)";
|
||||
break;
|
||||
case "EXECUTIVE":
|
||||
getDevelopment.scholarshipType =
|
||||
"ฝึกอบรมในประเทศที่ส่งไปพัฒนากับหน่วยวงานภายนอก (หลักสูตรประเภทนักบริหาร)";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
const formattedData = {
|
||||
id: getDevelopment.id,
|
||||
firstName: getDevelopment.firstName,
|
||||
lastName: getDevelopment.lastName,
|
||||
position: getDevelopment.position,
|
||||
root: getDevelopment.root,
|
||||
degreeLevel: getDevelopment.degreeLevel,
|
||||
course: getDevelopment.course,
|
||||
field: getDevelopment.field,
|
||||
studyPlace: getDevelopment.studyPlace,
|
||||
scholarshipType: getDevelopment.scholarshipType,
|
||||
startDate:
|
||||
getDevelopment.startDate == null
|
||||
? ""
|
||||
: Extension.ToThaiNumber(Extension.ToThaiFullDate(getDevelopment.startDate)),
|
||||
endDate:
|
||||
getDevelopment.endDate == null
|
||||
? ""
|
||||
: Extension.ToThaiNumber(Extension.ToThaiFullDate(getDevelopment.endDate)),
|
||||
reportBackNo:
|
||||
getDevelopment.reportBackNo == null
|
||||
? ""
|
||||
: Extension.ToThaiNumber(getDevelopment.reportBackNo),
|
||||
reportBackNoDate:
|
||||
getDevelopment.reportBackNoDate == null
|
||||
? ""
|
||||
: Extension.ToThaiNumber(Extension.ToThaiFullDate(getDevelopment.reportBackNoDate)),
|
||||
governmentDate:
|
||||
getDevelopment.governmentDate == null
|
||||
? ""
|
||||
: Extension.ToThaiNumber(Extension.ToThaiFullDate(getDevelopment.governmentDate)),
|
||||
graduatedDate:
|
||||
getDevelopment.graduatedDate == null
|
||||
? ""
|
||||
: Extension.ToThaiNumber(Extension.ToThaiFullDate(getDevelopment.graduatedDate)),
|
||||
graduatedReason: getDevelopment.graduatedReason,
|
||||
};
|
||||
|
||||
return new HttpSuccess({
|
||||
template: "repatriation",
|
||||
reportName: "repatriation",
|
||||
data: formattedData,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue