Merge branch 'develop'

This commit is contained in:
moss 2025-05-14 20:52:33 +07:00
commit 3c41a39fca
11 changed files with 679 additions and 77 deletions

View file

@ -193,6 +193,34 @@ export class DirectorController {
}
}
/**
* API
*
* @summary (ADMIN)
*
*/
@Put("duty/{id}")
async updateDuty(@Path() id: string, @Body() body:{duty: string} , @Request() request: RequestWithUser) {
try {
await new permission().PermissionUpdate(request, "SYS_EVA_INFO");
let director = await this.directorRepository.findOneBy({ id });
if (!director) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลกรรมการ");
}
const before = structuredClone(director);
director.duty = body?.duty;
director.lastUpdateUserId = request.user.sub;
director.lastUpdateFullName = request.user.name;
director.lastUpdatedAt = new Date();
await this.directorRepository.save(director, { data: request });
setLogDataDiff(request, { before, after: director });
return new HttpSuccess();
} catch (error: any) {
if (error instanceof HttpError) {
throw error;
} else throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, error);
}
}
/**
* API
*

View file

@ -63,12 +63,12 @@ export class DocumentController extends Controller {
public async getFile(@Path() volume: string, @Path() id: string) {
try {
const list = await listFile(["ระบบประเมิน", volume, id]);
if (!list) throw new Error("เกิดข้อผิดพลาดกับระบบจัดการไฟล์ ไม่สามารถสร้างแฟ้มได้");
if (!list) throw new Error("เกิดข้อผิดพลาดกับระบบจัดการไฟล์ ไม่สามารถอ่านแฟ้มได้");
return list;
} catch (error: any) {
if (error instanceof HttpError) {
throw error;
} else throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, error);
} else throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, error.message);
}
}
@ -108,12 +108,12 @@ export class DocumentController extends Controller {
public async getFileDownload(@Path() id: string, @Path() volume: string, @Path() file: string) {
try {
const data = await downloadFile(["ระบบประเมิน", volume, id], file);
if (!data) throw new Error("เกิดข้อผิดพลาดกับระบบจัดการไฟล์ ไม่สามารถสร้างแฟ้มได้");
if (!data) throw new Error("เกิดข้อผิดพลาดกับระบบจัดการไฟล์ ไม่สามารถดาวน์โหลดไฟล์ได้");
return data;
} catch (error: any) {
if (error instanceof HttpError) {
throw error;
} else throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, error);
} else throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, error.message);
}
}
@ -219,7 +219,7 @@ export class DocumentController extends Controller {
const list = await listFile(["ระบบประเมิน", volume, id]);
if (!list || !Array.isArray(list)) {
throw new Error("เกิดข้อผิดพลาดกับระบบจัดการไฟล์ ไม่สามารถสร้างแฟ้มได้");
throw new Error("เกิดข้อผิดพลาดกับระบบจัดการไฟล์ ไม่สามารถอ่านแฟ้มได้");
}
// let used: string[] = [];
@ -299,7 +299,7 @@ export class DocumentController extends Controller {
} catch (error: any) {
if (error instanceof HttpError) {
throw error;
} else throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, error);
} else throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, error.message);
}
}
@ -336,7 +336,7 @@ export class DocumentController extends Controller {
} catch (error: any) {
if (error instanceof HttpError) {
throw error;
} else throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, error);
} else throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, error.message);
}
}
@ -358,7 +358,7 @@ export class DocumentController extends Controller {
} catch (error: any) {
if (error instanceof HttpError) {
throw error;
} else throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, error);
} else throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, error.message);
}
}
@ -375,13 +375,13 @@ export class DocumentController extends Controller {
const result = await deleteFile(["ระบบประเมิน", volume, id], file);
if (!result) {
throw new Error("เกิดข้อผิดพลาดกับระบบจัดการไฟล์ ไม่สามารถอัปโหลดไฟล์ได้");
throw new Error("เกิดข้อผิดพลาดกับระบบจัดการไฟล์ ไม่สามารถลบไฟล์ได้");
}
return this.setStatus(HttpStatus.NO_CONTENT);
} catch (error: any) {
if (error instanceof HttpError) {
throw error;
} else throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, error);
} else throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, error.message);
}
}
}

View file

@ -27,12 +27,15 @@ import { Assessment } from "../entities/Assessment";
import { Director } from "../entities/Director";
import { Meeting } from "../entities/Meeting";
import { ConvertThaiToType, ConvertToThaiStep, ConvertToThaiType } from "../services/storage";
import { Brackets } from "typeorm";
import { Brackets, In } from "typeorm";
import CallAPI from "../interfaces/call-api";
import permission from "../interfaces/permission";
import { RequestWithUser } from "../middlewares/user";
import { setLogDataDiff } from "../interfaces/utils";
import Extension from "../interfaces/extension";
import { Portfolio } from "../entities/Portfolio";
import { Performance } from "../entities/Performance";
import { AnnounceTemplate } from "../entities/AnnounceTemplate";
@Route("api/v1/evaluation")
@Tags("evaluation")
@ -50,8 +53,11 @@ export class EvaluationController {
private salaryRepository = AppDataSource.getRepository(Salary);
private trainingRepository = AppDataSource.getRepository(Training);
private assessmentRepository = AppDataSource.getRepository(Assessment);
private portfolioRepository = AppDataSource.getRepository(Portfolio);
private performanceRepository = AppDataSource.getRepository(Performance);
private directorRepository = AppDataSource.getRepository(Director);
private meetingRepository = AppDataSource.getRepository(Meeting);
private announceTemplateRepository = AppDataSource.getRepository(AnnounceTemplate);
/**
* API
@ -64,6 +70,42 @@ export class EvaluationController {
return new HttpSuccess();
}
/**
* API
*
* @summary
*
*/
@Get("performance/user")
async listPerformance(@Request() request: RequestWithUser) {
const list = await AppDataSource.getRepository(Evaluation)
.createQueryBuilder("evaluation")
.where("evaluation.userId = :userId", { userId: request.user.sub })
.andWhere("evaluation.step = :step", { step: "DONE" })
.andWhere("evaluation.evaluationResult IN (:...evaluationResult)", {
evaluationResult: ["PASS", "NOTPASS"],
})
.select([
"evaluation.id",
"evaluation.type",
"evaluation.subject",
"evaluation.evaluationResult",
"evaluation.lastUpdatedAt",
])
.orderBy("evaluation.lastUpdatedAt", "ASC")
.getMany();
const performance = list.map((item) => ({
id: item.id,
year: item.lastUpdatedAt?Extension.ToThaiYear(item.lastUpdatedAt.getFullYear()):null,
type: item.type == "EXPERT" ? "ชำนาญการ" : item.type == "EXPERTISE" ? "เชียวชาญ" : item.type == "SPECIAL_EXPERT" ? "ชำนาญการพิเศษ": null,
subject: item.subject?item.subject[0]:null,
evaluationResult: item.evaluationResult == "PASS" ? "ผ่าน" : item.evaluationResult == "NOTPASS" ? "ไม่ผ่าน" : null,
}));
return new HttpSuccess(performance);
}
/**
*
*
@ -305,6 +347,28 @@ export class EvaluationController {
} else throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, error);
}
}
/**
* API get template
*
* @summary get template (ADMIN)
*
* @param {string} id id
*/
@Get("get-announce-template/{id}")
async getAnnounceTemp(@Path() id: string, @Request() request: RequestWithUser) {
try {
const evaluation = await this.evaluationRepository.findOne({ where: { id } , select: ["id","detailAnnounceStep5Body","detailAnnounceStep5Footer"]});
if (!evaluation) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการประเมิน");
}
return new HttpSuccess(evaluation);
} catch (error: any) {
if (error instanceof HttpError) {
throw error;
} else throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, error);
}
}
/**
* step
@ -439,11 +503,18 @@ export class EvaluationController {
async save(@Body() requestBody: CreateEvaluation, @Request() request: RequestWithUser) {
// await new permission().PermissionCreate(request, "SYS_EVA_REQ");
try {
const _null: any = null;
const evaluation = Object.assign(new Evaluation(), requestBody);
if (!evaluation) {
return `not found data`;
}
let _code = requestBody.type == "EXPERT" ? "ST05-1" : requestBody.type == "EXPERTISE" ? "ST05-1" : requestBody.type == "SPECIAL_EXPERT" ? "ST05-2" : "ST05-1";
const announceTemplate5 = await this.announceTemplateRepository.findOne({
where:{
code : _code
},
select: ["detailBody","detailFooter"]
})
const before = null;
await new CallAPI()
.GetData(request, `/org/profile/keycloak/commander/${request.user.sub}`)
@ -465,10 +536,13 @@ export class EvaluationController {
evaluation.lastUpdateFullName = request.user.name;
evaluation.lastUpdatedAt = new Date();
evaluation.userId = request.user.sub;
evaluation.detailAnnounceStep5Body = announceTemplate5?.detailBody??_null;
evaluation.detailAnnounceStep5Footer = announceTemplate5?.detailFooter??_null;
evaluation.positionArea = requestBody.positionArea && requestBody.positionArea !== "" ? requestBody.positionArea : _null;
evaluation.posExecutive = requestBody.posExecutive && requestBody.posExecutive !== "" ? requestBody.posExecutive : _null;
await this.evaluationRepository.save(evaluation, { data: request });
setLogDataDiff(request, { before, after: evaluation });
const _null: any = null;
//Education
if (requestBody.educations != null)
requestBody.educations.forEach(async (edu) => {
@ -638,7 +712,43 @@ export class EvaluationController {
await this.assessmentRepository.save(assessment, { data: request });
setLogDataDiff(request, { before, after: assessment });
});
//Portfolio
if (requestBody.portfolios != null)
requestBody.portfolios.forEach(async (pfo) => {
const portfolio = new Portfolio();
portfolio.createdUserId = request.user.sub;
portfolio.createdFullName = request.user.name;
portfolio.createdAt = new Date();
portfolio.lastUpdateUserId = request.user.sub;
portfolio.lastUpdateFullName = request.user.name;
portfolio.lastUpdatedAt = new Date();
portfolio.name = pfo.name ?? _null;
portfolio.detail = pfo.detail ?? _null;
portfolio.evaluation = evaluation;
await this.portfolioRepository.save(portfolio, { data: request });
setLogDataDiff(request, { before, after: portfolio });
});
//Performance
if (requestBody.performances != null)
requestBody.performances.forEach(async (pfm) => {
const performance = new Performance();
performance.createdUserId = request.user.sub;
performance.createdFullName = request.user.name;
performance.createdAt = new Date();
performance.lastUpdateUserId = request.user.sub;
performance.lastUpdateFullName = request.user.name;
performance.lastUpdatedAt = new Date();
performance.year = pfm.year ?? _null;
performance.type = pfm.type ?? _null;
performance.subject = pfm.subject ?? _null;
performance.evaluationResult = pfm.evaluationResult ?? _null;
performance.evaluation = evaluation;
await this.performanceRepository.save(performance, { data: request });
setLogDataDiff(request, { before, after: performance });
});
//EvaluationLogs
const evaluationLogs = new EvaluationLogs();
evaluationLogs.step = (await ConvertToThaiStep("PREPARE_DOC_V1")) ?? _null;
@ -932,6 +1042,8 @@ export class EvaluationController {
.leftJoin("evaluation.salaries", "salaries")
.leftJoin("evaluation.training", "training")
.leftJoin("evaluation.assessment", "assessment")
.leftJoin("evaluation.portfolios", "portfolios")
.leftJoin("evaluation.performances", "performances")
.where("evaluation.id = :id", { id })
.select([
"evaluation.isEducationalQft",
@ -952,6 +1064,9 @@ export class EvaluationController {
"evaluation.birthDate",
"evaluation.govAge",
"evaluation.experience",
"evaluation.detailAnnounceStep5Body",
"evaluation.detailAnnounceStep5Footer",
"evaluation.isUpdated",
"education.educationLevel",
"education.institute",
@ -1032,10 +1147,18 @@ export class EvaluationController {
"assessment.point2",
"assessment.pointSumTotal",
"assessment.pointSum",
"portfolios.name",
"portfolios.detail",
"performances.year",
"performances.type",
"performances.subject",
"performances.evaluationResult",
])
.orderBy("salaries.commandDateAffect", "DESC")
.getOne();
console.log(evaluation);
if (!evaluation) {
return "ไม่พบข้อมูล";
}
@ -1058,6 +1181,9 @@ export class EvaluationController {
birthDate: evaluation.birthDate,
govAge: evaluation.govAge,
experience: evaluation.experience,
detailAnnounceStep5Body: evaluation.detailAnnounceStep5Body,
detailAnnounceStep5Footer: evaluation.detailAnnounceStep5Footer,
isUpdated: evaluation.isUpdated,
educations: evaluation.education.map((education) => ({
educationLevel: education.educationLevel,
institute: education.institute,
@ -1143,6 +1269,16 @@ export class EvaluationController {
pointSumTotal: assessment.pointSumTotal,
pointSum: assessment.pointSum,
})),
portfolios: evaluation.portfolios.map((portfolio) => ({
name: portfolio.name,
detail: portfolio.detail,
})),
performances: evaluation.performances.map((performance) => ({
year: performance.year,
type: performance.type,
subject: performance.subject,
evaluationResult: performance.evaluationResult,
})),
// years: years
};
@ -1266,6 +1402,8 @@ export class EvaluationController {
.leftJoin("evaluation.salaries", "salaries")
.leftJoin("evaluation.training", "training")
.leftJoin("evaluation.assessment", "assessment")
.leftJoin("evaluation.portfolios", "portfolios")
.leftJoin("evaluation.performances", "performances")
.where("evaluation.id = :id", { id })
.select([
"evaluation.isEducationalQft",
@ -1286,6 +1424,9 @@ export class EvaluationController {
"evaluation.birthDate",
"evaluation.govAge",
"evaluation.experience",
"evaluation.detailAnnounceStep5Body",
"evaluation.detailAnnounceStep5Footer",
"evaluation.isUpdated",
"education.educationLevel",
"education.institute",
@ -1366,6 +1507,14 @@ export class EvaluationController {
"assessment.point2",
"assessment.pointSumTotal",
"assessment.pointSum",
"portfolios.name",
"portfolios.detail",
"performances.year",
"performances.type",
"performances.subject",
"performances.evaluationResult",
])
.orderBy("salaries.commandDateAffect", "DESC")
.getOne();
@ -1392,6 +1541,9 @@ export class EvaluationController {
birthDate: evaluation.birthDate,
govAge: evaluation.govAge,
experience: evaluation.experience,
detailAnnounceStep5Body: evaluation.detailAnnounceStep5Body,
detailAnnounceStep5Footer: evaluation.detailAnnounceStep5Footer,
isUpdated: evaluation.isUpdated,
educations: evaluation.education.map((education) => ({
educationLevel: education.educationLevel,
institute: education.institute,
@ -1477,6 +1629,16 @@ export class EvaluationController {
pointSumTotal: assessment.pointSumTotal,
pointSum: assessment.pointSum,
})),
portfolios: evaluation.portfolios.map((portfolio) => ({
name: portfolio.name,
detail: portfolio.detail,
})),
performances: evaluation.performances.map((performance) => ({
year: performance.year,
type: performance.type,
subject: performance.subject,
evaluationResult: performance.evaluationResult,
})),
};
if (!dataEvaluation) {
@ -1631,18 +1793,32 @@ export class EvaluationController {
await this.evaluationRepository.save(evaluation, { data: request });
setLogDataDiff(request, { before, after: evaluation });
let _director: any;
await new CallAPI()
.PostData(request, "/placement/noti/keycloak", {
subject: `${evaluation.fullName} แบบประเมินมีการบันทึกตรวจสอบจัดเตรียมเอกสารเล่ม 1`,
body: `${evaluation.fullName} แบบประเมินมีการบันทึกตรวจสอบจัดเตรียมเอกสารเล่ม 1`,
receiverUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
payload: "",
isSendMail: true,
isSendInbox: true,
isSendNotification: true,
.PostData(request, "/org/workflow/find/director-with-keycloak/SYS_EVA_REQ", {
refId: [evaluation.userId],
})
.then((x) => {
_director = x;
})
.then((x) => {})
.catch((x) => {});
await Promise.all(
_director.map((director:any) => {
return new CallAPI()
.PostData(request, "/placement/noti/keycloak", {
subject: `${evaluation.fullName} แบบประเมินมีการบันทึกตรวจสอบจัดเตรียมเอกสารเล่ม 1`,
body: `${evaluation.fullName} แบบประเมินมีการบันทึกตรวจสอบจัดเตรียมเอกสารเล่ม 1`,
receiverUserId: director.keycloak,
payload: "",
isSendMail: true,
isSendInbox: true,
isSendNotification: true,
})
.then((x) => {
})
.catch((x) => {});
})
);
return new HttpSuccess();
} catch (error: any) {
if (error instanceof HttpError) {
@ -1935,6 +2111,40 @@ export class EvaluationController {
}
}
/**
* API template
*
* @summary template (ADMIN)
*
* @param {string} id id
*/
@Put("edit-announce-template/{id}")
async editAnnounceTemp(@Path() id: string, @Request() request: RequestWithUser, @Body() body: {detailBody: string, detailFooter: string}) {
try {
await new permission().PermissionUpdate(request, "SYS_EVA_REQ");
const evaluation = await this.evaluationRepository.findOne({ where: { id } });
if (!evaluation) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "not found.");
}
const before = structuredClone(evaluation);
evaluation.detailAnnounceStep5Body = body.detailBody;
evaluation.detailAnnounceStep5Footer = body.detailFooter;
evaluation.lastUpdateUserId = request.user.sub;
evaluation.lastUpdateFullName = request.user.name;
evaluation.lastUpdatedAt = new Date();
await this.evaluationRepository.save(evaluation, { data: request });
setLogDataDiff(request, { before, after: evaluation });
return new HttpSuccess();
} catch (error: any) {
if (error instanceof HttpError) {
throw error;
} else throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, error);
}
}
/**
* API
*
@ -1975,6 +2185,14 @@ export class EvaluationController {
evaluation.commanderPositionDoc2 = evaluation.commanderPosition;
evaluation.commanderAboveFullnameDoc2 = evaluation.commanderAboveFullname;
evaluation.commanderAbovePositionDoc2 = evaluation.commanderAbovePosition;
evaluation.commanderOrgDoc2 = evaluation.commanderOrg;
evaluation.commanderOrgOldDoc2 = evaluation.commanderOrgOld;
evaluation.commanderPositionOldDoc2 = evaluation.commanderPositionOld;
evaluation.commanderAboveOrgDoc2 = evaluation.commanderAboveOrg;
evaluation.commanderAboveOrgOldDoc2 = evaluation.commanderAboveOrgOld;
evaluation.commanderAbovePositionOldDoc2 = evaluation.commanderAbovePositionOld;
evaluation.datePrepareDoc2 = new Date();
evaluation.lastUpdateUserId = request.user.sub;
evaluation.lastUpdateFullName = request.user.name;
@ -2335,6 +2553,7 @@ export class EvaluationController {
positionName: null,
email: director.email,
phone: director.phone,
duty: director.duty,
}));
const meetings = evaluation.meetings.map((meeting) => ({
@ -2536,9 +2755,15 @@ export class EvaluationController {
"author",
"subject",
"commanderFullname",
"commanderOrg",
"commanderOrgOld",
"commanderPosition",
"commanderPositionOld",
"commanderAboveFullname",
"commanderAboveOrg",
"commanderAboveOrgOld",
"commanderAbovePosition",
"commanderAbovePositionOld",
],
});
@ -2572,9 +2797,15 @@ export class EvaluationController {
"author",
"subject",
"commanderFullname",
"commanderOrg",
"commanderOrgOld",
"commanderPosition",
"commanderPositionOld",
"commanderAboveFullname",
"commanderAboveOrg",
"commanderAboveOrgOld",
"commanderAbovePosition",
"commanderAbovePositionOld",
],
});
if (!evaluation) {
@ -2605,10 +2836,17 @@ export class EvaluationController {
"subjectDoc2",
"assignedPosition",
"commanderFullnameDoc2",
"commanderOrgDoc2",
"commanderOrgOldDoc2",
"commanderPositionDoc2",
"commanderPositionOldDoc2",
"commanderAboveFullnameDoc2",
"commanderAboveOrgDoc2",
"commanderAboveOrgOldDoc2",
"commanderAbovePositionDoc2",
"commanderAbovePositionOldDoc2",
"evaluationResult",
"isUpdated",
],
});
if (!evaluation) {
@ -2642,10 +2880,17 @@ export class EvaluationController {
"subjectDoc2",
"assignedPosition",
"commanderFullnameDoc2",
"commanderOrgDoc2",
"commanderOrgOldDoc2",
"commanderPositionDoc2",
"commanderPositionOldDoc2",
"commanderAboveFullnameDoc2",
"commanderAboveOrgDoc2",
"commanderAboveOrgOldDoc2",
"commanderAbovePositionDoc2",
"commanderAbovePositionOldDoc2",
"evaluationResult",
"isUpdated",
],
});
if (!evaluation) {
@ -2682,11 +2927,17 @@ export class EvaluationController {
@Body()
body: {
author: string;
subject: string;
subject: string[];
commanderFullname: string;
commanderOrg?: string;
commanderOrgOld?: string;
commanderPosition: string;
commanderPositionOld?: string;
commanderAboveFullname: string;
commanderAboveOrg?: string;
commanderAboveOrgOld?: string;
commanderAbovePosition: string;
commanderAbovePositionOld?: string;
},
@Request() request: RequestWithUser,
) {
@ -2696,13 +2947,19 @@ export class EvaluationController {
if (!evaluation) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "not found.");
}
const _null:any = null;
evaluation.author = body.author;
evaluation.subject = body.subject;
evaluation.commanderFullname = body.commanderFullname;
evaluation.commanderOrg = body.commanderOrg??_null;
evaluation.commanderOrgOld = body.commanderOrgOld??_null;
evaluation.commanderPosition = body.commanderPosition;
evaluation.commanderPositionOld = body.commanderPositionOld??_null;
evaluation.commanderAboveFullname = body.commanderAboveFullname;
evaluation.commanderAboveOrg = body.commanderAboveOrg??_null;
evaluation.commanderAboveOrgOld = body.commanderAboveOrgOld??_null;
evaluation.commanderAbovePosition = body.commanderAbovePosition;
evaluation.commanderAbovePositionOld = body.commanderAbovePositionOld??_null;
evaluation.lastUpdateUserId = request.user.sub;
evaluation.lastUpdateFullName = request.user.name;
evaluation.lastUpdatedAt = new Date();
@ -2742,12 +2999,18 @@ export class EvaluationController {
@Body()
body: {
authorDoc2: string;
subjectDoc2: string;
subjectDoc2: string[];
assignedPosition: string;
commanderFullnameDoc2: string;
commanderPositionDoc2: string;
commanderAboveFullnameDoc2: string;
commanderAbovePositionDoc2: string;
commanderOrgDoc2?: string;
commanderOrgOldDoc2?: string;
commanderPositionOldDoc2?: string;
commanderAboveOrgDoc2?: string;
commanderAboveOrgOldDoc2?: string;
commanderAbovePositionOldDoc2?: string;
},
@Request() request: RequestWithUser,
) {
@ -2757,14 +3020,21 @@ export class EvaluationController {
if (!evaluation) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "not found.");
}
const _null:any = null;
evaluation.authorDoc2 = body.authorDoc2;
evaluation.subjectDoc2 = body.subjectDoc2;
evaluation.assignedPosition = body.assignedPosition;
evaluation.commanderFullnameDoc2 = body.commanderFullnameDoc2;
evaluation.commanderOrgDoc2 = body.commanderOrgDoc2??_null;
evaluation.commanderOrgOldDoc2 = body.commanderOrgOldDoc2??_null;
evaluation.commanderPositionDoc2 = body.commanderPositionDoc2;
evaluation.commanderPositionOldDoc2 = body.commanderPositionOldDoc2??_null;
evaluation.commanderAboveFullnameDoc2 = body.commanderAboveFullnameDoc2;
evaluation.commanderAboveOrgDoc2 = body.commanderAboveOrgDoc2??_null;
evaluation.commanderAboveOrgOldDoc2 = body.commanderAboveOrgOldDoc2??_null;
evaluation.commanderAbovePositionDoc2 = body.commanderAbovePositionDoc2;
evaluation.commanderAbovePositionOldDoc2 = body.commanderAbovePositionOldDoc2??_null;
evaluation.isUpdated = true;
evaluation.lastUpdateUserId = request.user.sub;
evaluation.lastUpdateFullName = request.user.name;
evaluation.lastUpdatedAt = new Date();
@ -2806,7 +3076,8 @@ export class EvaluationController {
await this.salaryRepository.delete({ evaluationId: id });
await this.trainingRepository.delete({ evaluationId: id });
await this.assessmentRepository.delete({ evaluationId: id });
await this.evaluationLogsRepository.delete({ evaluationId: id });
await this.portfolioRepository.delete({ evaluationId: id });
await this.performanceRepository.delete({ evaluationId: id });
await this.evaluationLogsRepository.delete({ evaluationId: id });
await Promise.all(
evaluation.meetings.map((meeting) =>

View file

@ -161,6 +161,8 @@ export class ReoportController {
.leftJoin("evaluation.salaries", "salaries")
.leftJoin("evaluation.training", "training")
.leftJoin("evaluation.assessment", "assessment")
.leftJoin("evaluation.portfolios", "portfolios")
.leftJoin("evaluation.performances", "performances")
.where("evaluation.id = :id", { id })
.select([
"evaluation.id",
@ -184,6 +186,20 @@ export class ReoportController {
"evaluation.birthDate",
"evaluation.govAge",
"evaluation.experience",
"evaluation.detailAnnounceStep5Body",
"evaluation.detailAnnounceStep5Footer",
"evaluation.positionArea",
"evaluation.posExecutive",
"evaluation.commanderFullname",
"evaluation.commanderPosition",
"evaluation.commanderPositionOld",
"evaluation.commanderOrg",
"evaluation.commanderOrgOld",
"evaluation.commanderAboveFullname",
"evaluation.commanderAbovePosition",
"evaluation.commanderAbovePositionOld",
"evaluation.commanderAboveOrg",
"evaluation.commanderAboveOrgOld",
"education.educationLevel",
"education.institute",
@ -265,6 +281,14 @@ export class ReoportController {
"assessment.point2",
"assessment.pointSumTotal",
"assessment.pointSum",
"portfolios.name",
"portfolios.detail",
"performances.year",
"performances.type",
"performances.subject",
"performances.evaluationResult",
])
.orderBy("salaries.commandDateAffect", "DESC")
.getOne();
@ -276,34 +300,9 @@ export class ReoportController {
let dateStart: any;
let dateRetireLaw: any;
let org: any;
let commanderFullname: any;
let commanderPosition: any;
let commanderRootName: any;
let commanderOrg: any;
let commanderAboveFullname: any;
let commanderAbovePosition: any;
let commanderAboveRootName: any;
let commanderAboveOrg: any;
if (!evaluation.userId) {
return "ไม่พบข้อมูลผู้ขอประเมิน";
}
await new CallAPI()
.GetData(request, `/org/profile/keycloak/commander/${evaluation.userId}`)
.then(async (x) => {
(root = x.root),
(dateStart = x.dateStart),
(dateRetireLaw = x.dateRetireLaw),
(org = x.org),
(commanderFullname = x.commanderFullname),
(commanderPosition = x.commanderPosition),
(commanderRootName = x.commanderRootName),
(commanderOrg = x.commanderOrg),
(commanderAboveFullname = x.commanderAboveFullname),
(commanderAbovePosition = x.commanderAbovePosition),
(commanderAboveRootName = x.commanderAboveRootName),
(commanderAboveOrg = x.commanderAboveOrg);
})
.catch();
const evaluationOld = await this.evaluationRepository.find({
where: {
id: Not(id),
@ -319,6 +318,10 @@ export class ReoportController {
lastOneYear: Extension.ToThaiNumber((thaiYear - 1).toString()),
currentYear: Extension.ToThaiNumber(thaiYear.toString()),
};
let _orgNoNewLine = (org ? org : "-").replace(/\n/g, " ");
let topic10 = evaluation.type == "EXPERT" || evaluation.type == "EXPERTISE" ? "หน่วยงาน" : evaluation.type == "SPECIAL_EXPERT" ? "กรุงเทพมหานคร" : "หน่วยงาน";
let footer10 = evaluation.type == "EXPERT" || evaluation.type == "EXPERTISE" ? "หัวหน้าหน่วยงาน" : evaluation.type == "SPECIAL_EXPERT" ? "ปลัดกรุงเทพมหานคร" : "หัวหน้าหน่วยงาน";
let typeTh = evaluation.type == "EXPERT" ? "ชำนาญการ" : evaluation.type == "EXPERTISE" ? "เชียวชาญ" : evaluation.type == "SPECIAL_EXPERT" ? "ชำนาญการพิเศษ":"";
const dataEvaluation = {
isEducationalQft: evaluation.isEducationalQft,
isGovermantServiceHtr: evaluation.isGovermantServiceHtr,
@ -328,19 +331,32 @@ export class ReoportController {
isHaveProLicense: evaluation.isHaveProLicense,
isHaveMinPeriodOrHoldPos: evaluation.isHaveMinPeriodOrHoldPos,
type: evaluation.type,
typeTh: typeTh,
prefix: evaluation.prefix,
fullName: evaluation.fullName ? `${evaluation.fullName}` : "-",
position: evaluation.position ? evaluation.position : "-",
posNo: evaluation.posNo ? Extension.ToThaiNumber(evaluation.posNo) : "-",
fullName: evaluation.fullName ? `${evaluation.fullName}` : "",
position: evaluation.position ? evaluation.position : "",
posAndPosLevel: (evaluation.position ? `${evaluation.position}` : "") + (evaluation.positionLevel ? `${evaluation.positionLevel}` : ""),
posAndTypeTh: (evaluation.position ? `${evaluation.position}` : "" ) + (typeTh ? `${typeTh}` : ""),
posNo: evaluation.posNo ? Extension.ToThaiNumber(evaluation.posNo) : "",
posNoWithSym: evaluation.posNo ? `(${Extension.ToThaiNumber(evaluation.posNo)})` : "",
oc: evaluation.oc ? evaluation.oc : "-",
org: org ? org : "-", //สังกัด
orgNoNewLine: _orgNoNewLine ? _orgNoNewLine : "-", //สังกัดแบบไม่เว้นวรรค
root: root ? root : "-", //หน่วยงาน
salary: evaluation.salary ? Extension.ToThaiNumber(evaluation.salary) : "-",
positionLevel: evaluation.positionLevel ? evaluation.positionLevel : "-",
salaryWithPrefix: evaluation.salary ? "อัตราเงินเดือนปัจจุบัน" +" "+ Extension.ToThaiNumber(evaluation.salary) : "-",
positionLevel: evaluation.positionLevel ? evaluation.positionLevel : "",
detailAnnounceStep5Body: evaluation.detailAnnounceStep5Body,
detailAnnounceStep5Footer: evaluation.detailAnnounceStep5Footer,
positionAreaWithSym: evaluation.positionArea?`(${Extension.ToThaiNumber(evaluation.positionArea)})` : "",
posExecutive: evaluation.posExecutive,
posFull: (evaluation.position ? `${evaluation.position}` : "") + (evaluation.positionLevel ? `${evaluation.positionLevel}` : "") + (evaluation.posExecutive ? " " + `${evaluation.posExecutive}` : "") ,
topic10: topic10,
footer10: footer10,
birthDate:
evaluation.birthDate != null && evaluation.birthDate != ""
? Extension.ToThaiNumber(
Extension.ToThaiShortDate_noPrefix(new Date(evaluation.birthDate)),
Extension.ToThaiFullDate2(new Date(evaluation.birthDate)),
)
: "-",
govAge: evaluation.govAge != null ? Extension.ToThaiNumber(evaluation.govAge) : "-",
@ -351,7 +367,7 @@ export class ReoportController {
dateRetireLaw: dateRetireLaw
? Extension.ToThaiNumber(Extension.ToThaiShortDate(new Date(dateRetireLaw)))
: "-",
subject: evaluation.subject != null ? evaluation.subject : "-",
subject: evaluation.subject != null ? evaluation.subject[0] : "-",
subjectOld: subjectOld,
educations:
evaluation.education.length > 0
@ -403,8 +419,8 @@ export class ReoportController {
certificateNo: certificate.certificateNo
? Extension.ToThaiNumber(certificate.certificateNo)
: "-",
issueDate: certificate.issueDate,
expireDate: certificate.expireDate,
issueDate: certificate.issueDate ? Extension.ToThaiNumber(Extension.ToThaiFullDate2(certificate.issueDate)) : "-",
expireDate: certificate.expireDate ? Extension.ToThaiNumber(Extension.ToThaiFullDate2(certificate.expireDate)) : "-",
}))
: [
{
@ -419,12 +435,14 @@ export class ReoportController {
evaluation.salaries.length > 0
? evaluation.salaries.map((salaries) => ({
date: salaries.commandDateAffect
? Extension.ToThaiNumber(Extension.ToThaiShortDate_noPrefix(salaries.commandDateAffect))
? Extension.ToThaiNumber(Extension.ToThaiFullDate2(salaries.commandDateAffect))
: "-",
amount: salaries.amount
? Extension.ToThaiNumber(salaries.amount.toLocaleString())
: "-",
position: salaries.positionName ? Extension.ToThaiNumber(salaries.positionName) : "-",
position: salaries.positionName ? salaries.positionName : "-",
positionExecutive: salaries.positionExecutive ? salaries.positionExecutive : "",
positionAndPosEx: (salaries.positionName ? salaries.positionName : "") + (salaries.positionExecutive ? " " + salaries.positionExecutive : ""),
positionSalaryAmount: salaries.positionSalaryAmount,
mouthSalaryAmount: salaries.mouthSalaryAmount,
posNo: salaries.posNo,
@ -452,10 +470,10 @@ export class ReoportController {
name: training.name ? Extension.ToThaiNumber(training.name) : "-",
topic: training.topic ? Extension.ToThaiNumber(training.topic) : "-",
startDate: training.startDate
? Extension.ToThaiNumber(Extension.ToThaiShortDate_noPrefix(training.startDate))
? Extension.ToThaiNumber(Extension.ToThaiFullDate2(training.startDate))
: "-",
endDate: training.endDate
? Extension.ToThaiNumber(Extension.ToThaiShortDate_noPrefix(training.endDate))
? Extension.ToThaiNumber(Extension.ToThaiFullDate2(training.endDate))
: "-",
yearly: training.yearly ? Extension.ToThaiNumber(training.yearly.toString()) : "-",
place: training.place,
@ -480,14 +498,32 @@ export class ReoportController {
pointSumTotal: assessment.pointSumTotal,
pointSum: assessment.pointSum,
})),
commanderFullname: commanderFullname ? commanderFullname : "-",
commanderPosition: commanderPosition ? commanderPosition : "-",
commanderRootName: commanderRootName ? commanderRootName : "-",
commanderOrg: commanderOrg ? commanderOrg : "-",
commanderAboveFullname: commanderAboveFullname ? commanderAboveFullname : "-",
commanderAbovePosition: commanderAbovePosition ? commanderAbovePosition : "-",
commanderAboveRootName: commanderAboveRootName ? commanderAboveRootName : "-",
commanderAboveOrg: commanderAboveOrg ? commanderAboveOrg : "-",
portfolios: evaluation.portfolios.map((portfolio) => ({
name: portfolio.name,
detail: portfolio.detail,
})),
performances: evaluation.performances.map((performance) => ({
year: performance.year ? Extension.ToThaiNumber(performance.year.toString()) : "-",
type: performance.type,
subject: performance.subject,
evaluationResult: performance.evaluationResult,
})),
commanderFullname: evaluation.commanderFullname ? evaluation.commanderFullname : "-",
commanderPosition: evaluation.commanderPosition ? evaluation.commanderPosition : "-",
commanderPositionOld: evaluation.commanderPositionOld ? evaluation.commanderPositionOld : "-",
commanderRootName: "-",
commanderOrg: evaluation.commanderOrg ? evaluation.commanderOrg : "-",
commanderOrgOld: evaluation.commanderOrg ? evaluation.commanderOrg : "-",
commanderAboveFullname: evaluation.commanderAboveFullname ? evaluation.commanderAboveFullname : "-",
commanderAbovePosition: evaluation.commanderAbovePosition ? evaluation.commanderAbovePosition : "-",
commanderAbovePositionOld: evaluation.commanderAbovePositionOld ? evaluation.commanderAbovePositionOld : "-",
commanderAboveRootName: "-",
commanderAboveOrg: evaluation.commanderAboveOrg ? evaluation.commanderAboveOrg : "-",
commanderAboveOrgOld: evaluation.commanderAboveOrgOld ? evaluation.commanderAboveOrgOld : "-",
commanderPositionSign: (evaluation.commanderPosition ? evaluation.commanderPosition : "") + (evaluation.commanderOrg ? " " + evaluation.commanderOrg : "")
+ (evaluation.commanderPosition || evaluation.commanderOrg ? `\n` + "ขณะดำรงตำแหน่ง" : "") + (evaluation.commanderPositionOld ? " " + evaluation.commanderPositionOld:"") + (evaluation.commanderOrgOld ? " " + evaluation.commanderOrgOld : ""),
commanderAbovePositionSign: (evaluation.commanderAbovePosition ? evaluation.commanderAbovePosition : "") + (evaluation.commanderAboveOrg ? " " + evaluation.commanderAboveOrg : "")
+ (evaluation.commanderAbovePosition || evaluation.commanderAboveOrg ? `\n` + "ขณะดำรงตำแหน่ง" : "") + (evaluation.commanderAbovePositionOld ? " " + evaluation.commanderAbovePositionOld: "") + (evaluation.commanderAboveOrgOld ? " " + evaluation.commanderAboveOrgOld : ""),
years: years,
};

View file

@ -0,0 +1,22 @@
import { Entity, Column, ManyToOne, JoinColumn, OneToOne } from "typeorm";
import { EntityBase } from "./base/Base";
import { Evaluation } from "./Evaluation";
@Entity("announcetemplate")
export class AnnounceTemplate extends EntityBase {
@Column({ nullable: true, comment: "code สำหรับเรียก template" }) //ตัวอย่าง ST05-1 (ใช้ที่ STEP 5 ลำดับที่ 1)
code: string;
@Column({ nullable: true, comment: "ชื่อประกาศ" })
name: string;
@Column({ type: 'text', nullable: true, comment: 'รายละเอียด'})
detailBody: string;
@Column({ type: 'text', nullable: true, comment: 'รายละเอียดส่วนท้าย'})
detailFooter: string;
}
export type UpdateAnnounceTemplate = Partial<AnnounceTemplate>;

View file

@ -25,6 +25,9 @@ export class Director extends EntityBase {
@Column({ nullable: true, comment: "ตำแหน่ง" })
position: string;
@Column({ nullable: true, comment: "หน้าที่" })
duty: string;
@ManyToMany(() => Evaluation, (evaluation) => evaluation.directors)
evaluations: Evaluation[];
}
@ -47,5 +50,8 @@ export class CreateDirector {
@Column()
position: string;
// @Column()
// duty?: string;
}
export type UpdateDirector = Partial<Director>;

View file

@ -8,6 +8,8 @@ import { Training } from "./Training";
import { Assessment } from "./Assessment";
import { Director } from "./Director";
import { Meeting } from "./Meeting";
import { Portfolio } from "./Portfolio";
import { Performance } from "./Performance";
@Entity("evaluation")
export class Evaluation extends EntityBase {
@ -199,6 +201,40 @@ export class Evaluation extends EntityBase {
@Column({ nullable: true, comment: "ตำแหน่ง ผู้บังคับบัญชาชั้นต้น (จัดเตรียมเอกสารเล่ม 2)" })
commanderPositionDoc2: string;
@Column({ nullable: true, comment: "สังกัดปัจุบัน ผู้บังคับบัญชาชั้นต้น" })
commanderOrg: string;
@Column({ nullable: true, comment: "สังกัดเดิม ผู้บังคับบัญชาชั้นต้น" })
commanderOrgOld: string;
@Column({ nullable: true, comment: "ตำแหน่งเดิม ผู้บังคับบัญชาชั้นต้น" })
commanderPositionOld: string;
@Column({ nullable: true, comment: "สังกัดปัจุบัน ผู้บังคับบัญชาเหนือขึ้นไป 1 ระดับ" })
commanderAboveOrg: string;
@Column({ nullable: true, comment: "สังกัดเดิม ผู้บังคับบัญชาเหนือขึ้นไป 1 ระดับ" })
commanderAboveOrgOld: string;
@Column({ nullable: true, comment: "ตำแหน่งเดิม ผู้บังคับบัญชาเหนือขึ้นไป 1 ระดับ" })
commanderAbovePositionOld: string;
@Column({ nullable: true, comment: "สังกัดปัจุบัน ผู้บังคับบัญชาชั้นต้น doc2" })
commanderOrgDoc2: string;
@Column({ nullable: true, comment: "สังกัดเดิม ผู้บังคับบัญชาชั้นต้น doc2" })
commanderOrgOldDoc2: string;
@Column({ nullable: true, comment: "ตำแหน่งเดิม ผู้บังคับบัญชาชั้นต้น doc2" })
commanderPositionOldDoc2: string;
@Column({ nullable: true, comment: "สังกัดปัจุบัน ผู้บังคับบัญชาเหนือขึ้นไป 1 ระดับ doc2" })
commanderAboveOrgDoc2: string;
@Column({ nullable: true, comment: "สังกัดเดิม ผู้บังคับบัญชาเหนือขึ้นไป 1 ระดับ doc2" })
commanderAboveOrgOldDoc2: string;
@Column({ nullable: true, comment: "ตำแหน่งเดิม ผู้บังคับบัญชาเหนือขึ้นไป 1 ระดับ doc2" })
commanderAbovePositionOldDoc2: string;
@Column({ nullable: true, comment: "ด้าน/สาขา" })
positionArea: string;
@Column({ nullable: true, comment: "ตำแหน่งทางการบริหาร" })
posExecutive: string;
@Column({
nullable: true,
comment: "ชื่อ-นามสกุล ผู้บังคับบัญชาเหนือขึ้นไป 1 ระดับ (จัดเตรียมเอกสารเล่ม 2)",
@ -220,14 +256,14 @@ export class Evaluation extends EntityBase {
@Column({ nullable: true, comment: "ชื่อเจ้าของผลงาน" })
author: string;
@Column({ nullable: true, comment: "ชื่อผลงาน" })
subject: string;
@Column({ type: 'json', nullable: true, comment: 'ชื่อผลงาน' })
subject: string[];
@Column({ nullable: true, comment: "ชื่อเจ้าของผลงาน2" })
authorDoc2: string;
@Column({ nullable: true, comment: "ชื่อผลงาน2" })
subjectDoc2: string;
@Column({ type: 'json', nullable: true, comment: "ชื่อผลงาน2" })
subjectDoc2: string[];
@Column({ nullable: true, comment: "ตำแหน่งที่ได้รับมอบหมาย" })
assignedPosition: string;
@ -235,6 +271,17 @@ export class Evaluation extends EntityBase {
@Column({ nullable: true, comment: "ผลการประเมิน", default: "PENDING" }) //PENDING,PASS,NOTPASS
evaluationResult: string;
@Column({ type: 'text', nullable: true, comment: 'รายละเอียดประกาศ(STEP5)'})
detailAnnounceStep5Body: string;
@Column({ type: 'text', nullable: true, comment: 'รายละเอียดส่วนท้าย(STEP5)'})
detailAnnounceStep5Footer: string;
@Column({ default: false, comment: 'สถานะเช็คการอัพเดทชื่อผลงาน (STEP6)'})
isUpdated: boolean;
@OneToMany(() => EvaluationLogs, (evaluationLogs) => evaluationLogs.evaluation)
evaluationLogs: EvaluationLogs[];
@ -253,6 +300,12 @@ export class Evaluation extends EntityBase {
@OneToMany(() => Assessment, (assessment) => assessment.evaluation)
assessment: Assessment[];
@OneToMany(() => Portfolio, (portfolio) => portfolio.evaluation)
portfolios: Portfolio[];
@OneToMany(() => Performance, (performance) => performance.evaluation)
performances: Performance[];
@ManyToMany(() => Director, (director) => director.evaluations)
@JoinTable()
directors: Director[];
@ -260,6 +313,8 @@ export class Evaluation extends EntityBase {
@ManyToMany(() => Meeting, (meeting) => meeting.evaluations)
@JoinTable()
meetings: Meeting[];
}
export class CreateEvaluation {
@ -341,11 +396,23 @@ export class CreateEvaluation {
@Column()
assessments?: CreateAssessment[];
@Column()
portfolios?: CreatePortfolio[];
@Column()
performances?: CreatePerformance[];
@Column()
root?: string | null;
@Column()
orgRootId?: string | null;
@Column()
positionArea?: string | null;
@Column()
posExecutive?: string | null;
}
export class CreateEducation {
@ -501,6 +568,29 @@ export class CreateAssessment {
@Column()
pointSum?: number | null;
}
export class CreatePortfolio {
@Column()
name?: string | null;
@Column()
detail?: string | null;
}
export class CreatePerformance {
@Column()
year?: number | null;
@Column()
type?: string | null;
@Column()
subject?: string | null;
@Column()
evaluationResult?: string | null;
}
export class CreateEvaluationExpertise {
@Column()
author?: string | null;

View file

@ -0,0 +1,47 @@
import { Entity, Column, ManyToOne, JoinColumn, OneToOne } from "typeorm";
import { EntityBase } from "./base/Base";
import { Evaluation } from "./Evaluation";
@Entity("performance")
export class Performance extends EntityBase {
@Column({
comment: "Id การทำรายการระบบประเมิน",
length: 40,
default: "00000000-0000-0000-0000-000000000000",
})
evaluationId: string;
@Column({
nullable: true,
comment: "ปีที่ประเมิน",
default: null,
})
year: number;
@Column({
nullable: true,
comment: "ประเภทที่ร้องขอประเมิน",
default: null,
})
type: string;
@Column({
nullable: true,
comment: "ชื่อผลงาน",
default: null,
})
subject: string;
@Column({
nullable: true,
comment: "ผลการประเมิน",
default: null,
})
evaluationResult: string;
@ManyToOne(() => Evaluation, (Evaluation) => Evaluation.performances)
@JoinColumn({ name: "evaluationId" })
evaluation: Evaluation;
}
export type UpdatePerformance = Partial<Performance>;

34
src/entities/Portfolio.ts Normal file
View file

@ -0,0 +1,34 @@
import { Entity, Column, ManyToOne, JoinColumn, OneToOne } from "typeorm";
import { EntityBase } from "./base/Base";
import { Evaluation } from "./Evaluation";
@Entity("portfolio")
export class Portfolio extends EntityBase {
@Column({
comment: "Id การทำรายการระบบประเมิน",
length: 40,
default: "00000000-0000-0000-0000-000000000000",
})
evaluationId: string;
@Column({
nullable: true,
comment: "ชื่อเอกสาร/ผลงาน",
default: null,
})
name: string;
@Column({
type: "longtext",
nullable: true,
comment: "รายละเอียดเอกสาร/ผลงาน",
default: null,
})
detail: string;
@ManyToOne(() => Evaluation, (Evaluation) => Evaluation.portfolios)
@JoinColumn({ name: "evaluationId" })
evaluation: Evaluation;
}
export type UpdatePortfolio = Partial<Portfolio>;

View file

@ -0,0 +1,26 @@
import { MigrationInterface, QueryRunner } from "typeorm";
export class UpdateTableEvaAndDirec1744957358284 implements MigrationInterface {
name = 'UpdateTableEvaAndDirec1744957358284'
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`director\` ADD \`duty\` varchar(255) NULL COMMENT 'หน้าที่'`);
await queryRunner.query(`ALTER TABLE \`evaluation\` ADD \`commanderOrg\` varchar(255) NULL COMMENT 'สังกัดปัจุบัน ผู้บังคับบัญชาชั้นต้น'`);
await queryRunner.query(`ALTER TABLE \`evaluation\` ADD \`commanderOrgOld\` varchar(255) NULL COMMENT 'สังกัดเดิม ผู้บังคับบัญชาชั้นต้น'`);
await queryRunner.query(`ALTER TABLE \`evaluation\` ADD \`commanderPositionOld\` varchar(255) NULL COMMENT 'ตำแหน่งเดิม ผู้บังคับบัญชาชั้นต้น'`);
await queryRunner.query(`ALTER TABLE \`evaluation\` ADD \`commanderAboveOrg\` varchar(255) NULL COMMENT 'สังกัดปัจุบัน ผู้บังคับบัญชาเหนือขึ้นไป 1 ระดับ'`);
await queryRunner.query(`ALTER TABLE \`evaluation\` ADD \`commanderAboveOrgOld\` varchar(255) NULL COMMENT 'สังกัดเดิม ผู้บังคับบัญชาเหนือขึ้นไป 1 ระดับ'`);
await queryRunner.query(`ALTER TABLE \`evaluation\` ADD \`commanderAbovePositionOld\` varchar(255) NULL COMMENT 'ตำแหน่งเดิม ผู้บังคับบัญชาเหนือขึ้นไป 1 ระดับ'`);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`evaluation\` DROP COLUMN \`commanderAbovePositionOld\``);
await queryRunner.query(`ALTER TABLE \`evaluation\` DROP COLUMN \`commanderAboveOrgOld\``);
await queryRunner.query(`ALTER TABLE \`evaluation\` DROP COLUMN \`commanderAboveOrg\``);
await queryRunner.query(`ALTER TABLE \`evaluation\` DROP COLUMN \`commanderPositionOld\``);
await queryRunner.query(`ALTER TABLE \`evaluation\` DROP COLUMN \`commanderOrgOld\``);
await queryRunner.query(`ALTER TABLE \`evaluation\` DROP COLUMN \`commanderOrg\``);
await queryRunner.query(`ALTER TABLE \`director\` DROP COLUMN \`duty\``);
}
}

View file

@ -0,0 +1,42 @@
import { MigrationInterface, QueryRunner } from "typeorm";
export class Update2404202514361745480210700 implements MigrationInterface {
name = 'Update2404202514361745480210700'
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`evaluation\` ADD \`commanderOrgDoc2\` varchar(255) NULL COMMENT 'สังกัดปัจุบัน ผู้บังคับบัญชาชั้นต้น doc2'`);
await queryRunner.query(`ALTER TABLE \`evaluation\` ADD \`commanderOrgOldDoc2\` varchar(255) NULL COMMENT 'สังกัดเดิม ผู้บังคับบัญชาชั้นต้น doc2'`);
await queryRunner.query(`ALTER TABLE \`evaluation\` ADD \`commanderPositionOldDoc2\` varchar(255) NULL COMMENT 'ตำแหน่งเดิม ผู้บังคับบัญชาชั้นต้น doc2'`);
await queryRunner.query(`ALTER TABLE \`evaluation\` ADD \`commanderAboveOrgDoc2\` varchar(255) NULL COMMENT 'สังกัดปัจุบัน ผู้บังคับบัญชาเหนือขึ้นไป 1 ระดับ doc2'`);
await queryRunner.query(`ALTER TABLE \`evaluation\` ADD \`commanderAboveOrgOldDoc2\` varchar(255) NULL COMMENT 'สังกัดเดิม ผู้บังคับบัญชาเหนือขึ้นไป 1 ระดับ doc2'`);
await queryRunner.query(`ALTER TABLE \`evaluation\` ADD \`commanderAbovePositionOldDoc2\` varchar(255) NULL COMMENT 'ตำแหน่งเดิม ผู้บังคับบัญชาเหนือขึ้นไป 1 ระดับ doc2'`);
await queryRunner.query(`ALTER TABLE \`evaluation\` ADD \`positionArea\` varchar(255) NULL COMMENT 'ด้าน/สาขา'`);
await queryRunner.query(`ALTER TABLE \`evaluation\` ADD \`posExecutive\` varchar(255) NULL COMMENT 'ตำแหน่งทางการบริหาร'`);
await queryRunner.query(`ALTER TABLE \`evaluation\` ADD \`detailAnnounceStep5Body\` text NULL COMMENT 'รายละเอียดประกาศ(STEP5)'`);
await queryRunner.query(`ALTER TABLE \`evaluation\` ADD \`detailAnnounceStep5Footer\` text NULL COMMENT 'รายละเอียดส่วนท้าย(STEP5)'`);
await queryRunner.query(`ALTER TABLE \`evaluation\` ADD \`isUpdated\` tinyint NOT NULL COMMENT 'สถานะเช็คการอัพเดทชื่อผลงาน (STEP6)' DEFAULT 0`);
await queryRunner.query(`ALTER TABLE \`evaluation\` DROP COLUMN \`subject\``);
await queryRunner.query(`ALTER TABLE \`evaluation\` ADD \`subject\` json NULL COMMENT 'ชื่อผลงาน'`);
await queryRunner.query(`ALTER TABLE \`evaluation\` DROP COLUMN \`subjectDoc2\``);
await queryRunner.query(`ALTER TABLE \`evaluation\` ADD \`subjectDoc2\` json NULL COMMENT 'ชื่อผลงาน2'`);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`evaluation\` DROP COLUMN \`subjectDoc2\``);
await queryRunner.query(`ALTER TABLE \`evaluation\` ADD \`subjectDoc2\` varchar(255) NULL COMMENT 'ชื่อผลงาน2'`);
await queryRunner.query(`ALTER TABLE \`evaluation\` DROP COLUMN \`subject\``);
await queryRunner.query(`ALTER TABLE \`evaluation\` ADD \`subject\` varchar(255) NULL COMMENT 'ชื่อผลงาน'`);
await queryRunner.query(`ALTER TABLE \`evaluation\` DROP COLUMN \`isUpdated\``);
await queryRunner.query(`ALTER TABLE \`evaluation\` DROP COLUMN \`detailAnnounceStep5Footer\``);
await queryRunner.query(`ALTER TABLE \`evaluation\` DROP COLUMN \`detailAnnounceStep5Body\``);
await queryRunner.query(`ALTER TABLE \`evaluation\` DROP COLUMN \`posExecutive\``);
await queryRunner.query(`ALTER TABLE \`evaluation\` DROP COLUMN \`positionArea\``);
await queryRunner.query(`ALTER TABLE \`evaluation\` DROP COLUMN \`commanderAbovePositionOldDoc2\``);
await queryRunner.query(`ALTER TABLE \`evaluation\` DROP COLUMN \`commanderAboveOrgOldDoc2\``);
await queryRunner.query(`ALTER TABLE \`evaluation\` DROP COLUMN \`commanderAboveOrgDoc2\``);
await queryRunner.query(`ALTER TABLE \`evaluation\` DROP COLUMN \`commanderPositionOldDoc2\``);
await queryRunner.query(`ALTER TABLE \`evaluation\` DROP COLUMN \`commanderOrgOldDoc2\``);
await queryRunner.query(`ALTER TABLE \`evaluation\` DROP COLUMN \`commanderOrgDoc2\``);
}
}