From e28f65f5f4de6a53022c28fd5fbe4b03c2b493f7 Mon Sep 17 00:00:00 2001 From: AdisakKanthawilang Date: Mon, 24 Feb 2025 17:17:21 +0700 Subject: [PATCH 01/19] fix commandNo : type (String) --- src/entities/ProfileSalary.ts | 10 +++++----- src/entities/ProfileSalaryHistory.ts | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/entities/ProfileSalary.ts b/src/entities/ProfileSalary.ts index d4039270..4ff74553 100644 --- a/src/entities/ProfileSalary.ts +++ b/src/entities/ProfileSalary.ts @@ -36,7 +36,7 @@ export class ProfileSalary extends EntityBase { comment: "เลขที่คำสั่ง", default: null, }) - commandNo: number; + commandNo: string; @Column({ nullable: true, @@ -266,7 +266,7 @@ export class CreateProfileSalary { positionCee?: string | null; commandCode?: string | null; commandName?: string | null; - commandNo?: number | null; + commandNo?: string | null; commandYear?: number | null; } @@ -293,7 +293,7 @@ export class CreateProfileSalaryEmployee { positionCee?: string | null; commandCode?: string | null; commandName?: string | null; - commandNo?: number | null; + commandNo?: string | null; commandYear?: number | null; } @@ -318,7 +318,7 @@ export class UpdateProfileSalaryEmployee { positionCee?: string | null; commandCode?: string | null; commandName?: string | null; - commandNo?: number | null; + commandNo?: string | null; commandYear?: number | null; } @@ -344,6 +344,6 @@ export type UpdateProfileSalary = { positionCee?: string | null; commandCode?: string | null; commandName?: string | null; - commandNo?: number | null; + commandNo?: string | null; commandYear?: number | null; }; diff --git a/src/entities/ProfileSalaryHistory.ts b/src/entities/ProfileSalaryHistory.ts index de1c212e..bd6f54c6 100644 --- a/src/entities/ProfileSalaryHistory.ts +++ b/src/entities/ProfileSalaryHistory.ts @@ -17,7 +17,7 @@ export class ProfileSalaryHistory extends EntityBase { comment: "เลขที่คำสั่ง", default: null, }) - commandNo: number; + commandNo: string; @Column({ nullable: true, From 438e164fcb2d8fe719d2944b98ee7fba08dcac26 Mon Sep 17 00:00:00 2001 From: Bright Date: Mon, 24 Feb 2025 17:31:03 +0700 Subject: [PATCH 02/19] migrate --- src/entities/ProfileSalary.ts | 2 +- .../1740392430192-updateProfileSalary.ts | 20 +++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 src/migration/1740392430192-updateProfileSalary.ts diff --git a/src/entities/ProfileSalary.ts b/src/entities/ProfileSalary.ts index 4ff74553..2ef4b4cf 100644 --- a/src/entities/ProfileSalary.ts +++ b/src/entities/ProfileSalary.ts @@ -242,7 +242,7 @@ export class ProfileSalary extends EntityBase { } export class CreateProfileSalary { - profileId: string; + profileId: string | null; commandDateAffect?: Date | null; commandDateSign?: Date | null; amount?: Double | null; diff --git a/src/migration/1740392430192-updateProfileSalary.ts b/src/migration/1740392430192-updateProfileSalary.ts new file mode 100644 index 00000000..6671212f --- /dev/null +++ b/src/migration/1740392430192-updateProfileSalary.ts @@ -0,0 +1,20 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class UpdateProfileSalary1740392430192 implements MigrationInterface { + name = 'UpdateProfileSalary1740392430192' + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`profileSalaryHistory\` DROP COLUMN \`commandNo\``); + await queryRunner.query(`ALTER TABLE \`profileSalaryHistory\` ADD \`commandNo\` varchar(255) NULL COMMENT 'เลขที่คำสั่ง'`); + await queryRunner.query(`ALTER TABLE \`profileSalary\` DROP COLUMN \`commandNo\``); + await queryRunner.query(`ALTER TABLE \`profileSalary\` ADD \`commandNo\` varchar(255) NULL COMMENT 'เลขที่คำสั่ง'`); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`profileSalary\` DROP COLUMN \`commandNo\``); + await queryRunner.query(`ALTER TABLE \`profileSalary\` ADD \`commandNo\` int NULL COMMENT 'เลขที่คำสั่ง'`); + await queryRunner.query(`ALTER TABLE \`profileSalaryHistory\` DROP COLUMN \`commandNo\``); + await queryRunner.query(`ALTER TABLE \`profileSalaryHistory\` ADD \`commandNo\` int NULL COMMENT 'เลขที่คำสั่ง'`); + } + +} From b2650a6b7aa5e6fb6b3c2a1cf282e31f611f7f97 Mon Sep 17 00:00:00 2001 From: Bright Date: Mon, 24 Feb 2025 17:50:17 +0700 Subject: [PATCH 03/19] del migrate --- src/migration/1740366319309-update2242025.ts | 246 ------------------- 1 file changed, 246 deletions(-) delete mode 100644 src/migration/1740366319309-update2242025.ts diff --git a/src/migration/1740366319309-update2242025.ts b/src/migration/1740366319309-update2242025.ts deleted file mode 100644 index bbcd2248..00000000 --- a/src/migration/1740366319309-update2242025.ts +++ /dev/null @@ -1,246 +0,0 @@ -import { MigrationInterface, QueryRunner } from "typeorm"; - -export class Update22420251740366319309 implements MigrationInterface { - name = 'Update22420251740366319309' - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE \`OFFICER\` DROP COLUMN \`idOFFICER\``); - await queryRunner.query(`ALTER TABLE \`OFFICER\` DROP PRIMARY KEY`); - await queryRunner.query(`ALTER TABLE \`OFFICER\` DROP COLUMN \`ID\``); - await queryRunner.query(`ALTER TABLE \`OFFICER\` DROP COLUMN \`FLAG_PERSON_TYPE\``); - await queryRunner.query(`ALTER TABLE \`OFFICER\` DROP COLUMN \`RANK_CODE\``); - await queryRunner.query(`ALTER TABLE \`OFFICER\` DROP COLUMN \`FLAG_TYPE\``); - await queryRunner.query(`ALTER TABLE \`OFFICER\` DROP COLUMN \`RET_BORN_DATE\``); - await queryRunner.query(`ALTER TABLE \`OFFICER\` DROP COLUMN \`RET_BORN_YEAR\``); - await queryRunner.query(`ALTER TABLE \`OFFICER\` DROP COLUMN \`RETURN_OCCUPY_DATE\``); - await queryRunner.query(`ALTER TABLE \`OFFICER\` DROP COLUMN \`MP_FORCE_DATE\``); - await queryRunner.query(`ALTER TABLE \`OFFICER\` DROP COLUMN \`UPCLASS_DATE\``); - await queryRunner.query(`ALTER TABLE \`OFFICER\` DROP COLUMN \`WORK_LINE_DATE\``); - await queryRunner.query(`ALTER TABLE \`OFFICER\` DROP COLUMN \`FUND_COURSE_NAME\``); - await queryRunner.query(`ALTER TABLE \`OFFICER\` DROP COLUMN \`EDUCATION_NAME\``); - await queryRunner.query(`ALTER TABLE \`OFFICER\` DROP COLUMN \`MAJOR_CODE\``); - await queryRunner.query(`ALTER TABLE \`OFFICER\` DROP COLUMN \`MAJOR_NAME\``); - await queryRunner.query(`ALTER TABLE \`OFFICER\` DROP COLUMN \`UNIVER_NAME\``); - await queryRunner.query(`ALTER TABLE \`OFFICER\` DROP COLUMN \`POSITION_CATG\``); - await queryRunner.query(`ALTER TABLE \`OFFICER\` DROP COLUMN \`WORK_LINE_CODE\``); - await queryRunner.query(`ALTER TABLE \`OFFICER\` DROP COLUMN \`MP_CEE_NAME\``); - await queryRunner.query(`ALTER TABLE \`OFFICER\` DROP COLUMN \`MP_CEE\``); - await queryRunner.query(`ALTER TABLE \`OFFICER\` DROP COLUMN \`ADMIN_CODE\``); - await queryRunner.query(`ALTER TABLE \`OFFICER\` DROP COLUMN \`ADMIN_NAME\``); - await queryRunner.query(`ALTER TABLE \`OFFICER\` DROP COLUMN \`SALARY_LEVEL_CODE\``); - await queryRunner.query(`ALTER TABLE \`OFFICER\` DROP COLUMN \`SALARY_POS_ABB_NAME\``); - await queryRunner.query(`ALTER TABLE \`OFFICER\` DROP COLUMN \`SAL_POS_AMOUNT_2\``); - await queryRunner.query(`ALTER TABLE \`OFFICER\` DROP COLUMN \`SPECIALIST_CODE\``); - await queryRunner.query(`ALTER TABLE \`OFFICER\` DROP COLUMN \`SPECIALIST_DATE\``); - await queryRunner.query(`ALTER TABLE \`OFFICER\` DROP COLUMN \`SALARY_POS_ABB_NAME_1\``); - await queryRunner.query(`ALTER TABLE \`OFFICER\` DROP COLUMN \`SAL_POS_AMOUNT_1\``); - await queryRunner.query(`ALTER TABLE \`OFFICER\` DROP COLUMN \`ADMIN_DATE\``); - await queryRunner.query(`ALTER TABLE \`OFFICER\` DROP COLUMN \`MP_FLAG\``); - await queryRunner.query(`ALTER TABLE \`OFFICER\` DROP COLUMN \`SALARY_ADD\``); - await queryRunner.query(`ALTER TABLE \`OFFICER\` DROP COLUMN \`SPECIAL_PERCENT\``); - await queryRunner.query(`ALTER TABLE \`OFFICER\` DROP COLUMN \`SPECIAL_AMT\``); - await queryRunner.query(`ALTER TABLE \`OFFICER\` DROP COLUMN \`PAYMENT_AMT\``); - await queryRunner.query(`ALTER TABLE \`OFFICER\` DROP COLUMN \`PAYMENT_PERCENT\``); - await queryRunner.query(`ALTER TABLE \`OFFICER\` DROP COLUMN \`MP_FLAG_1\``); - await queryRunner.query(`ALTER TABLE \`OFFICER\` DROP COLUMN \`COST_LIVING_AMOUNT\``); - await queryRunner.query(`ALTER TABLE \`OFFICER\` DROP COLUMN \`DEPARTMENT_CODE\``); - await queryRunner.query(`ALTER TABLE \`OFFICER\` DROP COLUMN \`DIVISION_CODE\``); - await queryRunner.query(`ALTER TABLE \`OFFICER\` DROP COLUMN \`SECTION_CODE\``); - await queryRunner.query(`ALTER TABLE \`OFFICER\` DROP COLUMN \`JOB_CODE\``); - await queryRunner.query(`ALTER TABLE \`OFFICER\` DROP COLUMN \`FLAG_CUR_ST\``); - await queryRunner.query(`ALTER TABLE \`OFFICER\` DROP COLUMN \`POS_NUM_CODE_SIT\``); - await queryRunner.query(`ALTER TABLE \`OFFICER\` DROP COLUMN \`MP_COMMAND_NUM\``); - await queryRunner.query(`ALTER TABLE \`OFFICER\` DROP COLUMN \`MP_COMMAND_DATE\``); - await queryRunner.query(`ALTER TABLE \`OFFICER\` DROP COLUMN \`FLAG_TO_NAME_CODE\``); - await queryRunner.query(`ALTER TABLE \`OFFICER\` DROP COLUMN \`MP_POS_DATE\``); - await queryRunner.query(`ALTER TABLE \`OFFICER\` DROP COLUMN \`MP_YEAR\``); - await queryRunner.query(`ALTER TABLE \`OFFICER\` DROP COLUMN \`RET_BORN_MP_YEAR\``); - await queryRunner.query(`ALTER TABLE \`OFFICER\` DROP COLUMN \`SALARY_POS_CODE\``); - await queryRunner.query(`ALTER TABLE \`OFFICER\` DROP COLUMN \`SALARY_POS_CODE_1\``); - await queryRunner.query(`ALTER TABLE \`OFFICER\` DROP COLUMN \`CUR_YEAR\``); - await queryRunner.query(`ALTER TABLE \`OFFICER\` DROP COLUMN \`FLAG_TO_NAME\``); - await queryRunner.query(`ALTER TABLE \`OFFICER\` DROP COLUMN \`POS_NUM_CODE_SIT_ABB\``); - await queryRunner.query(`ALTER TABLE \`OFFICER\` DROP COLUMN \`POS_NUM_CODE_SIT_CODE\``); - await queryRunner.query(`ALTER TABLE \`OFFICER\` DROP COLUMN \`CONTENT_NO\``); - await queryRunner.query(`ALTER TABLE \`OFFICER\` DROP COLUMN \`POS_NUM_CODE_SIT_O\``); - await queryRunner.query(`ALTER TABLE \`OFFICER\` DROP COLUMN \`POS_NUM_CODE_SIT_ABB_O\``); - await queryRunner.query(`ALTER TABLE \`OFFICER\` DROP COLUMN \`POS_NUM_CODE_SIT_CODE_O\``); - await queryRunner.query(`ALTER TABLE \`OFFICER\` DROP COLUMN \`MP_COMMAND_NUM_O\``); - await queryRunner.query(`ALTER TABLE \`OFFICER\` DROP COLUMN \`CUR_YEAR_O\``); - await queryRunner.query(`ALTER TABLE \`OFFICER\` DROP COLUMN \`MP_YEAR_O\``); - await queryRunner.query(`ALTER TABLE \`OFFICER\` DROP COLUMN \`FLAG_TO_NAME_CODE_O\``); - await queryRunner.query(`ALTER TABLE \`OFFICER\` DROP COLUMN \`FLAG_TO_NAME_O\``); - await queryRunner.query(`ALTER TABLE \`OFFICER\` DROP COLUMN \`MP_COMMAND_DATE_O\``); - await queryRunner.query(`ALTER TABLE \`OFFICER\` DROP COLUMN \`MP_POS_DATE_O\``); - await queryRunner.query(`ALTER TABLE \`OFFICER\` DROP COLUMN \`MP_FLAG_O\``); - await queryRunner.query(`ALTER TABLE \`OFFICER\` DROP COLUMN \`MP_FLAG_1_O\``); - await queryRunner.query(`ALTER TABLE \`OFFICER\` DROP COLUMN \`MP_CEE_O\``); - await queryRunner.query(`ALTER TABLE \`OFFICER\` DROP COLUMN \`SALARY_LEVEL_CODE_O\``); - await queryRunner.query(`ALTER TABLE \`OFFICER\` DROP COLUMN \`SALARY_O\``); - await queryRunner.query(`ALTER TABLE \`OFFICER\` DROP COLUMN \`SPECIAL_AMT_O\``); - await queryRunner.query(`ALTER TABLE \`OFFICER\` DROP COLUMN \`SALARY_ADD_O\``); - await queryRunner.query(`ALTER TABLE \`OFFICER\` DROP COLUMN \`MP_CEE_CODE\``); - await queryRunner.query(`ALTER TABLE \`OFFICER\` DROP COLUMN \`SALARY_LEVEL\``); - await queryRunner.query(`ALTER TABLE \`OFFICER\` DROP COLUMN \`MP_CEE_CODE_O\``); - await queryRunner.query(`ALTER TABLE \`OFFICER\` DROP COLUMN \`SALARY_LEVEL_O\``); - await queryRunner.query(`ALTER TABLE \`OFFICER\` DROP COLUMN \`GROUPWORK_CODE\``); - await queryRunner.query(`ALTER TABLE \`OFFICER\` DROP COLUMN \`WORK_LINE_CODE_O\``); - await queryRunner.query(`ALTER TABLE \`OFFICER\` DROP COLUMN \`WORK_LINE_NAME_O\``); - await queryRunner.query(`ALTER TABLE \`OFFICER\` DROP COLUMN \`FLAG_RETIRE_STATUS\``); - await queryRunner.query(`ALTER TABLE \`OFFICER\` DROP COLUMN \`MARRIAGE_STATE\``); - await queryRunner.query(`ALTER TABLE \`OFFICER\` DROP COLUMN \`SUN_NO\``); - await queryRunner.query(`ALTER TABLE \`OFFICER\` DROP COLUMN \`RETIRE_TYPE_CODE\``); - await queryRunner.query(`ALTER TABLE \`OFFICER\` DROP COLUMN \`RETIRE_POS_NO\``); - await queryRunner.query(`ALTER TABLE \`OFFICER\` DROP COLUMN \`DEXPIRE_DATE\``); - await queryRunner.query(`ALTER TABLE \`OFFICER\` DROP COLUMN \`HELP_LIVING_AMOUNT\``); - await queryRunner.query(`ALTER TABLE \`OFFICER\` DROP COLUMN \`OLD_RETIRE_DEPARTMENT_CODE\``); - await queryRunner.query(`ALTER TABLE \`OFFICER\` DROP COLUMN \`OLD_RETIRE_DIVISION_CODE\``); - await queryRunner.query(`ALTER TABLE \`OFFICER\` DROP COLUMN \`OLD_RETIRE_SECTION_CODE\``); - await queryRunner.query(`ALTER TABLE \`OFFICER\` DROP COLUMN \`OLD_RETIRE_JOB_CODE\``); - await queryRunner.query(`ALTER TABLE \`OFFICER\` DROP COLUMN \`CREATE_DATE\``); - await queryRunner.query(`ALTER TABLE \`OFFICER\` DROP COLUMN \`UPDATE_DATE\``); - await queryRunner.query(`ALTER TABLE \`HR_PERSONAL_EMP_ADDRESS\` DROP COLUMN \`STREET\``); - await queryRunner.query(`ALTER TABLE \`HR_PERSONAL_EMP_ADDRESS\` DROP COLUMN \`TEL\``); - await queryRunner.query(`ALTER TABLE \`HR_PERSONAL_EMP_ADDRESS\` DROP COLUMN \`CONTACT_STREET\``); - await queryRunner.query(`ALTER TABLE \`HR_PERSONAL_EMP_ADDRESS\` DROP COLUMN \`CONTACT_TEL\``); - await queryRunner.query(`ALTER TABLE \`HR_PERSONAL_EMP_FAMILY\` DROP COLUMN \`FATHER_RANK_CODE\``); - await queryRunner.query(`ALTER TABLE \`HR_PERSONAL_EMP_FAMILY\` DROP COLUMN \`MOTHER_RANK_CODE\``); - await queryRunner.query(`ALTER TABLE \`HR_PERSONAL_EMP_FAMILY\` DROP COLUMN \`SPOUSE_RANK_CODE\``); - await queryRunner.query(`ALTER TABLE \`HR_PERSONAL_EMP_FAMILY\` DROP COLUMN \`LIFE_SPOUSE\``); - await queryRunner.query(`ALTER TABLE \`HR_PERSONAL_EMP_FAMILY\` DROP COLUMN \`SUN_NO\``); - await queryRunner.query(`ALTER TABLE \`HR_EDUCATION_EMP\` DROP COLUMN \`FLAG_EDUCATION\``); - await queryRunner.query(`ALTER TABLE \`HR_EDUCATION_EMP\` DROP COLUMN \`MAJOR_CODE\``); - await queryRunner.query(`ALTER TABLE \`HR_EDUCATION_EMP\` DROP COLUMN \`MINOR_CODE\``); - await queryRunner.query(`ALTER TABLE \`HR_EDUCATION_EMP\` DROP COLUMN \`FUND_COURSE_CODE\``); - await queryRunner.query(`ALTER TABLE \`OFFICER\` ADD \`id\` int NOT NULL PRIMARY KEY AUTO_INCREMENT`); - await queryRunner.query(`ALTER TABLE \`positionOfficer\` DROP COLUMN \`id\``); - await queryRunner.query(`ALTER TABLE \`positionOfficer\` ADD \`id\` int NOT NULL PRIMARY KEY AUTO_INCREMENT`); - await queryRunner.query(`ALTER TABLE \`positionOfficer\` DROP COLUMN \`order_move_position\``); - await queryRunner.query(`ALTER TABLE \`positionOfficer\` ADD \`order_move_position\` text NULL`); - await queryRunner.query(`ALTER TABLE \`HR_EDUCATION\` DROP COLUMN \`EDUCATION_SEQ\``); - await queryRunner.query(`ALTER TABLE \`HR_EDUCATION\` ADD \`EDUCATION_SEQ\` varchar(255) NULL`); - await queryRunner.query(`ALTER TABLE \`HR_EDUCATION_EMP\` DROP COLUMN \`EDUCATION_SEQ\``); - await queryRunner.query(`ALTER TABLE \`HR_EDUCATION_EMP\` ADD \`EDUCATION_SEQ\` varchar(255) NULL`); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE \`HR_EDUCATION_EMP\` DROP COLUMN \`EDUCATION_SEQ\``); - await queryRunner.query(`ALTER TABLE \`HR_EDUCATION_EMP\` ADD \`EDUCATION_SEQ\` mediumtext NULL`); - await queryRunner.query(`ALTER TABLE \`HR_EDUCATION\` DROP COLUMN \`EDUCATION_SEQ\``); - await queryRunner.query(`ALTER TABLE \`HR_EDUCATION\` ADD \`EDUCATION_SEQ\` text NULL`); - await queryRunner.query(`ALTER TABLE \`positionOfficer\` DROP COLUMN \`order_move_position\``); - await queryRunner.query(`ALTER TABLE \`positionOfficer\` ADD \`order_move_position\` int NULL`); - await queryRunner.query(`ALTER TABLE \`positionOfficer\` DROP COLUMN \`id\``); - await queryRunner.query(`ALTER TABLE \`positionOfficer\` ADD \`id\` int NOT NULL DEFAULT '0'`); - await queryRunner.query(`ALTER TABLE \`OFFICER\` DROP COLUMN \`id\``); - await queryRunner.query(`ALTER TABLE \`HR_EDUCATION_EMP\` ADD \`FUND_COURSE_CODE\` mediumtext NULL`); - await queryRunner.query(`ALTER TABLE \`HR_EDUCATION_EMP\` ADD \`MINOR_CODE\` mediumtext NULL`); - await queryRunner.query(`ALTER TABLE \`HR_EDUCATION_EMP\` ADD \`MAJOR_CODE\` mediumtext NULL`); - await queryRunner.query(`ALTER TABLE \`HR_EDUCATION_EMP\` ADD \`FLAG_EDUCATION\` mediumtext NULL`); - await queryRunner.query(`ALTER TABLE \`HR_PERSONAL_EMP_FAMILY\` ADD \`SUN_NO\` mediumtext NULL`); - await queryRunner.query(`ALTER TABLE \`HR_PERSONAL_EMP_FAMILY\` ADD \`LIFE_SPOUSE\` mediumtext NULL`); - await queryRunner.query(`ALTER TABLE \`HR_PERSONAL_EMP_FAMILY\` ADD \`SPOUSE_RANK_CODE\` mediumtext NULL`); - await queryRunner.query(`ALTER TABLE \`HR_PERSONAL_EMP_FAMILY\` ADD \`MOTHER_RANK_CODE\` mediumtext NULL`); - await queryRunner.query(`ALTER TABLE \`HR_PERSONAL_EMP_FAMILY\` ADD \`FATHER_RANK_CODE\` mediumtext NULL`); - await queryRunner.query(`ALTER TABLE \`HR_PERSONAL_EMP_ADDRESS\` ADD \`CONTACT_TEL\` mediumtext NULL`); - await queryRunner.query(`ALTER TABLE \`HR_PERSONAL_EMP_ADDRESS\` ADD \`CONTACT_STREET\` mediumtext NULL`); - await queryRunner.query(`ALTER TABLE \`HR_PERSONAL_EMP_ADDRESS\` ADD \`TEL\` mediumtext NULL`); - await queryRunner.query(`ALTER TABLE \`HR_PERSONAL_EMP_ADDRESS\` ADD \`STREET\` mediumtext NULL`); - await queryRunner.query(`ALTER TABLE \`OFFICER\` ADD \`UPDATE_DATE\` text NULL`); - await queryRunner.query(`ALTER TABLE \`OFFICER\` ADD \`CREATE_DATE\` text NULL`); - await queryRunner.query(`ALTER TABLE \`OFFICER\` ADD \`OLD_RETIRE_JOB_CODE\` text NULL`); - await queryRunner.query(`ALTER TABLE \`OFFICER\` ADD \`OLD_RETIRE_SECTION_CODE\` text NULL`); - await queryRunner.query(`ALTER TABLE \`OFFICER\` ADD \`OLD_RETIRE_DIVISION_CODE\` text NULL`); - await queryRunner.query(`ALTER TABLE \`OFFICER\` ADD \`OLD_RETIRE_DEPARTMENT_CODE\` text NULL`); - await queryRunner.query(`ALTER TABLE \`OFFICER\` ADD \`HELP_LIVING_AMOUNT\` text NULL`); - await queryRunner.query(`ALTER TABLE \`OFFICER\` ADD \`DEXPIRE_DATE\` text NULL`); - await queryRunner.query(`ALTER TABLE \`OFFICER\` ADD \`RETIRE_POS_NO\` text NULL`); - await queryRunner.query(`ALTER TABLE \`OFFICER\` ADD \`RETIRE_TYPE_CODE\` text NULL`); - await queryRunner.query(`ALTER TABLE \`OFFICER\` ADD \`SUN_NO\` text NULL`); - await queryRunner.query(`ALTER TABLE \`OFFICER\` ADD \`MARRIAGE_STATE\` text NULL`); - await queryRunner.query(`ALTER TABLE \`OFFICER\` ADD \`FLAG_RETIRE_STATUS\` text NULL`); - await queryRunner.query(`ALTER TABLE \`OFFICER\` ADD \`WORK_LINE_NAME_O\` text NULL`); - await queryRunner.query(`ALTER TABLE \`OFFICER\` ADD \`WORK_LINE_CODE_O\` text NULL`); - await queryRunner.query(`ALTER TABLE \`OFFICER\` ADD \`GROUPWORK_CODE\` text NULL`); - await queryRunner.query(`ALTER TABLE \`OFFICER\` ADD \`SALARY_LEVEL_O\` text NULL`); - await queryRunner.query(`ALTER TABLE \`OFFICER\` ADD \`MP_CEE_CODE_O\` text NULL`); - await queryRunner.query(`ALTER TABLE \`OFFICER\` ADD \`SALARY_LEVEL\` text NULL`); - await queryRunner.query(`ALTER TABLE \`OFFICER\` ADD \`MP_CEE_CODE\` text NULL`); - await queryRunner.query(`ALTER TABLE \`OFFICER\` ADD \`SALARY_ADD_O\` text NULL`); - await queryRunner.query(`ALTER TABLE \`OFFICER\` ADD \`SPECIAL_AMT_O\` text NULL`); - await queryRunner.query(`ALTER TABLE \`OFFICER\` ADD \`SALARY_O\` text NULL`); - await queryRunner.query(`ALTER TABLE \`OFFICER\` ADD \`SALARY_LEVEL_CODE_O\` text NULL`); - await queryRunner.query(`ALTER TABLE \`OFFICER\` ADD \`MP_CEE_O\` text NULL`); - await queryRunner.query(`ALTER TABLE \`OFFICER\` ADD \`MP_FLAG_1_O\` text NULL`); - await queryRunner.query(`ALTER TABLE \`OFFICER\` ADD \`MP_FLAG_O\` text NULL`); - await queryRunner.query(`ALTER TABLE \`OFFICER\` ADD \`MP_POS_DATE_O\` text NULL`); - await queryRunner.query(`ALTER TABLE \`OFFICER\` ADD \`MP_COMMAND_DATE_O\` text NULL`); - await queryRunner.query(`ALTER TABLE \`OFFICER\` ADD \`FLAG_TO_NAME_O\` text NULL`); - await queryRunner.query(`ALTER TABLE \`OFFICER\` ADD \`FLAG_TO_NAME_CODE_O\` text NULL`); - await queryRunner.query(`ALTER TABLE \`OFFICER\` ADD \`MP_YEAR_O\` text NULL`); - await queryRunner.query(`ALTER TABLE \`OFFICER\` ADD \`CUR_YEAR_O\` text NULL`); - await queryRunner.query(`ALTER TABLE \`OFFICER\` ADD \`MP_COMMAND_NUM_O\` text NULL`); - await queryRunner.query(`ALTER TABLE \`OFFICER\` ADD \`POS_NUM_CODE_SIT_CODE_O\` text NULL`); - await queryRunner.query(`ALTER TABLE \`OFFICER\` ADD \`POS_NUM_CODE_SIT_ABB_O\` text NULL`); - await queryRunner.query(`ALTER TABLE \`OFFICER\` ADD \`POS_NUM_CODE_SIT_O\` text NULL`); - await queryRunner.query(`ALTER TABLE \`OFFICER\` ADD \`CONTENT_NO\` text NULL`); - await queryRunner.query(`ALTER TABLE \`OFFICER\` ADD \`POS_NUM_CODE_SIT_CODE\` text NULL`); - await queryRunner.query(`ALTER TABLE \`OFFICER\` ADD \`POS_NUM_CODE_SIT_ABB\` text NULL`); - await queryRunner.query(`ALTER TABLE \`OFFICER\` ADD \`FLAG_TO_NAME\` text NULL`); - await queryRunner.query(`ALTER TABLE \`OFFICER\` ADD \`CUR_YEAR\` text NULL`); - await queryRunner.query(`ALTER TABLE \`OFFICER\` ADD \`SALARY_POS_CODE_1\` text NULL`); - await queryRunner.query(`ALTER TABLE \`OFFICER\` ADD \`SALARY_POS_CODE\` text NULL`); - await queryRunner.query(`ALTER TABLE \`OFFICER\` ADD \`RET_BORN_MP_YEAR\` text NULL`); - await queryRunner.query(`ALTER TABLE \`OFFICER\` ADD \`MP_YEAR\` text NULL`); - await queryRunner.query(`ALTER TABLE \`OFFICER\` ADD \`MP_POS_DATE\` text NULL`); - await queryRunner.query(`ALTER TABLE \`OFFICER\` ADD \`FLAG_TO_NAME_CODE\` text NULL`); - await queryRunner.query(`ALTER TABLE \`OFFICER\` ADD \`MP_COMMAND_DATE\` text NULL`); - await queryRunner.query(`ALTER TABLE \`OFFICER\` ADD \`MP_COMMAND_NUM\` text NULL`); - await queryRunner.query(`ALTER TABLE \`OFFICER\` ADD \`POS_NUM_CODE_SIT\` text NULL`); - await queryRunner.query(`ALTER TABLE \`OFFICER\` ADD \`FLAG_CUR_ST\` text NULL`); - await queryRunner.query(`ALTER TABLE \`OFFICER\` ADD \`JOB_CODE\` text NULL`); - await queryRunner.query(`ALTER TABLE \`OFFICER\` ADD \`SECTION_CODE\` text NULL`); - await queryRunner.query(`ALTER TABLE \`OFFICER\` ADD \`DIVISION_CODE\` text NULL`); - await queryRunner.query(`ALTER TABLE \`OFFICER\` ADD \`DEPARTMENT_CODE\` text NULL`); - await queryRunner.query(`ALTER TABLE \`OFFICER\` ADD \`COST_LIVING_AMOUNT\` text NULL`); - await queryRunner.query(`ALTER TABLE \`OFFICER\` ADD \`MP_FLAG_1\` text NULL`); - await queryRunner.query(`ALTER TABLE \`OFFICER\` ADD \`PAYMENT_PERCENT\` text NULL`); - await queryRunner.query(`ALTER TABLE \`OFFICER\` ADD \`PAYMENT_AMT\` text NULL`); - await queryRunner.query(`ALTER TABLE \`OFFICER\` ADD \`SPECIAL_AMT\` text NULL`); - await queryRunner.query(`ALTER TABLE \`OFFICER\` ADD \`SPECIAL_PERCENT\` text NULL`); - await queryRunner.query(`ALTER TABLE \`OFFICER\` ADD \`SALARY_ADD\` text NULL`); - await queryRunner.query(`ALTER TABLE \`OFFICER\` ADD \`MP_FLAG\` text NULL`); - await queryRunner.query(`ALTER TABLE \`OFFICER\` ADD \`ADMIN_DATE\` text NULL`); - await queryRunner.query(`ALTER TABLE \`OFFICER\` ADD \`SAL_POS_AMOUNT_1\` text NULL`); - await queryRunner.query(`ALTER TABLE \`OFFICER\` ADD \`SALARY_POS_ABB_NAME_1\` text NULL`); - await queryRunner.query(`ALTER TABLE \`OFFICER\` ADD \`SPECIALIST_DATE\` text NULL`); - await queryRunner.query(`ALTER TABLE \`OFFICER\` ADD \`SPECIALIST_CODE\` text NULL`); - await queryRunner.query(`ALTER TABLE \`OFFICER\` ADD \`SAL_POS_AMOUNT_2\` text NULL`); - await queryRunner.query(`ALTER TABLE \`OFFICER\` ADD \`SALARY_POS_ABB_NAME\` text NULL`); - await queryRunner.query(`ALTER TABLE \`OFFICER\` ADD \`SALARY_LEVEL_CODE\` text NULL`); - await queryRunner.query(`ALTER TABLE \`OFFICER\` ADD \`ADMIN_NAME\` text NULL`); - await queryRunner.query(`ALTER TABLE \`OFFICER\` ADD \`ADMIN_CODE\` text NULL`); - await queryRunner.query(`ALTER TABLE \`OFFICER\` ADD \`MP_CEE\` text NULL`); - await queryRunner.query(`ALTER TABLE \`OFFICER\` ADD \`MP_CEE_NAME\` text NULL`); - await queryRunner.query(`ALTER TABLE \`OFFICER\` ADD \`WORK_LINE_CODE\` text NULL`); - await queryRunner.query(`ALTER TABLE \`OFFICER\` ADD \`POSITION_CATG\` text NULL`); - await queryRunner.query(`ALTER TABLE \`OFFICER\` ADD \`UNIVER_NAME\` text NULL`); - await queryRunner.query(`ALTER TABLE \`OFFICER\` ADD \`MAJOR_NAME\` text NULL`); - await queryRunner.query(`ALTER TABLE \`OFFICER\` ADD \`MAJOR_CODE\` text NULL`); - await queryRunner.query(`ALTER TABLE \`OFFICER\` ADD \`EDUCATION_NAME\` text NULL`); - await queryRunner.query(`ALTER TABLE \`OFFICER\` ADD \`FUND_COURSE_NAME\` text NULL`); - await queryRunner.query(`ALTER TABLE \`OFFICER\` ADD \`WORK_LINE_DATE\` text NULL`); - await queryRunner.query(`ALTER TABLE \`OFFICER\` ADD \`UPCLASS_DATE\` text NULL`); - await queryRunner.query(`ALTER TABLE \`OFFICER\` ADD \`MP_FORCE_DATE\` text NULL`); - await queryRunner.query(`ALTER TABLE \`OFFICER\` ADD \`RETURN_OCCUPY_DATE\` text NULL`); - await queryRunner.query(`ALTER TABLE \`OFFICER\` ADD \`RET_BORN_YEAR\` text NULL`); - await queryRunner.query(`ALTER TABLE \`OFFICER\` ADD \`RET_BORN_DATE\` text NULL`); - await queryRunner.query(`ALTER TABLE \`OFFICER\` ADD \`FLAG_TYPE\` text NULL`); - await queryRunner.query(`ALTER TABLE \`OFFICER\` ADD \`RANK_CODE\` text NULL`); - await queryRunner.query(`ALTER TABLE \`OFFICER\` ADD \`FLAG_PERSON_TYPE\` text NULL`); - await queryRunner.query(`ALTER TABLE \`OFFICER\` ADD \`ID\` varchar(13) NOT NULL`); - await queryRunner.query(`ALTER TABLE \`OFFICER\` ADD PRIMARY KEY (\`ID\`)`); - await queryRunner.query(`ALTER TABLE \`OFFICER\` ADD \`idOFFICER\` int NULL`); - } - -} From 240f2aab7e8020fb040143982fa285edf3930e15 Mon Sep 17 00:00:00 2001 From: Bright Date: Tue, 25 Feb 2025 11:02:12 +0700 Subject: [PATCH 04/19] fix issue #1194 --- src/controllers/ProfileEmployeeController.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/controllers/ProfileEmployeeController.ts b/src/controllers/ProfileEmployeeController.ts index fbc05caa..1d9eee4e 100644 --- a/src/controllers/ProfileEmployeeController.ts +++ b/src/controllers/ProfileEmployeeController.ts @@ -2443,7 +2443,9 @@ export class ProfileEmployeeController extends Controller { dateRetireLaw: profile.dateRetireLaw, posMaster: posMaster == null ? null : posMaster.posMasterNo, posMasterNo: posMaster == null ? null : posMaster.posMasterNo, - posLevelName: profile.posLevel == null ? null : profile.posLevel.posLevelName, + posLevelName: profile.posLevel == null && profile.posType == null + ? null + : `${profile.posType.posTypeShortName} ${profile.posLevel.posLevelName}`, posLevelRank: profile.posLevel == null ? null : profile.posLevel.posLevelRank, posLevelId: profile.posLevel == null ? null : profile.posLevel.id, posTypeName: profile.posType == null ? null : profile.posType.posTypeName, From ece5bbf051811ecd8cde792f18f8d83ac5d53455 Mon Sep 17 00:00:00 2001 From: Bright Date: Tue, 25 Feb 2025 11:30:45 +0700 Subject: [PATCH 05/19] fix posLevel --- src/controllers/ProfileGovernmentEmployeeController.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/controllers/ProfileGovernmentEmployeeController.ts b/src/controllers/ProfileGovernmentEmployeeController.ts index d8db83ed..5dabc746 100644 --- a/src/controllers/ProfileGovernmentEmployeeController.ts +++ b/src/controllers/ProfileGovernmentEmployeeController.ts @@ -111,7 +111,7 @@ export class ProfileGovernmentEmployeeController extends Controller { posLevel: record.posType == null && record.posLevel == null ? null - : `${record.posType.posTypeShortName}${record.posLevel.posLevelName}`, //ระดับ + : `${record.posType.posTypeShortName} ${record.posLevel.posLevelName}`, //ระดับ posMasterNo: posMaster == null ? null : `${orgShortName} ${posMaster.posMasterNo}`, //เลขที่ตำแหน่ง posType: record.posType == null ? null : record.posType.posTypeName, //ประเภท dateLeave: record.birthDate == null ? null : calculateRetireDate(record.birthDate), @@ -299,7 +299,9 @@ export class ProfileGovernmentEmployeeController extends Controller { const data = { org: org, //สังกัด position: record.position, //ตำแหน่ง - posLevel: record.posLevel == null ? null : record.posLevel.posLevelName, //ระดับ + posLevel: record.posLevel == null && record.posType == null + ? null + : `${record.posType.posTypeShortName} ${record.posLevel.posLevelName}`, //ระดับ posMasterNo: posMaster == null ? null : `${orgShortName} ${posMaster.posMasterNo}`, //เลขที่ตำแหน่ง posType: record.posType == null ? null : record.posType.posTypeName, //ประเภท dateLeave: record.birthDate == null ? null : calculateRetireDate(record.birthDate), //วันเกษียณ From f93b22c661e4945ef597c1d9dc3dd21f7ed61042 Mon Sep 17 00:00:00 2001 From: kittapath Date: Tue, 25 Feb 2025 11:53:29 +0700 Subject: [PATCH 06/19] =?UTF-8?q?=E0=B9=81=E0=B8=81=E0=B9=89=E0=B8=84?= =?UTF-8?q?=E0=B8=B3=E0=B8=AA=E0=B8=B1=E0=B9=88=E0=B8=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/CommandController.ts | 32 ++++++++++++++-------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/controllers/CommandController.ts b/src/controllers/CommandController.ts index 74be9cb5..aa3209e7 100644 --- a/src/controllers/CommandController.ts +++ b/src/controllers/CommandController.ts @@ -3451,8 +3451,8 @@ export class CommandController extends Controller { isGovernment: item.isGovernment, commandNo: item.commandNo, commandYear: item.commandYear, - posNo: shortName, - posNoAbb: posNo, + posNo: posNo, + posNoAbb: shortName, commandDateAffect: item.commandDateAffect, commandDateSign: item.commandDateSign, commandCode: item.commandCode, @@ -3638,8 +3638,8 @@ export class CommandController extends Controller { isGovernment: item.isGovernment, commandNo: item.commandNo, commandYear: item.commandYear, - posNo: shortName, - posNoAbb: posNo, + posNo: posNo, + posNoAbb: shortName, commandDateAffect: item.commandDateAffect, commandDateSign: item.commandDateSign, commandCode: item.commandCode, @@ -3867,8 +3867,8 @@ export class CommandController extends Controller { isGovernment: item.isGovernment, commandNo: item.commandNo, commandYear: item.commandYear, - posNo: shortName, - posNoAbb: posNo, + posNo: posNo, + posNoAbb: shortName, commandDateAffect: item.commandDateAffect, commandDateSign: item.commandDateSign, commandCode: item.commandCode, @@ -4091,8 +4091,8 @@ export class CommandController extends Controller { lastUpdatedAt: new Date(), commandNo: item.commandNo, commandYear: item.commandYear, - posNo: shortName, - posNoAbb: posNo, + posNo: posNo, + posNoAbb: shortName, commandDateAffect: item.commandDateAffect, commandDateSign: item.commandDateSign, commandCode: item.commandCode, @@ -4266,8 +4266,8 @@ export class CommandController extends Controller { isGovernment: item.isGovernment, commandNo: item.commandNo, commandYear: item.commandYear, - posNo: shortName, - posNoAbb: posNo, + posNo: posNo, + posNoAbb: shortName, commandDateAffect: item.commandDateAffect, commandDateSign: item.commandDateSign, commandCode: item.commandCode, @@ -4794,8 +4794,8 @@ export class CommandController extends Controller { lastUpdatedAt: new Date(), commandNo: item.commandNo, commandYear: item.commandYear, - posNo: orgShortName, - posNoAbb: profile.posMasterNoTemp ?? "", + posNo: profile.posMasterNoTemp ?? "", + posNoAbb: orgShortName, commandDateAffect: item.commandDateAffect, commandDateSign: item.commandDateSign, commandCode: item.commandCode, @@ -5048,8 +5048,8 @@ export class CommandController extends Controller { lastUpdatedAt: new Date(), commandNo: body.refIds[0].commandNo, commandYear: body.refIds[0].commandYear, - posNo: shortName, - posNoAbb: item.posMaster.posMasterNo, + posNo: item.posMaster.posMasterNo, + posNoAbb: shortName, commandDateAffect: body.refIds[0].commandDateAffect, commandDateSign: body.refIds[0].commandDateSign, commandCode: body.refIds[0].commandCode, @@ -5293,8 +5293,8 @@ export class CommandController extends Controller { lastUpdatedAt: new Date(), commandNo: item.commandNo, commandYear: item.commandYear, - posNo: shortName, - posNoAbb: posMaster.posMasterNo, + posNo: posMaster.posMasterNo, + posNoAbb: shortName, commandDateAffect: item.commandDateAffect, commandDateSign: item.commandDateSign, commandCode: item.commandCode, From 257411fe19db7001bbe6531253805f0d48a976b7 Mon Sep 17 00:00:00 2001 From: Bright Date: Tue, 25 Feb 2025 18:11:20 +0700 Subject: [PATCH 07/19] fix issue #1217 --- src/controllers/ProfileEmployeeController.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/controllers/ProfileEmployeeController.ts b/src/controllers/ProfileEmployeeController.ts index 1d9eee4e..0d76392c 100644 --- a/src/controllers/ProfileEmployeeController.ts +++ b/src/controllers/ProfileEmployeeController.ts @@ -2806,7 +2806,9 @@ export class ProfileEmployeeController extends Controller { name: fullName, birthDate: item.birthDate, positionLevel: item.posLevelId, - positionLevelName: item.posLevel?.posLevelName, + positionLevelName: item.posLevel == null && item.posType == null + ? null + : `${item.posType?.posTypeShortName} ${item.posLevel?.posLevelName}`, positionType: item.posTypeId, positionTypeName: item.posType?.posTypeName, posNo: shortName, @@ -4625,7 +4627,9 @@ export class ProfileEmployeeController extends Controller { name: fullName, birthDate: item.birthDate, positionLevel: item.posLevelId, - positionLevelName: item.posLevel?.posLevelName, + positionLevelName: item.posLevel == null && item.posType == null + ? null + : `${item.posType?.posTypeShortName} ${item.posLevel?.posLevelName}`, positionType: item.posTypeId, positionTypeName: item.posType?.posTypeName, posNo: shortName, From 3836062c1036f4d868c7b52b2b845f1e182f2a83 Mon Sep 17 00:00:00 2001 From: Bright Date: Tue, 25 Feb 2025 18:24:38 +0700 Subject: [PATCH 08/19] fix issue #1217 --- src/controllers/ProfileEmployeeController.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/controllers/ProfileEmployeeController.ts b/src/controllers/ProfileEmployeeController.ts index 0d76392c..9669f637 100644 --- a/src/controllers/ProfileEmployeeController.ts +++ b/src/controllers/ProfileEmployeeController.ts @@ -2806,9 +2806,7 @@ export class ProfileEmployeeController extends Controller { name: fullName, birthDate: item.birthDate, positionLevel: item.posLevelId, - positionLevelName: item.posLevel == null && item.posType == null - ? null - : `${item.posType?.posTypeShortName} ${item.posLevel?.posLevelName}`, + positionLevelName: item.posLevel?.posLevelName, positionType: item.posTypeId, positionTypeName: item.posType?.posTypeName, posNo: shortName, @@ -2838,7 +2836,9 @@ export class ProfileEmployeeController extends Controller { posTypeId: item.posTypeId, posTypeName: item.posType?.posTypeName, posLevelId: item.posLevelId, - posLevelName: item.posLevel?.posLevelName, + posLevelName: item.posLevel == null && item.posType == null + ? null + : `${item.posType?.posTypeShortName} ${item.posLevel?.posLevelName}`, educationDegree: latestProfileEducation != null && latestProfileEducation.educationLevel != null ? latestProfileEducation.educationLevel @@ -4627,9 +4627,7 @@ export class ProfileEmployeeController extends Controller { name: fullName, birthDate: item.birthDate, positionLevel: item.posLevelId, - positionLevelName: item.posLevel == null && item.posType == null - ? null - : `${item.posType?.posTypeShortName} ${item.posLevel?.posLevelName}`, + positionLevelName: item.posLevel?.posLevelName, positionType: item.posTypeId, positionTypeName: item.posType?.posTypeName, posNo: shortName, @@ -4639,7 +4637,9 @@ export class ProfileEmployeeController extends Controller { posTypeId: item.posTypeId, posTypeName: item.posType?.posTypeName, posLevelId: item.posLevelId, - posLevelName: item.posLevel?.posLevelName, + posLevelName: item.posLevel == null && item.posType == null + ? null + : `${item.posType?.posTypeShortName} ${item.posLevel?.posLevelName}`, educationDegree: latestProfileEducation != null && latestProfileEducation.educationLevel != null ? latestProfileEducation.educationLevel From a890b8f06eff20d73307a1eda44d5bdb8166f65b Mon Sep 17 00:00:00 2001 From: AdisakKanthawilang Date: Wed, 26 Feb 2025 14:11:58 +0700 Subject: [PATCH 09/19] fix report --- src/controllers/CommandController.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/controllers/CommandController.ts b/src/controllers/CommandController.ts index 74be9cb5..4c524fe6 100644 --- a/src/controllers/CommandController.ts +++ b/src/controllers/CommandController.ts @@ -3423,6 +3423,7 @@ export class CommandController extends Controller { profileId: profile.id, commandId: item.commandId, position: profile.position, + positionName: profile.position, positionType: profile?.posType?.posTypeName ?? null, positionLevel: profile?.posLevel?.posLevelName ?? null, positionExecutive: position?.posExecutive?.posExecutiveName ?? null, @@ -3612,6 +3613,7 @@ export class CommandController extends Controller { profileEmployeeId: profile.id, commandId: item.commandId, position: profile.position, + positionName: profile.position, positionType: profile?.posType?.posTypeName ?? null, positionLevel: profile?.posLevel?.posLevelName ?? null, amount: item.amount ? item.amount : null, From 2d1fc8b05ff4eb3086b16ccc0e2e64f9d9778a20 Mon Sep 17 00:00:00 2001 From: kittapath Date: Wed, 26 Feb 2025 15:45:45 +0700 Subject: [PATCH 10/19] update commander-director-position --- src/controllers/ImportDataController.ts | 351 ++++++++++++++++++++++-- src/controllers/ProfileController.ts | 3 +- src/entities/ProfileSalary.ts | 14 + 3 files changed, 337 insertions(+), 31 deletions(-) diff --git a/src/controllers/ImportDataController.ts b/src/controllers/ImportDataController.ts index d4f3fe24..a0004ba8 100644 --- a/src/controllers/ImportDataController.ts +++ b/src/controllers/ImportDataController.ts @@ -47,7 +47,8 @@ import { OFFICER } from "../entities/OFFICER"; import { Position } from "../entities/Position"; import { PosMaster } from "../entities/PosMaster"; import { positionOfficer } from "../entities/positionOfficer"; -// import { uuidv7 } from "uuidv7"; +import { uuidv7 } from "uuidv7"; +import { ProfileSalaries } from "../entities/ProfileSalaries"; @Route("api/v1/org/upload") @Tags("UPLOAD") @Security("bearerAuth") @@ -62,6 +63,7 @@ export class ImportDataController extends Controller { private posLevelRepo = AppDataSource.getRepository(PosLevel); private posTypeRepo = AppDataSource.getRepository(PosType); private positionOfficerRepo = AppDataSource.getRepository(positionOfficer); + private ProfileSalariesRepo = AppDataSource.getRepository(ProfileSalaries); private HR_PERSONAL_OFFICER_FAMILYRepo = AppDataSource.getRepository(HR_PERSONAL_OFFICER_FAMILY); private HR_EDUCATIONRepo = AppDataSource.getRepository(HR_EDUCATION); private HR_PERSONAL_OFFICER_ADDRESSRepo = AppDataSource.getRepository( @@ -330,13 +332,29 @@ export class ImportDataController extends Controller { .select(["profile.citizenId", "profile.id"]) .orderBy("profile.citizenId", "ASC") // .where("profile.citizenId = '3101702379675'") - .skip(0) - .take(10000) + .where({ + citizenId: In([ + // "1100600109451", + // "1209900075508", + // "1739900231556", + // "1809900305214", + // "1920600228762", + // "3101600963742", + // "3102401171243", + // "3120100454406", + // "3180100306172", + // "3700100094722", + // "3809900116957", + "3940900213929", + ]), + }) + // .skip(10000) + // .take(20000) .getManyAndCount(); var _profiles: ProfileSalary[] = []; - const filePath = path.join(__dirname, "salaryProfile.csv"); + const filePath = path.join(__dirname, "salaryProfile1.csv"); // CSV Header - let csvData = `"id","createdAt","createdUserId","lastUpdatedAt","lastUpdateUserId","createdFullName","lastUpdateFullName","profileId","profileEmployeeId","order","commandNo","commandYear","commandDateSign","commandDateAffect","commandCode","commandName","posNoAbb","posNo","positionName","positionType","positionLevel","positionCee","orgRoot","orgChild1","orgChild2","orgChild3","orgChild4","positionExecutive","amount","amountSpecial","positionSalaryAmount","mouthSalaryAmount","remark","dateGovernment","isGovernment","commandId"\n`; + let csvData = `"id","createdAt","createdUserId","lastUpdatedAt","lastUpdateUserId","createdFullName","lastUpdateFullName","profileId","profileEmployeeId","order","commandNo","commandYear","commandDateSign","commandDateAffect","commandCode","commandName","posNoAbb","posNo","positionName","positionType","positionLevel","positionCee","orgRoot","orgChild1","orgChild2","orgChild3","orgChild4","positionExecutive","amount","amountSpecial","positionSalaryAmount","mouthSalaryAmount","remark","dateGovernment","isGovernment","commandId","refId"\n`; fs.appendFile(filePath, csvData, (err) => { if (err) { @@ -364,8 +382,20 @@ export class ImportDataController extends Controller { order = order + 1; profileSalary.commandNo = item.mp_command_num; profileSalary.commandYear = item.cur_year > 2500 ? item.cur_year - 543 : item.cur_year; - profileSalary.commandDateSign = item.mp_command_date; - profileSalary.commandDateAffect = item.mp_pos_date; + profileSalary.commandDateSign = + item.mp_command_date == null + ? null_ + : new Date(item.mp_command_date.setDate(item.mp_command_date.getDate() + 1)) + .toISOString() + .replace("T", " ") + .substring(0, 19); + profileSalary.commandDateAffect = + item.mp_pos_date == null + ? null_ + : new Date(item.mp_pos_date.setDate(item.mp_pos_date.getDate() + 1)) + .toISOString() + .replace("T", " ") + .substring(0, 19); if ( [ "0", @@ -445,52 +475,203 @@ export class ImportDataController extends Controller { profileSalary.commandName = "รักษาราชการ, ช่วยราชการ"; } if ( - item.flag_to_name == "" && - (item.flag_to_name_code == "เลื่อน 1 ขั้นและเลื่อนระดับ" || - item.flag_to_name_code == "เลื่อน 0.5 ขั้นและเลื่อนระดับ" || - item.flag_to_name_code == "ลาศึกษาต่อ") + item.flag_to_name_code == null && + (item.flag_to_name == "เลื่อน 1 ขั้นและเลื่อนระดับ" || + item.flag_to_name == "เลื่อน 0.5 ขั้นและเลื่อนระดับ" || + item.flag_to_name == "ลาศึกษาต่อ") ) { profileSalary.commandCode = "0"; profileSalary.commandName = "อื่น ๆ"; - } else if (item.flag_to_name == "" && item.flag_to_name_code == "เลื่อนเงินเดือน") { + } else if (item.flag_to_name_code == null && item.flag_to_name == "เลื่อนเงินเดือน") { profileSalary.commandCode = "5"; profileSalary.commandName = "เลื่อนเงินเดือนตามปกติ"; } else if ( - item.flag_to_name == "" && - (item.flag_to_name_code == "ปรับตามบัญชีเงินเดือนใหม่" || - item.flag_to_name_code == "เลื่อนเงินเดือน" || - item.flag_to_name_code == "ปรับเงินเดือนตาม กพ.") + item.flag_to_name_code == null && + (item.flag_to_name == "ปรับตามบัญชีเงินเดือนใหม่" || + item.flag_to_name == "เลื่อนเงินเดือน" || + item.flag_to_name == "ปรับเงินเดือนตาม กพ.") ) { profileSalary.commandCode = "6"; profileSalary.commandName = "เลื่อนเงินเดือนกรณีอื่น ๆ"; } else if ( - item.flag_to_name == "" && - item.flag_to_name_code == "แต่งตั้งตามการปรับปรุงโครงฯ" + item.flag_to_name_code == null && + item.flag_to_name == "แต่งตั้งตามการปรับปรุงโครงฯ" ) { profileSalary.commandCode = "8"; profileSalary.commandName = "ปรับโครงสร้าง"; } else if ( - item.flag_to_name == "" && - item.flag_to_name_code == "พ้นทดลองปฏิบัติราชการ" + item.flag_to_name_code == null && + item.flag_to_name == "พ้นทดลองปฏิบัติราชการ" ) { profileSalary.commandCode = "9"; profileSalary.commandName = "พ้นทดลองปฏิบัติราชการ"; - } else if (item.flag_to_name == "" && item.flag_to_name_code == "ให้โอนมา") { + } else if (item.flag_to_name_code == null && item.flag_to_name == "ให้โอนมา") { profileSalary.commandCode = "11"; profileSalary.commandName = "รับโอน"; } else if ( - item.flag_to_name == "" && - item.flag_to_name_code == "โอนไปปฏิบัติราชการที่อื่น" + item.flag_to_name_code == null && + item.flag_to_name == "โอนไปปฏิบัติราชการที่อื่น" ) { profileSalary.commandCode = "12"; profileSalary.commandName = "ให้โอน"; - } else if (item.flag_to_name == "" && item.flag_to_name_code == "ยกเลิกคำสั่ง") { + } else if (item.flag_to_name_code == null && item.flag_to_name == "ยกเลิกคำสั่ง") { profileSalary.commandCode = "14"; profileSalary.commandName = "ยกเลิกคำสั่ง"; - } else if (item.flag_to_name == "" && item.flag_to_name_code == "รักษาการในตำแหน่ง") { + } else if (item.flag_to_name_code == null && item.flag_to_name == "รักษาการในตำแหน่ง") { profileSalary.commandCode = "17"; profileSalary.commandName = "รักษาราชการ, ช่วยราชการ"; } + if ( + (profileSalary.commandCode == null || profileSalary.commandCode == undefined) && + (profileSalary.commandName == null || profileSalary.commandName == undefined) + ) { + if ( + [ + "อื่นๆ", + "กลับไปปฏิบัติงานทางต้นสังกัด", + "เปลี่ยนประเภทข้าราชการ", + "โอนสับเปลี่ยน", + "เข้ารับฝึกอบรม", + "ดูงาน", + "ศึกษาต่อ", + "ขยายเวลาเข้ารับการฝึกอบรม", + "ขยายเวลาศึกษาต่อ", + "รายงานตัวกลับเข้าปฏิบัติราชการ", + "ไม่ได้เลื่อนขั้น", + "เลือนเงินเดือนและระดับ", + "เลื่อนเงินเดือนและระดับ", + "ตัดเงินเดือน", + "ลดขั้นเงินเดือน", + "ให้ข้าราชการกลับเข้ารับราชการ", + "ไม่ระบุ", + ].includes(item.flag_to_name) + ) { + profileSalary.commandCode = "0"; + profileSalary.commandName = "อื่น ๆ"; + } else if ( + [ + "บรรจุและแต่งตั้งผู้สอบแข่งขันได้", + "ทดลองปฎิบัติราชการ", + "ทดลองปฏิบัติราชการและปรับวุฒิ", + "บรรจุใหม่", + ].includes(item.flag_to_name) + ) { + profileSalary.commandCode = "1"; + profileSalary.commandName = "บรรจุและแต่งตั้งผู้สอบแข่งขันได้"; + } else if (["บรรจุและแต่งตั้งผู้ได้รับการคัดเลือก"].includes(item.flag_to_name)) { + profileSalary.commandCode = "2"; + profileSalary.commandName = "บรรจุและแต่งตั้งผู้ได้รับคัดเลือก"; + } else if ( + [ + "แต่งตั้ง (ย้ายสับเปลี่ยน)", + "แต่งตั้ง (ย้าย)", + "แต่งตั้ง", + "เปลี่ยนสายงาน", + "เปลี่ยนตำแหน่ง", + "ตัดโอนตำแหน่ง", + ].includes(item.flag_to_name) + ) { + profileSalary.commandCode = "3"; + profileSalary.commandName = "แต่งตั้ง ย้าย"; + } else if (["เลื่อนและแต่งตั้ง", "เลื่อนระดับ"].includes(item.flag_to_name)) { + profileSalary.commandCode = "4"; + profileSalary.commandName = "เลื่อน"; + } else if (["เลื่อนขั้นเงินเดือน", "เลื่อนเงินเดือน"].includes(item.flag_to_name)) { + profileSalary.commandCode = "5"; + profileSalary.commandName = "เลื่อนเงินเดือนตามปกติ"; + } else if ( + [ + "ปรับเงินเดือนตามคุณวุฒิ", + "ได้รับเงินตอบแทนพิเศษ", + "เงินเพิ่มการครองชีพชั่วคราว", + "เลื่อนขั้นเงินเดือนกรณีพิเศษ", + "ปรับอัตราเงินเดือนตามบัญชีอัตราเงินเดือนใหม่ ท้าย พ.ร.บ. เงินเดือนและเงินประจำตำ", + "ปรับอัตราเงินเดือนตามพระราชกฤษฎีกา การปรับอัตราเงินเดือนของข้าราชการ", + "เลื่อนขั้นเงินเดือน (เพิ่มเติม)", + "ปรับอัตราเงินเดือน", + "ให้ข้าราชการได้รับเงินเดือนตามคุณวุฒิ", + ].includes(item.flag_to_name) + ) { + profileSalary.commandCode = "6"; + profileSalary.commandName = "เลื่อนเงินเดือนกรณีอื่น ๆ"; + } else if (["--"].includes(item.flag_to_name)) { + profileSalary.commandCode = "7"; + profileSalary.commandName = "เงินพิเศษอื่น ๆ"; + } else if ( + ["ปรับโครงสร้าง", "แต่งตั้ง (จัดคนลงกรอบ)", "แต่งตั้งตามแผนอัตรากำลังฯ"].includes( + item.flag_to_name, + ) + ) { + profileSalary.commandCode = "8"; + profileSalary.commandName = "ปรับโครงสร้าง"; + } else if (["พ้นทดลองปฏิบัติราชการ"].includes(item.flag_to_name)) { + profileSalary.commandCode = "9"; + profileSalary.commandName = "พ้นทดลองปฏิบัติราชการ"; + } else if ( + [ + "บรรจุกลับ", + "บรรจุกลับข้าราชการ", + "บรรจุและแต่งตั้งผู้ไปรับราชการทหารกลับเข้ารับราชการ", + ].includes(item.flag_to_name) + ) { + profileSalary.commandCode = "10"; + profileSalary.commandName = "บรรจุกลับ"; + } else if ( + [ + "รับโอนข้าราชการตามกฎหมายอื่น", + "รับโอนข้าราชการตามกฎหมายอื่น ผู้สอบแข่งขันได้", + "รับโอนข้าราชการตามกฏหมายอื่น โดยการคัดเลือก", + ].includes(item.flag_to_name) + ) { + profileSalary.commandCode = "11"; + profileSalary.commandName = "รับโอน"; + } else if (["ให้โอน"].includes(item.flag_to_name)) { + profileSalary.commandCode = "12"; + profileSalary.commandName = "ให้โอน"; + } else if (["แก้ไขคำสั่ง"].includes(item.flag_to_name)) { + profileSalary.commandCode = "13"; + profileSalary.commandName = "แก้ไขคำสั่ง"; + } else if (["ยกเลิกคำสั่ง"].includes(item.flag_to_name)) { + profileSalary.commandCode = "14"; + profileSalary.commandName = "ยกเลิกคำสั่ง"; + } else if ( + [ + "ลาออกจากราชการ", + "พ้นจากราชการ/ลาออกจากราชการตามมาตรการพัฒนาและบริหารกำลังคน", + ].includes(item.flag_to_name) + ) { + profileSalary.commandCode = "15"; + profileSalary.commandName = "ลาออกจากราชการ"; + } else if ( + [ + "พ้นจากราชการ/เพื่อไปปฏิบัติราชการทหาร", + "เกษียณ", + "ไม่พ้นทดลองปฏิบัติราชการ", + "พ้นจากราชการ/ให้ออก", + "พ้นจากราชการ/ไล่ออก", + "พ้นจากราชการ/เสียชีวิต", + "พ้นจากราชการ/ปลดออก", + ].includes(item.flag_to_name) + ) { + profileSalary.commandCode = "16"; + profileSalary.commandName = "พ้นจากราชการ"; + } else if ( + [ + "แต่งตั้งข้าราชการรักษาราชการแทน", + "ช่วยราชการ", + "รักษาการ", + "รักษาราชการแทน", + "มอบหมายให้ปฏิบัติหน้าที่", + "มอบหมายข้าราชการปฏิบัติหน้าที่แทน", + ].includes(item.flag_to_name) + ) { + profileSalary.commandCode = "17"; + profileSalary.commandName = "รักษาราชการ, ช่วยราชการ"; + } else { + profileSalary.commandCode = "0"; + profileSalary.commandName = item.flag_to_name; + } + } profileSalary.posNoAbb = item.pos_num_name; profileSalary.posNo = item.pos_num_code; profileSalary.positionName = item.work_line_name; @@ -558,6 +739,8 @@ export class ImportDataController extends Controller { profileSalary.positionExecutive = item.admin_name; profileSalary.amount = item.salary; profileSalary.remark = item.remark; + profileSalary.refId = item.id; + profileSalary.isEntry = false; const sal_pos_amount_1: any = item.sal_pos_amount_1 == null || item.sal_pos_amount_1 == "" @@ -576,10 +759,10 @@ export class ImportDataController extends Controller { profileSalary.createdFullName = request.user.name; profileSalary.lastUpdateUserId = request.user.sub; profileSalary.lastUpdateFullName = request.user.name; - profileSalary.createdAt = new Date(); - profileSalary.lastUpdatedAt = new Date(); - // const result = uuidv7(); - // profileSalary.id = result; + profileSalary.createdAt = new Date().toISOString().split("T")[0]; + profileSalary.lastUpdatedAt = new Date().toISOString().split("T")[0]; + const result = uuidv7(); + profileSalary.id = result; // console.log(">>>>>>>>>>>>>>>>>>>" + rowCount); // // Generate SQL INSERT Statement using TypeORM QueryBuilder but don't execute it @@ -599,7 +782,8 @@ export class ImportDataController extends Controller { // Loop through each salary profile and format data as CSV // _profiles.forEach((profile) => { - csvData = `"${profileSalary.id || "NULL"}","${profileSalary.createdAt?.toISOString()?.split("T")[0] || "NULL"}","${profileSalary.createdUserId || "NULL"}","${profileSalary.lastUpdatedAt?.toISOString()?.split("T")[0] || "NULL"}","${profileSalary.lastUpdateUserId || "NULL"}","${profileSalary.createdFullName || "NULL"}","${profileSalary.lastUpdateFullName || "NULL"}","${profileSalary.profileId || "NULL"}","${profileSalary.profileEmployeeId || "NULL"}","${profileSalary.order || "NULL"}","${profileSalary.commandNo || "NULL"}","${profileSalary.commandYear || "NULL"}","${profileSalary.commandDateSign?.toISOString()?.split("T")[0] || "NULL"}","${profileSalary.commandDateAffect?.toISOString()?.split("T")[0] || "NULL"}","${profileSalary.commandCode || "NULL"}","${profileSalary.commandName || "NULL"}","${profileSalary.posNoAbb || "NULL"}","${profileSalary.posNo || "NULL"}","${profileSalary.positionName || "NULL"}","${profileSalary.positionType || "NULL"}","${profileSalary.positionLevel || "NULL"}","${profileSalary.positionCee || "NULL"}","${profileSalary.orgRoot || "NULL"}","${profileSalary.orgChild1 || "NULL"}","${profileSalary.orgChild2 || "NULL"}","${profileSalary.orgChild3 || "NULL"}","${profileSalary.orgChild4 || "NULL"}","${profileSalary.positionExecutive || "NULL"}","${profileSalary.amount || 0}","${profileSalary.amountSpecial || 0}","${profileSalary.positionSalaryAmount || 0}","${profileSalary.mouthSalaryAmount || 0}","${profileSalary.remark || "NULL"}","${profileSalary.dateGovernment?.toISOString()?.split("T")[0] || "NULL"}","${profileSalary.isGovernment || "NULL"}","${profileSalary.commandId || "NULL"}"\n`; + console.log(profileSalary.commandDateSign); + csvData = `"${profileSalary.id || "NULL"}","${profileSalary.createdAt || "NULL"}","${profileSalary.createdUserId || "NULL"}","${profileSalary.lastUpdatedAt || "NULL"}","${profileSalary.lastUpdateUserId || "NULL"}","${profileSalary.createdFullName || "NULL"}","${profileSalary.lastUpdateFullName || "NULL"}","${profileSalary.profileId || "NULL"}","${profileSalary.profileEmployeeId || "NULL"}","${profileSalary.order || "NULL"}","${profileSalary.commandNo || "NULL"}","${profileSalary.commandYear || "NULL"}","${profileSalary.commandDateSign || "NULL"}","${profileSalary.commandDateAffect || "NULL"}","${profileSalary.commandCode || "NULL"}","${profileSalary.commandName || "NULL"}","${profileSalary.posNoAbb || "NULL"}","${profileSalary.posNo || "NULL"}","${profileSalary.positionName || "NULL"}","${profileSalary.positionType || "NULL"}","${profileSalary.positionLevel || "NULL"}","${profileSalary.positionCee || "NULL"}","${profileSalary.orgRoot || "NULL"}","${profileSalary.orgChild1 || "NULL"}","${profileSalary.orgChild2 || "NULL"}","${profileSalary.orgChild3 || "NULL"}","${profileSalary.orgChild4 || "NULL"}","${profileSalary.positionExecutive || "NULL"}","${profileSalary.amount || 0}","${profileSalary.amountSpecial || 0}","${profileSalary.positionSalaryAmount || 0}","${profileSalary.mouthSalaryAmount || 0}","${profileSalary.remark || "NULL"}","${profileSalary.dateGovernment || "NULL"}","${profileSalary.isGovernment || "NULL"}","${profileSalary.commandId || "NULL"}","${profileSalary.refId || "NULL"}"\n`; // }); // Write the CSV data to the file @@ -1693,6 +1877,7 @@ export class ImportDataController extends Controller { }, }); + //order xxxxxxxxxxxxxxxx await Promise.all( IMPORT_CHILD.map(async (item) => { const orgRoot = new OrgRoot(); @@ -2092,4 +2277,110 @@ export class ImportDataController extends Controller { } return new HttpSuccess(); } + + /** + * @summary เงินเดือน ข้าราชการ + */ + @Post("uploadProfileSalary-OfficerEntry") + async UploadFileSQLSalaryEntry(@Request() request: { user: Record }) { + let rowCount = 0; + let null_: any = null; + let sqlStatements: string[] = []; + + const [profiles, total] = await AppDataSource.getRepository(Profile) + .createQueryBuilder("profile") + .select(["profile.citizenId", "profile.id"]) + .orderBy("profile.citizenId", "ASC") + // .where("profile.citizenId = '3101702379675'") + .skip(10000) + .take(20000) + .getManyAndCount(); + var _profiles: ProfileSalary[] = []; + const filePath = path.join(__dirname, "salaryProfile1.csv"); + // CSV Header + let csvData = `"id","createdAt","createdUserId","lastUpdatedAt","lastUpdateUserId","createdFullName","lastUpdateFullName","profileId","profileEmployeeId","order","commandNo","commandYear","commandDateSign","commandDateAffect","commandCode","commandName","posNoAbb","posNo","positionName","positionType","positionLevel","positionCee","orgRoot","orgChild1","orgChild2","orgChild3","orgChild4","positionExecutive","amount","amountSpecial","positionSalaryAmount","mouthSalaryAmount","remark","dateGovernment","isGovernment","commandId"\n`; + + fs.appendFile(filePath, csvData, (err) => { + if (err) { + console.error("Error writing CSV file:", err); + } else { + console.log("Salary profiles successfully written to salaryProfile.csv"); + } + }); + await Promise.all( + profiles.map(async (_item) => { + const existingProfile = await this.ProfileSalariesRepo.find({ + where: { ProfileId: _item.citizenId }, + order: { + Order: "ASC", + }, + }); + let order = 1; + await Promise.all( + existingProfile.map(async (item) => { + rowCount++; + const profileSalary: any = new ProfileSalary(); + profileSalary.profileId = _item.id; + profileSalary.order = item.Order; + + profileSalary.commandDateAffect = + item.Date == null + ? null_ + : new Date(item.Date.setDate(item.Date.getDate() + 1)) + .toISOString() + .replace("T", " ") + .substring(0, 19); + profileSalary.remark = item.SalaryRef + item.PositionName; + profileSalary.amount = item.Amount; + profileSalary.positionSalaryAmount = item.PositionSalaryAmount; + const str = item.PosNoName; + const parts = str.split(" "); + if (parts.length > 1) { + const posNo = parts.at(-1); + const posNoAbb = parts.slice(0, -1).join(" "); + profileSalary.posNoAbb = posNoAbb; + profileSalary.posNo = posNo; + } + profileSalary.posLevel = this.canConvertToInt(item.PositionLevelName) + ? null_ + : item.PositionLevelName; + profileSalary.posCee = this.canConvertToInt(item.PositionLevelName) + ? item.PositionLevelName + : null_; + //xxxxxxxxxxxxxxxxx + profileSalary.posType = item.PositionTypeName; + profileSalary.isEntry = true; + + profileSalary.createdUserId = request.user.sub; + profileSalary.createdFullName = request.user.name; + profileSalary.lastUpdateUserId = request.user.sub; + profileSalary.lastUpdateFullName = request.user.name; + profileSalary.createdAt = new Date().toISOString().split("T")[0]; + profileSalary.lastUpdatedAt = new Date().toISOString().split("T")[0]; + const result = uuidv7(); + profileSalary.id = result; + + console.log(profileSalary.commandDateSign); + csvData = `"${profileSalary.id || "NULL"}","${profileSalary.createdAt || "NULL"}","${profileSalary.createdUserId || "NULL"}","${profileSalary.lastUpdatedAt || "NULL"}","${profileSalary.lastUpdateUserId || "NULL"}","${profileSalary.createdFullName || "NULL"}","${profileSalary.lastUpdateFullName || "NULL"}","${profileSalary.profileId || "NULL"}","${profileSalary.profileEmployeeId || "NULL"}","${profileSalary.order || "NULL"}","${profileSalary.commandNo || "NULL"}","${profileSalary.commandYear || "NULL"}","${profileSalary.commandDateSign || "NULL"}","${profileSalary.commandDateAffect || "NULL"}","${profileSalary.commandCode || "NULL"}","${profileSalary.commandName || "NULL"}","${profileSalary.posNoAbb || "NULL"}","${profileSalary.posNo || "NULL"}","${profileSalary.positionName || "NULL"}","${profileSalary.positionType || "NULL"}","${profileSalary.positionLevel || "NULL"}","${profileSalary.positionCee || "NULL"}","${profileSalary.orgRoot || "NULL"}","${profileSalary.orgChild1 || "NULL"}","${profileSalary.orgChild2 || "NULL"}","${profileSalary.orgChild3 || "NULL"}","${profileSalary.orgChild4 || "NULL"}","${profileSalary.positionExecutive || "NULL"}","${profileSalary.amount || 0}","${profileSalary.amountSpecial || 0}","${profileSalary.positionSalaryAmount || 0}","${profileSalary.mouthSalaryAmount || 0}","${profileSalary.remark || "NULL"}","${profileSalary.dateGovernment || "NULL"}","${profileSalary.isGovernment || "NULL"}","${profileSalary.commandId || "NULL"}"\n`; + + fs.appendFile(filePath, csvData.replace('"NULL"', "NULL"), (err) => { + if (err) { + console.error("Error writing CSV file:", err); + } else { + console.log( + "Salary profiles successfully written to salaryProfile.csv: " + rowCount, + ); + } + }); + }), + ); + order = 1; + }), + ); + return new HttpSuccess(); + } + canConvertToInt(str: string) { + const num = Number(str); + return Number.isInteger(num); + } } diff --git a/src/controllers/ProfileController.ts b/src/controllers/ProfileController.ts index ec74fe15..f640b697 100644 --- a/src/controllers/ProfileController.ts +++ b/src/controllers/ProfileController.ts @@ -1739,7 +1739,8 @@ export class ProfileController extends Controller { orgRevision: { orgRevisionIsDraft: false, orgRevisionIsCurrent: true }, }, }); - return new HttpSuccess({ data: [], total: 0 }); + if (!posMaster) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลการครองตำแหน่ง"); + // return new HttpSuccess({ data: [], total: 0 }); } else if ((posMaster?.current_holder?.posLevel?.posLevelAuthority ?? null) == "GOVERNOR") { return new HttpSuccess({ data: [], total: 0 }); } diff --git a/src/entities/ProfileSalary.ts b/src/entities/ProfileSalary.ts index 2ef4b4cf..3411ed37 100644 --- a/src/entities/ProfileSalary.ts +++ b/src/entities/ProfileSalary.ts @@ -203,6 +203,13 @@ export class ProfileSalary extends EntityBase { }) remark: string; + @Column({ + nullable: true, + comment: "refId", + default: null, + }) + refId: number; + @Column({ comment: "วันที่", type: "datetime", @@ -217,6 +224,13 @@ export class ProfileSalary extends EntityBase { }) isGovernment: boolean; + @Column({ + nullable: true, + comment: "ข้อมูลจาก Entry", + default: null, + }) + isEntry: boolean; + @Column({ nullable: true, length: 40, From 34bc897c04decce0ded9d13f2159529125cc0eb4 Mon Sep 17 00:00:00 2001 From: kittapath Date: Wed, 26 Feb 2025 15:54:09 +0700 Subject: [PATCH 11/19] edit build --- src/controllers/ImportDataController.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/controllers/ImportDataController.ts b/src/controllers/ImportDataController.ts index a0004ba8..79bbbf58 100644 --- a/src/controllers/ImportDataController.ts +++ b/src/controllers/ImportDataController.ts @@ -47,7 +47,7 @@ import { OFFICER } from "../entities/OFFICER"; import { Position } from "../entities/Position"; import { PosMaster } from "../entities/PosMaster"; import { positionOfficer } from "../entities/positionOfficer"; -import { uuidv7 } from "uuidv7"; +// import { uuidv7 } from "uuidv7"; import { ProfileSalaries } from "../entities/ProfileSalaries"; @Route("api/v1/org/upload") @Tags("UPLOAD") @@ -761,8 +761,8 @@ export class ImportDataController extends Controller { profileSalary.lastUpdateFullName = request.user.name; profileSalary.createdAt = new Date().toISOString().split("T")[0]; profileSalary.lastUpdatedAt = new Date().toISOString().split("T")[0]; - const result = uuidv7(); - profileSalary.id = result; + // const result = uuidv7(); + // profileSalary.id = result; // console.log(">>>>>>>>>>>>>>>>>>>" + rowCount); // // Generate SQL INSERT Statement using TypeORM QueryBuilder but don't execute it @@ -2298,7 +2298,7 @@ export class ImportDataController extends Controller { var _profiles: ProfileSalary[] = []; const filePath = path.join(__dirname, "salaryProfile1.csv"); // CSV Header - let csvData = `"id","createdAt","createdUserId","lastUpdatedAt","lastUpdateUserId","createdFullName","lastUpdateFullName","profileId","profileEmployeeId","order","commandNo","commandYear","commandDateSign","commandDateAffect","commandCode","commandName","posNoAbb","posNo","positionName","positionType","positionLevel","positionCee","orgRoot","orgChild1","orgChild2","orgChild3","orgChild4","positionExecutive","amount","amountSpecial","positionSalaryAmount","mouthSalaryAmount","remark","dateGovernment","isGovernment","commandId"\n`; + let csvData = `"id","createdAt","createdUserId","lastUpdatedAt","lastUpdateUserId","createdFullName","lastUpdateFullName","profileId","profileEmployeeId","order","commandNo","commandYear","commandDateSign","commandDateAffect","commandCode","commandName","posNoAbb","posNo","positionName","positionType","positionLevel","positionCee","orgRoot","orgChild1","orgChild2","orgChild3","orgChild4","positionExecutive","amount","amountSpecial","positionSalaryAmount","mouthSalaryAmount","remark","dateGovernment","isGovernment","commandId","refId"\n`; fs.appendFile(filePath, csvData, (err) => { if (err) { @@ -2361,7 +2361,7 @@ export class ImportDataController extends Controller { profileSalary.id = result; console.log(profileSalary.commandDateSign); - csvData = `"${profileSalary.id || "NULL"}","${profileSalary.createdAt || "NULL"}","${profileSalary.createdUserId || "NULL"}","${profileSalary.lastUpdatedAt || "NULL"}","${profileSalary.lastUpdateUserId || "NULL"}","${profileSalary.createdFullName || "NULL"}","${profileSalary.lastUpdateFullName || "NULL"}","${profileSalary.profileId || "NULL"}","${profileSalary.profileEmployeeId || "NULL"}","${profileSalary.order || "NULL"}","${profileSalary.commandNo || "NULL"}","${profileSalary.commandYear || "NULL"}","${profileSalary.commandDateSign || "NULL"}","${profileSalary.commandDateAffect || "NULL"}","${profileSalary.commandCode || "NULL"}","${profileSalary.commandName || "NULL"}","${profileSalary.posNoAbb || "NULL"}","${profileSalary.posNo || "NULL"}","${profileSalary.positionName || "NULL"}","${profileSalary.positionType || "NULL"}","${profileSalary.positionLevel || "NULL"}","${profileSalary.positionCee || "NULL"}","${profileSalary.orgRoot || "NULL"}","${profileSalary.orgChild1 || "NULL"}","${profileSalary.orgChild2 || "NULL"}","${profileSalary.orgChild3 || "NULL"}","${profileSalary.orgChild4 || "NULL"}","${profileSalary.positionExecutive || "NULL"}","${profileSalary.amount || 0}","${profileSalary.amountSpecial || 0}","${profileSalary.positionSalaryAmount || 0}","${profileSalary.mouthSalaryAmount || 0}","${profileSalary.remark || "NULL"}","${profileSalary.dateGovernment || "NULL"}","${profileSalary.isGovernment || "NULL"}","${profileSalary.commandId || "NULL"}"\n`; + csvData = `"${profileSalary.id || "NULL"}","${profileSalary.createdAt || "NULL"}","${profileSalary.createdUserId || "NULL"}","${profileSalary.lastUpdatedAt || "NULL"}","${profileSalary.lastUpdateUserId || "NULL"}","${profileSalary.createdFullName || "NULL"}","${profileSalary.lastUpdateFullName || "NULL"}","${profileSalary.profileId || "NULL"}","${profileSalary.profileEmployeeId || "NULL"}","${profileSalary.order || "NULL"}","${profileSalary.commandNo || "NULL"}","${profileSalary.commandYear || "NULL"}","${profileSalary.commandDateSign || "NULL"}","${profileSalary.commandDateAffect || "NULL"}","${profileSalary.commandCode || "NULL"}","${profileSalary.commandName || "NULL"}","${profileSalary.posNoAbb || "NULL"}","${profileSalary.posNo || "NULL"}","${profileSalary.positionName || "NULL"}","${profileSalary.positionType || "NULL"}","${profileSalary.positionLevel || "NULL"}","${profileSalary.positionCee || "NULL"}","${profileSalary.orgRoot || "NULL"}","${profileSalary.orgChild1 || "NULL"}","${profileSalary.orgChild2 || "NULL"}","${profileSalary.orgChild3 || "NULL"}","${profileSalary.orgChild4 || "NULL"}","${profileSalary.positionExecutive || "NULL"}","${profileSalary.amount || 0}","${profileSalary.amountSpecial || 0}","${profileSalary.positionSalaryAmount || 0}","${profileSalary.mouthSalaryAmount || 0}","${profileSalary.remark || "NULL"}","${profileSalary.dateGovernment || "NULL"}","${profileSalary.isGovernment || "NULL"}","${profileSalary.commandId || "NULL"}","${profileSalary.refId || "NULL"}"\n`; fs.appendFile(filePath, csvData.replace('"NULL"', "NULL"), (err) => { if (err) { From 1e8265c4b95a1889c7843e60b52532d4e9eb24a8 Mon Sep 17 00:00:00 2001 From: kittapath Date: Wed, 26 Feb 2025 15:58:39 +0700 Subject: [PATCH 12/19] no message --- src/controllers/ImportDataController.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/controllers/ImportDataController.ts b/src/controllers/ImportDataController.ts index 79bbbf58..4ffe05d2 100644 --- a/src/controllers/ImportDataController.ts +++ b/src/controllers/ImportDataController.ts @@ -2357,8 +2357,8 @@ export class ImportDataController extends Controller { profileSalary.lastUpdateFullName = request.user.name; profileSalary.createdAt = new Date().toISOString().split("T")[0]; profileSalary.lastUpdatedAt = new Date().toISOString().split("T")[0]; - const result = uuidv7(); - profileSalary.id = result; + // const result = uuidv7(); + // profileSalary.id = result; console.log(profileSalary.commandDateSign); csvData = `"${profileSalary.id || "NULL"}","${profileSalary.createdAt || "NULL"}","${profileSalary.createdUserId || "NULL"}","${profileSalary.lastUpdatedAt || "NULL"}","${profileSalary.lastUpdateUserId || "NULL"}","${profileSalary.createdFullName || "NULL"}","${profileSalary.lastUpdateFullName || "NULL"}","${profileSalary.profileId || "NULL"}","${profileSalary.profileEmployeeId || "NULL"}","${profileSalary.order || "NULL"}","${profileSalary.commandNo || "NULL"}","${profileSalary.commandYear || "NULL"}","${profileSalary.commandDateSign || "NULL"}","${profileSalary.commandDateAffect || "NULL"}","${profileSalary.commandCode || "NULL"}","${profileSalary.commandName || "NULL"}","${profileSalary.posNoAbb || "NULL"}","${profileSalary.posNo || "NULL"}","${profileSalary.positionName || "NULL"}","${profileSalary.positionType || "NULL"}","${profileSalary.positionLevel || "NULL"}","${profileSalary.positionCee || "NULL"}","${profileSalary.orgRoot || "NULL"}","${profileSalary.orgChild1 || "NULL"}","${profileSalary.orgChild2 || "NULL"}","${profileSalary.orgChild3 || "NULL"}","${profileSalary.orgChild4 || "NULL"}","${profileSalary.positionExecutive || "NULL"}","${profileSalary.amount || 0}","${profileSalary.amountSpecial || 0}","${profileSalary.positionSalaryAmount || 0}","${profileSalary.mouthSalaryAmount || 0}","${profileSalary.remark || "NULL"}","${profileSalary.dateGovernment || "NULL"}","${profileSalary.isGovernment || "NULL"}","${profileSalary.commandId || "NULL"}","${profileSalary.refId || "NULL"}"\n`; From 5dab73c1411729f3920d8b0b9b114a2334d28ac5 Mon Sep 17 00:00:00 2001 From: kittapath Date: Wed, 26 Feb 2025 16:01:26 +0700 Subject: [PATCH 13/19] comment import entry --- src/controllers/ImportDataController.ts | 202 ++++++++++++------------ 1 file changed, 101 insertions(+), 101 deletions(-) diff --git a/src/controllers/ImportDataController.ts b/src/controllers/ImportDataController.ts index 4ffe05d2..ba243365 100644 --- a/src/controllers/ImportDataController.ts +++ b/src/controllers/ImportDataController.ts @@ -48,7 +48,7 @@ import { Position } from "../entities/Position"; import { PosMaster } from "../entities/PosMaster"; import { positionOfficer } from "../entities/positionOfficer"; // import { uuidv7 } from "uuidv7"; -import { ProfileSalaries } from "../entities/ProfileSalaries"; +// import { ProfileSalaries } from "../entities/ProfileSalaries"; @Route("api/v1/org/upload") @Tags("UPLOAD") @Security("bearerAuth") @@ -63,7 +63,7 @@ export class ImportDataController extends Controller { private posLevelRepo = AppDataSource.getRepository(PosLevel); private posTypeRepo = AppDataSource.getRepository(PosType); private positionOfficerRepo = AppDataSource.getRepository(positionOfficer); - private ProfileSalariesRepo = AppDataSource.getRepository(ProfileSalaries); + // private ProfileSalariesRepo = AppDataSource.getRepository(ProfileSalaries); private HR_PERSONAL_OFFICER_FAMILYRepo = AppDataSource.getRepository(HR_PERSONAL_OFFICER_FAMILY); private HR_EDUCATIONRepo = AppDataSource.getRepository(HR_EDUCATION); private HR_PERSONAL_OFFICER_ADDRESSRepo = AppDataSource.getRepository( @@ -2278,109 +2278,109 @@ export class ImportDataController extends Controller { return new HttpSuccess(); } - /** - * @summary เงินเดือน ข้าราชการ - */ - @Post("uploadProfileSalary-OfficerEntry") - async UploadFileSQLSalaryEntry(@Request() request: { user: Record }) { - let rowCount = 0; - let null_: any = null; - let sqlStatements: string[] = []; + // /** + // * @summary เงินเดือน ข้าราชการ + // */ + // @Post("uploadProfileSalary-OfficerEntry") + // async UploadFileSQLSalaryEntry(@Request() request: { user: Record }) { + // let rowCount = 0; + // let null_: any = null; + // let sqlStatements: string[] = []; - const [profiles, total] = await AppDataSource.getRepository(Profile) - .createQueryBuilder("profile") - .select(["profile.citizenId", "profile.id"]) - .orderBy("profile.citizenId", "ASC") - // .where("profile.citizenId = '3101702379675'") - .skip(10000) - .take(20000) - .getManyAndCount(); - var _profiles: ProfileSalary[] = []; - const filePath = path.join(__dirname, "salaryProfile1.csv"); - // CSV Header - let csvData = `"id","createdAt","createdUserId","lastUpdatedAt","lastUpdateUserId","createdFullName","lastUpdateFullName","profileId","profileEmployeeId","order","commandNo","commandYear","commandDateSign","commandDateAffect","commandCode","commandName","posNoAbb","posNo","positionName","positionType","positionLevel","positionCee","orgRoot","orgChild1","orgChild2","orgChild3","orgChild4","positionExecutive","amount","amountSpecial","positionSalaryAmount","mouthSalaryAmount","remark","dateGovernment","isGovernment","commandId","refId"\n`; + // const [profiles, total] = await AppDataSource.getRepository(Profile) + // .createQueryBuilder("profile") + // .select(["profile.citizenId", "profile.id"]) + // .orderBy("profile.citizenId", "ASC") + // // .where("profile.citizenId = '3101702379675'") + // .skip(10000) + // .take(20000) + // .getManyAndCount(); + // var _profiles: ProfileSalary[] = []; + // const filePath = path.join(__dirname, "salaryProfile1.csv"); + // // CSV Header + // let csvData = `"id","createdAt","createdUserId","lastUpdatedAt","lastUpdateUserId","createdFullName","lastUpdateFullName","profileId","profileEmployeeId","order","commandNo","commandYear","commandDateSign","commandDateAffect","commandCode","commandName","posNoAbb","posNo","positionName","positionType","positionLevel","positionCee","orgRoot","orgChild1","orgChild2","orgChild3","orgChild4","positionExecutive","amount","amountSpecial","positionSalaryAmount","mouthSalaryAmount","remark","dateGovernment","isGovernment","commandId","refId"\n`; - fs.appendFile(filePath, csvData, (err) => { - if (err) { - console.error("Error writing CSV file:", err); - } else { - console.log("Salary profiles successfully written to salaryProfile.csv"); - } - }); - await Promise.all( - profiles.map(async (_item) => { - const existingProfile = await this.ProfileSalariesRepo.find({ - where: { ProfileId: _item.citizenId }, - order: { - Order: "ASC", - }, - }); - let order = 1; - await Promise.all( - existingProfile.map(async (item) => { - rowCount++; - const profileSalary: any = new ProfileSalary(); - profileSalary.profileId = _item.id; - profileSalary.order = item.Order; + // fs.appendFile(filePath, csvData, (err) => { + // if (err) { + // console.error("Error writing CSV file:", err); + // } else { + // console.log("Salary profiles successfully written to salaryProfile.csv"); + // } + // }); + // await Promise.all( + // profiles.map(async (_item) => { + // const existingProfile = await this.ProfileSalariesRepo.find({ + // where: { ProfileId: _item.citizenId }, + // order: { + // Order: "ASC", + // }, + // }); + // let order = 1; + // await Promise.all( + // existingProfile.map(async (item) => { + // rowCount++; + // const profileSalary: any = new ProfileSalary(); + // profileSalary.profileId = _item.id; + // profileSalary.order = item.Order; - profileSalary.commandDateAffect = - item.Date == null - ? null_ - : new Date(item.Date.setDate(item.Date.getDate() + 1)) - .toISOString() - .replace("T", " ") - .substring(0, 19); - profileSalary.remark = item.SalaryRef + item.PositionName; - profileSalary.amount = item.Amount; - profileSalary.positionSalaryAmount = item.PositionSalaryAmount; - const str = item.PosNoName; - const parts = str.split(" "); - if (parts.length > 1) { - const posNo = parts.at(-1); - const posNoAbb = parts.slice(0, -1).join(" "); - profileSalary.posNoAbb = posNoAbb; - profileSalary.posNo = posNo; - } - profileSalary.posLevel = this.canConvertToInt(item.PositionLevelName) - ? null_ - : item.PositionLevelName; - profileSalary.posCee = this.canConvertToInt(item.PositionLevelName) - ? item.PositionLevelName - : null_; - //xxxxxxxxxxxxxxxxx - profileSalary.posType = item.PositionTypeName; - profileSalary.isEntry = true; + // profileSalary.commandDateAffect = + // item.Date == null + // ? null_ + // : new Date(item.Date.setDate(item.Date.getDate() + 1)) + // .toISOString() + // .replace("T", " ") + // .substring(0, 19); + // profileSalary.remark = item.SalaryRef + item.PositionName; + // profileSalary.amount = item.Amount; + // profileSalary.positionSalaryAmount = item.PositionSalaryAmount; + // const str = item.PosNoName; + // const parts = str.split(" "); + // if (parts.length > 1) { + // const posNo = parts.at(-1); + // const posNoAbb = parts.slice(0, -1).join(" "); + // profileSalary.posNoAbb = posNoAbb; + // profileSalary.posNo = posNo; + // } + // profileSalary.posLevel = this.canConvertToInt(item.PositionLevelName) + // ? null_ + // : item.PositionLevelName; + // profileSalary.posCee = this.canConvertToInt(item.PositionLevelName) + // ? item.PositionLevelName + // : null_; + // //xxxxxxxxxxxxxxxxx + // profileSalary.posType = item.PositionTypeName; + // profileSalary.isEntry = true; - profileSalary.createdUserId = request.user.sub; - profileSalary.createdFullName = request.user.name; - profileSalary.lastUpdateUserId = request.user.sub; - profileSalary.lastUpdateFullName = request.user.name; - profileSalary.createdAt = new Date().toISOString().split("T")[0]; - profileSalary.lastUpdatedAt = new Date().toISOString().split("T")[0]; - // const result = uuidv7(); - // profileSalary.id = result; + // profileSalary.createdUserId = request.user.sub; + // profileSalary.createdFullName = request.user.name; + // profileSalary.lastUpdateUserId = request.user.sub; + // profileSalary.lastUpdateFullName = request.user.name; + // profileSalary.createdAt = new Date().toISOString().split("T")[0]; + // profileSalary.lastUpdatedAt = new Date().toISOString().split("T")[0]; + // // const result = uuidv7(); + // // profileSalary.id = result; - console.log(profileSalary.commandDateSign); - csvData = `"${profileSalary.id || "NULL"}","${profileSalary.createdAt || "NULL"}","${profileSalary.createdUserId || "NULL"}","${profileSalary.lastUpdatedAt || "NULL"}","${profileSalary.lastUpdateUserId || "NULL"}","${profileSalary.createdFullName || "NULL"}","${profileSalary.lastUpdateFullName || "NULL"}","${profileSalary.profileId || "NULL"}","${profileSalary.profileEmployeeId || "NULL"}","${profileSalary.order || "NULL"}","${profileSalary.commandNo || "NULL"}","${profileSalary.commandYear || "NULL"}","${profileSalary.commandDateSign || "NULL"}","${profileSalary.commandDateAffect || "NULL"}","${profileSalary.commandCode || "NULL"}","${profileSalary.commandName || "NULL"}","${profileSalary.posNoAbb || "NULL"}","${profileSalary.posNo || "NULL"}","${profileSalary.positionName || "NULL"}","${profileSalary.positionType || "NULL"}","${profileSalary.positionLevel || "NULL"}","${profileSalary.positionCee || "NULL"}","${profileSalary.orgRoot || "NULL"}","${profileSalary.orgChild1 || "NULL"}","${profileSalary.orgChild2 || "NULL"}","${profileSalary.orgChild3 || "NULL"}","${profileSalary.orgChild4 || "NULL"}","${profileSalary.positionExecutive || "NULL"}","${profileSalary.amount || 0}","${profileSalary.amountSpecial || 0}","${profileSalary.positionSalaryAmount || 0}","${profileSalary.mouthSalaryAmount || 0}","${profileSalary.remark || "NULL"}","${profileSalary.dateGovernment || "NULL"}","${profileSalary.isGovernment || "NULL"}","${profileSalary.commandId || "NULL"}","${profileSalary.refId || "NULL"}"\n`; + // console.log(profileSalary.commandDateSign); + // csvData = `"${profileSalary.id || "NULL"}","${profileSalary.createdAt || "NULL"}","${profileSalary.createdUserId || "NULL"}","${profileSalary.lastUpdatedAt || "NULL"}","${profileSalary.lastUpdateUserId || "NULL"}","${profileSalary.createdFullName || "NULL"}","${profileSalary.lastUpdateFullName || "NULL"}","${profileSalary.profileId || "NULL"}","${profileSalary.profileEmployeeId || "NULL"}","${profileSalary.order || "NULL"}","${profileSalary.commandNo || "NULL"}","${profileSalary.commandYear || "NULL"}","${profileSalary.commandDateSign || "NULL"}","${profileSalary.commandDateAffect || "NULL"}","${profileSalary.commandCode || "NULL"}","${profileSalary.commandName || "NULL"}","${profileSalary.posNoAbb || "NULL"}","${profileSalary.posNo || "NULL"}","${profileSalary.positionName || "NULL"}","${profileSalary.positionType || "NULL"}","${profileSalary.positionLevel || "NULL"}","${profileSalary.positionCee || "NULL"}","${profileSalary.orgRoot || "NULL"}","${profileSalary.orgChild1 || "NULL"}","${profileSalary.orgChild2 || "NULL"}","${profileSalary.orgChild3 || "NULL"}","${profileSalary.orgChild4 || "NULL"}","${profileSalary.positionExecutive || "NULL"}","${profileSalary.amount || 0}","${profileSalary.amountSpecial || 0}","${profileSalary.positionSalaryAmount || 0}","${profileSalary.mouthSalaryAmount || 0}","${profileSalary.remark || "NULL"}","${profileSalary.dateGovernment || "NULL"}","${profileSalary.isGovernment || "NULL"}","${profileSalary.commandId || "NULL"}","${profileSalary.refId || "NULL"}"\n`; - fs.appendFile(filePath, csvData.replace('"NULL"', "NULL"), (err) => { - if (err) { - console.error("Error writing CSV file:", err); - } else { - console.log( - "Salary profiles successfully written to salaryProfile.csv: " + rowCount, - ); - } - }); - }), - ); - order = 1; - }), - ); - return new HttpSuccess(); - } - canConvertToInt(str: string) { - const num = Number(str); - return Number.isInteger(num); - } + // fs.appendFile(filePath, csvData.replace('"NULL"', "NULL"), (err) => { + // if (err) { + // console.error("Error writing CSV file:", err); + // } else { + // console.log( + // "Salary profiles successfully written to salaryProfile.csv: " + rowCount, + // ); + // } + // }); + // }), + // ); + // order = 1; + // }), + // ); + // return new HttpSuccess(); + // } + // canConvertToInt(str: string) { + // const num = Number(str); + // return Number.isInteger(num); + // } } From a064753efda120e3f1106dae88b5f58f0f0dd3c2 Mon Sep 17 00:00:00 2001 From: kittapath Date: Wed, 26 Feb 2025 17:05:13 +0700 Subject: [PATCH 14/19] =?UTF-8?q?=E0=B9=81=E0=B8=9A=E0=B8=9A=E0=B8=A3?= =?UTF-8?q?=E0=B9=88=E0=B8=B2=E0=B8=87=E0=B8=A5=E0=B8=B9=E0=B8=81=E0=B8=88?= =?UTF-8?q?=E0=B9=89=E0=B8=B2=E0=B8=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/OrganizationController.ts | 678 ++++++++++++++++++ ...40561148833-updateprofilesalaryaddrefid.ts | 18 + src/services/rabbitmq.ts | 63 +- 3 files changed, 757 insertions(+), 2 deletions(-) create mode 100644 src/migration/1740561148833-updateprofilesalaryaddrefid.ts diff --git a/src/controllers/OrganizationController.ts b/src/controllers/OrganizationController.ts index 79ef4608..20438a6d 100644 --- a/src/controllers/OrganizationController.ts +++ b/src/controllers/OrganizationController.ts @@ -34,6 +34,7 @@ import { PosMasterAssign } from "../entities/PosMasterAssign"; import { PosMasterAct } from "../entities/PosMasterAct"; import { EmployeePosition } from "../entities/EmployeePosition"; import { EmployeePosMaster } from "../entities/EmployeePosMaster"; +import { EmployeeTempPosMaster } from "../entities/EmployeeTempPosMaster"; @Route("api/v1/org") @Tags("Organization") @@ -57,6 +58,7 @@ export class OrganizationController extends Controller { private profileRepo = AppDataSource.getRepository(Profile); private employeePosMasterRepository = AppDataSource.getRepository(EmployeePosMaster); private employeePositionRepository = AppDataSource.getRepository(EmployeePosition); + private employeeTempPosMasterRepository = AppDataSource.getRepository(EmployeeTempPosMaster); /** * API ล้างข้อมูล @@ -243,6 +245,53 @@ export class OrganizationController extends Controller { })); await this.posMasterRepository.save(_orgPosMaster); } + + //หา dna posmaster ถ้าไม่มีให้เอาตัวเองเป็น dna + const orgemployeePosMaster = await this.employeePosMasterRepository.find({ + where: { orgRevisionId: requestBody.orgRevisionId }, + relations: ["positions"], + }); + + let _orgemployeePosMaster: EmployeePosMaster[]; + if ( + requestBody.typeDraft.toUpperCase() == "ORG_POSITION" || + requestBody.typeDraft.toUpperCase() == "ORG_POSITION_PERSON" || + requestBody.typeDraft.toUpperCase() == "ORG_POSITION_ROLE" || + requestBody.typeDraft.toUpperCase() == "ORG_POSITION_PERSON_ROLE" + ) { + _orgemployeePosMaster = orgemployeePosMaster.map((x) => ({ + ...x, + ancestorDNA: + x.ancestorDNA == null || x.ancestorDNA == "00000000-0000-0000-0000-000000000000" + ? x.id + : x.ancestorDNA, + })); + await this.employeePosMasterRepository.save(_orgemployeePosMaster); + } + + //หา dna posmaster ถ้าไม่มีให้เอาตัวเองเป็น dna + const orgemployeeTempPosMaster = await this.employeeTempPosMasterRepository.find({ + where: { orgRevisionId: requestBody.orgRevisionId }, + relations: ["positions"], + }); + + let _orgemployeeTempPosMaster: EmployeeTempPosMaster[]; + if ( + requestBody.typeDraft.toUpperCase() == "ORG_POSITION" || + requestBody.typeDraft.toUpperCase() == "ORG_POSITION_PERSON" || + requestBody.typeDraft.toUpperCase() == "ORG_POSITION_ROLE" || + requestBody.typeDraft.toUpperCase() == "ORG_POSITION_PERSON_ROLE" + ) { + _orgemployeeTempPosMaster = orgemployeeTempPosMaster.map((x) => ({ + ...x, + ancestorDNA: + x.ancestorDNA == null || x.ancestorDNA == "00000000-0000-0000-0000-000000000000" + ? x.id + : x.ancestorDNA, + })); + await this.employeeTempPosMasterRepository.save(_orgemployeeTempPosMaster); + } + //create org _orgRoot.forEach(async (x: any) => { var dataId = x.id; @@ -319,6 +368,126 @@ export class OrganizationController extends Controller { }); }), ); + //create employeePosmaster + await Promise.all( + _orgemployeePosMaster + .filter((x: EmployeePosMaster) => x.orgRootId == dataId && x.orgChild1Id == null) + .map(async (item: any) => { + delete item.id; + const employeePosMaster = Object.assign(new EmployeePosMaster(), item); + employeePosMaster.positions = []; + if ( + requestBody.typeDraft.toUpperCase() == "ORG_POSITION_PERSON" || + requestBody.typeDraft.toUpperCase() == "ORG_POSITION_PERSON_ROLE" + ) { + // employeePosMaster.next_holderId = item.current_holderId; + } else { + // employeePosMaster.next_holderId = null; + employeePosMaster.isSit = false; + } + if ( + requestBody.typeDraft.toUpperCase() == "ORG_POSITION_ROLE" || + requestBody.typeDraft.toUpperCase() == "ORG_POSITION_PERSON_ROLE" + ) { + employeePosMaster.authRoleId = item.authRoleId; + } else { + employeePosMaster.authRoleId = null; + } + // employeePosMaster.current_holderId = null; + employeePosMaster.orgRevisionId = revision.id; + employeePosMaster.orgRootId = data.id; + employeePosMaster.createdUserId = request.user.sub; + employeePosMaster.createdFullName = request.user.name; + employeePosMaster.createdAt = new Date(); + employeePosMaster.lastUpdateUserId = request.user.sub; + employeePosMaster.lastUpdateFullName = request.user.name; + employeePosMaster.lastUpdatedAt = new Date(); + await this.employeePosMasterRepository.save(employeePosMaster); + + //create employeePosition + item.positions.map(async (pos: any) => { + delete pos.id; + const employeePosition: EmployeePosition = Object.assign( + new EmployeePosition(), + pos, + ); + employeePosition.posMasterId = employeePosMaster.id; + if ( + requestBody.typeDraft.toUpperCase() == "ORG_POSITION" || + requestBody.typeDraft.toUpperCase() == "ORG_POSITION_ROLE" + ) { + employeePosition.positionIsSelected = false; + } + employeePosition.createdUserId = request.user.sub; + employeePosition.createdFullName = request.user.name; + employeePosition.createdAt = new Date(); + employeePosition.lastUpdateUserId = request.user.sub; + employeePosition.lastUpdateFullName = request.user.name; + employeePosition.lastUpdatedAt = new Date(); + await this.employeePositionRepository.save(employeePosition); + }); + }), + ); + //create employeeTempPosmaster + await Promise.all( + _orgemployeeTempPosMaster + .filter((x: EmployeeTempPosMaster) => x.orgRootId == dataId && x.orgChild1Id == null) + .map(async (item: any) => { + delete item.id; + const employeeTempPosMaster = Object.assign(new EmployeeTempPosMaster(), item); + employeeTempPosMaster.positions = []; + if ( + requestBody.typeDraft.toUpperCase() == "ORG_POSITION_PERSON" || + requestBody.typeDraft.toUpperCase() == "ORG_POSITION_PERSON_ROLE" + ) { + // employeeTempPosMaster.next_holderId = item.current_holderId; + } else { + // employeeTempPosMaster.next_holderId = null; + employeeTempPosMaster.isSit = false; + } + if ( + requestBody.typeDraft.toUpperCase() == "ORG_POSITION_ROLE" || + requestBody.typeDraft.toUpperCase() == "ORG_POSITION_PERSON_ROLE" + ) { + employeeTempPosMaster.authRoleId = item.authRoleId; + } else { + employeeTempPosMaster.authRoleId = null; + } + // employeeTempPosMaster.current_holderId = null; + employeeTempPosMaster.orgRevisionId = revision.id; + employeeTempPosMaster.orgRootId = data.id; + employeeTempPosMaster.createdUserId = request.user.sub; + employeeTempPosMaster.createdFullName = request.user.name; + employeeTempPosMaster.createdAt = new Date(); + employeeTempPosMaster.lastUpdateUserId = request.user.sub; + employeeTempPosMaster.lastUpdateFullName = request.user.name; + employeeTempPosMaster.lastUpdatedAt = new Date(); + await this.employeeTempPosMasterRepository.save(employeeTempPosMaster); + + //create employeePosition + item.positions.map(async (pos: any) => { + delete pos.id; + const employeePosition: EmployeePosition = Object.assign( + new EmployeePosition(), + pos, + ); + employeePosition.posMasterTempId = employeeTempPosMaster.id; + if ( + requestBody.typeDraft.toUpperCase() == "ORG_POSITION" || + requestBody.typeDraft.toUpperCase() == "ORG_POSITION_ROLE" + ) { + employeePosition.positionIsSelected = false; + } + employeePosition.createdUserId = request.user.sub; + employeePosition.createdFullName = request.user.name; + employeePosition.createdAt = new Date(); + employeePosition.lastUpdateUserId = request.user.sub; + employeePosition.lastUpdateFullName = request.user.name; + employeePosition.lastUpdatedAt = new Date(); + await this.employeePositionRepository.save(employeePosition); + }); + }), + ); } //create org @@ -401,6 +570,130 @@ export class OrganizationController extends Controller { }); }), ); + //create employeePosmaster + await Promise.all( + _orgemployeePosMaster + .filter( + (x: EmployeePosMaster) => x.orgChild1Id == data1Id && x.orgChild2Id == null, + ) + .map(async (item: any) => { + delete item.id; + const employeePosMaster = Object.assign(new EmployeePosMaster(), item); + employeePosMaster.positions = []; + if ( + requestBody.typeDraft.toUpperCase() == "ORG_POSITION_PERSON" || + requestBody.typeDraft.toUpperCase() == "ORG_POSITION_PERSON_ROLE" + ) { + // employeePosMaster.next_holderId = item.current_holderId; + } else { + // employeePosMaster.next_holderId = null; + employeePosMaster.isSit = false; + } + if ( + requestBody.typeDraft.toUpperCase() == "ORG_POSITION_ROLE" || + requestBody.typeDraft.toUpperCase() == "ORG_POSITION_PERSON_ROLE" + ) { + employeePosMaster.authRoleId = item.authRoleId; + } else { + employeePosMaster.authRoleId = null; + } + // employeePosMaster.current_holderId = null; + employeePosMaster.orgRevisionId = revision.id; + employeePosMaster.orgRootId = data.id; + employeePosMaster.createdUserId = request.user.sub; + employeePosMaster.createdFullName = request.user.name; + employeePosMaster.createdAt = new Date(); + employeePosMaster.lastUpdateUserId = request.user.sub; + employeePosMaster.lastUpdateFullName = request.user.name; + employeePosMaster.lastUpdatedAt = new Date(); + await this.employeePosMasterRepository.save(employeePosMaster); + + //create employeePosition + item.positions.map(async (pos: any) => { + delete pos.id; + const employeePosition: EmployeePosition = Object.assign( + new EmployeePosition(), + pos, + ); + employeePosition.posMasterId = employeePosMaster.id; + if ( + requestBody.typeDraft.toUpperCase() == "ORG_POSITION" || + requestBody.typeDraft.toUpperCase() == "ORG_POSITION_ROLE" + ) { + employeePosition.positionIsSelected = false; + } + employeePosition.createdUserId = request.user.sub; + employeePosition.createdFullName = request.user.name; + employeePosition.createdAt = new Date(); + employeePosition.lastUpdateUserId = request.user.sub; + employeePosition.lastUpdateFullName = request.user.name; + employeePosition.lastUpdatedAt = new Date(); + await this.employeePositionRepository.save(employeePosition); + }); + }), + ); + //create employeeTempPosmaster + await Promise.all( + _orgemployeeTempPosMaster + .filter( + (x: EmployeeTempPosMaster) => x.orgChild1Id == data1Id && x.orgChild2Id == null, + ) + .map(async (item: any) => { + delete item.id; + const employeeTempPosMaster = Object.assign(new EmployeeTempPosMaster(), item); + employeeTempPosMaster.positions = []; + if ( + requestBody.typeDraft.toUpperCase() == "ORG_POSITION_PERSON" || + requestBody.typeDraft.toUpperCase() == "ORG_POSITION_PERSON_ROLE" + ) { + // employeeTempPosMaster.next_holderId = item.current_holderId; + } else { + // employeeTempPosMaster.next_holderId = null; + employeeTempPosMaster.isSit = false; + } + if ( + requestBody.typeDraft.toUpperCase() == "ORG_POSITION_ROLE" || + requestBody.typeDraft.toUpperCase() == "ORG_POSITION_PERSON_ROLE" + ) { + employeeTempPosMaster.authRoleId = item.authRoleId; + } else { + employeeTempPosMaster.authRoleId = null; + } + // employeeTempPosMaster.current_holderId = null; + employeeTempPosMaster.orgRevisionId = revision.id; + employeeTempPosMaster.orgRootId = data.id; + employeeTempPosMaster.createdUserId = request.user.sub; + employeeTempPosMaster.createdFullName = request.user.name; + employeeTempPosMaster.createdAt = new Date(); + employeeTempPosMaster.lastUpdateUserId = request.user.sub; + employeeTempPosMaster.lastUpdateFullName = request.user.name; + employeeTempPosMaster.lastUpdatedAt = new Date(); + await this.employeeTempPosMasterRepository.save(employeeTempPosMaster); + + //create employeePosition + item.positions.map(async (pos: any) => { + delete pos.id; + const employeePosition: EmployeePosition = Object.assign( + new EmployeePosition(), + pos, + ); + employeePosition.posMasterTempId = employeeTempPosMaster.id; + if ( + requestBody.typeDraft.toUpperCase() == "ORG_POSITION" || + requestBody.typeDraft.toUpperCase() == "ORG_POSITION_ROLE" + ) { + employeePosition.positionIsSelected = false; + } + employeePosition.createdUserId = request.user.sub; + employeePosition.createdFullName = request.user.name; + employeePosition.createdAt = new Date(); + employeePosition.lastUpdateUserId = request.user.sub; + employeePosition.lastUpdateFullName = request.user.name; + employeePosition.lastUpdatedAt = new Date(); + await this.employeePositionRepository.save(employeePosition); + }); + }), + ); } //create org @@ -485,6 +778,134 @@ export class OrganizationController extends Controller { }); }), ); + //create employeePosmaster + await Promise.all( + _orgemployeePosMaster + .filter( + (x: EmployeePosMaster) => x.orgChild2Id == data2Id && x.orgChild3Id == null, + ) + .map(async (item: any) => { + delete item.id; + const employeePosMaster = Object.assign(new EmployeePosMaster(), item); + employeePosMaster.positions = []; + if ( + requestBody.typeDraft.toUpperCase() == "ORG_POSITION_PERSON" || + requestBody.typeDraft.toUpperCase() == "ORG_POSITION_PERSON_ROLE" + ) { + // employeePosMaster.next_holderId = item.current_holderId; + } else { + // employeePosMaster.next_holderId = null; + employeePosMaster.isSit = false; + } + if ( + requestBody.typeDraft.toUpperCase() == "ORG_POSITION_ROLE" || + requestBody.typeDraft.toUpperCase() == "ORG_POSITION_PERSON_ROLE" + ) { + employeePosMaster.authRoleId = item.authRoleId; + } else { + employeePosMaster.authRoleId = null; + } + // employeePosMaster.current_holderId = null; + employeePosMaster.orgRevisionId = revision.id; + employeePosMaster.orgRootId = data.id; + employeePosMaster.createdUserId = request.user.sub; + employeePosMaster.createdFullName = request.user.name; + employeePosMaster.createdAt = new Date(); + employeePosMaster.lastUpdateUserId = request.user.sub; + employeePosMaster.lastUpdateFullName = request.user.name; + employeePosMaster.lastUpdatedAt = new Date(); + await this.employeePosMasterRepository.save(employeePosMaster); + + //create employeePosition + item.positions.map(async (pos: any) => { + delete pos.id; + const employeePosition: EmployeePosition = Object.assign( + new EmployeePosition(), + pos, + ); + employeePosition.posMasterId = employeePosMaster.id; + if ( + requestBody.typeDraft.toUpperCase() == "ORG_POSITION" || + requestBody.typeDraft.toUpperCase() == "ORG_POSITION_ROLE" + ) { + employeePosition.positionIsSelected = false; + } + employeePosition.createdUserId = request.user.sub; + employeePosition.createdFullName = request.user.name; + employeePosition.createdAt = new Date(); + employeePosition.lastUpdateUserId = request.user.sub; + employeePosition.lastUpdateFullName = request.user.name; + employeePosition.lastUpdatedAt = new Date(); + await this.employeePositionRepository.save(employeePosition); + }); + }), + ); + //create employeeTempPosmaster + await Promise.all( + _orgemployeeTempPosMaster + .filter( + (x: EmployeeTempPosMaster) => + x.orgChild2Id == data2Id && x.orgChild3Id == null, + ) + .map(async (item: any) => { + delete item.id; + const employeeTempPosMaster = Object.assign( + new EmployeeTempPosMaster(), + item, + ); + employeeTempPosMaster.positions = []; + if ( + requestBody.typeDraft.toUpperCase() == "ORG_POSITION_PERSON" || + requestBody.typeDraft.toUpperCase() == "ORG_POSITION_PERSON_ROLE" + ) { + // employeeTempPosMaster.next_holderId = item.current_holderId; + } else { + // employeeTempPosMaster.next_holderId = null; + employeeTempPosMaster.isSit = false; + } + if ( + requestBody.typeDraft.toUpperCase() == "ORG_POSITION_ROLE" || + requestBody.typeDraft.toUpperCase() == "ORG_POSITION_PERSON_ROLE" + ) { + employeeTempPosMaster.authRoleId = item.authRoleId; + } else { + employeeTempPosMaster.authRoleId = null; + } + // employeeTempPosMaster.current_holderId = null; + employeeTempPosMaster.orgRevisionId = revision.id; + employeeTempPosMaster.orgRootId = data.id; + employeeTempPosMaster.createdUserId = request.user.sub; + employeeTempPosMaster.createdFullName = request.user.name; + employeeTempPosMaster.createdAt = new Date(); + employeeTempPosMaster.lastUpdateUserId = request.user.sub; + employeeTempPosMaster.lastUpdateFullName = request.user.name; + employeeTempPosMaster.lastUpdatedAt = new Date(); + await this.employeeTempPosMasterRepository.save(employeeTempPosMaster); + + //create employeePosition + item.positions.map(async (pos: any) => { + delete pos.id; + const employeePosition: EmployeePosition = Object.assign( + new EmployeePosition(), + pos, + ); + employeePosition.posMasterTempId = employeeTempPosMaster.id; + if ( + requestBody.typeDraft.toUpperCase() == "ORG_POSITION" || + requestBody.typeDraft.toUpperCase() == "ORG_POSITION_ROLE" + ) { + employeePosition.positionIsSelected = false; + } + employeePosition.createdUserId = request.user.sub; + employeePosition.createdFullName = request.user.name; + employeePosition.createdAt = new Date(); + employeePosition.lastUpdateUserId = request.user.sub; + employeePosition.lastUpdateFullName = request.user.name; + employeePosition.lastUpdatedAt = new Date(); + await this.employeePositionRepository.save(employeePosition); + }); + }), + ); } //create org @@ -573,6 +994,135 @@ export class OrganizationController extends Controller { }); }), ); + //create employeePosmaster + await Promise.all( + _orgemployeePosMaster + .filter( + (x: EmployeePosMaster) => + x.orgChild3Id == data3Id && x.orgChild4Id == null, + ) + .map(async (item: any) => { + delete item.id; + const employeePosMaster = Object.assign(new EmployeePosMaster(), item); + employeePosMaster.positions = []; + if ( + requestBody.typeDraft.toUpperCase() == "ORG_POSITION_PERSON" || + requestBody.typeDraft.toUpperCase() == "ORG_POSITION_PERSON_ROLE" + ) { + // employeePosMaster.next_holderId = item.current_holderId; + } else { + // employeePosMaster.next_holderId = null; + employeePosMaster.isSit = false; + } + if ( + requestBody.typeDraft.toUpperCase() == "ORG_POSITION_ROLE" || + requestBody.typeDraft.toUpperCase() == "ORG_POSITION_PERSON_ROLE" + ) { + employeePosMaster.authRoleId = item.authRoleId; + } else { + employeePosMaster.authRoleId = null; + } + // employeePosMaster.current_holderId = null; + employeePosMaster.orgRevisionId = revision.id; + employeePosMaster.orgRootId = data.id; + employeePosMaster.createdUserId = request.user.sub; + employeePosMaster.createdFullName = request.user.name; + employeePosMaster.createdAt = new Date(); + employeePosMaster.lastUpdateUserId = request.user.sub; + employeePosMaster.lastUpdateFullName = request.user.name; + employeePosMaster.lastUpdatedAt = new Date(); + await this.employeePosMasterRepository.save(employeePosMaster); + + //create employeePosition + item.positions.map(async (pos: any) => { + delete pos.id; + const employeePosition: EmployeePosition = Object.assign( + new EmployeePosition(), + pos, + ); + employeePosition.posMasterId = employeePosMaster.id; + if ( + requestBody.typeDraft.toUpperCase() == "ORG_POSITION" || + requestBody.typeDraft.toUpperCase() == "ORG_POSITION_ROLE" + ) { + employeePosition.positionIsSelected = false; + } + employeePosition.createdUserId = request.user.sub; + employeePosition.createdFullName = request.user.name; + employeePosition.createdAt = new Date(); + employeePosition.lastUpdateUserId = request.user.sub; + employeePosition.lastUpdateFullName = request.user.name; + employeePosition.lastUpdatedAt = new Date(); + await this.employeePositionRepository.save(employeePosition); + }); + }), + ); + //create employeeTempPosmaster + await Promise.all( + _orgemployeeTempPosMaster + .filter( + (x: EmployeeTempPosMaster) => + x.orgChild3Id == data3Id && x.orgChild4Id == null, + ) + .map(async (item: any) => { + delete item.id; + const employeeTempPosMaster = Object.assign( + new EmployeeTempPosMaster(), + item, + ); + employeeTempPosMaster.positions = []; + if ( + requestBody.typeDraft.toUpperCase() == "ORG_POSITION_PERSON" || + requestBody.typeDraft.toUpperCase() == "ORG_POSITION_PERSON_ROLE" + ) { + // employeeTempPosMaster.next_holderId = item.current_holderId; + } else { + // employeeTempPosMaster.next_holderId = null; + employeeTempPosMaster.isSit = false; + } + if ( + requestBody.typeDraft.toUpperCase() == "ORG_POSITION_ROLE" || + requestBody.typeDraft.toUpperCase() == "ORG_POSITION_PERSON_ROLE" + ) { + employeeTempPosMaster.authRoleId = item.authRoleId; + } else { + employeeTempPosMaster.authRoleId = null; + } + // employeeTempPosMaster.current_holderId = null; + employeeTempPosMaster.orgRevisionId = revision.id; + employeeTempPosMaster.orgRootId = data.id; + employeeTempPosMaster.createdUserId = request.user.sub; + employeeTempPosMaster.createdFullName = request.user.name; + employeeTempPosMaster.createdAt = new Date(); + employeeTempPosMaster.lastUpdateUserId = request.user.sub; + employeeTempPosMaster.lastUpdateFullName = request.user.name; + employeeTempPosMaster.lastUpdatedAt = new Date(); + await this.employeeTempPosMasterRepository.save(employeeTempPosMaster); + + //create employeePosition + item.positions.map(async (pos: any) => { + delete pos.id; + const employeePosition: EmployeePosition = Object.assign( + new EmployeePosition(), + pos, + ); + employeePosition.posMasterTempId = employeeTempPosMaster.id; + if ( + requestBody.typeDraft.toUpperCase() == "ORG_POSITION" || + requestBody.typeDraft.toUpperCase() == "ORG_POSITION_ROLE" + ) { + employeePosition.positionIsSelected = false; + } + employeePosition.createdUserId = request.user.sub; + employeePosition.createdFullName = request.user.name; + employeePosition.createdAt = new Date(); + employeePosition.lastUpdateUserId = request.user.sub; + employeePosition.lastUpdateFullName = request.user.name; + employeePosition.lastUpdatedAt = new Date(); + await this.employeePositionRepository.save(employeePosition); + }); + }), + ); } //create org @@ -661,6 +1211,134 @@ export class OrganizationController extends Controller { }); }), ); + //create employeePosmaster + await Promise.all( + _orgemployeePosMaster + .filter((x: EmployeePosMaster) => x.orgChild4Id == data4Id) + .map(async (item: any) => { + delete item.id; + const employeePosMaster = Object.assign( + new EmployeePosMaster(), + item, + ); + employeePosMaster.positions = []; + if ( + requestBody.typeDraft.toUpperCase() == "ORG_POSITION_PERSON" || + requestBody.typeDraft.toUpperCase() == "ORG_POSITION_PERSON_ROLE" + ) { + // employeePosMaster.next_holderId = item.current_holderId; + } else { + // employeePosMaster.next_holderId = null; + employeePosMaster.isSit = false; + } + if ( + requestBody.typeDraft.toUpperCase() == "ORG_POSITION_ROLE" || + requestBody.typeDraft.toUpperCase() == "ORG_POSITION_PERSON_ROLE" + ) { + employeePosMaster.authRoleId = item.authRoleId; + } else { + employeePosMaster.authRoleId = null; + } + // employeePosMaster.current_holderId = null; + employeePosMaster.orgRevisionId = revision.id; + employeePosMaster.orgRootId = data.id; + employeePosMaster.createdUserId = request.user.sub; + employeePosMaster.createdFullName = request.user.name; + employeePosMaster.createdAt = new Date(); + employeePosMaster.lastUpdateUserId = request.user.sub; + employeePosMaster.lastUpdateFullName = request.user.name; + employeePosMaster.lastUpdatedAt = new Date(); + await this.employeePosMasterRepository.save(employeePosMaster); + + //create employeePosition + item.positions.map(async (pos: any) => { + delete pos.id; + const employeePosition: EmployeePosition = Object.assign( + new EmployeePosition(), + pos, + ); + employeePosition.posMasterId = employeePosMaster.id; + if ( + requestBody.typeDraft.toUpperCase() == "ORG_POSITION" || + requestBody.typeDraft.toUpperCase() == "ORG_POSITION_ROLE" + ) { + employeePosition.positionIsSelected = false; + } + employeePosition.createdUserId = request.user.sub; + employeePosition.createdFullName = request.user.name; + employeePosition.createdAt = new Date(); + employeePosition.lastUpdateUserId = request.user.sub; + employeePosition.lastUpdateFullName = request.user.name; + employeePosition.lastUpdatedAt = new Date(); + await this.employeePositionRepository.save(employeePosition); + }); + }), + ); + //create employeeTempPosmaster + await Promise.all( + _orgemployeeTempPosMaster + .filter((x: EmployeeTempPosMaster) => x.orgChild4Id == data4Id) + .map(async (item: any) => { + delete item.id; + const employeeTempPosMaster = Object.assign( + new EmployeeTempPosMaster(), + item, + ); + employeeTempPosMaster.positions = []; + if ( + requestBody.typeDraft.toUpperCase() == "ORG_POSITION_PERSON" || + requestBody.typeDraft.toUpperCase() == "ORG_POSITION_PERSON_ROLE" + ) { + // employeeTempPosMaster.next_holderId = item.current_holderId; + } else { + // employeeTempPosMaster.next_holderId = null; + employeeTempPosMaster.isSit = false; + } + if ( + requestBody.typeDraft.toUpperCase() == "ORG_POSITION_ROLE" || + requestBody.typeDraft.toUpperCase() == "ORG_POSITION_PERSON_ROLE" + ) { + employeeTempPosMaster.authRoleId = item.authRoleId; + } else { + employeeTempPosMaster.authRoleId = null; + } + // employeeTempPosMaster.current_holderId = null; + employeeTempPosMaster.orgRevisionId = revision.id; + employeeTempPosMaster.orgRootId = data.id; + employeeTempPosMaster.createdUserId = request.user.sub; + employeeTempPosMaster.createdFullName = request.user.name; + employeeTempPosMaster.createdAt = new Date(); + employeeTempPosMaster.lastUpdateUserId = request.user.sub; + employeeTempPosMaster.lastUpdateFullName = request.user.name; + employeeTempPosMaster.lastUpdatedAt = new Date(); + await this.employeeTempPosMasterRepository.save( + employeeTempPosMaster, + ); + + //create employeePosition + item.positions.map(async (pos: any) => { + delete pos.id; + const employeePosition: EmployeePosition = Object.assign( + new EmployeePosition(), + pos, + ); + employeePosition.posMasterTempId = employeeTempPosMaster.id; + if ( + requestBody.typeDraft.toUpperCase() == "ORG_POSITION" || + requestBody.typeDraft.toUpperCase() == "ORG_POSITION_ROLE" + ) { + employeePosition.positionIsSelected = false; + } + employeePosition.createdUserId = request.user.sub; + employeePosition.createdFullName = request.user.name; + employeePosition.createdAt = new Date(); + employeePosition.lastUpdateUserId = request.user.sub; + employeePosition.lastUpdateFullName = request.user.name; + employeePosition.lastUpdatedAt = new Date(); + await this.employeePositionRepository.save(employeePosition); + }); + }), + ); } }); }); diff --git a/src/migration/1740561148833-updateprofilesalaryaddrefid.ts b/src/migration/1740561148833-updateprofilesalaryaddrefid.ts new file mode 100644 index 00000000..17b538e3 --- /dev/null +++ b/src/migration/1740561148833-updateprofilesalaryaddrefid.ts @@ -0,0 +1,18 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class Updateprofilesalaryaddrefid1740561148833 implements MigrationInterface { + name = 'Updateprofilesalaryaddrefid1740561148833' + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(`CREATE TABLE \`ProfileSalaries\` (\`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', \`Order\` int NULL, \`Date\` datetime NULL, \`SalaryRef\` varchar(255) NULL, \`Amount\` double NULL, \`PositionSalaryAmount\` double NULL, \`PosNoName\` varchar(255) NULL, \`PositionTypeName\` varchar(255) NULL, \`PositionLevelName\` varchar(255) NULL, \`PositionName\` varchar(255) NULL, \`ProfileId\` varchar(255) NULL, PRIMARY KEY (\`id\`)) ENGINE=InnoDB`); + await queryRunner.query(`ALTER TABLE \`profileSalary\` ADD \`refId\` int NULL COMMENT 'refId'`); + await queryRunner.query(`ALTER TABLE \`profileSalary\` ADD \`isEntry\` tinyint NULL COMMENT 'ข้อมูลจาก Entry'`); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`profileSalary\` DROP COLUMN \`isEntry\``); + await queryRunner.query(`ALTER TABLE \`profileSalary\` DROP COLUMN \`refId\``); + await queryRunner.query(`DROP TABLE \`ProfileSalaries\``); + } + +} diff --git a/src/services/rabbitmq.ts b/src/services/rabbitmq.ts index 7b1d35dd..65bc4066 100644 --- a/src/services/rabbitmq.ts +++ b/src/services/rabbitmq.ts @@ -8,6 +8,9 @@ import HttpStatusCode from "../interfaces/http-status"; import { RequestWithUser } from "../middlewares/user"; import { PosMaster } from "../entities/PosMaster"; import { Profile } from "../entities/Profile"; +import { EmployeePosMaster } from "../entities/EmployeePosMaster"; +import { EmployeeTempPosMaster } from "../entities/EmployeeTempPosMaster"; +import { ProfileEmployee } from "../entities/ProfileEmployee"; export let sendToQueue: (payload: any) => void; export let sendToQueueOrg: (payload: any) => void; @@ -42,7 +45,7 @@ export async function init() { console.log("[AMQ] Listening for message..."); createConsumer(queue, channel, handler), //----> (3) Process Consumer - createConsumer(queue_org, channel, handler_org); + createConsumer(queue_org, channel, handler_org); // createConsumer(queue2, channel, handler2); } @@ -125,7 +128,10 @@ async function handler(msg: amqp.ConsumeMessage): Promise { async function handler_org(msg: amqp.ConsumeMessage): Promise { //----> condition before process consume const repoPosmaster = AppDataSource.getRepository(PosMaster); + const repoEmployeePosmaster = AppDataSource.getRepository(EmployeePosMaster); + const repoEmployeeTempPosmaster = AppDataSource.getRepository(EmployeeTempPosMaster); const repoProfile = AppDataSource.getRepository(Profile); + const repoProfileEmployee = AppDataSource.getRepository(ProfileEmployee); const { data, token, user } = JSON.parse(msg.content.toString()); const { id, status, lastUpdateUserId, lastUpdateFullName, lastUpdatedAt } = data; try { @@ -166,6 +172,60 @@ async function handler_org(msg: amqp.ConsumeMessage): Promise { await repoPosmaster.save(item).catch((e) => console.log(e)); }), ); + const employeePosMaster = await repoEmployeePosmaster.find({ + where: { orgRevisionId: id }, + relations: ["positions", "positions.posLevel", "positions.posType"], + }); + await Promise.all( + employeePosMaster.map(async (item) => { + if (item.next_holderId != null && status == "NOW") { + const profile = await repoProfileEmployee.findOne({ + where: { id: item.next_holderId == null ? "" : item.next_holderId }, + }); + const position = await item.positions.find((x) => x.positionIsSelected == true); + const _null: any = null; + if (profile != null) { + profile.posLevelId = position?.posLevelId ?? _null; + profile.posTypeId = position?.posTypeId ?? _null; + profile.position = position?.positionName ?? _null; + await repoProfileEmployee.save(profile); + } + } + // item.current_holderId = item.next_holderId; + // item.next_holderId = null; + item.lastUpdateUserId = lastUpdateUserId; + item.lastUpdateFullName = lastUpdateFullName; + item.lastUpdatedAt = lastUpdatedAt; + await repoEmployeePosmaster.save(item).catch((e) => console.log(e)); + }), + ); + const employeeTempPosMaster = await repoEmployeeTempPosmaster.find({ + where: { orgRevisionId: id }, + relations: ["positions", "positions.posLevel", "positions.posType"], + }); + await Promise.all( + employeeTempPosMaster.map(async (item) => { + if (item.next_holderId != null && status == "NOW") { + const profile = await repoProfileEmployee.findOne({ + where: { id: item.next_holderId == null ? "" : item.next_holderId }, + }); + const position = await item.positions.find((x) => x.positionIsSelected == true); + const _null: any = null; + if (profile != null) { + profile.posLevelId = position?.posLevelId ?? _null; + profile.posTypeId = position?.posTypeId ?? _null; + profile.position = position?.positionName ?? _null; + await repoProfileEmployee.save(profile); + } + } + // item.current_holderId = item.next_holderId; + // item.next_holderId = null; + item.lastUpdateUserId = lastUpdateUserId; + item.lastUpdateFullName = lastUpdateFullName; + item.lastUpdatedAt = lastUpdatedAt; + await repoEmployeeTempPosmaster.save(item).catch((e) => console.log(e)); + }), + ); console.log("[AMQ] Excecute Organization Success"); return true; } catch (error) { @@ -173,4 +233,3 @@ async function handler_org(msg: amqp.ConsumeMessage): Promise { return false; } } - From f981e16243c1def2a0475a8d2e6948206f2d023e Mon Sep 17 00:00:00 2001 From: kittapath Date: Wed, 26 Feb 2025 17:45:45 +0700 Subject: [PATCH 15/19] no message --- src/controllers/OrganizationController.ts | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/controllers/OrganizationController.ts b/src/controllers/OrganizationController.ts index 20438a6d..a90492dc 100644 --- a/src/controllers/OrganizationController.ts +++ b/src/controllers/OrganizationController.ts @@ -380,7 +380,7 @@ export class OrganizationController extends Controller { requestBody.typeDraft.toUpperCase() == "ORG_POSITION_PERSON" || requestBody.typeDraft.toUpperCase() == "ORG_POSITION_PERSON_ROLE" ) { - // employeePosMaster.next_holderId = item.current_holderId; + employeePosMaster.current_holderId = item.current_holderId; } else { // employeePosMaster.next_holderId = null; employeePosMaster.isSit = false; @@ -440,7 +440,7 @@ export class OrganizationController extends Controller { requestBody.typeDraft.toUpperCase() == "ORG_POSITION_PERSON" || requestBody.typeDraft.toUpperCase() == "ORG_POSITION_PERSON_ROLE" ) { - // employeeTempPosMaster.next_holderId = item.current_holderId; + employeeTempPosMaster.current_holderId = item.current_holderId; } else { // employeeTempPosMaster.next_holderId = null; employeeTempPosMaster.isSit = false; @@ -584,7 +584,7 @@ export class OrganizationController extends Controller { requestBody.typeDraft.toUpperCase() == "ORG_POSITION_PERSON" || requestBody.typeDraft.toUpperCase() == "ORG_POSITION_PERSON_ROLE" ) { - // employeePosMaster.next_holderId = item.current_holderId; + employeePosMaster.current_holderId = item.current_holderId; } else { // employeePosMaster.next_holderId = null; employeePosMaster.isSit = false; @@ -646,7 +646,7 @@ export class OrganizationController extends Controller { requestBody.typeDraft.toUpperCase() == "ORG_POSITION_PERSON" || requestBody.typeDraft.toUpperCase() == "ORG_POSITION_PERSON_ROLE" ) { - // employeeTempPosMaster.next_holderId = item.current_holderId; + employeeTempPosMaster.current_holderId = item.current_holderId; } else { // employeeTempPosMaster.next_holderId = null; employeeTempPosMaster.isSit = false; @@ -792,7 +792,7 @@ export class OrganizationController extends Controller { requestBody.typeDraft.toUpperCase() == "ORG_POSITION_PERSON" || requestBody.typeDraft.toUpperCase() == "ORG_POSITION_PERSON_ROLE" ) { - // employeePosMaster.next_holderId = item.current_holderId; + employeePosMaster.current_holderId = item.current_holderId; } else { // employeePosMaster.next_holderId = null; employeePosMaster.isSit = false; @@ -858,7 +858,7 @@ export class OrganizationController extends Controller { requestBody.typeDraft.toUpperCase() == "ORG_POSITION_PERSON" || requestBody.typeDraft.toUpperCase() == "ORG_POSITION_PERSON_ROLE" ) { - // employeeTempPosMaster.next_holderId = item.current_holderId; + employeeTempPosMaster.current_holderId = item.current_holderId; } else { // employeeTempPosMaster.next_holderId = null; employeeTempPosMaster.isSit = false; @@ -1009,7 +1009,7 @@ export class OrganizationController extends Controller { requestBody.typeDraft.toUpperCase() == "ORG_POSITION_PERSON" || requestBody.typeDraft.toUpperCase() == "ORG_POSITION_PERSON_ROLE" ) { - // employeePosMaster.next_holderId = item.current_holderId; + employeePosMaster.current_holderId = item.current_holderId; } else { // employeePosMaster.next_holderId = null; employeePosMaster.isSit = false; @@ -1075,7 +1075,7 @@ export class OrganizationController extends Controller { requestBody.typeDraft.toUpperCase() == "ORG_POSITION_PERSON" || requestBody.typeDraft.toUpperCase() == "ORG_POSITION_PERSON_ROLE" ) { - // employeeTempPosMaster.next_holderId = item.current_holderId; + employeeTempPosMaster.current_holderId = item.current_holderId; } else { // employeeTempPosMaster.next_holderId = null; employeeTempPosMaster.isSit = false; @@ -1226,7 +1226,7 @@ export class OrganizationController extends Controller { requestBody.typeDraft.toUpperCase() == "ORG_POSITION_PERSON" || requestBody.typeDraft.toUpperCase() == "ORG_POSITION_PERSON_ROLE" ) { - // employeePosMaster.next_holderId = item.current_holderId; + employeePosMaster.current_holderId = item.current_holderId; } else { // employeePosMaster.next_holderId = null; employeePosMaster.isSit = false; @@ -1289,7 +1289,7 @@ export class OrganizationController extends Controller { requestBody.typeDraft.toUpperCase() == "ORG_POSITION_PERSON" || requestBody.typeDraft.toUpperCase() == "ORG_POSITION_PERSON_ROLE" ) { - // employeeTempPosMaster.next_holderId = item.current_holderId; + employeeTempPosMaster.current_holderId = item.current_holderId; } else { // employeeTempPosMaster.next_holderId = null; employeeTempPosMaster.isSit = false; From 0b1ba202fc6e461ec6ed9d169a7c84b960532822 Mon Sep 17 00:00:00 2001 From: kittapath Date: Wed, 26 Feb 2025 17:49:44 +0700 Subject: [PATCH 16/19] =?UTF-8?q?=E0=B8=AB=E0=B8=B2=E0=B8=AB=E0=B8=B1?= =?UTF-8?q?=E0=B8=A7=E0=B8=AB=E0=B8=99=E0=B9=89=E0=B8=B2=E0=B8=9B=E0=B8=A5?= =?UTF-8?q?=E0=B8=B1=E0=B8=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/ProfileController.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/controllers/ProfileController.ts b/src/controllers/ProfileController.ts index f640b697..82d0ed8c 100644 --- a/src/controllers/ProfileController.ts +++ b/src/controllers/ProfileController.ts @@ -1740,10 +1740,13 @@ export class ProfileController extends Controller { }, }); if (!posMaster) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลการครองตำแหน่ง"); + posMaster.current_holderId = ""; // return new HttpSuccess({ data: [], total: 0 }); } else if ((posMaster?.current_holder?.posLevel?.posLevelAuthority ?? null) == "GOVERNOR") { return new HttpSuccess({ data: [], total: 0 }); } + console.log(posMaster); + console.log(posMaster.id); let condition: any = { orgRootId: posMaster.orgRootId, id: Not(posMaster.current_holderId || ""), @@ -1773,6 +1776,9 @@ export class ProfileController extends Controller { condition.isDirector = true; conditionNow.isDirector = true; } + console.log(condition); + console.log("------------------"); + console.log(conditionNow); if (body.isAct == true) { const [lists, total] = await AppDataSource.getRepository(viewDirectorActing) .createQueryBuilder("viewDirectorActing") From 3591dff755453280644a2c50db6f6dfa6ce8c9d2 Mon Sep 17 00:00:00 2001 From: Bright Date: Wed, 26 Feb 2025 18:04:20 +0700 Subject: [PATCH 17/19] migrate --- .../view/viewCurrentTenureEmployee.ts | 151 +++++++++++++++ src/entities/view/viewCurrentTenureOfficer.ts | 151 +++++++++++++++ .../1740558529773-addViewCurrentTenure.ts | 172 ++++++++++++++++++ 3 files changed, 474 insertions(+) create mode 100644 src/entities/view/viewCurrentTenureEmployee.ts create mode 100644 src/entities/view/viewCurrentTenureOfficer.ts create mode 100644 src/migration/1740558529773-addViewCurrentTenure.ts diff --git a/src/entities/view/viewCurrentTenureEmployee.ts b/src/entities/view/viewCurrentTenureEmployee.ts new file mode 100644 index 00000000..294e7045 --- /dev/null +++ b/src/entities/view/viewCurrentTenureEmployee.ts @@ -0,0 +1,151 @@ +import { ViewColumn, ViewEntity } from "typeorm"; + +@ViewEntity({ + expression: ` + SELECT + DATE(MIN(commandDateAffect)) AS commandDateAffect, + TIMESTAMPDIFF( + DAY, + LAG(MIN(commandDateAffect)) OVER (PARTITION BY profileEmployeeId ORDER BY commandDateAffect, \`order\` ASC), MIN(commandDateAffect)) AS days_diff, + TIMESTAMPDIFF( + DAY, + LAG(MIN(commandDateAffect)) OVER (PARTITION BY profileEmployeeId ORDER BY commandDateAffect, \`order\` ASC), MIN(commandDateAffect)) / 365.2524 AS 'Years', + TIMESTAMPDIFF( + DAY, + LAG(MIN(commandDateAffect)) OVER (PARTITION BY profileEmployeeId ORDER BY commandDateAffect, \`order\` ASC), MIN(commandDateAffect)) / 30.4375 % 12 AS 'Months', + TIMESTAMPDIFF( + DAY, + LAG(MIN(commandDateAffect)) OVER (PARTITION BY profileEmployeeId ORDER BY commandDateAffect, \`order\` ASC), MIN(commandDateAffect)) % 30.4375 AS 'Days', + positionName, + positionCee, + posNo, + positionType, + positionLevel, + OrgRoot, + orgChild1, + orgChild2, + orgChild3, + orgChild4, + commandCode, + commandName, + commandNo, + commandYear, + remark, + profileEmployeeId, + ROW_NUMBER() OVER (PARTITION BY profileEmployeeId ORDER BY commandDateAffect ASC) AS orderNumber + FROM + profileSalary + WHERE + profileEmployeeId IS NOT NULL AND + commandCode IN (1, 2, 3, 4, 8, 10, 11, 12, 15, 16) + GROUP BY + profileEmployeeId, positionName + + UNION ALL + + SELECT + CURDATE() AS commandDateAffect, + TIMESTAMPDIFF(DAY, MAX(commandDateAffect), CURDATE()) AS days_diff, + TIMESTAMPDIFF(DAY, MAX(commandDateAffect), CURDATE()) / 365.2524 AS 'Years', + TIMESTAMPDIFF(DAY, MAX(commandDateAffect), CURDATE()) / 30.4375 % 12 AS 'Months', + TIMESTAMPDIFF(DAY, MAX(commandDateAffect), CURDATE()) % 30.4375 AS 'Days', + NULL AS positionName, + NULL AS positionCee, + NULL AS posNo, + NULL AS positionType, + NULL AS positionLevel, + NULL AS OrgRoot, + NULL AS orgChild1, + NULL AS orgChild2, + NULL AS orgChild3, + NULL AS orgChild4, + NULL AS commandCode, + NULL AS commandName, + NULL AS commandNo, + NULL AS commandYear, + 'Comparison with current date' AS remark, + profileEmployeeId, + NULL AS orderNumber + FROM + profileSalary + WHERE + profileEmployeeId IS NOT NULL AND + commandCode IN (1, 2, 3, 4, 8, 10, 11, 12, 15, 16) + GROUP BY + profileEmployeeId + + ORDER BY + profileEmployeeId, + commandDateAffect ASC + `, +}) +export class viewCurrentTenureEmployee { + @ViewColumn() + commandDateAffect: Date; + + @ViewColumn() + days_diff: number; + + @ViewColumn() + Years: number; + + @ViewColumn() + Months: number; + + @ViewColumn() + Days: number; + + @ViewColumn() + positionName: string; + + @ViewColumn() + positionCee: string; + + @ViewColumn() + posNo: string; + + @ViewColumn() + positionExecutive: string; + + @ViewColumn() + positionType: string; + + @ViewColumn() + positionLevel: string; + + @ViewColumn() + OrgRoot: string; + + @ViewColumn() + orgChild1: string; + + @ViewColumn() + orgChild2: string; + + @ViewColumn() + orgChild3: string; + + @ViewColumn() + orgChild4: string; + + @ViewColumn() + commandCode: number; + + @ViewColumn() + commandName: string; + + @ViewColumn() + commandNo: string; + + @ViewColumn() + commandYear: number; + + @ViewColumn() + remark: string; + + @ViewColumn() + profileEmployeeId: string; + + @ViewColumn() + orderNumber: number; +} \ No newline at end of file diff --git a/src/entities/view/viewCurrentTenureOfficer.ts b/src/entities/view/viewCurrentTenureOfficer.ts new file mode 100644 index 00000000..5899687c --- /dev/null +++ b/src/entities/view/viewCurrentTenureOfficer.ts @@ -0,0 +1,151 @@ +import { ViewColumn, ViewEntity } from "typeorm"; + +@ViewEntity({ + expression: ` + SELECT + DATE(MIN(commandDateAffect)) AS commandDateAffect, + TIMESTAMPDIFF( + DAY, + LAG(MIN(commandDateAffect)) OVER (PARTITION BY profileId ORDER BY commandDateAffect, \`order\` ASC), MIN(commandDateAffect)) AS days_diff, + TIMESTAMPDIFF( + DAY, + LAG(MIN(commandDateAffect)) OVER (PARTITION BY profileId ORDER BY commandDateAffect, \`order\` ASC), MIN(commandDateAffect)) / 365.2524 AS 'Years', + TIMESTAMPDIFF( + DAY, + LAG(MIN(commandDateAffect)) OVER (PARTITION BY profileId ORDER BY commandDateAffect, \`order\` ASC), MIN(commandDateAffect)) / 30.4375 % 12 AS 'Months', + TIMESTAMPDIFF( + DAY, + LAG(MIN(commandDateAffect)) OVER (PARTITION BY profileId ORDER BY commandDateAffect, \`order\` ASC), MIN(commandDateAffect)) % 30.4375 AS 'Days', + positionName, + positionCee, + posNo, + positionExecutive, + positionType, + positionLevel, + OrgRoot, + orgChild1, + orgChild2, + orgChild3, + orgChild4, + commandCode, + commandName, + commandNo, + commandYear, + remark, + profileId, + ROW_NUMBER() OVER (PARTITION BY profileId ORDER BY commandDateAffect ASC) AS orderNumber + FROM + profileSalary + WHERE + commandCode IN (1, 2, 3, 4, 8, 10, 11, 12, 15, 16) + GROUP BY + profileId, positionName + + UNION ALL + + SELECT + CURDATE() AS commandDateAffect, + TIMESTAMPDIFF(DAY, MAX(commandDateAffect), CURDATE()) AS days_diff, + TIMESTAMPDIFF(DAY, MAX(commandDateAffect), CURDATE()) / 365.2524 AS 'Years', + TIMESTAMPDIFF(DAY, MAX(commandDateAffect), CURDATE()) / 30.4375 % 12 AS 'Months', + TIMESTAMPDIFF(DAY, MAX(commandDateAffect), CURDATE()) % 30.4375 AS 'Days', + NULL AS positionName, + NULL AS positionCee, + NULL AS posNo, + NULL AS positionExecutive, + NULL AS positionType, + NULL AS positionLevel, + NULL AS OrgRoot, + NULL AS orgChild1, + NULL AS orgChild2, + NULL AS orgChild3, + NULL AS orgChild4, + NULL AS commandCode, + NULL AS commandName, + NULL AS commandNo, + NULL AS commandYear, + 'Comparison with current date' AS remark, + profileId, + NULL AS orderNumber + FROM + profileSalary + WHERE + commandCode IN (1, 2, 3, 4, 8, 10, 11, 12, 15, 16) + GROUP BY + profileId + + ORDER BY + profileId, + commandDateAffect ASC + `, +}) +export class viewCurrentTenureOfficer { + @ViewColumn() + commandDateAffect: Date; + + @ViewColumn() + days_diff: number; + + @ViewColumn() + Years: number; + + @ViewColumn() + Months: number; + + @ViewColumn() + Days: number; + + @ViewColumn() + positionName: string; + + @ViewColumn() + positionCee: string; + + @ViewColumn() + posNo: string; + + @ViewColumn() + positionExecutive: string; + + @ViewColumn() + positionType: string; + + @ViewColumn() + positionLevel: string; + + @ViewColumn() + OrgRoot: string; + + @ViewColumn() + orgChild1: string; + + @ViewColumn() + orgChild2: string; + + @ViewColumn() + orgChild3: string; + + @ViewColumn() + orgChild4: string; + + @ViewColumn() + commandCode: number; + + @ViewColumn() + commandName: string; + + @ViewColumn() + commandNo: string; + + @ViewColumn() + commandYear: number; + + @ViewColumn() + remark: string; + + @ViewColumn() + profileId: string; + + @ViewColumn() + orderNumber: number; +} diff --git a/src/migration/1740558529773-addViewCurrentTenure.ts b/src/migration/1740558529773-addViewCurrentTenure.ts new file mode 100644 index 00000000..fc2d96e8 --- /dev/null +++ b/src/migration/1740558529773-addViewCurrentTenure.ts @@ -0,0 +1,172 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class AddViewCurrentTenure1740558529773 implements MigrationInterface { + name = 'AddViewCurrentTenure1740558529773' + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(`CREATE VIEW \`view_current_tenure_officer\` AS + SELECT + DATE(MIN(commandDateAffect)) AS commandDateAffect, + TIMESTAMPDIFF( + DAY, + LAG(MIN(commandDateAffect)) OVER (PARTITION BY profileId ORDER BY commandDateAffect, \`order\` ASC), MIN(commandDateAffect)) AS days_diff, + TIMESTAMPDIFF( + DAY, + LAG(MIN(commandDateAffect)) OVER (PARTITION BY profileId ORDER BY commandDateAffect, \`order\` ASC), MIN(commandDateAffect)) / 365.2524 AS 'Years', + TIMESTAMPDIFF( + DAY, + LAG(MIN(commandDateAffect)) OVER (PARTITION BY profileId ORDER BY commandDateAffect, \`order\` ASC), MIN(commandDateAffect)) / 30.4375 % 12 AS 'Months', + TIMESTAMPDIFF( + DAY, + LAG(MIN(commandDateAffect)) OVER (PARTITION BY profileId ORDER BY commandDateAffect, \`order\` ASC), MIN(commandDateAffect)) % 30.4375 AS 'Days', + positionName, + positionCee, + posNo, + positionExecutive, + positionType, + positionLevel, + OrgRoot, + orgChild1, + orgChild2, + orgChild3, + orgChild4, + commandCode, + commandName, + commandNo, + commandYear, + remark, + profileId, + ROW_NUMBER() OVER (PARTITION BY profileId ORDER BY commandDateAffect ASC) AS orderNumber + FROM + profileSalary + WHERE + commandCode IN (1, 2, 3, 4, 8, 10, 11, 12, 15, 16) + GROUP BY + profileId, positionName + + UNION ALL + + SELECT + CURDATE() AS commandDateAffect, + TIMESTAMPDIFF(DAY, MAX(commandDateAffect), CURDATE()) AS days_diff, + TIMESTAMPDIFF(DAY, MAX(commandDateAffect), CURDATE()) / 365.2524 AS 'Years', + TIMESTAMPDIFF(DAY, MAX(commandDateAffect), CURDATE()) / 30.4375 % 12 AS 'Months', + TIMESTAMPDIFF(DAY, MAX(commandDateAffect), CURDATE()) % 30.4375 AS 'Days', + NULL AS positionName, + NULL AS positionCee, + NULL AS posNo, + NULL AS positionExecutive, + NULL AS positionType, + NULL AS positionLevel, + NULL AS OrgRoot, + NULL AS orgChild1, + NULL AS orgChild2, + NULL AS orgChild3, + NULL AS orgChild4, + NULL AS commandCode, + NULL AS commandName, + NULL AS commandNo, + NULL AS commandYear, + 'Comparison with current date' AS remark, + profileId, + NULL AS orderNumber + FROM + profileSalary + WHERE + commandCode IN (1, 2, 3, 4, 8, 10, 11, 12, 15, 16) + GROUP BY + profileId + + ORDER BY + profileId, + commandDateAffect ASC + `); + await queryRunner.query(`INSERT INTO \`bma_ehr_organization_demo\`.\`typeorm_metadata\`(\`database\`, \`schema\`, \`table\`, \`type\`, \`name\`, \`value\`) VALUES (DEFAULT, ?, DEFAULT, ?, ?, ?)`, ["bma_ehr_organization_demo","VIEW","view_current_tenure_officer","SELECT\n DATE(MIN(commandDateAffect)) AS commandDateAffect,\n TIMESTAMPDIFF(\n DAY,\n LAG(MIN(commandDateAffect)) OVER (PARTITION BY profileId ORDER BY commandDateAffect, `order` ASC), MIN(commandDateAffect)) AS days_diff,\n TIMESTAMPDIFF(\n DAY,\n LAG(MIN(commandDateAffect)) OVER (PARTITION BY profileId ORDER BY commandDateAffect, `order` ASC), MIN(commandDateAffect)) / 365.2524 AS 'Years',\n TIMESTAMPDIFF(\n DAY,\n LAG(MIN(commandDateAffect)) OVER (PARTITION BY profileId ORDER BY commandDateAffect, `order` ASC), MIN(commandDateAffect)) / 30.4375 % 12 AS 'Months',\n TIMESTAMPDIFF(\n DAY,\n LAG(MIN(commandDateAffect)) OVER (PARTITION BY profileId ORDER BY commandDateAffect, `order` ASC), MIN(commandDateAffect)) % 30.4375 AS 'Days',\n positionName,\n positionCee,\n posNo,\n positionExecutive,\n positionType,\n positionLevel,\n OrgRoot,\n orgChild1,\n orgChild2,\n orgChild3,\n orgChild4,\n commandCode,\n commandName,\n commandNo,\n commandYear,\n remark,\n profileId,\n ROW_NUMBER() OVER (PARTITION BY profileId ORDER BY commandDateAffect ASC) AS orderNumber\n FROM\n profileSalary\n WHERE\n commandCode IN (1, 2, 3, 4, 8, 10, 11, 12, 15, 16)\n GROUP BY\n profileId, positionName\n\n UNION ALL\n\n SELECT\n CURDATE() AS commandDateAffect,\n TIMESTAMPDIFF(DAY, MAX(commandDateAffect), CURDATE()) AS days_diff,\n TIMESTAMPDIFF(DAY, MAX(commandDateAffect), CURDATE()) / 365.2524 AS 'Years',\n TIMESTAMPDIFF(DAY, MAX(commandDateAffect), CURDATE()) / 30.4375 % 12 AS 'Months',\n TIMESTAMPDIFF(DAY, MAX(commandDateAffect), CURDATE()) % 30.4375 AS 'Days',\n NULL AS positionName,\n NULL AS positionCee,\n NULL AS posNo,\n NULL AS positionExecutive,\n NULL AS positionType,\n NULL AS positionLevel,\n NULL AS OrgRoot,\n NULL AS orgChild1,\n NULL AS orgChild2,\n NULL AS orgChild3,\n NULL AS orgChild4,\n NULL AS commandCode,\n NULL AS commandName,\n NULL AS commandNo,\n NULL AS commandYear,\n 'Comparison with current date' AS remark,\n profileId,\n NULL AS orderNumber\n FROM\n profileSalary\n WHERE\n commandCode IN (1, 2, 3, 4, 8, 10, 11, 12, 15, 16)\n GROUP BY\n profileId\n\n ORDER BY\n profileId,\n commandDateAffect ASC"]); + await queryRunner.query(`CREATE VIEW \`view_current_tenure_employee\` AS + SELECT + DATE(MIN(commandDateAffect)) AS commandDateAffect, + TIMESTAMPDIFF( + DAY, + LAG(MIN(commandDateAffect)) OVER (PARTITION BY profileEmployeeId ORDER BY commandDateAffect, \`order\` ASC), MIN(commandDateAffect)) AS days_diff, + TIMESTAMPDIFF( + DAY, + LAG(MIN(commandDateAffect)) OVER (PARTITION BY profileEmployeeId ORDER BY commandDateAffect, \`order\` ASC), MIN(commandDateAffect)) / 365.2524 AS 'Years', + TIMESTAMPDIFF( + DAY, + LAG(MIN(commandDateAffect)) OVER (PARTITION BY profileEmployeeId ORDER BY commandDateAffect, \`order\` ASC), MIN(commandDateAffect)) / 30.4375 % 12 AS 'Months', + TIMESTAMPDIFF( + DAY, + LAG(MIN(commandDateAffect)) OVER (PARTITION BY profileEmployeeId ORDER BY commandDateAffect, \`order\` ASC), MIN(commandDateAffect)) % 30.4375 AS 'Days', + positionName, + positionCee, + posNo, + positionType, + positionLevel, + OrgRoot, + orgChild1, + orgChild2, + orgChild3, + orgChild4, + commandCode, + commandName, + commandNo, + commandYear, + remark, + profileEmployeeId, + ROW_NUMBER() OVER (PARTITION BY profileEmployeeId ORDER BY commandDateAffect ASC) AS orderNumber + FROM + profileSalary + WHERE + profileEmployeeId IS NOT NULL AND + commandCode IN (1, 2, 3, 4, 8, 10, 11, 12, 15, 16) + GROUP BY + profileEmployeeId, positionName + + UNION ALL + + SELECT + CURDATE() AS commandDateAffect, + TIMESTAMPDIFF(DAY, MAX(commandDateAffect), CURDATE()) AS days_diff, + TIMESTAMPDIFF(DAY, MAX(commandDateAffect), CURDATE()) / 365.2524 AS 'Years', + TIMESTAMPDIFF(DAY, MAX(commandDateAffect), CURDATE()) / 30.4375 % 12 AS 'Months', + TIMESTAMPDIFF(DAY, MAX(commandDateAffect), CURDATE()) % 30.4375 AS 'Days', + NULL AS positionName, + NULL AS positionCee, + NULL AS posNo, + NULL AS positionType, + NULL AS positionLevel, + NULL AS OrgRoot, + NULL AS orgChild1, + NULL AS orgChild2, + NULL AS orgChild3, + NULL AS orgChild4, + NULL AS commandCode, + NULL AS commandName, + NULL AS commandNo, + NULL AS commandYear, + 'Comparison with current date' AS remark, + profileEmployeeId, + NULL AS orderNumber + FROM + profileSalary + WHERE + profileEmployeeId IS NOT NULL AND + commandCode IN (1, 2, 3, 4, 8, 10, 11, 12, 15, 16) + GROUP BY + profileEmployeeId + + ORDER BY + profileEmployeeId, + commandDateAffect ASC + `); + await queryRunner.query(`INSERT INTO \`bma_ehr_organization_demo\`.\`typeorm_metadata\`(\`database\`, \`schema\`, \`table\`, \`type\`, \`name\`, \`value\`) VALUES (DEFAULT, ?, DEFAULT, ?, ?, ?)`, ["bma_ehr_organization_demo","VIEW","view_current_tenure_employee","SELECT\n DATE(MIN(commandDateAffect)) AS commandDateAffect,\n TIMESTAMPDIFF(\n DAY,\n LAG(MIN(commandDateAffect)) OVER (PARTITION BY profileEmployeeId ORDER BY commandDateAffect, `order` ASC), MIN(commandDateAffect)) AS days_diff,\n TIMESTAMPDIFF(\n DAY,\n LAG(MIN(commandDateAffect)) OVER (PARTITION BY profileEmployeeId ORDER BY commandDateAffect, `order` ASC), MIN(commandDateAffect)) / 365.2524 AS 'Years',\n TIMESTAMPDIFF(\n DAY,\n LAG(MIN(commandDateAffect)) OVER (PARTITION BY profileEmployeeId ORDER BY commandDateAffect, `order` ASC), MIN(commandDateAffect)) / 30.4375 % 12 AS 'Months',\n TIMESTAMPDIFF(\n DAY,\n LAG(MIN(commandDateAffect)) OVER (PARTITION BY profileEmployeeId ORDER BY commandDateAffect, `order` ASC), MIN(commandDateAffect)) % 30.4375 AS 'Days',\n positionName,\n positionCee,\n posNo,\n positionType,\n positionLevel,\n OrgRoot,\n orgChild1,\n orgChild2,\n orgChild3,\n orgChild4,\n commandCode,\n commandName,\n commandNo,\n commandYear,\n remark,\n profileEmployeeId,\n ROW_NUMBER() OVER (PARTITION BY profileEmployeeId ORDER BY commandDateAffect ASC) AS orderNumber\n FROM\n profileSalary\n WHERE\n profileEmployeeId IS NOT NULL AND\n commandCode IN (1, 2, 3, 4, 8, 10, 11, 12, 15, 16)\n GROUP BY\n profileEmployeeId, positionName\n\n UNION ALL\n\n SELECT\n CURDATE() AS commandDateAffect,\n TIMESTAMPDIFF(DAY, MAX(commandDateAffect), CURDATE()) AS days_diff,\n TIMESTAMPDIFF(DAY, MAX(commandDateAffect), CURDATE()) / 365.2524 AS 'Years',\n TIMESTAMPDIFF(DAY, MAX(commandDateAffect), CURDATE()) / 30.4375 % 12 AS 'Months',\n TIMESTAMPDIFF(DAY, MAX(commandDateAffect), CURDATE()) % 30.4375 AS 'Days',\n NULL AS positionName,\n NULL AS positionCee,\n NULL AS posNo,\n NULL AS positionType,\n NULL AS positionLevel,\n NULL AS OrgRoot,\n NULL AS orgChild1,\n NULL AS orgChild2,\n NULL AS orgChild3,\n NULL AS orgChild4,\n NULL AS commandCode,\n NULL AS commandName,\n NULL AS commandNo,\n NULL AS commandYear,\n 'Comparison with current date' AS remark,\n profileEmployeeId,\n NULL AS orderNumber\n FROM\n profileSalary\n WHERE\n profileEmployeeId IS NOT NULL AND\n commandCode IN (1, 2, 3, 4, 8, 10, 11, 12, 15, 16)\n GROUP BY\n profileEmployeeId\n\n ORDER BY\n profileEmployeeId,\n commandDateAffect ASC"]); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`DELETE FROM \`bma_ehr_organization_demo\`.\`typeorm_metadata\` WHERE \`type\` = ? AND \`name\` = ? AND \`schema\` = ?`, ["VIEW","view_current_tenure_employee","bma_ehr_organization_demo"]); + await queryRunner.query(`DROP VIEW \`view_current_tenure_employee\``); + await queryRunner.query(`DELETE FROM \`bma_ehr_organization_demo\`.\`typeorm_metadata\` WHERE \`type\` = ? AND \`name\` = ? AND \`schema\` = ?`, ["VIEW","view_current_tenure_officer","bma_ehr_organization_demo"]); + await queryRunner.query(`DROP VIEW \`view_current_tenure_officer\``); + } + +} From b871a2425aa449ecdacee9423f200912a8efd237 Mon Sep 17 00:00:00 2001 From: Bright Date: Thu, 27 Feb 2025 14:42:35 +0700 Subject: [PATCH 18/19] =?UTF-8?q?=E0=B8=A3=E0=B8=B0=E0=B8=A2=E0=B8=B0?= =?UTF-8?q?=E0=B9=80=E0=B8=A7=E0=B8=A5=E0=B8=B2=E0=B8=84=E0=B8=A3=E0=B8=AD?= =?UTF-8?q?=E0=B8=87=E0=B8=95=E0=B8=B3=E0=B9=81=E0=B8=AB=E0=B8=99=E0=B9=88?= =?UTF-8?q?=E0=B8=87=20(=E0=B9=83=E0=B8=99=E0=B8=97=E0=B8=B0=E0=B9=80?= =?UTF-8?q?=E0=B8=9A=E0=B8=B5=E0=B8=A2=E0=B8=99=E0=B8=9B=E0=B8=A3=E0=B8=B0?= =?UTF-8?q?=E0=B8=A7=E0=B8=B1=E0=B8=95=E0=B8=B4)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/ProfileSalaryController.ts | 49 ++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/src/controllers/ProfileSalaryController.ts b/src/controllers/ProfileSalaryController.ts index cbba0397..d051704a 100644 --- a/src/controllers/ProfileSalaryController.ts +++ b/src/controllers/ProfileSalaryController.ts @@ -80,6 +80,55 @@ export class ProfileSalaryController extends Controller { return new HttpSuccess(record); } + @Get("tenure/{profileId}") + public async getPositionTenure(@Path() profileId: string, @Request() req: RequestWithUser) { + const position = await AppDataSource.query( + "CALL GetProfileSalaryPosition(?)", + [profileId] + ); + const _position = position.length > 0 ? position[0] : [] + const mapPosition = _position.length > 1 + ? _position + .slice(1) + .map((curr: any, index: number) => ({ + year: curr.Years ? Math.floor(Number(curr.Years)) : 0, + month: curr.Months ? Math.floor(Number(curr.Months)) : 0, + day: curr.Days ? Math.floor(Number(curr.Days)) : 0, + name: _position[index]?.positionName + })) + : []; + + const posLevel = [{ + year: 1, + month: 0, + day: 0, + name: "ต้น", + }]; + + const posExecutive = await AppDataSource.query( + "CALL GetProfileSalaryExecutive(?)", + [profileId] + ); + const _posExecutive = posExecutive.length > 0 ? posExecutive[0] : [] + const mapPosExecutive = _posExecutive.length > 1 + ? _posExecutive + .slice(1) + .map((curr: any, index: number) => ({ + year: curr.Years ? Math.floor(Number(curr.Years)) : 0, + month: curr.Months ? Math.floor(Number(curr.Months)) : 0, + day: curr.Days ? Math.floor(Number(curr.Days)) : 0, + name: _posExecutive[index]?.positionName + })) + : []; + + return new HttpSuccess({ + position: mapPosition, + posLevel: posLevel, + posExecutive: mapPosExecutive + }); + } + + @Get("admin/{profileId}") public async getSalaryAdmin(@Path() profileId: string, @Request() req: RequestWithUser) { let _workflow = await new permission().Workflow(req, profileId, "SYS_SALARY_OFFICER"); From 7b57a073d6645b6b95215462f81205bacd4a7fe7 Mon Sep 17 00:00:00 2001 From: AdisakKanthawilang Date: Thu, 27 Feb 2025 15:20:13 +0700 Subject: [PATCH 19/19] fix --- src/controllers/CommandController.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/controllers/CommandController.ts b/src/controllers/CommandController.ts index 77888655..e70ddebd 100644 --- a/src/controllers/CommandController.ts +++ b/src/controllers/CommandController.ts @@ -5008,7 +5008,6 @@ export class CommandController extends Controller { statusReport: "DONE", })); await this.posMasterActRepository.save(data); - await Promise.all( posMasters.map(async (item) => { if (item.posMasterChild != null && item.posMasterChild.current_holderId != null) { @@ -5049,6 +5048,7 @@ export class CommandController extends Controller { createdAt: new Date(), lastUpdatedAt: new Date(), commandNo: body.refIds[0].commandNo, + refCommandNo: body.refIds[0].commandNo, commandYear: body.refIds[0].commandYear, posNo: item.posMaster.posMasterNo, posNoAbb: shortName, @@ -5058,7 +5058,7 @@ export class CommandController extends Controller { commandName: body.refIds[0].commandName, remark: body.refIds[0].remark, }; - + const dataAct = new ProfileActposition(); Object.assign(dataAct, metaAct); const historyAct = new ProfileActpositionHistory();