|
|
@@ -242,6 +242,7 @@ public class DeviceInfoService {
|
|
|
return ResultContent.buildFail(String.format(ResultMessage.DATA_NOT_EXIST, param.getId()));
|
|
|
}
|
|
|
deviceInfo.setState(param.getState());
|
|
|
+ updateDeviceOnLineStateByState(deviceInfo);
|
|
|
deviceInfoDao.save(deviceInfo);
|
|
|
|
|
|
// 通知设备在线状态变化
|
|
|
@@ -256,6 +257,18 @@ public class DeviceInfoService {
|
|
|
return ResultContent.buildSuccess();
|
|
|
}
|
|
|
|
|
|
+ private void updateDeviceOnLineStateByState(DeviceInfo deviceInfo) {
|
|
|
+ if (deviceInfo != null) {
|
|
|
+ if (deviceInfo.getState() == DeviceState.Enable) {
|
|
|
+
|
|
|
+ } else if (deviceInfo.getState() == DeviceState.Disable) {
|
|
|
+ deviceInfo.setOnLineState(OnLineState.Disable);
|
|
|
+ } else if (deviceInfo.getState() == DeviceState.Cancel) {
|
|
|
+ deviceInfo.setOnLineState(OnLineState.Cancel);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 测试设备的连接时间
|
|
|
*
|
|
|
@@ -299,6 +312,9 @@ public class DeviceInfoService {
|
|
|
if (ObjectUtils.isEmpty(deviceInfo)) {
|
|
|
return ResultContent.buildFail(String.format("设备ID不存在:%s", deviceId));
|
|
|
}
|
|
|
+ if (deviceInfo.getState() != DeviceState.Cancel) {
|
|
|
+ return ResultContent.buildFail("设备未注销,不能删除");
|
|
|
+ }
|
|
|
deviceInfo.setIsDelete(Boolean.TRUE);
|
|
|
deviceInfoDao.save(deviceInfo);
|
|
|
|
|
|
@@ -328,6 +344,7 @@ public class DeviceInfoService {
|
|
|
return ResultContent.buildFail(String.format("设备ID不存在:%s", deviceId));
|
|
|
}
|
|
|
deviceInfo.setState(DeviceState.Cancel);
|
|
|
+ updateDeviceOnLineStateByState(deviceInfo);
|
|
|
deviceInfoDao.save(deviceInfo);
|
|
|
|
|
|
// 更新设备信息
|