From e0c8edd1d949fae5883a60019d02a9c5f7cb7a29 Mon Sep 17 00:00:00 2001
From: zss <zss@example.com>
Date: 星期三, 18 三月 2026 09:08:18 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/dev_宁夏_中盛建材' into dev_宁夏_中盛建材

---
 src/main/java/com/ruoyi/production/dto/BomImportDto.java                   |   22 +----
 doc/宁夏-中盛建材.sql                                                            |    5 +
 src/main/java/com/ruoyi/production/dto/ProductBomDto.java                  |    3 
 src/main/resources/mapper/production/ProductBomMapper.xml                  |   30 ++----
 src/main/java/com/ruoyi/production/service/impl/ProductBomServiceImpl.java |  122 +++++++++++-------------------
 src/main/resources/mapper/production/ProductStructureMapper.xml            |   29 ++----
 src/main/java/com/ruoyi/production/pojo/ProductBom.java                    |    5 +
 src/main/java/com/ruoyi/production/mapper/ProductBomMapper.java            |    2 
 src/main/java/com/ruoyi/production/controller/ProductBomController.java    |    6 
 src/main/java/com/ruoyi/production/service/ProductBomService.java          |    4 
 10 files changed, 92 insertions(+), 136 deletions(-)

diff --git "a/doc/\345\256\201\345\244\217-\344\270\255\347\233\233\345\273\272\346\235\220.sql" "b/doc/\345\256\201\345\244\217-\344\270\255\347\233\233\345\273\272\346\235\220.sql"
index ce5f676..8516a9f 100644
--- "a/doc/\345\256\201\345\244\217-\344\270\255\347\233\233\345\273\272\346\235\220.sql"
+++ "b/doc/\345\256\201\345\244\217-\344\270\255\347\233\233\345\273\272\346\235\220.sql"
@@ -268,3 +268,8 @@
 ADD COLUMN `sample_state` varchar(255) NULL COMMENT '璇曟牱鐘舵��' AFTER `sample_code`,
 ADD COLUMN `sample_time` date NULL COMMENT '鍙栨牱鏃ユ湡' AFTER `sample_state`,
 ADD COLUMN `license_plate_number` varchar(255) NULL COMMENT '杞︾墝鍙�' AFTER `sample_time`;
+
+
+ALTER TABLE `product_bom`
+    ADD COLUMN `dict_code` bigint NOT NULL COMMENT '鍏宠仈瀛楀吀鏁版嵁缂栫爜锛坰ys_dict_data.dict_code锛�';
+ALTER TABLE `product_bom` ADD INDEX `idx_dict_code` (`dict_code`);
\ No newline at end of file
diff --git a/src/main/java/com/ruoyi/production/controller/ProductBomController.java b/src/main/java/com/ruoyi/production/controller/ProductBomController.java
index 0ad7d59..5bfae99 100644
--- a/src/main/java/com/ruoyi/production/controller/ProductBomController.java
+++ b/src/main/java/com/ruoyi/production/controller/ProductBomController.java
@@ -57,7 +57,7 @@
     @GetMapping("/listPage")
     @Log(title = "BOM-鍒嗛〉鏌ヨ", businessType = BusinessType.OTHER)
     @ApiOperation("BOM-鍒嗛〉鏌ヨ")
