diff --git a/src/controllers/KpiUserPlannedController.ts b/src/controllers/KpiUserPlannedController.ts index 4d1db6c..c7e921d 100644 --- a/src/controllers/KpiUserPlannedController.ts +++ b/src/controllers/KpiUserPlannedController.ts @@ -176,6 +176,15 @@ export class KpiUserPlannedController extends Controller { includingName: item.kpiPlan.includingName, target: item.target, weight: item.weight, + unit: item.unit, + meaning: item.meaning, + formula: item.formula, + point: item.point, + achievement: item.point === 1 ? "ระดับ 1" : + item.point === 2 ? "ระดับ 2" : + item.point === 3 ? "ระดับ 3" : + item.point === 3 ? "ระดับ 4" : + item.point === 3 ? "ระดับ 5" : null, achievement1: item.kpiPlan.achievement1, achievement2: item.kpiPlan.achievement2, achievement3: item.kpiPlan.achievement3, diff --git a/src/controllers/KpiUserRoleController.ts b/src/controllers/KpiUserRoleController.ts index a60f12d..2ebc912 100644 --- a/src/controllers/KpiUserRoleController.ts +++ b/src/controllers/KpiUserRoleController.ts @@ -94,6 +94,19 @@ export class KpiUserRoleController extends Controller { if (!kpiUserRole) { throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลงานตามหน้าที่ความรับผิดชอบหลักนี้"); } + const chkUserEvaluation = await this.kpiUserEvaluationRepository.findOne({ + where:{id:requestBody.kpiUserEvaluationId}, + }) + if (!chkUserEvaluation) { + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบประเมินผู้ใช้งาน"); + } + + const chkKpiRole = await this.kpiRoleRepository.findOne({ + where:{id:requestBody.kpiRoleId}, + }) + if (!chkKpiRole) { + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบประเมินตามหน้าที่ความรับผิดชอบหลัก"); + } kpiUserRole.lastUpdateUserId = request.user.sub; kpiUserRole.lastUpdateFullName = request.user.name; @@ -161,8 +174,13 @@ export class KpiUserRoleController extends Controller { * */ @Get() - async GetKpiUserRole() { + async GetKpiUserRole( + @Query("id") id: string , + ) { const kpiUserRole = await this.kpiUserRoleRepository.find({ + where:{ + kpiUserEvaluationId:id + }, relations: ["kpiRole","kpiUserEvaluation"], order: { createdAt: "ASC" }, }); @@ -172,10 +190,20 @@ export class KpiUserRoleController extends Controller { const mapKpiUserRole = kpiUserRole.map((item) => ({ id: item.id, evaluationId: item.kpiUserEvaluation.id, - indicatorId: item.kpiRole.id, + kpiRoleId: item.kpiRole.id, + including: item.kpiRole.including, includingName: item.kpiRole.includingName, target: item.target, weight: item.weight, + unit: item.unit, + meaning: item.meaning, + formula: item.formula, + point: item.point, + achievement: item.point === 1 ? "ระดับ 1" : + item.point === 2 ? "ระดับ 2" : + item.point === 3 ? "ระดับ 3" : + item.point === 3 ? "ระดับ 4" : + item.point === 3 ? "ระดับ 5" : null, achievement1: item.kpiRole.achievement1, achievement2: item.kpiRole.achievement2, achievement3: item.kpiRole.achievement3, diff --git a/src/entities/kpiCapacity.ts b/src/entities/kpiCapacity.ts index b2b5a0b..ff5ff54 100644 --- a/src/entities/kpiCapacity.ts +++ b/src/entities/kpiCapacity.ts @@ -40,6 +40,36 @@ export class KpiCapacity extends EntityBase { }) description: string; + @Column({ + nullable: true, + comment: "ระดับที่คาดหวัง", + default: null, + }) + level: string; + + @Column({ + nullable: true, + comment: "น้ำหนัก", + default: null, + }) + weight: number; + + + @Column({ + nullable: true, + comment: "ระดับคะแนน", + default: null, + }) + point: number; + + @Column({ + type: "double", + nullable: true, + default: null, + comment: "ผลการประเมิน" + }) + summary: number; + @OneToMany(() => KpiCapacityDetail, (kpiCapacityDetail) => kpiCapacityDetail.kpiCapacity) kpiCapacityDetails: KpiCapacityDetail[]; diff --git a/src/entities/kpiUserPlanned.ts b/src/entities/kpiUserPlanned.ts index 53b6933..065c4da 100644 --- a/src/entities/kpiUserPlanned.ts +++ b/src/entities/kpiUserPlanned.ts @@ -63,6 +63,21 @@ export class KpiUserPlanned extends EntityBase { @ManyToOne(() => KpiPlan, (kpiPlan) => kpiPlan.kpiUserPlanneds) @JoinColumn({ name: "kpiPlanId" }) kpiPlan: KpiPlan; + + @Column({ + nullable: true, + comment: "ระดับคะแนน", + default: null, + }) + point: number; + + @Column({ + type: "double", + nullable: true, + default: null, + comment: "ผลการประเมิน" + }) + summary: number; } export class CreateKpiUserPlanned { diff --git a/src/entities/kpiUserRole.ts b/src/entities/kpiUserRole.ts index ff36d70..41e4a94 100644 --- a/src/entities/kpiUserRole.ts +++ b/src/entities/kpiUserRole.ts @@ -2,6 +2,7 @@ import { Entity, Column, ManyToOne, JoinColumn } from "typeorm"; import { EntityBase } from "./base/Base"; import { KpiUserEvaluation } from "./kpiUserEvaluation"; import { KpiRole } from "./kpiRole"; +import { Double } from "typeorm/browser"; @Entity("kpiUserRole") export class KpiUserRole extends EntityBase { @@ -63,6 +64,23 @@ export class KpiUserRole extends EntityBase { @ManyToOne(() => KpiRole, (kpiRole) => kpiRole.kpiUserRoles) @JoinColumn({ name: "kpiRoleId" }) kpiRole: KpiRole; + + @Column({ + nullable: true, + comment: "ระดับคะแนน", + default: null, + }) + point: number; + + + @Column({ + type: "double", + nullable: true, + default: null, + comment: "ผลการประเมิน" + }) + summary: number; + } export class CreateKpiUserRole { @@ -93,8 +111,8 @@ export class UpdateKpiUserRole { meaning: string; @Column() formula: string; - // @Column("uuid") - // kpiUserEvaluationId: string; - // @Column("uuid") - // kpiPlanId: string; + @Column("uuid") + kpiUserEvaluationId: string; + @Column("uuid") + kpiRoleId: string; } \ No newline at end of file