update:判断客户端是否启动了自动升级

This commit is contained in:
hrz 2025-04-25 17:55:53 +08:00
parent 9a79ab2ed2
commit cf7d148651

View file

@ -116,9 +116,15 @@ public class DeviceServiceImpl extends BaseServiceImpl<DeviceDao, DeviceEntity>
DeviceReportRespDTO response = new DeviceReportRespDTO(); DeviceReportRespDTO response = new DeviceReportRespDTO();
response.setServer_time(buildServerTime()); response.setServer_time(buildServerTime());
String type = deviceReport.getBoard() == null ? null : deviceReport.getBoard().getType(); DeviceEntity deviceById = getDeviceByMacAddress(macAddress);
DeviceReportRespDTO.Firmware firmware = buildFirmwareInfo(type, macAddress);
response.setFirmware(firmware); if (deviceById == null || deviceById.getAutoUpdate() != 0) {
String type = deviceReport.getBoard() == null ? null : deviceReport.getBoard().getType();
DeviceReportRespDTO.Firmware firmware = buildFirmwareInfo(type);
response.setFirmware(firmware);
} else {
response.setFirmware(null);
}
// 添加WebSocket配置 // 添加WebSocket配置
DeviceReportRespDTO.Websocket websocket = new DeviceReportRespDTO.Websocket(); DeviceReportRespDTO.Websocket websocket = new DeviceReportRespDTO.Websocket();
@ -141,7 +147,6 @@ public class DeviceServiceImpl extends BaseServiceImpl<DeviceDao, DeviceEntity>
response.setWebsocket(websocket); response.setWebsocket(websocket);
DeviceEntity deviceById = getDeviceByMacAddress(macAddress);
if (deviceById != null) { // 如果设备存在,则更新上次连接时间 if (deviceById != null) { // 如果设备存在,则更新上次连接时间
deviceById.setLastConnectedAt(new Date()); deviceById.setLastConnectedAt(new Date());
deviceDao.updateById(deviceById); deviceDao.updateById(deviceById);
@ -294,7 +299,7 @@ public class DeviceServiceImpl extends BaseServiceImpl<DeviceDao, DeviceEntity>
return code; return code;
} }
private DeviceReportRespDTO.Firmware buildFirmwareInfo(String type, String macAddress) { private DeviceReportRespDTO.Firmware buildFirmwareInfo(String type) {
if (StringUtils.isBlank(type)) { if (StringUtils.isBlank(type)) {
return null; return null;
} }