gongchunyi
14 小时以前 2ad2948d0e1c4e0d9d5000c3eb02605c3aceed94
src/main/java/com/ruoyi/production/service/impl/ProductMaterialSkuServiceImpl.java
@@ -13,6 +13,22 @@
import com.ruoyi.production.pojo.ProductMaterialSku;
import com.ruoyi.production.dto.ProductMaterialSkuImportDto;
import com.ruoyi.production.service.ProductMaterialSkuService;
import com.ruoyi.production.mapper.ProductOrderMapper;
import com.ruoyi.production.mapper.ProductStructureMapper;
import com.ruoyi.production.mapper.ProductionOrderRouteItemMapper;
import com.ruoyi.production.mapper.ProductionOrderRouteMapper;
import com.ruoyi.production.mapper.ProductionOrderStructureMapper;
import com.ruoyi.production.mapper.ProductionProductInputMapper;
import com.ruoyi.production.mapper.ProductionProductOutputMapper;
import com.ruoyi.production.pojo.ProductOrder;
import com.ruoyi.production.pojo.ProductStructure;
import com.ruoyi.production.pojo.ProductionOrderRoute;
import com.ruoyi.production.pojo.ProductionOrderRouteItem;
import com.ruoyi.production.pojo.ProductionOrderStructure;
import com.ruoyi.production.pojo.ProductionProductInput;
import com.ruoyi.production.pojo.ProductionProductOutput;
import com.ruoyi.productionPlan.mapper.ProductionPlanMapper;
import com.ruoyi.productionPlan.pojo.ProductionPlan;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -38,6 +54,30 @@
    @Autowired
    private ProductMaterialMapper productMaterialMapper;
    @Autowired
    private ProductionPlanMapper productionPlanMapper;
    @Autowired
    private ProductOrderMapper productOrderMapper;
    @Autowired
    private ProductStructureMapper productStructureMapper;
    @Autowired
    private ProductionOrderRouteItemMapper productionOrderRouteItemMapper;
    @Autowired
    private ProductionOrderRouteMapper productionOrderRouteMapper;
    @Autowired
    private ProductionOrderStructureMapper productionOrderStructureMapper;
    @Autowired
    private ProductionProductOutputMapper productionProductOutputMapper;
    @Autowired
    private ProductionProductInputMapper productionProductInputMapper;
    /**
     * 查询物料规格列表
@@ -99,6 +139,32 @@
        if (ids == null || ids.isEmpty()) {
            throw new ServiceException("请选择至少一条数据");
        }
        if (productionPlanMapper.selectCount(new LambdaQueryWrapper<ProductionPlan>().in(ProductionPlan::getProductMaterialSkuId, ids)) > 0) {
            throw new ServiceException("该物料已被销售生产计划引用,无法删除");
        }
        if (productOrderMapper.selectCount(new LambdaQueryWrapper<ProductOrder>().in(ProductOrder::getProductMaterialSkuId, ids)) > 0) {
            throw new ServiceException("该物料已被生产订单引用,无法删除");
        }
        if (productStructureMapper.selectCount(new LambdaQueryWrapper<ProductStructure>().in(ProductStructure::getProductModelId, ids)) > 0) {
            throw new ServiceException("该物料已被BOM子表引用,无法删除");
        }
        if (productionOrderRouteItemMapper.selectCount(new LambdaQueryWrapper<ProductionOrderRouteItem>().in(ProductionOrderRouteItem::getProductModelId, ids)) > 0) {
            throw new ServiceException("该物料已被生产订单绑定的工艺路线--工序表引用,无法删除");
        }
        if (productionOrderRouteMapper.selectCount(new LambdaQueryWrapper<ProductionOrderRoute>().in(ProductionOrderRoute::getProductModelId, ids)) > 0) {
            throw new ServiceException("该物料已被生产订单绑定的工艺路线表引用,无法删除");
        }
        if (productionOrderStructureMapper.selectCount(new LambdaQueryWrapper<ProductionOrderStructure>().in(ProductionOrderStructure::getProductModelId, ids)) > 0) {
            throw new ServiceException("该物料已被生产订单绑定的BOM子表引用,无法删除");
        }
        if (productionProductOutputMapper.selectCount(new LambdaQueryWrapper<ProductionProductOutput>().in(ProductionProductOutput::getProductModelId, ids)) > 0) {
            throw new ServiceException("该物料已被生产报工产出明细表引用,无法删除");
        }
        if (productionProductInputMapper.selectCount(new LambdaQueryWrapper<ProductionProductInput>().in(ProductionProductInput::getProductId, ids)) > 0) {
            throw new ServiceException("该物料已被生产报工物料投入表引用,无法删除");
        }
        if (!this.removeByIds(ids)) {
            throw new ServiceException("删除物料规格失败");
        }