From 94f57240334411f49d62fb765af8398eb66844c3 Mon Sep 17 00:00:00 2001 From: moss <> Date: Tue, 1 Apr 2025 00:38:43 +0700 Subject: [PATCH 01/12] check type object log --- src/interfaces/utils.ts | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/interfaces/utils.ts b/src/interfaces/utils.ts index 30035f0..c667f54 100644 --- a/src/interfaces/utils.ts +++ b/src/interfaces/utils.ts @@ -19,10 +19,20 @@ export type LogSequence = { }; export function setLogDataDiff(req: RequestWithUser, data: DataDiff) { - req.app.locals.logData.dataDiff = { - before: JSON.stringify(data.before), - after: JSON.stringify(data.after), - }; + // Check if data.before and data.after are valid objects + if ( + data.before && + typeof data.before === "object" && + data.after && + typeof data.after === "object" + ) { + req.app.locals.logData.dataDiff = { + before: JSON.stringify(data.before), + after: JSON.stringify(data.after), + }; + } else { + console.error("Invalid data provided: both before and after must be valid objects."); + } } export function addLogSequence(req: RequestWithUser, data: LogSequence) { From 7fa0e2f2426a1373242c153119da992ad9ff2d0f Mon Sep 17 00:00:00 2001 From: Bright Date: Fri, 4 Apr 2025 15:05:18 +0700 Subject: [PATCH 02/12] =?UTF-8?q?=E0=B8=A3=E0=B8=B0=E0=B8=9A=E0=B8=9A?= =?UTF-8?q?=E0=B8=9B=E0=B8=A3=E0=B8=B0=E0=B9=80=E0=B8=A1=E0=B8=B4=E0=B8=99?= =?UTF-8?q?=20=E0=B8=81=E0=B8=A3=E0=B8=93=E0=B8=B5=E0=B8=AD=E0=B8=B1?= =?UTF-8?q?=E0=B8=9B=E0=B9=82=E0=B8=AB=E0=B8=A5=E0=B8=94=E0=B9=80=E0=B8=AD?= =?UTF-8?q?=E0=B8=81=E0=B8=AA=E0=B8=B2=E0=B8=A3=E0=B8=97=E0=B8=B1=E0=B8=9A?= =?UTF-8?q?=E0=B8=AD=E0=B8=B1=E0=B8=99=E0=B9=80=E0=B8=94=E0=B8=B4=E0=B8=A1?= =?UTF-8?q?=20=20(=E0=B8=97=E0=B8=94=E0=B8=AA=E0=B8=AD=E0=B8=9A)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/DocumentController.ts | 44 +++++++++++++++++++++------ src/services/storage.ts | 31 +++++++++++++++++++ 2 files changed, 66 insertions(+), 9 deletions(-) diff --git a/src/controllers/DocumentController.ts b/src/controllers/DocumentController.ts index 78a3913..b20ba08 100644 --- a/src/controllers/DocumentController.ts +++ b/src/controllers/DocumentController.ts @@ -20,6 +20,7 @@ import { downloadFile, listFile, updateFile, + updateFile2 } from "../services/storage"; import { AppDataSource } from "../database/data-source"; import { Evaluation } from "../entities/Evaluation"; @@ -221,7 +222,7 @@ export class DocumentController extends Controller { throw new Error("เกิดข้อผิดพลาดกับระบบจัดการไฟล์ ไม่สามารถสร้างแฟ้มได้"); } - let used: string[] = []; + // let used: string[] = []; const evaluation = AppDataSource.getRepository(Evaluation); @@ -230,20 +231,45 @@ export class DocumentController extends Controller { }); let fileList = !body.replace - ? body.fileList.map(({ fileName, ...props }) => { + ? await Promise.all(body.fileList.map(async({ fileName, ...props }) => { const dotIndex = fileName.lastIndexOf("."); const originalName = dotIndex !== -1 && !fileName.startsWith(".") ? fileName.slice(0, dotIndex) : fileName; const extension = dotIndex !== -1 && !fileName.startsWith(".") ? fileName.slice(dotIndex) : ""; - let i = 1; + // let i = 1; + let copyFileName = fileName; while ( - list.findIndex((v) => v.fileName === fileName) !== -1 || - used.includes(fileName) + list.findIndex((v) => v.fileName === fileName) !== -1 /*|| + used.includes(fileName)*/ ) { - fileName = `${originalName} (${i++})`; - if (dotIndex !== -1) fileName += extension; + // fileName = `${originalName} (${i++})`; + // if (dotIndex !== -1) fileName += extension; + let copy = 0; + while ( + list.findIndex( + (v) => + v.fileName === + `${originalName} (${copy + 1})` + (dotIndex !== -1 ? extension : ""), + ) !== -1 + ) { + copy++; + } + copyFileName = `${originalName} (${copy + 1})` + extension; + + const result = await updateFile2( + ["ระบบประเมิน", volume, id], + fileName, + { ...props, title: copyFileName }, + ["ระบบประเมิน", volume, id], + copyFileName, + ); + + if (!result) { + throw new Error("เกิดข้อผิดพลาดกับระบบจัดการไฟล์ ไม่สามารถแก้ไขไฟล์ได้"); + } + break; } if (author) { props.author = `${author.prefix}${author.fullName}`; @@ -251,9 +277,9 @@ export class DocumentController extends Controller { props.author = "ไม่พบข้อมูล"; } - used.push(fileName); + // used.push(fileName); return { fileName: fileName, ...props }; - }) + })) : body.fileList; const map = fileList.map(async ({ fileName, ...props }) => [ diff --git a/src/services/storage.ts b/src/services/storage.ts index 60cbf17..e618475 100644 --- a/src/services/storage.ts +++ b/src/services/storage.ts @@ -167,6 +167,37 @@ export async function updateFile(path: string[], file: string, metadata: FilePro return Boolean(res); } +export async function updateFile2( + path: string[], + file: string, + metadata: FileProps, + destPath?: string[], + destFile?: string, +) { + const res = await fetch(`${STORAGE_URL}/storage/file`, { + method: "PUT", + headers: { + Authorization: `Bearer ${await getToken()}`, + "Content-Type": "application/json", + }, + body: JSON.stringify({ + from: { path, file }, + to: destPath && destFile ? { path: destPath, file: destFile } : undefined, + ...metadata, + upload: false, + }), + }).catch((e) => console.error(e)); + + if (!res || !res.ok) { + if (res && res.status === HttpStatus.NOT_FOUND) { + throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบไฟล์ในระบบ"); + } + return Boolean(console.error(res ? await res.json() : res)); + } + + return Boolean(res); +} + export async function deleteFolder(path: string[], name: string) { const res = await fetch(`${STORAGE_URL}/storage/folder`, { method: "DELETE", From 32f4ce2a5d7ff9ae2c9d94edb6e31f1379802e31 Mon Sep 17 00:00:00 2001 From: AdisakKanthawilang Date: Tue, 8 Apr 2025 13:39:51 +0700 Subject: [PATCH 03/12] checknull --- src/controllers/ReportController.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/controllers/ReportController.ts b/src/controllers/ReportController.ts index ae46f30..f522497 100644 --- a/src/controllers/ReportController.ts +++ b/src/controllers/ReportController.ts @@ -286,9 +286,9 @@ export class ReoportController { evaluationOld.length > 0 ? evaluationOld.map((x) => x.subject).join(", ") : "ไม่มี"; let thaiYear: number = new Date().getFullYear() + 543; let years = { - lastTwoYear: Extension.ToThaiNumber((thaiYear - 2).toString()), - lastOneYear: Extension.ToThaiNumber((thaiYear - 1).toString()), - currentYear: Extension.ToThaiNumber(thaiYear.toString()), + lastTwoYear: thaiYear ? Extension.ToThaiNumber((thaiYear - 2).toString()):"-", + lastOneYear: thaiYear ? Extension.ToThaiNumber((thaiYear - 1).toString()):"-", + currentYear: thaiYear ? Extension.ToThaiNumber(thaiYear.toString()):"-", }; const dataEvaluation = { isEducationalQft: evaluation.isEducationalQft, From 8b952b15c0116d03718c42af85f61bcd22b212a7 Mon Sep 17 00:00:00 2001 From: AdisakKanthawilang Date: Tue, 8 Apr 2025 15:52:32 +0700 Subject: [PATCH 04/12] add on salary entity --- src/entities/Salary.ts | 267 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 266 insertions(+), 1 deletion(-) diff --git a/src/entities/Salary.ts b/src/entities/Salary.ts index 062c3fd..d3c3078 100644 --- a/src/entities/Salary.ts +++ b/src/entities/Salary.ts @@ -1,4 +1,4 @@ -import { Entity, Column, ManyToOne, JoinColumn, OneToOne } from "typeorm"; +import { Entity, Column, ManyToOne, JoinColumn, OneToOne, Double } from "typeorm"; import { EntityBase } from "./base/Base"; import { Evaluation } from "./Evaluation"; @@ -44,9 +44,274 @@ export class Salary extends EntityBase { @Column({ nullable: true, comment: "ประเภทตำแหน่งกรณีพิเศษ" }) salaryStatus: string; + @Column({ + nullable: true, + length: 40, + comment: "คีย์นอก(FK)ของตาราง profile", + type: "uuid", + default: null, + }) + profileId: string; + + @Column({ + nullable: true, + length: 40, + comment: "คีย์นอก(FK)ของตาราง ProfileEmployee", + default: null, + }) + profileEmployeeId: string; + + @Column({ + nullable: true, + comment: "เรียงลำดับใหมาตามการนำเข้า", + default: null, + }) + order: number; + + @Column({ + nullable: true, + comment: "เลขที่คำสั่ง", + default: null, + }) + commandNo: string; + + @Column({ + nullable: true, + comment: "ปีที่ออกคำสั่ง", + default: null, + }) + commandYear: number; + + @Column({ + comment: "คำสั่งวันที่", + type: "datetime", + nullable: true, + }) + commandDateSign: Date; + + @Column({ + comment: "คำสั่งมีผลวันที่", + type: "datetime", + nullable: true, + }) + commandDateAffect: Date; + + @Column({ + nullable: true, + comment: "รหัสประเภทของคำสั่ง", + default: null, + }) + commandCode: string; + + @Column({ + nullable: true, + comment: "ชื่อประเภทคำสั่ง", + default: null, + }) + commandName: string; + + @Column({ + nullable: true, + length: 40, + comment: "ตัวย่อเลขที่ตำแหน่ง", + default: null, + }) + posNoAbb: string; + + @Column({ + nullable: true, + length: 255, + comment: "ตำแหน่ง", + default: null, + }) + positionName: string; + + @Column({ + nullable: true, + length: 255, + comment: "ประเภทตำแหน่ง", + default: null, + }) + positionType: string; + + @Column({ + nullable: true, + length: 255, + comment: "ระดับตำแหน่ง", + default: null, + }) + positionLevel: string; + + @Column({ + nullable: true, + comment: "ระดับของเก่าที่ยังไม่เทียบเท่าแบบแท่ง", + default: null, + }) + positionCee: string; + + @Column({ + nullable: true, + comment: "root name", + default: null, + }) + orgRoot: string; + + @Column({ + nullable: true, + comment: "child1 name", + default: null, + }) + orgChild1: string; + + @Column({ + nullable: true, + comment: "child2 name", + default: null, + }) + orgChild2: string; + + @Column({ + nullable: true, + comment: "child3 name", + default: null, + }) + orgChild3: string; + + @Column({ + nullable: true, + comment: "child4 name", + default: null, + }) + orgChild4: string; + + @Column({ + nullable: true, + length: 255, + comment: "ตำแหน่งทางการบริหาร", + default: null, + }) + positionExecutive: string; + + @Column({ + comment: "เงินพิเศษ", + default: 0, + nullable: true, + type: "double", + }) + amountSpecial: Double; + + @Column({ + nullable: true, + type: "text", + comment: "หมายเหตุ", + default: null, + }) + remark: string; + + @Column({ + nullable: true, + comment: "refId", + default: null, + }) + refId: string; + + @Column({ + comment: "วันที่", + type: "datetime", + nullable: true, + }) + dateGovernment: Date; + + @Column({ + nullable: true, + comment: "เข้ารับราชการ", + default: null, + }) + isGovernment: boolean; + + @Column({ + nullable: false, + comment: "ข้อมูลจาก Entry", + default: null, + }) + isEntry: boolean; + + @Column({ + nullable: true, + length: 255, + comment: "ด้านของตำแหน่ง", + default: null, + }) + positionPathSide: string; + + @Column({ + nullable: true, + length: 255, + comment: "ตำแหน่งในสายงาน", + default: null, + }) + positionLine: string; + + @Column({ + nullable: true, + length: 40, + comment: "คีย์นอก(FK)ของตาราง command", + default: null, + }) + commandId: string; + + @Column({ + nullable: true, + length: 255, + comment: "หน่วยงานที่ออกคำสั่ง", + default: null, + }) + posNumCodeSit: string; + + @Column({ + nullable: true, + length: 255, + comment: "หน่วยงานที่ออกคำสั่ง(ตัวย่อ)", + default: null, + }) + posNumCodeSitAbb: string; + @ManyToOne(() => Evaluation, (Evaluation) => Evaluation.salaries) @JoinColumn({ name: "evaluationId" }) evaluation: Evaluation; } +export class CreateSalary { + profileId?: string | null; + commandCode?: string | null; + commandNo?: string | null; + commandYear?: number | null; + commandDateAffect?: Date | null; + commandDateSign?: Date | null; + posNoAbb?: string | null; + posNo?: string | null; + positionName?: string | null; + positionType?: string | null; + positionLevel?: string | null; + positionLine?: string | null; + positionPathSide?: string | null; + positionExecutive?: string | null; + amount?: Double | null; + amountSpecial?: Double | null; + positionSalaryAmount?: Double | null; + mouthSalaryAmount?: Double | null; + orgRoot?: string | null; + orgChild1?: string | null; + orgChild2?: string | null; + orgChild3?: string | null; + orgChild4?: string | null; + remark?: string | null; + commandId?: string | null; + isGovernment?: boolean | null; + positionCee?: string | null; + commandName?: string | null; + posNumCodeSit?: string | null; + posNumCodeSitAbb?: string | null; +} + export type UpdateSalary = Partial; From cf947e9fa95fcc15dbca31c510718fc29c4d799d Mon Sep 17 00:00:00 2001 From: moss <> Date: Tue, 8 Apr 2025 16:02:48 +0700 Subject: [PATCH 05/12] migrate --- ...1730874813739-update_table_eva_add_root.ts | 22 ------ .../1734665465868-update_12202024me.ts | 14 ---- .../1736140332359-update_eva_add_root.ts | 16 ---- ...50613-update_salary_addProfilesalaeyAll.ts | 74 +++++++++++++++++++ 4 files changed, 74 insertions(+), 52 deletions(-) delete mode 100644 src/migration/1730874813739-update_table_eva_add_root.ts delete mode 100644 src/migration/1734665465868-update_12202024me.ts delete mode 100644 src/migration/1736140332359-update_eva_add_root.ts create mode 100644 src/migration/1744102850613-update_salary_addProfilesalaeyAll.ts diff --git a/src/migration/1730874813739-update_table_eva_add_root.ts b/src/migration/1730874813739-update_table_eva_add_root.ts deleted file mode 100644 index e4e4879..0000000 --- a/src/migration/1730874813739-update_table_eva_add_root.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { MigrationInterface, QueryRunner } from "typeorm"; - -export class UpdateTableEvaAddRoot1730874813739 implements MigrationInterface { - name = 'UpdateTableEvaAddRoot1730874813739' - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE \`evaluation\` ADD \`rootId\` varchar(255) NULL COMMENT 'root'`); - await queryRunner.query(`ALTER TABLE \`evaluation\` ADD \`child1Id\` varchar(255) NULL COMMENT 'child1'`); - await queryRunner.query(`ALTER TABLE \`evaluation\` ADD \`child2Id\` varchar(255) NULL COMMENT 'child2'`); - await queryRunner.query(`ALTER TABLE \`evaluation\` ADD \`child3Id\` varchar(255) NULL COMMENT 'child3'`); - await queryRunner.query(`ALTER TABLE \`evaluation\` ADD \`child4Id\` varchar(255) NULL COMMENT 'child4'`); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE \`evaluation\` DROP COLUMN \`child4Id\``); - await queryRunner.query(`ALTER TABLE \`evaluation\` DROP COLUMN \`child3Id\``); - await queryRunner.query(`ALTER TABLE \`evaluation\` DROP COLUMN \`child2Id\``); - await queryRunner.query(`ALTER TABLE \`evaluation\` DROP COLUMN \`child1Id\``); - await queryRunner.query(`ALTER TABLE \`evaluation\` DROP COLUMN \`rootId\``); - } - -} diff --git a/src/migration/1734665465868-update_12202024me.ts b/src/migration/1734665465868-update_12202024me.ts deleted file mode 100644 index cc68482..0000000 --- a/src/migration/1734665465868-update_12202024me.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { MigrationInterface, QueryRunner } from "typeorm"; - -export class Update12202024me1734665465868 implements MigrationInterface { - name = 'Update12202024me1734665465868' - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE \`evaluation\` ADD \`evaluationResult\` varchar(255) NULL COMMENT 'ผลการประเมิน' DEFAULT 'PENDING'`); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE \`evaluation\` DROP COLUMN \`evaluationResult\``); - } - -} diff --git a/src/migration/1736140332359-update_eva_add_root.ts b/src/migration/1736140332359-update_eva_add_root.ts deleted file mode 100644 index 434ad04..0000000 --- a/src/migration/1736140332359-update_eva_add_root.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { MigrationInterface, QueryRunner } from "typeorm"; - -export class UpdateEvaAddRoot1736140332359 implements MigrationInterface { - name = 'UpdateEvaAddRoot1736140332359' - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE \`evaluation\` ADD \`root\` varchar(255) NULL COMMENT 'สำนักงานที่สังกัด'`); - await queryRunner.query(`ALTER TABLE \`evaluation\` ADD \`orgRootId\` varchar(255) NULL COMMENT 'ไอดีสำนักงานที่สังกัด'`); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE \`evaluation\` DROP COLUMN \`orgRootId\``); - await queryRunner.query(`ALTER TABLE \`evaluation\` DROP COLUMN \`root\``); - } - -} diff --git a/src/migration/1744102850613-update_salary_addProfilesalaeyAll.ts b/src/migration/1744102850613-update_salary_addProfilesalaeyAll.ts new file mode 100644 index 0000000..3efafdb --- /dev/null +++ b/src/migration/1744102850613-update_salary_addProfilesalaeyAll.ts @@ -0,0 +1,74 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class UpdateSalaryAddProfilesalaeyAll1744102850613 implements MigrationInterface { + name = 'UpdateSalaryAddProfilesalaeyAll1744102850613' + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`salary\` ADD \`profileId\` varchar(40) NULL COMMENT 'คีย์นอก(FK)ของตาราง profile'`); + await queryRunner.query(`ALTER TABLE \`salary\` ADD \`profileEmployeeId\` varchar(40) NULL COMMENT 'คีย์นอก(FK)ของตาราง ProfileEmployee'`); + await queryRunner.query(`ALTER TABLE \`salary\` ADD \`order\` int NULL COMMENT 'เรียงลำดับใหมาตามการนำเข้า'`); + await queryRunner.query(`ALTER TABLE \`salary\` ADD \`commandNo\` varchar(255) NULL COMMENT 'เลขที่คำสั่ง'`); + await queryRunner.query(`ALTER TABLE \`salary\` ADD \`commandYear\` int NULL COMMENT 'ปีที่ออกคำสั่ง'`); + await queryRunner.query(`ALTER TABLE \`salary\` ADD \`commandDateSign\` datetime NULL COMMENT 'คำสั่งวันที่'`); + await queryRunner.query(`ALTER TABLE \`salary\` ADD \`commandDateAffect\` datetime NULL COMMENT 'คำสั่งมีผลวันที่'`); + await queryRunner.query(`ALTER TABLE \`salary\` ADD \`commandCode\` varchar(255) NULL COMMENT 'รหัสประเภทของคำสั่ง'`); + await queryRunner.query(`ALTER TABLE \`salary\` ADD \`commandName\` varchar(255) NULL COMMENT 'ชื่อประเภทคำสั่ง'`); + await queryRunner.query(`ALTER TABLE \`salary\` ADD \`posNoAbb\` varchar(40) NULL COMMENT 'ตัวย่อเลขที่ตำแหน่ง'`); + await queryRunner.query(`ALTER TABLE \`salary\` ADD \`positionName\` varchar(255) NULL COMMENT 'ตำแหน่ง'`); + await queryRunner.query(`ALTER TABLE \`salary\` ADD \`positionType\` varchar(255) NULL COMMENT 'ประเภทตำแหน่ง'`); + await queryRunner.query(`ALTER TABLE \`salary\` ADD \`positionLevel\` varchar(255) NULL COMMENT 'ระดับตำแหน่ง'`); + await queryRunner.query(`ALTER TABLE \`salary\` ADD \`positionCee\` varchar(255) NULL COMMENT 'ระดับของเก่าที่ยังไม่เทียบเท่าแบบแท่ง'`); + await queryRunner.query(`ALTER TABLE \`salary\` ADD \`orgRoot\` varchar(255) NULL COMMENT 'root name'`); + await queryRunner.query(`ALTER TABLE \`salary\` ADD \`orgChild1\` varchar(255) NULL COMMENT 'child1 name'`); + await queryRunner.query(`ALTER TABLE \`salary\` ADD \`orgChild2\` varchar(255) NULL COMMENT 'child2 name'`); + await queryRunner.query(`ALTER TABLE \`salary\` ADD \`orgChild3\` varchar(255) NULL COMMENT 'child3 name'`); + await queryRunner.query(`ALTER TABLE \`salary\` ADD \`orgChild4\` varchar(255) NULL COMMENT 'child4 name'`); + await queryRunner.query(`ALTER TABLE \`salary\` ADD \`positionExecutive\` varchar(255) NULL COMMENT 'ตำแหน่งทางการบริหาร'`); + await queryRunner.query(`ALTER TABLE \`salary\` ADD \`amountSpecial\` double NULL COMMENT 'เงินพิเศษ' DEFAULT '0'`); + await queryRunner.query(`ALTER TABLE \`salary\` ADD \`remark\` text NULL COMMENT 'หมายเหตุ'`); + await queryRunner.query(`ALTER TABLE \`salary\` ADD \`refId\` varchar(255) NULL COMMENT 'refId'`); + await queryRunner.query(`ALTER TABLE \`salary\` ADD \`dateGovernment\` datetime NULL COMMENT 'วันที่'`); + await queryRunner.query(`ALTER TABLE \`salary\` ADD \`isGovernment\` tinyint NULL COMMENT 'เข้ารับราชการ'`); + await queryRunner.query(`ALTER TABLE \`salary\` ADD \`isEntry\` tinyint NOT NULL COMMENT 'ข้อมูลจาก Entry'`); + await queryRunner.query(`ALTER TABLE \`salary\` ADD \`positionPathSide\` varchar(255) NULL COMMENT 'ด้านของตำแหน่ง'`); + await queryRunner.query(`ALTER TABLE \`salary\` ADD \`positionLine\` varchar(255) NULL COMMENT 'ตำแหน่งในสายงาน'`); + await queryRunner.query(`ALTER TABLE \`salary\` ADD \`commandId\` varchar(40) NULL COMMENT 'คีย์นอก(FK)ของตาราง command'`); + await queryRunner.query(`ALTER TABLE \`salary\` ADD \`posNumCodeSit\` varchar(255) NULL COMMENT 'หน่วยงานที่ออกคำสั่ง'`); + await queryRunner.query(`ALTER TABLE \`salary\` ADD \`posNumCodeSitAbb\` varchar(255) NULL COMMENT 'หน่วยงานที่ออกคำสั่ง(ตัวย่อ)'`); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`salary\` DROP COLUMN \`posNumCodeSitAbb\``); + await queryRunner.query(`ALTER TABLE \`salary\` DROP COLUMN \`posNumCodeSit\``); + await queryRunner.query(`ALTER TABLE \`salary\` DROP COLUMN \`commandId\``); + await queryRunner.query(`ALTER TABLE \`salary\` DROP COLUMN \`positionLine\``); + await queryRunner.query(`ALTER TABLE \`salary\` DROP COLUMN \`positionPathSide\``); + await queryRunner.query(`ALTER TABLE \`salary\` DROP COLUMN \`isEntry\``); + await queryRunner.query(`ALTER TABLE \`salary\` DROP COLUMN \`isGovernment\``); + await queryRunner.query(`ALTER TABLE \`salary\` DROP COLUMN \`dateGovernment\``); + await queryRunner.query(`ALTER TABLE \`salary\` DROP COLUMN \`refId\``); + await queryRunner.query(`ALTER TABLE \`salary\` DROP COLUMN \`remark\``); + await queryRunner.query(`ALTER TABLE \`salary\` DROP COLUMN \`amountSpecial\``); + await queryRunner.query(`ALTER TABLE \`salary\` DROP COLUMN \`positionExecutive\``); + await queryRunner.query(`ALTER TABLE \`salary\` DROP COLUMN \`orgChild4\``); + await queryRunner.query(`ALTER TABLE \`salary\` DROP COLUMN \`orgChild3\``); + await queryRunner.query(`ALTER TABLE \`salary\` DROP COLUMN \`orgChild2\``); + await queryRunner.query(`ALTER TABLE \`salary\` DROP COLUMN \`orgChild1\``); + await queryRunner.query(`ALTER TABLE \`salary\` DROP COLUMN \`orgRoot\``); + await queryRunner.query(`ALTER TABLE \`salary\` DROP COLUMN \`positionCee\``); + await queryRunner.query(`ALTER TABLE \`salary\` DROP COLUMN \`positionLevel\``); + await queryRunner.query(`ALTER TABLE \`salary\` DROP COLUMN \`positionType\``); + await queryRunner.query(`ALTER TABLE \`salary\` DROP COLUMN \`positionName\``); + await queryRunner.query(`ALTER TABLE \`salary\` DROP COLUMN \`posNoAbb\``); + await queryRunner.query(`ALTER TABLE \`salary\` DROP COLUMN \`commandName\``); + await queryRunner.query(`ALTER TABLE \`salary\` DROP COLUMN \`commandCode\``); + await queryRunner.query(`ALTER TABLE \`salary\` DROP COLUMN \`commandDateAffect\``); + await queryRunner.query(`ALTER TABLE \`salary\` DROP COLUMN \`commandDateSign\``); + await queryRunner.query(`ALTER TABLE \`salary\` DROP COLUMN \`commandYear\``); + await queryRunner.query(`ALTER TABLE \`salary\` DROP COLUMN \`commandNo\``); + await queryRunner.query(`ALTER TABLE \`salary\` DROP COLUMN \`order\``); + await queryRunner.query(`ALTER TABLE \`salary\` DROP COLUMN \`profileEmployeeId\``); + await queryRunner.query(`ALTER TABLE \`salary\` DROP COLUMN \`profileId\``); + } + +} From 0604185e25764e13715acb60d2c1e26ebbeda8d1 Mon Sep 17 00:00:00 2001 From: AdisakKanthawilang Date: Tue, 8 Apr 2025 16:40:11 +0700 Subject: [PATCH 06/12] fix eva --- src/controllers/EvaluationController.ts | 137 +++++++++++++++++++++--- src/controllers/ReportController.ts | 12 +-- src/entities/Evaluation.ts | 66 ++++++------ src/entities/Salary.ts | 32 ------ 4 files changed, 160 insertions(+), 87 deletions(-) diff --git a/src/controllers/EvaluationController.ts b/src/controllers/EvaluationController.ts index 90a1f61..3e10b27 100644 --- a/src/controllers/EvaluationController.ts +++ b/src/controllers/EvaluationController.ts @@ -32,6 +32,7 @@ import CallAPI from "../interfaces/call-api"; import permission from "../interfaces/permission"; import { RequestWithUser } from "../middlewares/user"; import { setLogDataDiff } from "../interfaces/utils"; +import Extension from "../interfaces/extension"; @Route("api/v1/evaluation") @Tags("evaluation") @@ -519,31 +520,78 @@ export class EvaluationController { }); //Salary - if (requestBody.salaries != null) + // if (requestBody.salaries != null) + // requestBody.salaries.forEach(async (salary) => { + // const salaries = new Salary(); + // salaries.createdUserId = request.user.sub; + // salaries.createdFullName = request.user.name; + // salaries.createdAt = new Date(); + // salaries.lastUpdateUserId = request.user.sub; + // salaries.lastUpdateFullName = request.user.name; + // salaries.lastUpdatedAt = new Date(); + // salaries.date = salary.date ?? _null; + // salaries.amount = salary.amount ?? _null; + // salaries.positionSalaryAmount = salary.positionSalaryAmount ?? _null; + // salaries.mouthSalaryAmount = salary.mouthSalaryAmount ?? _null; + // salaries.position = salary.position ?? _null; + // salaries.posNo = salary.posNo ?? _null; + // salaries.salaryClass = salary.salaryClass ?? _null; + // salaries.salaryRef = salary.salaryRef ?? _null; + // salaries.refCommandNo = salary.refCommandNo ?? _null; + // salaries.refCommandDate = salary.refCommandDate ?? _null; + // salaries.salaryStatus = salary.salaryStatus ?? _null; + // salaries.evaluation = evaluation; + // await this.salaryRepository.save(salaries, { data: request }); + // setLogDataDiff(request, { before, after: salaries }); + // }); + + if (requestBody.salaries != null) { requestBody.salaries.forEach(async (salary) => { const salaries = new Salary(); + salaries.profileId = salary.profileId ?? _null; + salaries.commandCode = salary.commandCode ?? _null; + salaries.commandNo = salary.commandNo ?? _null; + salaries.commandYear = salary.commandYear ?? _null; + salaries.commandDateAffect = salary.commandDateAffect ?? _null; + salaries.commandDateSign = salary.commandDateSign ?? _null; + salaries.posNoAbb = salary.posNoAbb ?? _null; + salaries.posNo = salary.posNo ?? _null; + salaries.positionName = salary.positionName ?? _null; + salaries.positionType = salary.positionType ?? _null; + salaries.positionLevel = salary.positionLevel ?? _null; + salaries.positionLine = salary.positionLine ?? _null; + salaries.positionPathSide = salary.positionPathSide ?? _null; + salaries.positionExecutive = salary.positionExecutive ?? _null; + salaries.amount = salary.amount ?? _null; + salaries.amountSpecial = salary.amountSpecial ?? _null; + salaries.positionSalaryAmount = salary.positionSalaryAmount ?? _null; + salaries.mouthSalaryAmount = salary.mouthSalaryAmount ?? _null; + salaries.orgRoot = salary.orgRoot ?? _null; + salaries.orgChild1 = salary.orgChild1 ?? _null; + salaries.orgChild2 = salary.orgChild2 ?? _null; + salaries.orgChild3 = salary.orgChild3 ?? _null; + salaries.orgChild4 = salary.orgChild4 ?? _null; + salaries.remark = salary.remark ?? _null; + salaries.commandId = salary.commandId ?? _null; + salaries.isGovernment = salary.isGovernment ?? _null; + salaries.positionCee = salary.positionCee ?? _null; + salaries.commandName = salary.commandName ?? _null; + salaries.posNumCodeSit = salary.posNumCodeSit ?? _null; + salaries.posNumCodeSitAbb = salary.posNumCodeSitAbb ?? _null; + salaries.isEntry = salary.isEntry ?? false; + salaries.evaluation = evaluation; + salaries.createdUserId = request.user.sub; salaries.createdFullName = request.user.name; salaries.createdAt = new Date(); salaries.lastUpdateUserId = request.user.sub; salaries.lastUpdateFullName = request.user.name; salaries.lastUpdatedAt = new Date(); - salaries.date = salary.date ?? _null; - salaries.amount = salary.amount ?? _null; - salaries.positionSalaryAmount = salary.positionSalaryAmount ?? _null; - salaries.mouthSalaryAmount = salary.mouthSalaryAmount ?? _null; - salaries.position = salary.position ?? _null; - salaries.posNo = salary.posNo ?? _null; - salaries.salaryClass = salary.salaryClass ?? _null; - salaries.salaryRef = salary.salaryRef ?? _null; - salaries.refCommandNo = salary.refCommandNo ?? _null; - salaries.refCommandDate = salary.refCommandDate ?? _null; - salaries.salaryStatus = salary.salaryStatus ?? _null; - salaries.evaluation = evaluation; + await this.salaryRepository.save(salaries, { data: request }); setLogDataDiff(request, { before, after: salaries }); }); - + } //Training if (requestBody.trainings != null) requestBody.trainings.forEach(async (train) => { @@ -871,6 +919,12 @@ export class EvaluationController { ]) async checkSpecGet(@Request() request: RequestWithUser, @Path() id: string) { try { + // let thaiYear: number = new Date().getFullYear() + 543; + // let years = { + // lastTwoYear: Extension.ToThaiNumber((thaiYear - 2).toString()), + // lastOneYear: Extension.ToThaiNumber((thaiYear - 1).toString()), + // currentYear: Extension.ToThaiNumber(thaiYear.toString()), + // }; const evaluation = await AppDataSource.getRepository(Evaluation) .createQueryBuilder("evaluation") .leftJoin("evaluation.education", "education") @@ -932,6 +986,33 @@ export class EvaluationController { "salaries.refCommandNo", "salaries.refCommandDate", "salaries.salaryStatus", + "salaries.profileId", + "salaries.commandCode", + "salaries.commandNo", + "salaries.commandYear", + "salaries.commandDateAffect", + "salaries.commandDateSign", + "salaries.posNoAbb", + "salaries.positionName", + "salaries.positionType", + "salaries.positionLevel", + "salaries.positionLine", + "salaries.positionPathSide", + "salaries.positionExecutive", + "salaries.amountSpecial", + "salaries.orgRoot", + "salaries.orgChild1", + "salaries.orgChild2", + "salaries.orgChild3", + "salaries.orgChild4", + "salaries.remark", + "salaries.commandId", + "salaries.isGovernment", + "salaries.positionCee", + "salaries.commandName", + "salaries.posNumCodeSit", + "salaries.posNumCodeSitAbb", + "salaries.isEntry", "training.name", "training.topic", @@ -1012,6 +1093,33 @@ export class EvaluationController { refCommandNo: salaries.refCommandNo, refCommandDate: salaries.refCommandDate, salaryStatus: salaries.salaryStatus, + profileId: salaries.profileId, + commandCode: salaries.commandCode, + commandNo: salaries.commandNo, + commandYear: salaries.commandYear, + commandDateAffect: salaries.commandDateAffect, + commandDateSign: salaries.commandDateSign, + posNoAbb: salaries.posNoAbb, + positionName: salaries.positionName, + positionType: salaries.positionType, + positionLevel: salaries.positionLevel, + positionLine: salaries.positionLine, + positionPathSide: salaries.positionPathSide, + positionExecutive: salaries.positionExecutive, + amountSpecial: salaries.amountSpecial, + orgRoot: salaries.orgRoot, + orgChild1: salaries.orgChild1, + orgChild2: salaries.orgChild2, + orgChild3: salaries.orgChild3, + orgChild4: salaries.orgChild4, + remark: salaries.remark, + commandId: salaries.commandId, + isGovernment: salaries.isGovernment, + positionCee: salaries.positionCee, + commandName: salaries.commandName, + posNumCodeSit: salaries.posNumCodeSit, + posNumCodeSitAbb: salaries.posNumCodeSitAbb, + isEntry: salaries.isEntry, })), trainings: evaluation.training.map((training) => ({ name: training.name, @@ -1034,6 +1142,7 @@ export class EvaluationController { pointSumTotal: assessment.pointSumTotal, pointSum: assessment.pointSum, })), + // years: years }; if (!dataEvaluation) { diff --git a/src/controllers/ReportController.ts b/src/controllers/ReportController.ts index f522497..1db6d94 100644 --- a/src/controllers/ReportController.ts +++ b/src/controllers/ReportController.ts @@ -286,9 +286,9 @@ export class ReoportController { evaluationOld.length > 0 ? evaluationOld.map((x) => x.subject).join(", ") : "ไม่มี"; let thaiYear: number = new Date().getFullYear() + 543; let years = { - lastTwoYear: thaiYear ? Extension.ToThaiNumber((thaiYear - 2).toString()):"-", - lastOneYear: thaiYear ? Extension.ToThaiNumber((thaiYear - 1).toString()):"-", - currentYear: thaiYear ? Extension.ToThaiNumber(thaiYear.toString()):"-", + lastTwoYear: Extension.ToThaiNumber((thaiYear - 2).toString()), + lastOneYear: Extension.ToThaiNumber((thaiYear - 1).toString()), + currentYear: Extension.ToThaiNumber(thaiYear.toString()), }; const dataEvaluation = { isEducationalQft: evaluation.isEducationalQft, @@ -340,13 +340,13 @@ export class ReoportController { startDate: education.startDate, endDate: education.endDate, finishDate: education.finishDate - ? Extension.ToThaiNumber( + ? `(${Extension.ToThaiNumber( Extension.ToThaiShortDate(education.finishDate).toString(), - ) + )})` : "-", isEducation: education.isEducation, degree: education.degree ? Extension.ToThaiNumber(education.degree) : "-", - field: education.field ? Extension.ToThaiNumber(education.field) : "-", + field: education.field ? `(${Extension.ToThaiNumber(education.field)})` : "-", fundName: education.fundName, gpa: education.gpa, country: education.country, diff --git a/src/entities/Evaluation.ts b/src/entities/Evaluation.ts index 0d7c953..b7e1daf 100644 --- a/src/entities/Evaluation.ts +++ b/src/entities/Evaluation.ts @@ -1,4 +1,4 @@ -import { Entity, Column, OneToMany, ManyToMany, JoinTable } from "typeorm"; +import { Entity, Column, OneToMany, ManyToMany, JoinTable, Double } from "typeorm"; import { EntityBase } from "./base/Base"; import { EvaluationLogs } from "./EvaluationLogs"; import { Education } from "./Education"; @@ -416,41 +416,37 @@ export class CreateCertificate { } export class CreateSalary { - @Column() - step?: string | null; - - @Column() - date?: Date | null; - - @Column() - amount?: number | null; - - @Column() - positionSalaryAmount?: number | null; - - @Column() - mouthSalaryAmount?: number | null; - - @Column() - position?: string | null; - - @Column() + profileId?: string | null; + commandCode?: string | null; + commandNo?: string | null; + commandYear?: number | null; + commandDateAffect?: Date | null; + commandDateSign?: Date | null; + posNoAbb?: string | null; posNo?: string | null; - - @Column() - salaryClass?: string | null; - - @Column() - salaryRef?: string | null; - - @Column() - refCommandNo?: string | null; - - @Column() - refCommandDate?: Date | null; - - @Column() - salaryStatus?: string | null; + positionName?: string | null; + positionType?: string | null; + positionLevel?: string | null; + positionLine?: string | null; + positionPathSide?: string | null; + positionExecutive?: string | null; + amount?: Double | null; + amountSpecial?: Double | null; + positionSalaryAmount?: Double | null; + mouthSalaryAmount?: Double | null; + orgRoot?: string | null; + orgChild1?: string | null; + orgChild2?: string | null; + orgChild3?: string | null; + orgChild4?: string | null; + remark?: string | null; + commandId?: string | null; + isGovernment?: boolean | null; + positionCee?: string | null; + commandName?: string | null; + posNumCodeSit?: string | null; + posNumCodeSitAbb?: string | null; + isEntry?: boolean | null; } export class CreateTraining { @Column() diff --git a/src/entities/Salary.ts b/src/entities/Salary.ts index d3c3078..d93db11 100644 --- a/src/entities/Salary.ts +++ b/src/entities/Salary.ts @@ -281,37 +281,5 @@ export class Salary extends EntityBase { evaluation: Evaluation; } -export class CreateSalary { - profileId?: string | null; - commandCode?: string | null; - commandNo?: string | null; - commandYear?: number | null; - commandDateAffect?: Date | null; - commandDateSign?: Date | null; - posNoAbb?: string | null; - posNo?: string | null; - positionName?: string | null; - positionType?: string | null; - positionLevel?: string | null; - positionLine?: string | null; - positionPathSide?: string | null; - positionExecutive?: string | null; - amount?: Double | null; - amountSpecial?: Double | null; - positionSalaryAmount?: Double | null; - mouthSalaryAmount?: Double | null; - orgRoot?: string | null; - orgChild1?: string | null; - orgChild2?: string | null; - orgChild3?: string | null; - orgChild4?: string | null; - remark?: string | null; - commandId?: string | null; - isGovernment?: boolean | null; - positionCee?: string | null; - commandName?: string | null; - posNumCodeSit?: string | null; - posNumCodeSitAbb?: string | null; -} export type UpdateSalary = Partial; From 5da1345333672762f0e374b2d04eb76caf41e35c Mon Sep 17 00:00:00 2001 From: AdisakKanthawilang Date: Tue, 8 Apr 2025 17:17:25 +0700 Subject: [PATCH 07/12] sort positionSalary --- src/controllers/EvaluationController.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/controllers/EvaluationController.ts b/src/controllers/EvaluationController.ts index 3e10b27..a73280f 100644 --- a/src/controllers/EvaluationController.ts +++ b/src/controllers/EvaluationController.ts @@ -1033,6 +1033,7 @@ export class EvaluationController { "assessment.pointSumTotal", "assessment.pointSum", ]) + .orderBy("salaries.commandDateAffect", "DESC") .getOne(); if (!evaluation) { From 2b7d44727cbe936e5fa53cbd86897a86cd9c384b Mon Sep 17 00:00:00 2001 From: AdisakKanthawilang Date: Tue, 8 Apr 2025 17:45:47 +0700 Subject: [PATCH 08/12] fix bug --- src/controllers/EvaluationController.ts | 57 +++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/src/controllers/EvaluationController.ts b/src/controllers/EvaluationController.ts index a73280f..5fa20b0 100644 --- a/src/controllers/EvaluationController.ts +++ b/src/controllers/EvaluationController.ts @@ -1320,6 +1320,33 @@ export class EvaluationController { "salaries.refCommandNo", "salaries.refCommandDate", "salaries.salaryStatus", + "salaries.profileId", + "salaries.commandCode", + "salaries.commandNo", + "salaries.commandYear", + "salaries.commandDateAffect", + "salaries.commandDateSign", + "salaries.posNoAbb", + "salaries.positionName", + "salaries.positionType", + "salaries.positionLevel", + "salaries.positionLine", + "salaries.positionPathSide", + "salaries.positionExecutive", + "salaries.amountSpecial", + "salaries.orgRoot", + "salaries.orgChild1", + "salaries.orgChild2", + "salaries.orgChild3", + "salaries.orgChild4", + "salaries.remark", + "salaries.commandId", + "salaries.isGovernment", + "salaries.positionCee", + "salaries.commandName", + "salaries.posNumCodeSit", + "salaries.posNumCodeSitAbb", + "salaries.isEntry", "training.name", "training.topic", @@ -1400,6 +1427,33 @@ export class EvaluationController { refCommandNo: salaries.refCommandNo, refCommandDate: salaries.refCommandDate, salaryStatus: salaries.salaryStatus, + profileId: salaries.profileId, + commandCode: salaries.commandCode, + commandNo: salaries.commandNo, + commandYear: salaries.commandYear, + commandDateAffect: salaries.commandDateAffect, + commandDateSign: salaries.commandDateSign, + posNoAbb: salaries.posNoAbb, + positionName: salaries.positionName, + positionType: salaries.positionType, + positionLevel: salaries.positionLevel, + positionLine: salaries.positionLine, + positionPathSide: salaries.positionPathSide, + positionExecutive: salaries.positionExecutive, + amountSpecial: salaries.amountSpecial, + orgRoot: salaries.orgRoot, + orgChild1: salaries.orgChild1, + orgChild2: salaries.orgChild2, + orgChild3: salaries.orgChild3, + orgChild4: salaries.orgChild4, + remark: salaries.remark, + commandId: salaries.commandId, + isGovernment: salaries.isGovernment, + positionCee: salaries.positionCee, + commandName: salaries.commandName, + posNumCodeSit: salaries.posNumCodeSit, + posNumCodeSitAbb: salaries.posNumCodeSitAbb, + isEntry: salaries.isEntry, })), trainings: evaluation.training.map((training) => ({ name: training.name, @@ -2478,6 +2532,7 @@ export class EvaluationController { const evaluation = await this.evaluationRepository.findOne({ where: { id }, select: [ + "id", "author", "subject", "commanderFullname", @@ -2486,6 +2541,7 @@ export class EvaluationController { "commanderAbovePosition", ], }); + if (!evaluation) { throw new HttpError(HttpStatusCode.NOT_FOUND, "not found."); } @@ -2513,6 +2569,7 @@ export class EvaluationController { const evaluation = await this.evaluationRepository.findOne({ where: { id }, select: [ + "id", "author", "subject", "commanderFullname", From 72772072bb2724165ca7c13b5a40e7d1b91a06c8 Mon Sep 17 00:00:00 2001 From: AdisakKanthawilang Date: Tue, 8 Apr 2025 18:05:12 +0700 Subject: [PATCH 09/12] sort --- src/controllers/EvaluationController.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/controllers/EvaluationController.ts b/src/controllers/EvaluationController.ts index 5fa20b0..065de78 100644 --- a/src/controllers/EvaluationController.ts +++ b/src/controllers/EvaluationController.ts @@ -1367,6 +1367,7 @@ export class EvaluationController { "assessment.pointSumTotal", "assessment.pointSum", ]) + .orderBy("salaries.commandDateAffect", "DESC") .getOne(); if (!evaluation) { From 9ffd131632507927eaafcd656642df34e0c6b232 Mon Sep 17 00:00:00 2001 From: AdisakKanthawilang Date: Wed, 9 Apr 2025 10:55:48 +0700 Subject: [PATCH 10/12] fix report --- src/controllers/ReportController.ts | 44 +++++++++++++++++++++++++---- 1 file changed, 39 insertions(+), 5 deletions(-) diff --git a/src/controllers/ReportController.ts b/src/controllers/ReportController.ts index 1db6d94..4a08172 100644 --- a/src/controllers/ReportController.ts +++ b/src/controllers/ReportController.ts @@ -207,6 +207,7 @@ export class ReoportController { "certificate.issueDate", "certificate.expireDate", + "salaries.date", "salaries.amount", "salaries.positionSalaryAmount", @@ -218,6 +219,33 @@ export class ReoportController { "salaries.refCommandNo", "salaries.refCommandDate", "salaries.salaryStatus", + "salaries.profileId", + "salaries.commandCode", + "salaries.commandNo", + "salaries.commandYear", + "salaries.commandDateAffect", + "salaries.commandDateSign", + "salaries.posNoAbb", + "salaries.positionName", + "salaries.positionType", + "salaries.positionLevel", + "salaries.positionLine", + "salaries.positionPathSide", + "salaries.positionExecutive", + "salaries.amountSpecial", + "salaries.orgRoot", + "salaries.orgChild1", + "salaries.orgChild2", + "salaries.orgChild3", + "salaries.orgChild4", + "salaries.remark", + "salaries.commandId", + "salaries.isGovernment", + "salaries.positionCee", + "salaries.commandName", + "salaries.posNumCodeSit", + "salaries.posNumCodeSitAbb", + "salaries.isEntry", "training.name", "training.topic", @@ -238,6 +266,7 @@ export class ReoportController { "assessment.pointSumTotal", "assessment.pointSum", ]) + .orderBy("salaries.commandDateAffect", "DESC") .getOne(); if (!evaluation) { @@ -343,10 +372,10 @@ export class ReoportController { ? `(${Extension.ToThaiNumber( Extension.ToThaiShortDate(education.finishDate).toString(), )})` - : "-", + : "", isEducation: education.isEducation, degree: education.degree ? Extension.ToThaiNumber(education.degree) : "-", - field: education.field ? `(${Extension.ToThaiNumber(education.field)})` : "-", + field: education.field ? `(${Extension.ToThaiNumber(education.field)})` : "", fundName: education.fundName, gpa: education.gpa, country: education.country, @@ -389,13 +418,13 @@ export class ReoportController { salaries: evaluation.salaries.length > 0 ? evaluation.salaries.map((salaries) => ({ - date: salaries.date - ? Extension.ToThaiNumber(Extension.ToThaiShortDate_noPrefix(salaries.date)) + date: salaries.commandDateAffect + ? Extension.ToThaiNumber(Extension.ToThaiShortDate_noPrefix(salaries.commandDateAffect)) : "-", amount: salaries.amount ? Extension.ToThaiNumber(salaries.amount.toLocaleString()) : "-", - position: salaries.position ? Extension.ToThaiNumber(salaries.position) : "-", + position: salaries.positionName ? Extension.ToThaiNumber(salaries.positionName) : "-", positionSalaryAmount: salaries.positionSalaryAmount, mouthSalaryAmount: salaries.mouthSalaryAmount, posNo: salaries.posNo, @@ -404,6 +433,11 @@ export class ReoportController { refCommandNo: salaries.refCommandNo, refCommandDate: salaries.refCommandDate, salaryStatus: salaries.salaryStatus, + org: (salaries.orgChild4 ? salaries.orgChild4 + "\n" : "") + + (salaries.orgChild3 ? salaries.orgChild3 + "\n" : "") + + (salaries.orgChild2 ? salaries.orgChild2 + "\n" : "") + + (salaries.orgChild1 ? salaries.orgChild1 + "\n" : "") + + (salaries.orgRoot ? salaries.orgRoot : ""), })) : [ { From be3c52706e74cf62b865ee017dc6246c561555e7 Mon Sep 17 00:00:00 2001 From: AdisakKanthawilang Date: Wed, 9 Apr 2025 15:14:02 +0700 Subject: [PATCH 11/12] fix --- src/controllers/EvaluationController.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/controllers/EvaluationController.ts b/src/controllers/EvaluationController.ts index 065de78..43e822c 100644 --- a/src/controllers/EvaluationController.ts +++ b/src/controllers/EvaluationController.ts @@ -2533,7 +2533,6 @@ export class EvaluationController { const evaluation = await this.evaluationRepository.findOne({ where: { id }, select: [ - "id", "author", "subject", "commanderFullname", @@ -2570,7 +2569,6 @@ export class EvaluationController { const evaluation = await this.evaluationRepository.findOne({ where: { id }, select: [ - "id", "author", "subject", "commanderFullname", From 488b3b09233833fd323b3098e604aa3b770e801b Mon Sep 17 00:00:00 2001 From: AdisakKanthawilang Date: Wed, 9 Apr 2025 17:34:32 +0700 Subject: [PATCH 12/12] 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(