From 488b3b09233833fd323b3098e604aa3b770e801b Mon Sep 17 00:00:00 2001 From: AdisakKanthawilang Date: Wed, 9 Apr 2025 17:34:32 +0700 Subject: [PATCH 01/39] update report --- src/controllers/ReportController.ts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/controllers/ReportController.ts b/src/controllers/ReportController.ts index 4a08172..452a4d0 100644 --- a/src/controllers/ReportController.ts +++ b/src/controllers/ReportController.ts @@ -319,6 +319,8 @@ export class ReoportController { lastOneYear: Extension.ToThaiNumber((thaiYear - 1).toString()), currentYear: Extension.ToThaiNumber(thaiYear.toString()), }; + let _orgNoNewLine = (org ? org : "-").replace(/\n/g, " "); + let typeTh = evaluation.type == "EXPERT" ? "ชำนาญการ" : evaluation.type == "EXPERTISE" ? "เชียวชาญ" : evaluation.type == "SPECIAL_EXPERT" ? "ชำนาญการพิเศษ":""; const dataEvaluation = { isEducationalQft: evaluation.isEducationalQft, isGovermantServiceHtr: evaluation.isGovermantServiceHtr, @@ -328,15 +330,18 @@ 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 : "", + 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 : "-", + positionLevel: evaluation.positionLevel ? evaluation.positionLevel : "", birthDate: evaluation.birthDate != null && evaluation.birthDate != "" ? Extension.ToThaiNumber( From da710215ec21e1bf3473174909bcdf77ae6f85bf Mon Sep 17 00:00:00 2001 From: waruneeauy Date: Wed, 9 Apr 2025 23:47:55 +0700 Subject: [PATCH 02/39] fixing throw error & message error --- src/controllers/DocumentController.ts | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/controllers/DocumentController.ts b/src/controllers/DocumentController.ts index b20ba08..3d1c952 100644 --- a/src/controllers/DocumentController.ts +++ b/src/controllers/DocumentController.ts @@ -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); } } } From 5abaacdf15cd84988c063b223ea034604a5b3bc1 Mon Sep 17 00:00:00 2001 From: AdisakKanthawilang Date: Thu, 17 Apr 2025 11:56:54 +0700 Subject: [PATCH 03/39] checkpoint --- src/controllers/ReportController.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/controllers/ReportController.ts b/src/controllers/ReportController.ts index 452a4d0..c687c2a 100644 --- a/src/controllers/ReportController.ts +++ b/src/controllers/ReportController.ts @@ -334,6 +334,8 @@ export class ReoportController { prefix: evaluation.prefix, 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 : "-", @@ -341,11 +343,12 @@ export class ReoportController { orgNoNewLine: _orgNoNewLine ? _orgNoNewLine : "-", //สังกัดแบบไม่เว้นวรรค root: root ? root : "-", //หน่วยงาน salary: evaluation.salary ? Extension.ToThaiNumber(evaluation.salary) : "-", + salaryWithPrefix: 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)), + Extension.ToThaiFullDate2(new Date(evaluation.birthDate)), ) : "-", govAge: evaluation.govAge != null ? Extension.ToThaiNumber(evaluation.govAge) : "-", From 879b6bfd0b2b96b285ef53d3702f4cbf5a017744 Mon Sep 17 00:00:00 2001 From: AdisakKanthawilang Date: Fri, 18 Apr 2025 13:18:11 +0700 Subject: [PATCH 04/39] update field and api update duty --- src/controllers/DirectorController.ts | 28 +++++++++++++++++++++++++++ src/entities/Director.ts | 6 ++++++ src/entities/Evaluation.ts | 15 ++++++++++++++ 3 files changed, 49 insertions(+) diff --git a/src/controllers/DirectorController.ts b/src/controllers/DirectorController.ts index dfb3b23..fd63984 100644 --- a/src/controllers/DirectorController.ts +++ b/src/controllers/DirectorController.ts @@ -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 สำหรับแก้ไขรายละเอียดกรรมการ * diff --git a/src/entities/Director.ts b/src/entities/Director.ts index dd6a209..2710d23 100644 --- a/src/entities/Director.ts +++ b/src/entities/Director.ts @@ -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; diff --git a/src/entities/Evaluation.ts b/src/entities/Evaluation.ts index b7e1daf..2a1934e 100644 --- a/src/entities/Evaluation.ts +++ b/src/entities/Evaluation.ts @@ -199,6 +199,21 @@ 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: "ชื่อ-นามสกุล ผู้บังคับบัญชาเหนือขึ้นไป 1 ระดับ (จัดเตรียมเอกสารเล่ม 2)", From 16732e2bfd1b2ca8f4f4f4b86f7e7be08296d003 Mon Sep 17 00:00:00 2001 From: Bright Date: Fri, 18 Apr 2025 13:23:39 +0700 Subject: [PATCH 05/39] migrate --- ...744957358284-update_table_eva_and_direc.ts | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 src/migration/1744957358284-update_table_eva_and_direc.ts diff --git a/src/migration/1744957358284-update_table_eva_and_direc.ts b/src/migration/1744957358284-update_table_eva_and_direc.ts new file mode 100644 index 0000000..56797ab --- /dev/null +++ b/src/migration/1744957358284-update_table_eva_and_direc.ts @@ -0,0 +1,26 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class UpdateTableEvaAndDirec1744957358284 implements MigrationInterface { + name = 'UpdateTableEvaAndDirec1744957358284' + + public async up(queryRunner: QueryRunner): Promise { + 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 { + 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\``); + } + +} From 6ad6788642034bda45a148bff7734d7bbfdb7f91 Mon Sep 17 00:00:00 2001 From: AdisakKanthawilang Date: Fri, 18 Apr 2025 13:33:48 +0700 Subject: [PATCH 06/39] update --- src/controllers/EvaluationController.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/controllers/EvaluationController.ts b/src/controllers/EvaluationController.ts index 43e822c..cf5dc1b 100644 --- a/src/controllers/EvaluationController.ts +++ b/src/controllers/EvaluationController.ts @@ -2335,6 +2335,7 @@ export class EvaluationController { positionName: null, email: director.email, phone: director.phone, + duty: director.duty, })); const meetings = evaluation.meetings.map((meeting) => ({ From 5d1153abf34182314421dc5d2639f5c24f112acd Mon Sep 17 00:00:00 2001 From: AdisakKanthawilang Date: Fri, 18 Apr 2025 14:55:24 +0700 Subject: [PATCH 07/39] add portfolio --- src/controllers/EvaluationController.ts | 20 +++++++++++++++ src/entities/Evaluation.ts | 16 ++++++++++++ src/entities/Portfolio.ts | 34 +++++++++++++++++++++++++ 3 files changed, 70 insertions(+) create mode 100644 src/entities/Portfolio.ts diff --git a/src/controllers/EvaluationController.ts b/src/controllers/EvaluationController.ts index cf5dc1b..5312d3e 100644 --- a/src/controllers/EvaluationController.ts +++ b/src/controllers/EvaluationController.ts @@ -638,6 +638,22 @@ 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; + // await this.assessmentRepository.save(assessment, { data: request }); + // setLogDataDiff(request, { before, after: assessment }); + // }); //EvaluationLogs const evaluationLogs = new EvaluationLogs(); @@ -1143,6 +1159,10 @@ export class EvaluationController { pointSumTotal: assessment.pointSumTotal, pointSum: assessment.pointSum, })), + // portfolios: evaluation.portfolio.map((portfolio) => ({ + // name: portfolio.name, + // detail: portfolio.detail, + // })), // years: years }; diff --git a/src/entities/Evaluation.ts b/src/entities/Evaluation.ts index 2a1934e..5c5ab84 100644 --- a/src/entities/Evaluation.ts +++ b/src/entities/Evaluation.ts @@ -8,6 +8,7 @@ import { Training } from "./Training"; import { Assessment } from "./Assessment"; import { Director } from "./Director"; import { Meeting } from "./Meeting"; +import { Portfolio } from "./Portfolio"; @Entity("evaluation") export class Evaluation extends EntityBase { @@ -275,6 +276,10 @@ export class Evaluation extends EntityBase { @ManyToMany(() => Meeting, (meeting) => meeting.evaluations) @JoinTable() meetings: Meeting[]; + + @ManyToMany(() => Portfolio, (portfolio) => portfolio.evaluations) + @JoinTable() + portfolios: Portfolio[]; } export class CreateEvaluation { @@ -356,6 +361,9 @@ export class CreateEvaluation { @Column() assessments?: CreateAssessment[]; + @Column() + portfolios?: CreatePortfolio[]; + @Column() root?: string | null; @@ -516,6 +524,14 @@ export class CreateAssessment { @Column() pointSum?: number | null; } + +export class CreatePortfolio { + @Column() + name?: string | null; + + @Column() + detail?: string | null; +} export class CreateEvaluationExpertise { @Column() author?: string | null; diff --git a/src/entities/Portfolio.ts b/src/entities/Portfolio.ts new file mode 100644 index 0000000..3814e57 --- /dev/null +++ b/src/entities/Portfolio.ts @@ -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" }) + evaluations: Evaluation; +} + +export type UpdatePortfolio = Partial; From db55795106c1c3eb254b969e38dc219fcd48e081 Mon Sep 17 00:00:00 2001 From: Bright Date: Fri, 18 Apr 2025 14:59:37 +0700 Subject: [PATCH 08/39] migrate --- .../1744963144566-add_table_portfolio.ts | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 src/migration/1744963144566-add_table_portfolio.ts diff --git a/src/migration/1744963144566-add_table_portfolio.ts b/src/migration/1744963144566-add_table_portfolio.ts new file mode 100644 index 0000000..71fc391 --- /dev/null +++ b/src/migration/1744963144566-add_table_portfolio.ts @@ -0,0 +1,24 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class AddTablePortfolio1744963144566 implements MigrationInterface { + name = 'AddTablePortfolio1744963144566' + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(`CREATE TABLE \`portfolio\` (\`id\` varchar(36) NOT NULL, \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6), \`createdUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่สร้างข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6), \`lastUpdateUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่แก้ไขข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`createdFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่สร้างข้อมูล' DEFAULT 'string', \`lastUpdateFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่แก้ไขข้อมูลล่าสุด' DEFAULT 'string', \`evaluationId\` varchar(40) NOT NULL COMMENT 'Id การทำรายการระบบประเมิน' DEFAULT '00000000-0000-0000-0000-000000000000', \`name\` varchar(255) NULL COMMENT 'ชื่อเอกสาร/ผลงาน', \`detail\` longtext NULL COMMENT 'รายละเอียดเอกสาร/ผลงาน', PRIMARY KEY (\`id\`)) ENGINE=InnoDB`); + await queryRunner.query(`CREATE TABLE \`evaluation_portfolios_portfolio\` (\`evaluationId\` varchar(36) NOT NULL, \`portfolioId\` varchar(36) NOT NULL, INDEX \`IDX_e0c1b7609f41d85fcd8d055bff\` (\`evaluationId\`), INDEX \`IDX_8d7d992c3379639cee695b9092\` (\`portfolioId\`), PRIMARY KEY (\`evaluationId\`, \`portfolioId\`)) ENGINE=InnoDB`); + await queryRunner.query(`ALTER TABLE \`portfolio\` ADD CONSTRAINT \`FK_f2975d47677601d29d7a3daa893\` FOREIGN KEY (\`evaluationId\`) REFERENCES \`evaluation\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE \`evaluation_portfolios_portfolio\` ADD CONSTRAINT \`FK_e0c1b7609f41d85fcd8d055bffa\` FOREIGN KEY (\`evaluationId\`) REFERENCES \`evaluation\`(\`id\`) ON DELETE CASCADE ON UPDATE CASCADE`); + await queryRunner.query(`ALTER TABLE \`evaluation_portfolios_portfolio\` ADD CONSTRAINT \`FK_8d7d992c3379639cee695b9092c\` FOREIGN KEY (\`portfolioId\`) REFERENCES \`portfolio\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`evaluation_portfolios_portfolio\` DROP FOREIGN KEY \`FK_8d7d992c3379639cee695b9092c\``); + await queryRunner.query(`ALTER TABLE \`evaluation_portfolios_portfolio\` DROP FOREIGN KEY \`FK_e0c1b7609f41d85fcd8d055bffa\``); + await queryRunner.query(`ALTER TABLE \`portfolio\` DROP FOREIGN KEY \`FK_f2975d47677601d29d7a3daa893\``); + await queryRunner.query(`DROP INDEX \`IDX_8d7d992c3379639cee695b9092\` ON \`evaluation_portfolios_portfolio\``); + await queryRunner.query(`DROP INDEX \`IDX_e0c1b7609f41d85fcd8d055bff\` ON \`evaluation_portfolios_portfolio\``); + await queryRunner.query(`DROP TABLE \`evaluation_portfolios_portfolio\``); + await queryRunner.query(`DROP TABLE \`portfolio\``); + } + +} From bb4634acf57f28fc21995a5cf34a50ec34ba36e6 Mon Sep 17 00:00:00 2001 From: AdisakKanthawilang Date: Fri, 18 Apr 2025 15:57:38 +0700 Subject: [PATCH 09/39] =?UTF-8?q?#207=20=E0=B8=9B=E0=B8=A3=E0=B8=B0?= =?UTF-8?q?=E0=B8=AA=E0=B8=9A=E0=B8=81=E0=B8=B2=E0=B8=A3=E0=B8=93=E0=B9=8C?= =?UTF-8?q?=E0=B9=83=E0=B8=99=E0=B8=81=E0=B8=B2=E0=B8=A3=E0=B8=9B=E0=B8=8F?= =?UTF-8?q?=E0=B8=B4=E0=B8=9A=E0=B8=B1=E0=B8=95=E0=B8=B4=E0=B8=87=E0=B8=B2?= =?UTF-8?q?=E0=B8=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/EvaluationController.ts | 45 ++++++++++++++----------- src/entities/Evaluation.ts | 7 ++-- src/entities/Portfolio.ts | 2 +- 3 files changed, 31 insertions(+), 23 deletions(-) diff --git a/src/controllers/EvaluationController.ts b/src/controllers/EvaluationController.ts index 5312d3e..d4015e9 100644 --- a/src/controllers/EvaluationController.ts +++ b/src/controllers/EvaluationController.ts @@ -33,6 +33,7 @@ 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"; @Route("api/v1/evaluation") @Tags("evaluation") @@ -50,6 +51,7 @@ export class EvaluationController { private salaryRepository = AppDataSource.getRepository(Salary); private trainingRepository = AppDataSource.getRepository(Training); private assessmentRepository = AppDataSource.getRepository(Assessment); + private portfolioRepository = AppDataSource.getRepository(Portfolio); private directorRepository = AppDataSource.getRepository(Director); private meetingRepository = AppDataSource.getRepository(Meeting); @@ -640,20 +642,21 @@ export class EvaluationController { }); //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; - // await this.assessmentRepository.save(assessment, { data: request }); - // setLogDataDiff(request, { before, after: assessment }); - // }); + 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 }); + }); //EvaluationLogs const evaluationLogs = new EvaluationLogs(); @@ -948,6 +951,7 @@ export class EvaluationController { .leftJoin("evaluation.salaries", "salaries") .leftJoin("evaluation.training", "training") .leftJoin("evaluation.assessment", "assessment") + .leftJoin("evaluation.portfolios", "portfolios") .where("evaluation.id = :id", { id }) .select([ "evaluation.isEducationalQft", @@ -1048,10 +1052,13 @@ export class EvaluationController { "assessment.point2", "assessment.pointSumTotal", "assessment.pointSum", + + "portfolios.name", + "portfolios.detail", ]) .orderBy("salaries.commandDateAffect", "DESC") .getOne(); - + console.log(evaluation); if (!evaluation) { return "ไม่พบข้อมูล"; } @@ -1159,10 +1166,10 @@ export class EvaluationController { pointSumTotal: assessment.pointSumTotal, pointSum: assessment.pointSum, })), - // portfolios: evaluation.portfolio.map((portfolio) => ({ - // name: portfolio.name, - // detail: portfolio.detail, - // })), + portfolios: evaluation.portfolios.map((portfolio) => ({ + name: portfolio.name, + detail: portfolio.detail, + })), // years: years }; diff --git a/src/entities/Evaluation.ts b/src/entities/Evaluation.ts index 5c5ab84..a4b5201 100644 --- a/src/entities/Evaluation.ts +++ b/src/entities/Evaluation.ts @@ -269,6 +269,9 @@ export class Evaluation extends EntityBase { @OneToMany(() => Assessment, (assessment) => assessment.evaluation) assessment: Assessment[]; + @OneToMany(() => Portfolio, (portfolio) => portfolio.evaluation) + portfolios: Portfolio[]; + @ManyToMany(() => Director, (director) => director.evaluations) @JoinTable() directors: Director[]; @@ -277,9 +280,7 @@ export class Evaluation extends EntityBase { @JoinTable() meetings: Meeting[]; - @ManyToMany(() => Portfolio, (portfolio) => portfolio.evaluations) - @JoinTable() - portfolios: Portfolio[]; + } export class CreateEvaluation { diff --git a/src/entities/Portfolio.ts b/src/entities/Portfolio.ts index 3814e57..9865ddf 100644 --- a/src/entities/Portfolio.ts +++ b/src/entities/Portfolio.ts @@ -28,7 +28,7 @@ export class Portfolio extends EntityBase { @ManyToOne(() => Evaluation, (Evaluation) => Evaluation.portfolios) @JoinColumn({ name: "evaluationId" }) - evaluations: Evaluation; + evaluation: Evaluation; } export type UpdatePortfolio = Partial; From 880ba36978462b91a17a8715f4489b6a9ee59226 Mon Sep 17 00:00:00 2001 From: AdisakKanthawilang Date: Fri, 18 Apr 2025 17:29:35 +0700 Subject: [PATCH 10/39] add api performance/user --- src/controllers/EvaluationController.ts | 45 ++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/src/controllers/EvaluationController.ts b/src/controllers/EvaluationController.ts index d4015e9..5fce0f4 100644 --- a/src/controllers/EvaluationController.ts +++ b/src/controllers/EvaluationController.ts @@ -27,7 +27,7 @@ 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"; @@ -66,6 +66,41 @@ 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.dateAnnounce", + "evaluation.type", + "evaluation.subject", + "evaluation.evaluationResult", + ]) + .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, + subject: item.subject, + evaluationResult: item.evaluationResult, + })); + + return new HttpSuccess(performance); + } + /** * ดึงข้อมูลรายการร้องขอการประเมิน * @@ -1293,6 +1328,7 @@ export class EvaluationController { .leftJoin("evaluation.salaries", "salaries") .leftJoin("evaluation.training", "training") .leftJoin("evaluation.assessment", "assessment") + .leftJoin("evaluation.portfolios", "portfolios") .where("evaluation.id = :id", { id }) .select([ "evaluation.isEducationalQft", @@ -1393,6 +1429,9 @@ export class EvaluationController { "assessment.point2", "assessment.pointSumTotal", "assessment.pointSum", + + "portfolios.name", + "portfolios.detail", ]) .orderBy("salaries.commandDateAffect", "DESC") .getOne(); @@ -1504,6 +1543,10 @@ export class EvaluationController { pointSumTotal: assessment.pointSumTotal, pointSum: assessment.pointSum, })), + portfolios: evaluation.portfolios.map((portfolio) => ({ + name: portfolio.name, + detail: portfolio.detail, + })), }; if (!dataEvaluation) { From b782c76ccb9bd53952e14f2dc65391e4554467cf Mon Sep 17 00:00:00 2001 From: AdisakKanthawilang Date: Fri, 18 Apr 2025 17:53:39 +0700 Subject: [PATCH 11/39] update database --- src/entities/Evaluation.ts | 4 ++++ src/entities/Performance.ts | 47 +++++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+) create mode 100644 src/entities/Performance.ts diff --git a/src/entities/Evaluation.ts b/src/entities/Evaluation.ts index a4b5201..5ad1989 100644 --- a/src/entities/Evaluation.ts +++ b/src/entities/Evaluation.ts @@ -9,6 +9,7 @@ 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 { @@ -272,6 +273,9 @@ export class Evaluation extends EntityBase { @OneToMany(() => Portfolio, (portfolio) => portfolio.evaluation) portfolios: Portfolio[]; + @OneToMany(() => Performance, (performance) => performance.evaluation) + performances: Performance[]; + @ManyToMany(() => Director, (director) => director.evaluations) @JoinTable() directors: Director[]; diff --git a/src/entities/Performance.ts b/src/entities/Performance.ts new file mode 100644 index 0000000..f4786a3 --- /dev/null +++ b/src/entities/Performance.ts @@ -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; From 894628e05b7af31b954824fa7212524a780af63d Mon Sep 17 00:00:00 2001 From: Bright Date: Fri, 18 Apr 2025 17:57:38 +0700 Subject: [PATCH 12/39] migrate --- .../1744973794458-update_and_add_table.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 src/migration/1744973794458-update_and_add_table.ts diff --git a/src/migration/1744973794458-update_and_add_table.ts b/src/migration/1744973794458-update_and_add_table.ts new file mode 100644 index 0000000..1f33527 --- /dev/null +++ b/src/migration/1744973794458-update_and_add_table.ts @@ -0,0 +1,16 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class UpdateAndAddTable1744973794458 implements MigrationInterface { + name = 'UpdateAndAddTable1744973794458' + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(`CREATE TABLE \`performance\` (\`id\` varchar(36) NOT NULL, \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6), \`createdUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่สร้างข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6), \`lastUpdateUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่แก้ไขข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`createdFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่สร้างข้อมูล' DEFAULT 'string', \`lastUpdateFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่แก้ไขข้อมูลล่าสุด' DEFAULT 'string', \`evaluationId\` varchar(40) NOT NULL COMMENT 'Id การทำรายการระบบประเมิน' DEFAULT '00000000-0000-0000-0000-000000000000', \`year\` int NULL COMMENT 'ปีที่ประเมิน', \`type\` varchar(255) NULL COMMENT 'ประเภทที่ร้องขอประเมิน', \`subject\` varchar(255) NULL COMMENT 'ชื่อผลงาน', \`evaluationResult\` varchar(255) NULL COMMENT 'ผลการประเมิน', PRIMARY KEY (\`id\`)) ENGINE=InnoDB`); + await queryRunner.query(`ALTER TABLE \`performance\` ADD CONSTRAINT \`FK_edf8c1deb31d77afecfc646615a\` FOREIGN KEY (\`evaluationId\`) REFERENCES \`evaluation\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`performance\` DROP FOREIGN KEY \`FK_edf8c1deb31d77afecfc646615a\``); + await queryRunner.query(`DROP TABLE \`performance\``); + } + +} From 590d6af340843678141fd40d24d5393599986531 Mon Sep 17 00:00:00 2001 From: AdisakKanthawilang Date: Mon, 21 Apr 2025 10:36:25 +0700 Subject: [PATCH 13/39] =?UTF-8?q?#207=20=E0=B8=9C=E0=B8=A5=E0=B8=87?= =?UTF-8?q?=E0=B8=B2=E0=B8=99=E0=B8=97=E0=B8=B5=E0=B9=88=E0=B9=80=E0=B8=84?= =?UTF-8?q?=E0=B8=A2=E0=B9=80=E0=B8=AA=E0=B8=99=E0=B8=AD=E0=B8=82=E0=B8=AD?= =?UTF-8?q?=E0=B8=9B=E0=B8=A3=E0=B8=B0=E0=B9=80=E0=B8=A1=E0=B8=B4=E0=B8=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/EvaluationController.ts | 50 ++++++++++++++++++++++++- src/entities/Evaluation.ts | 18 +++++++++ 2 files changed, 66 insertions(+), 2 deletions(-) diff --git a/src/controllers/EvaluationController.ts b/src/controllers/EvaluationController.ts index 5fce0f4..6a903f6 100644 --- a/src/controllers/EvaluationController.ts +++ b/src/controllers/EvaluationController.ts @@ -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) { diff --git a/src/entities/Evaluation.ts b/src/entities/Evaluation.ts index 5ad1989..feedea1 100644 --- a/src/entities/Evaluation.ts +++ b/src/entities/Evaluation.ts @@ -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; From 72786aeb1df8877c69c3f70997fd690fb60b58fb Mon Sep 17 00:00:00 2001 From: AdisakKanthawilang Date: Mon, 21 Apr 2025 11:01:29 +0700 Subject: [PATCH 14/39] fix --- src/controllers/EvaluationController.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/controllers/EvaluationController.ts b/src/controllers/EvaluationController.ts index 6a903f6..56903db 100644 --- a/src/controllers/EvaluationController.ts +++ b/src/controllers/EvaluationController.ts @@ -1235,7 +1235,7 @@ export class EvaluationController { })), performances: evaluation.performances.map((performance) => ({ year: performance.year, - type: performance.type == "EXPERT" ? "ชำนาญการ" : performance.type == "EXPERTISE" ? "เชียวชาญ" : performance.type == "SPECIAL_EXPERT" ? "ชำนาญการพิเศษ": null, + type: performance.type, subject: performance.subject, evaluationResult: performance.evaluationResult, })), From 38b67ebc38cef980631a465533b9af3684b47830 Mon Sep 17 00:00:00 2001 From: AdisakKanthawilang Date: Mon, 21 Apr 2025 11:13:05 +0700 Subject: [PATCH 15/39] fix delete --- src/controllers/EvaluationController.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/controllers/EvaluationController.ts b/src/controllers/EvaluationController.ts index 56903db..27bcd20 100644 --- a/src/controllers/EvaluationController.ts +++ b/src/controllers/EvaluationController.ts @@ -2923,7 +2923,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) => From 3d71a22002a2f538bd9695280a7b665c89985e8a Mon Sep 17 00:00:00 2001 From: AdisakKanthawilang Date: Mon, 21 Apr 2025 15:48:29 +0700 Subject: [PATCH 16/39] update commander --- src/controllers/EvaluationController.ts | 60 +++++++++++++++++++++---- src/controllers/ReportController.ts | 2 +- src/entities/Evaluation.ts | 22 +++++++-- 3 files changed, 71 insertions(+), 13 deletions(-) diff --git a/src/controllers/EvaluationController.ts b/src/controllers/EvaluationController.ts index 27bcd20..c5ae332 100644 --- a/src/controllers/EvaluationController.ts +++ b/src/controllers/EvaluationController.ts @@ -85,19 +85,19 @@ export class EvaluationController { }) .select([ "evaluation.id", - "evaluation.dateAnnounce", "evaluation.type", "evaluation.subject", "evaluation.evaluationResult", + "evaluation.lastUpdatedAt", ]) - .orderBy("evaluation.dateAnnounce", "ASC") + .orderBy("evaluation.lastUpdatedAt", "ASC") .getMany(); const performance = list.map((item) => ({ id: item.id, - year: item.dateAnnounce?Extension.ToThaiYear(item.dateAnnounce.getFullYear()):null, + year: item.lastUpdatedAt?Extension.ToThaiYear(item.lastUpdatedAt.getFullYear()):null, type: item.type == "EXPERT" ? "ชำนาญการ" : item.type == "EXPERTISE" ? "เชียวชาญ" : item.type == "SPECIAL_EXPERT" ? "ชำนาญการพิเศษ": null, - subject: item.subject, + subject: item.subject?item.subject[0]:null, evaluationResult: item.evaluationResult == "PASS" ? "ผ่าน" : item.evaluationResult == "NOTPASS" ? "ไม่ผ่าน" : null, })); @@ -2091,6 +2091,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; @@ -2653,9 +2661,15 @@ export class EvaluationController { "author", "subject", "commanderFullname", + "commanderOrg", + "commanderOrgOld", "commanderPosition", + "commanderPositionOld", "commanderAboveFullname", + "commanderAboveOrg", + "commanderAboveOrgOld", "commanderAbovePosition", + "commanderAbovePositionOld", ], }); @@ -2689,9 +2703,15 @@ export class EvaluationController { "author", "subject", "commanderFullname", + "commanderOrg", + "commanderOrgOld", "commanderPosition", + "commanderPositionOld", "commanderAboveFullname", + "commanderAboveOrg", + "commanderAboveOrgOld", "commanderAbovePosition", + "commanderAbovePositionOld", ], }); if (!evaluation) { @@ -2722,9 +2742,15 @@ export class EvaluationController { "subjectDoc2", "assignedPosition", "commanderFullnameDoc2", + "commanderOrgDoc2", + "commanderOrgOldDoc2", "commanderPositionDoc2", + "commanderPositionOldDoc2", "commanderAboveFullnameDoc2", + "commanderAboveOrgDoc2", + "commanderAboveOrgOldDoc2", "commanderAbovePositionDoc2", + "commanderAbovePositionOldDoc2", "evaluationResult", ], }); @@ -2759,9 +2785,15 @@ export class EvaluationController { "subjectDoc2", "assignedPosition", "commanderFullnameDoc2", + "commanderOrgDoc2", + "commanderOrgOldDoc2", "commanderPositionDoc2", + "commanderPositionOldDoc2", "commanderAboveFullnameDoc2", + "commanderAboveOrgDoc2", + "commanderAboveOrgOldDoc2", "commanderAbovePositionDoc2", + "commanderAbovePositionOldDoc2", "evaluationResult", ], }); @@ -2799,11 +2831,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, ) { @@ -2813,13 +2851,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; + evaluation.commanderOrgOld = body.commanderOrgOld??_null; evaluation.commanderPosition = body.commanderPosition; + evaluation.commanderPositionOld = body.commanderPositionOld??_null; evaluation.commanderAboveFullname = body.commanderAboveFullname; + evaluation.commanderAboveOrg = body.commanderAboveOrg; + 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(); @@ -2859,7 +2903,7 @@ export class EvaluationController { @Body() body: { authorDoc2: string; - subjectDoc2: string; + subjectDoc2: string[]; assignedPosition: string; commanderFullnameDoc2: string; commanderPositionDoc2: string; @@ -2874,7 +2918,7 @@ export class EvaluationController { if (!evaluation) { throw new HttpError(HttpStatusCode.NOT_FOUND, "not found."); } - + evaluation.authorDoc2 = body.authorDoc2; evaluation.subjectDoc2 = body.subjectDoc2; evaluation.assignedPosition = body.assignedPosition; diff --git a/src/controllers/ReportController.ts b/src/controllers/ReportController.ts index c687c2a..eac19d0 100644 --- a/src/controllers/ReportController.ts +++ b/src/controllers/ReportController.ts @@ -359,7 +359,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 diff --git a/src/entities/Evaluation.ts b/src/entities/Evaluation.ts index feedea1..657c46f 100644 --- a/src/entities/Evaluation.ts +++ b/src/entities/Evaluation.ts @@ -216,6 +216,20 @@ export class Evaluation extends EntityBase { @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: "ชื่อ-นามสกุล ผู้บังคับบัญชาเหนือขึ้นไป 1 ระดับ (จัดเตรียมเอกสารเล่ม 2)", @@ -237,14 +251,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; From cfd9606b0f197f33d3f8d6fe0327dd988cdc65f9 Mon Sep 17 00:00:00 2001 From: Bright Date: Mon, 21 Apr 2025 16:00:14 +0700 Subject: [PATCH 17/39] migrate --- ...9145-update_table_evaluation_add_fields.ts | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 src/migration/1745225569145-update_table_evaluation_add_fields.ts diff --git a/src/migration/1745225569145-update_table_evaluation_add_fields.ts b/src/migration/1745225569145-update_table_evaluation_add_fields.ts new file mode 100644 index 0000000..d728a7b --- /dev/null +++ b/src/migration/1745225569145-update_table_evaluation_add_fields.ts @@ -0,0 +1,32 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class UpdateTableEvaluationAddFields1745225569145 implements MigrationInterface { + name = 'UpdateTableEvaluationAddFields1745225569145' + + public async up(queryRunner: QueryRunner): Promise { + 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\` 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 { + 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 \`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\``); + } + +} From 49e7c248969941e4454ef7f698c6178b67636641 Mon Sep 17 00:00:00 2001 From: AdisakKanthawilang Date: Mon, 21 Apr 2025 16:01:05 +0700 Subject: [PATCH 18/39] update --- src/controllers/EvaluationController.ts | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/controllers/EvaluationController.ts b/src/controllers/EvaluationController.ts index c5ae332..1c05c85 100644 --- a/src/controllers/EvaluationController.ts +++ b/src/controllers/EvaluationController.ts @@ -2909,6 +2909,12 @@ export class EvaluationController { commanderPositionDoc2: string; commanderAboveFullnameDoc2: string; commanderAbovePositionDoc2: string; + commanderOrgDoc2?: string; + commanderOrgOldDoc2?: string; + commanderPositionOldDoc2?: string; + commanderAboveOrgDoc2?: string; + commanderAboveOrgOldDoc2?: string; + commanderAbovePositionOldDoc2?: string; }, @Request() request: RequestWithUser, ) { @@ -2918,14 +2924,20 @@ 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.lastUpdateUserId = request.user.sub; evaluation.lastUpdateFullName = request.user.name; evaluation.lastUpdatedAt = new Date(); From 41872546aee6a32bfbf5665c350bd49bea0162e6 Mon Sep 17 00:00:00 2001 From: AdisakKanthawilang Date: Mon, 21 Apr 2025 16:14:09 +0700 Subject: [PATCH 19/39] fix --- src/controllers/EvaluationController.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/controllers/EvaluationController.ts b/src/controllers/EvaluationController.ts index 1c05c85..1c8f9c5 100644 --- a/src/controllers/EvaluationController.ts +++ b/src/controllers/EvaluationController.ts @@ -2833,12 +2833,12 @@ export class EvaluationController { author: string; subject: string[]; commanderFullname: string; - commanderOrg: string; + commanderOrg?: string; commanderOrgOld?: string; commanderPosition: string; commanderPositionOld?: string; commanderAboveFullname: string; - commanderAboveOrg: string; + commanderAboveOrg?: string; commanderAboveOrgOld?: string; commanderAbovePosition: string; commanderAbovePositionOld?: string; @@ -2855,12 +2855,12 @@ export class EvaluationController { evaluation.author = body.author; evaluation.subject = body.subject; evaluation.commanderFullname = body.commanderFullname; - evaluation.commanderOrg = body.commanderOrg; + 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; + evaluation.commanderAboveOrg = body.commanderAboveOrg??_null; evaluation.commanderAboveOrgOld = body.commanderAboveOrgOld??_null; evaluation.commanderAbovePosition = body.commanderAbovePosition; evaluation.commanderAbovePositionOld = body.commanderAbovePositionOld??_null; From 5ca457e856fd9b0fd2b4bc989bd1b4747995c0d8 Mon Sep 17 00:00:00 2001 From: AdisakKanthawilang Date: Tue, 22 Apr 2025 10:38:05 +0700 Subject: [PATCH 20/39] migrate --- src/entities/AnnounceTemplate.ts | 22 +++++++++++++++++++ src/entities/Evaluation.ts | 6 +++++ ...nceTemplate_and_update_field_evaluation.ts | 18 +++++++++++++++ 3 files changed, 46 insertions(+) create mode 100644 src/entities/AnnounceTemplate.ts create mode 100644 src/migration/1745292839344-create_table_announceTemplate_and_update_field_evaluation.ts diff --git a/src/entities/AnnounceTemplate.ts b/src/entities/AnnounceTemplate.ts new file mode 100644 index 0000000..6ff004f --- /dev/null +++ b/src/entities/AnnounceTemplate.ts @@ -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; diff --git a/src/entities/Evaluation.ts b/src/entities/Evaluation.ts index 657c46f..88eb5b4 100644 --- a/src/entities/Evaluation.ts +++ b/src/entities/Evaluation.ts @@ -266,6 +266,12 @@ 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; + @OneToMany(() => EvaluationLogs, (evaluationLogs) => evaluationLogs.evaluation) evaluationLogs: EvaluationLogs[]; diff --git a/src/migration/1745292839344-create_table_announceTemplate_and_update_field_evaluation.ts b/src/migration/1745292839344-create_table_announceTemplate_and_update_field_evaluation.ts new file mode 100644 index 0000000..b975c38 --- /dev/null +++ b/src/migration/1745292839344-create_table_announceTemplate_and_update_field_evaluation.ts @@ -0,0 +1,18 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class CreateTableAnnounceTemplateAndUpdateFieldEvaluation1745292839344 implements MigrationInterface { + name = 'CreateTableAnnounceTemplateAndUpdateFieldEvaluation1745292839344' + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(`CREATE TABLE \`announcetemplate\` (\`id\` varchar(36) NOT NULL, \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6), \`createdUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่สร้างข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6), \`lastUpdateUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่แก้ไขข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`createdFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่สร้างข้อมูล' DEFAULT 'string', \`lastUpdateFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่แก้ไขข้อมูลล่าสุด' DEFAULT 'string', \`code\` varchar(255) NULL COMMENT 'code สำหรับเรียก template', \`name\` varchar(255) NULL COMMENT 'ชื่อประกาศ', \`detailBody\` text NULL COMMENT 'รายละเอียด', \`detailFooter\` text NULL COMMENT 'รายละเอียดส่วนท้าย', PRIMARY KEY (\`id\`)) ENGINE=InnoDB`); + await queryRunner.query(`ALTER TABLE \`evaluation\` ADD \`detailAnnounceStep5Body\` text NULL COMMENT 'รายละเอียดประกาศ(STEP5)'`); + await queryRunner.query(`ALTER TABLE \`evaluation\` ADD \`detailAnnounceStep5Footer\` text NULL COMMENT 'รายละเอียดส่วนท้าย(STEP5)'`); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`evaluation\` DROP COLUMN \`detailAnnounceStep5Footer\``); + await queryRunner.query(`ALTER TABLE \`evaluation\` DROP COLUMN \`detailAnnounceStep5Body\``); + await queryRunner.query(`DROP TABLE \`announcetemplate\``); + } + +} From b95868069219ea9001d0ace4d09568fb20e17fd1 Mon Sep 17 00:00:00 2001 From: AdisakKanthawilang Date: Tue, 22 Apr 2025 11:31:21 +0700 Subject: [PATCH 21/39] fix --- src/controllers/EvaluationController.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/controllers/EvaluationController.ts b/src/controllers/EvaluationController.ts index 1c8f9c5..9d607e5 100644 --- a/src/controllers/EvaluationController.ts +++ b/src/controllers/EvaluationController.ts @@ -1589,7 +1589,7 @@ export class EvaluationController { })), performances: evaluation.performances.map((performance) => ({ year: performance.year, - type: performance.type == "EXPERT" ? "ชำนาญการ" : performance.type == "EXPERTISE" ? "เชียวชาญ" : performance.type == "SPECIAL_EXPERT" ? "ชำนาญการพิเศษ": null, + type: performance.type, subject: performance.subject, evaluationResult: performance.evaluationResult, })), From 346d161083c1cae923d172a8075c13582f982b69 Mon Sep 17 00:00:00 2001 From: AdisakKanthawilang Date: Tue, 22 Apr 2025 13:51:46 +0700 Subject: [PATCH 22/39] migrate and update #207 --- src/controllers/EvaluationController.ts | 60 ++++++++++++++++++- src/entities/Evaluation.ts | 5 ++ ...358-add_field_isUpdate_table_evaluation.ts | 14 +++++ 3 files changed, 77 insertions(+), 2 deletions(-) create mode 100644 src/migration/1745303689358-add_field_isUpdate_table_evaluation.ts diff --git a/src/controllers/EvaluationController.ts b/src/controllers/EvaluationController.ts index 9d607e5..8d687e6 100644 --- a/src/controllers/EvaluationController.ts +++ b/src/controllers/EvaluationController.ts @@ -35,6 +35,7 @@ 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") @@ -56,6 +57,7 @@ export class EvaluationController { private performanceRepository = AppDataSource.getRepository(Performance); private directorRepository = AppDataSource.getRepository(Director); private meetingRepository = AppDataSource.getRepository(Meeting); + private announceTemplateRepository = AppDataSource.getRepository(AnnounceTemplate); /** * API ล้างข้อมูล @@ -479,11 +481,17 @@ 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`; } - + const announceTemplate5 = await this.announceTemplateRepository.findOne({ + where:{ + code : "ST05-1" + }, + select: ["detailBody","detailFooter"] + }) const before = null; await new CallAPI() .GetData(request, `/org/profile/keycloak/commander/${request.user.sub}`) @@ -505,10 +513,11 @@ 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; 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) => { @@ -1030,6 +1039,9 @@ export class EvaluationController { "evaluation.birthDate", "evaluation.govAge", "evaluation.experience", + "evaluation.detailAnnounceStep5Body", + "evaluation.detailAnnounceStep5Footer", + "evaluation.isUpdated", "education.educationLevel", "education.institute", @@ -1144,6 +1156,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, @@ -1384,6 +1399,9 @@ export class EvaluationController { "evaluation.birthDate", "evaluation.govAge", "evaluation.experience", + "evaluation.detailAnnounceStep5Body", + "evaluation.detailAnnounceStep5Footer", + "evaluation.isUpdated", "education.educationLevel", "education.institute", @@ -1498,6 +1516,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, @@ -2051,6 +2072,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 บันทึกแจ้งผลการประกาศคัดเลือก * @@ -2938,6 +2993,7 @@ export class EvaluationController { 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(); diff --git a/src/entities/Evaluation.ts b/src/entities/Evaluation.ts index 88eb5b4..1d86511 100644 --- a/src/entities/Evaluation.ts +++ b/src/entities/Evaluation.ts @@ -272,6 +272,11 @@ export class Evaluation extends EntityBase { @Column({ type: 'text', nullable: true, comment: 'รายละเอียดส่วนท้าย(STEP5)'}) detailAnnounceStep5Footer: string; + @Column({ default: false, comment: 'สถานะเช็คการอัพเดทชื่อผลงาน (STEP6)'}) + isUpdated: boolean; + + + @OneToMany(() => EvaluationLogs, (evaluationLogs) => evaluationLogs.evaluation) evaluationLogs: EvaluationLogs[]; diff --git a/src/migration/1745303689358-add_field_isUpdate_table_evaluation.ts b/src/migration/1745303689358-add_field_isUpdate_table_evaluation.ts new file mode 100644 index 0000000..1b8cbe5 --- /dev/null +++ b/src/migration/1745303689358-add_field_isUpdate_table_evaluation.ts @@ -0,0 +1,14 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class AddFieldIsUpdateTableEvaluation1745303689358 implements MigrationInterface { + name = 'AddFieldIsUpdateTableEvaluation1745303689358' + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`evaluation\` ADD \`isUpdated\` tinyint NOT NULL COMMENT 'สถานะเช็คการอัพเดทชื่อผลงาน (STEP6)' DEFAULT 0`); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`evaluation\` DROP COLUMN \`isUpdated\``); + } + +} From 022d88068b0f30ef91299f90534a7ee3dbf3ec00 Mon Sep 17 00:00:00 2001 From: AdisakKanthawilang Date: Tue, 22 Apr 2025 14:30:43 +0700 Subject: [PATCH 23/39] fix --- src/controllers/EvaluationController.ts | 30 +++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/controllers/EvaluationController.ts b/src/controllers/EvaluationController.ts index 8d687e6..2408bcf 100644 --- a/src/controllers/EvaluationController.ts +++ b/src/controllers/EvaluationController.ts @@ -347,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 การขอประเมิน @@ -1768,6 +1790,14 @@ export class EvaluationController { await this.evaluationRepository.save(evaluation, { data: request }); setLogDataDiff(request, { before, after: evaluation }); + // const _director = await new CallAPI() + // .PostData(request, "/org/workflow/find/director/SYS_EVA_REQ", { + // refId: [evaluation.userId], + // }) + // .then((x) => {}) + // .catch((x) => {}); + // console.log("_director>>",_director); + await new CallAPI() .PostData(request, "/placement/noti/keycloak", { subject: `${evaluation.fullName} แบบประเมินมีการบันทึกตรวจสอบจัดเตรียมเอกสารเล่ม 1`, From 536572d0e76373f0b393375bcdbf37dc352913e4 Mon Sep 17 00:00:00 2001 From: AdisakKanthawilang Date: Tue, 22 Apr 2025 16:11:45 +0700 Subject: [PATCH 24/39] fix --- src/controllers/EvaluationController.ts | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/src/controllers/EvaluationController.ts b/src/controllers/EvaluationController.ts index 2408bcf..85d892a 100644 --- a/src/controllers/EvaluationController.ts +++ b/src/controllers/EvaluationController.ts @@ -1790,19 +1790,22 @@ export class EvaluationController { await this.evaluationRepository.save(evaluation, { data: request }); setLogDataDiff(request, { before, after: evaluation }); - // const _director = await new CallAPI() - // .PostData(request, "/org/workflow/find/director/SYS_EVA_REQ", { - // refId: [evaluation.userId], - // }) - // .then((x) => {}) - // .catch((x) => {}); - // console.log("_director>>",_director); - + let _director: any; + await new CallAPI() + .PostData(request, "/org/workflow/find/director-with-keycloak/SYS_EVA_REQ", { + refId: [evaluation.userId], + }) + .then((x) => { + _director = x; + }) + .catch((x) => {}); + + await new CallAPI() .PostData(request, "/placement/noti/keycloak", { subject: `${evaluation.fullName} แบบประเมินมีการบันทึกตรวจสอบจัดเตรียมเอกสารเล่ม 1`, body: `${evaluation.fullName} แบบประเมินมีการบันทึกตรวจสอบจัดเตรียมเอกสารเล่ม 1`, - receiverUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0", + receiverUserId: _director.id, payload: "", isSendMail: true, isSendInbox: true, @@ -1810,6 +1813,7 @@ export class EvaluationController { }) .then((x) => {}) .catch((x) => {}); + return new HttpSuccess(); } catch (error: any) { if (error instanceof HttpError) { @@ -2837,6 +2841,7 @@ export class EvaluationController { "commanderAbovePositionDoc2", "commanderAbovePositionOldDoc2", "evaluationResult", + "isUpdated", ], }); if (!evaluation) { @@ -2880,6 +2885,7 @@ export class EvaluationController { "commanderAbovePositionDoc2", "commanderAbovePositionOldDoc2", "evaluationResult", + "isUpdated", ], }); if (!evaluation) { From 14f3a90d9b45ec0ac395d33e77f612fb74355a87 Mon Sep 17 00:00:00 2001 From: AdisakKanthawilang Date: Tue, 22 Apr 2025 16:18:37 +0700 Subject: [PATCH 25/39] fix --- src/controllers/EvaluationController.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/controllers/EvaluationController.ts b/src/controllers/EvaluationController.ts index 85d892a..a79c8ee 100644 --- a/src/controllers/EvaluationController.ts +++ b/src/controllers/EvaluationController.ts @@ -1805,7 +1805,7 @@ export class EvaluationController { .PostData(request, "/placement/noti/keycloak", { subject: `${evaluation.fullName} แบบประเมินมีการบันทึกตรวจสอบจัดเตรียมเอกสารเล่ม 1`, body: `${evaluation.fullName} แบบประเมินมีการบันทึกตรวจสอบจัดเตรียมเอกสารเล่ม 1`, - receiverUserId: _director.id, + receiverUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0", payload: "", isSendMail: true, isSendInbox: true, From 3b2c5f2cfd0cc3d03e770830571f9ba55c7b3e84 Mon Sep 17 00:00:00 2001 From: AdisakKanthawilang Date: Tue, 22 Apr 2025 17:26:47 +0700 Subject: [PATCH 26/39] fix --- src/controllers/EvaluationController.ts | 29 ++++++++++++++----------- src/controllers/ReportController.ts | 8 +++---- 2 files changed, 20 insertions(+), 17 deletions(-) diff --git a/src/controllers/EvaluationController.ts b/src/controllers/EvaluationController.ts index a79c8ee..09e4e86 100644 --- a/src/controllers/EvaluationController.ts +++ b/src/controllers/EvaluationController.ts @@ -1800,20 +1800,23 @@ export class EvaluationController { }) .catch((x) => {}); - - 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, + 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.id, + payload: "", + isSendMail: true, + isSendInbox: true, + isSendNotification: true, + }) + .then((x) => {}) + .catch((x) => {}); }) - .then((x) => {}) - .catch((x) => {}); - + ); + return new HttpSuccess(); } catch (error: any) { if (error instanceof HttpError) { diff --git a/src/controllers/ReportController.ts b/src/controllers/ReportController.ts index eac19d0..d2ba20e 100644 --- a/src/controllers/ReportController.ts +++ b/src/controllers/ReportController.ts @@ -411,8 +411,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)) : "-", })) : [ { @@ -460,10 +460,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, From 6a937b2f7c4c8f92c70ff4b9e2c4f005d4870e3f Mon Sep 17 00:00:00 2001 From: AdisakKanthawilang Date: Tue, 22 Apr 2025 17:36:37 +0700 Subject: [PATCH 27/39] fix --- src/controllers/EvaluationController.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/controllers/EvaluationController.ts b/src/controllers/EvaluationController.ts index 09e4e86..0e5ea45 100644 --- a/src/controllers/EvaluationController.ts +++ b/src/controllers/EvaluationController.ts @@ -1806,7 +1806,8 @@ export class EvaluationController { .PostData(request, "/placement/noti/keycloak", { subject: `${evaluation.fullName} แบบประเมินมีการบันทึกตรวจสอบจัดเตรียมเอกสารเล่ม 1`, body: `${evaluation.fullName} แบบประเมินมีการบันทึกตรวจสอบจัดเตรียมเอกสารเล่ม 1`, - receiverUserId: director.id, + // receiverUserId: director.id, + receiverUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0", payload: "", isSendMail: true, isSendInbox: true, From 171fb0595651d70925a8eceef6ca5764a0df394b Mon Sep 17 00:00:00 2001 From: AdisakKanthawilang Date: Wed, 23 Apr 2025 10:14:13 +0700 Subject: [PATCH 28/39] fix --- src/controllers/EvaluationController.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/controllers/EvaluationController.ts b/src/controllers/EvaluationController.ts index 0e5ea45..11c49b9 100644 --- a/src/controllers/EvaluationController.ts +++ b/src/controllers/EvaluationController.ts @@ -1806,8 +1806,8 @@ export class EvaluationController { .PostData(request, "/placement/noti/keycloak", { subject: `${evaluation.fullName} แบบประเมินมีการบันทึกตรวจสอบจัดเตรียมเอกสารเล่ม 1`, body: `${evaluation.fullName} แบบประเมินมีการบันทึกตรวจสอบจัดเตรียมเอกสารเล่ม 1`, - // receiverUserId: director.id, - receiverUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0", + receiverUserId: director.id, + // receiverUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0", payload: "", isSendMail: true, isSendInbox: true, From df5eada7c68eff2a2a020b4d2e2859ca1eed5137 Mon Sep 17 00:00:00 2001 From: AdisakKanthawilang Date: Wed, 23 Apr 2025 12:09:25 +0700 Subject: [PATCH 29/39] fix --- src/controllers/EvaluationController.ts | 51 +++++++++++++------------ 1 file changed, 26 insertions(+), 25 deletions(-) diff --git a/src/controllers/EvaluationController.ts b/src/controllers/EvaluationController.ts index 11c49b9..e8500fe 100644 --- a/src/controllers/EvaluationController.ts +++ b/src/controllers/EvaluationController.ts @@ -1767,28 +1767,28 @@ export class EvaluationController { if (!evaluation) { throw new HttpError(HttpStatusCode.NOT_FOUND, "not found."); } - if (evaluation.step != "WAIT_CHECK_DOC_V1") { - const evaluationLogs = new EvaluationLogs(); - const _null: any = null; - evaluationLogs.step = (await ConvertToThaiStep("WAIT_CHECK_DOC_V1")) ?? _null; - evaluationLogs.createdUserId = request.user.sub; - evaluationLogs.createdFullName = request.user.name; - evaluationLogs.createdAt = new Date(); - evaluationLogs.lastUpdateUserId = request.user.sub; - evaluationLogs.lastUpdateFullName = request.user.name; - evaluationLogs.lastUpdatedAt = new Date(); - evaluationLogs.evaluation = evaluation; - await this.evaluationLogsRepository.save(evaluationLogs, { data: request }); - setLogDataDiff(request, { before: null, after: evaluationLogs }); - } - const before = structuredClone(evaluation); + // if (evaluation.step != "WAIT_CHECK_DOC_V1") { + // const evaluationLogs = new EvaluationLogs(); + // const _null: any = null; + // evaluationLogs.step = (await ConvertToThaiStep("WAIT_CHECK_DOC_V1")) ?? _null; + // evaluationLogs.createdUserId = request.user.sub; + // evaluationLogs.createdFullName = request.user.name; + // evaluationLogs.createdAt = new Date(); + // evaluationLogs.lastUpdateUserId = request.user.sub; + // evaluationLogs.lastUpdateFullName = request.user.name; + // evaluationLogs.lastUpdatedAt = new Date(); + // evaluationLogs.evaluation = evaluation; + // await this.evaluationLogsRepository.save(evaluationLogs, { data: request }); + // setLogDataDiff(request, { before: null, after: evaluationLogs }); + // } + // const before = structuredClone(evaluation); - evaluation.step = "WAIT_CHECK_DOC_V1"; - 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 }); + // evaluation.step = "WAIT_CHECK_DOC_V1"; + // 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 }); let _director: any; await new CallAPI() @@ -1799,25 +1799,26 @@ export class EvaluationController { _director = x; }) .catch((x) => {}); - + console.log(_director); await Promise.all( _director.map((director:any) => { + console.log(">>",director.id); return new CallAPI() .PostData(request, "/placement/noti/keycloak", { subject: `${evaluation.fullName} แบบประเมินมีการบันทึกตรวจสอบจัดเตรียมเอกสารเล่ม 1`, body: `${evaluation.fullName} แบบประเมินมีการบันทึกตรวจสอบจัดเตรียมเอกสารเล่ม 1`, - receiverUserId: director.id, + receiverUserId: director.keycloak, // receiverUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0", payload: "", isSendMail: true, isSendInbox: true, isSendNotification: true, }) - .then((x) => {}) + .then((x) => { + }) .catch((x) => {}); }) ); - return new HttpSuccess(); } catch (error: any) { if (error instanceof HttpError) { From 5470f9fbd202d800ceb9fbb4d5b83211ac5dea9e Mon Sep 17 00:00:00 2001 From: AdisakKanthawilang Date: Wed, 23 Apr 2025 12:14:39 +0700 Subject: [PATCH 30/39] fix --- src/controllers/EvaluationController.ts | 45 ++++++++++++------------- 1 file changed, 21 insertions(+), 24 deletions(-) diff --git a/src/controllers/EvaluationController.ts b/src/controllers/EvaluationController.ts index e8500fe..1ae1d81 100644 --- a/src/controllers/EvaluationController.ts +++ b/src/controllers/EvaluationController.ts @@ -1767,28 +1767,28 @@ export class EvaluationController { if (!evaluation) { throw new HttpError(HttpStatusCode.NOT_FOUND, "not found."); } - // if (evaluation.step != "WAIT_CHECK_DOC_V1") { - // const evaluationLogs = new EvaluationLogs(); - // const _null: any = null; - // evaluationLogs.step = (await ConvertToThaiStep("WAIT_CHECK_DOC_V1")) ?? _null; - // evaluationLogs.createdUserId = request.user.sub; - // evaluationLogs.createdFullName = request.user.name; - // evaluationLogs.createdAt = new Date(); - // evaluationLogs.lastUpdateUserId = request.user.sub; - // evaluationLogs.lastUpdateFullName = request.user.name; - // evaluationLogs.lastUpdatedAt = new Date(); - // evaluationLogs.evaluation = evaluation; - // await this.evaluationLogsRepository.save(evaluationLogs, { data: request }); - // setLogDataDiff(request, { before: null, after: evaluationLogs }); - // } - // const before = structuredClone(evaluation); + if (evaluation.step != "WAIT_CHECK_DOC_V1") { + const evaluationLogs = new EvaluationLogs(); + const _null: any = null; + evaluationLogs.step = (await ConvertToThaiStep("WAIT_CHECK_DOC_V1")) ?? _null; + evaluationLogs.createdUserId = request.user.sub; + evaluationLogs.createdFullName = request.user.name; + evaluationLogs.createdAt = new Date(); + evaluationLogs.lastUpdateUserId = request.user.sub; + evaluationLogs.lastUpdateFullName = request.user.name; + evaluationLogs.lastUpdatedAt = new Date(); + evaluationLogs.evaluation = evaluation; + await this.evaluationLogsRepository.save(evaluationLogs, { data: request }); + setLogDataDiff(request, { before: null, after: evaluationLogs }); + } + const before = structuredClone(evaluation); - // evaluation.step = "WAIT_CHECK_DOC_V1"; - // 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 }); + evaluation.step = "WAIT_CHECK_DOC_V1"; + 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 }); let _director: any; await new CallAPI() @@ -1799,16 +1799,13 @@ export class EvaluationController { _director = x; }) .catch((x) => {}); - console.log(_director); await Promise.all( _director.map((director:any) => { - console.log(">>",director.id); return new CallAPI() .PostData(request, "/placement/noti/keycloak", { subject: `${evaluation.fullName} แบบประเมินมีการบันทึกตรวจสอบจัดเตรียมเอกสารเล่ม 1`, body: `${evaluation.fullName} แบบประเมินมีการบันทึกตรวจสอบจัดเตรียมเอกสารเล่ม 1`, receiverUserId: director.keycloak, - // receiverUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0", payload: "", isSendMail: true, isSendInbox: true, From e01ac9d70525d3e533ea073198f7a35b1a53a0da Mon Sep 17 00:00:00 2001 From: AdisakKanthawilang Date: Wed, 23 Apr 2025 13:46:52 +0700 Subject: [PATCH 31/39] last #207 --- src/controllers/ReportController.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/controllers/ReportController.ts b/src/controllers/ReportController.ts index d2ba20e..6e35071 100644 --- a/src/controllers/ReportController.ts +++ b/src/controllers/ReportController.ts @@ -184,6 +184,8 @@ export class ReoportController { "evaluation.birthDate", "evaluation.govAge", "evaluation.experience", + "evaluation.detailAnnounceStep5Body", + "evaluation.detailAnnounceStep5Footer", "education.educationLevel", "education.institute", @@ -345,6 +347,8 @@ export class ReoportController { salary: evaluation.salary ? Extension.ToThaiNumber(evaluation.salary) : "-", salaryWithPrefix: evaluation.salary ? "อัตราเงินเดือนปัจจุบัน" +" "+ Extension.ToThaiNumber(evaluation.salary) : "-", positionLevel: evaluation.positionLevel ? evaluation.positionLevel : "", + detailAnnounceStep5Body: evaluation.detailAnnounceStep5Body, + detailAnnounceStep5Footer: evaluation.detailAnnounceStep5Footer, birthDate: evaluation.birthDate != null && evaluation.birthDate != "" ? Extension.ToThaiNumber( From 0a4d3cf71f0e9f30189aea7dda169c68da0b9a4e Mon Sep 17 00:00:00 2001 From: AdisakKanthawilang Date: Wed, 23 Apr 2025 14:50:09 +0700 Subject: [PATCH 32/39] migrate and update --- src/controllers/ReportController.ts | 2 +- src/entities/Evaluation.ts | 11 +++++++++++ ...add_field_posExAndPosArea_table_evaluation.ts | 16 ++++++++++++++++ 3 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 src/migration/1745394229016-add_field_posExAndPosArea_table_evaluation.ts diff --git a/src/controllers/ReportController.ts b/src/controllers/ReportController.ts index 6e35071..7378b51 100644 --- a/src/controllers/ReportController.ts +++ b/src/controllers/ReportController.ts @@ -431,7 +431,7 @@ 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()) diff --git a/src/entities/Evaluation.ts b/src/entities/Evaluation.ts index 1d86511..97c1d7e 100644 --- a/src/entities/Evaluation.ts +++ b/src/entities/Evaluation.ts @@ -230,6 +230,11 @@ export class Evaluation extends EntityBase { @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)", @@ -402,6 +407,12 @@ export class CreateEvaluation { @Column() orgRootId?: string | null; + + @Column() + positionArea?: string; + + @Column() + posExecutive?: string; } export class CreateEducation { diff --git a/src/migration/1745394229016-add_field_posExAndPosArea_table_evaluation.ts b/src/migration/1745394229016-add_field_posExAndPosArea_table_evaluation.ts new file mode 100644 index 0000000..42538eb --- /dev/null +++ b/src/migration/1745394229016-add_field_posExAndPosArea_table_evaluation.ts @@ -0,0 +1,16 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class AddFieldPosExAndPosAreaTableEvaluation1745394229016 implements MigrationInterface { + name = 'AddFieldPosExAndPosAreaTableEvaluation1745394229016' + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`evaluation\` ADD \`positionArea\` varchar(255) NULL COMMENT 'ด้าน/สาขา'`); + await queryRunner.query(`ALTER TABLE \`evaluation\` ADD \`posExecutive\` varchar(255) NULL COMMENT 'ตำแหน่งทางการบริหาร'`); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`evaluation\` DROP COLUMN \`posExecutive\``); + await queryRunner.query(`ALTER TABLE \`evaluation\` DROP COLUMN \`positionArea\``); + } + +} From b2d4fd202cd3a31a38fcd890e0a33f164cd38cdf Mon Sep 17 00:00:00 2001 From: AdisakKanthawilang Date: Wed, 23 Apr 2025 15:21:57 +0700 Subject: [PATCH 33/39] checkpoint --- src/controllers/ReportController.ts | 4 ++++ src/entities/Evaluation.ts | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/controllers/ReportController.ts b/src/controllers/ReportController.ts index 7378b51..ffa50e9 100644 --- a/src/controllers/ReportController.ts +++ b/src/controllers/ReportController.ts @@ -186,6 +186,8 @@ export class ReoportController { "evaluation.experience", "evaluation.detailAnnounceStep5Body", "evaluation.detailAnnounceStep5Footer", + "evaluation.positionArea", + "evaluation.posExecutive", "education.educationLevel", "education.institute", @@ -349,6 +351,8 @@ export class ReoportController { positionLevel: evaluation.positionLevel ? evaluation.positionLevel : "", detailAnnounceStep5Body: evaluation.detailAnnounceStep5Body, detailAnnounceStep5Footer: evaluation.detailAnnounceStep5Footer, + positionArea: evaluation.positionArea, + posExecutive: evaluation.posExecutive, birthDate: evaluation.birthDate != null && evaluation.birthDate != "" ? Extension.ToThaiNumber( diff --git a/src/entities/Evaluation.ts b/src/entities/Evaluation.ts index 97c1d7e..e815f37 100644 --- a/src/entities/Evaluation.ts +++ b/src/entities/Evaluation.ts @@ -409,10 +409,10 @@ export class CreateEvaluation { orgRootId?: string | null; @Column() - positionArea?: string; + positionArea?: string | null; @Column() - posExecutive?: string; + posExecutive?: string | null; } export class CreateEducation { From 2dcabd5a6643a5fd4e6b66a1c26e86f513c1804c Mon Sep 17 00:00:00 2001 From: AdisakKanthawilang Date: Wed, 23 Apr 2025 16:40:42 +0700 Subject: [PATCH 34/39] update --- src/controllers/EvaluationController.ts | 2 ++ src/controllers/ReportController.ts | 41 +++++++++++++------------ 2 files changed, 24 insertions(+), 19 deletions(-) diff --git a/src/controllers/EvaluationController.ts b/src/controllers/EvaluationController.ts index 1ae1d81..c2d078f 100644 --- a/src/controllers/EvaluationController.ts +++ b/src/controllers/EvaluationController.ts @@ -537,6 +537,8 @@ export class EvaluationController { 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 }); diff --git a/src/controllers/ReportController.ts b/src/controllers/ReportController.ts index ffa50e9..892a12d 100644 --- a/src/controllers/ReportController.ts +++ b/src/controllers/ReportController.ts @@ -291,23 +291,23 @@ export class ReoportController { 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(); + // 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), @@ -351,8 +351,9 @@ export class ReoportController { positionLevel: evaluation.positionLevel ? evaluation.positionLevel : "", detailAnnounceStep5Body: evaluation.detailAnnounceStep5Body, detailAnnounceStep5Footer: evaluation.detailAnnounceStep5Footer, - positionArea: evaluation.positionArea, + positionAreaWithSym: evaluation.positionArea?`(${Extension.ToThaiNumber(evaluation.positionArea)})` : "", posExecutive: evaluation.posExecutive, + posFull: (evaluation.position ? `${evaluation.position}` : "") + (evaluation.posExecutive ? " " + `${evaluation.posExecutive}` : "") + (evaluation.positionLevel ? " " + `${evaluation.positionLevel}` : ""), birthDate: evaluation.birthDate != null && evaluation.birthDate != "" ? Extension.ToThaiNumber( @@ -440,7 +441,9 @@ export class ReoportController { 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, From 6cf0aa117ceaa9eef884f1c636ab9e37c74b9729 Mon Sep 17 00:00:00 2001 From: AdisakKanthawilang Date: Wed, 23 Apr 2025 16:43:37 +0700 Subject: [PATCH 35/39] no message --- src/controllers/ReportController.ts | 34 ++++++++++++++--------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/src/controllers/ReportController.ts b/src/controllers/ReportController.ts index 892a12d..808dd93 100644 --- a/src/controllers/ReportController.ts +++ b/src/controllers/ReportController.ts @@ -291,23 +291,23 @@ export class ReoportController { 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(); + 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), From 25fc86c8a8a194ec1de92206bc5f481c5d8b7fdd Mon Sep 17 00:00:00 2001 From: AdisakKanthawilang Date: Thu, 24 Apr 2025 10:11:34 +0700 Subject: [PATCH 36/39] fix --- src/controllers/ReportController.ts | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/controllers/ReportController.ts b/src/controllers/ReportController.ts index 808dd93..bc44751 100644 --- a/src/controllers/ReportController.ts +++ b/src/controllers/ReportController.ts @@ -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", @@ -269,6 +271,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(); @@ -353,7 +363,7 @@ export class ReoportController { detailAnnounceStep5Footer: evaluation.detailAnnounceStep5Footer, positionAreaWithSym: evaluation.positionArea?`(${Extension.ToThaiNumber(evaluation.positionArea)})` : "", posExecutive: evaluation.posExecutive, - posFull: (evaluation.position ? `${evaluation.position}` : "") + (evaluation.posExecutive ? " " + `${evaluation.posExecutive}` : "") + (evaluation.positionLevel ? " " + `${evaluation.positionLevel}` : ""), + posFull: (evaluation.position ? `${evaluation.position}` : "") + (evaluation.positionLevel ? `${evaluation.positionLevel}` : "") + (evaluation.posExecutive ? " " + `${evaluation.posExecutive}` : "") , birthDate: evaluation.birthDate != null && evaluation.birthDate != "" ? Extension.ToThaiNumber( @@ -499,6 +509,16 @@ export class ReoportController { 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 ? Extension.ToThaiNumber(performance.year.toString()) : "-", + type: performance.type, + subject: performance.subject, + evaluationResult: performance.evaluationResult, + })), commanderFullname: commanderFullname ? commanderFullname : "-", commanderPosition: commanderPosition ? commanderPosition : "-", commanderRootName: commanderRootName ? commanderRootName : "-", @@ -507,6 +527,7 @@ export class ReoportController { commanderAbovePosition: commanderAbovePosition ? commanderAbovePosition : "-", commanderAboveRootName: commanderAboveRootName ? commanderAboveRootName : "-", commanderAboveOrg: commanderAboveOrg ? commanderAboveOrg : "-", + // commanderPositionSign: `${commanderPosition} สำนักงานการเจ้าหน้าที่ ${commanderRootName}` + `\n` + `${commanderAbovePosition} ${commanderAboveRootName}`, years: years, }; From eb7eddabf66384909c268dd52155236ca88391cd Mon Sep 17 00:00:00 2001 From: AdisakKanthawilang Date: Thu, 24 Apr 2025 11:51:31 +0700 Subject: [PATCH 37/39] update --- src/controllers/ReportController.ts | 60 +++++++++++++---------------- 1 file changed, 26 insertions(+), 34 deletions(-) diff --git a/src/controllers/ReportController.ts b/src/controllers/ReportController.ts index bc44751..d0cbcff 100644 --- a/src/controllers/ReportController.ts +++ b/src/controllers/ReportController.ts @@ -190,6 +190,16 @@ export class ReoportController { "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", @@ -290,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), @@ -519,15 +504,22 @@ export class ReoportController { subject: performance.subject, evaluationResult: performance.evaluationResult, })), - commanderFullname: commanderFullname ? commanderFullname : "-", - commanderPosition: commanderPosition ? commanderPosition : "-", - commanderRootName: commanderRootName ? commanderRootName : "-", - commanderOrg: commanderOrg ? commanderOrg : "-", - commanderAboveFullname: commanderAboveFullname ? commanderAboveFullname : "-", - commanderAbovePosition: commanderAbovePosition ? commanderAbovePosition : "-", - commanderAboveRootName: commanderAboveRootName ? commanderAboveRootName : "-", - commanderAboveOrg: commanderAboveOrg ? commanderAboveOrg : "-", - // commanderPositionSign: `${commanderPosition} สำนักงานการเจ้าหน้าที่ ${commanderRootName}` + `\n` + `${commanderAbovePosition} ${commanderAboveRootName}`, + 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, }; From f22b35ea5e9234d98cd8e036857c623d3da50322 Mon Sep 17 00:00:00 2001 From: moss <> Date: Thu, 24 Apr 2025 14:40:44 +0700 Subject: [PATCH 38/39] migrate --- .../1744963144566-add_table_portfolio.ts | 24 ------------------- .../1744973794458-update_and_add_table.ts | 16 ------------- ...nceTemplate_and_update_field_evaluation.ts | 18 -------------- ...358-add_field_isUpdate_table_evaluation.ts | 14 ----------- ..._field_posExAndPosArea_table_evaluation.ts | 16 ------------- ...ts => 1745480210700-update240420251436.ts} | 14 +++++++++-- 6 files changed, 12 insertions(+), 90 deletions(-) delete mode 100644 src/migration/1744963144566-add_table_portfolio.ts delete mode 100644 src/migration/1744973794458-update_and_add_table.ts delete mode 100644 src/migration/1745292839344-create_table_announceTemplate_and_update_field_evaluation.ts delete mode 100644 src/migration/1745303689358-add_field_isUpdate_table_evaluation.ts delete mode 100644 src/migration/1745394229016-add_field_posExAndPosArea_table_evaluation.ts rename src/migration/{1745225569145-update_table_evaluation_add_fields.ts => 1745480210700-update240420251436.ts} (68%) diff --git a/src/migration/1744963144566-add_table_portfolio.ts b/src/migration/1744963144566-add_table_portfolio.ts deleted file mode 100644 index 71fc391..0000000 --- a/src/migration/1744963144566-add_table_portfolio.ts +++ /dev/null @@ -1,24 +0,0 @@ -import { MigrationInterface, QueryRunner } from "typeorm"; - -export class AddTablePortfolio1744963144566 implements MigrationInterface { - name = 'AddTablePortfolio1744963144566' - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query(`CREATE TABLE \`portfolio\` (\`id\` varchar(36) NOT NULL, \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6), \`createdUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่สร้างข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6), \`lastUpdateUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่แก้ไขข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`createdFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่สร้างข้อมูล' DEFAULT 'string', \`lastUpdateFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่แก้ไขข้อมูลล่าสุด' DEFAULT 'string', \`evaluationId\` varchar(40) NOT NULL COMMENT 'Id การทำรายการระบบประเมิน' DEFAULT '00000000-0000-0000-0000-000000000000', \`name\` varchar(255) NULL COMMENT 'ชื่อเอกสาร/ผลงาน', \`detail\` longtext NULL COMMENT 'รายละเอียดเอกสาร/ผลงาน', PRIMARY KEY (\`id\`)) ENGINE=InnoDB`); - await queryRunner.query(`CREATE TABLE \`evaluation_portfolios_portfolio\` (\`evaluationId\` varchar(36) NOT NULL, \`portfolioId\` varchar(36) NOT NULL, INDEX \`IDX_e0c1b7609f41d85fcd8d055bff\` (\`evaluationId\`), INDEX \`IDX_8d7d992c3379639cee695b9092\` (\`portfolioId\`), PRIMARY KEY (\`evaluationId\`, \`portfolioId\`)) ENGINE=InnoDB`); - await queryRunner.query(`ALTER TABLE \`portfolio\` ADD CONSTRAINT \`FK_f2975d47677601d29d7a3daa893\` FOREIGN KEY (\`evaluationId\`) REFERENCES \`evaluation\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE \`evaluation_portfolios_portfolio\` ADD CONSTRAINT \`FK_e0c1b7609f41d85fcd8d055bffa\` FOREIGN KEY (\`evaluationId\`) REFERENCES \`evaluation\`(\`id\`) ON DELETE CASCADE ON UPDATE CASCADE`); - await queryRunner.query(`ALTER TABLE \`evaluation_portfolios_portfolio\` ADD CONSTRAINT \`FK_8d7d992c3379639cee695b9092c\` FOREIGN KEY (\`portfolioId\`) REFERENCES \`portfolio\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE \`evaluation_portfolios_portfolio\` DROP FOREIGN KEY \`FK_8d7d992c3379639cee695b9092c\``); - await queryRunner.query(`ALTER TABLE \`evaluation_portfolios_portfolio\` DROP FOREIGN KEY \`FK_e0c1b7609f41d85fcd8d055bffa\``); - await queryRunner.query(`ALTER TABLE \`portfolio\` DROP FOREIGN KEY \`FK_f2975d47677601d29d7a3daa893\``); - await queryRunner.query(`DROP INDEX \`IDX_8d7d992c3379639cee695b9092\` ON \`evaluation_portfolios_portfolio\``); - await queryRunner.query(`DROP INDEX \`IDX_e0c1b7609f41d85fcd8d055bff\` ON \`evaluation_portfolios_portfolio\``); - await queryRunner.query(`DROP TABLE \`evaluation_portfolios_portfolio\``); - await queryRunner.query(`DROP TABLE \`portfolio\``); - } - -} diff --git a/src/migration/1744973794458-update_and_add_table.ts b/src/migration/1744973794458-update_and_add_table.ts deleted file mode 100644 index 1f33527..0000000 --- a/src/migration/1744973794458-update_and_add_table.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { MigrationInterface, QueryRunner } from "typeorm"; - -export class UpdateAndAddTable1744973794458 implements MigrationInterface { - name = 'UpdateAndAddTable1744973794458' - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query(`CREATE TABLE \`performance\` (\`id\` varchar(36) NOT NULL, \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6), \`createdUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่สร้างข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6), \`lastUpdateUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่แก้ไขข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`createdFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่สร้างข้อมูล' DEFAULT 'string', \`lastUpdateFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่แก้ไขข้อมูลล่าสุด' DEFAULT 'string', \`evaluationId\` varchar(40) NOT NULL COMMENT 'Id การทำรายการระบบประเมิน' DEFAULT '00000000-0000-0000-0000-000000000000', \`year\` int NULL COMMENT 'ปีที่ประเมิน', \`type\` varchar(255) NULL COMMENT 'ประเภทที่ร้องขอประเมิน', \`subject\` varchar(255) NULL COMMENT 'ชื่อผลงาน', \`evaluationResult\` varchar(255) NULL COMMENT 'ผลการประเมิน', PRIMARY KEY (\`id\`)) ENGINE=InnoDB`); - await queryRunner.query(`ALTER TABLE \`performance\` ADD CONSTRAINT \`FK_edf8c1deb31d77afecfc646615a\` FOREIGN KEY (\`evaluationId\`) REFERENCES \`evaluation\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE \`performance\` DROP FOREIGN KEY \`FK_edf8c1deb31d77afecfc646615a\``); - await queryRunner.query(`DROP TABLE \`performance\``); - } - -} diff --git a/src/migration/1745292839344-create_table_announceTemplate_and_update_field_evaluation.ts b/src/migration/1745292839344-create_table_announceTemplate_and_update_field_evaluation.ts deleted file mode 100644 index b975c38..0000000 --- a/src/migration/1745292839344-create_table_announceTemplate_and_update_field_evaluation.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { MigrationInterface, QueryRunner } from "typeorm"; - -export class CreateTableAnnounceTemplateAndUpdateFieldEvaluation1745292839344 implements MigrationInterface { - name = 'CreateTableAnnounceTemplateAndUpdateFieldEvaluation1745292839344' - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query(`CREATE TABLE \`announcetemplate\` (\`id\` varchar(36) NOT NULL, \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6), \`createdUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่สร้างข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6), \`lastUpdateUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่แก้ไขข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`createdFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่สร้างข้อมูล' DEFAULT 'string', \`lastUpdateFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่แก้ไขข้อมูลล่าสุด' DEFAULT 'string', \`code\` varchar(255) NULL COMMENT 'code สำหรับเรียก template', \`name\` varchar(255) NULL COMMENT 'ชื่อประกาศ', \`detailBody\` text NULL COMMENT 'รายละเอียด', \`detailFooter\` text NULL COMMENT 'รายละเอียดส่วนท้าย', PRIMARY KEY (\`id\`)) ENGINE=InnoDB`); - await queryRunner.query(`ALTER TABLE \`evaluation\` ADD \`detailAnnounceStep5Body\` text NULL COMMENT 'รายละเอียดประกาศ(STEP5)'`); - await queryRunner.query(`ALTER TABLE \`evaluation\` ADD \`detailAnnounceStep5Footer\` text NULL COMMENT 'รายละเอียดส่วนท้าย(STEP5)'`); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE \`evaluation\` DROP COLUMN \`detailAnnounceStep5Footer\``); - await queryRunner.query(`ALTER TABLE \`evaluation\` DROP COLUMN \`detailAnnounceStep5Body\``); - await queryRunner.query(`DROP TABLE \`announcetemplate\``); - } - -} diff --git a/src/migration/1745303689358-add_field_isUpdate_table_evaluation.ts b/src/migration/1745303689358-add_field_isUpdate_table_evaluation.ts deleted file mode 100644 index 1b8cbe5..0000000 --- a/src/migration/1745303689358-add_field_isUpdate_table_evaluation.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { MigrationInterface, QueryRunner } from "typeorm"; - -export class AddFieldIsUpdateTableEvaluation1745303689358 implements MigrationInterface { - name = 'AddFieldIsUpdateTableEvaluation1745303689358' - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE \`evaluation\` ADD \`isUpdated\` tinyint NOT NULL COMMENT 'สถานะเช็คการอัพเดทชื่อผลงาน (STEP6)' DEFAULT 0`); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE \`evaluation\` DROP COLUMN \`isUpdated\``); - } - -} diff --git a/src/migration/1745394229016-add_field_posExAndPosArea_table_evaluation.ts b/src/migration/1745394229016-add_field_posExAndPosArea_table_evaluation.ts deleted file mode 100644 index 42538eb..0000000 --- a/src/migration/1745394229016-add_field_posExAndPosArea_table_evaluation.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { MigrationInterface, QueryRunner } from "typeorm"; - -export class AddFieldPosExAndPosAreaTableEvaluation1745394229016 implements MigrationInterface { - name = 'AddFieldPosExAndPosAreaTableEvaluation1745394229016' - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE \`evaluation\` ADD \`positionArea\` varchar(255) NULL COMMENT 'ด้าน/สาขา'`); - await queryRunner.query(`ALTER TABLE \`evaluation\` ADD \`posExecutive\` varchar(255) NULL COMMENT 'ตำแหน่งทางการบริหาร'`); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE \`evaluation\` DROP COLUMN \`posExecutive\``); - await queryRunner.query(`ALTER TABLE \`evaluation\` DROP COLUMN \`positionArea\``); - } - -} diff --git a/src/migration/1745225569145-update_table_evaluation_add_fields.ts b/src/migration/1745480210700-update240420251436.ts similarity index 68% rename from src/migration/1745225569145-update_table_evaluation_add_fields.ts rename to src/migration/1745480210700-update240420251436.ts index d728a7b..2720308 100644 --- a/src/migration/1745225569145-update_table_evaluation_add_fields.ts +++ b/src/migration/1745480210700-update240420251436.ts @@ -1,7 +1,7 @@ import { MigrationInterface, QueryRunner } from "typeorm"; -export class UpdateTableEvaluationAddFields1745225569145 implements MigrationInterface { - name = 'UpdateTableEvaluationAddFields1745225569145' +export class Update2404202514361745480210700 implements MigrationInterface { + name = 'Update2404202514361745480210700' public async up(queryRunner: QueryRunner): Promise { await queryRunner.query(`ALTER TABLE \`evaluation\` ADD \`commanderOrgDoc2\` varchar(255) NULL COMMENT 'สังกัดปัจุบัน ผู้บังคับบัญชาชั้นต้น doc2'`); @@ -10,6 +10,11 @@ export class UpdateTableEvaluationAddFields1745225569145 implements MigrationInt 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\``); @@ -21,6 +26,11 @@ export class UpdateTableEvaluationAddFields1745225569145 implements MigrationInt 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\``); From a5e58d4552897609eb22db26f70376c2e9a57a3a Mon Sep 17 00:00:00 2001 From: AdisakKanthawilang Date: Thu, 24 Apr 2025 17:41:48 +0700 Subject: [PATCH 39/39] =?UTF-8?q?=E0=B8=9B=E0=B8=A3=E0=B8=B1=E0=B8=9A=20re?= =?UTF-8?q?port?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/EvaluationController.ts | 3 ++- src/controllers/ReportController.ts | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/controllers/EvaluationController.ts b/src/controllers/EvaluationController.ts index c2d078f..ba9c270 100644 --- a/src/controllers/EvaluationController.ts +++ b/src/controllers/EvaluationController.ts @@ -508,9 +508,10 @@ export class EvaluationController { 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 : "ST05-1" + code : _code }, select: ["detailBody","detailFooter"] }) diff --git a/src/controllers/ReportController.ts b/src/controllers/ReportController.ts index d0cbcff..287e9af 100644 --- a/src/controllers/ReportController.ts +++ b/src/controllers/ReportController.ts @@ -319,6 +319,8 @@ export class ReoportController { 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, @@ -349,6 +351,8 @@ export class ReoportController { 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(