From 72b971c98c46531064d74b68fc8fe8864ed0b544 Mon Sep 17 00:00:00 2001
From: guoshilong <123456>
Date: Tue, 08 Nov 2022 09:04:56 +0800
Subject: [PATCH] 大屏溯源统计次数sql修改

---
 src/main/java/org/springblade/modules/soldr/mapper/SoldrMapper.xml |   49 +++++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 47 insertions(+), 2 deletions(-)

diff --git a/src/main/java/org/springblade/modules/soldr/mapper/SoldrMapper.xml b/src/main/java/org/springblade/modules/soldr/mapper/SoldrMapper.xml
index 87c6b5a..75cef4f 100644
--- a/src/main/java/org/springblade/modules/soldr/mapper/SoldrMapper.xml
+++ b/src/main/java/org/springblade/modules/soldr/mapper/SoldrMapper.xml
@@ -56,7 +56,7 @@
         AND blade_dict_biz.tenant_id = #{soldr.codes}
     </if>) a ON
         a.dict_key = stf.type
-        WHERE st.is_deleted = 0
+        WHERE st.is_deleted = 0 AND st.amount1 !=0
         <if test="soldr.stype!=null and soldr.stype != ''">
             and stf.type = #{soldr.stype}
         </if>
@@ -79,6 +79,9 @@
         from sys_soldr
         where id = #{id}
     </delete>
+    <update id="delLogic">
+            UPDATE sys_soldr SET  amount1 = 0 WHERE sid =#{id}
+    </update>
 
     <!--已出农资列表-->
     <select id="selectSol" resultType="org.springblade.modules.soldr.vo.SoldrVO">
@@ -116,13 +119,55 @@
     <select id="selectCz" resultType="java.util.Map">
         SELECT census, sid, amount1
         FROM `sys_soldr`
-        WHERE sid = #{sid} AND dept_id = #{deptId}
+        WHERE sid = #{sid} AND dept_id = #{deptId} AND is_deleted = 0
     </select>
 <!--    根据stockId、specs1、specs_val1、specs_val2、sid-->
     <select id="getByServalParam" resultType="org.springblade.modules.soldr.entity.Soldr">
         SELECT * FROM sys_soldr WHERE
         stock_id1 = #{stockId1} and specs1=#{specs1} and specs_val1=#{specsVal1} and specs_val2=#{specsVal2} and sid=#{sid} and type=#{type} and is_deleted=0
     </select>
+    <select id="getSoldrInfo" resultType="org.springblade.modules.soldr.vo.SoldrVO">
+        SELECT st.id,st.stock_id1,
+        st.specs1,
+        st.sid,
+        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,
+        st.dept_id
+        FROM sys_soldr 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 <if test="soldr.codes!=null and soldr.codes != ''">
+        AND blade_dict_biz.tenant_id = #{soldr.codes}
+    </if>) 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 <if test="soldr.codes!=null and soldr.codes != ''">
+        AND blade_dict_biz.tenant_id = #{soldr.codes}
+    </if>) 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  <if
+        test="soldr.codes!=null and soldr.codes != ''">
+        AND blade_dict_biz.tenant_id = #{soldr.codes}
+    </if>) a ON
+        a.dict_key = stf.type
+        WHERE st.is_deleted = 0
+        <if test="soldr.id!=null and soldr.id != ''">
+            AND st.id = #{soldr.id}
+        </if>
+        <if test="soldr.stype!=null and soldr.stype != ''">
+            and stf.type = #{soldr.stype}
+        </if>
+        <if test="soldr.stockId1!=null and soldr.stockId1 != ''">
+            and st.stock_id1 = #{soldr.stockId1}
+        </if>
+        <if test="soldr.deptId != null and soldr.deptId !=''">
+            AND st.dept_id = #{soldr.deptId}
+        </if>
+    </select>
 
     <update id="cancelDel">
         UPDATE sys_soldr SET is_deleted = 0 WHERE id = #{id}

--
Gitblit v1.9.3