From 2d0226ea3dd2116cfcc9ec307f17edf191458aad Mon Sep 17 00:00:00 2001
From: pang.jiabao <pang_jiabao@163.com>
Date: 星期二, 27 八月 2024 17:04:30 +0800
Subject: [PATCH] mes对接单据相关

---
 src/main/java/com/zy/asrs/service/impl/MobileServiceImpl.java |   64 +++++++++++++++++++++++++++++++
 1 files changed, 63 insertions(+), 1 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 7dbc6d1..f0ea5d9 100644
--- a/src/main/java/com/zy/asrs/service/impl/MobileServiceImpl.java
+++ b/src/main/java/com/zy/asrs/service/impl/MobileServiceImpl.java
@@ -1423,7 +1423,8 @@
     public R pdaFxprk(FxprkParam param, Long userId) {
 
         // 鏍规嵁鍖呰缁勫彿鑾峰彇鍒版湪绠卞嵎淇℃伅
-        List<Mat> list = matService.selectList(new EntityWrapper<Mat>().in("brand", param.getBoxList().stream().map(FxprkParam.Box::getPackageGroupNo).collect(Collectors.toList())));
+        List<String> groupNos = param.getBoxList().stream().map(FxprkParam.Box::getPackageGroupNo).collect(Collectors.toList());
+        List<Mat> list = matService.selectList(new EntityWrapper<Mat>().in("brand", groupNos));
         if (list.isEmpty()) {
             throw new CoolException("娌℃湁鏌ヨ鍒拌鍖呰缁勫彿淇℃伅锛�" + param.getBoxList().toString());
         }
@@ -1493,6 +1494,9 @@
             }
         }
 
+        // 涓�妤煎弽淇搧鍏ュ簱鐨勬湪绠遍�氳繃鍖呰缁勫彿闇�缁檓es鎺ㄩ�佸緟鍒�
+        pushDpToMes(groupNos);
+
         // 鏇存柊鐩爣搴撲綅鐘舵��
         LocMast locMast = locMastService.selectById(dto.getLocNo());
         if (locMast.getLocSts().equals("O")) {
@@ -1506,6 +1510,64 @@
         }
         return R.ok("鍏ュ簱鎴愬姛");
     }
+
+    /**
+     * 涓�妤煎弽淇搧鍏ュ簱鐨勬湪绠遍�氳繃鍖呰缁勫彿闇�缁檓es鎺ㄩ�佸緟鍒�
+     */
+    private void pushDpToMes(List<String> groupNos) {
+        boolean success = false;
+        // 鑾峰彇璇锋眰澶�
+        Map<String,Object> headers = new HashMap<>();
+        headers.put("digi-type","sync ");
+        headers.put("digi-protocol","raw");
+        headers.put("digi-datakey"," XCommon.ImportData");
+
+        // 鏋勯�犺姹備綋
+        JSONObject jsonObject = new JSONObject();
+        jsonObject.put("groupNos", groupNos);
+        String body = jsonObject.toJSONString();
+
+        String response = "";
+        try {
+            response = new HttpHandler.Builder()
+                    .setUri(MesConstant.MES_IP_PORT)
+                    .setPath(MesConstant.MES_DP_URL)
+                    .setHeaders(headers)
+                    .setJson(body)
+                    .build()
+                    .doPost();
+            if (!Cools.isEmpty(response)) {
+                JSONObject jsonObject1 = JSONObject.parseObject(response);
+                int code = (int) jsonObject1.get("code");
+                String msg = (String) jsonObject1.get("msg");
+                if (code != 200) {
+                    throw new CoolException(msg);
+                }
+                success = true;
+            } else {
+                log.error("杩斾慨鍝佸叆搴撶粰mes鎺ㄩ�佸緟鍒ゅけ璐ワ紒锛侊紒url锛歿}锛況equest锛歿}锛況esponse锛歿}", MesConstant.URL + MesConstant.PAKIN_URL, body, response);
+                throw new CoolException("杩斾慨鍝佸叆搴撶粰mes鎺ㄩ�佸緟鍒ゅけ璐�");
+            }
+        } catch (Exception e) {
+            log.error("杩斾慨鍝佸叆搴撶粰mes鎺ㄩ�佸緟鍒ゅ紓甯革細{}", e.getMessage());
+        } finally {
+            try {
+                // 淇濆瓨鎺ュ彛鏃ュ織
+                apiLogService.save(
+                        "杩斾慨鍝佸叆搴撶粰mes鎺ㄩ�佸緟鍒�",
+                        MesConstant.MES_IP_PORT + MesConstant.MES_DP_URL,
+                        null,
+                        "127.0.0.1",
+                        body,
+                        response,
+                        success
+                );
+            } catch (Exception e) {
+                log.error("", e);
+            }
+        }
+    }
+
     public boolean pushStaNoToGwcs(Integer palletizingNo, Integer staNo, Integer workNo,String barcode) {
         boolean success = false;
         // 鑾峰彇璇锋眰澶�

--
Gitblit v1.9.1