|
@ -88,7 +88,7 @@ public class DeviceProServiceImpl implements IDeviceProService { |
|
|
@Autowired |
|
|
@Autowired |
|
|
private IDeviceProUserMapper deviceProUserMapper; |
|
|
private IDeviceProUserMapper deviceProUserMapper; |
|
|
|
|
|
|
|
|
private final ObjectMapper objectMapper = new ObjectMapper(); |
|
|
// private final ObjectMapper objectMapper = new ObjectMapper();
|
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public PaginationData<DeviceProEntity> listDeviceProEntityMap(Page page, DeviceProDTO deviceProDTO) { |
|
|
public PaginationData<DeviceProEntity> listDeviceProEntityMap(Page page, DeviceProDTO deviceProDTO) { |
|
@ -131,52 +131,52 @@ public class DeviceProServiceImpl implements IDeviceProService { |
|
|
public Boolean updateDeviceProUser(List<DeviceProUserEntity> userEntity,Integer proId) { |
|
|
public Boolean updateDeviceProUser(List<DeviceProUserEntity> userEntity,Integer proId) { |
|
|
try { |
|
|
try { |
|
|
//获取项目组信息
|
|
|
//获取项目组信息
|
|
|
DeviceProEntity deviceProEntity = deviceProMapper.selectOne(new LambdaQueryWrapper<DeviceProEntity>().eq(DeviceProEntity::getId, proId)); |
|
|
// DeviceProEntity deviceProEntity = deviceProMapper.selectOne(new LambdaQueryWrapper<DeviceProEntity>().eq(DeviceProEntity::getId, proId));
|
|
|
|
|
|
|
|
|
//查询之前项目所属的人员信息
|
|
|
//查询之前项目所属的人员信息
|
|
|
List<DeviceProUserEntity> proUserEntityList = deviceProUserMapper.selectList(new LambdaQueryWrapper<DeviceProUserEntity>().eq(DeviceProUserEntity::getDeviceProId, proId)); |
|
|
// List<DeviceProUserEntity> proUserEntityList = deviceProUserMapper.selectList(new LambdaQueryWrapper<DeviceProUserEntity>().eq(DeviceProUserEntity::getDeviceProId, proId));
|
|
|
|
|
|
//
|
|
|
List<DeviceProUserEntity> difference = new ArrayList<>(); |
|
|
// List<DeviceProUserEntity> difference = new ArrayList<>();
|
|
|
|
|
|
|
|
|
// 判断两个集合的差值(基于 userId)
|
|
|
// 判断两个集合的差值(基于 userId)
|
|
|
difference = proUserEntityList.stream() |
|
|
// difference = proUserEntityList.stream()
|
|
|
.filter(proUser -> userEntity.stream() |
|
|
// .filter(proUser -> userEntity.stream()
|
|
|
.noneMatch(user -> user.getUserId().equals(proUser.getUserId()))) |
|
|
// .noneMatch(user -> user.getUserId().equals(proUser.getUserId())))
|
|
|
.toList(); |
|
|
// .toList();
|
|
|
|
|
|
|
|
|
//--------------------------------------------缓存相关操作----------------------------------------------------------------
|
|
|
//--------------------------------------------缓存相关操作----------------------------------------------------------------
|
|
|
|
|
|
|
|
|
//人员如果解绑了项目删除缓存数据
|
|
|
//人员如果解绑了项目删除缓存数据
|
|
|
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<Map> projectList = projects.stream() |
|
|
// List<Map> projectList = projects.stream()
|
|
|
.filter(Map.class::isInstance) |
|
|
// .filter(Map.class::isInstance)
|
|
|
.map(Map.class::cast) |
|
|
// .map(Map.class::cast)
|
|
|
.toList(); |
|
|
// .toList();
|
|
|
|
|
|
//
|
|
|
//删除人员中所拥有的当前的项目组,然后构建新的存入redis
|
|
|
// //删除人员中所拥有的当前的项目组,然后构建新的存入redis
|
|
|
List<Map> deviceProEntities = projectList.stream().filter(p -> !Integer.valueOf(p.get("id") + "").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()));
|
|
|
//重新插入
|
|
|
// //重新插入
|
|
|
RedisUtils.setCacheList(String.format(Constants.PRO_GROUP, proUserEntity.getUserId()),deviceProEntities); |
|
|
// RedisUtils.setCacheList(String.format(Constants.PRO_GROUP, proUserEntity.getUserId()),deviceProEntities);
|
|
|
|
|
|
//
|
|
|
|
|
|
//
|
|
|
//删除人员所拥有的设备信息
|
|
|
// //删除人员所拥有的设备信息
|
|
|
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<Map> deviceList = cacheList.stream() |
|
|
// List<Map> deviceList = cacheList.stream()
|
|
|
.filter(Map.class::isInstance) |
|
|
// .filter(Map.class::isInstance)
|
|
|
.map(Map.class::cast) |
|
|
// .map(Map.class::cast)
|
|
|
.toList(); |
|
|
// .toList();
|
|
|
|
|
|
//
|
|
|
//过滤除了这个删除的项目组之外的设备
|
|
|
// //过滤除了这个删除的项目组之外的设备
|
|
|
deviceList = deviceList.stream().filter(p-> !Integer.valueOf(p.get("proId") + "").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(Constants.PRO_DEVICE, proUserEntity.getUserId()),deviceList); |
|
|
// RedisUtils.setCacheList(String.format(Constants.PRO_DEVICE, proUserEntity.getUserId()),deviceList);
|
|
|
}); |
|
|
// });
|
|
|
|
|
|
|
|
|
//--------------------------------------------缓存相关操作----------------------------------------------------------------
|
|
|
//--------------------------------------------缓存相关操作----------------------------------------------------------------
|
|
|
|
|
|
|
|
@ -188,18 +188,18 @@ public class DeviceProServiceImpl implements IDeviceProService { |
|
|
deviceProUserMapper.insert(userEntity); |
|
|
deviceProUserMapper.insert(userEntity); |
|
|
|
|
|
|
|
|
//更新缓存记录
|
|
|
//更新缓存记录
|
|
|
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<Map> projectList = projects.stream() |
|
|
// List<Map> projectList = projects.stream()
|
|
|
.filter(Map.class::isInstance) |
|
|
// .filter(Map.class::isInstance)
|
|
|
.map(Map.class::cast) |
|
|
// .map(Map.class::cast)
|
|
|
.toList(); |
|
|
// .toList();
|
|
|
|
|
|
//
|
|
|
if (!projectList.stream().anyMatch(p-> Integer.valueOf(p.get("id") + "").equals(proUserEntity.getDeviceProId()))){ |
|
|
// if (!projectList.stream().anyMatch(p-> Integer.valueOf(p.get("id") + "").equals(proUserEntity.getDeviceProId()))){
|
|
|
Map proMap = objectMapper.convertValue(deviceProEntity, Map.class); |
|
|
// Map proMap = objectMapper.convertValue(deviceProEntity, Map.class);
|
|
|
RedisUtils.addCacheList(String.format(Constants.PRO_GROUP, proUserEntity.getUserId()), proMap); |
|
|
// RedisUtils.addCacheList(String.format(Constants.PRO_GROUP, proUserEntity.getUserId()), proMap);
|
|
|
} |
|
|
// }
|
|
|
}); |
|
|
// });
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
return true; |
|
|
return true; |
|
@ -229,29 +229,31 @@ public class DeviceProServiceImpl implements IDeviceProService { |
|
|
wrapper.set(DeviceEntity::getProId, proId); |
|
|
wrapper.set(DeviceEntity::getProId, proId); |
|
|
wrapper.eq(DeviceEntity::getId, deviceId); |
|
|
wrapper.eq(DeviceEntity::getId, deviceId); |
|
|
|
|
|
|
|
|
if (deviceMapper.update(wrapper) > 0) { |
|
|
|
|
|
DeviceEntity deviceEntity = deviceMapper.selectOne(new LambdaQueryWrapper<DeviceEntity>().eq(DeviceEntity::getId, deviceId)); |
|
|
return deviceMapper.update(wrapper) > 0; |
|
|
//根据proid获取人员用于存储人员的设备权限
|
|
|
|
|
|
List<DeviceProUserEntity> proUserEntityList = deviceProUserMapper.selectList(new LambdaQueryWrapper<DeviceProUserEntity>().eq(DeviceProUserEntity::getDeviceProId, proId)); |
|
|
|
|
|
proUserEntityList.forEach(deviceProUserEntity -> { |
|
|
// if (deviceMapper.update(wrapper) > 0) {
|
|
|
List<Object> devices = RedisUtils.getCacheList(String.format(Constants.PRO_DEVICE, deviceProUserEntity.getUserId())); |
|
|
// DeviceEntity deviceEntity = deviceMapper.selectOne(new LambdaQueryWrapper<DeviceEntity>().eq(DeviceEntity::getId, deviceId));
|
|
|
List<Map> deviceList = devices.stream() |
|
|
// //根据proid获取人员用于存储人员的设备权限
|
|
|
.filter(Map.class::isInstance) |
|
|
// List<DeviceProUserEntity> proUserEntityList = deviceProUserMapper.selectList(new LambdaQueryWrapper<DeviceProUserEntity>().eq(DeviceProUserEntity::getDeviceProId, proId));
|
|
|
.map(Map.class::cast) |
|
|
// proUserEntityList.forEach(deviceProUserEntity -> {
|
|
|
.toList(); |
|
|
// List<Object> devices = RedisUtils.getCacheList(String.format(Constants.PRO_DEVICE, deviceProUserEntity.getUserId()));
|
|
|
|
|
|
// List<Map> deviceList = devices.stream()
|
|
|
if (!deviceList.stream().anyMatch(p-> Integer.valueOf(p.get("id") + "").equals(deviceEntity.getId()))){ |
|
|
// .filter(Map.class::isInstance)
|
|
|
Map deviceMap = objectMapper.convertValue(deviceEntity, Map.class); |
|
|
// .map(Map.class::cast)
|
|
|
|
|
|
// .toList();
|
|
|
RedisUtils.addCacheList(String.format(Constants.PRO_DEVICE, deviceProUserEntity.getUserId()), deviceMap); |
|
|
//
|
|
|
} |
|
|
// if (!deviceList.stream().anyMatch(p-> Integer.valueOf(p.get("id") + "").equals(deviceEntity.getId()))){
|
|
|
}); |
|
|
// Map deviceMap = objectMapper.convertValue(deviceEntity, Map.class);
|
|
|
} |
|
|
//
|
|
|
|
|
|
// RedisUtils.addCacheList(String.format(Constants.PRO_DEVICE, deviceProUserEntity.getUserId()), deviceMap);
|
|
|
|
|
|
// }
|
|
|
|
|
|
// });
|
|
|
|
|
|
// }
|
|
|
} catch (Exception e) { |
|
|
} catch (Exception e) { |
|
|
return false; |
|
|
return false; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|