lyh
2025-04-17 bb696e8e702854b62b144b22e20e36981301e6cf
lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/ComponentInfoSeServiceImpl.java
@@ -1,5 +1,7 @@
package org.jeecg.modules.dnc.service.impl;
import cn.hutool.core.bean.BeanUtil;
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;
@@ -11,6 +13,8 @@
import org.jeecg.modules.dnc.exception.ExceptionCast;
import org.jeecg.modules.dnc.mapper.ComponentInfoMapper;
import org.jeecg.modules.dnc.mapper.ProductInfoMapper;
import org.jeecg.modules.dnc.request.DocInfoQueryRequest;
import org.jeecg.modules.dnc.request.TreeInfoRequest;
import org.jeecg.modules.dnc.response.CommonCode;
import org.jeecg.modules.dnc.response.ComponentInfoCode;
import org.jeecg.modules.dnc.response.ProductInfoCode;
@@ -25,6 +29,7 @@
import org.springframework.transaction.annotation.Transactional;
import java.util.*;
import java.util.stream.Collectors;
@Service
public class ComponentInfoSeServiceImpl extends ServiceImpl<ComponentInfoMapper, ComponentInfo> implements IComponentInfoService {
@@ -40,6 +45,8 @@
    @Lazy
    private IPartsInfoService partsInfoService;
    @Autowired
    private IProcessSpecVersionService processSpecVersionService;
    @Autowired
    private IProcessStreamService processStreamService;
    @Autowired
    private IProductMixService productMixService;
@@ -47,7 +54,9 @@
    private IDocRelativeService iDocRelativeService;
    @Autowired
    private IProductPermissionService productPermissionService;
    @Autowired
    @Lazy
    private IDocInfoService docInfoService;
    @Override
    @Transactional(rollbackFor = {Exception.class})
    public boolean addComponentInfo(ComponentInfo componentInfo) {
@@ -515,4 +524,46 @@
        queryWrapper.orderByAsc(ComponentInfo::getCreateTime);
        return super.list(queryWrapper);
    }
    /**
     * 通过零件号、材质等查询对应电子样板
     * @param treeInfoRequest
     * @return
     */
    @Override
    public List<DocInfo> getByComponentInfo(TreeInfoRequest treeInfoRequest){
        LambdaQueryWrapper<ComponentInfo> queryWrapper = new LambdaQueryWrapper<>();
        if (treeInfoRequest.getProductIds() != null && !treeInfoRequest.getProductIds().isEmpty()) {
            queryWrapper.in(ComponentInfo::getProductId, treeInfoRequest.getProductIds());
        }
        if (treeInfoRequest.getAttributionType()==2){
            queryWrapper.eq(StrUtil.isNotEmpty(treeInfoRequest.getAttributionId()),ComponentInfo::getComponentId,treeInfoRequest.getAttributionId());
        }
        queryWrapper.like(StrUtil.isNotEmpty(treeInfoRequest.getTreeCode()),ComponentInfo::getComponentCode, treeInfoRequest.getTreeCode());
        queryWrapper.like(StrUtil.isNotEmpty(treeInfoRequest.getTreeName()),ComponentInfo::getComponentName, treeInfoRequest.getTreeName());
        queryWrapper.like(StrUtil.isNotEmpty(treeInfoRequest.getStructureType()),ComponentInfo::getStructureType, treeInfoRequest.getStructureType());
        queryWrapper.orderByDesc(ComponentInfo::getCreateTime);
        List<ComponentInfo> list = super.list(queryWrapper);
        List<DocInfo> docInfos = new ArrayList<>();
        if (list != null && !list.isEmpty()) {
            String ids=list.stream().map(ComponentInfo::getComponentId).collect(Collectors.joining(","));
            DocInfoQueryRequest docQuery = new DocInfoQueryRequest();
            BeanUtil.copyProperties(treeInfoRequest,docQuery);
            docQuery.setAttributionIds(ids);
            docQuery.setDocClassCode("OTHER");
            docQuery.setAttributionType(2);
            docInfos=docInfoService.findListByDocQuery(docQuery);
        }
        if (treeInfoRequest.getAttributionType()==2){
            List<String> id =new ArrayList<>();
            id.add(treeInfoRequest.getAttributionId());
            treeInfoRequest.setComponentIds(id);
            List<DocInfo> partsInfos = partsInfoService.getByPartsInfo(treeInfoRequest);
            docInfos.addAll(partsInfos);
            List<DocInfo> processSpecVersions = processSpecVersionService.getByProcessSpecVersion(treeInfoRequest);
            docInfos.addAll(processSpecVersions);
        }
        return docInfos;
    }
}