| | |
| | | @Autowired |
| | | private IDeviceGroupDepartService deviceGroupDepartService; |
| | | @Autowired |
| | | private IDepartmentService departmentService; |
| | | @Autowired |
| | | @Lazy |
| | | private IDeviceInfoService deviceInfoService; |
| | | @Autowired |
| | |
| | | return deviceGroupDepartService.getDepartNonPermsByGroupId(groupId); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = {Exception.class}) |
| | | public boolean assignAddDepartment(String groupId, Integer relativeFlag, String[] departmentIds) { |
| | | if(!ValidateUtil.validateString(groupId) || !ValidateUtil.validateInteger(relativeFlag) || departmentIds == null || departmentIds.length < 1) |
| | | ExceptionCast.cast(CommonCode.INVALID_PARAM); |
| | | List<String> ids = new ArrayList<>(departmentIds.length); |
| | | Collections.addAll(ids, departmentIds); |
| | | Collection<Department> departmentList = departmentService.listByIds(ids); |
| | | if(departmentList == null || departmentList.isEmpty() || departmentList.size() != departmentIds.length) |
| | | ExceptionCast.cast(CommonCode.INVALID_PARAM); |
| | | DeviceGroup deviceGroup = super.getById(groupId); |
| | | if(deviceGroup == null) |
| | | ExceptionCast.cast(DeviceGroupCode.DEVICE_GROUP_NOT_EXIST); |
| | | boolean b1 = deviceInfoService.checkDevicePerm(1, deviceGroup.getGroupId()); |
| | | if(!b1) { |
| | | ExceptionCast.cast(DeviceGroupCode.DEVICE_GROUP_PERM_ERROR); |
| | | } |
| | | b1 = assignAddDepartment(deviceGroup, departmentList); |
| | | if(!b1) { |
| | | ExceptionCast.cast(DeviceGroupCode.DEVICE_GROUP_PERM_ERROR); |
| | | } |
| | | if(relativeFlag == 1) { |
| | | //获取分组下所有的子分组 |
| | | List<DeviceGroup> childrenList = getChildrenByParentId(deviceGroup.getGroupId()); |
| | | if(childrenList != null && !childrenList.isEmpty()) { |
| | | childrenList.forEach(item -> { |
| | | boolean b = deviceInfoService.checkDevicePerm(1, item.getGroupId()); |
| | | if(b) { |
| | | b = assignAddDepartment(item, departmentList); |
| | | if(!b) { |
| | | ExceptionCast.cast(DeviceGroupCode.DEVICE_GROUP_PERM_ERROR); |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = {Exception.class}) |
| | | public boolean assignRemoveDepartment(String groupId, Integer relativeFlag, String[] departmentIds) { |
| | | if(!ValidateUtil.validateString(groupId) || !ValidateUtil.validateInteger(relativeFlag) || departmentIds == null || departmentIds.length < 1) |
| | | ExceptionCast.cast(CommonCode.INVALID_PARAM); |
| | | List<String> ids = new ArrayList<>(departmentIds.length); |
| | | Collections.addAll(ids, departmentIds); |
| | | Collection<Department> departmentList = departmentService.listByIds(ids); |
| | | if(departmentList == null || departmentList.isEmpty() || departmentList.size() != departmentIds.length) |
| | | ExceptionCast.cast(CommonCode.INVALID_PARAM); |
| | | DeviceGroup deviceGroup = super.getById(groupId); |
| | | if(deviceGroup == null) |
| | | ExceptionCast.cast(DeviceGroupCode.DEVICE_GROUP_NOT_EXIST); |
| | | boolean b1 = deviceInfoService.checkDevicePerm(1, deviceGroup.getGroupId()); |
| | | if(!b1) { |
| | | ExceptionCast.cast(DeviceGroupCode.DEVICE_GROUP_PERM_ERROR); |
| | | } |
| | | b1 = assignRemoveDepartment(deviceGroup, departmentList); |
| | | if(!b1) { |
| | | ExceptionCast.cast(DeviceGroupCode.DEVICE_GROUP_PERM_ERROR); |
| | | } |
| | | if(relativeFlag == 1) { |
| | | //获取分组下所有的子分组 |
| | | List<DeviceGroup> childrenList = getChildrenByParentId(deviceGroup.getGroupId()); |
| | | if(childrenList != null && !childrenList.isEmpty()) { |
| | | childrenList.forEach(item -> { |
| | | boolean b = deviceInfoService.checkDevicePerm(1, item.getGroupId()); |
| | | if(b) { |
| | | b = assignRemoveDepartment(item, departmentList); |
| | | if(!b) { |
| | | ExceptionCast.cast(DeviceGroupCode.DEVICE_GROUP_PERM_ERROR); |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | } |
| | | return true; |
| | | } |
| | | // @Override |
| | | // @Transactional(rollbackFor = {Exception.class}) |
| | | // public boolean assignAddDepartment(String groupId, Integer relativeFlag, String[] departmentIds) { |
| | | // if(!ValidateUtil.validateString(groupId) || !ValidateUtil.validateInteger(relativeFlag) || departmentIds == null || departmentIds.length < 1) |
| | | // ExceptionCast.cast(CommonCode.INVALID_PARAM); |
| | | // List<String> ids = new ArrayList<>(departmentIds.length); |
| | | // Collections.addAll(ids, departmentIds); |
| | | // Collection<Department> departmentList = departmentService.listByIds(ids); |
| | | // if(departmentList == null || departmentList.isEmpty() || departmentList.size() != departmentIds.length) |
| | | // ExceptionCast.cast(CommonCode.INVALID_PARAM); |
| | | // DeviceGroup deviceGroup = super.getById(groupId); |
| | | // if(deviceGroup == null) |
| | | // ExceptionCast.cast(DeviceGroupCode.DEVICE_GROUP_NOT_EXIST); |
| | | // boolean b1 = deviceInfoService.checkDevicePerm(1, deviceGroup.getGroupId()); |
| | | // if(!b1) { |
| | | // ExceptionCast.cast(DeviceGroupCode.DEVICE_GROUP_PERM_ERROR); |
| | | // } |
| | | // b1 = assignAddDepartment(deviceGroup, departmentList); |
| | | // if(!b1) { |
| | | // ExceptionCast.cast(DeviceGroupCode.DEVICE_GROUP_PERM_ERROR); |
| | | // } |
| | | // if(relativeFlag == 1) { |
| | | // //获取分组下所有的子分组 |
| | | // List<DeviceGroup> childrenList = getChildrenByParentId(deviceGroup.getGroupId()); |
| | | // if(childrenList != null && !childrenList.isEmpty()) { |
| | | // childrenList.forEach(item -> { |
| | | // boolean b = deviceInfoService.checkDevicePerm(1, item.getGroupId()); |
| | | // if(b) { |
| | | // b = assignAddDepartment(item, departmentList); |
| | | // if(!b) { |
| | | // ExceptionCast.cast(DeviceGroupCode.DEVICE_GROUP_PERM_ERROR); |
| | | // } |
| | | // } |
| | | // }); |
| | | // } |
| | | // } |
| | | // return true; |
| | | // } |
| | | // |
| | | // @Override |
| | | // @Transactional(rollbackFor = {Exception.class}) |
| | | // public boolean assignRemoveDepartment(String groupId, Integer relativeFlag, String[] departmentIds) { |
| | | // if(!ValidateUtil.validateString(groupId) || !ValidateUtil.validateInteger(relativeFlag) || departmentIds == null || departmentIds.length < 1) |
| | | // ExceptionCast.cast(CommonCode.INVALID_PARAM); |
| | | // List<String> ids = new ArrayList<>(departmentIds.length); |
| | | // Collections.addAll(ids, departmentIds); |
| | | // Collection<Department> departmentList = departmentService.listByIds(ids); |
| | | // if(departmentList == null || departmentList.isEmpty() || departmentList.size() != departmentIds.length) |
| | | // ExceptionCast.cast(CommonCode.INVALID_PARAM); |
| | | // DeviceGroup deviceGroup = super.getById(groupId); |
| | | // if(deviceGroup == null) |
| | | // ExceptionCast.cast(DeviceGroupCode.DEVICE_GROUP_NOT_EXIST); |
| | | // boolean b1 = deviceInfoService.checkDevicePerm(1, deviceGroup.getGroupId()); |
| | | // if(!b1) { |
| | | // ExceptionCast.cast(DeviceGroupCode.DEVICE_GROUP_PERM_ERROR); |
| | | // } |
| | | // b1 = assignRemoveDepartment(deviceGroup, departmentList); |
| | | // if(!b1) { |
| | | // ExceptionCast.cast(DeviceGroupCode.DEVICE_GROUP_PERM_ERROR); |
| | | // } |
| | | // if(relativeFlag == 1) { |
| | | // //获取分组下所有的子分组 |
| | | // List<DeviceGroup> childrenList = getChildrenByParentId(deviceGroup.getGroupId()); |
| | | // if(childrenList != null && !childrenList.isEmpty()) { |
| | | // childrenList.forEach(item -> { |
| | | // boolean b = deviceInfoService.checkDevicePerm(1, item.getGroupId()); |
| | | // if(b) { |
| | | // b = assignRemoveDepartment(item, departmentList); |
| | | // if(!b) { |
| | | // ExceptionCast.cast(DeviceGroupCode.DEVICE_GROUP_PERM_ERROR); |
| | | // } |
| | | // } |
| | | // }); |
| | | // } |
| | | // } |
| | | // return true; |
| | | // } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = {Exception.class}) |