Commit 39c7d181 by Ren Ping

fix:自动任务优化

1 parent 83792934
...@@ -214,6 +214,11 @@ public class BatchServiceImpl implements BatchService { ...@@ -214,6 +214,11 @@ public class BatchServiceImpl implements BatchService {
} else { } else {
batchNo = optional.get().getBatchNo(); batchNo = optional.get().getBatchNo();
batchDay = optional.get().getBatchDate(); batchDay = optional.get().getBatchDate();
// 执行数据库操作
String sqlInsert = "update dispatch_batch set" +
" group_id=?, engineer_num=0, order_num=0, start_time=?, end_time=null,status='RUNNING'" +
" where team_id=? and batch_no=?";
jdbcTemplate.update(sqlInsert, groupId, LocalDateTime.now(), teamId, batchNo);
} }
log.info("清理原批次数据, teamId:{}, day:{}, batchNo:{}", teamId, batchDay, batchNo); log.info("清理原批次数据, teamId:{}, day:{}, batchNo:{}", teamId, batchDay, batchNo);
......
package com.dituhui.pea.dispatch.service.impl; package com.dituhui.pea.dispatch.service.impl;
import cn.hutool.core.util.StrUtil;
import cn.hutool.crypto.SecureUtil; import cn.hutool.crypto.SecureUtil;
import com.dituhui.pea.dispatch.common.GeoDistanceCalculator; import com.dituhui.pea.dispatch.common.GeoDistanceCalculator;
import com.dituhui.pea.dispatch.constraint.DispatchConstraintProvider; import com.dituhui.pea.dispatch.constraint.DispatchConstraintProvider;
...@@ -260,7 +261,7 @@ public class SolveServiceImpl implements SolveService { ...@@ -260,7 +261,7 @@ public class SolveServiceImpl implements SolveService {
// technicianList // technicianList
ArrayList<Technician> technicianList = new ArrayList<>(); ArrayList<Technician> technicianList = new ArrayList<>();
dispatchEngineerRepo.findByTeamIdAndBatchNo(teamId, batchNo).forEach(engineer -> { dispatchEngineerRepo.findByTeamIdAndBatchNo(teamId, batchNo).forEach(engineer -> {
Location location = new Location(engineer.getId(), engineer.getEngineerCode(), "中心点", Double.parseDouble(engineer.getX()), Double.parseDouble(engineer.getY())); Location location = new Location(engineer.getId(), engineer.getEngineerCode(), "中心点", StrUtil.isEmpty(engineer.getX()) ? 0 : Double.parseDouble(engineer.getX()), StrUtil.isEmpty(engineer.getY()) ? 0 : Double.parseDouble(engineer.getY()));
// Depot depot = new Depot(engineer.getId(), engineer.getEngineerCode(), location, 60 * 8, 60 * 18); // Depot depot = new Depot(engineer.getId(), engineer.getEngineerCode(), location, 60 * 8, 60 * 18);
// depotList.add(depot); // depotList.add(depot);
...@@ -281,7 +282,7 @@ public class SolveServiceImpl implements SolveService { ...@@ -281,7 +282,7 @@ public class SolveServiceImpl implements SolveService {
if (engineer.getVehicleType() != null && engineer.getVehicleType() == 2) { if (engineer.getVehicleType() != null && engineer.getVehicleType() == 2) {
maxDistance = 40 * 1000; maxDistance = 40 * 1000;
} }
Technician vehicle = new Technician(engineer.getId(), engineer.getEngineerCode(), engineer.getMaxNum(), engineer.getMaxMinute(), maxDistance, engineer.getVehicleType() , oneDepot, 60 * 8, 60 * 18, Set.copyOf(skillList), preferedLoctionDistanceMap); Technician vehicle = new Technician(engineer.getId(), engineer.getEngineerCode(), engineer.getMaxNum(), engineer.getMaxMinute(), maxDistance, engineer.getVehicleType(), oneDepot, 60 * 8, 60 * 18, Set.copyOf(skillList), preferedLoctionDistanceMap);
technicianList.add(vehicle); technicianList.add(vehicle);
}); });
...@@ -302,7 +303,7 @@ public class SolveServiceImpl implements SolveService { ...@@ -302,7 +303,7 @@ public class SolveServiceImpl implements SolveService {
distanceCalculator.initDistanceMaps(locationList, vehicleTypes); distanceCalculator.initDistanceMaps(locationList, vehicleTypes);
long time2 = System.currentTimeMillis(); long time2 = System.currentTimeMillis();
log.info("组织问题对象 done, teamId:{}, batchNo:{}, technician-size:{}, customer-size:{}, location-size:{}, 路网耗时path:{}ms", teamId, batchNo, technicianList.size(), customerList.size(), locationList.size(), time2-time1); log.info("组织问题对象 done, teamId:{}, batchNo:{}, technician-size:{}, customer-size:{}, location-size:{}, 路网耗时path:{}ms", teamId, batchNo, technicianList.size(), customerList.size(), locationList.size(), time2 - time1);
return solution; return solution;
...@@ -449,7 +450,7 @@ public class SolveServiceImpl implements SolveService { ...@@ -449,7 +450,7 @@ public class SolveServiceImpl implements SolveService {
log.info("算法结果回写dispatch, step3-逐个客户处理, groupId:{}, batchNo:{}, employ: {}, customer:{}, service-duration:{} ", groupId, batchNo, technician.getCode(), customer.getCode(), customer.getServiceDuration()); log.info("算法结果回写dispatch, step3-逐个客户处理, groupId:{}, batchNo:{}, employ: {}, customer:{}, service-duration:{} ", groupId, batchNo, technician.getCode(), customer.getCode(), customer.getServiceDuration());
log.info(customer.toString()); log.info(customer.toString());
LocalDateTime customDateTime = LocalDateTime.parse(customer.getDt()+" 00:00:00", DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); LocalDateTime customDateTime = LocalDateTime.parse(customer.getDt() + " 00:00:00", DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
LocalDateTime arriveTime = customDateTime.plusMinutes(customer.getArrivalTime()); LocalDateTime arriveTime = customDateTime.plusMinutes(customer.getArrivalTime());
LocalDateTime leaveTime = customDateTime.plusMinutes(customer.getDepartureTime()); LocalDateTime leaveTime = customDateTime.plusMinutes(customer.getDepartureTime());
...@@ -500,7 +501,7 @@ public class SolveServiceImpl implements SolveService { ...@@ -500,7 +501,7 @@ public class SolveServiceImpl implements SolveService {
log.info("算法结果回写dispatch, step3-逐个客户处理, teamId:{}, batchNo:{}, employ: {}, customer:{}, service-duration:{} ", teamId, batchNo, technician.getCode(), customer.getCode(), customer.getServiceDuration()); log.info("算法结果回写dispatch, step3-逐个客户处理, teamId:{}, batchNo:{}, employ: {}, customer:{}, service-duration:{} ", teamId, batchNo, technician.getCode(), customer.getCode(), customer.getServiceDuration());
log.info(customer.toString()); log.info(customer.toString());
LocalDateTime customDateTime = LocalDateTime.parse(customer.getDt()+" 00:00:00", DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); LocalDateTime customDateTime = LocalDateTime.parse(customer.getDt() + " 00:00:00", DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
LocalDateTime arriveTime = customDateTime.plusMinutes(customer.getArrivalTime()); LocalDateTime arriveTime = customDateTime.plusMinutes(customer.getArrivalTime());
LocalDateTime leaveTime = customDateTime.plusMinutes(customer.getDepartureTime()); LocalDateTime leaveTime = customDateTime.plusMinutes(customer.getDepartureTime());
......
...@@ -60,12 +60,13 @@ spring: ...@@ -60,12 +60,13 @@ spring:
#调度实例失效的检查时间间隔 #调度实例失效的检查时间间隔
clusterCheckinInterval: 10000 clusterCheckinInterval: 10000
useProperties: false useProperties: false
misfireThreshold: 600000
threadPool: threadPool:
class: org.quartz.simpl.SimpleThreadPool class: org.quartz.simpl.SimpleThreadPool
# 指定在线程池里面创建的线程是否是守护线程 # 指定在线程池里面创建的线程是否是守护线程
makeThreadsDaemons: false makeThreadsDaemons: false
#指定线程数,至少为1(无默认值,一般设置为1-100) #指定线程数,至少为1(无默认值,一般设置为1-100)
threadCount: 5 threadCount: 10
#设置线程的优先级(最大为java.lang.Thread.MAX_PRIORITY 10,最小为Thread.MIN_PRIORITY 1,默认为5) #设置线程的优先级(最大为java.lang.Thread.MAX_PRIORITY 10,最小为Thread.MIN_PRIORITY 1,默认为5)
threadPriority: 5 threadPriority: 5
threadsInheritContextClassLoaderOfInitializingThread: true threadsInheritContextClassLoaderOfInitializingThread: true
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!