This commit is contained in:
AdisakKanthawilang 2024-12-16 13:05:14 +07:00
parent 1e64f973f1
commit ac263f25eb

View file

@ -98,12 +98,12 @@ export class ReportController extends Controller {
const latestEducation = x.current_holder.profileEducations.sort((a:any, b:any) => b.endDate - a.startDate)[0]; const latestEducation = x.current_holder.profileEducations.sort((a:any, b:any) => b.endDate - a.startDate)[0];
return { return {
name: x.current_holder.firstName + " " + x.current_holder.lastName, name: x.current_holder.firstName + " " + x.current_holder.lastName,
affiliation: x.orgRoot.orgRootName, affiliation: x.orgRoot.orgRootName??"-",
gender: x.current_holder.gender, gender: x.current_holder.gender??"-",
positionName: x.positions[0]?x.positions[0].positionName:"-", positionName: x.positions[0]?x.positions[0].positionName:"-",
status: x.current_holder.relationship, status: x.current_holder.relationship??"-",
posType: x.current_holder.posType.posTypeName, posType: x.current_holder.posType.posTypeName??"-",
posLevel: x.current_holder.posLevel.posLevelName, posLevel: x.current_holder.posLevel.posLevelName??"-",
degree: latestEducation ? latestEducation.educationLevel : "-", degree: latestEducation ? latestEducation.educationLevel : "-",
posExecutive: x.positions[0].posExecutive?x.positions[0].posExecutive.posExecutiveName:"-", posExecutive: x.positions[0].posExecutive?x.positions[0].posExecutive.posExecutiveName:"-",
currentPreiodPos: "-", currentPreiodPos: "-",
@ -115,14 +115,14 @@ export class ReportController extends Controller {
const key = `${item.posType} - ${item.affiliation} - ${item.gender} - ${item.degree || 'ไม่พบข้อมูล'} - ${item.status || 'ไม่พบข้อมูล'} - ${item.positionName} - ${item.posLevel} - ${item.posExecutive || 'ไม่พบข้อมูล'} `; const key = `${item.posType} - ${item.affiliation} - ${item.gender} - ${item.degree || 'ไม่พบข้อมูล'} - ${item.status || 'ไม่พบข้อมูล'} - ${item.positionName} - ${item.posLevel} - ${item.posExecutive || 'ไม่พบข้อมูล'} `;
if (!acc[key]) { if (!acc[key]) {
acc[key] = { acc[key] = {
posType: item.posType, posType: item.posType && item.posType != "" ? item.posType: "-",
affiliation: item.affiliation, affiliation: item.affiliation && item.affiliation != "" ? item.affiliation: "-",
gender: item.gender, gender: item.gender && item.gender != "" ? item.gender: "-",
degree: item.degree, degree: item.degree && item.degree != "" ? item.degree: "-",
status: item.status, status: item.status && item.status != "" ? item.status: "-",
positionName: item.positionName, positionName: item.positionName && item.positionName != "" ? item.positionName: "-",
posLevel: item.posLevel, posLevel: item.posLevel && item.posLevel != "" ? item.posLevel: "-",
posExecutive: item.posExecutive, posExecutive: item.posExecutive && item.posExecutive != "" ? item.posExecutive: "-",
currentPreiodPos: "-", currentPreiodPos: "-",
levelPeriodPos: "-", levelPeriodPos: "-",
count: 0, count: 0,
@ -133,10 +133,17 @@ export class ReportController extends Controller {
return acc; return acc;
}, {}); }, {});
const result = Object.values(groupedData).map((item: any) => ({
...item ,
count: item.count
}));
return new HttpSuccess({ return new HttpSuccess({
template: "registry-officer", template: "registry-officer",
reportName: "xlsx-report", reportName: "xlsx-report",
data: groupedData, data: {
list: result
},
}); });
} }
/** /**
@ -198,12 +205,12 @@ export class ReportController extends Controller {
const latestEducation = x.current_holder.profileEducations.sort((a:any, b:any) => b.endDate - a.startDate)[0]; const latestEducation = x.current_holder.profileEducations.sort((a:any, b:any) => b.endDate - a.startDate)[0];
return { return {
name: x.current_holder.firstName + " " + x.current_holder.lastName, name: x.current_holder.firstName + " " + x.current_holder.lastName,
affiliation: x.orgRoot.orgRootName, affiliation: x.orgRoot.orgRootName??"-",
gender: x.current_holder.gender, gender: x.current_holder.gender??"-",
positionName: x.positions[0]?x.positions[0].positionName: "-", positionName: x.positions[0]?x.positions[0].positionName: "-",
status: x.current_holder.relationship, status: x.current_holder.relationship??"-",
posType: x.current_holder.posType.posTypeName, posType: x.current_holder.posType.posTypeName??"-",
posLevel: x.current_holder.posLevel.posLevelName, posLevel: x.current_holder.posLevel.posLevelName??"-",
degree: latestEducation ? latestEducation.educationLevel : "-", degree: latestEducation ? latestEducation.educationLevel : "-",
period: "-", period: "-",
}; };
@ -214,12 +221,12 @@ export class ReportController extends Controller {
`; `;
if (!acc[key]) { if (!acc[key]) {
acc[key] = { acc[key] = {
affiliation: item.affiliation, affiliation: item.affiliation && item.affiliation != ""?item.affiliation:"-",
gender: item.gender, gender: item.gender && item.gender != ""?item.gender:"-",
degree: item.degree, degree: item.degree && item.degree != ""?item.degree:"-",
status: item.status, status: item.status && item.status != ""?item.status:"-",
posType: item.posType, posType: item.posType && item.posType != ""?item.posType:"-",
positionName: item.positionName, positionName: item.positionName && item.positionName != ""?item.positionName:"-",
posLevel: item.posLevel, posLevel: item.posLevel,
period: "-", period: "-",
count: 0, count: 0,
@ -230,10 +237,17 @@ export class ReportController extends Controller {
return acc; return acc;
}, {}); }, {});
const result = Object.values(groupedData).map((item: any) => ({
...item ,
count: item.count
}));
return new HttpSuccess({ return new HttpSuccess({
template: "registry-emp", template: "registry-emp",
reportName: "xlsx-report", reportName: "xlsx-report",
data: groupedData, data: {
list: result
},
}); });
} }