-
admin
2024-05-25 a60fef88880990c61fa45072b092150c1ffec437
jcdm-main/src/main/java/com/jcdm/main/plcserver/sub/OPCUaSubscription.java
@@ -172,10 +172,11 @@
                            }
                        }else {
                            //手动工位处理逻辑
                            WebSocketUsers.sendMessageToUserByText(map.get(device), "IN");
                            String RecordDataDoneAddress = thoroughfare + "." + device + ".RecordDataDone";
                            miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(RecordDataDoneAddress).value(11).build());
//                            if (map.containsKey(device)){
                                WebSocketUsers.sendMessageToUserByText(map.get(device), "IN");
                                String RecordDataDoneAddress = thoroughfare + "." + device + ".RecordDataDone";
                                miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(RecordDataDoneAddress).value(11).build());
//                            }
                        }
@@ -212,7 +213,8 @@
//                                } else {
//                                    writeToOpc(RecordDataDoneAddress, (short) 22);
//                                }
                                writeToOpc(RecordDataDoneAddress, (short) 21);
//                                writeToOpc(RecordDataDoneAddress, (short) 21);
                                miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(RecordDataDoneAddress).value(21).build());
                            }
@@ -540,32 +542,48 @@
     * 保存过站采集
     */
    public void saveStationInfo365(String thoroughfare,String device) throws Exception {
        String RecordDataDoneAddress = thoroughfare + "." + device + ".RecordDataDone";
        String prefix = thoroughfare+"."+device+".";
        List<DaPassingStationCollection> passingStationCollections = new ArrayList<>();
        String ModuleCodeA = miloService.readFromOpcUa(prefix + "ModuleCodeA").getValue().toString();
        String ModuleCodeB = miloService.readFromOpcUa(prefix + "ModuleCodeB").getValue().toString();
        String StationStatusA = miloService.readFromOpcUa(prefix + "StationStatusA").getValue().toString();
        String StationStatusB = miloService.readFromOpcUa(prefix + "StationStatusB").getValue().toString();
        String[] modeles = {ModuleCodeA,ModuleCodeB};
        String[] StationStatus = {StationStatusA,StationStatusB};
        String ModuleCodeA = "";
        String ModuleCodeB = "";
        String StationStatusA = "";
        String StationStatusB = "";
        String startTime = miloService.readFromOpcUa(prefix + "StartTime").getValue().toString();
        String stopTime = miloService.readFromOpcUa(prefix + "StopTime").getValue().toString();
        for (int i = 0; i < 2; i++) {
            DaPassingStationCollection daPassingStationCollection = new DaPassingStationCollection();
            String strt = TimeUtil.stringProcessing(startTime);
            String end = TimeUtil.stringProcessing(stopTime);
            daPassingStationCollection.setInboundTime(format.parse(TimeUtil.test(strt)));//入站时间
            daPassingStationCollection.setOutboundTime(format.parse(TimeUtil.test(end)));//出站时间
            daPassingStationCollection.setSfcCode(modeles[i]);
            daPassingStationCollection.setLocationCode(device);
            daPassingStationCollection.setOutRsSign(StationStatus[i]);//出站是否合格
            passingStationCollections.add(daPassingStationCollection);
        Object objectModuleCodeA = miloService.readFromOpcUa(prefix + "ModuleCodeA").getValue();
        Object objectModuleCodeB = miloService.readFromOpcUa(prefix + "ModuleCodeB").getValue();
        Object objectStationStatusA = miloService.readFromOpcUa(prefix + "StationStatusA").getValue();
        Object objectStationStatusB = miloService.readFromOpcUa(prefix + "StationStatusB").getValue();
        if(ObjectUtil.isNotNull(objectModuleCodeA) && ObjectUtil.isNotNull(objectStationStatusA) && ObjectUtil.isNotNull(objectModuleCodeB) && ObjectUtil.isNotNull(objectStationStatusB)){
            ModuleCodeA = objectModuleCodeA.toString();
            ModuleCodeB = objectModuleCodeB.toString();
            StationStatusA = objectStationStatusA.toString();
            StationStatusB = objectStationStatusB.toString();
            String[] modeles = {ModuleCodeA,ModuleCodeB};
            String[] StationStatus = {StationStatusA,StationStatusB};
            String startTime = miloService.readFromOpcUa(prefix + "StartTime").getValue().toString();
            String stopTime = miloService.readFromOpcUa(prefix + "StopTime").getValue().toString();
            for (int i = 0; i < 2; i++) {
                DaPassingStationCollection daPassingStationCollection = new DaPassingStationCollection();
                String strt = TimeUtil.stringProcessing(startTime);
                String end = TimeUtil.stringProcessing(stopTime);
                daPassingStationCollection.setInboundTime(format.parse(TimeUtil.test(strt)));//入站时间
                daPassingStationCollection.setOutboundTime(format.parse(TimeUtil.test(end)));//出站时间
                daPassingStationCollection.setSfcCode(modeles[i]);
                daPassingStationCollection.setLocationCode(device);
                daPassingStationCollection.setOutRsSign(StationStatus[i]);//出站是否合格
                passingStationCollections.add(daPassingStationCollection);
            }
            daPassingStationCollectionService.saveBeachDaPassingStationCollection(passingStationCollections);
            miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(RecordDataDoneAddress).value(21).build());
            return;
        }else {
            miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(RecordDataDoneAddress).value(22).build());
            return;
        }
        daPassingStationCollectionService.saveBeachDaPassingStationCollection(passingStationCollections);
        String RecordDataDoneAddress = thoroughfare + "." + device + ".RecordDataDone";
        miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(RecordDataDoneAddress).value(21).build());
        return;
    }
    private static void writeToOpc(String identifier, short value) {