<?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="org.jeecg.modules.itdmGongDan.mapper.ItdmTestPlanMapper">

    <select id="geChuanganqitByShiyanid" resultType="java.lang.String">

        select c.chuanganqi
        from itdm_gongdan_master as b

                 inner join itdm_gongdan_detail c on b.id = c.wo_id


        where b.test_items_id in


        <foreach item="item" collection="list" separator="," open="(" close=")" index="">
                   #{item}
        </foreach>

        and  c.chuanganqi is not null

    </select>
    <select id="geSBByShiyanid" resultType="java.lang.String">


        select c.shiji_shebei_id
        from itdm_gongdan_master as b

        inner join itdm_gongdan_detail c on b.id = c.wo_id


        where b.test_items_id in


        <foreach item="item" collection="list" separator="," open="(" close=")" index="">
            #{item}
        </foreach>
        and  c.shiji_shebei_id is not null


    </select>
    <select id="getImageByShiyanid" resultType="java.lang.String">


        select c.extra_pic
        from itdm_gongdan_image as c
        where c.weituo_id =#{weituoId}
        and c.extra_pic is not null

    </select>
    <select id="getShujuByShiyanid" resultType="java.util.HashMap">

        select c.shiyan_wendu,c.shiyan_shidu,c.shiyan_time,c.shiyan_date_time
        from itdm_gongdan_master as b

        inner join itdm_gongdan_shuju c on b.id = c.wo_id

        where b.test_items_id in


        <foreach item="item" collection="list" separator="," open="(" close=")" index="">
            #{item}
        </foreach>
        order by c.shiyan_date_time,c.shiyan_time,c.shiyan_type
    </select>
    <select id="getByweituoNO" resultType="java.lang.String">

        select m.id from itdm_test_plan as t
                            inner join itdm_gongdan_master as m
                                       on t.id=m.jihua_shiyan_id
        where  t.weituo_id=#{weituoId}



    </select>
    <select id="getWorkDateByWeituoNO" resultType="java.lang.String">

        select distinct  d.shiji_work_date
        from (select m.id
              from itdm_test_plan as t
                       inner join itdm_gongdan_master as m
                                  on t.id = m.jihua_shiyan_id
              where t.weituo_id = #{weituoId}) as a
                 inner join itdm_gongdan_detail as d on d.wo_id = a.id
        where d.shiji_work_date is not null order by d.shiji_work_date
    </select>
    <select id="getWoIdByWeituoIdAndWordDate" resultType="java.lang.String">

        select distinct wo_id from itdm_gongdan_detail where shiji_work_date=#{workDate} and wo_id in (
            select m.id
            from itdm_test_plan as t
                     inner join itdm_gongdan_master as m
                                on t.id = m.jihua_shiyan_id
            where t.weituo_id = #{weituoId}
        )
    </select>


</mapper>
