Commit f003b349 authored by DESKTOP-VKRD9QF\Administration's avatar DESKTOP-VKRD9QF\Administration

Merge branch 'jdt' of http://39.100.78.207:1213/tongli/hyh.apsj into jdt

parents ebfcf137 da07192c
......@@ -292,7 +292,7 @@ public class GeneticAlgorithm {
GeneticDecoder decoder = new GeneticDecoder(_GlobalParam, param.getBaseTime(), machines, orders, materials, machineScheduler,orderMaterials);
if(population!=null&&population.size()>0) {
population.forEach(chromosome -> {
population.parallelStream().forEach(chromosome -> {
chromosome.setResult(new ArrayList<>());
// 假设Machine类有拷贝方法,或使用MapStruct等工具进行映射
......
......@@ -70,7 +70,7 @@ public class GeneticDecoder {
FileHelper.writeLogFile("解码-----------开始-------"+chromosome.getID()+":"+cacheKey );
_allOperations=chromosome.getAllOperations();
if(orderMaterials!=null&&orderMaterials.size()>0) {
if(orderMaterials!=null&&orderMaterials.size()>0&&_globalParam.isIsCheckSf()) {
CreateNewOpSequence(chromosome);
}
......
......@@ -189,9 +189,6 @@ public class MachineCalculator {
LocalDateTime shiftStart = shift.getStart();
LocalDateTime shiftEnd = shift.getEnd();
// 计算有效时间
LocalDateTime effectiveStart = st.isAfter(shiftStart) ? st : shiftStart;
long availableSeconds = ChronoUnit.SECONDS.between(effectiveStart, shiftEnd);
......@@ -237,7 +234,10 @@ i++;
boolean requireContinuous) {
List<TimeSegment> availableSegments = new ArrayList<>();
LocalDateTime current = start;
if(requiredMinutes>3600*3999)
{
int i=0;
}
// 预先排序设备可用片段,避免后续遍历混乱
List<TimeSegment> allUseTimeSegment = machine.getAvailability().stream()
.filter(slot -> !slot.isUsed() && slot.getType() != SegmentType.MAINTENANCE)
......
......@@ -12,6 +12,7 @@ import org.springframework.context.annotation.ScopeMetadata;
import javax.xml.transform.Result;
import java.time.LocalDateTime;
import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
......@@ -695,11 +696,12 @@ Integer newMachineId1=newMachineId.intValue();
ScheduleResults.remove(OperationIndex1.getAsInt());
}
int i=0;
for (GlobalOperationInfo globalOp : globalOpList) {
globalOp.setGlobalOpId(i);
i++;
}
AtomicInteger globalOpId = new AtomicInteger(0);
globalOpList.forEach(t-> {
t.setGlobalOpId(globalOpId.getAndIncrement());
});
// chromosome.getOperatRel().remove(GroupId-1);
orders.remove(sourceorder);
redecode(chromosome, chromosome.getBaseTime(), globalParam);
......@@ -741,6 +743,7 @@ Integer newMachineId1=newMachineId.intValue();
GroupResult groupResult = OperatRels.get(targetOp.GroupId-1);
List<NodeInfo> nodeInfoList = groupResult.getNodeInfoList();
List<GlobalOperationInfo> globalOpList = chromosome.getGlobalOpList();
nodeInfoList = groupResult.getNodeInfoList();
for (Entry entry : entrys) {
......@@ -780,16 +783,27 @@ Integer newMachineId1=newMachineId.intValue();
if(info!=null) {
info.setSequence(node.getGroupSerial());
info.setOp(entry);
}
}else {
if(StringUtils.isBlank(entry.getMainId())) {
if(entry.getMainId()!=null&&!entry.getMainId().equals("")) {
//拆分的工序数量补齐到其他的
Entry main = entrys.stream().
filter(t -> t.MainId == entry.getMainId())
filter(t -> t.MainId.equals(entry.getMainId()) &&t.getId()!=entry.getId())
.findFirst()
.orElse(null);
if (main != null) {
main.setQuantity(main.getQuantity() + entry.getQuantity());
GlobalOperationInfo operationInfo= globalOpList.stream()
.filter(i -> i.getOp().getId() == main.getId())
.findFirst()
.orElseThrow(() -> new NoSuchElementException("Global operation not found: " + entry.getId()));
operationInfo.setOp(main);
}
}
......@@ -804,7 +818,6 @@ Integer newMachineId1=newMachineId.intValue();
chromosome.getOperationSequencing().remove(OperationIndex.getAsInt());
List<GlobalOperationInfo> globalOpList = chromosome.getGlobalOpList();
int globalOpIndex = IntStream.range(0, globalOpList.size())
.filter(i -> globalOpList.get(i).getOp().getId() == opId)
......@@ -815,6 +828,15 @@ Integer newMachineId1=newMachineId.intValue();
chromosome.getMachineSelection().remove(globalOpIndex);
globalOpList.remove(globalOpIndex);
AtomicInteger globalOpId = new AtomicInteger(0);
globalOpList.forEach(t-> {
t.setGlobalOpId(globalOpId.getAndIncrement());
});
List<Entry> operations = chromosome.getAllOperations();
IntStream.range(0, operations.size())
......@@ -877,11 +899,15 @@ Integer newMachineId1=newMachineId.intValue();
ScheduleResults.remove(OperationIndex1.getAsInt());
}
int i=0;
for (GlobalOperationInfo globalOp : globalOpList) {
globalOp.setGlobalOpId(i);
i++;
}
AtomicInteger globalOpId = new AtomicInteger(0);
globalOpList.forEach(t-> {
t.setGlobalOpId(globalOpId.getAndIncrement());
});
// chromosome.getOperatRel().remove(GroupId-1);
orders.remove(sourceorder);
redecode(chromosome, chromosome.getBaseTime(), globalParam);
......
......@@ -38,17 +38,18 @@ public class PlanResultServiceTest {
// nsgaiiUtils.Test();
//planResultService.execute2("C5FB5EF2A7334A0A92F826F4937E1008");
// planResultService.execute2("F79370487E4C455B8C4CF9BA41541CA9");
// planResultService.execute2("F79370487E4C455B8C4CF9BA41541CA9");
// LocalDateTime t= LocalDateTime.of(2025, 11, 15, 6, 51, 11);
// List<Integer> opids=new ArrayList<>();
// opids.add(1);
// planResultService.Move("B571EF6682DB463AB2977B1055A74112",opids,t,3403L);
// planResultService.Redecode("B6AE363FF5044DDF8DECE32D5FE0F7EA");
// planResultService.Redecode("B6AE363FF5044DDF8DECE32D5FE0F7EA");
// MaintenanceWindow maintenanceWindow=new MaintenanceWindow();
// maintenanceWindow.setStartTime(LocalDateTime.of(2025, 10, 21, 0, 0, 0));
// maintenanceWindow.setEndTime(LocalDateTime.of(2025, 10, 31, 0, 0, 0));
// planResultService.AddMaintenanceWindow("B6AE363FF5044DDF8DECE32D5FE0F7EA",1245l,maintenanceWindow);
planResultService.DelOperation("B6AE363FF5044DDF8DECE32D5FE0F7EA",7);
// planResultService.SpiltOrder("A41D662EE0764D008173C5A0E42B15F6","5f9d5383-b89a-4a4f-8805-2f617c711968",new Double[]{500d, 500d});
}
......
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