diff --git a/modules/thing/src/main/java/com/thing/device/source/service/IotThingSourceService.java b/modules/thing/src/main/java/com/thing/device/source/service/IotThingSourceService.java index fcd88bc..be79a95 100644 --- a/modules/thing/src/main/java/com/thing/device/source/service/IotThingSourceService.java +++ b/modules/thing/src/main/java/com/thing/device/source/service/IotThingSourceService.java @@ -49,5 +49,7 @@ public interface IotThingSourceService extends IBaseService attrGroup(); + Long getMaxSort(String configType,Long fromId,Long rootId); + List attrGroupRootId(IotThingSourceReqDTO iotThingSourceDTO); } diff --git a/modules/thing/src/main/java/com/thing/device/source/service/impl/IotThingSourceServiceImpl.java b/modules/thing/src/main/java/com/thing/device/source/service/impl/IotThingSourceServiceImpl.java index 88723b4..f26cb84 100644 --- a/modules/thing/src/main/java/com/thing/device/source/service/impl/IotThingSourceServiceImpl.java +++ b/modules/thing/src/main/java/com/thing/device/source/service/impl/IotThingSourceServiceImpl.java @@ -566,6 +566,21 @@ public class IotThingSourceServiceImpl extends BaseServiceImpl !StringUtils.isBlank(s)).distinct().collect(Collectors.toList()); } + @Override + public Long getMaxSort(String configType, Long fromId,Long rootId) { + List iotThingSourceEntities = mapper.selectListByQuery( + new QueryWrapper() + .eq(IotThingSourceEntity::getFromId, fromId) + .eq(IotThingSourceEntity::getConfigType, configType) + .eq(IotThingSourceEntity::getRootId, rootId) + .eq(IotThingSourceEntity::getTenantCode, UserContext.getRealTenantCode()) + ); + if(CollectionUtils.isEmpty(iotThingSourceEntities)){ + return 0L; + } + return iotThingSourceEntities.stream().max(Comparator.comparing(IotThingSourceEntity::getSort)).get().getSort()+1; + } + @Override public List attrGroupRootId(IotThingSourceReqDTO iotThingSourceDTO) { List iotThingSourceRelationDTOList = iotThingSourceDTO.getIotThingSourceRelationDTOList();