春风项目四线(合箱线、总装线)
吴健
9 天以前 8b43954926db6b4df6a61ab6e04d6cb11189069d
jcdm-main/src/main/java/com/jcdm/main/plcserver/sub/OPCUaSubscription.java
@@ -88,7 +88,7 @@
    public void onSubscribe(String identifier, Object value) {
        String ecpStr = "";//异常记录标记
        try {
            if(null != value && "1".equals(value.toString())) {
                 if(null != value && "1".equals(value.toString())) {
                //1、检索SN号
                //2、过站参数采集
                //3、扫码枪数据回传
@@ -127,6 +127,9 @@
                                        passingStationCollectionServiceImpl.sendMessage(type+"*"+boxCode,"OP030");
                                    }
                                } else if ("196".equals(type) || "296".equals(type)){
                                    ReadWriteEntity entity6 = new ReadWriteEntity("CFL4HX.OP030.CodeComplete", 1);
                                    miloService.writeToOpcByte(entity6);
                                }
                            }
@@ -169,23 +172,48 @@
                            Object SNCodeObject = miloService.readFromOpcUa("CFL4HX.OP020.Code").getValue();
                            if (ObjectUtil.isNotEmpty(SNCodeObject)){
                                String snCode = SNCodeObject.toString();
                                if (snCode.startsWith("380")){
                                    log.info("enter-380");
                                    String[] split = snCode.split(StrUtil.SPACE);
                                    if (split.length>1){
                                        ReadWriteEntity entity = new ReadWriteEntity("CFL4HX.OP020.PrintSN1", split[0]);
                                        OPCUaSubscription.miloService.writeToOpcUa(entity);//写完成
                                        ReadWriteEntity entity2 = new ReadWriteEntity("CFL4HX.OP020.PrintSN2", "☆"+split[1]+"☆");
                                        OPCUaSubscription.miloService.writeToOpcUa(entity2);//写完成
                                        ReadWriteEntity entity3 = new ReadWriteEntity("CFL4HX.OP020.SendSNDone", 1);
                                DaPassingStationCollection passingStationCollectionCheck = new DaPassingStationCollection();
                                passingStationCollectionCheck.setLocationCode("OP020");
                                passingStationCollectionCheck.setSfcCode(snCode);
                                List<DaPassingStationCollection> checkList = passingStationCollectionServiceImpl.selectDaPassingStationCollectionList(passingStationCollectionCheck);
                                if (CollUtil.isNotEmpty(checkList)){
                                    if (snCode.startsWith("380")){
                                        log.info("enter-380");
                                        String[] split = snCode.split(StrUtil.SPACE);
                                        if (split.length>1){
                                            ReadWriteEntity entity = new ReadWriteEntity("CFL4HX.OP020.PrintSN1", split[0]);
                                            OPCUaSubscription.miloService.writeToOpcUa(entity);//写完成
                                            ReadWriteEntity entity2 = new ReadWriteEntity("CFL4HX.OP020.PrintSN2", "☆"+split[1]+"☆");
                                            OPCUaSubscription.miloService.writeToOpcUa(entity2);//写完成
                                            ReadWriteEntity entity3 = new ReadWriteEntity("CFL4HX.OP020.SendSNDone", 2);
                                            OPCUaSubscription.miloService.writeToOpcByte(entity3);//写完成
                                        }
                                    } else {
                                        ReadWriteEntity entity = new ReadWriteEntity("CFL4HX.OP020.PrintSN1", snCode);
                                        OPCUaSubscription.miloService.writeToOpcByte(entity);//写完成
                                        ReadWriteEntity entity3 = new ReadWriteEntity("CFL4HX.OP020.SendSNDone", 2);
                                        OPCUaSubscription.miloService.writeToOpcByte(entity3);//写完成
                                    }
                                } else {
                                    ReadWriteEntity entity = new ReadWriteEntity("CFL4HX.OP020.PrintSN1", snCode);
                                    OPCUaSubscription.miloService.writeToOpcByte(entity);//写完成
                                    ReadWriteEntity entity3 = new ReadWriteEntity("CFL4HX.OP020.SendSNDone", 1);
                                    OPCUaSubscription.miloService.writeToOpcByte(entity3);//写完成
                                    if (snCode.startsWith("380")){
                                        log.info("enter-380");
                                        String[] split = snCode.split(StrUtil.SPACE);
                                        if (split.length>1){
                                            ReadWriteEntity entity = new ReadWriteEntity("CFL4HX.OP020.PrintSN1", split[0]);
                                            OPCUaSubscription.miloService.writeToOpcUa(entity);//写完成
                                            ReadWriteEntity entity2 = new ReadWriteEntity("CFL4HX.OP020.PrintSN2", "☆"+split[1]+"☆");
                                            OPCUaSubscription.miloService.writeToOpcUa(entity2);//写完成
                                            ReadWriteEntity entity3 = new ReadWriteEntity("CFL4HX.OP020.SendSNDone", 1);
                                            OPCUaSubscription.miloService.writeToOpcByte(entity3);//写完成
                                        }
                                    } else {
                                        ReadWriteEntity entity = new ReadWriteEntity("CFL4HX.OP020.PrintSN1", snCode);
                                        OPCUaSubscription.miloService.writeToOpcByte(entity);//写完成
                                        ReadWriteEntity entity3 = new ReadWriteEntity("CFL4HX.OP020.SendSNDone", 1);
                                        OPCUaSubscription.miloService.writeToOpcByte(entity3);//写完成
                                    }
                                }
                            }
                        } else if (OPCElement.OP030_SAVE_REQUEST.equals(identifier)) {
                            cleanForm("CFL4HX.OP030.SaveFeed");
@@ -238,6 +266,27 @@
                List<BsOrderScheduling> queryOrderList = bsOrderSchedulingService.selectBsOrderSchedulingList(bsOrderSchedulingQuery);
                if (CollUtil.isNotEmpty(queryOrderList)){
                    a = "1";
                    //如果是老车型,判断是否重复扫码
                    if (OPCElement.OP050_CODE_CHECK.equals(Node)){
                        String type = productNewFlag(SNCode);
                        if (!"280".equals(type) && !"380".equals(type) && !"196".equals(type) && !"296".equals(type) ){
                            DaPassingStationCollection passCheck = new DaPassingStationCollection();
                            passCheck.setSfcCode(SNCode);
                            passCheck.setLocationCode("OP060");
                            List<DaPassingStationCollection> passCheckList = passingStationCollectionServiceImpl.selectDaPassingStationCollectionList(passCheck);
                            if (CollUtil.isNotEmpty(passCheckList)){
                                //是否返修
                                a = "5";
//                                RmRepairRecord repairRecordCheck = new RmRepairRecord();
//                                repairRecordCheck.setBoxCode(SNCode);
//                                repairRecordCheck.setProcessesCode("OP050");
//                                List<RmRepairRecord> repairCheckList = rmRepairRecordService.selectRmRepairRecordList(repairRecordCheck);
//                                if (CollUtil.isEmpty(repairCheckList)){
//
//                                }
                            }
                        }
                    }
                }else {
                    a = "4";
                }
@@ -270,6 +319,23 @@
                }
                logger.info("-----返回codeCheckFeed-----,{}",a);
//                String a="1";
                //zz上线工位查询hx线是否过站合格
                if (OPCElement.OP120_ZZ_CODE_CHECK.equals(Node)){
                    //过站记录
                    DaPassingStationCollection PassingStationCollection=new DaPassingStationCollection();
                    PassingStationCollection.setSfcCode(SNCode);
                    PassingStationCollection.setLocationCode("OP160");
                    List<DaPassingStationCollection> ZZOP120PassCheck = passingStationCollectionServiceImpl.selectDaPassingStationCollectionList(PassingStationCollection);
                    if (CollUtil.isEmpty(ZZOP120PassCheck)){
                        a = "";
                    } else {
                        DaPassingStationCollection passingStationCollection = ZZOP120PassCheck.get(0);
                        String outRsSign = passingStationCollection.getOutRsSign();
                        if (!OPCElement.QUALIFIED.equals(outRsSign)){
                            a = "";
                        }
                    }
                }
                // 1:OK可生产 2:NG不可生产 3:NG可返工 4:PC检索失败(无记录)5:PC检索失败(软件)
                if (StrUtil.isNotBlank(a)){
                    int input = Integer.parseInt(a);
@@ -508,7 +574,7 @@
            //60只采集老车型
            if (OPCElement.OP060_SAVE_REQUEST.equals(Node) || OPCElement.OP060_SAVE_REQUEST_LAST.equals(Node)){
                String s = productNewFlag(SNCode);
                if ("280".equals(s) || "380".equals(s)){
                if ("280".equals(s) || "380".equals(s) || "196".equals(s) || "296".equals(s)){
                    list = new ArrayList<>();
                }
            }
@@ -519,7 +585,7 @@
                    || OPCElement.OP100_SAVE_REQUEST_LAST.equals(Node)){
                String s = productNewFlag(SNCode);
                if (StrUtil.isNotEmpty(s)){
                    if (!"280".equals(s) && !"380".equals(s)){
                    if (!"280".equals(s) && !"380".equals(s) && !"196".equals(s)){
                        list = new ArrayList<>();
                    }
                }
@@ -575,7 +641,7 @@
                                ParamCollection.setParamValue(readWriteEntityList.get(i).getValue().toString());
                            }
                            ParamCollection.setSfcCode(SNCode);
                            ParamCollection.setParamName(list.get(i).getCollectParameterName());
                            ParamCollection.setParamName(list.get(i).getParameterSetName());
                            ParamCollection.setParamUpper(list.get(i).getParamUpper());
                            ParamCollection.setParamLower(list.get(i).getParamLower());
                            ParamCollection.setUnit(list.get(i).getCollectParameterUnit());
@@ -608,6 +674,7 @@
            }
            DaPassingStationCollection PassingStationCollection=new DaPassingStationCollection();
            PassingStationCollection.setSfcCode(SNCode);
            PassingStationCollection.setProductCode(bsOrderScheduling.getModel());
            PassingStationCollection.setLocationCode(parts[1]);
            PassingStationCollection.setOutboundTime(new Date());
            PassingStationCollection.setInboundTime(new Date(new Date().getTime()-beatTime*1000));
@@ -646,6 +713,10 @@
            type = "280";
        } else if (SNCode.startsWith("380")){
            type = "380";
        } else if (SNCode.startsWith("196")){
            type = "196";
        } else if (SNCode.startsWith("296")){
            type = "296";
        }else {
            type = "oldType";
        }
@@ -672,6 +743,20 @@
                }
            } else if ("280".equals(productNewFlag)){
            } else if ("196".equals(productNewFlag)){
                ReadWriteEntity entity6 = new ReadWriteEntity("CFL4HX.OP040.CodeComplete", 1);
                miloService.writeToOpcByte(entity6);
//                ProductNewPassStation passStation = new ProductNewPassStation();
//                passStation.setSfcCode(SNCode);
//                List<ProductNewPassStation> productPassStationList = productNewPassStationService.getProductPassStationList(passStation);
//                if (CollUtil.isNotEmpty(productPassStationList)){
//                    ProductNewPassStation productNewPassStation = productPassStationList.get(0);
//                    String boxCode = productNewPassStation.getBoxCode();
//                    String productType = productNewPassStation.getProductType();
//                    log.info("发送到OP040的页面数据productType,{}",productType);
//                    log.info("发送到OP040的页面数据boxCode,{}",boxCode);
//                    passingStationCollectionServiceImpl.sendMessage(productType+"*"+boxCode, "OP040");
//                }
            }
        }
    }