浏览代码

Merge branch 'refs/heads/mode-min-unit' into mode-min-unit-xh

xiahan 1 年之前
父节点
当前提交
c669d54687

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

@@ -600,8 +600,8 @@ public class ApsBlankOrderServiceImpl extends ServiceImpl<ApsBlankOrderDao, ApsB
                     apsProcessOperationProcessEqu.setPlanenddate(Date.from(process.getEndTime().atZone(ZoneId.systemDefault()).toInstant()));
                     if ("小卷成退".equals(process.getProcessType()) || "小卷包装".equals(process.getProcessType())) {
                         apsProcessOperationProcessEqu.setPlanprocessrall(process.getMinThPcNum());
-                    } else {
-                        apsProcessOperationProcessEqu.setPlanprocessrall(1);
+                    }else{
+                        apsProcessOperationProcessEqu.setPlanprocessrall(process.getOpeProducePcNum());
                     }
                     apsProcessOperationProcessEqu.setHasconflict(process.getHasConflict());
                     apsProcessOperationProcessEqu.setConflictdes(process.getConflictDes());

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

@@ -142,7 +142,9 @@ public class ApsServiceImpl implements ApsService {
                                     if(alloystatus1 == null || alloystatus2 == null || alloystatus1.compareTo(alloystatus2) == 0){
                                         // 重量
                                         if(singlerollweight1.compareTo(singlerollweight2) == 0){
-                                            a = 0;
+//                                            a = 0;
+                                            // 卷数从大到小
+                                            a = v2.getRollnum().compareTo(v1.getRollnum());
                                         }else if(singlerollweight1.compareTo(singlerollweight2) > 0){
                                             a = -1;
                                         }else{
@@ -184,7 +186,9 @@ public class ApsServiceImpl implements ApsService {
                 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<>();
@@ -199,13 +203,156 @@ public class ApsServiceImpl implements ApsService {
                     ProductionScheduleVo productionScheduleVo = apsProductionScheduleInit(v);
                     productionScheduleVos.add(productionScheduleVo);
                     dataMap.put(productionScheduleVo.getProductionScheduleId(),v);
+
+                    int mergeThNum = mergeThNum(bo, productionScheduleVo);
+                    /*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{*/
+                        // 排程计划设备集合
+                        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())) {
+                            throw new CustomException(productionScheduleRetVo.getMsg());
+                        }
+                        // 获取坯料计划
+                        List<ApsBlankOrderVo> apsBlankOrderss = new ArrayList<>();
+                        apsBlankOrderss.add(bo);
+                        apsBlankOrderService.apsAfter(productionScheduleRetVo,apsBlankOrderss);
+//                    }
                 });
-                if(productionScheduleVos != null && productionScheduleVos.size()>0){
-                    JSONConfig jsonConfig = JSONConfig.create();
-                    jsonConfig.setDateFormat("yyyy-MM-dd HH:mm:ss");
-                    List<ApsScheduleConfigDo> apsConfigs = apsScheduleConfigService.list();
+                /*if(productionScheduleVos != null && productionScheduleVos.size()>0){
                     // 提前退火排程
-                    /*ProductionScheduleVo productionScheduleThVo = new ProductionScheduleVo();
+                    *//*ProductionScheduleVo productionScheduleThVo = new ProductionScheduleVo();
                     productionScheduleThVo.setProductionScheduleId("提前退火排程-"+SecurityUtil.getUUID());
                     productionScheduleThVo.setApsPlanStartDate(productionScheduleVos.get(0).getApsPlanStartDate());
                     productionScheduleThVo.setPlanSeconds(productionScheduleVos.get(0).getPlanSeconds());
@@ -250,7 +397,7 @@ public class ApsServiceImpl implements ApsService {
                     ProductionScheduleRetVo productionScheduleRetThVo = rwApsServer.productionThSchedule(productionScheduleThVo);
                     if (!"200".equals(productionScheduleRetThVo.getCode())) {
                         throw new CustomException(productionScheduleRetThVo.getMsg());
-                    }*/
+                    }*//*
 
                     // 全部排程,每4个一组
                     Map<String,ProductionProcesses> allProcesses = new HashMap<>();
@@ -263,6 +410,16 @@ public class ApsServiceImpl implements ApsService {
                             }
                         }
                     }
+
+                    for (ProductionScheduleVo productionScheduleVo : productionScheduleVos) {
+                        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)->{
                         // 合金
@@ -352,7 +509,7 @@ public class ApsServiceImpl implements ApsService {
                             getAllNextPross(processes,allProcesses,pssall,opId);
                         }
                         // 退火工序锁定
-                        /*if(productionScheduleRetThVo.getProcesses() != null && productionScheduleRetThVo.getProcesses().size()>0){
+                        *//*if(productionScheduleRetThVo.getProcesses() != null && productionScheduleRetThVo.getProcesses().size()>0){
                             for (ProductionProcesses process : pssall) {
                                 for (ProductionProcesses productionScheduleRetThVoProcess : productionScheduleRetThVo.getProcesses()) {
                                     if(productionScheduleRetThVoProcess.getId().equals(process.getId())){
@@ -367,7 +524,7 @@ public class ApsServiceImpl implements ApsService {
                                     }
                                 }
                             }
-                        }*/
+                        }*//*
                         // 排程计划设备集合
                         List<Equipment> equipmentList1 = new ArrayList<>();
                         List<ApsProcessOperationDo> operationDos1 = apsProcessOperationService.list(new LambdaQueryWrapper<ApsProcessOperationDo>()
@@ -397,7 +554,7 @@ public class ApsServiceImpl implements ApsService {
                         apsBlankOrderService.apsAfter(productionScheduleRetVo,apsBlankOrderss);
                     }
 
-                    /*for (ProductionScheduleVo productionScheduleVo : productionScheduleVos) {
+                    *//*for (ProductionScheduleVo productionScheduleVo : productionScheduleVos) {
                         // 退火工序锁定
                         if(productionScheduleRetThVo.getProcesses() != null && productionScheduleRetThVo.getProcesses().size()>0){
                             for (ProductionProcesses process : productionScheduleVo.getProcesses()) {
@@ -440,8 +597,8 @@ public class ApsServiceImpl implements ApsService {
                             throw new CustomException(productionScheduleRetVo.getMsg());
                         }
                         apsBlankOrderService.apsAfter(productionScheduleRetVo,dataMap.get(productionScheduleVo.getProductionScheduleId()));
-                    }*/
-                }
+                    }*//*
+                }*/
             } catch (Exception e) {
                 e.printStackTrace();
                 throw e;
@@ -453,6 +610,25 @@ public class ApsServiceImpl implements ApsService {
         }
     }
 
