智慧农业后台管理
guoshilong
2022-10-15 97da879dc16dffb2fbcc7447dee7db819049fa02
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.springblade.modules.farm.mapper.FarmMapper">
 
    <!--自定义查询农场分页数据-->
    <select id="selectFarmPage" resultType="org.springblade.modules.farm.vo.FarmVO">
        select id,
               farm_name,
               farm_address,
               farm_area,
               slogan,
               introduce,
               picture,
               panoramic,longitude,latitude,
               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>
 
    <!--自定义查询农场列表数据(不分页)-->
    <select id="getFarmList" resultType="org.springblade.modules.farm.vo.FarmVO">
        select id,
               farm_name,
               farm_address,
               farm_area,
               slogan,
               introduce,
               picture,
               panoramic,longitude,latitude,
               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>
        <if test="farm.ids!=null and farm.ids!=''">
            and id in
            <foreach item="id" collection="farm.ids.split(',')" open="(" separator=" , " close=")">
                #{id}
            </foreach>
        </if>
    </select>
 
    <!--自定义修改农场围栏数据-->
    <update id="updateFarmById">
        update sys_farm set farm_name = #{farm.farmName},
        farm_address = #{farm.farmAddress},
        farm_area = #{farm.farmArea},
        slogan = #{farm.slogan},
        introduce = #{farm.introduce},
        picture = #{farm.picture},
        province = #{farm.province},
        city = #{farm.city},
        district = #{farm.district},
        panoramic = #{farm.panoramic},
        longitude = #{farm.longitude},
        latitude = #{farm.latitude},
<!--        <if test="farm.position!=null and farm.position!=''">-->
<!--            position = ST_GeomFromText(${farm.position}),-->
<!--        </if>-->
        update_time = #{farm.updateTime}
        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,longitude,latitude)
        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},#{farm.longitude},#{farm.latitude})
    </insert>
 
    <!--详情信息(自定义查询)-->
    <select id="getFarmInfo" resultType="org.springblade.modules.farm.vo.FarmVO">
        select id,
               farm_name,
               farm_address,
               farm_area,
               slogan,
               introduce,
               picture,
               province,
               city,
               district,
               panoramic,longitude,latitude,
               ST_ASTEXT(position) as position,dept_id
        from
            sys_farm
        where 1=1
          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>