<?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.unis.emergencySupportCenter.modular.esEdProcessDesign.mapper.EsEdProcessDesignMapper">

    <select id="selectMyMapsPage" resultType="com.unis.emergencySupportCenter.modular.esEdProcessDesign.entity.EsEdProcessDesign">
    SELECT
    id,
    create_time,
    create_user,
    update_time,
    update_user,
    drill_theme,
    responsible_leader,
    responsible_department,
    drill_personnel,
    drill_process,
    drill_content,
    attachment
    FROM
	biz_es_ed_process_design
    <if test="ew.sqlSegment != null and ew.sqlSegment != ''">
        where ${ew.sqlSegment}
    </if>
    ORDER BY create_time desc
    </select>
    <select id="getEsEdProcessDesignSelect" resultType="com.unis.emergencySupportCenter.modular.esEdProcessDesign.entity.VO.EsEdProcessDesignSelectVO">

    <choose>
        <when  test=" type !='' and type == '2'.toString()" >
            SELECT DISTINCT
            b.id,
            b.create_time,
            a.drill_theme,
            a.responsible_leader,
            a.responsible_department,
            a.drill_personnel,
            a.attachment
            FROM
            biz_es_ed_process_design a
            INNER JOIN biz_es_ed_execution_process b ON a.id = b.es_ed_process_design_id
            LEFT JOIN biz_es_ed_scene_record c ON b.id = c.es_ed_execution_process_id
            WHERE	c.id IS NULL
            ORDER BY  b.create_time desc
        </when>
        <when  test=" type !='' and type == '3'.toString()" >
            SELECT DISTINCT
            c.id,
            c.create_time,
            a.drill_theme,
            a.responsible_leader,
            a.responsible_department,
            a.drill_personnel,
            a.attachment
            FROM
            biz_es_ed_process_design a
            INNER JOIN biz_es_ed_execution_process b ON a.id = b.es_ed_process_design_id
            INNER JOIN biz_es_ed_scene_record c ON b.id = c.es_ed_execution_process_id
            LEFT  JOIN biz_es_ed_assessment d ON c.id = d.es_ed_scene_record_id
            WHERE	d.id IS NULL
            ORDER BY  c.create_time desc
        </when>
        <otherwise>
            SELECT DISTINCT
            a.id,
            a.create_time,
            a.drill_theme,
            a.responsible_leader,
            a.responsible_department,
            a.drill_personnel,
            a.attachment
            FROM
            biz_es_ed_process_design a
            LEFT JOIN biz_es_ed_execution_process  b on a.id = b.es_ed_process_design_id
            where b.id is NULL
            ORDER BY  a.create_time desc
        </otherwise>
    </choose>

    </select>
</mapper>