From 0f51855b9046632aef8b517eb35b9116e5ea8b72 Mon Sep 17 00:00:00 2001
From: tangzy <tangzy123456>
Date: Mon, 30 May 2022 14:50:27 +0800
Subject: [PATCH] 农资管理

---
 src/main/java/org/springblade/modules/soldrecord/mapper/SoldrecordMapper.xml |   67 +++++++++++++++++++++++++++++----
 1 files changed, 58 insertions(+), 9 deletions(-)

diff --git a/src/main/java/org/springblade/modules/soldrecord/mapper/SoldrecordMapper.xml b/src/main/java/org/springblade/modules/soldrecord/mapper/SoldrecordMapper.xml
index 04871ec..8874abc 100644
--- a/src/main/java/org/springblade/modules/soldrecord/mapper/SoldrecordMapper.xml
+++ b/src/main/java/org/springblade/modules/soldrecord/mapper/SoldrecordMapper.xml
@@ -25,15 +25,56 @@
 
 
     <select id="selectSoldrecordPage" resultMap="soldrecordResultMap">
-        select * from sys_soldrecord where is_deleted = 0
+        select *
+        from sys_soldrecord
+        where is_deleted = 0
     </select>
 
     <select id="selectLists" resultType="org.springblade.modules.soldrecord.vo.SoldrecordVO">
-        SELECT st.*,
-               stf.factory_name AS factoryName,
-               stf.type AS stype,
-               d.dict_value AS dic1,
-               c.dict_value AS dic2
+        SELECT st.stock_id1,
+        st.specs1,
+        SUM(st.amount1 ) AS amount1,
+        stf.factory_name AS factoryName,
+        a.dict_value AS stype,
+        d.dict_value AS dic1,
+        c.dict_value AS dic2,
+        stf.agricultural_name as agrname
+        FROM sys_soldrecord st
+        LEFT JOIN sys_stockfactory stf ON stf.id = st.stock_id1
+        LEFT JOIN (SELECT dict_key, dict_value
+        FROM blade_dict_biz
+        WHERE CODE = 'stockSpecs1' AND is_deleted = 0) d ON d.dict_key = st.specs_val1
+        LEFT JOIN (SELECT dict_key, dict_value
+        FROM blade_dict_biz
+        WHERE CODE = 'stockSpecs2' AND is_deleted = 0) c ON c.dict_key = st.specs_val2
+        LEFT JOIN ( SELECT dict_key, dict_value FROM blade_dict_biz WHERE CODE = 'stockType' AND is_deleted = 0 ) a ON
+        a.dict_key = stf.type
+        WHERE st.is_deleted = 0
+        <if test="soldrecord.stype!=null and soldrecord.stype != ''">
+            and stf.type = #{soldrecord.stype}
+        </if>
+        <if test="soldrecord.stockId1!=null and soldrecord.stockId1 != ''">
+            and st.stock_id1 = #{soldrecord.stockId1}
+        </if>
+        GROUP BY
+        st.stock_id1,
+        st.specs1,
+        stf.factory_name,
+        a.dict_value,
+        d.dict_value,
+        c.dict_value
+    </select>
+    <!--查看变更明细-->
+    <select id="selectListbg" resultType="org.springblade.modules.soldrecord.vo.SoldrecordVO">
+        SELECT st.stock_id1,
+               st.specs1,
+               st.amount1,
+               stf.factory_name      AS factoryName,
+               stf.type as stype,
+               d.dict_value          AS dic1,
+               c.dict_value          AS dic2,
+               b.dict_value          AS dic3,
+               stf.agricultural_name AS agrname
         FROM sys_soldrecord st
                  LEFT JOIN sys_stockfactory stf ON stf.id = st.stock_id1
                  LEFT JOIN (SELECT dict_key, dict_value
@@ -42,13 +83,21 @@
                  LEFT JOIN (SELECT dict_key, dict_value
                             FROM blade_dict_biz
                             WHERE CODE = 'stockSpecs2' AND is_deleted = 0) c ON c.dict_key = st.specs_val2
+                 LEFT JOIN (SELECT dict_key, dict_value
+                            FROM blade_dict_biz
+                            WHERE CODE = 'stockPurchase1' AND is_deleted = 0) b ON b.dict_key = st.type
         WHERE st.is_deleted = 0
-        <if test="soldrecord.stype!=null and soldrecord.stype != ''">
-            and stf.type = #{soldrecord.stype}
-        </if>
         <if test="soldrecord.stockId1!=null and soldrecord.stockId1 != ''">
             and st.stock_id1 = #{soldrecord.stockId1}
         </if>
     </select>
 
+    <update id="updateSold">
+        update sys_soldr set amount1=#{amount} where sid = #{id}
+    </update>
+
+    <delete id="delc">
+        delete from sys_soldrecord where stock_id1 = #{id}
+    </delete>
+
 </mapper>

--
Gitblit v1.9.3