Merge branch 'develop' into adiDev
This commit is contained in:
commit
5f91e11042
2 changed files with 29 additions and 20 deletions
15
src/app.ts
15
src/app.ts
|
|
@ -12,7 +12,7 @@ import { RegisterRoutes } from "./routes";
|
|||
import { OrganizationController } from "./controllers/OrganizationController";
|
||||
import logMiddleware from "./middlewares/logs";
|
||||
import { CommandController } from "./controllers/CommandController";
|
||||
|
||||
import { ProfileSalaryController } from "./controllers/ProfileSalaryController";
|
||||
import { WebSocketServer } from "ws";
|
||||
import http from "http";
|
||||
|
||||
|
|
@ -85,6 +85,19 @@ async function main() {
|
|||
}
|
||||
});
|
||||
|
||||
const cronTime_Tenure = "0 0 * * *";
|
||||
cron.schedule(cronTime_Tenure, async () => {
|
||||
try {
|
||||
const profileSalaryController = new ProfileSalaryController();
|
||||
await profileSalaryController.cronjobTenurePositionOfficer();
|
||||
await profileSalaryController.cronjobTenureLevelOfficer();
|
||||
await profileSalaryController.cronjobTenurePositionEmployee();
|
||||
await profileSalaryController.cronjobTenureLevelEmployee();
|
||||
} catch (error) {
|
||||
console.error("Error executing function from controller:", error);
|
||||
}
|
||||
});
|
||||
|
||||
// app.listen(APP_PORT, APP_HOST, () => console.log(`Listening on: http://localhost:${APP_PORT}`));
|
||||
// app.listen(
|
||||
// APP_PORT,
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ import { ProfileSalaryHistory } from "../entities/ProfileSalaryHistory";
|
|||
import { RequestWithUser } from "../middlewares/user";
|
||||
import { Profile } from "../entities/Profile";
|
||||
import { ProfileEmployee } from "../entities/ProfileEmployee";
|
||||
import { In, IsNull, LessThan, MoreThan } from "typeorm";
|
||||
import { In, IsNull, LessThan, MoreThan, Not } from "typeorm";
|
||||
import permission from "../interfaces/permission";
|
||||
import { setLogDataDiff } from "../interfaces/utils";
|
||||
import { TenurePositionOfficer } from "../entities/TenurePositionOfficer";
|
||||
|
|
@ -43,11 +43,8 @@ export class ProfileSalaryController extends Controller {
|
|||
@Get("TenurePositionOfficer")
|
||||
public async cronjobTenurePositionOfficer() {
|
||||
let data: any = [];
|
||||
const positionOfficer = await this.positionOfficerRepo.find();
|
||||
await this.positionOfficerRepo.remove(positionOfficer);
|
||||
const profile = await this.profileRepo.find({
|
||||
where: { id: "46dec43d-2ed7-4f04-9843-dbade7a156c7" },
|
||||
});
|
||||
await this.positionOfficerRepo.clear();
|
||||
const profile = await this.profileRepo.find();
|
||||
for await (const x of profile) {
|
||||
const position = await AppDataSource.query("CALL GetProfileSalaryPosition(?)", [x.id]);
|
||||
const _position = position.length > 0 ? position[0] : [];
|
||||
|
|
@ -76,10 +73,8 @@ export class ProfileSalaryController extends Controller {
|
|||
Months: ((calDayDiff.days_diff / 30.4375) % 12).toFixed(4),
|
||||
Days: (calDayDiff.days_diff % 30.4375).toFixed(4),
|
||||
};
|
||||
console.log(mapData);
|
||||
return new HttpSuccess(mapData);
|
||||
// data.push(_mapData);
|
||||
// await this.positionOfficerRepo.save(mapData);
|
||||
await this.positionOfficerRepo.save(mapData);
|
||||
}
|
||||
// await this.positionOfficerRepo.save(data);
|
||||
|
||||
|
|
@ -88,11 +83,10 @@ export class ProfileSalaryController extends Controller {
|
|||
@Get("TenurePositionEmployee")
|
||||
public async cronjobTenurePositionEmployee() {
|
||||
let data: any = [];
|
||||
const positionEmployee = await this.positionEmployeeRepo.find();
|
||||
await this.positionEmployeeRepo.remove(positionEmployee);
|
||||
await this.positionEmployeeRepo.clear();
|
||||
const profile = await this.profileEmployeeRepo.find();
|
||||
for await (const x of profile) {
|
||||
const position = await AppDataSource.query("CALL GetProfileSalaryPosition(?)", [x.id]);
|
||||
const position = await AppDataSource.query("CALL GetProfileEmployeeSalaryPosition(?)", [x.id]);
|
||||
const _position = position.length > 0 ? position[0] : [];
|
||||
const mapPosition =
|
||||
_position.length > 1
|
||||
|
|
@ -129,9 +123,8 @@ export class ProfileSalaryController extends Controller {
|
|||
@Get("TenureLevelOfficer")
|
||||
public async cronjobTenureLevelOfficer() {
|
||||
let data: any = [];
|
||||
const positionOfficer = await this.levelOfficerRepo.find();
|
||||
await this.levelOfficerRepo.remove(positionOfficer);
|
||||
const profile = await this.profileRepo.find({ relations: ["posLevel"] });
|
||||
await this.levelOfficerRepo.clear();
|
||||
const profile = await this.profileRepo.find({ relations: ["posLevel", "posType"] });
|
||||
for await (const x of profile) {
|
||||
const positionLevel = await AppDataSource.query("CALL GetProfileSalaryLevel(?)", [x.id]);
|
||||
const _positionLevel = positionLevel.length > 0 ? positionLevel[0] : [];
|
||||
|
|
@ -145,7 +138,11 @@ export class ProfileSalaryController extends Controller {
|
|||
}))
|
||||
: [];
|
||||
const calDayDiff = mapPositionLevel
|
||||
.filter((curr: any) => curr.positionLevel == (x.posLevel?.posLevelName ?? null))
|
||||
.filter(
|
||||
(curr: any) =>
|
||||
curr.positionLevel == (x.posLevel?.posLevelName ?? null) &&
|
||||
curr.positionType == (x.posType?.posTypeName ?? null),
|
||||
)
|
||||
.reduce(
|
||||
(acc: any, curr: any) => {
|
||||
acc.days_diff += Number(curr.days_diff) || 0;
|
||||
|
|
@ -176,11 +173,10 @@ export class ProfileSalaryController extends Controller {
|
|||
@Get("TenureLevelEmployee")
|
||||
public async cronjobTenureLevelEmployee() {
|
||||
let data: any = [];
|
||||
const positionEmployee = await this.levelEmployeeRepo.find();
|
||||
await this.levelEmployeeRepo.remove(positionEmployee);
|
||||
await this.levelEmployeeRepo.clear();
|
||||
const profile = await this.profileEmployeeRepo.find({ relations: ["posLevel"] });
|
||||
for await (const x of profile) {
|
||||
const positionLevel = await AppDataSource.query("CALL GetProfileSalaryLevel(?)", [x.id]);
|
||||
const positionLevel = await AppDataSource.query("CALL GetProfileEmployeeSalaryLevel(?)", [x.id]);
|
||||
const _positionLevel = positionLevel.length > 0 ? positionLevel[0] : [];
|
||||
const mapPositionLevel =
|
||||
_positionLevel.length > 1
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue