智慧农业后台管理
guoshilong
2022-07-22 fdff4ca4813fc77a9006309ed4e5c232b4f3c85e
src/main/java/org/springblade/modules/farmplant/mapper/FarmPlantMapper.xml
@@ -12,8 +12,14 @@
        <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}
@@ -41,6 +47,9 @@
        </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
    </select>
@@ -80,11 +89,14 @@
        <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 test="farmPlant.farmId!=null and farmPlant.farmId!=''">
            and sl.farm_id = #{farmPlant.farmId}
        </if>
        <if test="farmPlant.tenantId!=null and farmPlant.tenantId!=''">
            and sfp.tenant_id = #{farmPlant.tenantId}
        </if>
        <if test="farmPlant.status!=null and farmPlant.status!=''">
            and sfp.status = #{farmPlant.status}
        </if>
        group by sfp.strain_id,strain_name,land_unit
    </select>
@@ -100,7 +112,14 @@
    <select id="selectCount" resultType="java.lang.Integer">
        SELECT IFNULL(COUNT(*), 0) as num
        FROM (SELECT strain_id FROM `sys_farm_plant` WHERE STATUS = 1 GROUP BY strain_id) a
        FROM (SELECT strain_id
        FROM `sys_farm_plant` ss
        LEFT JOIN sys_land sl ON sl.id = ss.land_id
        WHERE  ss.STATUS = 1
        <if test="farmPlant.farmId != null and farmPlant.farmId != ''">
            and sl.farm_id = #{farmPlant.farmId}
        </if>
        GROUP BY strain_id) a
    </select>
    <!--种植品种监管 0:有机 code=1(当天) =2(月) =3(年)-->
@@ -179,9 +198,6 @@
            and YEAR(create_time)=YEAR(#{time});
        </if>
    </select>
    <!--种植采收监管 产品等级(0:一等品)-->
@@ -292,12 +308,40 @@
        <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 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>
    <!--查询种养记录列表(不分页)-->
    <select id="getFarmPlantList" resultType="org.springblade.modules.farmplant.vo.FarmPlantVO">
        SELECT
        sfp.*,
        ss.strain_name strainName,
        ss.url,
        sl.land_area area,
        sl.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.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>
    </select>
</mapper>