job
This commit is contained in:
parent
990d80e64d
commit
e31e98b316
2 changed files with 16 additions and 3 deletions
15
src/app.ts
15
src/app.ts
|
|
@ -12,7 +12,7 @@ import { RegisterRoutes } from "./routes";
|
||||||
import { OrganizationController } from "./controllers/OrganizationController";
|
import { OrganizationController } from "./controllers/OrganizationController";
|
||||||
import logMiddleware from "./middlewares/logs";
|
import logMiddleware from "./middlewares/logs";
|
||||||
import { CommandController } from "./controllers/CommandController";
|
import { CommandController } from "./controllers/CommandController";
|
||||||
|
import { ProfileSalaryController } from "./controllers/ProfileSalaryController";
|
||||||
import { WebSocketServer } from "ws";
|
import { WebSocketServer } from "ws";
|
||||||
import http from "http";
|
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, APP_HOST, () => console.log(`Listening on: http://localhost:${APP_PORT}`));
|
||||||
// app.listen(
|
// app.listen(
|
||||||
// APP_PORT,
|
// APP_PORT,
|
||||||
|
|
|
||||||
|
|
@ -86,7 +86,7 @@ export class ProfileSalaryController extends Controller {
|
||||||
await this.positionEmployeeRepo.clear();
|
await this.positionEmployeeRepo.clear();
|
||||||
const profile = await this.profileEmployeeRepo.find();
|
const profile = await this.profileEmployeeRepo.find();
|
||||||
for await (const x of profile) {
|
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 _position = position.length > 0 ? position[0] : [];
|
||||||
const mapPosition =
|
const mapPosition =
|
||||||
_position.length > 1
|
_position.length > 1
|
||||||
|
|
@ -176,7 +176,7 @@ export class ProfileSalaryController extends Controller {
|
||||||
await this.levelEmployeeRepo.clear();
|
await this.levelEmployeeRepo.clear();
|
||||||
const profile = await this.profileEmployeeRepo.find({ relations: ["posLevel"] });
|
const profile = await this.profileEmployeeRepo.find({ relations: ["posLevel"] });
|
||||||
for await (const x of profile) {
|
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 _positionLevel = positionLevel.length > 0 ? positionLevel[0] : [];
|
||||||
const mapPositionLevel =
|
const mapPositionLevel =
|
||||||
_positionLevel.length > 1
|
_positionLevel.length > 1
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue