โครงการเพิ่มบันทึกยุทธศาสตร์
This commit is contained in:
parent
650c6fe3e3
commit
be703f8e3b
16 changed files with 930 additions and 84 deletions
|
|
@ -11,7 +11,6 @@ import {
|
|||
Path,
|
||||
Request,
|
||||
Query,
|
||||
Example,
|
||||
} from "tsoa";
|
||||
import { AppDataSource } from "../database/data-source";
|
||||
import { In, Not } from "typeorm";
|
||||
|
|
@ -22,8 +21,6 @@ import {
|
|||
Development,
|
||||
CreateDevelopment,
|
||||
UpdateDevelopment1,
|
||||
UpdateDevelopment2_1,
|
||||
UpdateDevelopment2_2,
|
||||
UpdateDevelopment3,
|
||||
UpdateDevelopment4,
|
||||
UpdateDevelopment5,
|
||||
|
|
@ -45,6 +42,11 @@ import {
|
|||
import { DevelopmentAddress } from "../entities/DevelopmentAddress";
|
||||
import { DevelopmentProjectTechniquePlanned } from "../entities/DevelopmentProjectTechniquePlanned";
|
||||
import { DevelopmentProjectTechniqueActual } from "../entities/DevelopmentProjectTechniqueActual";
|
||||
import { StrategyChild1 } from "../entities/StrategyChild1";
|
||||
import { StrategyChild2 } from "../entities/StrategyChild2";
|
||||
import { StrategyChild3 } from "../entities/StrategyChild3";
|
||||
import { StrategyChild4 } from "../entities/StrategyChild4";
|
||||
import { StrategyChild5 } from "../entities/StrategyChild5";
|
||||
|
||||
@Route("api/v1/development/main")
|
||||
@Tags("Development")
|
||||
|
|
@ -69,6 +71,11 @@ export class DevelopmentController extends Controller {
|
|||
private provinceRepository = AppDataSource.getRepository(Province);
|
||||
private posTypeRepository = AppDataSource.getRepository(PosType);
|
||||
private posLevelRepository = AppDataSource.getRepository(PosLevel);
|
||||
private strategyChild1Repository = AppDataSource.getRepository(StrategyChild1);
|
||||
private strategyChild2Repository = AppDataSource.getRepository(StrategyChild2);
|
||||
private strategyChild3Repository = AppDataSource.getRepository(StrategyChild3);
|
||||
private strategyChild4Repository = AppDataSource.getRepository(StrategyChild4);
|
||||
private strategyChild5Repository = AppDataSource.getRepository(StrategyChild5);
|
||||
|
||||
/**
|
||||
* API เพิ่มโครงการ/หลักสูตรการฝึกอบรม
|
||||
|
|
@ -97,8 +104,188 @@ export class DevelopmentController extends Controller {
|
|||
" มีอยู่ในระบบแล้ว",
|
||||
);
|
||||
}
|
||||
|
||||
let _null: any = null;
|
||||
const development = Object.assign(new Development(), requestBody);
|
||||
switch (requestBody.strategyChildPlannedNode) {
|
||||
case 1: {
|
||||
const checkId = await this.strategyChild1Repository.findOne({
|
||||
where: { id: requestBody.strategyChildPlannedId },
|
||||
});
|
||||
if (!checkId) {
|
||||
throw new HttpError(
|
||||
HttpStatusCode.NOT_FOUND,
|
||||
"ไม่พบข้อมูลยุทธศาสตร์เป้าหมายตามแผนระดับ 1",
|
||||
);
|
||||
}
|
||||
development.strategyChild1PlannedId = checkId.id;
|
||||
development.strategyChild2ActualId = _null;
|
||||
development.strategyChild3ActualId = _null;
|
||||
development.strategyChild4ActualId = _null;
|
||||
development.strategyChild5ActualId = _null;
|
||||
break;
|
||||
}
|
||||
case 2: {
|
||||
const checkId = await this.strategyChild2Repository.findOne({
|
||||
where: { id: requestBody.strategyChildPlannedId },
|
||||
});
|
||||
if (!checkId) {
|
||||
throw new HttpError(
|
||||
HttpStatusCode.NOT_FOUND,
|
||||
"ไม่พบข้อมูลยุทธศาสตร์เป้าหมายตามแผนระดับ 2",
|
||||
);
|
||||
}
|
||||
development.strategyChild1PlannedId = checkId.strategyChild1Id;
|
||||
development.strategyChild2PlannedId = checkId.id;
|
||||
development.strategyChild3ActualId = _null;
|
||||
development.strategyChild4ActualId = _null;
|
||||
development.strategyChild5ActualId = _null;
|
||||
break;
|
||||
}
|
||||
case 3: {
|
||||
const checkId = await this.strategyChild3Repository.findOne({
|
||||
where: { id: requestBody.strategyChildPlannedId },
|
||||
});
|
||||
if (!checkId) {
|
||||
throw new HttpError(
|
||||
HttpStatusCode.NOT_FOUND,
|
||||
"ไม่พบข้อมูลยุทธศาสตร์เป้าหมายตามแผนระดับ 2",
|
||||
);
|
||||
}
|
||||
development.strategyChild1PlannedId = checkId.strategyChild1Id;
|
||||
development.strategyChild2PlannedId = checkId.strategyChild2Id;
|
||||
development.strategyChild3PlannedId = checkId.id;
|
||||
development.strategyChild4ActualId = _null;
|
||||
development.strategyChild5ActualId = _null;
|
||||
break;
|
||||
}
|
||||
case 4: {
|
||||
const checkId = await this.strategyChild4Repository.findOne({
|
||||
where: { id: requestBody.strategyChildPlannedId },
|
||||
});
|
||||
if (!checkId) {
|
||||
throw new HttpError(
|
||||
HttpStatusCode.NOT_FOUND,
|
||||
"ไม่พบข้อมูลยุทธศาสตร์เป้าหมายตามแผนระดับ 3",
|
||||
);
|
||||
}
|
||||
development.strategyChild1PlannedId = checkId.strategyChild1Id;
|
||||
development.strategyChild2PlannedId = checkId.strategyChild2Id;
|
||||
development.strategyChild3PlannedId = checkId.strategyChild3Id;
|
||||
development.strategyChild4PlannedId = checkId.id;
|
||||
development.strategyChild5ActualId = _null;
|
||||
break;
|
||||
}
|
||||
case 5: {
|
||||
const checkId = await this.strategyChild5Repository.findOne({
|
||||
where: { id: requestBody.strategyChildPlannedId },
|
||||
});
|
||||
if (!checkId) {
|
||||
throw new HttpError(
|
||||
HttpStatusCode.NOT_FOUND,
|
||||
"ไม่พบข้อมูลยุทธศาสตร์เป้าหมายตามแผนระดับ 2",
|
||||
);
|
||||
}
|
||||
development.strategyChild1PlannedId = checkId.strategyChild1Id;
|
||||
development.strategyChild2PlannedId = checkId.strategyChild2Id;
|
||||
development.strategyChild3PlannedId = checkId.strategyChild3Id;
|
||||
development.strategyChild4PlannedId = checkId.strategyChild4Id;
|
||||
development.strategyChild5PlannedId = checkId.id;
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลยุทธศาสตร์เป้าหมายตามแผน");
|
||||
}
|
||||
switch (requestBody.strategyChildActualNode) {
|
||||
case 1: {
|
||||
const checkId = await this.strategyChild1Repository.findOne({
|
||||
where: { id: requestBody.strategyChildActualId },
|
||||
});
|
||||
if (!checkId) {
|
||||
throw new HttpError(
|
||||
HttpStatusCode.NOT_FOUND,
|
||||
"ไม่พบข้อมูลยุทธศาสตร์เป้าหมายตามจริงระดับ 1",
|
||||
);
|
||||
}
|
||||
development.strategyChild1ActualId = checkId.id;
|
||||
development.strategyChild2ActualId = _null;
|
||||
development.strategyChild3ActualId = _null;
|
||||
development.strategyChild4ActualId = _null;
|
||||
development.strategyChild5ActualId = _null;
|
||||
break;
|
||||
}
|
||||
case 2: {
|
||||
const checkId = await this.strategyChild2Repository.findOne({
|
||||
where: { id: requestBody.strategyChildActualId },
|
||||
});
|
||||
if (!checkId) {
|
||||
throw new HttpError(
|
||||
HttpStatusCode.NOT_FOUND,
|
||||
"ไม่พบข้อมูลยุทธศาสตร์เป้าหมายตามจริงระดับ 2",
|
||||
);
|
||||
}
|
||||
development.strategyChild1ActualId = checkId.strategyChild1Id;
|
||||
development.strategyChild2ActualId = checkId.id;
|
||||
development.strategyChild3ActualId = _null;
|
||||
development.strategyChild4ActualId = _null;
|
||||
development.strategyChild5ActualId = _null;
|
||||
break;
|
||||
}
|
||||
case 3: {
|
||||
const checkId = await this.strategyChild3Repository.findOne({
|
||||
where: { id: requestBody.strategyChildActualId },
|
||||
});
|
||||
if (!checkId) {
|
||||
throw new HttpError(
|
||||
HttpStatusCode.NOT_FOUND,
|
||||
"ไม่พบข้อมูลยุทธศาสตร์เป้าหมายตามจริงระดับ 3",
|
||||
);
|
||||
}
|
||||
development.strategyChild1ActualId = checkId.strategyChild1Id;
|
||||
development.strategyChild2ActualId = checkId.strategyChild2Id;
|
||||
development.strategyChild3ActualId = checkId.id;
|
||||
development.strategyChild4ActualId = _null;
|
||||
development.strategyChild5ActualId = _null;
|
||||
break;
|
||||
}
|
||||
case 4: {
|
||||
const checkId = await this.strategyChild4Repository.findOne({
|
||||
where: { id: requestBody.strategyChildActualId },
|
||||
});
|
||||
if (!checkId) {
|
||||
throw new HttpError(
|
||||
HttpStatusCode.NOT_FOUND,
|
||||
"ไม่พบข้อมูลยุทธศาสตร์เป้าหมายตามจริงระดับ 4",
|
||||
);
|
||||
}
|
||||
development.strategyChild1ActualId = checkId.strategyChild1Id;
|
||||
development.strategyChild2ActualId = checkId.strategyChild2Id;
|
||||
development.strategyChild3ActualId = checkId.strategyChild3Id;
|
||||
development.strategyChild4ActualId = checkId.id;
|
||||
development.strategyChild5ActualId = _null;
|
||||
break;
|
||||
}
|
||||
case 5: {
|
||||
const checkId = await this.strategyChild5Repository.findOne({
|
||||
where: { id: requestBody.strategyChildActualId },
|
||||
});
|
||||
if (!checkId) {
|
||||
throw new HttpError(
|
||||
HttpStatusCode.NOT_FOUND,
|
||||
"ไม่พบข้อมูลยุทธศาสตร์เป้าหมายตามจริงระดับ 5",
|
||||
);
|
||||
}
|
||||
development.strategyChild1ActualId = checkId.strategyChild1Id;
|
||||
development.strategyChild2ActualId = checkId.strategyChild2Id;
|
||||
development.strategyChild3ActualId = checkId.strategyChild3Id;
|
||||
development.strategyChild4ActualId = checkId.strategyChild4Id;
|
||||
development.strategyChild5ActualId = checkId.id;
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลยุทธศาสตร์เป้าหมายตามจริง");
|
||||
}
|
||||
development.createdUserId = request.user.sub;
|
||||
development.createdFullName = request.user.name;
|
||||
development.lastUpdateUserId = request.user.sub;
|
||||
|
|
@ -143,6 +330,187 @@ export class DevelopmentController extends Controller {
|
|||
" มีอยู่ในระบบแล้ว",
|
||||
);
|
||||
}
|
||||
let _null: any = null;
|
||||
switch (requestBody.strategyChildPlannedNode) {
|
||||
case 1: {
|
||||
const checkId = await this.strategyChild1Repository.findOne({
|
||||
where: { id: requestBody.strategyChildPlannedId },
|
||||
});
|
||||
if (!checkId) {
|
||||
throw new HttpError(
|
||||
HttpStatusCode.NOT_FOUND,
|
||||
"ไม่พบข้อมูลยุทธศาสตร์เป้าหมายตามแผนระดับ 1",
|
||||
);
|
||||
}
|
||||
development.strategyChild1PlannedId = checkId.id;
|
||||
development.strategyChild2ActualId = _null;
|
||||
development.strategyChild3ActualId = _null;
|
||||
development.strategyChild4ActualId = _null;
|
||||
development.strategyChild5ActualId = _null;
|
||||
break;
|
||||
}
|
||||
case 2: {
|
||||
const checkId = await this.strategyChild2Repository.findOne({
|
||||
where: { id: requestBody.strategyChildPlannedId },
|
||||
});
|
||||
if (!checkId) {
|
||||
throw new HttpError(
|
||||
HttpStatusCode.NOT_FOUND,
|
||||
"ไม่พบข้อมูลยุทธศาสตร์เป้าหมายตามแผนระดับ 2",
|
||||
);
|
||||
}
|
||||
development.strategyChild1PlannedId = checkId.strategyChild1Id;
|
||||
development.strategyChild2PlannedId = checkId.id;
|
||||
development.strategyChild3ActualId = _null;
|
||||
development.strategyChild4ActualId = _null;
|
||||
development.strategyChild5ActualId = _null;
|
||||
break;
|
||||
}
|
||||
case 3: {
|
||||
const checkId = await this.strategyChild3Repository.findOne({
|
||||
where: { id: requestBody.strategyChildPlannedId },
|
||||
});
|
||||
if (!checkId) {
|
||||
throw new HttpError(
|
||||
HttpStatusCode.NOT_FOUND,
|
||||
"ไม่พบข้อมูลยุทธศาสตร์เป้าหมายตามแผนระดับ 2",
|
||||
);
|
||||
}
|
||||
development.strategyChild1PlannedId = checkId.strategyChild1Id;
|
||||
development.strategyChild2PlannedId = checkId.strategyChild2Id;
|
||||
development.strategyChild3PlannedId = checkId.id;
|
||||
development.strategyChild4ActualId = _null;
|
||||
development.strategyChild5ActualId = _null;
|
||||
break;
|
||||
}
|
||||
case 4: {
|
||||
const checkId = await this.strategyChild4Repository.findOne({
|
||||
where: { id: requestBody.strategyChildPlannedId },
|
||||
});
|
||||
if (!checkId) {
|
||||
throw new HttpError(
|
||||
HttpStatusCode.NOT_FOUND,
|
||||
"ไม่พบข้อมูลยุทธศาสตร์เป้าหมายตามแผนระดับ 3",
|
||||
);
|
||||
}
|
||||
development.strategyChild1PlannedId = checkId.strategyChild1Id;
|
||||
development.strategyChild2PlannedId = checkId.strategyChild2Id;
|
||||
development.strategyChild3PlannedId = checkId.strategyChild3Id;
|
||||
development.strategyChild4PlannedId = checkId.id;
|
||||
development.strategyChild5ActualId = _null;
|
||||
break;
|
||||
}
|
||||
case 5: {
|
||||
const checkId = await this.strategyChild5Repository.findOne({
|
||||
where: { id: requestBody.strategyChildPlannedId },
|
||||
});
|
||||
if (!checkId) {
|
||||
throw new HttpError(
|
||||
HttpStatusCode.NOT_FOUND,
|
||||
"ไม่พบข้อมูลยุทธศาสตร์เป้าหมายตามแผนระดับ 2",
|
||||
);
|
||||
}
|
||||
development.strategyChild1PlannedId = checkId.strategyChild1Id;
|
||||
development.strategyChild2PlannedId = checkId.strategyChild2Id;
|
||||
development.strategyChild3PlannedId = checkId.strategyChild3Id;
|
||||
development.strategyChild4PlannedId = checkId.strategyChild4Id;
|
||||
development.strategyChild5PlannedId = checkId.id;
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลยุทธศาสตร์เป้าหมายตามแผน");
|
||||
}
|
||||
switch (requestBody.strategyChildActualNode) {
|
||||
case 1: {
|
||||
const checkId = await this.strategyChild1Repository.findOne({
|
||||
where: { id: requestBody.strategyChildActualId },
|
||||
});
|
||||
if (!checkId) {
|
||||
throw new HttpError(
|
||||
HttpStatusCode.NOT_FOUND,
|
||||
"ไม่พบข้อมูลยุทธศาสตร์เป้าหมายตามจริงระดับ 1",
|
||||
);
|
||||
}
|
||||
development.strategyChild1ActualId = checkId.id;
|
||||
development.strategyChild2ActualId = _null;
|
||||
development.strategyChild3ActualId = _null;
|
||||
development.strategyChild4ActualId = _null;
|
||||
development.strategyChild5ActualId = _null;
|
||||
break;
|
||||
}
|
||||
case 2: {
|
||||
const checkId = await this.strategyChild2Repository.findOne({
|
||||
where: { id: requestBody.strategyChildActualId },
|
||||
});
|
||||
if (!checkId) {
|
||||
throw new HttpError(
|
||||
HttpStatusCode.NOT_FOUND,
|
||||
"ไม่พบข้อมูลยุทธศาสตร์เป้าหมายตามจริงระดับ 2",
|
||||
);
|
||||
}
|
||||
development.strategyChild1ActualId = checkId.strategyChild1Id;
|
||||
development.strategyChild2ActualId = checkId.id;
|
||||
development.strategyChild3ActualId = _null;
|
||||
development.strategyChild4ActualId = _null;
|
||||
development.strategyChild5ActualId = _null;
|
||||
break;
|
||||
}
|
||||
case 3: {
|
||||
const checkId = await this.strategyChild3Repository.findOne({
|
||||
where: { id: requestBody.strategyChildActualId },
|
||||
});
|
||||
if (!checkId) {
|
||||
throw new HttpError(
|
||||
HttpStatusCode.NOT_FOUND,
|
||||
"ไม่พบข้อมูลยุทธศาสตร์เป้าหมายตามจริงระดับ 3",
|
||||
);
|
||||
}
|
||||
development.strategyChild1ActualId = checkId.strategyChild1Id;
|
||||
development.strategyChild2ActualId = checkId.strategyChild2Id;
|
||||
development.strategyChild3ActualId = checkId.id;
|
||||
development.strategyChild4ActualId = _null;
|
||||
development.strategyChild5ActualId = _null;
|
||||
break;
|
||||
}
|
||||
case 4: {
|
||||
const checkId = await this.strategyChild4Repository.findOne({
|
||||
where: { id: requestBody.strategyChildActualId },
|
||||
});
|
||||
if (!checkId) {
|
||||
throw new HttpError(
|
||||
HttpStatusCode.NOT_FOUND,
|
||||
"ไม่พบข้อมูลยุทธศาสตร์เป้าหมายตามจริงระดับ 4",
|
||||
);
|
||||
}
|
||||
development.strategyChild1ActualId = checkId.strategyChild1Id;
|
||||
development.strategyChild2ActualId = checkId.strategyChild2Id;
|
||||
development.strategyChild3ActualId = checkId.strategyChild3Id;
|
||||
development.strategyChild4ActualId = checkId.id;
|
||||
development.strategyChild5ActualId = _null;
|
||||
break;
|
||||
}
|
||||
case 5: {
|
||||
const checkId = await this.strategyChild5Repository.findOne({
|
||||
where: { id: requestBody.strategyChildActualId },
|
||||
});
|
||||
if (!checkId) {
|
||||
throw new HttpError(
|
||||
HttpStatusCode.NOT_FOUND,
|
||||
"ไม่พบข้อมูลยุทธศาสตร์เป้าหมายตามจริงระดับ 5",
|
||||
);
|
||||
}
|
||||
development.strategyChild1ActualId = checkId.strategyChild1Id;
|
||||
development.strategyChild2ActualId = checkId.strategyChild2Id;
|
||||
development.strategyChild3ActualId = checkId.strategyChild3Id;
|
||||
development.strategyChild4ActualId = checkId.strategyChild4Id;
|
||||
development.strategyChild5ActualId = checkId.id;
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลยุทธศาสตร์เป้าหมายตามจริง");
|
||||
}
|
||||
Object.assign(development, requestBody);
|
||||
development.lastUpdateUserId = request.user.sub;
|
||||
development.lastUpdateFullName = request.user.name;
|
||||
|
|
@ -988,6 +1356,16 @@ export class DevelopmentController extends Controller {
|
|||
"rootId",
|
||||
"orgRootShortName",
|
||||
"orgRevisionId",
|
||||
"strategyChild1Planned",
|
||||
"strategyChild2Planned",
|
||||
"strategyChild3Planned",
|
||||
"strategyChild4Planned",
|
||||
"strategyChild5Planned",
|
||||
"strategyChild1Actual",
|
||||
"strategyChild2Actual",
|
||||
"strategyChild3Actual",
|
||||
"strategyChild4Actual",
|
||||
"strategyChild5Actual",
|
||||
],
|
||||
});
|
||||
if (!getDevelopment) {
|
||||
|
|
@ -1191,31 +1569,37 @@ export class DevelopmentController extends Controller {
|
|||
*/
|
||||
@Get("tab6/{id}")
|
||||
async GetDevelopemtTab6ById(@Path() id: string) {
|
||||
const getDevelopment = await this.developmentRepository.findOne({
|
||||
where: { id: id },
|
||||
relations: [
|
||||
"developmentActualPeoples",
|
||||
"developmentPlannedPeoples",
|
||||
"developmentActualGoals",
|
||||
"developmentPlannedGoals",
|
||||
"developmentPlannedGoals.plannedGoalPositions",
|
||||
"provinces",
|
||||
// "provinces.developmentProvinces",
|
||||
],
|
||||
const getDevelopment = await this.developmentHistoryRepository.find({
|
||||
where: { developmentId: id },
|
||||
relations: ["posLevel", "posType", "employeePosLevel", "employeePosType"],
|
||||
});
|
||||
if (!getDevelopment) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลโครงการ/หลักสูตรการฝึกอบรมนี้");
|
||||
}
|
||||
let _getDevelopment: any = getDevelopment;
|
||||
_getDevelopment.actualPeoples = getDevelopment.developmentActualPeoples;
|
||||
_getDevelopment.plannedPeoples = getDevelopment.developmentPlannedPeoples;
|
||||
_getDevelopment.actualGoals = getDevelopment.developmentActualGoals;
|
||||
_getDevelopment.plannedGoals = getDevelopment.developmentPlannedGoals;
|
||||
// _getDevelopment.provinces = getDevelopment.provinces.map(x=>x.developmentProvinces);
|
||||
delete _getDevelopment.developmentActualPeoples;
|
||||
delete _getDevelopment.developmentPlannedPeoples;
|
||||
delete _getDevelopment.developmentActualGoals;
|
||||
delete _getDevelopment.developmentPlannedGoals;
|
||||
const _getDevelopment = getDevelopment.map((item) => ({
|
||||
id: item.id,
|
||||
citizenId: item.citizenId,
|
||||
fullName: item.prefix + item.firstName + " " + item.lastName,
|
||||
position: item.position,
|
||||
posType:
|
||||
item.type == "OFFICER"
|
||||
? item.posType
|
||||
? item.posType.posTypeName
|
||||
: null
|
||||
: item.employeePosType
|
||||
? item.employeePosType.posTypeName
|
||||
: null,
|
||||
posLevel:
|
||||
item.type == "OFFICER"
|
||||
? item.posLevel
|
||||
? item.posLevel.posLevelName
|
||||
: null
|
||||
: item.employeePosLevel
|
||||
? item.employeePosLevel.posLevelName
|
||||
: null,
|
||||
posExecutive: item.posExecutive,
|
||||
root: item.root,
|
||||
order: item.order,
|
||||
dateOrder: item.dateOrder,
|
||||
isDone: item.isDone,
|
||||
}));
|
||||
return new HttpSuccess(_getDevelopment);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -185,6 +185,7 @@ export class DevelopmentOfficerHistoryController extends Controller {
|
|||
@Query("pageSize") pageSize: number = 10,
|
||||
@Query("keyword") keyword?: string,
|
||||
@Query("year") year?: number,
|
||||
@Query("root") root?: number,
|
||||
) {
|
||||
const type = "OFFICER";
|
||||
const [development, total] = await AppDataSource.getRepository(DevelopmentHistory)
|
||||
|
|
@ -192,14 +193,18 @@ export class DevelopmentOfficerHistoryController extends Controller {
|
|||
.leftJoinAndSelect("developmentHistory.development", "development")
|
||||
.leftJoinAndSelect("developmentHistory.posLevel", "posLevel")
|
||||
.leftJoinAndSelect("developmentHistory.posType", "posType")
|
||||
.andWhere(year != 0 && year != null && year != undefined ? "development.year = :year" : "1=1", { year: year })
|
||||
.andWhere(
|
||||
year != 0 && year != null && year != undefined ? "development.year = :year" : "1=1",
|
||||
{ year: year },
|
||||
)
|
||||
.andWhere(root != null && root != undefined ? "development.root = :root" : "1=1", {
|
||||
root: root,
|
||||
})
|
||||
.andWhere("developmentHistory.type = :type", { type: type })
|
||||
.andWhere(
|
||||
new Brackets((qb) => {
|
||||
qb.where(
|
||||
keyword != null && keyword != ""
|
||||
? "developmentHistory.prefix LIKE :keyword"
|
||||
: "1=1",
|
||||
keyword != null && keyword != "" ? "developmentHistory.prefix LIKE :keyword" : "1=1",
|
||||
{
|
||||
keyword: `%${keyword}%`,
|
||||
},
|
||||
|
|
@ -237,25 +242,19 @@ export class DevelopmentOfficerHistoryController extends Controller {
|
|||
},
|
||||
)
|
||||
.orWhere(
|
||||
keyword != null && keyword != ""
|
||||
? "development.projectName LIKE :keyword"
|
||||
: "1=1",
|
||||
keyword != null && keyword != "" ? "development.projectName LIKE :keyword" : "1=1",
|
||||
{
|
||||
keyword: `%${keyword}%`,
|
||||
},
|
||||
)
|
||||
.orWhere(
|
||||
keyword != null && keyword != ""
|
||||
? "posType.posTypeName LIKE :keyword"
|
||||
: "1=1",
|
||||
keyword != null && keyword != "" ? "posType.posTypeName LIKE :keyword" : "1=1",
|
||||
{
|
||||
keyword: `%${keyword}%`,
|
||||
},
|
||||
)
|
||||
.orWhere(
|
||||
keyword != null && keyword != ""
|
||||
? "posLevel.posLevelName LIKE :keyword"
|
||||
: "1=1",
|
||||
keyword != null && keyword != "" ? "posLevel.posLevelName LIKE :keyword" : "1=1",
|
||||
{
|
||||
keyword: `%${keyword}%`,
|
||||
},
|
||||
|
|
@ -266,10 +265,10 @@ export class DevelopmentOfficerHistoryController extends Controller {
|
|||
.skip((page - 1) * pageSize)
|
||||
.take(pageSize)
|
||||
.getManyAndCount();
|
||||
const formattedData = development.map(item => ({
|
||||
const formattedData = development.map((item) => ({
|
||||
id: item.id,
|
||||
citizenId: item.citizenId,
|
||||
fullName: item.prefix+item.firstName+" "+item.lastName,
|
||||
fullName: item.prefix + item.firstName + " " + item.lastName,
|
||||
position: item.position,
|
||||
posType: item.posType ? item.posType.posTypeName : null,
|
||||
posLevel: item.posLevel ? item.posLevel.posLevelName : null,
|
||||
|
|
@ -287,11 +286,11 @@ export class DevelopmentOfficerHistoryController extends Controller {
|
|||
*
|
||||
* @param {string} id Id โครงการ
|
||||
*/
|
||||
@Get("{id}")
|
||||
@Get("{id}")
|
||||
async GetDevelopemtHistoryById(@Path() id: string) {
|
||||
const type = "OFFICER";
|
||||
const getDevelopment = await this.developmentHistoryRepository.findOne({
|
||||
relations: ["development","posLevel","posType"],
|
||||
relations: ["development", "posLevel", "posType"],
|
||||
where: { id: id, type: type },
|
||||
});
|
||||
if (!getDevelopment) {
|
||||
|
|
@ -306,7 +305,9 @@ export class DevelopmentOfficerHistoryController extends Controller {
|
|||
citizenId: getDevelopment.citizenId ? getDevelopment.citizenId : null,
|
||||
position: getDevelopment.position ? getDevelopment.position : null,
|
||||
posLevelId: getDevelopment.posLevelId ? getDevelopment.posLevelId : null,
|
||||
posLevelName: getDevelopment.posLevel.posLevelName ? getDevelopment.posLevel.posLevelName : null,
|
||||
posLevelName: getDevelopment.posLevel.posLevelName
|
||||
? getDevelopment.posLevel.posLevelName
|
||||
: null,
|
||||
posTypeId: getDevelopment.posTypeId ? getDevelopment.posTypeId : null,
|
||||
posTypeName: getDevelopment.posType.posTypeName ? getDevelopment.posType.posTypeName : null,
|
||||
posExecutive: getDevelopment.posExecutive ? getDevelopment.posExecutive : null,
|
||||
|
|
@ -314,17 +315,27 @@ export class DevelopmentOfficerHistoryController extends Controller {
|
|||
order: getDevelopment.order ? getDevelopment.order : null,
|
||||
dateOrder: getDevelopment.dateOrder ? getDevelopment.dateOrder : null,
|
||||
year: getDevelopment.development.year ? getDevelopment.development.year : null,
|
||||
projectName: getDevelopment.development.projectName ? getDevelopment.development.projectName : null,
|
||||
projectName: getDevelopment.development.projectName
|
||||
? getDevelopment.development.projectName
|
||||
: null,
|
||||
dateStart: getDevelopment.development.dateStart ? getDevelopment.development.dateStart : null,
|
||||
dateEnd: getDevelopment.development.dateEnd ? getDevelopment.development.dateEnd : null,
|
||||
totalDate: getDevelopment.development.totalDate ? getDevelopment.development.totalDate : null,
|
||||
addressAcademic: getDevelopment.development.addressAcademic ? getDevelopment.development.addressAcademic : null,
|
||||
topicAcademic: getDevelopment.development.topicAcademic ? getDevelopment.development.topicAcademic : null,
|
||||
dateStudyStart: getDevelopment.development.dateStudyStart ? getDevelopment.development.dateStudyStart : null,
|
||||
dateStudyEnd: getDevelopment.development.dateStudyEnd ? getDevelopment.development.dateStudyEnd : null,
|
||||
addressAcademic: getDevelopment.development.addressAcademic
|
||||
? getDevelopment.development.addressAcademic
|
||||
: null,
|
||||
topicAcademic: getDevelopment.development.topicAcademic
|
||||
? getDevelopment.development.topicAcademic
|
||||
: null,
|
||||
dateStudyStart: getDevelopment.development.dateStudyStart
|
||||
? getDevelopment.development.dateStudyStart
|
||||
: null,
|
||||
dateStudyEnd: getDevelopment.development.dateStudyEnd
|
||||
? getDevelopment.development.dateStudyEnd
|
||||
: null,
|
||||
org: null,
|
||||
};
|
||||
|
||||
|
||||
return new HttpSuccess(formattedData);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -238,6 +238,7 @@ export class DevelopmentScholarshipController extends Controller {
|
|||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลทุนการศึกษา/ฝึกอบรมนี้");
|
||||
}
|
||||
const formattedData = {
|
||||
root: getDevelopment.root ? getDevelopment.root : null,
|
||||
rank: getDevelopment.rank ? getDevelopment.rank : null,
|
||||
prefix: getDevelopment.prefix ? getDevelopment.prefix : null,
|
||||
firstName: getDevelopment.firstName ? getDevelopment.firstName : null,
|
||||
|
|
@ -364,6 +365,7 @@ export class DevelopmentScholarshipController extends Controller {
|
|||
"graduatedDate",
|
||||
"isNoGraduated",
|
||||
"graduatedReason",
|
||||
"root",
|
||||
],
|
||||
});
|
||||
if (!getDevelopment) {
|
||||
|
|
|
|||
|
|
@ -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