|
|
@@ -114,7 +114,7 @@ public class IotServiceImpl extends SuperService {
|
|
|
|
|
|
IotTemplate temp = iotTemplateDao.findTopByNameAndIotDataType(param.getName(), IotDataType.IotTemplate);
|
|
|
if (StringUtils.isNotEmpty(param.getId())) {
|
|
|
- // 编辑
|
|
|
+ // 编辑 (只能编辑名称和备注)
|
|
|
template = iotTemplateDao.findTopById(param.getId());
|
|
|
if (ObjectUtils.isEmpty(template)) {
|
|
|
return ResultContent.buildFail(String.format(ResultMessage.DATA_NOT_EXIST, param.getId()));
|
|
|
@@ -463,30 +463,36 @@ public class IotServiceImpl extends SuperService {
|
|
|
String iotTopic = iotMain.getIotTopic();
|
|
|
// 响应的topic
|
|
|
String replyIotTopic = iotMain.getReplyIotTopic();
|
|
|
+ if (StringUtils.isEmpty(iotTopic)) {
|
|
|
+ iotTopic = "";
|
|
|
+ }
|
|
|
+ if (StringUtils.isEmpty(replyIotTopic)) {
|
|
|
+ replyIotTopic = "";
|
|
|
+ }
|
|
|
|
|
|
+ // 消息topic
|
|
|
String realIotTopic = iotTopic;
|
|
|
String replyRealIotTopic = replyIotTopic;
|
|
|
- if (StringUtils.isNotEmpty(iotTopic)) {
|
|
|
- realIotTopic = realIotTopic.replaceAll(Pattern.quote("${deviceId}"), deviceId);
|
|
|
- }
|
|
|
- if (StringUtils.isNotEmpty(replyIotTopic)) {
|
|
|
- replyRealIotTopic = replyRealIotTopic.replaceAll(Pattern.quote("${deviceId}"), deviceId);
|
|
|
- }
|
|
|
+
|
|
|
+ realIotTopic = realIotTopic.replaceAll(Pattern.quote("${deviceId}"), deviceId);
|
|
|
+ replyRealIotTopic = replyRealIotTopic.replaceAll(Pattern.quote("${deviceId}"), deviceId);
|
|
|
|
|
|
DeviceInfo deviceInfo = deviceInfoDao.findTopByDeviceId(deviceId);
|
|
|
if (ObjectUtils.isNotEmpty(deviceInfo)) {
|
|
|
GateWay2Device gateWay2Device = gateWay2DeviceDao.findTopByDeviceInfoOrderByUpdateTimeDesc(deviceInfo);
|
|
|
if (ObjectUtils.isNotEmpty(gateWay2Device)) {
|
|
|
String gateWayId = gateWay2Device.getGateWayInfo().getDeviceId();
|
|
|
- if (StringUtils.isNotEmpty(iotTopic)) {
|
|
|
- realIotTopic = realIotTopic.replaceAll(Pattern.quote("${gateWayId}"), gateWayId);
|
|
|
- }
|
|
|
- if (StringUtils.isNotEmpty(replyRealIotTopic)) {
|
|
|
- replyRealIotTopic = replyRealIotTopic.replaceAll(Pattern.quote("${gateWayId}"), gateWayId);
|
|
|
- }
|
|
|
+ realIotTopic = realIotTopic.replaceAll(Pattern.quote("${gateWayId}"), gateWayId);
|
|
|
+ replyRealIotTopic = replyRealIotTopic.replaceAll(Pattern.quote("${gateWayId}"), gateWayId);
|
|
|
iotMain.setGateWayId(gateWayId);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ if (deviceInfo.getDeviceCategory() == DeviceCategory.GW) {
|
|
|
+ realIotTopic = realIotTopic.replaceAll(Pattern.quote("${gateWayId}"), deviceInfo.getDeviceId());
|
|
|
+ replyRealIotTopic = replyRealIotTopic.replaceAll(Pattern.quote("${gateWayId}"), deviceInfo.getDeviceId());
|
|
|
+ }
|
|
|
+
|
|
|
iotMain.setRealIotTopic(realIotTopic);
|
|
|
iotMain.setReplyRealIotTopic(replyRealIotTopic);
|
|
|
}
|
|
|
@@ -547,9 +553,7 @@ public class IotServiceImpl extends SuperService {
|
|
|
public ResultContent<Page<IotMainModel>> pageIotMain(Pageable pageable, IotMainSearch param) {
|
|
|
initSearchParam(param);
|
|
|
// 从物模型查看 或 从产品查看
|
|
|
- if (StringUtils.isEmpty(param.getIotTemplateId())
|
|
|
- && StringUtils.isEmpty(param.getIotThingId())
|
|
|
- && StringUtils.isEmpty(param.getDeviceId())) {
|
|
|
+ if (StringUtils.isEmpty(param.getIotTemplateId()) && StringUtils.isEmpty(param.getIotThingId()) && StringUtils.isEmpty(param.getDeviceId())) {
|
|
|
return ResultContent.buildFail("iotTemplateId和iotThingId和deviceId不能同时为空");
|
|
|
}
|
|
|
Page<IotMain> page = iotMainDao.page(pageable, param);
|