| | |
| | | package org.jeecg.modules.dnc.service.impl; |
| | | |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.shiro.SecurityUtils; |
| | | import org.jeecg.common.api.vo.Result; |
| | | import org.jeecg.common.system.vo.LoginUser; |
| | | import org.jeecg.modules.dnc.dto.ComponentExt; |
| | | import org.jeecg.modules.dnc.entity.*; |
| | |
| | | ExceptionCast.cast(ProductInfoCode.PRODUCT_SAVE_ERROR); |
| | | } |
| | | //添加结构树 |
| | | ProductMix productMix = new ProductMix(Long.parseLong(productInfo.getProductId()),0,productInfo.getProductName(),productInfo.getProductNo(),"1"); |
| | | ProductMix productMix = new ProductMix(Long.parseLong(productInfo.getProductId()),0L,productInfo.getProductName(),productInfo.getProductNo(),1); |
| | | productMixService.save(productMix); |
| | | //添加用户权限 |
| | | PermissionStreamNew stream = new PermissionStreamNew(); |
| | |
| | | productInfo.setProductId(id); |
| | | productInfo.setProductStatus(null); |
| | | boolean b = super.updateById(productInfo); |
| | | //同步修改结构树 |
| | | ProductMix productMix = productMixService.getById(Long.parseLong(id)); |
| | | productMix.setName(productInfo.getProductName()); |
| | | productMix.setCode(productInfo.getProductNo()); |
| | | productMixService.updateById(productMix); |
| | | if (!b) |
| | | return false; |
| | | ProductPermission permission = productPermissionService.getByProductIdAndUserId(id, userId); |
| | |
| | | return false; |
| | | } |
| | | |
| | | @Override |
| | | public Result<?> getTreeById(String id, Integer type){ |
| | | if (StrUtil.isNotEmpty(id)||type!=null){ |
| | | switch (type){ |
| | | case 1: |
| | | //产品 |
| | | QueryWrapper<ProductInfo> productInfoQueryWrapper = new QueryWrapper<>(); |
| | | productInfoQueryWrapper.eq("product_id",id); |
| | | List<ProductInfo> productInfos = this.list(productInfoQueryWrapper); |
| | | return Result.OK(productInfos); |
| | | case 2: |
| | | //组件 |
| | | QueryWrapper<ComponentInfo> componentInfoQueryWrapper = new QueryWrapper<>(); |
| | | componentInfoQueryWrapper.eq("component_id",id); |
| | | List<ComponentInfo> componentInfos = componentInfoService.list(componentInfoQueryWrapper); |
| | | return Result.OK(componentInfos); |
| | | case 3: |
| | | //零件 |
| | | QueryWrapper<PartsInfo> partsInfoQueryWrapper = new QueryWrapper<>(); |
| | | partsInfoQueryWrapper.eq("parts_id",id); |
| | | List<PartsInfo> partsInfos = partsInfoService.list(partsInfoQueryWrapper); |
| | | return Result.OK(partsInfos); |
| | | case 4: |
| | | //工艺规划版本 |
| | | QueryWrapper<ProcessSpecVersion> processSpecVersionQueryWrapper = new QueryWrapper<>(); |
| | | processSpecVersionQueryWrapper.eq("id",id); |
| | | List<ProcessSpecVersion> processSpecVersions = processSpecVersionService.list(processSpecVersionQueryWrapper); |
| | | return Result.OK(processSpecVersions); |
| | | case 5: |
| | | //工序 |
| | | QueryWrapper<ProcessStream> processStreamQueryWrapper = new QueryWrapper<>(); |
| | | processStreamQueryWrapper.eq("process_id",id); |
| | | List<ProcessStream> processStreams = processStreamService.list(processStreamQueryWrapper); |
| | | return Result.OK(processStreams); |
| | | case 6: |
| | | //工步 |
| | | QueryWrapper<WorkStep> workStepQueryWrapper = new QueryWrapper<>(); |
| | | workStepQueryWrapper.eq("id",id); |
| | | List<WorkStep> workSteps = workStepService.list(workStepQueryWrapper); |
| | | return Result.OK(workSteps); |
| | | } |
| | | } |
| | | return Result.error("参数错误"); |
| | | } |
| | | |
| | | /** |
| | | * 验证输入参数 |
| | | */ |
| | |
| | | .map(PartsInfo::getPartsId) |
| | | .collect(Collectors.toList()); |
| | | handlePartsPermissions(partsIds, userList, partsPermissionList, permissionStreamList); |
| | | List<String> psvIds = processSpecVersionService.getByPartsIds(partsIds).stream().map(ProcessSpecVersion::getId).collect(Collectors.toList()); |
| | | handlePsvPermissions(psvIds, userList, processSpecVersionPermissionList, permissionStreamList); |
| | | List<ProcessSpecVersion> processSpecVersionList = processSpecVersionService.getByPartsIds(partsIds); |
| | | if (processSpecVersionList!= null &&!processSpecVersionList.isEmpty()) { |
| | | List<String> psvIds = processSpecVersionList.stream().map(ProcessSpecVersion::getId).collect(Collectors.toList()); |
| | | handlePsvPermissions(psvIds, userList, processSpecVersionPermissionList, permissionStreamList); |
| | | } |
| | | List<ProcessStream> processStreamList = processStreamService.getByComponentIdList(productId, componentIds, partsIds); |
| | | processStreamApi(productId, userList, processionPermissionList, workStepPermissionList, permissionStreamList, processStreamList); |
| | | } |
| | |
| | | componentPermissionList.add(cp); |
| | | ComponentInfo cpInfo = componentInfoMap.get(cp.getComponentId()); |
| | | PermissionStreamNew s = new PermissionStreamNew(); |
| | | s.setBusinessId(cpInfo.getProductId()); |
| | | s.setBusinessType("1"); |
| | | s.setBusinessId(cpInfo.getComponentId()); |
| | | s.setBusinessType("2"); |
| | | s.setUserId(cp.getUserId()); |
| | | permissionStreamList.add(s); |
| | | } |
| | |
| | | .collect(Collectors.toList()); |
| | | } |
| | | componentIds.add(componentInfo.getComponentId()); |
| | | |
| | | |
| | | handleRelativePermissions(componentInfo.getProductId(), componentIds, null, null,null, userList); |
| | | } |
| | | }else { |
| | |
| | | |
| | | private void handlePartsRemovals(String productId, List<String> componentIds,Collection<SysUser> userList) { |
| | | List<PartsInfo> partsInfoList = partsInfoService.getByComponentIdList(productId, componentIds); |
| | | partsInfoList.forEach(item->{ |
| | | partsInfoService.assignRemoveUser(item,userList); |
| | | //删除 |
| | | handlePartRelatedRemovals(item, userList); |
| | | }); |
| | | if (partsInfoList!=null){ |
| | | partsInfoList.forEach(item->{ |
| | | partsInfoService.assignRemoveUser(item,userList); |
| | | //删除 |
| | | handlePartRelatedRemovals(item, userList); |
| | | }); |
| | | } |
| | | } |
| | | private void handlePartsDepartmentRemovals(String productId, List<String> componentIds, Collection<MdcProduction> mdcProductionList) { |
| | | List<PartsInfo> partsInfoList = partsInfoService.getByComponentIdList(productId, componentIds); |
| | | partsInfoList.forEach(item->{ |
| | | partsInfoService.assignRemoveDepart(item,mdcProductionList); |
| | | handlePartRelatedDepartmentRemovals(item, mdcProductionList); |
| | | }); |
| | | if (partsInfoList!=null) { |
| | | partsInfoList.forEach(item->{ |
| | | partsInfoService.assignRemoveDepart(item,mdcProductionList); |
| | | handlePartRelatedDepartmentRemovals(item, mdcProductionList); |
| | | }); |
| | | } |
| | | } |
| | | |
| | | private void handleComponentRelatedRemovals(ComponentInfo componentInfo, Collection<SysUser> userList, Collection<MdcProduction> mdcProductionList) { |