From cab87dcfaa7b1e2bc1298572b775026bb17ef38b Mon Sep 17 00:00:00 2001
From: Junjie <xjj@123>
Date: 星期四, 17 十月 2024 13:54:41 +0800
Subject: [PATCH] #

---
 zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/thread/impl/NyShuttleThread.java      |   74 +++++++---
 zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/model/enums/ShuttleTaskModeType.java |    4 
 zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/thread/impl/SurayShuttleThread.java   |   84 +++++++----
 zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/model/CommandResponse.java            |   23 +++
 zy-asrs-flow/src/pages/log/basShuttleOpt/index.jsx                                  |  143 ++++++++++----------
 zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/entity/BasShuttleOpt.java             |    8 
 zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/action/ShuttleAction.java            |   57 +++++--
 zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/thread/ShuttleThread.java             |   13 +
 8 files changed, 252 insertions(+), 154 deletions(-)

diff --git a/zy-asrs-flow/src/pages/log/basShuttleOpt/index.jsx b/zy-asrs-flow/src/pages/log/basShuttleOpt/index.jsx
index ef6663c..20af26e 100644
--- a/zy-asrs-flow/src/pages/log/basShuttleOpt/index.jsx
+++ b/zy-asrs-flow/src/pages/log/basShuttleOpt/index.jsx
@@ -1,6 +1,6 @@
 
 import React, { useState, useRef, useEffect } from 'react';
