From fdff4ca4813fc77a9006309ed4e5c232b4f3c85e Mon Sep 17 00:00:00 2001
From: guoshilong <123456>
Date: Fri, 22 Jul 2022 14:26:51 +0800
Subject: [PATCH] 返回数据新增农场全景地址

---
 src/main/java/org/springblade/modules/stock/mapper/StockMapper.xml |  138 +++++++++++++++++++++++++++++++++++++--------
 1 files changed, 112 insertions(+), 26 deletions(-)

diff --git a/src/main/java/org/springblade/modules/stock/mapper/StockMapper.xml b/src/main/java/org/springblade/modules/stock/mapper/StockMapper.xml
index 933d5ff..0e83182 100644
--- a/src/main/java/org/springblade/modules/stock/mapper/StockMapper.xml
+++ b/src/main/java/org/springblade/modules/stock/mapper/StockMapper.xml
@@ -26,9 +26,7 @@
 
 
     <select id="selectStockPage" resultMap="stockResultMap">
-        select *
-        from sys_stock
-        where is_deleted = 0
+        select * from sys_stock where is_deleted = 0
     </select>
 
     <select id="selectLists" resultType="org.springblade.modules.stock.vo.StockVO">
@@ -42,11 +40,68 @@
         LEFT JOIN sys_stockfactory stf ON stf.id = st.stock_id
         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_value1
+        WHERE CODE = 'stockSpecs1' AND is_deleted = 0
+        <if test="stock.codes!=null and stock.codes != ''">
+            AND blade_dict_biz.tenant_id = #{stock.codes}
+        </if>) d ON d.dict_key = st.specs_value1
         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_value2
