|
|
@ -3,6 +3,7 @@ package com.thing.device.source.service.impl; |
|
|
import cn.hutool.core.collection.CollectionUtil; |
|
|
import cn.hutool.core.collection.CollectionUtil; |
|
|
import cn.hutool.core.map.MapUtil; |
|
|
import cn.hutool.core.map.MapUtil; |
|
|
import com.alibaba.fastjson.JSON; |
|
|
import com.alibaba.fastjson.JSON; |
|
|
|
|
|
import com.google.common.collect.Lists; |
|
|
import com.mybatisflex.core.paginate.Page; |
|
|
import com.mybatisflex.core.paginate.Page; |
|
|
import com.mybatisflex.core.query.QueryWrapper; |
|
|
import com.mybatisflex.core.query.QueryWrapper; |
|
|
import com.thing.common.core.enumeration.AttributeTypeEnum; |
|
|
import com.thing.common.core.enumeration.AttributeTypeEnum; |
|
|
@ -31,7 +32,6 @@ import com.thing.thing.relation.detail.dto.ThingTreeDTO; |
|
|
import lombok.RequiredArgsConstructor; |
|
|
import lombok.RequiredArgsConstructor; |
|
|
import org.apache.commons.collections4.CollectionUtils; |
|
|
import org.apache.commons.collections4.CollectionUtils; |
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
|
|
import org.springframework.stereotype.Service; |
|
|
import org.springframework.stereotype.Service; |
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
|
@ -51,6 +51,10 @@ public class IotThingSourceServiceImpl extends BaseServiceImpl<IotThingSourceMap |
|
|
|
|
|
|
|
|
private final ThingManageContextService thingManageContextService; |
|
|
private final ThingManageContextService thingManageContextService; |
|
|
|
|
|
|
|
|
|
|
|
private final IotThingMenuConfigMapper iotThingMenuConfigMapper; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public QueryWrapper getWrapper(Map<String, Object> params) { |
|
|
public QueryWrapper getWrapper(Map<String, Object> params) { |
|
|
QueryWrapper queryWrapper = new QueryWrapper(); |
|
|
QueryWrapper queryWrapper = new QueryWrapper(); |
|
|
@ -427,10 +431,6 @@ public class IotThingSourceServiceImpl extends BaseServiceImpl<IotThingSourceMap |
|
|
.toList(); |
|
|
.toList(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
|
private IotThingMenuConfigMapper iotThingMenuConfigMapper; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public List<IotThingSourceAttrRespDTO> getAttrListByThingRelationDTONew(IotThingSourceGetAttrDTO iotThingSourceGetAttrDTO) { |
|
|
public List<IotThingSourceAttrRespDTO> getAttrListByThingRelationDTONew(IotThingSourceGetAttrDTO iotThingSourceGetAttrDTO) { |
|
|
if (CollectionUtil.isEmpty(iotThingSourceGetAttrDTO.getIotThingSourceRelationDTOList())) { |
|
|
if (CollectionUtil.isEmpty(iotThingSourceGetAttrDTO.getIotThingSourceRelationDTOList())) { |
|
|
@ -483,6 +483,52 @@ public class IotThingSourceServiceImpl extends BaseServiceImpl<IotThingSourceMap |
|
|
return iotThingSourceAttrList.stream().filter(distinctByKey(IotThingSourceAttrRespDTO::getThingAttrCode)).sorted(Comparator.comparing(IotThingSourceAttrRespDTO::getSort)).collect(Collectors.toList()); |
|
|
return iotThingSourceAttrList.stream().filter(distinctByKey(IotThingSourceAttrRespDTO::getThingAttrCode)).sorted(Comparator.comparing(IotThingSourceAttrRespDTO::getSort)).collect(Collectors.toList()); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public void dragAndDrop(Long id, Long toId, Long sort) { |
|
|
|
|
|
IotThingSourceEntity sourceEntity = mapper.selectOneById(id); |
|
|
|
|
|
IotThingSourceEntity toSourceEntity = mapper.selectOneById(toId); |
|
|
|
|
|
|
|
|
|
|
|
if(!Objects.equals(sourceEntity.getFromId(),toSourceEntity.getFromId()) || !Objects.equals(sourceEntity.getConfigType(),toSourceEntity.getConfigType())){ |
|
|
|
|
|
throw new SysException("不能拖拽到不同层级"); |
|
|
|
|
|
} |
|
|
|
|
|
//自定义字典列表 |
|
|
|
|
|
List<IotThingSourceEntity> sourceOtherEntities = mapper.selectListByQuery(QueryWrapper.create() |
|
|
|
|
|
.eq(IotThingSourceEntity::getFromId, sourceEntity.getFromId()) |
|
|
|
|
|
.eq(IotThingSourceEntity::getConfigType, sourceEntity.getConfigType()) |
|
|
|
|
|
.ne(IotThingSourceEntity::getId, id) |
|
|
|
|
|
); |
|
|
|
|
|
if(CollectionUtils.isEmpty(sourceOtherEntities)){ |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
//若是大于当前目前序号,则更新当前序号之前的排序 |
|
|
|
|
|
AtomicLong aLong = new AtomicLong(0); |
|
|
|
|
|
List<IotThingSourceEntity> resList = Lists.newArrayList(); |
|
|
|
|
|
if(toSourceEntity.getSort()<=sort){ |
|
|
|
|
|
sourceOtherEntities.stream().filter(s -> s.getSort() < sort) |
|
|
|
|
|
.sorted(Comparator.comparing(IotThingSourceEntity::getSort)) |
|
|
|
|
|
.forEach(s -> s.setSort(aLong.incrementAndGet())); |
|
|
|
|
|
sourceEntity.setSort(aLong.incrementAndGet()); |
|
|
|
|
|
mapper.update(sourceEntity); |
|
|
|
|
|
sourceOtherEntities.stream() |
|
|
|
|
|
.sorted(Comparator.comparing(IotThingSourceEntity::getSort)) |
|
|
|
|
|
.filter(s -> s.getSort() >= sort).forEach(s -> s.setSort(aLong.incrementAndGet())); |
|
|
|
|
|
}else{ |
|
|
|
|
|
List<IotThingSourceEntity> list = sourceOtherEntities.stream().filter(s -> s.getSort() <= sort).toList(); |
|
|
|
|
|
list.stream().sorted(Comparator.comparing(IotThingSourceEntity::getSort)) |
|
|
|
|
|
.forEach(s -> { |
|
|
|
|
|
s.setSort(aLong.incrementAndGet()); |
|
|
|
|
|
}); |
|
|
|
|
|
resList.addAll(list); |
|
|
|
|
|
sourceEntity.setSort(aLong.incrementAndGet()); |
|
|
|
|
|
resList.add(sourceEntity); |
|
|
|
|
|
List<IotThingSourceEntity> list1 = sourceOtherEntities.stream().filter(s -> s.getSort() > sort).toList(); |
|
|
|
|
|
list1.stream().sorted(Comparator.comparing(IotThingSourceEntity::getSort)) |
|
|
|
|
|
.forEach(s -> s.setSort(aLong.incrementAndGet())); |
|
|
|
|
|
resList.addAll(list1); |
|
|
|
|
|
} |
|
|
|
|
|
this.updateBatch(resList); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 自定义函数去重 |
|
|
* 自定义函数去重 |
|
|
* |
|
|
* |
|
|
|