Bladeren bron

排程数据组装优化

fangpy 11 maanden geleden
bovenliggende
commit
dda4316d02

+ 1 - 1
cx-aps/cx-aps-common/src/main/java/com/rongwei/bscommon/sys/service/ApsService.java

@@ -7,7 +7,7 @@ import java.util.List;
 
 public interface ApsService {
 
-    void apsSchedule(List<ApsBlankOrderVo> apsBlankOrders);
+    void apsSchedule(List<ApsBlankOrderVo> apsBlankOrders,String apsType);
 
     ProductionScheduleVo apsProductionScheduleInit(List<ApsBlankOrderVo> apsBlankOrders);
 

+ 2 - 1
cx-aps/cx-aps-common/src/main/java/com/rongwei/bscommon/sys/service/impl/ApsBlankOrderServiceImpl.java

@@ -28,6 +28,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.scheduling.annotation.Async;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
@@ -563,7 +564,7 @@ public class ApsBlankOrderServiceImpl extends ServiceImpl<ApsBlankOrderDao, ApsB
      */
     @Override
     public void blankOrderAps(List<ApsBlankOrderVo> apsBlankOrders) {
-        apsService.apsSchedule(apsBlankOrders);
+        apsService.apsSchedule(apsBlankOrders,null);
     }
 
     /**

+ 274 - 264
cx-aps/cx-aps-common/src/main/java/com/rongwei/bscommon/sys/service/impl/ApsServiceImpl.java

@@ -73,9 +73,13 @@ public class ApsServiceImpl implements ApsService {
     @Autowired
     private ApsMergeFurnaceService apsMergeFurnaceService;
 
+    /**
+     * Aps排程
+     * @param apsBlankOrders
+     * @param apsType cd:插单
+     */
     @Override
-//    @Async("customThreadPool")
-    public void apsSchedule(List<ApsBlankOrderVo> apsBlankOrders) {
+    public void apsSchedule(List<ApsBlankOrderVo> apsBlankOrders,String apsType) {
         // 当前等路人所属工厂
         SysUserVo currentUser = CXCommonUtils.getCurrentUser();
         String tenantId = currentUser.getOrganizationDoList().get(0).getFullpid().split(",")[1];
@@ -101,273 +105,23 @@ public class ApsServiceImpl implements ApsService {
                     idStrs = CollUtil.join(hasIds, "','");
                     idStrs = "'" + idStrs + "'";
                 }
-
                 // 查询存在未锁定的作业坯料计划
-//            List<ApsBlankOrderVo> fbNotLock = apsBlankOrderDao.getFbNotLock(idStrs,tenantId);
-                List<ApsBlankOrderVo> fbNotLock = apsBlankOrderDao.getOrdersHasNotLockProcess(idStrs,tenantId);
-                if (fbNotLock != null && fbNotLock.size() > 0) {
-                    apsBlankOrders.addAll(fbNotLock);
-                }
-                // 坯料计划排序
-                Collections.sort(apsBlankOrders,(v1,v2)->{
-                    // 合金
-                    String alloy1 = v1.getAlloy();
-                    String alloy2 = v2.getAlloy();
-                    // 合金状态
-                    String alloystatus1 = v1.getAlloystatus();
-                    String alloystatus2 = v2.getAlloystatus();
-                    // 产品类型
-                    String producttype1 = v1.getProducttype();
-                    String producttype2 = v2.getProducttype();
-                    // 宽度
-                    BigDecimal prowidth1 = v1.getProwidth();
-                    BigDecimal prowidth2 = v2.getProwidth();
-                    // 厚度
-                    BigDecimal thickness1 = v1.getThickness();
-                    BigDecimal thickness2 = v2.getThickness();
-                    // 重量
-                    BigDecimal singlerollweight1 = v1.getSinglerollweight();
-                    BigDecimal singlerollweight2 = v2.getSinglerollweight();
-
-                    int a = 0;
-                    // 合金
-                    if(alloy1.compareTo(alloy2) == 0){
-                        // 产品类型
-                        if(producttype1 == null || producttype2 == null || producttype1.compareTo(producttype2) == 0){
-                            // 宽度
-                            if(prowidth1.compareTo(prowidth2) == 0){
-                                // 厚度
-                                if(thickness1.compareTo(thickness2) == 0){
-                                    // 合金状态
-                                    if(alloystatus1 == null || alloystatus2 == null || alloystatus1.compareTo(alloystatus2) == 0){
-                                        // 重量
-                                        if(singlerollweight1.compareTo(singlerollweight2) == 0){
-//                                            a = 0;
-                                            // 卷数从大到小
-                                            a = v2.getRollnum().compareTo(v1.getRollnum());
-                                        }else if(singlerollweight1.compareTo(singlerollweight2) > 0){
-                                            a = -1;
-                                        }else{
-                                            a = 1;
-                                        }
-                                    }else{
-                                        a = alloystatus1.compareTo(alloystatus2);
-                                    }
-                                }else{
-                                    if(thickness1.compareTo(thickness2) > 0){
-                                        a = -1;
-                                    }else{
-                                        a = 1;
-                                    }
-                                }
-                            }else{
-                                if(prowidth1.compareTo(prowidth2) > 0){
-                                    a = -1;
-                                }else{
-                                    a = 1;
-                                }
-                            }
-                        }else{
-                            a = producttype1.compareTo(producttype2);
-                        }
-                    }else{
-                        a = alloy1.compareTo(alloy2);
+                // 插单重排会优先排插单再排程其它的订单
+                if("cd".equals(apsType) && apsBlankOrders != null && apsBlankOrders.size()>0){
+                    apsOrderSchedule(apsBlankOrders);
+                    List<ApsBlankOrderVo> fbNotLock = apsBlankOrderDao.getOrdersHasNotLockProcess(idStrs,tenantId);
+                    if (fbNotLock != null && fbNotLock.size() > 0) {
+                        apsOrderSchedule(fbNotLock);
                     }
-                    return a;
-                });
-                // 排程前解锁所有待排程订单
-                List<String> blankOrderIds = new ArrayList<>();
-                apsBlankOrders.forEach((bo)->{
-                    blankOrderIds.add(bo.getId());
-                });
-                processOperationProcessEquService.update(new LambdaUpdateWrapper<ApsProcessOperationProcessEquDo>().set(ApsProcessOperationProcessEquDo::getLockmark,"n")
-                        .in(ApsProcessOperationProcessEquDo::getBlankid,blankOrderIds));
-                // 更新待排程的锁定的作业
-                if(blankOrderIds != null && blankOrderIds.size()>0){
-                    String blankidStrs = CollUtil.join(blankOrderIds, "','");
-                    blankidStrs = "'" + blankidStrs + "'";
-                    apsBlankOrderDao.setLockMarkNullByToAps(blankidStrs);
-                }
-                // 排程
-                List<ProductionScheduleVo> productionScheduleVos = new ArrayList<>();
-                Map<String,List<ApsBlankOrderVo>> dataMap = new HashMap<>();
-                Map<String,ApsBlankOrderVo> dataMapOrder = new HashMap<>();
-                JSONConfig jsonConfig = JSONConfig.create();
-                jsonConfig.setDateFormat("yyyy-MM-dd HH:mm:ss");
-                List<ApsScheduleConfigDo> apsConfigs = apsScheduleConfigService.list();
-                // 所有设备
-                List<AspCheckItemsDo> eqs = aspCheckItemsService.list(new LambdaQueryWrapper<>());
-                Map<String, AspCheckItemsDo> eqMaps = new HashMap<>();
-                for (AspCheckItemsDo eq : eqs) {
-                    eqMaps.put(eq.getId(), eq);
+                }else{
+                    List<ApsBlankOrderVo> fbNotLock = apsBlankOrderDao.getOrdersHasNotLockProcess(idStrs,tenantId);
+                    if (fbNotLock != null && fbNotLock.size() > 0) {
+                        apsBlankOrders.addAll(fbNotLock);
+                    }
+                    apsOrderSchedule(apsBlankOrders);
                 }
-                // 1卷一起排
-                List<ApsBlankOrderVo> singleApsList = new ArrayList<>();
-                // 多卷先排
-                apsBlankOrders.forEach((bo)->{
-                    /*if(bo.getRollnum() == 1){
-                        singleApsList.add(bo);
-                    }else{*/
-                        List<ApsBlankOrderVo> v = new ArrayList<>();
-                        v.add(bo);
-                        dataMapOrder.put(bo.getId(),bo);
-
-                        // 模型转换
-                        ProductionScheduleVo productionScheduleVo = apsProductionScheduleInit(v);
-                        productionScheduleVos.add(productionScheduleVo);
-                        dataMap.put(productionScheduleVo.getProductionScheduleId(),v);
-//                        int mergeThNum = mergeThNum(bo, productionScheduleVo);
-                        // 排程计划设备集合
-                        List<Equipment> equipmentList1 = new ArrayList<>();
-                        List<ApsProcessOperationDo> operationDos1 = apsProcessOperationService.list(new LambdaQueryWrapper<ApsProcessOperationDo>()
-                                .in(ApsProcessOperationDo::getBlankid, bo.getId()));
-                        List<String> blankids = new ArrayList<>();
-                        blankids.add(bo.getId());
-                        for (ApsProcessOperationDo operationDo : operationDos1) {
-                            List<String> optionalEquipments = equipmentListInit(operationDo,equipmentList1,eqMaps,blankids,null,productionScheduleVo,apsConfigs.get(0));
-                        }
-                        productionScheduleVo.setEquipmentList(equipmentList1);
-
-                        System.out.println("排程数据:" + JSONUtil.toJsonStr(productionScheduleVo, jsonConfig));
-                        logger.info("排程数据:" + JSONUtil.toJsonStr(productionScheduleVo, jsonConfig));
-                        // APS平台排程接口调用
-                        ProductionScheduleRetVo productionScheduleRetVo = rwApsServer.productionSchedule(productionScheduleVo);
-                        if (!"200".equals(productionScheduleRetVo.getCode())) {
-                            logger.info("排程异常,坯料计划ID:" + bo.getId());
-                            /*processOperationProcessEquService.update(new LambdaUpdateWrapper<ApsProcessOperationProcessEquDo>().set(ApsProcessOperationProcessEquDo::getLockmark,"y")
-                                    .in(ApsProcessOperationProcessEquDo::getBlankid,blankOrderIds));*/
-                            throw new CustomException(productionScheduleRetVo.getMsg());
-                        }
-                        // 获取坯料计划
-                        List<ApsBlankOrderVo> apsBlankOrderss = new ArrayList<>();
-                        apsBlankOrderss.add(bo);
-                        apsBlankOrderService.apsAfter(productionScheduleRetVo,apsBlankOrderss);
-//                    }
-
-                    /*if(bo.getRollnum()>mergeThNum){
-                        Map<String,ProductionProcesses> allProcesses = new HashMap<>();
-                        List<ProductionProcesses> rootProcesses = new ArrayList<>();
-                        for (ProductionProcesses process : productionScheduleVo.getProcesses()) {
-                            allProcesses.put(process.getId(),process);
-                            if(process.getPreviousProcessesIds() == null || process.getPreviousProcessesIds().size() == 0){
-                                rootProcesses.add(process);
-                            }
-                        }
-
-                        // 坯料计划排序
-                        Collections.sort(rootProcesses,(v1,v2)->{
-                            // 合金
-                            String alloy1 = v1.getVolumeMetal();
-                            String alloy2 = v2.getVolumeMetal();
-                            // 合金状态
-                            String alloystatus1 = v1.getVolumeMetalstate();
-                            String alloystatus2 = v2.getVolumeMetalstate();
-                            // 产品类型
-                            String producttype1 = v1.getProducttype();
-                            String producttype2 = v2.getProducttype();
-                            // 宽度
-                            BigDecimal prowidth1 = v1.getVolumeWidth();
-                            BigDecimal prowidth2 = v2.getVolumeWidth();
-                            // 厚度
-                            BigDecimal thickness1 = v1.getVolumeThickness();
-                            BigDecimal thickness2 = v2.getVolumeThickness();
-                            // 重量
-                            BigDecimal singlerollweight1 = v1.getSinglerollweight();
-                            BigDecimal singlerollweight2 = v2.getSinglerollweight();
-
-                            int a = 0;
-                            // 宽度
-                            if(prowidth1.compareTo(prowidth2) == 0){
-                                // 合金
-                                if(alloy1.compareTo(alloy2) == 0){
-                                    // 产品类型
-                                    if(producttype1 == null || producttype2 == null || producttype1.compareTo(producttype2) == 0){
-                                        // 厚度
-                                        if(thickness1.compareTo(thickness2) == 0){
-                                            // 合金状态
-                                            if(alloystatus1 == null || alloystatus2 == null || alloystatus1.compareTo(alloystatus2) == 0){
-                                                // 重量
-                                                if(singlerollweight1.compareTo(singlerollweight2) == 0){
-                                                    a = 0;
-                                                }else if(singlerollweight1.compareTo(singlerollweight2) > 0){
-                                                    a = -1;
-                                                }else{
-                                                    a = 1;
-                                                }
-                                            }else{
-                                                a = alloystatus1.compareTo(alloystatus2);
-                                            }
-                                        }else{
-                                            if(thickness1.compareTo(thickness2) > 0){
-                                                a = -1;
-                                            }else{
-                                                a = 1;
-                                            }
-                                        }
-                                    }else{
-                                        a = producttype1.compareTo(producttype2);
-                                    }
-                                }else{
-                                    a = alloy1.compareTo(alloy2);
-                                }
-                            }else{
-                                if(prowidth1.compareTo(prowidth2) > 0){
-                                    a = -1;
-                                }else{
-                                    a = 1;
-                                }
-                            }
-                            return a;
-                        });
-                        List<List<ProductionProcesses>> chunks = new ArrayList<>();
-                        int listSize = rootProcesses.size();
-                        for (int i = 0; i < listSize; i += mergeThNum) {
-                            chunks.add(rootProcesses.subList(i, Math.min(i + mergeThNum, listSize)));
-                        }
 
-                        // 全部排程,每4个一组
-                        for (List<ProductionProcesses> rootpros : chunks) {
-//                            ProductionScheduleVo productionScheduleVo = productionScheduleVoInit();
-                            // 工序作业ID
-                            Set<String> opId = new LinkedHashSet<>();
-                            Set<String> orderIds = new LinkedHashSet<>();
-                            List<ProductionProcesses> pssall = new ArrayList<>();
-                            for (ProductionProcesses processes : rootpros) {
-                                pssall.add(processes);
-                                for (String s : processes.getBsProcessesId()) {
-                                    opId.add(s);
-                                }
-                                for (ProduceOrder produceOrder : processes.getProduceOrder()) {
-                                    orderIds.add(produceOrder.getId());
-                                }
-                                getAllNextPross(processes,allProcesses,pssall,opId);
-                            }
-                            // 排程计划设备集合
-                            List<Equipment> equipmentList1 = new ArrayList<>();
-                            List<ApsProcessOperationDo> operationDos1 = apsProcessOperationService.list(new LambdaQueryWrapper<ApsProcessOperationDo>()
-                                    .in(ApsProcessOperationDo::getId, opId));
-                            for (ApsProcessOperationDo operationDo : operationDos1) {
-                                List<String> optionalEquipments = equipmentListInit(operationDo,equipmentList1,eqMaps,null,opId,productionScheduleVo,apsConfigs.get(0));
-                            }
-                            productionScheduleVo.setEquipmentList(equipmentList1);
-                            productionScheduleVo.setProcesses(pssall);
 
-                            System.out.println("排程数据:" + JSONUtil.toJsonStr(productionScheduleVo, jsonConfig));
-                            logger.info("排程数据:" + JSONUtil.toJsonStr(productionScheduleVo, jsonConfig));
-                            // APS平台排程接口调用
-                            ProductionScheduleRetVo productionScheduleRetVo = rwApsServer.productionSchedule(productionScheduleVo);
-                            if (!"200".equals(productionScheduleRetVo.getCode())) {
-                                throw new CustomException(productionScheduleRetVo.getMsg());
-                            }
-                            // 获取坯料计划
-                            List<ApsBlankOrderVo> apsBlankOrderss = new ArrayList<>();
-                            apsBlankOrderss.add(bo);
-                            apsBlankOrderService.apsAfter(productionScheduleRetVo,apsBlankOrderss);
-                        }
-                    }else{*/
-
-//                    }
-                });
                 // 1卷排程
                 /*if(singleApsList != null && singleApsList.size()>0){
                     // 模型转换
@@ -660,6 +414,262 @@ public class ApsServiceImpl implements ApsService {
         }
     }
 
+    private void apsOrderSchedule(List<ApsBlankOrderVo> apsBlankOrders){
+        // 坯料计划排序
+        Collections.sort(apsBlankOrders,(v1,v2)->{
+            // 合金
+            String alloy1 = v1.getAlloy();
+            String alloy2 = v2.getAlloy();
+            // 合金状态
+            String alloystatus1 = v1.getAlloystatus();
+            String alloystatus2 = v2.getAlloystatus();
+            // 产品类型
+            String producttype1 = v1.getProducttype();
+            String producttype2 = v2.getProducttype();
+            // 宽度
+            BigDecimal prowidth1 = v1.getProwidth();
+            BigDecimal prowidth2 = v2.getProwidth();
+            // 厚度
+            BigDecimal thickness1 = v1.getThickness();
+            BigDecimal thickness2 = v2.getThickness();
+            // 重量
+            BigDecimal singlerollweight1 = v1.getSinglerollweight();
+            BigDecimal singlerollweight2 = v2.getSinglerollweight();
+
+            int a = 0;
+            // 合金
+            if(alloy1.compareTo(alloy2) == 0){
+                // 产品类型
+                if(producttype1 == null || producttype2 == null || producttype1.compareTo(producttype2) == 0){
+                    // 宽度
+                    if(prowidth1.compareTo(prowidth2) == 0){
+                        // 厚度
+                        if(thickness1.compareTo(thickness2) == 0){
+                            // 合金状态
+                            if(alloystatus1 == null || alloystatus2 == null || alloystatus1.compareTo(alloystatus2) == 0){
+                                // 重量
+                                if(singlerollweight1.compareTo(singlerollweight2) == 0){
+//                                            a = 0;
+                                    // 卷数从大到小
+                                    a = v2.getRollnum().compareTo(v1.getRollnum());
+                                }else if(singlerollweight1.compareTo(singlerollweight2) > 0){
+                                    a = -1;
+                                }else{
+                                    a = 1;
+                                }
+                            }else{
+                                a = alloystatus1.compareTo(alloystatus2);
+                            }
+                        }else{
+                            if(thickness1.compareTo(thickness2) > 0){
+                                a = -1;
+                            }else{
+                                a = 1;
+                            }
+                        }
+                    }else{
+                        if(prowidth1.compareTo(prowidth2) > 0){
+                            a = -1;
+                        }else{
+                            a = 1;
+                        }
+                    }
+                }else{
+                    a = producttype1.compareTo(producttype2);
+                }
+            }else{
+                a = alloy1.compareTo(alloy2);
+            }
+            return a;
+        });
+        // 排程前解锁所有待排程订单
+        List<String> blankOrderIds = new ArrayList<>();
+        apsBlankOrders.forEach((bo)->{
+            blankOrderIds.add(bo.getId());
+        });
+        processOperationProcessEquService.update(new LambdaUpdateWrapper<ApsProcessOperationProcessEquDo>().set(ApsProcessOperationProcessEquDo::getLockmark,"n")
+                .in(ApsProcessOperationProcessEquDo::getBlankid,blankOrderIds));
+        // 更新待排程的锁定的作业
+        if(blankOrderIds != null && blankOrderIds.size()>0){
+            String blankidStrs = CollUtil.join(blankOrderIds, "','");
+            blankidStrs = "'" + blankidStrs + "'";
+            apsBlankOrderDao.setLockMarkNullByToAps(blankidStrs);
+        }
+        // 排程
+        List<ProductionScheduleVo> productionScheduleVos = new ArrayList<>();
+        Map<String,List<ApsBlankOrderVo>> dataMap = new HashMap<>();
+        Map<String,ApsBlankOrderVo> dataMapOrder = new HashMap<>();
+        JSONConfig jsonConfig = JSONConfig.create();
+        jsonConfig.setDateFormat("yyyy-MM-dd HH:mm:ss");
+        List<ApsScheduleConfigDo> apsConfigs = apsScheduleConfigService.list();
+        // 所有设备
+        List<AspCheckItemsDo> eqs = aspCheckItemsService.list(new LambdaQueryWrapper<>());
+        Map<String, AspCheckItemsDo> eqMaps = new HashMap<>();
+        for (AspCheckItemsDo eq : eqs) {
+            eqMaps.put(eq.getId(), eq);
+        }
+        // 1卷一起排
+        List<ApsBlankOrderVo> singleApsList = new ArrayList<>();
+        // 多卷先排
+        apsBlankOrders.forEach((bo)->{
+            List<ApsBlankOrderVo> v = new ArrayList<>();
+            v.add(bo);
+            dataMapOrder.put(bo.getId(),bo);
+
+            // 模型转换
+            ProductionScheduleVo productionScheduleVo = apsProductionScheduleInit(v);
+            productionScheduleVos.add(productionScheduleVo);
+            dataMap.put(productionScheduleVo.getProductionScheduleId(),v);
+//                        int mergeThNum = mergeThNum(bo, productionScheduleVo);
+            // 排程计划设备集合
+            List<Equipment> equipmentList1 = new ArrayList<>();
+            List<ApsProcessOperationDo> operationDos1 = apsProcessOperationService.list(new LambdaQueryWrapper<ApsProcessOperationDo>()
+                    .in(ApsProcessOperationDo::getBlankid, bo.getId()));
+            List<String> blankids = new ArrayList<>();
+            blankids.add(bo.getId());
+            for (ApsProcessOperationDo operationDo : operationDos1) {
+                List<String> optionalEquipments = equipmentListInit(operationDo,equipmentList1,eqMaps,blankids,null,productionScheduleVo,apsConfigs.get(0));
+            }
+            productionScheduleVo.setEquipmentList(equipmentList1);
+
+            System.out.println("排程数据:" + JSONUtil.toJsonStr(productionScheduleVo, jsonConfig));
+            logger.info("排程数据:" + JSONUtil.toJsonStr(productionScheduleVo, jsonConfig));
+            // APS平台排程接口调用
+            ProductionScheduleRetVo productionScheduleRetVo = rwApsServer.productionSchedule(productionScheduleVo);
+            if (!"200".equals(productionScheduleRetVo.getCode())) {
+                logger.info("排程异常,坯料计划ID:" + bo.getId());
+                            /*processOperationProcessEquService.update(new LambdaUpdateWrapper<ApsProcessOperationProcessEquDo>().set(ApsProcessOperationProcessEquDo::getLockmark,"y")
+                                    .in(ApsProcessOperationProcessEquDo::getBlankid,blankOrderIds));*/
+                throw new CustomException(productionScheduleRetVo.getMsg());
+            }
+            // 获取坯料计划
+            List<ApsBlankOrderVo> apsBlankOrderss = new ArrayList<>();
+            apsBlankOrderss.add(bo);
+            apsBlankOrderService.apsAfter(productionScheduleRetVo,apsBlankOrderss);
+                    /*if(bo.getRollnum()>mergeThNum){
+                        Map<String,ProductionProcesses> allProcesses = new HashMap<>();
+                        List<ProductionProcesses> rootProcesses = new ArrayList<>();
+                        for (ProductionProcesses process : productionScheduleVo.getProcesses()) {
+                            allProcesses.put(process.getId(),process);
+                            if(process.getPreviousProcessesIds() == null || process.getPreviousProcessesIds().size() == 0){
+                                rootProcesses.add(process);
+                            }
+                        }
+
+                        // 坯料计划排序
+                        Collections.sort(rootProcesses,(v1,v2)->{
+                            // 合金
+                            String alloy1 = v1.getVolumeMetal();
+                            String alloy2 = v2.getVolumeMetal();
+                            // 合金状态
+                            String alloystatus1 = v1.getVolumeMetalstate();
+                            String alloystatus2 = v2.getVolumeMetalstate();
+                            // 产品类型
+                            String producttype1 = v1.getProducttype();
+                            String producttype2 = v2.getProducttype();
+                            // 宽度
+                            BigDecimal prowidth1 = v1.getVolumeWidth();
+                            BigDecimal prowidth2 = v2.getVolumeWidth();
+                            // 厚度
+                            BigDecimal thickness1 = v1.getVolumeThickness();
+                            BigDecimal thickness2 = v2.getVolumeThickness();
+                            // 重量
+                            BigDecimal singlerollweight1 = v1.getSinglerollweight();
+                            BigDecimal singlerollweight2 = v2.getSinglerollweight();
+
+                            int a = 0;
+                            // 宽度
+                            if(prowidth1.compareTo(prowidth2) == 0){
+                                // 合金
+                                if(alloy1.compareTo(alloy2) == 0){
+                                    // 产品类型
+                                    if(producttype1 == null || producttype2 == null || producttype1.compareTo(producttype2) == 0){
+                                        // 厚度
+                                        if(thickness1.compareTo(thickness2) == 0){
+                                            // 合金状态
+                                            if(alloystatus1 == null || alloystatus2 == null || alloystatus1.compareTo(alloystatus2) == 0){
+                                                // 重量
+                                                if(singlerollweight1.compareTo(singlerollweight2) == 0){
+                                                    a = 0;
+                                                }else if(singlerollweight1.compareTo(singlerollweight2) > 0){
+                                                    a = -1;
+                                                }else{
+                                                    a = 1;
+                                                }
+                                            }else{
+                                                a = alloystatus1.compareTo(alloystatus2);
+                                            }
+                                        }else{
+                                            if(thickness1.compareTo(thickness2) > 0){
+                                                a = -1;
+                                            }else{
+                                                a = 1;
+                                            }
+                                        }
+                                    }else{
+                                        a = producttype1.compareTo(producttype2);
+                                    }
+                                }else{
+                                    a = alloy1.compareTo(alloy2);
+                                }
+                            }else{
+                                if(prowidth1.compareTo(prowidth2) > 0){
+                                    a = -1;
+                                }else{
+                                    a = 1;
+                                }
+                            }
+                            return a;
+                        });
+                        List<List<ProductionProcesses>> chunks = new ArrayList<>();
+                        int listSize = rootProcesses.size();
+                        for (int i = 0; i < listSize; i += mergeThNum) {
+                            chunks.add(rootProcesses.subList(i, Math.min(i + mergeThNum, listSize)));
+                        }
+
+                        // 全部排程,每4个一组
+                        for (List<ProductionProcesses> rootpros : chunks) {
+//                            ProductionScheduleVo productionScheduleVo = productionScheduleVoInit();
+                            // 工序作业ID
+                            Set<String> opId = new LinkedHashSet<>();
+                            Set<String> orderIds = new LinkedHashSet<>();
+                            List<ProductionProcesses> pssall = new ArrayList<>();
+                            for (ProductionProcesses processes : rootpros) {
+                                pssall.add(processes);
+                                for (String s : processes.getBsProcessesId()) {
+                                    opId.add(s);
+                                }
+                                for (ProduceOrder produceOrder : processes.getProduceOrder()) {
+                                    orderIds.add(produceOrder.getId());
+                                }
+                                getAllNextPross(processes,allProcesses,pssall,opId);
+                            }
+                            // 排程计划设备集合
+                            List<Equipment> equipmentList1 = new ArrayList<>();
+                            List<ApsProcessOperationDo> operationDos1 = apsProcessOperationService.list(new LambdaQueryWrapper<ApsProcessOperationDo>()
+                                    .in(ApsProcessOperationDo::getId, opId));
+                            for (ApsProcessOperationDo operationDo : operationDos1) {
+                                List<String> optionalEquipments = equipmentListInit(operationDo,equipmentList1,eqMaps,null,opId,productionScheduleVo,apsConfigs.get(0));
+                            }
+                            productionScheduleVo.setEquipmentList(equipmentList1);
+                            productionScheduleVo.setProcesses(pssall);
+
+                            System.out.println("排程数据:" + JSONUtil.toJsonStr(productionScheduleVo, jsonConfig));
+                            logger.info("排程数据:" + JSONUtil.toJsonStr(productionScheduleVo, jsonConfig));
+                            // APS平台排程接口调用
+                            ProductionScheduleRetVo productionScheduleRetVo = rwApsServer.productionSchedule(productionScheduleVo);
+                            if (!"200".equals(productionScheduleRetVo.getCode())) {
+                                throw new CustomException(productionScheduleRetVo.getMsg());
+                            }
+                            // 获取坯料计划
+                            List<ApsBlankOrderVo> apsBlankOrderss = new ArrayList<>();
+                            apsBlankOrderss.add(bo);
+                            apsBlankOrderService.apsAfter(productionScheduleRetVo,apsBlankOrderss);
+                        }
+                    }else{*/
+        });
+    }
+
     /**
      * 计算合并退火的个数
      * @return

+ 1 - 1
cx-aps/cx-aps-server/src/main/java/com/rongwei/bsserver/controller/ApsBlankOrderController.java

@@ -135,7 +135,7 @@ public class ApsBlankOrderController {
                 Thread thread = new Thread(() -> {
 //                        apsBlankOrderService.apsReScheduling();
                     List<ApsBlankOrderVo> apsBlankOrders = new ArrayList<>();
-                    apsService.apsSchedule(apsBlankOrders);
+                    apsService.apsSchedule(apsBlankOrders,null);
                 });
                 thread.start(); // 启动线程
                 return resData;