Forráskód Böngészése

排程优化-退火合并

fangpy 9 hónapja
szülő
commit
85a106b2a5

+ 13 - 0
rw-aps-server/src/main/java/com/rongwei/rwapsserver/aps/domain/ProductionProcesses.java

@@ -345,6 +345,11 @@ public class ProductionProcesses implements Serializable {
      */
     private ProductionProcesses rooprocess;
 
+    /**
+     * 根结点
+     */
+    private List<ProductionProcesses> mergeRooprocess;
+
     /**
      * 是否已分卷
      */
@@ -1010,6 +1015,14 @@ public class ProductionProcesses implements Serializable {
         this.totalVolumeWidth = totalVolumeWidth;
     }
 
+    public List<ProductionProcesses> getMergeRooprocess() {
+        return mergeRooprocess;
+    }
+
+    public void setMergeRooprocess(List<ProductionProcesses> mergeRooprocess) {
+        this.mergeRooprocess = mergeRooprocess;
+    }
+
     public String getSeriSort(){
         String sortStr = this.getId();
         if(this.getStartTime() != null){

+ 6 - 1
rw-aps-server/src/main/java/com/rongwei/rwapsserver/aps/listener/TaskStartTimeListener.java

@@ -531,7 +531,7 @@ public class TaskStartTimeListener implements VariableListener<ApsSolution, Prod
             if(process.getProcessType().equals("成退") || process.getProcessType().equals("中退")){
                 if(process.getProcessType().equals(equipmentRunTime.getProcessType())
                         && process.getVolumeMetal().equals(equipmentRunTime.getVolumeMetal())
-                        && process.getVolumeMetalstate().equals(equipmentRunTime.getVolumeMetalstate())){
+                        && process.getVolumeMetalstate() != null && process.getVolumeMetalstate().equals(equipmentRunTime.getVolumeMetalstate())){
                     // 最大、最小宽度
                     BigDecimal maxVolumeWidth = equipmentRunTime.getMaxVolumeWidth();
                     BigDecimal minVolumeWidth = equipmentRunTime.getMinVolumeWidth();
@@ -680,6 +680,11 @@ public class TaskStartTimeListener implements VariableListener<ApsSolution, Prod
                         }
                     }
                 }
+
+                /*if(hasMergeTh){
+                    System.out.println("退火合并:  设备ID:"+process.getEquipmentId()
+                            +"开始时间:"+equipmentRunTime.getStartRunTime()+"组名:"+minThGroupNames+"描述信息:"+equipmentRunTime.getSeriesProduceMark()+"合金状态:"+equipmentRunTime.getVolumeMetalstate());
+                }*/
             }
         }
         return hasMergeTh;

+ 48 - 6
rw-aps-server/src/main/java/com/rongwei/rwapsserver/aps/score/ApsConstraintProvider.java