-    public AjaxResult listPage(Page page, ProductBomDto productBomDto) {
+    public AjaxResult listPage(Page<ProductBom> page, ProductBomDto productBomDto) {
         IPage<ProductBomDto> listPage = productBomService.listPage(page, productBomDto);
         return AjaxResult.success(listPage);
     }
@@ -106,8 +106,8 @@
     @PreAuthorize("@ss.hasPermi('product:bom:import')")
     @Log(title = "鏍规嵁Excel瀵煎叆BOM", businessType = BusinessType.IMPORT)
     @ApiOperation("鏍规嵁Excel瀵煎叆BOM")
-    public AjaxResult uploadBom(@RequestParam("file") MultipartFile file) {
-        return productBomService.uploadBom(file);
+    public AjaxResult uploadBom(@RequestParam("file") MultipartFile file, @RequestParam("dictCode") Long dictCode) {
+        return productBomService.uploadBom(file, dictCode);
     }
 
     @PostMapping("exportBom")
diff --git a/src/main/java/com/ruoyi/production/dto/BomImportDto.java b/src/main/java/com/ruoyi/production/dto/BomImportDto.java
index 0cea81a..e53fd4f 100644
--- a/src/main/java/com/ruoyi/production/dto/BomImportDto.java
+++ b/src/main/java/com/ruoyi/production/dto/BomImportDto.java
@@ -8,23 +8,11 @@
 @Data
 public class BomImportDto {
 
-    @Excel(name = "鐖堕」浜у搧缂栧彿")
+    @Excel(name = "缂栧彿")
+    private String code;
+
+    @Excel(name = "鐖堕」缂栧彿")
     private String parentCode;
-
-    @Excel(name = "鐖堕」浜у搧鍚嶇О")
-    private String parentName;
-
-    @Excel(name = "鐖堕」浜у搧瑙勬牸")
-    private String parentSpec;
-
-    @Excel(name = "瀛愰」浜у搧缂栧彿")
-    private String childCode;
-
-    @Excel(name = "瀛愰」浜у搧鍚嶇О")
-    private String childName;
-
-    @Excel(name = "瀛愰」浜у搧瑙勬牸")
-    private String childSpec;
 
     @Excel(name = "鍗曚綅鐢ㄩ噺")
     private BigDecimal unitQty;
@@ -34,4 +22,4 @@
 
     @Excel(name = "澶囨敞")
     private String remark;
-}
+}
\ No newline at end of file
diff --git a/src/main/java/com/ruoyi/production/dto/ProductBomDto.java b/src/main/java/com/ruoyi/production/dto/ProductBomDto.java
index 8468f82..8bcb254 100644
--- a/src/main/java/com/ruoyi/production/dto/ProductBomDto.java
+++ b/src/main/java/com/ruoyi/production/dto/ProductBomDto.java
@@ -18,4 +18,7 @@
     //浜у搧缂栫爜
     private String productCode;
 
+    //  浜у搧绫诲瀷
+    private String dictLabel;
+
 }
diff --git a/src/main/java/com/ruoyi/production/mapper/ProductBomMapper.java b/src/main/java/com/ruoyi/production/mapper/ProductBomMapper.java
index 1183335..44ac0c9 100644
--- a/src/main/java/com/ruoyi/production/mapper/ProductBomMapper.java
+++ b/src/main/java/com/ruoyi/production/mapper/ProductBomMapper.java
@@ -20,7 +20,7 @@
 @Mapper
 public interface ProductBomMapper extends BaseMapper<ProductBom> {
 
-    IPage<ProductBomDto> listPage(Page page, @Param("c") ProductBomDto productBomDto);
+    IPage<ProductBomDto> listPage(Page<ProductBom> page, @Param("c") ProductBomDto productBomDto);
 
     ProductBomDto getById(@Param("bomId") Long bomId);
 }
diff --git a/src/main/java/com/ruoyi/production/pojo/ProductBom.java b/src/main/java/com/ruoyi/production/pojo/ProductBom.java
index 2415eff..4ea1b0f 100644
--- a/src/main/java/com/ruoyi/production/pojo/ProductBom.java
+++ b/src/main/java/com/ruoyi/production/pojo/ProductBom.java
@@ -5,6 +5,7 @@
 import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
+
 import java.io.Serializable;
 import java.time.LocalDateTime;
 
@@ -38,9 +39,13 @@
     private String bomNo;
 
     @ApiModelProperty("浜у搧瑙勬牸id")
+    @TableField(exist = false)
     //瀹佸-涓洓寤烘潗浣跨敤鏂扮殑浜у搧琛ㄥ叧鑱攑roduct_material_sku
     private Long productModelId;
 
+    @ApiModelProperty("鍏宠仈瀛楀吀鏁版嵁缂栫爜锛坰ys_dict_data.dict_code锛�")
+    private Long dictCode;
+
     @ApiModelProperty("澶囨敞")
     private String remark;
 
diff --git a/src/main/java/com/ruoyi/production/service/ProductBomService.java b/src/main/java/com/ruoyi/production/service/ProductBomService.java
index d812f9f..af6979c 100644
--- a/src/main/java/com/ruoyi/production/service/ProductBomService.java
+++ b/src/main/java/com/ruoyi/production/service/ProductBomService.java
@@ -20,11 +20,11 @@
  */
 public interface ProductBomService extends IService<ProductBom> {
 
-    IPage<ProductBomDto> listPage(Page page, ProductBomDto productBomDto);
+    IPage<ProductBomDto> listPage(Page<ProductBom> page, ProductBomDto productBomDto);
 
     AjaxResult add(ProductBom productBom);
 
-    AjaxResult uploadBom(MultipartFile file);
+    AjaxResult uploadBom(MultipartFile file, Long dictCode);
 
     void exportBom(HttpServletResponse response, Integer bomId);
 }
diff --git a/src/main/java/com/ruoyi/production/service/impl/ProductBomServiceImpl.java b/src/main/java/com/ruoyi/production/service/impl/ProductBomServiceImpl.java
index 43a8942..b5c9562 100644
--- a/src/main/java/com/ruoyi/production/service/impl/ProductBomServiceImpl.java
+++ b/src/main/java/com/ruoyi/production/service/impl/ProductBomServiceImpl.java
@@ -4,8 +4,6 @@
 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.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;
@@ -18,6 +16,8 @@
 import com.ruoyi.production.pojo.ProductProcess;
 import com.ruoyi.production.pojo.ProductStructure;
 import com.ruoyi.production.service.*;
+import com.ruoyi.project.system.domain.SysDictData;
+import com.ruoyi.project.system.mapper.SysDictDataMapper;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
@@ -50,44 +50,30 @@
     private ProductProcessService productProcessService;
 
     @Autowired
-    private ProductMaterialService productMaterialService;
-
-    @Autowired
-    private ProductMaterialSkuService productMaterialSkuService;
+    private SysDictDataMapper sysDictDataMapper;
 
     @Override
-    public IPage<ProductBomDto> listPage(Page page, ProductBomDto productBomDto) {
+    public IPage<ProductBomDto> listPage(Page<ProductBom> page, ProductBomDto productBomDto) {
         return productBomMapper.listPage(page, productBomDto);
     }
 
     @Override
     @Transactional(rollbackFor = Exception.class)
     public AjaxResult add(ProductBom productBom) {
+        if (productBom == null || productBom.getDictCode() == null) {
+            throw new ServiceException("鏂板澶辫触,浜у搧绫诲瀷涓嶈兘涓虹┖");
+        }
+
+        SysDictData sysDictData = sysDictDataMapper.selectDictDataById(productBom.getDictCode());
+        if (sysDictData == null) {
+            throw new ServiceException("鏂板澶辫触,浜у搧绫诲瀷涓嶅瓨鍦�");
+        }
+
         boolean save = productBomMapper.insert(productBom) > 0;
         if (save) {
             String no = "BM." + String.format("%05d", productBom.getId());
             productBom.setBomNo(no);
             productBomMapper.updateById(productBom);
-
-            //  鏌ヨ鍑轰骇鍝佹ā鍨嬩俊鎭�
-            if (productBom.getProductModelId() == null) {
-                throw new ServiceException("璇烽�夋嫨浜у搧妯″瀷");
-            }
-
-            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(productMaterial != null ? productMaterial.getUnit() : null);
-            productStructure.setUnitQuantity(BigDecimal.valueOf(1));
-            productStructure.setBomId(productBom.getId());
-
-            productStructureService.save(productStructure);
 
             return AjaxResult.success();
         }
@@ -96,7 +82,15 @@
 
     @Override
     @Transactional(rollbackFor = Exception.class)
-    public AjaxResult uploadBom(MultipartFile file) {
+    public AjaxResult uploadBom(MultipartFile file, Long dictCode) {
+        if (dictCode == null) {
+            return AjaxResult.error("瀵煎叆澶辫触,浜у搧绫诲瀷涓嶈兘涓虹┖");
+        }
+        SysDictData sysDictData = sysDictDataMapper.selectDictDataById(dictCode);
+        if (sysDictData == null) {
+            return AjaxResult.error("瀵煎叆澶辫触,浜у搧绫诲瀷涓嶅瓨鍦�");
+        }
+
         ExcelUtil<BomImportDto> util = new ExcelUtil<>(BomImportDto.class);
         List<BomImportDto> list;
         try {
@@ -107,77 +101,66 @@
 
         if (list == null || list.isEmpty()) return AjaxResult.error("鏁版嵁涓虹┖");
 
-        //  澶勭悊宸ュ簭
+        //  澶勭悊瀛楁娓呯悊
         list.forEach(dto -> {
-            dto.setParentName(clean(dto.getParentName()));
-            dto.setParentSpec(clean(dto.getParentSpec()));
-            dto.setChildName(clean(dto.getChildName()));
-            dto.setChildSpec(clean(dto.getChildSpec()));
+            dto.setParentCode(clean(dto.getParentCode()));
+            dto.setCode(clean(dto.getCode()));
         });
         handleProcess(list);
         Map<String, Long> processMap = productProcessService.list().stream()
                 .collect(Collectors.toMap(ProductProcess::getName, ProductProcess::getId, (k1, k2) -> k1));
 
         //  鍒涘缓 BOM 鏁版嵁
-        BomImportDto first = list.get(0);
-        ProductMaterialSku rootModel = findModel(first.getParentName(), first.getParentSpec());
         ProductBom bom = new ProductBom();
-        bom.setProductModelId(rootModel.getId());
         bom.setVersion("1.0");
+        bom.setDictCode(dictCode);
         productBomMapper.insert(bom);
         bom.setBomNo("BM." + String.format("%05d", bom.getId()));
         productBomMapper.updateById(bom);
 
-        // 璁板綍宸茬粡鎻掑叆缁撴瀯鐨勮妭鐐癸細Key = "鍚嶇О+瑙勬牸", Value = structure_id
+        // 璁板綍宸茬粡鎻掑叆缁撴瀯鐨勮妭鐐癸細Key = "缂栫爜", Value = structure_id
         Map<String, Long> treePathMap = new HashMap<>();
 
         for (int i = 0; i < list.size(); i++) {
             BomImportDto dto = list.get(i);
-            String parentKey = dto.getParentName() + "|" + dto.getParentSpec();
-            String childKey = dto.getChildName() + "|" + dto.getChildSpec();
+            String currentCode = dto.getCode();
+            String parentCode = dto.getParentCode();
 
-            //澶勭悊鏍硅妭鐐�,绗竴琛屼笖瀛愰」涓虹┖
-            if (i == 0 && StringUtils.isBlank(dto.getChildName())) {
+            // 澶勭悊鏍硅妭鐐癸細涓�鑸寚绗竴琛屼笖娌℃湁鐖堕」缂栧彿
+            if (i == 0 && StringUtils.isBlank(parentCode)) {
                 ProductStructure rootNode = new ProductStructure();
                 rootNode.setBomId(bom.getId());
                 rootNode.setParentId(null); // 椤跺眰娌℃湁鐖惰妭鐐�
-                rootNode.setProductModelId(rootModel.getId());
+                if (processMap.containsKey(dto.getProcess())) {
+                    rootNode.setProcessId(processMap.get(dto.getProcess()));
+                }
                 rootNode.setUnitQuantity(BigDecimal.ONE);
-                ProductMaterial rootMaterial = productMaterialService.getById(rootModel.getProductId());
-                rootNode.setUnit(rootMaterial != null ? rootMaterial.getUnit() : null);
                 productStructureService.save(rootNode);
 
-                treePathMap.put(parentKey, rootNode.getId());
+                treePathMap.put(currentCode, rootNode.getId());
                 continue;
             }
 
             //  澶勭悊瀛愬眰绾ц妭鐐�
             //  鎵惧埌鐖惰妭鐐瑰湪鏁版嵁搴撻噷鐨� ID
-            Long parentStructureId = treePathMap.get(parentKey);
+            Long parentStructureId = treePathMap.get(parentCode);
             if (parentStructureId == null) {
                 // 濡傛灉 Map 閲屾壘涓嶅埌锛岃鏄� Excel 椤哄簭涔变簡鎴栬�呮暟鎹湁璇�
-                throw new ServiceException("瀵煎叆澶辫触: 鐖堕」[" + dto.getParentName() + "]蹇呴』鍦ㄥ叾瀛愰」涔嬪墠瀹氫箟");
+                throw new ServiceException("瀵煎叆澶辫触: 鐖堕」[" + parentCode + "]蹇呴』鍦ㄥ叾瀛愰」涔嬪墠瀹氫箟");
             }
-
-            //  鑾峰彇瀛愰」妯″瀷淇℃伅
-            ProductMaterialSku childModel = findModel(dto.getChildName(), dto.getChildSpec());
 
             //  鎻掑叆缁撴瀯琛�
             ProductStructure node = new ProductStructure();
             node.setBomId(bom.getId());
             node.setParentId(parentStructureId); // 鐖惰妭鐐笽D
-            node.setProductModelId(childModel.getId());
             node.setUnitQuantity(dto.getUnitQty());
-            ProductMaterial childMaterial = productMaterialService.getById(childModel.getProductId());
-            node.setUnit(childMaterial != null ? childMaterial.getUnit() : null);
             if (processMap.containsKey(dto.getProcess())) {
                 node.setProcessId(processMap.get(dto.getProcess()));
             }
             productStructureService.save(node);
 
-            //  鎶婂綋鍓嶅瓙椤硅褰曞埌 Map,浣滀负浠ュ悗鏇存繁灞傜骇鐨勭埗椤规煡鎵句緷鎹�
-            //  鍚屼竴鐖堕」涓嬬殑鍚屽悕瀛愰」涓嶉渶瑕侀噸澶嶈褰�
-            treePathMap.put(childKey, node.getId());
+            //  鎶婂綋鍓嶉」璁板綍鍒� Map, 浣滀负浠ュ悗鏇存繁灞傜骇鐨勭埗椤规煡鎵句緷鎹�
+            treePathMap.put(currentCode, node.getId());
         }
 
         return AjaxResult.success("BOM瀵煎叆鎴愬姛");
@@ -206,8 +189,7 @@
         for (ProductStructureDto root : treeData) {
             //  娣诲姞鏍硅妭鐐�
             BomImportDto rootRow = new BomImportDto();
-            rootRow.setParentName(root.getProductName());
-            rootRow.setParentSpec(root.getModel());
+            rootRow.setCode(root.getId().toString());
             rootRow.setUnitQty(root.getUnitQuantity());
             rootRow.setRemark("");
             exportList.add(rootRow);
@@ -229,14 +211,14 @@
                 }
 
                 BomImportDto row = new BomImportDto();
-                // 鐖剁被淇℃伅
-                row.setParentName(parent.getProductName());
-                row.setParentSpec(parent.getModel());
-                // 瀛愮被淇℃伅
-                row.setChildName(child.getProductName());
-                row.setChildSpec(child.getModel());
+                // 鐖剁被缂栧彿
+                row.setParentCode(parent.getId().toString());
+                // 鏈韩缂栧彿
+                row.setCode(child.getId().toString());
                 row.setUnitQty(child.getUnitQuantity());
                 row.setProcess(child.getProcessName());
+//                row.setProcess();
+                row.setRemark("");
 
                 exportList.add(row);
 
@@ -259,18 +241,6 @@
             map.put(node.getId(), node);
             populateMap(node.getChildren(), map);
         }
-    }
-
-    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);
-
-        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;
     }
 
     private void handleProcess(List<BomImportDto> list) {
diff --git a/src/main/resources/mapper/production/ProductBomMapper.xml b/src/main/resources/mapper/production/ProductBomMapper.xml
index 9c84a51..e3532c5 100644
--- a/src/main/resources/mapper/production/ProductBomMapper.xml
+++ b/src/main/resources/mapper/production/ProductBomMapper.xml
@@ -5,7 +5,7 @@
     <!-- 閫氱敤鏌ヨ鏄犲皠缁撴灉 -->
     <resultMap id="BaseResultMap" type="com.ruoyi.production.pojo.ProductBom">
         <id column="id" property="id"/>
-        <result column="product_model_id" property="productModelId"/>
+        <result column="dict_code" property="dictCode"/>
         <result column="bom_no" property="bomNo"/>
         <result column="remark" property="remark"/>
         <result column="version" property="version"/>
@@ -17,35 +17,27 @@
     </resultMap>
 
     <select id="listPage" resultType="com.ruoyi.production.dto.ProductBomDto">
-        SELECT * FROM (
         SELECT
-        pb.*,
-        pms.model AS productModelName,
-        pm.product_name AS productName,
-        pms.material_code AS productCode
-        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
+        pm.*,
+        sdd.dict_label AS dictLabel
+        FROM product_bom pm
+        LEFT JOIN sys_dict_data sdd ON sdd.dict_code = pm.dict_code
         WHERE 1=1
-        <if test="c.productModelName != null and c.productModelName != ''">
-            AND productModelName LIKE CONCAT('%', #{c.productModelName}, '%')
-        </if>
-        <if test="c.productName != null and c.productName != ''">
-            AND productName LIKE CONCAT('%', #{c.productName}, '%')
+        <if test="c.dictCode != null">
+            AND pm.dict_code = #{c.dictCode}
         </if>
         <if test="c.bomNo != null and c.bomNo != ''">
-            AND bom_no = #{c.bomNo}
+            AND pm.bom_no = #{c.bomNo}
         </if>
         <if test="c.version != null and c.version != ''">
-            AND version = #{c.version}
+            AND pm.version = #{c.version}
         </if>
     </select>
 
     <select id="getById" resultType="com.ruoyi.production.dto.ProductBomDto">
         select pb.*,
-               pms.model AS productModelName,
-               pm.product_name   AS productName
+               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
diff --git a/src/main/resources/mapper/production/ProductStructureMapper.xml b/src/main/resources/mapper/production/ProductStructureMapper.xml
index e5e692e..f92a9d0 100644
--- a/src/main/resources/mapper/production/ProductStructureMapper.xml
+++ b/src/main/resources/mapper/production/ProductStructureMapper.xml
@@ -13,29 +13,22 @@
     </resultMap>
 
     <select id="listByBomId" resultType="com.ruoyi.production.dto.ProductStructureDto">
-        select ps.*,
-               pm.product_name as product_name,
-               pp.name         as process_name,
-               pms.product_id as product_id,
-               pms.model       as model,
-               pms.material_code       as productCode
-        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 ps.id,
+               ps.parent_id,
+               ps.bom_id,
+               ps.unit_quantity,
+               ps.process_id,
+               pp.name AS process_name
+        FROM product_structure ps
+                 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 ps.*,
-               pm.product_name as product_name,
-               pp.name         as process_name,
-               pms.product_id as product_id,
-               pms.model       as model
+               pp.name as process_name
         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}

--
Gitblit v1.9.3