From b6a095a76848ffd15922cc4af7f14594fc5bf85d Mon Sep 17 00:00:00 2001
From: zjj <3272660260@qq.com>
Date: 星期五, 08 十一月 2024 11:16:26 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/jxgtasrs' into jxgtasrs

---
 src/main/java/com/zy/asrs/service/impl/MobileServiceImpl.java |  180 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 172 insertions(+), 8 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 26be866..6fe4876 100644
--- a/src/main/java/com/zy/asrs/service/impl/MobileServiceImpl.java
+++ b/src/main/java/com/zy/asrs/service/impl/MobileServiceImpl.java
@@ -7,14 +7,12 @@
 import com.core.common.*;
 import com.core.exception.CoolException;
 import com.zy.asrs.entity.*;
-import com.zy.asrs.entity.param.CombParam;
-import com.zy.asrs.entity.param.MobileAdjustParam;
-import com.zy.asrs.entity.param.OffSaleParam;
-import com.zy.asrs.entity.param.OpenOrderPakinParam;
+import com.zy.asrs.entity.param.*;
 import com.zy.asrs.mapper.ManLocDetlMapper;
 import com.zy.asrs.service.*;
 import com.zy.asrs.utils.MatUtils;
-import com.zy.common.CodeRes;
+import com.zy.common.constant.AgvSiteConstant;
+import com.zy.common.constant.ApiInterfaceConstant;
 import com.zy.common.constant.MesConstant;
 import com.zy.common.entity.Parameter;
 import com.zy.common.model.DetlDto;
@@ -77,6 +75,171 @@
 
 
     @Override
