debug:设备启动更新设备状态

This commit is contained in:
墨大叔 2024-09-21 17:38:46 +08:00
parent ddb0b75468
commit 7ff418ef44
3 changed files with 27 additions and 27 deletions

View File

@ -579,23 +579,23 @@ public class DeviceServiceImpl implements DeviceService
this.pullDeviceInfoAsync(Collections.singletonList(deviceId), 3, TimeUnit.SECONDS);
// 时长结束后修改设备状态
scheduledExecutorService.schedule(()-> {
freshStatus(deviceId);
}, seconds, TimeUnit.SECONDS);
// scheduledExecutorService.schedule(()-> {
// freshStatus(deviceId);
// }, seconds, TimeUnit.SECONDS);
}
return success;
}
private void freshStatus(Long deviceId) {
DeviceVO device = deviceMapper.selectSmDeviceByDeviceId(deviceId);
freshStatus(device);
}
// private void freshStatus(Long deviceId) {
// DeviceVO device = deviceMapper.selectSmDeviceByDeviceId(deviceId);
// freshStatus(device);
// }
@Override
public void freshStatus(DeviceVO device) {
if (device == null) {
if (device == null || device.getExpireTime() == null) {
return;
}
if (!DeviceStatus.USING.getStatus().equals(device.getStatus())) {
@ -610,12 +610,12 @@ public class DeviceServiceImpl implements DeviceService
return;
}
// 如果没有过期则延迟至过期时间继续查询
if (between.getSeconds() > 0) {
scheduledExecutorService.schedule(() -> {
freshStatus(device.getDeviceId());
}, between.getSeconds() , TimeUnit.SECONDS);
}
// // 如果没有过期则延迟至过期时间继续查询
// if (between.getSeconds() > 0) {
// scheduledExecutorService.schedule(() -> {
// freshStatus(device.getDeviceId());
// }, between.getSeconds() , TimeUnit.SECONDS);
// }
}
/**

View File

@ -31,18 +31,18 @@ public class DeviceStatusTask implements ApplicationRunner {
*/
@Override
public void run(ApplicationArguments args) throws Exception {
log.info("项目启动,查询正在使用中的设备");
DeviceQuery query = new DeviceQuery();
query.setStatus(DeviceStatus.USING.getStatus());
List<DeviceVO> list = deviceService.selectSmDeviceList(query);
if (CollectionUtils.isEmptyElement(list)) {
log.info("没有正在使用中的设备");
return;
}
for (DeviceVO device : list) {
deviceService.freshStatus(device);
}
// log.info("项目启动,查询正在使用中的设备");
// DeviceQuery query = new DeviceQuery();
// query.setStatus(DeviceStatus.USING.getStatus());
// List<DeviceVO> list = deviceService.selectSmDeviceList(query);
// if (CollectionUtils.isEmptyElement(list)) {
// log.info("没有正在使用中的设备");
// return;
// }
//
// for (DeviceVO device : list) {
// deviceService.freshStatus(device);
// }
}
}

View File

@ -33,7 +33,7 @@ wx:
# 设备配置
device:
# 项目启动时抄表
startRecord: true
startRecord: false
spring:
# redis 配置