| | |
| | | import org.apache.shiro.SecurityUtils; |
| | | import org.jeecg.common.api.vo.Result; |
| | | import org.jeecg.common.system.vo.LoginUser; |
| | | import org.jeecg.modules.dnc.constant.DocAttributionTypeEnum; |
| | | import org.jeecg.modules.dnc.entity.*; |
| | | import org.jeecg.modules.dnc.exception.ExceptionCast; |
| | | import org.jeecg.modules.dnc.mapper.ComponentInfoMapper; |
| | |
| | | @Autowired |
| | | private ComponentInfoMapper componentInfoMapper; |
| | | @Autowired |
| | | private PartsInfoMapper processSpecVersionMapper; |
| | | private PartsInfoMapper partsInfoMapper; |
| | | @Autowired |
| | | private IPermissionStreamNewService permissionStreamNewService; |
| | | @Autowired |
| | |
| | | |
| | | /** |
| | | * 新增工艺规程版本表信息 |
| | | * @param ProcessSpecVersion |
| | | * @param processSpecVersion |
| | | * @return |
| | | */ |
| | | @Override |
| | | public boolean addProcessSpecVersion(ProcessSpecVersion ProcessSpecVersion){ |
| | | if(ProcessSpecVersion == null) |
| | | public boolean addProcessSpecVersion(ProcessSpecVersion processSpecVersion){ |
| | | if(processSpecVersion == null) |
| | | ExceptionCast.cast(CommonCode.INVALID_PARAM); |
| | | if(!ValidateUtil.validateString(ProcessSpecVersion.getProcessSpecVersionName())) |
| | | if(!ValidateUtil.validateString(processSpecVersion.getProcessSpecVersionName())) |
| | | ExceptionCast.cast(PartsInfoCode.PROCESSSPECVERSION_NONE); |
| | | if(!ValidateUtil.validateString(ProcessSpecVersion.getProductId())) |
| | | if(!ValidateUtil.validateString(processSpecVersion.getProductId())) |
| | | ExceptionCast.cast(PartsInfoCode.PARTS_PRODUCT_NONE); |
| | | if(!ValidateUtil.validateString(ProcessSpecVersion.getComponentId())) |
| | | if(!ValidateUtil.validateString(processSpecVersion.getComponentId())) |
| | | ExceptionCast.cast(PartsInfoCode.PARTS_COMPONENT_NONE); |
| | | if(!ValidateUtil.validateString(ProcessSpecVersion.getPartsId())) |
| | | if(!ValidateUtil.validateString(processSpecVersion.getPartsId())) |
| | | ExceptionCast.cast(ProcessInfoCode.PROCESS_PARTS_NONE); |
| | | if(!ValidateUtil.validateString(ProcessSpecVersion.getProcessSpecVersionCode())) |
| | | if(!ValidateUtil.validateString(processSpecVersion.getProcessSpecVersionCode())) |
| | | ExceptionCast.cast(PartsInfoCode.PROCESSSPECVERSION_CODE_NONE); |
| | | ProcessSpecVersion en = getByCode(ProcessSpecVersion.getPartsId(),ProcessSpecVersion.getProcessSpecVersionCode()); |
| | | ProcessSpecVersion en = getByCode(processSpecVersion.getPartsId(),processSpecVersion.getProcessSpecVersionCode()); |
| | | if(en != null) |
| | | ExceptionCast.cast(PartsInfoCode.PROCESSSPECVERSION_IS_EXIST); |
| | | LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); |
| | | String userId = user.getId(); |
| | | if(!ValidateUtil.validateString(userId)) |
| | | ExceptionCast.cast(UcenterCode.UCENTER_ACCOUNT_NOT_EXIST); |
| | | ProductInfo productInfo = productInfoMapper.selectById(ProcessSpecVersion.getProductId()); |
| | | ProductInfo productInfo = productInfoMapper.selectById(processSpecVersion.getProductId()); |
| | | if(productInfo == null) |
| | | ExceptionCast.cast(PartsInfoCode.PARTS_PRODUCT_NONE); |
| | | ComponentInfo componentInfo = componentInfoMapper.selectById(ProcessSpecVersion.getComponentId()); |
| | | ComponentInfo componentInfo = componentInfoMapper.selectById(processSpecVersion.getComponentId()); |
| | | if(componentInfo == null) |
| | | ExceptionCast.cast(PartsInfoCode.PARTS_COMPONENT_NONE); |
| | | PartsInfo processSpecVersion = processSpecVersionMapper.selectById(ProcessSpecVersion.getPartsId()); |
| | | if(processSpecVersion == null) |
| | | PartsInfo partsInfo = partsInfoMapper.selectById(processSpecVersion.getPartsId()); |
| | | if(partsInfo == null) |
| | | ExceptionCast.cast(PartsInfoCode.PARTS_NOT_EXIST); |
| | | boolean b = super.save(ProcessSpecVersion); |
| | | //相同零件号下面版本号不能重复 |
| | | List<ProcessSpecVersion> list = super.list(new LambdaQueryWrapper<ProcessSpecVersion>().eq(ProcessSpecVersion::getPartsId,partsInfo.getPartsId())); |
| | | if (list != null && list.size() > 0) { |
| | | list.forEach(processSpecVersion1 -> { |
| | | if (processSpecVersion1.getProcessSpecVersionCode().equals(processSpecVersion.getProcessSpecVersionCode())) { |
| | | ExceptionCast.cast(PartsInfoCode.PROCESSSPECVERSION_IS_EXIST); |
| | | } |
| | | }); |
| | | } |
| | | boolean b = super.save(processSpecVersion); |
| | | if(!b) |
| | | ExceptionCast.cast(CommonCode.FAIL); |
| | | //添加部门权限 |
| | | List<PermissionStreamNew> oldDepartPermList = permissionStreamNewService.loadPermissionStreamNewByBusinessId(ProcessSpecVersion.getPartsId(),"3","1"); |
| | | List<PermissionStreamNew> oldDepartPermList = permissionStreamNewService.loadPermissionStreamNewByBusinessId(processSpecVersion.getPartsId(), DocAttributionTypeEnum.PARTS.getCode().toString(),"1"); |
| | | if(oldDepartPermList != null && !oldDepartPermList.isEmpty()) { |
| | | List<ProcessSpecVersionDepartment> processSpecVersionDepartmentList = new ArrayList<>(); |
| | | List<PermissionStreamNew> permissionStreamList = new ArrayList<>(); |
| | | oldDepartPermList.forEach(item -> { |
| | | ProcessSpecVersionDepartment pd = new ProcessSpecVersionDepartment(); |
| | | pd.setDepartId(item.getDepartId()); |
| | | pd.setPsvId(ProcessSpecVersion.getId()); |
| | | pd.setPsvId(processSpecVersion.getId()); |
| | | processSpecVersionDepartmentList.add(pd); |
| | | PermissionStreamNew perm = new PermissionStreamNew(); |
| | | perm.setDepartId(item.getDepartId()); |
| | | perm.setBusinessId(ProcessSpecVersion.getId()); |
| | | perm.setBusinessType("4"); |
| | | perm.setBusinessId(processSpecVersion.getId()); |
| | | perm.setBusinessType(DocAttributionTypeEnum.OPERATION.getCode().toString()); |
| | | permissionStreamList.add(perm); |
| | | }); |
| | | if(!processSpecVersionDepartmentList.isEmpty()) { |
| | |
| | | } |
| | | } |
| | | //添加用户权限 |
| | | b = productPermissionService.add(ProcessSpecVersion.getId(), userId,"4"); |
| | | b = productPermissionService.add(processSpecVersion.getId(), userId,DocAttributionTypeEnum.OPERATION.getCode().toString()); |
| | | if (!b) { |
| | | ExceptionCast.cast(ProductInfoCode.PRODUCT_SAVE_ERROR); |
| | | } |
| | | //添加结构树 |
| | | ProductMix productMix = new ProductMix(Long.parseLong(ProcessSpecVersion.getId()),Long.parseLong(ProcessSpecVersion.getPartsId()) |
| | | ,ProcessSpecVersion.getProcessSpecVersionName(), |
| | | ProcessSpecVersion.getProcessSpecVersionCode(),4,new Date()); |
| | | ProductMix productMix = new ProductMix(Long.parseLong(processSpecVersion.getId()),Long.parseLong(processSpecVersion.getPartsId()) |
| | | ,processSpecVersion.getProcessSpecVersionName(), |
| | | processSpecVersion.getProcessSpecVersionCode(),DocAttributionTypeEnum.OPERATION.getCode(),new Date()); |
| | | productMixService.save(productMix); |
| | | //添加用户权限 |
| | | PermissionStreamNew stream = new PermissionStreamNew(); |
| | | stream.setBusinessId(ProcessSpecVersion.getId()); |
| | | stream.setBusinessType("4"); |
| | | stream.setBusinessId(processSpecVersion.getId()); |
| | | stream.setBusinessType(DocAttributionTypeEnum.OPERATION.getCode().toString()); |
| | | stream.setUserId(userId); |
| | | return permissionStreamNewService.addPermissionStreamNew(stream); |
| | | } |
| | |
| | | boolean b = super.updateById(processSpecVersion); |
| | | //同步修改结构树 |
| | | ProductMix productMix = productMixService.getById(Long.parseLong(id)); |
| | | productMix.setName(processSpecVersion.getProcessSpecVersionName()); |
| | | productMix.setCode(processSpecVersion.getProcessSpecVersionCode()); |
| | | productMix.setTreeName(processSpecVersion.getProcessSpecVersionName()); |
| | | productMix.setTreeCode(processSpecVersion.getProcessSpecVersionCode()); |
| | | productMixService.updateById(productMix); |
| | | if(!b) |
| | | return false; |
| | |
| | | if(!b) |
| | | return false; |
| | | } |
| | | PermissionStreamNew stream = permissionStreamNewService.loadPermissionStreamNewByBusinessIdAndUserId(id, userId,"4"); |
| | | PermissionStreamNew stream = permissionStreamNewService.loadPermissionStreamNewByBusinessIdAndUserId(id, userId,DocAttributionTypeEnum.OPERATION.getCode().toString()); |
| | | if(stream == null) { |
| | | stream = new PermissionStreamNew(); |
| | | stream.setBusinessId(id); |
| | |
| | | b = processSpecVersionDepartmentService.deleteByPsvId(processSpecVersion.getId()); |
| | | if(!b) |
| | | ExceptionCast.cast(CommonCode.FAIL); |
| | | b = permissionStreamNewService.deletePermissionStreamNewByBusinessId(processSpecVersion.getId(),"4","0"); |
| | | b = permissionStreamNewService.deletePermissionStreamNewByBusinessId(processSpecVersion.getId(),DocAttributionTypeEnum.OPERATION.getCode().toString(),"0"); |
| | | if(!b) |
| | | ExceptionCast.cast(CommonCode.FAIL); |
| | | b = permissionStreamNewService.deletePermissionStreamNewByBusinessId(processSpecVersion.getId(),"4","1"); |
| | | b = permissionStreamNewService.deletePermissionStreamNewByBusinessId(processSpecVersion.getId(),DocAttributionTypeEnum.OPERATION.getCode().toString(),"1"); |
| | | if(!b) |
| | | ExceptionCast.cast(CommonCode.FAIL); |
| | | b = productMixService.removeById(processSpecVersion.getId()); |
| | |
| | | en.setPsvId(processSpecVersion.getId()); |
| | | permissionList.add(en); |
| | | } |
| | | PermissionStreamNew stream = permissionStreamNewService.loadPermissionStreamNewByBusinessIdAndUserId(processSpecVersion.getId(), item.getId(),"4"); |
| | | PermissionStreamNew stream = permissionStreamNewService.loadPermissionStreamNewByBusinessIdAndUserId(processSpecVersion.getId(), item.getId(),DocAttributionTypeEnum.OPERATION.getCode().toString()); |
| | | if(stream == null) { |
| | | stream = new PermissionStreamNew(); |
| | | stream.setUserId(item.getId()); |
| | | stream.setBusinessId(processSpecVersion.getId()); |
| | | stream.setBusinessType("4"); |
| | | stream.setBusinessType(DocAttributionTypeEnum.OPERATION.getCode().toString()); |
| | | permissionStreamList.add(stream); |
| | | } |
| | | }); |
| | |
| | | if(en != null) { |
| | | permissionList.add(en); |
| | | } |
| | | PermissionStreamNew stream = permissionStreamNewService.loadPermissionStreamNewByBusinessIdAndUserId(processSpecVersion.getId(), item.getId(),"4"); |
| | | PermissionStreamNew stream = permissionStreamNewService.loadPermissionStreamNewByBusinessIdAndUserId(processSpecVersion.getId(), item.getId(),DocAttributionTypeEnum.OPERATION.getCode().toString()); |
| | | if(stream != null) { |
| | | permissionStreamList.add(stream); |
| | | } |
| | |
| | | en.setPsvId(processSpecVersion.getId()); |
| | | partsDepartments.add(en); |
| | | } |
| | | PermissionStreamNew stream = permissionStreamNewService.loadPermissionStreamNewByBusinessIdAndDepartId(processSpecVersion.getId(), item.getId(),"4"); |
| | | PermissionStreamNew stream = permissionStreamNewService.loadPermissionStreamNewByBusinessIdAndDepartId(processSpecVersion.getId(), item.getId(),DocAttributionTypeEnum.OPERATION.getCode().toString()); |
| | | if(stream == null) { |
| | | stream = new PermissionStreamNew(); |
| | | stream.setDepartId(item.getId()); |
| | | stream.setBusinessId(processSpecVersion.getId()); |
| | | stream.setBusinessType("4"); |
| | | stream.setBusinessType(DocAttributionTypeEnum.OPERATION.getCode().toString()); |
| | | permissionStreamList.add(stream); |
| | | } |
| | | }); |
| | |
| | | if (treeInfoRequest.getPartsIds() != null && !treeInfoRequest.getPartsIds().isEmpty()) { |
| | | queryWrapper.in(ProcessSpecVersion::getPartsId, treeInfoRequest.getPartsIds()); |
| | | } |
| | | if (treeInfoRequest.getAttributionType()==4){ |
| | | if (Objects.equals(treeInfoRequest.getAttributionType(), DocAttributionTypeEnum.OPERATION.getCode())){ |
| | | queryWrapper.eq(StrUtil.isNotEmpty(treeInfoRequest.getAttributionId()),ProcessSpecVersion::getId,treeInfoRequest.getAttributionId()); |
| | | } |
| | | queryWrapper.like(StrUtil.isNotEmpty(treeInfoRequest.getTreeName()),ProcessSpecVersion::getProcessSpecVersionName, treeInfoRequest.getTreeName()); |
| | | queryWrapper.like(StrUtil.isNotEmpty(treeInfoRequest.getTreeCode()),ProcessSpecVersion::getProcessSpecVersionCode, treeInfoRequest.getTreeName()); |
| | | queryWrapper.orderByDesc(ProcessSpecVersion::getCreateTime); |
| | | List<ProcessSpecVersion> list = super.list(queryWrapper); |
| | | if (list == null || list.isEmpty()){ |
| | | List<DocInfo> docInfos; |
| | | if (list == null || list.isEmpty() || StrUtil.isNotBlank(treeInfoRequest.getStructureType())){ |
| | | return new ArrayList<>(); |
| | | }else { |
| | | String ids=list.stream().map(ProcessSpecVersion::getId).collect(Collectors.joining(",")); |
| | |
| | | BeanUtil.copyProperties(treeInfoRequest,docQuery); |
| | | docQuery.setAttributionIds(ids); |
| | | docQuery.setDocClassCode("OTHER"); |
| | | docQuery.setAttributionType(4); |
| | | return docInfoService.findListByDocQuery(docQuery); |
| | | docQuery.setAttributionType(DocAttributionTypeEnum.OPERATION.getCode()); |
| | | docInfos=docInfoService.findListByDocQuery(docQuery); |
| | | if (Objects.equals(treeInfoRequest.getAttributionType(), DocAttributionTypeEnum.OPERATION.getCode())){ |
| | | List<String> id =new ArrayList<>(); |
| | | id.add(treeInfoRequest.getAttributionId()); |
| | | treeInfoRequest.setPsvIds(id); |
| | | //工序 |
| | | List<DocInfo> processStreams = processStreamService.getByProcessStreamOtherFile(treeInfoRequest); |
| | | docInfos.addAll(processStreams); |
| | | //工步 |
| | | List<DocInfo> workSteps = workStepService.getByWorkStepOtherFile(treeInfoRequest); |
| | | docInfos.addAll(workSteps); |
| | | } |
| | | } |
| | | return docInfos; |
| | | } |
| | | |
| | | @Override |
| | | public boolean assignPermission(Object entity, Collection<SysUser> userList, boolean isAdd){ |
| | | if (isAdd) { |
| | | return assignAddUser((ProcessSpecVersion) entity, userList); |
| | | } else { |
| | | return assignRemoveUser((ProcessSpecVersion) entity, userList); |
| | | } |
| | | } |
| | | @Override |
| | | public boolean assignDepartPermission(Object entity, Collection<MdcProduction> departments, boolean isAdd) { |
| | | if (isAdd) { |
| | | return assignAddDepart((ProcessSpecVersion) entity, departments); |
| | | } else { |
| | | return assignRemoveDepart((ProcessSpecVersion) entity, departments); |
| | | } |
| | | } |
| | | } |