fixing bug

This commit is contained in:
Warunee Tamkoo 2025-03-05 17:48:31 +07:00
parent 9fa83891f2
commit 3c0d83631f

View file

@ -39,7 +39,9 @@ export class ProfileSalaryController extends Controller {
@Get("XXX") @Get("XXX")
public async cronjobTenurePositionOfficer() { public async cronjobTenurePositionOfficer() {
let data: any = []; let data: any = [];
const profile = await this.profileRepo.find({where:{id: "09e89026-c420-4136-bd9e-7e408f530b69"}}) const profile = await this.profileRepo.find({
where: { id: "09e89026-c420-4136-bd9e-7e408f530b69" },
});
await Promise.all( await Promise.all(
profile.map(async (x) => { profile.map(async (x) => {
const sql_mode = await AppDataSource.query( const sql_mode = await AppDataSource.query(
@ -49,11 +51,10 @@ export class ProfileSalaryController extends Controller {
const _position = position.length > 0 ? position[0] : []; const _position = position.length > 0 ? position[0] : [];
const mapPosition = const mapPosition =
_position.length > 1 _position.length > 1
? _position.slice(1) ? _position.slice(1).map((curr: any, index: number) => ({
.map((curr: any, index: number) => ({
days_diff: curr.days_diff, days_diff: curr.days_diff,
positionName: _position[index]?.positionName, positionName: _position[index]?.positionName,
})) }))
: []; : [];
const calDayDiff = mapPosition const calDayDiff = mapPosition
.filter((curr: any) => curr.positionName == x.position) .filter((curr: any) => curr.positionName == x.position)
@ -62,9 +63,9 @@ export class ProfileSalaryController extends Controller {
acc.days_diff += Number(curr.days_diff) || 0; acc.days_diff += Number(curr.days_diff) || 0;
return acc; return acc;
}, },
{ days_diff: 0} { days_diff: 0 },
); );
console.log("==========> ", calDayDiff) console.log("==========> ", calDayDiff);
const _mapData = { const _mapData = {
profileId: x.id, profileId: x.id,
positionName: x.position, positionName: x.position,
@ -72,9 +73,9 @@ export class ProfileSalaryController extends Controller {
Years: null, Years: null,
Months: null, Months: null,
Days: null, Days: null,
} };
data.push(_mapData); data.push(_mapData);
}) }),
// await this.positionOfficerRepo.save(data); // await this.positionOfficerRepo.save(data);
); );
@ -216,12 +217,13 @@ export class ProfileSalaryController extends Controller {
// year: curr.Years ? Math.floor(Number(curr.Years)) : 0, // year: curr.Years ? Math.floor(Number(curr.Years)) : 0,
// month: curr.Months ? Math.floor(Number(curr.Months)) : 0, // month: curr.Months ? Math.floor(Number(curr.Months)) : 0,
// day: curr.Days ? Math.floor(Number(curr.Days)) : 0, // day: curr.Days ? Math.floor(Number(curr.Days)) : 0,
name: !_posLevel[index]?.positionType name:
? `ระดับ ${_posLevel[index]?.positionCee.trim()}` !_posLevel[index]?.positionType && _posLevel[index]?.positionCee
: _posLevel[index]?.positionType == "บริหาร" || ? `ระดับ ${_posLevel[index]?.positionCee.trim()}`
_posLevel[index]?.positionType == "อำนวยการ" : _posLevel[index]?.positionType == "บริหาร" ||
? `${_posLevel[index]?.positionType}${_posLevel[index]?.positionLevel}` _posLevel[index]?.positionType == "อำนวยการ"
: _posLevel[index]?.positionLevel, ? `${_posLevel[index]?.positionType}${_posLevel[index]?.positionLevel}`
: _posLevel[index]?.positionLevel,
})) }))
: []; : [];