Browse Source

排程优化-退火合并优化

fangpy 6 tháng trước cách đây
mục cha
commit
bf2e9e7041

+ 38 - 30
rw-aps-server/src/main/java/com/rongwei/rwapsserver/aps/score/ApsConstraintProvider.java

@@ -892,7 +892,7 @@ public class ApsConstraintProvider implements ConstraintProvider {
             equipment = processes.get(0).getEquipment();
             apsNochangeRollerDos = processes.get(0).getApsOverallConfig().getApsNochangeRollerDos();
         }
-        if(processes.size() == 7){
+        if(processes.size() == 1 && processes.get(0).getId().equals("f391376a40da481ab92e219a6a933a9b") && processes.get(0).getDelay() == 47 && equipment.getId().equals("0001be252874536843730b100151")){
             int a = 0;
         }
         List<ProductionProcesses> hasStartTimeProcess = processes.stream().filter(v -> v.getStartTime() != null).collect(Collectors.toList());
@@ -911,6 +911,7 @@ public class ApsConstraintProvider implements ConstraintProvider {
                 pp.setProduceTime(equipmentRunTime.getOnceprocessmin());
                 pp.setSinglerollweight(equipmentRunTime.getTotalSinglerollweight());
                 pp.setLastSerialLbWeight(equipmentRunTime.getLastSerialLbWeight());
+                pp.setProZg(equipmentRunTime.getZjgid());
                 hasStartTimeProcess.add(pp);
             }
         }
@@ -927,6 +928,7 @@ public class ApsConstraintProvider implements ConstraintProvider {
             pp.setProduceTime(equipment.getOnceprocessmin());
             pp.setConflictRoptions(new HashMap<>());
             pp.setLastSerialLbWeight(equipment.getLastSerialLbWeight());
+            pp.setProZg(equipment.getLastZjgid());
             hasStartTimeProcess.add(0,pp);
         }
         for(int i=0;i<hasStartTimeProcess.size()-1;i++){
@@ -1015,11 +1017,22 @@ public class ApsConstraintProvider implements ConstraintProvider {
                             }
                         }
                     }
