fangpy 9 hónapja
szülő
commit
d27e71526f

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

@@ -258,6 +258,8 @@ public class ProductionProcesses implements Serializable {
      * 单卷宽度
      */
     private BigDecimal volumeWidth;
+
+    private BigDecimal totalVolumeWidth;
     // 单卷厚度
     private BigDecimal volumeThickness;
 
@@ -266,6 +268,8 @@ public class ProductionProcesses implements Serializable {
      */
     private BigDecimal singlerollweight;
 
+    private BigDecimal totalSinglerollweight;
+
     /**
      * 合金
      */
@@ -990,6 +994,22 @@ public class ProductionProcesses implements Serializable {
         this.volumeMetalAndState = volumeMetalAndState;
     }
 
+    public BigDecimal getTotalSinglerollweight() {
+        return totalSinglerollweight;
+    }
+
+    public void setTotalSinglerollweight(BigDecimal totalSinglerollweight) {
+        this.totalSinglerollweight = totalSinglerollweight;
+    }
+
+    public BigDecimal getTotalVolumeWidth() {
+        return totalVolumeWidth;
+    }
+
+    public void setTotalVolumeWidth(BigDecimal totalVolumeWidth) {
+        this.totalVolumeWidth = totalVolumeWidth;
+    }
+
     public String getSeriSort(){
         String sortStr = this.getId();
         if(this.getStartTime() != null){

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

@@ -244,6 +244,7 @@ public class TaskStartTimeListener implements VariableListener<ApsSolution, Prod
             if(preProcess != null){
                 if(preProcess.getEquipment() == null){
                     System.out.println("preProcess:"+preProcess.getId());
+                    System.out.println("preProcess-blankid:"+preProcess.getProduceOrder().get(0).getId());
                     System.out.println("process:"+process.getId());
                 }
                 if(preProcess.getEquipment() == null){

+ 63 - 22
rw-aps-server/src/main/java/com/rongwei/rwapsserver/aps/score/ApsConstraintProvider.java

@@ -289,6 +289,16 @@ public class ApsConstraintProvider implements ConstraintProvider {
                                 }
                             }
                         }
+                        List<LocalDateTime> nextStartTimes = new ArrayList<>();
+                        getAllNextProTime(productionProcesses,nextStartTimes,0);
+                        if(nextStartTimes != null && nextStartTimes.size()>0){
+                            for (LocalDateTime nextStartTime : nextStartTimes) {
+                                if(preEndTime.compareTo(nextStartTime)>=0){
+                                    bln = true;
+                                    break;
+                                }
+                            }
+                        }
                     }
                     return bln;
                 })
@@ -296,6 +306,29 @@ public class ApsConstraintProvider implements ConstraintProvider {
                 .asConstraint("nextLockPro");
     }
 
+    /**
+     * 递归计算是否比所有下道工序开始时间晚
+     * @param productionProcesses
+     * @param nextStartTimes
+     * @param totalMinWaitTime
+     */
+    private void getAllNextProTime(ProductionProcesses productionProcesses,List<LocalDateTime> nextStartTimes,Integer totalMinWaitTime){
+        List<ProductionProcesses> nextProcesses = productionProcesses.getNextProcesses();
+        if(nextProcesses != null && nextProcesses.size()>0){
+            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);
+                    }
+                    nextStartTimes.add(startTime);
+                }
+                getAllNextProTime(nextProcess,nextStartTimes,totalMinWaitTime);
+            }
+        }
+    }
+
     /**
      * 汇总所有下道工序的加工时间
      * @param nextProcess
@@ -1286,8 +1319,8 @@ public class ApsConstraintProvider implements ConstraintProvider {
                 pp.setVolumeMetal(equipmentRunTime.getVolumeMetal());
                 pp.setVolumeMetalstate(equipmentRunTime.getVolumeMetalstate());
                 pp.setBsProcessesId(Arrays.asList(new String[]{"haspcprocess"}));
-                pp.setVolumeWidth(equipmentRunTime.getTotalVolumeWidth());
-                pp.setSinglerollweight(equipmentRunTime.getTotalSinglerollweight());
+                pp.setTotalVolumeWidth(equipmentRunTime.getTotalVolumeWidth());
+                pp.setTotalSinglerollweight(equipmentRunTime.getTotalSinglerollweight());
                 pp.setVolumeThickness(equipmentRunTime.getTotalThickness());
                 pp.setConflictRoptions(new HashMap<>());
                 if(equipmentRunTime.getOccupyType().equals("process")){
@@ -1305,6 +1338,10 @@ public class ApsConstraintProvider implements ConstraintProvider {
         for(int i=0;i<hasStartTimeProcess.size()-1;i++){
             ProductionProcesses prePro = hasStartTimeProcess.get(i);
             ProductionProcesses nextPro = hasStartTimeProcess.get(i+1);
+            // 没有本次待排程的退火作业不考虑合并问题
+            if(prePro.getId().indexOf("equipmentRunTime") == 0 && nextPro.getId().indexOf("equipmentRunTime") == 0){
+                continue;
+            }
             Map<String, String> conflictRoptions1 = prePro.getConflictRoptions();
             Map<String, String> conflictRoptions2 = nextPro.getConflictRoptions();
             // 开始时间相等为合并工序
@@ -1404,24 +1441,26 @@ public class ApsConstraintProvider implements ConstraintProvider {
             BigDecimal minSinglerollweight = null;
 
             for (ProductionProcesses productionProcesses : v) {
-                totalWidth = totalWidth.add(productionProcesses.getVolumeWidth()).add(productionProcesses.getEquipment().getEquipmentParameter().getFurnace());
-                totalWeight = totalWeight.add(productionProcesses.getSinglerollweight());
+                totalWidth = totalWidth.add(productionProcesses.getTotalVolumeWidth()).add(productionProcesses.getEquipment().getEquipmentParameter().getFurnace());
+                totalWeight = totalWeight.add(productionProcesses.getTotalSinglerollweight());
                 metalSet.add(productionProcesses.getVolumeMetal());
                 processTypeSet.add(productionProcesses.getProcessType());
                 metalstateSet.add(productionProcesses.getVolumeMetalstate());
                 // 宽度
-                if(maxVolumeWidth == null){
-                    maxVolumeWidth = productionProcesses.getVolumeWidth();
-                }else{
-                    if(productionProcesses.getVolumeWidth().compareTo(maxVolumeWidth)>0){
+                if(productionProcesses.getVolumeWidth() != null){
+                    if(maxVolumeWidth == null){
                         maxVolumeWidth = productionProcesses.getVolumeWidth();
+                    }else{
+                        if(productionProcesses.getVolumeWidth().compareTo(maxVolumeWidth)>0){
+                            maxVolumeWidth = productionProcesses.getVolumeWidth();
+                        }
                     }
-                }
-                if(minVolumeWidth == null){
-                    minVolumeWidth = productionProcesses.getVolumeWidth();
-                }else{
-                    if(productionProcesses.getVolumeWidth().compareTo(minVolumeWidth)<0){
+                    if(minVolumeWidth == null){
                         minVolumeWidth = productionProcesses.getVolumeWidth();
+                    }else{
+                        if(productionProcesses.getVolumeWidth().compareTo(minVolumeWidth)<0){
+                            minVolumeWidth = productionProcesses.getVolumeWidth();
+                        }
                     }
                 }
                 // 厚度
@@ -1440,18 +1479,20 @@ public class ApsConstraintProvider implements ConstraintProvider {
                     }
                 }
                 // 重量
-                if(maxSinglerollweight == null){
-                    maxSinglerollweight = productionProcesses.getSinglerollweight();
-                }else{
-                    if(productionProcesses.getSinglerollweight().compareTo(maxSinglerollweight)>0){
+                if(productionProcesses.getSinglerollweight() != null){
+                    if(maxSinglerollweight == null){
                         maxSinglerollweight = productionProcesses.getSinglerollweight();
+                    }else{
+                        if(productionProcesses.getSinglerollweight().compareTo(maxSinglerollweight)>0){
+                            maxSinglerollweight = productionProcesses.getSinglerollweight();
+                        }
                     }
-                }
-                if(minSinglerollweight == null){
-                    minSinglerollweight = productionProcesses.getSinglerollweight();
-                }else{
-                    if(productionProcesses.getSinglerollweight().compareTo(minSinglerollweight)<0){
+                    if(minSinglerollweight == null){
                         minSinglerollweight = productionProcesses.getSinglerollweight();
+                    }else{
+                        if(productionProcesses.getSinglerollweight().compareTo(minSinglerollweight)<0){
+                            minSinglerollweight = productionProcesses.getSinglerollweight();
+                        }
                     }
                 }
             }

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

@@ -107,6 +107,8 @@ public class ApsServiceImpl implements ApsService {
                 .withMoveThreadCount(cores)
         );
         Solver<ApsSolution> solver1 = solverFactory1.buildSolver();
+        // 按照宽度排序
+        apsSolutionTh.getProcessesList().sort(Comparator.comparing(ProductionProcesses::getSeriesProduceMark));
         ApsSolution solvedBalance1 = solver1.solve(apsSolutionTh);
         log.info("**************退火排程评分分析***************");
         SolutionManager<ApsSolution, HardSoftScore> scoreManager1 = SolutionManager.create(solverFactory1);
@@ -115,7 +117,7 @@ public class ApsServiceImpl implements ApsService {
         log.info("**************退火排程评分分析***************");
 
         // 锁定退火工序
-        /*for (ProductionProcesses process : apsSolution.getProcessesList()) {
+        for (ProductionProcesses process : apsSolution.getProcessesList()) {
             List<ProductionProcesses> collect = solvedBalance1.getProcessesList().stream().filter(v -> v.getId().equals(process.getId())).collect(Collectors.toList());
             if(collect != null && collect.size()>0){
                 process.setStartTime(collect.get(0).getStartTime());
@@ -125,10 +127,10 @@ public class ApsServiceImpl implements ApsService {
                 process.setDelay(collect.get(0).getDelay());
                 process.setIfLock(true);
             }
-        }*/
+        }
 
         // 退火合并工序
