| | |
| | | */ |
| | | @Service |
| | | public class WorkStepServiceImpl extends ServiceImpl<WorkStepMapper, WorkStep> implements IWorkStepService { |
| | | |
| | | @Autowired |
| | | private IPermissionStreamService permissionStreamService; |
| | | private IPermissionStreamNewService permissionStreamNewService; |
| | | |
| | | @Autowired |
| | | private IWorkStepDepartmentService workStepDepartmentService; |
| | |
| | | |
| | | @Autowired |
| | | private IDocRelativeService iDocRelativeService; |
| | | |
| | | @Autowired |
| | | private IProductPermissionService productPermissionService; |
| | | |
| | | @Override |
| | | public List<WorkStep> getByUserPerms(String userId) { |
| | |
| | | boolean b =super.save(workStep); |
| | | if(!b) |
| | | ExceptionCast.cast(CommonCode.FAIL); |
| | | //添加权限验证 |
| | | PermissionStream permissionStream = new PermissionStream(); |
| | | permissionStream.setUserId(userId); |
| | | permissionStream.setProductId(workStep.getProductId()); |
| | | permissionStream.setComponentId(workStep.getComponentId()); |
| | | if (StrUtil.isNotEmpty(workStep.getPartsId())){ |
| | | permissionStream.setPartsId(workStep.getPartsId()); |
| | | //添加部门权限 |
| | | List<PermissionStreamNew> oldDepartPermList = permissionStreamNewService.loadPermissionStreamNewByBusinessId(workStep.getProcessId(),"5","1"); |
| | | if(oldDepartPermList != null && !oldDepartPermList.isEmpty()) { |
| | | List<WorkStepDepartment> workStepDepartmentList = new ArrayList<>(); |
| | | List<PermissionStreamNew> permissionStreamList = new ArrayList<>(); |
| | | oldDepartPermList.forEach(item -> { |
| | | WorkStepDepartment pd = new WorkStepDepartment(); |
| | | pd.setDepartId(item.getDepartId()); |
| | | pd.setStepId(workStep.getId()); |
| | | workStepDepartmentList.add(pd); |
| | | PermissionStreamNew perm = new PermissionStreamNew(); |
| | | perm.setBusinessId(workStep.getId()); |
| | | perm.setBusinessType("6"); |
| | | permissionStreamList.add(perm); |
| | | }); |
| | | if(!workStepDepartmentList.isEmpty()) { |
| | | b = workStepDepartmentService.saveBatch(workStepDepartmentList); |
| | | if(!b) |
| | | ExceptionCast.cast(CommonCode.FAIL); |
| | | } |
| | | if(!permissionStreamList.isEmpty()) { |
| | | b = permissionStreamNewService.saveBatch(permissionStreamList); |
| | | if(!b) |
| | | ExceptionCast.cast(CommonCode.FAIL); |
| | | } |
| | | } |
| | | permissionStream.setProcessId(workStep.getProcessId()); |
| | | permissionStream.setStepId(workStep.getId()); |
| | | return permissionStreamService.save(permissionStream); |
| | | //添加用户权限 |
| | | b = productPermissionService.add(workStep.getId(), userId,"6"); |
| | | if (!b) { |
| | | ExceptionCast.cast(ProductInfoCode.PRODUCT_SAVE_ERROR); |
| | | } |
| | | //添加权限验证 |
| | | PermissionStreamNew permissionStream = new PermissionStreamNew(); |
| | | permissionStream.setUserId(userId); |
| | | permissionStream.setBusinessId(workStep.getId()); |
| | | permissionStream.setBusinessType("6"); |
| | | return permissionStreamNewService.save(permissionStream); |
| | | } |
| | | |
| | | /** |
| | |
| | | WorkStep en = super.getById(id); |
| | | if(en == null) |
| | | ExceptionCast.cast(ProcessInfoCode.WORKSTEP_NOT_EXIST); |
| | | // workStep.setStepId(id); |
| | | // workStep.setProductId(null); |
| | | // workStep.setComponentId(null); |
| | | // workStep.setPartsId(null); |
| | | // workStep.setProcessId(null); |
| | | // workStep.setStepName(workStep.getStepName().toUpperCase()); |
| | | // workStep.setStepCode(null); |
| | | return super.updateById(workStep); |
| | | } |
| | | |
| | |
| | | if(workStep == null || departmentList == null || departmentList.isEmpty()) |
| | | ExceptionCast.cast(CommonCode.INVALID_PARAM); |
| | | List<WorkStepDepartment> workStepDepartmentList = new ArrayList<>(); |
| | | List<PermissionStream> permissionStreamList = new ArrayList<>(); |
| | | List<PermissionStreamNew> permissionStreamList = new ArrayList<>(); |
| | | departmentList.forEach(item -> { |
| | | WorkStepDepartment en = workStepDepartmentService.getByStepIdAndDepartId(workStep.getId(), item.getId()); |
| | | if(en == null) { |
| | |
| | | en.setStepId(workStep.getId()); |
| | | workStepDepartmentList.add(en); |
| | | } |
| | | PermissionStream stream = permissionStreamService.getByStepIdAndDepartId(workStep.getProductId(), workStep.getComponentId(), workStep.getPartsId(),workStep.getProcessId(),workStep.getId(),item.getId()); |
| | | PermissionStreamNew stream = permissionStreamNewService.loadPermissionStreamNewByBusinessIdAndDepartId(workStep.getId(),item.getId(),"6"); |
| | | if(stream == null) { |
| | | stream = new PermissionStream(); |
| | | stream = new PermissionStreamNew(); |
| | | stream.setDepartId(item.getId()); |
| | | stream.setProductId(workStep.getProductId()); |
| | | stream.setComponentId(workStep.getComponentId()); |
| | | stream.setPartsId(workStep.getPartsId()); |
| | | stream.setProcessId(workStep.getProcessId()); |
| | | stream.setStepId(workStep.getId()); |
| | | |
| | | stream.setBusinessId(workStep.getId()); |
| | | stream.setBusinessType("6"); |
| | | permissionStreamList.add(stream); |
| | | } |
| | | }); |
| | |
| | | } |
| | | } |
| | | if(!permissionStreamList.isEmpty()) { |
| | | boolean b = permissionStreamService.saveBatch(permissionStreamList); |
| | | boolean b = permissionStreamNewService.saveBatch(permissionStreamList); |
| | | if(!b) { |
| | | ExceptionCast.cast(ProductInfoCode.PRODUCT_USER_PERM_ERROR); |
| | | } |
| | |
| | | if(workStep == null || departmentList == null || departmentList.isEmpty()) |
| | | ExceptionCast.cast(CommonCode.INVALID_PARAM); |
| | | List<WorkStepDepartment> workStepDepartmentList = new ArrayList<>(); |
| | | List<PermissionStream> permissionStreamList = new ArrayList<>(); |
| | | List<PermissionStreamNew> permissionStreamList = new ArrayList<>(); |
| | | departmentList.forEach(item -> { |
| | | WorkStepDepartment en = workStepDepartmentService.getByStepIdAndDepartId(workStep.getId(), item.getId()); |
| | | if(en != null) { |
| | | workStepDepartmentList.add(en); |
| | | } |
| | | PermissionStream stream = permissionStreamService.getByStepIdAndDepartId(workStep.getProductId(), workStep.getComponentId(), workStep.getPartsId() |
| | | ,workStep.getProcessId(),workStep.getId(), item.getId()); |
| | | PermissionStreamNew stream = permissionStreamNewService.loadPermissionStreamNewByBusinessIdAndDepartId(workStep.getId(),item.getId(),"6"); |
| | | if(stream != null) { |
| | | permissionStreamList.add(stream); |
| | | } |
| | |
| | | } |
| | | } |
| | | if(!permissionStreamList.isEmpty()) { |
| | | boolean b = permissionStreamService.removeByCollection(permissionStreamList); |
| | | boolean b = permissionStreamNewService.deletePermissionStreamNewByList(permissionStreamList); |
| | | if(!b) { |
| | | ExceptionCast.cast(ProductInfoCode.PRODUCT_USER_PERM_ERROR); |
| | | } |
| | |
| | | if(workStep == null || userList == null || userList.isEmpty()) |
| | | ExceptionCast.cast(CommonCode.INVALID_PARAM); |
| | | List<WorkStepPermission> permissionList = new ArrayList<>(); |
| | | List<PermissionStream> permissionStreamList = new ArrayList<>(); |
| | | List<PermissionStreamNew> permissionStreamList = new ArrayList<>(); |
| | | userList.forEach(item -> { |
| | | WorkStepPermission en = workStepPermissionService.getByStepIdAndUserId(workStep.getId(), item.getId()); |
| | | if(en == null) { |
| | |
| | | en.setStepId(workStep.getId()); |
| | | permissionList.add(en); |
| | | } |
| | | PermissionStream stream = permissionStreamService.getByStepIdAndUserId(workStep.getProductId(), workStep.getComponentId(), workStep.getPartsId() |
| | | ,workStep.getProcessId(),workStep.getId(), item.getId()); |
| | | PermissionStreamNew stream = permissionStreamNewService.loadPermissionStreamNewByBusinessIdAndUserId(workStep.getId(),item.getId(),"6"); |
| | | if(stream == null) { |
| | | stream = new PermissionStream(); |
| | | stream = new PermissionStreamNew(); |
| | | stream.setUserId(item.getId()); |
| | | stream.setProductId(workStep.getProductId()); |
| | | stream.setComponentId(workStep.getComponentId()); |
| | | stream.setPartsId(workStep.getPartsId()); |
| | | stream.setProcessId(workStep.getProcessId()); |
| | | stream.setStepId(workStep.getId()); |
| | | stream.setBusinessId(workStep.getId()); |
| | | stream.setBusinessType("6"); |
| | | permissionStreamList.add(stream); |
| | | } |
| | | }); |
| | |
| | | } |
| | | } |
| | | if(!permissionStreamList.isEmpty()) { |
| | | boolean b = permissionStreamService.saveBatch(permissionStreamList); |
| | | boolean b = permissionStreamNewService.saveBatch(permissionStreamList); |
| | | if(!b) { |
| | | ExceptionCast.cast(ProductInfoCode.PRODUCT_USER_PERM_ERROR); |
| | | } |
| | |
| | | if(workStep == null || userList == null || userList.isEmpty()) |
| | | ExceptionCast.cast(CommonCode.INVALID_PARAM); |
| | | List<WorkStepPermission> permissionList = new ArrayList<>(); |
| | | List<PermissionStream> permissionStreamList = new ArrayList<>(); |
| | | List<PermissionStreamNew> permissionStreamList = new ArrayList<>(); |
| | | userList.forEach(item -> { |
| | | WorkStepPermission en = workStepPermissionService.getByStepIdAndUserId(workStep.getId(), item.getId()); |
| | | if(en != null) { |
| | | permissionList.add(en); |
| | | } |
| | | PermissionStream stream = permissionStreamService.getByStepIdAndUserId(workStep.getProductId(), workStep.getComponentId(), |
| | | workStep.getPartsId(),workStep.getProcessId(), workStep.getId(),item.getId()); |
| | | PermissionStreamNew stream = permissionStreamNewService.loadPermissionStreamNewByBusinessIdAndUserId(workStep.getId(),item.getId(),"6"); |
| | | if(stream != null) { |
| | | permissionStreamList.add(stream); |
| | | } |
| | |
| | | } |
| | | } |
| | | if(!permissionStreamList.isEmpty()) { |
| | | boolean b = permissionStreamService.removeByCollection(permissionStreamList); |
| | | boolean b = permissionStreamNewService.deletePermissionStreamNewByList(permissionStreamList); |
| | | if(!b) { |
| | | ExceptionCast.cast(ProductInfoCode.PRODUCT_USER_PERM_ERROR); |
| | | } |