|
@@ -23,6 +23,7 @@ import com.zhongshu.iot.server.core.service.iot.IotServiceImpl;
|
|
|
import com.zhongshu.iot.server.core.service.iot.IotThingService;
|
|
import com.zhongshu.iot.server.core.service.iot.IotThingService;
|
|
|
import com.zhongshu.iot.server.core.service.sync.DeviceSyncFullCardService;
|
|
import com.zhongshu.iot.server.core.service.sync.DeviceSyncFullCardService;
|
|
|
import com.zhongshu.iot.server.core.service.user.OperationLogsService;
|
|
import com.zhongshu.iot.server.core.service.user.OperationLogsService;
|
|
|
|
|
+import com.zhongshu.iot.server.core.util.CommonUtil;
|
|
|
import com.zhongshu.iot.server.core.util.DateUtils;
|
|
import com.zhongshu.iot.server.core.util.DateUtils;
|
|
|
import com.zhongshu.iot.server.core.util.bean.BeanUtils;
|
|
import com.zhongshu.iot.server.core.util.bean.BeanUtils;
|
|
|
import com.zhongshu.iot.server.core.util.page.PageEntityUtil;
|
|
import com.zhongshu.iot.server.core.util.page.PageEntityUtil;
|
|
@@ -99,6 +100,10 @@ public class DeviceInfoService {
|
|
|
// 编辑
|
|
// 编辑
|
|
|
deviceInfo = temp;
|
|
deviceInfo = temp;
|
|
|
param.setId(null);
|
|
param.setId(null);
|
|
|
|
|
+ if (deviceInfo.getIsDelete() != null && deviceInfo.getIsDelete()) {
|
|
|
|
|
+ deviceInfo.setIsDelete(Boolean.FALSE);
|
|
|
|
|
+ deviceInfo.setState(DeviceState.Enable);
|
|
|
|
|
+ }
|
|
|
} else {
|
|
} else {
|
|
|
// 添加
|
|
// 添加
|
|
|
deviceInfo.setActivityTime(System.currentTimeMillis());
|
|
deviceInfo.setActivityTime(System.currentTimeMillis());
|
|
@@ -130,8 +135,9 @@ public class DeviceInfoService {
|
|
|
|
|
|
|
|
DeviceInfo finalDeviceInfo = deviceInfo;
|
|
DeviceInfo finalDeviceInfo = deviceInfo;
|
|
|
CompletableFuture.runAsync(() -> {
|
|
CompletableFuture.runAsync(() -> {
|
|
|
-
|
|
|
|
|
|
|
+ // 设备关联的物模型创建或更新
|
|
|
iotThingService.initAutoThingByDevice(finalDeviceInfo);
|
|
iotThingService.initAutoThingByDevice(finalDeviceInfo);
|
|
|
|
|
+
|
|
|
// 日志
|
|
// 日志
|
|
|
operationLogsService.addLogs(String.format("添加了设备;%s", finalDeviceInfo.getDeviceName()), LogsLevel.Middle, finalDeviceInfo);
|
|
operationLogsService.addLogs(String.format("添加了设备;%s", finalDeviceInfo.getDeviceName()), LogsLevel.Middle, finalDeviceInfo);
|
|
|
|
|
|
|
@@ -156,6 +162,12 @@ public class DeviceInfoService {
|
|
|
* @return
|
|
* @return
|
|
|
*/
|
|
*/
|
|
|
public ResultContent<Page<DeviceInfoModel>> pageDevice(Pageable pageable, DeviceInfoSearchParam param) {
|
|
public ResultContent<Page<DeviceInfoModel>> pageDevice(Pageable pageable, DeviceInfoSearchParam param) {
|
|
|
|
|
+ if (!CommonUtil.longIsEmpty(param.getStartLastOnlineTime())) {
|
|
|
|
|
+ param.setStartLastOnlineTime(DateUtils.getDayStartTime(param.getStartLastOnlineTime()));
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!CommonUtil.longIsEmpty(param.getEndLastOnlineTime())) {
|
|
|
|
|
+ param.setEndLastOnlineTime(DateUtils.getDayEndTime(param.getEndLastOnlineTime()));
|
|
|
|
|
+ }
|
|
|
Page<DeviceInfo> page = deviceInfoDao.page(pageable, param);
|
|
Page<DeviceInfo> page = deviceInfoDao.page(pageable, param);
|
|
|
return ResultContent.buildSuccess(PageEntityUtil.toPageModel(page, this::toModel));
|
|
return ResultContent.buildSuccess(PageEntityUtil.toPageModel(page, this::toModel));
|
|
|
}
|
|
}
|
|
@@ -419,7 +431,11 @@ public class DeviceInfoService {
|
|
|
DeviceInfoModel deviceInfoModel = new DeviceInfoModel();
|
|
DeviceInfoModel deviceInfoModel = new DeviceInfoModel();
|
|
|
if (ObjectUtils.isNotEmpty(deviceInfo)) {
|
|
if (ObjectUtils.isNotEmpty(deviceInfo)) {
|
|
|
BeanUtils.copyProperties(deviceInfo, deviceInfoModel);
|
|
BeanUtils.copyProperties(deviceInfo, deviceInfoModel);
|
|
|
|
|
+ // 分组信息
|
|
|
deviceInfoModel.setProjectInfo(projectInfoService.toModel(deviceInfo.getProjectInfo()));
|
|
deviceInfoModel.setProjectInfo(projectInfoService.toModel(deviceInfo.getProjectInfo()));
|
|
|
|
|
+
|
|
|
|
|
+ // 产品信息
|
|
|
|
|
+ deviceInfoModel.setIotTemplate(iotService.toSimpleModel(deviceInfo.getProductCode()));
|
|
|
}
|
|
}
|
|
|
return deviceInfoModel;
|
|
return deviceInfoModel;
|
|
|
}
|
|
}
|