From 1ccd6932893e47722574e6d1147e63b2ec4972c1 Mon Sep 17 00:00:00 2001 From: admin <15939171744@163.com> Date: 星期五, 17 五月 2024 08:45:52 +0800 Subject: [PATCH] - --- jcdm-main/src/main/java/com/jcdm/main/plcserver/sub/OPCUaSubscription.java | 92 ++++++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 88 insertions(+), 4 deletions(-) diff --git a/jcdm-main/src/main/java/com/jcdm/main/plcserver/sub/OPCUaSubscription.java b/jcdm-main/src/main/java/com/jcdm/main/plcserver/sub/OPCUaSubscription.java index 8dc6dd6..b4679e5 100644 --- a/jcdm-main/src/main/java/com/jcdm/main/plcserver/sub/OPCUaSubscription.java +++ b/jcdm-main/src/main/java/com/jcdm/main/plcserver/sub/OPCUaSubscription.java @@ -3,6 +3,7 @@ import cn.hutool.core.collection.CollUtil; import cn.hutool.core.date.DateUtil; +import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; import cn.hutool.json.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; @@ -16,6 +17,8 @@ import com.jcdm.main.da.paramCollection.service.IDaParamCollectionService; import com.jcdm.main.da.passingStationCollection.domain.DaPassingStationCollection; import com.jcdm.main.da.passingStationCollection.service.IDaPassingStationCollectionService; +import com.jcdm.main.da.testDeviceInterface.domain.DaTestDeviceInterface; +import com.jcdm.main.da.testDeviceInterface.service.IDaTestDeviceInterfaceService; import com.jcdm.main.om.productionOrde.domain.OmProductionOrdeInfo; import com.jcdm.main.om.productionOrde.service.IOmProductionOrdeInfoService; import com.jcdm.main.plcserver.conf.OPCElement; @@ -74,16 +77,21 @@ public static IOmProductionOrdeInfoService omProductionOrdeInfoService; + private static IDaTestDeviceInterfaceService daTestDeviceInterfaceService; + + public OPCUaSubscription(MiloService miloService, IDaPassingStationCollectionService daPassingStationCollectionService, IDaCollectionParamConfService collectionParamConfService, IDaParamCollectionService daParamCollectionService, - IOmProductionOrdeInfoService omProductionOrdeInfoService) { + IOmProductionOrdeInfoService omProductionOrdeInfoService, + IDaTestDeviceInterfaceService daTestDeviceInterfaceService) { OPCUaSubscription.miloService = miloService; this.daPassingStationCollectionService = daPassingStationCollectionService; OPCUaSubscription.collectionParamConfService = collectionParamConfService; OPCUaSubscription.daParamCollectionService = daParamCollectionService; OPCUaSubscription.omProductionOrdeInfoService = omProductionOrdeInfoService; + OPCUaSubscription.daTestDeviceInterfaceService = daTestDeviceInterfaceService; } @@ -115,6 +123,16 @@ String RecordDataDoneAddress = thoroughfare + "." + device + ".RecordDataDone"; //璇绘ā缁勭爜 Object moduleCode = miloService.readFromOpcUa(thoroughfare + "." + device + ".ModuleCode").getValue(); + if(device.equals("OP365")){ + Object moduleCodeA = miloService.readFromOpcUa(thoroughfare + "." + device + ".ModuleCodeA").getValue(); + Object moduleCodeB = miloService.readFromOpcUa(thoroughfare + "." + device + ".ModuleCodeB").getValue(); + if(moduleCodeA!=null && moduleCodeB!=null){ + miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(RecordDataDoneAddress).value(11).build()); + }else { + miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(RecordDataDoneAddress).value(12).build()); + } + return; + } if(moduleCode!=null){ miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(RecordDataDoneAddress).value(11).build()); @@ -150,7 +168,6 @@ }else { miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(RecordDataDoneAddress).value(12).build()); } - } } }else { @@ -180,8 +197,25 @@ } if(testList.stream().anyMatch(s -> s.equals(device))){ String RecordDataDoneAddress = thoroughfare + "." + device + ".RecordDataDone"; - miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(RecordDataDoneAddress).value(21).build()); +// Object packCodeObject = miloService.readFromOpcUa(thoroughfare + "." + device + ".ModuleCode").getValue(); +// DaTestDeviceInterface deviceInterfaceOne = null; +// +// if (ObjectUtil.isNotNull(packCodeObject)) { +// String modelCode = packCodeObject.toString(); +// deviceInterfaceOne = daTestDeviceInterfaceService.getOne(new LambdaQueryWrapper<DaTestDeviceInterface>() +// .eq(DaTestDeviceInterface::getProductNum, modelCode) +// .eq(DaTestDeviceInterface::getStationCode, device)); +// } +// +// if (deviceInterfaceOne != null && "1".equals(deviceInterfaceOne.getTotalResult())) { +// writeToOpc(RecordDataDoneAddress, (short) 21); +// } else { +// writeToOpc(RecordDataDoneAddress, (short) 22); +// } + writeToOpc(RecordDataDoneAddress, (short) 21); } + + } }else { System.out.println("^"); @@ -231,6 +265,13 @@ if(nullList.stream().noneMatch(s -> s.equals(device))){ if(moduleCodeList.stream().anyMatch(s -> s.equals(device))){ read = read + "ModuleCode"; + if(device.equals("OP365")){ + try { + saveStationInfo365(thoroughfare,device); + }catch (Exception e){ + e.printStackTrace(); + } + } }else { read = read + "PACKCode"; } @@ -264,7 +305,10 @@ //1銆佹洿鏂板伐鍗曚俊鎭� updateOrderInfo(snCode); } - daParamCollectionService.pushGeelycvMesFeedback(snCode,device); + try{ + daParamCollectionService.pushGeelycvMesFeedback(snCode,device); + }catch (Exception e){ + } result = "21"; } @@ -492,4 +536,44 @@ return CollUtil.isEmpty(list); } + /** + * 淇濆瓨杩囩珯閲囬泦 + */ + public void saveStationInfo365(String thoroughfare,String device) throws Exception { + 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 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); + String RecordDataDoneAddress = thoroughfare + "." + device + ".RecordDataDone"; + miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(RecordDataDoneAddress).value(21).build()); + return; + } + + private static void writeToOpc(String identifier, short value) { + try { + miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(identifier).value(value).build()); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + } -- Gitblit v1.9.3