From ddb300bd410f6c9871c3c033e16451f709c2781e Mon Sep 17 00:00:00 2001 From: admin <15939171744@163.com> Date: 星期二, 16 四月 2024 10:09:46 +0800 Subject: [PATCH] - --- jcdm-main/src/main/java/com/jcdm/main/plcserver/sub/OPCUaSubscription.java | 31 +++++++++++++++++++++++++++---- 1 files changed, 27 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 7570daa..411e780 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 @@ -12,6 +12,7 @@ import com.jcdm.main.da.passingStationCollection.domain.DaPassingStationCollection; import com.jcdm.main.da.passingStationCollection.service.IDaPassingStationCollectionService; import com.jcdm.main.plcserver.conf.OPCElement; +import com.jcdm.main.plcserver.util.TimeUtil; import com.kangaroohy.milo.model.ReadWriteEntity; import com.kangaroohy.milo.runner.subscription.SubscriptionCallback; import com.kangaroohy.milo.service.MiloService; @@ -19,6 +20,7 @@ import org.springframework.stereotype.Component; import javax.websocket.Session; +import java.text.SimpleDateFormat; import java.util.*; import java.util.stream.Collectors; @@ -29,8 +31,10 @@ //鑷姩宸ヤ綅 public List<String> automaticList = Arrays.asList("OP300","OP280", "OP320", "OP340", "OP350", "OP360","OP370", "OP390", "OP470", "OP530", "OP540"); - public List<String> moduleCodeList = Arrays.asList("OP300","OP310", "OP320", "OP340", "OP350", "OP33"); + //閲囬泦妯$粍宸ヤ綅 + public List<String> moduleCodeList = Arrays.asList("OP300","OP310", "OP320", "OP340", "OP350", "OP330"); + //绌虹殑 public List<String> nullList = Arrays.asList("OP250","OP260"); @@ -87,10 +91,18 @@ recordDataDoneValue = "11"; //鏍¢獙鍏ョ珯鏄惁鍙互宸ヤ綔 + //plc缁欐垜浠竴涓猵ack鐮侊紝鎷縫ack鐮佹牎楠屽嚭鍨嬪彿 + if(moduleCodeList.stream().anyMatch(s -> s.equals(device))){ + //璇绘ā缁勭爜 + String moduleCode = miloService.readFromOpcUa(thoroughfare + "." + device + ".ModuleCode").getValue().toString(); + String productTye = thoroughfare + "." + device + ".ProductType"; + 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()); if(automaticList.stream().noneMatch(s -> s.equals(device))){ @@ -174,6 +186,7 @@ String workOrderNo = miloService.readFromOpcUa(thoroughfare + "." + device + "." + "WorkOrderNumber").getValue().toString(); String productCode = miloService.readFromOpcUa(thoroughfare + "." + device + "." + "ProductType").getValue().toString(); + saveStationInfo(snCode,thoroughfare,device,workOrderNo,productCode); //3銆佷繚瀛樺弬鏁伴噰闆嗘暟鎹� SaveParamData(snCode,thoroughfare,device,workOrderNo,productCode); @@ -223,6 +236,8 @@ * 淇濆瓨杩囩珯閲囬泦 */ public void saveStationInfo(String packCode,String thoroughfare,String device,String workOrderNo,String productCode) throws Exception { + SimpleDateFormat sdf = new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy", Locale.US); + sdf.setTimeZone(TimeZone.getTimeZone("GMT+8")); // CST閫氬父琛ㄧず涓浗鏍囧噯鏃堕棿锛屽嵆涓滃叓鍖� String prefix = thoroughfare+"."+device+"."; String startTime = miloService.readFromOpcUa(prefix + "StartTime").getValue().toString(); String stopTime = miloService.readFromOpcUa(prefix + "StopTime").getValue().toString(); @@ -233,8 +248,10 @@ daPassingStationCollection.setWorkOrderNo(workOrderNo); daPassingStationCollection.setProductCode(productCode); daPassingStationCollection.setLocationCode(device); -// daPassingStationCollection.setInboundTime(startTime);//鍏ョ珯鏃堕棿 -// daPassingStationCollection.setOutboundTime(stopTime);//鍑虹珯鏃堕棿 + String strt = TimeUtil.stringProcessing(startTime); + String end = TimeUtil.stringProcessing(stopTime); + daPassingStationCollection.setInboundTime(sdf.parse(strt));//鍏ョ珯鏃堕棿 + daPassingStationCollection.setOutboundTime(sdf.parse(end));//鍑虹珯鏃堕棿 daPassingStationCollection.setOutRsSign(stationStatus);//鍑虹珯鏄惁鍚堟牸 daPassingStationCollectionService.insertDaPassingStationCollection(daPassingStationCollection); } @@ -255,10 +272,16 @@ List<DaParamCollection> daParamCollectionlist = new ArrayList<>(); for(int i=0;i<nodeIdList.size();i++){ if(!readWriteEntityList.get(i).getValue().toString().equals("0.0")){ + String tt = readWriteEntityList.get(i).getValue().toString(); DaParamCollection ParamCollection = new DaParamCollection(); ParamCollection.setParamCode(list.get(i).getCollectParameterId()); ParamCollection.setLocationCode(device); - ParamCollection.setParamValue(readWriteEntityList.get(i).getValue().toString()); + if(tt.contains("Time")){ + String str = TimeUtil.getTimestamp(TimeUtil.stringProcessing(tt)); + ParamCollection.setParamValue(str); + }else { + ParamCollection.setParamValue(readWriteEntityList.get(i).getValue().toString()); + } ParamCollection.setSfcCode(packCode); ParamCollection.setParamName(list.get(i).getCollectParameterName()); ParamCollection.setParamUpper(list.get(i).getParamUpper()); -- Gitblit v1.9.3