From 2652673d45d9f142baed0d92f1deab38276dbd90 Mon Sep 17 00:00:00 2001
From: liyong <18434998025@163.com>
Date: 星期二, 03 三月 2026 10:07:15 +0800
Subject: [PATCH] 库存区分原材料和成品和半成品

---
 src/main/resources/mapper/basic/ProductModelMapper.xml |   25 +++++++++++++++++++++----
 1 files changed, 21 insertions(+), 4 deletions(-)

diff --git a/src/main/resources/mapper/basic/ProductModelMapper.xml b/src/main/resources/mapper/basic/ProductModelMapper.xml
index e12b63c..9b1ade3 100644
--- a/src/main/resources/mapper/basic/ProductModelMapper.xml
+++ b/src/main/resources/mapper/basic/ProductModelMapper.xml
@@ -15,18 +15,26 @@
         <result column="product_id" property="productId" />
     </resultMap>
     <select id="listPageProductModel" resultType="com.ruoyi.basic.pojo.ProductModel">
-        select pm.*,p.product_name
+        select pm.*,p.product_name,p.parent_id,p1.product_name as parent_name,
+        case
+        when p1.product_name is null then 0 -- 鍘熸潗鏂�
+        when p1.product_name is not null and p1.product_name like '%鍗婃垚鍝�%' then 1 -- 鍗婃垚鍝�
+        when p1.product_name is not null and p1.product_name like '%鎴愬搧%' then 2 -- 鎴愬搧
+        else 0 -- 榛樿涓哄師鏉愭枡
+        end as product_type
         from product_model pm
         left join product p on pm.product_id = p.id
+        left join product p1 on p1.id = p.parent_id
         <where>
             <if test="c.model != null and c.model != ''">
-                and pm.model  like  concat('%',#{c.model},'%')
+                and pm.model like concat('%',#{c.model},'%')
             </if>
             <if test="c.productName != null and c.productName != ''">
-                and p.product_name  like  concat('%',#{c.productName},'%')
+                and p.product_name like concat('%',#{c.productName},'%')
             </if>
         </where>
-        order by  pm.id
+        order by pm.id
+
     </select>
     <select id="selectLatestRecord" resultType="com.ruoyi.basic.pojo.ProductModel">
             SELECT * FROM product_model
@@ -97,5 +105,14 @@
 
         ORDER BY pm.id DESC
     </select>
+    <select id="getProductAndModelList" resultType="java.util.Map">
+        select p.id as id,
+               pm.id as modelId,
+               p.product_name as productName ,
+               pm.model as  model
+        from product_model pm
+        left join product p on p.id = pm.product_id
+        order by p.id,pm.id desc
+    </select>
 
 </mapper>
\ No newline at end of file

--
Gitblit v1.9.3