@@ -262,6 +262,7 @@ public class ApsConstraintProvider implements ConstraintProvider {
                     if(nextProcesses != null && nextProcesses.size()>0){
                         // 当前工序结束时间
                         LocalDateTime preEndTime = productionProcesses.getEndTime();
+                        LocalDateTime preStartTime = productionProcesses.getStartTime();
                         // 获取下道工序最早开始时间
                         LocalDateTime earlyStartTime = null;
                         for (ProductionProcesses nextProcess : nextProcesses) {
@@ -293,12 +294,24 @@ public class ApsConstraintProvider implements ConstraintProvider {
                         getAllNextProTime(productionProcesses,nextStartTimes,0);
                         if(nextStartTimes != null && nextStartTimes.size()>0){
                             for (LocalDateTime nextStartTime : nextStartTimes) {
-                                if(preEndTime.compareTo(nextStartTime)>=0){
+                                if(preEndTime.compareTo(nextStartTime)>0){
                                     bln = true;
                                     break;
                                 }
                             }
                         }
+                        /*if(!bln){
+                            List<LocalDateTime> nextMaxWaitStartTimes = new ArrayList<>();
+                            getAllNextLockMaxWaitTime(productionProcesses,nextMaxWaitStartTimes,0);
+                            if(nextMaxWaitStartTimes != null && nextMaxWaitStartTimes.size()>0){
+                                for (LocalDateTime nextMaxWaitStartTime : nextMaxWaitStartTimes) {
+                                    if(nextMaxWaitStartTime.compareTo(preStartTime)>0){
+                                        bln = true;
+                                        break;
+                                    }
+                                }
+                            }
+                        }*/
                     }
                     return bln;
                 })
@@ -315,16 +328,42 @@ public class ApsConstraintProvider implements ConstraintProvider {
     private void getAllNextProTime(ProductionProcesses productionProcesses,List<LocalDateTime> nextStartTimes,Integer totalMinWaitTime){
         List<ProductionProcesses> nextProcesses = productionProcesses.getNextProcesses();
         if(nextProcesses != null && nextProcesses.size()>0){
+            Integer nowTotalMinWaitTime = totalMinWaitTime;
             for (ProductionProcesses nextProcess : nextProcesses) {
                 if(nextProcess.getStartTime() != null){
                     LocalDateTime startTime = nextProcess.getStartTime();
                     if(nextProcess.getMinWaitTime() != null && nextProcess.getMinWaitTime()>0){
-                        totalMinWaitTime = totalMinWaitTime + nextProcess.getMinWaitTime();
-                        startTime = startTime.minusMinutes(totalMinWaitTime);
+                        nowTotalMinWaitTime = totalMinWaitTime + nextProcess.getMinWaitTime();
+                        startTime = startTime.minusMinutes(nowTotalMinWaitTime);
                     }
                     nextStartTimes.add(startTime);
                 }
-                getAllNextProTime(nextProcess,nextStartTimes,totalMinWaitTime);
+                getAllNextProTime(nextProcess,nextStartTimes,nowTotalMinWaitTime);
+            }
+        }
+    }
+
+    /**
+     * 所有下道工序最大等待时间考虑
+     * @param productionProcesses
+     * @param nextStartTimes
+     * @param totalMinWaitTime
+     */
+    private void getAllNextLockMaxWaitTime(ProductionProcesses productionProcesses,List<LocalDateTime> nextStartTimes,Integer totalMinWaitTime){
+        List<ProductionProcesses> nextProcesses = productionProcesses.getNextProcesses();
+        if(nextProcesses != null && nextProcesses.size()>0){
+            Integer nowTotalMinWaitTime = totalMinWaitTime;
+            for (ProductionProcesses nextProcess : nextProcesses) {
+                LocalDateTime startTime = nextProcess.getStartTime();
+                if(nextProcess.getMaxWaitTime() != null && nextProcess.getMaxWaitTime()>0){
+                    nowTotalMinWaitTime = totalMinWaitTime + nextProcess.getMaxWaitTime();
+                    if(nextProcess.getIfLock()){
+                        startTime = startTime.minusMinutes(nowTotalMinWaitTime);
+                        nextStartTimes.add(startTime);
+                    }else{
+                        getAllNextLockMaxWaitTime(nextProcess,nextStartTimes,nowTotalMinWaitTime);
+                    }
+                }
             }
         }
     }
@@ -1188,13 +1227,16 @@ public class ApsConstraintProvider implements ConstraintProvider {
 
             boolean mergeRule = true;
             for (ProductionProcesses productionProcesses : v) {
+                if(productionProcesses.getVolumeMetalstate() == null){
+                    int a = 1;
+                }
                 totalWeight = totalWeight.add(productionProcesses.getSinglerollweight());
                 // 检查小卷退火在哪个组
                 String groupname = null;
                 for (ApsFurnaceInstallationDo furnaceInstallation : furnaceInstallations) {
                     if(productionProcesses.getVolumeMetal().equals(furnaceInstallation.getAlloy())){
                         boolean a = true;
-                        if(furnaceInstallation.getAlloystatus() != null && !furnaceInstallation.getAlloystatus().contains(productionProcesses.getVolumeMetalstate())){
+                        if(furnaceInstallation.getAlloystatus() != null && (productionProcesses.getVolumeMetalstate() == null || !furnaceInstallation.getAlloystatus().contains(productionProcesses.getVolumeMetalstate()))){
                             a = false;
                         }
                         if(furnaceInstallation.getStartthickness() != null && furnaceInstallation.getStartthickness().compareTo(productionProcesses.getVolumeThickness())>0){
@@ -2601,7 +2643,7 @@ public class ApsConstraintProvider implements ConstraintProvider {
                 for (ApsFurnaceInstallationDo furnaceInstallation : furnaceInstallations) {
                     if(productionProcesses.getVolumeMetal().equals(furnaceInstallation.getAlloy())){
                         boolean a = true;
-                        if(furnaceInstallation.getAlloystatus() != null && !furnaceInstallation.getAlloystatus().contains(productionProcesses.getVolumeMetalstate())){
+                        if(furnaceInstallation.getAlloystatus() != null && (productionProcesses.getVolumeMetalstate() == null || !furnaceInstallation.getAlloystatus().contains(productionProcesses.getVolumeMetalstate()))){
                             a = false;
                         }
                         if(furnaceInstallation.getStartthickness() != null && furnaceInstallation.getStartthickness().compareTo(productionProcesses.getVolumeThickness())>0){

+ 1 - 1
rw-aps-server/src/main/java/com/rongwei/rwapsserver/aps/service/ApsService.java

@@ -12,7 +12,7 @@ public interface ApsService {
 
     ApsSolution tuihuoAps(ApsSolution apsSolution);
 
-    void tuihuoApsSch(ApsSolution apsSolution,List<ProductionProcesses> otherThproces);
+    void tuihuoApsSch(ApsSolution apsSolution,List<ProductionProcesses> otherThproces,List<ProductionProcesses> otherNotZzFirstProces,ProductionScheduleVo productionScheduleVo);
 
     SolverFactory<ApsSolution> solverInit(ProductionScheduleVo productionScheduleVo);
 

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

@@ -48,7 +48,7 @@ public class ApsServiceImpl implements ApsService {
         ApsSolution apsSolutionTuihuo = new ApsSolution();
         List<ProductionProcesses> tuihuos = new ArrayList<>();
         for (ProductionProcesses process : apsSolution.getProcessesList()) {
-            if(process.getProcessType().equals("成退") || process.getProcessType().equals("中退") || process.getProcessType().equals("小卷成退")){
+            if((process.getProcessType().equals("成退") || process.getProcessType().equals("中退") || process.getProcessType().equals("小卷成退")) && !process.getIfLock()){
                 List<Integer> preTimes = new ArrayList<>();
                 getAllPreTime(process,preTimes);
                 if(preTimes != null && preTimes.size()>0){
@@ -66,8 +66,22 @@ public class ApsServiceImpl implements ApsService {
                     // 全局配置
                     ApsOverallConfig apsOverallConfig = new ApsOverallConfig();
                     BeanUtil.copyProperties(process.getApsOverallConfig(),apsOverallConfig);
-                    if(process.getRooprocess() != null && process.getRooprocess().getStartTime() != null){
-                        apsOverallConfig.setStartTime(process.getRooprocess().getStartTime().plusMinutes(totaltime));
+                    LocalDateTime startTime = null;
+                    if(process.getMergeRooprocess() != null && process.getMergeRooprocess().size()>0){
+                        for (ProductionProcesses mergeRooprocess : process.getMergeRooprocess()) {
+                            if(mergeRooprocess.getStartTime() != null){
+                                if(startTime == null){
+                                    startTime = mergeRooprocess.getStartTime();
+                                }else{
+                                    if(mergeRooprocess.getStartTime().compareTo(startTime)>0){
+                                        startTime = mergeRooprocess.getStartTime();
+                                    }
+                                }
+                            }
+                        }
+                    }
+                    if(startTime != null){
+                        apsOverallConfig.setStartTime(startTime.plusMinutes(totaltime));
                     }else{
                         apsOverallConfig.setStartTime(process.getApsOverallConfig().getStartTime().plusMinutes(totaltime));
                     }
@@ -91,8 +105,39 @@ public class ApsServiceImpl implements ApsService {
      * @param apsSolution
      */
     @Override
-    public void tuihuoApsSch(ApsSolution apsSolution,List<ProductionProcesses> otherThproces){
+    public void tuihuoApsSch(ApsSolution apsSolution,List<ProductionProcesses> otherThproces,List<ProductionProcesses> otherNotZzFirstProces,ProductionScheduleVo productionScheduleVo){
+        if(otherNotZzFirstProces != null && otherNotZzFirstProces.size()>0){
+            otherNotZzFirstProces = new ArrayList<>();
+
+            List<ProductionProcesses> processesList = this.zzProcessAps(productionScheduleVo, apsSolution, otherNotZzFirstProces);
+            if(processesList != null && processesList.size()>0 && !processesList.get(0).getProcessType().equals("铸轧")){
+                for (ProductionProcesses productionProcesses : processesList) {
+                    for (ProductionProcesses processes : apsSolution.getProcessesList()) {
+                        if(processes.getId().equals(productionProcesses.getId())){
+                            processes.setStartTime(productionProcesses.getStartTime());
+                            processes.setEndTime(productionProcesses.getEndTime());
+                        }
+                    }
+                }
+            }
+        }
         ApsSolution apsSolutionTh = tuihuoAps(apsSolution);
+        if(otherNotZzFirstProces != null && otherNotZzFirstProces.size()>0){
+            // 取消第一道工序非铸轧提前排程的锁定状态
+            if(otherNotZzFirstProces != null && otherNotZzFirstProces.size()>0){
+                for (ProductionProcesses otherSerProcesMerge : apsSolution.getProcessesList()) {
+                    List<ProductionProcesses> list1 = otherNotZzFirstProces.stream().filter(v -> v.getId().equals(otherSerProcesMerge.getId())).collect(Collectors.toList());
+                    if(list1 != null && list1.size()>0){
+                        otherSerProcesMerge.setIfLock(false);
+                        otherSerProcesMerge.setStartTime(null);
+                        otherSerProcesMerge.setEndTime(null);
+                        otherSerProcesMerge.setEquipment(null);
+                        otherSerProcesMerge.setEquipmentId(null);
+                        otherSerProcesMerge.setDelay(null);
+                    }
+                }
+            }
+        }
         // 退火工序求解器运行
         int processNum1 = apsSolutionTh.getProcessesList().size();
         int runPlanSeconds1 = (processNum1)*30;
@@ -108,7 +153,32 @@ public class ApsServiceImpl implements ApsService {
         );
         Solver<ApsSolution> solver1 = solverFactory1.buildSolver();
         // 按照宽度排序
-        apsSolutionTh.getProcessesList().sort(Comparator.comparing(ProductionProcesses::getSeriesProduceMark));
+//        apsSolutionTh.getProcessesList().sort(Comparator.comparing(ProductionProcesses::getSeriesProduceMark));
+        Collections.sort(apsSolutionTh.getProcessesList(),(v1,v2)->{
+            int a = 0;
+            // 合金
+            String alloy1 = v1.getVolumeMetal();
+            String alloy2 = v2.getVolumeMetal();
+            // 合金状态
+            String alloystatus1 = v1.getVolumeMetalstate();
+            String alloystatus2 = v2.getVolumeMetalstate();
+            // 合金
+            if(alloy1.compareTo(alloy2) == 0){
+                // 合金状态
+                if(alloystatus1 == null || alloystatus2 == null || alloystatus1.compareTo(alloystatus2) == 0){
+                    if(v1.getApsOverallConfig().getStartTime().compareTo(v2.getApsOverallConfig().getStartTime()) == 0){
+                        a = v2.getVolumeWidth().compareTo(v1.getVolumeWidth());
+                    }else{
+                        a = v2.getApsOverallConfig().getStartTime().compareTo(v1.getApsOverallConfig().getStartTime());
+                    }
+                }else{
+                    a = alloystatus1.compareTo(alloystatus2);
+                }
+            }else{
+                a = alloy1.compareTo(alloy2);
+            }
+            return a;
+        });
         ApsSolution solvedBalance1 = solver1.solve(apsSolutionTh);
         log.info("**************退火排程评分分析***************");
         SolutionManager<ApsSolution, HardSoftScore> scoreManager1 = SolutionManager.create(solverFactory1);
@@ -297,14 +367,19 @@ public class ApsServiceImpl implements ApsService {
      * @param preTimes
      */
     private void getAllPreTime(ProductionProcesses process,List<Integer> preTimes){
-        if(process.getPreviousProcesses() != null){
+        if(process.getPreviousProcesses() != null && process.getPreviousProcesses().size()>0 && !"铸轧".equals(process.getPreviousProcesses().get(0).getProcessType())){
             Integer lzTime = process.getApsOverallConfig().getRoamTime().get("WORKSHOP_IN");
             if(process.getPreviousProcesses().get(0).getMinWaitTime() != null){
                 if(process.getPreviousProcesses().get(0).getMinWaitTime()>lzTime){
                     lzTime = process.getPreviousProcesses().get(0).getMinWaitTime();
                 }
             }
-            int pretime = process.getPreviousProcesses().get(0).getProduceTime() * process.getPreviousProcesses().get(0).getProducePcNum() + lzTime;
+            int pretime = 0;
+            if(process.getPreviousProcesses().get(0).getProcessType().equals("退火")){
+                pretime = process.getPreviousProcesses().get(0).getProduceTime() + lzTime;
+            }else{
+                pretime = process.getPreviousProcesses().get(0).getProduceTime() * process.getPreviousProcesses().size() + lzTime;
+            }
             preTimes.add(pretime);
             getAllPreTime(process.getPreviousProcesses().get(0),preTimes);
         }
@@ -492,6 +567,8 @@ public class ApsServiceImpl implements ApsService {
                                     if(i>0){
                                         // 设置待合并退火的主ID
                                         thps.get(i).setMergeThMainId(thps.get(0).getId());
+                                        // 设置合并作业的根节点
+                                        thps.get(0).getMergeRooprocess().add(thps.get(i).getRooprocess());
                                         otherThproces.add(thps.get(i));
                                         // 退火前一道作业设置下一作业ID
                                         ProductionProcesses prepro = allProMap.get(thps.get(i).getPreviousProcessesIds().get(0));
@@ -1698,6 +1775,7 @@ public class ApsServiceImpl implements ApsService {
      */
     @Override
     public List<ProductionProcesses> zzProcessAps(ProductionScheduleVo productionScheduleVo, ApsSolution apsSolution,List<ProductionProcesses> otherNotZzFirstProces) {
+        List<ProductionProcesses> retPros = null;
         ApsSolution apsSolutionZz = new ApsSolution();
         List<ProductionProcesses> zzprocesList = new ArrayList<>();
         for (ProductionProcesses process : apsSolution.getProcessesList()) {
@@ -1799,7 +1877,7 @@ public class ApsServiceImpl implements ApsService {
                 }
             }
             List<ProductionProcesses> mergeZzLists = solvedBalance1.getProcessesList().stream().filter(v ->v.getMergeProOrders() != null && v.getMergeProOrders().size() > 0).collect(Collectors.toList());
-            if(mergeZzLists != null && mergeZzLists.size() > 0){
+            if(mergeZzLists != null && mergeZzLists.size() > 0 && mergeZzLists.get(0).getProcessType().equals("铸轧")){
                 for (ProductionProcesses mergeZz : mergeZzLists) {
                     List<String> mergeProOrders = mergeZz.getMergeProOrders();
                     boolean hasreplacenextLock = false;
@@ -1824,7 +1902,9 @@ public class ApsServiceImpl implements ApsService {
                     }
                 }
             }
+
+            retPros = solvedBalance1.getProcessesList();
         }
-        return null;
+        return retPros;
     }
 }

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

@@ -96,7 +96,9 @@ public class ProductionScheduleServiceImpl implements ProductionScheduleService
                             newPro.setId(productionProcesses.getId());
                             newPro.setEquipmentId(productionProcesses.getEquipmentId());
                             Equipment eq = new Equipment();
-                            eq.setId(productionProcesses.getEquipment().getId());
+                            if(productionProcesses.getEquipment() != null){
+                                eq.setId(productionProcesses.getEquipment().getId());
+                            }
                             newPro.setEquipment(eq);
                             newPro.setProduceTime(productionProcesses.getProduceTime());
                             newPro.setStartTime(productionProcesses.getStartTime());
@@ -136,6 +138,9 @@ public class ProductionScheduleServiceImpl implements ProductionScheduleService
         List<ProductionProcesses> otherNotZzFirstProces = new ArrayList<>();
         // 铸轧提前排序
         apsService.zzProcessAps(productionScheduleVo,apsSolution,otherNotZzFirstProces);
+        /*if(1 == 1){
+            return null;
+        }*/
         // 取消第一道工序非铸轧提前排程的锁定状态
         if(otherNotZzFirstProces != null && otherNotZzFirstProces.size()>0){
             for (ProductionProcesses otherSerProcesMerge : apsSolution.getProcessesList()) {
@@ -166,6 +171,7 @@ public class ProductionScheduleServiceImpl implements ProductionScheduleService
         apsSolution.setProcessesList(otherSerProcesMerges);
         // 排程作业排序
         sortProcess(apsSolution.getProcessesList(),1);
+
         // 取消第一道工序非铸轧提前排程的锁定状态
         if(otherNotZzFirstProces != null && otherNotZzFirstProces.size()>0){
             for (ProductionProcesses otherSerProcesMerge : apsSolution.getProcessesList()) {
@@ -181,7 +187,8 @@ public class ProductionScheduleServiceImpl implements ProductionScheduleService
             }
         }
         // 退火提前排序
-        apsService.tuihuoApsSch(apsSolution,otherThproces);
+        apsService.tuihuoApsSch(apsSolution,otherThproces,otherNotZzFirstProces,productionScheduleVo);
+
         /*if(1 == 1){
             return null;
         }*/
@@ -285,7 +292,7 @@ public class ProductionScheduleServiceImpl implements ProductionScheduleService
         productionScheduleRetVo.setProcesses(solvedBalance.getProcessesList());
         // 循环引用ProductionProcesses置空
 //        solvedBalance.getProcessesList().addAll(solvedBalance1.getProcessesList());
-        solvedBalance.getProcessesList().addAll(hasLocks);
+//        solvedBalance.getProcessesList().addAll(hasLocks);
         // 退火合并工序排程完拆分
         if(otherThproces != null && otherThproces.size()>0){
             for (ProductionProcesses otherThproce : otherThproces) {
@@ -406,6 +413,8 @@ public class ProductionScheduleServiceImpl implements ProductionScheduleService
             productionProcesses.setPreviousStep(null);
             productionProcesses.setOptionalProviderEquipments(null);
             productionProcesses.setEquass(null);
+            productionProcesses.setMergeRooprocess(null);
+            productionProcesses.setOpeProducePcNum(1);
             if(productionProcesses.getApsOverallConfig() != null){
                 productionProcesses.getApsOverallConfig().setFurnaceInstallations(null);
                 productionProcesses.getApsOverallConfig().setMergeFurnaces(null);
@@ -885,6 +894,7 @@ public class ProductionScheduleServiceImpl implements ProductionScheduleService
             if(StrUtil.isBlank(process.getTaskType())){
                 process.setTaskType("processes");
             }
+            process.setMergeRooprocess(new ArrayList<>());
             process.setApsStatus("CH");
             process.setOrderId(process.getProduceOrder().get(0).getId());
             process.setTotalSinglerollweight(process.getSinglerollweight());
@@ -938,7 +948,7 @@ public class ProductionScheduleServiceImpl implements ProductionScheduleService
             if(process.getUnitProduceTime() == null){
                 process.setUnitProduceTime((int)(Math.ceil((double)process.getProduceTime()/process.getProducePcNum())));
             }
-            process.setVolumeMetalAndState(process.getVolumeMetal() + process.getVolumeMetalstate() == null ? "" : process.getVolumeMetalstate() + process.getProcessType());
+            process.setVolumeMetalAndState(process.getVolumeMetal() + (process.getVolumeMetalstate() == null ? "" : process.getVolumeMetalstate()) + process.getProcessType());
             // 可选设备初始化
             if(process.getOptionalEquipments() != null){
                 List<Equipment> providedEq = new ArrayList<>();
@@ -970,8 +980,18 @@ public class ProductionScheduleServiceImpl implements ProductionScheduleService
                 process.setCutfinishmin(0);
             }
             // 锁定工序处理
-            if(process.getIfLock()){
+            if(process.getIfLock() && process.getOptionalProviderEquipments().size()>0){
                 process.setIfLock(false);
+                int ai = -1;
+                for (int i = 0; i < process.getOptionalProviderEquipments().get(0).getEquipmentRunTimes().size(); i++) {
+                    EquipmentRunTime equipmentRunTime = process.getOptionalProviderEquipments().get(0).getEquipmentRunTimes().get(i);
+                    if(equipmentRunTime.getStartRunTime().compareTo(process.getStartTime()) == 0 && equipmentRunTime.getEndRunTime().compareTo(process.getEndTime()) == 0){
+                        ai = i;
+                    }
+                }
+                if(ai>-1){
+                    process.getOptionalProviderEquipments().get(0).getEquipmentRunTimes().remove(ai);
+                }
                 // 锁定工序的设备即可选设备
                 process.setEquipment(process.getOptionalProviderEquipments().get(0));
                 process.setIfLock(true);
@@ -1113,11 +1133,17 @@ public class ProductionScheduleServiceImpl implements ProductionScheduleService
         // 按坯料计划分组
         Map<String, List<ProductionProcesses>> orderProcess = processesSort.stream().collect(Collectors.groupingBy(ProductionProcesses::getOrderId));
         List<ProduceOrder> produceOrders = new ArrayList<>();
+        List<ProduceOrder> produceOrdersnotDeliveryDate = new ArrayList<>();
         orderProcess.forEach((k,v)->{
-            produceOrders.add(v.get(0).getProduceOrder().get(0));
+            if(v.get(0).getProduceOrder().get(0).getDeliveryDate() != null){
+                produceOrders.add(v.get(0).getProduceOrder().get(0));
+            }else{
+                produceOrdersnotDeliveryDate.add(v.get(0).getProduceOrder().get(0));
+            }
         });
-//        Collections.sort(produceOrders, Comparator.comparing(pro -> pro.getDeliveryDate()));
-        Collections.sort(produceOrders, (pro1, pro2) -> {
+        Collections.sort(produceOrders, Comparator.comparing(pro -> pro.getDeliveryDate()));
+        produceOrders.addAll(produceOrdersnotDeliveryDate);
+        /*Collections.sort(produceOrders, (pro1, pro2) -> {
             int a = 0;
             if(pro1 != null && pro2 != null){
                 if(pro1.getDeliveryDate() != null && pro2.getDeliveryDate() != null){
@@ -1131,7 +1157,7 @@ public class ProductionScheduleServiceImpl implements ProductionScheduleService
                 }
             }
             return a;
-        });
+        });*/
         Map<String,Integer> sortMap = new HashMap<>();
         sortMap.put("sortInt",0);
         if(produceOrders != null && produceOrders.size()>0){
@@ -1178,6 +1204,9 @@ public class ProductionScheduleServiceImpl implements ProductionScheduleService
         if(nowpro.getNextProcesses() != null && nowpro.getNextProcesses().size()>0){
             for (ProductionProcesses nextProcess : nowpro.getNextProcesses()) {
                 nextProcess.setRooprocess(root);
+                if (nextProcess.getMergeRooprocess().size() == 0){
+                    nextProcess.getMergeRooprocess().add(root);
+                }
                 setNextProRoot(root,nextProcess);
             }
         }

+ 13 - 2
rw-aps-server/src/test/java/com/rongwei/rwapsserver/RwApsServerApplicationTests.java

@@ -13,7 +13,7 @@ class RwApsServerApplicationTests {
 
     @Test
     void contextLoads() {
-        List<ProductionProcesses> sources = new ArrayList<>();
+        /*List<ProductionProcesses> sources = new ArrayList<>();
         ProductionProcesses p1 = new ProductionProcesses();
         p1.setId("1");
         p1.setOrderMark(1);
@@ -24,7 +24,18 @@ class RwApsServerApplicationTests {
         sources.add(p2);
 
         sources.sort(Comparator.comparing(ProductionProcesses::getOrderMark));
-        System.out.println(sources);
+        System.out.println(sources);*/
+
+        test1(3);
+    }
+
+    private void test1(Integer a){
+        Integer b = a;
+        for (int i = 0; i < 2; i++) {
+            b = a+1;
+            System.out.println("a:"+a);
+            System.out.println("b:"+b);
+        }
     }
 
 }