From 264fafdcbf41b9f8919bf6b9a251f9ed983b0e96 Mon Sep 17 00:00:00 2001 From: Bright Date: Fri, 13 Jun 2025 18:05:30 +0700 Subject: [PATCH] add field assignedPosLevel --- src/controllers/EvaluationController.ts | 12 ++++++++++++ src/controllers/ReportController.ts | 4 +++- src/entities/Evaluation.ts | 3 +++ .../1749811430532-add_field_assignedPosLevel.ts | 14 ++++++++++++++ 4 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 src/migration/1749811430532-add_field_assignedPosLevel.ts diff --git a/src/controllers/EvaluationController.ts b/src/controllers/EvaluationController.ts index abd41dd..e12b060 100644 --- a/src/controllers/EvaluationController.ts +++ b/src/controllers/EvaluationController.ts @@ -550,6 +550,7 @@ export class EvaluationController { select: ["detailBody", "detailFooter"], }); const before = null; + let typeTh = evaluation.type == "EXPERT" ? "ชำนาญการ" : evaluation.type == "EXPERTISE" ? "เชียวชาญ" : evaluation.type == "SPECIAL_EXPERT" ? "ชำนาญการพิเศษ":""; await new CallAPI() .GetData(request, `/org/profile/keycloak/commander/${request.user.sub}`) .then(async (x) => { @@ -560,6 +561,8 @@ export class EvaluationController { evaluation.child4DnaId = x.child4DnaId; }) .catch(); + evaluation.assignedPosition = requestBody.position ? requestBody.position : _null; + evaluation.assignedPosLevel = typeTh; evaluation.step = "PREPARE_DOC_V1"; evaluation.type = requestBody.type == "EXPERT" ? "EXPERT" : "SPECIAL_EXPERT"; evaluation.fullName = requestBody.fullName; @@ -837,6 +840,7 @@ export class EvaluationController { const evaluation = Object.assign(new Evaluation(), requestBody); const before = null; let org: any; + const __null: any = null; await new CallAPI() .GetData(request, `/org/profile/keycloak/commander/${request.user.sub}`) .then(async (x) => { @@ -849,6 +853,8 @@ export class EvaluationController { }) .catch(); //Evaluation + evaluation.assignedPosition = requestBody.position ? requestBody.position : __null; + evaluation.assignedPosLevel = "เชียวชาญ"; evaluation.oc = org; evaluation.step = "DONE"; evaluation.type = "EXPERTISE"; @@ -2226,6 +2232,7 @@ export class EvaluationController { evaluation.subjectDoc2 = evaluation.subject; evaluation.authorDoc2 = evaluation.author; evaluation.assignedPosition = evaluation.position; //xxxxxxxxxx + evaluation.assignedPosLevel = "xxxxxxxx"; //xxxxxxxxxx evaluation.commanderFullnameDoc2 = evaluation.commanderFullname; evaluation.commanderPositionDoc2 = evaluation.commanderPosition; evaluation.commanderAboveFullnameDoc2 = evaluation.commanderAboveFullname; @@ -2895,6 +2902,7 @@ export class EvaluationController { "authorDoc2", "subjectDoc2", "assignedPosition", + "assignedPosLevel", "commanderFullnameDoc2", "commanderOrgDoc2", "commanderOrgOldDoc2", @@ -2939,6 +2947,7 @@ export class EvaluationController { "authorDoc2", "subjectDoc2", "assignedPosition", + "assignedPosLevel", "commanderFullnameDoc2", "commanderOrgDoc2", "commanderOrgOldDoc2", @@ -3048,6 +3057,7 @@ export class EvaluationController { authorDoc2: "string", subjectDoc2: "string", assignedPosition: "string", + assignedPosLevel: "string", commanderFullnameDoc2: "string", commanderPositionDoc2: "string", commanderAboveFullnameDoc2: "string", @@ -3061,6 +3071,7 @@ export class EvaluationController { authorDoc2: string; subjectDoc2: string[]; assignedPosition: string; + assignedPosLevel?: string; commanderFullnameDoc2: string; commanderPositionDoc2: string; commanderAboveFullnameDoc2: string; @@ -3084,6 +3095,7 @@ export class EvaluationController { evaluation.authorDoc2 = body.authorDoc2; evaluation.subjectDoc2 = body.subjectDoc2; evaluation.assignedPosition = body.assignedPosition; + evaluation.assignedPosLevel = body.assignedPosLevel ? body.assignedPosLevel : _null; evaluation.commanderFullnameDoc2 = body.commanderFullnameDoc2; evaluation.commanderOrgDoc2 = body.commanderOrgDoc2 ?? _null; evaluation.commanderOrgOldDoc2 = body.commanderOrgOldDoc2 ?? _null; diff --git a/src/controllers/ReportController.ts b/src/controllers/ReportController.ts index 7984dae..c1097dc 100644 --- a/src/controllers/ReportController.ts +++ b/src/controllers/ReportController.ts @@ -335,8 +335,10 @@ export class ReoportController { prefix: evaluation.prefix, fullName: evaluation.fullName ? `${evaluation.fullName}` : "", position: evaluation.position ? evaluation.position : "", + // ตำแหน่งเดิม, posAndPosLevel: (evaluation.position ? `${evaluation.position}` : "") + (evaluation.positionLevel ? `${evaluation.positionLevel}` : ""), - posAndTypeTh: (evaluation.position ? `${evaluation.position}` : "" ) + (typeTh ? `${typeTh}` : ""), + // ตำแหน่งใหม่ + posAndTypeTh: (evaluation.assignedPosition ? `${evaluation.assignedPosition}` : "" ) + (evaluation.assignedPosLevel ? `${evaluation.assignedPosLevel}` : ""), posNo: evaluation.posNo ? Extension.ToThaiNumber(evaluation.posNo) : "", posNoWithSym: evaluation.posNo ? `(${Extension.ToThaiNumber(evaluation.posNo)})` : "", oc: evaluation.oc ? evaluation.oc.replace(/\n/g, " ") : "-", diff --git a/src/entities/Evaluation.ts b/src/entities/Evaluation.ts index b3c4d03..7bb865a 100644 --- a/src/entities/Evaluation.ts +++ b/src/entities/Evaluation.ts @@ -268,6 +268,9 @@ export class Evaluation extends EntityBase { @Column({ nullable: true, comment: "ตำแหน่งที่ได้รับมอบหมาย" }) assignedPosition: string; + @Column({ nullable: true, comment: "ระดับที่ได้รับมอบหมาย" }) + assignedPosLevel: string; + @Column({ nullable: true, comment: "ผลการประเมิน", default: "PENDING" }) //PENDING,PASS,NOTPASS evaluationResult: string; diff --git a/src/migration/1749811430532-add_field_assignedPosLevel.ts b/src/migration/1749811430532-add_field_assignedPosLevel.ts new file mode 100644 index 0000000..130e652 --- /dev/null +++ b/src/migration/1749811430532-add_field_assignedPosLevel.ts @@ -0,0 +1,14 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class AddFieldAssignedPosLevel1749811430532 implements MigrationInterface { + name = 'AddFieldAssignedPosLevel1749811430532' + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`evaluation\` ADD \`assignedPosLevel\` varchar(255) NULL COMMENT 'ระดับที่ได้รับมอบหมาย'`); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`evaluation\` DROP COLUMN \`assignedPosLevel\``); + } + +}