-        if(solvedBalance1.getProcessesList() != null && solvedBalance1.getProcessesList().size()>0){
+        /*if(solvedBalance1.getProcessesList() != null && solvedBalance1.getProcessesList().size()>0){
             Map<String, List<ProductionProcesses>> starttimeProcess = solvedBalance1.getProcessesList().stream()
                     .collect(Collectors.groupingBy(ProductionProcesses::getStartTimeStr));
             if(starttimeProcess != null && starttimeProcess.size()>0){
@@ -208,9 +210,9 @@ public class ApsServiceImpl implements ApsService {
                                     for (String nextProcessesId : thps.get(i).getNextProcessesIds()) {
                                         ProductionProcesses nextpro = allProMap.get(nextProcessesId);
                                         // 合并后关联关系重置
-                                        /*List<String> preids = new ArrayList<>();
+                                        *//*List<String> preids = new ArrayList<>();
                                         preids.add(thps.get(0).getId());
-                                        nextpro.setPreviousProcessesIds(preids);*/
+                                        nextpro.setPreviousProcessesIds(preids);*//*
                                         if(!nextpro.getPreviousProcessesIds().contains(thps.get(0).getId())){
                                             int i1 = nextpro.getPreviousProcessesIds().indexOf(thps.get(i).getId());
                                             nextpro.getPreviousProcessesIds().set(i1,thps.get(0).getId());
@@ -270,7 +272,7 @@ public class ApsServiceImpl implements ApsService {
                     apsSolution.setProcessesList(mThs);
                 }
             }
-        }
+        }*/
     }
 
     private void setPreOrderMark(List<ProductionProcesses> pres,Map<String,Integer> sortMap){
@@ -558,8 +560,8 @@ public class ApsServiceImpl implements ApsService {
                                 }
                                 // 取第一个作业作为合并作业
                                 ProductionProcesses mergePro = thps.get(0);
-                                mergePro.setVolumeWidth(mergePro.getVolumeWidth().multiply(new BigDecimal(thps.size())));
-                                mergePro.setSinglerollweight(mergePro.getSinglerollweight().multiply(new BigDecimal(thps.size())));
+                                mergePro.setTotalVolumeWidth(mergePro.getVolumeWidth().multiply(new BigDecimal(thps.size())));
+                                mergePro.setTotalSinglerollweight(mergePro.getTotalSinglerollweight().multiply(new BigDecimal(thps.size())));
                                 mergePro.setOpeProducePcNum(thps.size());
                                 // 设置是否满炉
                                 if(thps.size() == a){
@@ -1750,7 +1752,7 @@ public class ApsServiceImpl implements ApsService {
             List<ProductionProcesses> otherThproces = new ArrayList<>();
             // 铸轧提前排序
             int processNum1 = apsSolutionZz.getProcessesList().size();
-            int runPlanSeconds1 = (processNum1)*30;
+            int runPlanSeconds1 = (processNum1)*60;
             // CPU核数
             String cores = Runtime.getRuntime().availableProcessors() + "";
             SolverFactory<ApsSolution> solverFactory1 = SolverFactory.create(new SolverConfig()

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

@@ -182,6 +182,9 @@ public class ProductionScheduleServiceImpl implements ProductionScheduleService
         }
         // 退火提前排序
         apsService.tuihuoApsSch(apsSolution,otherThproces);
+        /*if(1 == 1){
+            return null;
+        }*/
         // 去掉锁定工序
         List<ProductionProcesses> notLocks = new ArrayList<>();
         List<ProductionProcesses> hasLocks = new ArrayList<>();
@@ -282,6 +285,7 @@ public class ProductionScheduleServiceImpl implements ProductionScheduleService
         productionScheduleRetVo.setProcesses(solvedBalance.getProcessesList());
         // 循环引用ProductionProcesses置空
 //        solvedBalance.getProcessesList().addAll(solvedBalance1.getProcessesList());
+        solvedBalance.getProcessesList().addAll(hasLocks);
         // 退火合并工序排程完拆分
         if(otherThproces != null && otherThproces.size()>0){
             for (ProductionProcesses otherThproce : otherThproces) {
@@ -356,7 +360,7 @@ public class ProductionScheduleServiceImpl implements ProductionScheduleService
         // 非退火合并拆分
         List<ProductionProcesses> sers = new ArrayList<>();
         for (ProductionProcesses productionProcesses : solvedBalance.getProcessesList()) {
-            if(productionProcesses.getMergeProOrders() != null && productionProcesses.getMergeProOrders().size()>0){
+            if(productionProcesses.getMergeProOrders() != null && productionProcesses.getMergeProOrders().size()>0 && !"铸轧".equals(productionProcesses.getProcessType())){
                 List<String> mergeProOrders = productionProcesses.getMergeProOrders();
                 ProductionProcesses lastpo = allToApsProcesMaps.get(mergeProOrders.get(mergeProOrders.size()-1));
                 boolean hasreplacenextLock = false;
@@ -392,7 +396,6 @@ public class ProductionScheduleServiceImpl implements ProductionScheduleService
 
         solvedBalance.getProcessesList().addAll(otherThproces);
         solvedBalance.getProcessesList().addAll(sers);
-        solvedBalance.getProcessesList().addAll(hasLocks);
 //        solvedBalance.getProcessesList().addAll(otherNotThproces);
         for (ProductionProcesses productionProcesses : solvedBalance.getProcessesList()) {
             productionProcesses.setPreviousProcesses(null);
@@ -884,6 +887,8 @@ public class ProductionScheduleServiceImpl implements ProductionScheduleService
             }
             process.setApsStatus("CH");
             process.setOrderId(process.getProduceOrder().get(0).getId());
+            process.setTotalSinglerollweight(process.getSinglerollweight());
+            process.setTotalVolumeWidth(process.getVolumeWidth());
             // 前道工序
             if(process.getPreviousProcessesIds() != null && process.getPreviousProcessesIds().size()>0){
                 List<ProductionProcesses> pres = new ArrayList<>();