liding
2026-09-01 bf2026a38d4d36371060673d4651b6e05ca90632
inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsOrderServiceImpl.java
@@ -16,6 +16,7 @@
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.basic.dto.InventoryDetailDTO;
import com.ruoyi.basic.mapper.IfsInventoryQuantityMapper;
import com.ruoyi.basic.mapper.StandardProductListMapper;
import com.ruoyi.basic.mapper.StructureItemParameterMapper;
@@ -647,13 +648,6 @@
                if(isSplitOrder){
                    ifsInventoryQuantity.setIsSplitOrder(1);
                }
                //todo:不清楚用途,暂时屏蔽掉
                // 查询产业链检测数据
//                String industryChainAttrFields = IndustryChainUtils.getIndustryChainAttrFields(ifsInventoryQuantity.getOrderNo(),
//                        ifsInventoryQuantity.getLineNo(),
//                        ifsInventoryQuantity.getReleaseNo());
//                ifsInventoryQuantity.setIndustryChain(industryChainAttrFields);
                ifsInventoryQuantityMapper.insert(ifsInventoryQuantity);
            }
        }
@@ -801,6 +795,9 @@
        ifsInventoryQuantity.setIsCopper(1);
        ifsInventoryQuantity.setIsQuarter(0);
        ifsInventoryQuantity.setInspectStatus(0);
        //铜材料下单默认值
        ifsInventoryQuantity.setOrderType(OrderType.RAW.getValue());
        ifsInventoryQuantity.setMaterialProp("01Cu");
        ifsInventoryQuantity.setQtyArrived(insOrder.getQtyArrived());
        ifsInventoryQuantity.setBuyUnitMeas(insOrder.getBuyUnitMeas());
@@ -810,10 +807,8 @@
        ifsInventoryQuantityMapper.insert(ifsInventoryQuantity);
        insOrder.setIfsInventoryId(ifsInventoryQuantity.getId());
        insOrder.setState(1);
        upInsOrderOfState(insOrder);
        upInsOrder(insOrder.getId(), null, appointed != null ? appointed.toString() : null, SecurityUtils.getUserId().intValue(), "原材料");
@@ -879,6 +874,19 @@
    @Override
    @Transactional(rollbackFor = Exception.class)
    public Boolean updateInsOrder(InsOrderUpdateDto insOrderUpdateDto) {
        InsOrder currentOrder = insOrderMapper.selectById(insOrderUpdateDto.getInsOrder().getId());
        if (currentOrder == null || !Objects.equals(currentOrder.getState(), 2)) {
            throw new ErrorException("只有退回的检验单可以修改");
        }
        boolean hasSelectedProduct = CollectionUtils.isNotEmpty(insOrderUpdateDto.getSampleProduct())
                && insOrderUpdateDto.getSampleProduct().stream()
                .filter(sample -> CollectionUtils.isNotEmpty(sample.getInsProduct()))
                .flatMap(sample -> sample.getInsProduct().stream())
                .anyMatch(product -> Objects.equals(product.getState(), 1));
        if (!hasSelectedProduct) {
            throw new ErrorException("请至少选择一个检验项");
        }
        // 修改订单
        insOrderUpdateDto.getInsOrder().setState(0);
        insOrderUpdateDto.getInsOrder().setTell("");
@@ -886,11 +894,50 @@
        // 修改检验项
        for (SampleProductDto sampleProductDto : insOrderUpdateDto.getSampleProduct()) {
            Long sampleCount = insSampleMapper.selectCount(Wrappers.<InsSample>lambdaQuery()
                    .eq(InsSample::getId, sampleProductDto.getId())
                    .eq(InsSample::getInsOrderId, insOrderUpdateDto.getInsOrder().getId()));
            if (sampleCount == 0) {
                throw new ErrorException("检验样品数据异常");
            }
            insSampleService.update(Wrappers.<InsSample>lambdaUpdate()
                    .eq(InsSample::getId, sampleProductDto.getId())
                    .set(InsSample::getSpecialStandardMethod, sampleProductDto.getSpecialStandardMethod()));
            insProductService.updateBatchById(sampleProductDto.getInsProduct());
            List<InsProduct> products = sampleProductDto.getInsProduct();
            if (CollectionUtils.isEmpty(products)) {
                continue;
            }
            Set<Integer> productIds = insProductMapper.selectList(Wrappers.<InsProduct>lambdaQuery()
                            .eq(InsProduct::getInsSampleId, sampleProductDto.getId()))
                    .stream()
                    .map(InsProduct::getId)
                    .collect(Collectors.toSet());
            if (products.stream().anyMatch(product -> product.getId() != null && !productIds.contains(product.getId()))) {
                throw new ErrorException("检验项数据异常");
            }
            List<Integer> removedIds = products.stream()
                    .filter(product -> product.getId() != null && !Objects.equals(product.getState(), 1))
                    .map(InsProduct::getId)
                    .collect(Collectors.toList());
            if (CollectionUtils.isNotEmpty(removedIds)) {
                insProductService.removeByIds(removedIds);
            }
            List<InsProduct> existingProducts = products.stream()
                    .filter(product -> product.getId() != null && Objects.equals(product.getState(), 1))
                    .collect(Collectors.toList());
            if (CollectionUtils.isNotEmpty(existingProducts)) {
                insProductService.updateBatchById(existingProducts);
            }
            List<InsProduct> newProducts = products.stream()
                    .filter(product -> product.getId() == null && Objects.equals(product.getState(), 1))
                    .collect(Collectors.toList());
            addInsProductMethod(sampleProductDto.getId(), newProducts);
        }
        return true;
@@ -904,6 +951,11 @@
    @Override
    public List<InsOrderPrintingVo> labelOrderPrinting(List<Integer> ids) {
        return insOrderMapper.labelOrderPrinting(ids);
    }
    @Override
    public List<InventoryDetailDTO> labelOutsideOrderPrinting(List<Integer> ids) {
        return insOrderMapper.labelOutsideOrderPrinting(ids);
    }
    /**
@@ -1216,8 +1268,7 @@
        // 检验后移库
        //1301:原材料合格库,CP-02-001:成品库
        if(StringUtils.equals(inventoryQuantity.getOrderType(), OrderType.RAW.getValue())){
            //如果订单为原材料的拆分订单,则移到外购原材料库位W03
            toLocation = one.getIsSplitOrder().equals(1)?"W03":"1301";
            toLocation = "1301";
        }else if(StringUtils.equals(inventoryQuantity.getOrderType(), OrderType.WG.getValue())){
            toLocation = "CP-02-001";
        }else{