-        LEFT JOIN ( SELECT dict_key, dict_value FROM blade_dict_biz WHERE CODE = 'stockType' AND is_deleted = 0 ) a ON
+        WHERE CODE = 'stockSpecs2' AND is_deleted = 0  <if test="stock.codes!=null and stock.codes != ''">
+        AND blade_dict_biz.tenant_id = #{stock.codes}
+    </if>) c ON c.dict_key = st.specs_value2
+        LEFT JOIN ( SELECT dict_key, dict_value FROM blade_dict_biz WHERE CODE = 'stockType' AND is_deleted = 0
+        <if test="stock.codes!=null and stock.codes != ''">
+            AND blade_dict_biz.tenant_id = #{stock.codes}
+        </if>) a ON
+        a.dict_key = stf.type
+        WHERE st.is_deleted = 0 and state=0
+        <if test="stock.stype!=null and stock.stype != ''">
+            and stf.type = #{stock.stype}
+        </if>
+        <if test="stock.specsValue1!=null and stock.specsValue1 != ''">
+            and st.specs_value1 = #{stock.specsValue1}
+        </if>
+        <if test="stock.year!=null and stock.year != ''">
+            and st.create_time like concat('%',#{stock.year},'%')
+        </if>
+        <if test="stock.specsValue2!=null and stock.specsValue2 != ''">
+            and st.specs_value2 = #{stock.specsValue2}
+        </if>
+        <if test="stock.state!=null and stock.state != ''">
+            and st.state = #{stock.state}
+        </if>
+        <if test="stock.type!=null and stock.type != ''">
+            and st.type = #{stock.type}
+        </if>
+        <if test="stock.agrname!=null and stock.agrname != ''">
+            and stf.agricultural_name like concat('%', #{stock.agrname},'%')
+        </if>
+    </select>
+
+    <select id="selectListss" resultType="org.springblade.modules.stock.vo.StockVO">
+        SELECT st.*,
+        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_stock st
+        LEFT JOIN sys_stockfactory stf ON stf.id = st.stock_id
+        LEFT JOIN (SELECT dict_key, dict_value
+        FROM blade_dict_biz
+        WHERE CODE = 'stockSpecs1' AND is_deleted = 0
+        <if test="stock.codes!=null and stock.codes != ''">
+            AND blade_dict_biz.tenant_id = #{stock.codes}
+        </if>) d ON d.dict_key = st.specs_value1
+        LEFT JOIN (SELECT dict_key, dict_value
+        FROM blade_dict_biz
+        WHERE CODE = 'stockSpecs2' AND is_deleted = 0  <if test="stock.codes!=null and stock.codes != ''">
+        AND blade_dict_biz.tenant_id = #{stock.codes}
+    </if>) c ON c.dict_key = st.specs_value2
+        LEFT JOIN ( SELECT dict_key, dict_value FROM blade_dict_biz WHERE CODE = 'stockType' AND is_deleted = 0
+        <if test="stock.codes!=null and stock.codes != ''">
+            AND blade_dict_biz.tenant_id = #{stock.codes}
+        </if>) a ON
         a.dict_key = stf.type
         WHERE st.is_deleted = 0 and state=0
         <if test="stock.stype!=null and stock.stype != ''">
@@ -108,10 +163,13 @@
         WHERE stock_type1 = 1
         AND type1 = 0
         <if test="stock.startTime!=null and stock.startTime!=''">
-            and time1 &gt;= #{stock.startTime}
+            and DATE_FORMAT(time1,'%Y-%m-%d') &gt;= #{stock.startTime}
         </if>
         <if test="stock.endTime!=null and stock.endTime!=''">
-            and time1 &lt;= #{stock.endTime}
+            and DATE_FORMAT(time1,'%Y-%m-%d') &lt;= #{stock.endTime}
+        </if>
+        <if test="stock.deptId!=null and stock.deptId!=''">
+            and dept_id = #{stock.deptId}
         </if>
         GROUP BY stock_id1) cg ON cg.stock_id1 = a.id
         LEFT JOIN (SELECT stock_id1, SUM(census) AS dbrknum
@@ -119,10 +177,13 @@
         WHERE stock_type1 = 1
         AND type1 = 1
         <if test="stock.startTime!=null and stock.startTime!=''">
-            and time1 &gt;= #{stock.startTime}
+            and DATE_FORMAT(time1,'%Y-%m-%d') &gt;= #{stock.startTime}
         </if>
         <if test="stock.endTime!=null and stock.endTime!=''">
-            and time1 &lt;= #{stock.endTime}
+            and DATE_FORMAT(time1,'%Y-%m-%d') &lt;= #{stock.endTime}
+        </if>
+        <if test="stock.deptId!=null and stock.deptId!=''">
+            and dept_id = #{stock.deptId}
         </if>
         GROUP BY stock_id1) dbr ON dbr.stock_id1 = a.id
         LEFT JOIN (SELECT stock_id1, SUM(census) AS lycknum
@@ -130,10 +191,13 @@
         WHERE stock_type1 = 0
         AND type1 = 0
         <if test="stock.startTime!=null and stock.startTime!=''">
-            and time1 &gt;= #{stock.startTime}
+            and DATE_FORMAT(time1,'%Y-%m-%d') &gt;= #{stock.startTime}
         </if>
         <if test="stock.endTime!=null and stock.endTime!=''">
-            and time1 &lt;= #{stock.endTime}
+            and DATE_FORMAT(time1,'%Y-%m-%d') &lt;= #{stock.endTime}
+        </if>
+        <if test="stock.deptId!=null and stock.deptId!=''">
+            and dept_id = #{stock.deptId}
         </if>
         GROUP BY stock_id1) lyc ON lyc.stock_id1 = a.id
         LEFT JOIN (SELECT stock_id1, SUM(census) AS dbcknum
@@ -141,10 +205,13 @@
         WHERE stock_type1 = 0
         AND type1 = 1
         <if test="stock.startTime!=null and stock.startTime!=''">
-            and time1 &gt;= #{stock.startTime}
+            and DATE_FORMAT(time1,'%Y-%m-%d') &gt;= #{stock.startTime}
         </if>
         <if test="stock.endTime!=null and stock.endTime!=''">
-            and time1 &lt;= #{stock.endTime}
+            and DATE_FORMAT(time1,'%Y-%m-%d') &lt;= #{stock.endTime}
+        </if>
+        <if test="stock.deptId!=null and stock.deptId!=''">
+            and dept_id = #{stock.deptId}
         </if>
         GROUP BY stock_id1) dbc ON dbc.stock_id1 = a.id
         LEFT JOIN (SELECT stock_id1, SUM(census) AS bfcknum
@@ -152,10 +219,13 @@
         WHERE stock_type1 = 0
         AND type1 = 2
         <if test="stock.startTime!=null and stock.startTime!=''">
-            and time1 &gt;= #{stock.startTime}
+            and DATE_FORMAT(time1,'%Y-%m-%d') &gt;= #{stock.startTime}
         </if>
         <if test="stock.endTime!=null and stock.endTime!=''">
-            and time1 &lt;= #{stock.endTime}
+            and DATE_FORMAT(time1,'%Y-%m-%d') &lt;= #{stock.endTime}
+        </if>
+        <if test="stock.deptId!=null and stock.deptId!=''">
+            and dept_id = #{stock.deptId}
         </if>
         GROUP BY stock_id1) bfc ON bfc.stock_id1 = a.id
     </select>
@@ -168,6 +238,7 @@
         FROM `sys_stock` st
                  LEFT JOIN (SELECT id, type FROM sys_stockfactory) sto ON st.stock_id = sto.id
         WHERE st.is_deleted = 0
+          and dept_id = #{deptId}
     </select>
 
     <!--小程序数据统计-->
@@ -196,10 +267,13 @@
         WHERE stock_type1 = 1
         AND type1 = 0
         <if test="startTime!=null and startTime!=''">
-            and time1 &gt;= #{stock.startTime}
+            and DATE_FORMAT(time1,'%Y-%m-%d') &gt;= #{startTime}
         </if>
         <if test="endTime!=null and endTime!=''">
-            and time1 &lt;= #{stock.endTime}
+            and DATE_FORMAT(time1,'%Y-%m-%d') &lt;= #{endTime}
+        </if>
+        <if test="deptId!=null and deptId!=''">
+            and dept_id = #{deptId}
         </if>
         GROUP BY stock_id1) cg ON cg.stock_id1 = a.id
         LEFT JOIN (SELECT stock_id1, SUM(census) AS dbrknum
@@ -207,10 +281,13 @@
         WHERE stock_type1 = 1
         AND type1 = 1
         <if test="startTime!=null and startTime!=''">
-            and time1 &gt;= #{stock.startTime}
+            and DATE_FORMAT(time1,'%Y-%m-%d') &gt;= #{startTime}
         </if>
         <if test="endTime!=null and endTime!=''">
-            and time1 &lt;= #{stock.endTime}
+            and DATE_FORMAT(time1,'%Y-%m-%d') &lt;= #{endTime}
+        </if>
+        <if test="deptId!=null and deptId!=''">
+            and dept_id = #{deptId}
         </if>
         GROUP BY stock_id1) dbr ON dbr.stock_id1 = a.id
         LEFT JOIN (SELECT stock_id1, SUM(census) AS lycknum
@@ -218,10 +295,13 @@
         WHERE stock_type1 = 0
         AND type1 = 0
         <if test="startTime!=null and startTime!=''">
-            and time1 &gt;= #{stock.startTime}
+            and DATE_FORMAT(time1,'%Y-%m-%d') &gt;= #{startTime}
         </if>
         <if test="endTime!=null and endTime!=''">
-            and time1 &lt;= #{stock.endTime}
+            and DATE_FORMAT(time1,'%Y-%m-%d') &lt;= #{endTime}
+        </if>
+        <if test="deptId!=null and deptId!=''">
+            and dept_id = #{deptId}
         </if>
         GROUP BY stock_id1) lyc ON lyc.stock_id1 = a.id
         LEFT JOIN (SELECT stock_id1, SUM(census) AS dbcknum
@@ -229,10 +309,13 @@
         WHERE stock_type1 = 0
         AND type1 = 1
         <if test="startTime!=null and startTime!=''">
-            and time1 &gt;= #{stock.startTime}
+            and DATE_FORMAT(time1,'%Y-%m-%d') &gt;= #{startTime}
         </if>
         <if test="endTime!=null and endTime!=''">
-            and time1 &lt;= #{stock.endTime}
+            and DATE_FORMAT(time1,'%Y-%m-%d') &lt;= #{endTime}
+        </if>
+        <if test="deptId!=null and deptId!=''">
+            and dept_id = #{deptId}
         </if>
         GROUP BY stock_id1) dbc ON dbc.stock_id1 = a.id
         LEFT JOIN (SELECT stock_id1, SUM(census) AS bfcknum
@@ -240,10 +323,13 @@
         WHERE stock_type1 = 0
         AND type1 = 2
         <if test="startTime!=null and startTime!=''">
-            and time1 &gt;= #{stock.startTime}
+            and DATE_FORMAT(time1,'%Y-%m-%d') &gt;= #{startTime}
         </if>
         <if test="endTime!=null and endTime!=''">
-            and time1 &lt;= #{stock.endTime}
+            and DATE_FORMAT(time1,'%Y-%m-%d') &lt;= #{endTime}
+        </if>
+        <if test="deptId!=null and deptId!=''">
+            and dept_id = #{deptId}
         </if>
         GROUP BY stock_id1) bfc ON bfc.stock_id1 = a.id
     </select>

--
Gitblit v1.9.3