<?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>
|