<?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.casic.missiles.mapper.customer.CustomerSampleMapper"> <select id="selectMaxSampleNo" resultType="Long"> SELECT IFNULL(MAX(RIGHT(sample_no, 12)), 0) FROM customer_sample_info </select> <select id="measureRecordsById" resultType="com.casic.missiles.dto.customer.MeasureRecordsResponse"> SELECT order_id AS orderId,order_code AS orderCode,order_time AS orderTime, customer_no AS customerCode,customer_name AS customerName,deliverer,real_deliver_time AS deliverTime FROM ( SELECT id FROM customer_sample_info csi WHERE csi.is_del =0 <if test="request.sampleId != null and request.sampleId !=''"> AND csi.id=#{request.sampleId} </if> <if test="request.customerId != null and request.customerId !=''"> AND csi.customer_id=#{request.customerId } </if> )csi JOIN ( SELECT sample_id,order_id,real_deliver_time FROM business_order_sample_relation WHERE 1=1 <if test="request.sampleId != null and request.sampleId !=''"> AND sample_id=#{request.sampleId} </if> )bosr ON bosr.sample_id=csi.id JOIN ( SELECT * FROM business_order WHERE is_del =0 <if test="request.customerId != null and request.customerId !=''"> AND customer_id=#{request.customerId} </if> )bo ON bo.id=bosr.order_id ORDER BY bosr.real_deliver_time DESC </select> <select id="samplesByOderId" resultType="com.casic.missiles.model.customer.CustomerSampleInfo"> SELECT csi.* FROM customer_sample_info csi LEFT JOIN business_order_sample_relation sr ON sr.sample_id = csi.id WHERE csi.is_del =0 <if test="sampleNo != null and sampleNo !=''"> and csi.sample_no like concat('%', #{sampleNo}, '%') </if> <if test="sampleName != null and sampleName !=''"> and csi.sample_name like concat('%', #{sampleName}, '%') </if> <if test="orderId != null and orderId !=''"> and sr.order_id = #{orderId} </if> ORDER BY csi.create_time DESC </select> </mapper>