From 64ce8e808e8b7dc95c79eecd9201d302d4335dfa Mon Sep 17 00:00:00 2001
From: zengh <123456>
Date: Tue, 19 Jul 2022 17:45:16 +0800
Subject: [PATCH] 1、首页农场条件追加

---
 src/main/java/org/springblade/modules/farm/mapper/FarmingRecordMapper.xml |   42 ++++++++++++++++++++++++------------------
 1 files changed, 24 insertions(+), 18 deletions(-)

diff --git a/src/main/java/org/springblade/modules/farm/mapper/FarmingRecordMapper.xml b/src/main/java/org/springblade/modules/farm/mapper/FarmingRecordMapper.xml
index af9e106..0b75f30 100644
--- a/src/main/java/org/springblade/modules/farm/mapper/FarmingRecordMapper.xml
+++ b/src/main/java/org/springblade/modules/farm/mapper/FarmingRecordMapper.xml
@@ -78,34 +78,40 @@
     <!--查询统计本年农事记录操作总数-->
     <select id="getFarmingCount" resultType="java.lang.Integer">
         select ifnull(count(*), 0) count
-        from sys_farming_record
+        from sys_farming_record ss
+        LEFT JOIN sys_land sl ON sl.id = ss.land_id
         where 1=1
           and YEAR (time)= YEAR (NOW())
-          and dept_id=#{deptId}
+        <if test="farmId != null and farmId != ''">
+            and sl.farm_id = #{sale.farmId}
+        </if>
     </select>
 
     <!--查询统计本年农事记录操作总数-->
     <select id="getFarmingStatis" resultType="org.springblade.modules.farm.vo.FarmingStatisVO">
-        select type,case when type = 0 then '施肥'
-                   when type = 1 then '翻耕'
-                   when type = 2 then '灌溉'
-                   when type = 3 then '起垄'
-                   when type = 4 then '用药'
-                   when type = 5 then '追肥'
-                   when type = 6 then '除草'
-                   when type = 7 then '修剪'
-                   when type = 8 then '浸种'
-                   when type = 9 then '拌种'
-                   when type = 10 then '移栽'
-                   when type = 11 then '直播'
-                   when type = 12 then '采收'
+        select ss.type,case when ss.type = 0 then '施肥'
+                   when ss.type = 1 then '翻耕'
+                   when ss.type = 2 then '灌溉'
+                   when ss.type = 3 then '起垄'
+                   when ss.type = 4 then '用药'
+                   when ss.type = 5 then '追肥'
+                   when ss.type = 6 then '除草'
+                   when ss.type = 7 then '修剪'
+                   when ss.type = 8 then '浸种'
+                   when ss.type = 9 then '拌种'
+                   when ss.type = 10 then '移栽'
+                   when ss.type = 11 then '直播'
+                   when ss.type = 12 then '采收'
                    else '其他' end as name,
                ifnull(count(*), 0) value
-        from sys_farming_record
+        from sys_farming_record ss
+	    LEFT JOIN sys_land sl ON sl.id = ss.land_id
         where 1=1
           and YEAR (time)= YEAR (NOW())
-          and dept_id=#{deptId}
-        group by type
+        <if test="farmId != null and farmId != ''">
+            and sl.farm_id = #{sale.farmId}
+        </if>
+        group by ss.type
     </select>
 
     <!--今年农资使用量-->

--
Gitblit v1.9.3