From c1063b1c52568ced60ce895a7c4bb519ec654236 Mon Sep 17 00:00:00 2001
From: luxiaotao1123 <t1341870251@163.com>
Date: 星期一, 25 三月 2024 15:14:39 +0800
Subject: [PATCH] Merge branch 'Four-Way-Rack' of http://47.97.1.152:5880/r/zy-asrs-master into Four-Way-Rack
---
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/constant/DeviceRedisConstant.java | 18 ++++
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/thread/impl/SurayShuttleThread.java | 6
zy-asrs-flow/src/pages/device/shuttle/index.jsx | 200 ++++++++++++++++++++++++++++++++++++++++++++++++++
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/model/protocol/ShuttleProtocol.java | 16 +++
4 files changed, 236 insertions(+), 4 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
diff --git a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/constant/DeviceRedisConstant.java b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/constant/DeviceRedisConstant.java
new file mode 100644
index 0000000..52dd32b
--- /dev/null
+++ b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/constant/DeviceRedisConstant.java
@@ -0,0 +1,18 @@
+package com.zy.asrs.wcs.rcs.constant;
+
+/**
+ * Created by vincent on 2023/11/6
+ */
+public class DeviceRedisConstant {
+
+ public static final String SHUTTLE_FLAG = "shuttle_no_";
+
+ public static final String SHUTTLE_WORK_FLAG = "shuttle_wrk_no_";
+
+ public static final String LIFT_FLAG = "lift_no_";
+
+ public static final String LIFT_WORK_FLAG = "lift_wrk_no_";
+
+ public static final String MAP = "realtimeBasMap_";
+
+}
diff --git a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/model/protocol/ShuttleProtocol.java b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/model/protocol/ShuttleProtocol.java
index 325a2f5..b0ff291 100644
--- a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/model/protocol/ShuttleProtocol.java
+++ b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/model/protocol/ShuttleProtocol.java
@@ -1,7 +1,10 @@
package com.zy.asrs.wcs.rcs.model.protocol;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.zy.asrs.framework.common.Cools;
import com.zy.asrs.framework.common.SpringUtils;
+import com.zy.asrs.wcs.core.utils.RedisUtil;
+import com.zy.asrs.wcs.rcs.constant.DeviceRedisConstant;
import com.zy.asrs.wcs.rcs.model.enums.ShuttleDeviceStatusType;
import com.zy.asrs.wcs.rcs.model.enums.ShuttleProtocolStatusType;
import com.zy.asrs.wcs.rcs.entity.Device;
@@ -26,7 +29,7 @@
/**
* 浠诲姟鍙�
*/
- private String taskNo;
+ private Integer taskNo;
/**
* 褰撳墠灏忚溅鐘舵�侊紙鍐呴儴鑷垜缁存姢锛�
@@ -211,4 +214,15 @@
return false;//榛樿涓嶇┖闂�
}
+ public Integer getTaskNo() {
+ RedisUtil redisUtil = SpringUtils.getBean(RedisUtil.class);
+ if (null != redisUtil) {
+ Object o = redisUtil.get(DeviceRedisConstant.SHUTTLE_FLAG + this.taskNo);
+ if (!Cools.isEmpty(o)) {
+ this.taskNo = Integer.parseInt(String.valueOf(o));
+ }
+ }
+ return this.taskNo == null ? 0 : this.taskNo;
+ }
+
}
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 2780f6e..6c46a09 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
@@ -85,15 +85,15 @@
//灏忚溅蹇欑姸鎬佷綅
shuttleProtocol.setDeviceStatus(data.getInteger("deviceStatus"));
//褰撳墠浜岀淮鐮�
- shuttleProtocol.setCurrentCode(data.getString("deviceLocation"));
+ shuttleProtocol.setCurrentCode(data.getString("deviceLocation") == null ? "0" : data.getString("deviceLocation"));
//鐢垫睜鐢甸噺
- shuttleProtocol.setBatteryPower(data.getString("battery"));
+ shuttleProtocol.setBatteryPower(data.getString("battery") == null ? "0%" : data.getString("battery"));
//鏄惁椤跺崌
shuttleProtocol.setHasLift(data.getInteger("palletStatus") == 1 ? true : false);
//琛岄┒鏂瑰悜
- shuttleProtocol.setRunDirection(data.getString("direction"));
+ shuttleProtocol.setRunDirection(data.getString("direction") == null ? "none" : data.getString("direction"));
///璇诲彇鍥涘悜绌挎杞︾姸鎬�-end
--
Gitblit v1.9.1