+    /**
+     * 计算合并退火的个数
+     * @return
+     */
+    private int mergeThNum(ApsBlankOrderVo apsBlankOrderVo,ProductionScheduleVo productionScheduleVo){
+        int a = 4;
+        List<ProductionProcesses> thpros = productionScheduleVo.getProcesses().stream().filter(v ->
+                v.getProcessType().equals("成退") || v.getProcessType().equals("小卷成退") || v.getProcessType().equals("中退")
+        ).collect(Collectors.toList());
+        if(thpros != null && thpros.size()>0){
+            String eqid = thpros.get(0).getOptionalEquipments().get(0);
+            AspCheckItemsDo checkItemsDo = aspCheckItemsService.getById(eqid);
+            if(checkItemsDo != null && checkItemsDo.getEquipmentbearing() != null){
+                a = checkItemsDo.getEquipmentbearing().divide(apsBlankOrderVo.getSinglerollweight(), 2, RoundingMode.HALF_UP).intValue();
+            }
+        }
+        return a;
+    }
+
     private void getAllNextPross(ProductionProcesses rootProcesses,Map<String,ProductionProcesses> allProcesses,List<ProductionProcesses> pss,Set<String> opId){
         if(rootProcesses.getNextProcessesIds() != null && rootProcesses.getNextProcessesIds().size()>0){
             for (String nextProcessesId : rootProcesses.getNextProcessesIds()) {
@@ -582,6 +758,10 @@ public class ApsServiceImpl implements ApsService {
         return productionScheduleVo;
     }
 
+    private void thMergePs(List<ApsProcessOperationDo> operationDos){
+
+    }
+
     private List<String> equipmentListInit(ApsProcessOperationDo operationDo,List<Equipment> equipmentList,Map<String, AspCheckItemsDo> eqMaps
             ,List<String> blankids,Set<String> opId,ProductionScheduleVo productionScheduleVo,ApsScheduleConfigDo apsScheduleConfig){
         // 设备列表
@@ -896,6 +1076,12 @@ public class ApsServiceImpl implements ApsService {
                     processes.setDelay(0);
                     processes.setStartTime(processDetail.getPlanstartdate().toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime());
                     processes.setEndTime(processDetail.getPlanenddate().toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime());
+                    if("小卷成退".equals(operationDo.getProcess()) || "小卷包装".equals(operationDo.getProcess())){
+                        String previousprocessid = operationDo.getPreviousprocessid();
+                        ApsProcessOperationDo preprocess = apsProcessOperationService.getById(previousprocessid);
+                        processes.setMinThPcNum(processDetail.getPlanprocessrall());
+                        processes.setProducePcNum(preprocess.getPlanprocessrall());
+                    }
                     operationProcess.add(processes);
                 }
             }else{
@@ -932,6 +1118,7 @@ public class ApsServiceImpl implements ApsService {
                         if(i<ys){
                             alls = alls + 1;
                         }
+                        processes.setProducePcNum(planprocessrall);
                         processes.setMinThPcNum(alls);
                         processes.setSinglerollweight(operationDo.getSinglerollweight().multiply(new BigDecimal(alls)));
 
@@ -974,6 +1161,7 @@ public class ApsServiceImpl implements ApsService {
                         if(i<ys){
                             alls = alls + 1;
                         }
+                        processes.setProducePcNum(planprocessrall);
                         processes.setMinThPcNum(alls);
                         processes.setProduceTime(operationDo.getOnceprocessmin().intValue() * alls);
 
@@ -1025,6 +1213,7 @@ public class ApsServiceImpl implements ApsService {
         processes.setOptionalEquipments(optionalEquipments);
         // 批次
         processes.setProducePcNum(operationDo.getPlanprocessrall());
+        processes.setOpeProducePcNum(1);
         processes.setProcessType(operationDo.getProcess());
         // 单次加工时长
         if(operationDo.getOnceprocessmin() == null){

+ 13 - 0
cx-aps/cx-aps-entity/src/main/java/com/rongwei/bsentity/vo/ProductionProcesses.java

@@ -121,6 +121,11 @@ public class ProductionProcesses{
      */
     private Integer producePcNum;
 
+    /**
+     * 当前作业加工卷数
+     */
+    private Integer opeProducePcNum;
+
     /**
      * 小卷退火加工卷数
      */
@@ -558,4 +563,12 @@ public class ProductionProcesses{
     public void setMinThPcNum(Integer minThPcNum) {
         this.minThPcNum = minThPcNum;
     }
+
+    public Integer getOpeProducePcNum() {
+        return opeProducePcNum;
+    }
+
+    public void setOpeProducePcNum(Integer opeProducePcNum) {
+        this.opeProducePcNum = opeProducePcNum;
+    }
 }