-import { Button, message, Modal, Tag  } from 'antd';
+import { Button, message, Modal, Tag } from 'antd';
 import {
     FooterToolbar,
     PageContainer,
@@ -168,6 +168,78 @@
             />,
         },
         {
+            title: '鍛戒护',
+            dataIndex: 'command',
+            valueType: 'text',
+            hidden: false,
+            width: 140,
+            ellipsis: true,
+            filterDropdown: (props) => <TextFilter
+                name='command'
+                {...props}
+                actionRef={actionRef}
+                setSearchParam={setSearchParam}
+            />,
+        },
+        {
+            title: '绯荤粺鐘舵��',
+            dataIndex: 'systemStatus',
+            valueType: 'text',
+            hidden: false,
+            width: 140,
+            ellipsis: true,
+            filterDropdown: (props) => <TextFilter
+                name='systemStatus'
+                {...props}
+                actionRef={actionRef}
+                setSearchParam={setSearchParam}
+            />,
+        },
+        {
+            title: '涓嬪彂鐘舵��',
+            dataIndex: 'send$',
+            valueType: 'text',
+            hidden: false,
+            width: 140,
+            filterDropdown: (props) => <SelectFilter
+                name='send'
+                {...props}
+                actionRef={actionRef}
+                setSearchParam={setSearchParam}
+                data={[
+                    { label: '鏈笅鍙�', value: 0 },
+                    { label: '宸蹭笅鍙�', value: 1 },
+                ]}
+            />,
+        },
+        {
+            title: '璇锋眰鍝嶅簲',
+            dataIndex: 'response',
+            valueType: 'text',
+            hidden: false,
+            width: 140,
+            ellipsis: true,
+            filterDropdown: (props) => <TextFilter
+                name='response'
+                {...props}
+                actionRef={actionRef}
+                setSearchParam={setSearchParam}
+            />,
+        },
+        {
+            title: '璁惧宸ヤ綔鍙�',
+            dataIndex: 'deviceWrk',
+            valueType: 'text',
+            hidden: false,
+            width: 140,
+            filterDropdown: (props) => <TextFilter
+                name='deviceWrk'
+                {...props}
+                actionRef={actionRef}
+                setSearchParam={setSearchParam}
+            />,
+        },
+        {
             title: '璧风偣搴撲綅',
             dataIndex: 'sourceLocNo',
             valueType: 'text',
@@ -228,75 +300,6 @@
             width: 140,
             filterDropdown: (props) => <TextFilter
                 name='memo'
-                {...props}
-                actionRef={actionRef}
-                setSearchParam={setSearchParam}
-            />,
-        },
-        {
-            title: '鍛戒护',
-            dataIndex: 'command',
-            valueType: 'text',
-            hidden: false,
-            width: 140,
-            filterDropdown: (props) => <TextFilter
-                name='command'
-                {...props}
-                actionRef={actionRef}
-                setSearchParam={setSearchParam}
-            />,
-        },
-        {
-            title: '绯荤粺鐘舵��',
-            dataIndex: 'systemStatus',
-            valueType: 'text',
-            hidden: false,
-            width: 140,
-            filterDropdown: (props) => <TextFilter
-                name='systemStatus'
-                {...props}
-                actionRef={actionRef}
-                setSearchParam={setSearchParam}
-            />,
-        },
-        {
-            title: '涓嬪彂鐘舵��',
-            dataIndex: 'send$',
-            valueType: 'text',
-            hidden: false,
-            width: 140,
-            filterDropdown: (props) => <SelectFilter
-                name='send'
-                {...props}
-                actionRef={actionRef}
-                setSearchParam={setSearchParam}
-                data={[
-                    { label: '鏈笅鍙�', value: 0 },
-                    { label: '宸蹭笅鍙�', value: 1 },
-                ]}
-            />,
-        },
-        {
-            title: '璇锋眰鍝嶅簲',
-            dataIndex: 'response',
-            valueType: 'text',
-            hidden: false,
-            width: 140,
-            filterDropdown: (props) => <TextFilter
-                name='response'
-                {...props}
-                actionRef={actionRef}
-                setSearchParam={setSearchParam}
-            />,
-        },
-        {
-            title: '璁惧宸ヤ綔鍙�',
-            dataIndex: 'deviceWrk',
-            valueType: 'text',
-            hidden: false,
-            width: 140,
-            filterDropdown: (props) => <TextFilter
-                name='deviceWrk'
                 {...props}
                 actionRef={actionRef}
                 setSearchParam={setSearchParam}
diff --git a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/action/ShuttleAction.java b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/action/ShuttleAction.java
index 61cd617..6bcfefc 100644
--- a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/action/ShuttleAction.java
+++ b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/action/ShuttleAction.java
@@ -23,20 +23,20 @@
 import com.zy.asrs.wcs.rcs.News;
 import com.zy.asrs.wcs.rcs.cache.SlaveConnection;
 import com.zy.asrs.wcs.rcs.constant.DeviceRedisConstant;
+import com.zy.asrs.wcs.rcs.entity.BasShuttleOpt;
 import com.zy.asrs.wcs.rcs.entity.Device;
+import com.zy.asrs.wcs.rcs.model.CommandResponse;
 import com.zy.asrs.wcs.rcs.model.enums.ShuttleProtocolStatusType;
 import com.zy.asrs.wcs.rcs.model.enums.SlaveType;
 import com.zy.asrs.wcs.rcs.model.protocol.ShuttleProtocol;
+import com.zy.asrs.wcs.rcs.service.BasShuttleOptService;
 import com.zy.asrs.wcs.rcs.thread.ShuttleThread;
 import com.zy.asrs.wcs.system.entity.Dict;
 import com.zy.asrs.wcs.system.service.DictService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Objects;
-import java.util.Optional;
+import java.util.*;
 
 @Component
 public class ShuttleAction {
@@ -57,6 +57,8 @@
     private DictService dictService;
     @Autowired
     private ConveyorDispatcher conveyorDispatcher;
+    @Autowired
+    private BasShuttleOptService basShuttleOptService;
 
     public synchronized boolean assignWork(Device device, ShuttleAssignCommand assignCommand) {
         ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, device.getId().intValue());
@@ -82,7 +84,8 @@
                     || assignCommand.getTaskMode() == ShuttleTaskModeType.MOVE_LOC_NO.id
                     || assignCommand.getTaskMode() == ShuttleTaskModeType.SHUTTLE_MOVE_LOC_NO.id) {
                 //涓嬪彂琛岄┒璺緞
-                boolean result = shuttleThread.movePath(assignCommand.getNodes(), assignCommand.getDeviceTaskNo());
+                CommandResponse response = shuttleThread.movePath(assignCommand.getNodes(), assignCommand.getDeviceTaskNo());
+                Boolean result = response.getResult();
                 if (!result) {
                     return false;
                 }
@@ -260,7 +263,28 @@
         ShuttleCommand command = commands.get(commandStep);
 
         // 涓嬪彂鍛戒护
-        if (!write(command, device)) {
+        CommandResponse response = write(command, device);
+
+        //淇濆瓨鍛戒护鏃ュ織
+        BasShuttleOpt basShuttleOpt = new BasShuttleOpt();
+        basShuttleOpt.setTaskNo(redisCommand.getTaskNo());
+        basShuttleOpt.setShuttleNo(Integer.parseInt(device.getDeviceNo()));
+
+        basShuttleOpt.setMode(ShuttleCommandModeType.get(command.getMode()).desc);
+        basShuttleOpt.setSourceLocNo(assignCommand.getSourceLocNo());
+        basShuttleOpt.setDistLocNo(assignCommand.getLocNo());
+        basShuttleOpt.setCommand(JSON.toJSONString(command));
+        basShuttleOpt.setSystemStatus(JSON.toJSONString(shuttleProtocol));
+        basShuttleOpt.setDeviceId(device.getId());
+        basShuttleOpt.setDeviceWrk(String.valueOf(command.getTaskNo()));
+        basShuttleOpt.setResponse(response.getMessage());//鑾峰彇鍝嶅簲
+        basShuttleOpt.setSendTime(new Date());//鎸囦护涓嬪彂鏃堕棿
+        basShuttleOpt.setSend(response.getResult() ? 1 : 0);
+        basShuttleOpt.setHostId(device.getHostId());
+        //淇濆瓨鍛戒护娴佹按
+        basShuttleOptService.save(basShuttleOpt);
+
+        if (!response.getResult()) {
             News.error("鍥涘悜绌挎杞﹀懡浠や笅鍙戝け璐ワ紝绌挎杞﹀彿={}锛屼换鍔℃暟鎹�={}", shuttleProtocol.getShuttleNo(), JSON.toJSON(command));
             return false;
         }
@@ -643,31 +667,32 @@
         }
     }
 
-    private synchronized boolean write(ShuttleCommand command, Device device) {
+    private synchronized CommandResponse write(ShuttleCommand command, Device device) {
+        CommandResponse response = new CommandResponse(false);
         if (null == command) {
             News.error("鍥涘悜绌挎杞﹀啓鍏ュ懡浠や负绌�");
-            return false;
+            response.setMessage("鍥涘悜绌挎杞﹀啓鍏ュ懡浠や负绌�");
+            return response;
         }
         ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, device.getId().intValue());
-        boolean result = false;
         if (command.getMode() == ShuttleCommandModeType.MOVE.id
                 || command.getMode() == ShuttleCommandModeType.IN_LIFT.id
                 || command.getMode() == ShuttleCommandModeType.OUT_LIFT.id) {//绉诲姩
-            result = shuttleThread.move(command);
+            response = shuttleThread.move(command);
         } else if (command.getMode() == ShuttleCommandModeType.PALLET_LIFT.id
                 || command.getMode() == ShuttleCommandModeType.PALLET_DOWN.id) {//椤跺崌
-            result = shuttleThread.lift(command);
+            response = shuttleThread.lift(command);
         } else if (command.getMode() == ShuttleCommandModeType.CHARGE_OPEN.id
                 || command.getMode() == ShuttleCommandModeType.CHARGE_CLOSE.id) {//鍏呯數
-            result = shuttleThread.charge(command);
+            response = shuttleThread.charge(command);
         } else if (command.getMode() == ShuttleCommandModeType.RESET.id) {//澶嶄綅
-            result = shuttleThread.reset(command);
+            response = shuttleThread.reset(command);
         } else if (command.getMode() == ShuttleCommandModeType.UPDATE_LOCATION.id) {//鏇存柊鍧愭爣
-            result = shuttleThread.updateLocation(command);
+            response = shuttleThread.updateLocation(command);
         }
 
-        News.info("鍥涘悜绌挎杞﹀懡浠や笅鍙戯紝绌挎杞﹀彿={}锛屼换鍔℃暟鎹�={}", device.getDeviceNo(), JSON.toJSON(command));
-        return result;
+//        News.info("鍥涘悜绌挎杞﹀懡浠や笅鍙戯紝绌挎杞﹀彿={}锛屼换鍔℃暟鎹�={}", device.getDeviceNo(), JSON.toJSON(command));
+        return response;
     }
 
 }
diff --git a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/model/enums/ShuttleTaskModeType.java b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/model/enums/ShuttleTaskModeType.java
index 6068f76..0aa9c0f 100644
--- a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/model/enums/ShuttleTaskModeType.java
+++ b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/model/enums/ShuttleTaskModeType.java
@@ -37,12 +37,12 @@
         this.desc = desc;
     }
 
-    public static ShuttleTaskModeType get(Short id) {
+    public static ShuttleTaskModeType get(Integer id) {
         if (null == id) {
             return null;
         }
         for (ShuttleTaskModeType type : ShuttleTaskModeType.values()) {
-            if (type.id.equals(id.intValue())) {
+            if (type.id.equals(id)) {
                 return type;
             }
         }
diff --git a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/entity/BasShuttleOpt.java b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/entity/BasShuttleOpt.java
index 38ee84d..48be646 100644
--- a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/entity/BasShuttleOpt.java
+++ b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/entity/BasShuttleOpt.java
@@ -108,9 +108,9 @@
     private String systemStatus;
 
     /**
-     * 涓嬪彂鐘舵�� 0: 鏈笅鍙�  1: 宸蹭笅鍙�  
+     * 涓嬪彂鐘舵�� 0: 澶辫触  1: 鎴愬姛
      */
-    @ApiModelProperty(value= "涓嬪彂鐘舵�� 0: 鏈笅鍙�  1: 宸蹭笅鍙�  ")
+    @ApiModelProperty(value= "涓嬪彂鐘舵�� 0: 澶辫触  1: 鎴愬姛  ")
     private Integer send;
 
     /**
@@ -213,9 +213,9 @@
         if (null == this.send){ return null; }
         switch (this.send){
             case 0:
-                return "鏈笅鍙�";
+                return "澶辫触";
             case 1:
-                return "宸蹭笅鍙�";
+                return "鎴愬姛";
             default:
                 return String.valueOf(this.send);
         }
diff --git a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/model/CommandResponse.java b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/model/CommandResponse.java
new file mode 100644
index 0000000..dbd25b6
--- /dev/null
+++ b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/model/CommandResponse.java
@@ -0,0 +1,23 @@
+package com.zy.asrs.wcs.rcs.model;
+
+import lombok.Data;
+
+@Data
+public class CommandResponse {
+
+    private Boolean result;
+
+    private String message;
+
+    public CommandResponse() {
+    }
+
+    public CommandResponse(Boolean result) {
+        this.result = result;
+    }
+
+    public CommandResponse(Boolean result, String message) {
+        this.result = result;
+        this.message = message;
+    }
+}
diff --git a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/thread/ShuttleThread.java b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/thread/ShuttleThread.java
index d99c109..7c9f4f2 100644
--- a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/thread/ShuttleThread.java
+++ b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/thread/ShuttleThread.java
@@ -6,6 +6,7 @@
 import com.zy.asrs.wcs.core.model.command.ShuttleCommand;
 import com.zy.asrs.wcs.core.model.enums.MotionCtgType;
 import com.zy.asrs.wcs.rcs.entity.Device;
+import com.zy.asrs.wcs.rcs.model.CommandResponse;
 import com.zy.asrs.wcs.rcs.model.enums.ShuttleProtocolStatusType;
 import com.zy.asrs.wcs.rcs.model.protocol.ShuttleProtocol;
 
@@ -19,17 +20,17 @@
 
     Device getDevice();//鑾峰彇璁惧淇℃伅
 
-    boolean movePath(List<NavigateNode> nodes, Integer taskNo);//璺緞涓嬪彂
+    CommandResponse movePath(List<NavigateNode> nodes, Integer taskNo);//璺緞涓嬪彂
 
-    boolean move(ShuttleCommand command);//绉诲姩
+    CommandResponse move(ShuttleCommand command);//绉诲姩
 
-    boolean lift(ShuttleCommand command);//椤跺崌
+    CommandResponse lift(ShuttleCommand command);//椤跺崌
 
-    boolean charge(ShuttleCommand command);//鍏呯數寮�鍏�
+    CommandResponse charge(ShuttleCommand command);//鍏呯數寮�鍏�
 
-    boolean reset(ShuttleCommand command);//澶嶄綅寮�鍏�
+    CommandResponse reset(ShuttleCommand command);//澶嶄綅寮�鍏�
 
-    boolean updateLocation(ShuttleCommand command);//鏇存柊鍧愭爣
+    CommandResponse updateLocation(ShuttleCommand command);//鏇存柊鍧愭爣
 
     boolean isIdle();
 
diff --git a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/thread/impl/NyShuttleThread.java b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/thread/impl/NyShuttleThread.java
index 705c89c..ee3af41 100644
--- a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/thread/impl/NyShuttleThread.java
+++ b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/thread/impl/NyShuttleThread.java
@@ -31,6 +31,7 @@
 import com.zy.asrs.wcs.rcs.constant.DeviceRedisConstant;
 import com.zy.asrs.wcs.rcs.entity.Device;
 import com.zy.asrs.wcs.rcs.entity.DeviceDataLog;
+import com.zy.asrs.wcs.rcs.model.CommandResponse;
 import com.zy.asrs.wcs.rcs.model.command.NyShuttleHttpCommand;
 import com.zy.asrs.wcs.rcs.model.enums.ShuttleProtocolStatusType;
 import com.zy.asrs.wcs.rcs.model.enums.SlaveType;
@@ -123,6 +124,8 @@
 
                     //灏忚溅绌洪棽涓旀湁璺戝簱绋嬪簭
                     shuttleAction.moveLoc(device);
+
+                    Thread.sleep(200);
                 } catch (Exception e) {
                     e.printStackTrace();
                 }
@@ -434,12 +437,14 @@
     }
 
     @Override
-    public boolean movePath(List<NavigateNode> nodes, Integer taskNo) {
-        return true;
+    public CommandResponse movePath(List<NavigateNode> nodes, Integer taskNo) {
+        CommandResponse response = new CommandResponse(true);
+        return response;
     }
 
     @Override
-    public boolean move(ShuttleCommand command) {
+    public CommandResponse move(ShuttleCommand command) {
+        CommandResponse response = new CommandResponse(false);
         try {
             //鍙戝嚭璇锋眰
             NyShuttleHttpCommand httpCommand = JSON.parseObject(command.getBody(), NyShuttleHttpCommand.class);
@@ -479,73 +484,85 @@
             for (NyShuttleHttpCommand requestCommand : commandList) {
                 JSONObject result = requestCommand(requestCommand);
                 if (result == null) {
-                    return false;//璇锋眰澶辫触
+                    return response;//璇锋眰澶辫触
                 }
                 this.shuttleProtocol.setSendTime(System.currentTimeMillis());//鎸囦护涓嬪彂鏃堕棿
+                response.setMessage(JSON.toJSONString(result));
+                response.setResult(true);
             }
-            return true;
+            return response;
         } catch (Exception e) {
             e.printStackTrace();
-            return false;
+            response.setMessage(e.getMessage());
+            return response;
         }
     }
 
     @Override
-    public boolean lift(ShuttleCommand command) {
+    public CommandResponse lift(ShuttleCommand command) {
+        CommandResponse response = new CommandResponse(false);
         try {
             //鍙戝嚭璇锋眰
             NyShuttleHttpCommand httpCommand = JSON.parseObject(command.getBody(), NyShuttleHttpCommand.class);
             JSONObject result = requestCommand(httpCommand);
             if (result == null) {
-                return false;//璇锋眰澶辫触
+                return response;//璇锋眰澶辫触
             }
             this.shuttleProtocol.setSendTime(System.currentTimeMillis());//鎸囦护涓嬪彂鏃堕棿
-            return true;
+            response.setMessage(JSON.toJSONString(result));
+            response.setResult(true);
+            return response;
         } catch (Exception e) {
             e.printStackTrace();
-            return false;
+            return response;
         }
     }
 
     @Override
-    public boolean charge(ShuttleCommand command) {
+    public CommandResponse charge(ShuttleCommand command) {
+        CommandResponse response = new CommandResponse(false);
         try {
             //鍙戝嚭璇锋眰
             NyShuttleHttpCommand httpCommand = JSON.parseObject(command.getBody(), NyShuttleHttpCommand.class);
             JSONObject result = requestCommand(httpCommand);
             if (result == null) {
-                return false;//璇锋眰澶辫触
+                return response;//璇锋眰澶辫触
             }
             this.shuttleProtocol.setSendTime(System.currentTimeMillis());//鎸囦护涓嬪彂鏃堕棿
-            return true;
+            response.setMessage(JSON.toJSONString(result));
+            response.setResult(true);
+            return response;
         } catch (Exception e) {
             e.printStackTrace();
-            return false;
+            return response;
         }
     }
 
     @Override
-    public boolean reset(ShuttleCommand command) {
+    public CommandResponse reset(ShuttleCommand command) {
         setSyncTaskNo(0);
         setProtocolStatus(ShuttleProtocolStatusType.IDLE);
         enableMoveLoc(null, false);
-        return true;
+        return new CommandResponse(true, JSON.toJSONString(command));
     }
 
     @Override
-    public boolean updateLocation(ShuttleCommand command) {
+    public CommandResponse updateLocation(ShuttleCommand command) {
+        CommandResponse response = new CommandResponse(false);
         try {
             //鍙戝嚭璇锋眰
             NyShuttleHttpCommand httpCommand = JSON.parseObject(command.getBody(), NyShuttleHttpCommand.class);
             JSONObject result = requestCommand(httpCommand);
             if (result == null) {
-                return false;//璇锋眰澶辫触
+                return response;//璇锋眰澶辫触
             }
             this.shuttleProtocol.setSendTime(System.currentTimeMillis());//鎸囦护涓嬪彂鏃堕棿
-            return true;
+            response.setMessage(JSON.toJSONString(result));
+            response.setResult(true);
+            return response;
         } catch (Exception e) {
             e.printStackTrace();
-            return false;
+            return response;
         }
     }
 
@@ -812,9 +829,10 @@
 
         ArrayList<HashMap<String, Object>> path = new ArrayList<>();
 
+        Integer taskId = getTaskId();
         HashMap<String, Object> body = new HashMap<>();
         body.put("requestType", "move");//绉诲姩鍛戒护
-        body.put("taskId", getTaskId());//TaskID闇�瑕侀殢鏈�
+        body.put("taskId", taskId);//TaskID闇�瑕侀殢鏈�
 //        body.put("start", navigateNodeToNyPointNode(NavigatePositionConvert.codeToNode(startCodeNum, device.getHostId())));//璧风偣
 //        body.put("target", navigateNodeToNyPointNode(NavigatePositionConvert.codeToNode(distCodeNum, device.getHostId())));//缁堢偣
         body.put("path", path);
@@ -857,6 +875,7 @@
         command.setBody(JSON.toJSONString(httpStandard));
         command.setMode(ShuttleCommandModeType.MOVE.id);
         command.setTargetLocNo(loc.getLocNo());
+        command.setTaskNo(taskId);
         return command;
     }
 
@@ -865,9 +884,10 @@
         NyShuttleHttpCommand httpStandard = getHttpStandard(Integer.parseInt(device.getDeviceNo()), taskNo);
         NyShuttleHttpCommand.NyRequest request = httpStandard.getRequest();
 
+        Integer taskId = getTaskId();//TaskID闇�瑕侀殢鏈�
         HashMap<String, Object> body = new HashMap<>();
         body.put("requestType", lift ? "liftUp" : "liftDown");//椤跺崌鎴栦笅闄嶅懡浠�
-        body.put("taskId", getTaskId());//TaskID闇�瑕侀殢鏈�
+        body.put("taskId", taskId);
         request.setBody(body);
 
         httpStandard.setRequest(request);
@@ -876,6 +896,7 @@
         command.setShuttleNo(Integer.parseInt(this.device.getDeviceNo()));
         command.setBody(JSON.toJSONString(httpStandard));
         command.setMode(lift ? ShuttleCommandModeType.PALLET_LIFT.id : ShuttleCommandModeType.PALLET_DOWN.id);
+        command.setTaskNo(taskId);
         return command;
     }
 
@@ -884,9 +905,10 @@
         NyShuttleHttpCommand httpStandard = getHttpStandard(Integer.parseInt(device.getDeviceNo()), taskNo);
         NyShuttleHttpCommand.NyRequest request = httpStandard.getRequest();
 
+        Integer taskId = getTaskId();//TaskID闇�瑕侀殢鏈�
         HashMap<String, Object> body = new HashMap<>();
         body.put("requestType", charge ? "charge" : "stopCharge");//鍏呯數鎴栧仠姝㈠厖鐢�
-        body.put("taskId", getTaskId());//TaskID闇�瑕侀殢鏈�
+        body.put("taskId", taskId);
         request.setBody(body);
 
         httpStandard.setRequest(request);
@@ -895,6 +917,7 @@
         command.setShuttleNo(Integer.parseInt(this.device.getDeviceNo()));
         command.setBody(JSON.toJSONString(httpStandard));
         command.setMode(charge ? ShuttleCommandModeType.CHARGE_OPEN.id : ShuttleCommandModeType.CHARGE_CLOSE.id);
+        command.setTaskNo(taskId);
         return command;
     }
 
@@ -914,6 +937,7 @@
         command.setShuttleNo(Integer.parseInt(this.device.getDeviceNo()));
         command.setBody(JSON.toJSONString(httpStandard));
         command.setMode(ShuttleCommandModeType.UPDATE_LOCATION.id);
+        command.setTaskNo(taskNo);
         return command;
     }
 
@@ -968,6 +992,7 @@
         command.setShuttleNo(Integer.parseInt(this.device.getDeviceNo()));
         command.setBody(JSON.toJSONString(httpStandard));
         command.setMode(ShuttleCommandModeType.RESET.id);
+        command.setTaskNo(taskNo);
         return command;
     }
 
@@ -1068,8 +1093,9 @@
                 } catch (Exception e) {
                     e.printStackTrace();
                 }
+            }else {
+                break;
             }
-            break;
         }
         return result;//杩斿洖Body缁撴灉闆�
     }
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 cfd9ac3..58c11a3 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
@@ -28,6 +28,7 @@
 import com.zy.asrs.wcs.rcs.cache.OutputQueue;
 import com.zy.asrs.wcs.rcs.constant.DeviceRedisConstant;
 import com.zy.asrs.wcs.rcs.entity.DeviceDataLog;
+import com.zy.asrs.wcs.rcs.model.CommandResponse;
 import com.zy.asrs.wcs.rcs.model.enums.ShuttleProtocolStatusType;
 import com.zy.asrs.wcs.rcs.model.enums.SlaveType;
 import com.zy.asrs.wcs.rcs.model.protocol.ShuttleProtocol;
@@ -240,7 +241,8 @@
     }
 
     @Override
-    public synchronized boolean movePath(List<NavigateNode> nodes, Integer taskNo) {
+    public synchronized CommandResponse movePath(List<NavigateNode> nodes, Integer taskNo) {
+        CommandResponse response = new CommandResponse(false);
         try {
             //榛樿鍦板浘姣嶈建鏂瑰悜x
             String mapDirection = "x";
@@ -254,7 +256,7 @@
 
             String loginToken = requestLoginToken();
             if (loginToken == null) {
-                return false;
+                return response;
             }
 
             HashMap<String, Object> headers = new HashMap<>();
@@ -310,7 +312,7 @@
             param.put("taskId", taskNo);
             param.put("nodeNum", nodes.size());
             param.put("modes", modes);
-            String response = new HttpHandler.Builder()
+            String responseStr = new HttpHandler.Builder()
                     .setUri(API_URL)
                     .setPath("/RDS/runRoute")
                     .setHeaders(headers)
@@ -318,33 +320,36 @@
                     .setTimeout(60, TimeUnit.SECONDS)
                     .build()
                     .doPost();
-            JSONObject jsonObject = JSON.parseObject(response);
+            JSONObject jsonObject = JSON.parseObject(responseStr);
             Integer code = jsonObject.getInteger("code");
             System.out.println("璺緞涓嬪彂" + taskNo);
             System.out.println(JSON.toJSONString(jsonObject));
             System.out.println(JSON.toJSONString(param));
             if (code.equals(200)) {
                 System.out.println("璺緞涓嬪彂" + taskNo);
-                return true;
+                response.setResult(true);
+                response.setMessage(responseStr);
+                return response;
             }
         } catch (Exception e) {
             e.printStackTrace();
         }
-        return false;
+        return response;
     }
 
     @Override
-    public synchronized boolean move(ShuttleCommand command) {
+    public synchronized CommandResponse move(ShuttleCommand 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/runOrder")
                     .setHeaders(headers)
@@ -352,31 +357,34 @@
                     .setTimeout(60, TimeUnit.SECONDS)
                     .build()
                     .doPost();
-            JSONObject jsonObject = JSON.parseObject(response);
+            JSONObject jsonObject = JSON.parseObject(responseStr);
             Integer code = jsonObject.getInteger("code");
             System.out.println(JSON.toJSONString(command.getBody()));
             if (code.equals(200)) {
                 this.shuttleProtocol.setSendTime(System.currentTimeMillis());//鎸囦护涓嬪彂鏃堕棿
-                return true;
+                response.setResult(true);
+                response.setMessage(responseStr);
+                return response;
             }
         } catch (Exception e) {
             e.printStackTrace();
         }
-        return false;
+        return response;
     }
 
     @Override
-    public synchronized boolean lift(ShuttleCommand command) {
+    public synchronized CommandResponse lift(ShuttleCommand 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/actionOrder")
                     .setHeaders(headers)
@@ -384,30 +392,33 @@
                     .setTimeout(60, TimeUnit.SECONDS)
                     .build()
                     .doPost();
-            JSONObject jsonObject = JSON.parseObject(response);
+            JSONObject jsonObject = JSON.parseObject(responseStr);
             Integer code = jsonObject.getInteger("code");
             if (code.equals(200)) {
                 this.shuttleProtocol.setSendTime(System.currentTimeMillis());//鎸囦护涓嬪彂鏃堕棿
-                return true;
+                response.setResult(true);
+                response.setMessage(responseStr);
+                return response;
             }
         } catch (Exception e) {
             e.printStackTrace();
         }
-        return false;
+        return response;
     }
 
     @Override
-    public synchronized boolean charge(ShuttleCommand command) {
+    public synchronized CommandResponse charge(ShuttleCommand 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/actionOrder")
                     .setHeaders(headers)
@@ -415,38 +426,41 @@
                     .setTimeout(60, TimeUnit.SECONDS)
                     .build()
                     .doPost();
-            JSONObject jsonObject = JSON.parseObject(response);
+            JSONObject jsonObject = JSON.parseObject(responseStr);
             Integer code = jsonObject.getInteger("code");
             if (code.equals(200)) {
                 this.shuttleProtocol.setSendTime(System.currentTimeMillis());//鎸囦护涓嬪彂鏃堕棿
-                return true;
+                response.setResult(true);
+                response.setMessage(responseStr);
+                return response;
             }
         } catch (Exception e) {
             e.printStackTrace();
         }
-        return false;
+        return response;
     }
 
     @Override
-    public synchronized boolean reset(ShuttleCommand command) {
+    public synchronized CommandResponse reset(ShuttleCommand command) {
         setSyncTaskNo(0);
         setProtocolStatus(ShuttleProtocolStatusType.IDLE);
         enableMoveLoc(null, false);
-        return true;
+        return new CommandResponse(true, JSON.toJSONString(command));
     }
 
     @Override
-    public boolean updateLocation(ShuttleCommand command) {
+    public CommandResponse updateLocation(ShuttleCommand 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/changeLocation")
                     .setHeaders(headers)
@@ -454,16 +468,18 @@
                     .setTimeout(60, TimeUnit.SECONDS)
                     .build()
                     .doPost();
-            JSONObject jsonObject = JSON.parseObject(response);
+            JSONObject jsonObject = JSON.parseObject(responseStr);
             Integer code = jsonObject.getInteger("code");
             if (code.equals(200)) {
                 this.shuttleProtocol.setSendTime(System.currentTimeMillis());//鎸囦护涓嬪彂鏃堕棿
-                return true;
+                response.setResult(true);
+                response.setMessage(responseStr);
+                return response;
             }
         } catch (Exception e) {
             e.printStackTrace();
         }
-        return false;
+        return response;
     }
 
     @Override
@@ -733,6 +749,7 @@
         command.setBody(JSON.toJSONString(body));
         command.setMode(ShuttleCommandModeType.MOVE.id);
         command.setTargetLocNo(loc.getLocNo());
+        command.setTaskNo(taskNo);
         return command;
     }
 
@@ -749,6 +766,7 @@
         command.setShuttleNo(Integer.parseInt(this.device.getDeviceNo()));
         command.setBody(JSON.toJSONString(body));
         command.setMode(lift ? ShuttleCommandModeType.PALLET_LIFT.id : ShuttleCommandModeType.PALLET_DOWN.id);
+        command.setTaskNo(taskNo);
         return command;
     }
 
@@ -765,6 +783,7 @@
         command.setShuttleNo(Integer.parseInt(this.device.getDeviceNo()));
         command.setBody(JSON.toJSONString(body));
         command.setMode(charge ? ShuttleCommandModeType.CHARGE_OPEN.id : ShuttleCommandModeType.CHARGE_CLOSE.id);
+        command.setTaskNo(taskNo);
         return command;
     }
 
@@ -782,6 +801,7 @@
         command.setShuttleNo(Integer.parseInt(this.device.getDeviceNo()));
         command.setBody(JSON.toJSONString(body));
         command.setMode(ShuttleCommandModeType.UPDATE_LOCATION.id);
+        command.setTaskNo(taskNo);
         return command;
     }
 

--
Gitblit v1.9.1