From 15771e0f71f3838104591b6113f0ee67e74bdcbd Mon Sep 17 00:00:00 2001
From: luxiaotao1123 <t1341870251@163.com>
Date: 星期四, 11 四月 2024 22:12:46 +0800
Subject: [PATCH] #

---
 /dev/null                                                                                  |    7 ---
 zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/map/websocket/MapRealTimeDataScheduler.java |   70 +++++++++++++++++++++++++++++++++++
 2 files changed, 70 insertions(+), 7 deletions(-)

diff --git a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/map/websocket/MapRealTimeDataScheduler.java b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/map/websocket/MapRealTimeDataScheduler.java
new file mode 100644
index 0000000..f9092d6
--- /dev/null
+++ b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/map/websocket/MapRealTimeDataScheduler.java
@@ -0,0 +1,70 @@
+package com.zy.asrs.wcs.core.map.websocket;
+
+import com.alibaba.fastjson.JSON;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.zy.asrs.wcs.core.map.entity.MapWsShuttleVo;
+import com.zy.asrs.wcs.core.map.entity.MapWsVo;
+import com.zy.asrs.wcs.core.model.enums.DeviceCtgType;
+import com.zy.asrs.wcs.core.service.BasShuttleService;
+import com.zy.asrs.wcs.rcs.cache.SlaveConnection;
+import com.zy.asrs.wcs.rcs.entity.Device;
+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.DeviceService;
+import com.zy.asrs.wcs.rcs.service.DeviceTypeService;
+import com.zy.asrs.wcs.rcs.service.ShuttleService;
+import com.zy.asrs.wcs.rcs.thread.ShuttleThread;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.scheduling.annotation.Scheduled;
+import org.springframework.stereotype.Component;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Created by vincent on 4/11/2024
+ */
+@Component
+public class MapRealTimeDataScheduler {
+
+    @Autowired
+    private DeviceTypeService deviceTypeService;
+    @Autowired
+    private DeviceService deviceService;
+    @Autowired
+    private BasShuttleService basShuttleService;
+
+    @Scheduled(cron = "0/1 * * * * ? ")
+    public void sync() {
+        MapWsVo wsVo = new MapWsVo();
+        // shuttle
+        wsVo.setShuttleVos(syncShuttle());
+        MapWebSocket.broadcast(JSON.toJSONString(wsVo));
+    }
+
+    private List<MapWsShuttleVo> syncShuttle() {
+        List<MapWsShuttleVo> shuttleVos = new ArrayList<>();
+
+        List<Device> deviceList = deviceService.list(new LambdaQueryWrapper<Device>().eq(Device::getDeviceType, DeviceCtgType.SHUTTLE.val()));
+        for (Device device : deviceList) {
+            basShuttleService.
+            ShuttleThread thread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, device.getId().intValue());
+            if (null == thread) {
+                continue;
+            }
+            ShuttleProtocol protocol = thread.getStatus();
+            if (null == protocol) {
+                continue;
+            }
+
+            MapWsShuttleVo shuttleVo = new MapWsShuttleVo();
+            shuttleVo.setShuttleNo();
+
+
+            shuttleVos.add(shuttleVo);
+        }
+
+        return shuttleVos;
+    }
+
+}
diff --git a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/map/websocket/MapRealTimeDatascheduler.java b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/map/websocket/MapRealTimeDatascheduler.java
deleted file mode 100644
index 3dde515..0000000
--- a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/map/websocket/MapRealTimeDatascheduler.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package com.zy.asrs.wcs.core.map.websocket;
-
-/**
- * Created by vincent on 4/11/2024
- */
-public class MapRealTimeDatascheduler {
-}

--
Gitblit v1.9.1