|
@@ -12,7 +12,9 @@ import org.optaplanner.core.api.score.buildin.hardsoft.HardSoftScore;
|
|
|
import org.optaplanner.core.api.solver.SolutionManager;
|
|
|
import org.optaplanner.core.api.solver.Solver;
|
|
|
import org.optaplanner.core.api.solver.SolverFactory;
|
|
|
+import org.optaplanner.core.config.solver.EnvironmentMode;
|
|
|
import org.optaplanner.core.config.solver.SolverConfig;
|
|
|
+import org.optaplanner.core.config.solver.termination.TerminationConfig;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import java.time.Duration;
|
|
|
import java.time.LocalDateTime;
|
|
@@ -44,10 +46,13 @@ public class ProductionScheduleServiceImpl implements ProductionScheduleService
|
|
|
|
|
|
// optaplanner 求解器配置实例化
|
|
|
SolverFactory<ApsSolution> solverFactory = SolverFactory.create(new SolverConfig()
|
|
|
+// .withEnvironmentMode(EnvironmentMode.FULL_ASSERT)
|
|
|
.withSolutionClass(ApsSolution.class)
|
|
|
.withEntityClasses(ProductionProcesses.class)
|
|
|
.withConstraintProviderClass(ApsConstraintProvider.class)
|
|
|
- .withTerminationSpentLimit(Duration.ofSeconds(planSeconds)));
|
|
|
+ .withTerminationConfig(new TerminationConfig().withUnimprovedSecondsSpentLimit(30L))
|
|
|
+// .withTerminationSpentLimit(Duration.ofSeconds(planSeconds))
|
|
|
+ );
|
|
|
Solver<ApsSolution> solver = solverFactory.buildSolver();
|
|
|
// optaplanner 求解器数据装配
|
|
|
ApsSolution apsSolution = getPreApsSolution(productionScheduleVo);
|
|
@@ -113,8 +118,16 @@ public class ProductionScheduleServiceImpl implements ProductionScheduleService
|
|
|
// 后道工序
|
|
|
if(process.getNextProcessesIds() != null && process.getNextProcessesIds().size()>0){
|
|
|
List<ProductionProcesses> nexts = new ArrayList<>();
|
|
|
- for (String nextId : process.getNextProcessesIds()) {
|
|
|
+ /*for (String nextId : process.getNextProcessesIds()) {
|
|
|
nexts.add(idMaps.get(nextId));
|
|
|
+ }*/
|
|
|
+ for (String previousProcessesId : process.getNextProcessesIds()) {
|
|
|
+ for (ProductionProcesses nextprocess : productionScheduleVo.getProcesses()) {
|
|
|
+ if(nextprocess.getBsProcessesId().contains(previousProcessesId)){
|
|
|
+ nexts.add(nextprocess);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
if(nexts != null && nexts.size()>0){
|
|
|
process.setNextProcesses(nexts);
|