Commit df233250 authored by 赵啸非's avatar 赵啸非

修改设备站点名称

parent 683d7e9a
......@@ -15,6 +15,7 @@ import com.mortals.xhx.common.code.DeviceSourceEnum;
import com.mortals.xhx.common.key.ParamKey;
import com.mortals.xhx.common.utils.SendTask;
import com.mortals.xhx.common.utils.SendTaskThreadPool;
import com.mortals.xhx.module.device.model.DeviceEntity;
import com.mortals.xhx.module.device.model.DeviceLogEntity;
import com.mortals.xhx.module.device.model.DeviceLogQuery;
import com.mortals.xhx.module.device.service.DeviceLogService;
......@@ -26,6 +27,7 @@ import org.springframework.util.ObjectUtils;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
/**
* 设备状态任务
......@@ -62,10 +64,10 @@ public class DeviceStatTaskImpl implements ITaskExcuteService {
try {
//获取所有设备,针对每个设备查询最近指定秒的日志,如果没有则更新下线
deviceService.getCacheList().stream()
List<DeviceEntity> collect = deviceService.getCacheList().stream()
.filter(f -> f.getDeviceSource() == DeviceSourceEnum.大厅.getValue())
.filter(f -> f.getDeviceOnlineStatus() == DeviceOnlineStatusEnum.在线.getValue())
.peek(device -> {
.map(device -> {
DeviceLogQuery query = new DeviceLogQuery();
query.setCreateTimeStart(DateUtils.getStrDateTime(new Date(System.currentTimeMillis() - timeout)));
......@@ -74,12 +76,14 @@ public class DeviceStatTaskImpl implements ITaskExcuteService {
//更新设备下线
device.setOfflineTime(new Date());
device.setDeviceOnlineStatus(DeviceOnlineStatusEnum.离线.getValue());
deviceService.update(device);
// deviceService.update(device);
WebSocketUtil.broadcast(SendToAllRequest.TYPE, new SendToAllRequest().setContent(JSON.toJSONString(device)));
return device;
}
}).count();
return null;
}).filter(f->f!=null).collect(Collectors.toList());
deviceService.update(collect,null);
} catch (Exception e) {
log.error("更新设备状态任务异常,结束执行", e);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment