智慧农业后台管理
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.springblade.modules.recovery.mapper.RecoveryMapper">
 
    <!--自定义查询采收记录分页数据-->
    <select id="selectRecoveryPage" resultType="org.springblade.modules.recovery.vo.RecoveryVO">
        select sr.*,sl.land_name landName,ss.strain_name strainName from sys_recovery sr
        left join sys_land sl on sl.id = sr.land_id
        left join sys_strain ss on ss.id = sr.strain_id
        where 1=1
        <if test="recovery.strainId!=null and recovery.strainId!=''">
            and sr.strain_id = #{recovery.strainId}
        </if>
        <if test="recovery.leaves!=null and recovery.leaves!=''">
            and sr.leaves = #{recovery.leaves}
        </if>
        <if test="recovery.landId!=null and recovery.landId!=''">
            and sr.land_id = #{recovery.landId}
        </if>
        <if test="recovery.jobWay!=null and recovery.jobWay!=''">
            and sr.job_way = #{recovery.jobWay}
        </if>
        <if test="recovery.operator!=null and recovery.operator!=''">
            and sr.operator = #{recovery.operator}
        </if>
        <if test="recovery.deptId!=null and recovery.deptId!=''">
            and sr.dept_id = #{recovery.deptId}
        </if>
        <if test="recovery.tenantId!=null and recovery.tenantId!=''">
            and sr.tenant_id = #{recovery.tenantId}
        </if>
    </select>
 
    <!--查询当前前缀已有的溯源码编号,取倒数7位的最大值-->
    <select id="getCodePreCount" resultType="java.lang.Integer">
        select ifnull(max(0+RIGHT(code,7)),0) from sys_traceability
        where code like concat('%', #{pre},'%')
    </select>
</mapper>