+    public R inLocCallAgv(String sta, String inSta) {
+        // 鍒ゆ柇鍏ュ簱绔欑偣鏈夋棤鍑哄簱浠诲姟杩囨护鐩樼偣鎹℃枡
+        int count = wrkMastService.selectCount(new EntityWrapper<WrkMast>().eq("sta_no", inSta).ne("wrk_sts",15).notIn("io_type",103,107));
+        if (count > 0) {
+            return R.parse(inSta + "绔欑偣瀛樺湪鍑哄簱浠诲姟");
+        }
+
+        // 鍏堢粦瀹�
+//        boolean flag = bindPodAndBerth(sta);
+//        if (!flag) {
+//            return R.parse(inSta + "缁戝畾澶辫触");
+//        }
+
+        ForwardAGVTaskParam forwardAGVTaskParam = new ForwardAGVTaskParam();
+        forwardAGVTaskParam.setReqCode(UUID.randomUUID().toString().replace("-", ""));
+        forwardAGVTaskParam.setClientCode("IWMS");
+        forwardAGVTaskParam.setTaskTyp("GT3");
+        forwardAGVTaskParam.setCtnrTyp("2");
+        forwardAGVTaskParam.setPriority("1");
+        List<ForwardAGVTaskParam.PositionCodePaths> positionCodePathsList = new ArrayList<>();
+        positionCodePathsList.add(new ForwardAGVTaskParam.PositionCodePaths(sta, "05"));
+        positionCodePathsList.add(new ForwardAGVTaskParam.PositionCodePaths(inSta, "05"));
+        forwardAGVTaskParam.setPositionCodePath(positionCodePathsList);
+
+        String body = JSON.toJSONString(forwardAGVTaskParam);
+        String response = "";
+        String message = "";
+        boolean success = false;
+        try {
+            response = new HttpHandler.Builder()
+                    .setUri(ApiInterfaceConstant.AGV_IP)
+                    .setPath(ApiInterfaceConstant.AGV_CALL_IN_PATH)
+                    .setJson(body)
+                    .build()
+                    .doPost();
+            JSONObject jsonObject = JSON.parseObject(response);
+            jsonObject.getString("message");
+            if (jsonObject.getInteger("code").equals(0)) {
+                success = true;
+            } else {
+                log.error("鍏ュ簱鍛煎彨agv澶辫触锛侊紒锛乽rl锛歿}锛況equest锛歿}锛況esponse锛歿}", ApiInterfaceConstant.AGV_IP + ApiInterfaceConstant.AGV_CALL_IN_PATH, body, response);
+            }
+        } catch (Exception e) {
+            log.error("鍏ュ簱鍛煎彨agv寮傚父", e);
+        } finally {
+            try {
+                // 淇濆瓨鎺ュ彛鏃ュ織
+                apiLogService.save(
+                        "鍏ュ簱鍛煎彨agv",
+                        ApiInterfaceConstant.AGV_IP + ApiInterfaceConstant.AGV_CALL_IN_PATH,
+                        null,
+                        "127.0.0.1",
+                        body,
+                        response,
+                        success
+                );
+            } catch (Exception e) {
+                log.error("", e);
+            }
+        }
+
+        return success ? R.ok("鍛煎彨agv鎴愬姛") : R.parse(message);
+    }
+
+    @Override
+    public R unbind(String site) {
+        String staMap = AgvSiteConstant.SiteMap.get(site);
+        if (staMap == null) {
+            return R.parse("娌℃湁鎵惧埌璇ョ珯鐐圭殑鍏ュ簱鏄犲皠锛�" + site);
+        }
+        JSONObject jsonObject = new JSONObject();
+        jsonObject.put("reqCode",UUID.randomUUID().toString().replace("-", "")); // 璇锋眰鍞竴鍊�
+        jsonObject.put("ctnrTyp","2"); // 瀹瑰櫒绫诲瀷2
+        jsonObject.put("stgBinCode",staMap); // 浠撲綅缂栧彿锛屾牴鎹浠撶紪鍙疯浆鎹�
+        jsonObject.put("indBind","0"); // 1缁戝畾锛�0瑙g粦
+
+        String body = jsonObject.toJSONString();
+        String response = "";
+        String message = "";
+        boolean success = false;
+        try {
+            response = new HttpHandler.Builder()
+                    .setUri(ApiInterfaceConstant.AGV_IP)
+                    .setPath(ApiInterfaceConstant.AGV_BIND_PATH)
+                    .setJson(body)
+                    .build()
+                    .doPost();
+            JSONObject res = JSON.parseObject(response);
+            message = jsonObject.getString("message");
+            if (res.getInteger("code").equals(0)) {
+                success = true;
+            } else {
+                log.error("璋冪敤agv瑙g粦鏆傚瓨浣嶅け璐ワ紒锛侊紒url锛歿}锛況equest锛歿}锛況esponse锛歿}", ApiInterfaceConstant.AGV_IP + ApiInterfaceConstant.AGV_BIND_PATH, body, response);
+            }
+        } catch (Exception e) {
+            log.error("璋冪敤agv瑙g粦鏆傚瓨浣嶅紓甯�", e);
+        } finally {
+            try {
+                // 淇濆瓨鎺ュ彛鏃ュ織
+                apiLogService.save(
+                        "璋冪敤agv瑙g粦鏆傚瓨浣�",
+                        ApiInterfaceConstant.AGV_IP + ApiInterfaceConstant.AGV_BIND_PATH,
+                        null,
+                        "127.0.0.1",
+                        body,
+                        response,
+                        success
+                );
+            } catch (Exception e) {
+                log.error("", e);
+            }
+        }
+        return success ? R.ok("瑙g粦鎴愬姛") : R.parse(message);
+    }
+
+    private boolean bindPodAndBerth(String sta) {
+        String staMap = AgvSiteConstant.SiteMap.get(sta);
+        if (staMap == null) {
+            log.error("娌℃湁鎵惧埌璇ョ珯鐐圭殑鍏ュ簱鏄犲皠:{}",sta);
+            return false;
+        }
+        JSONObject jsonObject = new JSONObject();
+        jsonObject.put("reqCode",UUID.randomUUID().toString().replace("-", "")); // 璇锋眰鍞竴鍊�
+        jsonObject.put("ctnrTyp","2"); // 瀹瑰櫒绫诲瀷2
+        jsonObject.put("stgBinCode",staMap); // 浠撲綅缂栧彿锛屾牴鎹浠撶紪鍙疯浆鎹�
+        jsonObject.put("indBind","1"); // 1缁戝畾锛�0瑙g粦
+
+        String body = jsonObject.toJSONString();
+        String response = "";
+        boolean success = false;
+        try {
+            response = new HttpHandler.Builder()
+                    .setUri(ApiInterfaceConstant.AGV_IP)
+                    .setPath(ApiInterfaceConstant.AGV_BIND_PATH)
+                    .setJson(body)
+                    .build()
+                    .doPost();
+            JSONObject res = JSON.parseObject(response);
+            if (res.getInteger("code").equals(0)) {
+                success = true;
+            } else {
+                log.error("璋冪敤agv缁戝畾浠撲綅澶辫触锛侊紒锛乽rl锛歿}锛況equest锛歿}锛況esponse锛歿}", ApiInterfaceConstant.AGV_IP + ApiInterfaceConstant.AGV_BIND_PATH, body, response);
+            }
+        } catch (Exception e) {
+            log.error("璋冪敤agv缁戝畾浠撲綅寮傚父", e);
+        } finally {
+            try {
+                // 淇濆瓨鎺ュ彛鏃ュ織
+                apiLogService.save(
+                        "璋冪敤agv缁戝畾浠撲綅",
+                        ApiInterfaceConstant.AGV_IP + ApiInterfaceConstant.AGV_BIND_PATH,
+                        null,
+                        "127.0.0.1",
+                        body,
+                        response,
+                        success
+                );
+            } catch (Exception e) {
+                log.error("", e);
+            }
+        }
+        return success;
+    }
+
+    @Override
     @Transactional
     public void comb(CombParam param, Long userId) {
         if (Cools.isEmpty(param.getBarcode(), param.getCombMats())) {
@@ -91,8 +254,8 @@
             throw new CoolException(param.getBarcode() + "鏁版嵁姝e湪杩涜鍏ュ簱");
         }
 
-        if(param.getBarcode().length()!=8){
-            throw new CoolException("鏉$爜闀垮害涓嶆槸8浣�===>>" + param.getBarcode());
+        if(param.getBarcode().length()!=9){
+            throw new CoolException("鏉$爜闀垮害涓嶆槸9浣�===>>" + param.getBarcode());
         }
         if (param.getCombMats().size()>1){
             throw new CoolException("涓嶅厑璁告贩鏂�===>>" + param.getBarcode());
@@ -171,7 +334,7 @@
                     throw new CoolException("淇敼鍗曟嵁浣滀笟鏁伴噺澶辫触");
                 }
 
-                DetlDto detlDto = new DetlDto(elem.getMatnr(), elem.getBatch(), elem.getAnfme());
+                DetlDto detlDto = new DetlDto(elem.getMatnr(), elem.getBatch(), elem.getAnfme(),orderDetl.getManu());
                 if (DetlDto.has(detlDtos, detlDto)) {
                     DetlDto one = DetlDto.find(detlDtos, detlDto.getMatnr(), detlDto.getBatch());
                     assert one != null;
@@ -198,6 +361,7 @@
                 waitPakin.setAppeTime(now);
                 waitPakin.setModiUser(userId);
                 waitPakin.setModiTime(now);
+                waitPakin.setManu(detlDto.getMark());
                 if (!waitPakinService.insert(waitPakin)) {
                     throw new CoolException("淇濆瓨鍏ュ簱閫氱煡妗eけ璐�");
                 }

--
Gitblit v1.9.1