| | |
| | | |
| | | <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 |
| | | v.farm_name as deptname, |
| | | l.farm_id as farmId, |
| | | l.land_type,l.type, |
| | | GROUP_CONCAT(a.url) AS strainUrl |
| | | 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> ) c ON c.dict_key = l.land_unit |
| | | LEFT JOIN ( SELECT id, farm_name FROM sys_farm ) v ON v.id = l.farm_id |
| | | LEFT JOIN |
| | | ( |
| | | SELECT sfp.strain_id,strain.url,sfp.land_id FROM sys_farm_plant sfp LEFT JOIN sys_strain strain ON strain.id = sfp.strain_id WHERE sfp.`status` = 1 |
| | | ) a ON l.id = a.land_id |
| | | where l.is_deleted = 0 |
| | | <if test="land.landType!=null and land.landType != ''"> |
| | | <if test="land.landType!=null and land.landType != '' or land.landType == 0 "> |
| | | and l.land_type = #{land.landType} |
| | | </if> |
| | | <if test="land.landName!=null and land.landName != ''"> |
| | |
| | | <if test="land.tenantId!=null and land.tenantId != ''"> |
| | | and l.tenant_id =#{land.tenantId} |
| | | </if> |
| | | <if test="land.farmId !=null and land.farmId !=''"> |
| | | AND l.farm_id = #{land.farmId} |
| | | </if> |
| | | GROUP BY l.id,d.dict_value,c.dict_value |
| | | </select> |
| | | |
| | | <!--查询地块列表(不分页)--> |
| | | <select id="getLandList" resultType="org.springblade.modules.lang.vo.LandVO"> |
| | | <select id="getLandList" resultMap="landResultMap"> |
| | | 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 |
| | | l.id, |
| | | l.land_name, |
| | | l.land_area, |
| | | ST_ASTEXT(l.land_range) as land_range, |
| | | l.url, |
| | | l.type, |
| | | l.land_type, |
| | | l.land_unit, |
| | | l.dept_id, |
| | | l.farm_id, |
| | | GROUP_CONCAT(a.url) AS strainUrl |
| | | FROM sys_land l |
| | | LEFT JOIN |
| | | ( |
| | | SELECT sfp.strain_id,strain.url,sfp.land_id FROM sys_farm_plant sfp LEFT JOIN sys_strain strain ON strain.id = sfp.strain_id WHERE sfp.`status` = 1 |
| | | ) a ON l.id = a.land_id |
| | | where is_deleted = 0 |
| | | <if test="land.landType!=null and land.landType != ''"> |
| | | and land_type = #{land.landType} |
| | |
| | | <if test="land.farmId!=null and land.farmId != ''"> |
| | | and farm_id =#{land.farmId} |
| | | </if> |
| | | GROUP BY l.id |
| | | </select> |
| | | |
| | | <insert id="saveLandInfo"> |
| | |
| | | |
| | | <!--详情信息(自定义查询)--> |
| | | <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 |
| | | select DISTINCT |
| | | l.user_id, |
| | | l.land_name, |
| | | l.land_type, |
| | | l.land_area, |
| | | ST_ASTEXT(l.land_range) as landRange, |
| | | l.type, |
| | | l.land_unit, |
| | | l.url, |
| | | bdb.dict_value dica |
| | | from sys_land l |
| | | LEFT JOIN blade_dict_biz bdb ON bdb.dict_key =l.land_unit |
| | | where 1 = 1 |
| | | and is_deleted = 0 |
| | | and id = #{land.id} |
| | | and l.is_deleted = 0 |
| | | AND bdb.code = 'landunit' |
| | | and l.id = #{land.id} |
| | | GROUP BY l.user_id,l.land_name,l.land_type,l.land_area,landRange,l.type,l.land_unit,l.url,dica |
| | | </select> |
| | | |
| | | <!--自定义地块数据--> |
| | |
| | | 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} |
| | | where farm_id = #{userid} |
| | | and is_deleted = 0 |
| | | </select> |
| | | <!--土地总面积--> |
| | |
| | | WHERE is_deleted = 0 |
| | | <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> |
| | | <!--土地使用面积--> |
| | |
| | | <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> |
| | | <!--土地未使用面积--> |
| | | <select id="selectWAre" resultType="java.util.HashMap"> |
| | |
| | | and type = 1 |
| | | <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> |
| | | |
| | |
| | | GROUP BY sfp.strain_id |
| | | </select> |
| | | |
| | | <!--查询统计地块是否有轮廓--> |
| | | <select id="getLandIsAreaStatistic" resultType="java.lang.Integer"> |
| | | SELECT count(*) FROM sys_land where land_range is not null AND sys_land.is_deleted = 0 |
| | | <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 AND sys_land.is_deleted = 0 |
| | | <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> |
| | | |
| | | <select id="selectByStrainId" resultType="org.springblade.modules.lang.vo.LandVO"> |
| | | SELECT DISTINCT land.id,land.land_name,land.url,land.farm_id,fps.weight, |
| | | ( CASE WHEN land_unit = 2 THEN FORMAT(land.land_area * 0.0015,3) WHEN land_unit = 1 THEN land.land_area * 0.1 ELSE land.land_area END ) land_area |
| | | FROM sys_land land |
| | | LEFT JOIN sys_farm_product_stock fps ON fps.land_id = land.id |
| | | LEFT JOIN sys_farm_plant sfp ON sfp.land_id = land.id |
| | | WHERE 1=1 |
| | | <if test="strainId !=null and strainId != ''"> |
| | | AND fps.strain_id = #{strainId} |
| | | </if> |
| | | <if test="farmId !=null and farmId != '' "> |
| | | AND land.farm_id = #{farmId} |
| | | </if> |
| | | </select> |
| | | <select id="getByStrainIdFarmId" resultType="org.springblade.modules.lang.entity.Land"> |
| | | SELECT DISTINCT land.id,land.land_name,land.url,land.farm_id |
| | | FROM sys_land land |
| | | LEFT JOIN sys_farm_plant sfp ON sfp.land_id = land.id |
| | | WHERE land.is_deleted = 0 AND sfp.planting_way !=2 |
| | | <if test="land.strainId !=null and land.strainId !=''"> |
| | | AND sfp.strain_id = #{land.strainId} |
| | | </if> |
| | | <if test="land.farmId !=null and land.farmId != '' "> |
| | | AND land.farm_id = #{land.farmId} |
| | | </if> |
| | | <if test="land.sfpStatus !=null and land.sfpStatus !=''"> |
| | | AND sfp.status = #{land.sfpStatus} |
| | | </if> |
| | | </select> |
| | | <select id="findPlantInLand" resultType="org.springblade.modules.lang.vo.LandVO"> |
| | | SELECT land.*,sfp.id AS sfpId,sfp.strain_id |
| | | FROM sys_land land |
| | | LEFT JOIN sys_farm_plant sfp ON land.id = sfp.land_id |
| | | WHERE land.is_deleted = 0 AND sfp.status = 1 |
| | | AND land.id = #{ids} |
| | | </select> |
| | | <select id="selectRecoveryLandList" resultType="org.springblade.modules.lang.vo.LandVO"> |
| | | SELECT |
| | | DISTINCT l.id,l.land_name AS landName |
| | | FROM |
| | | sys_recovery r |
| | | LEFT JOIN sys_land l ON r.land_id = l.id |
| | | WHERE l.is_deleted = 0 |
| | | <if test="farmId !=null and farmId !=''"> |
| | | AND r.dept_id = #{farmId} |
| | | </if> |
| | | </select> |
| | | |
| | | </mapper> |