|
|
@@ -1,12 +1,12 @@
|
|
|
package com.zhongshu.iot.server.core.service.device;
|
|
|
|
|
|
+import com.github.microservice.busInfoModel.device.DeviceInfoModel;
|
|
|
import com.github.microservice.net.ResultContent;
|
|
|
import com.github.microservice.types.FunctionType;
|
|
|
import com.github.microservice.types.deviceUse.DeviceState;
|
|
|
import com.github.microservice.types.deviceUse.OnLineState;
|
|
|
import com.zhongshu.iot.client.model.iot.IotMainModel;
|
|
|
import com.zhongshu.iot.client.model.mqtt.DeviceInfoAddParam;
|
|
|
-import com.github.microservice.busInfoModel.device.DeviceInfoModel;
|
|
|
import com.zhongshu.iot.client.model.mqtt.DeviceInfoSearchParam;
|
|
|
import com.zhongshu.iot.client.model.mqtt.DeviceInfoUpdateRemark;
|
|
|
import com.zhongshu.iot.client.type.IotDataType;
|
|
|
@@ -100,6 +100,8 @@ public class DeviceInfoService {
|
|
|
// 编辑
|
|
|
deviceInfo = temp;
|
|
|
param.setId(null);
|
|
|
+
|
|
|
+ // 如果已删除的
|
|
|
if (deviceInfo.getIsDelete() != null && deviceInfo.getIsDelete()) {
|
|
|
deviceInfo.setIsDelete(Boolean.FALSE);
|
|
|
deviceInfo.setState(DeviceState.Enable);
|
|
|
@@ -111,6 +113,7 @@ public class DeviceInfoService {
|
|
|
}
|
|
|
BeanUtils.copyProperties(param, deviceInfo, "id");
|
|
|
|
|
|
+ // 最近的上线时间
|
|
|
deviceInfo.setLastOnlineTime(System.currentTimeMillis());
|
|
|
deviceInfo.setLastOnlineTimeStr(DateUtils.paresTime(System.currentTimeMillis(), DateUtils.FORMAT_LONG));
|
|
|
deviceInfo.setOnLineState(OnLineState.OnLine);
|
|
|
@@ -141,7 +144,7 @@ public class DeviceInfoService {
|
|
|
// 日志
|
|
|
operationLogsService.addLogs(String.format("添加了设备;%s", finalDeviceInfo.getDeviceName()), LogsLevel.Middle, finalDeviceInfo);
|
|
|
|
|
|
- // 跟新账号的绑定设备数量
|
|
|
+ // 更新账号的绑定设备数量
|
|
|
gateWayUserInfoService.updateBindNumber(finalDeviceInfo.getMqttUserName());
|
|
|
|
|
|
// 同步设备权限
|
|
|
@@ -403,7 +406,7 @@ public class DeviceInfoService {
|
|
|
if (StringUtils.isNotEmpty(deviceId)) {
|
|
|
deviceInfo = deviceInfoDao.findTopByDeviceId(deviceId);
|
|
|
}
|
|
|
- return deviceCanUse(deviceInfo);
|
|
|
+ return deviceCanUse(deviceInfo, deviceId);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -412,9 +415,9 @@ public class DeviceInfoService {
|
|
|
* @param deviceInfo
|
|
|
* @return
|
|
|
*/
|
|
|
- public ResultContent deviceCanUse(DeviceInfo deviceInfo) {
|
|
|
+ public ResultContent deviceCanUse(DeviceInfo deviceInfo, String deviceId) {
|
|
|
if (ObjectUtils.isEmpty(deviceInfo)) {
|
|
|
- return ResultContent.buildFail("设备未找到");
|
|
|
+ return ResultContent.buildFail(String.format("设备未找到:%s", deviceId));
|
|
|
}
|
|
|
if (deviceInfo.getState() != DeviceState.Enable) {
|
|
|
return ResultContent.buildFail(String.format("设备状态不可用:%s", deviceInfo.getState().getRemark()));
|