“zhuo”
2023-08-09 80b2025993331ac057b9a63210be2cb6ba124806
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
<?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.yuanchu.limslaboratory.mapper.PlanMapper">
 
    <!--查询检验计划-->
    <select id="selectAllPlan" resultType="com.yuanchu.limslaboratory.pojo.vo.PlanVo">
        select i.equipment_name device,
        im.name samplename,
        im.code sampleid,
        im.specifications modelandspecification,
        im.unit unit,
        im.num amount,
        ip.name checkproject,
        u.name checker,
        ip.start_time starttime,
        ip.end_time finishtime,
        i.id deviceId,
        u.id userId,
        ip.test_state state
        from instrument i
        left join (select ip.*
        from inspection_product ip
        right join (select instrument_id, max(ip.end_time) t
        from inspection_product ip
        group by instrument_id) it
        on ip.instrument_id = it.instrument_id and ip.end_time = it.t) ip
        on i.id = ip.instrument_id
        left join inspection_material im on im.id = ip.inspection_material_id
        left join user u on u.id = ip.user_id
        <where>
            <if test="deviceId != null">
                and i.id = #{deviceId}
            </if>
            <if test="userId != null">
                and u.id = #{userId}
            </if>
            <if test="beginTime != null and endTime != null">
                and ip.start_time between #{beginTime} and #{endTime}
            </if>
        </where>
    </select>
</mapper>