智慧农业后台管理
zhongrj
2022-07-18 981a3d85848753a799da2d909089c2fe4fcd3ccf
src/main/java/org/springblade/modules/lang/mapper/LandMapper.xml
@@ -30,13 +30,15 @@
        AND blade_dict_biz.tenant_id = #{land.tenantId}
    </if> ) d
        ON d.dict_key = l.land_type
        LEFT JOIN (SELECT dict_key, dict_value
        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
        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, 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 != ''">
@@ -47,6 +49,9 @@
        </if>
        <if test="land.deptId!=null and land.deptId != ''">
            and l.dept_id=#{land.deptId}
        </if>
        <if test="land.farmId!=null and land.farmId != ''">
            and l.farm_id=#{land.farmId}
        </if>
        <if test="land.type!=null and land.type != ''">
            and l.type=#{land.type}
@@ -63,7 +68,12 @@
        land_name,
        land_area,
        ST_ASTEXT(land_range) as land_range,
        url
        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 != ''">
@@ -142,11 +152,13 @@
    </select>
    <!--土地总面积-->
    <select id="selectZAre" resultType="java.util.HashMap">
        SELECT IFNULL(land_area, 0) as area, IFNULL(land_unit, 0) as unit
        FROM sys_land
        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 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>
    <!--土地使用面积-->
@@ -155,8 +167,11 @@
        FROM sys_land
        WHERE is_deleted = 0
        and type = 0
        <if test="deptId!= null and deptId!=''">
            and dept_id=#{deptId}
        <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>
    <!--土地未使用面积-->
@@ -165,18 +180,25 @@
        FROM sys_land
        WHERE is_deleted = 0
        and type = 1
        <if test="deptId!= null and deptId!=''">
            and dept_id=#{deptId}
        <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="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}
        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>
        GROUP BY strain_id
        <if test="land.deptId!= null and land.deptId!=''">
            and sfp.dept_id=#{land.deptId}
        </if>
        GROUP BY sfp.strain_id
    </select>
</mapper>