|
@@ -1,5 +1,6 @@
|
|
|
package com.rongwei.rwapsserver.aps.service.impl;
|
|
|
|
|
|
+import cn.hutool.core.collection.CollUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import com.rongwei.rwapsserver.aps.domain.*;
|
|
|
import com.rongwei.rwapsserver.aps.score.ApsConstraintProvider;
|
|
@@ -188,7 +189,8 @@ public class ProductionScheduleServiceImpl implements ProductionScheduleService
|
|
|
}
|
|
|
}
|
|
|
// 退火提前排序
|
|
|
- apsService.tuihuoApsSch(apsSolution,otherThproces,otherNotZzFirstProces,productionScheduleVo);
|
|
|
+ Map<String,List<String>> ordergrous = new HashMap<>();
|
|
|
+ apsService.tuihuoApsSch(apsSolution,otherThproces,otherNotZzFirstProces,productionScheduleVo,ordergrous);
|
|
|
|
|
|
/*if(1 == 1){
|
|
|
return null;
|
|
@@ -209,7 +211,76 @@ public class ProductionScheduleServiceImpl implements ProductionScheduleService
|
|
|
//
|
|
|
// }
|
|
|
apsSolution.setProcessesList(notLocks);
|
|
|
- ApsSolution solvedBalance = solver.solve(apsSolution);
|
|
|
+
|
|
|
+ SolutionManager<ApsSolution, HardSoftScore> scoreManager = SolutionManager.create(solverFactory);
|
|
|
+ // 按照退火组炉分批排程
|
|
|
+ List<CommonJavaBean> orderMerges = produceOrderMerge(ordergrous,apsSolution);
|
|
|
+ Collections.sort(orderMerges, (pro1, pro2) -> {return pro2.getMaxVolumeWidth().compareTo(pro1.getMaxVolumeWidth());});
|
|
|
+ ApsSolution solvedBalance = new ApsSolution();
|
|
|
+ solvedBalance.setProcessesList(new ArrayList<>());
|
|
|
+ List<String> thOrderids = new ArrayList<>();
|
|
|
+ if(ordergrous != null && ordergrous.size()>0){
|
|
|
+ for (CommonJavaBean cjb : orderMerges) {
|
|
|
+ List<String> v = cjb.getOrderids();
|
|
|
+ ApsSolution apsSolution1 = new ApsSolution();
|
|
|
+ apsSolution1.setStartTime(apsSolution.getStartTime());
|
|
|
+ List<ProductionProcesses> processesList1 = apsSolution.getProcessesList().stream().filter(m -> v.contains(m.getProduceOrder().get(0).getId())).collect(Collectors.toList());
|
|
|
+ apsSolution1.setProcessesList(processesList1);
|
|
|
+ apsSolution1.setEquipmentList(apsSolution.getEquipmentList());
|
|
|
+ ApsSolution solvedBalance1 = solver.solve(apsSolution1);
|
|
|
+ log.info("**************排程评分分析***************");
|
|
|
+ ScoreExplanation<ApsSolution, HardSoftScore> explain = scoreManager.explain(solvedBalance1);
|
|
|
+ log.info(explain.toString());
|
|
|
+ log.info("**************排程评分分析***************");
|
|
|
+ productionScheduleRetVo.setScoreResult(scoreManager.explain(solvedBalance1).toString());
|
|
|
+ // 得分分析
|
|
|
+ softExplain(explain,solvedBalance1.getProcessesList());
|
|
|
+
|
|
|
+ solvedBalance.getProcessesList().addAll(solvedBalance1.getProcessesList());
|
|
|
+ thOrderids.addAll(v);
|
|
|
+
|
|
|
+ // 排程结束的数据手动添加到设备占用列表中
|
|
|
+ setEqRunTimes(solvedBalance1.getProcessesList());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 剩余数据按照坯料计划分组排程
|
|
|
+ List<ProductionProcesses> otherPros = apsSolution.getProcessesList().stream().filter(n -> !thOrderids.contains(n.getProduceOrder().get(0).getId())).collect(Collectors.toList());
|
|
|
+ if(otherPros != null && otherPros.size()>0){
|
|
|
+ Map<String, List<ProductionProcesses>> equass = new HashMap<>();
|
|
|
+ for (ProductionProcesses otherPro : otherPros) {
|
|
|
+ if(equass.containsKey(otherPro.getProduceOrder().get(0).getId())){
|
|
|
+ equass.get(otherPro.getProduceOrder().get(0).getId()).add(otherPro);
|
|
|
+ }else {
|
|
|
+ List<ProductionProcesses> p1 = new ArrayList<>();
|
|
|
+ p1.add(otherPro);
|
|
|
+ equass.put(otherPro.getProduceOrder().get(0).getId(),p1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(equass != null && equass.size()>0){
|
|
|
+ equass.forEach((k,processesList1)->{
|
|
|
+ ApsSolution apsSolution1 = new ApsSolution();
|
|
|
+ apsSolution1.setStartTime(apsSolution.getStartTime());
|
|
|
+ apsSolution1.setProcessesList(processesList1);
|
|
|
+ apsSolution1.setEquipmentList(apsSolution.getEquipmentList());
|
|
|
+ ApsSolution solvedBalance1 = solver.solve(apsSolution1);
|
|
|
+ log.info("**************排程评分分析***************");
|
|
|
+ ScoreExplanation<ApsSolution, HardSoftScore> explain = scoreManager.explain(solvedBalance1);
|
|
|
+ log.info(explain.toString());
|
|
|
+ log.info("**************排程评分分析***************");
|
|
|
+ productionScheduleRetVo.setScoreResult(scoreManager.explain(solvedBalance1).toString());
|
|
|
+ // 得分分析
|
|
|
+ softExplain(explain,solvedBalance1.getProcessesList());
|
|
|
+
|
|
|
+ solvedBalance.getProcessesList().addAll(solvedBalance1.getProcessesList());
|
|
|
+
|
|
|
+ // 排程结束的数据手动添加到设备占用列表中
|
|
|
+ setEqRunTimes(solvedBalance1.getProcessesList());
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /*ApsSolution solvedBalance = solver.solve(apsSolution);
|
|
|
log.info("**************排程评分分析***************");
|
|
|
SolutionManager<ApsSolution, HardSoftScore> scoreManager = SolutionManager.create(solverFactory);
|
|
|
ScoreExplanation<ApsSolution, HardSoftScore> explain = scoreManager.explain(solvedBalance);
|
|
@@ -217,7 +288,8 @@ public class ProductionScheduleServiceImpl implements ProductionScheduleService
|
|
|
log.info("**************排程评分分析***************");
|
|
|
productionScheduleRetVo.setScoreResult(scoreManager.explain(solvedBalance).toString());
|
|
|
// 得分分析
|
|
|
- softExplain(explain,solvedBalance.getProcessesList());
|
|
|
+ softExplain(explain,solvedBalance.getProcessesList());*/
|
|
|
+
|
|
|
// 最大等待时间冲突手动解决
|
|
|
/*List<ProductionProcesses> maxSetPros = new ArrayList<>();
|
|
|
for (ProductionProcesses productionProcesses : solvedBalance.getProcessesList()) {
|
|
@@ -259,7 +331,7 @@ public class ProductionScheduleServiceImpl implements ProductionScheduleService
|
|
|
}
|
|
|
}*/
|
|
|
|
|
|
- log.info("**************排程最终评分分析***************");
|
|
|
+ /*log.info("**************排程最终评分分析***************");
|
|
|
if(notLocks != null && notLocks.size()>0){
|
|
|
for (ProductionProcesses notLock : notLocks) {
|
|
|
for (ProductionProcesses productionProcesses : solvedBalance.getProcessesList()) {
|
|
@@ -288,7 +360,7 @@ public class ProductionScheduleServiceImpl implements ProductionScheduleService
|
|
|
log.info(explain2.toString());
|
|
|
log.info("**************排程最终评分分析***************");
|
|
|
productionScheduleRetVo.setScoreResult(explain2.toString());
|
|
|
- softExplain(explain2,solvedBalance.getProcessesList());
|
|
|
+ softExplain(explain2,solvedBalance.getProcessesList());*/
|
|
|
|
|
|
productionScheduleRetVo.setProcesses(solvedBalance.getProcessesList());
|
|
|
// 循环引用ProductionProcesses置空
|
|
@@ -474,6 +546,112 @@ public class ProductionScheduleServiceImpl implements ProductionScheduleService
|
|
|
return productionScheduleRetVo;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 根据退火组炉合并待排程的坯料计划
|
|
|
+ * @param ordergrous
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private List<CommonJavaBean> produceOrderMerge(Map<String,List<String>> ordergrous,ApsSolution apsSolution){
|
|
|
+ List<CommonJavaBean> resetIds = new ArrayList<>();
|
|
|
+ if(ordergrous != null && ordergrous.size()>0){
|
|
|
+ List<List<String>> allIds = new ArrayList<>();
|
|
|
+ ordergrous.forEach((k,v)->{
|
|
|
+ allIds.add(v);
|
|
|
+ });
|
|
|
+ listSet(allIds,resetIds,apsSolution);
|
|
|
+ }
|
|
|
+ return resetIds;
|
|
|
+ }
|
|
|
+
|
|
|
+ private void listSet(List<List<String>> allIds,List<CommonJavaBean> resetIds,ApsSolution apsSolution){
|
|
|
+ if(allIds != null && allIds.size()>0){
|
|
|
+ CommonJavaBean cjb = new CommonJavaBean();
|
|
|
+ if(allIds.size()>1){
|
|
|
+ List<String> fids = allIds.get(0);
|
|
|
+ List<List<String>> syids = new ArrayList<>();
|
|
|
+ for (int i = 1; i < allIds.size(); i++) {
|
|
|
+ List<String> iids = allIds.get(i);
|
|
|
+ boolean bl = CollUtil.containsAny(fids, iids);
|
|
|
+ if(bl){
|
|
|
+ CollUtil.addAllIfNotContains(fids,iids);
|
|
|
+ }else{
|
|
|
+ syids.add(iids);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ cjb.setOrderids(fids);
|
|
|
+ BigDecimal maxVolumeWidth = null;
|
|
|
+ for (String orderid : cjb.getOrderids()) {
|
|
|
+ List<ProductionProcesses> processes = apsSolution.getProcessesList().stream().filter(v ->
|
|
|
+ v.getProduceOrder().get(0).getId().equals(orderid)).collect(Collectors.toList());
|
|
|
+ ProductionProcesses productionProcesses = processes.get(0);
|
|
|
+ if(maxVolumeWidth == null){
|
|
|
+ maxVolumeWidth = productionProcesses.getVolumeWidth();
|
|
|
+ }else{
|
|
|
+ if(productionProcesses.getVolumeWidth().compareTo(maxVolumeWidth) > 0){
|
|
|
+ maxVolumeWidth = productionProcesses.getVolumeWidth();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ cjb.setMaxVolumeWidth(maxVolumeWidth);
|
|
|
+ resetIds.add(cjb);
|
|
|
+ listSet(syids,resetIds,apsSolution);
|
|
|
+ }else{
|
|
|
+ cjb.setOrderids(allIds.get(0));
|
|
|
+ BigDecimal maxVolumeWidth = null;
|
|
|
+ for (String orderid : cjb.getOrderids()) {
|
|
|
+ List<ProductionProcesses> processes = apsSolution.getProcessesList().stream().filter(v ->
|
|
|
+ v.getProduceOrder().get(0).getId().equals(orderid)).collect(Collectors.toList());
|
|
|
+ ProductionProcesses productionProcesses = processes.get(0);
|
|
|
+ if(maxVolumeWidth == null){
|
|
|
+ maxVolumeWidth = productionProcesses.getVolumeWidth();
|
|
|
+ }else{
|
|
|
+ if(productionProcesses.getVolumeWidth().compareTo(maxVolumeWidth) > 0){
|
|
|
+ maxVolumeWidth = productionProcesses.getVolumeWidth();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ cjb.setMaxVolumeWidth(maxVolumeWidth);
|
|
|
+ resetIds.add(cjb);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 排程结束数据手动添加到设备占用列表中
|
|
|
+ * @param pps
|
|
|
+ */
|
|
|
+ private void setEqRunTimes(List<ProductionProcesses> pps){
|
|
|
+ if(pps != null && pps.size()>0){
|
|
|
+ for (ProductionProcesses productionProcesses : pps) {
|
|
|
+ // 添加锁定工序设备占用时间
|
|
|
+ List<EquipmentRunTime> equipmentRunTimes = new ArrayList<>();
|
|
|
+ EquipmentRunTime pper = new EquipmentRunTime();
|
|
|
+ pper.setStartRunTime(productionProcesses.getStartTime());
|
|
|
+ pper.setEndRunTime(productionProcesses.getEndTime());
|
|
|
+ pper.setSeriesProduceMark(productionProcesses.getSeriesProduceMark());
|
|
|
+ pper.setProcessType(productionProcesses.getProcessType());
|
|
|
+ pper.setVolumeMetal(productionProcesses.getVolumeMetal());
|
|
|
+ pper.setTotalVolumeWidth(productionProcesses.getVolumeWidth());
|
|
|
+ pper.setTotalSinglerollweight(productionProcesses.getSinglerollweight());
|
|
|
+ pper.setTotalThickness(productionProcesses.getVolumeThickness());
|
|
|
+ pper.setProducttype(productionProcesses.getProducttype());
|
|
|
+ pper.setOnceprocessmin(productionProcesses.getProduceTime());
|
|
|
+ pper.setPcNum(productionProcesses.getOpeProducePcNum());
|
|
|
+ pper.setOccupyType("process");
|
|
|
+ equipmentRunTimes.add(pper);
|
|
|
+
|
|
|
+ if(equipmentRunTimes.size()>0){
|
|
|
+ if(productionProcesses.getEquipment().getEquipmentRunTimes() == null){
|
|
|
+ productionProcesses.getEquipment().setEquipmentRunTimes(equipmentRunTimes);
|
|
|
+ }else{
|
|
|
+ productionProcesses.getEquipment().getEquipmentRunTimes().addAll(equipmentRunTimes);
|
|
|
+ }
|
|
|
+ apsService.equipmentRunTimeMerge(productionProcesses.getEquipment(),productionProcesses.getApsOverallConfig().getFurnaceInstallations());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
private ProductionProcesses maxWaitTimeCheck(ProductionProcesses process,List<ProductionProcesses> maxSetPros,List<ProductionProcesses> processes,List<Equipment> equipments){
|
|
|
ProductionProcesses newPre = null;
|
|
|
List<ProductionProcesses> previousProcesses = process.getPreviousProcesses();
|