report kpi

This commit is contained in:
Bright 2025-02-25 13:42:47 +07:00
parent 74f8f9b298
commit a564cd5ee9

View file

@ -1810,7 +1810,7 @@ export class ReportController extends Controller {
const isGroup2: boolean = ["ทั่วไป", "วิชาการ"].includes(kpiUserEvaluation.posTypeName); const isGroup2: boolean = ["ทั่วไป", "วิชาการ"].includes(kpiUserEvaluation.posTypeName);
const Plan = await this.kpiPlanRepository.find(); const Plan = await this.kpiPlanRepository.find();
const Role = await this.kpiRoleRepository.find(); const Role = await this.kpiRoleRepository.find();
const Capacitys = await this.kpiCapacityRepository.find({ const Capacitys = await this.kpiCapacityRepository.find({
where: { where: {
type: In(["HEAD", "EXECUTIVE", "GROUP"]) type: In(["HEAD", "EXECUTIVE", "GROUP"])
} }
@ -1863,39 +1863,47 @@ export class ReportController extends Controller {
posTypeNameEvaluator: kpiUserEvaluation.posTypeNameEvaluator, posTypeNameEvaluator: kpiUserEvaluation.posTypeNameEvaluator,
posLevelNameEvaluator: kpiUserEvaluation.posLevelNameEvaluator, posLevelNameEvaluator: kpiUserEvaluation.posLevelNameEvaluator,
orgEvaluator: kpiUserEvaluation.orgEvaluator, orgEvaluator: kpiUserEvaluation.orgEvaluator,
fullnameCommander: fullnameCommander: kpiUserEvaluation.prefixCommander != null && kpiUserEvaluation.firstNameCommander != null
`${kpiUserEvaluation.prefixCommander}${kpiUserEvaluation.firstNameCommander} ${kpiUserEvaluation.lastNameCommander}`, && kpiUserEvaluation.lastNameCommander != null
positionCommander: kpiUserEvaluation.positionCommander ? kpiUserEvaluation.positionCommander : "-", ? `${kpiUserEvaluation.prefixCommander}${kpiUserEvaluation.firstNameCommander} ${kpiUserEvaluation.lastNameCommander}`
fullnameCommanderHigh: : ` `,
`${kpiUserEvaluation.prefixCommanderHigh}${kpiUserEvaluation.firstNameCommanderHigh} ${kpiUserEvaluation.lastNameCommanderHigh}`, positionCommander: kpiUserEvaluation.positionCommander
positionCommanderHigh: kpiUserEvaluation.positionCommanderHigh ? kpiUserEvaluation.positionCommanderHigh : "-", ? kpiUserEvaluation.positionCommander
: ` `,
fullnameCommanderHigh: kpiUserEvaluation.prefixCommanderHigh != null && kpiUserEvaluation.firstNameCommanderHigh != null
&& kpiUserEvaluation.lastNameCommanderHigh != null
? `${kpiUserEvaluation.prefixCommanderHigh}${kpiUserEvaluation.firstNameCommanderHigh} ${kpiUserEvaluation.lastNameCommanderHigh}`
: ` `,
positionCommanderHigh: kpiUserEvaluation.positionCommanderHigh
? kpiUserEvaluation.positionCommanderHigh
: ` `,
planneds: kpiUserEvaluation.kpiUserPlanneds.length != 0 planneds: kpiUserEvaluation.kpiUserPlanneds.length != 0
? kpiUserEvaluation.kpiUserPlanneds ? kpiUserEvaluation.kpiUserPlanneds
.map( .map(
x => ({ x => ({
name: Plan.find(y => y.id === x.kpiPlanId)?.includingName || "-", name: Plan.find(y => y.id === x.kpiPlanId)?.includingName || "-",
target: x.target ? Extension.ToThaiNumber(x.target.toLocaleString()) : "-", target: x.target ? Extension.ToThaiNumber(x.target.toLocaleString()) : "-",
point1: x.point == 1 ? "✔" : "-", point1: x.point == 1 ? "🗹" : "☐",
point2: x.point == 2 ? "✔" : "-", point2: x.point == 2 ? "🗹" : "☐",
point3: x.point == 3 ? "✔" : "-", point3: x.point == 3 ? "🗹" : "☐",
point4: x.point == 4 ? "✔" : "-", point4: x.point == 4 ? "🗹" : "☐",
point5: x.point == 5 ? "✔" : "-", point5: x.point == 5 ? "🗹" : "☐",
weight: x.weight ? Extension.ToThaiNumber(x.weight.toLocaleString()) : "-", weight: x.weight ? Extension.ToThaiNumber(x.weight.toLocaleString()) : "-",
achievement: Extension.ToThaiNumber(`ระดับ ${x.point}`), achievement: x.point ? Extension.ToThaiNumber(`ระดับ ${x.point}`) : "-",
summary: x.summary ? Extension.ToThaiNumber(x.summary.toLocaleString()) : "-", summary: x.summary ? Extension.ToThaiNumber(x.summary.toLocaleString()) : "-",
}) })
) )
: [{ : [{
name: "-", name: "-",
target: "-", target: "-",
point1: "-", point1: "☐",
point2: "-", point2: "☐",
point3: "-", point3: "☐",
point4: "-", point4: "☐",
point5: "-", point5: "☐",
weight: "-", weight: "-",
achievement: "-", achievement: "-",
summary: "-", summary: "-",
}], }],
roles: kpiUserEvaluation.kpiUserRoles.length != 0 roles: kpiUserEvaluation.kpiUserRoles.length != 0
? kpiUserEvaluation.kpiUserRoles ? kpiUserEvaluation.kpiUserRoles
@ -1903,27 +1911,27 @@ export class ReportController extends Controller {
x => ({ x => ({
name: Role.find(y => y.id === x.kpiRoleId)?.includingName || "-", name: Role.find(y => y.id === x.kpiRoleId)?.includingName || "-",
target: x.target ? Extension.ToThaiNumber(x.target.toLocaleString()) : "-", target: x.target ? Extension.ToThaiNumber(x.target.toLocaleString()) : "-",
point1: x.point == 1 ? "✔" : "-", point1: x.point == 1 ? "🗹" : "☐",
point2: x.point == 2 ? "✔" : "-", point2: x.point == 2 ? "🗹" : "☐",
point3: x.point == 3 ? "✔" : "-", point3: x.point == 3 ? "🗹" : "☐",
point4: x.point == 4 ? "✔" : "-", point4: x.point == 4 ? "🗹" : "☐",
point5: x.point == 5 ? "✔" : "-", point5: x.point == 5 ? "🗹" : "☐",
weight: x.weight ? Extension.ToThaiNumber(x.weight.toLocaleString()) : "-", weight: x.weight ? Extension.ToThaiNumber(x.weight.toLocaleString()) : "-",
achievement: Extension.ToThaiNumber(`ระดับ ${x.point}`), achievement: x.point ? Extension.ToThaiNumber(`ระดับ ${x.point}`) : "-",
summary: x.summary ? Extension.ToThaiNumber(x.summary.toLocaleString()) : "-", summary: x.summary ? Extension.ToThaiNumber(x.summary.toLocaleString()) : "-",
}) })
) )
: [{ : [{
name: "-", name: "-",
target: "-", target: "-",
point1: "-", point1: "☐",
point2: "-", point2: "☐",
point3: "-", point3: "☐",
point4: "-", point4: "☐",
point5: "-", point5: "☐",
weight: "-", weight: "-",
achievement: "-", achievement: "-",
summary: "-", summary: "-",
}], }],
specials: kpiUserEvaluation.kpiUserSpecials.length != 0 specials: kpiUserEvaluation.kpiUserSpecials.length != 0
? kpiUserEvaluation.kpiUserSpecials ? kpiUserEvaluation.kpiUserSpecials
@ -1931,28 +1939,28 @@ export class ReportController extends Controller {
x => ({ x => ({
name: x.includingName ?? "-", name: x.includingName ?? "-",
target: x.target ? Extension.ToThaiNumber(x.target.toLocaleString()) : "-", target: x.target ? Extension.ToThaiNumber(x.target.toLocaleString()) : "-",
point1: x.point == 1 ? "✔" : "-", point1: x.point == 1 ? "🗹" : "☐",
point2: x.point == 2 ? "✔" : "-", point2: x.point == 2 ? "🗹" : "☐",
point3: x.point == 3 ? "✔" : "-", point3: x.point == 3 ? "🗹" : "☐",
point4: x.point == 4 ? "✔" : "-", point4: x.point == 4 ? "🗹" : "☐",
point5: x.point == 5 ? "✔" : "-", point5: x.point == 5 ? "🗹" : "☐",
weight: x.weight ? Extension.ToThaiNumber(x.weight.toLocaleString()) : "-", weight: x.weight ? Extension.ToThaiNumber(x.weight.toLocaleString()) : "-",
achievement: Extension.ToThaiNumber(`ระดับ ${x.point}`), achievement: x.point ? Extension.ToThaiNumber(`ระดับ ${x.point}`) : "-",
summary: x.summary ? Extension.ToThaiNumber(x.summary.toLocaleString()) : "-", summary: x.summary ? Extension.ToThaiNumber(x.summary.toLocaleString()) : "-",
}) })
) )
: [{ : [{
name: "-", name: "-",
target: "-", target: "-",
point1: "-", point1: "☐",
point2: "-", point2: "☐",
point3: "-", point3: "☐",
point4: "-", point4: "☐",
point5: "-", point5: "☐",
weight: "-", weight: "-",
achievement: "-", achievement: "-",
summary: "-", summary: "-",
}], }],
develops: kpiUserEvaluation.kpiUserDevelopments.length != 0 develops: kpiUserEvaluation.kpiUserDevelopments.length != 0
? kpiUserEvaluation.kpiUserDevelopments ? kpiUserEvaluation.kpiUserDevelopments
.map( .map(
@ -1965,66 +1973,64 @@ export class ReportController extends Controller {
isDevelopment70: x.isDevelopment70 == true ? `🗹 ๗๐ การลงมือปฏิบัติ(โดยผู้บังคับบัญชามอบหมาย)` : `☐ ๗๐ การลงมือปฏิบัติ(โดยผู้บังคับบัญชามอบหมาย)`, isDevelopment70: x.isDevelopment70 == true ? `🗹 ๗๐ การลงมือปฏิบัติ(โดยผู้บังคับบัญชามอบหมาย)` : `☐ ๗๐ การลงมือปฏิบัติ(โดยผู้บังคับบัญชามอบหมาย)`,
isDevelopment20: x.isDevelopment20 == true ? `🗹 ๒๐ การเรียนรู้จากผู้อื่น Coach/Mentor/Consulting` : `☐ ๒๐ การเรียนรู้จากผู้อื่น Coach/Mentor/Consulting`, isDevelopment20: x.isDevelopment20 == true ? `🗹 ๒๐ การเรียนรู้จากผู้อื่น Coach/Mentor/Consulting` : `☐ ๒๐ การเรียนรู้จากผู้อื่น Coach/Mentor/Consulting`,
isDevelopment10: x.isDevelopment10 == true ? `🗹 ๑๐ การฝึกอบรมอื่น ๆ` : `☐ ๑๐ การฝึกอบรมอื่น ๆ`, isDevelopment10: x.isDevelopment10 == true ? `🗹 ๑๐ การฝึกอบรมอื่น ๆ` : `☐ ๑๐ การฝึกอบรมอื่น ๆ`,
point: x.point ? Extension.ToThaiNumber(x.point.toLocaleString()) : "-", point: x.point ? Extension.ToThaiNumber(x.point.toLocaleString()) : "-",
summary: x.summary ? Extension.ToThaiNumber(x.summary.toLocaleString()) : "-", summary: x.summary ? Extension.ToThaiNumber(x.summary.toLocaleString()) : "-",
}) })
) )
: [{ : [{
name: "-", name: "-",
target: "-", target: "-",
achievement10: "-", achievement10: "-",
// achievement5: "-", isDevelopment70: "-",
// achievement0: "-", point: "-",
isDevelopment70: "-", summary: "-",
// isDevelopment20: "-", }],
// isDevelopment10: "-",
point: "-",
summary: "-",
}],
headCaps: kpiUserEvaluation.kpiUserCapacitys.length != 0 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")).length != 0
? kpiUserEvaluation.kpiUserCapacitys ? kpiUserEvaluation.kpiUserCapacitys
.filter( .filter(
x => Capacitys.some(y => y.id === x.kpiCapacityId && y.type === "HEAD") x => Capacitys.some(y => y.id === x.kpiCapacityId && y.type === "HEAD")
).map( )
.map(
x => ({ x => ({
name: `- ${Capacitys.find(y => y.id === x.kpiCapacityId)?.name}`, name: `- ${Capacitys.find(y => y.id === x.kpiCapacityId)?.name ?? ""}`,
level: x.level ? Extension.ToThaiNumber(x.level.toLocaleString()) : "-", level: x.level ? Extension.ToThaiNumber(x.level.toLocaleString()) : "-",
weight: x.weight ? Extension.ToThaiNumber(x.weight.toLocaleString()) : "-", weight: x.weight ? Extension.ToThaiNumber(x.weight.toLocaleString()) : "-",
point1: x.point == 1 ? "✔" : "-", point1: x.point == 1 ? "🗹" : "☐",
point2: x.point == 2 ? "✔" : "-", point2: x.point == 2 ? "🗹" : "☐",
point3: x.point == 3 ? "✔" : "-", point3: x.point == 3 ? "🗹" : "☐",
point4: x.point == 4 ? "✔" : "-", point4: x.point == 4 ? "🗹" : "☐",
point5: x.point == 5 ? "✔" : "-", point5: x.point == 5 ? "🗹" : "☐",
summary: x.summary ? Extension.ToThaiNumber(x.summary.toLocaleString()) : "-", summary: x.summary ? Extension.ToThaiNumber(x.summary.toLocaleString()) : "-",
}) })
) )
: [{ : [{
name: "-", name: "-",
level: "-", level: "-",
weight: "-", weight: "-",
point1: "-", point1: "☐",
point2: "-", point2: "☐",
point3: "-", point3: "☐",
point4: "-", point4: "☐",
point5: "-", point5: "☐",
summary: "-", summary: "-",
}], }],
executiveCaps: kpiUserEvaluation.kpiUserCapacitys.length != 0 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")).length != 0
? kpiUserEvaluation.kpiUserCapacitys ? kpiUserEvaluation.kpiUserCapacitys
.filter( .filter(
x => Capacitys.some(y => y.id === x.kpiCapacityId && y.type === "EXECUTIVE") x => Capacitys.some(y => y.id === x.kpiCapacityId && y.type === "EXECUTIVE")
).map( )
.map(
x => ({ x => ({
name: `- ${Capacitys.find(y => y.id === x.kpiCapacityId)?.name}`, name: `- ${Capacitys.find(y => y.id === x.kpiCapacityId)?.name ?? ""}`,
level: x.level ? Extension.ToThaiNumber(x.level.toLocaleString()) : "-", level: x.level ? Extension.ToThaiNumber(x.level.toLocaleString()) : "-",
weight: x.weight ? Extension.ToThaiNumber(x.weight.toLocaleString()) : "-", weight: x.weight ? Extension.ToThaiNumber(x.weight.toLocaleString()) : "-",
point1: x.point == 1 ? "✔" : "-", point1: x.point == 1 ? "🗹" : "☐",
point2: x.point == 2 ? "✔" : "-", point2: x.point == 2 ? "🗹" : "☐",
point3: x.point == 3 ? "✔" : "-", point3: x.point == 3 ? "🗹" : "☐",
point4: x.point == 4 ? "✔" : "-", point4: x.point == 4 ? "🗹" : "☐",
point5: x.point == 5 ? "✔" : "-", point5: x.point == 5 ? "🗹" : "☐",
summary: x.summary ? Extension.ToThaiNumber(x.summary.toLocaleString()) : "-", summary: x.summary ? Extension.ToThaiNumber(x.summary.toLocaleString()) : "-",
}) })
) )
@ -2032,28 +2038,29 @@ export class ReportController extends Controller {
name: "-", name: "-",
level: "-", level: "-",
weight: "-", weight: "-",
point1: "-", point1: "",
point2: "-", point2: "",
point3: "-", point3: "",
point4: "-", point4: "",
point5: "-", point5: "",
summary: "-", summary: "-",
}], }],
groupCaps: kpiUserEvaluation.kpiUserCapacitys.length != 0 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")).length != 0
? kpiUserEvaluation.kpiUserCapacitys ? kpiUserEvaluation.kpiUserCapacitys
.filter( .filter(
x => Capacitys.some(y => y.id === x.kpiCapacityId && y.type === "GROUP") x => Capacitys.some(y => y.id === x.kpiCapacityId && y.type === "GROUP")
).map( )
.map(
x => ({ x => ({
name: `- ${Capacitys.find(y => y.id === x.kpiCapacityId)?.name}`, name: `- ${Capacitys.find(y => y.id === x.kpiCapacityId)?.name ?? ""}`,
level: x.level ? Extension.ToThaiNumber(x.level.toLocaleString()) : "-", level: x.level ? Extension.ToThaiNumber(x.level.toLocaleString()) : "-",
weight: x.weight ? Extension.ToThaiNumber(x.weight.toLocaleString()) : "-", weight: x.weight ? Extension.ToThaiNumber(x.weight.toLocaleString()) : "-",
point1: x.point == 1 ? "✔" : "-", point1: x.point == 1 ? "🗹" : "☐",
point2: x.point == 2 ? "✔" : "-", point2: x.point == 2 ? "🗹" : "☐",
point3: x.point == 3 ? "✔" : "-", point3: x.point == 3 ? "🗹" : "☐",
point4: x.point == 4 ? "✔" : "-", point4: x.point == 4 ? "🗹" : "☐",
point5: x.point == 5 ? "✔" : "-", point5: x.point == 5 ? "🗹" : "☐",
summary: x.summary ? Extension.ToThaiNumber(x.summary.toLocaleString()) : "-", summary: x.summary ? Extension.ToThaiNumber(x.summary.toLocaleString()) : "-",
}) })
) )
@ -2061,13 +2068,34 @@ export class ReportController extends Controller {
name: "-", name: "-",
level: "-", level: "-",
weight: "-", weight: "-",
point1: "-", point1: "",
point2: "-", point2: "",
point3: "-", point3: "",
point4: "-", point4: "",
point5: "-", point5: "",
summary: "-", summary: "-",
}], }],
summaryPlanneds: Extension.ToThaiNumber(kpiUserEvaluation.kpiUserPlanneds.reduce((sum, r) => sum + r.summary, 0).toLocaleString()),
summarySpecials: Extension.ToThaiNumber(kpiUserEvaluation.kpiUserSpecials.reduce((sum, r) => sum + r.summary, 0).toLocaleString()),
summaryPoint1:
Extension.ToThaiNumber((kpiUserEvaluation.kpiUserPlanneds.reduce((sum, p) => sum + p.summary, 0)
+kpiUserEvaluation.kpiUserRoles.reduce((sum, r) => sum + r.summary, 0)
+kpiUserEvaluation.kpiUserSpecials.reduce((sum, s) => sum + s.summary, 0)).toLocaleString()),
totalPoint1: kpiUserEvaluation.totalPoint1
? Extension.ToThaiNumber(kpiUserEvaluation.totalPoint1.toLocaleString())
: "-",
totalPoint2_1: kpiUserEvaluation.totalPoint2_1
? Extension.ToThaiNumber(kpiUserEvaluation.totalPoint2_1.toLocaleString())
: "-",
totalPoint2_2: kpiUserEvaluation.totalPoint2_2
? Extension.ToThaiNumber(kpiUserEvaluation.totalPoint2_2.toLocaleString())
: "-",
totalPoint2: kpiUserEvaluation.totalPoint2_1 && kpiUserEvaluation.totalPoint2_2
? Extension.ToThaiNumber((kpiUserEvaluation.totalPoint2_1 + kpiUserEvaluation.totalPoint2_2).toLocaleString())
: "-",
summaryPoint: kpiUserEvaluation.summaryPoint
? Extension.ToThaiNumber(kpiUserEvaluation.summaryPoint.toLocaleString())
: "-",
}; };
return new HttpSuccess({ return new HttpSuccess({