Merge branch 'develop'

This commit is contained in:
DESKTOP-2S5P7D1\Windows 10 2024-12-24 00:45:37 +07:00
commit 17dee5b79e
4 changed files with 242 additions and 159 deletions

View file

@ -52,6 +52,17 @@ export class EvaluationController {
private directorRepository = AppDataSource.getRepository(Director); private directorRepository = AppDataSource.getRepository(Director);
private meetingRepository = AppDataSource.getRepository(Meeting); private meetingRepository = AppDataSource.getRepository(Meeting);
/**
* API
*
* @summary
*
*/
@Get("clear-db")
async ClearDb() {
return new HttpSuccess();
}
/** /**
* *
* *
@ -647,6 +658,44 @@ export class EvaluationController {
return error.status; return error.status;
} }
} }
/**
* API
*
* @summary
*
* @param {string} id id
*/
@Put("updateEvaluationResult/{id}")
async updateEvaluationResult(
@Request() request: RequestWithUser,
@Path() id: string,
@Body() body: { result: string },
) {
try {
const result = body.result.toUpperCase();
if (result !== "PASS" && result !== "NOTPASS" && result !== "PENDING") {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบผลลัพธ์ดังกล่าว");
}
const evaluation = await this.evaluationRepository.findOne({
where: { id },
});
if (!evaluation) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "not found.");
}
evaluation.evaluationResult = result;
evaluation.lastUpdateUserId = request.user.sub;
evaluation.lastUpdateFullName = request.user.name;
evaluation.lastUpdatedAt = new Date();
await this.evaluationRepository.save(evaluation, { data: request });
return new HttpSuccess();
} catch (error: any) {
return error.status;
}
}
/** /**
* *
* *

View file

@ -13,6 +13,7 @@ import {
SuccessResponse, SuccessResponse,
Tags, Tags,
Delete, Delete,
Query,
} from "tsoa"; } from "tsoa";
import HttpStatusCode from "../interfaces/http-status"; import HttpStatusCode from "../interfaces/http-status";
import { Evaluation } from "../entities/Evaluation"; import { Evaluation } from "../entities/Evaluation";
@ -30,7 +31,7 @@ import { Brackets } from "typeorm";
import CallAPI from "../interfaces/call-api"; import CallAPI from "../interfaces/call-api";
import { RequestWithUser } from "../middlewares/user"; import { RequestWithUser } from "../middlewares/user";
import Extension from "../interfaces/extension"; import Extension from "../interfaces/extension";
import { Not } from "typeorm" import { Not } from "typeorm";
@Route("api/v1/evaluation/report") @Route("api/v1/evaluation/report")
@Tags("report") @Tags("report")
@Security("bearerAuth") @Security("bearerAuth")
@ -50,6 +51,21 @@ export class ReoportController {
private directorRepository = AppDataSource.getRepository(Director); private directorRepository = AppDataSource.getRepository(Director);
private meetingRepository = AppDataSource.getRepository(Meeting); private meetingRepository = AppDataSource.getRepository(Meeting);
/**
* Report
*
* @summary Report
*
*/
@Get()
async sumaryEvaluationReport(@Query("year") year?: string, @Query("rootid") rootId?: string) {
return new HttpSuccess({
template: "summary-evaluation",
reportName: "xlsx-report",
data: null,
});
}
/** /**
* Report * Report
* *
@ -148,54 +164,53 @@ export class ReoportController {
if (!evaluation) { if (!evaluation) {
return "ไม่พบข้อมูล"; return "ไม่พบข้อมูล";
} }
let root: any let root: any;
let dateStart: any let dateStart: any;
let dateRetireLaw: any let dateRetireLaw: any;
let org: any let org: any;
let commanderFullname: any let commanderFullname: any;
let commanderPosition: any let commanderPosition: any;
let commanderRootName: any let commanderRootName: any;
let commanderOrg: any let commanderOrg: any;
let commanderAboveFullname: any let commanderAboveFullname: any;
let commanderAbovePosition: any let commanderAbovePosition: any;
let commanderAboveRootName: any let commanderAboveRootName: any;
let commanderAboveOrg: any let commanderAboveOrg: any;
if (!evaluation.userId) { if (!evaluation.userId) {
return "ไม่พบข้อมูลผู้ขอประเมิน"; return "ไม่พบข้อมูลผู้ขอประเมิน";
} }
await new CallAPI() await new CallAPI()
.GetData(request, `/org/profile/keycloak/commander/${evaluation.userId}`) .GetData(request, `/org/profile/keycloak/commander/${evaluation.userId}`)
.then(async (x) => { .then(async (x) => {
root = x.root, (root = x.root),
dateStart = x.dateStart, (dateStart = x.dateStart),
dateRetireLaw = x.dateRetireLaw, (dateRetireLaw = x.dateRetireLaw),
org = x.org, (org = x.org),
commanderFullname = x.commanderFullname, (commanderFullname = x.commanderFullname),
commanderPosition = x.commanderPosition, (commanderPosition = x.commanderPosition),
commanderRootName = x.commanderRootName, (commanderRootName = x.commanderRootName),
commanderOrg = x.commanderOrg, (commanderOrg = x.commanderOrg),
commanderAboveFullname = x.commanderAboveFullname, (commanderAboveFullname = x.commanderAboveFullname),
commanderAbovePosition = x.commanderAbovePosition, (commanderAbovePosition = x.commanderAbovePosition),
commanderAboveRootName = x.commanderAboveRootName, (commanderAboveRootName = x.commanderAboveRootName),
commanderAboveOrg = x.commanderAboveOrg (commanderAboveOrg = x.commanderAboveOrg);
}) })
.catch(); .catch();
const evaluationOld = await this.evaluationRepository.find({ const evaluationOld = await this.evaluationRepository.find({
where: { where: {
id: Not(id), id: Not(id),
userId: evaluation.userId, userId: evaluation.userId,
step: "DONE" step: "DONE",
} },
}); });
let subjectOld = evaluationOld.length > 0 let subjectOld =
? evaluationOld.map(x => x.subject).join(", ") evaluationOld.length > 0 ? evaluationOld.map((x) => x.subject).join(", ") : "ไม่มี";
: "ไม่มี" let thaiYear: number = new Date().getFullYear() + 543;
let thaiYear:number = new Date().getFullYear()+543
let years = { let years = {
lastTwoYear: Extension.ToThaiNumber((thaiYear - 2).toString()), lastTwoYear: Extension.ToThaiNumber((thaiYear - 2).toString()),
lastOneYear: Extension.ToThaiNumber((thaiYear - 1).toString()), lastOneYear: Extension.ToThaiNumber((thaiYear - 1).toString()),
currentYear: Extension.ToThaiNumber(thaiYear.toString()), currentYear: Extension.ToThaiNumber(thaiYear.toString()),
} };
const dataEvaluation = { const dataEvaluation = {
isEducationalQft: evaluation.isEducationalQft, isEducationalQft: evaluation.isEducationalQft,
isGovermantServiceHtr: evaluation.isGovermantServiceHtr, isGovermantServiceHtr: evaluation.isGovermantServiceHtr,
@ -206,7 +221,10 @@ export class ReoportController {
isHaveMinPeriodOrHoldPos: evaluation.isHaveMinPeriodOrHoldPos, isHaveMinPeriodOrHoldPos: evaluation.isHaveMinPeriodOrHoldPos,
type: evaluation.type, type: evaluation.type,
prefix: evaluation.prefix, prefix: evaluation.prefix,
fullName: evaluation.prefix && evaluation.fullName ? `${evaluation.prefix}${evaluation.fullName}` : "-", fullName:
evaluation.prefix && evaluation.fullName
? `${evaluation.prefix}${evaluation.fullName}`
: "-",
position: evaluation.position ? evaluation.position : "-", position: evaluation.position ? evaluation.position : "-",
posNo: evaluation.posNo ? Extension.ToThaiNumber(evaluation.posNo) : "-", posNo: evaluation.posNo ? Extension.ToThaiNumber(evaluation.posNo) : "-",
oc: evaluation.oc ? evaluation.oc : "-", oc: evaluation.oc ? evaluation.oc : "-",
@ -214,12 +232,13 @@ export class ReoportController {
root: root ? root : "-", //หน่วยงาน root: root ? root : "-", //หน่วยงาน
salary: evaluation.salary ? Extension.ToThaiNumber(evaluation.salary) : "-", salary: evaluation.salary ? Extension.ToThaiNumber(evaluation.salary) : "-",
positionLevel: evaluation.positionLevel ? evaluation.positionLevel : "-", positionLevel: evaluation.positionLevel ? evaluation.positionLevel : "-",
birthDate: evaluation.birthDate != null && evaluation.birthDate != "" birthDate:
? Extension.ToThaiNumber(Extension.ToThaiShortDate_noPrefix(new Date(evaluation.birthDate))) evaluation.birthDate != null && evaluation.birthDate != ""
: "-", ? Extension.ToThaiNumber(
govAge: evaluation.govAge != null Extension.ToThaiShortDate_noPrefix(new Date(evaluation.birthDate)),
? Extension.ToThaiNumber(evaluation.govAge) )
: "-", : "-",
govAge: evaluation.govAge != null ? Extension.ToThaiNumber(evaluation.govAge) : "-",
experience: evaluation.experience ? evaluation.experience : "-", experience: evaluation.experience ? evaluation.experience : "-",
dateStart: dateStart dateStart: dateStart
? Extension.ToThaiNumber(Extension.ToThaiShortDate(new Date(dateStart))) ? Extension.ToThaiNumber(Extension.ToThaiShortDate(new Date(dateStart)))
@ -229,16 +248,17 @@ export class ReoportController {
: "-", : "-",
subject: evaluation.subject != null ? evaluation.subject : "-", subject: evaluation.subject != null ? evaluation.subject : "-",
subjectOld: subjectOld, subjectOld: subjectOld,
educations: evaluation.education.length > 0 educations:
evaluation.education.length > 0
? evaluation.education.map((education) => ({ ? evaluation.education.map((education) => ({
educationLevel: education.educationLevel educationLevel: education.educationLevel
? Extension.ToThaiNumber(education.educationLevel) ? Extension.ToThaiNumber(education.educationLevel)
: "-", : "-",
institute: education.institute institute: education.institute ? Extension.ToThaiNumber(education.institute) : "-",
? Extension.ToThaiNumber(education.institute)
: "-",
finishYear: education.finishDate finishYear: education.finishDate
? Extension.ToThaiNumber((Extension.ToThaiYear(education.finishDate.getFullYear())).toString()) ? Extension.ToThaiNumber(
Extension.ToThaiYear(education.finishDate.getFullYear()).toString(),
)
: "-", : "-",
isDate: education.isDate, isDate: education.isDate,
startDate: education.startDate, startDate: education.startDate,
@ -247,12 +267,8 @@ export class ReoportController {
? Extension.ToThaiNumber(Extension.ToThaiShortDate(education.finishDate).toString()) ? Extension.ToThaiNumber(Extension.ToThaiShortDate(education.finishDate).toString())
: "-", : "-",
isEducation: education.isEducation, isEducation: education.isEducation,
degree: education.degree degree: education.degree ? Extension.ToThaiNumber(education.degree) : "-",
? Extension.ToThaiNumber(education.degree) field: education.field ? Extension.ToThaiNumber(education.field) : "-",
: "-",
field: education.field
? Extension.ToThaiNumber(education.field)
: "-",
fundName: education.fundName, fundName: education.fundName,
gpa: education.gpa, gpa: education.gpa,
country: education.country, country: education.country,
@ -260,36 +276,40 @@ export class ReoportController {
duration: education.duration, duration: education.duration,
durationYear: education.durationYear, durationYear: education.durationYear,
})) }))
: [{ : [
{
educationLevel: "-", educationLevel: "-",
institute: "-", institute: "-",
finishYear: "-", finishYear: "-",
finishDate: "-", finishDate: "-",
degree: "-", degree: "-",
field: "-" field: "-",
}], },
certificates: evaluation.certificate.length > 0 ],
certificates:
evaluation.certificate.length > 0
? evaluation.certificate.map((certificate) => ({ ? evaluation.certificate.map((certificate) => ({
certificateType: certificate.certificateType certificateType: certificate.certificateType
? Extension.ToThaiNumber(certificate.certificateType) ? Extension.ToThaiNumber(certificate.certificateType)
: "-", : "-",
issuer: certificate.issuer issuer: certificate.issuer ? Extension.ToThaiNumber(certificate.issuer) : "-",
? Extension.ToThaiNumber(certificate.issuer)
: "-",
certificateNo: certificate.certificateNo certificateNo: certificate.certificateNo
? Extension.ToThaiNumber(certificate.certificateNo) ? Extension.ToThaiNumber(certificate.certificateNo)
: "-", : "-",
issueDate: certificate.issueDate, issueDate: certificate.issueDate,
expireDate: certificate.expireDate, expireDate: certificate.expireDate,
})) }))
: [{ : [
{
certificateType: "-", certificateType: "-",
issuer: "-", issuer: "-",
certificateNo: "-", certificateNo: "-",
issueDate: "-", issueDate: "-",
expireDate: "-", expireDate: "-",
}], },
salaries: evaluation.salaries.length > 0 ],
salaries:
evaluation.salaries.length > 0
? evaluation.salaries.map((salaries) => ({ ? evaluation.salaries.map((salaries) => ({
date: salaries.date date: salaries.date
? Extension.ToThaiNumber(Extension.ToThaiShortDate_noPrefix(salaries.date)) ? Extension.ToThaiNumber(Extension.ToThaiShortDate_noPrefix(salaries.date))
@ -297,9 +317,7 @@ export class ReoportController {
amount: salaries.amount amount: salaries.amount
? Extension.ToThaiNumber(salaries.amount.toLocaleString()) ? Extension.ToThaiNumber(salaries.amount.toLocaleString())
: "-", : "-",
position: salaries.position position: salaries.position ? Extension.ToThaiNumber(salaries.position) : "-",
? Extension.ToThaiNumber(salaries.position)
: "-",
positionSalaryAmount: salaries.positionSalaryAmount, positionSalaryAmount: salaries.positionSalaryAmount,
mouthSalaryAmount: salaries.mouthSalaryAmount, mouthSalaryAmount: salaries.mouthSalaryAmount,
posNo: salaries.posNo, posNo: salaries.posNo,
@ -309,39 +327,38 @@ export class ReoportController {
refCommandDate: salaries.refCommandDate, refCommandDate: salaries.refCommandDate,
salaryStatus: salaries.salaryStatus, salaryStatus: salaries.salaryStatus,
})) }))
: [{ : [
{
date: "-", date: "-",
amount: "-", amount: "-",
position: "-", position: "-",
}], },
trainings: evaluation.training.length > 0 ],
trainings:
evaluation.training.length > 0
? evaluation.training.map((training) => ({ ? evaluation.training.map((training) => ({
name: training.name name: training.name ? Extension.ToThaiNumber(training.name) : "-",
? Extension.ToThaiNumber(training.name) topic: training.topic ? Extension.ToThaiNumber(training.topic) : "-",
: "-",
topic: training.topic
? Extension.ToThaiNumber(training.topic)
: "-",
startDate: training.startDate startDate: training.startDate
? Extension.ToThaiNumber(Extension.ToThaiShortDate_noPrefix(training.startDate)) ? Extension.ToThaiNumber(Extension.ToThaiShortDate_noPrefix(training.startDate))
: "-", : "-",
endDate: training.endDate endDate: training.endDate
? Extension.ToThaiNumber(Extension.ToThaiShortDate_noPrefix(training.endDate)) ? Extension.ToThaiNumber(Extension.ToThaiShortDate_noPrefix(training.endDate))
: "-", : "-",
yearly: training.yearly yearly: training.yearly ? Extension.ToThaiNumber(training.yearly.toString()) : "-",
? Extension.ToThaiNumber(training.yearly.toString())
: "-",
place: training.place, place: training.place,
duration: training.duration, duration: training.duration,
department: training.department, department: training.department,
numberOrder: training.numberOrder, numberOrder: training.numberOrder,
dateOrder: training.dateOrder, dateOrder: training.dateOrder,
})) }))
: [{ : [
{
name: "-", name: "-",
topic: "-", topic: "-",
yearly: "-", yearly: "-",
}], },
],
assessments: evaluation.assessment.map((assessment) => ({ assessments: evaluation.assessment.map((assessment) => ({
date: assessment.date, date: assessment.date,
point1Total: assessment.point1Total, point1Total: assessment.point1Total,
@ -359,7 +376,7 @@ export class ReoportController {
commanderAbovePosition: commanderAbovePosition ? commanderAbovePosition : "-", commanderAbovePosition: commanderAbovePosition ? commanderAbovePosition : "-",
commanderAboveRootName: commanderAboveRootName ? commanderAboveRootName : "-", commanderAboveRootName: commanderAboveRootName ? commanderAboveRootName : "-",
commanderAboveOrg: commanderAboveOrg ? commanderAboveOrg : "-", commanderAboveOrg: commanderAboveOrg ? commanderAboveOrg : "-",
years: years years: years,
}; };
if (!dataEvaluation) { if (!dataEvaluation) {

View file

@ -186,6 +186,9 @@ export class Evaluation extends EntityBase {
@Column({ nullable: true, comment: "ตำแหน่งที่ได้รับมอบหมาย" }) @Column({ nullable: true, comment: "ตำแหน่งที่ได้รับมอบหมาย" })
assignedPosition: string; assignedPosition: string;
@Column({ nullable: true, comment: "ผลการประเมิน", default: "PENDING" })//PENDING,PASS,NOTPASS
evaluationResult: string;
@OneToMany(() => EvaluationLogs, (evaluationLogs) => evaluationLogs.evaluation) @OneToMany(() => EvaluationLogs, (evaluationLogs) => evaluationLogs.evaluation)
evaluationLogs: EvaluationLogs[]; evaluationLogs: EvaluationLogs[];

View file

@ -0,0 +1,14 @@
import { MigrationInterface, QueryRunner } from "typeorm";
export class Update12202024me1734665465868 implements MigrationInterface {
name = 'Update12202024me1734665465868'
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`evaluation\` ADD \`evaluationResult\` varchar(255) NULL COMMENT 'ผลการประเมิน' DEFAULT 'PENDING'`);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`evaluation\` DROP COLUMN \`evaluationResult\``);
}
}