|
|
@ -996,14 +996,14 @@ public class IotThingRelationDetailServiceImpl extends BaseServiceImpl<IotThingR |
|
|
List<IotThingRelationDetailExcel> resList = list.stream().map(node -> { |
|
|
List<IotThingRelationDetailExcel> resList = list.stream().map(node -> { |
|
|
IotThingRelationDetailExcel excel = new IotThingRelationDetailExcel(); |
|
|
IotThingRelationDetailExcel excel = new IotThingRelationDetailExcel(); |
|
|
excel.setFromName(node.get("fromName").asText()); |
|
|
excel.setFromName(node.get("fromName").asText()); |
|
|
excel.setFromCode(node.get("fromCode").isEmpty() ? "" : node.get("fromCode").asText()); |
|
|
|
|
|
|
|
|
excel.setFromCode(node.get("fromCode").isNull() ? "" : node.get("fromCode").asText()); |
|
|
excel.setToName(node.get("toName").asText()); |
|
|
excel.setToName(node.get("toName").asText()); |
|
|
excel.setToCode(node.get("toCode").asText()); |
|
|
excel.setToCode(node.get("toCode").asText()); |
|
|
excel.setConfig(node.get("config").isEmpty() ? "" : node.get("config").asText()); |
|
|
|
|
|
excel.setRemark(node.get("remark").isEmpty() ? "" : node.get("remark").asText()); |
|
|
|
|
|
|
|
|
excel.setConfig(node.get("config").isNull() ? "" : node.get("config").asText()); |
|
|
|
|
|
excel.setRemark(node.get("remark").isNull() ? "" : node.get("remark").asText()); |
|
|
excel.setSort(node.get("sort").asLong()); |
|
|
excel.setSort(node.get("sort").asLong()); |
|
|
excel.setUrl(node.get("url").isEmpty() ? "" : node.get("url").asText()); |
|
|
|
|
|
excel.setTag(node.get("tag").isEmpty() ? "" : node.get("tag").asText()); |
|
|
|
|
|
|
|
|
excel.setUrl(node.get("url").isNull() ? "" : node.get("url").asText()); |
|
|
|
|
|
excel.setTag(node.get("tag").isNull() ? "" : node.get("tag").asText()); |
|
|
long rootThingId = node.get("rootThingId").asLong(); |
|
|
long rootThingId = node.get("rootThingId").asLong(); |
|
|
IotThingEntityInfoDTO entity = thingEntitiesService.findEntityById(rootThingId); |
|
|
IotThingEntityInfoDTO entity = thingEntitiesService.findEntityById(rootThingId); |
|
|
excel.setRootThingCode(entity.getCode()); |
|
|
excel.setRootThingCode(entity.getCode()); |
|
|
@ -1033,36 +1033,38 @@ public class IotThingRelationDetailServiceImpl extends BaseServiceImpl<IotThingR |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
sheetDataList.forEach(excel -> { |
|
|
sheetDataList.forEach(excel -> { |
|
|
//关系名称 |
|
|
|
|
|
if(!Objects.isNull(rootDTO)){ |
|
|
|
|
|
IotThingRelationDetailEntity entity = new IotThingRelationDetailEntity(); |
|
|
|
|
|
|
|
|
IotThingRelationDetailEntity entity = new IotThingRelationDetailEntity(); |
|
|
|
|
|
//说明是第一节点 |
|
|
|
|
|
if(StringUtils.equals(excel.getRootThingCode(),excel.getToCode()) && StringUtils.isBlank(excel.getFromCode())){ |
|
|
|
|
|
entity.setFromId(rootDTO.getId()); |
|
|
|
|
|
entity.setFromName(rootDTO.getName()); |
|
|
|
|
|
}else{ |
|
|
IotThingEntity fromEntity = entities.stream().filter(e -> e.getCode().equals(excel.getFromCode())).findFirst().get(); |
|
|
IotThingEntity fromEntity = entities.stream().filter(e -> e.getCode().equals(excel.getFromCode())).findFirst().get(); |
|
|
IotThingEntity toEntity = entities.stream().filter(e -> e.getCode().equals(excel.getToCode())).findFirst().get(); |
|
|
|
|
|
IotThingEntity rootEntity = entities.stream().filter(e -> e.getCode().equals(excel.getRootThingCode())).findFirst().get(); |
|
|
|
|
|
entity.setRootId(rootDTO.getId()); |
|
|
|
|
|
entity.setFromCode(excel.getFromCode()); |
|
|
|
|
|
entity.setFromCode(excel.getName()); |
|
|
|
|
|
entity.setFromId(fromEntity.getId()); |
|
|
entity.setFromId(fromEntity.getId()); |
|
|
entity.setToCode(excel.getToCode()); |
|
|
|
|
|
entity.setToName(excel.getToName()); |
|
|
|
|
|
entity.setToId(toEntity.getId()); |
|
|
|
|
|
entity.setConfig(excel.getConfig()); |
|
|
|
|
|
entity.setConfig(excel.getRemark()); |
|
|
|
|
|
entity.setSort(excel.getSort()); |
|
|
|
|
|
entity.setRootThingId(rootEntity.getId()); |
|
|
|
|
|
entity.setUrl(excel.getUrl()); |
|
|
|
|
|
entity.setTag(excel.getTag()); |
|
|
|
|
|
mapper.insert(entity); |
|
|
|
|
|
ObjectNode node = JsonConverter.convertToJsonObjectObjectNode(ConvertUtils.sourceToTarget(entity, IotThingRelationDetailDTO.class)); |
|
|
|
|
|
List<ObjectNode> 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("thingStatus", status); |
|
|
|
|
|
} |
|
|
|
|
|
cache.updateAccurateKeyMap(CacheNameEnum.THING_DETAIL_RELATION, |
|
|
|
|
|
entity.getRootId() + CacheInit.KEY + entity.getId() + CacheInit.KEY + entity.getRootThingId(), node); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
entity.setFromName(excel.getFromName()); |
|
|
|
|
|
entity.setFromCode(excel.getFromCode()); |
|
|
} |
|
|
} |
|
|
|
|
|
IotThingEntity toEntity = entities.stream().filter(e -> e.getCode().equals(excel.getToCode())).findFirst().get(); |
|
|
|
|
|
IotThingEntity rootEntity = entities.stream().filter(e -> e.getCode().equals(excel.getRootThingCode())).findFirst().get(); |
|
|
|
|
|
entity.setRootId(rootDTO.getId()); |
|
|
|
|
|
entity.setToCode(excel.getToCode()); |
|
|
|
|
|
entity.setToName(excel.getToName()); |
|
|
|
|
|
entity.setToId(toEntity.getId()); |
|
|
|
|
|
entity.setConfig(excel.getConfig()); |
|
|
|
|
|
entity.setConfig(excel.getRemark()); |
|
|
|
|
|
entity.setSort(excel.getSort()); |
|
|
|
|
|
entity.setRootThingId(rootEntity.getId()); |
|
|
|
|
|
entity.setUrl(excel.getUrl()); |
|
|
|
|
|
entity.setTag(excel.getTag()); |
|
|
|
|
|
mapper.insert(entity); |
|
|
|
|
|
ObjectNode node = JsonConverter.convertToJsonObjectObjectNode(ConvertUtils.sourceToTarget(entity, IotThingRelationDetailDTO.class)); |
|
|
|
|
|
List<ObjectNode> 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("thingStatus", status); |
|
|
|
|
|
} |
|
|
|
|
|
cache.updateAccurateKeyMap(CacheNameEnum.THING_DETAIL_RELATION, |
|
|
|
|
|
entity.getRootId() + CacheInit.KEY + entity.getId() + CacheInit.KEY + entity.getRootThingId(), node); |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|