โครงการเพิ่มบันทึกยุทธศาสตร์

This commit is contained in:
Kittapath 2024-04-13 20:47:28 +07:00
parent 650c6fe3e3
commit be703f8e3b
16 changed files with 930 additions and 84 deletions

View file

@ -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);
}

View file

@ -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);
}
}

View file

@ -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) {

View file

@ -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,
});
}
}

View file

@ -11,6 +11,11 @@ import { DevelopmentProjectTechniquePlanned } from "./DevelopmentProjectTechniqu
import { CreateDevelopmentEvaluation, DevelopmentEvaluation } from "./DevelopmentEvaluation";
import { CreateDevelopmentAddress, DevelopmentAddress } from "./DevelopmentAddress";
import { DevelopmentProjectTechniqueActual } from "./DevelopmentProjectTechniqueActual";
import { StrategyChild5 } from "./StrategyChild5";
import { StrategyChild4 } from "./StrategyChild4";
import { StrategyChild3 } from "./StrategyChild3";
import { StrategyChild2 } from "./StrategyChild2";
import { StrategyChild1 } from "./StrategyChild1";
@Entity("development")
export class Development extends EntityBase {
@ -402,6 +407,116 @@ export class Development extends EntityBase {
(developmentHistory: DevelopmentHistory) => developmentHistory.development,
)
developmentHistorys: DevelopmentHistory[];
@Column({
nullable: true,
length: 40,
comment: "คีย์นอก(FK)ของตาราง strategyChild1 เป้าหมายตามแผน",
default: null,
})
strategyChild1PlannedId: string;
@ManyToOne(() => StrategyChild1, (strategyChild1) => strategyChild1.developmentPlanneds)
@JoinColumn({ name: "strategyChild1PlannedId" })
strategyChild1Planned: StrategyChild1;
@Column({
nullable: true,
length: 40,
comment: "คีย์นอก(FK)ของตาราง strategyChild2 เป้าหมายตามแผน",
default: null,
})
strategyChild2PlannedId: string;
@ManyToOne(() => StrategyChild2, (strategyChild2) => strategyChild2.developmentPlanneds)
@JoinColumn({ name: "strategyChild2PlannedId" })
strategyChild2Planned: StrategyChild2;
@Column({
nullable: true,
length: 40,
comment: "คีย์นอก(FK)ของตาราง strategyChild3 เป้าหมายตามแผน",
default: null,
})
strategyChild3PlannedId: string;
@ManyToOne(() => StrategyChild3, (strategyChild3) => strategyChild3.developmentPlanneds)
@JoinColumn({ name: "strategyChild3PlannedId" })
strategyChild3Planned: StrategyChild3;
@Column({
nullable: true,
length: 40,
comment: "คีย์นอก(FK)ของตาราง strategyChild4 เป้าหมายตามแผน",
default: null,
})
strategyChild4PlannedId: string;
@ManyToOne(() => StrategyChild4, (strategyChild4) => strategyChild4.developmentPlanneds)
@JoinColumn({ name: "strategyChild4PlannedId" })
strategyChild4Planned: StrategyChild4;
@Column({
nullable: true,
length: 40,
comment: "คีย์นอก(FK)ของตาราง strategyChild5 เป้าหมายตามแผน",
default: null,
})
strategyChild5PlannedId: string;
@ManyToOne(() => StrategyChild5, (strategyChild5) => strategyChild5.developmentPlanneds)
@JoinColumn({ name: "strategyChild5PlannedId" })
strategyChild5Planned: StrategyChild5;
@Column({
nullable: true,
length: 40,
comment: "คีย์นอก(FK)ของตาราง strategyChild1 เป้าหมายตามจริง",
default: null,
})
strategyChild1ActualId: string;
@ManyToOne(() => StrategyChild1, (strategyChild1) => strategyChild1.developmentActuals)
@JoinColumn({ name: "strategyChild1ActualId" })
strategyChild1Actual: StrategyChild1;
@Column({
nullable: true,
length: 40,
comment: "คีย์นอก(FK)ของตาราง strategyChild2 เป้าหมายตามจริง",
default: null,
})
strategyChild2ActualId: string;
@ManyToOne(() => StrategyChild2, (strategyChild2) => strategyChild2.developmentActuals)
@JoinColumn({ name: "strategyChild2ActualId" })
strategyChild2Actual: StrategyChild2;
@Column({
nullable: true,
length: 40,
comment: "คีย์นอก(FK)ของตาราง strategyChild3 เป้าหมายตามจริง",
default: null,
})
strategyChild3ActualId: string;
@ManyToOne(() => StrategyChild3, (strategyChild3) => strategyChild3.developmentActuals)
@JoinColumn({ name: "strategyChild3ActualId" })
strategyChild3Actual: StrategyChild3;
@Column({
nullable: true,
length: 40,
comment: "คีย์นอก(FK)ของตาราง strategyChild4 เป้าหมายตามจริง",
default: null,
})
strategyChild4ActualId: string;
@ManyToOne(() => StrategyChild4, (strategyChild4) => strategyChild4.developmentActuals)
@JoinColumn({ name: "strategyChild4ActualId" })
strategyChild4Actual: StrategyChild4;
@Column({
nullable: true,
length: 40,
comment: "คีย์นอก(FK)ของตาราง strategyChild5 เป้าหมายตามจริง",
default: null,
})
strategyChild5ActualId: string;
@ManyToOne(() => StrategyChild5, (strategyChild5) => strategyChild5.developmentActuals)
@JoinColumn({ name: "strategyChild5ActualId" })
strategyChild5Actual: StrategyChild5;
}
export class CreateDevelopment {
@Column()
@ -416,6 +531,14 @@ export class CreateDevelopment {
orgRootShortName: string;
@Column()
orgRevisionId: string;
@Column()
strategyChildPlannedId: string;
@Column()
strategyChildPlannedNode: number;
@Column()
strategyChildActualId: string;
@Column()
strategyChildActualNode: number;
}
export class UpdateDevelopment1 {
@ -435,6 +558,14 @@ export class UpdateDevelopment1 {
orgRootShortName: string;
@Column()
orgRevisionId: string;
@Column()
strategyChildPlannedId: string;
@Column()
strategyChildPlannedNode: number;
@Column()
strategyChildActualId: string;
@Column()
strategyChildActualNode: number;
}
export class UpdateDevelopment2_1 {
@Column()

View file

@ -8,6 +8,34 @@ import { EmployeePosLevel } from "./EmployeePosLevel";
@Entity("developmentHistory")
export class DevelopmentHistory extends EntityBase {
@Column({
nullable: true,
comment: "id หน่วยงาน",
default: null,
})
rootId: string;
@Column({
nullable: true,
comment: "ชื่อหน่วยงาน",
default: null,
})
root: string;
@Column({
nullable: true,
comment: "ชื่อย่ิหน่วยงาน",
default: null,
})
orgRootShortName: string;
@Column({
nullable: true,
comment: "id revision",
default: null,
})
orgRevisionId: string;
@Column({
nullable: true,
comment: "ประเภทราชการ",
@ -142,6 +170,12 @@ export class DevelopmentHistory extends EntityBase {
default: null,
})
dateOrder: Date;
@Column({
comment: "บันทึกลงทะเบียนประวัติ",
default: false,
})
isDone: boolean;
}
export class CreateDevelopmentHistory {
@Column()

View file

@ -5,6 +5,34 @@ import { PosType } from "./PosType";
@Entity("developmentScholarship")
export class DevelopmentScholarship extends EntityBase {
@Column({
nullable: true,
comment: "id หน่วยงาน",
default: null,
})
rootId: string;
@Column({
nullable: true,
comment: "ชื่อหน่วยงาน",
default: null,
})
root: string;
@Column({
nullable: true,
comment: "ชื่อย่อหน่วยงาน",
default: null,
})
orgRootShortName: string;
@Column({
nullable: true,
comment: "id revision",
default: null,
})
orgRevisionId: string;
@Column({
nullable: true,
comment: "id profile",
@ -213,7 +241,7 @@ export class DevelopmentScholarship extends EntityBase {
@Column({
nullable: true,
type: "date",
type: "datetime",
comment: "ลงวันที่(หนังสือ)",
default: null,
})
@ -221,7 +249,7 @@ export class DevelopmentScholarship extends EntityBase {
@Column({
nullable: true,
type: "date",
type: "datetime",
comment: "หนังสืออนุมัติเมื่อวันที่",
default: null,
})
@ -272,7 +300,7 @@ export class DevelopmentScholarship extends EntityBase {
@Column({
nullable: true,
type: "date",
type: "datetime",
comment: "ลงวันที่(เลขที่สัญญา)",
default: null,
})
@ -288,7 +316,7 @@ export class DevelopmentScholarship extends EntityBase {
@Column({
nullable: true,
type: "date",
type: "datetime",
comment: "ลงวันที่(เลขที่หนังสือรายงานตัวกลับ)",
default: null,
})
@ -296,7 +324,7 @@ export class DevelopmentScholarship extends EntityBase {
@Column({
nullable: true,
type: "date",
type: "datetime",
comment: "รายงานตัวกลับวันที่",
default: null,
})
@ -482,6 +510,10 @@ export class DevelopmentScholarship extends EntityBase {
graduatedReason: string;
}
export class CreateDevelopmentScholarship {
rootId: string | null;
root: string | null;
orgRootShortName: string | null;
orgRevisionId: string | null;
profileId: string | null;
rank?: string | null;
prefix: string | null;
@ -537,6 +569,10 @@ export class CreateDevelopmentScholarship {
}
export class UpdateDevelopmentScholarship {
rootId: string | null;
root: string | null;
orgRootShortName: string | null;
orgRevisionId: string | null;
profileId: string | null;
rank?: string | null;
prefix: string | null;

View file

@ -4,7 +4,7 @@ import { StrategyChild2 } from "./StrategyChild2";
import { StrategyChild3 } from "./StrategyChild3";
import { StrategyChild4 } from "./StrategyChild4";
import { StrategyChild5 } from "./StrategyChild5";
import { Development } from "./Development";
@Entity("strategyChild1")
export class StrategyChild1 extends EntityBase {
@ -28,6 +28,10 @@ export class StrategyChild1 extends EntityBase {
@OneToMany(() => StrategyChild5, (strategyChild5) => strategyChild5.strategyChild1)
strategyChild5s: StrategyChild5[];
@OneToMany(() => Development, (development) => development.strategyChild1Planned)
developmentPlanneds: Development[];
@OneToMany(() => Development, (development) => development.strategyChild1Actual)
developmentActuals: Development[];
}
export class CreateStrategyChild1 {

View file

@ -4,7 +4,7 @@ import { StrategyChild1 } from "./StrategyChild1";
import { StrategyChild3 } from "./StrategyChild3";
import { StrategyChild4 } from "./StrategyChild4";
import { StrategyChild5 } from "./StrategyChild5";
import { Development } from "./Development";
@Entity("strategyChild2")
export class StrategyChild2 extends EntityBase {
@ -21,7 +21,7 @@ export class StrategyChild2 extends EntityBase {
comment: "คีย์นอก(FK)ของตาราง strategyChild1",
})
strategyChild1Id: string;
@ManyToOne(() => StrategyChild1, (strategyChild1) => strategyChild1.strategyChild2s)
@JoinColumn({ name: "strategyChild1Id" })
strategyChild1: StrategyChild1;
@ -35,9 +35,11 @@ export class StrategyChild2 extends EntityBase {
@OneToMany(() => StrategyChild5, (strategyChild5) => strategyChild5.strategyChild2)
strategyChild5s: StrategyChild5[];
}
@OneToMany(() => Development, (development) => development.strategyChild2Planned)
developmentPlanneds: Development[];
@OneToMany(() => Development, (development) => development.strategyChild2Actual)
developmentActuals: Development[];
}
export class CreateStrategyChild2 {
@Column()

View file

@ -4,7 +4,7 @@ import { StrategyChild1 } from "./StrategyChild1";
import { StrategyChild2 } from "./StrategyChild2";
import { StrategyChild4 } from "./StrategyChild4";
import { StrategyChild5 } from "./StrategyChild5";
import { Development } from "./Development";
@Entity("strategyChild3")
export class StrategyChild3 extends EntityBase {
@ -42,12 +42,16 @@ export class StrategyChild3 extends EntityBase {
@OneToMany(() => StrategyChild5, (strategyChild5) => strategyChild5.strategyChild3)
strategyChild5s: StrategyChild5[];
}
@OneToMany(() => Development, (development) => development.strategyChild3Planned)
developmentPlanneds: Development[];
@OneToMany(() => Development, (development) => development.strategyChild3Actual)
developmentActuals: Development[];
}
export class CreateStrategyChild3 {
@Column()
strategyChild3Name: string;
@Column("uuid")
strategyChild2Id: string;
}

View file

@ -4,7 +4,7 @@ import { StrategyChild1 } from "./StrategyChild1";
import { StrategyChild2 } from "./StrategyChild2";
import { StrategyChild3 } from "./StrategyChild3";
import { StrategyChild5 } from "./StrategyChild5";
import { Development } from "./Development";
@Entity("strategyChild4")
export class StrategyChild4 extends EntityBase {
@ -48,8 +48,12 @@ export class StrategyChild4 extends EntityBase {
@OneToMany(() => StrategyChild5, (strategyChild5) => strategyChild5.strategyChild4)
strategyChild5s: StrategyChild5[];
}
@OneToMany(() => Development, (development) => development.strategyChild4Planned)
developmentPlanneds: Development[];
@OneToMany(() => Development, (development) => development.strategyChild4Actual)
developmentActuals: Development[];
}
export class CreateStrategyChild4 {
@Column()

View file

@ -4,7 +4,7 @@ import { StrategyChild1 } from "./StrategyChild1";
import { StrategyChild2 } from "./StrategyChild2";
import { StrategyChild3 } from "./StrategyChild3";
import { StrategyChild4 } from "./StrategyChild4";
import { Development } from "./Development";
@Entity("strategyChild5")
export class StrategyChild5 extends EntityBase {
@ -56,8 +56,11 @@ export class StrategyChild5 extends EntityBase {
@JoinColumn({ name: "strategyChild4Id" })
strategyChild4: StrategyChild4;
}
@OneToMany(() => Development, (development) => development.strategyChild5Planned)
developmentPlanneds: Development[];
@OneToMany(() => Development, (development) => development.strategyChild5Actual)
developmentActuals: Development[];
}
export class CreateStrategyChild5 {
@Column()

View file

@ -0,0 +1,52 @@
import { MigrationInterface, QueryRunner } from "typeorm";
export class UpdateTableDevelopmentAddStrategyChild1712927871127 implements MigrationInterface {
name = 'UpdateTableDevelopmentAddStrategyChild1712927871127'
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`development\` ADD \`strategyChild1PlannedId\` varchar(40) NULL COMMENT 'คีย์นอก(FK)ของตาราง strategyChild1 เป้าหมายตามแผน'`);
await queryRunner.query(`ALTER TABLE \`development\` ADD \`strategyChild2PlannedId\` varchar(40) NULL COMMENT 'คีย์นอก(FK)ของตาราง strategyChild2 เป้าหมายตามแผน'`);
await queryRunner.query(`ALTER TABLE \`development\` ADD \`strategyChild3PlannedId\` varchar(40) NULL COMMENT 'คีย์นอก(FK)ของตาราง strategyChild3 เป้าหมายตามแผน'`);
await queryRunner.query(`ALTER TABLE \`development\` ADD \`strategyChild4PlannedId\` varchar(40) NULL COMMENT 'คีย์นอก(FK)ของตาราง strategyChild4 เป้าหมายตามแผน'`);
await queryRunner.query(`ALTER TABLE \`development\` ADD \`strategyChild5PlannedId\` varchar(40) NULL COMMENT 'คีย์นอก(FK)ของตาราง strategyChild5 เป้าหมายตามแผน'`);
await queryRunner.query(`ALTER TABLE \`development\` ADD \`strategyChild1ActualId\` varchar(40) NULL COMMENT 'คีย์นอก(FK)ของตาราง strategyChild1 เป้าหมายตามจริง'`);
await queryRunner.query(`ALTER TABLE \`development\` ADD \`strategyChild2ActualId\` varchar(40) NULL COMMENT 'คีย์นอก(FK)ของตาราง strategyChild2 เป้าหมายตามจริง'`);
await queryRunner.query(`ALTER TABLE \`development\` ADD \`strategyChild3ActualId\` varchar(40) NULL COMMENT 'คีย์นอก(FK)ของตาราง strategyChild3 เป้าหมายตามจริง'`);
await queryRunner.query(`ALTER TABLE \`development\` ADD \`strategyChild4ActualId\` varchar(40) NULL COMMENT 'คีย์นอก(FK)ของตาราง strategyChild4 เป้าหมายตามจริง'`);
await queryRunner.query(`ALTER TABLE \`development\` ADD \`strategyChild5ActualId\` varchar(40) NULL COMMENT 'คีย์นอก(FK)ของตาราง strategyChild5 เป้าหมายตามจริง'`);
await queryRunner.query(`ALTER TABLE \`development\` ADD CONSTRAINT \`FK_10ff41d23b977cf8dce92e9b167\` FOREIGN KEY (\`strategyChild1PlannedId\`) REFERENCES \`strategyChild1\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
await queryRunner.query(`ALTER TABLE \`development\` ADD CONSTRAINT \`FK_593bc4c0cda43a2bee2928bda49\` FOREIGN KEY (\`strategyChild2PlannedId\`) REFERENCES \`strategyChild2\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
await queryRunner.query(`ALTER TABLE \`development\` ADD CONSTRAINT \`FK_231ce173640401d258c977aae79\` FOREIGN KEY (\`strategyChild3PlannedId\`) REFERENCES \`strategyChild3\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
await queryRunner.query(`ALTER TABLE \`development\` ADD CONSTRAINT \`FK_44fb0c37a11d7ad9b8ca98aaa08\` FOREIGN KEY (\`strategyChild4PlannedId\`) REFERENCES \`strategyChild4\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
await queryRunner.query(`ALTER TABLE \`development\` ADD CONSTRAINT \`FK_4cd86d57223a295e6de3c42cb61\` FOREIGN KEY (\`strategyChild5PlannedId\`) REFERENCES \`strategyChild5\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
await queryRunner.query(`ALTER TABLE \`development\` ADD CONSTRAINT \`FK_a54d96cd5fda35d92815f7f65eb\` FOREIGN KEY (\`strategyChild1ActualId\`) REFERENCES \`strategyChild1\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
await queryRunner.query(`ALTER TABLE \`development\` ADD CONSTRAINT \`FK_8a8b6b92dfd3f78d012300524df\` FOREIGN KEY (\`strategyChild2ActualId\`) REFERENCES \`strategyChild2\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
await queryRunner.query(`ALTER TABLE \`development\` ADD CONSTRAINT \`FK_9ee4f1c6a2f2c86760da928f01a\` FOREIGN KEY (\`strategyChild3ActualId\`) REFERENCES \`strategyChild3\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
await queryRunner.query(`ALTER TABLE \`development\` ADD CONSTRAINT \`FK_adf3d238b02f5806c9ed1e9b90b\` FOREIGN KEY (\`strategyChild4ActualId\`) REFERENCES \`strategyChild4\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
await queryRunner.query(`ALTER TABLE \`development\` ADD CONSTRAINT \`FK_f078e198298457e517c8d90e337\` FOREIGN KEY (\`strategyChild5ActualId\`) REFERENCES \`strategyChild5\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`development\` DROP FOREIGN KEY \`FK_f078e198298457e517c8d90e337\``);
await queryRunner.query(`ALTER TABLE \`development\` DROP FOREIGN KEY \`FK_adf3d238b02f5806c9ed1e9b90b\``);
await queryRunner.query(`ALTER TABLE \`development\` DROP FOREIGN KEY \`FK_9ee4f1c6a2f2c86760da928f01a\``);
await queryRunner.query(`ALTER TABLE \`development\` DROP FOREIGN KEY \`FK_8a8b6b92dfd3f78d012300524df\``);
await queryRunner.query(`ALTER TABLE \`development\` DROP FOREIGN KEY \`FK_a54d96cd5fda35d92815f7f65eb\``);
await queryRunner.query(`ALTER TABLE \`development\` DROP FOREIGN KEY \`FK_4cd86d57223a295e6de3c42cb61\``);
await queryRunner.query(`ALTER TABLE \`development\` DROP FOREIGN KEY \`FK_44fb0c37a11d7ad9b8ca98aaa08\``);
await queryRunner.query(`ALTER TABLE \`development\` DROP FOREIGN KEY \`FK_231ce173640401d258c977aae79\``);
await queryRunner.query(`ALTER TABLE \`development\` DROP FOREIGN KEY \`FK_593bc4c0cda43a2bee2928bda49\``);
await queryRunner.query(`ALTER TABLE \`development\` DROP FOREIGN KEY \`FK_10ff41d23b977cf8dce92e9b167\``);
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`strategyChild5ActualId\``);
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`strategyChild4ActualId\``);
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`strategyChild3ActualId\``);
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`strategyChild2ActualId\``);
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`strategyChild1ActualId\``);
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`strategyChild5PlannedId\``);
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`strategyChild4PlannedId\``);
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`strategyChild3PlannedId\``);
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`strategyChild2PlannedId\``);
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`strategyChild1PlannedId\``);
}
}

View file

@ -0,0 +1,22 @@
import { MigrationInterface, QueryRunner } from "typeorm";
export class UpdateTableDevelopmentAddStrategyChild11712930900458 implements MigrationInterface {
name = 'UpdateTableDevelopmentAddStrategyChild11712930900458'
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`developmentHistory\` ADD \`rootId\` varchar(255) NULL COMMENT 'id หน่วยงาน'`);
await queryRunner.query(`ALTER TABLE \`developmentHistory\` ADD \`root\` varchar(255) NULL COMMENT 'ชื่อหน่วยงาน'`);
await queryRunner.query(`ALTER TABLE \`developmentHistory\` ADD \`orgRootShortName\` varchar(255) NULL COMMENT 'ชื่อย่ิหน่วยงาน'`);
await queryRunner.query(`ALTER TABLE \`developmentHistory\` ADD \`orgRevisionId\` varchar(255) NULL COMMENT 'id revision'`);
await queryRunner.query(`ALTER TABLE \`developmentHistory\` ADD \`isDone\` tinyint NOT NULL COMMENT 'บันทึกลงทะเบียนประวัติ' DEFAULT 0`);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`developmentHistory\` DROP COLUMN \`isDone\``);
await queryRunner.query(`ALTER TABLE \`developmentHistory\` DROP COLUMN \`orgRevisionId\``);
await queryRunner.query(`ALTER TABLE \`developmentHistory\` DROP COLUMN \`orgRootShortName\``);
await queryRunner.query(`ALTER TABLE \`developmentHistory\` DROP COLUMN \`root\``);
await queryRunner.query(`ALTER TABLE \`developmentHistory\` DROP COLUMN \`rootId\``);
}
}

View file

@ -0,0 +1,20 @@
import { MigrationInterface, QueryRunner } from "typeorm";
export class UpdateTableDevelopmentscholarAddRootid1713012352435 implements MigrationInterface {
name = 'UpdateTableDevelopmentscholarAddRootid1713012352435'
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`rootId\` varchar(255) NULL COMMENT 'id หน่วยงาน'`);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`root\` varchar(255) NULL COMMENT 'ชื่อหน่วยงาน'`);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`orgRootShortName\` varchar(255) NULL COMMENT 'ชื่อย่อหน่วยงาน'`);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`orgRevisionId\` varchar(255) NULL COMMENT 'id revision'`);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`orgRevisionId\``);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`orgRootShortName\``);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`root\``);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`rootId\``);
}
}

View file

@ -0,0 +1,32 @@
import { MigrationInterface, QueryRunner } from "typeorm";
export class UpdateTableDevelopmentscholarDateToDatetime1713014657464 implements MigrationInterface {
name = 'UpdateTableDevelopmentscholarDateToDatetime1713014657464'
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`bookNoDate\``);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`bookNoDate\` datetime NULL COMMENT 'ลงวันที่(หนังสือ)'`);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`bookApproveDate\``);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`bookApproveDate\` datetime NULL COMMENT 'หนังสืออนุมัติเมื่อวันที่'`);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`contractDate\``);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`contractDate\` datetime NULL COMMENT 'ลงวันที่(เลขที่สัญญา)'`);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`reportBackNoDate\``);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`reportBackNoDate\` datetime NULL COMMENT 'ลงวันที่(เลขที่หนังสือรายงานตัวกลับ)'`);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`reportBackDate\``);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`reportBackDate\` datetime NULL COMMENT 'รายงานตัวกลับวันที่'`);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`reportBackDate\``);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`reportBackDate\` date NULL COMMENT 'รายงานตัวกลับวันที่'`);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`reportBackNoDate\``);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`reportBackNoDate\` date NULL COMMENT 'ลงวันที่(เลขที่หนังสือรายงานตัวกลับ)'`);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`contractDate\``);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`contractDate\` date NULL COMMENT 'ลงวันที่(เลขที่สัญญา)'`);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`bookApproveDate\``);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`bookApproveDate\` date NULL COMMENT 'หนังสืออนุมัติเมื่อวันที่'`);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`bookNoDate\``);
await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`bookNoDate\` date NULL COMMENT 'ลงวันที่(หนังสือ)'`);
}
}