| | |
| | | |
| | | <!--自定义查询农场养殖记录分页数据--> |
| | | <select id="selectFarmPlantPage" resultType="org.springblade.modules.farmplant.vo.FarmPlantVO"> |
| | | select sfp.*,ss.strain_name strainName,ss.url,sl.land_name landName,sl.land_area area,land_unit landUnit from sys_farm_plant sfp |
| | | select sfp.*,ss.strain_name strainName,ss.url,sl.land_name landName,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.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 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 >= #{farmPlant.startTime} |
| | | </if> |
| | | <if test="farmPlant.endTime!=null and farmPlant.endTime!=''"> |
| | | and sfp.transplan_time <= #{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 |
| | | </select> |
| | | |
| | | <!--自定义查询农场养殖记录分页数据--> |
| | | <select id="getFarmPlantStatistics" resultType="org.springblade.modules.farmplant.vo.FarmPlantVO"> |
| | | select sfp.strain_id,ss.strain_name strainName,sum(sl.land_area) areas,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 >= #{farmPlant.startTime} |
| | | </if> |
| | | <if test="farmPlant.endTime!=null and farmPlant.endTime!=''"> |
| | | and sfp.transplan_time <= #{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.status !=null and farmPlant.status!=''"> |
| | | and sfp.status = #{farmPlant.status} |
| | | </if> |
| | | group by sfp.strain_id,strain_name,land_unit |
| | | </select> |
| | | |
| | | <!--查询农场养殖记录数据--> |
| | | <select id="getFarmPlantStatisticsCount" resultType="org.springblade.modules.farmplant.vo.FarmPlantVO"> |
| | | select sfp.strain_id,ss.strain_name strainName,sum(sl.land_area) areas,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 >= #{farmPlant.startTime} |
| | | </if> |
| | | <if test="farmPlant.endTime!=null and farmPlant.endTime!=''"> |
| | | and sfp.transplan_time <= #{farmPlant.endTime} |
| | | </if> |
| | | <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> |
| | | |
| | | <!--已种植农产品列表--> |
| | | <select id="strainTree" resultType="org.springblade.modules.farmplant.entity.Strain"> |
| | | select ss.id, ss.strain_name strainName |
| | | from sys_farm_plant sfp |
| | | left join sys_strain ss on ss.id = sfp.strain_id |
| | | where sfp.status = "1" |
| | | and sfp.land_id = #{farm.landId} |
| | | </select> |
| | | |
| | | <select id="selectCount" resultType="java.lang.Integer"> |
| | | SELECT IFNULL(COUNT(*), 0) as num |
| | | 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(年)--> |
| | | <select id="selectPlant" resultType="java.util.HashMap"> |
| | | SELECT |
| | | IFNULL( COUNT( * ), 0 ) AS num |
| | | FROM |
| | | `sys_farm_plant` |
| | | WHERE |
| | | plant = 0 |
| | | AND STATUS = 1 |
| | | <if test="1 == code"> |
| | | and to_days(create_time) = to_days(#{time}); |
| | | </if> |
| | | <if test="2 == code"> |
| | | and DATE_FORMAT( create_time, '%Y%m' ) = DATE_FORMAT(#{time} ,'%Y%m' ) |
| | | </if> |
| | | <if test="3 == code"> |
| | | and YEAR(create_time)=YEAR(#{time}); |
| | | </if> |
| | | </select> |
| | | <!--种植品种监管 1:绿色 --> |
| | | <select id="selectPlantl" resultType="java.util.HashMap"> |
| | | SELECT |
| | | IFNULL( COUNT( * ), 0 ) AS num |
| | | FROM |
| | | `sys_farm_plant` |
| | | WHERE |
| | | plant = 1 |
| | | AND STATUS = 1 |
| | | <if test="1 == code"> |
| | | and to_days(create_time) = to_days(#{time}); |
| | | </if> |
| | | <if test="2 == code"> |
| | | and DATE_FORMAT( create_time, '%Y%m' ) = DATE_FORMAT(#{time} ,'%Y%m' ) |
| | | </if> |
| | | <if test="3 == code"> |
| | | and YEAR(create_time)=YEAR(#{time}); |
| | | </if> |
| | | </select> |
| | | <!--种植品种监管 2:无公害 --> |
| | | <select id="selectPlantw" resultType="java.util.HashMap"> |
| | | SELECT |
| | | IFNULL( COUNT( * ), 0 ) AS num |
| | | FROM |
| | | `sys_farm_plant` |
| | | WHERE |
| | | plant = 2 |
| | | AND STATUS = 1 |
| | | <if test="1 == code"> |
| | | and to_days(create_time) = to_days(#{time}); |
| | | </if> |
| | | <if test="2 == code"> |
| | | and DATE_FORMAT( create_time, '%Y%m' ) = DATE_FORMAT(#{time} ,'%Y%m' ) |
| | | </if> |
| | | <if test="3 == code"> |
| | | and YEAR(create_time)=YEAR(#{time}); |
| | | </if> |
| | | </select> |
| | | <!--种植品种监管 3:普通 --> |
| | | <select id="selectPlantp" resultType="java.util.HashMap"> |
| | | SELECT |
| | | IFNULL( COUNT( * ), 0 ) AS num |
| | | FROM |
| | | `sys_farm_plant` |
| | | WHERE |
| | | plant = 3 |
| | | AND STATUS = 1 |
| | | <if test="1 == code"> |
| | | and to_days(create_time) = to_days(#{time}); |
| | | </if> |
| | | <if test="2 == code"> |
| | | and DATE_FORMAT( create_time, '%Y%m' ) = DATE_FORMAT(#{time} ,'%Y%m' ) |
| | | </if> |
| | | <if test="3 == code"> |
| | | and YEAR(create_time)=YEAR(#{time}); |
| | | </if> |
| | | </select> |
| | | |
| | | |
| | | <!--种植采收监管 产品等级(0:一等品)--> |
| | | <select id="selectProduct" resultType="java.util.HashMap"> |
| | | SELECT |
| | | IFNULL( COUNT( * ), 0 ) AS num |
| | | FROM |
| | | `sys_farm_product_stock` |
| | | WHERE |
| | | leaves = 0 |
| | | <if test="1 == code"> |
| | | and to_days(create_time) = to_days(#{time}); |
| | | </if> |
| | | <if test="2 == code"> |
| | | and DATE_FORMAT( create_time, '%Y%m' ) = DATE_FORMAT(#{time} ,'%Y%m' ) |
| | | </if> |
| | | <if test="3 == code"> |
| | | and YEAR(create_time)=YEAR(#{time}); |
| | | </if> |
| | | </select> |
| | | <!--种植采收监管 产品等级 1:二等品 --> |
| | | <select id="selectProducty" resultType="java.util.HashMap"> |
| | | SELECT |
| | | IFNULL( COUNT( * ), 0 ) AS num |
| | | FROM |
| | | `sys_farm_product_stock` |
| | | WHERE |
| | | leaves = 1 |
| | | <if test="1 == code"> |
| | | and to_days(create_time) = to_days(#{time}); |
| | | </if> |
| | | <if test="2 == code"> |
| | | and DATE_FORMAT( create_time, '%Y%m' ) = DATE_FORMAT(#{time} ,'%Y%m' ) |
| | | </if> |
| | | <if test="3 == code"> |
| | | and YEAR(create_time)=YEAR(#{time}); |
| | | </if> |
| | | </select> |
| | | <!--种植采收监管 产品等级 2:三等品 --> |
| | | <select id="selectProductr" resultType="java.util.HashMap"> |
| | | SELECT |
| | | IFNULL( COUNT( * ), 0 ) AS num |
| | | FROM |
| | | `sys_farm_product_stock` |
| | | WHERE |
| | | leaves = 2 |
| | | <if test="1 == code"> |
| | | and to_days(create_time) = to_days(#{time}); |
| | | </if> |
| | | <if test="2 == code"> |
| | | and DATE_FORMAT( create_time, '%Y%m' ) = DATE_FORMAT(#{time} ,'%Y%m' ) |
| | | </if> |
| | | <if test="3 == code"> |
| | | and YEAR(create_time)=YEAR(#{time}); |
| | | </if> |
| | | </select> |
| | | <!--种植采收监管 产品等级3:四等品--> |
| | | <select id="selectProducts" resultType="java.util.HashMap"> |
| | | SELECT |
| | | IFNULL( COUNT( * ), 0 ) AS num |
| | | FROM |
| | | `sys_farm_product_stock` |
| | | WHERE |
| | | leaves = 3 |
| | | <if test="1 == code"> |
| | | and to_days(create_time) = to_days(#{time}); |
| | | </if> |
| | | <if test="2 == code"> |
| | | and DATE_FORMAT( create_time, '%Y%m' ) = DATE_FORMAT(#{time} ,'%Y%m' ) |
| | | </if> |
| | | <if test="3 == code"> |
| | | and YEAR(create_time)=YEAR(#{time}); |
| | | </if> |
| | | </select> |
| | | <!--种植采收监管 产品等级 4:五等品 --> |
| | | <select id="selectProductf" resultType="java.util.HashMap"> |
| | | SELECT |
| | | IFNULL( COUNT( * ), 0 ) AS num |
| | | FROM |
| | | `sys_farm_product_stock` |
| | | WHERE |
| | | leaves = 4 |
| | | <if test="1 == code"> |
| | | and to_days(create_time) = to_days(#{time}); |
| | | </if> |
| | | <if test="2 == code"> |
| | | and DATE_FORMAT( create_time, '%Y%m' ) = DATE_FORMAT(#{time} ,'%Y%m' ) |
| | | </if> |
| | | <if test="3 == code"> |
| | | and YEAR(create_time)=YEAR(#{time}); |
| | | </if> |
| | | </select> |
| | | |
| | | <!--小程序查询农场养殖记录数据--> |
| | | <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 >= #{farmPlant.startTime}--> |
| | | <!-- </if>--> |
| | | <!-- <if test="farmPlant.endTime!=null and farmPlant.endTime!=''">--> |
| | | <!-- and sfp.transplan_time <= #{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 |
| | | 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 >= #{farmPlant.startTime} |
| | | </if> |
| | | <if test="farmPlant.endTime!=null and farmPlant.endTime!=''"> |
| | | and sfp.transplan_time <= #{farmPlant.endTime} |
| | | </if> |
| | | <!-- 小程序端会传farmId和status的值过来,但是为了和web端统一所以不加入查询条件 --> |
| | | <!-- <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> |
| | | <if test=" farmPlant.deptId !=null and farmPlant.deptId != ''"> |
| | | and sfp.dept_id = #{farmPlant.deptId} |
| | | </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> |