From fb471175d8eeecfe0195071d9b7a6c1bbfefe46b Mon Sep 17 00:00:00 2001 From: Suchin Sapphasitthatha Date: Thu, 12 Dec 2024 08:23:39 +0000 Subject: [PATCH 1/6] add CI --- .onedev-buildspec.yml | 102 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 102 insertions(+) create mode 100644 .onedev-buildspec.yml diff --git a/.onedev-buildspec.yml b/.onedev-buildspec.yml new file mode 100644 index 0000000..d434821 --- /dev/null +++ b/.onedev-buildspec.yml @@ -0,0 +1,102 @@ +version: 37 +jobs: +- name: CI for UAT + steps: + - !CheckoutStep + name: checkout code + cloneCredential: !DefaultCredential {} + withLfs: false + withSubmodules: false + condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL + - !GenerateChecksumStep + name: generate package checksum + files: package-lock.json yarn.lock + targetFile: checksum + condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL + - !SetupCacheStep + name: set up npm cache + key: node_modules_@file:checksum@ + loadKeys: + - node_modules + paths: + - node_modules + uploadStrategy: UPLOAD_IF_NOT_HIT + condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL + - !SetBuildVersionStep + name: set build version + buildVersion: '@tag@' + condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL + - !CommandStep + name: build & test + runInContainer: true + image: node + interpreter: !DefaultInterpreter + commands: | + npm install + npm run build + useTTY: true + condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL + - !BuildImageStep + name: build docker image + dockerfile: ./docker/Dockerfile + output: !RegistryOutput + tags: hrms-git.chin.in.th/bma-hrms/hrms-api-kpi:@build_version@ hrms-git.chin.in.th/bma-hrms/hrms-api-kpi:latest + condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL + triggers: + - !TagCreateTrigger + tags: uat-* + branches: main + retryCondition: never + maxRetries: 3 + retryDelay: 30 + timeout: 14400 +- name: CI for PROD + steps: + - !CheckoutStep + name: checkout code + cloneCredential: !DefaultCredential {} + withLfs: false + withSubmodules: false + condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL + - !GenerateChecksumStep + name: generate package checksum + files: package-lock.json yarn.lock + targetFile: checksum + condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL + - !SetupCacheStep + name: set up npm cache + key: node_modules_@file:checksum@ + loadKeys: + - node_modules + paths: + - node_modules + uploadStrategy: UPLOAD_IF_NOT_HIT + condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL + - !SetBuildVersionStep + name: set build version + buildVersion: '@tag@' + condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL + - !CommandStep + name: build & test + runInContainer: true + image: node + interpreter: !DefaultInterpreter + commands: | + npm install + npm run build + useTTY: true + condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL + - !BuildImageStep + name: build docker image + dockerfile: ./docker/Dockerfile + output: !RegistryOutput + tags: hrms-git.bangkok.go.th/bma-hrms/hrms-api-kpi:@build_version@ hrms-git.bangkok.go.th/bma-hrms/hrms-api-kpi:latest + condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL + triggers: + - !TagCreateTrigger + tags: prod-* + branches: main + retryCondition: never + maxRetries: 3 + retryDelay: 30 + timeout: 14400 From a3003e35514847ea3d5c3bb77ec9de03dc9f4f2b Mon Sep 17 00:00:00 2001 From: waruneeauy Date: Sat, 11 Jan 2025 13:54:12 +0700 Subject: [PATCH 2/6] fixing order capacitor head --- src/controllers/KpiCapacityController.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/controllers/KpiCapacityController.ts b/src/controllers/KpiCapacityController.ts index 1f20c24..b923d75 100644 --- a/src/controllers/KpiCapacityController.ts +++ b/src/controllers/KpiCapacityController.ts @@ -209,6 +209,7 @@ export class kpiCapacityController extends Controller { }, select: ["id", "name"], relations: ["kpiCapacityDetails"], + order: { createdAt: "ASC" }, }); const mapData = kpiCapacity.map((x) => ({ From 8a676e7d6e9a88ed7fba0a59c2f5fbb502ca8e54 Mon Sep 17 00:00:00 2001 From: kittapath Date: Tue, 14 Jan 2025 18:45:26 +0700 Subject: [PATCH 3/6] add commander --- .../KpiUserEvaluationController.ts | 78 +++++++-- src/controllers/ReportController.ts | 153 ++++++++++-------- src/entities/kpiUserEvaluation.ts | 64 ++++++++ 3 files changed, 220 insertions(+), 75 deletions(-) diff --git a/src/controllers/KpiUserEvaluationController.ts b/src/controllers/KpiUserEvaluationController.ts index 9c26cad..68b59ab 100644 --- a/src/controllers/KpiUserEvaluationController.ts +++ b/src/controllers/KpiUserEvaluationController.ts @@ -569,17 +569,39 @@ export class KpiUserEvaluationController extends Controller { throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลในทะเบียนประวัติ"); }); } - await new CallAPI() - .GetData(request, "/org/profile/profileid/position/" + requestBody.evaluatorId) - .then((x) => { - kpiUserEvaluation.prefixEvaluator = x.prefix; - kpiUserEvaluation.firstNameEvaluator = x.firstName; - kpiUserEvaluation.lastNameEvaluator = x.lastName; - kpiUserEvaluation.positionEvaluator = x.position; - kpiUserEvaluation.posLevelNameEvaluator = x.posLevelName; - kpiUserEvaluation.posTypeNameEvaluator = x.posTypeName; - kpiUserEvaluation.orgEvaluator = x.root; - }); + if (requestBody.evaluatorId) { + await new CallAPI() + .GetData(request, "/org/profile/profileid/position/" + requestBody.evaluatorId) + .then((x) => { + kpiUserEvaluation.prefixEvaluator = x.prefix; + kpiUserEvaluation.firstNameEvaluator = x.firstName; + kpiUserEvaluation.lastNameEvaluator = x.lastName; + kpiUserEvaluation.positionEvaluator = x.position; + kpiUserEvaluation.posLevelNameEvaluator = x.posLevelName; + kpiUserEvaluation.posTypeNameEvaluator = x.posTypeName; + kpiUserEvaluation.orgEvaluator = x.root; + }); + } + if (requestBody.commanderId) { + await new CallAPI() + .GetData(request, "/org/profile/profileid/position/" + requestBody.commanderId) + .then((x) => { + kpiUserEvaluation.prefixCommander = x.prefix; + kpiUserEvaluation.firstNameCommander = x.firstName; + kpiUserEvaluation.lastNameCommander = x.lastName; + kpiUserEvaluation.positionCommander = x.position; + }); + } + if (requestBody.commanderHighId) { + await new CallAPI() + .GetData(request, "/org/profile/profileid/position/" + requestBody.commanderHighId) + .then((x) => { + kpiUserEvaluation.prefixCommanderHigh = x.prefix; + kpiUserEvaluation.firstNameCommanderHigh = x.firstName; + kpiUserEvaluation.lastNameCommanderHigh = x.lastName; + kpiUserEvaluation.positionCommanderHigh = x.position; + }); + } const before = null; kpiUserEvaluation.evaluationStatus = "NEW"; kpiUserEvaluation.evaluationResults = "PENDING"; @@ -747,6 +769,40 @@ export class KpiUserEvaluationController extends Controller { } const before = structuredClone(kpiUserEvaluation); + if (requestBody.evaluatorId) { + await new CallAPI() + .GetData(request, "/org/profile/profileid/position/" + requestBody.evaluatorId) + .then((x) => { + kpiUserEvaluation.prefixEvaluator = x.prefix; + kpiUserEvaluation.firstNameEvaluator = x.firstName; + kpiUserEvaluation.lastNameEvaluator = x.lastName; + kpiUserEvaluation.positionEvaluator = x.position; + kpiUserEvaluation.posLevelNameEvaluator = x.posLevelName; + kpiUserEvaluation.posTypeNameEvaluator = x.posTypeName; + kpiUserEvaluation.orgEvaluator = x.root; + }); + } + if (requestBody.commanderId) { + await new CallAPI() + .GetData(request, "/org/profile/profileid/position/" + requestBody.commanderId) + .then((x) => { + kpiUserEvaluation.prefixCommander = x.prefix; + kpiUserEvaluation.firstNameCommander = x.firstName; + kpiUserEvaluation.lastNameCommander = x.lastName; + kpiUserEvaluation.positionCommander = x.position; + }); + } + if (requestBody.commanderHighId) { + await new CallAPI() + .GetData(request, "/org/profile/profileid/position/" + requestBody.commanderHighId) + .then((x) => { + kpiUserEvaluation.prefixCommanderHigh = x.prefix; + kpiUserEvaluation.firstNameCommanderHigh = x.firstName; + kpiUserEvaluation.lastNameCommanderHigh = x.lastName; + kpiUserEvaluation.positionCommanderHigh = x.position; + }); + } + kpiUserEvaluation.lastUpdateUserId = request.user.sub; kpiUserEvaluation.lastUpdateFullName = request.user.name; kpiUserEvaluation.lastUpdatedAt = new Date(); diff --git a/src/controllers/ReportController.ts b/src/controllers/ReportController.ts index 6728421..147c5de 100644 --- a/src/controllers/ReportController.ts +++ b/src/controllers/ReportController.ts @@ -788,10 +788,10 @@ export class ReportController extends Controller { ? Extension.ToThaiNumber(Extension.ToThaiYear(x.kpiPeriod.year).toString()) : null; } else { - acc.summaryPointAPR1 = "-" - acc.textPointAPR1 = "-" - acc.periodAPR1 = "-" - acc.yearAPR1 = "-" + acc.summaryPointAPR1 = "-"; + acc.textPointAPR1 = "-"; + acc.periodAPR1 = "-"; + acc.yearAPR1 = "-"; } if (x.kpiPeriod.year === yearNow - 4 && x.kpiPeriod.durationKPI === "OCT") { @@ -804,10 +804,10 @@ export class ReportController extends Controller { ? Extension.ToThaiNumber(Extension.ToThaiYear(x.kpiPeriod.year).toString()) : null; } else { - acc.summaryPointOCT1 = "-" - acc.textPointOCT1 = "-" - acc.periodOCT1 = "-" - acc.yearOCT1 = "-" + acc.summaryPointOCT1 = "-"; + acc.textPointOCT1 = "-"; + acc.periodOCT1 = "-"; + acc.yearOCT1 = "-"; } if (x.kpiPeriod.year === yearNow - 3 && x.kpiPeriod.durationKPI === "APR") { @@ -820,10 +820,10 @@ export class ReportController extends Controller { ? Extension.ToThaiNumber(Extension.ToThaiYear(x.kpiPeriod.year).toString()) : null; } else { - acc.summaryPointAPR2 = "-" - acc.textPointAPR2 = "-" - acc.periodAPR2 = "-" - acc.yearAPR2 = "-" + acc.summaryPointAPR2 = "-"; + acc.textPointAPR2 = "-"; + acc.periodAPR2 = "-"; + acc.yearAPR2 = "-"; } if (x.kpiPeriod.year === yearNow - 3 && x.kpiPeriod.durationKPI === "OCT") { @@ -836,10 +836,10 @@ export class ReportController extends Controller { ? Extension.ToThaiNumber(Extension.ToThaiYear(x.kpiPeriod.year).toString()) : null; } else { - acc.summaryPointOCT2 = "-" - acc.textPointOCT2 = "-" - acc.periodOCT2 = "-" - acc.yearOCT2 = "-" + acc.summaryPointOCT2 = "-"; + acc.textPointOCT2 = "-"; + acc.periodOCT2 = "-"; + acc.yearOCT2 = "-"; } if (x.kpiPeriod.year === yearNow - 2 && x.kpiPeriod.durationKPI === "APR") { @@ -852,10 +852,10 @@ export class ReportController extends Controller { ? Extension.ToThaiNumber(Extension.ToThaiYear(x.kpiPeriod.year).toString()) : null; } else { - acc.summaryPointAPR3 = "-" - acc.textPointAPR3 = "-" - acc.periodAPR3 = "-" - acc.yearAPR3 = "-" + acc.summaryPointAPR3 = "-"; + acc.textPointAPR3 = "-"; + acc.periodAPR3 = "-"; + acc.yearAPR3 = "-"; } if (x.kpiPeriod.year === yearNow - 2 && x.kpiPeriod.durationKPI === "OCT") { @@ -868,10 +868,10 @@ export class ReportController extends Controller { ? Extension.ToThaiNumber(Extension.ToThaiYear(x.kpiPeriod.year).toString()) : null; } else { - acc.summaryPointOCT3 = "-" - acc.textPointOCT3 = "-" - acc.periodOCT3 = "-" - acc.yearOCT3 = "-" + acc.summaryPointOCT3 = "-"; + acc.textPointOCT3 = "-"; + acc.periodOCT3 = "-"; + acc.yearOCT3 = "-"; } if (x.kpiPeriod.year === yearNow - 1 && x.kpiPeriod.durationKPI === "APR") { @@ -884,10 +884,10 @@ export class ReportController extends Controller { ? Extension.ToThaiNumber(Extension.ToThaiYear(x.kpiPeriod.year).toString()) : null; } else { - acc.summaryPointAPR4 = "-" - acc.textPointAPR4 = "-" - acc.periodAPR4 = "-" - acc.yearAPR4 = "-" + acc.summaryPointAPR4 = "-"; + acc.textPointAPR4 = "-"; + acc.periodAPR4 = "-"; + acc.yearAPR4 = "-"; } if (x.kpiPeriod.year === yearNow - 1 && x.kpiPeriod.durationKPI === "OCT") { @@ -900,10 +900,10 @@ export class ReportController extends Controller { ? Extension.ToThaiNumber(Extension.ToThaiYear(x.kpiPeriod.year).toString()) : null; } else { - acc.summaryPointOCT4 = "-" - acc.textPointOCT4 = "-" - acc.periodOCT4 = "-" - acc.yearOCT4 = "-" + acc.summaryPointOCT4 = "-"; + acc.textPointOCT4 = "-"; + acc.periodOCT4 = "-"; + acc.yearOCT4 = "-"; } if (x.kpiPeriod.year === yearNow && x.kpiPeriod.durationKPI === "APR") { @@ -916,10 +916,10 @@ export class ReportController extends Controller { ? Extension.ToThaiNumber(Extension.ToThaiYear(x.kpiPeriod.year).toString()) : null; } else { - acc.summaryPointAPR5 = "-" - acc.textPointAPR5 = "-" - acc.periodAPR5 = "-" - acc.yearAPR5 = "-" + acc.summaryPointAPR5 = "-"; + acc.textPointAPR5 = "-"; + acc.periodAPR5 = "-"; + acc.yearAPR5 = "-"; } if (x.kpiPeriod.year === yearNow && x.kpiPeriod.durationKPI === "OCT") { @@ -932,10 +932,10 @@ export class ReportController extends Controller { ? Extension.ToThaiNumber(Extension.ToThaiYear(x.kpiPeriod.year).toString()) : null; } else { - acc.summaryPointOCT5 = "-" - acc.textPointOCT5 = "-" - acc.periodOCT5 = "-" - acc.yearOCT5 = "-" + acc.summaryPointOCT5 = "-"; + acc.textPointOCT5 = "-"; + acc.periodOCT5 = "-"; + acc.yearOCT5 = "-"; } return acc; @@ -1143,10 +1143,10 @@ export class ReportController extends Controller { ? Extension.ToThaiNumber(Extension.ToThaiYear(x.kpiPeriod.year).toString()) : null; } else { - acc.summaryPointAPR1 = "-" - acc.textPointAPR1 = "-" - acc.periodAPR1 = "-" - acc.yearAPR1 = "-" + acc.summaryPointAPR1 = "-"; + acc.textPointAPR1 = "-"; + acc.periodAPR1 = "-"; + acc.yearAPR1 = "-"; } if (x.kpiPeriod.year === yearNow - 2 && x.kpiPeriod.durationKPI === "OCT") { @@ -1159,10 +1159,10 @@ export class ReportController extends Controller { ? Extension.ToThaiNumber(Extension.ToThaiYear(x.kpiPeriod.year).toString()) : null; } else { - acc.summaryPointOCT1 = "-" - acc.textPointOCT1 = "-" - acc.periodOCT1 = "-" - acc.yearOCT1 = "-" + acc.summaryPointOCT1 = "-"; + acc.textPointOCT1 = "-"; + acc.periodOCT1 = "-"; + acc.yearOCT1 = "-"; } if (x.kpiPeriod.year === yearNow - 1 && x.kpiPeriod.durationKPI === "APR") { @@ -1175,10 +1175,10 @@ export class ReportController extends Controller { ? Extension.ToThaiNumber(Extension.ToThaiYear(x.kpiPeriod.year).toString()) : null; } else { - acc.summaryPointAPR2 = "-" - acc.textPointAPR2 = "-" - acc.periodAPR2 = "-" - acc.yearAPR2 = "-" + acc.summaryPointAPR2 = "-"; + acc.textPointAPR2 = "-"; + acc.periodAPR2 = "-"; + acc.yearAPR2 = "-"; } if (x.kpiPeriod.year === yearNow - 1 && x.kpiPeriod.durationKPI === "OCT") { @@ -1191,10 +1191,10 @@ export class ReportController extends Controller { ? Extension.ToThaiNumber(Extension.ToThaiYear(x.kpiPeriod.year).toString()) : null; } else { - acc.summaryPointOCT2 = "-" - acc.textPointOCT2 = "-" - acc.periodOCT2 = "-" - acc.yearOCT2 = "-" + acc.summaryPointOCT2 = "-"; + acc.textPointOCT2 = "-"; + acc.periodOCT2 = "-"; + acc.yearOCT2 = "-"; } if (x.kpiPeriod.year === yearNow && x.kpiPeriod.durationKPI === "APR") { @@ -1207,10 +1207,10 @@ export class ReportController extends Controller { ? Extension.ToThaiNumber(Extension.ToThaiYear(x.kpiPeriod.year).toString()) : null; } else { - acc.summaryPointAPR3 = "-" - acc.textPointAPR3 = "-" - acc.periodAPR3 = "-" - acc.yearAPR3 = "-" + acc.summaryPointAPR3 = "-"; + acc.textPointAPR3 = "-"; + acc.periodAPR3 = "-"; + acc.yearAPR3 = "-"; } if (x.kpiPeriod.year === yearNow && x.kpiPeriod.durationKPI === "OCT") { @@ -1223,10 +1223,10 @@ export class ReportController extends Controller { ? Extension.ToThaiNumber(Extension.ToThaiYear(x.kpiPeriod.year).toString()) : null; } else { - acc.summaryPointOCT3 = "-" - acc.textPointOCT3 = "-" - acc.periodOCT3 = "-" - acc.yearOCT3 = "-" + acc.summaryPointOCT3 = "-"; + acc.textPointOCT3 = "-"; + acc.periodOCT3 = "-"; + acc.yearOCT3 = "-"; } return acc; @@ -1639,12 +1639,37 @@ export class ReportController extends Controller { (kpiUserEvaluation.firstNameEvaluator == null ? "" : kpiUserEvaluation.firstNameEvaluator) + " " + (kpiUserEvaluation.lastNameEvaluator == null ? "" : kpiUserEvaluation.lastNameEvaluator), + + fullnameCommander: + (kpiUserEvaluation.prefixCommander == null ? "" : kpiUserEvaluation.prefixCommander) + + "" + + (kpiUserEvaluation.firstNameCommander == null ? "" : kpiUserEvaluation.firstNameCommander) + + " " + + (kpiUserEvaluation.lastNameCommander == null ? "" : kpiUserEvaluation.lastNameCommander), + + fullnameCommanderHigh: + (kpiUserEvaluation.prefixCommanderHigh == null + ? "" + : kpiUserEvaluation.prefixCommanderHigh) + + "" + + (kpiUserEvaluation.firstNameCommanderHigh == null + ? "" + : kpiUserEvaluation.firstNameCommanderHigh) + + " " + + (kpiUserEvaluation.lastNameCommanderHigh == null + ? "" + : kpiUserEvaluation.lastNameCommanderHigh), positionEvaluator: kpiUserEvaluation.positionEvaluator, + positionCommander: kpiUserEvaluation.positionCommander, + positionCommanderHigh: kpiUserEvaluation.positionCommanderHigh, posTypeNameEvaluator: kpiUserEvaluation.posTypeNameEvaluator, posLevelNameEvaluator: kpiUserEvaluation.posLevelNameEvaluator, orgEvaluator: kpiUserEvaluation.orgEvaluator, year: Extension.ToThaiNumber(String(Extension.ToThaiYear(kpiUserEvaluation.kpiPeriod.year))), + yearOld: Extension.ToThaiNumber( + String(Extension.ToThaiYear(kpiUserEvaluation.kpiPeriod.year + 1)), + ), startDateApr: kpiUserEvaluation.kpiPeriod == null || diff --git a/src/entities/kpiUserEvaluation.ts b/src/entities/kpiUserEvaluation.ts index 2409b8e..ad6e9bd 100644 --- a/src/entities/kpiUserEvaluation.ts +++ b/src/entities/kpiUserEvaluation.ts @@ -200,6 +200,70 @@ export class KpiUserEvaluation extends EntityBase { }) orgEvaluator: string; + @Column({ + nullable: true, + comment: "คำนำหน้าผู้บังคับบัญชาเหนือขึ้นไป", + length: 255, + default: null, + }) + prefixCommander: string; + + @Column({ + nullable: true, + comment: "ชื่อผู้บังคับบัญชาเหนือขึ้นไป", + length: 255, + default: null, + }) + firstNameCommander: string; + + @Column({ + nullable: true, + comment: "สกุลผู้บังคับบัญชาเหนือขึ้นไป", + length: 255, + default: null, + }) + lastNameCommander: string; + + @Column({ + nullable: true, + comment: "ตำแหน่งผู้บังคับบัญชาเหนือขึ้นไป", + length: 255, + default: null, + }) + positionCommander: string; + + @Column({ + nullable: true, + comment: "คำนำหน้าผู้บังคับบัญชาเหนือขึ้นไปอีกชั้นหนึ่ง", + length: 255, + default: null, + }) + prefixCommanderHigh: string; + + @Column({ + nullable: true, + comment: "ชื่อผู้บังคับบัญชาเหนือขึ้นไปอีกชั้นหนึ่ง", + length: 255, + default: null, + }) + firstNameCommanderHigh: string; + + @Column({ + nullable: true, + comment: "สกุลผู้บังคับบัญชาเหนือขึ้นไปอีกชั้นหนึ่ง", + length: 255, + default: null, + }) + lastNameCommanderHigh: string; + + @Column({ + nullable: true, + comment: "ตำแหน่งผู้บังคับบัญชาเหนือขึ้นไปอีกชั้นหนึ่ง", + length: 255, + default: null, + }) + positionCommanderHigh: string; + @Column({ nullable: true, length: 40, From 4c06594af80c34c64f448e961ea483b21f5bd3a8 Mon Sep 17 00:00:00 2001 From: kittapath Date: Thu, 16 Jan 2025 14:07:29 +0700 Subject: [PATCH 4/6] add auery --- src/controllers/KpiPlanController.ts | 12 +++-- .../KpiUserEvaluationController.ts | 4 ++ src/controllers/KpiUserPlannedController.ts | 46 +++++++++++++++---- src/controllers/KpiUserRoleController.ts | 33 +++++++++---- src/entities/kpiUserEvaluation.ts | 7 +++ 5 files changed, 78 insertions(+), 24 deletions(-) diff --git a/src/controllers/KpiPlanController.ts b/src/controllers/KpiPlanController.ts index d21a7ca..59afe58 100644 --- a/src/controllers/KpiPlanController.ts +++ b/src/controllers/KpiPlanController.ts @@ -59,7 +59,10 @@ export class kpiPlanController extends Controller { .where("kpiPeriod.year = :year", { year: requestBody.year }) .andWhere("kpiPeriod.durationKPI = :durationKPI", { durationKPI: requestBody.period }) .getOne(); - const year = requestBody.year && parseInt(requestBody.year) > 0?parseInt(requestBody.year) + 543:"ดังกล่าว"; + const year = + requestBody.year && parseInt(requestBody.year) > 0 + ? parseInt(requestBody.year) + 543 + : "ดังกล่าว"; if (!kpiPeriod) { // throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลตัวชี้วัดตามตำแหน่งนี้"); throw new HttpError( @@ -453,6 +456,7 @@ export class kpiPlanController extends Controller { if (kpiPlan.strategyChild5Id != null) { strategy = 5; strategyId = kpiPlan.strategyChild5Id; + strategyName = kpiPlan.strategyChild5; } else if (kpiPlan.strategyChild4Id != null) { strategy = 4; strategyId = kpiPlan.strategyChild4Id; @@ -870,11 +874,11 @@ export class kpiPlanController extends Controller { type = 4; } - const _null:any = null; + const _null: any = null; await this.kpiPlanHistoryRepository.delete({ kpiPlanId: id }); - await this.kpiUserPlanRepository.update({ kpiPlanId: id },{ kpiPlanId: _null }); + await this.kpiUserPlanRepository.update({ kpiPlanId: id }, { kpiPlanId: _null }); await this.kpiPlanRepository.remove(kpiPlan, { data: request }); - + if (kpiPlan) { let remainingKpiPlans: any; if (type == 0) { diff --git a/src/controllers/KpiUserEvaluationController.ts b/src/controllers/KpiUserEvaluationController.ts index 68b59ab..9ab95ca 100644 --- a/src/controllers/KpiUserEvaluationController.ts +++ b/src/controllers/KpiUserEvaluationController.ts @@ -526,6 +526,7 @@ export class KpiUserEvaluationController extends Controller { kpiUserEvaluation.posLevelName = x.posLevelName; kpiUserEvaluation.posTypeName = x.posTypeName; kpiUserEvaluation.posExecutiveName = x.posExecutiveName; + kpiUserEvaluation.isProbation = x.isProbation; kpiUserEvaluation.org = x.root; kpiUserEvaluation.orgId = x.rootId; kpiUserEvaluation.child1 = x.child1; @@ -553,6 +554,7 @@ export class KpiUserEvaluationController extends Controller { kpiUserEvaluation.posLevelName = x.posLevelName; kpiUserEvaluation.posTypeName = x.posTypeName; kpiUserEvaluation.posExecutiveName = x.posExecutiveName; + kpiUserEvaluation.isProbation = x.isProbation; kpiUserEvaluation.org = x.root; kpiUserEvaluation.orgId = x.rootId; kpiUserEvaluation.child1 = x.child1; @@ -1058,6 +1060,7 @@ export class KpiUserEvaluationController extends Controller { evaluationStatus: kpiUserEvaluation.evaluationStatus, evaluationResults: kpiUserEvaluation.evaluationResults, evaluationReqEdit: kpiUserEvaluation.evaluationReqEdit, + isProbation: kpiUserEvaluation.isProbation, createdAt: kpiUserEvaluation.createdAt, evaluatorId: kpiUserEvaluation.evaluatorId, commanderId: kpiUserEvaluation.commanderId, @@ -1482,6 +1485,7 @@ export class KpiUserEvaluationController extends Controller { evaluationStatus: kpiUserEvaluation.evaluationStatus, evaluationResults: kpiUserEvaluation.evaluationResults, evaluationReqEdit: kpiUserEvaluation.evaluationReqEdit, + isProbation: kpiUserEvaluation.isProbation, createdAt: kpiUserEvaluation.createdAt, evaluatorId: kpiUserEvaluation.evaluatorId, commanderId: kpiUserEvaluation.commanderId, diff --git a/src/controllers/KpiUserPlannedController.ts b/src/controllers/KpiUserPlannedController.ts index 9253ed5..50fbfbd 100644 --- a/src/controllers/KpiUserPlannedController.ts +++ b/src/controllers/KpiUserPlannedController.ts @@ -198,12 +198,38 @@ export class KpiUserPlannedController extends Controller { throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลงานตามแผนปฏิบัติราชการประจำปีนี้"); } + let nodeName = null; + if (getKpiUserPlanned.kpiPlan.child4Id != null) { + nodeName = getKpiUserPlanned.kpiPlan.child4; + } else if (getKpiUserPlanned.kpiPlan.child3Id != null) { + nodeName = getKpiUserPlanned.kpiPlan.child3; + } else if (getKpiUserPlanned.kpiPlan.child2Id != null) { + nodeName = getKpiUserPlanned.kpiPlan.child2; + } else if (getKpiUserPlanned.kpiPlan.child1Id != null) { + nodeName = getKpiUserPlanned.kpiPlan.child1; + } else if (getKpiUserPlanned.kpiPlan.rootId != null) { + nodeName = getKpiUserPlanned.kpiPlan.root; + } + let strategyName = null; + if (getKpiUserPlanned.kpiPlan.strategyChild5Id != null) { + strategyName = getKpiUserPlanned.kpiPlan.strategyChild5; + } else if (getKpiUserPlanned.kpiPlan.strategyChild4Id != null) { + strategyName = getKpiUserPlanned.kpiPlan.strategyChild4; + } else if (getKpiUserPlanned.kpiPlan.strategyChild3Id != null) { + strategyName = getKpiUserPlanned.kpiPlan.strategyChild3; + } else if (getKpiUserPlanned.kpiPlan.strategyChild2Id != null) { + strategyName = getKpiUserPlanned.kpiPlan.strategyChild2; + } else if (getKpiUserPlanned.kpiPlan.strategyChild1Id != null) { + strategyName = getKpiUserPlanned.kpiPlan.strategyChild1; + } const mapGetKpiUserPlanned = { id: getKpiUserPlanned.id, evaluationId: getKpiUserPlanned.kpiUserEvaluation.id, kpiPlanId: getKpiUserPlanned.kpiPlan.id, including: getKpiUserPlanned.kpiPlan.including, //รหัสตัวชี้วัด includingName: getKpiUserPlanned.kpiPlan.includingName, //ชื่อตัวชี้วัด + nodeName: nodeName, + strategyName: strategyName, target: getKpiUserPlanned.target, weight: getKpiUserPlanned.weight, unit: getKpiUserPlanned.unit, @@ -254,21 +280,21 @@ export class KpiUserPlannedController extends Controller { point: item.point, achievement: item.point === 1 - ? item.kpiPlan.achievement1 + ? item.achievement1 : item.point === 2 - ? item.kpiPlan.achievement2 + ? item.achievement2 : item.point === 3 - ? item.kpiPlan.achievement3 + ? item.achievement3 : item.point === 4 - ? item.kpiPlan.achievement4 + ? item.achievement4 : item.point === 5 - ? item.kpiPlan.achievement5 + ? item.achievement5 : null, - achievement1: item.kpiPlan.achievement1, - achievement2: item.kpiPlan.achievement2, - achievement3: item.kpiPlan.achievement3, - achievement4: item.kpiPlan.achievement4, - achievement5: item.kpiPlan.achievement5, + achievement1: item.achievement1, + achievement2: item.achievement2, + achievement3: item.achievement3, + achievement4: item.achievement4, + achievement5: item.achievement5, })); return new HttpSuccess(mapKpiUserPlanned); } diff --git a/src/controllers/KpiUserRoleController.ts b/src/controllers/KpiUserRoleController.ts index 4de3c2f..9398c28 100644 --- a/src/controllers/KpiUserRoleController.ts +++ b/src/controllers/KpiUserRoleController.ts @@ -202,12 +202,25 @@ export class KpiUserRoleController extends Controller { throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลงานตามหน้าที่ความรับผิดชอบหลักนี้"); } + let nodeName = null; + if (getKpiUserRole.kpiRole.child4Id != null) { + nodeName = getKpiUserRole.kpiRole.child4; + } else if (getKpiUserRole.kpiRole.child3Id != null) { + nodeName = getKpiUserRole.kpiRole.child3; + } else if (getKpiUserRole.kpiRole.child2Id != null) { + nodeName = getKpiUserRole.kpiRole.child2; + } else if (getKpiUserRole.kpiRole.child1Id != null) { + nodeName = getKpiUserRole.kpiRole.child1; + } else if (getKpiUserRole.kpiRole.rootId != null) { + nodeName = getKpiUserRole.kpiRole.root; + } const mapKpiUserRole = { id: getKpiUserRole.id, evaluationId: getKpiUserRole.kpiUserEvaluation.id, kpiRoleId: getKpiUserRole.kpiRole.id, including: getKpiUserRole.kpiRole.including, includingName: getKpiUserRole.kpiRole.includingName, + nodeName: nodeName, target: getKpiUserRole.target, weight: getKpiUserRole.weight, unit: getKpiUserRole.unit, @@ -259,21 +272,21 @@ export class KpiUserRoleController extends Controller { point: item.point, achievement: item.point === 1 - ? item.kpiRole.achievement1 + ? item.achievement1 : item.point === 2 - ? item.kpiRole.achievement2 + ? item.achievement2 : item.point === 3 - ? item.kpiRole.achievement3 + ? item.achievement3 : item.point === 4 - ? item.kpiRole.achievement4 + ? item.achievement4 : item.point === 5 - ? item.kpiRole.achievement5 + ? item.achievement5 : null, - achievement1: item.kpiRole.achievement1, - achievement2: item.kpiRole.achievement2, - achievement3: item.kpiRole.achievement3, - achievement4: item.kpiRole.achievement4, - achievement5: item.kpiRole.achievement5, + achievement1: item.achievement1, + achievement2: item.achievement2, + achievement3: item.achievement3, + achievement4: item.achievement4, + achievement5: item.achievement5, })); return new HttpSuccess(mapKpiUserRole); } diff --git a/src/entities/kpiUserEvaluation.ts b/src/entities/kpiUserEvaluation.ts index ad6e9bd..14f32d9 100644 --- a/src/entities/kpiUserEvaluation.ts +++ b/src/entities/kpiUserEvaluation.ts @@ -481,6 +481,13 @@ export class KpiUserEvaluation extends EntityBase { }) isOpen: boolean; + @Column({ + nullable: true, + comment: "สถานะทดลองงาน", + default: false, + }) + isProbation: boolean; + @Column({ nullable: true, type: "datetime", From f7dea55b5e56538f13612d76ea160da5e3a0051a Mon Sep 17 00:00:00 2001 From: kittapath Date: Mon, 20 Jan 2025 12:30:12 +0700 Subject: [PATCH 5/6] =?UTF-8?q?=E0=B9=80=E0=B8=9E=E0=B8=B4=E0=B9=88?= =?UTF-8?q?=E0=B8=A1=20=E0=B8=AA=E0=B8=B1=E0=B8=87=E0=B8=81=E0=B8=B1?= =?UTF-8?q?=E0=B8=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/KpiUserEvaluationController.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/controllers/KpiUserEvaluationController.ts b/src/controllers/KpiUserEvaluationController.ts index 9ab95ca..ca9b3f6 100644 --- a/src/controllers/KpiUserEvaluationController.ts +++ b/src/controllers/KpiUserEvaluationController.ts @@ -1076,6 +1076,11 @@ export class KpiUserEvaluationController extends Controller { summaryPoint: kpiUserEvaluation.summaryPoint, isOpen: kpiUserEvaluation.isOpen, openDate: kpiUserEvaluation.openDate, + org: kpiUserEvaluation.org, + child1: kpiUserEvaluation.child1, + child2: kpiUserEvaluation.child2, + child3: kpiUserEvaluation.child3, + child4: kpiUserEvaluation.child4, year: kpiUserEvaluation.kpiPeriod == null ? null : kpiUserEvaluation.kpiPeriod.year, durationKPI: kpiUserEvaluation.kpiPeriod == null ? null : kpiUserEvaluation.kpiPeriod.durationKPI, @@ -1497,6 +1502,11 @@ export class KpiUserEvaluationController extends Controller { summaryPoint: kpiUserEvaluation.summaryPoint, isOpen: kpiUserEvaluation.isOpen, openDate: kpiUserEvaluation.openDate, + org: kpiUserEvaluation.org, + child1: kpiUserEvaluation.child1, + child2: kpiUserEvaluation.child2, + child3: kpiUserEvaluation.child3, + child4: kpiUserEvaluation.child4, year: kpiUserEvaluation.kpiPeriod == null ? null : kpiUserEvaluation.kpiPeriod.year, durationKPI: kpiUserEvaluation.kpiPeriod == null ? null : kpiUserEvaluation.kpiPeriod.durationKPI, From e9aabfa83a81e387de390cf3c8ea9c8f7d639ed7 Mon Sep 17 00:00:00 2001 From: kittapath Date: Mon, 20 Jan 2025 12:31:59 +0700 Subject: [PATCH 6/6] no message --- src/controllers/KpiUserEvaluationController.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/controllers/KpiUserEvaluationController.ts b/src/controllers/KpiUserEvaluationController.ts index ca9b3f6..04590dd 100644 --- a/src/controllers/KpiUserEvaluationController.ts +++ b/src/controllers/KpiUserEvaluationController.ts @@ -1076,7 +1076,7 @@ export class KpiUserEvaluationController extends Controller { summaryPoint: kpiUserEvaluation.summaryPoint, isOpen: kpiUserEvaluation.isOpen, openDate: kpiUserEvaluation.openDate, - org: kpiUserEvaluation.org, + root: kpiUserEvaluation.org, child1: kpiUserEvaluation.child1, child2: kpiUserEvaluation.child2, child3: kpiUserEvaluation.child3, @@ -1502,7 +1502,7 @@ export class KpiUserEvaluationController extends Controller { summaryPoint: kpiUserEvaluation.summaryPoint, isOpen: kpiUserEvaluation.isOpen, openDate: kpiUserEvaluation.openDate, - org: kpiUserEvaluation.org, + root: kpiUserEvaluation.org, child1: kpiUserEvaluation.child1, child2: kpiUserEvaluation.child2, child3: kpiUserEvaluation.child3,