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,