<?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="cn.shlanbao.qms.mapper.LbTestResultMapper">
|
<!-- 根据产品型号、批次号、检测项目和 createTime 时间段查询测试结果 -->
|
<select id="selectByProdModelAndConditions" resultType="cn.shlanbao.qms.domain.vo.LbTestResultVo">
|
SELECT tr.*
|
FROM lb_test_result tr
|
JOIN lb_batch b ON tr.batch_code = b.batch_code
|
<where>
|
<if test="ew.prodModel != null and ew.prodModel != ''">
|
AND b.prod_model = #{ew.prodModel}
|
</if>
|
<if test="ew.batchCode != null and ew.batchCode != ''">
|
AND tr.batch_code LIKE CONCAT('%', #{ew.batchCode}, '%')
|
</if>
|
<if test="ew.testItem != null and ew.testItem != ''">
|
<choose>
|
<when test="ew.testItem.contains(','.toString())">
|
AND tr.test_item IN
|
<foreach collection="ew.testItem.split(',')" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</when>
|
<otherwise>
|
AND tr.test_item = #{ew.testItem}
|
</otherwise>
|
</choose>
|
</if>
|
<if test="ew.params.beginCreateTime != null and ew.params.endCreateTime != null">
|
AND tr.create_time BETWEEN
|
DATE_FORMAT(#{ew.params.beginCreateTime}, '%Y-%m-%d 00:00:00') AND
|
DATE_FORMAT(#{ew.params.endCreateTime}, '%Y-%m-%d 23:59:59')
|
</if>
|
|
</where>
|
ORDER BY tr.create_time ASC
|
</select>
|
</mapper>
|