智慧农业后台管理
tangzy
2022-06-15 bb844f41d295106fba26e54c248be9cc61389d77
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
130
131
132
133
134
135
136
137
<?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.lang.mapper.LandMapper">
 
    <!-- 通用查询映射结果 -->
    <resultMap id="landResultMap" type="org.springblade.modules.lang.vo.LandVO">
        <result column="id" property="id"/>
        <result column="user_id" property="userId"/>
        <result column="land_name" property="landName"/>
        <result column="land_type" property="landType"/>
        <result column="land_area" property="landArea"/>
        <result column="land_range" property="landRange"/>
        <result column="type" property="type"/>
        <result column="land_unit" property="landUnit"/>
    </resultMap>
 
 
    <select id="selectLandPage" resultMap="landResultMap">
        SELECT l.land_name,
        l.land_area ,
        ST_ASTEXT(land_range) as land_range,
        l.url,
        d.dict_value as dic,
        c.dict_value as dica,
        v.dept_name as deptname
        FROM `sys_land` l
        LEFT JOIN (SELECT dict_key, dict_value FROM blade_dict_biz WHERE CODE = 'land' AND is_deleted = 0) d
        ON d.dict_key = l.land_type
        LEFT JOIN (SELECT dict_key, dict_value
        FROM blade_dict_biz
        WHERE CODE = 'landunit'
        AND is_deleted = 0) c ON c.dict_key = l.land_unit
        LEFT JOIN ( SELECT id, dept_name FROM blade_dept WHERE is_deleted = 0 ) v ON v.id = l.dept_id
        where l.is_deleted = 0
        <if test="land.landType!=null and land.landType != ''">
            and l.land_type = #{land.landType}
        </if>
        <if test="land.landName!=null and land.landName != ''">
            and l.land_name like concat('%', #{land.landName},'%')
        </if>
        <if test="land.deptId!=null and land.deptId != ''">
            and l.dept_id like concat('%', #{land.deptId},'%')
        </if>
        <if test="land.type!=null and land.type != ''">
            and l.type like concat('%', #{land.type},'%')
        </if>
        <if test="land.tenantId!=null and land.tenantId != ''">
            and l.tenant_id like concat('%', #{land.tenantId},'%')
        </if>
    </select>
 
    <insert id="saveLandInfo">
        insert into sys_land
        (user_id,land_name,land_type,land_area,land_range,type,land_unit,dept_id)
        values
        (#{land.userId},#{land.landName},#{land.landType},#{land.landArea},
        <if test="land.landRange!=null and land.landRange!=''">
            ST_GeomFromText(${land.landRange}),
        </if>
        #{land.type},#{land.landUnit},#{land.deptId})
    </insert>
 
    <!--详情信息(自定义查询)-->
    <select id="getLandInfo" resultType="org.springblade.modules.lang.vo.LandVO">
        select user_id,
               land_name,
               land_type,
               land_area,
               ST_ASTEXT(land_range) as landRange,
               type,
               land_unit
        from sys_land
        where 1 = 1
          and is_deleted = 0
          and id = #{land.id}
    </select>
 
    <!--自定义修改电子围栏数据-->
    <update id="updateLandById">
        update sys_land set user_id = #{land.userId},
        land_name = #{land.landName},
        land_type = #{land.landType},
        land_area = #{land.landArea},
        <if test="land.landRange!=null and land.landRange!=''">
            land_range = ST_GeomFromText(${land.landRange}),
        </if>
        type = #{land.type},
        land_unit = #{land.landUnit},
        where id = #{land.id}
    </update>
 
    <select id="selectLandList" resultType="java.util.HashMap">
        select id, land_name as landName
        from sys_land
        where dept_id = #{userid}
          and is_deleted = 0
    </select>
    <!--土地总面积-->
    <select id="selectZAre" resultType="java.util.HashMap">
        SELECT IFNULL(land_area, 0) as area, IFNULL(land_unit, 0) as unit
        FROM sys_land
        WHERE is_deleted = 0
        <if test="deptId!= null and deptId!=''">
            and dept_id=#{deptId}
        </if>
    </select>
    <!--土地使用面积-->
    <select id="selectSAre" resultType="java.util.HashMap">
        SELECT IFNULL(land_area, 0) as area, IFNULL(land_unit, 0) as unit
        FROM sys_land
        WHERE is_deleted = 0
        and type = 0
        <if test="deptId!= null and deptId!=''">
            and dept_id=#{deptId}
        </if>
    </select>
    <!--土地未使用面积-->
    <select id="selectWAre" resultType="java.util.HashMap">
        SELECT IFNULL(land_area, 0) as area, IFNULL(land_unit, 0) as unit
        FROM sys_land
        WHERE is_deleted = 0
        and type = 1
        <if test="deptId!= null and deptId!=''">
            and dept_id=#{deptId}
        </if>
    </select>
    <select id="selectNum" resultType="java.util.HashMap">
        SELECT strain_id
        FROM `sys_farm_plant`
        WHERE status = 1
        <if test="deptId!= null and deptId!=''">
            and dept_id=#{deptId}
        </if>
        GROUP BY strain_id
    </select>
 
</mapper>