From b3d0580439b9a00c7eb918085de1694151066004 Mon Sep 17 00:00:00 2001
From: Kenmegne <stephanie.kenmegne@gmail.com>
Date: Thu, 18 Jun 2026 16:02:49 +0000
Subject: [PATCH] rename packages
---
fdx_convert/src/main/java/com/megatim/fdxconvert/service/util/SchedulerUtil.java | 298 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 298 insertions(+), 0 deletions(-)
diff --git a/fdx_convert/src/main/java/com/megatim/fdxconvert/service/util/SchedulerUtil.java b/fdx_convert/src/main/java/com/megatim/fdxconvert/service/util/SchedulerUtil.java
new file mode 100644
index 0000000..af4c99a
--- /dev/null
+++ b/fdx_convert/src/main/java/com/megatim/fdxconvert/service/util/SchedulerUtil.java
@@ -0,0 +1,298 @@
+package com.megatim.fdxconvert.service.util;
+
+import com.megatim.fdxconvert.model.Tache;
+import java.time.DayOfWeek;
+import java.time.LocalDate;
+import java.time.LocalTime;
+import org.quartz.CronScheduleBuilder;
+import org.quartz.CronTrigger;
+import org.quartz.TriggerBuilder;
+
+/**
+ *
+ * @author MGT_DEV3
+ */
+public class SchedulerUtil {
+
+ private SchedulerUtil() {
+ }
+
+ public static CronTrigger buildTriggerForTache(Tache tache) {
+
+ return TriggerBuilder.newTrigger()
+ .startNow()
+ .withSchedule(CronScheduleBuilder.cronSchedule(getPlanification(tache))) //"0/20 * * * * ?"
+ .build();
+ }
+
+ //Prend une tâche en entrée et renvoie l'expression cron de sa planifaction
+ public static String getPlanification(Tache tache) {
+
+ LocalDate localDate = LocalDate.now();
+
+ boolean isActual = (tache.isMonday() && localDate.getDayOfWeek() == DayOfWeek.MONDAY)
+ || (tache.isTuesday() && localDate.getDayOfWeek() == DayOfWeek.TUESDAY)
+ || (tache.isWednesday() && localDate.getDayOfWeek() == DayOfWeek.WEDNESDAY)
+ || (tache.isThursday() && localDate.getDayOfWeek() == DayOfWeek.THURSDAY)
+ || (tache.isFriday() && localDate.getDayOfWeek() == DayOfWeek.FRIDAY)
+ || (tache.isSaturday() && localDate.getDayOfWeek() == DayOfWeek.SATURDAY)
+ || (tache.isSunday() && localDate.getDayOfWeek() == DayOfWeek.SUNDAY);
+
+ int heureTache = tache.getHeureTache();
+
+ int minuteTache = tache.getMinuteTache();
+
+ LocalTime tacheTime = LocalTime.parse(String.format("%02d", heureTache) + ":" + String.format("%02d", minuteTache) + ":00");
+
+ LocalTime actualTime = LocalTime.now();
+
+ if (isActual && !tache.isWithoutInterval() && actualTime.isAfter(tacheTime)) {
+
+ heureTache = actualTime.getHour();
+
+ minuteTache = actualTime.getMinute();
+
+ }
+
+ StringBuilder strBuilder = new StringBuilder();
+
+ strBuilder.append("0 ");
+
+ if (tache.isWithoutInterval()) {
+
+ strBuilder.append(minuteTache).append(" ");
+
+ strBuilder.append(heureTache).append(" ");
+
+ } else {
+
+ strBuilder.append(minuteTache).append("/").append(tache.getIntervalleTache()).append(" ");
+
+ if (heureTache == 0) {
+
+ strBuilder.append("*").append(" ");
+
+ } else {
+
+ strBuilder.append(heureTache).append("-").append("0").append(" ");
+
+ }
+ }
+
+ strBuilder.append("? * ");
+
+ StringBuilder strBuilderJour = new StringBuilder();
+
+ if (tache.isMonday()) {
+
+ strBuilderJour.append("2");
+
+ }
+
+ if (tache.isTuesday()) {
+
+ if (strBuilderJour.toString().isEmpty()) {
+
+ strBuilderJour.append("3");
+
+ } else {
+
+ strBuilderJour.append(",3");
+
+ }
+ }
+
+ if (tache.isWednesday()) {
+
+ if (strBuilderJour.toString().isEmpty()) {
+
+ strBuilderJour.append("4");
+
+ } else {
+
+ strBuilderJour.append(",4");
+
+ }
+ }
+
+ if (tache.isThursday()) {
+
+ if (strBuilderJour.toString().isEmpty()) {
+
+ strBuilderJour.append("5");
+
+ } else {
+
+ strBuilderJour.append(",5");
+
+ }
+ }
+
+ if (tache.isFriday()) {
+
+ if (strBuilderJour.toString().isEmpty()) {
+
+ strBuilderJour.append("6");
+
+ } else {
+
+ strBuilderJour.append(",6");
+
+ }
+
+ }
+
+ if (tache.isSaturday()) {
+
+ if (strBuilderJour.toString().isEmpty()) {
+
+ strBuilderJour.append("7");
+
+ } else {
+
+ strBuilderJour.append(",7");
+
+ }
+ }
+
+ if (tache.isSunday()) {
+
+ if (strBuilderJour.toString().isEmpty()) {
+
+ strBuilderJour.append("1");
+
+ } else {
+
+ strBuilderJour.append(",1");
+
+ }
+ }
+
+ //Ajout de l'expression énumérant les jours construite
+ strBuilder.append(strBuilderJour.toString());
+
+ return strBuilder.toString();
+ }
+
+ //Prend une tâche du protocol fdx en paramêtre et contruit en fonction des information de celle-ci le déclencheur approprié
+ /*public static CronTrigger buildTriggerForTache(Tache tache) {
+
+ System.out.println("LA PLANIFICATION SPECIFIEE EST : " + getPlanification(tache));
+
+ return TriggerBuilder.newTrigger()
+ .startNow()
+ .withSchedule(CronScheduleBuilder.cronSchedule(getPlanification(tache))) //"0/20 * * * * ?"
+ .withIdentity(tache.getLibelle())
+ .build();
+ }
+
+ //Prend une tâche en entrée et renvoie l'expression cron de sa planifaction
+ public static String getPlanification(Tache tache) {
+
+ StringBuilder strBuilder = new StringBuilder();
+
+ strBuilder.append("0 ");
+ strBuilder.append(tache.getMinuteTache()).append(" ");
+ strBuilder.append(tache.getHeureTache()).append(" ");
+
+ strBuilder.append("? * ");
+
+ StringBuilder strBuilderJour = new StringBuilder();
+
+ if (tache.isMonday()) {
+
+ strBuilderJour.append("2");
+
+ }
+
+ if (tache.isTuesday()) {
+
+ if (strBuilderJour.toString().isEmpty()) {
+
+ strBuilderJour.append("3");
+
+ } else {
+
+ strBuilderJour.append(",3");
+
+ }
+
+ }
+
+ if (tache.isWednesday()) {
+
+ if (strBuilderJour.toString().isEmpty()) {
+
+ strBuilderJour.append("4");
+
+ } else {
+
+ strBuilderJour.append(",4");
+
+ }
+
+ }
+
+ if (tache.isThursday()) {
+
+ if (strBuilderJour.toString().isEmpty()) {
+
+ strBuilderJour.append("5");
+
+ } else {
+
+ strBuilderJour.append(",5");
+
+ }
+
+ }
+
+ if (tache.isFriday()) {
+
+ if (strBuilderJour.toString().isEmpty()) {
+
+ strBuilderJour.append("6");
+
+ } else {
+
+ strBuilderJour.append(",6");
+
+ }
+
+ }
+
+ if (tache.isSaturday()) {
+
+ if (strBuilderJour.toString().isEmpty()) {
+
+ strBuilderJour.append("7");
+
+ } else {
+
+ strBuilderJour.append(",7");
+
+ }
+
+ }
+
+ if (tache.isSunday()) {
+
+ if (strBuilderJour.toString().isEmpty()) {
+
+ strBuilderJour.append("1");
+
+ } else {
+
+ strBuilderJour.append(",1");
+
+ }
+
+ }
+
+ //Ajout de l'expression énumérant les jours construite
+ strBuilder.append(strBuilderJour.toString());
+
+ return strBuilder.toString();
+ }*/
+
+}
--
Gitblit v1.10.0