From f23e2ce66fdf032b2560d5547c77f30eb8de0c75 Mon Sep 17 00:00:00 2001 From: hdy <1105738590@qq.com> Date: 星期二, 11 三月 2025 19:21:43 +0800 Subject: [PATCH] 修改 --- billion-main/src/main/java/com/billion/main/plcServer/sub/OPCUaSubscription.java | 46 ++++++++++++++++++++++++++++++++++------------ 1 files changed, 34 insertions(+), 12 deletions(-) diff --git a/billion-main/src/main/java/com/billion/main/plcServer/sub/OPCUaSubscription.java b/billion-main/src/main/java/com/billion/main/plcServer/sub/OPCUaSubscription.java index 84bb29a..da49e78 100644 --- a/billion-main/src/main/java/com/billion/main/plcServer/sub/OPCUaSubscription.java +++ b/billion-main/src/main/java/com/billion/main/plcServer/sub/OPCUaSubscription.java @@ -16,6 +16,7 @@ import com.billion.main.om.domain.OmProductionOrderInfo; import com.billion.main.om.service.IOmOrderSchedulingService; import com.billion.main.om.service.IOmProductionOrderInfoService; +import com.billion.main.plcServer.util.TimeUtil; import com.billion.main.sys.domain.SysCount; import com.billion.main.sys.service.ISysCountService; import com.kangaroohy.milo.model.ReadWriteEntity; @@ -23,7 +24,6 @@ import com.kangaroohy.milo.service.MiloService; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Component; -import com.billion.main.plcServer.util.TimeUtil; import java.text.SimpleDateFormat; import java.time.LocalDateTime; @@ -140,6 +140,11 @@ omOrderScheduling.setWorkOrderNo(workOrderNumber.toString()); omOrderScheduling.setNowQty(nowQty.toString()); omOrderScheduling.setSfcCode(SFCCode.toString()); + Date Time = new Date(); + ReadWriteEntity TimeRead = miloService.readFromOpcUa(thoroughfare + "." + device + ".StartTime"); + Time = format.parse(TimeUtil.test(TimeUtil.stringProcessing(TimeRead.getValue().toString()))); + omOrderScheduling.setOnlineTime(Time); + omOrderScheduling.setStatus("1"); //鎵樼洏缁戝畾SFCCode鍜屽伐鍗曞拰浜х嚎 if(Constants.OP005.equals(device)){ omOrderScheduling.setRemarks("Body"); @@ -149,6 +154,11 @@ } omOrderSchedulingService.insertOmOrderScheduling(omOrderScheduling); }else if(Constants.OFFLINE.contains(device)){ + Date Time = new Date(); + ReadWriteEntity TimeRead = miloService.readFromOpcUa(thoroughfare + "." + device + ".StopTime"); + Time = format.parse(TimeUtil.test(TimeUtil.stringProcessing(TimeRead.getValue().toString()))); + omOrderScheduling.setOfflineTime(Time); + omOrderScheduling.setStatus("2"); if(Constants.C060.equals(device)){ omOrderScheduling.setRemarks("Head"); omOrderScheduling.setSfcCode(SFCCode.toString()); @@ -203,38 +213,50 @@ //鏌ヨdescriptive瀛楁绛変簬1鐨勯噰闆嗛」淇濆瓨鍒版壂鐮佷繚瀛樺埌da_material_collection琛ㄩ噷 DaCollectionParamConf daCollectionParamConf1 = new DaCollectionParamConf(); daCollectionParamConf1.setProcessesCode(device); - daCollectionParamConf1.setDescriptive("3"); + daCollectionParamConf1.setDescriptive("1"); List<DaCollectionParamConf> daCollectionParamConfList1 = daCollectionParamConfService.selectDaCollectionParamConfList(daCollectionParamConf1); for (DaCollectionParamConf conf : daCollectionParamConfList1) { String gatherAddress = conf.getGatherAddress(); - Object valueObj = miloService.readFromOpcUa(gatherAddress).getValue(); // 鑾峰彇鍘熷鍊煎璞♀��:ml-citation{ref="4" data="citationList"} - if (valueObj != null ) { + String valueObj = miloService.readFromOpcUa(gatherAddress).getValue().toString(); // 鑾峰彇鍘熷鍊煎璞♀��:ml-citation{ref="4" data="citationList"} + if (!Objects.equals(valueObj, " ")) { DaMaterialCollection materialCollection = new DaMaterialCollection(); materialCollection.setSfcCode(SFCCode.toString()); materialCollection.setLocationCode(device); materialCollection.setParamName(conf.getParameterSetName()); - materialCollection.setParamValue((String) miloService.readFromOpcUa(gatherAddress).getValue()); - materialCollection.setCollectTime(new Date()); + materialCollection.setParamValue(miloService.readFromOpcUa(gatherAddress).getValue().toString()); + Date Time = new Date(); + ReadWriteEntity TimeRead = miloService.readFromOpcUa(thoroughfare + "." + device + ".StopTime"); + Time = format.parse(TimeUtil.test(TimeUtil.stringProcessing(TimeRead.getValue().toString()))); + materialCollection.setCollectTime(Time); daMaterialCollectionService.insertDaMaterialCollection(materialCollection); } + else { + log.debug("閲囬泦椤逛负绌�: {}", gatherAddress); + } } - //鏌ヨdescriptive瀛楁绛変簬2鐨勯噰闆嗛」淇濆瓨鍒版壂鐮佷繚瀛樺埌da_param_collection琛ㄩ噷 +// 鏌ヨdescriptive瀛楁绛変簬2鐨勯噰闆嗛」淇濆瓨鍒版壂鐮佷繚瀛樺埌da_param_collection琛ㄩ噷 DaCollectionParamConf daCollectionParamConf2 = new DaCollectionParamConf(); daCollectionParamConf2.setProcessesCode(device); - daCollectionParamConf2.setDescriptive("4"); + daCollectionParamConf2.setDescriptive("2"); List<DaCollectionParamConf> daCollectionParamConfList2 = daCollectionParamConfService.selectDaCollectionParamConfList(daCollectionParamConf2); for (DaCollectionParamConf conf : daCollectionParamConfList2) { String gatherAddress = conf.getGatherAddress(); - Object valueObj = miloService.readFromOpcUa(gatherAddress).getValue(); // 鑾峰彇鍘熷鍊煎璞♀��:ml-citation{ref="4" data="citationList"} - if (valueObj != null ) { + String valueObj = miloService.readFromOpcUa(gatherAddress).getValue().toString(); // 鑾峰彇鍘熷鍊煎璞♀��:ml-citation{ref="4" data="citationList"} + if (!Objects.equals(valueObj, "0.0") && !Objects.equals(valueObj, "0")) { DaParamCollection paramCollection = new DaParamCollection(); paramCollection.setSfcCode(SFCCode.toString()); paramCollection.setLocationCode(device); paramCollection.setParamName(conf.getParameterSetName()); - paramCollection.setParamValue((String) miloService.readFromOpcUa(gatherAddress).getValue()); - paramCollection.setCollectionTime(new Date()); + paramCollection.setParamValue(miloService.readFromOpcUa(gatherAddress).getValue().toString()); + Date Time = new Date(); + ReadWriteEntity TimeRead = miloService.readFromOpcUa(thoroughfare + "." + device + ".StopTime"); + Time = format.parse(TimeUtil.test(TimeUtil.stringProcessing(TimeRead.getValue().toString()))); + paramCollection.setCollectTime(Time); daParamCollectionService.insertDaParamCollection(paramCollection); } + else { + log.debug("閲囬泦椤逛负绌�: {}", gatherAddress); + } } DaStationCollection daStationCollection = new DaStationCollection(); daStationCollection.setLocationCode(device); -- Gitblit v1.9.3