Commit d5dfcb6f authored by Tong Li's avatar Tong Li

排产逻辑

parent 35468cd2
package com.aps.entity.basic;
import com.aps.entity.Algorithm.GAScheduleResult;
import lombok.Data;
import java.util.ArrayList;
......@@ -27,6 +28,11 @@ public class Machine {
*/
private int earliestTime=0;
/**
* 最后的任务,默认值:0
*/
private GAScheduleResult lastGene=null;
/**
* 总任务时间
*/
......
......@@ -271,10 +271,13 @@ public class MachineCalculator {
Machine machine, int processingTime, LocalDateTime currentTime,
String prevtime, CopyOnWriteArrayList<GAScheduleResult> existingTasks,double oneTime,double quantity, boolean checkprevtime, boolean islockMachineTime
,boolean isInterrupt) {
CopyOnWriteArrayList<GAScheduleResult> machineTasks =existingTasks.stream()
CopyOnWriteArrayList<GAScheduleResult> machineTasks=null;
if(existingTasks!=null) {
machineTasks = existingTasks.stream()
.filter(t -> t.getMachineId() == machine.getId())
.sorted(Comparator.comparingInt(GAScheduleResult::getStartTime))
.collect(Collectors.toCollection(CopyOnWriteArrayList::new));
}
CopyOnWriteArrayList<ScheduleResultDetail> times = new CopyOnWriteArrayList<>();
......
......@@ -201,7 +201,6 @@ int newStartTime=0;
}
/**
* 移动工序方法
* @param chromosome 染色体对象
......@@ -212,6 +211,35 @@ int newStartTime=0;
public void moveOperation(Chromosome chromosome, List<Integer> opIds, int newStartTime,
Long newMachineId, GlobalParam globalParam,int lockStartTime) {
List<Entry> allOperations = chromosome.getAllOperations();
for (Integer opId:opIds) {
GAScheduleResult targetResults = chromosome.getResult().stream()
.filter(r -> r.getOperationId() == opId).findFirst()
.orElseThrow(() -> new NoSuchElementException("Operation not found: " + opId));
targetResults.setLockStartTime(1);
targetResults.setDesignatedStartTime(newStartTime);
Entry targetOp = allOperations.stream()
.filter(o -> o.getId() == opId)
.findFirst()
.orElseThrow(() -> new NoSuchElementException("Operation not found: " + opId));
targetOp.setDesignatedStartTime(chromosome.getBaseTime().plusSeconds(newStartTime));
}
redecode(chromosome, chromosome.getBaseTime(), globalParam);
}
/**
* 移动工序方法
* @param chromosome 染色体对象
* @param opIds 工序ID
* @param newStartTime 新开始时间
* @param newMachineId 新设备ID
*/
public void moveOperation1(Chromosome chromosome, List<Integer> opIds, int newStartTime,
Long newMachineId, GlobalParam globalParam,int lockStartTime) {
List<Entry> allOperations = chromosome.getAllOperations();
int newStartTime1=newStartTime;
......
......@@ -28,7 +28,7 @@ public class DiscreteParameterDurationServiceImpl extends ServiceImpl<DiscretePa
Machine machine,
List<Entry> allOperations,int startTime,List<GAScheduleResult> machineTasks) {
if ( machineTasks.isEmpty()) {
if (machineTasks==null|| machineTasks.isEmpty()) {
return 0.0;
}
......@@ -38,15 +38,7 @@ public class DiscreteParameterDurationServiceImpl extends ServiceImpl<DiscretePa
return 0.0;
}
// 获取设备上最后一个任务
GAScheduleResult lastGene = machineTasks.stream()
.filter(g -> g.getMachineId() == machine.getId())
.max(Comparator.comparingInt(GAScheduleResult::getEndTime))
.orElse(null);
if (lastGene == null) {
return 0.0;
}
......
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