เพิ่มวันที่เวลา แก้ไข/สร้าง
This commit is contained in:
parent
f8bebde592
commit
1c2bc1dbda
17 changed files with 505 additions and 361 deletions
|
|
@ -7,8 +7,6 @@ import HttpStatusCode from "../interfaces/http-status";
|
|||
import { KpiPeriod } from "../entities/kpiPeriod";
|
||||
import { KpiUserEvaluation } from "../entities/kpiUserEvaluation";
|
||||
import Extension from "../interfaces/extension";
|
||||
import { KpiRole } from "../entities/kpiRole";
|
||||
import { KpiPlan } from "../entities/kpiPlan";
|
||||
import { KpiUserDevelopment } from "../entities/kpiUserDevelopment";
|
||||
import CallAPI from "../interfaces/call-api";
|
||||
@Route("api/v1/kpi/report")
|
||||
|
|
@ -17,8 +15,6 @@ import CallAPI from "../interfaces/call-api";
|
|||
export class ReportController extends Controller {
|
||||
private kpiPeriodRepository = AppDataSource.getRepository(KpiPeriod);
|
||||
private kpiUserEvaluationRepository = AppDataSource.getRepository(KpiUserEvaluation);
|
||||
private kpiRoleRepository = AppDataSource.getRepository(KpiRole);
|
||||
private kpiPlanRepository = AppDataSource.getRepository(KpiPlan);
|
||||
private kpiUserDevelopmentRepository = AppDataSource.getRepository(KpiUserDevelopment);
|
||||
|
||||
@Post("announcement")
|
||||
|
|
@ -44,7 +40,7 @@ export class ReportController extends Controller {
|
|||
let dataKpiUserEvaluations: any;
|
||||
let period1: any;
|
||||
let period2: any;
|
||||
let rootName: any
|
||||
let rootName: any;
|
||||
if (requestBody.root && requestBody.periodId) {
|
||||
data = await this.kpiPeriodRepository.findOne({
|
||||
where: { id: requestBody.periodId },
|
||||
|
|
@ -56,11 +52,9 @@ export class ReportController extends Controller {
|
|||
evaluationStatus: "KP7",
|
||||
},
|
||||
});
|
||||
await new CallAPI()
|
||||
.GetData(request, `/org/root/${requestBody.root}`)
|
||||
.then((x) => {
|
||||
rootName = x.orgRootName;
|
||||
});
|
||||
await new CallAPI().GetData(request, `/org/root/${requestBody.root}`).then((x) => {
|
||||
rootName = x.orgRootName;
|
||||
});
|
||||
data = {
|
||||
id: data.id,
|
||||
year: data.year,
|
||||
|
|
@ -68,7 +62,7 @@ export class ReportController extends Controller {
|
|||
startDate: data.startDate,
|
||||
endDate: data.endDate,
|
||||
kpiUserEvaluations: dataKpiUserEvaluations,
|
||||
rootName: rootName
|
||||
rootName: rootName,
|
||||
};
|
||||
|
||||
if (data.durationKPI == "APR") {
|
||||
|
|
@ -170,10 +164,7 @@ export class ReportController extends Controller {
|
|||
period1: Extension.ToThaiNumber(period1),
|
||||
period2: Extension.ToThaiNumber(period2),
|
||||
durationKPI: data?.durationKPI,
|
||||
root:
|
||||
data && data.rootName != null
|
||||
? data.rootName
|
||||
: "-",
|
||||
root: data && data.rootName != null ? data.rootName : "-",
|
||||
userEvaluations: [
|
||||
{
|
||||
no: userEvaluationOrg.length > 0 ? "๑" : "-",
|
||||
|
|
@ -205,172 +196,210 @@ export class ReportController extends Controller {
|
|||
.filter((x: any) => x.evaluationResults == "EXCELLENT")
|
||||
.map((x: any, idx: number) => ({
|
||||
no: Extension.ToThaiNumber((idx + 1).toString()),
|
||||
fullName: x.prefix!=null&&x.firstName!=null&&x.lastName!=null
|
||||
? `${x.prefix}${x.firstName} ${x.lastName}`
|
||||
: "-",
|
||||
fullName:
|
||||
x.prefix != null && x.firstName != null && x.lastName != null
|
||||
? `${x.prefix}${x.firstName} ${x.lastName}`
|
||||
: "-",
|
||||
position: x.position ? x.position : "-",
|
||||
posLevelName: x.posLevelName ? x.posLevelName : "-",
|
||||
org: x.org ? x.org : "-",
|
||||
}))
|
||||
: [{
|
||||
no: "-",
|
||||
fullName: "-",
|
||||
position: "-",
|
||||
posLevelName: "-",
|
||||
org: "-",
|
||||
}];
|
||||
: [
|
||||
{
|
||||
no: "-",
|
||||
fullName: "-",
|
||||
position: "-",
|
||||
posLevelName: "-",
|
||||
org: "-",
|
||||
},
|
||||
];
|
||||
const verygood =
|
||||
data.kpiUserEvaluations.length > 0
|
||||
? data.kpiUserEvaluations
|
||||
.filter((x: any) => x.evaluationResults == "VERY_GOOD")
|
||||
.map((x: any, idx: number) => ({
|
||||
no: Extension.ToThaiNumber((idx + 1).toString()),
|
||||
fullName: x.prefix!=null&&x.firstName!=null&&x.lastName!=null
|
||||
? `${x.prefix}${x.firstName} ${x.lastName}`
|
||||
: "-",
|
||||
fullName:
|
||||
x.prefix != null && x.firstName != null && x.lastName != null
|
||||
? `${x.prefix}${x.firstName} ${x.lastName}`
|
||||
: "-",
|
||||
position: x.position ? x.position : "-",
|
||||
posLevelName: x.posLevelName ? x.posLevelName : "-",
|
||||
org: x.org ? x.org : "-",
|
||||
}))
|
||||
: [{
|
||||
no: "-",
|
||||
fullName: "-",
|
||||
position: "-",
|
||||
posLevelName: "-",
|
||||
org: "-",
|
||||
}];
|
||||
: [
|
||||
{
|
||||
no: "-",
|
||||
fullName: "-",
|
||||
position: "-",
|
||||
posLevelName: "-",
|
||||
org: "-",
|
||||
},
|
||||
];
|
||||
const good =
|
||||
data.kpiUserEvaluations.length > 0
|
||||
? data.kpiUserEvaluations
|
||||
.filter((x: any) => x.evaluationResults == "GOOD")
|
||||
.map((x: any, idx: number) => ({
|
||||
no: Extension.ToThaiNumber((idx + 1).toString()),
|
||||
fullName: x.prefix!=null&&x.firstName!=null&&x.lastName!=null
|
||||
? `${x.prefix}${x.firstName} ${x.lastName}`
|
||||
: "-",
|
||||
fullName:
|
||||
x.prefix != null && x.firstName != null && x.lastName != null
|
||||
? `${x.prefix}${x.firstName} ${x.lastName}`
|
||||
: "-",
|
||||
position: x.position ? x.position : "-",
|
||||
posLevelName: x.posLevelName ? x.posLevelName : "-",
|
||||
org: x.org ? x.org : "-",
|
||||
}))
|
||||
: [{
|
||||
no: "-",
|
||||
fullName: "-",
|
||||
position: "-",
|
||||
posLevelName: "-",
|
||||
org: "-",
|
||||
}];
|
||||
: [
|
||||
{
|
||||
no: "-",
|
||||
fullName: "-",
|
||||
position: "-",
|
||||
posLevelName: "-",
|
||||
org: "-",
|
||||
},
|
||||
];
|
||||
const fair =
|
||||
data.kpiUserEvaluations.length > 0
|
||||
? data.kpiUserEvaluations
|
||||
.filter((x: any) => x.evaluationResults == "FAIR")
|
||||
.map((x: any, idx: number) => ({
|
||||
no: Extension.ToThaiNumber((idx + 1).toString()),
|
||||
fullName: x.prefix!=null&&x.firstName!=null&&x.lastName!=null
|
||||
? `${x.prefix}${x.firstName} ${x.lastName}`
|
||||
: "-",
|
||||
fullName:
|
||||
x.prefix != null && x.firstName != null && x.lastName != null
|
||||
? `${x.prefix}${x.firstName} ${x.lastName}`
|
||||
: "-",
|
||||
position: x.position ? x.position : "-",
|
||||
posLevelName: x.posLevelName ? x.posLevelName : "-",
|
||||
org: x.org ? x.org : "-",
|
||||
}))
|
||||
: [{
|
||||
no: "-",
|
||||
fullName: "-",
|
||||
position: "-",
|
||||
posLevelName: "-",
|
||||
org: "-",
|
||||
}];
|
||||
: [
|
||||
{
|
||||
no: "-",
|
||||
fullName: "-",
|
||||
position: "-",
|
||||
posLevelName: "-",
|
||||
org: "-",
|
||||
},
|
||||
];
|
||||
const improvment =
|
||||
data.kpiUserEvaluations.length > 0
|
||||
? data.kpiUserEvaluations
|
||||
.filter((x: any) => x.evaluationResults == "IMPROVEMENT")
|
||||
.map((x: any, idx: number) => ({
|
||||
no: Extension.ToThaiNumber((idx + 1).toString()),
|
||||
fullName: x.prefix!=null&&x.firstName!=null&&x.lastName!=null
|
||||
? `${x.prefix}${x.firstName} ${x.lastName}`
|
||||
: "-",
|
||||
fullName:
|
||||
x.prefix != null && x.firstName != null && x.lastName != null
|
||||
? `${x.prefix}${x.firstName} ${x.lastName}`
|
||||
: "-",
|
||||
position: x.position ? x.position : "-",
|
||||
posLevelName: x.posLevelName ? x.posLevelName : "-",
|
||||
org: x.org ? x.org : "-",
|
||||
}))
|
||||
: [{
|
||||
no: "-",
|
||||
fullName: "-",
|
||||
position: "-",
|
||||
posLevelName: "-",
|
||||
org: "-",
|
||||
}];
|
||||
: [
|
||||
{
|
||||
no: "-",
|
||||
fullName: "-",
|
||||
position: "-",
|
||||
posLevelName: "-",
|
||||
org: "-",
|
||||
},
|
||||
];
|
||||
formattedData = {
|
||||
year: data?.year ? Extension.ToThaiNumber((data.year + 543).toString()) : "-",
|
||||
period1: Extension.ToThaiNumber(period1),
|
||||
period2: Extension.ToThaiNumber(period2),
|
||||
durationKPI: data?.durationKPI,
|
||||
root: data && data.rootName != null
|
||||
? data.rootName
|
||||
: "-",
|
||||
root: data && data.rootName != null ? data.rootName : "-",
|
||||
excellents: {
|
||||
count:
|
||||
data.kpiUserEvaluations.length > 0
|
||||
? Extension.ToThaiNumber(excellent.length.toString())
|
||||
: "๐",
|
||||
data: excellent.length > 0 ? excellent : [{
|
||||
no: "-",
|
||||
fullName: "-",
|
||||
position: "-",
|
||||
posLevelName: "-",
|
||||
org: "-",
|
||||
}],
|
||||
data:
|
||||
excellent.length > 0
|
||||
? excellent
|
||||
: [
|
||||
{
|
||||
no: "-",
|
||||
fullName: "-",
|
||||
position: "-",
|
||||
posLevelName: "-",
|
||||
org: "-",
|
||||
},
|
||||
],
|
||||
},
|
||||
verygoods: {
|
||||
count:
|
||||
data.kpiUserEvaluations.length > 0
|
||||
? Extension.ToThaiNumber(verygood.length.toString())
|
||||
: "๐",
|
||||
data: verygood.length > 0 ? verygood : [{
|
||||
no: "-",
|
||||
fullName: "-",
|
||||
position: "-",
|
||||
posLevelName: "-",
|
||||
org: "-",
|
||||
}],
|
||||
data:
|
||||
verygood.length > 0
|
||||
? verygood
|
||||
: [
|
||||
{
|
||||
no: "-",
|
||||
fullName: "-",
|
||||
position: "-",
|
||||
posLevelName: "-",
|
||||
org: "-",
|
||||
},
|
||||
],
|
||||
},
|
||||
goods: {
|
||||
count:
|
||||
data.kpiUserEvaluations.length > 0
|
||||
? Extension.ToThaiNumber(good.length.toString())
|
||||
: "๐",
|
||||
data: good.length > 0 ? good : [{
|
||||
no: "-",
|
||||
fullName: "-",
|
||||
position: "-",
|
||||
posLevelName: "-",
|
||||
org: "-",
|
||||
}],
|
||||
data:
|
||||
good.length > 0
|
||||
? good
|
||||
: [
|
||||
{
|
||||
no: "-",
|
||||
fullName: "-",
|
||||
position: "-",
|
||||
posLevelName: "-",
|
||||
org: "-",
|
||||
},
|
||||
],
|
||||
},
|
||||
fairs: {
|
||||
count:
|
||||
data.kpiUserEvaluations.length > 0
|
||||
? Extension.ToThaiNumber(fair.length.toString())
|
||||
: "๐",
|
||||
data: fair.length > 0 ? fair : [{
|
||||
no: "-",
|
||||
fullName: "-",
|
||||
position: "-",
|
||||
posLevelName: "-",
|
||||
org: "-",
|
||||
}],
|
||||
data:
|
||||
fair.length > 0
|
||||
? fair
|
||||
: [
|
||||
{
|
||||
no: "-",
|
||||
fullName: "-",
|
||||
position: "-",
|
||||
posLevelName: "-",
|
||||
org: "-",
|
||||
},
|
||||
],
|
||||
},
|
||||
improvments: {
|
||||
count:
|
||||
data.kpiUserEvaluations.length > 0
|
||||
? Extension.ToThaiNumber(improvment.length.toString())
|
||||
: "๐",
|
||||
data: improvment.length > 0 ? improvment : [{
|
||||
no: "-",
|
||||
fullName: "-",
|
||||
position: "-",
|
||||
posLevelName: "-",
|
||||
org: "-",
|
||||
}],
|
||||
data:
|
||||
improvment.length > 0
|
||||
? improvment
|
||||
: [
|
||||
{
|
||||
no: "-",
|
||||
fullName: "-",
|
||||
position: "-",
|
||||
posLevelName: "-",
|
||||
org: "-",
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
}
|
||||
|
|
@ -380,15 +409,14 @@ export class ReportController extends Controller {
|
|||
const userEvaluations_ =
|
||||
data?.kpiUserEvaluations?.length > 0
|
||||
? data.kpiUserEvaluations.map((x: any, idx: number) => ({
|
||||
no: idx != null ?Extension.ToThaiNumber((idx + 1).toString()) : "-",
|
||||
fullName: x.prefix != null && x.firstName != null && x.lastName != null
|
||||
? `${x.prefix}${x.firstName} ${x.lastName}`
|
||||
: "-",
|
||||
no: idx != null ? Extension.ToThaiNumber((idx + 1).toString()) : "-",
|
||||
fullName:
|
||||
x.prefix != null && x.firstName != null && x.lastName != null
|
||||
? `${x.prefix}${x.firstName} ${x.lastName}`
|
||||
: "-",
|
||||
position: x.position ? x.position : "-",
|
||||
point1:
|
||||
x.summaryPoint >= 90.0
|
||||
? Extension.ToThaiNumber(x.summaryPoint.toString())
|
||||
: "-",
|
||||
x.summaryPoint >= 90.0 ? Extension.ToThaiNumber(x.summaryPoint.toString()) : "-",
|
||||
point2:
|
||||
x.summaryPoint >= 80.0 && x.summaryPoint <= 89.99
|
||||
? Extension.ToThaiNumber(x.summaryPoint.toString())
|
||||
|
|
@ -402,22 +430,22 @@ export class ReportController extends Controller {
|
|||
? Extension.ToThaiNumber(x.summaryPoint.toString())
|
||||
: "-",
|
||||
point5:
|
||||
x.summaryPoint < 60.0
|
||||
? Extension.ToThaiNumber(x.summaryPoint.toString())
|
||||
: "-",
|
||||
x.summaryPoint < 60.0 ? Extension.ToThaiNumber(x.summaryPoint.toString()) : "-",
|
||||
remark: x.reasonEvaluator,
|
||||
}))
|
||||
: [{
|
||||
no: "-",
|
||||
fullName: "-",
|
||||
position: "-",
|
||||
point1: "-",
|
||||
point2: "-",
|
||||
point3: "-",
|
||||
point4: "-",
|
||||
point5: "-",
|
||||
remark: "-",
|
||||
}];
|
||||
: [
|
||||
{
|
||||
no: "-",
|
||||
fullName: "-",
|
||||
position: "-",
|
||||
point1: "-",
|
||||
point2: "-",
|
||||
point3: "-",
|
||||
point4: "-",
|
||||
point5: "-",
|
||||
remark: "-",
|
||||
},
|
||||
];
|
||||
const prefixEvaluator_ =
|
||||
data.kpiUserEvaluations.length > 0 ? data.kpiUserEvaluations[0].prefixEvaluator : "";
|
||||
const firstNameEvaluator_ =
|
||||
|
|
@ -449,7 +477,7 @@ export class ReportController extends Controller {
|
|||
posTypeNameCommander = x.posTypeName;
|
||||
posLevelNameCommander = x.posLevelName;
|
||||
})
|
||||
.catch((x) => {
|
||||
.catch(() => {
|
||||
// throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลในทะเบียนประวัติ");
|
||||
});
|
||||
}
|
||||
|
|
@ -479,7 +507,7 @@ export class ReportController extends Controller {
|
|||
posTypeNameCommanderHigh = x.posTypeName;
|
||||
posLevelNameCommanderHigh = x.posLevelName;
|
||||
})
|
||||
.catch((x) => {
|
||||
.catch(() => {
|
||||
// throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลในทะเบียนประวัติ");
|
||||
});
|
||||
}
|
||||
|
|
@ -493,10 +521,7 @@ export class ReportController extends Controller {
|
|||
period1: Extension.ToThaiNumber(period1),
|
||||
period2: Extension.ToThaiNumber(period2),
|
||||
durationKPI: data?.durationKPI,
|
||||
root:
|
||||
data && data.rootName != null
|
||||
? data.rootName
|
||||
: "-",
|
||||
root: data && data.rootName != null ? data.rootName : "-",
|
||||
fullNameEvaluator: fullNameEvaluator,
|
||||
positionEvaluator:
|
||||
data.kpiUserEvaluations.length > 0 ? data.kpiUserEvaluations[0].positionEvaluator : "-",
|
||||
|
|
@ -541,7 +566,6 @@ export class ReportController extends Controller {
|
|||
if (requestBody.type == "KPI4") {
|
||||
templateName = "KPI4";
|
||||
reportName = "KPI4";
|
||||
const yearNow = new Date().getFullYear();
|
||||
let combinedDatas: any;
|
||||
if (requestBody.profileId) {
|
||||
//ชั่วคราว
|
||||
|
|
@ -913,60 +937,61 @@ export class ReportController extends Controller {
|
|||
year5: Extension.ToThaiNumber(Extension.ToThaiYear(yearNow).toString()),
|
||||
},
|
||||
);
|
||||
formattedData = profileEvaluation.length > 0
|
||||
? combinedData
|
||||
: {
|
||||
fullName: "-",
|
||||
position: "-",
|
||||
posType: "-",
|
||||
posLevel: "-",
|
||||
affiliation: "-",
|
||||
summaryPointAPR1: "-",
|
||||
textPointAPR1: "-",
|
||||
periodAPR1: "-",
|
||||
yearAPR1: "-",
|
||||
summaryPointOCT1: "-",
|
||||
textPointOCT1: "-",
|
||||
periodOCT1: "-",
|
||||
yearOCT1: "-",
|
||||
summaryPointAPR2: "-",
|
||||
textPointAPR2: "-",
|
||||
periodAPR2: "-",
|
||||
yearAPR2: "-",
|
||||
summaryPointOCT2: "-",
|
||||
textPointOCT2: "-",
|
||||
periodOCT2: "-",
|
||||
yearOCT2: "-",
|
||||
summaryPointAPR3: "-",
|
||||
textPointAPR3: "-",
|
||||
periodAPR3: "-",
|
||||
yearAPR3: "-",
|
||||
summaryPointOCT3: "-",
|
||||
textPointOCT3: "-",
|
||||
periodOCT3: "-",
|
||||
yearOCT3: "-",
|
||||
summaryPointAPR4: "-",
|
||||
textPointAPR4: "-",
|
||||
periodAPR4: "-",
|
||||
yearAPR4: "-",
|
||||
summaryPointOCT4: "-",
|
||||
textPointOCT4: "-",
|
||||
periodOCT4: "-",
|
||||
yearOCT4: "-",
|
||||
summaryPointAPR5: "-",
|
||||
textPointAPR5: "-",
|
||||
periodAPR5: "-",
|
||||
yearAPR5: "-",
|
||||
summaryPointOCT5: "-",
|
||||
textPointOCT5: "-",
|
||||
periodOCT5: "-",
|
||||
yearOCT5: "-",
|
||||
year1: Extension.ToThaiNumber(Extension.ToThaiYear(yearNow - 4).toString()),
|
||||
year2: Extension.ToThaiNumber(Extension.ToThaiYear(yearNow - 3).toString()),
|
||||
year3: Extension.ToThaiNumber(Extension.ToThaiYear(yearNow - 2).toString()),
|
||||
year4: Extension.ToThaiNumber(Extension.ToThaiYear(yearNow - 1).toString()),
|
||||
year5: Extension.ToThaiNumber(Extension.ToThaiYear(yearNow).toString()),
|
||||
};
|
||||
formattedData =
|
||||
profileEvaluation.length > 0
|
||||
? combinedData
|
||||
: {
|
||||
fullName: "-",
|
||||
position: "-",
|
||||
posType: "-",
|
||||
posLevel: "-",
|
||||
affiliation: "-",
|
||||
summaryPointAPR1: "-",
|
||||
textPointAPR1: "-",
|
||||
periodAPR1: "-",
|
||||
yearAPR1: "-",
|
||||
summaryPointOCT1: "-",
|
||||
textPointOCT1: "-",
|
||||
periodOCT1: "-",
|
||||
yearOCT1: "-",
|
||||
summaryPointAPR2: "-",
|
||||
textPointAPR2: "-",
|
||||
periodAPR2: "-",
|
||||
yearAPR2: "-",
|
||||
summaryPointOCT2: "-",
|
||||
textPointOCT2: "-",
|
||||
periodOCT2: "-",
|
||||
yearOCT2: "-",
|
||||
summaryPointAPR3: "-",
|
||||
textPointAPR3: "-",
|
||||
periodAPR3: "-",
|
||||
yearAPR3: "-",
|
||||
summaryPointOCT3: "-",
|
||||
textPointOCT3: "-",
|
||||
periodOCT3: "-",
|
||||
yearOCT3: "-",
|
||||
summaryPointAPR4: "-",
|
||||
textPointAPR4: "-",
|
||||
periodAPR4: "-",
|
||||
yearAPR4: "-",
|
||||
summaryPointOCT4: "-",
|
||||
textPointOCT4: "-",
|
||||
periodOCT4: "-",
|
||||
yearOCT4: "-",
|
||||
summaryPointAPR5: "-",
|
||||
textPointAPR5: "-",
|
||||
periodAPR5: "-",
|
||||
yearAPR5: "-",
|
||||
summaryPointOCT5: "-",
|
||||
textPointOCT5: "-",
|
||||
periodOCT5: "-",
|
||||
yearOCT5: "-",
|
||||
year1: Extension.ToThaiNumber(Extension.ToThaiYear(yearNow - 4).toString()),
|
||||
year2: Extension.ToThaiNumber(Extension.ToThaiYear(yearNow - 3).toString()),
|
||||
year3: Extension.ToThaiNumber(Extension.ToThaiYear(yearNow - 2).toString()),
|
||||
year4: Extension.ToThaiNumber(Extension.ToThaiYear(yearNow - 1).toString()),
|
||||
year5: Extension.ToThaiNumber(Extension.ToThaiYear(yearNow).toString()),
|
||||
};
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
|
@ -1149,42 +1174,43 @@ export class ReportController extends Controller {
|
|||
year3: Extension.ToThaiNumber(Extension.ToThaiYear(yearNow).toString()),
|
||||
},
|
||||
);
|
||||
formattedData = profileEvaluation.length > 0
|
||||
? combinedData
|
||||
: {
|
||||
fullName: "-",
|
||||
position: "-",
|
||||
posType: "-",
|
||||
posLevel: "-",
|
||||
affiliation: "-",
|
||||
summaryPointAPR1: "-",
|
||||
textPointAPR1: "-",
|
||||
periodAPR1: "-",
|
||||
yearAPR1: "-",
|
||||
summaryPointOCT1: "-",
|
||||
textPointOCT1: "-",
|
||||
periodOCT1: "-",
|
||||
yearOCT1: "-",
|
||||
summaryPointAPR2: "-",
|
||||
textPointAPR2: "-",
|
||||
periodAPR2: "-",
|
||||
yearAPR2: "-",
|
||||
summaryPointOCT2: "-",
|
||||
textPointOCT2: "-",
|
||||
periodOCT2: "-",
|
||||
yearOCT2: "-",
|
||||
summaryPointAPR3: "-",
|
||||
textPointAPR3: "-",
|
||||
periodAPR3: "-",
|
||||
yearAPR3: "-",
|
||||
summaryPointOCT3: "-",
|
||||
textPointOCT3: "-",
|
||||
periodOCT3: "-",
|
||||
yearOCT3: "-",
|
||||
year1: Extension.ToThaiNumber(Extension.ToThaiYear(yearNow - 2).toString()),
|
||||
year2: Extension.ToThaiNumber(Extension.ToThaiYear(yearNow - 1).toString()),
|
||||
year3: Extension.ToThaiNumber(Extension.ToThaiYear(yearNow).toString()),
|
||||
};
|
||||
formattedData =
|
||||
profileEvaluation.length > 0
|
||||
? combinedData
|
||||
: {
|
||||
fullName: "-",
|
||||
position: "-",
|
||||
posType: "-",
|
||||
posLevel: "-",
|
||||
affiliation: "-",
|
||||
summaryPointAPR1: "-",
|
||||
textPointAPR1: "-",
|
||||
periodAPR1: "-",
|
||||
yearAPR1: "-",
|
||||
summaryPointOCT1: "-",
|
||||
textPointOCT1: "-",
|
||||
periodOCT1: "-",
|
||||
yearOCT1: "-",
|
||||
summaryPointAPR2: "-",
|
||||
textPointAPR2: "-",
|
||||
periodAPR2: "-",
|
||||
yearAPR2: "-",
|
||||
summaryPointOCT2: "-",
|
||||
textPointOCT2: "-",
|
||||
periodOCT2: "-",
|
||||
yearOCT2: "-",
|
||||
summaryPointAPR3: "-",
|
||||
textPointAPR3: "-",
|
||||
periodAPR3: "-",
|
||||
yearAPR3: "-",
|
||||
summaryPointOCT3: "-",
|
||||
textPointOCT3: "-",
|
||||
periodOCT3: "-",
|
||||
yearOCT3: "-",
|
||||
year1: Extension.ToThaiNumber(Extension.ToThaiYear(yearNow - 2).toString()),
|
||||
year2: Extension.ToThaiNumber(Extension.ToThaiYear(yearNow - 1).toString()),
|
||||
year3: Extension.ToThaiNumber(Extension.ToThaiYear(yearNow).toString()),
|
||||
};
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
|
@ -1210,9 +1236,10 @@ export class ReportController extends Controller {
|
|||
// : ""
|
||||
return {
|
||||
no: Extension.ToThaiNumber((idx + 1).toString()),
|
||||
fullName: x.prefix != null && x.firstName != null && x.lastName != null
|
||||
? `${x.prefix}${x.firstName} ${x.lastName}`
|
||||
: "-",
|
||||
fullName:
|
||||
x.prefix != null && x.firstName != null && x.lastName != null
|
||||
? `${x.prefix}${x.firstName} ${x.lastName}`
|
||||
: "-",
|
||||
position: x.position ? x.position : "-",
|
||||
posLevelName: x.posLevelName ? x.posLevelName : "-",
|
||||
developName: x.topicEvaluator ? x.topicEvaluator : "-",
|
||||
|
|
@ -1225,42 +1252,44 @@ export class ReportController extends Controller {
|
|||
: "-",
|
||||
};
|
||||
})
|
||||
: [{
|
||||
no: "-",
|
||||
fullName: "-",
|
||||
position: "-",
|
||||
posLevelName: "-",
|
||||
developName: "-",
|
||||
developEvaluator: "-",
|
||||
target: "-",
|
||||
timeEvaluator: "-",
|
||||
developResults: "-",
|
||||
evaluationResults: "-"
|
||||
}],
|
||||
: [
|
||||
{
|
||||
no: "-",
|
||||
fullName: "-",
|
||||
position: "-",
|
||||
posLevelName: "-",
|
||||
developName: "-",
|
||||
developEvaluator: "-",
|
||||
target: "-",
|
||||
timeEvaluator: "-",
|
||||
developResults: "-",
|
||||
evaluationResults: "-",
|
||||
},
|
||||
],
|
||||
);
|
||||
formattedData = {
|
||||
year: data.year ? Extension.ToThaiNumber((data.year + 543).toString()) : "-",
|
||||
period1: Extension.ToThaiNumber(period1),
|
||||
period2: Extension.ToThaiNumber(period2),
|
||||
durationKPI: data.durationKPI,
|
||||
root:
|
||||
data && data.rootName != null
|
||||
? data.rootName
|
||||
: "-",
|
||||
userEvaluations: userEvaluations_.length > 0
|
||||
? userEvaluations_
|
||||
: [{
|
||||
no: "-",
|
||||
fullName: "-",
|
||||
position: "-",
|
||||
posLevelName: "-",
|
||||
developName: "-",
|
||||
developEvaluator: "-",
|
||||
target: "-",
|
||||
timeEvaluator: "-",
|
||||
developResults: "-",
|
||||
evaluationResults: "-"
|
||||
}],
|
||||
root: data && data.rootName != null ? data.rootName : "-",
|
||||
userEvaluations:
|
||||
userEvaluations_.length > 0
|
||||
? userEvaluations_
|
||||
: [
|
||||
{
|
||||
no: "-",
|
||||
fullName: "-",
|
||||
position: "-",
|
||||
posLevelName: "-",
|
||||
developName: "-",
|
||||
developEvaluator: "-",
|
||||
target: "-",
|
||||
timeEvaluator: "-",
|
||||
developResults: "-",
|
||||
evaluationResults: "-",
|
||||
},
|
||||
],
|
||||
};
|
||||
}
|
||||
if (requestBody.type == "KPI8") {
|
||||
|
|
@ -1395,45 +1424,47 @@ export class ReportController extends Controller {
|
|||
posLevel: userInfo ? userInfo[0]?.posLevelName : "-",
|
||||
period1: period1 ? Extension.ToThaiNumber(period1) : "-",
|
||||
period2: period2 ? Extension.ToThaiNumber(period2) : "-",
|
||||
developments: formattedUserDevelopmentLists
|
||||
? formattedUserDevelopmentLists
|
||||
: [{
|
||||
no:"-",
|
||||
name:"-",
|
||||
target:"-",
|
||||
summary:"-"
|
||||
}],
|
||||
developments: formattedUserDevelopmentLists
|
||||
? formattedUserDevelopmentLists
|
||||
: [
|
||||
{
|
||||
no: "-",
|
||||
name: "-",
|
||||
target: "-",
|
||||
summary: "-",
|
||||
},
|
||||
],
|
||||
};
|
||||
}
|
||||
if (requestBody.type == "KPI9") {
|
||||
templateName = "KPI9";
|
||||
reportName = "KPI9";
|
||||
if(data && data.kpiUserEvaluations.length == 0) {
|
||||
if (data && data.kpiUserEvaluations.length == 0) {
|
||||
//แก้ไขกรณีมีผู้ประเมินที่มีผลการประเมินดีเด่น แต่ RootId ไม่ตรงกับหน่วยงานที่ filter
|
||||
let userEvaInRoot: any
|
||||
let userEvaOutRoot: any []
|
||||
let userEvaInRoot: any;
|
||||
let userEvaOutRoot: any[];
|
||||
userEvaInRoot = await this.kpiUserEvaluationRepository.findOne({
|
||||
select: ["org"],
|
||||
where: {
|
||||
kpiPeriodId: String(requestBody.periodId),
|
||||
orgId: String(requestBody.root),
|
||||
},
|
||||
});
|
||||
if(userEvaInRoot) {
|
||||
kpiPeriodId: String(requestBody.periodId),
|
||||
orgId: String(requestBody.root),
|
||||
},
|
||||
});
|
||||
if (userEvaInRoot) {
|
||||
userEvaOutRoot = await this.kpiUserEvaluationRepository.find({
|
||||
where: {
|
||||
kpiPeriodId: String(requestBody.periodId),
|
||||
orgId: Not(String(requestBody.root)),
|
||||
org: userEvaInRoot.org,
|
||||
evaluationStatus: "KP7",
|
||||
},
|
||||
});
|
||||
if(userEvaOutRoot.length > 0) {
|
||||
data.kpiUserEvaluations = userEvaOutRoot
|
||||
kpiPeriodId: String(requestBody.periodId),
|
||||
orgId: Not(String(requestBody.root)),
|
||||
org: userEvaInRoot.org,
|
||||
evaluationStatus: "KP7",
|
||||
},
|
||||
});
|
||||
if (userEvaOutRoot.length > 0) {
|
||||
data.kpiUserEvaluations = userEvaOutRoot;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const userEvaluations_ =
|
||||
data.kpiUserEvaluations.length > 0
|
||||
? data.kpiUserEvaluations
|
||||
|
|
@ -1443,39 +1474,42 @@ export class ReportController extends Controller {
|
|||
)
|
||||
.map((x: any, idx: number) => ({
|
||||
no: Extension.ToThaiNumber((idx + 1).toString()),
|
||||
fullName: x.prefix != null && x.firstName != null && x.lastName != null
|
||||
? `${x.prefix}${x.firstName} ${x.lastName}`
|
||||
: "-",
|
||||
fullName:
|
||||
x.prefix != null && x.firstName != null && x.lastName != null
|
||||
? `${x.prefix}${x.firstName} ${x.lastName}`
|
||||
: "-",
|
||||
position: x.position ? x.position : "-",
|
||||
posLevelName: x.posLevelName ? x.posLevelName : "-",
|
||||
evaluationResults: x.evaluationResults
|
||||
? Extension.EvaluationResult(x.evaluationResults)
|
||||
: "-",
|
||||
}))
|
||||
: [{
|
||||
no: "-",
|
||||
fullName: "-",
|
||||
position: "-",
|
||||
posLevelName: "-",
|
||||
evaluationResults: "-",
|
||||
}];
|
||||
: [
|
||||
{
|
||||
no: "-",
|
||||
fullName: "-",
|
||||
position: "-",
|
||||
posLevelName: "-",
|
||||
evaluationResults: "-",
|
||||
},
|
||||
];
|
||||
|
||||
formattedData = {
|
||||
root:
|
||||
data && data.rootName != null
|
||||
? data.rootName
|
||||
: "-",
|
||||
root: data && data.rootName != null ? data.rootName : "-",
|
||||
period: data?.durationKPI == "APR" ? "๑" : data?.durationKPI == "OCT" ? "๒" : "-",
|
||||
year: data.year ? Extension.ToThaiNumber((data.year + 543).toString()) : "-",
|
||||
userEvaluations: userEvaluations_.length > 0
|
||||
? userEvaluations_
|
||||
: [{
|
||||
no: "-",
|
||||
fullName: "-",
|
||||
position: "-",
|
||||
posLevelName: "-",
|
||||
evaluationResults: "-",
|
||||
}],
|
||||
userEvaluations:
|
||||
userEvaluations_.length > 0
|
||||
? userEvaluations_
|
||||
: [
|
||||
{
|
||||
no: "-",
|
||||
fullName: "-",
|
||||
position: "-",
|
||||
posLevelName: "-",
|
||||
evaluationResults: "-",
|
||||
},
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue