fangpengyuan před 4 měsíci
rodič
revize
3f427583d9

+ 17 - 3
rw-aps-server/src/main/java/com/rongwei/rwapsserver/aps/taskassigning/service/impl/ProductionScheduleTaServiceImpl.java

@@ -56,9 +56,14 @@ public class ProductionScheduleTaServiceImpl implements ProductionScheduleTaServ
     public ProductionScheduleRetTaVo productionSchedule(ProductionScheduleTaVo productionScheduleVo) throws Exception{
         log.info("*************** 排程开始(productionLxSchedule):"+productionScheduleVo.getProductionScheduleId()+" *******************");
 
+        List<String> orderidStrs = new ArrayList<>();
+        orderidStrs.add("fdf23365c4fb41ed8d25b135f3a850bd");
+//        orderidStrs.add("0c1394851a64456e9f2749720be27c41");
+//        orderidStrs.add("5494eff9337c4d58bad240c32a6d9a1e");
+//        orderidStrs.add("6f8da7c629f54b5a810ed6ce13dbee17");
         /*List<ProductionProcessesTa> pdps = productionScheduleVo.getProcesses().stream().filter(v ->
-                v.getProduceOrder().get(0).getId().equals("85e8e1938b7445939713f70f00401333"))
-                .collect(Collectors.toList());
+                        orderidStrs.contains(v.getProduceOrder().get(0).getId())
+                ).collect(Collectors.toList());
         productionScheduleVo.setProcesses(pdps);*/
         // 排程结果对象
         ApsUtils apsUtils = new ApsUtils();
@@ -124,7 +129,7 @@ public class ProductionScheduleTaServiceImpl implements ProductionScheduleTaServ
                         .withSolutionClass(ApsSolutionTa.class)
                         .withEntityClasses(ProductionProcessesTa.class, EquipmentTa.class)
                         .withConstraintProviderClass(ApsConstraintListProvider.class)
-                        .withTerminationConfig(new TerminationConfig().withUnimprovedSecondsSpentLimit(60L))
+                        .withTerminationConfig(new TerminationConfig().withUnimprovedSecondsSpentLimit(120L))
 //                        .withTerminationSpentLimit(Duration.ofSeconds(180))
                         .withMoveThreadCount(cores)
         );
@@ -247,6 +252,15 @@ public class ProductionScheduleTaServiceImpl implements ProductionScheduleTaServ
                         productionProcesses.setProZg(productionProcesses.getOptionalEquipmentZg().get(productionProcesses.getEquipment().getId()));
                     }
                 }
+
+                List<EquipmentTa> equipmentTaList1 = solvedBalance1.getEquipmentList().stream().filter(v -> v.getId().equals("0001be252874536843730b100152")).collect(Collectors.toList());
+                if(equipmentTaList1 != null && equipmentTaList1.size() > 0){
+                    int a1 = 0;
+                }
+                List<EquipmentTa> equipmentTaList2 = solvedBalance1.getEquipmentList().stream().filter(v -> v.getId().equals("0001be252874536843730b100151")).collect(Collectors.toList());
+                if(equipmentTaList2 != null && equipmentTaList2.size() > 0){
+                    int a1 = 0;
+                }
                 log.info("**************排程评分分析***************");
                 SolutionManager<ApsSolutionTa, HardSoftScore> scoreManager = SolutionManager.create(solverFactory);
                 ScoreExplanation<ApsSolutionTa, HardSoftScore> explain = scoreManager.explain(solvedBalance1);

+ 32 - 116
rw-aps-server/src/main/java/com/rongwei/rwapsserver/aps/taskassigning/tado/ApsConstraintListProvider.java

@@ -234,6 +234,10 @@ public class ApsConstraintListProvider implements ConstraintProvider {
                     }
                     if(deliveryMinDate == null){
                         return false;
+                    }else{
+                        if(productionProcesses.getApsOverallConfig().getStartTime().atZone(zoneId).toInstant().toEpochMilli()>deliveryMinDate.getTime()){
+                            return false;
+                        }
                     }
                     Boolean bol = productionProcesses.getEndTime().atZone(zoneId).toInstant().toEpochMilli()>deliveryMinDate.getTime();
                     return bol;
@@ -254,7 +258,7 @@ public class ApsConstraintListProvider implements ConstraintProvider {
                         int aa = 0;
                     }
                     return i;*/
-                    return 100;
+                    return 1000;
                 })
                 .asConstraint("deliveryDate");
     }
