Prechádzať zdrojové kódy

排程数据组装优化

fangpy 10 mesiacov pred
rodič
commit
98dd56b9bf

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

@@ -558,135 +558,20 @@ public class ApsServiceImpl implements ApsService {
             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());
+                // 排程异常后恢复历史排程结果为锁定状态
+                processOperationProcessEquService.update(new LambdaUpdateWrapper<ApsProcessOperationProcessEquDo>().set(ApsProcessOperationProcessEquDo::getLockmark,"y")
+                        .eq(ApsProcessOperationProcessEquDo::getBlankid,bo.getId()));
+                // 没有可排程工序的订单跳过
+                if("没有可排程的工序".equals(productionScheduleRetVo.getMsg())){
+                    logger.info("排程异常:没有可排程的工序,坯料计划编号:" + bo.getBlanknumber());
+                }else{
+                    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{*/
         });
     }