春风项目四线(合箱线、总装线)
wujian
2024-04-28 9bc5106810d7c0e6f27e904b584c9bbfb3725a19
jcdm-main/src/main/java/com/jcdm/main/plcserver/sub/OPCUaSubscription.java
@@ -21,7 +21,6 @@
import com.kangaroohy.milo.model.ReadWriteEntity;
import com.kangaroohy.milo.runner.subscription.SubscriptionCallback;
import com.kangaroohy.milo.service.MiloService;
import javafx.animation.Timeline;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
@@ -149,15 +148,17 @@
                if (CollUtil.isNotEmpty(queryOrderList)){
                    a = "1";
                }else {
                    a = "5";
                    a = "4";
                }
                //如果是返修工位需要传输返修工位号
                List<DaPassingStationCollection> daPassingStationCollections = new ArrayList<>();
                List<RmRepairRecord> rmRepairRecords = new ArrayList<>();
                if (OPCElement.OP465_ZZ_CODE_CHECK.equals(Node) || OPCElement.OP355_ZZ_CODE_CHECK.equals(Node)
                        || OPCElement.OP695_ZZ_CODE_CHECK.equals(Node) || OPCElement.OP755_ZZ_CODE_CHECK.equals(Node)){
                    //过站记录
                    DaPassingStationCollection PassingStationCollection=new DaPassingStationCollection();
                    PassingStationCollection.setSfcCode(SNCode);
                    List<DaPassingStationCollection> daPassingStationCollections = passingStationCollectionServiceImpl.selectDaPassingStationCollectionList(PassingStationCollection);
                    daPassingStationCollections = passingStationCollectionServiceImpl.selectDaPassingStationCollectionList(PassingStationCollection);
                    if (CollUtil.isNotEmpty(daPassingStationCollections)){
                        DaPassingStationCollection lastOne = daPassingStationCollections.get(daPassingStationCollections.size() - 1);
                        String outRsSign = lastOne.getOutRsSign();
@@ -167,6 +168,13 @@
                            a = "2";
                        }
                    }
                    RmRepairRecord rmRepairRecord = new RmRepairRecord();
                    rmRepairRecord.setBoxCode(SNCode);
                    rmRepairRecords = rmRepairRecordService.selectRmRepairRecordList(rmRepairRecord);
                    if (CollUtil.isNotEmpty(rmRepairRecords)){
                        a = "1";
                    }
                }
                log.info("-----返回codeCheckFeed-----,{}",a);
//                String a="1";
@@ -196,7 +204,7 @@
                    if (OPCElement.OP465_ZZ_CODE_CHECK.equals(Node) || OPCElement.OP355_ZZ_CODE_CHECK.equals(Node)
                    || OPCElement.OP695_ZZ_CODE_CHECK.equals(Node) || OPCElement.OP755_ZZ_CODE_CHECK.equals(Node)){
                        rework(SNCode,Node);
                        rework(SNCode,Node,daPassingStationCollections,rmRepairRecords);
                    }
                    System.out.println(entity);
@@ -206,7 +214,7 @@
        }
    }
    private void rework(String SNCode,String Node)  throws Exception{
    private void rework(String SNCode,String Node,List<DaPassingStationCollection> daPassingStationCollections,List<RmRepairRecord> rmRepairRecords)  throws Exception{
        BsOrderScheduling bsOrderScheduling = new BsOrderScheduling();
        bsOrderScheduling.setEngineNo(SNCode);
        List<String> allProcessCoed = new ArrayList<>();
@@ -220,15 +228,15 @@
                allProcessCoed = bsTechnologyRouteChildInfos.stream().map(BsTechnologyRouteChildInfo::getProcessesCode).collect(Collectors.toList());
            }
        }
        RmRepairRecord rmRepairRecord = new RmRepairRecord();
        rmRepairRecord.setBoxCode(SNCode);
//        RmRepairRecord rmRepairRecord = new RmRepairRecord();
//        rmRepairRecord.setBoxCode(SNCode);
        List<ReadWriteEntity> writeList = new ArrayList<>();
        List<RmRepairRecord> rmRepairRecords = rmRepairRecordService.selectRmRepairRecordList(rmRepairRecord);