@@ -344,18 +348,35 @@ public class ApsConstraintListProvider implements ConstraintProvider {
                 .penalize(HardMediumSoftScore.ONE_MEDIUM,(equipment) -> {
                     int b = 0;
                     List<ProductionProcessesTa> tasks = new ArrayList<>();
-                    tasks.addAll(equipment.getTasks());
 
-                    if(tasks != null && tasks.size()>1){
+                    if(equipment.getTasks() != null && equipment.getTasks().size()>0){
+                        if(equipment.getLastProcessEndTime() != null){
+                            ProductionProcessesTa pta = new ProductionProcessesTa();
+                            LocalDateTime eqlastTime = equipment.getLastProcessEndTime().toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime();
+                            LocalDateTime startTime = equipment.getTasks().get(0).getApsOverallConfig().getStartTime();
+                            if(startTime.compareTo(eqlastTime)>0){
+                                pta.setStartTime(startTime.plusMinutes(-10));
+                                pta.setEndTime(startTime);
+                            }else{
+                                pta.setStartTime(eqlastTime.plusMinutes(-10));
+                                pta.setEndTime(eqlastTime);
+                            }
+                            tasks.add(pta);
+                        }
+                        tasks.addAll(equipment.getTasks());
+
                         // 根据开始时间排序
-                        Collections.sort(tasks, Comparator.comparing(ProductionProcessesTa::getStartTime));
-                        for (int i = 0; i < tasks.size()-1; i++) {
-                            ProductionProcessesTa preTask = tasks.get(i);
-                            ProductionProcessesTa nextTask = tasks.get(i + 1);
-                            if(preTask.getEndTime().plusMinutes(60).compareTo(nextTask.getStartTime())<0){
-                                b = b + 20;
+                        if(tasks.size()>1){
+                            Collections.sort(tasks, Comparator.comparing(ProductionProcessesTa::getStartTime));
+                            for (int i = 0; i < tasks.size()-1; i++) {
+                                ProductionProcessesTa preTask = tasks.get(i);
+                                ProductionProcessesTa nextTask = tasks.get(i + 1);
+                                if(preTask.getEndTime().plusMinutes(60).compareTo(nextTask.getStartTime())<0){
+                                    b = b + 100;
+                                }
                             }
                         }
+
                     }
                     return b;
                 })
@@ -467,9 +488,7 @@ public class ApsConstraintListProvider implements ConstraintProvider {
                     if(hasStartTimeProcess.get(i).getId() == null){
                         continue;
                     }else{
-                        if("铸轧".equals(hasStartTimeProcess.get(i).getProcessType())){
-//                            b = b+15;
-                        }else if ("冷轧".equals(hasStartTimeProcess.get(i).getProcessType())) {
+                        if ("冷轧".equals(hasStartTimeProcess.get(i).getProcessType())) {
                             b = b+10;
                         }else if ("箔轧".equals(hasStartTimeProcess.get(i).getProcessType())) {
                             b = b+5;
@@ -483,85 +502,7 @@ public class ApsConstraintListProvider implements ConstraintProvider {
                     if(hasStartTimeProcess.get(i).getSeriesProduceMark() != null && hasStartTimeProcess.get(i+1).getSeriesProduceMark() != null){
                         Map<String, String> conflictRoptions1 = hasStartTimeProcess.get(i).getConflictRoptions();
                         Map<String, String> conflictRoptions2 = hasStartTimeProcess.get(i+1).getConflictRoptions();
-                        if("铸轧".equals(hasStartTimeProcess.get(i).getProcessType())){
-                            if(hasStartTimeProcess.get(i+1).getId() == null){
-                                continue;
-                            }
-                            String[] serspre = hasStartTimeProcess.get(i).getSeriesProduceMark().split("\\^_\\^");
-                            String[] sersafter = hasStartTimeProcess.get(i+1).getSeriesProduceMark().split("\\^_\\^");
-                            // 获取产品类型二级
-                            String bfcplx = serspre[1].split("-")[0];
-                            // 获取产品类型二级
-                            String afcplx = sersafter[1].split("-")[0];
-                            // 周期立板总重量统计
-                            if(zqlb.compareTo(new BigDecimal("0")) == 0){
-                                if(hasStartTimeProcess.get(i).getLastSerialLbWeight() != null){
-                                    zqlb = hasStartTimeProcess.get(i).getLastSerialLbWeight();
-                                }else{
-                                    zqlb = hasStartTimeProcess.get(i).getSinglerollweight();
-                                }
-                            }else{
-                                zqlb = zqlb.add(hasStartTimeProcess.get(i).getSinglerollweight());
-                            }
-                            // 铸轧立板是否连续
-                            boolean lbserice = true;
-                            if(serspre.length == 5 && sersafter.length == 5){
-                                // 铸轧换辊兼容规则
-                                if(!zzSeriesJr(hasStartTimeProcess.get(i),hasStartTimeProcess.get(i+1),apsNochangeRollerDos)){
-                                    b = b+15;
-                                    if(hasStartTimeProcess.get(i).getId() != null){
-                                        conflictRoptions1.put("soft-seriesProduceZz",conflictRoptions1.get("soft-seriesProduceZz") == null ? "和后一道工序违反换辊和立板的连续约束" : conflictRoptions1.get("soft-seriesProduceZz")+";和后一道工序违反换辊和立板的连续约束");
-                                    }else{
-                                        conflictRoptions2.put("soft-seriesProduceZz","和前一道工序违反换辊和立板的连续约束");
-                                    }
-                                    zqlb = new BigDecimal("0");
-                                    lbserice = false;
-                                }else{
-                                    // 合金相同情况下后面的宽度大于前面的宽度需要换辊和立板
-                                    // 合金相同情况下后面的宽度小于前面的宽度需要立板
-                                    // 合金相同情况下后面的宽度等于前面的宽度换辊和立板都不需要
-                                    String s1 = serspre[2];
-                                    String s2 = sersafter[2];
-                                    try{
-                                        BigDecimal i1 = new BigDecimal(s1);
-                                        BigDecimal i2 = new BigDecimal(s2);
-                                        if(i1.compareTo(i2)<0){
-                                            b = b+15;
-                                            if(hasStartTimeProcess.get(i).getId() != null){
-                                                conflictRoptions1.put("soft-seriesProduceZz",conflictRoptions1.get("soft-seriesProduceZz") == null ? "和后一道工序违反换辊和立板的连续约束" : conflictRoptions1.get("soft-seriesProduceZz")+";和后一道工序违反换辊和立板的连续约束");
-                                            }else{
-                                                conflictRoptions2.put("soft-seriesProduceZz","和前一道工序违反换辊和立板的连续约束");
-                                            }
-                                            zqlb = new BigDecimal("0");
-                                            lbserice = false;
-                                        }else if(i1.compareTo(i2)>0){
-                                            b = b+8;
-                                            if(hasStartTimeProcess.get(i).getId() != null){
-                                                conflictRoptions1.put("soft-seriesProduceZz",conflictRoptions1.get("soft-seriesProduceZz") == null ? "和后一道工序违反立板的连续约束" : conflictRoptions1.get("soft-seriesProduceZz")+";和后一道工序违反立板的连续约束");
-                                            }else{
-                                                conflictRoptions2.put("soft-seriesProduceZz","和前一道工序违反立板的连续约束");
-                                            }
-                                            zqlb = new BigDecimal("0");
-                                            lbserice = false;
-                                        }else{
-                                            // 二级产品类型不一样的也需要立板
-                                            if(!bfcplx.equals(afcplx)){
-                                                b = b+8;
-                                                if(hasStartTimeProcess.get(i).getId() != null){
-                                                    conflictRoptions1.put("soft-seriesProduceZz",conflictRoptions1.get("soft-seriesProduceZz") == null ? "和后一道工序违反立板的连续约束" : conflictRoptions1.get("soft-seriesProduceZz")+";和后一道工序违反立板的连续约束");
-                                                }else{
-                                                    conflictRoptions2.put("soft-seriesProduceZz","和前一道工序违反立板的连续约束");
-                                                }
-                                                zqlb = new BigDecimal("0");
-                                                lbserice = false;
-                                            }
-                                        }
-                                    }catch (Exception e){
-                                        e.printStackTrace();
-                                    }
-                                }
-                            }
-                        } else if ("冷轧".equals(hasStartTimeProcess.get(i).getProcessType()) || "箔轧".equals(hasStartTimeProcess.get(i).getProcessType())) {
+                        if ("冷轧".equals(hasStartTimeProcess.get(i).getProcessType()) || "箔轧".equals(hasStartTimeProcess.get(i).getProcessType())) {
                             ProductionProcessesTa prepro = hasStartTimeProcess.get(i);
                             ProductionProcessesTa nextpro = hasStartTimeProcess.get(i+1);
                             String[] serspre = hasStartTimeProcess.get(i).getSeriesProduceMark().split("\\^_\\^");
@@ -702,31 +643,6 @@ public class ApsConstraintListProvider implements ConstraintProvider {
                                 }
                             }
                         }
-                        /*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){
-                                        b = b+5;
-                                        if(hasStartTimeProcess.get(i).getId() != null){
-                                            conflictRoptions1.put("soft-seriesProduceLz",conflictRoptions1.get("soft-seriesProduceLz") == null ? "和后一道工序违反换辊的连续约束" : conflictRoptions1.get("soft-seriesProduceLz")+";和后一道工序违反换辊的连续约束");
-                                        }else{
-                                            conflictRoptions2.put("soft-seriesProduceLz","和前一道工序违反换辊的连续约束");
-                                        }
-                                    } else if (volumeWidth.compareTo(volumeWidth1)<0) {
-                                        b = b+1;
-                                    }
-                                }catch (Exception e){
-                                    e.printStackTrace();
-                                }
-                            }
-                        }*/
                     }
                 }
             }