Commit 1d704a34 by 张晓

Merge branch 'feature-dispatch-zx' into develop

2 parents 6025ee0c e16f06dc
......@@ -3,6 +3,9 @@ FROM openjdk:11-jdk-slim as builder
LABEL author="yuluo" \
email="yuluo829@aliyun.com"
ENV TZ=Asia/Shanghai
RUN echo -e "${TZ}" > /etc/timezone && ln -sf /usr/share/zoneinfo/${TZ} /etc/localtime
ADD ./project-dispatch/target/project-dispatch-*.jar /app.jar
ADD ./project-dispatch/src/main/resources/data /data
......
......@@ -24,7 +24,7 @@ import org.springframework.scheduling.annotation.EnableScheduling;
* @author gpzhang
*/
@SpringBootApplication
//@EnableScheduling
@EnableScheduling
public class DispatchServiceApplication {
public static void main(String[] args) {
......
......@@ -95,7 +95,7 @@ public class BatchController {
public Result<?> buildBatch(@PathVariable String groupId, @PathVariable String day) {
log.info("buildBatch, groupId:{}, day:{}", groupId, day);
try {
String batchNo = batchService.buildBatchNo(groupId, day);
String batchNo = batchService.buildBatchData(groupId, day);
DispatchBatch batch = batchService.queryBatch(groupId, batchNo);
DispatchBatchDTO batchDTO = new DispatchBatchDTO();
BeanUtil.copyProperties(batch, batchDTO, CopyOptions.create().setIgnoreNullValue(true));
......
......@@ -10,12 +10,10 @@ import com.dituhui.pea.dispatch.service.SolveService;
import lombok.extern.slf4j.Slf4j;
import org.optaplanner.core.api.solver.Solver;
import org.optaplanner.core.api.solver.SolverFactory;
import org.optaplanner.core.api.solver.SolverJob;
import org.optaplanner.core.api.solver.SolverManager;
import org.optaplanner.core.config.solver.SolverConfig;
import org.optaplanner.core.config.solver.SolverManagerConfig;
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;
......@@ -23,7 +21,6 @@ import java.io.File;
import java.sql.SQLException;
import java.time.Duration;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Arrays;
import java.util.UUID;
......@@ -34,7 +31,10 @@ public class BatchScheduler {
String groupId = "gsuzhou";
int nextDays = 3;
@Value("${dispatch.cron.next-day-limit}")
int nextDaysLimit = 3;
@Autowired
BatchService batchService;
......@@ -65,11 +65,11 @@ public class BatchScheduler {
public void dispatchRun() {
log.info("dispatchRun group:{}", groupId);
try {
for (int i = 0; i <= 2; i++) {
for (int i = 0; i <= nextDaysLimit; i++) {
String currDay = LocalDate.now().plusDays(i).format(DateTimeFormatter.ISO_LOCAL_DATE);
log.info("dispatchRun begin----- group:{}, day:{}", groupId, currDay);
String batchNo = batchService.buildBatchNo(groupId, currDay);
String batchNo = batchService.buildBatchData(groupId, currDay);
UUID problemId = solveService.generateProblemId(groupId, batchNo);
log.info("dispatchRun group:{}, day:{}, batch:{}, problemId:{}", groupId, currDay, batchNo, problemId);
......
......@@ -17,7 +17,7 @@ public interface BatchService {
// 检查指定日期的小组是否有在运行的批次任务,有则返回,没有则创建后返回批次码
@Transactional
String buildBatchNo(String groupId, String day) throws SQLException;
String buildBatchData(String groupId, String day) throws SQLException;
DispatchBatch queryBatch(String groupId, String day);
......
......@@ -56,7 +56,7 @@ public class BatchServiceImpl implements BatchService {
// 检查给定小组、日期是否有在运行的批次任务,没则返回,没有则创建
@Transactional
@Override
public String buildBatchNo(String groupId, String day) {
public String buildBatchData(String groupId, String day) {
log.info("准备批次数据, groupId:{}, day:{}", groupId, day);
String batchNo = "";
String batchDay = "";
......
......@@ -76,7 +76,7 @@ public class SolveServiceImpl implements SolveService {
Depot oneDepot;
Optional<OrgGroup> optional = groupRepository.findByGroupId(groupId);
if (!optional.isPresent()) {
log.error("组织问题对象, 未查询到组织信息 ,groupId:{}, batchNo:{}");
log.error("组织问题对象, 未查询到组织信息 ,groupId:{}, batchNo:{}", groupId, batchNo);
throw new RuntimeException(String.format("组织问题对象, 未查询到组织信息 ,groupId:%s, batchNo:%s", groupId, batchNo));
}
......@@ -118,10 +118,10 @@ public class SolveServiceImpl implements SolveService {
Depot depot = new Depot(engineer.getId(), engineer.getEngineerCode(), location, 60 * 8, 60 * 18);
depotList.add(depot);
log.info("组织问题对象, technicianList groupId:{}, batchNo:{}, engineer-code:{}", groupId, batchNo, engineer.getEngineerCode());
// log.debug("组织问题对象, technicianList groupId:{}, batchNo:{}, engineer-code:{}", groupId, batchNo, engineer.getEngineerCode());
List<String> skillList = queryEngineerSkills(engineer.getEngineerCode());
log.info("组织问题对象, technicianList groupId:{}, batchNo:{}, engineer-code:{} , skills:{}", groupId, batchNo, engineer.getEngineerCode(), String.join(";", skillList));
// log.debug("组织问题对象, technicianList groupId:{}, batchNo:{}, engineer-code:{} , skills:{}", groupId, batchNo, engineer.getEngineerCode(), String.join(";", skillList));
// 距离偏好map
Map<String, Long> preferedLoctionDistanceMap = new HashMap<String, Long>();
......@@ -136,8 +136,8 @@ public class SolveServiceImpl implements SolveService {
technicianList.add(vehicle);
});
log.info("组织问题对象, depotList-list, groupId:{}, batchNo:{}, depotList-list:{}", groupId, batchNo, depotList);
log.info("组织问题对象, technician-list, groupId:{}, batchNo:{}, technician-list:{}", groupId, batchNo, technicianList);
log.info("组织问题对象, depotList-list, groupId:{}, batchNo:{}, depotList-list:{}", groupId, batchNo, depotList.size());
log.info("组织问题对象, technician-list, groupId:{}, batchNo:{}, technician-list:{}", groupId, batchNo, technicianList.size());
//locationlist
List<Location> locationList = Stream.concat(depotList.stream().map(Depot::getLocation), customerList.stream().map(Customer::getLocation)).collect(Collectors.toList());
......@@ -180,7 +180,8 @@ public class SolveServiceImpl implements SolveService {
DispatchSolution.class);
// Set the output file.
exporter.write(solution, new File("dispatchSolution.json"));
String fileName = String.format("dispatchSolution-%s-%s.json", groupId, batchNo);
exporter.write(solution, new File(fileName));
return solution;
}
......
......@@ -3,7 +3,8 @@ server:
dispatch:
cron:
expr: 0 45 8-18 * * ?
expr: 0 36 8-18 * * ?
next-day-limit: 3
# expr: 0 */10 8-18 * * ?
spring:
......
......@@ -4,6 +4,7 @@ server:
dispatch:
cron:
expr: 0 */30 8-18 * * ?
next-day-limit: 3
spring:
application:
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!