|
|
@ -394,16 +394,17 @@ public class IotThingDictServiceImpl extends BaseServiceImpl<IotThingDictMapper, |
|
|
|
|
|
|
|
|
//自定义字典列表 |
|
|
//自定义字典列表 |
|
|
List<IotThingDictEntity> noDefaultList = mapper.selectListByQuery(QueryWrapper.create().eq(IotThingDictEntity::getTenantCode, UserContext.getRealTenantCode()) |
|
|
List<IotThingDictEntity> noDefaultList = mapper.selectListByQuery(QueryWrapper.create().eq(IotThingDictEntity::getTenantCode, UserContext.getRealTenantCode()) |
|
|
.eq(IotThingDictEntity::getIsDefault, 1)); |
|
|
|
|
|
|
|
|
.eq(IotThingDictEntity::getIsDefault, 1).ne(IotThingDictEntity::getId, id)); |
|
|
|
|
|
|
|
|
//自定义字典列表 |
|
|
//自定义字典列表 |
|
|
List<IotThingDictEntity> defaultList = mapper.selectListByQuery(QueryWrapper.create() |
|
|
List<IotThingDictEntity> defaultList = mapper.selectListByQuery(QueryWrapper.create() |
|
|
.eq(IotThingDictEntity::getIsDefault, 0)); |
|
|
|
|
|
|
|
|
.eq(IotThingDictEntity::getIsDefault, 0).ne(IotThingDictEntity::getId, id)); |
|
|
List<IotThingDictEntity> iotThingDictEntities = Lists.newArrayList(); |
|
|
List<IotThingDictEntity> iotThingDictEntities = Lists.newArrayList(); |
|
|
iotThingDictEntities.addAll(noDefaultList); |
|
|
iotThingDictEntities.addAll(noDefaultList); |
|
|
iotThingDictEntities.addAll(defaultList); |
|
|
iotThingDictEntities.addAll(defaultList); |
|
|
//若是大于当前目前序号,则更新当前序号之前的排序 |
|
|
//若是大于当前目前序号,则更新当前序号之前的排序 |
|
|
AtomicLong aLong = new AtomicLong(0); |
|
|
AtomicLong aLong = new AtomicLong(0); |
|
|
|
|
|
List<IotThingDictEntity> resList = Lists.newArrayList(); |
|
|
if(toDictEntity.getSort()<=sort){ |
|
|
if(toDictEntity.getSort()<=sort){ |
|
|
iotThingDictEntities.stream().filter(s -> s.getSort() < sort) |
|
|
iotThingDictEntities.stream().filter(s -> s.getSort() < sort) |
|
|
.sorted(Comparator.comparing(IotThingDictEntity::getSort)) |
|
|
.sorted(Comparator.comparing(IotThingDictEntity::getSort)) |
|
|
@ -420,20 +421,26 @@ public class IotThingDictServiceImpl extends BaseServiceImpl<IotThingDictMapper, |
|
|
mapper.update(s); |
|
|
mapper.update(s); |
|
|
}); |
|
|
}); |
|
|
}else{ |
|
|
}else{ |
|
|
iotThingDictEntities.stream().filter(s -> s.getSort() >= sort) |
|
|
|
|
|
.sorted(Comparator.comparing(IotThingDictEntity::getSort)) |
|
|
|
|
|
|
|
|
List<IotThingDictEntity> list = iotThingDictEntities.stream().filter(s -> s.getSort() <= sort).toList(); |
|
|
|
|
|
list.stream().sorted(Comparator.comparing(IotThingDictEntity::getSort)) |
|
|
.forEach(s -> { |
|
|
.forEach(s -> { |
|
|
s.setSort(aLong.incrementAndGet()); |
|
|
s.setSort(aLong.incrementAndGet()); |
|
|
mapper.update(s); |
|
|
|
|
|
|
|
|
// mapper.update(s); |
|
|
}); |
|
|
}); |
|
|
|
|
|
resList.addAll(list); |
|
|
iotThingDictEntity.setSort(aLong.incrementAndGet()); |
|
|
iotThingDictEntity.setSort(aLong.incrementAndGet()); |
|
|
iotThingDictEntities.stream().filter(s -> s.getSort() > sort) |
|
|
|
|
|
.sorted(Comparator.comparing(IotThingDictEntity::getSort)) |
|
|
|
|
|
|
|
|
resList.add(iotThingDictEntity); |
|
|
|
|
|
|
|
|
|
|
|
List<IotThingDictEntity> list1 = iotThingDictEntities.stream().filter(s -> s.getSort() > sort).toList(); |
|
|
|
|
|
list1.stream().sorted(Comparator.comparing(IotThingDictEntity::getSort)) |
|
|
.forEach(s -> { |
|
|
.forEach(s -> { |
|
|
s.setSort(aLong.incrementAndGet()); |
|
|
s.setSort(aLong.incrementAndGet()); |
|
|
mapper.update(s); |
|
|
|
|
|
|
|
|
// mapper.update(s); |
|
|
}); |
|
|
}); |
|
|
|
|
|
resList.addAll(list1); |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
resList.forEach(s -> mapper.update(s)); |
|
|
|
|
|
|
|
|
// Db.executeBatch(iotThingDictEntities.size(), 1000, IotThingDictMapper.class, (mapper, index) -> { |
|
|
// Db.executeBatch(iotThingDictEntities.size(), 1000, IotThingDictMapper.class, (mapper, index) -> { |
|
|
// IotThingDictEntity account = iotThingDictEntities.get(index); |
|
|
// IotThingDictEntity account = iotThingDictEntities.get(index); |
|
|
|