| | |
| | | import org.jeecg.modules.dnc.response.*; |
| | | |
| | | import org.jeecg.modules.dnc.service.*; |
| | | import org.jeecg.modules.dnc.ucenter.Department; |
| | | import org.jeecg.modules.dnc.utils.ValidateUtil; |
| | | |
| | | |
| | | import org.jeecg.modules.dnc.request.ProcessStreamRequest; |
| | | import org.jeecg.modules.dnc.entity.*; |
| | | import org.jeecg.modules.system.entity.MdcProduction; |
| | | import org.jeecg.modules.system.entity.SysUser; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.context.annotation.Lazy; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | private IWorkStepService workStepService; |
| | | @Autowired |
| | | private IDocRelativeService iDocRelativeService; |
| | | @Autowired |
| | | private IProcessStreamPermissionService processStreamPermissionService; |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = {Exception.class}) |
| | |
| | | return true; |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = {Exception.class}) |
| | | public boolean assignAddUser(ProcessStream processStream, Collection<SysUser> userList) { |
| | | if(processStream == null || userList == null || userList.isEmpty()) |
| | | ExceptionCast.cast(CommonCode.INVALID_PARAM); |
| | | List<ProcessionPermission> permissionList = new ArrayList<>(); |
| | | List<PermissionStream> permissionStreamList = new ArrayList<>(); |
| | | userList.forEach(item -> { |
| | | ProcessionPermission en = processStreamPermissionService.getByProcessIdAndUserId(processStream.getProcessId(), item.getId()); |
| | | if(en == null) { |
| | | en = new ProcessionPermission(); |
| | | en.setUserId(item.getId()); |
| | | en.setProcessId(processStream.getProcessId()); |
| | | permissionList.add(en); |
| | | } |
| | | PermissionStream stream = permissionStreamService.getByProcessIdAndUserId(processStream.getProductId(), processStream.getComponentId(), processStream.getPartsId(),processStream.getProcessId(), item.getId()); |
| | | if(stream == null) { |
| | | stream = new PermissionStream(); |
| | | stream.setUserId(item.getId()); |
| | | stream.setProductId(processStream.getProductId()); |
| | | stream.setComponentId(processStream.getComponentId()); |
| | | stream.setPartsId(processStream.getPartsId()); |
| | | stream.setProcessId(processStream.getProcessId()); |
| | | permissionStreamList.add(stream); |
| | | } |
| | | }); |
| | | if(!permissionList.isEmpty()) { |
| | | boolean b = processStreamPermissionService.saveBatch(permissionList); |
| | | if(!b) { |
| | | ExceptionCast.cast(ProductInfoCode.PRODUCT_USER_PERM_ERROR); |
| | | } |
| | | } |
| | | if(!permissionStreamList.isEmpty()) { |
| | | boolean b = permissionStreamService.saveBatch(permissionStreamList); |
| | | if(!b) { |
| | | ExceptionCast.cast(ProductInfoCode.PRODUCT_USER_PERM_ERROR); |
| | | } |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = {Exception.class}) |
| | | public boolean assignRemoveUser(ProcessStream processStream, Collection<SysUser> userList) { |
| | | if(processStream == null || userList == null || userList.isEmpty()) |
| | | ExceptionCast.cast(CommonCode.INVALID_PARAM); |
| | | List<ProcessionPermission> permissionList = new ArrayList<>(); |
| | | List<PermissionStream> permissionStreamList = new ArrayList<>(); |
| | | userList.forEach(item -> { |
| | | ProcessionPermission en = processStreamPermissionService.getByProcessIdAndUserId(processStream.getProcessId(), item.getId()); |
| | | if(en != null) { |
| | | permissionList.add(en); |
| | | } |
| | | PermissionStream stream = permissionStreamService.getByProcessIdAndUserId(processStream.getProductId(), processStream.getComponentId(), processStream.getPartsId(),processStream.getProcessId(), item.getId()); |
| | | if(stream != null) { |
| | | permissionStreamList.add(stream); |
| | | } |
| | | }); |
| | | //清空用户权限校验 |
| | | if(!permissionList.isEmpty()) { |
| | | boolean b = processStreamPermissionService.removeByCollection(permissionList); |
| | | if(!b) { |
| | | ExceptionCast.cast(ProductInfoCode.PRODUCT_USER_PERM_ERROR); |
| | | } |
| | | } |
| | | if(!permissionStreamList.isEmpty()) { |
| | | boolean b = permissionStreamService.removeByCollection(permissionStreamList); |
| | | if(!b) { |
| | | ExceptionCast.cast(ProductInfoCode.PRODUCT_USER_PERM_ERROR); |
| | | } |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | } |