Commit 82403c41 authored by 赵啸非's avatar 赵啸非

添加评价器事件地址

parent f0929f26
......@@ -203,14 +203,7 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D
messageProducer.queueAddAndBinds(QueueKey.DEFAULT_EXCHANGE, Constant.DOWN_TOPIC + deviceCode, Constant.DOWN_TOPIC + deviceCode);
//订阅上行队列
container.addQueueNames(Constant.UPLOAD_TOPIC + deviceCode);
// registerRabbitQueue(deviceEntity, platformEntity, productEntity);
//
// TbQueueConsumer<TbQueueMsg> mainConsumer = consumerService.getMainConsumer();
// String exchangeName = platformEntity.getPlatformSn() + Constant.EXCHANGE_SPLIT + productEntity.getProductCode();
// TopicPartitionInfo topicPartitionInfo = new TopicPartitionInfo(Constant.UPLOAD_TOPIC + deviceCode, null, exchangeName);
// Set<TopicPartitionInfo> topicPartitionInfos = new HashSet<>();
// topicPartitionInfos.add(topicPartitionInfo);
// mainConsumer.subscribe(topicPartitionInfos);
//新增设备通知第三方平台,先新增后激活
sendThirdParty(deviceEntity, productEntity, platformEntity, DeviceMethodEnum.ADD);
sendThirdParty(deviceEntity, productEntity, platformEntity, DeviceMethodEnum.ACTIVE);
......@@ -259,6 +252,7 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D
@Override
protected void saveAfter(DeviceEntity entity, Context context) throws AppException {
super.saveAfter(entity, context);
PlatformEntity platformEntity = platformService.get(entity.getPlatformId());
ProductEntity productEntity = productService.get(entity.getProductId());
if (!ObjectUtils.isEmpty(platformEntity) && !ObjectUtils.isEmpty(productEntity)) {
......@@ -267,11 +261,11 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D
} else {
throw new AppException("产品或平台不存在!");
}
super.saveAfter(entity, context);
}
@Override
protected void updateAfter(DeviceEntity entity, Context context) throws AppException {
super.updateAfter(entity, context);
PlatformEntity platformEntity = platformService.get(entity.getPlatformId());
ProductEntity productEntity = productService.get(entity.getProductId());
if (!ObjectUtils.isEmpty(platformEntity) && !ObjectUtils.isEmpty(productEntity)) {
......@@ -281,11 +275,9 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D
messageProducer.queueAddAndBinds(QueueKey.DEFAULT_EXCHANGE, Constant.UPLOAD_TOPIC + entity.getDeviceCode(), Constant.UPLOAD_TOPIC + entity.getDeviceCode());
messageProducer.queueAddAndBinds(QueueKey.DEFAULT_EXCHANGE, Constant.DOWN_TOPIC + entity.getDeviceCode(), Constant.DOWN_TOPIC + entity.getDeviceCode());
//registerRabbitQueue(entity, platformEntity, productEntity);
sendThirdParty(entity, productEntity, platformEntity, DeviceMethodEnum.UPDATE);
}
}
super.updateAfter(entity, context);
}
@Override
......@@ -583,6 +575,7 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D
@Override
protected void saveBefore(DeviceEntity entity, Context context) throws AppException {
super.saveBefore(entity, context);
if (ObjectUtils.isEmpty(entity.getDeviceCode())) {
throw new AppException("设备编码不能为空!");
}
......@@ -657,15 +650,15 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D
sendThirdParty(entity, productEntity, platformEntity, DeviceMethodEnum.ACTIVE);
}
updateDeviceHomeUrl(entity);
super.saveBefore(entity, context);
}
@Override
protected void updateBefore(DeviceEntity entity, Context context) throws AppException {
super.updateBefore(entity, context);
ProductEntity productEntity = productService.get(entity.getProductId(), context);
entity.setProductCode(productEntity.getProductCode());
updateDeviceHomeUrl(entity);
super.updateBefore(entity, context);
}
private void updateDeviceHomeUrl(DeviceEntity entity) {
......
......@@ -89,7 +89,7 @@ POST {{baseUrl}}/api/register
Content-Type: application/json
{
"deviceCode": "a109"
"deviceCode": "18-93-7F-C0-AD-B5"
}
> {%
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment