Merge branch 'develop' into adiDev
This commit is contained in:
commit
f0cdce966a
2 changed files with 51 additions and 21 deletions
|
|
@ -22,6 +22,10 @@ import { Profile } from "../entities/Profile";
|
|||
import { In, LessThan, MoreThan } from "typeorm";
|
||||
import permission from "../interfaces/permission";
|
||||
import { setLogDataDiff } from "../interfaces/utils";
|
||||
import { TenurePositionOfficer } from "../entities/TenurePositionOfficer";
|
||||
import { TenureLevelOfficer } from "../entities/TenureLevelOfficer";
|
||||
import { TenurePositionEmployee } from "../entities/TenurePositionEmployee";
|
||||
import { TenureLevelEmployee } from "../entities/TenureLevelEmployee";
|
||||
@Route("api/v1/org/profile/salary")
|
||||
@Tags("ProfileSalary")
|
||||
@Security("bearerAuth")
|
||||
|
|
@ -29,7 +33,54 @@ export class ProfileSalaryController extends Controller {
|
|||
private profileRepo = AppDataSource.getRepository(Profile);
|
||||
private salaryRepo = AppDataSource.getRepository(ProfileSalary);
|
||||
private salaryHistoryRepo = AppDataSource.getRepository(ProfileSalaryHistory);
|
||||
private positionOfficerRepo = AppDataSource.getRepository(TenurePositionOfficer);
|
||||
private levelOfficerRepo = AppDataSource.getRepository(TenureLevelOfficer);
|
||||
// async cronjobTenurePositionOfficer() {
|
||||
@Get("XXX")
|
||||
public async cronjobTenurePositionOfficer() {
|
||||
let data: any = [];
|
||||
const profile = await this.profileRepo.find({where:{id: "09e89026-c420-4136-bd9e-7e408f530b69"}})
|
||||
await Promise.all(
|
||||
profile.map(async (x) => {
|
||||
const sql_mode = await AppDataSource.query(
|
||||
"SET SESSION sql_mode=(SELECT REPLACE(@@sql_mode,'ONLY_FULL_GROUP_BY',''));",
|
||||
);
|
||||
const position = await AppDataSource.query("CALL GetProfileSalaryPosition(?)", [x.id]);
|
||||
const _position = position.length > 0 ? position[0] : [];
|
||||
const mapPosition =
|
||||
_position.length > 1
|
||||
? _position.slice(1)
|
||||
.map((curr: any, index: number) => ({
|
||||
days_diff: curr.days_diff,
|
||||
positionName: _position[index]?.positionName,
|
||||
}))
|
||||
: [];
|
||||
const calDayDiff = mapPosition
|
||||
.filter((curr: any) => curr.positionName == x.position)
|
||||
.reduce(
|
||||
(acc: any, curr: any) => {
|
||||
acc.days_diff += Number(curr.days_diff) || 0;
|
||||
return acc;
|
||||
},
|
||||
{ days_diff: 0}
|
||||
);
|
||||
console.log("==========> ", calDayDiff)
|
||||
const _mapData = {
|
||||
profileId: x.id,
|
||||
positionName: x.position,
|
||||
days_diff: null,
|
||||
Years: null,
|
||||
Months: null,
|
||||
Days: null,
|
||||
}
|
||||
data.push(_mapData);
|
||||
})
|
||||
|
||||
// await this.positionOfficerRepo.save(data);
|
||||
);
|
||||
|
||||
return new HttpSuccess();
|
||||
}
|
||||
@Get("user")
|
||||
public async getSalaryUser(@Request() request: { user: Record<string, any> }) {
|
||||
const profile = await this.profileRepo.findOneBy({ keycloak: request.user.sub });
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue