Commit 763253c6 authored by 赵啸非's avatar 赵啸非

更新下发消息为线程池发送

parent e6b31455
......@@ -243,12 +243,11 @@ public class DeviceApiController {
deviceEntity.setOnlineTime(new Date());
deviceEntity.setDeviceStatus(DeviceStatusEnum.在线.getValue());
deviceEntity.setDeviceVersion(req.getDeviceVersion() == null ? "" : req.getDeviceVersion());
//todo 延迟队列更新 此时进入redis 队列
DeviceEntity entity = new DeviceEntity();
entity.setId(deviceEntity.getId());
entity.setOnlineTime(new Date());
entity.setDeviceStatus(DeviceStatusEnum.在线.getValue());
//cacheService.lpush(RedisKey.KEY_DEVICE_ONLINE_QUEUE, entity);
deviceService.getDeviceDao().update(deviceEntity);
rsp.setData(deviceResp);
......
......@@ -13,7 +13,6 @@ import com.mortals.xhx.common.code.DeviceStatusEnum;
import com.mortals.xhx.common.code.LogTypeEnum;
import com.mortals.xhx.common.key.RedisKey;
import com.mortals.xhx.module.device.model.DeviceEntity;
import com.mortals.xhx.module.device.model.DeviceQuery;
import com.mortals.xhx.module.device.service.DeviceService;
import com.mortals.xhx.module.platform.model.PlatformEntity;
import com.mortals.xhx.module.platform.service.PlatformService;
......@@ -24,7 +23,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
......@@ -49,7 +47,7 @@ public class DeviceStatTaskImpl implements ITaskExcuteService {
@Override
public void excuteTask(ITask task) throws AppException {
log.info("设备状态修正任务");
List<DeviceEntity> waitDeviceInfos = new ArrayList<>();
/* List<DeviceEntity> waitDeviceInfos = new ArrayList<>();
while (true) {
DeviceEntity deviceEntity = cacheService.blpop(RedisKey.KEY_DEVICE_ONLINE_QUEUE,10, DeviceEntity.class);
if (ObjectUtils.isEmpty(deviceEntity)) {
......@@ -70,9 +68,12 @@ public class DeviceStatTaskImpl implements ITaskExcuteService {
cacheService.lpush(RedisKey.KEY_DEVICE_UPDATE_QUEUE,waitDeviceInfo);
}
// deviceService.update(waitDeviceInfos);
}
}*/
//获取所有在线设备
List<DeviceEntity> deviceList = deviceService.find(new DeviceQuery().deviceStatus(DeviceStatusEnum.在线.getValue()));
List<DeviceEntity> deviceList = deviceService.getCacheList().stream().filter(f->DeviceStatusEnum.在线.getValue()==f.getDeviceStatus()).collect(Collectors.toList());
// List<DeviceEntity> deviceList = deviceService.find(new DeviceQuery().deviceStatus(DeviceStatusEnum.在线.getValue()));
//更新离线
List<DeviceEntity> deviceOfflineList = deviceList.parallelStream().map(item -> {
if (ObjectUtils.isEmpty(item.getDeviceCode())) return null;
......
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