| | |
| | | </resultMap> |
| | | |
| | | <select id="findInsSampleAndOrder" resultType="com.yuanchu.mom.vo.InsOrderPlanVO"> |
| | | <!--select * from(select * from( |
| | | SELECT |
| | | a.*,ios.ins_state,ios.verify_tell,isu2.order_user_id,verify_user |
| | | FROM |
| | | ( |
| | | <!--SELECT * |
| | | FROM ( |
| | | SELECT * |
| | | FROM ( |
| | | SELECT |
| | | io.id, |
| | | io.entrust_code, |
| | | io.type, |
| | | io.appointed, |
| | | io.send_time, |
| | | group_concat(distinct isa.sample,' ') sample, |
| | | isu.user_id, |
| | | user.name userName, |
| | | GROUP_CONCAT(DISTINCT isa.sample SEPARATOR ' ') AS sample, |
| | | isu.userName, |
| | | isu2.checkName, |
| | | ip.son_laboratory, |
| | | io.ins_time, |
| | | io.laboratory |
| | | io.laboratory, |
| | | ios.ins_state, |
| | | ios.verify_tell, |
| | | ios.verify_user |
| | | FROM |
| | | ins_order io |
| | | LEFT JOIN ins_sample isa ON isa.ins_order_id = io.id |
| | | LEFT JOIN ( |
| | | SELECT * |
| | | FROM ins_sample_user u |
| | | WHERE son_laboratory=#{sonLaboratory} and (ins_sample_id, id) IN ( |
| | | SELECT ins_sample_id, MAX(id) |
| | | FROM ins_sample_user |
| | | WHERE son_laboratory=#{sonLaboratory} |
| | | GROUP BY ins_sample_id |
| | | ) |
| | | ORDER BY ins_sample_id, id |
| | | SELECT |
| | | ins_sample_id, |
| | | GROUP_CONCAT(DISTINCT uu.name SEPARATOR ',') AS userName |
| | | FROM |
| | | ins_sample_user u |
| | | LEFT JOIN user uu ON u.user_id = uu.id |
| | | WHERE |
| | | son_laboratory = #{sonLaboratory} AND u.state = 0 |
| | | GROUP BY |
| | | ins_sample_id |
| | | ) isu ON isu.ins_sample_id = io.id |
| | | LEFT JOIN ( |
| | | SELECT |
| | | ins_sample_id, |
| | | uu.name AS checkName |
| | | FROM |
| | | ins_sample_user u |
| | | LEFT JOIN user uu ON u.user_id = uu.id |
| | | WHERE |
| | | son_laboratory = #{sonLaboratory} AND u.state = 1 |
| | | GROUP BY |
| | | ins_sample_id |
| | | ) isu2 ON isu2.ins_sample_id = io.id |
| | | LEFT JOIN ins_product ip ON ip.ins_sample_id = isa.id |
| | | LEFT JOIN user ON isu.user_id = user.id |
| | | LEFT JOIN ins_order_state ios ON ios.ins_order_id = io.id AND ios.laboratory = ip.son_laboratory |
| | | WHERE |
| | | io.state = 1 |
| | | and send_time is not null |
| | | <if test="userId !=null and userId!=''"> |
| | | and (isu.user_id = #{userId} OR isu.user_id is NULL ) |
| | | AND io.send_time IS NOT NULL |
| | | AND (ip.son_laboratory = #{sonLaboratory} OR isu.userName IS NULL OR isu2.checkName IS NULL) |
| | | <if test="userName != null and userName != ''"> |
| | | AND (isu.userName LIKE CONCAT('%', #{userName}, '%') OR isu2.checkName LIKE CONCAT('%', #{userName}, '%')) |
| | | </if> |
| | | OR isu.user_id is NULL |
| | | |
| | | GROUP BY |
| | | ip.son_laboratory, |
| | | io.id |
| | | ) a |
| | | LEFT JOIN ins_order_state ios ON ios.ins_order_id = a.id AND ios.laboratory = a.son_laboratory |
| | | left join (SELECT td.user_id order_user_id, td.ins_sample_id FROM ins_sample_user td,(SELECT max(id) id FROM |
| | | ins_sample_user where son_laboratory=#{sonLaboratory} GROUP BY ins_sample_id) md where td.id = md.id |
| | | <if test="userId !=null and userId!=''"> |
| | | and user_id = #{userId} OR user_id is NULL |
| | | </if> |
| | | OR user_id is NULL |
| | | ) isu2 on |
| | | isu2.ins_sample_id = a.id |
| | | io.id, ip.son_laboratory |
| | | ORDER BY |
| | | a.type DESC, |
| | | a.id |
| | | ) b |
| | | where ins_state is not null--> |
| | | |
| | | io.type DESC, io.id |
| | | ) a |
| | | WHERE |
| | | a.ins_state IS NOT NULL |
| | | <if test="laboratory != null and laboratory != ''"> |
| | | AND a.laboratory = #{laboratory} |
| | | </if> |
| | | ) b--> |
| | | select * from(select * from( |
| | | SELECT |
| | | a.*,ios.ins_state,ios.verify_tell,verify_user |
| | |
| | | FROM |
| | | ins_order io |
| | | LEFT JOIN ins_sample isa ON isa.ins_order_id = io.id |
| | | |
| | | LEFT JOIN ( |
| | | SELECT ins_sample_id,GROUP_CONCAT( DISTINCT uu.name SEPARATOR ',') AS userName |
| | | FROM ins_sample_user u LEFT JOIN user uu ON u.user_id = uu.id |
| | |
| | | GROUP BY ins_sample_id |
| | | ORDER BY ins_sample_id |
| | | ) isu ON isu.ins_sample_id = io.id |
| | | |
| | | LEFT JOIN ( |
| | | SELECT ins_sample_id,uu.name checkName |
| | | FROM ins_sample_user u LEFT JOIN user uu ON u.user_id = uu.id |
| | |
| | | GROUP BY ins_sample_id |
| | | ORDER BY ins_sample_id |
| | | )isu2 ON isu2.ins_sample_id = io.id |
| | | |
| | | LEFT JOIN ins_product ip ON ip.ins_sample_id = isa.id |
| | | WHERE io.state = 1 and send_time is not null |
| | | <if test="userName !=null and userName!=''"> |
| | |
| | | ip.son_laboratory, |
| | | io.id |
| | | ) a |
| | | |
| | | |
| | | LEFT JOIN ins_order_state ios ON ios.ins_order_id = a.id AND ios.laboratory = a.son_laboratory |
| | | |
| | | ORDER BY |
| | | a.type DESC, |
| | | a.id |
| | | ) b |
| | | where ins_state is not null |
| | | and son_laboratory=#{sonLaboratory} |
| | | <if test="laboratory!=null and laboratory!=''"> |
| | | and laboratory=#{laboratory} |
| | | </if> |
| | |
| | | where ins_order_id = #{id} |
| | | and state = 1 |
| | | and ip.son_laboratory = #{laboratory} |
| | | and ins_fiber_id is null |
| | | and ins_fibers_id is null |
| | | </select> |
| | | <select id="getSampleEn" resultType="java.lang.String"> |
| | | select name_en |