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/rcs/thread/impl/SurayLiftThread.java |  109 +++++++++++++++++++++++++++++++++++++++---------------
 1 files changed, 78 insertions(+), 31 deletions(-)

diff --git a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/thread/impl/SurayLiftThread.java b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/thread/impl/SurayLiftThread.java
index 9a7d6ab..a08d18d 100644
--- a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/thread/impl/SurayLiftThread.java
+++ b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/thread/impl/SurayLiftThread.java
@@ -17,6 +17,7 @@
 import com.zy.asrs.wcs.rcs.News;
 import com.zy.asrs.wcs.rcs.cache.OutputQueue;
 import com.zy.asrs.wcs.rcs.entity.DeviceDataLog;
+import com.zy.asrs.wcs.rcs.model.CommandResponse;
 import com.zy.asrs.wcs.rcs.model.enums.LiftProtocolStatusType;
 import com.zy.asrs.wcs.rcs.model.protocol.LiftProtocol;
 import com.zy.asrs.wcs.rcs.service.DeviceDataLogService;
@@ -92,8 +93,13 @@
                 //----------璇诲彇鎻愬崌鏈虹姸鎬�-----------
                 //妯″紡
                 liftProtocol.setModel(true);
+
+                boolean runningState = data.getInteger("runningState") == 1;
+                if (!data.getInteger("completeTaskNo").equals(data.getInteger("taskNo"))) {
+                    runningState = true;//宸ヤ綔鍙蜂笉涓�鑷达紝璁や负澶勪簬杩愯涓�
+                }
                 //杩愯鐘舵��
-                liftProtocol.setRun(data.getInteger("runningState") == 1);
+                liftProtocol.setRun(runningState);
                 //灏辩华鐘舵��
                 liftProtocol.setReady(data.getInteger("readyState") == 1);
                 //鏈夋墭鐩�
@@ -104,6 +110,8 @@
                 liftProtocol.setErrorCode("0");
                 //灞�
                 liftProtocol.setLev(data.getInteger("curFloor"));
+                //宸插畬鎴愮殑浠诲姟鍙�
+                liftProtocol.setCompleteTaskNo(data.getString("completeTaskNo"));
 
 
                 //************琛ュ厖鎵╁睍瀛楁*************
@@ -210,148 +218,163 @@
     }
 
     @Override
