|
|
@ -632,7 +632,7 @@ public class IotThingRelationDetailServiceImpl extends BaseServiceImpl<IotThingR |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public void draggingSort(Long id, Long targetId, Long parentId, Long sort) { |
|
|
|
|
|
|
|
|
public void draggingSort(Long id, Long targetId, Long parentId, Long rootThingId, Long sort) { |
|
|
IotThingRelationDetailEntity sourceEntity = mapper.selectOneById(id); |
|
|
IotThingRelationDetailEntity sourceEntity = mapper.selectOneById(id); |
|
|
if (Objects.isNull(sourceEntity)) { |
|
|
if (Objects.isNull(sourceEntity)) { |
|
|
throw new SysException("当前拖拽节点不存在,请重新选择"); |
|
|
throw new SysException("当前拖拽节点不存在,请重新选择"); |
|
|
@ -641,6 +641,21 @@ public class IotThingRelationDetailServiceImpl extends BaseServiceImpl<IotThingR |
|
|
if (Objects.isNull(targetEntity)) { |
|
|
if (Objects.isNull(targetEntity)) { |
|
|
throw new SysException("当前目标节点不存在,请重新选择"); |
|
|
throw new SysException("当前目标节点不存在,请重新选择"); |
|
|
} |
|
|
} |
|
|
|
|
|
//若是不相等,则作为targetId的子节点下 |
|
|
|
|
|
List<IotThingRelationDetailEntity> parentEntities; |
|
|
|
|
|
if(!Objects.equals(sourceEntity.getRootId(), parentId)){ |
|
|
|
|
|
parentEntities = mapper.selectListByQuery(new QueryWrapper().eq(IotThingRelationDetailEntity::getToId, parentId) |
|
|
|
|
|
.eq(IotThingRelationDetailEntity::getRootThingId, rootThingId)); |
|
|
|
|
|
if (CollectionUtils.isEmpty(parentEntities)) { |
|
|
|
|
|
throw new SysException("父节点不存在,请重新选择"); |
|
|
|
|
|
} |
|
|
|
|
|
}else{ |
|
|
|
|
|
IotThingRelationRootDTO relationRootDTO = relationRootsService.findById(parentId); |
|
|
|
|
|
parentEntities = Lists.newArrayList(new IotThingRelationDetailEntity().setFromId(relationRootDTO.getId()).setFromName(relationRootDTO.getName())) ; |
|
|
|
|
|
if (CollectionUtils.isEmpty(parentEntities)) { |
|
|
|
|
|
throw new SysException("父节点不存在,请重新选择"); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
List<IotThingRelationDetailEntity> allDetailEntities = mapper.selectListByQuery(new QueryWrapper() |
|
|
List<IotThingRelationDetailEntity> allDetailEntities = mapper.selectListByQuery(new QueryWrapper() |
|
|
.eq(IotThingRelationDetailEntity::getRootId, sourceEntity.getRootId()) |
|
|
.eq(IotThingRelationDetailEntity::getRootId, sourceEntity.getRootId()) |
|
|
.ne(IotThingRelationDetailEntity::getId, id) |
|
|
.ne(IotThingRelationDetailEntity::getId, id) |
|
|
@ -648,45 +663,17 @@ public class IotThingRelationDetailServiceImpl extends BaseServiceImpl<IotThingR |
|
|
|
|
|
|
|
|
List<IotThingRelationDetailEntity> resList = new ArrayList<>(); |
|
|
List<IotThingRelationDetailEntity> resList = new ArrayList<>(); |
|
|
//若是相等,则作为targetId的子节点下 |
|
|
//若是相等,则作为targetId的子节点下 |
|
|
if(Objects.equals(targetId,parentId)){ |
|
|
|
|
|
sourceEntity.setFromName(targetEntity.getFromName()); |
|
|
|
|
|
sourceEntity.setFromCode(targetEntity.getFromCode()); |
|
|
|
|
|
sourceEntity.setId(targetEntity.getId()); |
|
|
|
|
|
|
|
|
if(!Objects.equals(targetEntity.getFromId(),parentId) && Objects.equals(targetEntity.getRootThingId(),rootThingId)){ |
|
|
|
|
|
sourceEntity.setFromName(targetEntity.getToName()); |
|
|
|
|
|
sourceEntity.setFromCode(targetEntity.getToCode()); |
|
|
|
|
|
sourceEntity.setFromId(targetEntity.getToId()); |
|
|
sourceEntity.setSort(sort); |
|
|
sourceEntity.setSort(sort); |
|
|
// if(targetEntity.getSort()< sort){ |
|
|
|
|
|
// //向下拖拽 |
|
|
|
|
|
// List<IotThingRelationDetailEntity> upList = allDetailEntities.stream() |
|
|
|
|
|
// .filter(s -> s.getSort() < sort).sorted(Comparator.comparing(IotThingRelationDetailEntity::getSort)).toList(); |
|
|
|
|
|
// resList.addAll(upList); |
|
|
|
|
|
// resList.add(sourceEntity); |
|
|
|
|
|
// List<IotThingRelationDetailEntity> downList = allDetailEntities.stream() |
|
|
|
|
|
// .filter(s -> s.getSort() >= sort).sorted(Comparator.comparing(IotThingRelationDetailEntity::getSort)).toList(); |
|
|
|
|
|
// resList.addAll(downList); |
|
|
|
|
|
// }else{ |
|
|
|
|
|
// //向上拖拽 |
|
|
|
|
|
// List<IotThingRelationDetailEntity> upList = allDetailEntities.stream() |
|
|
|
|
|
// .filter(s -> s.getSort() <= sort).sorted(Comparator.comparing(IotThingRelationDetailEntity::getSort)).toList(); |
|
|
|
|
|
// resList.addAll(upList); |
|
|
|
|
|
// resList.add(sourceEntity); |
|
|
|
|
|
// List<IotThingRelationDetailEntity> downList = allDetailEntities.stream() |
|
|
|
|
|
// .filter(s -> s.getSort() > sort).sorted(Comparator.comparing(IotThingRelationDetailEntity::getSort)).toList(); |
|
|
|
|
|
// resList.addAll(downList); |
|
|
|
|
|
// } |
|
|
|
|
|
}else{ |
|
|
}else{ |
|
|
//若是不相等,则作为targetId的子节点下 |
|
|
|
|
|
IotThingRelationDetailEntity parentEntity = mapper.selectOneById(parentId); |
|
|
|
|
|
if (Objects.isNull(parentEntity)) { |
|
|
|
|
|
throw new SysException("父节点不存在,请重新选择"); |
|
|
|
|
|
} |
|
|
|
|
|
sourceEntity.setFromName(parentEntity.getFromName()); |
|
|
|
|
|
sourceEntity.setFromCode(parentEntity.getFromCode()); |
|
|
|
|
|
sourceEntity.setId(parentEntity.getId()); |
|
|
|
|
|
|
|
|
sourceEntity.setFromName(parentEntities.get(0).getToName()); |
|
|
|
|
|
sourceEntity.setFromCode(parentEntities.get(0).getToCode()); |
|
|
|
|
|
sourceEntity.setFromId(parentEntities.get(0).getToId()); |
|
|
sourceEntity.setSort(sort); |
|
|
sourceEntity.setSort(sort); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(targetEntity.getSort()< sort){ |
|
|
if(targetEntity.getSort()< sort){ |
|
|
//向下拖拽 |
|
|
//向下拖拽 |
|
|
List<IotThingRelationDetailEntity> upList = allDetailEntities.stream() |
|
|
List<IotThingRelationDetailEntity> upList = allDetailEntities.stream() |
|
|
@ -706,7 +693,6 @@ public class IotThingRelationDetailServiceImpl extends BaseServiceImpl<IotThingR |
|
|
.filter(s -> s.getSort() > sort).sorted(Comparator.comparing(IotThingRelationDetailEntity::getSort)).toList(); |
|
|
.filter(s -> s.getSort() > sort).sorted(Comparator.comparing(IotThingRelationDetailEntity::getSort)).toList(); |
|
|
resList.addAll(downList); |
|
|
resList.addAll(downList); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
AtomicLong atomicLong = new AtomicLong(0); |
|
|
AtomicLong atomicLong = new AtomicLong(0); |
|
|
resList.forEach(s -> |
|
|
resList.forEach(s -> |
|
|
{ |
|
|
{ |
|
|
|