From 0f69561e397093b5165c4aac58530721d5c62178 Mon Sep 17 00:00:00 2001
From: zjj <3272660260@qq.com>
Date: 星期一, 25 十一月 2024 11:03:16 +0800
Subject: [PATCH] #led

---
 zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/service/impl/MainServiceImpl.java |   65 ++++++++++++++++++--------------
 1 files changed, 36 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 730a94f..6a5ef93 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,11 +255,26 @@
 
                                 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", "31002");
+                                hashMap.put("sta", "31001");
                                 new HttpHandler.Builder()
                                         .setUri(wmsUrl)
                                         .setPath("/rpc/led/getError")
@@ -915,7 +930,7 @@
                     .eq(BasLed::getDeviceId, ledDevice.getId()));
             List<Integer> staArr = JSON.parseArray(led.getSta(), Integer.class);
 
-            BasConveyor basConveyor = basConveyorService.getById(new LambdaQueryWrapper<BasConveyor>()
+            BasConveyor basConveyor = basConveyorService.getOne(new LambdaQueryWrapper<BasConveyor>()
                     .eq(BasConveyor::getDeviceId, led.getConveyorId().intValue()));
             if (basConveyor == null) {
                 continue;
@@ -930,26 +945,26 @@
             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) {
-                    continue;
-                }
+                String taskNo = "0";
+                if (staProtocol.isOutEnable() && staProtocol.getSiteId() == 31001 ){
+                    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();
+                    }
 
-                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()));
+                } else if (staProtocol.isInEnable() && staProtocol.getSiteId() == 31002) {
+                    taskNo = staProtocol.getStaNo().toString();
+                }
 
                 try {
                     //鑾峰彇WMS鍦板潃
@@ -958,32 +973,24 @@
                         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