Update attendances module

Add services files directory configuration to application.properties
This commit is contained in:
Kheireddine Mehdi
2024-11-18 15:55:30 +01:00
parent 8d8a94b65f
commit cfb149ef0f
3 changed files with 25 additions and 8 deletions

View File

@@ -10,10 +10,12 @@ import org.quartz.JobExecutionException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.quartz.SchedulerException;
import com.axelor.app.AppSettings;
public class FetchAttendanceJob implements Job {
private final Logger log = LoggerFactory.getLogger(FetchCheckInOutJob.class);
private final String pythonScriptDir = AppSettings.get().get("services.dir");
@Override
public void execute(JobExecutionContext context) throws JobExecutionException{
@@ -22,9 +24,14 @@ public class FetchAttendanceJob implements Job {
return;
}
if (pythonScriptDir == null || pythonScriptDir.isEmpty()) {
log.error("Python script path is not configured in AppSettings.");
return;
}
try {
// Define the command to run the Python script with the correct path (V3)
String[] args = {"python", "C:\\Users\\administrator\\Desktop\\Scrape\\main.py"};
String[] args = {"python", pythonScriptDir + "\\Scrape\\main.py"};
// Execute the command
Process p = Runtime.getRuntime().exec(args);

View File

@@ -14,10 +14,12 @@ import org.slf4j.LoggerFactory;
import com.axelor.inject.Beans;
import java.time.LocalDate;
import org.quartz.SchedulerException;
import com.axelor.app.AppSettings;
public class FetchCheckInOutJob implements Job {
private final Logger log = LoggerFactory.getLogger(FetchCheckInOutJob.class);
private final String pythonScriptDir = AppSettings.get().get("services.dir");
@Override
public void execute(JobExecutionContext context) throws JobExecutionException {
@@ -26,6 +28,11 @@ public class FetchCheckInOutJob implements Job {
return;
}
if (pythonScriptDir == null || pythonScriptDir.isEmpty()) {
log.error("Python script path is not configured in AppSettings.");
return;
}
try {
LocalDate today = LocalDate.now();
@@ -35,11 +42,10 @@ public class FetchCheckInOutJob implements Job {
.all()
.filter("self.date_attendance = :today")
.bind("today", today)
.fetch()
.size();
.fetch().size();
// Define the command to run the Python script with the correct path (V3)
String[] args = {"python", "C:\\Users\\administrator\\Desktop\\Scrape\\main2.py", String.valueOf(lenCheckInOutList)};
String[] args = {"python", pythonScriptDir + "\\Scrape\\main2.py", String.valueOf(lenCheckInOutList)};
// Execute the command
Process p = Runtime.getRuntime().exec(args);

View File

@@ -8,16 +8,20 @@
# ~~~~~
db.default.driver = org.postgresql.Driver
db.default.ddl = update
db.default.url = jdbc:postgresql://localhost:5432/postgres5
db.default.url = jdbc:postgresql://localhost:5432/bdd_test2
db.default.user = postgres
db.default.password = Mal@Ben$$23
# API
# Api
# ~~~~~
portail.api.baseurl = http://127.0.0.1:8000/api/
portail.api.user = admin
portail.api.password = 0000
# Services file directory
# ~~~~~~~~~~~~~~~~~~~~~~
services.dir = {user.home}/axelor/services
# Application Information
# ~~~~~
application.name = SOPHAL SPA
@@ -193,8 +197,8 @@ logging.level.com.axelor = DEBUG
# Quartz scheduler
# ~~~~~
quartz.enable = false
# quartz.threadCount = 5
quartz.enable = true
quartz.threadCount = 1
# Allows to open maximum 10 Tabs
view.tabs.max = 10