gongchunyi
4 小时以前 91acbe8b56194bbd834b1169b5578de8a5ed442c
fix: BOM产品查询调整、重命名字段
已重命名1个文件
已修改18个文件
286 ■■■■ 文件已修改
src/main/java/com/ruoyi/production/controller/ProductMaterialSkuController.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/production/controller/ProductStructureController.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/production/dto/ProductMaterialDto.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/production/dto/ProductMaterialSkuDto.java 10 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/production/dto/ProductMaterialSkuImportDto.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/production/mapper/ProductStructureMapper.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/production/pojo/ProductMaterial.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/production/pojo/ProductMaterialSku.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/production/service/ProductStructureService.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/production/service/impl/ProductBomServiceImpl.java 51 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/production/service/impl/ProductMaterialServiceImpl.java 40 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/production/service/impl/ProductMaterialSkuServiceImpl.java 33 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/production/service/impl/ProductStructureServiceImpl.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/production/service/impl/ProductionProductMainServiceImpl.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/sales/service/impl/SalesLedgerProductServiceImpl.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/production/ProductBomMapper.xml 44 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/production/ProductMaterialMapper.xml 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/production/ProductMaterialSkuMapper.xml 28 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/production/ProductStructureMapper.xml 42 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/production/controller/ProductMaterialSkuController.java
@@ -7,7 +7,7 @@
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.production.dto.ProductMaterialSkuDto;
import com.ruoyi.production.pojo.ProductMaterialSku;
import com.ruoyi.production.pojo.ProductMaterialSkuImportDto;
import com.ruoyi.production.dto.ProductMaterialSkuImportDto;
import com.ruoyi.production.service.ProductMaterialSkuService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
src/main/java/com/ruoyi/production/controller/ProductStructureController.java
@@ -34,7 +34,7 @@
    @ApiOperation("BOM查看子集详情")
    @GetMapping("/listBybomId/{bomId}")
    public R listBybomId( @PathVariable("bomId") Integer bomId){
        return R.ok(productStructureService.listBybomId(bomId));
    public R listByBomId( @PathVariable("bomId") Integer bomId){
        return R.ok(productStructureService.listByBomId(bomId));
    }
}
src/main/java/com/ruoyi/production/dto/ProductMaterialDto.java
@@ -33,7 +33,7 @@
    private Integer inventoryCategoryId;
    @ApiModelProperty("物料名称")
    private String materialName;
    private String productName;
}
src/main/java/com/ruoyi/production/dto/ProductMaterialSkuDto.java
@@ -18,22 +18,22 @@
public class ProductMaterialSkuDto {
    @ApiModelProperty("物料ID")
    private Long materialId;
    private Long productId;
    @ApiModelProperty("物料名称")
    private String materialName;
    private String productName;
    @ApiModelProperty("物料编码")
    private String materialCode;
    @ApiModelProperty("单位")
    private String baseUnit;
    private String unit;
    @ApiModelProperty("规格ID")
    private Long skuId;
    private Long id;
    @ApiModelProperty("规格型号")
    private String specification;
    private String model;
    @ApiModelProperty("供应方式")
    private String supplyType;
src/main/java/com/ruoyi/production/dto/ProductMaterialSkuImportDto.java
ÎļþÃû´Ó src/main/java/com/ruoyi/production/pojo/ProductMaterialSkuImportDto.java ÐÞ¸Ä
@@ -1,4 +1,4 @@
package com.ruoyi.production.pojo;
package com.ruoyi.production.dto;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
@@ -25,7 +25,7 @@
    @ApiModelProperty("规格型号")
    @Excel(name = "规格型号")
    private String specification;
    private String model;
    @ApiModelProperty("供应方式(自制,外购)")
    @Excel(name = "供应方式")
src/main/java/com/ruoyi/production/mapper/ProductStructureMapper.java
@@ -13,7 +13,7 @@
@Mapper
public interface ProductStructureMapper  extends BaseMapper<ProductStructure> {
    List<ProductStructureDto> listBybomId(@Param("bomId") Integer bomId);
    List<ProductStructureDto> listByBomId(@Param("bomId") Integer bomId);
    List<ProductStructureDto> listBybomAndProcess(@Param("bomId") Integer bomId, @Param("processId") Long processId);
    List<ProductStructureDto> listByBomAndProcess(@Param("bomId") Integer bomId, @Param("processId") Long processId);
}
src/main/java/com/ruoyi/production/pojo/ProductMaterial.java
@@ -38,10 +38,10 @@
    private Integer inventoryCategoryId;
    @ApiModelProperty("物料名称")
    private String materialName;
    private String productName;
    @ApiModelProperty("基本单位")
    private String baseUnit;
    private String unit;
    @ApiModelProperty("备注")
    private String remark;
src/main/java/com/ruoyi/production/pojo/ProductMaterialSku.java
@@ -29,7 +29,7 @@
    private Long id;
    @ApiModelProperty("物料ID")
    private Long materialId;
    private Long productId;
    @ApiModelProperty("标识编码")
    private String identifierCode;
@@ -38,7 +38,7 @@
    private String materialCode;
    @ApiModelProperty("规格型号")
    private String specification;
    private String model;
    @ApiModelProperty("供应方式(自制,外购)")
    private String supplyType;
src/main/java/com/ruoyi/production/service/ProductStructureService.java
@@ -12,6 +12,6 @@
    Boolean addProductStructureDto(ProductStructureDto productStructureDto);
    List<ProductStructureDto> listBybomId(Integer bomId);
    List<ProductStructureDto> listByBomId(Integer bomId);
}
src/main/java/com/ruoyi/production/service/impl/ProductBomServiceImpl.java
@@ -4,10 +4,8 @@
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.basic.pojo.Product;
import com.ruoyi.basic.pojo.ProductModel;
import com.ruoyi.basic.service.IProductModelService;
import com.ruoyi.basic.service.IProductService;
import com.ruoyi.production.pojo.ProductMaterial;
import com.ruoyi.production.pojo.ProductMaterialSku;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.poi.ExcelUtil;
@@ -19,9 +17,7 @@
import com.ruoyi.production.pojo.ProductBom;
import com.ruoyi.production.pojo.ProductProcess;
import com.ruoyi.production.pojo.ProductStructure;
import com.ruoyi.production.service.ProductBomService;
import com.ruoyi.production.service.ProductProcessService;
import com.ruoyi.production.service.ProductStructureService;
import com.ruoyi.production.service.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -44,20 +40,20 @@
public class ProductBomServiceImpl extends ServiceImpl<ProductBomMapper, ProductBom> implements ProductBomService {
    @Autowired
    private IProductService productService;
    @Autowired
    private ProductBomMapper productBomMapper;
    @Autowired
    private IProductModelService productModelService;
    @Autowired
    private ProductStructureService productStructureService;
    @Autowired
    private ProductProcessService productProcessService;
    @Autowired
    private ProductMaterialService productMaterialService;
    @Autowired
    private ProductMaterialSkuService productMaterialSkuService;
    @Override
    public IPage<ProductBomDto> listPage(Page page, ProductBomDto productBomDto) {
@@ -78,15 +74,16 @@
                throw new ServiceException("请选择产品模型");
            }
            ProductModel productModel = productModelService.getById(productBom.getProductModelId());
            ProductMaterialSku productModel = productMaterialSkuService.getById(productBom.getProductModelId());
            if (productModel == null) {
                throw new ServiceException("选择的产品模型不存在");
            }
            ProductMaterial productMaterial = productMaterialService.getById(productModel.getProductId());
            //  æ·»åŠ åˆå§‹çš„äº§å“ç»“æž„
            ProductStructure productStructure = new ProductStructure();
            productStructure.setProductModelId(productBom.getProductModelId());
            productStructure.setUnit(productModel.getUnit());
            productStructure.setUnit(productMaterial != null ? productMaterial.getUnit() : null);
            productStructure.setUnitQuantity(BigDecimal.valueOf(1));
            productStructure.setBomId(productBom.getId());
@@ -123,7 +120,7 @@
        //  åˆ›å»º BOM æ•°æ®
        BomImportDto first = list.get(0);
        ProductModel rootModel = findModel(first.getParentName(), first.getParentSpec());
        ProductMaterialSku rootModel = findModel(first.getParentName(), first.getParentSpec());
        ProductBom bom = new ProductBom();
        bom.setProductModelId(rootModel.getId());
        bom.setVersion("1.0");
@@ -146,7 +143,8 @@
                rootNode.setParentId(null); // é¡¶å±‚没有父节点
                rootNode.setProductModelId(rootModel.getId());
                rootNode.setUnitQuantity(BigDecimal.ONE);
                rootNode.setUnit(rootModel.getUnit());
                ProductMaterial rootMaterial = productMaterialService.getById(rootModel.getProductId());
                rootNode.setUnit(rootMaterial != null ? rootMaterial.getUnit() : null);
                productStructureService.save(rootNode);
                treePathMap.put(parentKey, rootNode.getId());
@@ -162,7 +160,7 @@
            }
            //  èŽ·å–å­é¡¹æ¨¡åž‹ä¿¡æ¯
            ProductModel childModel = findModel(dto.getChildName(), dto.getChildSpec());
            ProductMaterialSku childModel = findModel(dto.getChildName(), dto.getChildSpec());
            //  æ’入结构表
            ProductStructure node = new ProductStructure();
