Commit ea051d6f by 刘鑫

Merge branch 'develop' of https://gitlab.dituhui.com/bsh/project/project into develop

2 parents b10f663e 51a6ab44
package com.dituhui.pea.dispatch.constraint; package com.dituhui.pea.dispatch.constraint;
import java.util.List;
import org.optaplanner.core.api.score.buildin.hardsoftlong.HardSoftLongScore; import org.optaplanner.core.api.score.buildin.hardsoftlong.HardSoftLongScore;
import org.optaplanner.core.api.score.stream.Constraint; import org.optaplanner.core.api.score.stream.Constraint;
import org.optaplanner.core.api.score.stream.ConstraintFactory; import org.optaplanner.core.api.score.stream.ConstraintFactory;
...@@ -54,9 +56,31 @@ public class DispatchConstraintProvider implements ConstraintProvider { ...@@ -54,9 +56,31 @@ public class DispatchConstraintProvider implements ConstraintProvider {
protected Constraint technicianTimeWindowsMatch(ConstraintFactory factory) { protected Constraint technicianTimeWindowsMatch(ConstraintFactory factory) {
return factory.forEach(Technician.class).filter( return factory.forEach(Technician.class).filter(
// EndTime ==0 表示不起作用 technician -> {
technician -> technician.getEndTime() > 0 && technician.getOffWorkTime() > technician.getEndTime()) boolean ret = false;
.penalizeLong(HardSoftLongScore.ONE_HARD, technician -> 1) // 单子的服务时间都在时间窗口内
int[][] timeWindows = technician.getTimeWindows();
List<Customer> customers = technician.getCustomerList();
if (null != timeWindows && timeWindows.length > 0 && null != customers && customers.size() > 0) {
for (Customer customer : customers) {
Integer arrivalTime = customer.getArrivalTime();
if (arrivalTime != null && arrivalTime > 0) {
boolean in = false;
for (int[] window : timeWindows) {
if (window[0] <= arrivalTime && window[1] >= arrivalTime) {
in = true;
break;
}
}
if (!in) {
// 到达时间在日历窗口外,惩罚得分
ret = true;
}
}
}
}
return ret;
}).penalizeLong(HardSoftLongScore.ONE_HARD, technician -> 1)
.asConstraint(ConstraintNameEnum.technicianTimeWindowsMatch.name()); .asConstraint(ConstraintNameEnum.technicianTimeWindowsMatch.name());
} }
......
...@@ -26,8 +26,16 @@ public class Technician { ...@@ -26,8 +26,16 @@ public class Technician {
private Depot depot; private Depot depot;
// 上班时间窗 分钟480-1080 8-18点 // 上班时间窗 分钟480-1080 8-18点
private int startTime; // private int startTime;
private int endTime; // private int endTime;
/**
* 上班多时间窗
* 时间窗格式:[[起始时间段1,结束时间段1],[起始时间段2,结束时间段2]...]
* 时间格式:从0点开始的分钟数,如早上8点为480.
*/
private int[][] timeWindows;
// 技能 // 技能
private Set<String> skills; private Set<String> skills;
...@@ -59,8 +67,7 @@ public class Technician { ...@@ -59,8 +67,7 @@ public class Technician {
this.id = id; this.id = id;
this.code = code; this.code = code;
this.depot = depot; this.depot = depot;
this.startTime = startTime; this.timeWindows = new int[][] { new int[] { startTime, endTime } };
this.endTime = endTime;
this.skills = skills; this.skills = skills;
this.preferredlocationDistanceMap = preferredlocationDistanceMap; this.preferredlocationDistanceMap = preferredlocationDistanceMap;
this.preferredlocation = preferredlocation; this.preferredlocation = preferredlocation;
...@@ -71,8 +78,7 @@ public class Technician { ...@@ -71,8 +78,7 @@ public class Technician {
this.id = id; this.id = id;
this.code = code; this.code = code;
this.depot = depot; this.depot = depot;
this.startTime = startTime; this.timeWindows = new int[][] { new int[] { startTime, endTime } };
this.endTime = endTime;
this.skills = skills; this.skills = skills;
this.maxCount = maxCount; this.maxCount = maxCount;
this.maxMinute = maxMinute; this.maxMinute = maxMinute;
...@@ -85,8 +91,7 @@ public class Technician { ...@@ -85,8 +91,7 @@ public class Technician {
this.id = id; this.id = id;
this.code = code; this.code = code;
this.depot = depot; this.depot = depot;
this.startTime = startTime; this.timeWindows = new int[][] { new int[] { startTime, endTime } };
this.endTime = endTime;
this.skills = skills; this.skills = skills;
this.maxCount = maxCount; this.maxCount = maxCount;
this.maxMinute = maxMinute; this.maxMinute = maxMinute;
...@@ -208,8 +213,8 @@ public class Technician { ...@@ -208,8 +213,8 @@ public class Technician {
@Override @Override
public String toString() { public String toString() {
return "Technician{" + "id=" + id + ", code='" + code + '\'' + ", depot=" + depot + ", startTime=" + startTime return "Technician{" + "id=" + id + ", code='" + code + '\'' + ", depot=" + depot + ", timeWindows=" + timeWindows
+ ", endTime=" + endTime + ", skills=" + skills + ", maxCount=" + maxCount + ", maxMinute=" + maxMinute + ", skills=" + skills + ", maxCount=" + maxCount + ", maxMinute=" + maxMinute
+ ", maxDistanceMeter=" + maxDistanceMeter + '}'; + ", maxDistanceMeter=" + maxDistanceMeter + '}';
} }
} }
...@@ -63,7 +63,7 @@ public class DispatchSolutionUtils { ...@@ -63,7 +63,7 @@ public class DispatchSolutionUtils {
AtomicInteger totalNum = new AtomicInteger(0); AtomicInteger totalNum = new AtomicInteger(0);
solution.getTechnicianList().forEach(technician -> { solution.getTechnicianList().forEach(technician -> {
System.out.printf("技术员%s(%s) [%s,%s]%n", technician.getId(), technician.getCode(), System.out.printf("技术员%s(%s) [%s,%s]%n", technician.getId(), technician.getCode(),
printTime(technician.getStartTime()), printTime(technician.getEndTime())); printTime(technician.getTimeWindows()[0][0]), printTime(technician.getTimeWindows()[0][1]));
totalNum.addAndGet(technician.getCustomerList().size()); totalNum.addAndGet(technician.getCustomerList().size());
for (Customer customer : technician.getCustomerList()) { for (Customer customer : technician.getCustomerList()) {
Customer previousCustomer = customer.getPreviousCustomer(); Customer previousCustomer = customer.getPreviousCustomer();
......
...@@ -91,6 +91,8 @@ public class OrderServiceDetailResp { ...@@ -91,6 +91,8 @@ public class OrderServiceDetailResp {
*/ */
private String multipleOrders; private String multipleOrders;
private String beanTags;
@Data @Data
@JsonInclude(JsonInclude.Include.NON_NULL) @JsonInclude(JsonInclude.Include.NON_NULL)
public static class OrderDetail { public static class OrderDetail {
......
...@@ -93,6 +93,7 @@ public class OrderServiceDetailImpl implements OrderServiceDetail { ...@@ -93,6 +93,7 @@ public class OrderServiceDetailImpl implements OrderServiceDetail {
res.setIsCutoff(order.getIsCutoff()); res.setIsCutoff(order.getIsCutoff());
res.setIsSpecialTime(order.getIsSpecialTime()); res.setIsSpecialTime(order.getIsSpecialTime());
res.setMultipleOrders(order.getMultipleOrders()); res.setMultipleOrders(order.getMultipleOrders());
res.setBeanTags(order.getBeanTags());
return Result.success(res); return Result.success(res);
} }
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!