From 1c55c76741d0916495cfdb76b561ea38a85ce477 Mon Sep 17 00:00:00 2001 From: Kittapath Date: Tue, 6 Feb 2024 15:44:21 +0700 Subject: [PATCH] no message --- src/controllers/ReportController.ts | 94 +++++++++---------- .../1707208924575-add_table_profile5.ts | 40 ++++++++ 2 files changed, 87 insertions(+), 47 deletions(-) create mode 100644 src/migration/1707208924575-add_table_profile5.ts diff --git a/src/controllers/ReportController.ts b/src/controllers/ReportController.ts index f018ac2d..d24f9df8 100644 --- a/src/controllers/ReportController.ts +++ b/src/controllers/ReportController.ts @@ -207,11 +207,11 @@ export class ReportController extends Controller { .map(async (posMaster) => { let posMasterOld: any = null; if (posMaster.next_holder != null) { - posMasterOld = posMasterOlds.find((posMasOld) => - posMasOld.current_holder == null - ? false - : posMasOld.current_holder.id === posMaster.next_holder.id, - ); + // posMasterOld = posMasterOlds.find((posMasOld) => + // posMasOld.current_holder == null + // ? false + // : posMasOld.current_holder.id === posMaster.next_holder.id, + // ); } let positionOld: any = null; if (posMasterOld != null) @@ -222,10 +222,10 @@ export class ReportController extends Controller { posMasterNoPrefix: posMaster.posMasterNoPrefix, posMasterNo: posMaster.posMasterNo, posMasterNoSuffix: posMaster.posMasterNoSuffix, - profileFullname: - posMaster.next_holder == null - ? null - : `${posMaster.next_holder.prefix}${posMaster.next_holder.firstName} ${posMaster.next_holder.lastName}`, + // profileFullname: + // posMaster.next_holder == null + // ? null + // : `${posMaster.next_holder.prefix}${posMaster.next_holder.firstName} ${posMaster.next_holder.lastName}`, profilePosMasterNo: posMasterOld == null ? null : posMasterOld.posMasterNo, profilePositionName: positionOld == null ? null : positionOld.positionName, profilePosType: positionOld == null ? null : positionOld.posType.posTypeName, @@ -268,11 +268,11 @@ export class ReportController extends Controller { .map(async (posMaster) => { let posMasterOld: any = null; if (posMaster.next_holder != null) { - posMasterOld = posMasterOlds.find((posMasOld) => - posMasOld.current_holder == null - ? false - : posMasOld.current_holder.id === posMaster.next_holder.id, - ); + // posMasterOld = posMasterOlds.find((posMasOld) => + // posMasOld.current_holder == null + // ? false + // : posMasOld.current_holder.id === posMaster.next_holder.id, + // ); } let positionOld: any = null; if (posMasterOld != null) @@ -283,10 +283,10 @@ export class ReportController extends Controller { posMasterNoPrefix: posMaster.posMasterNoPrefix, posMasterNo: posMaster.posMasterNo, posMasterNoSuffix: posMaster.posMasterNoSuffix, - fullname: - posMaster.next_holder == null - ? null - : `${posMaster.next_holder.prefix}${posMaster.next_holder.firstName} ${posMaster.next_holder.lastName}`, + // fullname: + // posMaster.next_holder == null + // ? null + // : `${posMaster.next_holder.prefix}${posMaster.next_holder.firstName} ${posMaster.next_holder.lastName}`, profilePosMasterNo: posMasterOld == null ? null : posMasterOld.posMasterNo, profilePositionName: @@ -335,11 +335,11 @@ export class ReportController extends Controller { .map(async (posMaster) => { let posMasterOld: any = null; if (posMaster.next_holder != null) { - posMasterOld = posMasterOlds.find((posMasOld) => - posMasOld.current_holder == null - ? false - : posMasOld.current_holder.id === posMaster.next_holder.id, - ); + // posMasterOld = posMasterOlds.find((posMasOld) => + // posMasOld.current_holder == null + // ? false + // : posMasOld.current_holder.id === posMaster.next_holder.id, + // ); } let positionOld: any = null; if (posMasterOld != null) @@ -350,10 +350,10 @@ export class ReportController extends Controller { posMasterNoPrefix: posMaster.posMasterNoPrefix, posMasterNo: posMaster.posMasterNo, posMasterNoSuffix: posMaster.posMasterNoSuffix, - fullname: - posMaster.next_holder == null - ? null - : `${posMaster.next_holder.prefix}${posMaster.next_holder.firstName} ${posMaster.next_holder.lastName}`, + // fullname: + // posMaster.next_holder == null + // ? null + // : `${posMaster.next_holder.prefix}${posMaster.next_holder.firstName} ${posMaster.next_holder.lastName}`, profilePosMasterNo: posMasterOld == null ? null : posMasterOld.posMasterNo, profilePositionName: @@ -404,12 +404,12 @@ export class ReportController extends Controller { .map(async (posMaster) => { let posMasterOld: any = null; if (posMaster.next_holder != null) { - posMasterOld = posMasterOlds.find((posMasOld) => - posMasOld.current_holder == null - ? false - : posMasOld.current_holder.id === - posMaster.next_holder.id, - ); + // posMasterOld = posMasterOlds.find((posMasOld) => + // posMasOld.current_holder == null + // ? false + // : posMasOld.current_holder.id === + // posMaster.next_holder.id, + // ); } let positionOld: any = null; if (posMasterOld != null) @@ -421,10 +421,10 @@ export class ReportController extends Controller { posMasterNoPrefix: posMaster.posMasterNoPrefix, posMasterNo: posMaster.posMasterNo, posMasterNoSuffix: posMaster.posMasterNoSuffix, - fullname: - posMaster.next_holder == null - ? null - : `${posMaster.next_holder.prefix}${posMaster.next_holder.firstName} ${posMaster.next_holder.lastName}`, + // fullname: + // posMaster.next_holder == null + // ? null + // : `${posMaster.next_holder.prefix}${posMaster.next_holder.firstName} ${posMaster.next_holder.lastName}`, profilePosMasterNo: posMasterOld == null ? null : posMasterOld.posMasterNo, profilePositionName: @@ -483,12 +483,12 @@ export class ReportController extends Controller { .map(async (posMaster) => { let posMasterOld: any = null; if (posMaster.next_holder != null) { - posMasterOld = posMasterOlds.find((posMasOld) => - posMasOld.current_holder == null - ? false - : posMasOld.current_holder.id === - posMaster.next_holder.id, - ); + // posMasterOld = posMasterOlds.find((posMasOld) => + // posMasOld.current_holder == null + // ? false + // : posMasOld.current_holder.id === + // posMaster.next_holder.id, + // ); } let positionOld: any = null; if (posMasterOld != null) @@ -500,10 +500,10 @@ export class ReportController extends Controller { posMasterNoPrefix: posMaster.posMasterNoPrefix, posMasterNo: posMaster.posMasterNo, posMasterNoSuffix: posMaster.posMasterNoSuffix, - fullname: - posMaster.next_holder == null - ? null - : `${posMaster.next_holder.prefix}${posMaster.next_holder.firstName} ${posMaster.next_holder.lastName}`, + // fullname: + // posMaster.next_holder == null + // ? null + // : `${posMaster.next_holder.prefix}${posMaster.next_holder.firstName} ${posMaster.next_holder.lastName}`, profilePosMasterNo: posMasterOld == null ? null diff --git a/src/migration/1707208924575-add_table_profile5.ts b/src/migration/1707208924575-add_table_profile5.ts new file mode 100644 index 00000000..d84f54bf --- /dev/null +++ b/src/migration/1707208924575-add_table_profile5.ts @@ -0,0 +1,40 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class AddTableProfile51707208924575 implements MigrationInterface { + name = 'AddTableProfile51707208924575' + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`posMaster\` DROP FOREIGN KEY \`FK_22499e79738c6873fc7ede3f6dd\``); + await queryRunner.query(`ALTER TABLE \`posMaster\` DROP FOREIGN KEY \`FK_9f765a0fef405dfafbd1b5f6c0a\``); + await queryRunner.query(`ALTER TABLE \`profile\` DROP FOREIGN KEY \`FK_ee79137a2909faa188c20a70413\``); + await queryRunner.query(`ALTER TABLE \`profile\` DROP FOREIGN KEY \`FK_c2ff3f61c281ece7f3ab5a2c20b\``); + await queryRunner.query(`DROP INDEX \`REL_22499e79738c6873fc7ede3f6d\` ON \`posMaster\``); + await queryRunner.query(`DROP INDEX \`REL_9f765a0fef405dfafbd1b5f6c0\` ON \`posMaster\``); + await queryRunner.query(`DROP INDEX \`IDX_c2ff3f61c281ece7f3ab5a2c20\` ON \`profile\``); + await queryRunner.query(`DROP INDEX \`IDX_ee79137a2909faa188c20a7041\` ON \`profile\``); + await queryRunner.query(`DROP INDEX \`REL_c2ff3f61c281ece7f3ab5a2c20\` ON \`profile\``); + await queryRunner.query(`DROP INDEX \`REL_ee79137a2909faa188c20a7041\` ON \`profile\``); + await queryRunner.query(`ALTER TABLE \`profile\` DROP COLUMN \`current_holderId\``); + await queryRunner.query(`ALTER TABLE \`profile\` DROP COLUMN \`next_holderId\``); + await queryRunner.query(`ALTER TABLE \`posMaster\` ADD CONSTRAINT \`FK_9f765a0fef405dfafbd1b5f6c0a\` FOREIGN KEY (\`current_holderId\`) REFERENCES \`posMaster\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE \`posMaster\` ADD CONSTRAINT \`FK_22499e79738c6873fc7ede3f6dd\` FOREIGN KEY (\`next_holderId\`) REFERENCES \`posMaster\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`posMaster\` DROP FOREIGN KEY \`FK_22499e79738c6873fc7ede3f6dd\``); + await queryRunner.query(`ALTER TABLE \`posMaster\` DROP FOREIGN KEY \`FK_9f765a0fef405dfafbd1b5f6c0a\``); + await queryRunner.query(`ALTER TABLE \`profile\` ADD \`next_holderId\` varchar(40) NULL COMMENT 'คนที่กำลังจะมาครอง ตอนปรับโครงสร้าง ถ้าเลือกให้ใครมาครอง ProfileId ของคนนั้นจะมาอยู่ในช่องนี้ รวมทั้งตอนเลือกตำแหน่งเพื่อบรรจุ แต่งตั้ง เลื่อน ย้าย ในระบบบรรจุแต่งตั้งด้วย'`); + await queryRunner.query(`ALTER TABLE \`profile\` ADD \`current_holderId\` varchar(40) NULL COMMENT 'คนครองปัจจุบัน เมื่อทำสำเนาโครงสร้างและตำแหน่งพร้อมกับคนครองมา คนครองจะอยู่ในฟิลด์นี้'`); + await queryRunner.query(`CREATE UNIQUE INDEX \`REL_ee79137a2909faa188c20a7041\` ON \`profile\` (\`current_holderId\`)`); + await queryRunner.query(`CREATE UNIQUE INDEX \`REL_c2ff3f61c281ece7f3ab5a2c20\` ON \`profile\` (\`next_holderId\`)`); + await queryRunner.query(`CREATE UNIQUE INDEX \`IDX_ee79137a2909faa188c20a7041\` ON \`profile\` (\`current_holderId\`)`); + await queryRunner.query(`CREATE UNIQUE INDEX \`IDX_c2ff3f61c281ece7f3ab5a2c20\` ON \`profile\` (\`next_holderId\`)`); + await queryRunner.query(`CREATE UNIQUE INDEX \`REL_9f765a0fef405dfafbd1b5f6c0\` ON \`posMaster\` (\`current_holderId\`)`); + await queryRunner.query(`CREATE UNIQUE INDEX \`REL_22499e79738c6873fc7ede3f6d\` ON \`posMaster\` (\`next_holderId\`)`); + await queryRunner.query(`ALTER TABLE \`profile\` ADD CONSTRAINT \`FK_c2ff3f61c281ece7f3ab5a2c20b\` FOREIGN KEY (\`next_holderId\`) REFERENCES \`posMaster\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE \`profile\` ADD CONSTRAINT \`FK_ee79137a2909faa188c20a70413\` FOREIGN KEY (\`current_holderId\`) REFERENCES \`posMaster\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE \`posMaster\` ADD CONSTRAINT \`FK_9f765a0fef405dfafbd1b5f6c0a\` FOREIGN KEY (\`current_holderId\`) REFERENCES \`profile\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE \`posMaster\` ADD CONSTRAINT \`FK_22499e79738c6873fc7ede3f6dd\` FOREIGN KEY (\`next_holderId\`) REFERENCES \`profile\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); + } + +}