| | |
| | | @Autowired |
| | | private IPartsPermissionService partsPermissionService; |
| | | @Autowired |
| | | private IPermissionStreamService permissionStreamService; |
| | | private IPermissionStreamNewService permissionStreamNewService; |
| | | @Autowired |
| | | private IPartsDepartmentService partsDepartmentService; |
| | | @Autowired |
| | | @Lazy |
| | | private IProcessStreamService processStreamService; |
| | | @Autowired |
| | | private IDocInfoService docInfoService; |
| | | @Autowired |
| | | private INcLogInfoService iNcLogInfoService; |
| | | private IProcessSpecVersionService processSpecVersionService; |
| | | @Autowired |
| | | private IDocRelativeService iDocRelativeService; |
| | | @Autowired |
| | | private IProductPermissionService productPermissionService; |
| | | @Override |
| | | @Transactional(rollbackFor = {Exception.class}) |
| | | public boolean addPartsInfo(PartsInfo partsInfo) { |
| | |
| | | if(componentInfo == null) |
| | | ExceptionCast.cast(PartsInfoCode.PARTS_COMPONENT_NONE); |
| | | partsInfo.setPartsStatus(1); |
| | | //添加日志 |
| | | NcLogInfo ncLogInfo = new NcLogInfo(); |
| | | //模块 |
| | | ncLogInfo.setModuleInfo("产品结构树"); |
| | | //类型 |
| | | ncLogInfo.setOperateType(2); |
| | | //日志内容 |
| | | ncLogInfo.setLogContent("零件名称:"+partsInfo.getPartsName()+",零件代号:"+partsInfo.getPartsCode()); |
| | | iNcLogInfoService.saveLogNcInfos(ncLogInfo); |
| | | boolean b = super.save(partsInfo); |
| | | List<PermissionStream> oldDepartPermList = permissionStreamService.getByComponentId(componentInfo.getProductId(), componentInfo.getComponentId()); |
| | | List<PermissionStreamNew> oldDepartPermList = permissionStreamNewService.loadPermissionStreamNewByBusinessId(componentInfo.getComponentId(),"2","1"); |
| | | if(oldDepartPermList != null && !oldDepartPermList.isEmpty()) { |
| | | List<PartsDepartment> partsDepartmentList = new ArrayList<>(); |
| | | List<PermissionStream> permissionStreamList = new ArrayList<>(); |
| | | List<PermissionStreamNew> permissionStreamList = new ArrayList<>(); |
| | | oldDepartPermList.forEach(item -> { |
| | | PartsDepartment pd = new PartsDepartment(); |
| | | pd.setDepartId(item.getDepartId()); |
| | | pd.setPartsId(partsInfo.getPartsId()); |
| | | partsDepartmentList.add(pd); |
| | | PermissionStream perm = new PermissionStream(); |
| | | PermissionStreamNew perm = new PermissionStreamNew(); |
| | | perm.setDepartId(item.getDepartId()); |
| | | perm.setProductId(partsInfo.getProductId()); |
| | | perm.setComponentId(partsInfo.getComponentId()); |
| | | perm.setPartsId(partsInfo.getPartsId()); |
| | | perm.setBusinessId(partsInfo.getPartsId()); |
| | | perm.setBusinessType("3"); |
| | | permissionStreamList.add(perm); |
| | | }); |
| | | if(!partsDepartmentList.isEmpty()) { |
| | |
| | | ExceptionCast.cast(CommonCode.FAIL); |
| | | } |
| | | if(!permissionStreamList.isEmpty()) { |
| | | b = permissionStreamService.saveBatch(permissionStreamList); |
| | | b = permissionStreamNewService.saveBatch(permissionStreamList); |
| | | if(!b) |
| | | ExceptionCast.cast(CommonCode.FAIL); |
| | | } |
| | | } |
| | | if(!b) |
| | | ExceptionCast.cast(CommonCode.FAIL); |
| | | PartsPermission permission = new PartsPermission(); |
| | | permission.setPartsId(partsInfo.getPartsId()); |
| | | permission.setUserId(userId); |
| | | b = partsPermissionService.save(permission); |
| | | if(!b) |
| | | ExceptionCast.cast(CommonCode.FAIL); |
| | | // if(!b) |
| | | // ExceptionCast.cast(CommonCode.FAIL); |
| | | b = productPermissionService.add(partsInfo.getPartsId(), userId,"3"); |
| | | if (!b) { |
| | | ExceptionCast.cast(ProductInfoCode.PRODUCT_SAVE_ERROR); |
| | | } |
| | | //添加用户权限 |
| | | PermissionStream stream = new PermissionStream(); |
| | | stream.setProductId(partsInfo.getProductId()); |
| | | stream.setComponentId(partsInfo.getComponentId()); |
| | | stream.setPartsId(partsInfo.getPartsId()); |
| | | PermissionStreamNew stream = new PermissionStreamNew(); |
| | | stream.setBusinessId(partsInfo.getPartsId()); |
| | | stream.setBusinessType("3"); |
| | | stream.setUserId(userId); |
| | | // //添加日志 |
| | | // NcLogInfo ncLogInfogx = new NcLogInfo(); |
| | | // //模块 |
| | | // ncLogInfogx.setModuleInfo("产品结构树"); |
| | | // //类型 |
| | | // ncLogInfogx.setOperateType(2); |
| | | // //日志内容 |
| | | // ncLogInfogx.setLogContent("零件名称:"+partsInfo.getPartsName()+"生成默认工序,工序号:"+processStream.getProcessCode()); |
| | | // iNcLogInfoService.saveLogNcInfos(ncLogInfogx); |
| | | return permissionStreamService.save(stream); |
| | | return permissionStreamNewService.save(stream); |
| | | } |
| | | |
| | | @Override |
| | |
| | | partsInfo.setPartsStatus(null); |
| | | partsInfo.setProductId(null); |
| | | partsInfo.setComponentId(null); |
| | | //添加日志 |
| | | NcLogInfo ncLogInfo = new NcLogInfo(); |
| | | //模块 |
| | | ncLogInfo.setModuleInfo("产品结构树"); |
| | | //类型 |
| | | ncLogInfo.setOperateType(3); |
| | | //修改保存备注 |
| | | ncLogInfo.setRemark(JSONObject.toJSONString(en)); |
| | | //日志内容 |
| | | ncLogInfo.setLogContent("修改部件名称:"+productInfoMapper.selectById(en.getProductId()).getProductName()+"子集零件"); |
| | | iNcLogInfoService.saveLogNcInfos(ncLogInfo); |
| | | boolean b = super.updateById(partsInfo); |
| | | if(!b) |
| | | return false; |
| | |
| | | if(!b) |
| | | return false; |
| | | } |
| | | PermissionStream stream = permissionStreamService.getByPartsIdAndUserId(en.getProductId(), en.getComponentId(), id, userId); |
| | | PermissionStreamNew stream = permissionStreamNewService.loadPermissionStreamNewByBusinessIdAndUserId( id, userId,"3"); |
| | | if(stream == null) { |
| | | stream = new PermissionStream(); |
| | | stream.setProductId(en.getProductId()); |
| | | stream.setComponentId(en.getComponentId()); |
| | | stream.setPartsId(id); |
| | | stream = new PermissionStreamNew(); |
| | | stream.setBusinessId(id); |
| | | stream.setBusinessType("3"); |
| | | stream.setUserId(userId); |
| | | return permissionStreamService.save(stream); |
| | | return permissionStreamNewService.save(stream); |
| | | } |
| | | return b; |
| | | } |
| | |
| | | b = partsDepartmentService.deleteByPartsId(item.getPartsId()); |
| | | if(!b) |
| | | ExceptionCast.cast(PartsInfoCode.PARTS_DELETE_ERROR); |
| | | b = permissionStreamService.deleteUserPermsByPartsId(item.getProductId(), item.getComponentId(), item.getPartsId()); |
| | | b = permissionStreamNewService.deletePermissionStreamNewByBusinessId(item.getPartsId(),"3","0"); |
| | | if(!b) |
| | | ExceptionCast.cast(PartsInfoCode.PARTS_DELETE_ERROR); |
| | | b = permissionStreamService.deleteDepartPermsByPartsId(item.getProductId(), item.getComponentId(), item.getPartsId()); |
| | | b = permissionStreamNewService.deletePermissionStreamNewByBusinessId(item.getPartsId(),"3","1"); |
| | | if(!b) |
| | | ExceptionCast.cast(PartsInfoCode.PARTS_DELETE_ERROR); |
| | | b = super.removeById(item.getPartsId()); |
| | |
| | | PartsInfo partsInfo = super.getById(partsId); |
| | | if(partsInfo == null) |
| | | ExceptionCast.cast(PartsInfoCode.PARTS_NOT_EXIST); |
| | | List<ProcessStream> processStreams = processStreamService.findByPartsId(partsId); |
| | | if(processStreams != null && !processStreams.isEmpty()) |
| | | List<ProcessSpecVersion> processSpecVersions = processSpecVersionService.getByPartsId(partsId); |
| | | if(processSpecVersions != null && !processSpecVersions.isEmpty()) |
| | | ExceptionCast.cast(PartsInfoCode.PARTS_PROCESS_EXIST); |
| | | boolean b = partsPermissionService.deleteByPartsId(partsInfo.getPartsId()); |
| | | //验证是否存在文档 |
| | |
| | | b = partsDepartmentService.deleteByPartsId(partsInfo.getPartsId()); |
| | | if(!b) |
| | | ExceptionCast.cast(CommonCode.FAIL); |
| | | b = permissionStreamService.deleteUserPermsByPartsId(partsInfo.getProductId(), partsInfo.getComponentId(), partsInfo.getPartsId()); |
| | | b = permissionStreamNewService.deletePermissionStreamNewByBusinessId(partsId,"3","0"); |
| | | if(!b) |
| | | ExceptionCast.cast(CommonCode.FAIL); |
| | | b = permissionStreamService.deleteDepartPermsByPartsId(partsInfo.getProductId(), partsInfo.getComponentId(), partsInfo.getPartsId()); |
| | | b = permissionStreamNewService.deletePermissionStreamNewByBusinessId(partsId,"3","1"); |
| | | if(!b) |
| | | ExceptionCast.cast(CommonCode.FAIL); |
| | | return super.removeById(partsInfo.getPartsId()); |
| | |
| | | if(partsInfo == null || userList == null || userList.isEmpty()) |
| | | ExceptionCast.cast(CommonCode.INVALID_PARAM); |
| | | List<PartsPermission> permissionList = new ArrayList<>(); |
| | | List<PermissionStream> permissionStreamList = new ArrayList<>(); |
| | | List<PermissionStreamNew> permissionStreamList = new ArrayList<>(); |
| | | userList.forEach(item -> { |
| | | PartsPermission en = partsPermissionService.getByPartsIdAndUserId(partsInfo.getPartsId(), item.getId()); |
| | | if(en == null) { |
| | |
| | | en.setPartsId(partsInfo.getPartsId()); |
| | | permissionList.add(en); |
| | | } |
| | | PermissionStream stream = permissionStreamService.getByPartsIdAndUserId(partsInfo.getProductId(), partsInfo.getComponentId(), partsInfo.getPartsId(), item.getId()); |
| | | PermissionStreamNew stream = permissionStreamNewService.loadPermissionStreamNewByBusinessIdAndUserId(partsInfo.getPartsId(), item.getId(),"3"); |
| | | if(stream == null) { |
| | | stream = new PermissionStream(); |
| | | stream = new PermissionStreamNew(); |
| | | stream.setUserId(item.getId()); |
| | | stream.setProductId(partsInfo.getProductId()); |
| | | stream.setComponentId(partsInfo.getComponentId()); |
| | | stream.setPartsId(partsInfo.getPartsId()); |
| | | stream.setBusinessId(partsInfo.getPartsId()); |
| | | stream.setBusinessType("3"); |
| | | 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(partsInfo == null || userList == null || userList.isEmpty()) |
| | | ExceptionCast.cast(CommonCode.INVALID_PARAM); |
| | | List<PartsPermission> permissionList = new ArrayList<>(); |
| | | List<PermissionStream> permissionStreamList = new ArrayList<>(); |
| | | List<PermissionStreamNew> permissionStreamList = new ArrayList<>(); |
| | | userList.forEach(item -> { |
| | | PartsPermission en = partsPermissionService.getByPartsIdAndUserId(partsInfo.getPartsId(), item.getId()); |
| | | if(en != null) { |
| | | permissionList.add(en); |
| | | } |
| | | PermissionStream stream = permissionStreamService.getByPartsIdAndUserId(partsInfo.getProductId(), partsInfo.getComponentId(), partsInfo.getPartsId(), item.getId()); |
| | | PermissionStreamNew stream = permissionStreamNewService.loadPermissionStreamNewByBusinessIdAndUserId(partsInfo.getPartsId(), item.getId(),"3"); |
| | | if(stream != null) { |
| | | permissionStreamList.add(stream); |
| | | } |
| | | }); |
| | | //清空用户权限校验 |
| | | /*List<PartsPermission> exitsList = partsPermissionService.getByPartsId(partsInfo.getPartsId()); |
| | | if(exitsList.size() <= permissionList.size()) |
| | | ExceptionCast.cast(PartsInfoCode.PARTS_USER_NONE);*/ |
| | | if(!permissionList.isEmpty()) { |
| | | boolean b = partsPermissionService.removeByCollection(permissionList); |
| | | if(!b) { |
| | |
| | | } |
| | | } |
| | | if(!permissionStreamList.isEmpty()) { |
| | | boolean b = permissionStreamService.removeByCollection(permissionStreamList); |
| | | boolean b = permissionStreamNewService.deletePermissionStreamNewByList(permissionStreamList); |
| | | if(!b) { |
| | | ExceptionCast.cast(ProductInfoCode.PRODUCT_USER_PERM_ERROR); |
| | | } |
| | |
| | | if(partsInfo == null || departmentList == null || departmentList.isEmpty()) |
| | | ExceptionCast.cast(CommonCode.INVALID_PARAM); |
| | | List<PartsDepartment> partsDepartments = new ArrayList<>(); |
| | | List<PermissionStream> permissionStreamList = new ArrayList<>(); |
| | | List<PermissionStreamNew> permissionStreamList = new ArrayList<>(); |
| | | departmentList.forEach(item -> { |
| | | PartsDepartment en = partsDepartmentService.getByPartsIdAndDepartId(partsInfo.getPartsId(), item.getId()); |
| | | if(en == null) { |
| | |
| | | en.setPartsId(partsInfo.getPartsId()); |
| | | partsDepartments.add(en); |
| | | } |
| | | PermissionStream stream = permissionStreamService.getByPartsIdAndDepartId(partsInfo.getProductId(), partsInfo.getComponentId(), |
| | | partsInfo.getPartsId(), item.getId()); |
| | | PermissionStreamNew stream = permissionStreamNewService.loadPermissionStreamNewByBusinessIdAndDepartId(partsInfo.getPartsId(), item.getId(),"3"); |
| | | if(stream == null) { |
| | | stream = new PermissionStream(); |
| | | stream = new PermissionStreamNew(); |
| | | stream.setDepartId(item.getId()); |
| | | stream.setProductId(partsInfo.getProductId()); |
| | | stream.setComponentId(partsInfo.getComponentId()); |
| | | stream.setPartsId(partsInfo.getPartsId()); |
| | | stream.setBusinessId(partsInfo.getPartsId()); |
| | | stream.setBusinessType("3"); |
| | | 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(partsInfo == null || departmentList == null || departmentList.isEmpty()) |
| | | ExceptionCast.cast(CommonCode.INVALID_PARAM); |
| | | List<PartsDepartment> partsDepartments = new ArrayList<>(); |
| | | List<PermissionStream> permissionStreamList = new ArrayList<>(); |
| | | List<PermissionStreamNew> permissionStreamList = new ArrayList<>(); |
| | | departmentList.forEach(item -> { |
| | | PartsDepartment en = partsDepartmentService.getByPartsIdAndDepartId(partsInfo.getPartsId(), item.getId()); |
| | | if(en != null) { |
| | | partsDepartments.add(en); |
| | | } |
| | | PermissionStream stream = permissionStreamService.getByPartsIdAndDepartId(partsInfo.getProductId(), partsInfo.getComponentId(), |
| | | partsInfo.getPartsId(), item.getId()); |
| | | PermissionStreamNew stream = permissionStreamNewService.loadPermissionStreamNewByBusinessIdAndDepartId(partsInfo.getPartsId(), item.getId(),"3"); |
| | | 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); |
| | | } |