@@ -170,7 +168,8 @@
            node.setParentId(parentStructureId); // çˆ¶èŠ‚ç‚¹ID
            node.setProductModelId(childModel.getId());
            node.setUnitQuantity(dto.getUnitQty());
            node.setUnit(childModel.getUnit());
            ProductMaterial childMaterial = productMaterialService.getById(childModel.getProductId());
            node.setUnit(childMaterial != null ? childMaterial.getUnit() : null);
            if (processMap.containsKey(dto.getProcess())) {
                node.setProcessId(processMap.get(dto.getProcess()));
            }
@@ -191,7 +190,7 @@
            return;
        }
        List<ProductStructureDto> treeData = productStructureService.listBybomId(bomId);
        List<ProductStructureDto> treeData = productStructureService.listByBomId(bomId);
        if (treeData == null || treeData.isEmpty()) {
            return;
        }
@@ -262,14 +261,14 @@
        }
    }
    private ProductModel findModel(String name, String spec) {
        Product product = productService.getOne(new LambdaQueryWrapper<Product>()
                .eq(Product::getProductName, name).last("limit 1"));
    private ProductMaterialSku findModel(String name, String spec) {
        ProductMaterial product = productMaterialService.getOne(new LambdaQueryWrapper<ProductMaterial>()
                .eq(ProductMaterial::getProductName, name).last("limit 1"));
        if (product == null) throw new ServiceException("产品未维护:" + name);
        ProductModel model = productModelService.getOne(new LambdaQueryWrapper<ProductModel>()
                .eq(ProductModel::getProductId, product.getId())
                .eq(ProductModel::getModel, spec).last("limit 1"));
        ProductMaterialSku model = productMaterialSkuService.getOne(new LambdaQueryWrapper<ProductMaterialSku>()
                .eq(ProductMaterialSku::getProductId, product.getId())
                .eq(ProductMaterialSku::getModel, spec).last("limit 1"));
        if (model == null) throw new ServiceException("规格未维护:" + name + "[" + spec + "]");
        return model;
    }
src/main/java/com/ruoyi/production/service/impl/ProductMaterialServiceImpl.java
@@ -143,8 +143,8 @@
            JSONObject formData = item.getJSONObject("formData");
            //  å¤„理物料主表数据
            ProductMaterial material = new ProductMaterial();
            material.setMaterialName(formData.getString("textField_l92f36f5"));
            material.setBaseUnit(formData.getString("textField_la147lnw"));
            material.setProductName(formData.getString("textField_l92f36f5"));
            material.setUnit(formData.getString("textField_la147lnw"));
            material.setRemark(formData.getString("textareaField_l92f36f9"));
            String materialType = formData.getString("selectField_l92f36fb");
@@ -156,11 +156,11 @@
            //  å¤„理物料规格数据
            ProductMaterialSku sku = new ProductMaterialSku();
            sku.setMaterialId(materialId);
            sku.setProductId(materialId);
            sku.setFormInstanceId(formInstanceId);
            sku.setIdentifierCode(formData.getString("textField_l92h77ju"));
            sku.setMaterialCode(formData.getString("textField_l92f36f2"));
            sku.setSpecification(formData.getString("textField_l92f36f6"));
            sku.setModel(formData.getString("textField_l92f36f6"));
            sku.setSupplyType(formData.getString("selectField_la14k51j"));
            sku.setOriginatorName(originatorName);
            sku.setOriginatorOrg("宁夏中创绿能实业集团有限公司");
@@ -175,7 +175,7 @@
    private Long getOrCreateMaterial(ProductMaterial material) {
        LambdaQueryWrapper<ProductMaterial> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(ProductMaterial::getMaterialName, material.getMaterialName());
        queryWrapper.eq(ProductMaterial::getProductName, material.getProductName());
        ProductMaterial exist = this.getOne(queryWrapper);
        if (exist == null) {
@@ -194,8 +194,8 @@
                exist.setInventoryCategoryId(material.getInventoryCategoryId());
                needUpdate = true;
            }
            if (StringUtils.isNotEmpty(material.getBaseUnit()) && !material.getBaseUnit().equals(exist.getBaseUnit())) {
                exist.setBaseUnit(material.getBaseUnit());
            if (StringUtils.isNotEmpty(material.getUnit()) && !material.getUnit().equals(exist.getUnit())) {
                exist.setUnit(material.getUnit());
                needUpdate = true;
            }
            if (needUpdate) {
@@ -229,8 +229,8 @@
        for (ProductMaterialSku sku : list) {
            LambdaQueryWrapper<ProductMaterialSku> wrapper = new LambdaQueryWrapper<>();
            wrapper.eq(ProductMaterialSku::getMaterialId, sku.getMaterialId())
                    .eq(ProductMaterialSku::getSpecification, sku.getSpecification());
            wrapper.eq(ProductMaterialSku::getProductId, sku.getProductId())
                    .eq(ProductMaterialSku::getModel, sku.getModel());
            if (StringUtils.isNotEmpty(sku.getMaterialCode())) {
                wrapper.eq(ProductMaterialSku::getMaterialCode, sku.getMaterialCode());
@@ -242,7 +242,7 @@
            if (exist == null) {
                productMaterialSkuService.save(sku);
                affected++;
                log.info("新增物料规格 {}", sku.getSpecification());
                log.info("新增物料规格 {}", sku.getModel());
            } else {
                if (exist.getFormModifiedTime() == null || !exist.getFormModifiedTime().equals(sku.getFormModifiedTime())) {
                    sku.setId(exist.getId());
@@ -250,7 +250,7 @@
                    productMaterialSkuService.updateById(sku);
                    affected++;
                    log.info("更新物料规格 {}", sku.getSpecification());
                    log.info("更新物料规格 {}", sku.getModel());
                }
            }
        }
@@ -273,7 +273,7 @@
                            ProductMaterial::getId,
                            ProductMaterial::getMaterialTypeId,
                            ProductMaterial::getInventoryCategoryId,
                            ProductMaterial::getMaterialName
                            ProductMaterial::getProductName
                    )
            );
            materialMap = materialList.stream()
@@ -307,10 +307,10 @@
                ProductMaterial::getId,
                ProductMaterial::getMaterialTypeId,
                ProductMaterial::getInventoryCategoryId,
                ProductMaterial::getMaterialName
                ProductMaterial::getProductName
        );
        if (StringUtils.isNotEmpty(materialName)) {
            wrapper.like(ProductMaterial::getMaterialName, materialName);
            wrapper.like(ProductMaterial::getProductName, materialName);
        }
        if (materialTypeId != null) {
            wrapper.eq(ProductMaterial::getMaterialTypeId, materialTypeId);
@@ -345,7 +345,7 @@
    private ProductMaterialDto convert(ProductMaterial m) {
        ProductMaterialDto dto = new ProductMaterialDto();
        dto.setId(m.getId());
        dto.setMaterialName(m.getMaterialName());
        dto.setProductName(m.getProductName());
        dto.setMaterialTypeId(m.getMaterialTypeId());
        dto.setInventoryCategoryId(m.getInventoryCategoryId());
        return dto;
@@ -355,7 +355,7 @@
    @Transactional(rollbackFor = Exception.class)
    public void addProductMaterial(ProductMaterial productMaterial) {
        validateProductMaterial(productMaterial, false);
        if (existsMaterialName(productMaterial.getMaterialName(), null)) {
        if (existsMaterialName(productMaterial.getProductName(), null)) {
            throw new ServiceException("物料名称已存在");
        }
        LocalDateTime now = LocalDateTime.now();
@@ -366,7 +366,7 @@
        if (!this.save(productMaterial)) {
            throw new ServiceException("新增物料失败");
        }
        log.info("新增物料成功 materialName={}", productMaterial.getMaterialName());
        log.info("新增物料成功 materialName={}", productMaterial.getProductName());
    }
    @Override
@@ -377,7 +377,7 @@
        if (exist == null) {
            throw new ServiceException("物料不存在");
        }
        if (existsMaterialName(productMaterial.getMaterialName(), productMaterial.getId())) {
        if (existsMaterialName(productMaterial.getProductName(), productMaterial.getId())) {
            throw new ServiceException("物料名称已存在");
        }
        productMaterial.setUpdateTime(LocalDateTime.now());
@@ -406,7 +406,7 @@
        if (requireId && productMaterial.getId() == null) {
            throw new ServiceException("主键ID不能为空");
        }
        if (StringUtils.isEmpty(productMaterial.getMaterialName())) {
        if (StringUtils.isEmpty(productMaterial.getProductName())) {
            throw new ServiceException("物料名称不能为空");
        }
    }
@@ -416,7 +416,7 @@
            return false;
        }
        LambdaQueryWrapper<ProductMaterial> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(ProductMaterial::getMaterialName, materialName);
        queryWrapper.eq(ProductMaterial::getProductName, materialName);
        if (excludeId != null) {
            queryWrapper.ne(ProductMaterial::getId, excludeId);
        }
src/main/java/com/ruoyi/production/service/impl/ProductMaterialSkuServiceImpl.java
@@ -11,7 +11,7 @@
import com.ruoyi.production.mapper.ProductMaterialSkuMapper;
import com.ruoyi.production.pojo.ProductMaterial;
import com.ruoyi.production.pojo.ProductMaterialSku;
import com.ruoyi.production.pojo.ProductMaterialSkuImportDto;
import com.ruoyi.production.dto.ProductMaterialSkuImportDto;
import com.ruoyi.production.service.ProductMaterialSkuService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
@@ -21,7 +21,6 @@
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
@@ -59,12 +58,12 @@
    public void addProductMaterialSku(ProductMaterialSku sku) {
        validateProductMaterialSku(sku, false);
        // æ ¡éªŒç‰©æ–™æ˜¯å¦å­˜åœ¨
        ProductMaterial material = productMaterialMapper.selectById(sku.getMaterialId());
        ProductMaterial material = productMaterialMapper.selectById(sku.getProductId());
        if (material == null) {
            throw new ServiceException("物料不存在");
        }
        // æ ¡éªŒè§„格是否重复
        if (existsSameSpecification(sku.getMaterialId(), sku.getSpecification(), null)) {
        if (existsSameSpecification(sku.getProductId(), sku.getModel(), null)) {
            throw new ServiceException("该物料已存在相同规格");
        }
        LocalDateTime now = LocalDateTime.now();
@@ -76,7 +75,7 @@
        if (!this.save(sku)) {
            throw new ServiceException("新增物料规格失败");
        }
        log.info("新增物料规格成功 materialId={}, specification={}", sku.getMaterialId(), sku.getSpecification());
        log.info("新增物料规格成功 materialId={}, specification={}", sku.getProductId(), sku.getModel());
    }
    /**
@@ -86,7 +85,7 @@
    public void updateProductMaterialSku(ProductMaterialSku sku) {
        validateProductMaterialSku(sku, true);
        // æ ¡éªŒè§„格是否重复
        if (existsSameSpecification(sku.getMaterialId(), sku.getSpecification(), sku.getId())) {
        if (existsSameSpecification(sku.getProductId(), sku.getModel(), sku.getId())) {
            throw new ServiceException("该物料已存在相同规格");
        }
        sku.setUpdateTime(LocalDateTime.now());
@@ -120,10 +119,10 @@
        if (requireId && sku.getId() == null) {
            throw new ServiceException("主键ID不能为空");
        }
        if (sku.getMaterialId() == null) {
        if (sku.getProductId() == null) {
            throw new ServiceException("物料ID不能为空");
        }
        if (StringUtils.isEmpty(sku.getSpecification())) {
        if (StringUtils.isEmpty(sku.getModel())) {
            throw new ServiceException("规格不能为空");
        }
    }
@@ -133,8 +132,8 @@
     */
    private boolean existsSameSpecification(Long materialId, String specification, Long excludeId) {
        LambdaQueryWrapper<ProductMaterialSku> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(ProductMaterialSku::getMaterialId, materialId)
                .eq(ProductMaterialSku::getSpecification, specification);
        queryWrapper.eq(ProductMaterialSku::getProductId, materialId)
                .eq(ProductMaterialSku::getModel, specification);
        if (excludeId != null) {
            queryWrapper.ne(ProductMaterialSku::getId, excludeId);
        }
@@ -172,10 +171,10 @@
        Map<String, ProductMaterialSkuImportDto> specMap = new LinkedHashMap<>();
        for (ProductMaterialSkuImportDto dto : importList) {
            if (dto == null || StringUtils.isEmpty(dto.getSpecification())) {
            if (dto == null || StringUtils.isEmpty(dto.getModel())) {
                continue;
            }
            String specification = dto.getSpecification().trim();
            String specification = dto.getModel().trim();
            if (specification.isEmpty()) {
                continue;
            }
@@ -189,10 +188,10 @@
        Set<String> specifications = specMap.keySet();
        List<ProductMaterialSku> existList = this.list(new LambdaQueryWrapper<ProductMaterialSku>()
                .eq(ProductMaterialSku::getMaterialId, materialId)
                .in(ProductMaterialSku::getSpecification, specifications));
                .eq(ProductMaterialSku::getProductId, materialId)
                .in(ProductMaterialSku::getModel, specifications));
        Map<String, ProductMaterialSku> existMap = existList.stream()
                .collect(Collectors.toMap(ProductMaterialSku::getSpecification, sku -> sku, (a, b) -> a));
                .collect(Collectors.toMap(ProductMaterialSku::getModel, sku -> sku, (a, b) -> a));
        LocalDateTime now = LocalDateTime.now();
        List<ProductMaterialSku> saveList = new ArrayList<>();
@@ -206,8 +205,8 @@
            ProductMaterialSku exist = existMap.get(specification);
            if (exist == null) {
                ProductMaterialSku sku = new ProductMaterialSku();
                sku.setMaterialId(materialId);
                sku.setSpecification(specification);
                sku.setProductId(materialId);
                sku.setModel(specification);
                sku.setSupplyType(supplyType);
                sku.setCreateTime(now);
                sku.setUpdateTime(now);
src/main/java/com/ruoyi/production/service/impl/ProductStructureServiceImpl.java
@@ -130,8 +130,8 @@
    @Override
    public List<ProductStructureDto> listBybomId(Integer bomId) {
        List<ProductStructureDto> list = productStructureMapper.listBybomId(bomId);
    public List<ProductStructureDto> listByBomId(Integer bomId) {
        List<ProductStructureDto> list = productStructureMapper.listByBomId(bomId);
        Map<Long, ProductStructureDto> map = new HashMap<>();
        for (ProductStructureDto node : list) {
src/main/java/com/ruoyi/production/service/impl/ProductionProductMainServiceImpl.java
@@ -140,7 +140,7 @@
        productionProductMain.setStatus(0);
        productionProductMainMapper.insert(productionProductMain);
        /*新增报工投入表*/
        List<ProductStructureDto> productStructureDtos = productStructureMapper.listBybomAndProcess(productProcessRoute.getBomId(), productProcess.getId());
        List<ProductStructureDto> productStructureDtos = productStructureMapper.listByBomAndProcess(productProcessRoute.getBomId(), productProcess.getId());
        if (productStructureDtos.size() == 0) {
            //如果该工序没有产品结构的投入品,那这个投入品和产出品是同一个
            ProductStructureDto productStructureDto = new ProductStructureDto();
src/main/java/com/ruoyi/sales/service/impl/SalesLedgerProductServiceImpl.java
@@ -495,7 +495,7 @@
        if (processRoute == null) {
            return R.fail("请先设置工艺路线");
        }
        List<ProductStructureDto> productStructureDtos = productStructureMapper.listBybomId(processRoute.getBomId());
        List<ProductStructureDto> productStructureDtos = productStructureMapper.listByBomId(processRoute.getBomId());
        if (productStructureDtos.isEmpty()) {
            return R.fail("请先设置产品结构");
        }
src/main/resources/mapper/production/ProductBomMapper.xml
@@ -15,34 +15,40 @@
        <result column="update_user" property="updateUser"/>
        <result column="tenant_id" property="tenantId"/>
    </resultMap>
    <select id="listPage" resultType="com.ruoyi.production.dto.ProductBomDto">
        select * from (select pb.*,
        pm.model productModelName,
        p.product_name productName
        from product_bom pb
        left join product_model pm on pb.product_model_id = pm.id
        left join product p on pm.product_id = p.id)A
        where 1=1
        <if test="c.productModelName != null">
            and productModelName = #{c.productModelName}
        SELECT * FROM (
        SELECT
        pb.*,
        pms.model AS productModelName,
        pm.product_name AS productName
        FROM product_bom pb
        LEFT JOIN product_material_sku pms ON pb.product_model_id = pms.id
        LEFT JOIN product_material pm ON pms.product_id = pm.id
        ) A
        WHERE 1=1
        <if test="c.productModelName != null and c.productModelName != ''">
            AND productModelName LIKE CONCAT('%', #{c.productModelName}, '%')
        </if>
        <if test="c.productName != null">
            and productName = #{c.productName}
        <if test="c.productName != null and c.productName != ''">
            AND productName LIKE CONCAT('%', #{c.productName}, '%')
        </if>
        <if test="c.bomNo != null">
            and bom_no = #{c.bomNo}
        <if test="c.bomNo != null and c.bomNo != ''">
            AND bom_no = #{c.bomNo}
        </if>
        <if test="c.version != null">
            and version = #{c.version}
        <if test="c.version != null and c.version != ''">
            AND version = #{c.version}
        </if>
    </select>
    <select id="getById" resultType="com.ruoyi.production.dto.ProductBomDto">
        select pb.*,
               pm.model productModelName,
               p.product_name productName
               pms.model AS productModelName,
               pm.product_name   AS productName
        from product_bom pb
                 left join product_model pm on pb.product_model_id = pm.id
                 left join product p on pm.product_id = p.id
                 left join product_material_sku pms on pb.product_model_id = pms.id
                 left join product_material pm on pms.product_id = pm.id
        where pb.id = #{id}
    </select>
</mapper>
src/main/resources/mapper/production/ProductMaterialMapper.xml
@@ -9,8 +9,8 @@
        <result property="tenantId" column="tenant_id"/>
        <result property="materialTypeId" column="material_type_id"/>
        <result property="inventoryCategoryId" column="inventory_category_id"/>
        <result property="materialName" column="material_name"/>
        <result property="baseUnit" column="base_unit"/>
        <result property="productName" column="product_name"/>
        <result property="unit" column="unit"/>
        <result property="remark" column="remark"/>
        <result property="createTime" column="create_time"/>
        <result property="updateTime" column="update_time"/>
src/main/resources/mapper/production/ProductMaterialSkuMapper.xml
@@ -6,10 +6,10 @@
    <resultMap id="ProductMaterialSkuResultMap" type="com.ruoyi.production.pojo.ProductMaterialSku">
        <id property="id" column="id"/>
        <result property="materialId" column="material_id"/>
        <result property="productId" column="product_id"/>
        <result property="identifierCode" column="identifier_code"/>
        <result property="materialCode" column="material_code"/>
        <result property="specification" column="specification"/>
        <result property="model" column="model"/>
        <result property="supplyType" column="supply_type"/>
        <result property="originatorName" column="originator_name"/>
        <result property="originatorOrg" column="originator_org"/>
@@ -21,28 +21,28 @@
    <select id="selectSkuWithMaterialPage" resultType="com.ruoyi.production.dto.ProductMaterialSkuDto">
        SELECT
        sku.id AS skuId,
        sku.material_id AS materialId,
        sku.id AS id,
        sku.product_id AS productId,
        sku.material_code AS materialCode,
        sku.specification AS specification,
        sku.model AS model,
        sku.supply_type AS supplyType,
        m.material_name AS materialName,
        m.base_unit AS baseUnit
        m.product_name AS productName,
        m.unit AS unit
        FROM product_material_sku sku
        LEFT JOIN product_material m ON sku.material_id = m.id
        LEFT JOIN product_material m ON sku.product_id = m.id
        <where>
            <if test="dto.materialId != null">
                AND sku.material_id = #{dto.materialId}
            <if test="dto.productId != null">
                AND sku.product_id = #{dto.productId}
            </if>
            <if test="dto.specification != null and dto.specification != ''">
                AND sku.specification LIKE CONCAT('%', #{dto.specification}, '%')
            <if test="dto.model != null and dto.model != ''">
                AND sku.model LIKE CONCAT('%', #{dto.model}, '%')
            </if>
            <if test="dto.materialCode != null and dto.materialCode != ''">
                AND sku.material_code LIKE CONCAT('%', #{dto.materialCode}, '%')
            </if>
            <if test="type != null and type == 1 and dto.materialName != null and dto.materialName != ''">
                AND m.material_name LIKE CONCAT('%', #{dto.materialName}, '%')
            <if test="type != null and type == 1 and dto.productName != null and dto.productName != ''">
                AND m.product_name LIKE CONCAT('%', #{dto.productName}, '%')
            </if>
        </where>
        ORDER BY sku.id ASC
src/main/resources/mapper/production/ProductStructureMapper.xml
@@ -11,33 +11,33 @@
        <result property="unit" column="unit"/>
        <result property="tenantId" column="tenant_id"/>
    </resultMap>
    <select id="listBybomId" resultType="com.ruoyi.production.dto.ProductStructureDto">
    <select id="listByBomId" resultType="com.ruoyi.production.dto.ProductStructureDto">
        select ps.*,
               p.product_name,
               pp.name as  process_name,
               pm.product_id,
               pm.model
        from
            product_structure ps
                left join product_model pm on ps.product_model_id = pm.id
                left join product p on pm.product_id = p.id
                left join product_process pp on ps.process_id = pp.id
               pm.product_name as product_name,
               pp.name         as process_name,
               pms.product_id as product_id,
               pms.model       as model
        from product_structure ps
                 left join product_material_sku pms on ps.product_model_id = pms.id
                 left join product_material pm on pms.product_id = pm.id
                 left join product_process pp on ps.process_id = pp.id
        where ps.bom_id = #{bomId}
        order by ps.id
    </select>
    <select id="listBybomAndProcess" resultType="com.ruoyi.production.dto.ProductStructureDto">
    <select id="listByBomAndProcess" resultType="com.ruoyi.production.dto.ProductStructureDto">
        select ps.*,
               p.product_name,
               pp.name as  process_name,
               pm.product_id,
               pm.model
        from
            product_structure ps
                left join product_model pm on ps.product_model_id = pm.id
                left join product p on pm.product_id = p.id
                left join product_process pp on ps.process_id = pp.id
               pm.product_name as product_name,
               pp.name         as process_name,
               pms.product_id as product_id,
               pms.model       as model
        from product_structure ps
                 left join product_material_sku pms on ps.product_model_id = pms.id
                 left join product_material pm on pms.product_id = pm.id
                 left join product_process pp on ps.process_id = pp.id
        where ps.bom_id = #{bomId}
        and ps.process_id=#{processId}
          and ps.process_id = #{processId}
        order by ps.id
    </select>
</mapper>