-
admin
2024-04-29 2c7661d0bca739a9b403cdd420d2b91eb77470e6
jcdm-main/src/main/java/com/jcdm/main/plcserver/sub/OPCUaSubscription.java
@@ -34,11 +34,19 @@
    public SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    //自动工位
    public List<String> automaticList = Arrays.asList("OP300","OP280", "OP320", "OP340", "OP350", "OP360","OP370", "OP390", "OP470", "OP530", "OP540");
    //新自动工站
    public List<String> automaticList = Arrays.asList("OP280", "OP300A","OP300B", "OP320A","OP320B", "OP340A","OP340B", "OP350A","OP350B", "OP360","OP365","OP370", "OP390", "OP470");
    //采集模组工位
    public List<String> moduleCodeList = Arrays.asList("OP300","OP310", "OP320", "OP340", "OP350", "OP330");
    //采集模组工位 ModuleCode
    public List<String> moduleCodeList = Arrays.asList("OP300A","OP300B","OP320A","OP320B","OP340A","OP340B","OP365", "OP350A", "OP350B", "OP330");
    //区分模组型号工位
    public List<String> distinguishingModules = Arrays.asList("OP300","OP310", "OP340", "OP350", "OP330");
    //区分pack型号的工位
    public List<String> packIdList = Arrays.asList("OP280","OP360","OP390","OP470");
    //空的
    public List<String> nullList = Arrays.asList("OP250","OP260");
@@ -73,7 +81,7 @@
    public void onSubscribe(String identifier, Object value) {
        try {
            if(null != value) {
            if(null != value && Integer.valueOf(value.toString())!= 0) {
                String[] nodes = identifier.split("[.]");
                String thoroughfare = nodes[0];//通道
                String device = nodes[1];//设备
@@ -104,24 +112,32 @@
//                        }
                        //自动工位
                        //plc给我们一个pack码,拿pack码校验出型号
                        if(moduleCodeList.stream().anyMatch(s -> s.equals(device))){
                            //读模组码
                            String moduleCode = miloService.readFromOpcUa(thoroughfare + "." + device + ".ModuleCode").getValue().toString();
                            String productTye = thoroughfare + "." + device + ".ProductType";
                            if(null!=moduleCode && moduleCode.length() == 24){
                                miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(productTye).value(Integer.valueOf(moduleCode.substring(7,8))).build());
                                //进站保存数据
//                              inSaveDate(thoroughfare,device)
                        if(automaticList.stream().anyMatch(s -> s.equals(device))){
                            //plc给我们一个模组码,拿模组码校验出型号
                            if(distinguishingModules.stream().anyMatch(s -> s.equals(device))) {
                                //读模组码
//                                String moduleCode = miloService.readFromOpcUa(thoroughfare + "." + device + ".ModuleCode").getValue().toString();
//                                String productTye = thoroughfare + "." + device + ".ProductType";
//                                if (null != moduleCode && moduleCode.length() == 24) {
//                                    miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(productTye).value(Integer.valueOf(moduleCode.substring(7, 8))).build());
//                                    //进站保存数据
////                              inSaveDate(thoroughfare,device)
//                                    //记录数据完成
//                                    String RecordDataDoneAddress = thoroughfare + "." + device + ".RecordDataDone";
//
//                                    miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(RecordDataDoneAddress).value(11).build());
//
//
//                                    //请求工单
//                                } else {
//                                    miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".RecordDataDone").value(12).build());
//                                }
                            }else {
                                //pack 如果区分型号的话就要处理
                                //记录数据完成
                                String RecordDataDoneAddress = thoroughfare + "." + device + ".RecordDataDone";
                                miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(RecordDataDoneAddress).value(11).build());
                                //请求工单
                            }else {
                                miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".RecordDataDone").value(12).build());
                            }
                        }else {
                            //手动工位处理逻辑
@@ -143,7 +159,7 @@
                            recordDataDoneValue = outSaveDate(thoroughfare,device);
                            //记录数据完成
                            String RecordDataDoneAddress = thoroughfare + "." + device + ".RecordDataDone";
                            miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(RecordDataDoneAddress).value(Integer.valueOf(RecordDataDoneAddress)).build());
                            miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(RecordDataDoneAddress).value(Integer.valueOf(recordDataDoneValue)).build());
                        }else {
                            //手动工位
                            WebSocketUsers.sendMessageToUserByText(map.get(device), "END");
@@ -209,8 +225,6 @@
                String workOrderNo = "";
                String productCode = "";
                //2、保存过站采集数据
//                String workOrderNo = miloService.readFromOpcUa(thoroughfare + "." + device + "." + "WorkOrderNumber").getValue().toString();
//                String productCode = miloService.readFromOpcUa(thoroughfare + "." + device + "." + "ProductType").getValue().toString();
                Object orderNumberObject = miloService.readFromOpcUa(thoroughfare + "." + device + "." + "WorkOrderNumber").getValue();
                if(orderNumberObject!=null){
                    workOrderNo = orderNumberObject.toString();