From 5f7592e30296aa6c48373befbcbfc8173009a787 Mon Sep 17 00:00:00 2001
From: Junjie <540245094@qq.com>
Date: 星期一, 15 四月 2024 08:44:56 +0800
Subject: [PATCH] #

---
 zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/thread/impl/SurayShuttleThread.java |   51 ++++++++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 48 insertions(+), 3 deletions(-)

diff --git a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/thread/impl/SurayShuttleThread.java b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/thread/impl/SurayShuttleThread.java
index 9dedf44..9311484 100644
--- a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/thread/impl/SurayShuttleThread.java
+++ b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/thread/impl/SurayShuttleThread.java
@@ -3,6 +3,8 @@
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
 import com.zy.asrs.common.utils.HttpHandler;
 import com.zy.asrs.framework.common.DateUtils;
 import com.zy.asrs.framework.common.SpringUtils;
@@ -206,7 +208,7 @@
 
     @Override
     public ShuttleProtocol getStatus() {
-        return this.shuttleProtocol;
+        return this.shuttleProtocol.clone();
     }
 
     @Override
@@ -412,7 +414,23 @@
         boolean res = (this.shuttleProtocol.getDeviceStatus() == 3 || this.shuttleProtocol.getDeviceStatus() == 11)
                 && this.shuttleProtocol.getPakMk()
                 && this.shuttleProtocol.getErrorCode().equals("0")
-                && this.shuttleProtocol.getProtocolStatus() == ShuttleProtocolStatusType.IDLE.id
+                && (this.shuttleProtocol.getProtocolStatus() == ShuttleProtocolStatusType.IDLE.id || this.shuttleProtocol.getProtocolStatus() == ShuttleProtocolStatusType.WAITING.id)
+                ;
+        return res;
+    }
+
+    @Override
+    public boolean isDeviceIdle() {
+        if (this.shuttleProtocol.getDeviceStatus() == null
+                || this.shuttleProtocol.getPakMk() == null
+                || this.shuttleProtocol.getErrorCode() == null
+        ) {
+            return false;
+        }
+
+        boolean res = (this.shuttleProtocol.getDeviceStatus() == 3 || this.shuttleProtocol.getDeviceStatus() == 11)
+                && this.shuttleProtocol.getPakMk()
+                && this.shuttleProtocol.getErrorCode().equals("0")
                 ;
         return res;
     }
@@ -484,13 +502,22 @@
 
     @Override
     public List<NavigateNode> getMoveAdvancePath() {
+        ObjectMapper objectMapper = SpringUtils.getBean(ObjectMapper.class);
         ArrayList<NavigateNode> path = new ArrayList<>();
         if (shuttleProtocol.getTaskNo() != 0) {
             //瀛樺湪浠诲姟锛岃幏鍙栨寚浠�
             Object object = redisUtil.get(DeviceRedisConstant.SHUTTLE_WORK_FLAG + shuttleProtocol.getTaskNo());
             if (object != null) {
-                ShuttleRedisCommand redisCommand = JSON.parseObject(object.toString(), ShuttleRedisCommand.class);
+                ShuttleRedisCommand redisCommand = null;
+                try {
+                    redisCommand = objectMapper.readValue(String.valueOf(object), ShuttleRedisCommand.class);
+                } catch (JsonProcessingException e) {
+                    return path;
+                }
                 List<NavigateNode> nodes = redisCommand.getAssignCommand().getNodes();//绌挎杞﹂璁¤矾寰�
+                if (nodes == null) {
+                    return path;
+                }
                 if (!nodes.isEmpty()) {
                     path.addAll(nodes);
                 }
@@ -509,6 +536,24 @@
     }
 
     @Override
+    public synchronized boolean setProtocolStatus(ShuttleProtocolStatusType status) {
+        this.shuttleProtocol.setProtocolStatus(status);
+        return true;
+    }
+
+    @Override
+    public synchronized boolean setSyncTaskNo(Integer taskNo) {
+        this.shuttleProtocol.setSyncTaskNo(taskNo);
+        return true;
+    }
+
+    @Override
+    public synchronized boolean setPakMk(boolean pakMk) {
+        this.shuttleProtocol.setPakMk(pakMk);
+        return true;
+    }
+
+    @Override
     public ShuttleCommand getMoveCommand(Integer taskNo, String startCodeNum, String distCodeNum, Integer allDistance, Integer runDirection, Integer runSpeed) {
         HashMap<String, Object> body = new HashMap<>();
         body.put("messageName", "runOrder");

--
Gitblit v1.9.1