Commit 7b570154 authored by 赵啸非's avatar 赵啸非

添加设备告警

parent 3ff5f8bf
......@@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.core.json.JsonGeneratorImpl;
import com.mortals.framework.ap.GlobalSysInfo;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.service.ICacheService;
import com.mortals.framework.service.ITask;
import com.mortals.framework.service.ITaskExcuteService;
import com.mortals.framework.util.DateUtils;
......@@ -32,6 +33,8 @@ import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
import static com.mortals.xhx.common.key.RedisKey.KEY_DEVICE_TYPE_CACHE;
/**
* 设备状态任务
*
......@@ -51,6 +54,8 @@ public class DeviceStatTaskImpl implements ITaskExcuteService {
private SendTaskThreadPool sendTaskThreadPool;
@Autowired
private DeviceAlarmService deviceAlarmService;
@Autowired
private ICacheService cacheService;
@Override
......@@ -82,13 +87,14 @@ public class DeviceStatTaskImpl implements ITaskExcuteService {
//更新设备下线
device.setOfflineTime(new Date());
device.setDeviceOnlineStatus(DeviceOnlineStatusEnum.离线.getValue());
cacheService.del(KEY_DEVICE_TYPE_CACHE + device.getDeviceCode());
return device;
}
return null;
}).filter(f->f!=null).collect(Collectors.toList());
}).filter(f -> f != null).collect(Collectors.toList());
log.info("更新设备下线:{} ,时间:{}", JSON.toJSONString(collect),DateUtils.getStrDateTime(new Date(System.currentTimeMillis() - timeout)));
deviceService.update(collect,null);
log.info("更新设备下线:{} ,时间:{}", JSON.toJSONString(collect), DateUtils.getStrDateTime(new Date(System.currentTimeMillis() - timeout)));
deviceService.update(collect, null);
List<DeviceAlarmEntity> alarmEntityList = collect.stream().map(device -> {
//新增告警信息
......@@ -140,9 +146,9 @@ public class DeviceStatTaskImpl implements ITaskExcuteService {
deviceService.getCacheList().parallelStream()
.filter(f -> f.getDeviceSource() == DeviceSourceEnum.其它.getValue())
.peek(device -> {
String sendUrl = GlobalSysInfo.getParamValue(ParamKey.SYS_PARAM_SEND_QUERY_URL,"http://127.0.0.1:18211/m/test/equipStateQuery");
String sendUrl = GlobalSysInfo.getParamValue(ParamKey.SYS_PARAM_SEND_QUERY_URL, "http://127.0.0.1:18211/m/test/equipStateQuery");
JSONObject jsonObject = new JSONObject();
jsonObject.put("macAddress",device.getDeviceMac());
jsonObject.put("macAddress", device.getDeviceMac());
SendTask sendTask = new SendTask(sendUrl, device.getId(), jsonObject.toJSONString(), deviceService);
sendTaskThreadPool.execute(sendTask);
}).count();
......
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