From 8fa5c45ca9761ae4b181f0921db615841b9aae15 Mon Sep 17 00:00:00 2001
From: Junjie <xjj@123>
Date: 星期三, 02 四月 2025 16:43:23 +0800
Subject: [PATCH] #

---
 zy-asrs-flow/src/pages/device/shuttle/index.jsx |   27 ++++++++++++++++++++++-----
 1 files changed, 22 insertions(+), 5 deletions(-)

diff --git a/zy-asrs-flow/src/pages/device/shuttle/index.jsx b/zy-asrs-flow/src/pages/device/shuttle/index.jsx
index 1aebf64..dea6fef 100644
--- a/zy-asrs-flow/src/pages/device/shuttle/index.jsx
+++ b/zy-asrs-flow/src/pages/device/shuttle/index.jsx
@@ -6,6 +6,7 @@
     PageContainer,
 } from '@ant-design/pro-components';
 import './index.less'
+import { WEBSOCKET_BASE_URL } from '@/config/setting';
 
 const Main = () => {
     const [deviceInfos, setDeviceInfos] = useState([]);
@@ -21,8 +22,7 @@
     const [moveLocType, setMoveLocType] = useState(1);
 
     useEffect(() => {
-        var newWs = new WebSocket("ws://127.0.0.1:9090/wcs/ws/shuttle/websocket");
-        setWs(newWs);
+        connect();
 
         return () => {
             if (ws) {
@@ -58,6 +58,7 @@
 
             ws.onclose = function (e) {
                 console.log("close");
+                reconnect();
             }
 
             ws.onerror = function (e) {
@@ -65,6 +66,18 @@
             }
         }
     }, [ws]);
+
+    const connect = () => {
+        var newWs = new WebSocket(WEBSOCKET_BASE_URL + "/ws/shuttle/websocket");
+        setWs(newWs);
+    }
+
+    const reconnect = () => {
+        setTimeout(() => {
+            console.log('WebSocketClient: Attempting to reconnect...');
+            connect();
+        }, 3000);
+    }
 
     const sendWs = (message) => {
         if (ws.readyState == WebSocket.OPEN) {
@@ -278,7 +291,12 @@
                         key: '13',
                         label: '鑷姩',
                         children: item.mode ? 'Y' : 'N',
-                    }
+                    },
+                    {
+                        key: '14',
+                        label: '搴撲綅鍙�',
+                        children: item.currentLocNo,
+                    },
                 ];
                 return <div key={item.id} style={{ width: '45%' }}>
                     <div style={{ marginBottom: '10px' }}>
@@ -307,8 +325,6 @@
                             </p>
                             <p>
                             </p>
-                            <p>
-                            </p>
                             <div className="commandItem">
                                 <Button onClick={() => shuttleOperator('moveLoc')}>绉诲姩鍒扮洰鏍囦綅缃�</Button>
                                 <Button onClick={() => shuttleOperator('takeMove')}>鍙栨斁璐т綔涓�</Button>
@@ -323,6 +339,7 @@
                                 <Button onClick={() => shuttleOperator('palletDown')}>鎵樼洏涓嬮檷</Button>
                                 <Button onClick={() => shuttleOperator('chargeOpen')}>鍏呯數寮�</Button>
                                 <Button onClick={() => shuttleOperator('chargeClose')}>鍏呯數鍏�</Button>
+                                <Button onClick={() => shuttleOperator('requestWaiting')}>鐢宠纭</Button>
                                 <Button onClick={() => shuttleOperator('reset')}>澶嶄綅</Button>
                             </div>
                         </Card>

--
Gitblit v1.9.1