From d95f6551e8214d69cd0fd511ec693641eb61ba16 Mon Sep 17 00:00:00 2001
From: zengh <123456>
Date: Mon, 01 Aug 2022 10:36:26 +0800
Subject: [PATCH] 1、大屏首页接口修复,解决double类型相加精度问题

---
 src/main/java/org/springblade/modules/farm/mapper/FarmMapper.xml |   98 +++++++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 90 insertions(+), 8 deletions(-)

diff --git a/src/main/java/org/springblade/modules/farm/mapper/FarmMapper.xml b/src/main/java/org/springblade/modules/farm/mapper/FarmMapper.xml
index 65dee27..3eb5c87 100644
--- a/src/main/java/org/springblade/modules/farm/mapper/FarmMapper.xml
+++ b/src/main/java/org/springblade/modules/farm/mapper/FarmMapper.xml
@@ -4,13 +4,48 @@
 
     <!--自定义查询农场分页数据-->
     <select id="selectFarmPage" resultType="org.springblade.modules.farm.vo.FarmVO">
-        select
-        id,farm_name,farm_address,farm_area,slogan,introduce,picture,ST_ASTEXT(position) as position,user_id
+        select id,
+               farm_name,
+               farm_address,
+               farm_area,
+               slogan,
+               introduce,
+               picture,
+               panoramic,
+               ST_ASTEXT(position) as position
         from
-        sys_farm where 1=1
+            sys_farm
+        where 1=1
+        <if test="farm.farmName!=null and farm.farmName!=''">
+            and farm_name like concat('%',#{farm.farmName},'%')
+        </if>
+        <if test="farm.deptId!=null and farm.deptId!=''">
+            and dept_id = #{farm.deptId}
+        </if>
     </select>
 
-    <!--自定义修改电子围栏数据-->
+    <!--自定义查询农场列表数据(不分页)-->
+    <select id="getFarmList" resultType="org.springblade.modules.farm.vo.FarmVO">
+        select id,
+               farm_name,
+               farm_address,
+               farm_area,
+               slogan,
+               introduce,
+               picture,
+               ST_ASTEXT(position) as position
+        from
+            sys_farm
+        where 1=1
+        <if test="farm.farmName!=null and farm.farmName!=''">
+            and farm_name like concat('%',#{farm.farmName},'%')
+        </if>
+        <if test="farm.deptId!=null and farm.deptId!=''">
+            and dept_id = #{farm.deptId}
+        </if>
+    </select>
+
+    <!--自定义修改农场围栏数据-->
     <update id="updateFarmById">
         update sys_farm set farm_name = #{farm.farmName},
         farm_address = #{farm.farmAddress},
@@ -18,6 +53,10 @@
         slogan = #{farm.slogan},
         introduce = #{farm.introduce},
         picture = #{farm.picture},
+        province = #{farm.province},
+        city = #{farm.city},
+        district = #{farm.district},
+        panoramic = #{farm.panoramic},
         <if test="farm.position!=null and farm.position!=''">
             position = ST_GeomFromText(${farm.position}),
         </if>
@@ -25,13 +64,56 @@
         where id = #{farm.id}
     </update>
 
+    <!--自定义新增农场围栏数据-->
+    <insert id="saveFarmInfo">
+        insert into  sys_farm (farm_name,farm_address,farm_area,slogan,introduce,picture,position,create_time,update_time,dept_id,province,city,district,panoramic)
+        values
+        (#{farm.farmName},#{farm.farmAddress},#{farm.farmArea},#{farm.slogan},#{farm.introduce},#{farm.picture},
+        <choose>
+            <when test="farm.position!=null and farm.position!=''">
+                ST_GeomFromText(${farm.position}),
+            </when>
+            <otherwise>
+                null,
+            </otherwise>
+        </choose>
+        #{farm.createTime},#{farm.updateTime},#{farm.deptId},#{farm.province},#{farm.city},#{farm.district},#{farm.panoramic})
+    </insert>
+
     <!--详情信息(自定义查询)-->
     <select id="getFarmInfo" resultType="org.springblade.modules.farm.vo.FarmVO">
-        select
-        id,farm_name,farm_address,farm_area,slogan,introduce,picture,ST_ASTEXT(position) as position,user_id
+        select id,
+               farm_name,
+               farm_address,
+               farm_area,
+               slogan,
+               introduce,
+               picture,
+               province,
+               city,
+               district,
+               panoramic,
+               ST_ASTEXT(position) as position,dept_id
         from
-        sys_farm
+            sys_farm
         where 1=1
-        and user_id = #{farm.userId}
+          and id = #{farm.id}
     </select>
+
+    <!--农场数量-->
+    <select id="selectCountFarm" resultType="java.lang.Integer">
+        SELECT
+            COUNT( * ) AS count
+        FROM
+            sys_farm
+    </select>
+
+    <!--人员数量-->
+    <select id="selectCountUser" resultType="java.lang.Integer">
+        SELECT COUNT(*) as countuser
+        FROM `blade_user`
+        WHERE tenant_id = '000000'
+          AND is_deleted = 0
+    </select>
+
 </mapper>

--
Gitblit v1.9.3