2025-02-13 10:28:05 +07:00
|
|
|
import { Controller, Get, Post, Route, Security, Tags, Body, Path, Query } from "tsoa";
|
2024-04-09 11:38:13 +07:00
|
|
|
import { AppDataSource } from "../database/data-source";
|
|
|
|
|
import HttpSuccess from "../interfaces/http-success";
|
|
|
|
|
import HttpError from "../interfaces/http-error";
|
|
|
|
|
import HttpStatusCode from "../interfaces/http-status";
|
|
|
|
|
import { Development } from "../entities/Development";
|
2024-09-03 15:18:30 +07:00
|
|
|
import { DevelopmentHistory } from "../entities/DevelopmentHistory";
|
2024-04-09 11:38:13 +07:00
|
|
|
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-13 20:47:28 +07:00
|
|
|
import { DevelopmentScholarship } from "../entities/DevelopmentScholarship";
|
2025-01-17 20:02:52 +07:00
|
|
|
import { IsNull, Not } from "typeorm";
|
2024-04-09 11:38:13 +07:00
|
|
|
@Route("api/v1/development/report")
|
|
|
|
|
@Tags("Report")
|
|
|
|
|
@Security("bearerAuth")
|
|
|
|
|
export class ReportController extends Controller {
|
2024-04-13 20:47:28 +07:00
|
|
|
private developmentScholarshipRepository = AppDataSource.getRepository(DevelopmentScholarship);
|
2024-04-09 11:38:13 +07:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* API Report รายการโครงการ/หลักสูตรการฝึกอบรมที่หน่วยงานของกรุงเทพมหานครเป็นผู้จัด
|
|
|
|
|
*
|
|
|
|
|
* @summary DEV_0xx - Report รายการโครงการ/หลักสูตรการฝึกอบรมที่หน่วยงานของกรุงเทพมหานครเป็นผู้จัด #xx
|
|
|
|
|
*
|
|
|
|
|
* @param {string} type type ประเภท report
|
|
|
|
|
*/
|
2024-07-17 13:19:20 +07:00
|
|
|
@Get("main")
|
|
|
|
|
async GetReportDevelopemtMain(/*@Path() type: string*/) {
|
2025-01-17 20:02:52 +07:00
|
|
|
|
2024-07-17 12:47:36 +07:00
|
|
|
// const _type = type.trim().toUpperCase();
|
2024-04-09 11:38:13 +07:00
|
|
|
const formattedData = {
|
2024-07-17 12:47:36 +07:00
|
|
|
org: "_type",
|
2024-04-09 11:38:13 +07:00
|
|
|
};
|
|
|
|
|
|
2025-01-17 20:02:52 +07:00
|
|
|
//ตารางรายละเอียด กับ แบบรายงาน
|
|
|
|
|
const dataDevelopment = await AppDataSource.getRepository(Development)
|
|
|
|
|
.createQueryBuilder("development")
|
|
|
|
|
.leftJoinAndSelect("development.developmentHistorys", "history")
|
|
|
|
|
.leftJoinAndSelect("development.developmentPlannedGoals", "planGoals")
|
|
|
|
|
.leftJoinAndSelect("development.strategyChild1Actual", "strategy1")
|
|
|
|
|
.leftJoinAndSelect("development.strategyChild2Actual", "strategy2")
|
|
|
|
|
.leftJoinAndSelect("development.strategyChild3Actual", "strategy3")
|
|
|
|
|
.leftJoinAndSelect("development.strategyChild4Actual", "strategy4")
|
|
|
|
|
.leftJoinAndSelect("development.strategyChild5Actual", "strategy5")
|
|
|
|
|
.where("development.status = :status", { status: "FINISH" })
|
|
|
|
|
.andWhere("development.strategyChild1ActualId IS NOT NULL")
|
|
|
|
|
.select([
|
|
|
|
|
"development.id AS id",
|
|
|
|
|
"development.projectName AS projectName",
|
|
|
|
|
"development.year AS year",
|
|
|
|
|
"development.totalDate AS totalDate",
|
|
|
|
|
"development.budget AS budget",
|
|
|
|
|
"SUM(DISTINCT planGoals.amount) AS goalParticipants",
|
|
|
|
|
"COUNT(DISTINCT history.id) AS actualParticipants",
|
|
|
|
|
"strategy1.strategyChild1Name AS strategy1",
|
|
|
|
|
"strategy2.strategyChild2Name AS strategy2",
|
|
|
|
|
"strategy3.strategyChild3Name AS strategy3",
|
|
|
|
|
"strategy4.strategyChild4Name AS strategy4",
|
|
|
|
|
"strategy5.strategyChild5Name AS strategy5",
|
|
|
|
|
"development.accept AS acceptBudget",
|
|
|
|
|
"development.receive AS receiveBudget",
|
|
|
|
|
"development.obstacle AS obstacle",
|
|
|
|
|
"development.root AS root",
|
|
|
|
|
])
|
|
|
|
|
.groupBy("development.id")
|
|
|
|
|
.getRawMany();
|
|
|
|
|
|
|
|
|
|
const mappedDataDev = dataDevelopment.map((item, index) => {
|
|
|
|
|
let budget = null;
|
|
|
|
|
if (item.budget == "REGULATIONBUDGET") {
|
|
|
|
|
budget = "งบตามข้อบัญญัติ";
|
|
|
|
|
}else if (item.budget == "OTHERBUDGET") {
|
|
|
|
|
budget = "เงินนอกงบประมาณ";
|
|
|
|
|
}else if (item.budget == "BANGKOKBUDGET") {
|
|
|
|
|
budget = "ไม่ใช้งบประมาณ";
|
|
|
|
|
}
|
|
|
|
|
return {
|
|
|
|
|
strategy: item.strategy1,
|
|
|
|
|
projectName: item.projectName,
|
2025-01-21 11:00:27 +07:00
|
|
|
totalDate: item.totalDate != null && item.totalDate != "" ? Extension.ToThaiNumber(item.totalDate.toLocaleString()): "-",
|
|
|
|
|
goalParticipants: item.goalParticipants != null && item.goalParticipants != "" ? Extension.ToThaiNumber(item.goalParticipants.toLocaleString()): "-",
|
|
|
|
|
actualParticipants: item.actualParticipants != null && item.actualParticipants != "" ? Extension.ToThaiNumber(item.actualParticipants.toLocaleString()): "-",
|
2025-01-17 20:02:52 +07:00
|
|
|
budget: budget,
|
2025-01-21 11:00:27 +07:00
|
|
|
acceptBudget: item.acceptBudget != null && item.acceptBudget != "" ? Extension.ToThaiNumber(item.acceptBudget.toLocaleString()): "-",
|
|
|
|
|
receiveBudget: item.receiveBudget != null && item.receiveBudget != "" ? Extension.ToThaiNumber(item.receiveBudget.toLocaleString()): "-",
|
2025-01-17 20:02:52 +07:00
|
|
|
obstacle: item.obstacle,
|
|
|
|
|
root: item.root,
|
|
|
|
|
output: "-",
|
|
|
|
|
outcome: "-",
|
|
|
|
|
position: "-",
|
|
|
|
|
indicators: "-",
|
|
|
|
|
devResult: "-",
|
|
|
|
|
positionActual: "-",
|
|
|
|
|
};
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const resultAllStrategy = await AppDataSource.getRepository(Development)
|
|
|
|
|
.createQueryBuilder("development")
|
|
|
|
|
.leftJoinAndSelect("development.strategyChild1Actual", "strategy1")
|
|
|
|
|
.where("development.status = :status", { status: "FINISH" })
|
|
|
|
|
.andWhere("development.strategyChild1ActualId IS NOT NULL")
|
|
|
|
|
.select([
|
|
|
|
|
"development.rootId AS rootId",
|
|
|
|
|
"development.strategyChild1ActualId AS strategyId",
|
|
|
|
|
"strategy1.strategyChild1Name AS strategyName",
|
|
|
|
|
"COUNT(development.id) AS devCount",
|
|
|
|
|
"SUM(development.receive) AS receiveBudget",
|
|
|
|
|
"development.root AS root",
|
|
|
|
|
])
|
|
|
|
|
.groupBy("development.rootId, development.strategyChild1ActualId, strategy1.strategyChild1Name, development.root")
|
|
|
|
|
.orderBy("strategy1.createdAt", "ASC")
|
|
|
|
|
.getRawMany();
|
|
|
|
|
|
|
|
|
|
interface Strategy {
|
|
|
|
|
strategyId: string;
|
|
|
|
|
strategyName: string;
|
|
|
|
|
devCount: string;
|
|
|
|
|
receiveBudget: string;
|
|
|
|
|
sumDev: string;
|
|
|
|
|
sumTraget: string;
|
|
|
|
|
sumBudget: string;
|
|
|
|
|
sumRowDev: string,
|
|
|
|
|
sumRowTarget: string,
|
|
|
|
|
sumRowBudget: string,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
interface GroupedData {
|
|
|
|
|
rootId: string;
|
|
|
|
|
root: string;
|
|
|
|
|
strategy: Strategy[];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const groupedData: GroupedData[] = resultAllStrategy.reduce((acc: GroupedData[], item) => {
|
|
|
|
|
const existingRoot = acc.find(entry => entry.rootId === item.rootId);
|
|
|
|
|
|
|
|
|
|
if (existingRoot) {
|
|
|
|
|
existingRoot.strategy.push({
|
|
|
|
|
strategyId: item.strategyId,
|
|
|
|
|
strategyName: item.strategyName,
|
2025-01-20 18:20:09 +07:00
|
|
|
devCount: item.devCount?item.devCount:"-",
|
|
|
|
|
receiveBudget: item.receiveBudget?item.receiveBudget:"-",
|
2025-01-17 20:02:52 +07:00
|
|
|
sumDev: "",
|
|
|
|
|
sumTraget: "",
|
|
|
|
|
sumBudget: "",
|
|
|
|
|
sumRowDev:"",
|
|
|
|
|
sumRowTarget:"",
|
|
|
|
|
sumRowBudget:"",
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
acc.push({
|
|
|
|
|
rootId: item.rootId,
|
|
|
|
|
root: item.root,
|
|
|
|
|
strategy: [{
|
|
|
|
|
strategyId: item.strategyId,
|
|
|
|
|
strategyName: item.strategyName,
|
2025-01-20 18:20:09 +07:00
|
|
|
devCount: item.devCount?item.devCount:"-",
|
|
|
|
|
receiveBudget: item.receiveBudget?item.receiveBudget:"-",
|
2025-01-17 20:02:52 +07:00
|
|
|
sumDev: "",
|
|
|
|
|
sumTraget: "",
|
|
|
|
|
sumBudget: "",
|
|
|
|
|
sumRowDev:"",
|
|
|
|
|
sumRowTarget:"",
|
|
|
|
|
sumRowBudget:"",
|
|
|
|
|
}]
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return acc;
|
|
|
|
|
}, []);
|
2025-01-21 11:00:27 +07:00
|
|
|
let sumDev1 = 0;
|
|
|
|
|
let sumTraget1 = 0;
|
|
|
|
|
let sumBudget1 = 0;
|
|
|
|
|
let sumDev2 = 0;
|
|
|
|
|
let sumTraget2 = 0;
|
|
|
|
|
let sumBudget2 = 0;
|
|
|
|
|
let sumDev3 = 0;
|
|
|
|
|
let sumTraget3 = 0;
|
|
|
|
|
let sumBudget3 = 0;
|
|
|
|
|
let sumDev4 = 0;
|
|
|
|
|
let sumTraget4 = 0;
|
|
|
|
|
let sumBudget4 = 0;
|
2025-01-17 20:02:52 +07:00
|
|
|
const reformattedData = groupedData.map((group,x) => {
|
2025-01-20 18:20:09 +07:00
|
|
|
const sumRowDev = (group.strategy[0] && group.strategy[0].devCount !== "-" ? Number(group.strategy[0].devCount) : 0) +
|
|
|
|
|
(group.strategy[1] && group.strategy[1].devCount !== "-" ? Number(group.strategy[1].devCount) : 0) +
|
|
|
|
|
(group.strategy[2] && group.strategy[2].devCount !== "-" ? Number(group.strategy[2].devCount) : 0);
|
|
|
|
|
(group.strategy[3] && group.strategy[3].devCount !== "-" ? Number(group.strategy[3].devCount) : 0);
|
|
|
|
|
const sumRowBudget = (group.strategy[0] && group.strategy[0].receiveBudget !== "-" ? Number(group.strategy[0].receiveBudget) : 0) +
|
|
|
|
|
(group.strategy[1] && group.strategy[1].receiveBudget !== "-" ? Number(group.strategy[1].receiveBudget) : 0) +
|
|
|
|
|
(group.strategy[2] && group.strategy[2].receiveBudget !== "-" ? Number(group.strategy[2].receiveBudget) : 0);
|
|
|
|
|
(group.strategy[3] && group.strategy[3].receiveBudget !== "-" ? Number(group.strategy[3].receiveBudget) : 0);
|
2025-01-21 11:00:27 +07:00
|
|
|
sumDev1 = groupedData.reduce((sum, group) => {
|
|
|
|
|
const devCount = group.strategy[0] && group.strategy[0].devCount !== "-" ? Number(group.strategy[0].devCount) : 0;
|
|
|
|
|
return sum + devCount;
|
|
|
|
|
}, 0);
|
|
|
|
|
sumBudget1 = groupedData.reduce((sum, group) => {
|
|
|
|
|
const devCount = group.strategy[0] && group.strategy[0].receiveBudget !== "-" ? Number(group.strategy[0].receiveBudget) : 0;
|
|
|
|
|
return sum + devCount;
|
|
|
|
|
}, 0);
|
|
|
|
|
sumDev2 = groupedData.reduce((sum, group) => {
|
|
|
|
|
const devCount = group.strategy[1] && group.strategy[1].devCount !== "-" ? Number(group.strategy[1].devCount) : 0;
|
|
|
|
|
return sum + devCount;
|
|
|
|
|
}, 0);
|
|
|
|
|
sumBudget2 = groupedData.reduce((sum, group) => {
|
|
|
|
|
const devCount = group.strategy[1] && group.strategy[1].receiveBudget !== "-" ? Number(group.strategy[1].receiveBudget) : 0;
|
|
|
|
|
return sum + devCount;
|
|
|
|
|
}, 0);
|
|
|
|
|
sumDev3 = groupedData.reduce((sum, group) => {
|
|
|
|
|
const devCount = group.strategy[2] && group.strategy[2].devCount !== "-" ? Number(group.strategy[2].devCount) : 0;
|
|
|
|
|
return sum + devCount;
|
|
|
|
|
}, 0);
|
|
|
|
|
sumBudget3 = groupedData.reduce((sum, group) => {
|
|
|
|
|
const devCount = group.strategy[2] && group.strategy[2].receiveBudget !== "-" ? Number(group.strategy[2].receiveBudget) : 0;
|
|
|
|
|
return sum + devCount;
|
|
|
|
|
}, 0);
|
|
|
|
|
sumDev4 = groupedData.reduce((sum, group) => {
|
|
|
|
|
const devCount = group.strategy[3] && group.strategy[3].devCount !== "-" ? Number(group.strategy[3].devCount) : 0;
|
|
|
|
|
return sum + devCount;
|
|
|
|
|
}, 0);
|
|
|
|
|
sumBudget4 = groupedData.reduce((sum, group) => {
|
|
|
|
|
const devCount = group.strategy[3] && group.strategy[3].receiveBudget !== "-" ? Number(group.strategy[3].receiveBudget) : 0;
|
|
|
|
|
return sum + devCount;
|
|
|
|
|
}, 0);
|
|
|
|
|
|
2025-01-17 20:02:52 +07:00
|
|
|
const formattedGroup = {
|
|
|
|
|
rowNo: x?Extension.ToThaiNumber((x + 1).toString()):Extension.ToThaiNumber("๑"),
|
|
|
|
|
rootId: group.rootId,
|
|
|
|
|
root: group.root,
|
2025-01-20 18:20:09 +07:00
|
|
|
strategyName1: group.strategy[0]&&group.strategy[0].strategyName?group.strategy[0].strategyName:"-",
|
2025-01-21 11:00:27 +07:00
|
|
|
devCount1: group.strategy[0]&&group.strategy[0].devCount?Extension.ToThaiNumber(group.strategy[0].devCount.toLocaleString()):"-",
|
2025-01-20 18:20:09 +07:00
|
|
|
target1: "-",
|
2025-01-21 11:00:27 +07:00
|
|
|
receiveBudget1: group.strategy[0]&&group.strategy[0].receiveBudget?Extension.ToThaiNumber(group.strategy[0].receiveBudget.toLocaleString()):"-",
|
2025-01-20 18:20:09 +07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
strategyName2: group.strategy[1]&&group.strategy[1].strategyName?group.strategy[1].strategyName:"-",
|
2025-01-21 11:00:27 +07:00
|
|
|
devCount2: group.strategy[1]&&group.strategy[1].devCount?Extension.ToThaiNumber(group.strategy[1].devCount.toLocaleString()):"-",
|
2025-01-20 18:20:09 +07:00
|
|
|
target2: "-",
|
2025-01-21 11:00:27 +07:00
|
|
|
receiveBudget2: group.strategy[1]&&group.strategy[1].receiveBudget?Extension.ToThaiNumber(group.strategy[1].receiveBudget.toLocaleString()):"-",
|
2025-01-20 18:20:09 +07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
strategyName3: group.strategy[2]&&group.strategy[2].strategyName?group.strategy[2].strategyName:"-",
|
2025-01-21 11:00:27 +07:00
|
|
|
devCount3: group.strategy[2]&&group.strategy[2].devCount?Extension.ToThaiNumber(group.strategy[2].devCount.toLocaleString()):"-",
|
2025-01-20 18:20:09 +07:00
|
|
|
target3: "-",
|
2025-01-21 11:00:27 +07:00
|
|
|
receiveBudget3: group.strategy[2]&&group.strategy[2].receiveBudget?Extension.ToThaiNumber(group.strategy[2].receiveBudget.toLocaleString()):"-",
|
2025-01-20 18:20:09 +07:00
|
|
|
|
2025-01-17 20:02:52 +07:00
|
|
|
|
2025-01-20 18:20:09 +07:00
|
|
|
strategyName4: group.strategy[3]&&group.strategy[3].strategyName?group.strategy[3].strategyName:"-",
|
2025-01-21 11:00:27 +07:00
|
|
|
devCount4: group.strategy[3]&&group.strategy[3].devCount?Extension.ToThaiNumber(group.strategy[3].devCount.toLocaleString()):"-",
|
2025-01-20 18:20:09 +07:00
|
|
|
target4: "-",
|
2025-01-21 11:00:27 +07:00
|
|
|
receiveBudget4: group.strategy[3]&&group.strategy[3].receiveBudget?Extension.ToThaiNumber(group.strategy[3].receiveBudget.toLocaleString()):"-",
|
2025-01-20 18:20:09 +07:00
|
|
|
|
|
|
|
|
|
2025-01-21 11:00:27 +07:00
|
|
|
sumRowDev: sumRowDev?Extension.ToThaiNumber(sumRowDev.toLocaleString()):"-",
|
2025-01-20 18:20:09 +07:00
|
|
|
sumRowTarget: "-",
|
2025-01-21 11:00:27 +07:00
|
|
|
sumRowBudget: sumRowBudget?Extension.ToThaiNumber(sumRowBudget.toLocaleString()):"-",
|
2025-01-20 18:20:09 +07:00
|
|
|
// strategy: Array(4).fill(null).map((_, index) => {
|
|
|
|
|
// const strategy = group.strategy[index] || {
|
|
|
|
|
// strategyName: "",
|
|
|
|
|
// devCount: "",
|
|
|
|
|
// target: "",
|
|
|
|
|
// receiveBudget: "",
|
|
|
|
|
// sumDev: "",
|
|
|
|
|
// sumTraget: "",
|
|
|
|
|
// sumBudget: "",
|
|
|
|
|
// sumRowDev: "",
|
|
|
|
|
// sumRowTarget: "",
|
|
|
|
|
// sumRowBudget: "",
|
|
|
|
|
// };
|
|
|
|
|
|
|
|
|
|
// return {
|
|
|
|
|
// [`strategyName${index + 1}`]: strategy.strategyName ?? "",
|
|
|
|
|
// [`devCount${index + 1}`]: strategy.devCount ?? "",
|
|
|
|
|
// [`target${index + 1}`]: "",
|
|
|
|
|
// [`receiveBudget${index + 1}`]: strategy.receiveBudget ?? "",
|
|
|
|
|
// [`sumDev${index + 1}`]: strategy.sumDev ?? "",
|
|
|
|
|
// [`sumTraget${index + 1}`]: strategy.sumTraget ?? "",
|
|
|
|
|
// [`sumBudget${index + 1}`]: strategy.sumBudget ?? "",
|
|
|
|
|
// [`sumRowDev`]: strategy.sumRowDev ?? "",
|
|
|
|
|
// [`sumRowTarget`]: strategy.sumRowTarget ?? "",
|
|
|
|
|
// [`sumRowBudget`]: strategy.sumRowBudget ?? "",
|
|
|
|
|
// };
|
|
|
|
|
// }),
|
2025-01-17 20:02:52 +07:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return formattedGroup;
|
|
|
|
|
});
|
|
|
|
|
|
2024-04-09 11:38:13 +07:00
|
|
|
return new HttpSuccess({
|
|
|
|
|
template: "development",
|
|
|
|
|
reportName: "development",
|
|
|
|
|
data: {
|
2025-01-17 20:02:52 +07:00
|
|
|
data: mappedDataDev,
|
|
|
|
|
resultAllStrategy: reformattedData,
|
2025-01-21 11:00:27 +07:00
|
|
|
sumDev1: Extension.ToThaiNumber(sumDev1.toLocaleString())??"-",
|
|
|
|
|
sumTraget1: Extension.ToThaiNumber(sumTraget1.toLocaleString())??"-",
|
|
|
|
|
sumBudget1: Extension.ToThaiNumber(sumBudget1.toLocaleString())??"-",
|
|
|
|
|
sumDev2: Extension.ToThaiNumber(sumDev2.toLocaleString())??"-",
|
|
|
|
|
sumTraget2: Extension.ToThaiNumber(sumTraget2.toLocaleString())??"-",
|
|
|
|
|
sumBudget2: Extension.ToThaiNumber(sumBudget2.toLocaleString())??"-",
|
|
|
|
|
sumDev3: Extension.ToThaiNumber(sumDev3.toLocaleString())??"-",
|
|
|
|
|
sumTraget3: Extension.ToThaiNumber(sumTraget3.toLocaleString())??"-",
|
|
|
|
|
sumBudget3: Extension.ToThaiNumber(sumBudget3.toLocaleString())??"-",
|
|
|
|
|
sumDev4: Extension.ToThaiNumber(sumDev4.toLocaleString())??"-",
|
|
|
|
|
sumTraget4: Extension.ToThaiNumber(sumTraget4.toLocaleString())??"-",
|
|
|
|
|
sumBudget4: Extension.ToThaiNumber(sumBudget4.toLocaleString())??"-",
|
|
|
|
|
sumAllDev: Extension.ToThaiNumber((sumDev1 + sumDev2 + sumDev3 + sumDev4).toLocaleString())??"-",
|
|
|
|
|
sumTraget: Extension.ToThaiNumber((sumTraget1 +sumTraget2 +sumTraget3 +sumTraget4).toLocaleString())??"-",
|
|
|
|
|
sumAllBudget: Extension.ToThaiNumber((sumBudget1 + sumBudget2 + sumBudget3 + sumBudget4).toLocaleString())??"-",
|
2024-04-09 11:38:13 +07:00
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* API Report รายการประวัติการฝึกอบรม/ดูงานของข้าราชการกรุงเทพมหานครสามัญ
|
|
|
|
|
*
|
|
|
|
|
* @summary DEV_0xx - Report รายการประวัติการฝึกอบรม/ดูงานของข้าราชการกรุงเทพมหานครสามัญ #xx
|
|
|
|
|
*
|
|
|
|
|
*/
|
2024-04-13 20:47:28 +07:00
|
|
|
@Post("history-officer")
|
|
|
|
|
async PostReportDevelopemtHistoryOfficer(
|
|
|
|
|
@Body()
|
|
|
|
|
body: {
|
|
|
|
|
year: number;
|
|
|
|
|
root: string;
|
|
|
|
|
},
|
|
|
|
|
) {
|
2024-04-11 18:02:03 +07:00
|
|
|
const development = await AppDataSource.getRepository(DevelopmentHistory)
|
|
|
|
|
.createQueryBuilder("developmentHistory")
|
|
|
|
|
.leftJoinAndSelect("developmentHistory.posLevel", "posLevel")
|
|
|
|
|
.leftJoinAndSelect("developmentHistory.posType", "posType")
|
|
|
|
|
.leftJoinAndSelect("developmentHistory.development", "development")
|
2024-04-13 20:47:28 +07:00
|
|
|
.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" })
|
2024-04-11 18:02:03 +07:00
|
|
|
.select([
|
|
|
|
|
"developmentHistory.citizenId",
|
|
|
|
|
"developmentHistory.rank",
|
|
|
|
|
"developmentHistory.position",
|
|
|
|
|
"developmentHistory.posExecutive",
|
|
|
|
|
"developmentHistory.developmentId",
|
|
|
|
|
"developmentHistory.prefix",
|
|
|
|
|
"developmentHistory.firstName",
|
|
|
|
|
"developmentHistory.lastName",
|
|
|
|
|
"posLevel.posLevelName",
|
|
|
|
|
"posType.posTypeName",
|
|
|
|
|
"development.projectName",
|
2024-04-13 20:47:28 +07:00
|
|
|
"development.root",
|
2024-04-11 18:02:03 +07:00
|
|
|
])
|
|
|
|
|
.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-13 20:47:28 +07:00
|
|
|
root: item.root,
|
2024-04-11 18:02:03 +07:00
|
|
|
}));
|
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-13 20:47:28 +07:00
|
|
|
@Post("history-employee")
|
|
|
|
|
async PostReportDevelopemtHistoryEmployee(
|
|
|
|
|
@Body()
|
|
|
|
|
body: {
|
|
|
|
|
year: number;
|
|
|
|
|
root: string;
|
|
|
|
|
},
|
|
|
|
|
) {
|
2024-04-11 18:02:03 +07:00
|
|
|
const development = await AppDataSource.getRepository(DevelopmentHistory)
|
|
|
|
|
.createQueryBuilder("developmentHistory")
|
|
|
|
|
.leftJoinAndSelect("developmentHistory.employeePosLevel", "employeePosLevel")
|
|
|
|
|
.leftJoinAndSelect("developmentHistory.employeePosType", "employeePosType")
|
|
|
|
|
.leftJoinAndSelect("developmentHistory.development", "development")
|
2024-04-13 20:47:28 +07:00
|
|
|
.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" })
|
2024-04-11 18:02:03 +07:00
|
|
|
.select([
|
|
|
|
|
"developmentHistory.citizenId",
|
|
|
|
|
"developmentHistory.position",
|
|
|
|
|
"developmentHistory.developmentId",
|
|
|
|
|
"developmentHistory.prefix",
|
|
|
|
|
"developmentHistory.firstName",
|
|
|
|
|
"developmentHistory.lastName",
|
|
|
|
|
"employeePosLevel.posLevelName",
|
|
|
|
|
"employeePosType.posTypeName",
|
|
|
|
|
"employeePosType.posTypeShortName",
|
|
|
|
|
"development.projectName",
|
2024-04-13 20:47:28 +07:00
|
|
|
"development.root",
|
2024-04-11 18:02:03 +07:00
|
|
|
])
|
|
|
|
|
.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-13 20:47:28 +07:00
|
|
|
root: item.root,
|
2024-04-11 18:02:03 +07:00
|
|
|
}));
|
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,
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
}
|
2024-04-13 20:47:28 +07:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 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;
|
2025-01-21 09:22:42 +07:00
|
|
|
case "RESEARCH":
|
|
|
|
|
getDevelopment.scholarshipType =
|
|
|
|
|
"ศึกษา ฝึกอบรม ประชุม ดูงาน และปฏิบัติการวิจัย ณ ต่างประเทศ";
|
|
|
|
|
break;
|
2024-04-13 20:47:28 +07:00
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const formattedData = {
|
|
|
|
|
id: getDevelopment.id,
|
|
|
|
|
firstName: getDevelopment.firstName,
|
|
|
|
|
lastName: getDevelopment.lastName,
|
|
|
|
|
position: getDevelopment.position,
|
2024-04-19 09:28:57 +07:00
|
|
|
org: getDevelopment.org,
|
2024-04-13 20:47:28 +07:00
|
|
|
degreeLevel: getDevelopment.degreeLevel,
|
|
|
|
|
course: getDevelopment.course,
|
|
|
|
|
field: getDevelopment.field,
|
|
|
|
|
studyPlace: getDevelopment.studyPlace,
|
|
|
|
|
scholarshipType: getDevelopment.scholarshipType,
|
2024-04-19 09:28:57 +07:00
|
|
|
bookNoDate:
|
|
|
|
|
getDevelopment.bookNoDate == null
|
|
|
|
|
? ""
|
2024-07-17 13:58:37 +07:00
|
|
|
: Extension.ToThaiNumber(Extension.ToThaiFullDate3(getDevelopment.bookNoDate)),
|
2024-04-13 20:47:28 +07:00
|
|
|
startDate:
|
|
|
|
|
getDevelopment.startDate == null
|
|
|
|
|
? ""
|
2024-07-17 13:58:37 +07:00
|
|
|
: Extension.ToThaiNumber(Extension.ToThaiFullDate3(getDevelopment.startDate)),
|
2024-04-13 20:47:28 +07:00
|
|
|
endDate:
|
|
|
|
|
getDevelopment.endDate == null
|
|
|
|
|
? ""
|
2024-07-17 13:58:37 +07:00
|
|
|
: Extension.ToThaiNumber(Extension.ToThaiFullDate3(getDevelopment.endDate)),
|
2024-04-13 20:47:28 +07:00
|
|
|
reportBackNo:
|
|
|
|
|
getDevelopment.reportBackNo == null
|
|
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(getDevelopment.reportBackNo),
|
|
|
|
|
reportBackNoDate:
|
|
|
|
|
getDevelopment.reportBackNoDate == null
|
|
|
|
|
? ""
|
2024-07-17 13:58:37 +07:00
|
|
|
: Extension.ToThaiNumber(Extension.ToThaiFullDate3(getDevelopment.reportBackNoDate)),
|
2024-04-13 20:47:28 +07:00
|
|
|
governmentDate:
|
|
|
|
|
getDevelopment.governmentDate == null
|
|
|
|
|
? ""
|
2024-07-17 13:58:37 +07:00
|
|
|
: Extension.ToThaiNumber(Extension.ToThaiFullDate3(getDevelopment.governmentDate)),
|
2024-04-13 20:47:28 +07:00
|
|
|
graduatedDate:
|
|
|
|
|
getDevelopment.graduatedDate == null
|
|
|
|
|
? ""
|
2024-07-17 13:58:37 +07:00
|
|
|
: Extension.ToThaiNumber(Extension.ToThaiFullDate3(getDevelopment.graduatedDate)),
|
2024-09-03 15:18:30 +07:00
|
|
|
graduatedReason: getDevelopment.graduatedReason == null ? "" : getDevelopment.graduatedReason,
|
2024-04-30 11:48:23 +07:00
|
|
|
useOfficialTime: getDevelopment.useOfficialTime,
|
2024-07-17 12:49:07 +07:00
|
|
|
useOffTime: getDevelopment.useOfficialTime == true ? "🗹 ใช้ ☐ ไม่ใช้" : "☐ ใช้ 🗹 ไม่ใช้",
|
2024-05-17 10:05:15 +07:00
|
|
|
isGraduated: getDevelopment.isGraduated,
|
2024-07-17 12:49:07 +07:00
|
|
|
isG1: getDevelopment.isGraduated == true ? "🗹" : "☐",
|
|
|
|
|
isG2: getDevelopment.isGraduated == true ? "☐" : "🗹",
|
2024-07-17 12:47:36 +07:00
|
|
|
totalPeriod:
|
2024-05-17 10:05:15 +07:00
|
|
|
getDevelopment.totalPeriod == null || getDevelopment.totalPeriod == ""
|
2024-07-17 12:47:36 +07:00
|
|
|
? ""
|
|
|
|
|
: Extension.ToThaiNumber(getDevelopment.totalPeriod),
|
2024-04-13 20:47:28 +07:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return new HttpSuccess({
|
|
|
|
|
template: "repatriation",
|
|
|
|
|
reportName: "repatriation",
|
|
|
|
|
data: formattedData,
|
|
|
|
|
});
|
|
|
|
|
}
|
2025-02-11 19:23:29 +07:00
|
|
|
|
|
|
|
|
/**
|
2025-02-11 19:49:41 +07:00
|
|
|
* API Report รายงานข้อมูลข้าราชการกรุงเทพมหานครสามัญที่ได้รับทุนการศึกษา
|
2025-02-11 19:23:29 +07:00
|
|
|
*
|
2025-02-11 19:49:41 +07:00
|
|
|
* @summary DEV_0xx - Report รายงานข้อมูลข้าราชการกรุงเทพมหานครสามัญที่ได้รับทุนการศึกษา #xx
|
2025-02-11 19:23:29 +07:00
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
@Get("report3")
|
2025-02-13 10:28:05 +07:00
|
|
|
async report3(
|
|
|
|
|
@Query("year") year: number,
|
|
|
|
|
@Query("rootId") rootId?: string,
|
|
|
|
|
) {
|
|
|
|
|
const [development, total] = await AppDataSource.getRepository(DevelopmentScholarship)
|
|
|
|
|
.createQueryBuilder("developmentScholarship")
|
|
|
|
|
.leftJoinAndSelect("developmentScholarship.posLevel", "posLevel")
|
|
|
|
|
.leftJoinAndSelect("developmentScholarship.posType", "posType")
|
|
|
|
|
.andWhere(
|
|
|
|
|
year !== 0 && year != null && year != undefined
|
|
|
|
|
? "developmentScholarship.scholarshipYear = :scholarshipYear"
|
|
|
|
|
: "1=1",
|
|
|
|
|
{ scholarshipYear: year },
|
|
|
|
|
)
|
|
|
|
|
.andWhere(
|
|
|
|
|
rootId != "" && rootId != null && rootId != undefined
|
|
|
|
|
? "developmentScholarship.rootId = :rootId"
|
|
|
|
|
: "1=1",
|
|
|
|
|
{ rootId: rootId },
|
|
|
|
|
)
|
|
|
|
|
.orderBy("developmentScholarship.scholarshipYear", "DESC")
|
|
|
|
|
.addOrderBy("developmentScholarship.createdAt", "DESC")
|
|
|
|
|
.getManyAndCount();
|
2025-02-11 19:23:29 +07:00
|
|
|
|
|
|
|
|
return new HttpSuccess({
|
|
|
|
|
template: "reportFund3",
|
|
|
|
|
reportName: "reportFund3",
|
|
|
|
|
data: {
|
2025-02-13 10:28:05 +07:00
|
|
|
year: year ? Extension.ToThaiNumber(year.toString()) : "-",
|
|
|
|
|
root: null,
|
|
|
|
|
developments: development,
|
|
|
|
|
total: total
|
2025-02-11 19:23:29 +07:00
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
/**
|
2025-02-11 19:49:41 +07:00
|
|
|
* API Report รายงานข้อมูลข้าราชการกรุงเทพมหานครสามัญ ที่ส่งไปพัฒนากับหน่วยงานภายนอก
|
2025-02-11 19:23:29 +07:00
|
|
|
*
|
2025-02-11 19:49:41 +07:00
|
|
|
* @summary DEV_0xx - Report รายงานข้อมูลข้าราชการกรุงเทพมหานครสามัญ ที่ส่งไปพัฒนากับหน่วยงานภายนอก #xx
|
2025-02-11 19:23:29 +07:00
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
@Get("report4")
|
|
|
|
|
async report4() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return new HttpSuccess({
|
|
|
|
|
template: "reportFund4",
|
|
|
|
|
reportName: "reportFund4",
|
|
|
|
|
data: {
|
|
|
|
|
data: "",
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
/**
|
2025-02-11 19:49:41 +07:00
|
|
|
* API Report รายงานข้อมูลข้าราชการกรุงเทพมหานครสามัญที่ไปศึกษา ฝึกอบรม ประชุม ดูงาน และปฏิบัติการวิจัย ณ ต่างประเทศ
|
2025-02-11 19:23:29 +07:00
|
|
|
*
|
2025-02-11 19:49:41 +07:00
|
|
|
* @summary DEV_0xx - Report รายงานข้อมูลข้าราชการกรุงเทพมหานครสามัญที่ไปศึกษา ฝึกอบรม ประชุม ดูงาน และปฏิบัติการวิจัย ณ ต่างประเทศ #xx
|
2025-02-11 19:23:29 +07:00
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
@Get("report5")
|
|
|
|
|
async report5() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return new HttpSuccess({
|
|
|
|
|
template: "reportFund5",
|
|
|
|
|
reportName: "reportFund5",
|
|
|
|
|
data: {
|
|
|
|
|
data: "",
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
/**
|
2025-02-11 19:49:41 +07:00
|
|
|
* API Report รายงานสถิติข้อมูลการศึกษาต่อ การฝึกอบรม ศึกษาดูงาน ของข้าราชการกรุงเทพมหานครสามัญ
|
2025-02-11 19:23:29 +07:00
|
|
|
*
|
2025-02-11 19:49:41 +07:00
|
|
|
* @summary DEV_0xx - Report รายงานสถิติข้อมูลการศึกษาต่อ การฝึกอบรม ศึกษาดูงาน ของข้าราชการกรุงเทพมหานครสามัญ #xx
|
2025-02-11 19:23:29 +07:00
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
@Get("report6")
|
|
|
|
|
async report6() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return new HttpSuccess({
|
|
|
|
|
template: "reportFund6",
|
|
|
|
|
reportName: "reportFund6",
|
|
|
|
|
data: {
|
|
|
|
|
data: "",
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2024-04-09 11:38:13 +07:00
|
|
|
}
|
2025-02-11 19:23:29 +07:00
|
|
|
|
|
|
|
|
|