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
78
79
80
<?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="com.ruoyi.stock.mapper.ProductBorrowReturnMapper">
 
    <resultMap id="ProductBorrowReturnDtoMap" type="com.ruoyi.stock.dto.ProductBorrowReturnDto">
        <id column="id" property="id"/>
        <result column="borrow_id" property="borrowId"/>
        <result column="product_model_id" property="productModelId"/>
        <result column="batch_no" property="batchNo"/>
        <result column="return_quantity" property="returnQuantity"/>
        <result column="returner_id" property="returnerId"/>
        <result column="returner_name" property="returnerName"/>
        <result column="return_time" property="returnTime"/>
        <result column="remark" property="remark"/>
        <result column="tenant_id" property="tenantId"/>
        <result column="dept_id" property="deptId"/>
        <result column="create_user" property="createUser"/>
        <result column="create_time" property="createTime"/>
        <result column="borrow_no" property="borrowNo"/>
        <result column="product_name" property="productName"/>
        <result column="model" property="model"/>
        <result column="product_code" property="productCode"/>
        <result column="unit" property="unit"/>
        <result column="borrow_quantity" property="borrowQuantity"/>
        <result column="borrower_name" property="borrowerName"/>
    </resultMap>
 
    <select id="listPage" resultMap="ProductBorrowReturnDtoMap">
        SELECT
            pbr.*,
            pb.borrow_no,
            pb.borrow_quantity,
            pb.borrower_name,
            p.product_name,
            pm.model,
            pm.product_code,
            pm.unit
        FROM product_borrow_return pbr
        LEFT JOIN product_borrow pb ON pbr.borrow_id = pb.id
        LEFT JOIN product_model pm ON pbr.product_model_id = pm.id
        LEFT JOIN product p ON pm.product_id = p.id
        <where>
            <if test="ew.borrowId != null">
                AND pbr.borrow_id = #{ew.borrowId}
            </if>
            <if test="ew.productModelId != null">
                AND pbr.product_model_id = #{ew.productModelId}
            </if>
            <if test="ew.returnerId != null">
                AND pbr.returner_id = #{ew.returnerId}
            </if>
            <if test="ew.returnerName != null and ew.returnerName != ''">
                AND pbr.returner_name LIKE CONCAT('%', #{ew.returnerName}, '%')
            </if>
            <if test="ew.deptId != null">
                AND pbr.dept_id = #{ew.deptId}
            </if>
        </where>
        ORDER BY pbr.create_time DESC
    </select>
 
    <select id="listByBorrowId" resultMap="ProductBorrowReturnDtoMap">
        SELECT
            pbr.*,
            pb.borrow_no,
            pb.borrow_quantity,
            pb.borrower_name,
            p.product_name,
            pm.model,
            pm.product_code,
            pm.unit
        FROM product_borrow_return pbr
        LEFT JOIN product_borrow pb ON pbr.borrow_id = pb.id
        LEFT JOIN product_model pm ON pbr.product_model_id = pm.id
        LEFT JOIN product p ON pm.product_id = p.id
        WHERE pbr.borrow_id = #{borrowId}
        ORDER BY pbr.create_time DESC
    </select>
 
</mapper>