This commit is contained in:
tangzh 2025-07-13 10:34:00 +08:00
parent 06466a4e45
commit 712e5e9038
4 changed files with 11 additions and 6 deletions

View File

@ -4,6 +4,7 @@ import me.zhengjie.config.properties.FileProperties;
import me.zhengjie.modules.system.domain.dto.ImageDataVo; import me.zhengjie.modules.system.domain.dto.ImageDataVo;
import me.zhengjie.utils.StringUtils; import me.zhengjie.utils.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct; import javax.annotation.PostConstruct;
@ -16,7 +17,7 @@ public class WebSocketService {
public static BusDeviceService myDeviceService; public static BusDeviceService myDeviceService;
public static FileProperties myFileProperties; public static FileProperties myFileProperties;
@Autowired private BusDeviceService deviceService; @Autowired @Lazy private BusDeviceService deviceService;
@Autowired private FileProperties fileProperties; @Autowired private FileProperties fileProperties;
// 初始化 // 初始化

View File

@ -32,6 +32,8 @@ import lombok.RequiredArgsConstructor;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import me.zhengjie.utils.*; import me.zhengjie.utils.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.scheduling.annotation.Async; import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
@ -56,9 +58,9 @@ public class BusDeviceServiceImpl extends ServiceImpl<BusDeviceMapper, BusDevice
private final BusUserCommandMapper busUserCommandMapper; private final BusUserCommandMapper busUserCommandMapper;
private final BusCommandLogMapper busCommandLogMapper; private final BusCommandLogMapper busCommandLogMapper;
private final WeChatService weChatService; private final WeChatService weChatService;
private final WebSocketSdcpServiceImpl webSocketSdcpService; @Autowired @Lazy private WebSocketSdcpServiceImpl webSocketSdcpService;
private final WebSocketVueServiceImpl webSocketVueService; @Autowired @Lazy private WebSocketVueServiceImpl webSocketVueService;
private final RedisUtils redisUtils; // private final RedisUtils redisUtils;
@Override @Override
public BusDevice getByDeviceCode(String deviceCode) { public BusDevice getByDeviceCode(String deviceCode) {

View File

@ -109,6 +109,10 @@ public class WebSocketSdcpServiceImpl extends WebSocketService {
// 初始状态刷新消息(Cmd:0) 指令 // 初始状态刷新消息(Cmd:0) 指令
private void pushDeviceStatus(String deviceSn) { private void pushDeviceStatus(String deviceSn) {
WebSocketService socket = getSocket(WebSocketConfig.TOPIC_PREFIX); WebSocketService socket = getSocket(WebSocketConfig.TOPIC_PREFIX);
if (null == socket || null == socket.session || !socket.session.isOpen()) {
log.info("<<< 第三方未连接,无法初始化,略过");
return;
}
long currentTimeLong = System.currentTimeMillis(); long currentTimeLong = System.currentTimeMillis();
Map<String, Object> dataParam = new HashMap<>(); Map<String, Object> dataParam = new HashMap<>();
dataParam.put("UserId", socket.session.getId()); dataParam.put("UserId", socket.session.getId());

View File

@ -35,8 +35,6 @@ public class WebSocketVueServiceImpl extends WebSocketService {
log.info("<<< 设备初始化"); log.info("<<< 设备初始化");
} }
// 每30秒刷新设备
@Scheduled(fixedRate = 30000)
public void refreshDeviceList() { public void refreshDeviceList() {
deviceList = new ArrayList<>(); deviceList = new ArrayList<>();
List<BusDevice> devices = myDeviceService.queryAll(new BusDeviceQueryCriteria()); List<BusDevice> devices = myDeviceService.queryAll(new BusDeviceQueryCriteria());