chenrui
2025-04-08 9f8f73240c885488fdffc1062826520cf7abb86b
inspect-server/src/main/java/com/ruoyi/inspect/service/impl/RawMaterialOrderServiceImpl.java
@@ -12,14 +12,14 @@
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.basic.dto.*;
import com.ruoyi.basic.pojo.IfsInventoryQuantity;
import com.ruoyi.common.constant.InsOrderTypeConstants;
import com.ruoyi.common.core.domain.Result;
import com.ruoyi.common.core.domain.entity.User;
import com.ruoyi.common.properties.WechatProperty;
import com.ruoyi.common.config.WechatProperty;
import com.ruoyi.common.utils.LimsDateUtil;
import com.ruoyi.common.utils.QueryWrappers;
import com.ruoyi.common.utils.SecurityUtils;
@@ -57,7 +57,6 @@
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;
/**
 * @Author zhuo
@@ -82,65 +81,55 @@
    @Override
    public RawMaterialStandardTreeDto selectStandardTreeListByPartNo(String partNo) {
        if (StringUtils.isBlank(partNo)) {
            throw new ErrorException("零件号丢失");
        }
    public Result selectStandardTreeListByPartNo(String partNo) {
        List<FactoryDto> factoryDtos = standardTreeMapper.selectStandardTreeListByPartNo(partNo);
        if (CollectionUtil.isEmpty(factoryDtos)) {
            throw new ErrorException("零件号为" + partNo + "的原材料没有对应的标准库配置");
            return Result.success(null, "零件号为" + partNo + "的原材料没有对应的标准库配置");
        }
        RawMaterialStandardTreeDto rawMaterialStandardTreeDto = new RawMaterialStandardTreeDto();
        Set<String> sampleTypeValues = new HashSet<>();
        for (FactoryDto factoryDto : factoryDtos) {
            for (LaboratoryDto laboratoryDto : factoryDto.getChildren()) {
                for (SampleTypeDto sampleTypeDto : laboratoryDto.getChildren()) {
                    if (sampleTypeDto.getChildren().size() == 0) {
                        sampleTypeValues.add(sampleTypeDto.getValue());
                    }
                }
            }
        }
        // 批量查询所有 sampleTypeDto 的数据
        List<SampleDto> standardList = standardTreeMapper.getStandardTree3Batch(sampleTypeValues);
        Map<String, List<SampleDto>> standardTreeMap = standardList.stream().collect(Collectors.groupingBy(SampleDto::getValue));
        for (FactoryDto factoryDto : factoryDtos) {
            for (LaboratoryDto laboratoryDto : factoryDto.getChildren()) {
                for (SampleTypeDto sampleTypeDto : laboratoryDto.getChildren()) {
                    List<SampleDto> standardTreeList = standardTreeMap.get(sampleTypeDto.getValue());
                    if (sampleTypeDto.getChildren().size() == 0) {
                        sampleTypeDto.getChildren().addAll(standardTreeList);
                    }
                    // 判断绑定的是否是当前零件号
                    if (sampleTypeDto.getPartNo() != null && sampleTypeDto.getPartNo().equals(partNo)) {
                        // 添加对象
                        rawMaterialStandardTreeDto.setTreeName(factoryDto.getValue() + "-"
                                + laboratoryDto.getValue() + "-"
                                + sampleTypeDto.getValue());
                        rawMaterialStandardTreeDto.setCode(sampleTypeDto.getCode());
                        rawMaterialStandardTreeDto.setLabel(sampleTypeDto.getLabel());
                        rawMaterialStandardTreeDto.setValue(sampleTypeDto.getValue());
                        rawMaterialStandardTreeDto.setChildren1(sampleTypeDto.getChildren());
                    } else {
                        for (SampleDto sampleDto : sampleTypeDto.getChildren()) {
                            if (sampleDto.getPartNo() != null && sampleDto.getPartNo().equals(partNo)) {
                for (ObjectTypeDto objectTypeDto : laboratoryDto.getChildren()) {
                    for (WorkShopNameDto workShopNameDto : objectTypeDto.getChildren()) {
                        for (SampleTypeDto sampleTypeDto : workShopNameDto.getChildren()) {
                            if (sampleTypeDto.getChildren().size() == 0) {
                                sampleTypeDto.setChildren(standardTreeMapper.getStandardTree3(sampleTypeDto.getValue()));
                            }
                            // 判断绑定的是否是当前零件号
                            if (sampleTypeDto.getPartNo() != null && sampleTypeDto.getPartNo().equals(partNo)) {
                                // 添加对象
                                rawMaterialStandardTreeDto.setTreeName(factoryDto.getValue() + "-"
                                        + laboratoryDto.getValue() + "-"
                                        + sampleTypeDto.getValue() + "-"
                                        + sampleDto.getValue());
                                rawMaterialStandardTreeDto.setCode(sampleDto.getCode());
                                rawMaterialStandardTreeDto.setLabel(sampleDto.getLabel());
                                rawMaterialStandardTreeDto.setValue(sampleDto.getValue());
                                rawMaterialStandardTreeDto.setChildren2(sampleDto.getChildren());
                                        + laboratoryDto.getValue() + "-" + objectTypeDto.getValue() + "-" + workShopNameDto.getValue() + "-"
                                        + sampleTypeDto.getValue());
                                rawMaterialStandardTreeDto.setCode(sampleTypeDto.getCode());
                                rawMaterialStandardTreeDto.setLabel(sampleTypeDto.getLabel());
                                rawMaterialStandardTreeDto.setValue(sampleTypeDto.getValue());
                                rawMaterialStandardTreeDto.setChildren1(sampleTypeDto.getChildren());
                                rawMaterialStandardTreeDto.setWorkShopName(sampleTypeDto.getWorkShopName());
                                rawMaterialStandardTreeDto.setWorkShopId(sampleTypeDto.getWorkShopId());
                            } else {
                                for (SampleDto sampleDto : sampleTypeDto.getChildren()) {
                                    if (sampleDto.getPartNo() != null && sampleDto.getPartNo().equals(partNo)) {
                                        // 添加对象
                                        rawMaterialStandardTreeDto.setTreeName(factoryDto.getValue() + "-"
                                                + laboratoryDto.getValue() + "-" + objectTypeDto.getValue() + "-" + workShopNameDto.getValue() + "-"
                                                + sampleTypeDto.getValue() + "-"
                                                + sampleDto.getValue());
                                        rawMaterialStandardTreeDto.setCode(sampleDto.getCode());
                                        rawMaterialStandardTreeDto.setLabel(sampleDto.getLabel());
                                        rawMaterialStandardTreeDto.setValue(sampleDto.getValue());
                                        rawMaterialStandardTreeDto.setChildren2(sampleDto.getChildren());
                                        rawMaterialStandardTreeDto.setWorkShopName(sampleTypeDto.getWorkShopName());
                                        rawMaterialStandardTreeDto.setWorkShopId(sampleTypeDto.getWorkShopId());
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        return rawMaterialStandardTreeDto;
        return Result.success(rawMaterialStandardTreeDto);
    }
    @Override
@@ -156,6 +145,7 @@
    /**
     * 报检
     *
     * @param ids
     * @return
     */
