Merge branch 'adiDev' into develop
This commit is contained in:
commit
d4f440295c
2 changed files with 64 additions and 38 deletions
|
|
@ -15,6 +15,7 @@ import HttpStatus from "../interfaces/http-status";
|
|||
import { ProfileAssessment } from "../entities/ProfileAssessment";
|
||||
import { log } from "console";
|
||||
import { format } from "path";
|
||||
import { viewProfileEvaluation } from "../entities/view/viewProfileEvaluation";
|
||||
|
||||
@Route("api/v1/org/unauthorize")
|
||||
@Tags("OrganizationUnauthorize")
|
||||
|
|
@ -28,6 +29,7 @@ export class OrganizationUnauthorizeController extends Controller {
|
|||
private profileRepo = AppDataSource.getRepository(Profile);
|
||||
private profileEmpRepo = AppDataSource.getRepository(ProfileEmployee);
|
||||
private profileAssessmentRepo = AppDataSource.getRepository(ProfileAssessment);
|
||||
private viewProfileEvaluationRepo = AppDataSource.getRepository(viewProfileEvaluation);
|
||||
|
||||
/**
|
||||
* API รายชื่อราชการที่เลื่อนเงินเดือน (unauthorize)
|
||||
|
|
@ -1172,43 +1174,53 @@ export class OrganizationUnauthorizeController extends Controller {
|
|||
* @summary ผลการประเมิน 5 ปีย้อนหลังนับจากปีปัจจุบัน
|
||||
*
|
||||
*/
|
||||
@Get("calculate-Eva/{profileId}")
|
||||
@Get("calculate-Eva/{node}/{nodeId}")
|
||||
async calculateEva(
|
||||
@Path() profileId: string,
|
||||
@Path() node: string,
|
||||
@Path() nodeId: string,
|
||||
) {
|
||||
|
||||
// const list = await this.viewProfileEvaluation.findOne({
|
||||
// where: {
|
||||
// profileId: profileId,
|
||||
// },
|
||||
// });
|
||||
const lists = await this.viewProfileEvaluationRepo.find({
|
||||
// where:{
|
||||
// profileId: profileId
|
||||
// }
|
||||
})
|
||||
|
||||
const formattedResults: any = {};
|
||||
const year = new Date().getFullYear();
|
||||
const years = [year, year - 1, year - 2, year - 3, year - 4];
|
||||
|
||||
lists.forEach((item: any) => {
|
||||
if (!formattedResults[item.profileId]) {
|
||||
formattedResults[item.profileId] = {
|
||||
profileId: item.profileId,
|
||||
yearAPR1: "-", periodAPR1: "-", resultAPR1: "-",
|
||||
yearOCT1: "-", periodOCT1: "-", resultOCT1: "-",
|
||||
yearAPR2: "-", periodAPR2: "-", resultAPR2: "-",
|
||||
yearOCT2: "-", periodOCT2: "-", resultOCT2: "-",
|
||||
yearAPR3: "-", periodAPR3: "-", resultAPR3: "-",
|
||||
yearOCT3: "-", periodOCT3: "-", resultOCT3: "-",
|
||||
yearAPR4: "-", periodAPR4: "-", resultAPR4: "-",
|
||||
yearOCT4: "-", periodOCT4: "-", resultOCT4: "-",
|
||||
yearAPR5: "-", periodAPR5: "-", resultAPR5: "-",
|
||||
yearOCT5: "-", periodOCT5: "-", resultOCT5: "-"
|
||||
};
|
||||
}
|
||||
|
||||
const yearIndex = years.indexOf(parseInt(item.year));
|
||||
if (yearIndex !== -1) {
|
||||
const yearSuffix = yearIndex + 1;
|
||||
const yearKey = `year${item.period}${yearSuffix}`;
|
||||
const periodKey = `period${item.period}${yearSuffix}`;
|
||||
const resultKey = `result${item.period}${yearSuffix}`;
|
||||
|
||||
formattedResults[item.profileId][yearKey] = item.year;
|
||||
formattedResults[item.profileId][periodKey] = item.period;
|
||||
formattedResults[item.profileId][resultKey] = item.result;
|
||||
}
|
||||
});
|
||||
|
||||
// const formattedData = list.map((item: any) => {
|
||||
// const year = new Date().getFullYear();
|
||||
// const result: any = {};
|
||||
|
||||
// for (let i = 1; i <= 5; i++) {
|
||||
// const currentYear = year - (i - 1);
|
||||
// const periodKey = `periodAPR${i}`;
|
||||
// const resultKey = `resultAPR${i}`;
|
||||
|
||||
// result[`yearAPR${i}`] = item.year === currentYear ? item.year : "-";
|
||||
// result[periodKey] = item.period ? item.period : "-";
|
||||
// result[resultKey] = item.result ? item.result : "-";
|
||||
|
||||
// const octYear = year - (i - 1);
|
||||
// const octPeriodKey = `periodOCT${i}`;
|
||||
// const octResultKey = `resultOCT${i}`;
|
||||
|
||||
// result[`yearOCT${i}`] = item.year === octYear ? item.year : "-";
|
||||
// result[octPeriodKey] = item.period ? item.period : "-";
|
||||
// result[octResultKey] = item.result ? item.result : "-";
|
||||
// }
|
||||
|
||||
// return result;
|
||||
// });
|
||||
|
||||
return new HttpSuccess();
|
||||
return new HttpSuccess(formattedResults);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue