package org.acme.employeescheduling.domain; import java.util.List; import java.util.ArrayList; import java.util.stream.Collectors; import ai.timefold.solver.core.api.domain.solution.PlanningEntityCollectionProperty; import ai.timefold.solver.core.api.domain.solution.PlanningScore; import ai.timefold.solver.core.api.domain.solution.PlanningSolution; import ai.timefold.solver.core.api.domain.solution.ProblemFactCollectionProperty; import ai.timefold.solver.core.api.domain.valuerange.ValueRangeProvider; import ai.timefold.solver.core.api.score.buildin.hardsoftbigdecimal.HardSoftBigDecimalScore; import ai.timefold.solver.core.api.solver.SolverStatus; @PlanningSolution public class EmployeeSchedule { @ProblemFactCollectionProperty @ValueRangeProvider(id = "employeeRange") private List employees; @ProblemFactCollectionProperty private List collectes; @PlanningEntityCollectionProperty private List shifts; @PlanningScore private HardSoftBigDecimalScore score; private SolverStatus solverStatus; // Constructeur vide requis par Timefold public EmployeeSchedule() { this.employees = new ArrayList<>(); this.collectes = new ArrayList<>(); this.shifts = new ArrayList<>(); } // Constructeur principal public EmployeeSchedule(List employees, List collectes) { this.employees = employees != null ? employees : new ArrayList<>(); this.collectes = collectes != null ? collectes : new ArrayList<>(); // Générer les shifts à partir des collectes this.shifts = collectes != null ? collectes.stream() .peek(Collecte::generateShifts) .flatMap(collecte -> collecte.getShifts().stream()) .collect(Collectors.toList()) : new ArrayList<>(); } // Getters et setters public List getEmployees() { return employees; } public void setEmployees(List employees) { this.employees = employees; } public List getCollectes() { return collectes; } public void setCollectes(List collectes) { this.collectes = collectes; } public List getShifts() { return shifts; } public void setShifts(List shifts) { this.shifts = shifts; } public HardSoftBigDecimalScore getScore() { return score; } public void setScore(HardSoftBigDecimalScore score) { this.score = score; } public SolverStatus getSolverStatus() { return solverStatus; } public void setSolverStatus(SolverStatus solverStatus) { this.solverStatus = solverStatus; } }