| | |
| | | private IProcessionDepartmentService processionDepartmentService; |
| | | @Autowired |
| | | private IMdcProductionService mdcProductionService; |
| | | @Autowired |
| | | private IDocRelativeService iDocRelativeService; |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = {Exception.class}) |
| | |
| | | if(processStreams != null && !processStreams.isEmpty()) |
| | | ExceptionCast.cast(ProductInfoCode.PRODUCT_PROCESS_EXIST); |
| | | boolean b = productPermissionService.deleteByProductId(id); |
| | | //验证是否存在文档 |
| | | List<DocRelative> docRelativeList=iDocRelativeService.list(new QueryWrapper<DocRelative>().eq("attribution_type","1").eq("attribution_id",id)); |
| | | if (!docRelativeList.isEmpty()){ |
| | | ExceptionCast.cast(ProductInfoCode.PRODUCT_DOC_EXIST); |
| | | } |
| | | if(!b) |
| | | ExceptionCast.cast(CommonCode.FAIL); |
| | | b = productDepartmentService.deleteByProductId(id); |
| | |
| | | b = permissionStreamService.deleteDepartPermsByProductId(id); |
| | | if(!b) |
| | | ExceptionCast.cast(CommonCode.FAIL); |
| | | b = docInfoService.deleteByProductId(id); |
| | | if(!b) |
| | | ExceptionCast.cast(CommonCode.FAIL); |
| | | //添加日志 |
| | | NcLogInfo ncLogInfo = new NcLogInfo(); |
| | | //模块 |
| | | ncLogInfo.setModuleInfo("产品结构树"); |
| | | //类型 |
| | | ncLogInfo.setOperateType(4); |
| | | //日志内容 |
| | | ncLogInfo.setLogContent("产品名称:"+productInfo.getProductName()); |
| | | iNcLogInfoService.saveLogNcInfos(ncLogInfo); |
| | | return super.removeById(id); |
| | | } |
| | | |
| | |
| | | ProcessStream processStream=processStreamService.getById(paramId); |
| | | if(processStream == null) |
| | | ExceptionCast.cast(ProcessInfoCode.PROCESS_NOT_EXIST); |
| | | PermissionStream permission = permissionStreamService.getByProcessIdAndUserId(processStream.getProcessId(),processStream.getComponentId() |
| | | PermissionStream permission = permissionStreamService.getByProcessIdAndUserId(processStream.getProductId(),processStream.getComponentId() |
| | | ,processStream.getPartsId(),processStream.getProcessId(),userId); |
| | | return permission != null; |
| | | }else if (nodeType == 6){ |
| | | WorkStep workStep=workStepService.getById(paramId); |
| | | if(workStep == null) |
| | | ExceptionCast.cast(ProcessInfoCode.WORKSTEP_NOT_EXIST); |
| | | PermissionStream permission = permissionStreamService.getByStepIdAndUserId(workStep.getProcessId(),workStep.getComponentId() |
| | | PermissionStream permission = permissionStreamService.getByStepIdAndUserId(workStep.getProductId(),workStep.getComponentId() |
| | | ,workStep.getPartsId(),workStep.getProcessId(),workStep.getId(),userId); |
| | | return permission != null; |
| | | } |
| | |
| | | String key; |
| | | ComponentDepartment cp; |
| | | ComponentInfo cpInfo; |
| | | for(ComponentInfo c : childrenList){ |
| | | componentIdList.add(c.getComponentId()); |
| | | componentInfoMap.put(c.getComponentId(), c); |
| | | for(MdcProduction mdcProduction : mdcProductionList){ |
| | | key = c.getComponentId() + "," + mdcProduction.getId(); |
| | | cp = new ComponentDepartment(c.getComponentId(), mdcProduction.getId()); |
| | | componentPermissionMap.put(key, cp); |
| | | } |
| | | } |
| | | //查询已存在的权限数据 |
| | | List<ComponentDepartment> existList = componentDepartmentService.getByComponentIdsAndDepartIds(componentIdList, ids); |
| | | if(existList != null && !existList.isEmpty()){ |
| | | //踢出权限数据 |
| | | for(ComponentDepartment permission : existList){ |
| | | key = permission.getComponentId() + "," + permission.getDepartId(); |
| | | if(componentPermissionMap.containsKey(key)){ |
| | | componentPermissionMap.remove(key); |
| | | if(childrenList != null && !childrenList.isEmpty()) { |
| | | for (ComponentInfo c : childrenList) { |
| | | componentIdList.add(c.getComponentId()); |
| | | componentInfoMap.put(c.getComponentId(), c); |
| | | for (MdcProduction mdcProduction : mdcProductionList) { |
| | | key = c.getComponentId() + "," + mdcProduction.getId(); |
| | | cp = new ComponentDepartment(c.getComponentId(), mdcProduction.getId()); |
| | | componentPermissionMap.put(key, cp); |
| | | } |
| | | } |
| | | } |
| | | for(Map.Entry<String, ComponentDepartment> entry : componentPermissionMap.entrySet()){ |
| | | cp = entry.getValue(); |
| | | componentPermissionList.add(cp); |
| | | cpInfo = componentInfoMap.get(cp.getComponentId()); |
| | | s = new PermissionStream(); |
| | | s.setProductId(cpInfo.getProductId()); |
| | | s.setComponentId(cpInfo.getComponentId()); |
| | | s.setDepartId(cp.getDepartId()); |
| | | permissionStreamList.add(s); |
| | | //查询已存在的权限数据 |
| | | List<ComponentDepartment> existList = componentDepartmentService.getByComponentIdsAndDepartIds(componentIdList, ids); |
| | | if (existList != null && !existList.isEmpty()) { |
| | | //踢出权限数据 |
| | | for (ComponentDepartment permission : existList) { |
| | | key = permission.getComponentId() + "," + permission.getDepartId(); |
| | | if (componentPermissionMap.containsKey(key)) { |
| | | componentPermissionMap.remove(key); |
| | | } |
| | | } |
| | | } |
| | | for (Map.Entry<String, ComponentDepartment> entry : componentPermissionMap.entrySet()) { |
| | | cp = entry.getValue(); |
| | | componentPermissionList.add(cp); |
| | | cpInfo = componentInfoMap.get(cp.getComponentId()); |
| | | s = new PermissionStream(); |
| | | s.setProductId(cpInfo.getProductId()); |
| | | s.setComponentId(cpInfo.getComponentId()); |
| | | s.setDepartId(cp.getDepartId()); |
| | | permissionStreamList.add(s); |
| | | } |
| | | } |
| | | |
| | | //处理子零件 |
| | |
| | | |
| | | return ProductTreeWrapper.loadTree(productInfoList, componentExtList, partsInfos,processStreams,workSteps); |
| | | } |
| | | |
| | | @Override |
| | | public boolean deleteProductTree(String id, Integer type){ |
| | | switch (type) { |
| | | //产品 |
| | | case 1: |
| | | return deleteProductInfo(id); |
| | | //部门 |
| | | case 2: |
| | | return componentInfoService.deleteComponentInfo(id); |
| | | //零件 |
| | | case 3: |
| | | return partsInfoService.deletePartsInfo(id); |
| | | //工序 |
| | | case 5: |
| | | return processStreamService.deleteProcessStream(id); |
| | | //工步 |
| | | case 6: |
| | | return workStepService.deleteWorkStep(id); |
| | | default: |
| | | } |
| | | return false; |
| | | } |
| | | } |