update report

This commit is contained in:
Bright 2025-03-04 18:21:28 +07:00
parent 3b9002f505
commit 74644cc70c

View file

@ -334,7 +334,28 @@ export class ReportController extends Controller {
.orderBy(`registryOfficer.${sortBy}`, sort) .orderBy(`registryOfficer.${sortBy}`, sort)
.getManyAndCount(); .getManyAndCount();
const mapData = lists.map((x) => ({ const mapData = await Promise.all(lists.map(async(x) => {
const position = await AppDataSource.query("CALL GetProfileSalaryPosition(?)", [x.profileId])
const _position = position.length > 0 ? position[0] : [];
const lastPosition = _position.length > 0 ? _position[_position.length - 1] : null; // last row
const mapPosition = lastPosition
? [{
Years: lastPosition.Years ? Math.floor(Number(lastPosition.Years)) : 0,
Months: lastPosition.Months ? Math.floor(Number(lastPosition.Months)) : 0,
Daysday: lastPosition.Days ? Math.floor(Number(lastPosition.Days)) : 0,
}]
: [];
const posLevel = await AppDataSource.query("CALL GetProfileSalaryLevel(?)", [x.profileId])
const _posLevel = posLevel.length > 0 ? posLevel[0] : [];
const lastPosLevel= _posLevel.length > 0 ? _posLevel[_posLevel.length - 1] : null;
const mapPosLevel = lastPosLevel
? [{
Years: lastPosLevel.Years ? Math.floor(Number(lastPosLevel.Years)) : 0,
Months: lastPosLevel.Months ? Math.floor(Number(lastPosLevel.Months)) : 0,
Daysday: lastPosLevel.Days ? Math.floor(Number(lastPosLevel.Days)) : 0,
}]
: [];
return {
profileId: x.profileId, profileId: x.profileId,
citizenId: x.citizenId, citizenId: x.citizenId,
prefix: x.prefix, prefix: x.prefix,
@ -371,21 +392,24 @@ export class ReportController extends Controller {
age: x.age, age: x.age,
currentPosition: null, currentPosition: null,
lengthPosition: null, lengthPosition: null,
positionDate: { // positionDate: {
Years: x.Years, // Years: x.Years,
Months: x.Months, // Months: x.Months,
Days: x.Days, // Days: x.Days,
}, // },
posExcutiveDate: { // posExcutiveDate: {
Years: x.posExecutiveYears, // Years: x.posExecutiveYears,
Months: x.posExecutiveMonths, // Months: x.posExecutiveMonths,
Days: x.posExecutiveDays, // Days: x.posExecutiveDays,
}, // },
posLevelDate: { // posLevelDate: {
Years: x.levelYears, // Years: x.levelYears,
Months: x.levelMonths, // Months: x.levelMonths,
Days: x.levelDays, // Days: x.levelDays,
}, // },
positionDate: mapPosition,
posLevelDate: mapPosLevel
}
})); }));
return new HttpSuccess({ return new HttpSuccess({
data: mapData, data: mapData,
@ -654,7 +678,29 @@ export class ReportController extends Controller {
) )
.orderBy(`registryEmployee.${sortBy}`, sort) .orderBy(`registryEmployee.${sortBy}`, sort)
.getManyAndCount(); .getManyAndCount();
const mapData = lists.map((x) => ({
const mapData = await Promise.all(lists.map(async(x) => {
const position = await AppDataSource.query("CALL GetProfileEmployeeSalaryPosition(?)", [x.profileEmployeeId])
const _position = position.length > 0 ? position[0] : [];
const lastPosition = _position.length > 0 ? _position[_position.length - 1] : null;
const mapPosition = lastPosition
? [{
Years: lastPosition.Years ? Math.floor(Number(lastPosition.Years)) : 0,
Months: lastPosition.Months ? Math.floor(Number(lastPosition.Months)) : 0,
Daysday: lastPosition.Days ? Math.floor(Number(lastPosition.Days)) : 0,
}]
: [];
const posLevel = await AppDataSource.query("CALL GetProfileEmployeeSalaryLevel(?)", [x.profileEmployeeId])
const _posLevel = posLevel.length > 0 ? posLevel[0] : [];
const lastPosLevel= _posLevel.length > 0 ? _posLevel[_posLevel.length - 1] : null;
const mapPosLevel = lastPosLevel
? [{
Years: lastPosLevel.Years ? Math.floor(Number(lastPosLevel.Years)) : 0,
Months: lastPosLevel.Months ? Math.floor(Number(lastPosLevel.Months)) : 0,
Daysday: lastPosLevel.Days ? Math.floor(Number(lastPosLevel.Days)) : 0,
}]
: [];
return {
profileId: x.profileEmployeeId, profileId: x.profileEmployeeId,
citizenId: x.citizenId, citizenId: x.citizenId,
prefix: x.prefix, prefix: x.prefix,
@ -690,6 +736,9 @@ export class ReportController extends Controller {
age: x.age, age: x.age,
currentPosition: null, currentPosition: null,
lengthPosition: null, lengthPosition: null,
positionDate: mapPosition,
posLevelDate: mapPosLevel
}
})); }));
return new HttpSuccess({ return new HttpSuccess({
data: mapData, data: mapData,