From 9cec64faba70f6a4c37a6c6ddefadc59badcb3c1 Mon Sep 17 00:00:00 2001
From: Junjie <xjj@123>
Date: 星期一, 25 三月 2024 11:19:02 +0800
Subject: [PATCH] #

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

diff --git a/zy-asrs-flow/src/pages/device/shuttle/index.jsx b/zy-asrs-flow/src/pages/device/shuttle/index.jsx
new file mode 100644
index 0000000..eff130e
--- /dev/null
+++ b/zy-asrs-flow/src/pages/device/shuttle/index.jsx
@@ -0,0 +1,200 @@
+import React, { useEffect, useRef, useState } from "react";
+import { getToken } from '@/utils/token-util'
+import { Badge, Descriptions } from 'antd';
+import {
+    PageContainer,
+} from '@ant-design/pro-components';
+
+let items = [
+    {
+        key: '1',
+        label: '浠诲姟鍙�',
+        children: '1',
+    },
+    {
+        key: '2',
+        label: '宸ヤ綔鐘舵��',
+        children: <Badge status="processing" text="Running" />,
+    },
+    {
+        key: '3',
+        label: '璁惧鐘舵��',
+        children: <Badge status="processing" text="Running" />,
+    },
+    {
+        key: '4',
+        label: '鍧愭爣鐮�',
+        children: '1,2,3',
+    },
+    {
+        key: '5',
+        label: '鐢甸噺',
+        children: '50%',
+    },
+    {
+        key: '6',
+        label: '閿欒鐮�',
+        children: '0',
+    },
+    {
+        key: '7',
+        label: '椤跺崌鐘舵��',
+        children: 'Y',
+    },
+    {
+        key: '8',
+        label: '鍏呯數鐘舵��',
+        children: 'Y',
+    },
+    {
+        key: '9',
+        label: '浣滀笟鏍囪',
+        children: 'Y',
+    },
+    {
+        key: '10',
+        label: '璺戝簱寮�鍏�',
+        children: 'Y',
+    },
+];
+
+const Main = () => {
+    const [deviceInfos, setDeviceInfos] = useState([]);
+    const [ws, setWs] = useState(null);
+
+    useEffect(() => {
+        var newWs = new WebSocket("ws://127.0.0.1:9090/wcs/ws/shuttle/websocket");
+        setWs(newWs);
+
+        return () => {
+            if (ws) {
+                ws.close();
+            }
+        }
+    }, [])
+
+    useEffect(() => {
+
+        if (ws) {
+            ws.onopen = function () {
+                console.log("open");
+
+                sendWs(JSON.stringify({
+                    "url": "login",
+                    "data": {
+                        "token": getToken()
+                    }
+                }))
+            }
+
+            ws.onmessage = function (e) {
+                const result = JSON.parse(e.data);
+                if (result.url == "login") {
+                    setInterval(function () {
+                        getDeviceInfo();
+                    }, 1000)
+                } else if (result.url == "/shuttle/status/list") {
+                    const data = JSON.parse(result.data);
+                    setDeviceInfos(data);
+                }
+            }
+
+            ws.onclose = function (e) {
+                console.log("close");
+            }
+
+            ws.onerror = function (e) {
+                console.log(e);
+            }
+        }
+    }, [ws]);
+
+    const sendWs = (message) => {
+        if (ws.readyState == WebSocket.OPEN) {
+            ws.send(message)
+        }
+    }
+
+    const getDeviceInfo = () => {
+        sendWs(JSON.stringify({
+            "url": "/shuttle/status/list",
+            "data": {}
+        }))
+    }
+
+    return (
+        <PageContainer
+            header={{
+                breadcrumb: {},
+            }}
+        >
+            <div style={{ display: 'flex', flexWrap: 'wrap', justifyContent: 'space-around' }}>
+                {deviceInfos.map(item => {
+                    let tmpTitle = item.shuttleNo + "鍙峰洓鍚戣溅"
+                    let tmpData = [
+                        {
+                            key: '1',
+                            label: '浠诲姟鍙�',
+                            children: item.taskNo,
+                        },
+                        {
+                            key: '2',
+                            label: '宸ヤ綔鐘舵��',
+                            children: <Badge status="processing" text={item.protocolStatusType} />,
+                        },
+                        {
+                            key: '3',
+                            label: '璁惧鐘舵��',
+                            children: <Badge status="processing" text={item.deviceStatus$} />,
+                        },
+                        {
+                            key: '4',
+                            label: '鍧愭爣鐮�',
+                            children: item.currentCode,
+                        },
+                        {
+                            key: '5',
+                            label: '鐢甸噺',
+                            children: item.batteryPower,
+                        },
+                        {
+                            key: '6',
+                            label: '閿欒鐮�',
+                            children: '0',
+                        },
+                        {
+                            key: '7',
+                            label: '椤跺崌鐘舵��',
+                            children: item.hasLift ? 'Y' : 'N',
+                        },
+                        {
+                            key: '8',
+                            label: '鍏呯數鐘舵��',
+                            children: 'N',
+                        },
+                        {
+                            key: '9',
+                            label: '浣滀笟鏍囪',
+                            children: item.pakMk ? 'Y' : 'N',
+                        },
+                        {
+                            key: '10',
+                            label: '璺戝簱寮�鍏�',
+                            children: item.moveLoc ? 'Y' : 'N',
+                        },
+                        {
+                            key: '11',
+                            label: '杩愯鏂瑰悜',
+                            children: item.runDirection,
+                        },
+                    ];
+                    return <div key={item.id} style={{ width: '45%' }}>
+                        <Descriptions size="small" title={tmpTitle} bordered items={tmpData} />
+                    </div>
+                })}
+            </div>
+        </PageContainer>
+    )
+}
+
+export default Main;
\ No newline at end of file

--
Gitblit v1.9.1