From e726415232fd4141135a399aa51ffafd45d8deff Mon Sep 17 00:00:00 2001
From: pang.jiabao <pang_jiabao@163.com>
Date: 星期四, 07 十一月 2024 20:12:22 +0800
Subject: [PATCH] 一楼返修入库,和出库推送mes记录日志

---
 src/main/java/com/zy/asrs/service/impl/MobileServiceImpl.java |   61 +++++++++++++++++++++++++++++-
 1 files changed, 59 insertions(+), 2 deletions(-)

diff --git a/src/main/java/com/zy/asrs/service/impl/MobileServiceImpl.java b/src/main/java/com/zy/asrs/service/impl/MobileServiceImpl.java
index 619b6e9..37969e5 100644
--- a/src/main/java/com/zy/asrs/service/impl/MobileServiceImpl.java
+++ b/src/main/java/com/zy/asrs/service/impl/MobileServiceImpl.java
@@ -1547,10 +1547,67 @@
             throw new CoolException(dto.getLocNo() + "鐩爣搴撲綅宸茶鍗犵敤");
         }
 
+        // 涓�妤艰繑淇叆搴撴帹閫乵es鍋氳褰�
+        pushFxrkToMes(param);
+
         // 杩斿洖GWCS鐩爣淇℃伅
         openServiceImpl.pushStaNoToGwcs(param.getPalletizingNo(), dto.getStaNo(), dto.getWorkNo(), param.getBarcode(), "浜屾ゼ杩斾慨鍏ュ簱鎺ㄩ�乬wcs");
 
         return R.ok("鍙嶄慨鍏ュ簱鎴愬姛");
+    }
+
+    private void pushFxrkToMes(GwmsGenerateInventoryDto param) {
+
+        for (GwmsGenerateInventoryDto.MatList matList : param.getMatList()){
+            matList.setOutOrIn("in");
+            matList.setStockType("杩斾慨鍏ュ簱");
+        }
+
+        boolean success = false;
+        // 鑾峰彇璇锋眰澶�
+        Map<String,Object> headers = new HashMap<>();
+        headers.put("Content-Type","application/json;charset=UTF-8");
+
+        // 鏋勯�犺姹備綋
+        String body = JSON.toJSONString(param);
+        String response = "";
+        try {
+            response = new HttpHandler.Builder()
+                    .setUri(MesConstant.MES_CC_IP_PORT)
+                    .setPath(MesConstant.MES_CC_FXRK_URL)
+                    .setHeaders(headers)
+                    .setJson(body)
+                    .build()
+                    .doGet();
+            if (!Cools.isEmpty(response)) {
+                JSONObject jsonObject1 = JSONObject.parseObject(response);
+                int code = (int) jsonObject1.get("code");
+                boolean state  = jsonObject1.getBoolean("state");
+                if (code == 200 && state) {
+                    success = true;
+                }
+            } else {
+                log.error("杩斾慨鍏ュ簱鎺ㄩ�乵es璁板綍澶辫触锛侊紒锛乽rl锛歿}锛況equest锛歿}锛況esponse锛歿}", MesConstant.MES_CC_IP_PORT + MesConstant.MES_CC_FXRK_URL, body, response);
+            }
+        } catch (Exception e) {
+            log.error("杩斾慨鍏ュ簱鎺ㄩ�乵es璁板綍寮傚父锛歿}", e.getMessage());
+        } finally {
+            try {
+                // 淇濆瓨鎺ュ彛鏃ュ織
+                apiLogService.save(
+                        "杩斾慨鍏ュ簱鎺ㄩ�乵es璁板綍",
+                        MesConstant.MES_CC_IP_PORT + MesConstant.MES_CC_FXRK_URL,
+                        null,
+                        "127.0.0.1",
+                        body,
+                        response,
+                        success
+                );
+            } catch (Exception e) {
+                log.error("", e);
+            }
+        }
+
     }
 
     @Override
@@ -1914,7 +1971,7 @@
                 }
                 throw new CoolException(msg);
             } else {
-                log.error("杩斾慨鍝佸叆搴撶粰mes鎺ㄩ�佸緟鍒ゅけ璐ワ紒锛侊紒url锛歿}锛況equest锛歿}锛況esponse锛歿}", MesConstant.MES_CC_IP_PORT + MesConstant.MES_CC_IP_PORT, body, response);
+                log.error("杩斾慨鍝佸叆搴撶粰mes鎺ㄩ�佸緟鍒ゅけ璐ワ紒锛侊紒url锛歿}锛況equest锛歿}锛況esponse锛歿}", MesConstant.MES_CC_IP_PORT + MesConstant.MES_CC_DP_URL, body, response);
                 throw new CoolException("杩斾慨鍝佸叆搴撶粰mes鎺ㄩ�佸緟鍒ゅけ璐�");
             }
         } catch (Exception e) {
@@ -1924,7 +1981,7 @@
                 // 淇濆瓨鎺ュ彛鏃ュ織
                 apiLogService.save(
                         "杩斾慨鍝佸叆搴撶粰mes鎺ㄩ�佸緟鍒�",
-                        MesConstant.MES_CC_IP_PORT + MesConstant.MES_CC_IP_PORT,
+                        MesConstant.MES_CC_IP_PORT + MesConstant.MES_CC_DP_URL,
                         null,
                         "127.0.0.1",
                         body,

--
Gitblit v1.9.1