From 25fa65b3b54eaa546142c475a6cecaf019519917 Mon Sep 17 00:00:00 2001 From: Kittapath Date: Tue, 9 Jul 2024 00:03:47 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B9=81=E0=B8=81=E0=B9=89env?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/release.yaml | 3 +- .../KpiUserEvaluationController.ts | 43 +++++++++++++++++++ src/entities/kpiUserEvaluation.ts | 4 +- .../1720326486719-add_table_kpi_add_bool.ts | 16 +++++++ 4 files changed, 63 insertions(+), 3 deletions(-) create mode 100644 src/migration/1720326486719-add_table_kpi_add_bool.ts diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 0442504..4f4bfa4 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -9,7 +9,8 @@ env: REGISTRY: docker.frappet.com IMAGE_NAME: ehr/bma-ehr-kpi-service DEPLOY_HOST: frappet.com - COMPOSE_PATH: /home/frappet/docker/bma/bma-ehr-kpi + COMPOSE_PATH: /home/frappet/docker/bma-ehr + # COMPOSE_PATH: /home/frappet/docker/bma/bma-ehr-kpi jobs: # act workflow_dispatch -W .github/workflows/release.yaml --input IMAGE_VER=latest -s DOCKER_USER=admin -s DOCKER_PASS=FPTadmin2357 -s SSH_PASSWORD=FPTadmin2357 release-test: diff --git a/src/controllers/KpiUserEvaluationController.ts b/src/controllers/KpiUserEvaluationController.ts index 8335f7b..45bff04 100644 --- a/src/controllers/KpiUserEvaluationController.ts +++ b/src/controllers/KpiUserEvaluationController.ts @@ -1234,6 +1234,49 @@ export class KpiUserEvaluationController extends Controller { await this.kpiUserEvalutionRepository.save(kpiUserEvaluation); return new HttpSuccess(kpiUserEvaluation.id); } + /** + * API บันทึกข้อมูลลง kp7 (USER) + * + * @summary บันทึกข้อมูลลง kp7 (USER) + * + * @param {string} id Guid, *Id คนประเมิน (USER) + */ + @Post("done/kp7") + async updateKpiEvaluationTokp7( + @Body() + requestBody: { + id: string[]; + }, + @Request() request: { user: Record }, + ) { + const kpiUserEvaluations = await this.kpiUserEvalutionRepository.find({ + where: { id: In(requestBody.id) }, + }); + + Promise.all( + kpiUserEvaluations.map(async (kpiUserEvaluation) => { + kpiUserEvaluation.evaluationStatus = "KP7"; + await new CallAPI() + .PostData(request, "org/profile/assessments", { + date: new Date(), + name: kpiUserEvaluation.evaluationResults, + point1Total: kpiUserEvaluation.weightPoint1, + point1: kpiUserEvaluation.totalPoint1, + point2Total: kpiUserEvaluation.weightPoint2, + point2: kpiUserEvaluation.totalPoint2_1 + kpiUserEvaluation.totalPoint2_2, + pointSumTotal: kpiUserEvaluation.summaryWeight, + pointSum: kpiUserEvaluation.summaryPoint, + profileId: kpiUserEvaluation.profileId, + }) + .then(async (x) => {}); + kpiUserEvaluation.lastUpdateUserId = request.user.sub; + kpiUserEvaluation.lastUpdateFullName = request.user.name; + await this.kpiUserEvalutionRepository.save(kpiUserEvaluation); + }), + ); + + return new HttpSuccess(); + } /** * API รายละเอียดสรุปผลการประเมิน (USER) diff --git a/src/entities/kpiUserEvaluation.ts b/src/entities/kpiUserEvaluation.ts index 2d680be..9168238 100644 --- a/src/entities/kpiUserEvaluation.ts +++ b/src/entities/kpiUserEvaluation.ts @@ -311,7 +311,7 @@ export class KpiUserEvaluation extends EntityBase { @Column({ nullable: true, comment: "หมายเหตุ ผู้บังคับบัญชาเหนือขึ้นไป", - default: false, + default: null, }) isReasonCommander: boolean; @@ -326,7 +326,7 @@ export class KpiUserEvaluation extends EntityBase { @Column({ nullable: true, comment: "หมายเหตุ ผู้บังคับบัญชาเหนือขึ้นไปอีกชั้นหนึ่ง", - default: false, + default: null, }) isReasonCommanderHigh: boolean; diff --git a/src/migration/1720326486719-add_table_kpi_add_bool.ts b/src/migration/1720326486719-add_table_kpi_add_bool.ts new file mode 100644 index 0000000..2f37e57 --- /dev/null +++ b/src/migration/1720326486719-add_table_kpi_add_bool.ts @@ -0,0 +1,16 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class AddTableKpiAddBool1720326486719 implements MigrationInterface { + name = 'AddTableKpiAddBool1720326486719' + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`kpiUserEvaluation\` CHANGE \`isReasonCommander\` \`isReasonCommander\` tinyint NULL COMMENT 'หมายเหตุ ผู้บังคับบัญชาเหนือขึ้นไป'`); + await queryRunner.query(`ALTER TABLE \`kpiUserEvaluation\` CHANGE \`isReasonCommanderHigh\` \`isReasonCommanderHigh\` tinyint NULL COMMENT 'หมายเหตุ ผู้บังคับบัญชาเหนือขึ้นไปอีกชั้นหนึ่ง'`); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`kpiUserEvaluation\` CHANGE \`isReasonCommanderHigh\` \`isReasonCommanderHigh\` tinyint NULL COMMENT 'หมายเหตุ ผู้บังคับบัญชาเหนือขึ้นไปอีกชั้นหนึ่ง' DEFAULT '0'`); + await queryRunner.query(`ALTER TABLE \`kpiUserEvaluation\` CHANGE \`isReasonCommander\` \`isReasonCommander\` tinyint NULL COMMENT 'หมายเหตุ ผู้บังคับบัญชาเหนือขึ้นไป' DEFAULT '0'`); + } + +}