From 20635fa3540068045b07471f08ab107b9d0f4281 Mon Sep 17 00:00:00 2001 From: admin <15939171744@163.com> Date: 星期五, 05 七月 2024 08:54:01 +0800 Subject: [PATCH] -统一工厂MES UAT环境URL字符串 --- jcdm-main/src/main/java/com/jcdm/main/plcserver/sub/OPCUaSubscription.java | 117 +++++++++++++++++++++++++++++++++++----------------------- 1 files changed, 70 insertions(+), 47 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 ee8ec87..41602ba 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 @@ -62,8 +62,8 @@ public static IDaTestDeviceInterfaceTempService daTestDeviceInterfaceTempService; - @Value("${orderLineUrl}") - private static String orderLineUrl; +/* @Value("${orderLineUrl}") + private static String orderLineUrl;*/ public OPCUaSubscription(MiloService miloService, IDaPassingStationCollectionService daPassingStationCollectionService, @@ -127,34 +127,6 @@ } }else if (Constants.RECORD_SN.equals(tab)){//姹備笅鍙戞ā缁勭爜璇�9 if (Constants.ONE.equals(valueString)){ - /*if (Constants.OP100_1.equals(device) || Constants.OP100_2.equals(device) ){ - //鏌ヨ瑕佺敓浜х殑宸ュ崟 - List<OmProductionOrdeInfo> orderList = omProductionOrdeInfoService.list(new LambdaQueryWrapper<OmProductionOrdeInfo>() - .eq(OmProductionOrdeInfo::getOrderStatus, Constants.ONE));//宸ュ崟鐘舵�� - - if (CollUtil.isNotEmpty(orderList)){ - Long id = orderList.get(0).getId(); - String productNum = orderList.get(0).getProductNum();//妯$粍鐮� - //涓嬪彂浜у搧妯$粍鐮� - 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.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".MES_ProductType").value(productNum).build()); - miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".RecordSNDone").value(1).build()); - - //鏇存柊宸ュ崟鐘舵�佷负鎵ц涓� - OmProductionOrdeInfo omProductionOrdeInfo = new OmProductionOrdeInfo(); - omProductionOrdeInfo.setId(id); - omProductionOrdeInfo.setOrderStatus("3"); - omProductionOrdeInfoService.updateOmProductionOrdeInfo(omProductionOrdeInfo); - - //灏嗕骇鍝丼N鍙戦�佸埌鍓嶅彴 - productNum = "productNum,"+ productNum; - WebSocketUsers.sendMessageToUserByText(map.get(device), productNum); - }else{ - miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".RecordSNDone").value(2).build());//娌℃湁瑕佺敓浜х殑宸ュ崟 - } - }*/ - miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".RecordSNDone").value(1).build());//娌℃湁瑕佺敓浜х殑宸ュ崟 } }else if (Constants.RECORD_DATA.equals(tab)){//鍑哄叆绔� @@ -178,7 +150,7 @@ String productType = productTypeRead.getValue().toString(); CompletableFuture<Void> cp1 = CompletableFuture.runAsync(() -> { - //璋冪敤宸ュ巶MES锛屼繚瀛樺埌鏁版嵁搴�,骞朵笖灏嗗伐鍗曚紶缁橮LC + //璋冪敤宸ュ巶MES锛屼繚瀛樺埌鏁版嵁搴�,骞朵笖灏嗗伐鍗曚紶缁橮LC (鐩墠涓存椂鐢ㄨ鏂规硶锛� receivingWorkOrders(thoroughfare, device); }); @@ -249,14 +221,46 @@ } } - public void receivingWorkOrders(String thoroughfare ,String device) + { + String paramProductNum = ""; + try { + + List<OmProductionOrdeInfo> orderList = omProductionOrdeInfoService.list(new LambdaQueryWrapper<OmProductionOrdeInfo>() + .eq(OmProductionOrdeInfo::getOrderStatus, Constants.ONE));//宸ュ崟鐘舵�� + + if (CollUtil.isNotEmpty(orderList)){ + Long id = orderList.get(0).getId(); + String productNum = orderList.get(0).getProductNum();//妯$粍鐮� + //涓嬪彂浜у搧妯$粍鐮� + 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.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".RecordSNDone").value(1).build()); + + //鏇存柊宸ュ崟鐘舵�佷负鎵ц涓� + OmProductionOrdeInfo omProductionOrdeInfo = new OmProductionOrdeInfo(); + omProductionOrdeInfo.setId(id); + omProductionOrdeInfo.setOrderStatus("3"); + omProductionOrdeInfoService.updateOmProductionOrdeInfo(omProductionOrdeInfo); + + //灏嗕骇鍝丼N鍙戦�佸埌鍓嶅彴 + productNum = "productNum,"+ productNum; + WebSocketUsers.sendMessageToUserByText(map.get(device), productNum); + }/*else{ + miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".RecordSNDone").value(2).build());//娌℃湁瑕佺敓浜х殑宸ュ崟 + }*/ + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + /* public void receivingWorkOrders(String thoroughfare ,String device) { String paramProductNum = ""; try { // 鏌ヨ鏈�鏂扮殑宸ュ崟淇℃伅 OmProductionOrdeInfo lastOrder = omProductionOrdeInfoService.getLastOrder(); - String orderJsonString = RestfulService.getProductionWorkOrderRequest(lastOrder.getProductNum(), "OP230"); + String orderJsonString = RestfulService.getProductionWorkOrderRequest(lastOrder.getProductNum(), "M1OP100"); JSONObject jsonObject = new JSONObject(orderJsonString); // 浠嶫SONObject涓幏鍙杁ata瀵硅薄 JSONObject dataObject = jsonObject.getJSONObject("data"); @@ -287,7 +291,7 @@ } catch (Exception e) { throw new RuntimeException(e); } - } + }*/ /** * 璇诲彇鐢佃姱鐮� @@ -310,9 +314,9 @@ for (ReadWriteEntity readWriteEntity : readWriteEntityList) { if (ObjectUtil.isNotNull(readWriteEntity.getValue()) && !"".equals(readWriteEntity.getValue().toString().trim())){ cellCodeList.add(readWriteEntity.getValue().toString());//灏佽鐢佃姱鐮� - }else{ + }/*else{ cellCodeList.add("");//灏佽鐢佃姱鐮� - } + }*/ } } catch (Exception e) { @@ -503,7 +507,7 @@ parentVO.setCheckList(mesList); log.info("鎵ц宸ュ巶MES鏂规硶start锛屼紶鍏ユ暟鎹細{}",parentVO); - HttpResponse execute = HttpRequest.post(orderLineUrl).body(JSONUtil.toJsonStr(parentVO)).execute(); + HttpResponse execute = HttpRequest.post(Constants.FACTORY_EMS_UAT_RUL+"deviceResultFeedback").body(JSONUtil.toJsonStr(parentVO)).execute(); log.info("鎵ц宸ュ巶MES鏂规硶end锛岃繑鍥炴暟鎹細{}",execute.body()); }); @@ -743,7 +747,7 @@ parentVO.setCheckList(mesChildList);//鍙傛暟 //CompletableFuture<Void> cp1 = CompletableFuture.runAsync(() -> { log.info("鎵ц宸ュ巶MES鏂规硶start锛屼紶鍏ユ暟鎹細{}",parentVO); - HttpResponse execute = HttpRequest.post(orderLineUrl).body(JSONUtil.toJsonStr(parentVO)).execute(); + HttpResponse execute = HttpRequest.post(Constants.FACTORY_EMS_UAT_RUL+"deviceResultFeedback").body(JSONUtil.toJsonStr(parentVO)).execute(); log.info("鎵ц宸ュ巶MES鏂规硶end锛岃繑鍥炴暟鎹細{}",execute.body()); } } @@ -778,7 +782,10 @@ miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".CellStatus_1").value(2).build()); } daTestDeviceInterfaceTempService.deleteDaTestDeviceInterfaceTempByProductNum(cellCode); - + }else { + flag = false; + miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".CellStatus_1").value(2).build()); + log.info("璇诲彇鍒板伐浣峽},娴嬭瘯璁惧杩斿洖鐨勬暟鎹煡璇笉鍒帮紝鐢佃姱鐮佷负锛歿}",device,cellCode); } return flag; } @@ -797,15 +804,19 @@ .eq(DaTestDeviceInterfaceTemp::getStationCode, device) .eq(DaTestDeviceInterfaceTemp::getProductNum,cellCode)); if (CollUtil.isNotEmpty(list)){ - DaTestDeviceInterfaceTemp daTestDeviceInterfaceTemp = list.get(0); + DaTestDeviceInterfaceTemp daTestDeviceInterfaceTemp = list.get(list.size()-1); if (Constants.ONE.equals(daTestDeviceInterfaceTemp.getTotalResult())){ miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".CellStatus_1").value(1).build()); }else { flag = false; miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".CellStatus_1").value(2).build()); } - daTestDeviceInterfaceTempService.deleteDaTestDeviceInterfaceTempById(daTestDeviceInterfaceTemp.getId()); + daTestDeviceInterfaceTempService.deleteDaTestDeviceInterfaceTempByProductNum(cellCode); } + }else { + flag = false; + miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".CellStatus_1").value(2).build()); + log.info("璇诲彇鍒板伐浣峽},PLC娌℃湁缁欑數鑺爜",device); } Object value2 = miloService.readFromOpcUa(thoroughfare + "." + device + ".CellCode_2").getValue(); if (ObjectUtil.isNotNull(value2)){ @@ -814,15 +825,19 @@ .eq(DaTestDeviceInterfaceTemp::getStationCode, device) .eq(DaTestDeviceInterfaceTemp::getProductNum,cellCode)); if (CollUtil.isNotEmpty(list)){ - DaTestDeviceInterfaceTemp daTestDeviceInterfaceTemp = list.get(0); + DaTestDeviceInterfaceTemp daTestDeviceInterfaceTemp = list.get(list.size()-1); if (Constants.ONE.equals(daTestDeviceInterfaceTemp.getTotalResult())){ miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".CellStatus_2").value(1).build()); }else { flag = false; miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".CellStatus_2").value(2).build()); } - daTestDeviceInterfaceTempService.deleteDaTestDeviceInterfaceTempById(daTestDeviceInterfaceTemp.getId()); + daTestDeviceInterfaceTempService.deleteDaTestDeviceInterfaceTempByProductNum(cellCode); } + }else { + flag = false; + miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".CellStatus_2").value(2).build()); + log.info("璇诲彇鍒板伐浣峽},PLC娌℃湁缁欑數鑺爜",device); } Object value3 = miloService.readFromOpcUa(thoroughfare + "." + device + ".CellCode_3").getValue(); @@ -832,15 +847,19 @@ .eq(DaTestDeviceInterfaceTemp::getStationCode, device) .eq(DaTestDeviceInterfaceTemp::getProductNum,cellCode)); if (CollUtil.isNotEmpty(list)){ - DaTestDeviceInterfaceTemp daTestDeviceInterfaceTemp = list.get(0); + DaTestDeviceInterfaceTemp daTestDeviceInterfaceTemp = list.get(list.size()-1); if (Constants.ONE.equals(daTestDeviceInterfaceTemp.getTotalResult())){ miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".CellStatus_3").value(1).build()); }else { flag = false; miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".CellStatus_3").value(2).build()); } - daTestDeviceInterfaceTempService.deleteDaTestDeviceInterfaceTempById(daTestDeviceInterfaceTemp.getId()); + daTestDeviceInterfaceTempService.deleteDaTestDeviceInterfaceTempByProductNum(cellCode); } + }else { + flag = false; + miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".CellStatus_3").value(2).build()); + log.info("璇诲彇鍒板伐浣峽},PLC娌℃湁缁欑數鑺爜",device); } Object value4 = miloService.readFromOpcUa(thoroughfare + "." + device + ".CellCode_4").getValue(); @@ -850,15 +869,19 @@ .eq(DaTestDeviceInterfaceTemp::getStationCode, device) .eq(DaTestDeviceInterfaceTemp::getProductNum,cellCode)); if (CollUtil.isNotEmpty(list)){ - DaTestDeviceInterfaceTemp daTestDeviceInterfaceTemp = list.get(0); + DaTestDeviceInterfaceTemp daTestDeviceInterfaceTemp = list.get(list.size()-1); if (Constants.ONE.equals(daTestDeviceInterfaceTemp.getTotalResult())){ miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".CellStatus_4").value(1).build()); }else { flag = false; miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".CellStatus_4").value(2).build()); } - daTestDeviceInterfaceTempService.deleteDaTestDeviceInterfaceTempById(daTestDeviceInterfaceTemp.getId()); + daTestDeviceInterfaceTempService.deleteDaTestDeviceInterfaceTempByProductNum(cellCode); } + }else { + flag = false; + miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".CellStatus_4").value(2).build()); + log.info("璇诲彇鍒板伐浣峽},PLC娌℃湁缁欑數鑺爜",device); } return flag; -- Gitblit v1.9.3