Commit 57cd90f1 authored by Tong Li's avatar Tong Li

1、物料约束不勾选,则采购检验时长为0

2、如果采购订单到货时间晚于基准日期+采购,检验时长,则不使用
3、瓶颈设备瓶颈工序过滤掉无限产能设备
parent 9d489cbf
...@@ -24,6 +24,11 @@ public class GAScheduleResult { ...@@ -24,6 +24,11 @@ public class GAScheduleResult {
private String productName; private String productName;
private String productCode; private String productCode;
private long MachineId; private long MachineId;
/**
* 设备类型
*
*/
private String capacityTypeName;
private int StartTime; // 相对开始时间(秒) private int StartTime; // 相对开始时间(秒)
private int EndTime; // 相对结束时间(秒) private int EndTime; // 相对结束时间(秒)
private int teardownTime; //后处理 private int teardownTime; //后处理
......
...@@ -507,7 +507,8 @@ public class GeneticDecoder { ...@@ -507,7 +507,8 @@ public class GeneticDecoder {
boolean isJit=_globalParam.isJit(); boolean isJit=_globalParam.isJit();
if (rebuildStructureForCurrentDecode) {
if (rebuildStructureForCurrentDecode&&_globalParam.isIsCheckSf()) {
long t1 = System.nanoTime(); long t1 = System.nanoTime();
//创建半成品订单 //创建半成品订单
materialRequirementService.buildMultiLevelRequirementNetwork(chromosome, sceneId, baseTime,_globalParam); materialRequirementService.buildMultiLevelRequirementNetwork(chromosome, sceneId, baseTime,_globalParam);
...@@ -686,6 +687,10 @@ public class GeneticDecoder { ...@@ -686,6 +687,10 @@ public class GeneticDecoder {
int scheduledCount = orderProcessCounter.get(groupId); int scheduledCount = orderProcessCounter.get(groupId);
if(groupId==51)
{
int k=0;
}
List<Entry> orderOps=new ArrayList<>(); List<Entry> orderOps=new ArrayList<>();
...@@ -730,7 +735,7 @@ public class GeneticDecoder { ...@@ -730,7 +735,7 @@ public class GeneticDecoder {
} else { } else {
orderAnchor = bom.computeSemiFinishedAnchor(this, groupId, entrysBygroupId, orderAnchor = bom.computeSemiFinishedAnchor(this, groupId, entrysBygroupId,
opMachineKeyMap, chromosome, opMachineKeyMap, chromosome,
scheduleIndexById, machineTasksCache, machineIdMap, entryIndexById); scheduleIndexById, machineTasksCache, machineIdMap, entryIndexById,_globalParam.isIsCheckMp());
if (orderAnchor < 0) { if (orderAnchor < 0) {
orderIsJit = false; orderIsJit = false;
orderSchedulingInfo.put(groupId, orderSchedulingInfo.put(groupId,
...@@ -1619,7 +1624,7 @@ public class GeneticDecoder { ...@@ -1619,7 +1624,7 @@ public class GeneticDecoder {
} }
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);
result.setCapacityTypeName(machine.getCapacityTypeName());
if(islockMachineTime) { if(islockMachineTime) {
chromosome.getResult().add(result); chromosome.getResult().add(result);
machine.setLastGene(result); machine.setLastGene(result);
...@@ -1648,7 +1653,7 @@ public class GeneticDecoder { ...@@ -1648,7 +1653,7 @@ public class GeneticDecoder {
if (needMaterialCheck&&islockMachineTime) { if (needMaterialCheck&&islockMachineTime) {
if(!isJit) { if(!isJit) {
//正排获取半成品结束时间,如果没有半成品获取原材料时间 //正排获取半成品结束时间,如果没有半成品获取原材料时间
bomtime = getOperationBOMTime(operation, chromosome, earliestStartTime, 2); bomtime = getOperationBOMTime(operation, chromosome, earliestStartTime, 2,_globalParam.isIsCheckMp());
earliestStartTime = Math.max(earliestStartTime, bomtime); earliestStartTime = Math.max(earliestStartTime, bomtime);
//倒排需要工序排完再验证原材料,保证bom供应商就行 //倒排需要工序排完再验证原材料,保证bom供应商就行
// FileHelper.writeLogFile("工序:"+operation.getId()+ "BOMTIME:"+bomtime); // FileHelper.writeLogFile("工序:"+operation.getId()+ "BOMTIME:"+bomtime);
...@@ -1803,7 +1808,7 @@ public class GeneticDecoder { ...@@ -1803,7 +1808,7 @@ public class GeneticDecoder {
if(maxPurchase>startTime) if(maxPurchase>startTime)
{ {
int bomtime1 = getOperationBOMTime(operation, chromosome, startTime, 3); int bomtime1 = getOperationBOMTime(operation, chromosome, startTime, 3,_globalParam.isIsCheckMp());
if(bomtime1>startTime) if(bomtime1>startTime)
{ {
if (isJit && islockMachineTime) { if (isJit && islockMachineTime) {
...@@ -1835,7 +1840,7 @@ public class GeneticDecoder { ...@@ -1835,7 +1840,7 @@ 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);
result.setCapacityTypeName(machine.getCapacityTypeName());
// System.out.println("huanxingshijian="+result.getChangeOverTime()+"-------------------"+result.getOrderId()+"--------"+result.getExecId()+"---------"+prev.getOrderId()+"--------"+prev.getExecId()); // System.out.println("huanxingshijian="+result.getChangeOverTime()+"-------------------"+result.getOrderId()+"--------"+result.getExecId()+"---------"+prev.getOrderId()+"--------"+prev.getExecId());
if (islockMachineTime) if (islockMachineTime)
...@@ -2460,7 +2465,7 @@ if(geneDetails!=null&&geneDetails.size()>0) ...@@ -2460,7 +2465,7 @@ if(geneDetails!=null&&geneDetails.size()>0)
* 汇总当前工序的物料约束,返回所有原料/半成品中最晚满足的那个时刻。 * 汇总当前工序的物料约束,返回所有原料/半成品中最晚满足的那个时刻。
* 返回值含义是“这道工序最早允许因物料而开工的秒数”。 * 返回值含义是“这道工序最早允许因物料而开工的秒数”。
*/ */
private int getOperationBOMTime(Entry currentOp, Chromosome chromosome,int estimatedStartTime,int bomtype) { private int getOperationBOMTime(Entry currentOp, Chromosome chromosome,int estimatedStartTime,int bomtype,boolean isCheckMp ) {
List<OrderMaterialRequirement> opboms= currentOp.getMaterialRequirements(); List<OrderMaterialRequirement> opboms= currentOp.getMaterialRequirements();
//if(opboms==null||!_globalParam.isIsCheckMp()) //if(opboms==null||!_globalParam.isIsCheckMp())
...@@ -2536,8 +2541,9 @@ if(geneDetails!=null&&geneDetails.size()>0) ...@@ -2536,8 +2541,9 @@ if(geneDetails!=null&&geneDetails.size()>0)
totalNeededByMaterial.put(req.getMaterialId(), reqq1); totalNeededByMaterial.put(req.getMaterialId(), reqq1);
} }
} }
List<OrderMaterialRequirement> remove=new ArrayList<>(); List<OrderMaterialRequirement> remove=new ArrayList<>();
materialRequirementService.CalBom(chromosome,0, totalNeededByMaterial,chromosome.getMaterials(),baseTime.plusSeconds(estimatedStartTime) ,false,remove,null,false); materialRequirementService.CalBom(chromosome,0, totalNeededByMaterial,chromosome.getMaterials(),baseTime.plusSeconds(estimatedStartTime) ,false,remove,null,false, isCheckMp);
Optional<LocalDateTime> rawDateOpt = totalNeededByMaterial.values().stream() Optional<LocalDateTime> rawDateOpt = totalNeededByMaterial.values().stream()
.map(OrderMaterialRequirement::getUseTime) .map(OrderMaterialRequirement::getUseTime)
...@@ -2590,7 +2596,7 @@ if(geneDetails!=null&&geneDetails.size()>0) ...@@ -2590,7 +2596,7 @@ if(geneDetails!=null&&geneDetails.size()>0)
} }
} }
List<OrderMaterialRequirement> remove=new ArrayList<>(); List<OrderMaterialRequirement> remove=new ArrayList<>();
materialRequirementService.CalBom(chromosome,0, totalNeededByMaterial,chromosome.getMaterials(),baseTime.plusSeconds(estimatedStartTime) ,false,remove,null,false); materialRequirementService.CalBom(chromosome,0, totalNeededByMaterial,chromosome.getMaterials(),baseTime.plusSeconds(estimatedStartTime) ,false,remove,null,false, isCheckMp);
Optional<LocalDateTime> rawDateOpt = totalNeededByMaterial.values().stream() Optional<LocalDateTime> rawDateOpt = totalNeededByMaterial.values().stream()
.map(OrderMaterialRequirement::getUseTime) .map(OrderMaterialRequirement::getUseTime)
......
...@@ -36,7 +36,7 @@ public class GeneticDecoderBom { ...@@ -36,7 +36,7 @@ public class GeneticDecoderBom {
Map<String, OpMachine> opMachineKeyMap, Map<String, OpMachine> opMachineKeyMap,
Chromosome chromosome, Chromosome chromosome,
Map<Integer, GAScheduleResult> scheduleIndexById, Map<Integer, GAScheduleResult> scheduleIndexById,
Map<Long, CopyOnWriteArrayList<GAScheduleResult>> machineTasksCache,Map<Long, Machine> machineIdMap,Map<Integer, Entry> entryIndexById) { Map<Long, CopyOnWriteArrayList<GAScheduleResult>> machineTasksCache,Map<Long, Machine> machineIdMap,Map<Integer, Entry> entryIndexById,boolean isCheckMp) {
List<Entry> semiOps = entrysBygroupId.get(semiGroupId); List<Entry> semiOps = entrysBygroupId.get(semiGroupId);
if (semiOps == null || semiOps.isEmpty()) return 0; if (semiOps == null || semiOps.isEmpty()) return 0;
...@@ -70,7 +70,7 @@ public class GeneticDecoderBom { ...@@ -70,7 +70,7 @@ public class GeneticDecoderBom {
chainGroupIds.add(targetGroupId); chainGroupIds.add(targetGroupId);
rootStart = correctByRawMaterialStockForChain(chainGroupIds,targetGroupId,targetOpId, rootStart = correctByRawMaterialStockForChain(chainGroupIds,targetGroupId,targetOpId,
rootStart, entrysBygroupId,chromosome); rootStart, entrysBygroupId,chromosome,isCheckMp);
int anchor = rootStart; int anchor = rootStart;
// FileHelper.writeLogFile(" 成品开始 "+targetGroupId+" : "+rootStart); // FileHelper.writeLogFile(" 成品开始 "+targetGroupId+" : "+rootStart);
...@@ -299,7 +299,7 @@ if(isJit) ...@@ -299,7 +299,7 @@ if(isJit)
private int correctByRawMaterialStockForChain(List<Integer> chainGroupIds,int pfGroupId,int pfOpId, private int correctByRawMaterialStockForChain(List<Integer> chainGroupIds,int pfGroupId,int pfOpId,
int estimatedStartTime, int estimatedStartTime,
Map<Integer, List<Entry>> entrysBygroupId, Map<Integer, List<Entry>> entrysBygroupId,
Chromosome chromosome) { Chromosome chromosome,boolean isCheckMp) {
TreeMap<String, Material> materials = chromosome.getMaterials(); TreeMap<String, Material> materials = chromosome.getMaterials();
if (materials == null || materials.isEmpty()) return estimatedStartTime; if (materials == null || materials.isEmpty()) return estimatedStartTime;
...@@ -339,7 +339,7 @@ if(isJit) ...@@ -339,7 +339,7 @@ if(isJit)
} }
if(totalNeededByMaterial!=null&&totalNeededByMaterial.size()>0) { if(totalNeededByMaterial!=null&&totalNeededByMaterial.size()>0) {
//结合库存计算半成品生产数量,因为可能会修改生产数量所以和原材料分开 //结合库存计算半成品生产数量,因为可能会修改生产数量所以和原材料分开
materialRequirementService.CalBom(chromosome, 0, totalNeededByMaterial, materials, baseTime.plusSeconds(estimatedStartTime), false, remove, entrysBygroupId, true); materialRequirementService.CalBom(chromosome, 0, totalNeededByMaterial, materials, baseTime.plusSeconds(estimatedStartTime), false, remove, entrysBygroupId, true,isCheckMp);
} }
totalNeededByMaterial.clear(); totalNeededByMaterial.clear();
for (int groupId : chainGroupIds) { for (int groupId : chainGroupIds) {
...@@ -379,7 +379,7 @@ if(isJit) ...@@ -379,7 +379,7 @@ if(isJit)
} }
LocalDateTime estimatedStartTime1= materialRequirementService.CalBom(chromosome,0, totalNeededByMaterial,materials,baseTime.plusSeconds(estimatedStartTime) ,false,remove,entrysBygroupId,false); LocalDateTime estimatedStartTime1= materialRequirementService.CalBom(chromosome,0, totalNeededByMaterial,materials,baseTime.plusSeconds(estimatedStartTime) ,false,remove,entrysBygroupId,false,isCheckMp);
int rawTime = (int) Duration.between(baseTime, estimatedStartTime1).getSeconds(); int rawTime = (int) Duration.between(baseTime, estimatedStartTime1).getSeconds();
return Math.max(estimatedStartTime, rawTime); return Math.max(estimatedStartTime, rawTime);
...@@ -419,7 +419,7 @@ int start=Integer.MAX_VALUE; ...@@ -419,7 +419,7 @@ int start=Integer.MAX_VALUE;
// 成品还没排(不应该发生在JIT模式),降级为原有逻辑 // 成品还没排(不应该发生在JIT模式),降级为原有逻辑
return computeSemiFinishedAnchor(decoder, semiOrderId, entrysBygroupId, return computeSemiFinishedAnchor(decoder, semiOrderId, entrysBygroupId,
opMachineKeyMap, chromosome, scheduleIndexById, machineTasksCache, opMachineKeyMap, chromosome, scheduleIndexById, machineTasksCache,
machineIdMap, entryIndexById); machineIdMap, entryIndexById,_globalParam.isIsCheckMp());
} }
......
...@@ -453,7 +453,22 @@ public class SimulatedAnnealing { ...@@ -453,7 +453,22 @@ public class SimulatedAnnealing {
} }
log(String.format("模拟退火 - kpi:%s", fitness),true); log(String.format("模拟退火 - kpi:%s", fitness),true);
if(chromosome.getMakespan()!=0) {
FileHelper.writeLogFile(String.format("模拟退火 - kpi-Makespan: %f", chromosome.getMakespan()));
}
if(chromosome.getDelayTime()!=0) {
FileHelper.writeLogFile(String.format("模拟退火 - kpi-DelayTime: %f", chromosome.getDelayTime()));
}
if(chromosome.getTotalChangeoverTime()!=0) {
FileHelper.writeLogFile(String.format("模拟退火 - kpi-ChangeoverTime: %f", chromosome.getTotalChangeoverTime()));
}
if(chromosome.getMachineLoadStd()!=0) {
FileHelper.writeLogFile(String.format("模拟退火 - kpi-MachineLoad: %f", chromosome.getMachineLoadStd()));
}
if(chromosome.getTotalFlowTime()!=0) {
FileHelper.writeLogFile(String.format("模拟退火 - kpi-FlowTime: %f", chromosome.getTotalFlowTime()));
}
} }
/** /**
......
...@@ -239,7 +239,22 @@ public class TabuSearch { ...@@ -239,7 +239,22 @@ public class TabuSearch {
} }
log(String.format("禁忌搜索 - kpi:%s", fitness),true); log(String.format("禁忌搜索 - kpi:%s", fitness),true);
if(chromosome.getMakespan()!=0) {
FileHelper.writeLogFile(String.format("禁忌搜索 - kpi-Makespan: %f", chromosome.getMakespan()));
}
if(chromosome.getDelayTime()!=0) {
FileHelper.writeLogFile(String.format("禁忌搜索 - kpi-DelayTime: %f", chromosome.getDelayTime()));
}
if(chromosome.getTotalChangeoverTime()!=0) {
FileHelper.writeLogFile(String.format("禁忌搜索 - kpi-ChangeoverTime: %f", chromosome.getTotalChangeoverTime()));
}
if(chromosome.getMachineLoadStd()!=0) {
FileHelper.writeLogFile(String.format("禁忌搜索 - kpi-MachineLoad: %f", chromosome.getMachineLoadStd()));
}
if(chromosome.getTotalFlowTime()!=0) {
FileHelper.writeLogFile(String.format("禁忌搜索 - kpi-FlowTime: %f", chromosome.getTotalFlowTime()));
}
} }
/** /**
* 记录禁忌搜索改进详情 * 记录禁忌搜索改进详情
......
...@@ -190,7 +190,7 @@ public class PlanResultService { ...@@ -190,7 +190,7 @@ public class PlanResultService {
try { try {
ScheduleParams param = InitScheduleParams(); ScheduleParams param = InitScheduleParams();
// param.setBaseTime(LocalDateTime.of(2026, 5, 20, 0, 0, 0)); param.setBaseTime(LocalDateTime.of(2026, 5, 20, 0, 0, 0));
this.baseTime=param.getBaseTime(); this.baseTime=param.getBaseTime();
// 策略读取入口:优先使用前端传入的 userId;没传时用 sceneId 查场景创建人。 // 策略读取入口:优先使用前端传入的 userId;没传时用 sceneId 查场景创建人。
Long effectiveUserId = scheduleStrategyService.resolveScheduleUserId(SceneId, userId); Long effectiveUserId = scheduleStrategyService.resolveScheduleUserId(SceneId, userId);
...@@ -298,7 +298,7 @@ public class PlanResultService { ...@@ -298,7 +298,7 @@ public class PlanResultService {
throw new BusinessException("排产计算结果保存失败,请稍后重试或联系管理员"); throw new BusinessException("排产计算结果保存失败,请稍后重试或联系管理员");
} }
// WriteScheduleSummary(chromosome); WriteScheduleSummary(chromosome);
return chromosome; return chromosome;
...@@ -1781,6 +1781,14 @@ public class PlanResultService { ...@@ -1781,6 +1781,14 @@ public class PlanResultService {
_sceneService.saveChromosomeToFile(chromosome, SceneId); _sceneService.saveChromosomeToFile(chromosome, SceneId);
return chromosome; return chromosome;
} }
public void redecode(String SceneId) {
Chromosome chromosome= _sceneService.loadChromosomeFromFile(SceneId);
ScheduleOperationService ScheduleOperation=new ScheduleOperationService(materialRequirementService,this);
GlobalParam globalParam = buildGlobalParamFromSnapshot(SceneId, chromosome);
ScheduleOperation.redecode(chromosome, chromosome.getBaseTime(), globalParam);
}
/** /**
* 插单功能:在指定订单后插入新订单 * 插单功能:在指定订单后插入新订单
......
...@@ -42,8 +42,8 @@ public class PlanResultServiceTest { ...@@ -42,8 +42,8 @@ public class PlanResultServiceTest {
// nsgaiiUtils.Test(); // nsgaiiUtils.Test();
// planResultService.execute2("64E64F6B68094AF38CEDC418630C3CC2");//2000 // planResultService.execute2("64E64F6B68094AF38CEDC418630C3CC2");//2000
// planResultService.execute2("E1448B3C9C8743DEAB39708F2CFE348A");//倒排bomces // planResultService.execute2("E1448B3C9C8743DEAB39708F2CFE348A");//倒排bomces
planResultService.execute2("197083D0D26A449EB179AC103C753FD3"); planResultService.execute2("197083D0D26A449EB179AC103C753FD3");
// planResultService.execute2("9FEDFD92BB6A4675BF9B1CC64505D1AB"); // planResultService.execute2("9FEDFD92BB6A4675BF9B1CC64505D1AB");
// planResultService.execute2("15210B13B88A453F8B84AAC7F16C7541");//2000 // planResultService.execute2("15210B13B88A453F8B84AAC7F16C7541");//2000
...@@ -72,7 +72,7 @@ public class PlanResultServiceTest { ...@@ -72,7 +72,7 @@ public class PlanResultServiceTest {
// planResultService.AddMaintenanceWindow("5475E00B844847ACB6DC20227967BA2F",2488l,maintenanceWindow); // planResultService.AddMaintenanceWindow("5475E00B844847ACB6DC20227967BA2F",2488l,maintenanceWindow);
// // planResultService.DelOperation("B6AE363FF5044DDF8DECE32D5FE0F7EA",7); // // planResultService.DelOperation("B6AE363FF5044DDF8DECE32D5FE0F7EA",7);
// planResultService.SpiltOperation("92BB773E1E2447C99D8176C991D5C9D2",1,new Double[]{50d, 50d}); // planResultService.SpiltOperation("92BB773E1E2447C99D8176C991D5C9D2",1,new Double[]{50d, 50d});
// planResultService.SpiltOrder("A41D662EE0764D008173C5A0E42B15F6","5f9d5383-b89a-4a4f-8805-2f617c711968",new Double[]{500d, 500d}); // planResultService.redecode("0785676B4E5E40CDAA62AA320CFC958C");
} }
@Test @Test
......
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