Commit e38a012a authored by 赵啸非's avatar 赵啸非

修改平台获取方式为缓存方式

parent d99b0ba8
...@@ -82,8 +82,8 @@ public class CustomerKeyExpirationListener implements MessageListener { ...@@ -82,8 +82,8 @@ public class CustomerKeyExpirationListener implements MessageListener {
deviceService.putCache(deviceEntity.getId().toString(), deviceEntity); deviceService.putCache(deviceEntity.getId().toString(), deviceEntity);
log.info("deviceCode:{},deviceName:{}==>离线", deviceEntity.getDeviceCode(), deviceEntity.getDeviceName()); log.info("deviceCode:{},deviceName:{}==>离线", deviceEntity.getDeviceCode(), deviceEntity.getDeviceName());
// deviceService.update(deviceEntity); // deviceService.update(deviceEntity);
PlatformEntity platformEntity = platformService.get(deviceEntity.getPlatformId()); PlatformEntity platformEntity = platformService.getCache(deviceEntity.getPlatformId().toString());
ProductEntity productEntity = productService.get(deviceEntity.getProductId()); ProductEntity productEntity = productService.getCache(deviceEntity.getProductId().toString());
if (!ObjectUtils.isEmpty(platformEntity) && !ObjectUtils.isEmpty(productEntity)) { if (!ObjectUtils.isEmpty(platformEntity) && !ObjectUtils.isEmpty(productEntity)) {
//通知第三方平台 //通知第三方平台
deviceService.sendThirdParty(deviceEntity, productEntity, platformEntity, DeviceMethodEnum.OFFLINE); deviceService.sendThirdParty(deviceEntity, productEntity, platformEntity, DeviceMethodEnum.OFFLINE);
......
...@@ -86,7 +86,7 @@ public class DirectDynamicListener implements MessageListener { ...@@ -86,7 +86,7 @@ public class DirectDynamicListener implements MessageListener {
// deviceService.update(deviceEntity); // deviceService.update(deviceEntity);
deviceService.putCache(deviceEntity.getId().toString(),deviceEntity); deviceService.putCache(deviceEntity.getId().toString(),deviceEntity);
PlatformEntity platformEntity = platformService.get(deviceEntity.getPlatformId()); PlatformEntity platformEntity = platformService.getCache(deviceEntity.getPlatformId().toString());
ProductEntity productEntity = productService.get(deviceEntity.getProductId()); ProductEntity productEntity = productService.get(deviceEntity.getProductId());
if (!ObjectUtils.isEmpty(platformEntity) && !ObjectUtils.isEmpty(productEntity)) { if (!ObjectUtils.isEmpty(platformEntity) && !ObjectUtils.isEmpty(productEntity)) {
//新增设备通知第三方平台 //新增设备通知第三方平台
...@@ -110,7 +110,7 @@ public class DirectDynamicListener implements MessageListener { ...@@ -110,7 +110,7 @@ public class DirectDynamicListener implements MessageListener {
deviceLogService.save(deviceLogEntity); deviceLogService.save(deviceLogEntity);
} }
//获取exchange, //获取exchange,
PlatformEntity platformEntity = platformService.get(deviceEntity.getPlatformId()); PlatformEntity platformEntity = platformService.getCache(deviceEntity.getPlatformId().toString());
String phpInUrl = GlobalSysInfo.getParamValue(PARAM_SERVER_PHP_IN_HTTP_URL, "http://172.15.28.116:8090"); String phpInUrl = GlobalSysInfo.getParamValue(PARAM_SERVER_PHP_IN_HTTP_URL, "http://172.15.28.116:8090");
if (!Constant.MESSAGETYPE_HEARTBEAT.equalsIgnoreCase(messageType) if (!Constant.MESSAGETYPE_HEARTBEAT.equalsIgnoreCase(messageType)
......
...@@ -664,12 +664,12 @@ public class DeviceApiController { ...@@ -664,12 +664,12 @@ public class DeviceApiController {
DeviceEntity deviceEntity = deviceService.getExtCache(req.getDeviceCode()); DeviceEntity deviceEntity = deviceService.getExtCache(req.getDeviceCode());
if (!ObjectUtils.isEmpty(deviceEntity)) { if (!ObjectUtils.isEmpty(deviceEntity)) {
//将上报信息转发到mq中 //将上报信息转发到mq中
PlatformEntity platformEntity = platformService.get(deviceEntity.getPlatformId()); PlatformEntity platformEntity = platformService.getCache(deviceEntity.getPlatformId().toString());
if (ObjectUtils.isEmpty(platformEntity)) { if (ObjectUtils.isEmpty(platformEntity)) {
throw new AppException("当前设备未配置所属系统平台,请在后台配置后再激活!"); throw new AppException("当前设备未配置所属系统平台,请在后台配置后再激活!");
} }
// authInfo.setHost(platformEntity.getPlatformSn()); // authInfo.setHost(platformEntity.getPlatformSn());
ProductEntity productEntity = productService.get(deviceEntity.getProductId()); ProductEntity productEntity = productService.getCache(deviceEntity.getProductId().toString());
if (ObjectUtils.isEmpty(productEntity)) { if (ObjectUtils.isEmpty(productEntity)) {
throw new AppException("当前设备未配置所属产品,请在后台配置后再激活!"); throw new AppException("当前设备未配置所属产品,请在后台配置后再激活!");
} }
...@@ -769,7 +769,7 @@ public class DeviceApiController { ...@@ -769,7 +769,7 @@ public class DeviceApiController {
if (ObjectUtils.isEmpty(productEntity)) { if (ObjectUtils.isEmpty(productEntity)) {
throw new AppException(PRODUCT_IS_EMPTY, PRODUCT_IS_EMPTY_CONTENT); throw new AppException(PRODUCT_IS_EMPTY, PRODUCT_IS_EMPTY_CONTENT);
} }
PlatformEntity platformEntity = platformService.get(productEntity.getPlatformId()); PlatformEntity platformEntity = platformService.getCache(productEntity.getPlatformId().toString());
if (ObjectUtils.isEmpty(platformEntity)) { if (ObjectUtils.isEmpty(platformEntity)) {
throw new AppException(PLATFORM_IS_EMPTY, PLATFORM_IS_EMPTY_CONTENT); throw new AppException(PLATFORM_IS_EMPTY, PLATFORM_IS_EMPTY_CONTENT);
} }
...@@ -813,7 +813,7 @@ public class DeviceApiController { ...@@ -813,7 +813,7 @@ public class DeviceApiController {
throw new AppException(PRODUCT_IS_EMPTY, PRODUCT_IS_EMPTY_CONTENT); throw new AppException(PRODUCT_IS_EMPTY, PRODUCT_IS_EMPTY_CONTENT);
} }
PlatformEntity platformEntity = platformService.get(productEntity.getPlatformId()); PlatformEntity platformEntity = platformService.getCache(productEntity.getPlatformId().toString());
if (ObjectUtils.isEmpty(platformEntity)) { if (ObjectUtils.isEmpty(platformEntity)) {
throw new AppException(PLATFORM_IS_EMPTY, PLATFORM_IS_EMPTY_CONTENT); throw new AppException(PLATFORM_IS_EMPTY, PLATFORM_IS_EMPTY_CONTENT);
} }
......
...@@ -151,7 +151,7 @@ public class DemoApiController { ...@@ -151,7 +151,7 @@ public class DemoApiController {
if (!ObjectUtils.isEmpty(deviceEntity)) { if (!ObjectUtils.isEmpty(deviceEntity)) {
//将上报信息转发到mq中 //将上报信息转发到mq中
PlatformEntity platformEntity = platformService.get(deviceEntity.getPlatformId()); PlatformEntity platformEntity = platformService.getCache(deviceEntity.getPlatformId().toString());
if (ObjectUtils.isEmpty(platformEntity)) { if (ObjectUtils.isEmpty(platformEntity)) {
throw new AppException("当前设备未配置所属系统平台,请在后台配置后再激活!"); throw new AppException("当前设备未配置所属系统平台,请在后台配置后再激活!");
} }
......
...@@ -49,8 +49,8 @@ public class DeviceComsumersRegisterService implements IApplicationStartedServic ...@@ -49,8 +49,8 @@ public class DeviceComsumersRegisterService implements IApplicationStartedServic
deviceService.find(new DeviceEntity()) deviceService.find(new DeviceEntity())
.stream() .stream()
.filter(f -> !ObjectUtils.isEmpty(platformService.get(f.getPlatformId()))) .filter(f -> !ObjectUtils.isEmpty(platformService.getCache(f.getPlatformId().toString())))
.filter(f -> !ObjectUtils.isEmpty(productService.get(f.getProductId()))).forEach(item -> { .filter(f -> !ObjectUtils.isEmpty(productService.getCache(f.getProductId().toString()))).forEach(item -> {
String uploadQueue = Constant.UPLOAD_TOPIC + item.getDeviceCode(); String uploadQueue = Constant.UPLOAD_TOPIC + item.getDeviceCode();
String downQueue = Constant.DOWN_TOPIC + item.getDeviceCode(); String downQueue = Constant.DOWN_TOPIC + item.getDeviceCode();
messageProducer.queueAddAndBinds(QueueKey.DEFAULT_EXCHANGE, uploadQueue, uploadQueue); messageProducer.queueAddAndBinds(QueueKey.DEFAULT_EXCHANGE, uploadQueue, uploadQueue);
...@@ -59,8 +59,8 @@ public class DeviceComsumersRegisterService implements IApplicationStartedServic ...@@ -59,8 +59,8 @@ public class DeviceComsumersRegisterService implements IApplicationStartedServic
String[] queues = deviceService.find(new DeviceEntity()) String[] queues = deviceService.find(new DeviceEntity())
.stream() .stream()
.filter(f -> !ObjectUtils.isEmpty(platformService.get(f.getPlatformId()))) .filter(f -> !ObjectUtils.isEmpty(platformService.getCache(f.getPlatformId().toString())))
.filter(f -> !ObjectUtils.isEmpty(productService.get(f.getProductId()))) .filter(f -> !ObjectUtils.isEmpty(productService.getCache(f.getProductId().toString())))
.filter(f->!ObjectUtils.isEmpty(f.getDeviceCode())) .filter(f->!ObjectUtils.isEmpty(f.getDeviceCode()))
.map(item -> Constant.UPLOAD_TOPIC + item.getDeviceCode()) .map(item -> Constant.UPLOAD_TOPIC + item.getDeviceCode())
.toArray(String[]::new); .toArray(String[]::new);
......
...@@ -73,11 +73,11 @@ public class DeviceMsgComsumerStartedService implements IApplicationStartedServi ...@@ -73,11 +73,11 @@ public class DeviceMsgComsumerStartedService implements IApplicationStartedServi
//.status(StatusEnum.启用.getValue()) //.status(StatusEnum.启用.getValue())
) )
.stream() .stream()
.filter(f -> !ObjectUtils.isEmpty(platformService.get(f.getPlatformId()))) .filter(f -> !ObjectUtils.isEmpty(platformService.getCache(f.getPlatformId().toString())))
.filter(f -> !ObjectUtils.isEmpty(productService.get(f.getProductId()))) .filter(f -> !ObjectUtils.isEmpty(productService.getCache(f.getProductId().toString())))
.map(item -> { .map(item -> {
PlatformEntity platformEntity = platformService.get(item.getPlatformId()); PlatformEntity platformEntity = platformService.getCache(item.getPlatformId().toString());
ProductEntity productEntity = productService.get(item.getProductId()); ProductEntity productEntity = productService.getCache(item.getProductId().toString());
String exchangeName = platformEntity.getPlatformSn() + Constant.EXCHANGE_SPLIT + productEntity.getProductCode(); String exchangeName = platformEntity.getPlatformSn() + Constant.EXCHANGE_SPLIT + productEntity.getProductCode();
return new TopicPartitionInfo(Constant.UPLOAD_TOPIC + item.getDeviceCode(), null, exchangeName); return new TopicPartitionInfo(Constant.UPLOAD_TOPIC + item.getDeviceCode(), null, exchangeName);
} }
...@@ -169,8 +169,8 @@ public class DeviceMsgComsumerStartedService implements IApplicationStartedServi ...@@ -169,8 +169,8 @@ public class DeviceMsgComsumerStartedService implements IApplicationStartedServi
deviceEntity.setDeviceStatus(DeviceStatusEnum.在线.getValue()); deviceEntity.setDeviceStatus(DeviceStatusEnum.在线.getValue());
deviceService.update(deviceEntity); deviceService.update(deviceEntity);
PlatformEntity platformEntity = platformService.get(deviceEntity.getPlatformId()); PlatformEntity platformEntity = platformService.getCache(deviceEntity.getPlatformId().toString());
ProductEntity productEntity = productService.get(deviceEntity.getProductId()); ProductEntity productEntity = productService.getCache(deviceEntity.getProductId().toString());
if (!ObjectUtils.isEmpty(platformEntity) && !ObjectUtils.isEmpty(productEntity)) { if (!ObjectUtils.isEmpty(platformEntity) && !ObjectUtils.isEmpty(productEntity)) {
//新增设备通知第三方平台 //新增设备通知第三方平台
deviceService.sendThirdParty(deviceEntity, productEntity, platformEntity, DeviceMethodEnum.ONLINE); deviceService.sendThirdParty(deviceEntity, productEntity, platformEntity, DeviceMethodEnum.ONLINE);
...@@ -192,7 +192,7 @@ public class DeviceMsgComsumerStartedService implements IApplicationStartedServi ...@@ -192,7 +192,7 @@ public class DeviceMsgComsumerStartedService implements IApplicationStartedServi
deviceLogService.save(deviceLogEntity); deviceLogService.save(deviceLogEntity);
} }
//获取exchange, //获取exchange,
PlatformEntity platformEntity = platformService.get(deviceEntity.getPlatformId()); PlatformEntity platformEntity = platformService.getCache(deviceEntity.getPlatformId().toString());
String phpInUrl = GlobalSysInfo.getParamValue(PARAM_SERVER_PHP_IN_HTTP_URL, "http://172.15.28.116:8090"); String phpInUrl = GlobalSysInfo.getParamValue(PARAM_SERVER_PHP_IN_HTTP_URL, "http://172.15.28.116:8090");
if (!Constant.MESSAGETYPE_HEARTBEAT.equalsIgnoreCase(messageType) if (!Constant.MESSAGETYPE_HEARTBEAT.equalsIgnoreCase(messageType)
&& !ObjectUtils.isEmpty(platformEntity) && !ObjectUtils.isEmpty(platformEntity)
......
...@@ -39,8 +39,8 @@ public class RabbitMsgComsumerStartedService implements IApplicationStartedServi ...@@ -39,8 +39,8 @@ public class RabbitMsgComsumerStartedService implements IApplicationStartedServi
log.info("服务端消费消息服务开始.."); log.info("服务端消费消息服务开始..");
String[] queues = deviceService.find(new DeviceEntity()) String[] queues = deviceService.find(new DeviceEntity())
.stream() .stream()
.filter(f -> !ObjectUtils.isEmpty(platformService.get(f.getPlatformId()))) .filter(f -> !ObjectUtils.isEmpty(platformService.getCache(f.getPlatformId().toString())))
.filter(f -> !ObjectUtils.isEmpty(productService.get(f.getProductId()))) .filter(f -> !ObjectUtils.isEmpty(productService.getCache(f.getProductId().toString())))
.map(item -> Constant.UPLOAD_TOPIC + item.getDeviceCode()) .map(item -> Constant.UPLOAD_TOPIC + item.getDeviceCode())
.distinct() .distinct()
.toArray(String[]::new); .toArray(String[]::new);
......
...@@ -76,8 +76,8 @@ public class DeviceStatTaskImpl implements ITaskExcuteService { ...@@ -76,8 +76,8 @@ public class DeviceStatTaskImpl implements ITaskExcuteService {
log.info("修正设备数量:size:{}", deviceOfflineList.size()); log.info("修正设备数量:size:{}", deviceOfflineList.size());
deviceService.update(deviceOfflineList); deviceService.update(deviceOfflineList);
deviceOfflineList.forEach(deviceEntity -> { deviceOfflineList.forEach(deviceEntity -> {
PlatformEntity platformEntity = platformService.get(deviceEntity.getPlatformId()); PlatformEntity platformEntity = platformService.getCache(deviceEntity.getPlatformId().toString());
ProductEntity productEntity = productService.get(deviceEntity.getProductId()); ProductEntity productEntity = productService.getCache(deviceEntity.getProductId().toString());
if (!ObjectUtils.isEmpty(platformEntity) && !ObjectUtils.isEmpty(productEntity)) { if (!ObjectUtils.isEmpty(platformEntity) && !ObjectUtils.isEmpty(productEntity)) {
//通知第三方平台 //通知第三方平台
deviceService.sendThirdParty(deviceEntity, productEntity, platformEntity, DeviceMethodEnum.OFFLINE); deviceService.sendThirdParty(deviceEntity, productEntity, platformEntity, DeviceMethodEnum.OFFLINE);
......
...@@ -41,8 +41,8 @@ public class DeviceModuleUseServiceImpl extends AbstractCRUDServiceImpl<DeviceMo ...@@ -41,8 +41,8 @@ public class DeviceModuleUseServiceImpl extends AbstractCRUDServiceImpl<DeviceMo
list.stream().forEach(item -> { list.stream().forEach(item -> {
DeviceEntity deviceEntity = deviceService.getExtCache(item.getDeviceId().toString()); DeviceEntity deviceEntity = deviceService.getExtCache(item.getDeviceId().toString());
if (!ObjectUtils.isEmpty(deviceEntity)) { if (!ObjectUtils.isEmpty(deviceEntity)) {
PlatformEntity platformEntity = platformService.get(deviceEntity.getPlatformId()); PlatformEntity platformEntity = platformService.getCache(deviceEntity.getPlatformId().toString());
ProductEntity productEntity = productService.get(deviceEntity.getProductId()); ProductEntity productEntity = productService.getCache(deviceEntity.getProductId().toString());
if (!ObjectUtils.isEmpty(platformEntity) && !ObjectUtils.isEmpty(productEntity)) { if (!ObjectUtils.isEmpty(platformEntity) && !ObjectUtils.isEmpty(productEntity)) {
item.setPlatformAndProductName(platformEntity.getPlatformName() + "/" + productEntity.getProductName()); item.setPlatformAndProductName(platformEntity.getPlatformName() + "/" + productEntity.getProductName());
} }
......
...@@ -210,8 +210,8 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D ...@@ -210,8 +210,8 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D
deviceEntity.setDeviceStatus(DeviceStatusEnum.离线.getValue()); deviceEntity.setDeviceStatus(DeviceStatusEnum.离线.getValue());
deviceEntity.setEnabled(EnabledEnum.启用.getValue()); deviceEntity.setEnabled(EnabledEnum.启用.getValue());
this.update(deviceEntity); this.update(deviceEntity);
PlatformEntity platformEntity = platformService.get(deviceEntity.getPlatformId()); PlatformEntity platformEntity = platformService.getCache(deviceEntity.getPlatformId().toString());
ProductEntity productEntity = productService.get(deviceEntity.getProductId()); ProductEntity productEntity = productService.getCache(deviceEntity.getProductId().toString());
if (!ObjectUtils.isEmpty(platformEntity) && !ObjectUtils.isEmpty(productEntity)) { if (!ObjectUtils.isEmpty(platformEntity) && !ObjectUtils.isEmpty(productEntity)) {
//注册rabbmit相关队列与绑定 //注册rabbmit相关队列与绑定
messageProducer.queueAddAndBinds(QueueKey.DEFAULT_EXCHANGE, Constant.UPLOAD_TOPIC + deviceCode, Constant.UPLOAD_TOPIC + deviceCode); messageProducer.queueAddAndBinds(QueueKey.DEFAULT_EXCHANGE, Constant.UPLOAD_TOPIC + deviceCode, Constant.UPLOAD_TOPIC + deviceCode);
...@@ -292,8 +292,8 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D ...@@ -292,8 +292,8 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D
deviceEntity.setUpdateTime(new Date()); deviceEntity.setUpdateTime(new Date());
deviceEntity.setUpdateUserId(getContextUserId(context)); deviceEntity.setUpdateUserId(getContextUserId(context));
this.getDeviceDao().update(deviceEntity); this.getDeviceDao().update(deviceEntity);
ProductEntity productEntity = productService.get(deviceEntity.getProductId()); ProductEntity productEntity = productService.getCache(deviceEntity.getProductId().toString());
PlatformEntity platformEntity = platformService.get(deviceEntity.getPlatformId()); PlatformEntity platformEntity = platformService.getCache(deviceEntity.getPlatformId().toString());
if (enabled == YesNoEnum.YES.getValue()) { if (enabled == YesNoEnum.YES.getValue()) {
this.sendThirdParty(deviceEntity, productEntity, platformEntity, DeviceMethodEnum.ENABLED); this.sendThirdParty(deviceEntity, productEntity, platformEntity, DeviceMethodEnum.ENABLED);
} else { } else {
...@@ -306,8 +306,8 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D ...@@ -306,8 +306,8 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D
DeviceEntity deviceEntity = this.get(id, context); DeviceEntity deviceEntity = this.get(id, context);
if (ObjectUtils.isEmpty(deviceEntity)) throw new AppException("当前设备不存在!"); if (ObjectUtils.isEmpty(deviceEntity)) throw new AppException("当前设备不存在!");
PlatformEntity platformEntity = platformService.get(deviceEntity.getPlatformId()); PlatformEntity platformEntity = platformService.getCache(deviceEntity.getPlatformId().toString());
ProductEntity productEntity = productService.get(deviceEntity.getProductId()); ProductEntity productEntity = productService.getCache(deviceEntity.getProductId().toString());
String exchangeName = platformEntity.getPlatformSn() + Constant.EXCHANGE_SPLIT + productEntity.getProductCode(); String exchangeName = platformEntity.getPlatformSn() + Constant.EXCHANGE_SPLIT + productEntity.getProductCode();
TopicPartitionInfo topicPartitionInfo = new TopicPartitionInfo(Constant.UPLOAD_TOPIC + deviceEntity.getDeviceCode(), null, exchangeName); TopicPartitionInfo topicPartitionInfo = new TopicPartitionInfo(Constant.UPLOAD_TOPIC + deviceEntity.getDeviceCode(), null, exchangeName);
...@@ -326,8 +326,8 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D ...@@ -326,8 +326,8 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D
@Override @Override
protected void saveAfter(DeviceEntity entity, Context context) throws AppException { protected void saveAfter(DeviceEntity entity, Context context) throws AppException {
super.saveAfter(entity, context); super.saveAfter(entity, context);
PlatformEntity platformEntity = platformService.get(entity.getPlatformId()); PlatformEntity platformEntity = platformService.getCache(entity.getPlatformId().toString());
ProductEntity productEntity = productService.get(entity.getProductId()); ProductEntity productEntity = productService.getCache(entity.getProductId().toString());
if (!ObjectUtils.isEmpty(platformEntity) && !ObjectUtils.isEmpty(productEntity)) { if (!ObjectUtils.isEmpty(platformEntity) && !ObjectUtils.isEmpty(productEntity)) {
//注册rabbmit相关队列与绑定 激活后才註冊綁定隊列 //注册rabbmit相关队列与绑定 激活后才註冊綁定隊列
// registerRabbitQueue(entity, platformEntity, productEntity); // registerRabbitQueue(entity, platformEntity, productEntity);
...@@ -339,8 +339,8 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D ...@@ -339,8 +339,8 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D
@Override @Override
protected void updateAfter(DeviceEntity entity, Context context) throws AppException { protected void updateAfter(DeviceEntity entity, Context context) throws AppException {
super.updateAfter(entity, context); super.updateAfter(entity, context);
PlatformEntity platformEntity = platformService.get(entity.getPlatformId()); PlatformEntity platformEntity = platformService.getCache(entity.getPlatformId().toString());
ProductEntity productEntity = productService.get(entity.getProductId()); ProductEntity productEntity = productService.getCache(entity.getProductId().toString());
if (!ObjectUtils.isEmpty(platformEntity) && !ObjectUtils.isEmpty(productEntity)) { if (!ObjectUtils.isEmpty(platformEntity) && !ObjectUtils.isEmpty(productEntity)) {
//新增设备通知第三方平台 激活后的设备才通知和更新 //新增设备通知第三方平台 激活后的设备才通知和更新
if (entity.getDeviceStatus() > 0) { if (entity.getDeviceStatus() > 0) {
...@@ -614,8 +614,8 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D ...@@ -614,8 +614,8 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D
Long[] removeIds = Arrays.asList(ids).stream().map(id -> { Long[] removeIds = Arrays.asList(ids).stream().map(id -> {
DeviceEntity deviceEntity = this.get(id, context); DeviceEntity deviceEntity = this.get(id, context);
if (!ObjectUtils.isEmpty(deviceEntity)) { if (!ObjectUtils.isEmpty(deviceEntity)) {
PlatformEntity platformEntity = platformService.get(deviceEntity.getPlatformId()); PlatformEntity platformEntity = platformService.getCache(deviceEntity.getPlatformId().toString());
ProductEntity productEntity = productService.get(deviceEntity.getProductId()); ProductEntity productEntity = productService.getCache(deviceEntity.getProductId().toString());
if (!ObjectUtils.isEmpty(platformEntity) && !ObjectUtils.isEmpty(productEntity)) { if (!ObjectUtils.isEmpty(platformEntity) && !ObjectUtils.isEmpty(productEntity)) {
Rest<String> thirtyRest = sendThirdParty(deviceEntity, productEntity, platformEntity, DeviceMethodEnum.DEL); Rest<String> thirtyRest = sendThirdParty(deviceEntity, productEntity, platformEntity, DeviceMethodEnum.DEL);
if (YesNoEnum.YES.getValue() == thirtyRest.getCode()) { if (YesNoEnum.YES.getValue() == thirtyRest.getCode()) {
...@@ -651,8 +651,8 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D ...@@ -651,8 +651,8 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D
@Override @Override
protected void exportAfter(DeviceEntity params, Context context, List<DeviceEntity> list) throws AppException { protected void exportAfter(DeviceEntity params, Context context, List<DeviceEntity> list) throws AppException {
list.stream().forEach(deviceEntity -> { list.stream().forEach(deviceEntity -> {
PlatformEntity platformEntity = platformService.get(deviceEntity.getPlatformId()); PlatformEntity platformEntity = platformService.getCache(deviceEntity.getPlatformId().toString());
ProductEntity productEntity = productService.get(deviceEntity.getProductId()); ProductEntity productEntity = productService.getCache(deviceEntity.getProductId().toString());
if (!ObjectUtils.isEmpty(platformEntity) && !ObjectUtils.isEmpty(productEntity)) { if (!ObjectUtils.isEmpty(platformEntity) && !ObjectUtils.isEmpty(productEntity)) {
deviceEntity.setProductCode(productEntity.getProductCode()); deviceEntity.setProductCode(productEntity.getProductCode());
deviceEntity.setPlatformCode(platformEntity.getPlatformSn()); deviceEntity.setPlatformCode(platformEntity.getPlatformSn());
...@@ -695,7 +695,7 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D ...@@ -695,7 +695,7 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D
entity.setProductName(productEntity.getProductName()); entity.setProductName(productEntity.getProductName());
//根据产品查询平台 //根据产品查询平台
if (!ObjectUtils.isEmpty(productEntity.getPlatformId())) { if (!ObjectUtils.isEmpty(productEntity.getPlatformId())) {
PlatformEntity platformEntity = platformService.get(productEntity.getPlatformId()); PlatformEntity platformEntity = platformService.getCache(productEntity.getPlatformId().toString());
entity.setPlatformId(platformEntity.getId()); entity.setPlatformId(platformEntity.getId());
entity.setPlatformCode(platformEntity.getPlatformSn()); entity.setPlatformCode(platformEntity.getPlatformSn());
entity.setPlatformName(platformEntity.getPlatformName()); entity.setPlatformName(platformEntity.getPlatformName());
...@@ -710,7 +710,7 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D ...@@ -710,7 +710,7 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D
entity.setProductName(productEntity.getProductName()); entity.setProductName(productEntity.getProductName());
//根据产品查询平台 //根据产品查询平台
if (!ObjectUtils.isEmpty(productEntity.getPlatformId())) { if (!ObjectUtils.isEmpty(productEntity.getPlatformId())) {
PlatformEntity platformEntity = platformService.get(productEntity.getPlatformId()); PlatformEntity platformEntity = platformService.getCache(productEntity.getPlatformId().toString());
entity.setPlatformId(platformEntity.getId()); entity.setPlatformId(platformEntity.getId());
entity.setPlatformCode(platformEntity.getPlatformSn()); entity.setPlatformCode(platformEntity.getPlatformSn());
entity.setPlatformName(platformEntity.getPlatformName()); entity.setPlatformName(platformEntity.getPlatformName());
...@@ -732,8 +732,8 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D ...@@ -732,8 +732,8 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D
if (!ObjectUtils.isEmpty(entity.getDeviceStatus()) && entity.getDeviceStatus() > DeviceStatusEnum.未激活.getValue()) { if (!ObjectUtils.isEmpty(entity.getDeviceStatus()) && entity.getDeviceStatus() > DeviceStatusEnum.未激活.getValue()) {
//激活设备,添加队列订阅 //激活设备,添加队列订阅
container.addQueueNames(Constant.UPLOAD_TOPIC + entity.getDeviceCode()); container.addQueueNames(Constant.UPLOAD_TOPIC + entity.getDeviceCode());
PlatformEntity platformEntity = platformService.get(entity.getPlatformId()); PlatformEntity platformEntity = platformService.getCache(entity.getPlatformId().toString());
ProductEntity productEntity = productService.get(entity.getProductId()); ProductEntity productEntity = productService.getCache(entity.getProductId().toString());
sendThirdParty(entity, productEntity, platformEntity, DeviceMethodEnum.ADD); sendThirdParty(entity, productEntity, platformEntity, DeviceMethodEnum.ADD);
sendThirdParty(entity, productEntity, platformEntity, DeviceMethodEnum.ACTIVE); sendThirdParty(entity, productEntity, platformEntity, DeviceMethodEnum.ACTIVE);
} }
......
...@@ -122,7 +122,7 @@ public class ProductServiceImpl extends AbstractCRUDCacheServiceImpl<ProductDao, ...@@ -122,7 +122,7 @@ public class ProductServiceImpl extends AbstractCRUDCacheServiceImpl<ProductDao,
if (ObjectUtils.isEmpty(productEntity)) { if (ObjectUtils.isEmpty(productEntity)) {
throw new AppException("当前设备未配置所属产品,请在后台配置后再激活!"); throw new AppException("当前设备未配置所属产品,请在后台配置后再激活!");
} }
PlatformEntity platformEntity = platformService.get(productEntity.getPlatformId()); PlatformEntity platformEntity = platformService.getCache(productEntity.getPlatformId().toString());
if (ObjectUtils.isEmpty(platformEntity)) { if (ObjectUtils.isEmpty(platformEntity)) {
throw new AppException("当前设备未配置所属系统平台,请在后台配置后再激活!"); throw new AppException("当前设备未配置所属系统平台,请在后台配置后再激活!");
} }
......
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