Merge branch 'develop'

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2025-09-09 10:31:03 +07:00
commit 585619df3c
29 changed files with 890 additions and 364 deletions

View file

@ -104,4 +104,3 @@ jobs:
}] }]
}' \ }' \
${{ secrets.DISCORD_WEBHOOK }} ${{ secrets.DISCORD_WEBHOOK }}

View file

@ -34,6 +34,8 @@ import { ActualGoal, CreateActualGoal } from "../entities/ActualGoal";
import { CreatePlannedGoal, PlannedGoal } from "../entities/PlannedGoal"; import { CreatePlannedGoal, PlannedGoal } from "../entities/PlannedGoal";
import { PosType } from "../entities/PosType"; import { PosType } from "../entities/PosType";
import { PosLevel } from "../entities/PosLevel"; import { PosLevel } from "../entities/PosLevel";
import { EmployeePosType } from "../entities/EmployeePosType";
import { EmployeePosLevel } from "../entities/EmployeePosLevel";
import { PlannedGoalPosition } from "../entities/PlannedGoalPosition"; import { PlannedGoalPosition } from "../entities/PlannedGoalPosition";
import { CreateDevelopmentHistoryOBO, DevelopmentHistory } from "../entities/DevelopmentHistory"; import { CreateDevelopmentHistoryOBO, DevelopmentHistory } from "../entities/DevelopmentHistory";
import { DevelopmentProjectType } from "../entities/DevelopmentProjectType"; import { DevelopmentProjectType } from "../entities/DevelopmentProjectType";
@ -84,6 +86,8 @@ export class DevelopmentController extends Controller {
private plannedGoalPositionRepository = AppDataSource.getRepository(PlannedGoalPosition); private plannedGoalPositionRepository = AppDataSource.getRepository(PlannedGoalPosition);
private posTypeRepository = AppDataSource.getRepository(PosType); private posTypeRepository = AppDataSource.getRepository(PosType);
private posLevelRepository = AppDataSource.getRepository(PosLevel); private posLevelRepository = AppDataSource.getRepository(PosLevel);
private empPosTypeRepository = AppDataSource.getRepository(EmployeePosType);
private empPosLevelRepository = AppDataSource.getRepository(EmployeePosLevel);
private strategyChild1Repository = AppDataSource.getRepository(StrategyChild1); private strategyChild1Repository = AppDataSource.getRepository(StrategyChild1);
private strategyChild2Repository = AppDataSource.getRepository(StrategyChild2); private strategyChild2Repository = AppDataSource.getRepository(StrategyChild2);
private strategyChild3Repository = AppDataSource.getRepository(StrategyChild3); private strategyChild3Repository = AppDataSource.getRepository(StrategyChild3);
@ -366,22 +370,60 @@ export class DevelopmentController extends Controller {
await Promise.all( await Promise.all(
requestBody.positions.map(async (x) => { requestBody.positions.map(async (x) => {
const _data = Object.assign(new PlannedGoalPosition(), x); const _data = Object.assign(new PlannedGoalPosition(), x);
if (x.posTypePlannedId != null) { let checkPosType: any = null;
const checkId = await this.posTypeRepository.findOne({ let posTypeShortName: any = null;
where: { id: x.posTypePlannedId }, if (x.posTypePlanned) {
if (
requestBody.groupTarget == "PERSONNEL" &&
(requestBody.groupTargetSub == "EMPLOYEE" ||
requestBody.groupTargetSub == "EMPLOYEETEMP")
) {
checkPosType = await this.empPosTypeRepository.findOne({
where: { posTypeName: x.posTypePlanned },
}); });
if (!checkId) { if (!checkPosType) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลกลุ่มงาน");
}
posTypeShortName = checkPosType.posTypeShortName;
} else {
checkPosType = await this.posTypeRepository.findOne({
where: { posTypeName: x.posTypePlanned },
});
if (!checkPosType) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลประเภทตำแหน่ง"); throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลประเภทตำแหน่ง");
} }
} }
if (x.posLevelPlannedId != null) { }
const checkId = await this.posLevelRepository.findOne({ if (x.posLevelPlanned) {
where: { id: x.posLevelPlannedId }, let checkPosLevel: any;
if (
requestBody.groupTarget == "PERSONNEL" &&
(requestBody.groupTargetSub == "EMPLOYEE" ||
requestBody.groupTargetSub == "EMPLOYEETEMP")
) {
checkPosLevel = await this.empPosLevelRepository.find({
where: {
posTypeId: checkPosType.id,
},
}); });
if (!checkId) { const mapShortName = checkPosLevel.flatMap(
(x: any) => `${posTypeShortName} ${x.posLevelName}`,
);
if (checkPosLevel.length == 0 /*|| !mapShortName.includes(x.posLevelPlanned)*/) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลระดับชั้นงาน");
}
} else {
checkPosLevel = await this.posLevelRepository.findOne({
where: {
posLevelName: x.posLevelPlanned,
posTypeId: checkPosType.id,
},
});
if (!checkPosLevel) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลระดับตำแหน่ง"); throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลระดับตำแหน่ง");
} }
} }
}
const before = structuredClone(development); const before = structuredClone(development);
_data.createdUserId = request.user.sub; _data.createdUserId = request.user.sub;
_data.createdFullName = request.user.name; _data.createdFullName = request.user.name;
@ -466,32 +508,58 @@ export class DevelopmentController extends Controller {
if (!development) { if (!development) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลโครงการ/หลักสูตรการฝึกอบรมนี้"); throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลโครงการ/หลักสูตรการฝึกอบรมนี้");
} }
if (requestBody.posTypeActualId != null) { let checkPosType: any = null;
// addLogSequence(request, { let posTypeShortName: any = null;
// action: "database", if (requestBody.posTypeActual) {
// status: "success", if (
// description: "Get Position Type.", requestBody.groupTarget == "PERSONNEL" &&
// }); (requestBody.groupTargetSub == "EMPLOYEE" || requestBody.groupTargetSub == "EMPLOYEETEMP")
const checkId = await this.posTypeRepository.findOne({ ) {
where: { id: requestBody.posTypeActualId }, checkPosType = await this.empPosTypeRepository.findOne({
where: { posTypeName: requestBody.posTypeActual },
}); });
if (!checkId) { if (!checkPosType) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลกลุ่มงาน");
}
posTypeShortName = checkPosType.posTypeShortName;
} else {
checkPosType = await this.posTypeRepository.findOne({
where: { posTypeName: requestBody.posTypeActual },
});
if (!checkPosType) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลประเภทตำแหน่ง"); throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลประเภทตำแหน่ง");
} }
} }
if (requestBody.posLevelActualId != null) { }
// addLogSequence(request, { if (requestBody.posLevelActual) {
// action: "database", let checkPosLevel: any;
// status: "success", if (
// description: "Get Position Level.", requestBody.groupTarget == "PERSONNEL" &&
// }); (requestBody.groupTargetSub == "EMPLOYEE" || requestBody.groupTargetSub == "EMPLOYEETEMP")
const checkId = await this.posLevelRepository.findOne({ ) {
where: { id: requestBody.posLevelActualId }, checkPosLevel = await this.empPosLevelRepository.find({
where: {
posTypeId: checkPosType.id,
},
}); });
if (!checkId) { const mapShortName = checkPosLevel.flatMap(
(x: any) => `${posTypeShortName} ${x.posLevelName}`,
);
if (checkPosLevel.length == 0 /*|| !mapShortName.includes(x.posLevelPlanned)*/) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลระดับชั้นงาน");
}
} else {
checkPosLevel = await this.posLevelRepository.findOne({
where: {
posLevelName: requestBody.posLevelActual,
posTypeId: checkPosType.id,
},
});
if (!checkPosLevel) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลระดับตำแหน่ง"); throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลระดับตำแหน่ง");
} }
} }
}
const before = structuredClone(development); const before = structuredClone(development);
const data = Object.assign(new ActualGoal(), requestBody); const data = Object.assign(new ActualGoal(), requestBody);
data.createdUserId = request.user.sub; data.createdUserId = request.user.sub;
@ -607,22 +675,60 @@ export class DevelopmentController extends Controller {
await Promise.all( await Promise.all(
requestBody.positions.map(async (x) => { requestBody.positions.map(async (x) => {
const _data = Object.assign(new PlannedGoalPosition(), x); const _data = Object.assign(new PlannedGoalPosition(), x);
if (x.posTypePlannedId != null) { let checkPosType: any = null;
const checkId = await this.posTypeRepository.findOne({ let posTypeShortName: any = null;
where: { id: x.posTypePlannedId }, if (x.posTypePlanned) {
if (
requestBody.groupTarget == "PERSONNEL" &&
(requestBody.groupTargetSub == "EMPLOYEE" ||
requestBody.groupTargetSub == "EMPLOYEETEMP")
) {
checkPosType = await this.empPosTypeRepository.findOne({
where: { posTypeName: x.posTypePlanned },
}); });
if (!checkId) { if (!checkPosType) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลกลุ่มงาน");
}
posTypeShortName = checkPosType.posTypeShortName;
} else {
checkPosType = await this.posTypeRepository.findOne({
where: { posTypeName: x.posTypePlanned },
});
if (!checkPosType) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลประเภทตำแหน่ง"); throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลประเภทตำแหน่ง");
} }
} }
if (x.posLevelPlannedId != null) { }
const checkId = await this.posLevelRepository.findOne({ if (x.posLevelPlanned) {
where: { id: x.posLevelPlannedId }, let checkPosLevel: any;
if (
requestBody.groupTarget == "PERSONNEL" &&
(requestBody.groupTargetSub == "EMPLOYEE" ||
requestBody.groupTargetSub == "EMPLOYEETEMP")
) {
checkPosLevel = await this.empPosLevelRepository.find({
where: {
posTypeId: checkPosType.id,
},
}); });
if (!checkId) { const mapShortName = checkPosLevel.flatMap(
(x: any) => `${posTypeShortName} ${x.posLevelName}`,
);
if (checkPosLevel.length == 0 /*|| !mapShortName.includes(x.posLevelPlanned)*/) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลระดับชั้นงาน");
}
} else {
checkPosLevel = await this.posLevelRepository.findOne({
where: {
posLevelName: x.posLevelPlanned,
posTypeId: checkPosType.id,
},
});
if (!checkPosLevel) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลระดับตำแหน่ง"); throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลระดับตำแหน่ง");
} }
} }
}
_data.createdUserId = request.user.sub; _data.createdUserId = request.user.sub;
_data.createdFullName = request.user.name; _data.createdFullName = request.user.name;
_data.lastUpdateUserId = request.user.sub; _data.lastUpdateUserId = request.user.sub;
@ -711,32 +817,58 @@ export class DevelopmentController extends Controller {
if (!development) { if (!development) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลโครงการ/หลักสูตรการฝึกอบรมนี้"); throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลโครงการ/หลักสูตรการฝึกอบรมนี้");
} }
if (requestBody.posTypeActualId != null) { let checkPosType: any = null;
// addLogSequence(request, { let posTypeShortName: any = null;
// action: "database", if (requestBody.posTypeActual) {
// status: "success", if (
// description: "Get Position Type.", requestBody.groupTarget == "PERSONNEL" &&
// }); (requestBody.groupTargetSub == "EMPLOYEE" || requestBody.groupTargetSub == "EMPLOYEETEMP")
const checkId = await this.posTypeRepository.findOne({ ) {
where: { id: requestBody.posTypeActualId }, checkPosType = await this.empPosTypeRepository.findOne({
where: { posTypeName: requestBody.posTypeActual },
}); });
if (!checkId) { if (!checkPosType) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลกลุ่มงาน");
}
posTypeShortName = checkPosType.posTypeShortName;
} else {
checkPosType = await this.posTypeRepository.findOne({
where: { posTypeName: requestBody.posTypeActual },
});
if (!checkPosType) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลประเภทตำแหน่ง"); throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลประเภทตำแหน่ง");
} }
} }
if (requestBody.posLevelActualId != null) { }
// addLogSequence(request, { if (requestBody.posLevelActual) {
// action: "database", let checkPosLevel: any;
// status: "success", if (
// description: "Get Position Level.", requestBody.groupTarget == "PERSONNEL" &&
// }); (requestBody.groupTargetSub == "EMPLOYEE" || requestBody.groupTargetSub == "EMPLOYEETEMP")
const checkId = await this.posLevelRepository.findOne({ ) {
where: { id: requestBody.posLevelActualId }, checkPosLevel = await this.empPosLevelRepository.find({
where: {
posTypeId: checkPosType.id,
},
}); });
if (!checkId) { const mapShortName = checkPosLevel.flatMap(
(x: any) => `${posTypeShortName} ${x.posLevelName}`,
);
if (checkPosLevel.length == 0 /*|| !mapShortName.includes(x.posLevelPlanned)*/) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลระดับชั้นงาน");
}
} else {
checkPosLevel = await this.posLevelRepository.findOne({
where: {
posLevelName: requestBody.posLevelActual,
posTypeId: checkPosType.id,
},
});
if (!checkPosLevel) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลระดับตำแหน่ง"); throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลระดับตำแหน่ง");
} }
} }
}
const before = structuredClone(development); const before = structuredClone(development);
Object.assign(development, requestBody); Object.assign(development, requestBody);
development.lastUpdateUserId = request.user.sub; development.lastUpdateUserId = request.user.sub;
@ -1419,7 +1551,7 @@ export class DevelopmentController extends Controller {
if (!development) { if (!development) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลโครงการ/หลักสูตรการฝึกอบรมนี้"); throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลโครงการ/หลักสูตรการฝึกอบรมนี้");
} }
Object.assign(development, { ...requestBody, developmentAddresss: [] }); Object.assign(development, { ...requestBody});
development.lastUpdateUserId = request.user.sub; development.lastUpdateUserId = request.user.sub;
development.lastUpdateFullName = request.user.name; development.lastUpdateFullName = request.user.name;
development.lastUpdatedAt = new Date(); development.lastUpdatedAt = new Date();
@ -1814,6 +1946,9 @@ export class DevelopmentController extends Controller {
developmentProjectTechniqueActuals: true, developmentProjectTechniqueActuals: true,
developmentEvaluations: true, developmentEvaluations: true,
developmentAddresss: true, developmentAddresss: true,
developmentRisks: true,
developmentHistorys: true,
developmentOthers: true,
}, },
}); });
if (!development) { if (!development) {
@ -1827,92 +1962,46 @@ export class DevelopmentController extends Controller {
const plannedGoalPosition = await this.plannedGoalPositionRepository.find({ const plannedGoalPosition = await this.plannedGoalPositionRepository.find({
where: { plannedGoalId: In(development.developmentPlannedGoals.map((x) => x.id)) }, where: { plannedGoalId: In(development.developmentPlannedGoals.map((x) => x.id)) },
}); });
// addLogSequence(request, {
// action: "remove",
// status: "success",
// description: "Remove PlannedGoalPosition.",
// });
await this.plannedGoalPositionRepository.remove(plannedGoalPosition, { data: request }); await this.plannedGoalPositionRepository.remove(plannedGoalPosition, { data: request });
} }
// addLogSequence(request, {
// action: "remove",
// status: "success",
// description: "Remove ActualPeople.",
// });
await this.actualPeopleRepository.remove(development.developmentActualPeoples, { await this.actualPeopleRepository.remove(development.developmentActualPeoples, {
data: request, data: request,
}); });
// addLogSequence(request, {
// action: "remove",
// status: "success",
// description: "Remove PlannedPeople.",
// });
await this.plannedPeopleRepository.remove(development.developmentPlannedPeoples, { await this.plannedPeopleRepository.remove(development.developmentPlannedPeoples, {
data: request, data: request,
}); });
// addLogSequence(request, {
// action: "remove",
// status: "success",
// description: "Remove ActualGoal.",
// });
await this.actualGoalRepository.remove(development.developmentActualGoals, { data: request }); await this.actualGoalRepository.remove(development.developmentActualGoals, { data: request });
// addLogSequence(request, {
// action: "remove",
// status: "success",
// description: "Remove PlannedGoal.",
// });
await this.plannedGoalRepository.remove(development.developmentPlannedGoals, { data: request }); await this.plannedGoalRepository.remove(development.developmentPlannedGoals, { data: request });
// addLogSequence(request, {
// action: "remove",
// status: "success",
// description: "Remove DevelopmentProjectType.",
// });
await this.developmentProjectTypeRepository.remove(development.developmentProjectTypes, { await this.developmentProjectTypeRepository.remove(development.developmentProjectTypes, {
data: request, data: request,
}); });
// addLogSequence(request, {
// action: "remove",
// status: "success",
// description: "Remove DevelopmentProjectTechniquePlanned.",
// });
await this.developmentProjectTechniquePlannedRepository.remove( await this.developmentProjectTechniquePlannedRepository.remove(
development.developmentProjectTechniquePlanneds, development.developmentProjectTechniquePlanneds,
{ {
data: request, data: request,
}, },
); );
// addLogSequence(request, {
// action: "remove",
// status: "success",
// description: "Remove DevelopmentProjectTechniqueActuals.",
// });
await this.developmentProjectTechniqueActualRepository.remove( await this.developmentProjectTechniqueActualRepository.remove(
development.developmentProjectTechniqueActuals, development.developmentProjectTechniqueActuals,
{ {
data: request, data: request,
}, },
); );
// addLogSequence(request, {
// action: "remove",
// status: "success",
// description: "Remove DevelopmentEvaluation.",
// });
await this.developmentEvaluationRepository.remove(development.developmentEvaluations, { await this.developmentEvaluationRepository.remove(development.developmentEvaluations, {
data: request, data: request,
}); });
// addLogSequence(request, {
// action: "remove",
// status: "success",
// description: "Remove DevelopmentAddresss.",
// });
await this.developmentAddresssRepository.remove(development.developmentAddresss, { await this.developmentAddresssRepository.remove(development.developmentAddresss, {
data: request, data: request,
}); });
// addLogSequence(request, { await this.developmentRiskRepository.remove(development.developmentRisks, {
// action: "remove", data: request,
// status: "success", });
// description: "Remove Development.", await this.developmentHistoryRepository.remove(development.developmentHistorys, {
// }); data: request,
});
await this.developmentOtherRepository.remove(development.developmentOthers, {
data: request,
});
await this.developmentRepository.remove(development, { data: request }); await this.developmentRepository.remove(development, { data: request });
return new HttpSuccess(); return new HttpSuccess();
} }
@ -1934,7 +2023,13 @@ export class DevelopmentController extends Controller {
@Query("node") node?: number | null, @Query("node") node?: number | null,
@Query("keyword") keyword?: string, @Query("keyword") keyword?: string,
) { ) {
// await new permission().PermissionOrgList(request, "SYS_DEV_SCHOLARSHIP"); let _data = await new permission().PermissionOrgList(request, "SYS_DEV_PROJECT");
await new CallAPI()
.PostData(request, "/org/finddna", _data)
.then((x) => {
_data = x;
})
.catch((x) => {});
const [development, total] = await AppDataSource.getRepository(Development) const [development, total] = await AppDataSource.getRepository(Development)
.createQueryBuilder("development") .createQueryBuilder("development")
.andWhere(year > 0 ? "development.year LIKE :year" : "1=1", { .andWhere(year > 0 ? "development.year LIKE :year" : "1=1", {
@ -1974,6 +2069,56 @@ export class DevelopmentController extends Controller {
keyword: `%${keyword}%`, keyword: `%${keyword}%`,
}, },
) )
.andWhere(
_data.root != undefined && _data.root != null
? _data.root[0] != null
? `development.rootDnaId IN (:...root)`
: `development.rootDnaId is null`
: "1=1",
{
root: _data.root,
},
)
.andWhere(
_data.child1 != undefined && _data.child1 != null
? _data.child1[0] != null
? `development.child1DnaId IN (:...child1)`
: `development.child1DnaId is null`
: "1=1",
{
child1: _data.child1,
},
)
.andWhere(
_data.child2 != undefined && _data.child2 != null
? _data.child2[0] != null
? `development.child2DnaId IN (:...child2)`
: `development.child2DnaId is null`
: "1=1",
{
child2: _data.child2,
},
)
.andWhere(
_data.child3 != undefined && _data.child3 != null
? _data.child3[0] != null
? `development.child3DnaId IN (:...child3)`
: `development.child3DnaId is null`
: "1=1",
{
child3: _data.child3,
},
)
.andWhere(
_data.child4 != undefined && _data.child4 != null
? _data.child4[0] != null
? `development.child4DnaId IN (:...child4)`
: `development.child4DnaId is null`
: "1=1",
{
child4: _data.child4,
},
)
.select([ .select([
"development.id", "development.id",
"development.projectName", "development.projectName",
@ -2116,17 +2261,18 @@ export class DevelopmentController extends Controller {
if (_workflow == false) await new permission().PermissionGet(request, "SYS_DEV_PROJECT"); if (_workflow == false) await new permission().PermissionGet(request, "SYS_DEV_PROJECT");
const getDevelopment = await this.developmentRepository.findOne({ const getDevelopment = await this.developmentRepository.findOne({
where: { id: id }, where: { id: id },
//posTypeActual
relations: [ relations: [
"developmentActualPeoples", "developmentActualPeoples",
"developmentPlannedPeoples", "developmentPlannedPeoples",
"developmentActualGoals", "developmentActualGoals",
"developmentActualGoals.posTypeActual", // "developmentActualGoals.posTypeActual",
"developmentActualGoals.posLevelActual", // "developmentActualGoals.posLevelActual",
"developmentActualGoals", "developmentActualGoals",
"developmentPlannedGoals", "developmentPlannedGoals",
"developmentPlannedGoals.plannedGoalPositions", "developmentPlannedGoals.plannedGoalPositions",
"developmentPlannedGoals.plannedGoalPositions.posTypePlanned", // "developmentPlannedGoals.plannedGoalPositions.posTypePlanned",
"developmentPlannedGoals.plannedGoalPositions.posLevelPlanned", // "developmentPlannedGoals.plannedGoalPositions.posLevelPlanned",
], ],
}); });
if (!getDevelopment) { if (!getDevelopment) {
@ -2164,10 +2310,12 @@ export class DevelopmentController extends Controller {
groupTarget: x.groupTarget, groupTarget: x.groupTarget,
groupTargetSub: x.groupTargetSub, groupTargetSub: x.groupTargetSub,
position: x.position, position: x.position,
posTypeId: x.posTypeActualId, // posTypeId: x.posTypeActualId,
posType: x.posTypeActual == null ? null : x.posTypeActual.posTypeName, // posType: x.posTypeActual == null ? null : x.posTypeActual.posTypeName,
posLevelId: x.posLevelActualId, // posLevelId: x.posLevelActualId,
posLevel: x.posLevelActual == null ? null : x.posLevelActual.posLevelName, // posLevel: x.posLevelActual == null ? null : x.posLevelActual.posLevelName,
posType: x.posTypeActual,
posLevel: x.posLevelActual,
type: x.type, type: x.type,
amount: x.amount, amount: x.amount,
})), })),
@ -2189,10 +2337,12 @@ export class DevelopmentController extends Controller {
id: y.id, id: y.id,
position: y.position, position: y.position,
posExecutive: y.posExecutive, posExecutive: y.posExecutive,
posTypeId: y.posTypePlannedId, // posTypeId: y.posTypePlannedId,
posType: y.posTypePlanned == null ? null : y.posTypePlanned.posTypeName, // posType: y.posTypePlanned == null ? null : y.posTypePlanned.posTypeName,
posLevelId: y.posLevelPlannedId, // posLevelId: y.posLevelPlannedId,
posLevel: y.posLevelPlanned == null ? null : y.posLevelPlanned.posLevelName, // posLevel: y.posLevelPlanned == null ? null : y.posLevelPlanned.posLevelName,
posType: y.posTypePlanned,
posLevel: y.posLevelPlanned,
})), })),
amount: x.amount, amount: x.amount,
})), })),
@ -2269,7 +2419,11 @@ export class DevelopmentController extends Controller {
dateEnd: getDevelopment.dateEnd, dateEnd: getDevelopment.dateEnd,
totalDate: getDevelopment.totalDate, totalDate: getDevelopment.totalDate,
developmentAddresss: developmentAddresss:
getDevelopment.developmentAddresss == null ? null : getDevelopment.developmentAddresss, getDevelopment.developmentAddresss == null
? null
: getDevelopment.developmentAddresss.sort(
(a, b) => new Date(a.createdAt).getTime() - new Date(b.createdAt).getTime(),
),
}; };
return new HttpSuccess(_getDevelopment); return new HttpSuccess(_getDevelopment);
} }
@ -2434,7 +2588,7 @@ export class DevelopmentController extends Controller {
? item.posLevel.posLevelName ? item.posLevel.posLevelName
: null : null
: item.employeePosLevel : item.employeePosLevel
? item.employeePosLevel.posLevelName ? `${item.employeePosType.posTypeShortName ?? ""} ${item.employeePosLevel.posLevelName ?? ""}`
: null, : null,
posExecutive: item.posExecutive, posExecutive: item.posExecutive,
org: item.org, org: item.org,
@ -2451,9 +2605,9 @@ export class DevelopmentController extends Controller {
} }
/** /**
* API / tab6 * API / tab6 (>/)
* *
* @summary DEV_00 - /tab6 # * @summary DEV_00 - /tab6 (>/) #
* *
* @param {string} id Id * @param {string} id Id
*/ */
@ -2481,6 +2635,7 @@ export class DevelopmentController extends Controller {
startDate: x.dateStart, startDate: x.dateStart,
endDate: x.dateEnd, endDate: x.dateEnd,
isDate: true, isDate: true,
developmentId: id,
}) })
.then((x) => { .then((x) => {
_data.isDone = true; _data.isDone = true;
@ -2503,6 +2658,7 @@ export class DevelopmentController extends Controller {
startDate: x.dateStart, startDate: x.dateStart,
endDate: x.dateEnd, endDate: x.dateEnd,
isDate: true, isDate: true,
developmentId: id,
}) })
.then((x) => { .then((x) => {
_data.isDone = true; _data.isDone = true;
@ -2527,9 +2683,9 @@ export class DevelopmentController extends Controller {
} }
/** /**
* API / tab6 IDP * API / tab6 IDP (>)
* *
* @summary DEV_00 - /tab6 IDP # * @summary DEV_00 - /tab6 IDP (>)#
* *
* @param {string} id Id * @param {string} id Id
*/ */
@ -2539,9 +2695,55 @@ export class DevelopmentController extends Controller {
where: { developmentId: id, isDoneIDP: false }, where: { developmentId: id, isDoneIDP: false },
relations: ["development", "development.developmentProjectTechniqueActuals"], relations: ["development", "development.developmentProjectTechniqueActuals"],
}); });
let isDevelopment70: boolean = false;
const dev70Lists = [
"on_the_job_training",
"job_project_assignment",
"job_shadowing",
"job_enlargement",
"internal_trainer",
"rotation",
"activity",
"site_visit",
"benchmarking",
"problem_solving",
"team_working",
"other1",
];
let isDevelopment20: boolean = false;
const dev20Lists = [
"coaching",
"mentoring",
"team_meeting",
"consulting",
"feedback",
"other2",
];
let isDevelopment10: boolean = false;
const dev10Lists = [
"self_learning",
"classroom_training",
"in_house_training",
"public_training",
"e_training",
"meeting",
"seminar",
"other3",
];
await Promise.all( await Promise.all(
getDevelopment.map(async (x) => { getDevelopment.map(async (x) => {
const _data = Object.assign(new DevelopmentHistory(), x); const _data = Object.assign(new DevelopmentHistory(), x);
const techniqueActuals =
x.development?.developmentProjectTechniqueActuals.flatMap((x) => x.name) || [];
isDevelopment70 =
techniqueActuals.length > 0 && dev70Lists.some((item) => techniqueActuals.includes(item));
isDevelopment20 =
techniqueActuals.length > 0 && dev20Lists.some((item) => techniqueActuals.includes(item));
isDevelopment10 =
techniqueActuals.length > 0 && dev10Lists.some((item) => techniqueActuals.includes(item));
if (x.type == "OFFICER") { if (x.type == "OFFICER") {
await new CallAPI() await new CallAPI()
.PostData(request, "/org/profile/development", { .PostData(request, "/org/profile/development", {
@ -2555,9 +2757,9 @@ export class DevelopmentController extends Controller {
reasonDevelopment70: x.development.reasonActual70, reasonDevelopment70: x.development.reasonActual70,
reasonDevelopment20: x.development.reasonActual20, reasonDevelopment20: x.development.reasonActual20,
reasonDevelopment10: x.development.reasonActual10, reasonDevelopment10: x.development.reasonActual10,
isDevelopment70: x.development.isReasonActual70, isDevelopment70: isDevelopment70,
isDevelopment20: x.development.isReasonActual20, isDevelopment20: isDevelopment20,
isDevelopment10: x.development.isReasonActual10, isDevelopment10: isDevelopment10,
developmentTarget: null, developmentTarget: null,
developmentResults: null, developmentResults: null,
developmentReport: null, developmentReport: null,
@ -2584,9 +2786,9 @@ export class DevelopmentController extends Controller {
reasonDevelopment70: x.development.reasonActual70, reasonDevelopment70: x.development.reasonActual70,
reasonDevelopment20: x.development.reasonActual20, reasonDevelopment20: x.development.reasonActual20,
reasonDevelopment10: x.development.reasonActual10, reasonDevelopment10: x.development.reasonActual10,
isDevelopment70: x.development.isReasonActual70, isDevelopment70: isDevelopment70,
isDevelopment20: x.development.isReasonActual20, isDevelopment20: isDevelopment20,
isDevelopment10: x.development.isReasonActual10, isDevelopment10: isDevelopment10,
developmentTarget: null, developmentTarget: null,
developmentResults: null, developmentResults: null,
developmentReport: null, developmentReport: null,

View file

@ -275,6 +275,14 @@ export class DevelopmentEmployeeHistoryController extends Controller {
{ {
keyword: `%${body.keyword}%`, keyword: `%${body.keyword}%`,
}, },
)
.orWhere(
body.keyword != null && body.keyword != ""
? "CONCAT(employeePosType.posTypeShortName,' ',employeePosLevel.posLevelName) LIKE :keyword"
: "1=1",
{
keyword: `%${body.keyword}%`,
},
) )
.orWhere( .orWhere(
body.keyword != null && body.keyword != "" body.keyword != null && body.keyword != ""
@ -403,6 +411,7 @@ export class DevelopmentEmployeeHistoryController extends Controller {
dateStart: getDevelopment.development != null ? getDevelopment.development.dateStart : null, dateStart: getDevelopment.development != null ? getDevelopment.development.dateStart : null,
dateEnd: getDevelopment.development != null ? getDevelopment.development.dateEnd : null, dateEnd: getDevelopment.development != null ? getDevelopment.development.dateEnd : null,
totalDate: getDevelopment.development != null ? getDevelopment.development.totalDate : null, totalDate: getDevelopment.development != null ? getDevelopment.development.totalDate : null,
trainingDays: getDevelopment.development != null ? getDevelopment.trainingDays : null,
// addressAcademic: // addressAcademic:
// getDevelopment.development != null ? getDevelopment.development.addressAcademic : null, // getDevelopment.development != null ? getDevelopment.development.addressAcademic : null,
// topicAcademic: // topicAcademic:

View file

@ -250,6 +250,7 @@ export class DevelopmentOfficerHistoryController extends Controller {
.leftJoinAndSelect("developmentHistory.development", "development") .leftJoinAndSelect("developmentHistory.development", "development")
.leftJoinAndSelect("developmentHistory.posLevel", "posLevel") .leftJoinAndSelect("developmentHistory.posLevel", "posLevel")
.leftJoinAndSelect("developmentHistory.posType", "posType") .leftJoinAndSelect("developmentHistory.posType", "posType")
.where("developmentHistory.profileId IS NOT NULL")
.andWhere( .andWhere(
body.year != 0 && body.year != null && body.year != undefined body.year != 0 && body.year != null && body.year != undefined
? "development.year = :year" ? "development.year = :year"
@ -389,6 +390,7 @@ export class DevelopmentOfficerHistoryController extends Controller {
dateStart: getDevelopment.development != null ? getDevelopment.development.dateStart : null, dateStart: getDevelopment.development != null ? getDevelopment.development.dateStart : null,
dateEnd: getDevelopment.development != null ? getDevelopment.development.dateEnd : null, dateEnd: getDevelopment.development != null ? getDevelopment.development.dateEnd : null,
totalDate: getDevelopment.development != null ? getDevelopment.development.totalDate : null, totalDate: getDevelopment.development != null ? getDevelopment.development.totalDate : null,
trainingDays: getDevelopment.development != null ? getDevelopment.trainingDays : null,
// addressAcademic: // addressAcademic:
// getDevelopment.development != null ? getDevelopment.development.addressAcademic : null, // getDevelopment.development != null ? getDevelopment.development.addressAcademic : null,
// topicAcademic: // topicAcademic:

View file

@ -161,7 +161,13 @@ export class DevelopmentScholarshipController extends Controller {
@Query("year") year?: number, @Query("year") year?: number,
@Query("scholarshipType") scholarshipType?: string, @Query("scholarshipType") scholarshipType?: string,
) { ) {
await new permission().PermissionList(request, "SYS_DEV_SCHOLARSHIP"); let _data = await new permission().PermissionOrgList(request, "SYS_DEV_SCHOLARSHIP");
await new CallAPI()
.PostData(request, "/org/finddna", _data)
.then((x) => {
_data = x;
})
.catch((x) => {});
const [development, total] = await AppDataSource.getRepository(DevelopmentScholarship) const [development, total] = await AppDataSource.getRepository(DevelopmentScholarship)
.createQueryBuilder("developmentScholarship") .createQueryBuilder("developmentScholarship")
.leftJoinAndSelect("developmentScholarship.posLevel", "posLevel") .leftJoinAndSelect("developmentScholarship.posLevel", "posLevel")
@ -226,6 +232,16 @@ export class DevelopmentScholarshipController extends Controller {
); );
}), }),
) )
.andWhere(
_data.root != undefined && _data.root != null
? _data.root[0] != null
? `developmentScholarship.rootDnaId IN (:...root)`
: `developmentScholarship.rootDnaId is null`
: "1=1",
{
root: _data.root,
},
)
.orderBy("developmentScholarship.scholarshipYear", "DESC") .orderBy("developmentScholarship.scholarshipYear", "DESC")
.addOrderBy("developmentScholarship.createdAt", "DESC") .addOrderBy("developmentScholarship.createdAt", "DESC")
.skip((page - 1) * pageSize) .skip((page - 1) * pageSize)
@ -264,6 +280,7 @@ export class DevelopmentScholarshipController extends Controller {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลทุนการศึกษา/ฝึกอบรมนี้"); throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลทุนการศึกษา/ฝึกอบรมนี้");
} }
const formattedData = { const formattedData = {
rootDnaId: getDevelopment.rootDnaId ? getDevelopment.rootDnaId : null,
rootId: getDevelopment.rootId ? getDevelopment.rootId : null, rootId: getDevelopment.rootId ? getDevelopment.rootId : null,
root: getDevelopment.root ? getDevelopment.root : null, root: getDevelopment.root ? getDevelopment.root : null,
org: getDevelopment.org ? getDevelopment.org : null, org: getDevelopment.org ? getDevelopment.org : null,
@ -282,6 +299,9 @@ export class DevelopmentScholarshipController extends Controller {
: null, : null,
posTypeId: getDevelopment.posTypeId ? getDevelopment.posTypeId : null, posTypeId: getDevelopment.posTypeId ? getDevelopment.posTypeId : null,
posTypeName: getDevelopment.posType?.posTypeName ? getDevelopment.posType?.posTypeName : null, posTypeName: getDevelopment.posType?.posTypeName ? getDevelopment.posType?.posTypeName : null,
guarantorRootDnaId: getDevelopment.guarantorRootDnaId
? getDevelopment.guarantorRootDnaId
: null,
guarantorRootId: getDevelopment.guarantorRootId ? getDevelopment.guarantorRootId : null, guarantorRootId: getDevelopment.guarantorRootId ? getDevelopment.guarantorRootId : null,
guarantorRoot: getDevelopment.guarantorRoot ? getDevelopment.guarantorRoot : null, guarantorRoot: getDevelopment.guarantorRoot ? getDevelopment.guarantorRoot : null,
guarantorOrg: getDevelopment.guarantorOrg ? getDevelopment.guarantorOrg : null, guarantorOrg: getDevelopment.guarantorOrg ? getDevelopment.guarantorOrg : null,
@ -322,7 +342,7 @@ export class DevelopmentScholarshipController extends Controller {
bookNo: getDevelopment.bookNo ? getDevelopment.bookNo : null, bookNo: getDevelopment.bookNo ? getDevelopment.bookNo : null,
bookNoDate: getDevelopment.bookNoDate ? getDevelopment.bookNoDate : null, bookNoDate: getDevelopment.bookNoDate ? getDevelopment.bookNoDate : null,
bookApproveDate: getDevelopment.bookApproveDate ? getDevelopment.bookApproveDate : null, bookApproveDate: getDevelopment.bookApproveDate ? getDevelopment.bookApproveDate : null,
useOfficialTime: getDevelopment.useOfficialTime ? getDevelopment.useOfficialTime : false, useOfficialTime: getDevelopment.useOfficialTime ? getDevelopment.useOfficialTime : null,
changeDetail: getDevelopment.changeDetail ? getDevelopment.changeDetail : null, changeDetail: getDevelopment.changeDetail ? getDevelopment.changeDetail : null,
scholarshipType: getDevelopment.scholarshipType ? getDevelopment.scholarshipType : null, scholarshipType: getDevelopment.scholarshipType ? getDevelopment.scholarshipType : null,
fundType: getDevelopment.fundType ? getDevelopment.fundType : null, fundType: getDevelopment.fundType ? getDevelopment.fundType : null,
@ -426,6 +446,7 @@ export class DevelopmentScholarshipController extends Controller {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลทุนการศึกษา/ฝึกอบรมนี้"); throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลทุนการศึกษา/ฝึกอบรมนี้");
} }
const formattedData = { const formattedData = {
rootDnaId: getDevelopment.rootDnaId ? getDevelopment.rootDnaId : null,
rootId: getDevelopment.rootId ? getDevelopment.rootId : null, rootId: getDevelopment.rootId ? getDevelopment.rootId : null,
root: getDevelopment.root ? getDevelopment.root : null, root: getDevelopment.root ? getDevelopment.root : null,
org: getDevelopment.org ? getDevelopment.org : null, org: getDevelopment.org ? getDevelopment.org : null,
@ -444,6 +465,9 @@ export class DevelopmentScholarshipController extends Controller {
: null, : null,
posTypeId: getDevelopment.posTypeId ? getDevelopment.posTypeId : null, posTypeId: getDevelopment.posTypeId ? getDevelopment.posTypeId : null,
posTypeName: getDevelopment.posType?.posTypeName ? getDevelopment.posType?.posTypeName : null, posTypeName: getDevelopment.posType?.posTypeName ? getDevelopment.posType?.posTypeName : null,
guarantorRootDnaId: getDevelopment.guarantorRootDnaId
? getDevelopment.guarantorRootDnaId
: null,
guarantorRootId: getDevelopment.guarantorRootId ? getDevelopment.guarantorRootId : null, guarantorRootId: getDevelopment.guarantorRootId ? getDevelopment.guarantorRootId : null,
guarantorRoot: getDevelopment.guarantorRoot ? getDevelopment.guarantorRoot : null, guarantorRoot: getDevelopment.guarantorRoot ? getDevelopment.guarantorRoot : null,
guarantorOrg: getDevelopment.guarantorOrg ? getDevelopment.guarantorOrg : null, guarantorOrg: getDevelopment.guarantorOrg ? getDevelopment.guarantorOrg : null,
@ -484,7 +508,7 @@ export class DevelopmentScholarshipController extends Controller {
bookNo: getDevelopment.bookNo ? getDevelopment.bookNo : null, bookNo: getDevelopment.bookNo ? getDevelopment.bookNo : null,
bookNoDate: getDevelopment.bookNoDate ? getDevelopment.bookNoDate : null, bookNoDate: getDevelopment.bookNoDate ? getDevelopment.bookNoDate : null,
bookApproveDate: getDevelopment.bookApproveDate ? getDevelopment.bookApproveDate : null, bookApproveDate: getDevelopment.bookApproveDate ? getDevelopment.bookApproveDate : null,
useOfficialTime: getDevelopment.useOfficialTime ? getDevelopment.useOfficialTime : false, useOfficialTime: getDevelopment.useOfficialTime ? getDevelopment.useOfficialTime : null,
changeDetail: getDevelopment.changeDetail ? getDevelopment.changeDetail : null, changeDetail: getDevelopment.changeDetail ? getDevelopment.changeDetail : null,
scholarshipType: getDevelopment.scholarshipType ? getDevelopment.scholarshipType : null, scholarshipType: getDevelopment.scholarshipType ? getDevelopment.scholarshipType : null,
fundType: getDevelopment.fundType ? getDevelopment.fundType : null, fundType: getDevelopment.fundType ? getDevelopment.fundType : null,
@ -519,6 +543,7 @@ export class DevelopmentScholarshipController extends Controller {
profileId: getDevelopment.profileId ? getDevelopment.profileId : null, profileId: getDevelopment.profileId ? getDevelopment.profileId : null,
planType: getDevelopment.planType ? getDevelopment.planType : null, planType: getDevelopment.planType ? getDevelopment.planType : null,
isNoUseBudget: getDevelopment.isNoUseBudget ? getDevelopment.isNoUseBudget : null, isNoUseBudget: getDevelopment.isNoUseBudget ? getDevelopment.isNoUseBudget : null,
budgetSourceOther: getDevelopment.budgetSourceOther ? getDevelopment.budgetSourceOther : null,
}; };
return new HttpSuccess(formattedData); return new HttpSuccess(formattedData);
} }
@ -558,6 +583,44 @@ export class DevelopmentScholarshipController extends Controller {
return new HttpSuccess(getDevelopment); return new HttpSuccess(getDevelopment);
} }
/**
* API admin
*
* @summary DEV_0 - admin #
*
* @param {string} id id
*/
@Get("admin/detail/{id}")
async GetDevelopemtScholarshipUserDetailAdminById(
@Request() request: RequestWithUser,
@Path() id: string,
) {
let _workflow = await new permission().Workflow(request, id, "SYS_DEV_SCHOLARSHIP");
if (_workflow == false) await new permission().PermissionGet(request, "SYS_DEV_SCHOLARSHIP");
const getDevelopment = await this.developmentScholarshipRepository.findOne({
where: { id: id },
select: [
"id",
"scholarshipYear",
"scholarshipType",
"fundType",
"bookNumber",
"bookDate",
"governmentDate",
"governmentEndDate",
"isGraduated",
"graduatedDate",
"graduatedReason",
"org",
],
});
if (!getDevelopment) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลทุนการศึกษา/ฝึกอบรมนี้");
}
return new HttpSuccess(getDevelopment);
}
/** /**
* API user * API user
* *
@ -621,6 +684,36 @@ export class DevelopmentScholarshipController extends Controller {
return new HttpSuccess(getDevelopment.id); return new HttpSuccess(getDevelopment.id);
} }
/**
* API admin
*
* @summary DEV_015 - admin #15
*
* @param {string} id
*/
@Put("admin/detail/{id}")
async UpdateDevelopemtScholarshipAdminById(
@Path() id: string,
@Body() requestBody: UpdateDevelopmentScholarshipUser,
@Request() request: RequestWithUser,
) {
await new permission().PermissionUpdate(request, "SYS_DEV_SCHOLARSHIP");
const getDevelopment = await this.developmentScholarshipRepository.findOne({
where: { id: id },
});
if (!getDevelopment) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลทุนการศึกษา/ฝึกอบรมนี้");
}
const before = structuredClone(getDevelopment);
Object.assign(getDevelopment, requestBody);
getDevelopment.lastUpdateUserId = request.user.sub;
getDevelopment.lastUpdateFullName = request.user.name;
getDevelopment.lastUpdatedAt = new Date();
await this.developmentScholarshipRepository.save(getDevelopment, { data: request });
setLogDataDiff(request, { before, after: getDevelopment });
return new HttpSuccess(getDevelopment.id);
}
/** /**
* API * API
* *

View file

@ -59,6 +59,30 @@ export class PortfolioController extends Controller {
return new HttpSuccess(_portfolio); return new HttpSuccess(_portfolio);
} }
/**
* API list
*
* @summary list
*
*/
@Get("user")
async GetResultForEva(@Request() request: RequestWithUser) {
const _portfolio = await this.portfolioRepository.find({
where: { createdUserId: request.user.sub },
select: [
"id",
"name",
"detail",
"createdAt",
"lastUpdatedAt",
"createdFullName",
"lastUpdateFullName",
],
order: { createdAt: "DESC" },
});
return new HttpSuccess(_portfolio);
}
/** /**
* API * API
* *
@ -79,6 +103,32 @@ export class PortfolioController extends Controller {
return new HttpSuccess(_portfolio); return new HttpSuccess(_portfolio);
} }
/**
* API ..7/..1
*
* @summary ..7/..1
*
*/
@Get("kk1/{keycloak}")
async GetPortfolio(@Path() keycloak: string, @Request() request: RequestWithUser) {
const _portfolio = await this.portfolioRepository.find({
where: { createdUserId: keycloak },
select: [
"name",
"createdAt"
],
order: { createdAt: "DESC" },
});
const result =
_portfolio.map(x => ({
name: x.name,
year: x.createdAt.getFullYear() > 2500
? x.createdAt.getFullYear()
: x.createdAt.getFullYear()+543
}));
return new HttpSuccess(result);
}
/** /**
* API body * API body
* *

View file

@ -16,6 +16,7 @@ import { isNotEmittedStatement } from "typescript";
@Tags("Report") @Tags("Report")
@Security("bearerAuth") @Security("bearerAuth")
export class ReportController extends Controller { export class ReportController extends Controller {
private developmentRepository = AppDataSource.getRepository(Development);
private developmentScholarshipRepository = AppDataSource.getRepository(DevelopmentScholarship); private developmentScholarshipRepository = AppDataSource.getRepository(DevelopmentScholarship);
private viewDevScholarship = AppDataSource.getRepository(viewDevScholarship); private viewDevScholarship = AppDataSource.getRepository(viewDevScholarship);
/** /**
@ -44,6 +45,7 @@ export class ReportController extends Controller {
.leftJoinAndSelect("development.strategyChild5Actual", "strategy5") .leftJoinAndSelect("development.strategyChild5Actual", "strategy5")
.where("development.status = :status", { status: "FINISH" }) .where("development.status = :status", { status: "FINISH" })
.andWhere("development.strategyChild1ActualId IS NOT NULL") .andWhere("development.strategyChild1ActualId IS NOT NULL")
.andWhere("development.rootDnaId = :rootDnaId", { rootDnaId: rootId })
.select([ .select([
"development.id AS id", "development.id AS id",
"development.projectName AS projectName", "development.projectName AS projectName",
@ -114,6 +116,7 @@ export class ReportController extends Controller {
.leftJoinAndSelect("development.strategyChild1Actual", "strategy1") .leftJoinAndSelect("development.strategyChild1Actual", "strategy1")
.where("development.status = :status", { status: "FINISH" }) .where("development.status = :status", { status: "FINISH" })
.andWhere("development.strategyChild1ActualId IS NOT NULL") .andWhere("development.strategyChild1ActualId IS NOT NULL")
.andWhere("development.rootDnaId = :rootDnaId", { rootDnaId: rootId })
.select([ .select([
"development.rootId AS rootId", "development.rootId AS rootId",
"development.strategyChild1ActualId AS strategyId", "development.strategyChild1ActualId AS strategyId",
@ -377,10 +380,17 @@ export class ReportController extends Controller {
return formattedGroup; return formattedGroup;
}); });
const dev = await this.developmentRepository.findOne({
where: { rootDnaId: rootId },
select: ["root", "year"]
})
return new HttpSuccess({ return new HttpSuccess({
template: "development", template: "development",
reportName: "development", reportName: "development",
data: { data: {
root: dev && dev.root ? dev.root : "-",
year: dev && dev.year ? Extension.ToThaiNumber((dev.year+543).toString()) : "-",
data: mappedDataDev, data: mappedDataDev,
resultAllStrategy: reformattedData, resultAllStrategy: reformattedData,
sumDev1: Extension.ToThaiNumber(sumDev1.toLocaleString()) ?? "-", sumDev1: Extension.ToThaiNumber(sumDev1.toLocaleString()) ?? "-",
@ -431,7 +441,7 @@ export class ReportController extends Controller {
.andWhere(body.year != 0 && body.year != null ? "development.year = :year" : "1=1", { .andWhere(body.year != 0 && body.year != null ? "development.year = :year" : "1=1", {
year: body.year, year: body.year,
}) })
.andWhere(body.root != null ? "development.root = :root" : "1=1", { .andWhere(body.root != null ? "developmentHistory.root = :root" : "1=1", {
root: body.root, root: body.root,
}) })
.andWhere("developmentHistory.type = :type", { type: "OFFICER" }) .andWhere("developmentHistory.type = :type", { type: "OFFICER" })
@ -495,7 +505,7 @@ export class ReportController extends Controller {
.andWhere(body.year != 0 && body.year != null ? "development.year = :year" : "1=1", { .andWhere(body.year != 0 && body.year != null ? "development.year = :year" : "1=1", {
year: body.year, year: body.year,
}) })
.andWhere(body.root != null ? "development.root = :root" : "1=1", { .andWhere(body.root != null ? "developmentHistory.root = :root" : "1=1", {
root: body.root, root: body.root,
}) })
.andWhere("developmentHistory.type = :type", { type: "EMPLOYEE" }) .andWhere("developmentHistory.type = :type", { type: "EMPLOYEE" })
@ -580,31 +590,39 @@ export class ReportController extends Controller {
break; break;
case "NOABROAD": case "NOABROAD":
getDevelopment.scholarshipType = getDevelopment.scholarshipType =
"ฝึกอบรมในประเทศที่ส่งไปพัฒนากับหน่วยงานภายนอก (หลักสูตรที่ไม่มีการไปต่างประเทศ)"; "ฝึกอบรมในประเทศที่ส่งไปพัฒนากับหน่วยงานภายนอก (หลักสูตรที่ไม่มีการไปต่างประเทศ)";
break; break;
case "ABROAD": case "ABROAD":
getDevelopment.scholarshipType = getDevelopment.scholarshipType =
"ฝึกอบรมในประเทศที่ส่งไปพัฒนากับหน่วยงานภายนอก (หลักสูตรที่มีการไปต่างประเทศ)"; "ฝึกอบรมในประเทศที่ส่งไปพัฒนากับหน่วยงานภายนอก (หลักสูตรที่มีการไปต่างประเทศ)";
break; break;
case "EXECUTIVE": case "EXECUTIVE":
getDevelopment.scholarshipType = getDevelopment.scholarshipType =
"ฝึกอบรมในประเทศที่ส่งไปพัฒนากับหน่วยงานภายนอก (หลักสูตรประเภทนักบริหาร)"; "ฝึกอบรมในประเทศที่ส่งไปพัฒนากับหน่วยงานภายนอก (หลักสูตรประเภทนักบริหาร)";
break; break;
case "RESEARCH": case "RESEARCH":
getDevelopment.scholarshipType = getDevelopment.scholarshipType =
"ศึกษา ฝึกอบรม ประชุม ดูงาน และปฏิบัติการวิจัย ณ ต่างประเทศ"; "ศึกษา ฝึกอบรม ประชุม ดูงาน และปฏิบัติการวิจัย ณ ต่างประเทศ";
break; break;
case "STUDY":
getDevelopment.scholarshipType =
"ทุนการศึกษา ณ ต่างประเทศ";
break;
case "TRAINING":
getDevelopment.scholarshipType =
"ทุนฝึกอบรม ณ ต่างประเทศ";
break;
default: default:
break; break;
} }
} }
let _orgNoNewLine = (getDevelopment.org ? getDevelopment.org : "-").replace(/\n/g, " ");
const formattedData = { const formattedData = {
id: getDevelopment.id, id: getDevelopment.id,
firstName: getDevelopment.firstName, firstName: getDevelopment.firstName,
lastName: getDevelopment.lastName, lastName: getDevelopment.lastName,
position: getDevelopment.position, position: getDevelopment.position,
org: getDevelopment.org, org: _orgNoNewLine,
degreeLevel: getDevelopment.degreeLevel, degreeLevel: getDevelopment.degreeLevel,
course: getDevelopment.course, course: getDevelopment.course,
field: getDevelopment.field, field: getDevelopment.field,
@ -640,7 +658,7 @@ export class ReportController extends Controller {
: Extension.ToThaiNumber(Extension.ToThaiFullDate3(getDevelopment.graduatedDate)), : Extension.ToThaiNumber(Extension.ToThaiFullDate3(getDevelopment.graduatedDate)),
graduatedReason: getDevelopment.graduatedReason == null ? "" : getDevelopment.graduatedReason, graduatedReason: getDevelopment.graduatedReason == null ? "" : getDevelopment.graduatedReason,
useOfficialTime: getDevelopment.useOfficialTime, useOfficialTime: getDevelopment.useOfficialTime,
useOffTime: getDevelopment.useOfficialTime == true ? "🗹 ใช้ ☐ ไม่ใช้" : "☐ ใช้ 🗹 ไม่ใช้", useOffTime: getDevelopment.useOfficialTime == "NOUSETIME" ? "🗹 ใช้ ☐ ไม่ใช้" : "☐ ใช้ 🗹 ไม่ใช้",
isGraduated: getDevelopment.isGraduated, isGraduated: getDevelopment.isGraduated,
isG1: getDevelopment.isGraduated == true ? "🗹" : "☐", isG1: getDevelopment.isGraduated == true ? "🗹" : "☐",
isG2: getDevelopment.isGraduated == true ? "☐" : "🗹", isG2: getDevelopment.isGraduated == true ? "☐" : "🗹",

View file

@ -6,6 +6,7 @@ import {
Patch, Patch,
Path, Path,
Post, Post,
Put,
Request, Request,
Route, Route,
Security, Security,
@ -43,32 +44,46 @@ export class StrategyController extends Controller {
"strategyChild2s.strategyChild3s.strategyChild4s", "strategyChild2s.strategyChild3s.strategyChild4s",
"strategyChild2s.strategyChild3s.strategyChild4s.strategyChild5s", "strategyChild2s.strategyChild3s.strategyChild4s.strategyChild5s",
], ],
order: { createdAt: "ASC" }, order: {
order: "ASC",
strategyChild2s: {
order: "ASC",
strategyChild3s: {
order: "ASC",
strategyChild4s: { order: "ASC", strategyChild5s: { order: "ASC" } },
},
},
},
}); });
const formattedData = listStrategyChild1.map((item) => ({ const formattedData = listStrategyChild1.map((item) => ({
id: item.id, id: item.id,
level: 1, level: 1,
name: item.strategyChild1Name, name: item.strategyChild1Name,
order: item.order,
children: item.strategyChild2s.map((child2) => ({ children: item.strategyChild2s.map((child2) => ({
id: child2.id, id: child2.id,
level: 2, level: 2,
name: child2.strategyChild2Name, name: child2.strategyChild2Name,
order: child2.order,
children: child2.strategyChild3s children: child2.strategyChild3s
? child2.strategyChild3s.map((child3) => ({ ? child2.strategyChild3s.map((child3) => ({
id: child3.id, id: child3.id,
level: 3, level: 3,
name: child3.strategyChild3Name, name: child3.strategyChild3Name,
order: child3.order,
children: child3.strategyChild4s children: child3.strategyChild4s
? child3.strategyChild4s.map((child4) => ({ ? child3.strategyChild4s.map((child4) => ({
id: child4.id, id: child4.id,
level: 4, level: 4,
name: child4.strategyChild4Name, name: child4.strategyChild4Name,
order: child4.order,
children: child4.strategyChild5s children: child4.strategyChild5s
? child4.strategyChild5s.map((child5) => ({ ? child4.strategyChild5s.map((child5) => ({
id: child5.id, id: child5.id,
level: 5, level: 5,
name: child5.strategyChild5Name, name: child5.strategyChild5Name,
order: child5.order,
})) }))
: [], : [],
})) }))
@ -100,7 +115,16 @@ export class StrategyController extends Controller {
"strategyChild2s.strategyChild3s.strategyChild4s", "strategyChild2s.strategyChild3s.strategyChild4s",
"strategyChild2s.strategyChild3s.strategyChild4s.strategyChild5s", "strategyChild2s.strategyChild3s.strategyChild4s.strategyChild5s",
], ],
order: { createdAt: "ASC" }, order: {
order: "ASC",
strategyChild2s: {
order: "ASC",
strategyChild3s: {
order: "ASC",
strategyChild4s: { order: "ASC", strategyChild5s: { order: "ASC" } },
},
},
},
}); });
// if (!listStrategyChild1 || listStrategyChild1.length === 0) { // if (!listStrategyChild1 || listStrategyChild1.length === 0) {
@ -111,25 +135,30 @@ export class StrategyController extends Controller {
id: item.id, id: item.id,
level: 1, level: 1,
name: item.strategyChild1Name, name: item.strategyChild1Name,
order: item.order,
children: item.strategyChild2s.map((child2) => ({ children: item.strategyChild2s.map((child2) => ({
id: child2.id, id: child2.id,
level: 2, level: 2,
name: child2.strategyChild2Name, name: child2.strategyChild2Name,
order: child2.order,
children: child2.strategyChild3s children: child2.strategyChild3s
? child2.strategyChild3s.map((child3) => ({ ? child2.strategyChild3s.map((child3) => ({
id: child3.id, id: child3.id,
level: 3, level: 3,
name: child3.strategyChild3Name, name: child3.strategyChild3Name,
order: child3.order,
children: child3.strategyChild4s children: child3.strategyChild4s
? child3.strategyChild4s.map((child4) => ({ ? child3.strategyChild4s.map((child4) => ({
id: child4.id, id: child4.id,
level: 4, level: 4,
name: child4.strategyChild4Name, name: child4.strategyChild4Name,
order: child4.order,
children: child4.strategyChild5s children: child4.strategyChild5s
? child4.strategyChild5s.map((child5) => ({ ? child4.strategyChild5s.map((child5) => ({
id: child5.id, id: child5.id,
level: 5, level: 5,
name: child5.strategyChild5Name, name: child5.strategyChild5Name,
order: child5.order,
})) }))
: [], : [],
})) }))
@ -151,7 +180,16 @@ export class StrategyController extends Controller {
"strategyChild2s.strategyChild3s.strategyChild4s", "strategyChild2s.strategyChild3s.strategyChild4s",
"strategyChild2s.strategyChild3s.strategyChild4s.strategyChild5s", "strategyChild2s.strategyChild3s.strategyChild4s.strategyChild5s",
], ],
order: { createdAt: "ASC" }, order: {
order: "ASC",
strategyChild2s: {
order: "ASC",
strategyChild3s: {
order: "ASC",
strategyChild4s: { order: "ASC", strategyChild5s: { order: "ASC" } },
},
},
},
}); });
// if (!listStrategyChild1 || listStrategyChild1.length === 0) { // if (!listStrategyChild1 || listStrategyChild1.length === 0) {
@ -162,25 +200,30 @@ export class StrategyController extends Controller {
id: item.id, id: item.id,
level: 1, level: 1,
name: item.strategyChild1Name, name: item.strategyChild1Name,
order: item.order,
children: item.strategyChild2s.map((child2) => ({ children: item.strategyChild2s.map((child2) => ({
id: child2.id, id: child2.id,
level: 2, level: 2,
name: child2.strategyChild2Name, name: child2.strategyChild2Name,
order: child2.order,
children: child2.strategyChild3s children: child2.strategyChild3s
? child2.strategyChild3s.map((child3) => ({ ? child2.strategyChild3s.map((child3) => ({
id: child3.id, id: child3.id,
level: 3, level: 3,
name: child3.strategyChild3Name, name: child3.strategyChild3Name,
order: child3.order,
children: child3.strategyChild4s children: child3.strategyChild4s
? child3.strategyChild4s.map((child4) => ({ ? child3.strategyChild4s.map((child4) => ({
id: child4.id, id: child4.id,
level: 4, level: 4,
name: child4.strategyChild4Name, name: child4.strategyChild4Name,
order: child4.order,
children: child4.strategyChild5s children: child4.strategyChild5s
? child4.strategyChild5s.map((child5) => ({ ? child4.strategyChild5s.map((child5) => ({
id: child5.id, id: child5.id,
level: 5, level: 5,
name: child5.strategyChild5Name, name: child5.strategyChild5Name,
order: child5.order,
})) }))
: [], : [],
})) }))
@ -210,22 +253,31 @@ export class StrategyController extends Controller {
switch (body.levelnode) { switch (body.levelnode) {
case 0: case 0:
const ckOrder = await this.strategy1Repo.findOne({
where: {},
order: { order: "DESC" },
});
strategyRepo = this.strategy1Repo;
strategyRepo = this.strategy1Repo; strategyRepo = this.strategy1Repo;
repoSave = this.strategy1Repo; repoSave = this.strategy1Repo;
strategyChild = new StrategyChild1(); strategyChild = new StrategyChild1();
strategyChild.strategyChild1Name = body.name; strategyChild.strategyChild1Name = body.name;
strategyChild.order = ckOrder ? ckOrder.order + 1 : 1;
break; break;
case 1: case 1:
strategyRepo = this.strategy1Repo; strategyRepo = this.strategy1Repo;
repoSave = this.strategy2Repo; repoSave = this.strategy2Repo;
strategyChild = new StrategyChild2(); strategyChild = new StrategyChild2();
strategyChild.strategyChild2Name = body.name; strategyChild.strategyChild2Name = body.name;
strategyChild.order = 1;
if (body.idnode) { if (body.idnode) {
const chk1 = await this.strategy1Repo.findOne({ const chk1 = await this.strategy1Repo.findOne({
where: { id: body.idnode }, where: { id: body.idnode },
order: { order: "DESC" },
}); });
if (chk1) { if (chk1) {
strategyChild.strategyChild1Id = chk1.id; strategyChild.strategyChild1Id = chk1.id;
strategyChild.order = chk1 ? chk1.order + 1 : 1;
} else { } else {
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลยุทธศาสตร์"); throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลยุทธศาสตร์");
} }
@ -236,13 +288,16 @@ export class StrategyController extends Controller {
repoSave = this.strategy3Repo; repoSave = this.strategy3Repo;
strategyChild = new StrategyChild3(); strategyChild = new StrategyChild3();
strategyChild.strategyChild3Name = body.name; strategyChild.strategyChild3Name = body.name;
strategyChild.order = 1;
if (body.idnode) { if (body.idnode) {
const chk2 = await this.strategy2Repo.findOne({ const chk2 = await this.strategy2Repo.findOne({
where: { id: body.idnode }, where: { id: body.idnode },
order: { order: "DESC" },
}); });
if (chk2) { if (chk2) {
strategyChild.strategyChild1Id = chk2.strategyChild1Id; strategyChild.strategyChild1Id = chk2.strategyChild1Id;
strategyChild.strategyChild2Id = chk2.id; strategyChild.strategyChild2Id = chk2.id;
strategyChild.order = chk2 ? chk2.order + 1 : 1;
} else { } else {
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลยุทธศาสตร์"); throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลยุทธศาสตร์");
} }
@ -253,14 +308,17 @@ export class StrategyController extends Controller {
repoSave = this.strategy4Repo; repoSave = this.strategy4Repo;
strategyChild = new StrategyChild4(); strategyChild = new StrategyChild4();
strategyChild.strategyChild4Name = body.name; strategyChild.strategyChild4Name = body.name;
strategyChild.order = 1;
if (body.idnode) { if (body.idnode) {
const chk3 = await this.strategy3Repo.findOne({ const chk3 = await this.strategy3Repo.findOne({
where: { id: body.idnode }, where: { id: body.idnode },
order: { order: "DESC" },
}); });
if (chk3) { if (chk3) {
strategyChild.strategyChild1Id = chk3.strategyChild1Id; strategyChild.strategyChild1Id = chk3.strategyChild1Id;
strategyChild.strategyChild2Id = chk3.strategyChild2Id; strategyChild.strategyChild2Id = chk3.strategyChild2Id;
strategyChild.strategyChild3Id = chk3.id; strategyChild.strategyChild3Id = chk3.id;
strategyChild.order = chk3 ? chk3.order + 1 : 1;
} else { } else {
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลยุทธศาสตร์"); throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลยุทธศาสตร์");
} }
@ -271,15 +329,18 @@ export class StrategyController extends Controller {
repoSave = this.strategy5Repo; repoSave = this.strategy5Repo;
strategyChild = new StrategyChild5(); strategyChild = new StrategyChild5();
strategyChild.strategyChild5Name = body.name; strategyChild.strategyChild5Name = body.name;
strategyChild.order = 1;
if (body.idnode) { if (body.idnode) {
const chk4 = await this.strategy4Repo.findOne({ const chk4 = await this.strategy4Repo.findOne({
where: { id: body.idnode }, where: { id: body.idnode },
order: { order: "DESC" },
}); });
if (chk4) { if (chk4) {
strategyChild.strategyChild1Id = chk4.strategyChild1Id; strategyChild.strategyChild1Id = chk4.strategyChild1Id;
strategyChild.strategyChild2Id = chk4.strategyChild2Id; strategyChild.strategyChild2Id = chk4.strategyChild2Id;
strategyChild.strategyChild3Id = chk4.strategyChild3Id; strategyChild.strategyChild3Id = chk4.strategyChild3Id;
strategyChild.strategyChild4Id = chk4.id; strategyChild.strategyChild4Id = chk4.id;
strategyChild.order = chk4 ? chk4.order + 1 : 1;
} else { } else {
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลยุทธศาสตร์"); throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลยุทธศาสตร์");
} }
@ -594,4 +655,89 @@ export class StrategyController extends Controller {
throw new HttpError(HttpStatus.NOT_FOUND, "not found type: " + requestBody.strategy); throw new HttpError(HttpStatus.NOT_FOUND, "not found type: " + requestBody.strategy);
} }
} }
/**
* API
*
* @summary (ADMIN)
*
*/
@Post("sort")
async sortNode(
@Body() requestBody: { strategy: number; strategyId: string[]; id: string | null },
@Request() request: RequestWithUser,
) {
switch (requestBody.strategy) {
case 1: {
const data = await this.strategy1Repo.find();
if (data == null) {
throw new HttpError(HttpStatus.NOT_FOUND, "not found strategy1.");
}
const sortLevel = data.map((data) => ({
...data,
order: requestBody.strategyId.indexOf(data.id) + 1,
}));
await this.strategy1Repo.save(sortLevel);
return new HttpSuccess(sortLevel);
}
case 2: {
const data = await this.strategy2Repo.find({
where: { strategyChild1Id: requestBody.id ?? "" },
});
if (data == null) {
throw new HttpError(HttpStatus.NOT_FOUND, "not found strategy2.");
}
const sortLevel = data.map((data) => ({
...data,
order: requestBody.strategyId.indexOf(data.id) + 1,
}));
await this.strategy2Repo.save(sortLevel);
return new HttpSuccess(sortLevel);
}
case 3: {
const data = await this.strategy3Repo.find({
where: { strategyChild2Id: requestBody.id ?? "" },
});
if (data == null) {
throw new HttpError(HttpStatus.NOT_FOUND, "not found strategy3.");
}
const sortLevel = data.map((data) => ({
...data,
order: requestBody.strategyId.indexOf(data.id) + 1,
}));
await this.strategy3Repo.save(sortLevel);
return new HttpSuccess(sortLevel);
}
case 4: {
const data = await this.strategy4Repo.find({
where: { strategyChild3Id: requestBody.id ?? "" },
});
if (data == null) {
throw new HttpError(HttpStatus.NOT_FOUND, "not found strategy4.");
}
const sortLevel = data.map((data) => ({
...data,
order: requestBody.strategyId.indexOf(data.id) + 1,
}));
await this.strategy4Repo.save(sortLevel);
return new HttpSuccess(sortLevel);
}
case 5: {
const data = await this.strategy5Repo.find({
where: { strategyChild4Id: requestBody.id ?? "" },
});
if (data == null) {
throw new HttpError(HttpStatus.NOT_FOUND, "not found strategy5.");
}
const sortLevel = data.map((data) => ({
...data,
order: requestBody.strategyId.indexOf(data.id) + 1,
}));
await this.strategy5Repo.save(sortLevel);
return new HttpSuccess(sortLevel);
}
default:
throw new HttpError(HttpStatus.NOT_FOUND, "not found type: " + requestBody.strategy);
}
}
} }

View file

@ -29,25 +29,39 @@ export class ActualGoal extends EntityBase {
@Column({ @Column({
nullable: true, nullable: true,
comment: "ประเภทตำแหน่ง", comment: "ประเภทตำแหน่ง & กลุ่มงาน",
default: null, default: null,
}) })
posTypeActualId: string; posTypeActual: string;
@ManyToOne(() => PosType, (posType: PosType) => posType.actualGoals) // @Column({
@JoinColumn({ name: "posTypeActualId" }) // nullable: true,
posTypeActual: PosType; // comment: "ประเภทตำแหน่ง",
// default: null,
// })
// posTypeActualId: string;
// @ManyToOne(() => PosType, (posType: PosType) => posType.actualGoals)
// @JoinColumn({ name: "posTypeActualId" })
// posTypeActual: PosType;
@Column({ @Column({
nullable: true, nullable: true,
comment: "ระดับตำแหน่ง", comment: "ระดับตำแหน่ง & ระดับชั้นงาน",
default: null, default: null,
}) })
posLevelActualId: string; posLevelActual: string;
@ManyToOne(() => PosLevel, (posLevel: PosLevel) => posLevel.actualGoals) // @Column({
@JoinColumn({ name: "posLevelActualId" }) // nullable: true,
posLevelActual: PosLevel; // comment: "ระดับตำแหน่ง",
// default: null,
// })
// posLevelActualId: string;
// @ManyToOne(() => PosLevel, (posLevel: PosLevel) => posLevel.actualGoals)
// @JoinColumn({ name: "posLevelActualId" })
// posLevelActual: PosLevel;
@Column({ @Column({
nullable: true, nullable: true,
@ -82,10 +96,14 @@ export class CreateActualGoal {
groupTargetSub: string | null; groupTargetSub: string | null;
@Column() @Column()
position: string | null; position: string | null;
// @Column()
// posTypeActualId: string | null;
// @Column()
// posLevelActualId: string | null;
@Column() @Column()
posTypeActualId: string | null; posTypeActual: string | null;
@Column() @Column()
posLevelActualId: string | null; posLevelActual: string | null;
@Column() @Column()
type: string | null; type: string | null;
@Column() @Column()

View file

@ -20,7 +20,7 @@ export class DevelopmentAddress extends EntityBase {
@Column({ @Column({
nullable: true, nullable: true,
comment: "โครงการ/หลักสูตรการฝึกอบรม", comment: "ชื่อจังหวัด (กรณีเลือกสถานที่ดำเนินการในประเทศ)",
default: null, default: null,
}) })
provinceName: string; provinceName: string;
@ -32,6 +32,20 @@ export class DevelopmentAddress extends EntityBase {
}) })
developmentId: string; developmentId: string;
@Column({
nullable: true,
comment: "สถานที่ดำเนินการ ในประเทศ(IN_COUNTRY) หรือ ต่างประเทศ(ABROAD)",
default: null,
})
addressType: string;
@Column({
nullable: true,
comment: "ชื่อประเทศ (กรณีเลือกสถานที่ดำเนินการต่างประเทศ)",
default: null,
})
country: string;
@ManyToOne(() => Development, (development: Development) => development.developmentAddresss) @ManyToOne(() => Development, (development: Development) => development.developmentAddresss)
@JoinColumn({ name: "developmentId" }) @JoinColumn({ name: "developmentId" })
development: Development; development: Development;
@ -39,6 +53,16 @@ export class DevelopmentAddress extends EntityBase {
export class CreateDevelopmentAddress { export class CreateDevelopmentAddress {
@Column() @Column()
address: string | null; address: string | null;
@Column() @Column()
provinceId: string | null; provinceId: string | null;
@Column()
addressType?: string | null;
@Column()
provinceName?: string | null;
@Column()
country?: string | null;
} }

View file

@ -5,6 +5,13 @@ import { PosType } from "./PosType";
@Entity("developmentScholarship") @Entity("developmentScholarship")
export class DevelopmentScholarship extends EntityBase { export class DevelopmentScholarship extends EntityBase {
@Column({
nullable: true,
comment: "id dna หน่วยงาน",
default: null,
})
rootDnaId: string;
@Column({ @Column({
nullable: true, nullable: true,
comment: "id หน่วยงาน", comment: "id หน่วยงาน",
@ -137,6 +144,13 @@ export class DevelopmentScholarship extends EntityBase {
@JoinColumn({ name: "posTypeId" }) @JoinColumn({ name: "posTypeId" })
posType: PosType; posType: PosType;
@Column({
nullable: true,
comment: "id Dna หน่วยงาน",
default: null,
})
guarantorRootDnaId: string;
@Column({ @Column({
nullable: true, nullable: true,
comment: "id หน่วยงาน", comment: "id หน่วยงาน",
@ -301,7 +315,7 @@ export class DevelopmentScholarship extends EntityBase {
comment: "ใช้เวลาราชการ", comment: "ใช้เวลาราชการ",
default: false, default: false,
}) })
useOfficialTime: boolean; useOfficialTime: string;
@Column({ @Column({
nullable: true, nullable: true,
@ -567,8 +581,16 @@ export class DevelopmentScholarship extends EntityBase {
default: null, default: null,
}) })
graduatedReason: string; graduatedReason: string;
@Column({
nullable: true,
comment: "เงินอื่นๆ",
default: null,
})
budgetSourceOther: string;
} }
export class CreateDevelopmentScholarship { export class CreateDevelopmentScholarship {
rootDnaId?: string | null;
rootId: string | null; rootId: string | null;
root: string | null; root: string | null;
org: string | null; org: string | null;
@ -584,6 +606,7 @@ export class CreateDevelopmentScholarship {
posExecutive: string | null; posExecutive: string | null;
posLevelId: string | null; posLevelId: string | null;
posTypeId: string | null; posTypeId: string | null;
guarantorRootDnaId?: string | null;
guarantorRootId: string | null; guarantorRootId: string | null;
guarantorRoot: string | null; guarantorRoot: string | null;
guarantorOrg: string | null; guarantorOrg: string | null;
@ -604,7 +627,7 @@ export class CreateDevelopmentScholarship {
bookNo: string | null; bookNo: string | null;
bookNoDate: Date | null; bookNoDate: Date | null;
bookApproveDate: Date | null; bookApproveDate: Date | null;
useOfficialTime: boolean | false; useOfficialTime: string | null;
changeDetail: string | null; changeDetail: string | null;
scholarshipType: string | null; scholarshipType: string | null;
fundType: string | null; fundType: string | null;
@ -631,9 +654,11 @@ export class CreateDevelopmentScholarship {
totalPeriod: string | null; totalPeriod: string | null;
planType: string | null; planType: string | null;
isNoUseBudget: boolean | null; isNoUseBudget: boolean | null;
budgetSourceOther?: string | null;
} }
export class UpdateDevelopmentScholarship { export class UpdateDevelopmentScholarship {
rootDnaId?: string | null;
rootId: string | null; rootId: string | null;
root: string | null; root: string | null;
org: string | null; org: string | null;
@ -649,6 +674,7 @@ export class UpdateDevelopmentScholarship {
posExecutive: string | null; posExecutive: string | null;
posLevelId: string | null; posLevelId: string | null;
posTypeId: string | null; posTypeId: string | null;
guarantorRootDnaId?: string | null;
guarantorRootId?: string | null; guarantorRootId?: string | null;
guarantorRoot?: string | null; guarantorRoot?: string | null;
guarantorOrg?: string | null; guarantorOrg?: string | null;
@ -669,7 +695,7 @@ export class UpdateDevelopmentScholarship {
bookNo: string | null; bookNo: string | null;
bookNoDate: Date | null; bookNoDate: Date | null;
bookApproveDate: Date | null; bookApproveDate: Date | null;
useOfficialTime: boolean | false; useOfficialTime: string | null;
changeDetail: string | null; changeDetail: string | null;
scholarshipType: string | null; scholarshipType: string | null;
fundType: string | null; fundType: string | null;
@ -696,6 +722,7 @@ export class UpdateDevelopmentScholarship {
totalPeriod: string | null; totalPeriod: string | null;
planType: string | null; planType: string | null;
isNoUseBudget: boolean | null; isNoUseBudget: boolean | null;
budgetSourceOther?: string | null;
} }
export class UpdateDevelopmentScholarshipUser { export class UpdateDevelopmentScholarshipUser {
@ -706,4 +733,5 @@ export class UpdateDevelopmentScholarshipUser {
isGraduated: boolean | null; isGraduated: boolean | null;
graduatedDate: Date | null; graduatedDate: Date | null;
graduatedReason: string | null; graduatedReason: string | null;
budgetSourceOther?: string | null;
} }

View file

@ -22,25 +22,39 @@ export class PlannedGoalPosition extends EntityBase {
@Column({ @Column({
nullable: true, nullable: true,
comment: "ประเภทตำแหน่ง", comment: "ประเภทตำแหน่ง & กลุ่มงาน",
default: null, default: null,
}) })
posTypePlannedId: string; posTypePlanned: string;
@ManyToOne(() => PosType, (posType: PosType) => posType.plannedGoalPositions) // @Column({
@JoinColumn({ name: "posTypePlannedId" }) // nullable: true,
posTypePlanned: PosType; // comment: "ประเภทตำแหน่ง",
// default: null,
// })
// posTypePlannedId: string;
// @ManyToOne(() => PosType, (posType: PosType) => posType.plannedGoalPositions)
// @JoinColumn({ name: "posTypePlannedId" })
// posTypePlanned: PosType;
@Column({ @Column({
nullable: true, nullable: true,
comment: "ระดับตำแหน่ง", comment: "ระดับตำแหน่ง & ระดับชั้นงาน",
default: null, default: null,
}) })
posLevelPlannedId: string; posLevelPlanned: string;
@ManyToOne(() => PosLevel, (posLevel: PosLevel) => posLevel.plannedGoalPositions) // @Column({
@JoinColumn({ name: "posLevelPlannedId" }) // nullable: true,
posLevelPlanned: PosLevel; // comment: "ระดับตำแหน่ง",
// default: null,
// })
// posLevelPlannedId: string;
// @ManyToOne(() => PosLevel, (posLevel: PosLevel) => posLevel.plannedGoalPositions)
// @JoinColumn({ name: "posLevelPlannedId" })
// posLevelPlanned: PosLevel;
@Column({ @Column({
nullable: true, nullable: true,
@ -59,10 +73,14 @@ export class CreatePlannedGoalPosition {
position: string | null; position: string | null;
@Column() @Column()
posExecutive: string | null; posExecutive: string | null;
// @Column()
// posTypePlannedId: string | null;
// @Column()
// posLevelPlannedId: string | null;
@Column() @Column()
posTypePlannedId: string | null; posTypePlanned: string | null;
@Column() @Column()
posLevelPlannedId: string | null; posLevelPlanned: string | null;
} }
export type UpdatePlannedGoalPosition = Partial<CreatePlannedGoalPosition>; export type UpdatePlannedGoalPosition = Partial<CreatePlannedGoalPosition>;

View file

@ -48,14 +48,14 @@ export class PosLevel extends EntityBase {
@JoinColumn({ name: "posTypeId" }) @JoinColumn({ name: "posTypeId" })
posType: PosType; posType: PosType;
@OneToMany(() => ActualGoal, (actualGoal: ActualGoal) => actualGoal.posLevelActual) // @OneToMany(() => ActualGoal, (actualGoal: ActualGoal) => actualGoal.posLevelActual)
actualGoals: ActualGoal[]; // actualGoals: ActualGoal[];
@OneToMany( // @OneToMany(
() => PlannedGoalPosition, // () => PlannedGoalPosition,
(plannedGoalPosition: PlannedGoalPosition) => plannedGoalPosition.posLevelPlanned, // (plannedGoalPosition: PlannedGoalPosition) => plannedGoalPosition.posLevelPlanned,
) // )
plannedGoalPositions: PlannedGoalPosition[]; // plannedGoalPositions: PlannedGoalPosition[];
@OneToMany(() => DevelopmentHistory, (developmentHistory) => developmentHistory.posLevel) @OneToMany(() => DevelopmentHistory, (developmentHistory) => developmentHistory.posLevel)
developmentHistorys: DevelopmentHistory[]; developmentHistorys: DevelopmentHistory[];

View file

@ -28,14 +28,14 @@ export class PosType extends EntityBase {
@OneToMany(() => PosLevel, (posLevel: PosLevel) => posLevel.posType) @OneToMany(() => PosLevel, (posLevel: PosLevel) => posLevel.posType)
posLevels: PosLevel[]; posLevels: PosLevel[];
@OneToMany(() => ActualGoal, (actualGoal: ActualGoal) => actualGoal.posTypeActual) // @OneToMany(() => ActualGoal, (actualGoal: ActualGoal) => actualGoal.posTypeActual)
actualGoals: ActualGoal[]; // actualGoals: ActualGoal[];
@OneToMany( // @OneToMany(
() => PlannedGoalPosition, // () => PlannedGoalPosition,
(plannedGoalPosition: PlannedGoalPosition) => plannedGoalPosition.posTypePlanned, // (plannedGoalPosition: PlannedGoalPosition) => plannedGoalPosition.posTypePlanned,
) // )
plannedGoalPositions: PlannedGoalPosition[]; // plannedGoalPositions: PlannedGoalPosition[];
@OneToMany(() => DevelopmentHistory, (developmentHistory) => developmentHistory.posType) @OneToMany(() => DevelopmentHistory, (developmentHistory) => developmentHistory.posType)
developmentHistorys: DevelopmentHistory[]; developmentHistorys: DevelopmentHistory[];

View file

@ -16,6 +16,13 @@ export class StrategyChild1 extends EntityBase {
}) })
strategyChild1Name: string; strategyChild1Name: string;
@Column({
nullable: true,
comment: "ลำดับความสำคัญ",
default: null,
})
order: number;
@OneToMany(() => StrategyChild2, (strategyChild2) => strategyChild2.strategyChild1) @OneToMany(() => StrategyChild2, (strategyChild2) => strategyChild2.strategyChild1)
strategyChild2s: StrategyChild2[]; strategyChild2s: StrategyChild2[];

View file

@ -22,6 +22,13 @@ export class StrategyChild2 extends EntityBase {
}) })
strategyChild1Id: string; strategyChild1Id: string;
@Column({
nullable: true,
comment: "ลำดับความสำคัญ",
default: null,
})
order: number;
@ManyToOne(() => StrategyChild1, (strategyChild1) => strategyChild1.strategyChild2s) @ManyToOne(() => StrategyChild1, (strategyChild1) => strategyChild1.strategyChild2s)
@JoinColumn({ name: "strategyChild1Id" }) @JoinColumn({ name: "strategyChild1Id" })
strategyChild1: StrategyChild1; strategyChild1: StrategyChild1;

View file

@ -28,6 +28,13 @@ export class StrategyChild3 extends EntityBase {
}) })
strategyChild2Id: string; strategyChild2Id: string;
@Column({
nullable: true,
comment: "ลำดับความสำคัญ",
default: null,
})
order: number;
@ManyToOne(() => StrategyChild1, (strategyChild1) => strategyChild1.strategyChild3s) @ManyToOne(() => StrategyChild1, (strategyChild1) => strategyChild1.strategyChild3s)
@JoinColumn({ name: "strategyChild1Id" }) @JoinColumn({ name: "strategyChild1Id" })
strategyChild1: StrategyChild1; strategyChild1: StrategyChild1;

View file

@ -34,6 +34,13 @@ export class StrategyChild4 extends EntityBase {
}) })
strategyChild3Id: string; strategyChild3Id: string;
@Column({
nullable: true,
comment: "ลำดับความสำคัญ",
default: null,
})
order: number;
@ManyToOne(() => StrategyChild1, (strategyChild1) => strategyChild1.strategyChild4s) @ManyToOne(() => StrategyChild1, (strategyChild1) => strategyChild1.strategyChild4s)
@JoinColumn({ name: "strategyChild1Id" }) @JoinColumn({ name: "strategyChild1Id" })
strategyChild1: StrategyChild1; strategyChild1: StrategyChild1;

View file

@ -40,6 +40,13 @@ export class StrategyChild5 extends EntityBase {
}) })
strategyChild4Id: string; strategyChild4Id: string;
@Column({
nullable: true,
comment: "ลำดับความสำคัญ",
default: null,
})
order: number;
@ManyToOne(() => StrategyChild1, (strategyChild1) => strategyChild1.strategyChild5s) @ManyToOne(() => StrategyChild1, (strategyChild1) => strategyChild1.strategyChild5s)
@JoinColumn({ name: "strategyChild1Id" }) @JoinColumn({ name: "strategyChild1Id" })
strategyChild1: StrategyChild1; strategyChild1: StrategyChild1;

View file

@ -19,10 +19,20 @@ export type LogSequence = {
}; };
export function setLogDataDiff(req: RequestWithUser, data: DataDiff) { export function setLogDataDiff(req: RequestWithUser, data: DataDiff) {
// Check if data.before and data.after are valid objects
if (
data.before &&
typeof data.before === "object" &&
data.after &&
typeof data.after === "object"
) {
req.app.locals.logData.dataDiff = { req.app.locals.logData.dataDiff = {
before: JSON.stringify(data.before), before: JSON.stringify(data.before),
after: JSON.stringify(data.after), after: JSON.stringify(data.after),
}; };
} else {
console.error("Invalid data provided: both before and after must be valid objects.");
}
} }
export function addLogSequence(req: RequestWithUser, data: LogSequence) { export function addLogSequence(req: RequestWithUser, data: LogSequence) {

View file

@ -1,14 +0,0 @@
import { MigrationInterface, QueryRunner } from "typeorm";
export class UpdateDevelopmentHisAddIsDoneIDP1727719189429 implements MigrationInterface {
name = 'UpdateDevelopmentHisAddIsDoneIDP1727719189429'
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`developmentHistory\` ADD \`isDoneIDP\` tinyint NOT NULL COMMENT 'บันทึก IDP ที่ทะเบียนประวัติ' DEFAULT 0`);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`developmentHistory\` DROP COLUMN \`isDoneIDP\``);
}
}

View file

@ -1,24 +0,0 @@
import { MigrationInterface, QueryRunner } from "typeorm";
export class UpdateDevelopmentAddIsReasonActual701727753251629 implements MigrationInterface {
name = 'UpdateDevelopmentAddIsReasonActual701727753251629'
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`development\` ADD \`isReasonPlanned70\` tinyint NOT NULL COMMENT 'รายละเอียดอื่นๆ 70 แผน' DEFAULT 0`);
await queryRunner.query(`ALTER TABLE \`development\` ADD \`isReasonPlanned20\` tinyint NOT NULL COMMENT 'รายละเอียดอื่นๆ 20 แผน' DEFAULT 0`);
await queryRunner.query(`ALTER TABLE \`development\` ADD \`isReasonPlanned10\` varchar(255) NULL COMMENT 'รายละเอียดอื่นๆ 10 แผน'`);
await queryRunner.query(`ALTER TABLE \`development\` ADD \`isReasonActual70\` tinyint NOT NULL COMMENT 'รายละเอียดอื่นๆ 70 จริง' DEFAULT 0`);
await queryRunner.query(`ALTER TABLE \`development\` ADD \`isReasonActual20\` tinyint NOT NULL COMMENT 'รายละเอียดอื่นๆ 20 จริง' DEFAULT 0`);
await queryRunner.query(`ALTER TABLE \`development\` ADD \`isReasonActual10\` varchar(255) NULL COMMENT 'รายละเอียดอื่นๆ 10 จริง'`);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`isReasonActual10\``);
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`isReasonActual20\``);
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`isReasonActual70\``);
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`isReasonPlanned10\``);
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`isReasonPlanned20\``);
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`isReasonPlanned70\``);
}
}

View file

@ -1,20 +0,0 @@
import { MigrationInterface, QueryRunner } from "typeorm";
export class UpdateDevelopmentAddIsReasonActual101727755044851 implements MigrationInterface {
name = 'UpdateDevelopmentAddIsReasonActual101727755044851'
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`isReasonPlanned10\``);
await queryRunner.query(`ALTER TABLE \`development\` ADD \`isReasonPlanned10\` tinyint NOT NULL COMMENT 'รายละเอียดอื่นๆ 10 แผน' DEFAULT 0`);
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`isReasonActual10\``);
await queryRunner.query(`ALTER TABLE \`development\` ADD \`isReasonActual10\` tinyint NOT NULL COMMENT 'รายละเอียดอื่นๆ 10 จริง' DEFAULT 0`);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`isReasonActual10\``);
await queryRunner.query(`ALTER TABLE \`development\` ADD \`isReasonActual10\` varchar(255) NULL COMMENT 'รายละเอียดอื่นๆ 10 จริง'`);
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`isReasonPlanned10\``);
await queryRunner.query(`ALTER TABLE \`development\` ADD \`isReasonPlanned10\` varchar(255) NULL COMMENT 'รายละเอียดอื่นๆ 10 แผน'`);
}
}

View file

@ -1,22 +0,0 @@
import { MigrationInterface, QueryRunner } from "typeorm";
export class UpdateDeleteDevProvincename1737111015155 implements MigrationInterface {
name = 'UpdateDeleteDevProvincename1737111015155'
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`developmentAddress\` DROP FOREIGN KEY \`FK_e2721b3f440256b56ce83a04fb2\``);
await queryRunner.query(`ALTER TABLE \`developmentOther\` DROP FOREIGN KEY \`FK_47bbbecaea9b7b31d2536054656\``);
await queryRunner.query(`ALTER TABLE \`development\` DROP FOREIGN KEY \`FK_bdafbb824b88c3bdb73adf7f220\``);
await queryRunner.query(`ALTER TABLE \`developmentAddress\` ADD \`provinceName\` varchar(255) NULL COMMENT 'โครงการ/หลักสูตรการฝึกอบรม'`);
await queryRunner.query(`ALTER TABLE \`developmentOther\` ADD \`provinceActualName\` varchar(255) NULL COMMENT 'จังหวัด(ข้อมูลวิชาการ)'`);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`developmentOther\` DROP COLUMN \`provinceActualName\``);
await queryRunner.query(`ALTER TABLE \`developmentAddress\` DROP COLUMN \`provinceName\``);
await queryRunner.query(`ALTER TABLE \`development\` ADD CONSTRAINT \`FK_bdafbb824b88c3bdb73adf7f220\` FOREIGN KEY (\`provinceActualId\`) REFERENCES \`province\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
await queryRunner.query(`ALTER TABLE \`developmentOther\` ADD CONSTRAINT \`FK_47bbbecaea9b7b31d2536054656\` FOREIGN KEY (\`provinceActualId\`) REFERENCES \`province\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
await queryRunner.query(`ALTER TABLE \`developmentAddress\` ADD CONSTRAINT \`FK_e2721b3f440256b56ce83a04fb2\` FOREIGN KEY (\`provinceId\`) REFERENCES \`province\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
}
}

View file

@ -1,28 +0,0 @@
import { MigrationInterface, QueryRunner } from "typeorm";
export class Updatedevadddna1738201344610 implements MigrationInterface {
name = 'Updatedevadddna1738201344610'
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`DROP INDEX \`FK_e2721b3f440256b56ce83a04fb2\` ON \`developmentAddress\``);
await queryRunner.query(`DROP INDEX \`FK_47bbbecaea9b7b31d2536054656\` ON \`developmentOther\``);
await queryRunner.query(`DROP INDEX \`FK_bdafbb824b88c3bdb73adf7f220\` ON \`development\``);
await queryRunner.query(`ALTER TABLE \`development\` ADD \`rootDnaId\` varchar(255) NULL COMMENT 'id Dna หน่วยงาน'`);
await queryRunner.query(`ALTER TABLE \`development\` ADD \`child1DnaId\` varchar(255) NULL COMMENT 'id Dna หน่วยงาน child1'`);
await queryRunner.query(`ALTER TABLE \`development\` ADD \`child2DnaId\` varchar(255) NULL COMMENT 'id Dna หน่วยงาน child2'`);
await queryRunner.query(`ALTER TABLE \`development\` ADD \`child3DnaId\` varchar(255) NULL COMMENT 'id Dna หน่วยงาน child3'`);
await queryRunner.query(`ALTER TABLE \`development\` ADD \`child4DnaId\` varchar(255) NULL COMMENT 'id Dna หน่วยงาน child4'`);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`child4DnaId\``);
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`child3DnaId\``);
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`child2DnaId\``);
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`child1DnaId\``);
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`rootDnaId\``);
await queryRunner.query(`CREATE INDEX \`FK_bdafbb824b88c3bdb73adf7f220\` ON \`development\` (\`provinceActualId\`)`);
await queryRunner.query(`CREATE INDEX \`FK_47bbbecaea9b7b31d2536054656\` ON \`developmentOther\` (\`provinceActualId\`)`);
await queryRunner.query(`CREATE INDEX \`FK_e2721b3f440256b56ce83a04fb2\` ON \`developmentAddress\` (\`provinceId\`)`);
}
}

View file

@ -1,23 +0,0 @@
import { MigrationInterface, QueryRunner } from "typeorm";
export class UpdateView1739444714910 implements MigrationInterface {
name = 'UpdateView1739444714910'
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`CREATE VIEW \`view_dev_scholarship\` AS SELECT MAX(\`rootId\`) AS rootId,
MAX(\`root\`) AS root,\`degreeLevel\`,
COUNT(*) AS numberOfRecords,
COUNT(DISTINCT \`scholarshipType\`) AS numberOfScholarshipTypes,
SUM(\`budgetApprove\`) AS totalBudgetApprove
FROM \`developmentScholarship\`
GROUP BY \`rootId\`,\`degreeLevel\`
`);
await queryRunner.query(`INSERT INTO \`bma_ehr_development_demo\`.\`typeorm_metadata\`(\`database\`, \`schema\`, \`table\`, \`type\`, \`name\`, \`value\`) VALUES (DEFAULT, ?, DEFAULT, ?, ?, ?)`, ["bma_ehr_development_demo","VIEW","view_dev_scholarship","SELECT MAX(`rootId`) AS rootId, \n MAX(`root`) AS root,`degreeLevel`,\n COUNT(*) AS numberOfRecords, \n COUNT(DISTINCT `scholarshipType`) AS numberOfScholarshipTypes,\n SUM(`budgetApprove`) AS totalBudgetApprove\n FROM `developmentScholarship`\n GROUP BY `rootId`,`degreeLevel`"]);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`DELETE FROM \`bma_ehr_development_demo\`.\`typeorm_metadata\` WHERE \`type\` = ? AND \`name\` = ? AND \`schema\` = ?`, ["VIEW","view_dev_scholarship","bma_ehr_development_demo"]);
await queryRunner.query(`DROP VIEW \`view_dev_scholarship\``);
}
}

View file

@ -1,23 +0,0 @@
import { MigrationInterface, QueryRunner } from "typeorm";
export class UpdateViewDevScholarship1739446719623 implements MigrationInterface {
name = 'UpdateViewDevScholarship1739446719623'
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`CREATE VIEW \`view_dev_scholarship\` AS SELECT MAX(\`rootId\`) AS rootId,
MAX(\`root\`) AS root,\`degreeLevel\`,
COUNT(*) AS numberOfRecords,
COUNT(DISTINCT \`scholarshipType\`) AS numberOfScholarshipTypes,
SUM(\`budgetApprove\`) AS totalBudgetApprove
FROM \`developmentScholarship\`
GROUP BY \`rootId\`,\`degreeLevel\`
`);
await queryRunner.query(`INSERT INTO \`bma_ehr_development_demo\`.\`typeorm_metadata\`(\`database\`, \`schema\`, \`table\`, \`type\`, \`name\`, \`value\`) VALUES (DEFAULT, ?, DEFAULT, ?, ?, ?)`, ["bma_ehr_development_demo","VIEW","view_dev_scholarship","SELECT MAX(`rootId`) AS rootId, \n MAX(`root`) AS root,`degreeLevel`,\n COUNT(*) AS numberOfRecords, \n COUNT(DISTINCT `scholarshipType`) AS numberOfScholarshipTypes,\n SUM(`budgetApprove`) AS totalBudgetApprove\n FROM `developmentScholarship`\n GROUP BY `rootId`,`degreeLevel`"]);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`DELETE FROM \`bma_ehr_development_demo\`.\`typeorm_metadata\` WHERE \`type\` = ? AND \`name\` = ? AND \`schema\` = ?`, ["VIEW","view_dev_scholarship","bma_ehr_development_demo"]);
await queryRunner.query(`DROP VIEW \`view_dev_scholarship\``);
}
}

View file

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

View file

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