|
@ -88,6 +88,8 @@ public class DeviceProServiceImpl implements IDeviceProService { |
|
|
@Autowired |
|
|
@Autowired |
|
|
private IDeviceProUserMapper deviceProUserMapper; |
|
|
private IDeviceProUserMapper deviceProUserMapper; |
|
|
|
|
|
|
|
|
|
|
|
private final ObjectMapper objectMapper = new ObjectMapper(); |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public PaginationData<DeviceProEntity> listDeviceProEntityMap(Page page, DeviceProDTO deviceProDTO) { |
|
|
public PaginationData<DeviceProEntity> listDeviceProEntityMap(Page page, DeviceProDTO deviceProDTO) { |
|
|
Page<DeviceProEntity> pagination = deviceProMapper.listDeviceProEntityMap(page, deviceProDTO); |
|
|
Page<DeviceProEntity> pagination = deviceProMapper.listDeviceProEntityMap(page, deviceProDTO); |
|
@ -148,13 +150,13 @@ public class DeviceProServiceImpl implements IDeviceProService { |
|
|
difference.forEach(proUserEntity -> { |
|
|
difference.forEach(proUserEntity -> { |
|
|
//删除人员项目组信息
|
|
|
//删除人员项目组信息
|
|
|
List<Object> projects = RedisUtils.getCacheList(String.format(Constants.PRO_GROUP, proUserEntity.getUserId())); |
|
|
List<Object> projects = RedisUtils.getCacheList(String.format(Constants.PRO_GROUP, proUserEntity.getUserId())); |
|
|
List<DeviceProEntity> projectList = projects.stream() |
|
|
List<Map> projectList = projects.stream() |
|
|
.filter(DeviceProEntity.class::isInstance) |
|
|
.filter(Map.class::isInstance) |
|
|
.map(DeviceProEntity.class::cast) |
|
|
.map(Map.class::cast) |
|
|
.toList(); |
|
|
.toList(); |
|
|
|
|
|
|
|
|
//删除人员中所拥有的当前的项目组,然后构建新的存入redis
|
|
|
//删除人员中所拥有的当前的项目组,然后构建新的存入redis
|
|
|
List<DeviceProEntity> deviceProEntities = projectList.stream().filter(p -> !p.getId().equals(proId)).toList(); |
|
|
List<Map> deviceProEntities = projectList.stream().filter(p -> !Integer.valueOf(p.get("id") + "").equals(proId)).toList(); |
|
|
//删除
|
|
|
//删除
|
|
|
RedisUtils.deleteObject(String.format(Constants.PRO_GROUP, proUserEntity.getUserId())); |
|
|
RedisUtils.deleteObject(String.format(Constants.PRO_GROUP, proUserEntity.getUserId())); |
|
|
//重新插入
|
|
|
//重新插入
|
|
@ -163,19 +165,21 @@ public class DeviceProServiceImpl implements IDeviceProService { |
|
|
|
|
|
|
|
|
//删除人员所拥有的设备信息
|
|
|
//删除人员所拥有的设备信息
|
|
|
List<Object> cacheList = RedisUtils.getCacheList(String.format(Constants.PRO_DEVICE, proUserEntity.getUserId())); |
|
|
List<Object> cacheList = RedisUtils.getCacheList(String.format(Constants.PRO_DEVICE, proUserEntity.getUserId())); |
|
|
List<DeviceEntity> deviceList = cacheList.stream() |
|
|
List<Map> deviceList = cacheList.stream() |
|
|
.filter(DeviceEntity.class::isInstance) |
|
|
.filter(Map.class::isInstance) |
|
|
.map(DeviceEntity.class::cast) |
|
|
.map(Map.class::cast) |
|
|
.toList(); |
|
|
.toList(); |
|
|
|
|
|
|
|
|
//过滤除了这个删除的项目组之外的设备
|
|
|
//过滤除了这个删除的项目组之外的设备
|
|
|
deviceList = deviceList.stream().filter(p-> !p.getProId().equals(proId)).toList(); |
|
|
deviceList = deviceList.stream().filter(p-> !Integer.valueOf(p.get("proId") + "").equals(proId)).toList(); |
|
|
//删除
|
|
|
//删除
|
|
|
RedisUtils.deleteObject(String.format(Constants.PRO_DEVICE, proUserEntity.getUserId())); |
|
|
RedisUtils.deleteObject(String.format(Constants.PRO_DEVICE, proUserEntity.getUserId())); |
|
|
|
|
|
|
|
|
RedisUtils.setCacheList(String.format(String.format(Constants.PRO_DEVICE, proUserEntity.getUserId())),deviceList); |
|
|
RedisUtils.setCacheList(String.format(Constants.PRO_DEVICE, proUserEntity.getUserId()),deviceList); |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------缓存相关操作----------------------------------------------------------------
|
|
|
|
|
|
|
|
|
//先清除原来的项目组成员
|
|
|
//先清除原来的项目组成员
|
|
|
deviceProUserMapper.delete(new LambdaQueryWrapper<DeviceProUserEntity>().eq(DeviceProUserEntity::getDeviceProId, proId)); |
|
|
deviceProUserMapper.delete(new LambdaQueryWrapper<DeviceProUserEntity>().eq(DeviceProUserEntity::getDeviceProId, proId)); |
|
|
|
|
|
|
|
@ -186,13 +190,14 @@ public class DeviceProServiceImpl implements IDeviceProService { |
|
|
//更新缓存记录
|
|
|
//更新缓存记录
|
|
|
userEntity.forEach(proUserEntity -> { |
|
|
userEntity.forEach(proUserEntity -> { |
|
|
List<Object> projects = RedisUtils.getCacheList(String.format(Constants.PRO_GROUP, proUserEntity.getUserId())); |
|
|
List<Object> projects = RedisUtils.getCacheList(String.format(Constants.PRO_GROUP, proUserEntity.getUserId())); |
|
|
List<DeviceProEntity> projectList = projects.stream() |
|
|
List<Map> projectList = projects.stream() |
|
|
.filter(DeviceProEntity.class::isInstance) |
|
|
.filter(Map.class::isInstance) |
|
|
.map(DeviceProEntity.class::cast) |
|
|
.map(Map.class::cast) |
|
|
.toList(); |
|
|
.toList(); |
|
|
|
|
|
|
|
|
if (!projectList.stream().anyMatch(p-> p.getId().equals(proUserEntity.getDeviceProId()))){ |
|
|
if (!projectList.stream().anyMatch(p-> Integer.valueOf(p.get("id") + "").equals(proUserEntity.getDeviceProId()))){ |
|
|
RedisUtils.addCacheList(String.format(String.format(Constants.PRO_GROUP, proUserEntity.getUserId())), deviceProEntity); |
|
|
Map proMap = objectMapper.convertValue(deviceProEntity, Map.class); |
|
|
|
|
|
RedisUtils.addCacheList(String.format(String.format(Constants.PRO_GROUP, proUserEntity.getUserId())), proMap); |
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
@ -230,13 +235,15 @@ public class DeviceProServiceImpl implements IDeviceProService { |
|
|
List<DeviceProUserEntity> proUserEntityList = deviceProUserMapper.selectList(new LambdaQueryWrapper<DeviceProUserEntity>().eq(DeviceProUserEntity::getDeviceProId, proId)); |
|
|
List<DeviceProUserEntity> proUserEntityList = deviceProUserMapper.selectList(new LambdaQueryWrapper<DeviceProUserEntity>().eq(DeviceProUserEntity::getDeviceProId, proId)); |
|
|
proUserEntityList.forEach(deviceProUserEntity -> { |
|
|
proUserEntityList.forEach(deviceProUserEntity -> { |
|
|
List<Object> devices = RedisUtils.getCacheList(String.format(Constants.PRO_DEVICE, deviceProUserEntity.getUserId())); |
|
|
List<Object> devices = RedisUtils.getCacheList(String.format(Constants.PRO_DEVICE, deviceProUserEntity.getUserId())); |
|
|
List<DeviceEntity> deviceList = devices.stream() |
|
|
List<Map> deviceList = devices.stream() |
|
|
.filter(DeviceEntity.class::isInstance) |
|
|
.filter(Map.class::isInstance) |
|
|
.map(DeviceEntity.class::cast) |
|
|
.map(Map.class::cast) |
|
|
.toList(); |
|
|
.toList(); |
|
|
|
|
|
|
|
|
if (!deviceList.stream().anyMatch(p-> p.getId().equals(deviceEntity.getId()))){ |
|
|
if (!deviceList.stream().anyMatch(p-> Integer.valueOf(p.get("id") + "").equals(deviceEntity.getId()))){ |
|
|
RedisUtils.addCacheList(String.format(String.format(Constants.PRO_DEVICE, deviceProUserEntity.getUserId())), deviceEntity); |
|
|
Map deviceMap = objectMapper.convertValue(deviceEntity, Map.class); |
|
|
|
|
|
|
|
|
|
|
|
RedisUtils.addCacheList(String.format(String.format(Constants.PRO_DEVICE, deviceProUserEntity.getUserId())), deviceMap); |
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|