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

Merge remote-tracking branch 'origin/master'

parents 65fd45ea 1bf5a775
This diff is collapsed.
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<>();
......
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