-                } else if ("冷轧".equals(hasStartTimeProcess.get(i).getProcessType())) {
+                } else if ("冷轧".equals(hasStartTimeProcess.get(i).getProcessType()) || "箔轧".equals(hasStartTimeProcess.get(i).getProcessType())) {
+                    ProductionProcesses prepro = hasStartTimeProcess.get(i);
+                    ProductionProcesses nextpro = hasStartTimeProcess.get(i+1);
                     String[] serspre = hasStartTimeProcess.get(i).getSeriesProduceMark().split("\\^_\\^");
                     String[] sersafter = hasStartTimeProcess.get(i+1).getSeriesProduceMark().split("\\^_\\^");
-                    if(serspre.length == 5 && sersafter.length == 5){
-                        if(!serspre[0].equals(sersafter[0]) || !serspre[1].equals(sersafter[1])){
+                    // 前道工序宽度、输入物料厚度、输出物料厚度
+                    String s1 = serspre[2];
+                    // 后道工序宽度、输入物料厚度、输出物料厚度
+                    String s2 = sersafter[2];
+                    BigDecimal i1 = new BigDecimal(s1);
+                    BigDecimal i2 = new BigDecimal(s2);
+                    // 前后道所属作业ID
+                    if(StrUtil.isNotBlank(prepro.getProZg()) && StrUtil.isNotBlank(nextpro.getProZg())){
+                        String preZg = prepro.getProZg();
+                        String nextZg = nextpro.getProZg();
+                        if(!preZg.equals(nextZg)){
                             if(hasStartTimeProcess.get(i).getEndTime().plusMinutes(hasStartTimeProcess.get(i).getCutfinishmin())
                                     .plusMinutes(hasStartTimeProcess.get(i+1).getPrepressworkmin()).compareTo(hasStartTimeProcess.get(i+1).getStartTime())>0){
                                 b++;
@@ -1027,11 +1040,19 @@ public class ApsConstraintProvider implements ConstraintProvider {
                                 conflictRoptions2.put("hard-seriesProduceTimeWait","和上道工序没有预留足够的上机准备时间和下机收尾时间");
                             }
                         }else{
-                            String s1 = serspre[2];
-                            String s2 = sersafter[2];
+                            if(i1.compareTo(i2)<0){
+                                if(hasStartTimeProcess.get(i).getEndTime().plusMinutes(hasStartTimeProcess.get(i).getCutfinishmin())
+                                        .plusMinutes(hasStartTimeProcess.get(i+1).getPrepressworkmin()).compareTo(hasStartTimeProcess.get(i+1).getStartTime())>0){
+                                    b++;
+                                    conflictRoptions1.put("hard-seriesProduceTimeWait","和下道工序没有预留足够的上机准备时间和下机收尾时间");
+                                    conflictRoptions2.put("hard-seriesProduceTimeWait","和上道工序没有预留足够的上机准备时间和下机收尾时间");
+                                }
+                            }
+                        }
+                    }else{
+                        if(serspre.length == 5 && sersafter.length == 5){
                             try{
-                                BigDecimal i1 = new BigDecimal(s1);
-                                BigDecimal i2 = new BigDecimal(s2);
+                                // 后端工序大于前道工序,并且大于30mm
                                 if(i1.compareTo(i2)<0){
                                     if(hasStartTimeProcess.get(i).getEndTime().plusMinutes(hasStartTimeProcess.get(i).getCutfinishmin())
                                             .plusMinutes(hasStartTimeProcess.get(i+1).getPrepressworkmin()).compareTo(hasStartTimeProcess.get(i+1).getStartTime())>0){
@@ -1039,34 +1060,21 @@ public class ApsConstraintProvider implements ConstraintProvider {
                                         conflictRoptions1.put("hard-seriesProduceTimeWait","和下道工序没有预留足够的上机准备时间和下机收尾时间");
                                         conflictRoptions2.put("hard-seriesProduceTimeWait","和上道工序没有预留足够的上机准备时间和下机收尾时间");
                                     }
+                                }else{
+                                    if(!serspre[1].equals(sersafter[1])){
+                                        if(hasStartTimeProcess.get(i).getEndTime().plusMinutes(hasStartTimeProcess.get(i).getCutfinishmin())
+                                                .plusMinutes(hasStartTimeProcess.get(i+1).getPrepressworkmin()).compareTo(hasStartTimeProcess.get(i+1).getStartTime())>0){
+                                            b++;
+                                            conflictRoptions1.put("hard-seriesProduceTimeWait","和下道工序没有预留足够的上机准备时间和下机收尾时间");
+                                            conflictRoptions2.put("hard-seriesProduceTimeWait","和上道工序没有预留足够的上机准备时间和下机收尾时间");
+                                        }
+                                    }
                                 }
                             }catch (Exception e){
                                 e.printStackTrace();
                             }
                         }
                     }
-                }else if ("箔轧".equals(hasStartTimeProcess.get(i).getProcessType())) {
-                    // 宽度从大到小
-                    String[] serspre = hasStartTimeProcess.get(i).getSeriesProduceMark().split("\\^_\\^");
-                    String[] sersafter = hasStartTimeProcess.get(i+1).getSeriesProduceMark().split("\\^_\\^");
-                    if(serspre.length == 5 && sersafter.length == 5){
-                        String s1 = serspre[2];
-                        String s2 = sersafter[2];
-                        try {
-                            BigDecimal volumeWidth = new BigDecimal(s1);
-                            BigDecimal volumeWidth1 = new BigDecimal(s2);
-                            if(volumeWidth.compareTo(volumeWidth1)<0){
-                                if(hasStartTimeProcess.get(i).getEndTime().plusMinutes(hasStartTimeProcess.get(i).getCutfinishmin())
-                                        .plusMinutes(hasStartTimeProcess.get(i+1).getPrepressworkmin()).compareTo(hasStartTimeProcess.get(i+1).getStartTime())>0){
-                                    b++;
-                                    conflictRoptions1.put("hard-seriesProduceTimeWait","和下道工序没有预留足够的上机准备时间和下机收尾时间");
-                                    conflictRoptions2.put("hard-seriesProduceTimeWait","和上道工序没有预留足够的上机准备时间和下机收尾时间");
-                                }
-                            }
-                        }catch (Exception e){
-                            e.printStackTrace();
-                        }
-                    }
                 }
             }
         }

+ 20 - 18
rw-aps-server/src/main/java/com/rongwei/rwapsserver/aps/service/impl/ApsServiceImpl.java

@@ -392,7 +392,22 @@ public class ApsServiceImpl implements ApsService {
                 thpros.add(process);
                 thGroup.put(thkey,thpros);
             }
+            // 先全部还原退火的关联关系
+            List<ProductionProcesses> collect = apsSolution.getProcessesList().stream().filter(vp -> vp.getId().equals(process.getId())).collect(Collectors.toList());
+            if(collect != null && collect.size()>0){
+                for (ProductionProcesses productionProcesses : collect) {
+                    if(productionProcesses.getRooprocess() != null){
+                        productionProcesses.getApsOverallConfig().setStartTime(productionProcesses.getRooprocess().getApsOverallConfig().getStartTime());
+                    }
+                    if(relPros.containsKey(productionProcesses.getId())){
+                        Map<String, List<ProductionProcesses>> stringListMap = relPros.get(productionProcesses.getId());
+                        productionProcesses.setPreviousProcesses(stringListMap.get("pres"));
+                        productionProcesses.setNextProcesses(stringListMap.get("nexts"));
+                    }
+                }
+            }
         }
+
         thGroup.forEach((k,v)->{
             Set<String> orderids = new HashSet<>();
             for (ProductionProcesses productionProcesses : v) {
@@ -403,6 +418,7 @@ public class ApsServiceImpl implements ApsService {
             List<String> orderidlist = new ArrayList<>();
             orderidlist.addAll(orderids);
             ordergrous.put(k,orderidlist);
+
             if(orderids.size()>1){
                 /*List<EquipmentRunTime> equipmentRunTimes = new ArrayList<>();
                 for (ProductionProcesses process : v) {
@@ -476,7 +492,9 @@ public class ApsServiceImpl implements ApsService {
                 if(mainTh.getNextProcesses() != null && mainTh.getNextProcesses().size()>0){
                     for (ProductionProcesses productionProcesses : mainTh.getNextProcesses()) {
                         if(productionProcesses.getProcessCategory() != null && "40".equals(productionProcesses.getProcessCategory())
-                                && (productionProcesses.getNextProcesses() == null || productionProcesses.getNextProcesses().size() == 0)){
+                                && (productionProcesses.getNextProcesses() == null || productionProcesses.getNextProcesses().size() == 0)
+                                && !productionProcesses.getIfLock()
+                        ){
                             lastProMerge.add(productionProcesses);
                         }
                     }
@@ -559,22 +577,6 @@ public class ApsServiceImpl implements ApsService {
                 }
                 // 退火前一道工序合并
 
-            }else{
-                for (ProductionProcesses process : v) {
-                    List<ProductionProcesses> collect = apsSolution.getProcessesList().stream().filter(vp -> vp.getId().equals(process.getId())).collect(Collectors.toList());
-                    if(collect != null && collect.size()>0){
-                        for (ProductionProcesses productionProcesses : collect) {
-                            if(productionProcesses.getRooprocess() != null){
-                                productionProcesses.getApsOverallConfig().setStartTime(productionProcesses.getRooprocess().getApsOverallConfig().getStartTime());
-                            }
-                            if(relPros.containsKey(productionProcesses.getId())){
-                                Map<String, List<ProductionProcesses>> stringListMap = relPros.get(productionProcesses.getId());
-                                productionProcesses.setPreviousProcesses(stringListMap.get("pres"));
-                                productionProcesses.setNextProcesses(stringListMap.get("nexts"));
-                            }
-                        }
-                    }
-                }
             }
         });
     }
@@ -642,7 +644,7 @@ public class ApsServiceImpl implements ApsService {
                             nextpro.setPreviousProcesses(nextprepros);
 
                             // 设置合并退火作业下一道工序
-                            thps.get(0).getNextProcessesIds().addAll(thps.get(i).getNextProcessesIds());
+                            thps.get(0).getNextProcessesIds().add(nextProcessesId);
                             List<ProductionProcesses> thnexts = new ArrayList<>();
                             for (String pid : thps.get(0).getNextProcessesIds()) {
                                 thnexts.add(allProMap.get(pid));

+ 34 - 1
rw-aps-server/src/main/java/com/rongwei/rwapsserver/aps/service/impl/ProductionScheduleServiceImpl.java

@@ -191,6 +191,22 @@ public class ProductionScheduleServiceImpl implements ProductionScheduleService
             }
         }
 
+        /*Map<String, List<ProductionProcesses>> orderProcess = apsSolution.getProcessesList().stream().collect(Collectors.groupingBy(ProductionProcesses::getOrderId));
+        orderProcess.forEach((m,n)->{
+            Collections.sort(n, Comparator.comparing(pro -> pro.getOrderMark()));
+            List<ProductionProcesses> roots = new ArrayList<>();
+            for (ProductionProcesses productionProcesses : n) {
+                if(productionProcesses.getPreviousProcesses() == null || productionProcesses.getPreviousProcesses().size() == 0){
+                    roots.add(productionProcesses);
+                }
+            }
+            for (ProductionProcesses root : roots) {
+                System.out.println("**********************************");
+                testOne(root);
+                System.out.println("**********************************");
+            }
+        });*/
+
         // 退火提前排序
         Map<String,List<String>> ordergrous = new HashMap<>();
         apsService.tuihuoApsSch(apsSolution,otherThproces,otherNotZzFirstProces,productionScheduleVo,ordergrous);
@@ -226,7 +242,15 @@ public class ProductionScheduleServiceImpl implements ProductionScheduleService
         List<String> thOrderids = new ArrayList<>();
         if(ordergrous != null && ordergrous.size()>0){
             for (CommonJavaBean cjb : orderMerges) {
-                List<String> v = cjb.getOrderids();
+                List<String> v = new ArrayList<>();
+                for (String orderid : cjb.getOrderids()) {
+                    if(!thOrderids.contains(orderid)){
+                        v.add(orderid);
+                    }
+                }
+                if(v.size() == 0){
+                    continue;
+                }
                 try{
                     log.info("分批排程开始,当前批次坯料计划ID:"+v);
                     ApsSolution apsSolution1 = new ApsSolution();
@@ -683,6 +707,15 @@ public class ProductionScheduleServiceImpl implements ProductionScheduleService
         return productionScheduleRetVo;
     }
 
+    private void testOne(ProductionProcesses root){
+        System.out.println(root.getId()+"-"+root.getOrderMark());
+        if(root.getNextProcesses() != null && root.getNextProcesses().size()>0){
+            for (ProductionProcesses nextProcess : root.getNextProcesses()) {
+                testOne(nextProcess);
+            }
+        }
+    }
+
     /**
      * 根据退火组炉合并待排程的坯料计划
      * @param ordergrous