//        List<RmRepairRecord> rmRepairRecords = rmRepairRecordService.selectRmRepairRecordList(rmRepairRecord);
        //过站记录
        DaPassingStationCollection PassingStationCollection=new DaPassingStationCollection();
        PassingStationCollection.setSfcCode(SNCode);
//        DaPassingStationCollection PassingStationCollection=new DaPassingStationCollection();
//        PassingStationCollection.setSfcCode(SNCode);
        //过站记录
        List<DaPassingStationCollection> daPassingStationCollections = passingStationCollectionServiceImpl.selectDaPassingStationCollectionList(PassingStationCollection);
//        List<DaPassingStationCollection> daPassingStationCollections = passingStationCollectionServiceImpl.selectDaPassingStationCollectionList(PassingStationCollection);
        //所有反工工位
        List<String> collect1 = rmRepairRecords.stream().map(RmRepairRecord::getProcessesCode).collect(Collectors.toList());
@@ -253,8 +261,15 @@
            //获取过站记录的最大工位
            String maxCode = null;
            if (CollUtil.isNotEmpty(daPassingStationCollections)){
                DaPassingStationCollection lastOne = daPassingStationCollections.get(daPassingStationCollections.size() - 1);
                maxCode = lastOne.getLocationCode();
                List<DaPassingStationCollection> collect2 = daPassingStationCollections.stream().filter(x -> "不合格".equals(x.getOutRsSign())).collect(Collectors.toList());
                if (CollUtil.isNotEmpty(collect2)){
                    DaPassingStationCollection lastOne = collect2.get(collect2.size() - 1);
                    maxCode = lastOne.getLocationCode();
                }else {
                    DaPassingStationCollection lastOne = daPassingStationCollections.get(daPassingStationCollections.size() - 1);
                    maxCode = lastOne.getLocationCode();
                }
            }
@@ -379,7 +394,7 @@
                List<DaParamCollection> daParamCollectionlist = new ArrayList<>();
                if (CollUtil.isNotEmpty(nodeIdList)){
                    for(int i=0;i<nodeIdList.size();i++){
                        if(!readWriteEntityList.get(i).getValue().toString().equals("0.0")){
                        if(ObjectUtil.isNotEmpty(readWriteEntityList.get(i).getValue()) && !readWriteEntityList.get(i).getValue().toString().equals("0.0")){
                            DaParamCollection ParamCollection = new DaParamCollection();
                            ParamCollection.setParamCode(readWriteEntityList.get(i).getIdentifier().toString().split("[.]")[2]);
                            ParamCollection.setLocationCode(parts[1]);
@@ -411,6 +426,17 @@
                String str = object.toString();
                beatTime = Float.valueOf(str).longValue();
            }
            Object ProductStatus = miloService.readFromOpcUa(parts[0] + "." + parts[1] + ".ProductStatus").getValue();
            log.info("ProductStatus,{}",ProductStatus.toString());
            String str1="合格" ;
            if (ObjectUtil.isNotEmpty(ProductStatus)){
                String productStatusString = ProductStatus.toString();
                if (productStatusString.contains("2") || productStatusString.contains("3")){
                    str1="不合格";
                }else {
                    str1="合格";
                }
            }
            DaPassingStationCollection PassingStationCollection=new DaPassingStationCollection();
            PassingStationCollection.setSfcCode(SNCode);
            PassingStationCollection.setLocationCode(parts[1]);
@@ -419,7 +445,7 @@
            PassingStationCollection.setCollectionTime(new Date());
            PassingStationCollection.setCreateTime(new Date());
            PassingStationCollection.setBeatTime(beatTime.toString());
            PassingStationCollection.setOutRsSign("合格");
            PassingStationCollection.setOutRsSign(str1);
            passingStationCollectionServiceImpl.insertDaPassingStationCollection(PassingStationCollection);
            log.info("-------保存过站记录数据完成---------");