From d8b1f82c07cf723b2590cae5a432ff78a514b05e Mon Sep 17 00:00:00 2001
From: gtsxc <3272660260@qq.com>
Date: 星期一, 25 十一月 2024 10:30:30 +0800
Subject: [PATCH] #

---
 zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/service/impl/MainServiceImpl.java |   72 +++++++++++++++++++++--------------
 1 files changed, 43 insertions(+), 29 deletions(-)

diff --git a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/service/impl/MainServiceImpl.java b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/service/impl/MainServiceImpl.java
index 8a31403..1ac7110 100644
--- a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/service/impl/MainServiceImpl.java
+++ b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/service/impl/MainServiceImpl.java
@@ -255,7 +255,32 @@
 
                                 R result = openUtils.createInTask(createInTaskParam);
                                 News.info("鍒涘缓鍏ュ簱浠诲姟锛屼换鍔℃暟鎹�={}锛學MS鍝嶅簲={}锛岃姹傚搷搴�={}", JSON.toJSON(param), JSON.toJSON(jsonObject), JSON.toJSON(result));
+                                try{
+                                    String msg = "";
+                                    HashMap<String, String> hashMap = new HashMap<>();
+                                    hashMap.put("msg", msg);
+                                    hashMap.put("sta", "31001");
+                                    new HttpHandler.Builder()
+                                            .setUri(wmsUrl)
+                                            .setPath("/rpc/led/getError")
+                                            .setJson(JSON.toJSONString(hashMap))
+                                            .build()
+                                            .doPost();
+                                }catch (Exception e){
+
+                                }
+
                             }else {
+                                String msg = jsonObject.getString("msg");
+                                HashMap<String, String> hashMap = new HashMap<>();
+                                hashMap.put("msg", msg);
+                                hashMap.put("sta", "31001");
+                                new HttpHandler.Builder()
+                                        .setUri(wmsUrl)
+                                        .setPath("/rpc/led/getError")
+                                        .setJson(JSON.toJSONString(hashMap))
+                                        .build()
+                                        .doPost();
                                 News.error("鍏ュ簱鐢宠澶辫触锛屼换鍔℃暟鎹�={}锛岃姹傚搷搴�={}", JSON.toJSON(param), JSON.toJSON(jsonObject));
                             }
                         } catch (Exception e) {
@@ -905,7 +930,8 @@
                     .eq(BasLed::getDeviceId, ledDevice.getId()));
             List<Integer> staArr = JSON.parseArray(led.getSta(), Integer.class);
 
-            BasConveyor basConveyor = basConveyorService.getById(led.getConveyorId().intValue());
+            BasConveyor basConveyor = basConveyorService.getOne(new LambdaQueryWrapper<BasConveyor>()
+                    .eq(BasConveyor::getDeviceId, led.getConveyorId().intValue()));
             if (basConveyor == null) {
                 continue;
             }
@@ -919,27 +945,24 @@
             for (Integer staNo : staArr) {
                 // 鑾峰彇鍙夎溅绔欑偣
                 StaProtocol staProtocol = devpThread.getStation().get(staNo);
-                if (null == staProtocol || null == staProtocol.getWorkNo() || 0 == staProtocol.getWorkNo() || !staProtocol.isLoading()) {
+                if (null == staProtocol || null == staProtocol.getWorkNo()) {
                     continue;
                 } else {
                     staProtocol = staProtocol.clone();
                 }
-                // 鑾峰彇宸ヤ綔妗f暟鎹�
-                Task task = taskService.getOne(new LambdaQueryWrapper<Task>().eq(Task::getTaskNo, staProtocol.getWorkNo()));
-                if (null == task) {
+                if (!staProtocol.isOutEnable()){
                     continue;
                 }
-
-                tasks.add(task);
-                // 缁勮鍛戒护
-                LedCommand ledCommand = new LedCommand();
-                ledCommand.setWorkNo(task.getTaskNo());
-                ledCommand.setIoType(task.getTaskCtg().intValue());
-                ledCommand.setTitle(task.getTaskCtg$());
-                ledCommand.setSourceLocNo(task.getOriginLoc());
-                ledCommand.setLocNo(task.getDestLoc());
-                ledCommand.setStaNo(Integer.parseInt(task.getDestSite()));
-
+                String taskNo = "0";
+                if (0 != staProtocol.getWorkNo()){
+                    Motion motion = motionService.getOne(new LambdaQueryWrapper<Motion>().eq(Motion::getMotionCtg, 9).eq(Motion::getTemp, staProtocol.getWorkNo()));
+                    // 鑾峰彇宸ヤ綔妗f暟鎹�
+                    Task task = taskService.getOne(new LambdaQueryWrapper<Task>().eq(Task::getTaskNo, motion.getTaskNo()));
+                    if (null == task) {
+                        continue;
+                    }
+                    taskNo = task.getWmsTaskNo();
+                }
                 try {
                     //鑾峰彇WMS鍦板潃
                     Dict dict = dictService.getOne(new LambdaQueryWrapper<Dict>().eq(Dict::getFlag, "WMS_URL").eq(Dict::getStatus, 1));
@@ -947,32 +970,23 @@
                         String wmsUrl = dict.getValue();
 
                         HashMap<String, Object> param = new HashMap<>();
-                        param.put("taskNo", task.getTaskNo());
+                        param.put("taskNo", taskNo);
+                        param.put("sta",staNo);
                         String response = new HttpHandler.Builder()
                                 .setUri(wmsUrl)
-                                .setPath("/queryTask")
+                                .setPath("/rpc/led/getTask")
                                 .setJson(JSON.toJSONString(param))
                                 .build()
                                 .doPost();
                         JSONObject jsonObject = JSON.parseObject(response);
                         Integer code = jsonObject.getInteger("code");
                         if (code.equals(200)) {
-                            List<MatDto> matDtos = JSON.parseArray(jsonObject.getString("data"), MatDto.class);
-                            ledCommand.setMatDtos(matDtos);
+
                         }
                     }
                 } catch (Exception e) {
                     e.printStackTrace();
                 }
-
-                commands.add(ledCommand);
-            }
-            // 鑾峰彇LED绾跨▼
-            LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, ledDevice.getId().intValue());
-            // 鍛戒护涓嬪彂 -------------------------------------------------------------------------------
-            if (!commands.isEmpty()) {
-                ledThread.write(commands);
-                ledThread.setLedMk(false);
             }
         }
     }

--
Gitblit v1.9.1