Merge branch 'develop'
This commit is contained in:
commit
17dee5b79e
4 changed files with 242 additions and 159 deletions
|
|
@ -52,6 +52,17 @@ export class EvaluationController {
|
|||
private directorRepository = AppDataSource.getRepository(Director);
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ import {
|
|||
SuccessResponse,
|
||||
Tags,
|
||||
Delete,
|
||||
Query,
|
||||
} from "tsoa";
|
||||
import HttpStatusCode from "../interfaces/http-status";
|
||||
import { Evaluation } from "../entities/Evaluation";
|
||||
|
|
@ -30,7 +31,7 @@ import { Brackets } from "typeorm";
|
|||
import CallAPI from "../interfaces/call-api";
|
||||
import { RequestWithUser } from "../middlewares/user";
|
||||
import Extension from "../interfaces/extension";
|
||||
import { Not } from "typeorm"
|
||||
import { Not } from "typeorm";
|
||||
@Route("api/v1/evaluation/report")
|
||||
@Tags("report")
|
||||
@Security("bearerAuth")
|
||||
|
|
@ -50,6 +51,21 @@ export class ReoportController {
|
|||
private directorRepository = AppDataSource.getRepository(Director);
|
||||
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 ระบบประเมินบุคคล
|
||||
*
|
||||
|
|
@ -148,54 +164,53 @@ export class ReoportController {
|
|||
if (!evaluation) {
|
||||
return "ไม่พบข้อมูล";
|
||||
}
|
||||
let root: any
|
||||
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
|
||||
let root: any;
|
||||
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
|
||||
(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: {
|
||||
where: {
|
||||
id: Not(id),
|
||||
userId: evaluation.userId,
|
||||
step: "DONE"
|
||||
}
|
||||
step: "DONE",
|
||||
},
|
||||
});
|
||||
let subjectOld = evaluationOld.length > 0
|
||||
? evaluationOld.map(x => x.subject).join(", ")
|
||||
: "ไม่มี"
|
||||
let thaiYear:number = new Date().getFullYear()+543
|
||||
let subjectOld =
|
||||
evaluationOld.length > 0 ? evaluationOld.map((x) => x.subject).join(", ") : "ไม่มี";
|
||||
let thaiYear: number = new Date().getFullYear() + 543;
|
||||
let years = {
|
||||
lastTwoYear: Extension.ToThaiNumber((thaiYear-2).toString()),
|
||||
lastOneYear: Extension.ToThaiNumber((thaiYear-1).toString()),
|
||||
lastTwoYear: Extension.ToThaiNumber((thaiYear - 2).toString()),
|
||||
lastOneYear: Extension.ToThaiNumber((thaiYear - 1).toString()),
|
||||
currentYear: Extension.ToThaiNumber(thaiYear.toString()),
|
||||
}
|
||||
};
|
||||
const dataEvaluation = {
|
||||
isEducationalQft: evaluation.isEducationalQft,
|
||||
isGovermantServiceHtr: evaluation.isGovermantServiceHtr,
|
||||
|
|
@ -206,7 +221,10 @@ export class ReoportController {
|
|||
isHaveMinPeriodOrHoldPos: evaluation.isHaveMinPeriodOrHoldPos,
|
||||
type: evaluation.type,
|
||||
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 : "-",
|
||||
posNo: evaluation.posNo ? Extension.ToThaiNumber(evaluation.posNo) : "-",
|
||||
oc: evaluation.oc ? evaluation.oc : "-",
|
||||
|
|
@ -214,134 +232,133 @@ export class ReoportController {
|
|||
root: root ? root : "-", //หน่วยงาน
|
||||
salary: evaluation.salary ? Extension.ToThaiNumber(evaluation.salary) : "-",
|
||||
positionLevel: evaluation.positionLevel ? evaluation.positionLevel : "-",
|
||||
birthDate: evaluation.birthDate != null && evaluation.birthDate != ""
|
||||
? Extension.ToThaiNumber(Extension.ToThaiShortDate_noPrefix(new Date(evaluation.birthDate)))
|
||||
: "-",
|
||||
govAge: evaluation.govAge != null
|
||||
? Extension.ToThaiNumber(evaluation.govAge)
|
||||
: "-",
|
||||
birthDate:
|
||||
evaluation.birthDate != null && evaluation.birthDate != ""
|
||||
? Extension.ToThaiNumber(
|
||||
Extension.ToThaiShortDate_noPrefix(new Date(evaluation.birthDate)),
|
||||
)
|
||||
: "-",
|
||||
govAge: evaluation.govAge != null ? Extension.ToThaiNumber(evaluation.govAge) : "-",
|
||||
experience: evaluation.experience ? evaluation.experience : "-",
|
||||
dateStart: dateStart
|
||||
dateStart: dateStart
|
||||
? Extension.ToThaiNumber(Extension.ToThaiShortDate(new Date(dateStart)))
|
||||
: "-",
|
||||
dateRetireLaw: dateRetireLaw
|
||||
dateRetireLaw: dateRetireLaw
|
||||
? Extension.ToThaiNumber(Extension.ToThaiShortDate(new Date(dateRetireLaw)))
|
||||
: "-",
|
||||
subject: evaluation.subject != null ? evaluation.subject : "-",
|
||||
subject: evaluation.subject != null ? evaluation.subject : "-",
|
||||
subjectOld: subjectOld,
|
||||
educations: evaluation.education.length > 0
|
||||
? evaluation.education.map((education) => ({
|
||||
educationLevel: education.educationLevel
|
||||
? Extension.ToThaiNumber(education.educationLevel)
|
||||
: "-",
|
||||
institute: education.institute
|
||||
? Extension.ToThaiNumber(education.institute)
|
||||
: "-",
|
||||
finishYear: education.finishDate
|
||||
? Extension.ToThaiNumber((Extension.ToThaiYear(education.finishDate.getFullYear())).toString())
|
||||
: "-",
|
||||
isDate: education.isDate,
|
||||
startDate: education.startDate,
|
||||
endDate: education.endDate,
|
||||
finishDate: education.finishDate
|
||||
? Extension.ToThaiNumber(Extension.ToThaiShortDate(education.finishDate).toString())
|
||||
: "-",
|
||||
isEducation: education.isEducation,
|
||||
degree: education.degree
|
||||
? Extension.ToThaiNumber(education.degree)
|
||||
: "-",
|
||||
field: education.field
|
||||
? Extension.ToThaiNumber(education.field)
|
||||
: "-",
|
||||
fundName: education.fundName,
|
||||
gpa: education.gpa,
|
||||
country: education.country,
|
||||
other: education.other,
|
||||
duration: education.duration,
|
||||
durationYear: education.durationYear,
|
||||
}))
|
||||
: [{
|
||||
educationLevel: "-",
|
||||
institute: "-",
|
||||
finishYear: "-",
|
||||
finishDate: "-",
|
||||
degree: "-",
|
||||
field: "-"
|
||||
}],
|
||||
certificates: evaluation.certificate.length > 0
|
||||
? evaluation.certificate.map((certificate) => ({
|
||||
certificateType: certificate.certificateType
|
||||
? Extension.ToThaiNumber(certificate.certificateType)
|
||||
: "-",
|
||||
issuer: certificate.issuer
|
||||
? Extension.ToThaiNumber(certificate.issuer)
|
||||
: "-",
|
||||
certificateNo: certificate.certificateNo
|
||||
? Extension.ToThaiNumber(certificate.certificateNo)
|
||||
: "-",
|
||||
issueDate: certificate.issueDate,
|
||||
expireDate: certificate.expireDate,
|
||||
}))
|
||||
: [{
|
||||
certificateType: "-",
|
||||
issuer: "-",
|
||||
certificateNo: "-",
|
||||
issueDate: "-",
|
||||
expireDate: "-",
|
||||
}],
|
||||
salaries: evaluation.salaries.length > 0
|
||||
? evaluation.salaries.map((salaries) => ({
|
||||
date: salaries.date
|
||||
? Extension.ToThaiNumber(Extension.ToThaiShortDate_noPrefix(salaries.date))
|
||||
: "-",
|
||||
amount: salaries.amount
|
||||
? Extension.ToThaiNumber(salaries.amount.toLocaleString())
|
||||
: "-",
|
||||
position: salaries.position
|
||||
? Extension.ToThaiNumber(salaries.position)
|
||||
: "-",
|
||||
positionSalaryAmount: salaries.positionSalaryAmount,
|
||||
mouthSalaryAmount: salaries.mouthSalaryAmount,
|
||||
posNo: salaries.posNo,
|
||||
salaryClass: salaries.salaryClass,
|
||||
salaryRef: salaries.salaryRef,
|
||||
refCommandNo: salaries.refCommandNo,
|
||||
refCommandDate: salaries.refCommandDate,
|
||||
salaryStatus: salaries.salaryStatus,
|
||||
}))
|
||||
: [{
|
||||
date: "-",
|
||||
amount: "-",
|
||||
position: "-",
|
||||
}],
|
||||
trainings: evaluation.training.length > 0
|
||||
? evaluation.training.map((training) => ({
|
||||
name: training.name
|
||||
? Extension.ToThaiNumber(training.name)
|
||||
: "-",
|
||||
topic: training.topic
|
||||
? Extension.ToThaiNumber(training.topic)
|
||||
: "-",
|
||||
startDate: training.startDate
|
||||
? Extension.ToThaiNumber(Extension.ToThaiShortDate_noPrefix(training.startDate))
|
||||
: "-",
|
||||
endDate: training.endDate
|
||||
? Extension.ToThaiNumber(Extension.ToThaiShortDate_noPrefix(training.endDate))
|
||||
: "-",
|
||||
yearly: training.yearly
|
||||
? Extension.ToThaiNumber(training.yearly.toString())
|
||||
: "-",
|
||||
place: training.place,
|
||||
duration: training.duration,
|
||||
department: training.department,
|
||||
numberOrder: training.numberOrder,
|
||||
dateOrder: training.dateOrder,
|
||||
}))
|
||||
: [{
|
||||
name: "-",
|
||||
topic: "-",
|
||||
yearly: "-",
|
||||
}],
|
||||
educations:
|
||||
evaluation.education.length > 0
|
||||
? evaluation.education.map((education) => ({
|
||||
educationLevel: education.educationLevel
|
||||
? Extension.ToThaiNumber(education.educationLevel)
|
||||
: "-",
|
||||
institute: education.institute ? Extension.ToThaiNumber(education.institute) : "-",
|
||||
finishYear: education.finishDate
|
||||
? Extension.ToThaiNumber(
|
||||
Extension.ToThaiYear(education.finishDate.getFullYear()).toString(),
|
||||
)
|
||||
: "-",
|
||||
isDate: education.isDate,
|
||||
startDate: education.startDate,
|
||||
endDate: education.endDate,
|
||||
finishDate: education.finishDate
|
||||
? Extension.ToThaiNumber(Extension.ToThaiShortDate(education.finishDate).toString())
|
||||
: "-",
|
||||
isEducation: education.isEducation,
|
||||
degree: education.degree ? Extension.ToThaiNumber(education.degree) : "-",
|
||||
field: education.field ? Extension.ToThaiNumber(education.field) : "-",
|
||||
fundName: education.fundName,
|
||||
gpa: education.gpa,
|
||||
country: education.country,
|
||||
other: education.other,
|
||||
duration: education.duration,
|
||||
durationYear: education.durationYear,
|
||||
}))
|
||||
: [
|
||||
{
|
||||
educationLevel: "-",
|
||||
institute: "-",
|
||||
finishYear: "-",
|
||||
finishDate: "-",
|
||||
degree: "-",
|
||||
field: "-",
|
||||
},
|
||||
],
|
||||
certificates:
|
||||
evaluation.certificate.length > 0
|
||||
? evaluation.certificate.map((certificate) => ({
|
||||
certificateType: certificate.certificateType
|
||||
? Extension.ToThaiNumber(certificate.certificateType)
|
||||
: "-",
|
||||
issuer: certificate.issuer ? Extension.ToThaiNumber(certificate.issuer) : "-",
|
||||
certificateNo: certificate.certificateNo
|
||||
? Extension.ToThaiNumber(certificate.certificateNo)
|
||||
: "-",
|
||||
issueDate: certificate.issueDate,
|
||||
expireDate: certificate.expireDate,
|
||||
}))
|
||||
: [
|
||||
{
|
||||
certificateType: "-",
|
||||
issuer: "-",
|
||||
certificateNo: "-",
|
||||
issueDate: "-",
|
||||
expireDate: "-",
|
||||
},
|
||||
],
|
||||
salaries:
|
||||
evaluation.salaries.length > 0
|
||||
? evaluation.salaries.map((salaries) => ({
|
||||
date: salaries.date
|
||||
? Extension.ToThaiNumber(Extension.ToThaiShortDate_noPrefix(salaries.date))
|
||||
: "-",
|
||||
amount: salaries.amount
|
||||
? Extension.ToThaiNumber(salaries.amount.toLocaleString())
|
||||
: "-",
|
||||
position: salaries.position ? Extension.ToThaiNumber(salaries.position) : "-",
|
||||
positionSalaryAmount: salaries.positionSalaryAmount,
|
||||
mouthSalaryAmount: salaries.mouthSalaryAmount,
|
||||
posNo: salaries.posNo,
|
||||
salaryClass: salaries.salaryClass,
|
||||
salaryRef: salaries.salaryRef,
|
||||
refCommandNo: salaries.refCommandNo,
|
||||
refCommandDate: salaries.refCommandDate,
|
||||
salaryStatus: salaries.salaryStatus,
|
||||
}))
|
||||
: [
|
||||
{
|
||||
date: "-",
|
||||
amount: "-",
|
||||
position: "-",
|
||||
},
|
||||
],
|
||||
trainings:
|
||||
evaluation.training.length > 0
|
||||
? evaluation.training.map((training) => ({
|
||||
name: training.name ? Extension.ToThaiNumber(training.name) : "-",
|
||||
topic: training.topic ? Extension.ToThaiNumber(training.topic) : "-",
|
||||
startDate: training.startDate
|
||||
? Extension.ToThaiNumber(Extension.ToThaiShortDate_noPrefix(training.startDate))
|
||||
: "-",
|
||||
endDate: training.endDate
|
||||
? Extension.ToThaiNumber(Extension.ToThaiShortDate_noPrefix(training.endDate))
|
||||
: "-",
|
||||
yearly: training.yearly ? Extension.ToThaiNumber(training.yearly.toString()) : "-",
|
||||
place: training.place,
|
||||
duration: training.duration,
|
||||
department: training.department,
|
||||
numberOrder: training.numberOrder,
|
||||
dateOrder: training.dateOrder,
|
||||
}))
|
||||
: [
|
||||
{
|
||||
name: "-",
|
||||
topic: "-",
|
||||
yearly: "-",
|
||||
},
|
||||
],
|
||||
assessments: evaluation.assessment.map((assessment) => ({
|
||||
date: assessment.date,
|
||||
point1Total: assessment.point1Total,
|
||||
|
|
@ -359,7 +376,7 @@ export class ReoportController {
|
|||
commanderAbovePosition: commanderAbovePosition ? commanderAbovePosition : "-",
|
||||
commanderAboveRootName: commanderAboveRootName ? commanderAboveRootName : "-",
|
||||
commanderAboveOrg: commanderAboveOrg ? commanderAboveOrg : "-",
|
||||
years: years
|
||||
years: years,
|
||||
};
|
||||
|
||||
if (!dataEvaluation) {
|
||||
|
|
|
|||
|
|
@ -186,6 +186,9 @@ export class Evaluation extends EntityBase {
|
|||
@Column({ nullable: true, comment: "ตำแหน่งที่ได้รับมอบหมาย" })
|
||||
assignedPosition: string;
|
||||
|
||||
@Column({ nullable: true, comment: "ผลการประเมิน", default: "PENDING" })//PENDING,PASS,NOTPASS
|
||||
evaluationResult: string;
|
||||
|
||||
@OneToMany(() => EvaluationLogs, (evaluationLogs) => evaluationLogs.evaluation)
|
||||
evaluationLogs: EvaluationLogs[];
|
||||
|
||||
|
|
|
|||
14
src/migration/1734665465868-update_12202024me.ts
Normal file
14
src/migration/1734665465868-update_12202024me.ts
Normal 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\``);
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue