liding
2026-06-09 c9675b38b799d8b1a479928bcee73e53067788f9
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
<?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.report.mapper.SampleRecordMapper">
 
    <!-- 分页查询领样记录 -->
    <select id="pageSampleRecord" resultType="com.ruoyi.report.vo.SampleRecordVo">
        SELECT
            h.id AS id,
            s.id AS sampleId,
            s.sample_code AS sampleCode,
            s.sample_name AS sampleName,
            o.custom AS custom,
            h.operate_type AS operateType,
            u.name AS operateUser,
            h.operate_time AS operateTime,
            h.from_cell AS fromCell,
            h.to_cell AS toCell,
            h.remark AS remark
        FROM warehouse_history h
        LEFT JOIN ins_sample s ON h.sample_id = s.id
        LEFT JOIN ins_order o ON s.ins_order_id = o.id
        LEFT JOIN user u ON h.operate_user_id = u.id
        WHERE 1=1
        <if test="dto.sampleCode != null and dto.sampleCode != ''">
            AND s.sample_code LIKE CONCAT('%', #{dto.sampleCode}, '%')
        </if>
        <if test="dto.sampleName != null and dto.sampleName != ''">
            AND s.sample_name LIKE CONCAT('%', #{dto.sampleName}, '%')
        </if>
        <if test="dto.custom != null and dto.custom != ''">
            AND o.custom LIKE CONCAT('%', #{dto.custom}, '%')
        </if>
        <if test="dto.receiveUser != null and dto.receiveUser != ''">
            AND u.name LIKE CONCAT('%', #{dto.receiveUser}, '%')
        </if>
        <if test="dto.startTime != null and dto.startTime != ''">
            AND h.operate_time >= #{dto.startTime}
        </if>
        <if test="dto.endTime != null and dto.endTime != ''">
            AND h.operate_time &lt;= #{dto.endTime}
        </if>
        ORDER BY h.operate_time DESC
    </select>
 
    <!-- 查询样品流转记录 -->
    <select id="getFlowRecord" resultType="com.ruoyi.report.vo.SampleRecordVo">
        SELECT
            h.id AS id,
            s.id AS sampleId,
            s.sample_code AS sampleCode,
            s.sample_name AS sampleName,
            o.custom AS custom,
            h.operate_type AS operateType,
            u.name AS operateUser,
            h.operate_time AS operateTime,
            h.from_cell AS fromCell,
            h.to_cell AS toCell,
            h.remark AS remark
        FROM warehouse_history h
        LEFT JOIN ins_sample s ON h.sample_id = s.id
        LEFT JOIN ins_order o ON s.ins_order_id = o.id
        LEFT JOIN user u ON h.operate_user_id = u.id
        WHERE s.id = #{sampleId}
        ORDER BY h.operate_time ASC
    </select>
 
</mapper>