|
|
@@ -8,10 +8,7 @@ import com.zswl.dataservice.domain.iot.IotTemplate;
|
|
|
import com.zswl.dataservice.domain.mqtt.DeviceInfo;
|
|
|
import com.zswl.dataservice.domain.mqtt.ProjectInfo;
|
|
|
import com.zswl.dataservice.model.iot.IotMainModel;
|
|
|
-import com.zswl.dataservice.model.mqtt.DeviceInfoAddParam;
|
|
|
-import com.zswl.dataservice.model.mqtt.DeviceInfoModel;
|
|
|
-import com.zswl.dataservice.model.mqtt.DeviceInfoSearchParam;
|
|
|
-import com.zswl.dataservice.model.mqtt.DeviceInfoUpdateRemark;
|
|
|
+import com.zswl.dataservice.model.mqtt.*;
|
|
|
import com.zswl.dataservice.service.iot.IotServiceImpl;
|
|
|
import com.zswl.dataservice.type.FunctionType;
|
|
|
import com.zswl.dataservice.utils.bean.BeanUtils;
|
|
|
@@ -56,7 +53,7 @@ public class DeviceInfoService {
|
|
|
DeviceSyncFullCardService deviceSyncFullCardService;
|
|
|
|
|
|
/**
|
|
|
- * 添加-编辑设备
|
|
|
+ * 添加-编辑设备 (基础信息)
|
|
|
*
|
|
|
* @param param
|
|
|
* @return
|
|
|
@@ -69,40 +66,18 @@ public class DeviceInfoService {
|
|
|
param.setId(null);
|
|
|
}
|
|
|
BeanUtils.copyProperties(param, deviceInfo, "id");
|
|
|
+
|
|
|
// 项目
|
|
|
- ProjectInfo projectInfo = null;
|
|
|
- if (StringUtils.isNotEmpty(param.getProjectInfoOid())) {
|
|
|
- projectInfo = projectInfoDao.findTopByCode(param.getProjectInfoOid());
|
|
|
+ if (StringUtils.isNotEmpty(param.getProjectInfoCode())) {
|
|
|
+ ProjectInfo projectInfo = projectInfoDao.findTopByCode(param.getProjectInfoCode());
|
|
|
+ deviceInfo.setProjectInfo(projectInfo);
|
|
|
}
|
|
|
- deviceInfo.setProjectInfo(projectInfo);
|
|
|
|
|
|
- // 模版
|
|
|
- IotTemplate iotTemplate = null;
|
|
|
- if (StringUtils.isNotEmpty(param.getIotTemplateId())) {
|
|
|
- iotTemplate = iotTemplateDao.findTopById(param.getIotTemplateId());
|
|
|
- }
|
|
|
- deviceInfo.setIotTemplate(iotTemplate);
|
|
|
deviceInfoDao.save(deviceInfo);
|
|
|
operationLogsService.addLogs(String.format("添加了设备;%s", deviceInfo.getDeviceName()), LogsLevel.Middle, deviceInfo);
|
|
|
return ResultContent.buildSuccess(deviceInfo);
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 初始设备
|
|
|
- *
|
|
|
- * @param param
|
|
|
- * @return
|
|
|
- */
|
|
|
- public ResultContent<DeviceInfo> initDeviceInfo(DeviceInfoAddParam param) {
|
|
|
- DeviceInfo deviceInfo = deviceInfoDao.findTopByDeviceId(param.getDeviceId());
|
|
|
- if (ObjectUtils.isEmpty(deviceInfo)) {
|
|
|
- ResultContent<DeviceInfo> resultContent = addDeviceInfo(param);
|
|
|
- deviceInfo = resultContent.getContent();
|
|
|
- operationLogsService.addLogs(String.format("添加了设备;%s", deviceInfo.getDeviceName()), LogsLevel.Middle, deviceInfo);
|
|
|
- }
|
|
|
- return ResultContent.buildSuccess(deviceInfo);
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* 设备列表
|
|
|
*
|
|
|
@@ -148,6 +123,26 @@ public class DeviceInfoService {
|
|
|
return ResultContent.buildSuccess();
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 编辑设备关联的项目信息
|
|
|
+ *
|
|
|
+ * @param param
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public ResultContent updateProject(DeviceInfoUpdateRemark param) {
|
|
|
+ DeviceInfo deviceInfo = deviceInfoDao.findTopById(param.getId());
|
|
|
+ if (ObjectUtils.isEmpty(deviceInfo)) {
|
|
|
+ return ResultContent.buildFail(String.format(ResultMessage.DATA_NOT_EXIST, param.getId()));
|
|
|
+ }
|
|
|
+ ProjectInfo projectInfo = projectInfoDao.findTopByCode(param.getProjectCode());
|
|
|
+ if (ObjectUtils.isEmpty(projectInfo)) {
|
|
|
+ return ResultContent.buildFail(String.format("项目不存在:", param.getId()));
|
|
|
+ }
|
|
|
+ deviceInfo.setProjectInfo(projectInfo);
|
|
|
+ deviceInfoDao.save(deviceInfo);
|
|
|
+ return ResultContent.buildSuccess();
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 编辑设备关联的模版
|
|
|
*
|
|
|
@@ -212,7 +207,6 @@ public class DeviceInfoService {
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* 删除设备
|
|
|
*
|