Commit 9362e4ee authored by Tong Li's avatar Tong Li

遗传算法-增加可中断

parent b8789253
...@@ -91,6 +91,7 @@ public class ProdProcessExec { ...@@ -91,6 +91,7 @@ public class ProdProcessExec {
*/ */
private String connectPropertyName; private String connectPropertyName;
private Long canInterrupt;
private Integer routingId; private Integer routingId;
......
...@@ -94,7 +94,7 @@ public class Entry { ...@@ -94,7 +94,7 @@ public class Entry {
/** /**
* 是否可中断,间缝插针 * 是否可中断,间缝插针
*/ */
public Boolean IsInterrupt = true; public Long IsInterrupt = 1l;
/** /**
* 所需物料 * 所需物料
......
...@@ -188,6 +188,7 @@ public class GeneticAlgorithm { ...@@ -188,6 +188,7 @@ public class GeneticAlgorithm {
if(bestFitness<best.getWeightedObjective()) if(bestFitness<best.getWeightedObjective())
{ {
bestFitness=best.getWeightedObjective(); bestFitness=best.getWeightedObjective();
Iteration=1;
}else { }else {
Iteration++; Iteration++;
......
...@@ -367,7 +367,7 @@ if(finishedOrder==null||finishedOrder.size()==0) ...@@ -367,7 +367,7 @@ if(finishedOrder==null||finishedOrder.size()==0)
int preTime = machineOption.getPreTime(); int preTime = machineOption.getPreTime();
int setupTime = calculateSetupTime(chromosome.getResult(), operation, machine, machineOption); int setupTime = calculateSetupTime(chromosome.getResult(), operation, machine, machineOption);
System.out.println(" 处理时间: " + processingTime + ", 后处理: " + teardownTime + FileHelper.writeLogFile (" 处理时间: " + processingTime + ", 后处理: " + teardownTime +
", 前处理: " + preTime + ", 换型: " + setupTime+ ", 数量: " + operation.getQuantity()); ", 前处理: " + preTime + ", 换型: " + setupTime+ ", 数量: " + operation.getQuantity());
......
...@@ -119,12 +119,8 @@ public class MachineCalculator { ...@@ -119,12 +119,8 @@ public class MachineCalculator {
if (!prevEnd.isEqual(LocalDateTime.of(2000, 1, 1, 0, 0, 0))) { if (!prevEnd.isEqual(LocalDateTime.of(2000, 1, 1, 0, 0, 0))) {
if (prevEnd.isBefore(currentTime)) { if (prevEnd.isBefore(currentTime)) {
// 检查班次间任务 // 检查班次间任务
LocalDateTime finalPrevEnd = prevEnd;
boolean hasTask = machineTasks.stream() boolean hasTask= CheckTask( machine, machineTasks, prevEnd, shiftStart);
.anyMatch(t -> {
LocalDateTime taskStart = baseTime.plusSeconds(t.getStartTime());
return taskStart.isAfter(finalPrevEnd) && taskStart.isBefore(shiftStart);
});
if (hasTask) { if (hasTask) {
// 重置状态 // 重置状态
...@@ -137,21 +133,8 @@ public class MachineCalculator { ...@@ -137,21 +133,8 @@ public class MachineCalculator {
continue; continue;
} }
// 检查班次间维修窗口
if (machine.getMaintenanceWindows() != null) {
LocalDateTime finalPrevEnd1 = prevEnd;
boolean hasMaintenance = machine.getMaintenanceWindows().stream()
.anyMatch(w -> w.getStartTime().isAfter(finalPrevEnd1) && w.getStartTime().isBefore(shiftStart));
if (hasMaintenance) {
currentTime = shiftStart;
st = shiftStart;
remainingTime = processingTime;
prevEnd = LocalDateTime.of(2000, 1, 1, 0, 0, 0);
times.clear();
continue;
}
}
} }
} }
...@@ -188,6 +171,26 @@ public class MachineCalculator { ...@@ -188,6 +171,26 @@ public class MachineCalculator {
return times; return times;
} }
private boolean CheckTask(Machine machine,List<GAScheduleResult> machineTasks,LocalDateTime prevEnd,LocalDateTime shiftStart) {
LocalDateTime finalPrevEnd = prevEnd;
boolean hasTask = machineTasks.stream()
.anyMatch(t -> {
LocalDateTime taskStart = baseTime.plusSeconds(t.getStartTime());
return taskStart.isAfter(finalPrevEnd) && taskStart.isBefore(shiftStart);
});
if (!hasTask) {
// 检查班次间维修窗口
if (machine.getMaintenanceWindows() != null) {
LocalDateTime finalPrevEnd1 = prevEnd;
boolean hasMaintenance = machine.getMaintenanceWindows().stream()
.anyMatch(w -> w.getStartTime().isAfter(finalPrevEnd1) && w.getStartTime().isBefore(shiftStart));
return hasMaintenance;
}
}
return hasTask;
}
/** /**
* 获取设备当前或下一个有效班次 * 获取设备当前或下一个有效班次
*/ */
......
...@@ -196,6 +196,7 @@ public class RoutingDataService { ...@@ -196,6 +196,7 @@ public class RoutingDataService {
entry.setRoutingDetailId(op.getRoutingDetailId()); entry.setRoutingDetailId(op.getRoutingDetailId());
entry.setTaskSeq(op.getTaskSeq()); entry.setTaskSeq(op.getTaskSeq());
entry.setRoutingDetailName(op.getRoutingDetailName()); entry.setRoutingDetailName(op.getRoutingDetailName());
entry.setIsInterrupt(op.getCanInterrupt());
Order order = ProdLaunchOrders.stream() Order order = ProdLaunchOrders.stream()
.filter(t -> t.getOrderId().equals(op.getOrderId())) .filter(t -> t.getOrderId().equals(op.getOrderId()))
.findFirst().orElse(null); .findFirst().orElse(null);
......
...@@ -643,6 +643,8 @@ public class LanuchServiceImpl implements LanuchService { ...@@ -643,6 +643,8 @@ public class LanuchServiceImpl implements LanuchService {
prodProcessExec.setRoutingId(prodOrderMain.getRoutingId()); prodProcessExec.setRoutingId(prodOrderMain.getRoutingId());
prodProcessExec.setRoutingCode(prodOrderMain.getRoutingCode()); prodProcessExec.setRoutingCode(prodOrderMain.getRoutingCode());
prodProcessExec.setConnectPropertyName(detail.getConnectPropertyName()); prodProcessExec.setConnectPropertyName(detail.getConnectPropertyName());
prodProcessExec.setCanInterrupt(detail.getCanInterrupt());
prodProcessExec.setSpeed( prodProcessExec.setSpeed(
Optional.ofNullable(detail.getRuntime()) Optional.ofNullable(detail.getRuntime())
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment