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

Merge remote-tracking branch 'origin/master'

parents 65fd45ea 1bf5a775
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
package com.aps.common.util;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import com.fasterxml.jackson.databind.SerializationFeature;
......@@ -126,5 +127,16 @@ public class ProductionDeepCopyUtil {
}
}
public static <K, V> Map<K, V> deepCopyMap(Map<K, V> source) {
if (source == null) {
return new HashMap<>();
}
try {
String json = objectMapper.writeValueAsString(source);
return objectMapper.readValue(json, new TypeReference<Map<K, V>>() {});
} catch (Exception e) {
throw new RuntimeException("Map深拷贝失败", e);
}
}
}
\ No newline at end of file
......@@ -127,6 +127,8 @@ public class Chromosome {
private ObjectiveWeights objectiveWeights;
// private Map<String,Material> materials = new HashMap<>();
private List<Material> materials = new ArrayList<>();
private List<String> materialIds = new ArrayList<>();
......
......@@ -639,9 +639,9 @@ public class GeneticDecoder {
// 半成品订单首次处理时,延迟计算锚点:沿依赖链找到根成品工序并正推
if (orderIsJit && orderAnchor == 0) {
orderAnchor =bom.computeSemiFinishedAnchor(groupId, entrysBygroupId,
orderAnchor =bom.computeSemiFinishedAnchor(this,groupId, entrysBygroupId,
opMachineKeyMap, chromosome,
scheduleIndexById, machineTasksCache);
scheduleIndexById, machineTasksCache, machineIdMap, entryIndexById);
if(orderAnchor<0) {
orderIsJit=false;
orderSchedulingInfo.put(groupId,
......@@ -702,7 +702,7 @@ public class GeneticDecoder {
int dueDateForOp = opIsJit ? orderAnchor
: (schedInfo != null ? schedInfo.getValue() : 0);
int actualEndTime = processOperation(currentOp,machineId,processTime,machineOption,chromosome,machineIdMap,machineTasksCache,entryIndexById,scheduleIndexById,dueDateForOp,opIsJit);
int actualEndTime = processOperation(currentOp,machineId,processTime,machineOption,chromosome,machineIdMap,machineTasksCache,entryIndexById,scheduleIndexById,dueDateForOp,true,opIsJit);
long opElapsed = System.nanoTime() - opStart;
opCount++;
......@@ -1011,7 +1011,7 @@ public class GeneticDecoder {
int orderDueDate1=orderDueDate.get(op.getGroupId());
// 处理当前工序
// long processStartTime = System.currentTimeMillis();
int actualEndTime = processOperation(op,machineId,processTime,machineOption,chromosome,machineIdMap,machineTasksCache, entryIndexById,scheduleIndexById,orderDueDate1,false);
int actualEndTime = processOperation(op,machineId,processTime,machineOption,chromosome,machineIdMap,machineTasksCache, entryIndexById,scheduleIndexById,orderDueDate1,true,false);
// long processEndTime = System.currentTimeMillis();
......@@ -1169,7 +1169,18 @@ public class GeneticDecoder {
private int processOperation(Entry currentOp,Long machineId,double processTime,OpMachine machineOption,Chromosome chromosome,Map<Long, Machine> machineIdMap,Map<Long, CopyOnWriteArrayList<GAScheduleResult>> machineTasksCache,Map<Integer, Entry> entryIndexById,Map<Integer, GAScheduleResult> scheduleIndexById,int orderDueDate, boolean isJit)
private int processOperation(Entry currentOp,Long machineId,double processTime,OpMachine machineOption,Chromosome chromosome,Map<Long, Machine> machineIdMap,Map<Long, CopyOnWriteArrayList<GAScheduleResult>> machineTasksCache,Map<Integer, Entry> entryIndexById,Map<Integer, GAScheduleResult> scheduleIndexById,int orderDueDate,boolean islockMachineTime, boolean isJit)
{
GAScheduleResult result= processOperationResult( currentOp, machineId, processTime, machineOption, chromosome, machineIdMap, machineTasksCache, entryIndexById, scheduleIndexById, orderDueDate, islockMachineTime, isJit);
if(result==null)
return 0;
return result.getEndTime();
}
public GAScheduleResult processOperationResult(Entry currentOp,Long machineId,double processTime,OpMachine machineOption,Chromosome chromosome,Map<Long, Machine> machineIdMap,Map<Long, CopyOnWriteArrayList<GAScheduleResult>> machineTasksCache,Map<Integer, Entry> entryIndexById,Map<Integer, GAScheduleResult> scheduleIndexById,int orderDueDate,boolean islockMachineTime, boolean isJit)
{
Machine targetMachine = machineIdMap.get(machineId);
......@@ -1192,32 +1203,33 @@ public class GeneticDecoder {
int prevendtime=prevtime;
Machine machine = machineIdMap.get(machineId);
int actualEndTime = processWithSingleMachine(currentOp, machine, processTime, prevtime,machineOption, chromosome,false,prevendtime,machineTasksCache,entryIndexById, scheduleIndexById,isJit);
return actualEndTime;
GAScheduleResult result= processWithSingleMachine(currentOp, machine, processTime, prevtime,machineOption, chromosome,false,prevendtime,machineTasksCache,entryIndexById, scheduleIndexById, islockMachineTime,isJit);
return result;
}
private int processWithSingleMachine(Entry operation, Machine machine, double processingTime,
int prevOperationEndTime,OpMachine machineOption, Chromosome chromosome,boolean calbom,int prevendtime,Map<Long, CopyOnWriteArrayList<GAScheduleResult>> machineTasksCache,Map<Integer, Entry> entryIndexById,Map<Integer, GAScheduleResult> scheduleIndexById,boolean isJit) {
private GAScheduleResult processWithSingleMachine(Entry operation, Machine machine, double processingTime,
int prevOperationEndTime,OpMachine machineOption, Chromosome chromosome,boolean calbom,int prevendtime,Map<Long, CopyOnWriteArrayList<GAScheduleResult>> machineTasksCache,Map<Integer, Entry> entryIndexById,Map<Integer, GAScheduleResult> scheduleIndexById,boolean islockMachineTime,boolean isJit) {
long pwsStart = System.nanoTime();
int processingTimeTotal=0;
int processingTimeTotal = 0;
int earliestStartTime = prevOperationEndTime;
if(operation.getConstTime()==1)//常数时间
if (operation.getConstTime() == 1)//常数时间
{
processingTimeTotal=(int)Math.ceil (processingTime);
}else {
double t= machineOption.getRuntime().doubleValue()/machineOption.getSingleOut().doubleValue()*(operation.getQuantity());
processingTimeTotal =(int)Math.ceil (t);
processingTimeTotal = (int) Math.ceil(processingTime);
} else {
double t = machineOption.getRuntime().doubleValue() / machineOption.getSingleOut().doubleValue() * (operation.getQuantity());
processingTimeTotal = (int) Math.ceil(t);
}
int days=(int) ((processingTimeTotal)/24/3600);
if(days>600)
{
throw new RuntimeException("工序总加工时长"+days+"天超出限制");
int days = (int) ((processingTimeTotal) / 24 / 3600);
if (days > 600) {
throw new RuntimeException("工序总加工时长" + days + "天超出限制");
}
if(machine==null||operation.getMachineOptions()==null)
{
return 0;
if (machine == null || operation.getMachineOptions() == null) {
return null;
}
// MachineOption machineOption= operation.getMachineOptions().stream()
......@@ -1229,9 +1241,8 @@ public class GeneticDecoder {
operation.setEquipName(machine.getName());
//准备工时
int setTime = operation.getSetupTime().intValue();
if(setTime>0)
{
processingTimeTotal+=setTime;//加上准备工时
if (setTime > 0) {
processingTimeTotal += setTime;//加上准备工时
}
//后处理时间
......@@ -1244,104 +1255,99 @@ public class GeneticDecoder {
// 就是 最早开工时间是否+前处理时间,总的加工工时不考虑前处理
if (!_globalParam.is_smoothSetup()) {
// 工序的前处理不能提前,则要在前处理完成后才能开工,所以要在前一工序的结束时间基础上+前处理
earliestStartTime+=preTime;
earliestStartTime += preTime;
}
int operationId = operation.getId();
GAScheduleResult existingResult = chromosome.getResultOld().stream().filter(r-> r.getOperationId() == operationId).findFirst().orElse(null);
if(existingResult!=null)
{
earliestStartTime = Math.max(earliestStartTime,existingResult.getDesignatedStartTime());
GAScheduleResult existingResult = chromosome.getResultOld().stream().filter(r -> r.getOperationId() == operationId).findFirst().orElse(null);
if (existingResult != null) {
earliestStartTime = Math.max(earliestStartTime, existingResult.getDesignatedStartTime());
}
if (operation.isJitTemporary() && operation.getJitPreferredStartTime() != null) {
int jitPreferredStartTime = (int) ChronoUnit.SECONDS.between(baseTime, operation.getJitPreferredStartTime());
earliestStartTime = Math.max(earliestStartTime, jitPreferredStartTime);
}
if(machine.getCapacityTypeName().equals("Infinite"))
{
int endTime=0;
int startTime=0;
if(operation.getQuantity()==0)
{
processingTimeTotal=0;
}else {
if (machine.getCapacityTypeName().equals("Infinite")) {
int endTime = 0;
int startTime = 0;
if (operation.getQuantity() == 0) {
processingTimeTotal = 0;
} else {
processingTimeTotal = (int) Math.ceil(processingTime);
}
if(isJit)
{
endTime=earliestStartTime;
startTime=endTime-processingTimeTotal;
if (isJit) {
endTime = earliestStartTime;
startTime = endTime - processingTimeTotal;
}else {
startTime=earliestStartTime;
endTime=startTime+processingTimeTotal;
} else {
startTime = earliestStartTime;
endTime = startTime + processingTimeTotal;
}
GAScheduleResult result= CreateResult(operation,machine.getId(),startTime,endTime,processingTime,0,preTime,teardownTime,0,null,existingResult);
GAScheduleResult result = CreateResult(operation, machine.getId(), startTime, endTime, processingTime, 0, preTime, teardownTime, 0, null, existingResult);
if(islockMachineTime) {
chromosome.getResult().add(result);
machine.setLastGene(result);
scheduleIndexById.put(operation.getId(),result);
return endTime;
scheduleIndexById.put(operation.getId(), result);
}
// if (isJit) {
// FileHelper.writeLogFile(" 半成品 " + operation.getGroupId() + " - " + operation.getSequence() + ",开始时间: " + startTime + ",结束时间: " + endTime + ",处理时间: " + processingTime + ", 后处理: " + teardownTime +
// ", 前处理: " + preTime + ", 换型: " + 0 + ", 数量: " + operation.getQuantity() + ", 设备: " + machine.getId() + ", 是否可中断: " + operation.getIsInterrupt());
//
// }
return result;
}
int setupTime=0;
int setupTime = 0;
long machineId = machine.getId();
// 只有存在物料约束(或本次被强制要求重算 BOM)的工序,才需要联立求解“机台何时能排”和“物料何时可用”。
// targetFinishedOperationId != null 的工序通常由前置成品工序驱动,这里不再额外触发一轮 BOM 试算。
boolean needMaterialCheck =(operation.getMaterialRequirements()!=null&&operation.getMaterialRequirements().size()>0&&operation.getTargetFinishedOperationId()==null)||calbom;
boolean needMaterialCheck = (operation.getMaterialRequirements() != null && operation.getMaterialRequirements().size() > 0 && operation.getTargetFinishedOperationId() == null) || calbom;
CopyOnWriteArrayList<GAScheduleResult> machineTasks = getMachineTasks(machineId, chromosome, machineTasksCache);
GAScheduleResult lastGeneOnMachine = getLastMachineTask(machineTasks);
int bomtime=0;
if(needMaterialCheck) {
int bomtime = 0;
if (needMaterialCheck&&islockMachineTime) {
bomtime = getOperationBOMTime(operation, chromosome, 2);
earliestStartTime=Math.max(earliestStartTime,bomtime);
earliestStartTime = Math.max(earliestStartTime, bomtime);
}
// 正式落排前,再取一次当前机台最后一道工序,保证换型计算基于最新排程结果。
if(machineTasks!=null&&machineTasks.size()>0&&_globalParam.is_smoothChangeOver())
{
lastGeneOnMachine=machineTasks.get(machineTasks.size()-1);
if (machineTasks != null && machineTasks.size() > 0 && _globalParam.is_smoothChangeOver()) {
lastGeneOnMachine = machineTasks.get(machineTasks.size() - 1);
}
CopyOnWriteArrayList<ScheduleResultDetail> geneDetails=new CopyOnWriteArrayList<>();
CopyOnWriteArrayList<ScheduleResultDetail> geneDetails = new CopyOnWriteArrayList<>();
// 下面开始生成正式的 geneDetails。
// 与 buildMachinePreview 的区别是:这里得到的结果会继续向下写入 GAScheduleResult,成为真正排程结果。
if (_globalParam.is_smoothChangeOver()) {
if (!isJit&&_globalParam.is_smoothChangeOver()) {
//是否考虑换型时间
Map<Integer,Object> reslte = calculateSetupTime(lastGeneOnMachine, operation, machine,earliestStartTime,processingTimeTotal, _globalParam.is_smoothChangeOverInWeek(),chromosome.getAllOperations());
setupTime=(int)reslte.get(1);//换型时间
int setupStartTime=(int)reslte.get(2);//换型开始时间
Map<Integer, Object> reslte = calculateSetupTime(lastGeneOnMachine, operation, machine, earliestStartTime, processingTimeTotal, _globalParam.is_smoothChangeOverInWeek(), chromosome.getAllOperations());
setupTime = (int) reslte.get(1);//换型时间
int setupStartTime = (int) reslte.get(2);//换型开始时间
//earliestStartTime=(int)reslte.get(3);//上个任务的结束时间
earliestStartTime=(int)reslte.get(4);//最早开工时间
processingTimeTotal=(int)reslte.get(5);//processingTimeTotal
if(setupTime==0)
{
earliestStartTime = (int) reslte.get(4);//最早开工时间
processingTimeTotal = (int) reslte.get(5);//processingTimeTotal
if (setupTime == 0) {
geneDetails = machineCalculator.getNextAvailableTime(machine, operation, earliestStartTime, -1,
processingTimeTotal, machineTasks, operation.getIsInterrupt()!=1, true,processingTime, operation.getQuantity(), true,isJit);
processingTimeTotal, machineTasks, operation.getIsInterrupt() != 1, islockMachineTime, processingTime, operation.getQuantity(), true, isJit);
}else {
} else {
CopyOnWriteArrayList<TimeSegment> AvailableTimeSegment = (CopyOnWriteArrayList<TimeSegment>) reslte.get(6);
Map<Integer,Object> result = machineCalculator.CreateScheduleResult(machine, operation, processingTimeTotal, earliestStartTime,
AvailableTimeSegment, processingTime, operation.getQuantity(), operation.getIsInterrupt() != 1, setupTime, _globalParam.is_smoothChangeOverInWeek(), setupStartTime,true,isJit);
Map<Integer, Object> result = machineCalculator.CreateScheduleResult(machine, operation, processingTimeTotal, earliestStartTime,
AvailableTimeSegment, processingTime, operation.getQuantity(), operation.getIsInterrupt() != 1, setupTime, _globalParam.is_smoothChangeOverInWeek(), setupStartTime, true, isJit);
setupTime=(int)result.get(1);
setupTime = (int) result.get(1);
operation.setChangeLineTime(setupTime);
geneDetails=(CopyOnWriteArrayList<ScheduleResultDetail>) result.get(2);
geneDetails = (CopyOnWriteArrayList<ScheduleResultDetail>) result.get(2);
}
}else {
} else {
geneDetails = machineCalculator.getNextAvailableTime(machine, operation, earliestStartTime, -1,
processingTimeTotal, machineTasks, operation.getIsInterrupt()!=1, true,processingTime, operation.getQuantity(), true,isJit);
processingTimeTotal, machineTasks, operation.getIsInterrupt() != 1, true, processingTime, operation.getQuantity(), islockMachineTime, isJit);
}
......@@ -1352,22 +1358,51 @@ public class GeneticDecoder {
// 确定任务的最早开始时间(基于前一道工序的完整结束时间,包含后处理)
// System.out.println(" 最终最早开始时间: " + earliestStartTime +
// " (前序工序结束含后处理: " + prevOperationEndTime + ", 设备可用: " +
// (lastGeneOnMachine != null ? lastGeneOnMachine.getEndTime() : 0) +
// ", 换型: " + setupTime + ")");
if (geneDetails == null||geneDetails.size()==0) {
if(islockMachineTime)
{
// FileHelper.writeLogFile(" 半成品111111 " + operation.getGroupId() + " - " + operation.getSequence() + ",开始时间: " + 0 + ",结束时间: " + 0 + ",处理时间: " + processingTime + ", 后处理: " + teardownTime +
// ", 前处理: " + preTime + ", 换型: " + setupTime + ", 数量: " + operation.getQuantity() + ", 设备: " + machine.getId() + ", 是否可中断: " + operation.getIsInterrupt());
}
return null;
}
int startTime = geneDetails.stream()
.mapToInt(ScheduleResultDetail::getStartTime)
.min()
.orElse(0);
if (startTime == 0) {
if(islockMachineTime)
{
// FileHelper.writeLogFile(" 半成品222222 " + operation.getGroupId() + " - " + operation.getSequence() + ",开始时间: " + startTime + ",结束时间: " + 0 + ",处理时间: " + processingTime + ", 后处理: " + teardownTime +
// ", 前处理: " + preTime + ", 换型: " + setupTime + ", 数量: " + operation.getQuantity() + ", 设备: " + machine.getId() + ", 是否可中断: " + operation.getIsInterrupt());
}
return null;
}
int endTime = geneDetails.stream()
.mapToInt(ScheduleResultDetail::getEndTime)
.max()
.orElse(0);
// if (isJit) {
// FileHelper.writeLogFile(" 半成品 " + operation.getGroupId() + " - " + operation.getSequence() + ",开始时间: " + startTime + ",结束时间: " + endTime + ",处理时间: " + processingTime + ", 后处理: " + teardownTime +
// ", 前处理: " + preTime + ", 换型: " + setupTime + ", 数量: " + operation.getQuantity() + ", 设备: " + machine.getId() + ", 是否可中断: " + operation.getIsInterrupt());
//
// }
//扣库存
if(needMaterialCheck) {
if (needMaterialCheck && islockMachineTime) {
EditOperationBOMTime(operation, chromosome, startTime, machineTasksCache, entryIndexById, scheduleIndexById);
}
//换型时间是否占用设备加工时间
......@@ -1382,11 +1417,12 @@ public class GeneticDecoder {
// 后处理时间 相同任务的前一工序的结束时间+后处理时间 =当前工序最早开工时间
GAScheduleResult result= CreateResult(operation,machine.getId(),startTime,endTime,processingTime,setupTime,preTime,teardownTime,bomtime,geneDetails,existingResult);
GAScheduleResult result = CreateResult(operation, machine.getId(), startTime, endTime, processingTime, setupTime, preTime, teardownTime, bomtime, geneDetails, existingResult);
// System.out.println("huanxingshijian="+result.getChangeOverTime()+"-------------------"+result.getOrderId()+"--------"+result.getExecId()+"---------"+prev.getOrderId()+"--------"+prev.getExecId());
if (islockMachineTime)
{
chromosome.getResult().add(result);
machine.setLastGene(result);
......@@ -1395,14 +1431,15 @@ public class GeneticDecoder {
if (machineTasks != null) {
machineTasks.add(result);
}
scheduleIndexById.put(operation.getId(),result);
scheduleIndexById.put(operation.getId(), result);
}
// long pwsElapsed = System.nanoTime() - pwsStart;
// if (pwsElapsed > 500_000_000L) {
// FileHelper.writeLogFile("[PERF] processWithSingleMachine 总慢 opId=" + operationId
// + ", groupId=" + operation.getGroupId() + ", machineId=" + machineId
// + ", hasBOM=" + commitMaterialCheck + ", 耗时=" + fmtMs(pwsElapsed));
// }
return endTime;
return result;
}
private GAScheduleResult CreateResult(Entry operation,long machineId
......@@ -1721,7 +1758,7 @@ if(geneDetails!=null&&geneDetails.size()>0)
}
}
return nexttime;
return nexttime-currentOp.getTeardownTime();
}
......@@ -1913,7 +1950,7 @@ if(geneDetails!=null&&geneDetails.size()>0)
.findFirst()
.orElse(null);
// 缓存机器任务
int actualEndTime = processWithSingleMachine(currentOp, machine, processTime, prevtime,opMachine, chromosome,true,prevendtime,machineTasksCache, entryIndexById, scheduleIndexById,true);
processWithSingleMachine(currentOp, machine, processTime, prevtime,opMachine, chromosome,true,prevendtime,machineTasksCache, entryIndexById, scheduleIndexById,true,true);
}
......
package com.aps.service.Algorithm;
import com.aps.common.util.FileHelper;
import com.aps.common.util.ProductionDeepCopyUtil;
import com.aps.entity.Algorithm.*;
import com.aps.entity.basic.*;
......@@ -30,12 +31,12 @@ public class GeneticDecoderBom {
materialRequirementService=_materialRequirementService;
}
public int computeSemiFinishedAnchor(int semiGroupId,
public int computeSemiFinishedAnchor(GeneticDecoder decoder,int semiGroupId,
Map<Integer, List<Entry>> entrysBygroupId,
Map<String, OpMachine> opMachineKeyMap,
Chromosome chromosome,
Map<Integer, GAScheduleResult> scheduleIndexById,
Map<Long, CopyOnWriteArrayList<GAScheduleResult>> machineTasksCache) {
Map<Long, CopyOnWriteArrayList<GAScheduleResult>> machineTasksCache,Map<Long, Machine> machineIdMap,Map<Integer, Entry> entryIndexById) {
List<Entry> semiOps = entrysBygroupId.get(semiGroupId);
if (semiOps == null || semiOps.isEmpty()) return 0;
......@@ -58,23 +59,34 @@ public class GeneticDecoderBom {
Entry firstTargetOp = targetOps.get(0);
if (Entry.SchedulingMode.FORWARD.name().equals(
firstTargetOp.getSchedulingMode())) {
int rootStart = forwardEstimateToOperation(targetOpId, targetGroupId,0,
int rootStart = forwardEstimateToOperation(decoder,targetOpId, targetGroupId,0,
entrysBygroupId, opMachineKeyMap, chromosome,
scheduleIndexById, machineTasksCache,false);
scheduleIndexById, machineTasksCache,machineIdMap,entryIndexById,false);
List<Integer> chainGroupIds = new ArrayList<>(intermediateGroupIds);
chainGroupIds.add(targetGroupId);
rootStart = correctByRawMaterialStockForChain(chainGroupIds,targetGroupId,targetOpId,
rootStart, entrysBygroupId,chromosome);
int anchor = rootStart;
// FileHelper.writeLogFile(" 成品开始 "+targetGroupId+" : "+rootStart);
if(anchor==0)
{
return -1;
}
for (int i = intermediateGroupIds.size() - 1; i >= 0; i--) {
int start1= forwardEstimateToOperation(0, intermediateGroupIds.get(i),anchor,
int sfGroupId= intermediateGroupIds.get(i);
int start1= forwardEstimateToOperation(decoder,0,sfGroupId ,anchor,
entrysBygroupId, opMachineKeyMap, chromosome,
scheduleIndexById, machineTasksCache,true);
if(start1<0) {
scheduleIndexById, machineTasksCache,machineIdMap,entryIndexById,true);
// FileHelper.writeLogFile(" 半成品开始 "+sfGroupId+" : "+start1+" - "+anchor);
if(start1<=0) {
isFORWARD=true;
break;
}
......@@ -126,12 +138,14 @@ public class GeneticDecoderBom {
}
return -1;
}
private int forwardEstimateToOperation(int targetOpId, int groupId,int startSecond,
private int forwardEstimateToOperation(GeneticDecoder decoder, int targetOpId, int groupId,int startSecond,
Map<Integer, List<Entry>> entrysBygroupId,
Map<String, OpMachine> opMachineKeyMap,
Chromosome chromosome,
Map<Integer, GAScheduleResult> scheduleIndexById,
Map<Long, CopyOnWriteArrayList<GAScheduleResult>> machineTasksCache,boolean isJit) {
Map<Long, CopyOnWriteArrayList<GAScheduleResult>> machineTasksCache,
Map<Long, Machine> machineIdMap,
Map<Integer, Entry> entryIndexById,boolean isJit) {
List<Entry> ops = entrysBygroupId.get(groupId);
if (ops == null) return 0;
......@@ -209,30 +223,35 @@ if(isJit)
if (machine != null&&!machine.getCapacityTypeName().equals("Infinite")) {
CopyOnWriteArrayList<GAScheduleResult> machineTasks = getMachineTasks(mId, chromosome, machineTasksCache);
CopyOnWriteArrayList<ScheduleResultDetail> geneDetails = estimateCalendarAwareDuration(machine,op,machineTasks, start, rawDur,mo.getProcessingTime(),isJit);
if(geneDetails!=null) {
start = geneDetails.stream()
.mapToInt(ScheduleResultDetail::getStartTime)
.min()
.orElse(0);
end = geneDetails.stream()
.mapToInt(ScheduleResultDetail::getEndTime)
.max()
.orElse(0);
GAScheduleResult result= decoder.processOperationResult( op, mId, mo.getProcessingTime(), mo, chromosome, machineIdMap, machineTasksCache, entryIndexById, scheduleIndexById, start, false, isJit);
// CopyOnWriteArrayList<ScheduleResultDetail> geneDetails = estimateCalendarAwareDuration(machine,op,machineTasks, start, rawDur,mo.getProcessingTime(),isJit);
if(result!=null) {
start = result.getStartTime();
end = result.getEndTime();
}else {
return -1;
}
}else {
if(isJit)
{
start=start-rawDur;
end=start;
start=start-rawDur;
}else {
start=end;
end=start+rawDur;
}
// FileHelper.writeLogFile(" 半成品 " + op.getGroupId() + " - " + op.getSequence() + ",开始时间: " + start + ",结束时间: " + end + ",处理时间: " + rawDur );
}
if (op.getId() == targetOpId) return start;
......
......@@ -507,7 +507,20 @@ public class MachineCalculator {
if(timeSegments1==null) {
int i = 0;
CopyOnWriteArrayList<TimeSegment> usedSegments =new CopyOnWriteArrayList<>();
double AvTotal = calculateTotalMinutesByIndex(timeSegments, currentTime, timeSegments.size(), isJit);
if(AvTotal<remainingTime)
{
return null;
}
while (remainingTime > 0) {
TimeSegment shift = timeSegments.get(i);
Map<Integer, Object> outMap = CreateScheduleResultDetail(shift, currentTime, remainingTime, oneTime,isJit);
......
......@@ -1906,17 +1906,6 @@ if(targetOp.getSequence()>1) {
GeneticDecoder decoder = prepareDecodePass(chromosome, baseTime, globalParam, baseMaterialsSnapshot, true);
decoder.decode(chromosome,false);
PostEditJitService postEditJitService = new PostEditJitService();
try {
if (postEditJitService.applyPostEditJitBias(chromosome, globalParam)) {
chromosome.setResultOld(ProductionDeepCopyUtil.deepCopyList(chromosome.getResult(),GAScheduleResult.class));
decoder = prepareDecodePass(chromosome, baseTime, globalParam, baseMaterialsSnapshot, false);
decoder.decode(chromosome,false, false);
}
} finally {
postEditJitService.clearTemporaryJitBias(chromosome);
}
KpiCalculator kpiCalculator=new KpiCalculator(chromosome);
kpiCalculator.calculatekpi();
......
......@@ -264,7 +264,7 @@ public class PlanResultService {
throw new BusinessException("排产计算结果保存失败,请稍后重试或联系管理员");
}
WriteScheduleSummary(chromosome);
// WriteScheduleSummary(chromosome);
return chromosome;
......
......@@ -40,7 +40,7 @@ public class PlanResultServiceTest {
// sortService.test1();
// nsgaiiUtils.Test();
planResultService.execute2("6D7C59CF2576457EBCB5F6CCDF5AF342");//2000
// planResultService.execute2("6D7C59CF2576457EBCB5F6CCDF5AF342");//2000
// planResultService.execute2("15210B13B88A453F8B84AAC7F16C7541");//2000
......@@ -48,7 +48,7 @@ public class PlanResultServiceTest {
// planResultService.execute2("E2CD1FC6FF9B4B19A59FEC7F846D4952");//600
// planResultService.execute2("EAF3C94B8F3345278F226C94FB0FED86");//bom
// planResultService.execute2("6D63146BE5C84A78B5AB044327BA55BD");//2000
// planResultService.execute2("6D63146BE5C84A78B5AB044327BA55BD");//5000
planResultService.execute2("6D63146BE5C84A78B5AB044327BA55BD");//5000
// planResultService.execute2("C8B533BD8944405B9A2F8823C575C204");//500
// planResultService.execute2("EFDD34E4B5BC434BAEAE6A84DFCD4E7B");//20
// planResultService.execute2("00E0C5D3E4AD4F36B56C39395906618D");
......
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