diff --git a/modules/thing/src/main/java/com/thing/thing/relation/detail/service/impl/IotThingRelationDetailServiceImpl.java b/modules/thing/src/main/java/com/thing/thing/relation/detail/service/impl/IotThingRelationDetailServiceImpl.java index b1511f0..976618f 100644 --- a/modules/thing/src/main/java/com/thing/thing/relation/detail/service/impl/IotThingRelationDetailServiceImpl.java +++ b/modules/thing/src/main/java/com/thing/thing/relation/detail/service/impl/IotThingRelationDetailServiceImpl.java @@ -281,8 +281,14 @@ public class IotThingRelationDetailServiceImpl extends BaseServiceImpl mapAccurateKey = cache.findMapAccurateKey(CacheNameEnum.THING_MODEL, item.getToCode()); + if (CollectionUtils.isNotEmpty(mapAccurateKey)) { + String status = mapAccurateKey.get(0).get(CacheNameEnum.ModelField.THING_MODEL_STATUS.getField()).asText(); + node.put(CacheNameEnum.ModelField.THING_MODEL_STATUS.getField(), status); + } + cache.updateAccurateKeyMap(CacheNameEnum.THING_DETAIL_RELATION, + item.getRootId() + CacheInit.KEY + item.getId() + CacheInit.KEY + item.getRootThingId(), node); }); } @@ -355,8 +361,17 @@ public class IotThingRelationDetailServiceImpl extends BaseServiceImpl cache.updateAccurateKeyEntity(CacheNameEnum.THING_DETAIL_RELATION, - entity.getRootId()+CacheInit.KEY+entity.getId()+CacheInit.KEY+entity.getRootThingId(),ConvertUtils.sourceToTarget(entity, IotThingRelationDetailDTO.class))); + list.forEach(entity -> + { + ObjectNode node = JsonConverter.convertToJsonObjectObjectNode(entity); + List mapAccurateKey = cache.findMapAccurateKey(CacheNameEnum.THING_MODEL, entity.getToCode()); + if (CollectionUtils.isNotEmpty(mapAccurateKey)) { + String status = mapAccurateKey.get(0).get(CacheNameEnum.ModelField.THING_MODEL_STATUS.getField()).asText(); + node.put(CacheNameEnum.ModelField.THING_MODEL_STATUS.getField(), status); + } + cache.updateAccurateKeyMap(CacheNameEnum.THING_DETAIL_RELATION, + entity.getRootId() + CacheInit.KEY + entity.getId() + CacheInit.KEY + entity.getRootThingId(), node); + }); } @Transactional(rollbackFor = Exception.class) @@ -367,13 +382,17 @@ public class IotThingRelationDetailServiceImpl extends BaseServiceImpl mapAccurateKey = cache.findMapAccurateKey(CacheNameEnum.THING_MODEL, sourceEntity.getToCode()); + if(CollectionUtils.isNotEmpty(mapAccurateKey)){ + String status = mapAccurateKey.get(0).get(CacheNameEnum.ModelField.THING_MODEL_STATUS.getField()).asText(); + node.put(CacheNameEnum.ModelField.THING_MODEL_STATUS.getField(), status); + } + cache.updateAccurateKeyMap(CacheNameEnum.THING_DETAIL_RELATION, + sourceEntity.getRootId()+CacheInit.KEY+sourceEntity.getId()+CacheInit.KEY+sourceEntity.getRootThingId(),node); } else { IotThingRelationDetailEntity targetEntity = mapper.selectOneById(dto.getPid()); if (Objects.isNull(targetEntity)) { @@ -384,8 +403,14 @@ public class IotThingRelationDetailServiceImpl extends BaseServiceImpl mapAccurateKey = cache.findMapAccurateKey(CacheNameEnum.THING_MODEL, sourceEntity.getToCode()); + if(CollectionUtils.isNotEmpty(mapAccurateKey)){ + String status = mapAccurateKey.get(0).get(CacheNameEnum.ModelField.THING_MODEL_STATUS.getField()).asText(); + node.put(CacheNameEnum.ModelField.THING_MODEL_STATUS.getField(), status); + } + cache.updateAccurateKeyMap(CacheNameEnum.THING_DETAIL_RELATION, + sourceEntity.getRootId()+CacheInit.KEY+sourceEntity.getId()+CacheInit.KEY+sourceEntity.getRootThingId(),node); }else{ //查询当前关系下所有节点信息 List iotThingRelationDetailEntities = mapper.selectListByQuery(QueryWrapper.create().eq(IotThingRelationDetailEntity::getRootId, dto.getRootId())); @@ -430,8 +455,14 @@ public class IotThingRelationDetailServiceImpl extends BaseServiceImpl mapAccurateKey = cache.findMapAccurateKey(CacheNameEnum.THING_MODEL, sourceEntity.getToCode()); + if(CollectionUtils.isNotEmpty(mapAccurateKey)){ + String status = mapAccurateKey.get(0).get(CacheNameEnum.ModelField.THING_MODEL_STATUS.getField()).asText(); + node.put(CacheNameEnum.ModelField.THING_MODEL_STATUS.getField(), status); + } + cache.updateAccurateKeyMap(CacheNameEnum.THING_DETAIL_RELATION, + sourceEntity.getRootId()+CacheInit.KEY+sourceEntity.getId()+CacheInit.KEY+sourceEntity.getRootThingId(),node); } ); } @@ -544,8 +575,17 @@ public class IotThingRelationDetailServiceImpl extends BaseServiceImpl item.setSort(sort.getAndIncrement())); this.updateBatch(resultList); //更新缓存 - resultList.forEach(s -> cache.updateAccurateKeyEntity(CacheNameEnum.THING_DETAIL_RELATION, - s.getRootId()+CacheInit.KEY+s.getId()+CacheInit.KEY+s.getRootThingId(),ConvertUtils.sourceToTarget(s, IotThingRelationDetailDTO.class))); + resultList.forEach(s -> + { + ObjectNode node = JsonConverter.convertToJsonObjectObjectNode(s); + List mapAccurateKey = cache.findMapAccurateKey(CacheNameEnum.THING_MODEL, s.getToCode()); + if (CollectionUtils.isNotEmpty(mapAccurateKey)) { + String status = mapAccurateKey.get(0).get(CacheNameEnum.ModelField.THING_MODEL_STATUS.getField()).asText(); + node.put(CacheNameEnum.ModelField.THING_MODEL_STATUS.getField(), status); + } + cache.updateAccurateKeyMap(CacheNameEnum.THING_DETAIL_RELATION, + s.getRootId() + CacheInit.KEY + s.getId() + CacheInit.KEY + s.getRootThingId(), node); + }); } @Override @@ -578,8 +618,17 @@ public class IotThingRelationDetailServiceImpl extends BaseServiceImpl item.setSort(sort1.getAndIncrement())); this.updateBatch(reslutList); //更新缓存 - reslutList.forEach(s -> cache.updateAccurateKeyEntity(CacheNameEnum.THING_DETAIL_RELATION, - s.getRootId()+CacheInit.KEY+s.getId()+CacheInit.KEY+s.getRootThingId(),ConvertUtils.sourceToTarget(s, IotThingRelationDetailDTO.class))); + reslutList.forEach(s -> + { + ObjectNode node = JsonConverter.convertToJsonObjectObjectNode(s); + List mapAccurateKey = cache.findMapAccurateKey(CacheNameEnum.THING_MODEL, s.getToCode()); + if (CollectionUtils.isNotEmpty(mapAccurateKey)) { + String status = mapAccurateKey.get(0).get(CacheNameEnum.ModelField.THING_MODEL_STATUS.getField()).asText(); + node.put(CacheNameEnum.ModelField.THING_MODEL_STATUS.getField(), status); + } + cache.updateAccurateKeyMap(CacheNameEnum.THING_DETAIL_RELATION, + s.getRootId() + CacheInit.KEY + s.getId() + CacheInit.KEY + s.getRootThingId(), node); + }); } @Override @@ -609,8 +658,15 @@ public class IotThingRelationDetailServiceImpl extends BaseServiceImpl mapAccurateKey = cache.findMapAccurateKey(CacheNameEnum.THING_MODEL, s.getToCode()); + if (CollectionUtils.isNotEmpty(mapAccurateKey)) { + String status = mapAccurateKey.get(0).get(CacheNameEnum.ModelField.THING_MODEL_STATUS.getField()).asText(); + node.put(CacheNameEnum.ModelField.THING_MODEL_STATUS.getField(), status); + } + cache.updateAccurateKeyMap(CacheNameEnum.THING_DETAIL_RELATION, + s.getRootId() + CacheInit.KEY + s.getId() + CacheInit.KEY + s.getRootThingId(), node); }); }