智慧农业后台管理
guoshilong
2022-08-31 a50990dee016e9dcb2f591ec66f32becb8808d36
src/main/java/org/springblade/modules/farmplant/mapper/FarmPlantMapper.xml
@@ -463,31 +463,6 @@
    <!--小程序查询农场养殖记录数据-->
    <select id="getFarmPlantStatisticsCountz" resultType="org.springblade.modules.farmplant.vo.FarmPlantVO">
<!--        SELECT-->
<!--        sfp.strain_id,-->
<!--        ss.strain_name strainName,-->
<!--        sum( sl.land_area ) area,-->
<!--        land_unit landUnit-->
<!--        FROM-->
<!--        sys_farm_plant sfp-->
<!--        LEFT JOIN sys_strain ss ON ss.id = sfp.strain_id-->
<!--        LEFT JOIN sys_land sl ON sl.id = sfp.land_id where 1=1-->
<!--        <if test="farmPlant.startTime!=null and farmPlant.startTime!=''">-->
<!--            and sfp.transplan_time &gt;= #{farmPlant.startTime}-->
<!--        </if>-->
<!--        <if test="farmPlant.endTime!=null and farmPlant.endTime!=''">-->
<!--            and sfp.transplan_time &lt;= #{farmPlant.endTime}-->
<!--        </if>-->
<!--        <if test="farmPlant.farmId!=null and farmPlant.farmId!=''">-->
<!--            and sl.farm_id = #{farmPlant.farmId}-->
<!--        </if>-->
<!--        <if test="farmPlant.status!=null and farmPlant.status!=''">-->
<!--            and sfp.status = #{farmPlant.status}-->
<!--        </if>-->
<!--        <if test="farmPlant.tenantId!=null and farmPlant.tenantId!=''">-->
<!--            and sfp.tenant_id = #{farmPlant.tenantId}-->
<!--        </if>-->
<!--        group by sfp.strain_id,strain_name,land_unit-->
        SELECT a.strain_id,a.strainName,SUM(TRUNCATE(a.land_area,3)) areas,a.url FROM
        (
        select sfp.strain_id,ss.url,
@@ -521,16 +496,55 @@
    <!--查询种养记录列表(不分页)-->
    <select id="getFarmPlantList" resultType="org.springblade.modules.farmplant.vo.FarmPlantVO">
<!--        SELECT-->
<!--        a.strain_id,a.strainName,SUM(TRUNCATE(a.land_area,3)) area,a.url-->
<!--        FROM-->
<!--        (-->
<!--        SELECT-->
<!--        sfp.*,-->
<!--        ss.strain_name strainName,-->
<!--        ss.strain_name AS strainName,-->
<!--        ss.url,-->
<!--        sl.land_area area,-->
<!--        sl.land_unit landUnit-->
<!--        sl.land_name AS landName,-->
<!--        land_unit AS landUnit,-->
<!--        ( CASE WHEN land_unit = 2 THEN FORMAT(sl.land_area * 0.0015,3) WHEN land_unit = 1 THEN sl.land_area * 0.1 ELSE sl.land_area END ) land_area-->
<!--        FROM-->
<!--        sys_farm_plant sfp-->
<!--        LEFT JOIN sys_strain ss ON ss.id = sfp.strain_id-->
<!--        LEFT JOIN sys_land sl ON sl.id = sfp.land_id-->
<!--        where 1=1-->
<!--        WHERE-->
<!--        1 = 1-->
<!--        <if test="farmPlant.plant!=null and farmPlant.plant!=''">-->
<!--            and sfp.plant = #{farmPlant.plant}-->
<!--        </if>-->
<!--        <if test="farmPlant.year!=null and farmPlant.year!=''">-->
<!--            and sfp.create_time like concat('%',#{farmPlant.year},'%')-->
<!--        </if>-->
<!--        <if test="farmPlant.landId!=null and farmPlant.landId!=''">-->
<!--            and sfp.land_id = #{farmPlant.landId}-->
<!--        </if>-->
<!--        <if test="farmPlant.strainId!=null and farmPlant.strainId!=''">-->
<!--            and sfp.strain_id = #{farmPlant.strainId}-->
<!--        </if>-->
<!--        <if test="farmPlant.plantingWay!=null and farmPlant.plantingWay!=''">-->
<!--            and sfp.planting_way = #{farmPlant.plantingWay}-->
<!--        </if>-->
<!--        <if test="farmPlant.jobWay!=null and farmPlant.jobWay!=''">-->
<!--            and sfp.job_way = #{farmPlant.jobWay}-->
<!--        </if>-->
<!--        <if test="farmPlant.status!=null and farmPlant.status!=''">-->
<!--            and sfp.status = #{farmPlant.status}-->
<!--        </if>-->
<!--        <if test="farmPlant.strainName!=null and farmPlant.strainName!=''">-->
<!--            and ss.strain_name like concat('%',#{farmPlant.strainName},'%')-->
<!--        </if>-->
<!--        <if test="farmPlant.varieties!=null and farmPlant.varieties!=''">-->
<!--            and sfp.varieties like concat('%',#{farmPlant.varieties},'%')-->
<!--        </if>-->
<!--        <if test="farmPlant.startTime!=null and farmPlant.startTime!=''">-->
<!--            and sfp.transplan_time &gt;= #{farmPlant.startTime}-->
<!--        </if>-->
<!--        <if test="farmPlant.endTime!=null and farmPlant.endTime!=''">-->
<!--            and sfp.transplan_time &lt;= #{farmPlant.endTime}-->
<!--        </if>-->
<!--        <if test="farmPlant.deptId!=null and farmPlant.deptId!=''">-->
<!--            and sfp.dept_id = #{farmPlant.deptId}-->
<!--        </if>-->
@@ -540,12 +554,91 @@
<!--        <if test="farmPlant.farmId!=null and farmPlant.farmId!=''">-->
<!--            and sl.farm_id = #{farmPlant.farmId}-->
<!--        </if>-->
<!--        <if test="farmPlant.status!=null and farmPlant.status!=''">-->
<!--            and sfp.status = #{farmPlant.status}-->
<!--        </if>-->
<!--        ORDER BY-->
<!--        sfp.id DESC-->
<!--        ) a-->
<!--        GROUP BY-->
<!--        a.strain_id,a.dept_id-->
        SELECT b.strain_id,b.strainName,SUM(b.area) AS area,b.url,b.tenant_id,b.dept_id FROM
        (
        SELECT
        a.strain_id,a.strainName,SUM(TRUNCATE(a.land_area,3)) area,a.url
        a.strain_id,a.strainName,SUM(TRUNCATE(a.land_area,3)) area,a.url,a.tenant_id,a.dept_id,a.planting_way
        FROM
        (
        SELECT
        sfp.*,
        ss.strain_name AS strainName,
        ss.url,
        sl.land_name AS landName,
        land_unit AS landUnit,
        ( CASE WHEN land_unit = 2 THEN FORMAT(sl.land_area * 0.0015,3) WHEN land_unit = 1 THEN sl.land_area * 0.1 ELSE
        sl.land_area END ) land_area
        FROM
        sys_farm_plant sfp
        LEFT JOIN sys_strain ss ON ss.id = sfp.strain_id
        LEFT JOIN sys_land sl ON sl.id = sfp.land_id
        WHERE
        1 = 1
        <if test="farmPlant.plant!=null and farmPlant.plant!=''">
            and sfp.plant = #{farmPlant.plant}
        </if>
        <if test="farmPlant.year!=null and farmPlant.year!=''">
            and sfp.create_time like concat('%',#{farmPlant.year},'%')
        </if>
        <if test="farmPlant.landId!=null and farmPlant.landId!=''">
            and sfp.land_id = #{farmPlant.landId}
        </if>
        <if test="farmPlant.strainId!=null and farmPlant.strainId!=''">
            and sfp.strain_id = #{farmPlant.strainId}
        </if>
        <if test="farmPlant.plantingWay!=null and farmPlant.plantingWay!=''">
            and sfp.planting_way = #{farmPlant.plantingWay}
        </if>
        <if test="farmPlant.jobWay!=null and farmPlant.jobWay!=''">
            and sfp.job_way = #{farmPlant.jobWay}
        </if>
        <if test="farmPlant.status!=null and farmPlant.status!=''">
            and sfp.status = #{farmPlant.status}
        </if>
        <if test="farmPlant.strainName!=null and farmPlant.strainName!=''">
            and ss.strain_name like concat('%',#{farmPlant.strainName},'%')
        </if>
        <if test="farmPlant.varieties!=null and farmPlant.varieties!=''">
            and sfp.varieties like concat('%',#{farmPlant.varieties},'%')
        </if>
        <if test="farmPlant.startTime!=null and farmPlant.startTime!=''">
            and sfp.transplan_time &gt;= #{farmPlant.startTime}
        </if>
        <if test="farmPlant.endTime!=null and farmPlant.endTime!=''">
            and sfp.transplan_time &lt;= #{farmPlant.endTime}
        </if>
        <if test="farmPlant.deptId!=null and farmPlant.deptId!=''">
            and sfp.dept_id = #{farmPlant.deptId}
        </if>
        <if test="farmPlant.tenantId!=null and farmPlant.tenantId!=''">
            and sfp.tenant_id = #{farmPlant.tenantId}
        </if>
        <if test="farmPlant.farmId!=null and farmPlant.farmId!=''">
            and sl.farm_id = #{farmPlant.farmId}
        </if>ORDER BY
        sfp.id
        DESC
        ) a
        GROUP BY
        a.strain_id,
        a.dept_id,
        a.tenant_id,
        a.planting_way HAVING planting_way !=2
        ) b
        GROUP BY
        b.strain_id,
        b.dept_id,
        b.tenant_id
    </select>
    <select id="getFarmPlantYMList" resultType="org.springblade.modules.farmplant.vo.FarmPlantVO">
        SELECT
        a.strain_id,a.strainName,SUM(TRUNCATE(a.land_area,3)) area,a.url,a.tenant_id,a.dept_id,a.planting_way
        FROM
        (
        SELECT
@@ -607,7 +700,7 @@
        sfp.id DESC
        ) a
        GROUP BY
        a.strain_id,a.dept_id
        a.strain_id,a.dept_id,a.tenant_id,a.planting_way HAVING planting_way !=0 AND planting_way !=1
    </select>
</mapper>