-    public synchronized boolean move(LiftCommand command) {
+    public synchronized CommandResponse move(LiftCommand command) {
+        CommandResponse response = new CommandResponse(false);
         try {
             String loginToken = requestLoginToken();
             if (loginToken == null) {
-                return false;
+                return response;
             }
 
             HashMap<String, Object> headers = new HashMap<>();
             headers.put("Authorization", "Bearer " + loginToken);
 
-            String response = new HttpHandler.Builder()
+            String responseStr = new HttpHandler.Builder()
                     .setUri(API_URL)
                     .setPath("/RDS/lifterTask")
                     .setHeaders(headers)
                     .setJson(command.getBody())
                     .build()
                     .doPost();
-            JSONObject jsonObject = JSON.parseObject(response);
+            JSONObject jsonObject = JSON.parseObject(responseStr);
             Integer code = jsonObject.getInteger("code");
+            response.setMessage(JSON.toJSONString(jsonObject));
             if (code.equals(200)) {
-                return true;
+                response.setResult(true);
+                return response;
             }
         } catch (Exception e) {
             e.printStackTrace();
         }
-        return false;
+        return response;
     }
 
     @Override
-    public synchronized boolean palletInOut(LiftCommand command) {
+    public synchronized CommandResponse palletInOut(LiftCommand command) {
+        CommandResponse response = new CommandResponse(false);
         try {
             String loginToken = requestLoginToken();
             if (loginToken == null) {
-                return false;
+                return response;
             }
 
             HashMap<String, Object> headers = new HashMap<>();
             headers.put("Authorization", "Bearer " + loginToken);
 
-            String response = new HttpHandler.Builder()
+            String responseStr = new HttpHandler.Builder()
                     .setUri(API_URL)
                     .setPath("/RDS/lifterTask")
                     .setHeaders(headers)
                     .setJson(command.getBody())
                     .build()
                     .doPost();
-            JSONObject jsonObject = JSON.parseObject(response);
+            JSONObject jsonObject = JSON.parseObject(responseStr);
             Integer code = jsonObject.getInteger("code");
+            response.setMessage(JSON.toJSONString(jsonObject));
             if (code.equals(200)) {
-                return true;
+                response.setResult(true);
+                return response;
             }
         } catch (Exception e) {
             e.printStackTrace();
         }
-        return false;
+        return response;
     }
 
     @Override
-    public synchronized boolean lock(LiftCommand command) {
+    public synchronized CommandResponse lock(LiftCommand command) {
+        CommandResponse response = new CommandResponse(false);
         try {
             String loginToken = requestLoginToken();
             if (loginToken == null) {
-                return false;
+                return response;
             }
 
             HashMap<String, Object> headers = new HashMap<>();
             headers.put("Authorization", "Bearer " + loginToken);
 
-            String response = new HttpHandler.Builder()
+            String responseStr = new HttpHandler.Builder()
                     .setUri(API_URL)
                     .setPath("/RDS/lifterOperation")
                     .setHeaders(headers)
                     .setJson(command.getBody())
                     .build()
                     .doPost();
-            JSONObject jsonObject = JSON.parseObject(response);
+            JSONObject jsonObject = JSON.parseObject(responseStr);
             Integer code = jsonObject.getInteger("code");
+            response.setMessage(JSON.toJSONString(jsonObject));
             if (code.equals(200)) {
-                return true;
+                response.setResult(true);
+                return response;
             }
         } catch (Exception e) {
             e.printStackTrace();
         }
-        return false;
+        return response;
     }
 
     @Override
-    public synchronized boolean unlock(LiftCommand command) {
+    public synchronized CommandResponse unlock(LiftCommand command) {
+        CommandResponse response = new CommandResponse(false);
         try {
             String loginToken = requestLoginToken();
             if (loginToken == null) {
-                return false;
+                return response;
             }
 
             HashMap<String, Object> headers = new HashMap<>();
             headers.put("Authorization", "Bearer " + loginToken);
 
-            String response = new HttpHandler.Builder()
+            String responseStr = new HttpHandler.Builder()
                     .setUri(API_URL)
                     .setPath("/RDS/lifterOperation")
                     .setHeaders(headers)
                     .setJson(command.getBody())
                     .build()
                     .doPost();
-            JSONObject jsonObject = JSON.parseObject(response);
+            JSONObject jsonObject = JSON.parseObject(responseStr);
             Integer code = jsonObject.getInteger("code");
+            response.setMessage(JSON.toJSONString(jsonObject));
             if (code.equals(200)) {
-                return true;
+                response.setResult(true);
+                return response;
             }
         } catch (Exception e) {
             e.printStackTrace();
         }
-        return false;
+        return response;
     }
 
     @Override
-    public synchronized boolean reset(LiftCommand command) {
+    public synchronized CommandResponse reset(LiftCommand command) {
+        CommandResponse response = new CommandResponse(false);
         try {
             String loginToken = requestLoginToken();
             if (loginToken == null) {
-                return false;
+                return response;
             }
 
             HashMap<String, Object> headers = new HashMap<>();
             headers.put("Authorization", "Bearer " + loginToken);
 
-            String response = new HttpHandler.Builder()
+            String responseStr = new HttpHandler.Builder()
                     .setUri(API_URL)
                     .setPath("/RDS/lifterOperation")
                     .setHeaders(headers)
                     .setJson(command.getBody())
                     .build()
                     .doPost();
-            JSONObject jsonObject = JSON.parseObject(response);
+            JSONObject jsonObject = JSON.parseObject(responseStr);
             Integer code = jsonObject.getInteger("code");
+            response.setMessage(JSON.toJSONString(jsonObject));
             if (code.equals(200)) {
-                return true;
+                response.setResult(true);
+                return response;
             }
         } catch (Exception e) {
             e.printStackTrace();
         }
-        return false;
+        return response;
     }
 
     @Override
@@ -381,7 +404,11 @@
         switch (Objects.requireNonNull(MotionCtgType.get(String.valueOf(flag)))){
             case SHUTTLE_MOVE_FROM_LIFT://绌挎杞﹀嚭鎻愬崌鏈�
             case SHUTTLE_MOVE_TO_LIFT://绌挎杞﹁繘鎻愬崌鏈�
+            case LIFT_SHUTTLE_ARRIVAL://鎻愬崌鏈鸿В閿�
                 return isIdleShuttleMoveToLift();
+            case LIFT_LOCK://鎻愬崌鏈洪攣瀹�
+            case LIFT_UNLOCK://鎻愬崌鏈鸿В閿�
+                return isIdleLiftLock();
         }
 
         return false;
@@ -404,6 +431,21 @@
                     return false;
                 }
             }
+            return true;
+        }
+        return false;
+    }
+
+    //鎻愬崌鏈洪攣瀹�-鎻愬崌鏈虹姸鎬佸垽鏂�
+    private boolean isIdleLiftLock() {
+        // 鍒ゆ柇鎻愬崌鏈烘槸鍚﹁嚜鍔ㄣ�佸氨缁�佺┖闂�
+        if (this.liftProtocol.getModel()
+                && !this.liftProtocol.getRun()
+                && this.liftProtocol.getPakMk()
+                && this.liftProtocol.getErrorCode().equals("0")
+                && (this.liftProtocol.getProtocolStatusType().equals(LiftProtocolStatusType.IDLE)
+                || this.liftProtocol.getProtocolStatusType().equals(LiftProtocolStatusType.WAITING))
+        ) {
             return true;
         }
         return false;
@@ -457,6 +499,11 @@
         return extend.getLock();
     }
 
+    @Override
+    public int generateDeviceTaskNo(int taskNo, MotionCtgType motionCtgType) {
+        return taskNo;
+    }
+
     //***************璁惧灞傞�氳-涓嶅悓鍘傚晢璁惧閫氳鏂规涓嶄竴鑷�***************
 
     //璇锋眰鐧诲綍

--
Gitblit v1.9.1