Commit c42cce5c by 王力

Merge branch 'dev_dispatch_op0712' into 'develop'

修改

See merge request !220
2 parents 06396a98 bccb35e6
......@@ -87,22 +87,45 @@ public class OrderAssignCheck {
log.info("插入位置为第{}单", index);
// 计算距离 & 时间
if(index == 0) {
// 第一订单为出发地
if(index == 0 && orderSegments.isEmpty()) {
// 第一订单为出发地, 没有其他订单
EngineerBusiness b = engineerBusinessMPDao.getByEngineerCode(engineerCode);
OrderSegment post = orderSegments.get(1);
OrderSegment pre = new OrderSegment(480, post.getStart(), Double.parseDouble(b.getX()), Double.parseDouble(b.getY()));
OrderSegment pre = new OrderSegment(480, 480, Double.parseDouble(b.getX()), Double.parseDouble(b.getY()));
Pair p = this.getDistanceAndDuration(pre.getX(), pre.getY(), curX, curY);
// 最早可插入位置为技术员出发时间+行程时间
int startPos = pre.getEnd() + p.getDuration();
int startInsert = (startPos >= start) ? startPos : start; // 客户期望最早时间是start, 可最早插入时间是startPos
int endInsert = startInsert + takeTime;
LocalDateTime startDateTime = this.point2LocalDateTime(startInsert, order.getDt());
LocalDateTime endDateTime = this.point2LocalDateTime(endInsert, order.getDt());
return new Result(true, "success", 0, 0, startDateTime, endDateTime);
}
else if(index == 0 && !orderSegments.isEmpty()) {
// 第一订单为出发地, 且有其他订单
EngineerBusiness b = engineerBusinessMPDao.getByEngineerCode(engineerCode);
OrderSegment post = orderSegments.get(0);
OrderSegment pre = new OrderSegment(480, 480, Double.parseDouble(b.getX()), Double.parseDouble(b.getY()));
return this.getResult(curX, curY, pre, post, takeTime, order.getDt());
}
else if(index == orderSegments.size()) {
// 最后一个订单出发
OrderSegment pre = orderSegments.get(index);
// 为当前订单
OrderSegment post = new OrderSegment(start, end, Double.parseDouble(order.getX()), Double.parseDouble(order.getY()));
return this.getResult(curX, curY, pre, post, takeTime, order.getDt());
Pair p = this.getDistanceAndDuration(pre.getX(), pre.getY(), curX, curY);
// 最早可插入位置为技术员上一单出发时间+行程时间
int startPos = pre.getEnd() + p.getDuration();
int startInsert = (startPos >= start) ? startPos : start; // 客户期望最早时间是start, 可最早插入时间是startPos
int endInsert = startInsert + takeTime;
LocalDateTime startDateTime = this.point2LocalDateTime(startInsert, order.getDt());
LocalDateTime endDateTime = this.point2LocalDateTime(endInsert, order.getDt());
return new Result(true, "success", 0, 0, startDateTime, endDateTime);
} else {
OrderSegment pre = orderSegments.get(index);
OrderSegment post = orderSegments.get(index+1);
OrderSegment pre = orderSegments.get(index-1);
OrderSegment post = orderSegments.get(index);
return this.getResult(curX, curY, pre, post, takeTime, order.getDt());
}
}
......@@ -194,6 +217,7 @@ public class OrderAssignCheck {
long duration = distance / (19 * 1000 / 60); // 时间为分钟,假设电动车速度为19km/h
return new Pair((int)distance, (int)duration);
}
}
@Data
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!