From c6e578ba4ed1f850b76ce6905b18f2d262d9a532 Mon Sep 17 00:00:00 2001 From: AdisakKanthawilang Date: Mon, 21 Oct 2024 14:21:15 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B9=80=E0=B8=9E=E0=B8=B4=E0=B9=88=E0=B8=A1?= =?UTF-8?q?=20id=20=E0=B8=84=E0=B8=B3=E0=B8=AA=E0=B8=B1=E0=B9=88=E0=B8=87?= =?UTF-8?q?=E0=B8=A5=E0=B8=87=E0=B8=9B=E0=B8=A3=E0=B8=B0=E0=B8=A7=E0=B8=B1?= =?UTF-8?q?=E0=B8=95=E0=B8=B4=E0=B8=95=E0=B8=B3=E0=B9=81=E0=B8=AB=E0=B8=99?= =?UTF-8?q?=E0=B9=88=E0=B8=87=20#665?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/CommandController.ts | 18 ++++++++++++--- src/controllers/ProfileSalaryController.ts | 1 - src/entities/ProfileSalary.ts | 1 + src/interfaces/utils.ts | 20 ++++++++--------- ...92903054-update_table_migration10212024.ts | 22 +++++++++++++++++++ 5 files changed, 48 insertions(+), 14 deletions(-) create mode 100644 src/migration/1729492903054-update_table_migration10212024.ts diff --git a/src/controllers/CommandController.ts b/src/controllers/CommandController.ts index 27778027..0ddd00c6 100644 --- a/src/controllers/CommandController.ts +++ b/src/controllers/CommandController.ts @@ -1427,6 +1427,7 @@ export class CommandController extends Controller { templateDoc: string | null; posmasterId: string; positionId: string; + commandId?: string | null; }[]; }, ) { @@ -1436,7 +1437,7 @@ export class CommandController extends Controller { if (!profile) { throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลทะเบียนประวัตินี้"); } - + let _null: any = null; const dest_item = await this.salaryRepo.findOne({ where: { profileId: item.profileId }, order: { order: "DESC" }, @@ -1457,10 +1458,9 @@ export class CommandController extends Controller { Object.assign(data, { ...item, ...meta }); const history = new ProfileSalaryHistory(); Object.assign(history, { ...data, id: undefined }); - await this.salaryRepo.save(data, { data: req }); setLogDataDiff(req, { before, after: data }); - history.profileSalaryId = data.id; + history.commandId = item.commandId??_null; await this.salaryHistoryRepo.save(history, { data: req }); const posMaster = await this.posMasterRepository.findOne({ @@ -1545,6 +1545,7 @@ export class CommandController extends Controller { templateDoc: string | null; posmasterId: string; positionId: string; + commandId?: string | null; }[]; }, ) { @@ -1678,6 +1679,7 @@ export class CommandController extends Controller { isLeave: boolean; leaveReason?: string | null; dateLeave?: Date | null; + commandId?: string | null; }[]; }, ) { @@ -1829,6 +1831,7 @@ export class CommandController extends Controller { positionLevel: string | null; refCommandNo: string | null; templateDoc: string | null; + commandId?: string | null; }[]; }, ) { @@ -1950,6 +1953,7 @@ export class CommandController extends Controller { detail?: string | null; level?: string | null; unStigma?: string | null; + commandId?: string | null; }[]; }, ) { @@ -2064,6 +2068,7 @@ export class CommandController extends Controller { date?: Date | null; refCommandNo?: string | null; salaryRef?: string | null; + commandId?: string | null; }[]; }, ) { @@ -2143,6 +2148,7 @@ export class CommandController extends Controller { date?: Date | null; refCommandNo?: string | null; salaryRef?: string | null; + commandId?: string | null; }[]; }, ) { @@ -2180,6 +2186,7 @@ export class CommandController extends Controller { date: item.date, refCommandNo: item.refCommandNo, templateDoc: item.salaryRef, + commandId: item.commandId, position: profile.profileSalary.length > 0 ? profile.profileSalary[0].position : null, positionType: profile.profileSalary.length > 0 ? profile.profileSalary[0].positionType : null, @@ -2434,6 +2441,7 @@ export class CommandController extends Controller { refId: string; commandAffectDate: Date | null; commandNo: string | null; + commandId?: string | null; commandYear: number; templateDoc: string | null; amount: Double | null; @@ -2460,6 +2468,7 @@ export class CommandController extends Controller { profileEmployeeId: profile.id, date: new Date(), amount: item.amount, + commandId: item.commandId, positionSalaryAmount: item.positionSalaryAmount, mouthSalaryAmount: item.mouthSalaryAmount, posNo: profile.posMasterNoTemp, @@ -2600,6 +2609,7 @@ export class CommandController extends Controller { refId: string; commandAffectDate: Date | null; commandNo: string | null; + commandId?: string | null; commandYear: number; templateDoc: string | null; amount: Double | null; @@ -2738,6 +2748,7 @@ export class CommandController extends Controller { refId: string; commandAffectDate: Date | null; commandNo: string | null; + commandId?: string | null; commandYear: number; templateDoc: string | null; amount: Double | null; @@ -2767,6 +2778,7 @@ export class CommandController extends Controller { profileId: profile.id, date: new Date(), amount: item.amount, + commandId: item.commandId, positionSalaryAmount: item.positionSalaryAmount, mouthSalaryAmount: item.mouthSalaryAmount, posNo: "", diff --git a/src/controllers/ProfileSalaryController.ts b/src/controllers/ProfileSalaryController.ts index a7fbea2c..26f2c188 100644 --- a/src/controllers/ProfileSalaryController.ts +++ b/src/controllers/ProfileSalaryController.ts @@ -121,7 +121,6 @@ export class ProfileSalaryController extends Controller { Object.assign(data, { ...body, ...meta }); const history = new ProfileSalaryHistory(); Object.assign(history, { ...data, id: undefined }); - await this.salaryRepo.save(data, { data: req }); setLogDataDiff(req, { before, after: data }); history.profileSalaryId = data.id; diff --git a/src/entities/ProfileSalary.ts b/src/entities/ProfileSalary.ts index 9c02c4c7..0d76a620 100644 --- a/src/entities/ProfileSalary.ts +++ b/src/entities/ProfileSalary.ts @@ -203,6 +203,7 @@ export class CreateProfileSalaryEmployee { profileEmployeeId: string | null; date?: Date | null; amount?: Double | null; + commandId: string | null; positionSalaryAmount?: Double | null; mouthSalaryAmount?: Double | null; posNo: string | null; diff --git a/src/interfaces/utils.ts b/src/interfaces/utils.ts index d3f9ded0..65c27d12 100644 --- a/src/interfaces/utils.ts +++ b/src/interfaces/utils.ts @@ -233,9 +233,9 @@ export function commandTypePath(commandCode: string): string | null { case "C-PM-10": return "/xxxxxx"; case "C-PM-11": - return "/probation/report/command11/officer/report"; + return "/probation/report/command11/officer/report";//PROBATION case "C-PM-12": - return "/probation/report/command12/officer/report"; + return "/probation/report/command12/officer/report";//PROBATION case "C-PM-13": return "/placement/transfer/command/report"; case "C-PM-14": @@ -253,7 +253,7 @@ export function commandTypePath(commandCode: string): string | null { case "C-PM-20": return "/discipline/result/command20/report"; case "C-PM-21": - return "/org/command/command21/employee/report"; + return "/org/command/command21/employee/report";//ORG case "C-PM-22": return "/placement/appointment/employee-appoint/report"; case "C-PM-23": @@ -277,21 +277,21 @@ export function commandTypePath(commandCode: string): string | null { case "C-PM-32": return "/discipline/result/command32/report"; case "C-PM-33": - return "/salary/report/command/officer/report"; + return "/salary/report/command/officer/report";//SALARY case "C-PM-34": - return "/salary/report/command/officer/report"; + return "/salary/report/command/officer/report";//SALARY case "C-PM-35": - return "/salary/report/command/officer/report"; + return "/salary/report/command/officer/report";//SALARY case "C-PM-36": - return "/salary/report/command/employee/report"; + return "/salary/report/command/employee/report";//SALARY case "C-PM-37": - return "/salary/report/command/employee/report"; + return "/salary/report/command/employee/report";//SALARY case "C-PM-38": - return "/org/command/command38/officer/report"; + return "/org/command/command38/officer/report";//ORG case "C-PM-39": return "/placement/slip/report"; case "C-PM-40": - return "/org/command/command40/officer/report"; + return "/org/command/command40/officer/report";//ORG case "C-PM-41": return "/retirement/resign/leave-cancel/report"; default: diff --git a/src/migration/1729492903054-update_table_migration10212024.ts b/src/migration/1729492903054-update_table_migration10212024.ts new file mode 100644 index 00000000..90e53e48 --- /dev/null +++ b/src/migration/1729492903054-update_table_migration10212024.ts @@ -0,0 +1,22 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class UpdateTableMigration102120241729492903054 implements MigrationInterface { + name = 'UpdateTableMigration102120241729492903054' + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(`CREATE TABLE \`commandSend\` (\`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', \`citizenId\` varchar(255) NULL COMMENT 'เลขประจำตัวประชาชน', \`prefix\` varchar(255) NULL COMMENT 'คำนำหน้า', \`firstName\` varchar(255) NULL COMMENT 'ชื่อ', \`lastName\` varchar(255) NULL COMMENT 'สกุล', \`position\` varchar(255) NULL COMMENT 'ตำแหน่ง', \`org\` varchar(255) NULL COMMENT 'หน่วยงาน', \`commandId\` varchar(40) NOT NULL COMMENT 'คีย์นอก(FK)ของตาราง command', \`profileId\` varchar(40) NOT NULL COMMENT 'คีย์นอก(FK)ของตาราง profile', PRIMARY KEY (\`id\`)) ENGINE=InnoDB`); + await queryRunner.query(`ALTER TABLE \`profileSalaryHistory\` ADD \`commandId\` varchar(40) NULL COMMENT 'คีย์นอก(FK)ของตาราง command'`); + await queryRunner.query(`ALTER TABLE \`commandSend\` ADD CONSTRAINT \`FK_71884cff2519003c997c4129374\` FOREIGN KEY (\`commandId\`) REFERENCES \`command\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE \`commandSend\` ADD CONSTRAINT \`FK_4f257ba4ce200ddc0726156a00d\` FOREIGN KEY (\`profileId\`) REFERENCES \`profile\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE \`profileSalaryHistory\` ADD CONSTRAINT \`FK_8ba1f49c8315bf86848ebcb29f5\` FOREIGN KEY (\`commandId\`) REFERENCES \`command\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`profileSalaryHistory\` DROP FOREIGN KEY \`FK_8ba1f49c8315bf86848ebcb29f5\``); + await queryRunner.query(`ALTER TABLE \`commandSend\` DROP FOREIGN KEY \`FK_4f257ba4ce200ddc0726156a00d\``); + await queryRunner.query(`ALTER TABLE \`commandSend\` DROP FOREIGN KEY \`FK_71884cff2519003c997c4129374\``); + await queryRunner.query(`ALTER TABLE \`profileSalaryHistory\` DROP COLUMN \`commandId\``); + await queryRunner.query(`DROP TABLE \`commandSend\``); + } + +}