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/bs/formulaChild/controller/BsFormulaChildInfoController.java |    4 ++--
 jcdm-main/src/main/java/com/jcdm/main/plcserver/sub/OPCUaSubscription.java                         |   47 +++++++++++++++++++++++++----------------------
 2 files changed, 27 insertions(+), 24 deletions(-)

diff --git a/jcdm-main/src/main/java/com/jcdm/main/bs/formulaChild/controller/BsFormulaChildInfoController.java b/jcdm-main/src/main/java/com/jcdm/main/bs/formulaChild/controller/BsFormulaChildInfoController.java
index a3a871a..8b0121b 100644
--- a/jcdm-main/src/main/java/com/jcdm/main/bs/formulaChild/controller/BsFormulaChildInfoController.java
+++ b/jcdm-main/src/main/java/com/jcdm/main/bs/formulaChild/controller/BsFormulaChildInfoController.java
@@ -112,14 +112,14 @@
             String thoroughfare = Constants.thoroughfareMap.get(bsFormulaChildInfo.getProcessesCode());//鑾峰彇閫氶亾
             String str = thoroughfare+"."+bsFormulaChildInfo.getProcessesCode()+".MESScrew";
             miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(str).value(stepNumber).build());//鎷х揣姝ラ
-            if(bsFormulaChildInfo.getProcessesCode().equals("OP230")){
+            if("OP230".equals(bsFormulaChildInfo.getProcessesCode())){
                 //鎵�鏈夎繘绔欏皢杩涚珯鏃堕棿鍐欑粰PLC
                 SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                 String currentDate = dateFormat.format(new Date());
                 miloService.writeToOpcUa(ReadWriteEntity.builder().identifier(thoroughfare + "." + bsFormulaChildInfo.getProcessesCode() + ".StartTime").value(currentDate).build());
                 miloService.writeToOpcUa(ReadWriteEntity.builder().identifier(thoroughfare + "." + bsFormulaChildInfo.getProcessesCode() + ".SNCode").value(bsFormulaChildInfo.getSfcBarcode()).build());
                 miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + bsFormulaChildInfo.getProcessesCode() + ".RecordDataDone").value(11).build());
-            }else if(bsFormulaChildInfo.getProcessesCode().equals("OP220")){
+            }else if("OP220".equals(bsFormulaChildInfo.getProcessesCode())){
                 miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + bsFormulaChildInfo.getProcessesCode() + ".RecordDataDone").value(11).build());
             }
 
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