Commit 27bcdacf by chamberone

feat: 调整算法工具

1 parent 42a53b83
package com.dituhui.pea.dispatch.scheduler;
import com.dituhui.pea.dispatch.constraint.DispatchConstraintProvider;
import com.dituhui.pea.dispatch.entity.DispatchBatch;
import com.dituhui.pea.dispatch.pojo.Customer;
import com.dituhui.pea.dispatch.pojo.DispatchSolution;
import com.dituhui.pea.dispatch.pojo.Technician;
import com.dituhui.pea.dispatch.service.BatchService;
import com.dituhui.pea.dispatch.service.ExtractService;
import com.dituhui.pea.dispatch.service.SolveService;
import com.dituhui.pea.dispatch.utils.DispatchSolutionUtils;
import java.io.File;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.UUID;
import lombok.extern.slf4j.Slf4j;
import org.optaplanner.core.api.solver.Solver;
import org.optaplanner.core.api.solver.SolverFactory;
import org.optaplanner.core.config.solver.SolverConfig;
import org.optaplanner.core.impl.solver.DefaultSolverFactory;
import org.optaplanner.persistence.jackson.impl.domain.solution.JacksonSolutionFileIO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import java.io.File;
import java.time.Duration;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;
import java.util.Arrays;
import java.util.UUID;
import com.dituhui.pea.dispatch.pojo.DispatchSolution;
import com.dituhui.pea.dispatch.service.BatchService;
import com.dituhui.pea.dispatch.service.ExtractService;
import com.dituhui.pea.dispatch.service.SolveService;
import com.dituhui.pea.dispatch.utils.DispatchSolutionUtils;
import lombok.extern.slf4j.Slf4j;
@Slf4j
@Component
......@@ -49,17 +41,11 @@ public class BatchScheduler {
@Autowired
ExtractService extractService;
private SolverFactory<DispatchSolution> solverFactory;
private DefaultSolverFactory<DispatchSolution> solverFactory;
private Solver<DispatchSolution> solver;
public BatchScheduler() {
SolverConfig solverConfig = new SolverConfig().withSolutionClass(DispatchSolution.class);
solverConfig.withEntityClassList(Arrays.asList(Technician.class, Customer.class));// 这里不能漏掉,否则约束不生效
solverConfig.withConstraintProviderClass(DispatchConstraintProvider.class);
solverConfig.withTerminationSpentLimit(Duration.ofSeconds(60 * 5));
solverFactory = SolverFactory.create(solverConfig);
solverFactory = DispatchSolutionUtils.getSolverFactory(30, 60 * 5);
solver = solverFactory.buildSolver();
}
......@@ -74,8 +60,8 @@ public class BatchScheduler {
String currDay = LocalDate.now().plusDays(i).format(DateTimeFormatter.ISO_LOCAL_DATE);
log.info("dispatchRun begin----- group:{}, day:{}", groupId, currDay);
LocalTime currentTime = LocalTime.now();
LocalTime cutoffTime = LocalTime.parse("18:00:00", DateTimeFormatter.ISO_LOCAL_TIME);
// LocalTime currentTime = LocalTime.now();
// LocalTime cutoffTime = LocalTime.parse("18:00:00", DateTimeFormatter.ISO_LOCAL_TIME);
// 明天单才有cutoff
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!