| | |
| | | import org.jeecg.modules.dnc.response.ProcessInfoCode; |
| | | import org.jeecg.modules.dnc.response.ProductInfoCode; |
| | | import org.jeecg.modules.dnc.response.UcenterCode; |
| | | import org.jeecg.modules.dnc.service.IPartsInfoService; |
| | | import org.jeecg.modules.dnc.service.IPermissionStreamService; |
| | | import org.jeecg.modules.dnc.service.IWorkStepDepartmentService; |
| | | import org.jeecg.modules.dnc.service.IWorkStepService; |
| | | import org.jeecg.modules.dnc.ucenter.Department; |
| | | import org.jeecg.modules.dnc.service.*; |
| | | import org.jeecg.modules.dnc.utils.ValidateUtil; |
| | | import org.jeecg.modules.system.entity.MdcProduction; |
| | | import org.jeecg.modules.system.entity.SysUser; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | |
| | | |
| | | @Autowired |
| | | private IWorkStepDepartmentService workStepDepartmentService; |
| | | |
| | | @Autowired |
| | | private IWorkStepPermissionService workStepPermissionService; |
| | | |
| | | @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); |
| | | //添加用户权限 |
| | | //添加用户权限 |
| | | b = productPermissionService.add(workStep.getId(), userId,"6"); |
| | | if (!b) { |
| | | ExceptionCast.cast(ProductInfoCode.PRODUCT_SAVE_ERROR); |
| | | } |
| | | //添加权限验证 |
| | | PermissionStream permissionStream = new PermissionStream(); |
| | | permissionStream.setUserId(userId); |
| | |
| | | return true; |
| | | } |
| | | |
| | | /** |
| | | * 删除工步信息 逻辑删除 |
| | | * @param id |
| | | * @return |
| | | */ |
| | | public boolean deleteWorkStep(String id){ |
| | | if(!ValidateUtil.validateString(id)) |
| | | ExceptionCast.cast(CommonCode.INVALID_PARAM); |
| | | WorkStep en = super.getById(id); |
| | | if(en == null) |
| | | ExceptionCast.cast(ProcessInfoCode.PROCESS_NOT_EXIST); |
| | | //验证是否存在文档 |
| | | List<DocRelative> docRelativeList=iDocRelativeService.list(new QueryWrapper<DocRelative>().eq("attribution_type","6").eq("attribution_id",id)); |
| | | if (!docRelativeList.isEmpty()){ |
| | | ExceptionCast.cast(ProcessInfoCode.WORKSTEP_HAS_DOC); |
| | | } |
| | | return super.removeById(id); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = {Exception.class}) |
| | | public boolean assignAddUser(WorkStep workStep, Collection<SysUser> userList) { |
| | | if(workStep == null || userList == null || userList.isEmpty()) |
| | | ExceptionCast.cast(CommonCode.INVALID_PARAM); |
| | | List<WorkStepPermission> permissionList = new ArrayList<>(); |
| | | List<PermissionStream> permissionStreamList = new ArrayList<>(); |
| | | userList.forEach(item -> { |
| | | WorkStepPermission en = workStepPermissionService.getByStepIdAndUserId(workStep.getId(), item.getId()); |
| | | if(en == null) { |
| | | en = new WorkStepPermission(); |
| | | en.setUserId(item.getId()); |
| | | en.setStepId(workStep.getId()); |
| | | permissionList.add(en); |
| | | } |
| | | PermissionStream stream = permissionStreamService.getByStepIdAndUserId(workStep.getProductId(), workStep.getComponentId(), workStep.getPartsId() |
| | | ,workStep.getProcessId(),workStep.getId(), item.getId()); |
| | | if(stream == null) { |
| | | stream = new PermissionStream(); |
| | | stream.setUserId(item.getId()); |
| | | stream.setProductId(workStep.getProductId()); |
| | | stream.setComponentId(workStep.getComponentId()); |
| | | stream.setPartsId(workStep.getPartsId()); |
| | | stream.setProcessId(workStep.getProcessId()); |
| | | stream.setStepId(workStep.getId()); |
| | | permissionStreamList.add(stream); |
| | | } |
| | | }); |
| | | if(!permissionList.isEmpty()) { |
| | | boolean b = workStepPermissionService.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(WorkStep workStep, Collection<SysUser> userList) { |
| | | if(workStep == null || userList == null || userList.isEmpty()) |
| | | ExceptionCast.cast(CommonCode.INVALID_PARAM); |
| | | List<WorkStepPermission> permissionList = new ArrayList<>(); |
| | | List<PermissionStream> 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()); |
| | | if(stream != null) { |
| | | permissionStreamList.add(stream); |
| | | } |
| | | }); |
| | | //清空用户权限校验 |
| | | if(!permissionList.isEmpty()) { |
| | | boolean b = workStepPermissionService.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; |
| | | } |
| | | |
| | | } |