Commit d64e0934 by chamberone

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

1 parent 700a7c71
...@@ -279,57 +279,62 @@ public class SolveServiceImpl implements SolveService { ...@@ -279,57 +279,62 @@ 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,
List<String> skillList = queryEngineerSkills(engineer.getEngineerCode()); engineer.getEngineerName(), new Gson().toJson(timeWindows));
// log.debug("组织问题对象, technicianList groupId:{}, batchNo:{}, engineer-code:{} , skills:{}", groupId, batchNo, engineer.getEngineerCode(), String.join(";", skillList)); // 技术员技能
List<String> skillList = queryEngineerSkills(engineer.getEngineerCode());
// 距离偏好map
Map<String, Long> preferedLoctionDistanceMap = new HashMap<String, Long>(); // 距离偏好map
if (location.getLongitude() > 1 && location.getLatitude() > 1) { Location location = new Location(engineer.getId(), engineer.getEngineerCode(), "中心点",
// 设置了偏好位置 StrUtil.isEmpty(engineer.getX()) ? 0 : Double.parseDouble(engineer.getX()),
customerList.forEach(customer -> { StrUtil.isEmpty(engineer.getY()) ? 0 : Double.parseDouble(engineer.getY()));
long distance = distanceCalculator.calculateDistance(location, customer.getLocation()); Map<String, Long> preferedLoctionDistanceMap = new HashMap<String, Long>();
preferedLoctionDistanceMap.put(customer.getCode(), distance); if (location.getLongitude() > 1 && location.getLatitude() > 1) {
}); // 设置了偏好位置
customerList.forEach(customer -> {
long distance = distanceCalculator.calculateDistance(location, customer.getLocation());
preferedLoctionDistanceMap.put(customer.getCode(), distance);
});
} else {
// 未设置,不参与计算
}
// 最大距离,硬约束:电动车固定40km上限,其他无限制
int maxDistance = engineer.getMaxDistance() * 1000;
if (engineer.getVehicleType() != null && engineer.getVehicleType() == 2) {
maxDistance = 40 * 1000;
}
// 技术员出发地
Double x = null;
Double y = null;
if (ObjectUtil.equal(engineer.getDeparture(), DepartureEnum.WORK_ADDR.getCode())) {
x = Double.parseDouble(engineer.getWorkX());
y = Double.parseDouble(engineer.getWorkY());
} else {
x = Double.parseDouble(orgWarehouseInfoEntity.getX());
y = Double.parseDouble(orgWarehouseInfoEntity.getY());
}
Location engineerLocation = new Location(engineer.getId(), engineer.getEngineerCode(), "起点", x, y);
Depot engineerDepot = new Depot(engineer.getId(), engineer.getEngineerCode(), engineerLocation, 60 * 8,
60 * 18);
Technician vehicle = new Technician(engineer.getId(), engineer.getEngineerCode(), engineer.getMaxNum(),
engineer.getMaxMinute(), maxDistance, engineer.getVehicleType(), engineerDepot, timeWindows,
Set.copyOf(skillList), preferedLoctionDistanceMap);
technicianList.add(vehicle);
} else { } else {
// 未设置,不参与计算 // 没有时间窗技术员,不参与派工
log.info("技术员时间窗, teamId:{}, batchNo:{}, engineerName:{}, no timeWindows", teamId, batchNo,
engineer.getEngineerName());
} }
});
// 硬约束:电动车固定40km上限,其他无限制
int maxDistance = engineer.getMaxDistance() * 1000;
if (engineer.getVehicleType() != null && engineer.getVehicleType() == 2) {
maxDistance = 40 * 1000;
}
Double x = null;
Double y = null;
if (ObjectUtil.equal(engineer.getDeparture(), DepartureEnum.WORK_ADDR.getCode())) {
x = Double.parseDouble(engineer.getWorkX());
y = Double.parseDouble(engineer.getWorkY());
} else {
x = Double.parseDouble(orgWarehouseInfoEntity.getX());
y = Double.parseDouble(orgWarehouseInfoEntity.getY());
}
Location engineerLocation = new Location(engineer.getId(), engineer.getEngineerCode(), "起点", x, y);
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);
technicianList.add(vehicle);
});
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!