智慧农业后台管理
guoshilong
2022-08-12 be9da335cb28e12e1439c24e4596f069e342d83f
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<?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.traceability.mapper.TraceabilityMapper">
 
    <!--自定义查询溯源码分页数据-->
    <select id="selectTraceabilityPage" resultType="org.springblade.modules.traceability.vo.TraceabilityVO">
        select st.*,sr.land_id landId from sys_traceability st
        left join sys_recovery sr on st.recovery_id = sr.id
        LEFT JOIN sys_land sl ON sl.id = sr.land_id
        where 1=1
        <if test="traceability.code!=null and traceability.code!=''">
            and st.code like concat('%',#{traceability.code},'%')
        </if>
        <if test="traceability.farmId!=null and traceability.farmId!=''">
            and sl.farm_id = #{traceability.farmId}
        </if>
        <if test="traceability.tenantId!=null and traceability.tenantId!=''">
            and st.tenant_id = #{traceability.tenantId}
        </if>
    </select>
 
    <!--自定义查询溯源码分页数据-->
    <select id="selectTraceabilityXcxPage" resultType="org.springblade.modules.traceability.vo.TraceabilityVO">
        select a.id,a.code,c.land_name as landName,c.id as landId,a.product_name productName,
               a.create_time createTime,d.url,d.strain_name AS strainName,b.create_time AS recoveryTime from sys_traceability a
        LEFT JOIN sys_recovery b ON a.recovery_id = b.id
        LEFT JOIN sys_land c ON b.land_id = c.id
        LEFT JOIN sys_strain d ON b.strain_id = d.id
        where 1=1
        <if test="traceability.code!=null and traceability.code!=''">
            and a.code like concat('%',#{traceability.code},'%')
        </if>
        <if test="traceability.farmId!=null and traceability.farmId!=''">
            and c.farm_id = #{traceability.farmId}
        </if>
        <if test="traceability.tenantId!=null and traceability.tenantId!=''">
            and a.tenant_id = #{traceability.tenantId}
        </if>
    </select>
 
    <!--自定义查询溯源码数据,不分页-->
    <select id="getTraceabilityList" resultType="org.springblade.modules.traceability.vo.TraceabilityVO">
        select st.* from sys_traceability st
        left join sys_recovery sr on st.recovery_id = sr.id
        left join sys_land sl on sr.land_id = sl.id
        where 1=1
        <if test="traceability.code!=null and traceability.code!=''">
            and st.code like concat('%',#{traceability.code},'%')
        </if>
        <if test="traceability.deptId!=null and traceability.deptId!=''">
            and st.dept_id = #{traceability.deptId}
        </if>
        <if test="traceability.tenantId!=null and traceability.tenantId!=''">
            and st.tenant_id = #{traceability.tenantId}
        </if>
        <if test="traceability.farmId!=null and traceability.farmId!=''">
            and sl.farm_id = #{traceability.farmId}
        </if>
    </select>
 
    <select id="selectRevorid" resultType="java.lang.String">
        select recovery_id
        from sys_traceability
        where code = #{code}
    </select>
 
    <!--获取溯源简介信息-->
    <select id="getSimpleInfo" resultType="org.springblade.modules.traceability.dto.TraceabilityDTO">
        SELECT concat(sf.farm_name, '-', ifnull(sl.land_name, '-'), '-', ss.strain_name, '-', sr.time, ' 采收') remark
        FROM `sys_traceability` st
                 left join sys_recovery sr on sr.id = st.recovery_id
                 left join sys_land sl on sl.id = sr.land_id
                 left join sys_strain ss on ss.id = sr.strain_id
                 left join sys_farm sf on sf.id = sl.farm_id
        where st.code = #{traceability.code}
    </select>
</mapper>