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

添加设备告警

parent 2bff30df
...@@ -47,15 +47,16 @@ public class UploadTask implements Runnable { ...@@ -47,15 +47,16 @@ public class UploadTask implements Runnable {
if (deviceEntity.getDeviceOnlineStatus() == DeviceOnlineStatusEnum.离线.getValue()) { if (deviceEntity.getDeviceOnlineStatus() == DeviceOnlineStatusEnum.离线.getValue()) {
bool = true; bool = true;
} }
deviceEntity.setOnlineTime(new Date()); if(bool){
deviceEntity.setDeviceOnlineStatus(DeviceOnlineStatusEnum.在线.getValue()); deviceEntity.setOnlineTime(new Date());
deviceEntity.setIp(req.getIp()); deviceEntity.setDeviceOnlineStatus(DeviceOnlineStatusEnum.在线.getValue());
deviceEntity.setPort(req.getPort()); deviceEntity.setIp(req.getIp());
deviceEntity.setSiteNum(req.getSitenum()); deviceEntity.setPort(req.getPort());
deviceEntity.setSiteName(req.getSitename()); deviceEntity.setSiteNum(req.getSitenum());
deviceEntity.setCenternum(req.getCenternum()); deviceEntity.setSiteName(req.getSitename());
// deviceService.update(deviceEntity); deviceEntity.setCenternum(req.getCenternum());
deviceService.update(deviceEntity);
}
DeviceLogEntity deviceLogEntity = new DeviceLogEntity(); DeviceLogEntity deviceLogEntity = new DeviceLogEntity();
deviceLogEntity.initAttrValue(); deviceLogEntity.initAttrValue();
deviceLogEntity.setDeviceId(deviceEntity.getId()); deviceLogEntity.setDeviceId(deviceEntity.getId());
...@@ -66,7 +67,7 @@ public class UploadTask implements Runnable { ...@@ -66,7 +67,7 @@ public class UploadTask implements Runnable {
deviceLogService.save(deviceLogEntity); deviceLogService.save(deviceLogEntity);
if (bool) { if (bool) {
WebSocketUtil.broadcast(SendToAllRequest.TYPE, new SendToAllRequest().setContent(JSON.toJSONString(deviceEntity))); // WebSocketUtil.broadcast(SendToAllRequest.TYPE, new SendToAllRequest().setContent(JSON.toJSONString(deviceEntity)));
} }
} else { } else {
...@@ -93,7 +94,7 @@ public class UploadTask implements Runnable { ...@@ -93,7 +94,7 @@ public class UploadTask implements Runnable {
deviceLogEntity.setContent(JSONObject.toJSONString(req)); deviceLogEntity.setContent(JSONObject.toJSONString(req));
deviceLogEntity.setCreateTime(new Date()); deviceLogEntity.setCreateTime(new Date());
deviceLogService.save(deviceLogEntity); deviceLogService.save(deviceLogEntity);
WebSocketUtil.broadcast(SendToAllRequest.TYPE, new SendToAllRequest().setContent(JSON.toJSONString(deviceEntity))); // WebSocketUtil.broadcast(SendToAllRequest.TYPE, new SendToAllRequest().setContent(JSON.toJSONString(deviceEntity)));
} }
} catch (Exception e) { } catch (Exception e) {
log.error("异常:" ,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