<?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_unit,
|
l.id,
|
l.land_area ,
|
ST_ASTEXT(land_range) as land_range,
|
l.url,
|
d.dict_value as dic,
|
c.dict_value as dica,
|
v.farm_name as deptname,
|
l.farm_id as farmId,
|
l.land_type
|
FROM `sys_land` l
|
LEFT JOIN (SELECT dict_key, dict_value FROM blade_dict_biz WHERE CODE = 'land' AND is_deleted = 0 <if
|
test="land.tenantId!=null and land.tenantId != ''">
|
AND blade_dict_biz.tenant_id = #{land.tenantId}
|
</if> ) 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 <if
|
test="land.tenantId!=null and land.tenantId != ''">
|
AND blade_dict_biz.tenant_id = #{land.tenantId}
|
</if> ) c ON c.dict_key = l.land_unit
|
LEFT JOIN ( SELECT id, farm_name FROM sys_farm ) v ON v.id = l.farm_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=#{land.deptId}
|
</if>
|
<if test="land.type!=null and land.type != ''">
|
and l.type=#{land.type}
|
</if>
|
<if test="land.tenantId!=null and land.tenantId != ''">
|
and l.tenant_id =#{land.tenantId}
|
</if>
|
</select>
|
|
<!--查询地块列表(不分页)-->
|
<select id="getLandList" resultType="org.springblade.modules.lang.vo.LandVO">
|
SELECT
|
id,
|
land_name,
|
land_area,
|
ST_ASTEXT(land_range) as land_range,
|
url,
|
type,
|
land_type,
|
land_unit,
|
dept_id,
|
farm_id
|
FROM sys_land
|
where is_deleted = 0
|
<if test="land.landType!=null and land.landType != ''">
|
and land_type = #{land.landType}
|
</if>
|
<if test="land.landName!=null and land.landName != ''">
|
and land_name like concat('%', #{land.landName},'%')
|
</if>
|
<if test="land.deptId!=null and land.deptId != ''">
|
and dept_id=#{land.deptId}
|
</if>
|
<if test="land.type!=null and land.type != ''">
|
and type=#{land.type}
|
</if>
|
<if test="land.tenantId!=null and land.tenantId != ''">
|
and tenant_id =#{land.tenantId}
|
</if>
|
<if test="land.farmId!=null and land.farmId != ''">
|
and farm_id =#{land.farmId}
|
</if>
|
</select>
|
|
<insert id="saveLandInfo">
|
insert into sys_land
|
(user_id,land_name,land_type,land_area,land_range,type,land_unit,dept_id,url,farm_id)
|
values
|
(#{land.userId},#{land.landName},#{land.landType},#{land.landArea},
|
<choose>
|
<when test="land.landRange!=null and land.landRange!=''">
|
ST_GeomFromText(${land.landRange}),
|
</when>
|
<otherwise>
|
null,
|
</otherwise>
|
</choose>
|
#{land.type},#{land.landUnit},#{land.deptId},#{land.url},#{land.farmId})
|
</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,
|
url
|
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},
|
farm_id = #{land.farmId},
|
url = #{land.url}
|
where id = #{land.id}
|
</update>
|
|
<update id="updateLandAr">
|
update sys_land set user_id = #{land.userId},
|
land_area = #{land.landArea},
|
<if test="land.landRange!=null and land.landRange!=''">
|
land_range = ST_GeomFromText(${land.landRange}),
|
</if>
|
url = #{land.url},
|
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="land.farmId!= null and land.farmId!=''">
|
and farm_id=#{land.farmId}
|
</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="land.farmId!= null and land.farmId!=''">
|
and farm_id=#{land.farmId}
|
</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="land.farmId!= null and land.farmId!=''">
|
and farm_id=#{land.farmId}
|
</if>
|
</select>
|
|
<select id="selectNum" resultType="java.util.HashMap">
|
SELECT strain_id FROM sys_farm_plant sfp
|
left join sys_land sl on sl.id = sfp.land_id
|
WHERE sfp.status = 1
|
<if test="land.farmId!= null and land.farmId!=''">
|
and sl.farm_id=#{land.farmId}
|
</if>
|
<if test="land.deptId!= null and land.deptId!=''">
|
and sfp.dept_id=#{land.deptId}
|
</if>
|
GROUP BY sfp.strain_id
|
</select>
|
|
<!--查询统计地块是否有轮廓-->
|
<select id="getLandIsAreaStatistic" resultType="java.lang.Integer">
|
SELECT count(*) FROM sys_land where land_range is not null
|
<if test="land.farmId!= null and land.farmId!=''">
|
and farm_id=#{land.farmId}
|
</if>
|
<if test="land.deptId!= null and land.deptId!=''">
|
and dept_id=#{land.deptId}
|
</if>
|
union all
|
SELECT count(*) FROM sys_land where land_range is null
|
<if test="land.farmId!= null and land.farmId!=''">
|
and farm_id=#{land.farmId}
|
</if>
|
<if test="land.deptId!= null and land.deptId!=''">
|
and dept_id=#{land.deptId}
|
</if>
|
</select>
|
|
</mapper>
|