Commit d64e0934 by chamberone

fix: 加入优化后的日历逻辑

1 parent 700a7c71
...@@ -280,16 +280,20 @@ public class SolveServiceImpl implements SolveService { ...@@ -280,16 +280,20 @@ 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(), "中心点", 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); int[][] timeWindows = engineerCalendarService.timeWindows(engineer.getEngineerCode(), teamId,
// depotList.add(depot); LocalDateTimeUtil.parseDate(currDay, DateTimeFormatter.ofPattern("yyyy-MM-dd")));
if (null != timeWindows && timeWindows.length > 0) {
// log.debug("组织问题对象, technicianList groupId:{}, batchNo:{}, engineer-code:{}", groupId, batchNo, engineer.getEngineerCode()); log.info("技术员时间窗, teamId:{}, batchNo:{}, engineerName:{}, timeWindows:{}", teamId, batchNo,
engineer.getEngineerName(), new Gson().toJson(timeWindows));
// 技术员技能
List<String> skillList = queryEngineerSkills(engineer.getEngineerCode()); List<String> skillList = queryEngineerSkills(engineer.getEngineerCode());
// log.debug("组织问题对象, technicianList groupId:{}, batchNo:{}, engineer-code:{} , skills:{}", groupId, batchNo, engineer.getEngineerCode(), String.join(";", skillList));
// 距离偏好map // 距离偏好map
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()));
Map<String, Long> preferedLoctionDistanceMap = new HashMap<String, Long>(); Map<String, Long> preferedLoctionDistanceMap = new HashMap<String, Long>();
if (location.getLongitude() > 1 && location.getLatitude() > 1) { if (location.getLongitude() > 1 && location.getLatitude() > 1) {
// 设置了偏好位置 // 设置了偏好位置
...@@ -301,12 +305,13 @@ public class SolveServiceImpl implements SolveService { ...@@ -301,12 +305,13 @@ public class SolveServiceImpl implements SolveService {
// 未设置,不参与计算 // 未设置,不参与计算
} }
// 硬约束:电动车固定40km上限,其他无限制 // 最大距离,硬约束:电动车固定40km上限,其他无限制
int maxDistance = engineer.getMaxDistance() * 1000; int maxDistance = engineer.getMaxDistance() * 1000;
if (engineer.getVehicleType() != null && engineer.getVehicleType() == 2) { if (engineer.getVehicleType() != null && engineer.getVehicleType() == 2) {
maxDistance = 40 * 1000; maxDistance = 40 * 1000;
} }
// 技术员出发地
Double x = null; Double x = null;
Double y = null; Double y = null;
if (ObjectUtil.equal(engineer.getDeparture(), DepartureEnum.WORK_ADDR.getCode())) { if (ObjectUtil.equal(engineer.getDeparture(), DepartureEnum.WORK_ADDR.getCode())) {
...@@ -317,19 +322,19 @@ public class SolveServiceImpl implements SolveService { ...@@ -317,19 +322,19 @@ public class SolveServiceImpl implements SolveService {
y = Double.parseDouble(orgWarehouseInfoEntity.getY()); y = Double.parseDouble(orgWarehouseInfoEntity.getY());
} }
Location engineerLocation = new Location(engineer.getId(), engineer.getEngineerCode(), "起点", x, y); Location engineerLocation = new Location(engineer.getId(), engineer.getEngineerCode(), "起点", x, y);
Depot engineerDepot = new Depot(engineer.getId(), engineer.getEngineerCode(), engineerLocation, 60 * 8, 60 * 18); Depot engineerDepot = new Depot(engineer.getId(), engineer.getEngineerCode(), engineerLocation, 60 * 8,
60 * 18);
// FIXME 无锡时间窗数据错误,暂时改成固定值
int[][] timeWindows = engineerCalendarService.timeWindows(engineer.getEngineerCode(), teamId, LocalDateTimeUtil.parseDate(currDay, DateTimeFormatter.ofPattern("yyyy-MM-dd")));
System.err.println(engineer.getEngineerName()+" : " + new Gson().toJson(timeWindows));
log.info(engineer.getEngineerName()+" : " + new Gson().toJson(timeWindows));
timeWindows = new int[][] { { 480, 1080 } };
Technician vehicle = new Technician(engineer.getId(), engineer.getEngineerCode(), engineer.getMaxNum(), engineer.getMaxMinute(), maxDistance, engineer.getVehicleType(), engineerDepot, timeWindows, Set.copyOf(skillList), preferedLoctionDistanceMap); Technician vehicle = new Technician(engineer.getId(), engineer.getEngineerCode(), engineer.getMaxNum(),
engineer.getMaxMinute(), maxDistance, engineer.getVehicleType(), engineerDepot, timeWindows,
Set.copyOf(skillList), preferedLoctionDistanceMap);
technicianList.add(vehicle); technicianList.add(vehicle);
} else {
// 没有时间窗技术员,不参与派工
log.info("技术员时间窗, teamId:{}, batchNo:{}, engineerName:{}, no timeWindows", teamId, batchNo,
engineer.getEngineerName());
}
}); });
log.info("组织问题对象, depotList-list, teamId:{}, batchNo:{}", teamId, batchNo);
log.info("组织问题对象, technician-list, teamId:{}, batchNo:{}, technician-list:{}", teamId, batchNo, technicianList.size()); log.info("组织问题对象, technician-list, teamId:{}, batchNo:{}, technician-list:{}", teamId, batchNo, technicianList.size());
// locationlist 起点+订单地点 // locationlist 起点+订单地点
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!