From 069a9b2f61470d063124fba757f25cf7ef49a32f Mon Sep 17 00:00:00 2001 From: cl <418351270@qq.com> Date: 星期五, 12 七月 2024 10:24:46 +0800 Subject: [PATCH] 修改参数采集 --- jcdm-main/src/main/java/com/jcdm/main/plcserver/sub/OPCUaSubscription.java | 52 ++++++++++++++++++++++++++-------------------------- 1 files changed, 26 insertions(+), 26 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 b1180b0..2383d39 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 @@ -199,7 +199,7 @@ }else{ result = savePassingStation(thoroughfare, device,cellCodeList);//淇濆瓨杩囩珯 if(result == 21) { - result = saveParamCollection(thoroughfare, device,cellCodeList);//淇濆瓨鍙傛暟锛屽彂閫佸伐鍘侻ES + result = saveParamCollection(device,cellCodeList);//淇濆瓨鍙傛暟锛屽彂閫佸伐鍘侻ES } } miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".RecordDataDone").value(result).build()); @@ -214,10 +214,18 @@ result = 23; }else{ String moduleCode = modulCodeObjcet.toString(); - result = savePassingStation(thoroughfare, device,moduleCode);//淇濆瓨杩囩珯 - if(result == 21) { - result = saveParamCollection(thoroughfare, device,moduleCode);//淇濆瓨鍙傛暟锛屽彂閫佸伐鍘侻ES + Object stationStatusObjcet = miloService.readFromOpcUa(thoroughfare + "." + device + ".StationStatus").getValue();//绔欑姸鎬佸湴鍧� + if (ObjectUtil.isNotNull(stationStatusObjcet)){ + String stationStatus = stationStatusObjcet.toString(); + result = savePassingStation(thoroughfare, device,moduleCode,stationStatus);//淇濆瓨杩囩珯 + if(result == 21) { + result = saveParamCollection(device,moduleCode,stationStatus);//淇濆瓨鍙傛暟锛屽彂閫佸伐鍘侻ES + } + }else{ + result = 23; + log.info("璇诲彇鍒板伐浣峽}StationStatus鏁版嵁锛歿},杩斿洖RecordDataDone鐨勫�间负{}",device,"IS NULL锛�",result); } + } miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".RecordDataDone").value(result).build()); log.info("鍐欏叆鍒板伐浣峽}鐨凴ecordDataDone鏁版嵁锛歿}",device,result); @@ -267,6 +275,8 @@ try { // 鏌ヨ鏈�鏂扮殑宸ュ崟淇℃伅 OmProductionOrdeInfo lastOrder = omProductionOrdeInfoService.getLastOrder(); + + log.info("璇锋眰宸ュ巶MES宸ュ崟锛氬叆鍙俤evice{},materialCode锛歿}", device, materialCode); String orderJsonString = RestfulService.getProductionWorkOrderRequest(lastOrder.getProductNum(), "M1OP100",materialCode); JSONObject jsonObject = new JSONObject(orderJsonString); // 浠嶫SONObject涓幏鍙杁ata瀵硅薄 @@ -339,10 +349,11 @@ * @param thoroughfare 閫氶亾 * @param device 宸ヤ綅 * @param moduleCode 妯$粍鍙� + * @param stationStatus 绔欑姸鎬� * @return list * @throws Exception e */ - private static Integer savePassingStation(String thoroughfare, String device,String moduleCode){ + private static Integer savePassingStation(String thoroughfare, String device,String moduleCode,String stationStatus){ Integer result = 21; try { @@ -354,20 +365,6 @@ }else{ result = 23; log.info("璇诲彇鍒板伐浣峽}鐨凷tartTime鏁版嵁锛歿},杩斿洖RecordDataDone鐨勫�间负{}",device,"IS NULL锛�",result); - return result; - } - - //璇诲伐绔欑姸鎬� - String stationStatus = Constants.PASS; - ReadWriteEntity stationStatusRead = miloService.readFromOpcUa(thoroughfare + "." + device + ".StationStatus");//绔欑姸鎬佸湴鍧� - if (ObjectUtil.isNotNull(stationStatusRead.getValue())){ - String string = stationStatusRead.getValue().toString(); - if (Constants.TWO.equals(string)){ - stationStatus = Constants.UN_PASS; - } - }else{ - result = 23; - log.info("璇诲彇鍒板伐浣峽}StationStatus鏁版嵁锛歿},杩斿洖RecordDataDone鐨勫�间负{}",device,"IS NULL锛�",result); return result; } @@ -452,13 +449,13 @@ /** * 淇濆瓨鍙傛暟鏁版嵁鍜屽彂閫佸伐鍘侻ES - * @param thoroughfare 閫氶亾 * @param device 宸ヤ綅 * @param moduleCode 妯$粍鍙� + * @param stationStatus 绔欑姸鎬� * @return list * @throws Exception e */ - private static Integer saveParamCollection(String thoroughfare, String device,String moduleCode){ + private static Integer saveParamCollection(String device,String moduleCode,String stationStatus){ Integer result = 21;//杩斿洖缁撴灉 String sendMes = ""; @@ -513,12 +510,16 @@ parentVO.setSiteCode("3983"); parentVO.setRecordId(UUID.randomUUID().toString()); - parentVO.setTotalResult("1"); + if("2".equals(stationStatus)){ + parentVO.setTotalResult("0"); + }else { + parentVO.setTotalResult("1"); + } parentVO.setProductNum(moduleCode); parentVO.setCheckList(mesList); log.info("鎵ц宸ュ巶MES鏂规硶start锛屽伐浣嶅彿{} 浼犲叆鏁版嵁锛歿}",device ,parentVO); - HttpResponse execute = HttpRequest.post(Constants.FACTORY_EMS_UAT_RUL+"deviceResultFeedback").body(JSONUtil.toJsonStr(parentVO)).execute(); + HttpResponse execute = HttpRequest.post(Constants.FACTORY_EMS_UAT_GET_RUL+"deviceResultFeedback").body(JSONUtil.toJsonStr(parentVO)).execute(); log.info("鎵ц宸ュ巶MES鏂规硶end锛屽伐浣嶅彿{} 杩斿洖鏁版嵁锛歿}",device,execute.body()); }); @@ -531,13 +532,12 @@ /** * 淇濆瓨鍙傛暟鏁版嵁鍜屽彂閫佸伐鍘侻ES - * @param thoroughfare 閫氶亾 * @param device 宸ヤ綅 * @param cellCodeList 鐢佃姱鐮侀泦鍚� * @return list * @throws Exception e */ - private static Integer saveParamCollection(String thoroughfare, String device,List<String> cellCodeList){ + private static Integer saveParamCollection(String device,List<String> cellCodeList){ Integer result = 21;//杩斿洖缁撴灉 List<ChildVO> mesChildList1 = new ArrayList<>();//灏佽缁欏伐鍘侻ES鍙戦�佺殑childlist1 List<ChildVO> mesChildList2 = new ArrayList<>();//灏佽缁欏伐鍘侻ES鍙戦�佺殑childlist2 @@ -758,7 +758,7 @@ parentVO.setCheckList(mesChildList);//鍙傛暟 //CompletableFuture<Void> cp1 = CompletableFuture.runAsync(() -> { log.info("鎵ц宸ュ巶MES鏂规硶start锛屼紶鍏ユ暟鎹細{}",parentVO); - HttpResponse execute = HttpRequest.post(Constants.FACTORY_EMS_UAT_RUL+"deviceResultFeedback").body(JSONUtil.toJsonStr(parentVO)).execute(); + HttpResponse execute = HttpRequest.post(Constants.FACTORY_EMS_UAT_GET_RUL+"deviceResultFeedback").body(JSONUtil.toJsonStr(parentVO)).execute(); log.info("鎵ц宸ュ巶MES鏂规硶end锛岃繑鍥炴暟鎹細{}",execute.body()); } } -- Gitblit v1.9.3