Commit e1788d68 by wangli

修改

1 parent 47540644
......@@ -47,14 +47,16 @@ public class OrderAssignCheck {
private int distanceAddition;
private LocalDateTime start;
private LocalDateTime end;
private int index;
public Result(boolean canAssign, String message, int minuteAddition, int distanceAddition, LocalDateTime start, LocalDateTime end){
public Result(boolean canAssign, String message, int minuteAddition, int distanceAddition, LocalDateTime start, LocalDateTime end, int index){
this.canAssign = canAssign;
this.message = message;
this.minuteAddition = minuteAddition;
this.distanceAddition = distanceAddition;
this.start = start;
this.end = end;
this.index = index;
}
}
......@@ -83,7 +85,7 @@ public class OrderAssignCheck {
int index = SegmentInsertion.insertSegment(takeTime, start, end, segments);
if (index == -1) {
log.info("没有可连续插入的空间");
return new Result(false, "没有连续可插入空间(没计算时间)", 0, 0, null, null);
return new Result(false, "没有连续可插入空间(没计算时间)", 0, 0, null, null, index);
}
log.info("插入位置为第{}单, 已分配单数(不包含本单):{}", index, orderSegments.size());
......@@ -105,7 +107,7 @@ public class OrderAssignCheck {
LocalDateTime startDateTime = this.point2LocalDateTime(startInsert, order.getDt());
LocalDateTime endDateTime = this.point2LocalDateTime(endInsert, order.getDt());
return new Result(true, "success", 0, 0, startDateTime, endDateTime);
return new Result(true, "success", 0, 0, startDateTime, endDateTime, index);
}
else if(index == 0 && !orderSegments.isEmpty()) {
// 第一订单为出发地, 且有其他订单
......@@ -115,7 +117,7 @@ public class OrderAssignCheck {
OrderSegment post = orderSegments.get(0);
OrderSegment pre = new OrderSegment(480, 480, preX, preY);
return this.getResult(curX, curY, pre, post, takeTime, order.getDt());
return this.getResult(curX, curY, pre, post, takeTime, order.getDt(), index);
}
else if(index == orderSegments.size()) {
// 最后一个订单出发
......@@ -128,12 +130,12 @@ public class OrderAssignCheck {
LocalDateTime startDateTime = this.point2LocalDateTime(startInsert, order.getDt());
LocalDateTime endDateTime = this.point2LocalDateTime(endInsert, order.getDt());
return new Result(true, "success", 0, 0, startDateTime, endDateTime);
return new Result(true, "success", 0, 0, startDateTime, endDateTime, index);
} else {
OrderSegment pre = orderSegments.get(index-1);
OrderSegment post = orderSegments.get(index);
return this.getResult(curX, curY, pre, post, takeTime, order.getDt());
return this.getResult(curX, curY, pre, post, takeTime, order.getDt(), index);
}
}
......@@ -181,7 +183,7 @@ public class OrderAssignCheck {
return segments;
}
private Result getResult(double curX, double curY, OrderSegment pre, OrderSegment post, int takeTime, LocalDate dt) {
private Result getResult(double curX, double curY, OrderSegment pre, OrderSegment post, int takeTime, LocalDate dt, int index) {
Pair preCurPair = this.getDistanceAndDuration(pre.getX(), pre.getY(), curX, curY);
Pair postCurPair = this.getDistanceAndDuration(post.getX(), post.getY(), curX, curY);
Pair prePostPair = this.getDistanceAndDuration(post.getX(), post.getY(), pre.getX(), pre.getY());
......@@ -190,7 +192,7 @@ public class OrderAssignCheck {
int distance = post.getStart() - postCurPair.getDuration() - (pre.getEnd() + preCurPair.getDuration());
if(distance < takeTime) {
// 不支持插入
return new Result(false, "增加时间路程后,不支持插入", 0, 0, null, null);
return new Result(false, "增加时间路程后,不支持插入", 0, 0, null, null, index);
}
// 插入点(时间点)
int startInsert = pre.getEnd() + preCurPair.getDuration();
......@@ -200,7 +202,7 @@ public class OrderAssignCheck {
int minuteAddition = preCurPair.getDuration() + postCurPair.getDuration() - prePostPair.getDuration();
int distanceAddition = preCurPair.getDistance() + postCurPair.getDistance() - prePostPair.getDistance();
return new Result(true, "success", minuteAddition, distanceAddition, startDateTime, endDateTime);
return new Result(true, "success", minuteAddition, distanceAddition, startDateTime, endDateTime, index);
}
private double[] getEngineerDepartureLocation(String engineerCode){
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!