|
@@ -62,13 +62,26 @@ public class ScheduledService {
|
|
|
|
|
|
|
|
|
|
|
|
|
//定时更新设备在线状态
|
|
//定时更新设备在线状态
|
|
|
- @Scheduled(cron="0 30 * * * ?")
|
|
|
|
|
|
|
+ @Scheduled(cron="20 */5 * * * ?")
|
|
|
// @RequestMapping("/updateDeviceState")
|
|
// @RequestMapping("/updateDeviceState")
|
|
|
public void updateDeviceState() {
|
|
public void updateDeviceState() {
|
|
|
- List<Devices> devicesList=devicesService.list(new QueryWrapper<>());
|
|
|
|
|
- for (Devices devices:devicesList){
|
|
|
|
|
- realTimeRecordsService.listAll();
|
|
|
|
|
|
|
+ List<Map<String,Object>> mapList=realTimeRecordsService.listAll();
|
|
|
|
|
+ List<Devices> devicesList=new ArrayList<>();
|
|
|
|
|
+ long currentTimeMillis = new Date().getTime();
|
|
|
|
|
+ //10分钟前
|
|
|
|
|
+ Date fiveagotime = new Date(currentTimeMillis - 600000);
|
|
|
|
|
+ for(int i=0;i<mapList.size();i++){
|
|
|
|
|
+ Devices devices=new Devices();
|
|
|
|
|
+ Date updateAt= (Date) mapList.get(i).get("updateAt");
|
|
|
|
|
+ if (updateAt!=null&&updateAt.compareTo(fiveagotime)>0){
|
|
|
|
|
+ devices.setOnline(1);
|
|
|
|
|
+ }else{
|
|
|
|
|
+ devices.setOnline(0);
|
|
|
|
|
+ }
|
|
|
|
|
+ devices.setId((Integer) mapList.get(i).get("id"));
|
|
|
|
|
+ devicesList.add(devices);
|
|
|
}
|
|
}
|
|
|
|
|
+ devicesService.updateBatchById(devicesList);
|
|
|
}
|
|
}
|
|
|
//定时保存设备传感器假数据 后续删除
|
|
//定时保存设备传感器假数据 后续删除
|
|
|
// @Scheduled(cron="0 0/5 * * * ?")
|
|
// @Scheduled(cron="0 0/5 * * * ?")
|