Merge branch 'develop' into adiDev
This commit is contained in:
commit
2688e8267c
2 changed files with 76 additions and 22 deletions
|
|
@ -215,7 +215,8 @@ export class kpiPeriodController extends Controller {
|
||||||
year !== 0 && year != null && year != undefined ? "kpiPeriod.year = :year" : "1=1",
|
year !== 0 && year != null && year != undefined ? "kpiPeriod.year = :year" : "1=1",
|
||||||
{ year: year },
|
{ year: year },
|
||||||
)
|
)
|
||||||
.orderBy("kpiPeriod.createdAt", "DESC")
|
.orderBy("kpiPeriod.startDate", "ASC")
|
||||||
|
.addOrderBy("kpiPeriod.year", "ASC")
|
||||||
.skip((page - 1) * pageSize)
|
.skip((page - 1) * pageSize)
|
||||||
.take(pageSize)
|
.take(pageSize)
|
||||||
.getManyAndCount();
|
.getManyAndCount();
|
||||||
|
|
|
||||||
|
|
@ -75,6 +75,7 @@ export class ReportController extends Controller {
|
||||||
where: {
|
where: {
|
||||||
kpiPeriodId: requestBody.periodId,
|
kpiPeriodId: requestBody.periodId,
|
||||||
orgId: requestBody.root,
|
orgId: requestBody.root,
|
||||||
|
evaluationStatus: "KP7"
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
data = {
|
data = {
|
||||||
|
|
@ -971,6 +972,15 @@ export class ReportController extends Controller {
|
||||||
const target_ = await this.kpiUserDevelopmentRepository.findOne({
|
const target_ = await this.kpiUserDevelopmentRepository.findOne({
|
||||||
where: { kpiUserEvaluationId: x.id },
|
where: { kpiUserEvaluationId: x.id },
|
||||||
});
|
});
|
||||||
|
const isDev70 = target_ && target_?.isDevelopment70 === true
|
||||||
|
? "🗹 70 การลงมือปฏิบัติ (โดยผู้บังคับบัญชามอบหมาย)"
|
||||||
|
: ""
|
||||||
|
const isDev20 = target_ && target_?.isDevelopment20 === true
|
||||||
|
? "🗹 20 การเรียนรู้จากผู้อื่น (Coach/Mentor/Consulting)"
|
||||||
|
: ""
|
||||||
|
const isDev10 = target_ && target_?.isDevelopment10 === true
|
||||||
|
? "🗹 10 การฝึกอบรมอื่นๆ"
|
||||||
|
: ""
|
||||||
return {
|
return {
|
||||||
no: Extension.ToThaiNumber((idx + 1).toString()),
|
no: Extension.ToThaiNumber((idx + 1).toString()),
|
||||||
fullName: `${x.prefix}${x.firstName} ${x.lastName}`,
|
fullName: `${x.prefix}${x.firstName} ${x.lastName}`,
|
||||||
|
|
@ -981,6 +991,9 @@ export class ReportController extends Controller {
|
||||||
target: target_ ? target_.target : "",
|
target: target_ ? target_.target : "",
|
||||||
timeEvaluator: x.timeEvaluator ? Extension.ToThaiNumber(x.timeEvaluator) : "",
|
timeEvaluator: x.timeEvaluator ? Extension.ToThaiNumber(x.timeEvaluator) : "",
|
||||||
developResults: "", //วิธีการวัดผลการพัฒนา
|
developResults: "", //วิธีการวัดผลการพัฒนา
|
||||||
|
isDev70,
|
||||||
|
isDev20,
|
||||||
|
isDev10,
|
||||||
evaluationResults: x.evaluationResults
|
evaluationResults: x.evaluationResults
|
||||||
? Extension.EvaluationResult(x.evaluationResults)
|
? Extension.EvaluationResult(x.evaluationResults)
|
||||||
: "",
|
: "",
|
||||||
|
|
@ -1004,7 +1017,44 @@ export class ReportController extends Controller {
|
||||||
templateName = "KPI8";
|
templateName = "KPI8";
|
||||||
reportName = "KPI8";
|
reportName = "KPI8";
|
||||||
//use_filter
|
//use_filter
|
||||||
if (requestBody.profileId) {
|
let period_:any
|
||||||
|
let formattedUserDevelopmentLists:any
|
||||||
|
let userInfo:any
|
||||||
|
let userDevelopmentLists:any
|
||||||
|
let fullNameParts:any
|
||||||
|
let affiliation:any
|
||||||
|
if (requestBody.profileId && requestBody.periodId) {
|
||||||
|
period_ = await this.kpiPeriodRepository.findOne({
|
||||||
|
where: { id: String(requestBody.periodId) }
|
||||||
|
})
|
||||||
|
if(period_ && !period1 && !period2) {
|
||||||
|
if(period_?.durationKPI === "APR") {
|
||||||
|
period1 = `${Extension.ToThaiFullDate2(period_.startDate)} ถึง ${Extension.ToThaiFullDate2(period_.endDate)}`;
|
||||||
|
let _period2 = await this.kpiPeriodRepository.findOne({
|
||||||
|
where: {
|
||||||
|
year: period_.year,
|
||||||
|
durationKPI: "OCT",
|
||||||
|
isActive: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
period2 = _period2
|
||||||
|
? `${Extension.ToThaiFullDate2(_period2?.startDate)} ถึง ${Extension.ToThaiFullDate2(_period2?.endDate)}`
|
||||||
|
: "";
|
||||||
|
}
|
||||||
|
else if (period_?.durationKPI === "OCT"){
|
||||||
|
period2 = `${Extension.ToThaiFullDate2(period_.startDate)} ถึง ${Extension.ToThaiFullDate2(period_.endDate)}`;
|
||||||
|
let _period1 = await this.kpiPeriodRepository.findOne({
|
||||||
|
where: {
|
||||||
|
year: period_.year,
|
||||||
|
durationKPI: "APR",
|
||||||
|
isActive: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
period1 = _period1
|
||||||
|
? `${Extension.ToThaiFullDate2(_period1?.startDate)} ถึง ${Extension.ToThaiFullDate2(_period1?.endDate)}`
|
||||||
|
: "";
|
||||||
|
}
|
||||||
|
}
|
||||||
const profileEvaluationIds = await AppDataSource.getRepository(KpiUserEvaluation)
|
const profileEvaluationIds = await AppDataSource.getRepository(KpiUserEvaluation)
|
||||||
.createQueryBuilder("kpiUserEvaluation")
|
.createQueryBuilder("kpiUserEvaluation")
|
||||||
.leftJoinAndSelect("kpiUserEvaluation.kpiPeriod", "kpiPeriod")
|
.leftJoinAndSelect("kpiUserEvaluation.kpiPeriod", "kpiPeriod")
|
||||||
|
|
@ -1012,16 +1062,18 @@ export class ReportController extends Controller {
|
||||||
.andWhere("kpiUserEvaluation.kpiPeriodId = :kpiPeriodId", {
|
.andWhere("kpiUserEvaluation.kpiPeriodId = :kpiPeriodId", {
|
||||||
kpiPeriodId: requestBody.periodId,
|
kpiPeriodId: requestBody.periodId,
|
||||||
})
|
})
|
||||||
|
.andWhere("kpiUserEvaluation.evaluationStatus = 'KP7'")
|
||||||
.groupBy("kpiUserEvaluation.kpiPeriodId")
|
.groupBy("kpiUserEvaluation.kpiPeriodId")
|
||||||
.select("MIN(kpiUserEvaluation.id) as id")
|
.select("MIN(kpiUserEvaluation.id) as id")
|
||||||
.getRawMany();
|
.getRawMany();
|
||||||
if (profileEvaluationIds.length > 0) {
|
if (profileEvaluationIds.length > 0) {
|
||||||
const userInfo = await this.kpiUserEvaluationRepository.find({
|
userInfo = await this.kpiUserEvaluationRepository.find({
|
||||||
where: {
|
where: {
|
||||||
id: In(profileEvaluationIds.map((x: any) => x.id)),
|
id: In(profileEvaluationIds.map((x: any) => x.id)),
|
||||||
|
evaluationStatus: "KP7"
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
const userDevelopmentLists = await this.kpiUserDevelopmentRepository.find({
|
userDevelopmentLists = await this.kpiUserDevelopmentRepository.find({
|
||||||
where: {
|
where: {
|
||||||
kpiUserEvaluationId: In(profileEvaluationIds.map((x: any) => x.id)),
|
kpiUserEvaluationId: In(profileEvaluationIds.map((x: any) => x.id)),
|
||||||
},
|
},
|
||||||
|
|
@ -1040,7 +1092,7 @@ export class ReportController extends Controller {
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
const formattedUserDevelopmentLists = userDevelopmentLists.map(
|
formattedUserDevelopmentLists = userDevelopmentLists.map(
|
||||||
(development: any, index: number) => ({
|
(development: any, index: number) => ({
|
||||||
no: Extension.ToThaiNumber((index + 1).toString()),
|
no: Extension.ToThaiNumber((index + 1).toString()),
|
||||||
...development,
|
...development,
|
||||||
|
|
@ -1053,32 +1105,33 @@ export class ReportController extends Controller {
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
const fullNameParts = [
|
fullNameParts = [
|
||||||
userInfo[0]?.child4,
|
userInfo[0]?.child4,
|
||||||
userInfo[0]?.child3,
|
userInfo[0]?.child3,
|
||||||
userInfo[0]?.child2,
|
userInfo[0]?.child2,
|
||||||
userInfo[0]?.child1,
|
userInfo[0]?.child1,
|
||||||
userInfo[0]?.org,
|
userInfo[0]?.org,
|
||||||
];
|
];
|
||||||
const affiliation = fullNameParts
|
affiliation = fullNameParts
|
||||||
.filter((part) => part !== undefined && part !== null)
|
.filter((part:any) => part !== undefined && part !== null)
|
||||||
.join("/");
|
.join("/");
|
||||||
formattedData = {
|
|
||||||
fullName: userInfo
|
|
||||||
? userInfo[0]?.prefix + userInfo[0]?.firstName + " " + userInfo[0]?.lastName
|
|
||||||
: null,
|
|
||||||
affiliation: affiliation ?? null,
|
|
||||||
durationKPI: data?.durationKPI ?? null,
|
|
||||||
position: userInfo ? userInfo[0]?.position : null,
|
|
||||||
posType: userInfo ? userInfo[0]?.posTypeName : null,
|
|
||||||
posLevel: userInfo ? userInfo[0]?.posLevelName : null,
|
|
||||||
period1: Extension.ToThaiNumber(period1),
|
|
||||||
period2: Extension.ToThaiNumber(period2),
|
|
||||||
developments:
|
|
||||||
formattedUserDevelopmentLists.length > 0 ? formattedUserDevelopmentLists : [{}],
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
formattedData = {
|
||||||
|
year: period_ ? Extension.ToThaiNumber((period_.year+543).toString()) : "-",
|
||||||
|
fullName: userInfo
|
||||||
|
? userInfo[0]?.prefix + userInfo[0]?.firstName + " " + userInfo[0]?.lastName
|
||||||
|
: "-",
|
||||||
|
affiliation: affiliation ?? "-",
|
||||||
|
durationKPI: period_ ? period_.durationKPI : "-",
|
||||||
|
position: userInfo ? userInfo[0]?.position : "-",
|
||||||
|
posType: userInfo ? userInfo[0]?.posTypeName : "-",
|
||||||
|
posLevel: userInfo ? userInfo[0]?.posLevelName : "-",
|
||||||
|
period1: period1 ? Extension.ToThaiNumber(period1) : "-",
|
||||||
|
period2: period2 ? Extension.ToThaiNumber(period2) : "-",
|
||||||
|
developments:
|
||||||
|
formattedUserDevelopmentLists ? formattedUserDevelopmentLists : [{}],
|
||||||
|
};
|
||||||
}
|
}
|
||||||
if (requestBody.type == "KPI9") {
|
if (requestBody.type == "KPI9") {
|
||||||
templateName = "KPI9";
|
templateName = "KPI9";
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue