Commit 51cf694a authored by DESKTOP-VKRD9QF\Administration's avatar DESKTOP-VKRD9QF\Administration
parents d080df16 250695e0
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<>();
......
......@@ -276,6 +276,8 @@ public class MaterialRequirementService {
.eq(Routingsupporting::getIsdeleted, 0);
routingsupportings1 = routingsupportingMapper.selectList(routingsupportingwrapper);
if(routingsupportings1!=null&&routingsupportings1.size()>0)
{
routingsupportings.addAll(routingsupportings1);
List<String> routingsupportingids = routingsupportings1.stream()
......@@ -339,6 +341,7 @@ public class MaterialRequirementService {
}
}
}
}
if(routingIds1!=null)
{
routingIds.addAll(routingIds1);
......
......@@ -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;
}
......
......@@ -39,7 +39,7 @@ public class PlanResultServiceTest {
// TestSortService sortService=new TestSortService();
// sortService.test1();
// nsgaiiUtils.Test();
planResultService.execute2("EDDAFBAC0BD84375B7CF89BC85255082");
planResultService.execute2("18E5F8BE09B14EAE822651BFEF100900");
// planResultService.execute2("726D4C1A712B4B1393175BD44B775B66");
// planResultService.execute2("265F24B6DF3C40E4B17D193B0CC8AAF2");
// LocalDateTime t= LocalDateTime.of(2026, 02, 14, 1, 25, 52);
......
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