Commit 55c7d33d authored by 赵啸非's avatar 赵啸非

添加设备上线下线通知

parent ad20dfa4
......@@ -59,6 +59,12 @@ public class DeviceCallbackController {
case STOP:
deviceStop(req);
break;
case ONLINE:
deviceOnline(req);
break;
case OFFLINE:
deviceOffline(req);
break;
}
} catch (Exception e) {
log.error("接收数据失败", e);
......@@ -105,7 +111,7 @@ public class DeviceCallbackController {
if (ObjectUtils.isEmpty(deviceEntity)) {
//不存在设备 则新增
this.deviceAdd(req);
}else{
} else {
log.info("设备更新~");
deviceEntity.setDeviceName(req.getDeviceName());
deviceEntity.setDeviceCode(req.getDeviceCode());
......@@ -175,6 +181,29 @@ public class DeviceCallbackController {
deviceService.update(deviceEntity);
}
private void deviceOnline(DeviceReq req) throws AppException {
log.info("【设备上线】【请求体】--> " + JSONObject.toJSONString(req));
DeviceEntity deviceEntity = checkDeviceExist(req);
deviceEntity.setDeviceStatus(DeviceStatusEnum.在线.getValue());
deviceEntity.setUpdateTime(new Date());
deviceEntity.setUpdateUserId(1L);
deviceEntity.setUpdateTime(new Date());
deviceEntity.setUpdateUserId(1L);
deviceService.update(deviceEntity);
}
private void deviceOffline(DeviceReq req) throws AppException {
log.info("【设备离线】【请求体】--> " + JSONObject.toJSONString(req));
DeviceEntity deviceEntity = checkDeviceExist(req);
deviceEntity.setDeviceStatus(DeviceStatusEnum.离线.getValue());
deviceEntity.setUpdateTime(new Date());
deviceEntity.setUpdateUserId(1L);
deviceEntity.setUpdateTime(new Date());
deviceEntity.setUpdateUserId(1L);
deviceService.update(deviceEntity);
}
private DeviceEntity checkDeviceExist(DeviceReq req) {
if (ObjectUtils.isEmpty(req.getDeviceCode())) {
throw new AppException(DEVICE_CODE_IS_EMPTY, DEVICE_CODE_IS_EMPTY_CONTENT);
......
......@@ -188,8 +188,6 @@ public class DeviceController extends BaseCRUDJsonBodyMappingController<DeviceSe
condition.setDeviceId(entity.getId());
roomDeviceService.getDao().delete(condition);
}
}
private String getToken() {
......
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