@@ -199,6 +189,7 @@
    /**
     * 撤销报检
     *
     * @param id
     * @return
     */
@@ -212,6 +203,7 @@
    /**
     * 打印标签查询
     *
     * @param ids
     * @return
     */
@@ -222,6 +214,7 @@
    /**
     * 报检
     *
     * @param ifsInventoryQuantity
     * @return
     */
@@ -252,6 +245,7 @@
    /**
     * 获取铜产业链检测数据
     *
     * @param id
     * @return
     */
@@ -262,6 +256,7 @@
    /**
     * 原材料撤销接口
     *
     * @param ifsInventoryId
     * @return
     */
@@ -288,6 +283,7 @@
    /**
     * 原材料免检下单
     *
     * @param list
     * @param insOrder
     * @return
@@ -364,6 +360,7 @@
    /**
     * 查询待下单
     *
     * @param page
     * @param ifsInventoryQuantity
     * @return
@@ -375,6 +372,7 @@
    /**
     * 查询已检验
     *
     * @param page
     * @param ifsInventoryQuantityDto
     * @return
@@ -393,6 +391,7 @@
    /**
     * 删除原材料报检信息
     *
     * @param id
     * @return
     */
@@ -403,6 +402,7 @@
    /**
     * 原材料放行免检
     *
     * @param ifsInventoryId
     * @return
     */
@@ -456,8 +456,9 @@
    /**
     * 0, 无提示, 1提示  当前批次的样品已检验过, 可以免检, 2 提示 当前批次的样品已超20吨, 需要多级多次检验
     *
     * <p>
     * 原材料下单通知免检或者多次检验
     *
     * @param ifsInventoryId
     * @return
     */
@@ -497,6 +498,7 @@
    /**
     * 报检可以新增报检信息
     *
     * @param ifsInventoryQuantity
     */
    @Override
@@ -508,10 +510,9 @@
    }
    /**
     * 铜单丝下单免检
     *
     * @param list
     * @param insOrder
     */
@@ -608,6 +609,7 @@
    /**
     * 原材料进厂撤销下单
     *
     * @param enterOrderId
     * @return
     */
@@ -646,6 +648,7 @@
    /**
     * 原材料季度撤销下单
     *
     * @param quarterOrderId
     * @return
     */
@@ -686,6 +689,7 @@
    /**
     * 原材料报检全部信息导出
     *
     * @param ifsInventoryQuantityDto
     * @param response
     */
@@ -748,6 +752,7 @@
    /**
     * 原材料查询可以季度检验的内容
     *
     * @param page
     * @param ifsInventoryQuantityDto
     * @return
@@ -766,6 +771,7 @@
    /**
     * 提前入库
     *
     * @param ifsInventoryId
     * @return
     */
@@ -793,6 +799,7 @@
    /**
     * 添加工时
     *
     * @param insOrder
     * @param ifsInventoryQuantity
     */