From 8de7931d4fafb52d97f45836bbce08f3cdd87b06 Mon Sep 17 00:00:00 2001 From: Bright Date: Mon, 17 Feb 2025 10:27:26 +0700 Subject: [PATCH] no message --- src/controllers/ReportController.ts | 307 ++++++++++++++++++---------- 1 file changed, 199 insertions(+), 108 deletions(-) diff --git a/src/controllers/ReportController.ts b/src/controllers/ReportController.ts index 3cf7c44..9f0875c 100644 --- a/src/controllers/ReportController.ts +++ b/src/controllers/ReportController.ts @@ -1869,114 +1869,205 @@ export class ReportController extends Controller { fullnameCommanderHigh: `${kpiUserEvaluation.prefixCommanderHigh}${kpiUserEvaluation.firstNameCommanderHigh} ${kpiUserEvaluation.lastNameCommanderHigh}`, positionCommanderHigh: kpiUserEvaluation.positionCommanderHigh ? kpiUserEvaluation.positionCommanderHigh : "-", - planneds: kpiUserEvaluation.kpiUserPlanneds - .map( - x => ({ - name: Plan.find(y => y.id === x.kpiPlanId)?.includingName || "-", - target: x.target ? Extension.ToThaiNumber(x.target.toLocaleString()) : "-", - point1: x.point == 1 ? "✔" : "-", - point2: x.point == 2 ? "✔" : "-", - point3: x.point == 3 ? "✔" : "-", - point4: x.point == 4 ? "✔" : "-", - point5: x.point == 5 ? "✔" : "-", - weight: x.weight ? Extension.ToThaiNumber(x.weight.toLocaleString()) : "-", - achievement: Extension.ToThaiNumber(`ระดับ ${x.point}`), - summary: x.summary ? Extension.ToThaiNumber(x.summary.toLocaleString()) : "-", - }) - ), - roles: kpiUserEvaluation.kpiUserRoles - .map( - x => ({ - name: Role.find(y => y.id === x.kpiRoleId)?.includingName || "-", - target: x.target ? Extension.ToThaiNumber(x.target.toLocaleString()) : "-", - point1: x.point == 1 ? "✔" : "-", - point2: x.point == 2 ? "✔" : "-", - point3: x.point == 3 ? "✔" : "-", - point4: x.point == 4 ? "✔" : "-", - point5: x.point == 5 ? "✔" : "-", - weight: x.weight ? Extension.ToThaiNumber(x.weight.toLocaleString()) : "-", - achievement: Extension.ToThaiNumber(`ระดับ ${x.point}`), - summary: x.summary ? Extension.ToThaiNumber(x.summary.toLocaleString()) : "-", - }) - ), - specials: kpiUserEvaluation.kpiUserSpecials - .map( - x => ({ - name: x.includingName ?? "-", - target: x.target ? Extension.ToThaiNumber(x.target.toLocaleString()) : "-", - point1: x.point == 1 ? "✔" : "-", - point2: x.point == 2 ? "✔" : "-", - point3: x.point == 3 ? "✔" : "-", - point4: x.point == 4 ? "✔" : "-", - point5: x.point == 5 ? "✔" : "-", - weight: x.weight ? Extension.ToThaiNumber(x.weight.toLocaleString()) : "-", - achievement: Extension.ToThaiNumber(`ระดับ ${x.point}`), - summary: x.summary ? Extension.ToThaiNumber(x.summary.toLocaleString()) : "-", - }) - ), - develops: kpiUserEvaluation.kpiUserDevelopments - .map( - x => ({ - name: x.name ?? "-", - target: x.target ? Extension.ToThaiNumber(x.target.toLocaleString()) : "-", - achievement10: x.point == 10 ? `🗹 ${x.achievement10}` : `☐ ${x.achievement10}`, - achievement5: x.point == 5 ? `🗹 ${x.achievement5}` : `☐ ${x.achievement5}`, - achievement0: x.point == 0 ? `🗹 ${x.achievement0}` : `☐ ${x.achievement0}`, - isDevelopment70: x.isDevelopment70 == true ? `🗹 ๗๐ การลงมือปฏิบัติ(โดยผู้บังคับบัญชามอบหมาย)` : `☐ ๗๐ การลงมือปฏิบัติ(โดยผู้บังคับบัญชามอบหมาย)`, - isDevelopment20: x.isDevelopment20 == true ? `🗹 ๒๐ การเรียนรู้จากผู้อื่น Coach/Mentor/Consulting` : `☐ ๒๐ การเรียนรู้จากผู้อื่น Coach/Mentor/Consulting`, - isDevelopment10: x.isDevelopment10 == true ? `🗹 ๑๐ การฝึกอบรมอื่น ๆ` : `☐ ๑๐ การฝึกอบรมอื่น ๆ`, - point: x.point ? Extension.ToThaiNumber(x.point.toLocaleString()) : "-", - summary: x.summary ? Extension.ToThaiNumber(x.summary.toLocaleString()) : "-", - }) - ), - headCaps: kpiUserEvaluation.kpiUserCapacitys - .filter( - x => Capacitys.some(y => y.id === x.kpiCapacityId && y.type === "HEAD") - ).map( - x => ({ - name: `- ${Capacitys.find(y => y.id === x.kpiCapacityId)?.name}`, - level: x.level ? Extension.ToThaiNumber(x.level.toLocaleString()) : "-", - weight: x.weight ? Extension.ToThaiNumber(x.weight.toLocaleString()) : "-", - point1: x.point == 1 ? "✔" : "-", - point2: x.point == 2 ? "✔" : "-", - point3: x.point == 3 ? "✔" : "-", - point4: x.point == 4 ? "✔" : "-", - point5: x.point == 5 ? "✔" : "-", - summary: x.summary ? Extension.ToThaiNumber(x.summary.toLocaleString()) : "-", - }) - ), - executiveCaps: kpiUserEvaluation.kpiUserCapacitys - .filter( - x => Capacitys.some(y => y.id === x.kpiCapacityId && y.type === "EXECUTIVE") - ).map( - x => ({ - name: `- ${Capacitys.find(y => y.id === x.kpiCapacityId)?.name}`, - level: x.level ? Extension.ToThaiNumber(x.level.toLocaleString()) : "-", - weight: x.weight ? Extension.ToThaiNumber(x.weight.toLocaleString()) : "-", - point1: x.point == 1 ? "✔" : "-", - point2: x.point == 2 ? "✔" : "-", - point3: x.point == 3 ? "✔" : "-", - point4: x.point == 4 ? "✔" : "-", - point5: x.point == 5 ? "✔" : "-", - summary: x.summary ? Extension.ToThaiNumber(x.summary.toLocaleString()) : "-", - }) - ), - groupCaps: kpiUserEvaluation.kpiUserCapacitys - .filter( - x => Capacitys.some(y => y.id === x.kpiCapacityId && y.type === "GROUP") - ).map( - x => ({ - name: `- ${Capacitys.find(y => y.id === x.kpiCapacityId)?.name}`, - level: x.level ? Extension.ToThaiNumber(x.level.toLocaleString()) : "-", - weight: x.weight ? Extension.ToThaiNumber(x.weight.toLocaleString()) : "-", - point1: x.point == 1 ? "✔" : "-", - point2: x.point == 2 ? "✔" : "-", - point3: x.point == 3 ? "✔" : "-", - point4: x.point == 4 ? "✔" : "-", - point5: x.point == 5 ? "✔" : "-", - summary: x.summary ? Extension.ToThaiNumber(x.summary.toLocaleString()) : "-", - }) - ), + planneds: kpiUserEvaluation.kpiUserPlanneds.length != 0 + ? kpiUserEvaluation.kpiUserPlanneds + .map( + x => ({ + name: Plan.find(y => y.id === x.kpiPlanId)?.includingName || "-", + target: x.target ? Extension.ToThaiNumber(x.target.toLocaleString()) : "-", + point1: x.point == 1 ? "✔" : "-", + point2: x.point == 2 ? "✔" : "-", + point3: x.point == 3 ? "✔" : "-", + point4: x.point == 4 ? "✔" : "-", + point5: x.point == 5 ? "✔" : "-", + weight: x.weight ? Extension.ToThaiNumber(x.weight.toLocaleString()) : "-", + achievement: Extension.ToThaiNumber(`ระดับ ${x.point}`), + summary: x.summary ? Extension.ToThaiNumber(x.summary.toLocaleString()) : "-", + }) + ) + : [{ + name: "-", + target: "-", + point1: "-", + point2: "-", + point3: "-", + point4: "-", + point5: "-", + weight: "-", + achievement: "-", + summary: "-", + }], + roles: kpiUserEvaluation.kpiUserRoles.length != 0 + ? kpiUserEvaluation.kpiUserRoles + .map( + x => ({ + name: Role.find(y => y.id === x.kpiRoleId)?.includingName || "-", + target: x.target ? Extension.ToThaiNumber(x.target.toLocaleString()) : "-", + point1: x.point == 1 ? "✔" : "-", + point2: x.point == 2 ? "✔" : "-", + point3: x.point == 3 ? "✔" : "-", + point4: x.point == 4 ? "✔" : "-", + point5: x.point == 5 ? "✔" : "-", + weight: x.weight ? Extension.ToThaiNumber(x.weight.toLocaleString()) : "-", + achievement: Extension.ToThaiNumber(`ระดับ ${x.point}`), + summary: x.summary ? Extension.ToThaiNumber(x.summary.toLocaleString()) : "-", + }) + ) + : [{ + name: "-", + target: "-", + point1: "-", + point2: "-", + point3: "-", + point4: "-", + point5: "-", + weight: "-", + achievement: "-", + summary: "-", + }], + specials: kpiUserEvaluation.kpiUserSpecials.length != 0 + ? kpiUserEvaluation.kpiUserSpecials + .map( + x => ({ + name: x.includingName ?? "-", + target: x.target ? Extension.ToThaiNumber(x.target.toLocaleString()) : "-", + point1: x.point == 1 ? "✔" : "-", + point2: x.point == 2 ? "✔" : "-", + point3: x.point == 3 ? "✔" : "-", + point4: x.point == 4 ? "✔" : "-", + point5: x.point == 5 ? "✔" : "-", + weight: x.weight ? Extension.ToThaiNumber(x.weight.toLocaleString()) : "-", + achievement: Extension.ToThaiNumber(`ระดับ ${x.point}`), + summary: x.summary ? Extension.ToThaiNumber(x.summary.toLocaleString()) : "-", + }) + ) + : [{ + name: "-", + target: "-", + point1: "-", + point2: "-", + point3: "-", + point4: "-", + point5: "-", + weight: "-", + achievement: "-", + summary: "-", + }], + develops: kpiUserEvaluation.kpiUserDevelopments.length != 0 + ? kpiUserEvaluation.kpiUserDevelopments + .map( + x => ({ + name: x.name ?? "-", + target: x.target ? Extension.ToThaiNumber(x.target.toLocaleString()) : "-", + achievement10: x.point == 10 ? `🗹 ${x.achievement10}` : `☐ ${x.achievement10}`, + achievement5: x.point == 5 ? `🗹 ${x.achievement5}` : `☐ ${x.achievement5}`, + achievement0: x.point == 0 ? `🗹 ${x.achievement0}` : `☐ ${x.achievement0}`, + isDevelopment70: x.isDevelopment70 == true ? `🗹 ๗๐ การลงมือปฏิบัติ(โดยผู้บังคับบัญชามอบหมาย)` : `☐ ๗๐ การลงมือปฏิบัติ(โดยผู้บังคับบัญชามอบหมาย)`, + isDevelopment20: x.isDevelopment20 == true ? `🗹 ๒๐ การเรียนรู้จากผู้อื่น Coach/Mentor/Consulting` : `☐ ๒๐ การเรียนรู้จากผู้อื่น Coach/Mentor/Consulting`, + isDevelopment10: x.isDevelopment10 == true ? `🗹 ๑๐ การฝึกอบรมอื่น ๆ` : `☐ ๑๐ การฝึกอบรมอื่น ๆ`, + point: x.point ? Extension.ToThaiNumber(x.point.toLocaleString()) : "-", + summary: x.summary ? Extension.ToThaiNumber(x.summary.toLocaleString()) : "-", + }) + ) + : [{ + name: "-", + target: "-", + achievement10: "-", + // achievement5: "-", + // achievement0: "-", + isDevelopment70: "-", + // isDevelopment20: "-", + // isDevelopment10: "-", + point: "-", + summary: "-", + }], + headCaps: kpiUserEvaluation.kpiUserCapacitys.length != 0 + //&& Capacitys.filter(cap => cap.type === "HEAD" && cap.id == kpiUserEvaluation.kpiUserCapacitys[0].kpiCapacityId).length != 0 + ? kpiUserEvaluation.kpiUserCapacitys + .filter( + x => Capacitys.some(y => y.id === x.kpiCapacityId && y.type === "HEAD") + ).map( + x => ({ + name: `- ${Capacitys.find(y => y.id === x.kpiCapacityId)?.name}`, + level: x.level ? Extension.ToThaiNumber(x.level.toLocaleString()) : "-", + weight: x.weight ? Extension.ToThaiNumber(x.weight.toLocaleString()) : "-", + point1: x.point == 1 ? "✔" : "-", + point2: x.point == 2 ? "✔" : "-", + point3: x.point == 3 ? "✔" : "-", + point4: x.point == 4 ? "✔" : "-", + point5: x.point == 5 ? "✔" : "-", + summary: x.summary ? Extension.ToThaiNumber(x.summary.toLocaleString()) : "-", + }) + ) + : [{ + name: "-", + level: "-", + weight: "-", + point1: "-", + point2: "-", + point3: "-", + point4: "-", + point5: "-", + summary: "-", + }], + executiveCaps: kpiUserEvaluation.kpiUserCapacitys.length != 0 + //&& Capacitys.filter(cap => cap.type === "EXECUTIVE" && cap.id == kpiUserEvaluation.kpiUserCapacitys[0].kpiCapacityId).length != 0 + ? kpiUserEvaluation.kpiUserCapacitys + .filter( + x => Capacitys.some(y => y.id === x.kpiCapacityId && y.type === "EXECUTIVE") + ).map( + x => ({ + name: `- ${Capacitys.find(y => y.id === x.kpiCapacityId)?.name}`, + level: x.level ? Extension.ToThaiNumber(x.level.toLocaleString()) : "-", + weight: x.weight ? Extension.ToThaiNumber(x.weight.toLocaleString()) : "-", + point1: x.point == 1 ? "✔" : "-", + point2: x.point == 2 ? "✔" : "-", + point3: x.point == 3 ? "✔" : "-", + point4: x.point == 4 ? "✔" : "-", + point5: x.point == 5 ? "✔" : "-", + summary: x.summary ? Extension.ToThaiNumber(x.summary.toLocaleString()) : "-", + }) + ) + : [{ + name: "-", + level: "-", + weight: "-", + point1: "-", + point2: "-", + point3: "-", + point4: "-", + point5: "-", + summary: "-", + }], + groupCaps: kpiUserEvaluation.kpiUserCapacitys.length != 0 + //&& Capacitys.filter(cap => cap.type === "GROUP" && cap.id == kpiUserEvaluation.kpiUserCapacitys[0].kpiCapacityId).length != 0 + ? kpiUserEvaluation.kpiUserCapacitys + .filter( + x => Capacitys.some(y => y.id === x.kpiCapacityId && y.type === "GROUP") + ).map( + x => ({ + name: `- ${Capacitys.find(y => y.id === x.kpiCapacityId)?.name}`, + level: x.level ? Extension.ToThaiNumber(x.level.toLocaleString()) : "-", + weight: x.weight ? Extension.ToThaiNumber(x.weight.toLocaleString()) : "-", + point1: x.point == 1 ? "✔" : "-", + point2: x.point == 2 ? "✔" : "-", + point3: x.point == 3 ? "✔" : "-", + point4: x.point == 4 ? "✔" : "-", + point5: x.point == 5 ? "✔" : "-", + summary: x.summary ? Extension.ToThaiNumber(x.summary.toLocaleString()) : "-", + }) + ) + : [{ + name: "-", + level: "-", + weight: "-", + point1: "-", + point2: "-", + point3: "-", + point4: "-", + point5: "-", + summary: "-", + }], }; return new HttpSuccess({