From 90869d75f496350fcb11587010fef20fba16157b Mon Sep 17 00:00:00 2001
From: gongchunyi <deslre0381@gmail.com>
Date: 星期三, 08 四月 2026 14:52:59 +0800
Subject: [PATCH] fix: 新增主生成计划的申请单编号不能重复,报工查看详情数据重复问题

---
 src/main/resources/mapper/production/ProductMaterialMapper.xml |   55 ++++++++++++++++++++++++++++++++++++++++++++++---------
 1 files changed, 46 insertions(+), 9 deletions(-)

diff --git a/src/main/resources/mapper/production/ProductMaterialMapper.xml b/src/main/resources/mapper/production/ProductMaterialMapper.xml
index 84d8ca4..93f4a8e 100644
--- a/src/main/resources/mapper/production/ProductMaterialMapper.xml
+++ b/src/main/resources/mapper/production/ProductMaterialMapper.xml
@@ -3,23 +3,60 @@
         "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 
 <mapper namespace="com.ruoyi.production.mapper.ProductMaterialMapper">
+
     <resultMap id="ProductMaterialResultMap" type="com.ruoyi.production.pojo.ProductMaterial">
         <id property="id" column="id"/>
         <result property="tenantId" column="tenant_id"/>
         <result property="materialTypeId" column="material_type_id"/>
         <result property="inventoryCategoryId" column="inventory_category_id"/>
-        <result property="identifierCode" column="identifier_code"/>
-        <result property="materialCode" column="material_code"/>
-        <result property="materialName" column="material_name"/>
-        <result property="specification" column="specification"/>
-        <result property="baseUnit" column="base_unit"/>
-        <result property="materialAttribute" column="material_attribute"/>
-        <result property="finishedProductName" column="finished_product_name"/>
-        <result property="originatorName" column="originator_name"/>
-        <result property="originatorOrg" column="originator_org"/>
+        <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"/>
     </resultMap>
 
+    <select id="selectProductByModelId" resultType="com.ruoyi.production.dto.ProductMaterialSkuDto"
+            parameterType="java.lang.Long">
+        select pm.product_name as productName,
+        pm.unit,
+        pms.material_code as materialCode,
+        pms.model
+        from product_material pm
+        left join product_material_sku pms on pms.product_id = pm.id
+        <where>
+            <choose>
+                <when test="productModelId != null">
+                    pms.id = #{productModelId}
+                </when>
+                <otherwise>
+                    1 = 0
+                </otherwise>
+            </choose>
+        </where>
+    </select>
+
+    <select id="selectProductByProductMainId" resultType="com.ruoyi.production.dto.ProductMaterialSkuDto"
+            parameterType="java.lang.Long">
+        select
+        pm.product_name as productName,
+        pm.unit,
+        pms.material_code as materialCode,
+        pms.model
+        from product_order po
+        left join product_material_sku pms on pms.id = po.product_material_sku_id
+        left join product_material pm on pm.id = pms.product_id
+        <where>
+            <choose>
+                <when test="productOrderId != null">
+                    po.id = #{productOrderId}
+                </when>
+                <otherwise>
+                    1 = 0
+                </otherwise>
+            </choose>
+        </where>
+    </select>
+
+
 </mapper>
\ No newline at end of file

--
Gitblit v1.9.3