From eda15ed46a021ae8ea988c9438b23b6a14359819 Mon Sep 17 00:00:00 2001 From: cl <418351270@qq.com> Date: 星期日, 07 七月 2024 13:55:13 +0800 Subject: [PATCH] 修改参数采集 --- jcdm-main/src/main/java/com/jcdm/main/plcserver/sub/OPCUaSubscription.java | 52 +++++++++++++++++++++++++++++++--------------------- 1 files changed, 31 insertions(+), 21 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 41602ba..43060d8 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 @@ -145,10 +145,9 @@ } } else if(Constants.OP100_1.equals(device) || Constants.OP100_2.equals(device)){ //1銆佽繘绔橮LC缁欎骇鍝佺被鍨嬶紝MES璇诲彇浜у搧绫诲瀷 - ReadWriteEntity productTypeRead = miloService.readFromOpcUa(thoroughfare + "." + device + ".MES_ProductType");//浜у搧绫诲瀷 - if (ObjectUtil.isNotNull(productTypeRead.getValue())){ - String productType = productTypeRead.getValue().toString(); - + Object productTypeObjcet = miloService.readFromOpcUa(thoroughfare + "." + device + ".ProductType").getValue();//浜у搧绫诲瀷 + if (ObjectUtil.isNotNull(productTypeObjcet)){ + String productType = productTypeObjcet.toString();//浜у搧绫诲瀷 CompletableFuture<Void> cp1 = CompletableFuture.runAsync(() -> { //璋冪敤宸ュ巶MES锛屼繚瀛樺埌鏁版嵁搴�,骞朵笖灏嗗伐鍗曚紶缁橮LC (鐩墠涓存椂鐢ㄨ鏂规硶锛� receivingWorkOrders(thoroughfare, device); @@ -156,12 +155,19 @@ miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".RecordDataDone").value(11).build()); log.info("鍐欏叆鍒板伐浣峽}鐨凴ecordDataDone鏁版嵁锛歿}",device,11); - }else{ miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".RecordDataDone").value(12).build()); } - }else { + }else if (Constants.ModuleList.contains(device)){//鏈夋ā缁勭爜鐨勫伐浣� + Object modulCodeObjcet = miloService.readFromOpcUa(thoroughfare + "." + device + ".ModuleCode").getValue(); + if (ObjectUtil.isNull(modulCodeObjcet)){ + miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".RecordDataDone").value(12).build()); + }else{ + miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".RecordDataDone").value(11).build()); + } + } + else { miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".RecordDataDone").value(11).build()); log.info("鍐欏叆鍒板伐浣峽}鐨凴ecordDataDone鏁版嵁锛歿}",device,11); } @@ -171,7 +177,7 @@ //010宸ヤ綅鏃犺繃绔欒褰曪紝鍙粰鏀捐淇″彿 miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".RecordDataDone").value(21).build()); log.info("鍐欏叆鍒板伐浣峽}鐨凴ecordDataDone鏁版嵁锛歿}",device,21); - }else if (Constants.OP020_OP065.contains(device)){ + }else if (Constants.OP020_OP090.contains(device)){ Integer result = 21; //璇诲彇鐢佃姱鐮� List<String> cellCodeList = readCellCodeList(thoroughfare, device); @@ -185,13 +191,13 @@ } miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".RecordDataDone").value(result).build()); log.info("鍐欏叆鍒板伐浣峽}鐨凴ecordDataDone鏁版嵁锛歿}",device,result); - } else if (Constants.OP100_1.equals(device) || Constants.OP100_2.equals(device)){ - + } else if (Constants.OP100_OP150.contains(device)){//浜哄伐宸ヤ綅 WebSocketUsers.sendMessageToUserByText(map.get(device), "END"); } else { Integer result = 21; + Object productTypeObjcet = miloService.readFromOpcUa(thoroughfare + "." + device + ".ProductType").getValue();//浜у搧绫诲瀷 Object modulCodeObjcet = miloService.readFromOpcUa(thoroughfare + "." + device + ".ModuleCode").getValue(); - if (ObjectUtil.isNull(modulCodeObjcet) && modulCodeObjcet.toString().trim().isEmpty()){ + if (ObjectUtil.isNull(modulCodeObjcet)){ result = 23; }else{ String moduleCode = modulCodeObjcet.toString(); @@ -232,9 +238,10 @@ if (CollUtil.isNotEmpty(orderList)){ Long id = orderList.get(0).getId(); String productNum = orderList.get(0).getProductNum();//妯$粍鐮� + String orderNum = orderList.get(0).getWorkOrderNo(); //涓嬪彂浜у搧妯$粍鐮� - miloService.writeToOpcUa(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".MES_ModuleCode").value(productNum).build()); - miloService.writeToOpcUa(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".MES_WorkOrderNumber").value(productNum).build()); + miloService.writeToOpcUa(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".ModuleCode").value(productNum).build()); + miloService.writeToOpcUa(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".WorkOrderNumber").value(productNum).build()); //miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".RecordSNDone").value(1).build()); //鏇存柊宸ュ崟鐘舵�佷负鎵ц涓� @@ -476,6 +483,9 @@ String paramValue = ""; if (ObjectUtil.isNotNull(readWriteEntityList.get(i).getValue())){ paramValue = readWriteEntityList.get(i).getValue().toString();//鍙傛暟鍊� + if("DATE".equals(list.get(i).getCollectParameterType()) && !paramValue.isEmpty()){ + paramValue = format.parse(TimeUtil.test(TimeUtil.stringProcessing(paramValue))).toString(); + } } daParamCollection.setParamValue(paramValue);//鍙傛暟鍊� daParamCollection.setLocationCode(device);//宸ヤ綅 @@ -489,7 +499,7 @@ childVO.setItemValue(paramValue);//鍙傛暟鍊� childVO.setItemText(list.get(i).getCollectParameterName()); childVO.setCheckResult("1"); - childVO.setCheckTime(new Date().toString()); + childVO.setCheckTime(format.format(new Date())); mesList.add(childVO); } @@ -590,7 +600,7 @@ childVO.setItemValue(paramValue);//鍙傛暟鍊� childVO.setItemText(confColl1.get(i).getParameterSetName()); childVO.setCheckResult("1"); - childVO.setCheckTime(new Date().toString()); + childVO.setCheckTime(format.format(new Date())); mesChildList1.add(childVO); } @@ -618,7 +628,7 @@ childVO.setItemValue(paramValue);//鍙傛暟鍊� childVO.setItemText(confColl2.get(i).getParameterSetName()); childVO.setCheckResult("1"); - childVO.setCheckTime(new Date().toString()); + childVO.setCheckTime(format.format(new Date())); mesChildList2.add(childVO); } } @@ -644,7 +654,7 @@ childVO.setItemValue(paramValue);//鍙傛暟鍊� childVO.setItemText(confColl3.get(i).getParameterSetName()); childVO.setCheckResult("1"); - childVO.setCheckTime(new Date().toString()); + childVO.setCheckTime(format.format(new Date())); mesChildList3.add(childVO); } } @@ -670,7 +680,7 @@ childVO.setItemValue(paramValue);//鍙傛暟鍊� childVO.setItemText(confColl4.get(i).getParameterSetName()); childVO.setCheckResult("1"); - childVO.setCheckTime(new Date().toString()); + childVO.setCheckTime(format.format(new Date())); mesChildList4.add(childVO); } } @@ -687,9 +697,9 @@ String paramValue = ""; if (ObjectUtil.isNotNull(paramCollectionList0.get(j).getValue())) { paramValue = paramCollectionList0.get(j).getValue().toString();//鍙傛暟鍊� - } - if(confColl0.get(j).getCollectParameterName().contains("鏃堕棿") && !"".equals(paramValue)){ - paramValue = format.parse(TimeUtil.test(TimeUtil.stringProcessing(paramValue))).toString(); + if("DATE".equals(confColl0.get(j).getCollectParameterType()) && !paramValue.isEmpty()){ + paramValue = TimeUtil.test(TimeUtil.stringProcessing(paramValue)); + } } daParamCollection.setParamValue(paramValue);//鍙傛暟鍊� daParamCollection.setLocationCode(device);//宸ヤ綅 @@ -703,7 +713,7 @@ childVO.setItemValue(paramValue);//鍙傛暟鍊� childVO.setItemText(confColl0.get(j).getParameterSetName()); childVO.setCheckResult("1"); - childVO.setCheckTime(new Date().toString()); + childVO.setCheckTime(format.format(new Date())); mesChildList0.add(childVO); } } -- Gitblit v1.9.3