fix report kpi
This commit is contained in:
parent
87524118df
commit
a9958c7e71
1 changed files with 31 additions and 40 deletions
|
|
@ -36,7 +36,8 @@ export class ReportController extends Controller {
|
|||
|
||||
//KPI1, KPI2, KPI3, KPI7, KPI9
|
||||
let data: any;
|
||||
|
||||
let durationKpi_APR: string ="";
|
||||
let durationKpi_OCT: string ="";
|
||||
let dataKpiUserEvaluations: any;
|
||||
let period1: any;
|
||||
let period2: any;
|
||||
|
|
@ -45,6 +46,8 @@ export class ReportController extends Controller {
|
|||
data = await this.kpiPeriodRepository.findOne({
|
||||
where: { id: requestBody.periodId },
|
||||
});
|
||||
durationKpi_APR = data && data.durationKPI == "APR" ? `🗹` : `☐`
|
||||
durationKpi_OCT = data && data.durationKPI == "OCT" ? `🗹` : `☐`
|
||||
dataKpiUserEvaluations = await this.kpiUserEvaluationRepository.find({
|
||||
where: {
|
||||
kpiPeriodId: requestBody.periodId,
|
||||
|
|
@ -66,29 +69,28 @@ export class ReportController extends Controller {
|
|||
};
|
||||
|
||||
if (data.durationKPI == "APR") {
|
||||
period1 = `${Extension.ToThaiFullDate2(data.startDate)} ถึง ${Extension.ToThaiFullDate2(data.endDate)}`;
|
||||
period1 = `${durationKpi_APR} รอบที่ ๑ ตั้งแต่ ${Extension.ToThaiFullDate2(data.startDate)} ถึง ${Extension.ToThaiFullDate2(data.endDate)}`;
|
||||
let _period2 = await this.kpiPeriodRepository.findOne({
|
||||
where: {
|
||||
year: data.year,
|
||||
durationKPI: "OCT",
|
||||
// isActive: true,
|
||||
},
|
||||
});
|
||||
period2 = _period2
|
||||
? `${Extension.ToThaiFullDate2(_period2?.startDate)} ถึง ${Extension.ToThaiFullDate2(_period2?.endDate)}`
|
||||
: "";
|
||||
} else if (data.durationKPI == "OCT") {
|
||||
period2 = `${Extension.ToThaiFullDate2(data.startDate)} ถึง ${Extension.ToThaiFullDate2(data.endDate)}`;
|
||||
? `${durationKpi_OCT} รอบที่ ๒ ตั้งแต่ ${Extension.ToThaiFullDate2(_period2?.startDate)} ถึง ${Extension.ToThaiFullDate2(_period2?.endDate)}`
|
||||
: `${durationKpi_OCT} รอบที่ ๒ ตั้งแต่ ๑ เมษายน ${Extension.ToThaiYear(data.year)} ถึง ๓๑ กันยายน ${Extension.ToThaiYear(data.year)}`;
|
||||
}
|
||||
else if (data.durationKPI == "OCT") {
|
||||
period2 = `${durationKpi_OCT} รอบที่ ๒ ตั้งแต่ ${Extension.ToThaiFullDate2(data.startDate)} ถึง ${Extension.ToThaiFullDate2(data.endDate)}`;
|
||||
let _period1 = await this.kpiPeriodRepository.findOne({
|
||||
where: {
|
||||
year: data.year,
|
||||
durationKPI: "APR",
|
||||
// isActive: true,
|
||||
},
|
||||
});
|
||||
period1 = _period1
|
||||
? `${Extension.ToThaiFullDate2(_period1?.startDate)} ถึง ${Extension.ToThaiFullDate2(_period1?.endDate)}`
|
||||
: "";
|
||||
? `${durationKpi_APR} รอบที่ ๑ ตั้งแต่ ${Extension.ToThaiFullDate2(_period1?.startDate)} ถึง ${Extension.ToThaiFullDate2(_period1?.endDate)}`
|
||||
: `${durationKpi_APR} รอบที่ ๑ ตั้งแต่ ๑ ตุลาคม ${Extension.ToThaiYear(data.year-1)} ถึง ๓๑ มีนาคม ${Extension.ToThaiYear(data.year)}`;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -576,21 +578,10 @@ export class ReportController extends Controller {
|
|||
.andWhere("kpiUserEvaluation.evaluationStatus = :evaluationStatus", {
|
||||
evaluationStatus: "KP7",
|
||||
})
|
||||
// .where("kpiPeriod.year = :year", { year: yearNow })
|
||||
.groupBy("kpiUserEvaluation.kpiPeriodId")
|
||||
.select("MIN(kpiUserEvaluation.id) as id")
|
||||
.getRawMany();
|
||||
|
||||
// const profileEvaluationNextYearIds = await AppDataSource.getRepository(KpiUserEvaluation)
|
||||
// .createQueryBuilder("kpiUserEvaluation")
|
||||
// .leftJoinAndSelect("kpiUserEvaluation.kpiPeriod", "kpiPeriod")
|
||||
// .where("kpiUserEvaluation.profileId = :profileId", { profileId: requestBody.profileId })
|
||||
// .where("kpiPeriod.year = :year", { year: yearNow + 1 })
|
||||
// .groupBy("kpiUserEvaluation.kpiPeriodId")
|
||||
// .select("MIN(kpiUserEvaluation.id) as id")
|
||||
// .getRawMany();
|
||||
// const profileEvaluationCombianIds = profileEvaluationNowYearIds.concat(profileEvaluationNextYearIds);
|
||||
|
||||
//ชั่วคราว
|
||||
const profileEvaluations = await this.kpiUserEvaluationRepository.find({
|
||||
relations: ["kpiPeriod"],
|
||||
|
|
@ -627,46 +618,47 @@ export class ReportController extends Controller {
|
|||
data.summaryPointAPR1 =
|
||||
evaluation.summaryPoint >= 90
|
||||
? Extension.ToThaiNumber(evaluation.summaryPoint.toString())
|
||||
: null;
|
||||
: "-";
|
||||
data.summaryPointAPR2 =
|
||||
evaluation.summaryPoint >= 80 && evaluation.summaryPoint < 90
|
||||
? Extension.ToThaiNumber(evaluation.summaryPoint.toString())
|
||||
: null;
|
||||
: "-";
|
||||
data.summaryPointAPR3 =
|
||||
evaluation.summaryPoint >= 70 && evaluation.summaryPoint < 80
|
||||
? Extension.ToThaiNumber(evaluation.summaryPoint.toString())
|
||||
: null;
|
||||
: "-";
|
||||
data.summaryPointAPR4 =
|
||||
evaluation.summaryPoint >= 60 && evaluation.summaryPoint < 70
|
||||
? Extension.ToThaiNumber(evaluation.summaryPoint.toString())
|
||||
: null;
|
||||
: "-";
|
||||
data.summaryPointAPR5 =
|
||||
evaluation.summaryPoint < 60
|
||||
? Extension.ToThaiNumber(evaluation.summaryPoint.toString())
|
||||
: null;
|
||||
data.periodAPR = evaluation.kpiPeriod.durationKPI;
|
||||
} else if (evaluation.kpiPeriod.durationKPI === "OCT") {
|
||||
: "-";
|
||||
data.periodAPR = evaluation.kpiPeriod.durationKPI ?? "-";
|
||||
}
|
||||
else if (evaluation.kpiPeriod.durationKPI === "OCT") {
|
||||
data.summaryPointOCT1 =
|
||||
evaluation.summaryPoint >= 90
|
||||
? Extension.ToThaiNumber(evaluation.summaryPoint.toString())
|
||||
: null;
|
||||
: "-";
|
||||
data.summaryPointOCT2 =
|
||||
evaluation.summaryPoint >= 80 && evaluation.summaryPoint < 90
|
||||
? Extension.ToThaiNumber(evaluation.summaryPoint.toString())
|
||||
: null;
|
||||
: "-";
|
||||
data.summaryPointOCT3 =
|
||||
evaluation.summaryPoint >= 70 && evaluation.summaryPoint < 80
|
||||
? Extension.ToThaiNumber(evaluation.summaryPoint.toString())
|
||||
: null;
|
||||
: "-";
|
||||
data.summaryPointOCT4 =
|
||||
evaluation.summaryPoint >= 60 && evaluation.summaryPoint < 70
|
||||
? Extension.ToThaiNumber(evaluation.summaryPoint.toString())
|
||||
: null;
|
||||
: "-";
|
||||
data.summaryPointOCT5 =
|
||||
evaluation.summaryPoint < 60
|
||||
? Extension.ToThaiNumber(evaluation.summaryPoint.toString())
|
||||
: null;
|
||||
data.periodOCT = evaluation.kpiPeriod.durationKPI ?? null;
|
||||
: "-";
|
||||
data.periodOCT = evaluation.kpiPeriod.durationKPI ?? "-";
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -750,7 +742,7 @@ export class ReportController extends Controller {
|
|||
.groupBy("kpiUserEvaluation.kpiPeriodId")
|
||||
.select("MIN(kpiUserEvaluation.id) as id")
|
||||
.getRawMany();
|
||||
// if (profileEvaluationIds.length > 0) {
|
||||
|
||||
const profileEvaluation = await this.kpiUserEvaluationRepository.find({
|
||||
relations: ["kpiPeriod"],
|
||||
where: { id: In(profileEvaluationIds.map((evaluation) => evaluation.id)) },
|
||||
|
|
@ -759,7 +751,7 @@ export class ReportController extends Controller {
|
|||
const combinedData: KPIData = profileEvaluation.reduce(
|
||||
(acc: KPIData, x) => {
|
||||
const fullNameParts = [x.child4, x.child3, x.child2, x.child1, x.org];
|
||||
|
||||
|
||||
const affiliation = fullNameParts
|
||||
.filter((part) => part !== undefined && part !== null)
|
||||
.join("/");
|
||||
|
|
@ -769,7 +761,7 @@ export class ReportController extends Controller {
|
|||
acc.position = x.position;
|
||||
acc.posType = x.posTypeName;
|
||||
acc.posLevel = x.posLevelName;
|
||||
acc.affiliation = affiliation;
|
||||
acc.affiliation = affiliation ?? "-";
|
||||
} else {
|
||||
acc.fullName = "-";
|
||||
acc.position = "-";
|
||||
|
|
@ -1048,7 +1040,6 @@ export class ReportController extends Controller {
|
|||
year4: Extension.ToThaiNumber(Extension.ToThaiYear(yearNow - 1).toString()),
|
||||
year5: Extension.ToThaiNumber(Extension.ToThaiYear(yearNow).toString()),
|
||||
};
|
||||
// }
|
||||
}
|
||||
}
|
||||
if (requestBody.type == "KPI6") {
|
||||
|
|
@ -1478,9 +1469,9 @@ export class ReportController extends Controller {
|
|||
: null,
|
||||
pointText: (development.point = 0
|
||||
? development.achievement0
|
||||
: (development.point = 5
|
||||
: (development.point == 5
|
||||
? development.achievement5
|
||||
: (development.point = 10 ? development.achievement10 : null))),
|
||||
: (development.point == 10 ? development.achievement10 : null))),
|
||||
isDevelopmentText: [
|
||||
development.isDevelopment10,
|
||||
development.isDevelopment20,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue