#207 ผลงานที่เคยเสนอขอประเมิน

This commit is contained in:
AdisakKanthawilang 2025-04-21 10:36:25 +07:00
parent 894628e05b
commit 590d6af340
2 changed files with 66 additions and 2 deletions

View file

@ -34,6 +34,7 @@ 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";
@Route("api/v1/evaluation")
@Tags("evaluation")
@ -52,6 +53,7 @@ export class EvaluationController {
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);
@ -88,14 +90,15 @@ export class EvaluationController {
"evaluation.subject",
"evaluation.evaluationResult",
])
.orderBy("evaluation.dateAnnounce", "ASC")
.getMany();
const performance = list.map((item) => ({
id: item.id,
year: item.dateAnnounce?Extension.ToThaiYear(item.dateAnnounce.getFullYear()):null,
type: item.type == "EXPERT" ? "ชำนาญการ" : item.type == "EXPERTISE" ? "เชียวชาญ" : item.type == "SPECIAL_EXPERT" ? "ชำนาญการพิเศษ":null,
type: item.type == "EXPERT" ? "ชำนาญการ" : item.type == "EXPERTISE" ? "เชียวชาญ" : item.type == "SPECIAL_EXPERT" ? "ชำนาญการพิเศษ": null,
subject: item.subject,
evaluationResult: item.evaluationResult,
evaluationResult: item.evaluationResult == "PASS" ? "ผ่าน" : item.evaluationResult == "NOTPASS" ? "ไม่ผ่าน" : null,
}));
return new HttpSuccess(performance);
@ -693,6 +696,25 @@ export class EvaluationController {
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;
@ -987,6 +1009,7 @@ export class EvaluationController {
.leftJoin("evaluation.training", "training")
.leftJoin("evaluation.assessment", "assessment")
.leftJoin("evaluation.portfolios", "portfolios")
.leftJoin("evaluation.performances", "performances")
.where("evaluation.id = :id", { id })
.select([
"evaluation.isEducationalQft",
@ -1090,6 +1113,11 @@ export class EvaluationController {
"portfolios.name",
"portfolios.detail",
"performances.year",
"performances.type",
"performances.subject",
"performances.evaluationResult",
])
.orderBy("salaries.commandDateAffect", "DESC")
.getOne();
@ -1205,6 +1233,12 @@ export class EvaluationController {
name: portfolio.name,
detail: portfolio.detail,
})),
performances: evaluation.performances.map((performance) => ({
year: performance.year,
type: performance.type == "EXPERT" ? "ชำนาญการ" : performance.type == "EXPERTISE" ? "เชียวชาญ" : performance.type == "SPECIAL_EXPERT" ? "ชำนาญการพิเศษ": null,
subject: performance.subject,
evaluationResult: performance.evaluationResult,
})),
// years: years
};
@ -1329,6 +1363,7 @@ export class EvaluationController {
.leftJoin("evaluation.training", "training")
.leftJoin("evaluation.assessment", "assessment")
.leftJoin("evaluation.portfolios", "portfolios")
.leftJoin("evaluation.performances", "performances")
.where("evaluation.id = :id", { id })
.select([
"evaluation.isEducationalQft",
@ -1432,6 +1467,11 @@ export class EvaluationController {
"portfolios.name",
"portfolios.detail",
"performances.year",
"performances.type",
"performances.subject",
"performances.evaluationResult",
])
.orderBy("salaries.commandDateAffect", "DESC")
.getOne();
@ -1547,6 +1587,12 @@ export class EvaluationController {
name: portfolio.name,
detail: portfolio.detail,
})),
performances: evaluation.performances.map((performance) => ({
year: performance.year,
type: performance.type == "EXPERT" ? "ชำนาญการ" : performance.type == "EXPERTISE" ? "เชียวชาญ" : performance.type == "SPECIAL_EXPERT" ? "ชำนาญการพิเศษ": null,
subject: performance.subject,
evaluationResult: performance.evaluationResult,
})),
};
if (!dataEvaluation) {

View file

@ -369,6 +369,9 @@ export class CreateEvaluation {
@Column()
portfolios?: CreatePortfolio[];
@Column()
performances?: CreatePerformance[];
@Column()
root?: string | null;
@ -537,6 +540,21 @@ export class CreatePortfolio {
@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;