report
This commit is contained in:
parent
13f6f80114
commit
db434764fa
1 changed files with 64 additions and 0 deletions
|
|
@ -822,6 +822,70 @@ export class ReportController extends Controller {
|
|||
templateName = "KPI8";
|
||||
reportName = "KPI8";
|
||||
//use_filter
|
||||
if (requestBody.profileId) {
|
||||
const profileEvaluationIds = await AppDataSource.getRepository(KpiUserEvaluation)
|
||||
.createQueryBuilder("kpiUserEvaluation")
|
||||
.leftJoinAndSelect("kpiUserEvaluation.kpiPeriod", "kpiPeriod")
|
||||
.where("kpiUserEvaluation.profileId = :profileId", { profileId: requestBody.profileId })
|
||||
.andWhere("kpiUserEvaluation.kpiPeriodId = :kpiPeriodId", {
|
||||
kpiPeriodId: requestBody.periodId,
|
||||
})
|
||||
.groupBy("kpiUserEvaluation.kpiPeriodId")
|
||||
.select("MIN(kpiUserEvaluation.id) as id")
|
||||
.getRawMany();
|
||||
const userInfo = await this.kpiUserEvaluationRepository.find({
|
||||
where: {
|
||||
id: In(profileEvaluationIds.map((x: any) => x.id)),
|
||||
},
|
||||
});
|
||||
const userDevelopmentLists = await this.kpiUserDevelopmentRepository.find({
|
||||
where: {
|
||||
kpiUserEvaluationId: In(profileEvaluationIds.map((x: any) => x.id)),
|
||||
},
|
||||
select: [
|
||||
"id",
|
||||
"name",
|
||||
"target",
|
||||
"summary",
|
||||
"point",
|
||||
"achievement0",
|
||||
"achievement5",
|
||||
"achievement10",
|
||||
"isDevelopment10",
|
||||
"isDevelopment20",
|
||||
"isDevelopment70",
|
||||
],
|
||||
});
|
||||
|
||||
const formattedUserDevelopmentLists = userDevelopmentLists.map(
|
||||
(development: any, index: number) => ({
|
||||
no: Extension.ToThaiNumber((index + 1).toString()),
|
||||
...development,
|
||||
summary: development.summary
|
||||
? Extension.ToThaiNumber(development.summary.toString())
|
||||
: null,
|
||||
point: development.point ? Extension.ToThaiNumber(development.point.toString()) : null,
|
||||
}),
|
||||
);
|
||||
|
||||
const fullNameParts = [userInfo[0].child4, userInfo[0].child3, userInfo[0].child2, userInfo[0].child1, userInfo[0].org];
|
||||
const affiliation = fullNameParts
|
||||
.filter((part) => part !== undefined && part !== null)
|
||||
.join("/");
|
||||
formattedData = {
|
||||
fullName: userInfo
|
||||
? userInfo[0].prefix + userInfo[0].firstName + " " + userInfo[0].lastName
|
||||
: null,
|
||||
affiliation: affiliation,
|
||||
durationKPI: data?.durationKPI,
|
||||
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,
|
||||
} || [{}];
|
||||
}
|
||||
}
|
||||
if (requestBody.type == "KPI9") {
|
||||
templateName = "KPI9";
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue