From 252f60a80998f2b50e5864c5ce087fac9a8d9ff8 Mon Sep 17 00:00:00 2001 From: cl <418351270@qq.com> Date: 星期五, 06 九月 2024 09:44:46 +0800 Subject: [PATCH] 添加二次报工 --- jcdm-main/src/main/java/com/jcdm/main/plcserver/sub/OPCUaSubscription.java | 47 +++++++++++++++++++++++++---------------------- 1 files changed, 25 insertions(+), 22 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 ca019ce..e4e6c25 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 @@ -109,11 +109,11 @@ if (Constants.RECORD_DATA.equals(tab)) { //鍑哄叆绔� if (Constants.ONE.equals(valueString)) {//鍏ョ珯 if(Constants.OP040_OP160.contains(device)){//浜哄伐宸ヤ綅 - Object snCodeObjcet = miloService.readFromOpcUa(thoroughfare + "." + device + ".SNCode").getValue(); - if (ObjectUtil.isNull(snCodeObjcet)){ + Object snCodeObject = miloService.readFromOpcUa(thoroughfare + "." + device + ".SNCode").getValue(); + if (ObjectUtil.isNull(snCodeObject)){ miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".RecordDataDone").value(12).build()); }else{ - String productNum = snCodeObjcet.toString().trim(); + String productNum = snCodeObject.toString().trim(); if(productNum.length()<10){ miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".RecordDataDone").value(12).build()); }else{ @@ -145,14 +145,14 @@ WebSocketUsers.sendMessageToUserByText(map.get(device), "END"); } else{//鑷姩宸ヤ綅 //鍏堝垽鏂槸鍚︽湁浜у搧SN - Object snCodeObjcet = miloService.readFromOpcUa(thoroughfare + "." + device + ".SNCode").getValue(); + Object snCodeObject = miloService.readFromOpcUa(thoroughfare + "." + device + ".SNCode").getValue(); Object orderObjcet = miloService.readFromOpcUa(thoroughfare + "." + device + ".WorkOrderNumber").getValue(); - if (ObjectUtil.isNull(snCodeObjcet)){ + if (ObjectUtil.isNull(snCodeObject)){ miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".RecordDataDone").value(25).build()); }else { Integer result = 21; - String snCode = snCodeObjcet.toString().trim();//浜у搧SN + String snCode = snCodeObject.toString().trim();//浜у搧SN String orderNumber = orderObjcet.toString().trim();//宸ュ崟鍙� if(snCode.length()<10){ result = 22; @@ -167,11 +167,11 @@ if (ObjectUtil.isNotNull(stationStatusObjcet)) { String stationStatus = stationStatusObjcet.toString(); if (Constants.OP010.equals(device)) { - Object housingCodeObjcet = miloService.readFromOpcUa(thoroughfare + "." + device + ".HousingCode").getValue();//澹充綋鏉$爜锛屽瓨鍒板伐鍗曪紝杩斾慨鐢� - if (ObjectUtil.isNull(housingCodeObjcet)){ + Object housingCodeObject = miloService.readFromOpcUa(thoroughfare + "." + device + ".HousingCode").getValue();//澹充綋鏉$爜锛屽瓨鍒板伐鍗曪紝杩斾慨鐢� + if (ObjectUtil.isNull(housingCodeObject)){ result = 25; }else{ - String housingCode = housingCodeObjcet.toString();//澹充綋鏉$爜锛屽瓨鍒板伐鍗曪紝杩斾慨鐢� + String housingCode = housingCodeObject.toString();//澹充綋鏉$爜锛屽瓨鍒板伐鍗曪紝杩斾慨鐢� if(housingCode.length()<10){ result = 25; }else{ @@ -397,7 +397,7 @@ JSONObject dataObject = jsonObject.getJSONObject("data"); String code = jsonObject.getStr("code"); // 鍒ゆ柇鎺ュ崟鏄惁鎴愬姛 - if(code.equals("success")) { + if("success".equals(code)) { OmProductionOrdeInfo omProductionOrdeInfo = new OmProductionOrdeInfo(); omProductionOrdeInfo.setWorkOrderNo(dataObject.getStr("productionOrderNum")); omProductionOrdeInfo.setProductNum(dataObject.getStr("productNum")); @@ -460,27 +460,30 @@ * 宸ュ巶MES鎶ュ伐 * @param productNum 閫氶亾 * @param stationCode 宸ヤ綅 - * @param confirmTime 鐗╂枡鍙� + * @param confirmTime 鏃堕棿 * @throws Exception e */ //{"code":"success","data":{"productNum":"LCV123456P0600036","stationCode":"1HZ01","resultCode":"S","resultText":"鎶ュ伐鎴愬姛"},"message":"API璋冪敤鎴愬姛"} - public static void reportFactoryMes(String productNum, String stationCode, String confirmTime) + public static void reportFactoryMes(String productNum,String stationCode,String confirmTime) { + String result = ""; + String url = Constants.FACTORY_EMS_UAT_GET_RUL + "workReportResultFeedback?siteCode="+Constants.FACTORY_EMS_SITE_CODE+"&stationCode="+stationCode+"&productNum="+productNum+"&confirmTime="+confirmTime; try { - CompletableFuture<Void> cp1 = CompletableFuture.runAsync(() -> { - log.info("璇锋眰宸ュ巶MES鎶ュ伐锛氬叆鍙俤evice{},productNum锛歿}", stationCode, productNum); - String url = Constants.FACTORY_EMS_UAT_GET_RUL + "workReportResultFeedback?siteCode="+Constants.FACTORY_EMS_SITE_CODE+"&stationCode="+stationCode+"&productNum="+productNum+"&confirmTime="+confirmTime; - HttpResponse response = HttpRequest.get(url).execute(); - /*HttpRequest httpRequest = HttpRequest.get(url);*/ - String result = response.body(); - log.info("璇锋眰宸ュ巶MES鎶ュ伐锛氬嚭鍙傦細{}", result); - }); - + log.info("鎵ц宸ュ巶MES鎶ュ伐鏂规硶start锛屽簭鍒楀彿{}宸ヤ綅鍙穥}url{}",productNum,stationCode ,url); + HttpResponse response = HttpRequest.get(url).execute(); + //HttpRequest httpRequest = HttpRequest.get(url); + result = response.body(); + log.info("鎵ц宸ュ巶MES鎶ュ伐鏂规硶绗竴娆nd锛屽簭鍒楀彿{}宸ヤ綅鍙穥}杩斿洖鏁版嵁{}",productNum,stationCode ,result); }catch (Exception e){ throw new RuntimeException(e); + }finally { + if(result.isEmpty()){ + HttpResponse response = HttpRequest.get(url).execute(); + result = response.body(); + log.info("鎵ц宸ュ巶MES鎶ュ伐鏂规硶绗簩娆nd锛屽簭鍒楀彿{}宸ヤ綅鍙穥}杩斿洖鏁版嵁{}",productNum,stationCode ,result); + } } } - public static String TightenTheConversionOkNg(String param){ // 鍘婚櫎棣栧熬鐨勬柟鎷彿锛岀劧鍚庢寜鐓ч�楀彿鍒嗗壊瀛楃涓� String[] parts = param.substring(1, param.length() - 1).split(","); -- Gitblit v1.9.3