|
@@ -2,12 +2,14 @@ package com.zswl.dataservice.service.iot;
|
|
|
|
|
|
|
|
import ch.qos.logback.core.model.NamedModel;
|
|
import ch.qos.logback.core.model.NamedModel;
|
|
|
import com.zswl.dataservice.dao.UserDao;
|
|
import com.zswl.dataservice.dao.UserDao;
|
|
|
|
|
+import com.zswl.dataservice.dao.iot.IotDeviceDataDao;
|
|
|
import com.zswl.dataservice.dao.iot.IotMainDao;
|
|
import com.zswl.dataservice.dao.iot.IotMainDao;
|
|
|
import com.zswl.dataservice.dao.iot.IotTemplateDao;
|
|
import com.zswl.dataservice.dao.iot.IotTemplateDao;
|
|
|
import com.zswl.dataservice.dao.iot.IotTopicDao;
|
|
import com.zswl.dataservice.dao.iot.IotTopicDao;
|
|
|
import com.zswl.dataservice.dao.mqtt.DeviceInfoDao;
|
|
import com.zswl.dataservice.dao.mqtt.DeviceInfoDao;
|
|
|
import com.zswl.dataservice.dao.mqtt.GateWay2DeviceDao;
|
|
import com.zswl.dataservice.dao.mqtt.GateWay2DeviceDao;
|
|
|
import com.zswl.dataservice.dataConfig.ResultMessage;
|
|
import com.zswl.dataservice.dataConfig.ResultMessage;
|
|
|
|
|
+import com.zswl.dataservice.domain.iot.IotDeviceData;
|
|
|
import com.zswl.dataservice.domain.iot.IotMain;
|
|
import com.zswl.dataservice.domain.iot.IotMain;
|
|
|
import com.zswl.dataservice.domain.iot.IotTemplate;
|
|
import com.zswl.dataservice.domain.iot.IotTemplate;
|
|
|
import com.zswl.dataservice.domain.iot.IotTopic;
|
|
import com.zswl.dataservice.domain.iot.IotTopic;
|
|
@@ -62,8 +64,13 @@ public class IotServiceImpl extends SuperService {
|
|
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
|
DeviceInfoDao deviceInfoDao;
|
|
DeviceInfoDao deviceInfoDao;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
private GateWay2DeviceDao gateWay2DeviceDao;
|
|
private GateWay2DeviceDao gateWay2DeviceDao;
|
|
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ IotDeviceDataDao iotDeviceDataDao;
|
|
|
|
|
+
|
|
|
//----------------------------- 模版 start----------------------------
|
|
//----------------------------- 模版 start----------------------------
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -408,13 +415,24 @@ public class IotServiceImpl extends SuperService {
|
|
|
return ResultContent.buildSuccess(toModel(entity));
|
|
return ResultContent.buildSuccess(toModel(entity));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 物模型 结构查询
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param pageable
|
|
|
|
|
+ * @param param
|
|
|
|
|
+ * @return
|
|
|
|
|
+ */
|
|
|
public ResultContent<Page<IotMainModel>> pageIotMain(Pageable pageable, IotMainSearch param) {
|
|
public ResultContent<Page<IotMainModel>> pageIotMain(Pageable pageable, IotMainSearch param) {
|
|
|
initSearchParam(param);
|
|
initSearchParam(param);
|
|
|
if (StringUtils.isEmpty(param.getIotTemplateId())) {
|
|
if (StringUtils.isEmpty(param.getIotTemplateId())) {
|
|
|
return ResultContent.buildFail("iotTemplateId不能为空");
|
|
return ResultContent.buildFail("iotTemplateId不能为空");
|
|
|
}
|
|
}
|
|
|
Page<IotMain> page = iotMainDao.page(pageable, param);
|
|
Page<IotMain> page = iotMainDao.page(pageable, param);
|
|
|
- return ResultContent.buildSuccess(PageEntityUtil.toPageModel(page, this::toModel));
|
|
|
|
|
|
|
+ if (param.getFunctionType() != null && param.getFunctionType() == FunctionType.Attribute) {
|
|
|
|
|
+ return ResultContent.buildSuccess(PageEntityUtil.toPageModel(page, this::toAttributeModel));
|
|
|
|
|
+ } else {
|
|
|
|
|
+ return ResultContent.buildSuccess(PageEntityUtil.toPageModel(page, this::toModel));
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -452,6 +470,12 @@ public class IotServiceImpl extends SuperService {
|
|
|
return model;
|
|
return model;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * IOTMain模型
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param entity
|
|
|
|
|
+ * @return
|
|
|
|
|
+ */
|
|
|
public IotMainModel toModel(IotMain entity) {
|
|
public IotMainModel toModel(IotMain entity) {
|
|
|
IotMainModel model = null;
|
|
IotMainModel model = null;
|
|
|
if (ObjectUtils.isNotEmpty(entity)) {
|
|
if (ObjectUtils.isNotEmpty(entity)) {
|
|
@@ -461,5 +485,26 @@ public class IotServiceImpl extends SuperService {
|
|
|
return model;
|
|
return model;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 属性 类型的model,包含值
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param entity
|
|
|
|
|
+ * @return
|
|
|
|
|
+ */
|
|
|
|
|
+ public IotMainAttributeModel toAttributeModel(IotMain entity) {
|
|
|
|
|
+ IotMainAttributeModel model = null;
|
|
|
|
|
+ if (ObjectUtils.isNotEmpty(entity)) {
|
|
|
|
|
+ model = new IotMainAttributeModel();
|
|
|
|
|
+ BeanUtils.copyProperties(entity, model);
|
|
|
|
|
+ IotDeviceData iotDeviceData = iotDeviceDataDao.findTopByIotMain(entity);
|
|
|
|
|
+ if (ObjectUtils.isNotEmpty(iotDeviceData)) {
|
|
|
|
|
+ IotDeviceDataModel deviceData = new IotDeviceDataModel();
|
|
|
|
|
+ BeanUtils.copyProperties(iotDeviceData, deviceData);
|
|
|
|
|
+ model.setDeviceData(deviceData);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ return model;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
|
|
|
}
|
|
}
|