63 lines
2.6 KiB
Java
63 lines
2.6 KiB
Java
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<Employee> employees;
|
|
|
|
@ProblemFactCollectionProperty
|
|
private List<Collecte> collectes;
|
|
|
|
@PlanningEntityCollectionProperty
|
|
private List<Shift> 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<Employee> employees, List<Collecte> 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<Employee> getEmployees() { return employees; }
|
|
public void setEmployees(List<Employee> employees) { this.employees = employees; }
|
|
public List<Collecte> getCollectes() { return collectes; }
|
|
public void setCollectes(List<Collecte> collectes) { this.collectes = collectes; }
|
|
public List<Shift> getShifts() { return shifts; }
|
|
public void setShifts(List<Shift> 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; }
|
|
}
|