<?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.lutao.cloud.oil.mapper.EmergencyRecordMapper">

  <resultMap id="emergencyRecordMap" type="com.lutao.entity.EmergencyRecord">
                  <id property="id" column="id"/>
                        <result property="originId" column="origin_id"/>
                        <result property="recordDate" column="record_date"/>
                        <result property="nextrecordDate" column="nextrecord_date"/>
                        <result property="recordCode" column="record_code"/>
                        <result property="personnelLifeboatQuantity" column="personnel_lifeboat_quantity"/>
                        <result property="emergencyplanFile" column="emergencyplan_file"/>
                        <result property="pfId" column="pf_id"/>
                        <result property="appId" column="app_id"/>
                        <result property="platformCode" column="platform_code"/>
                        <result property="platformName" column="platform_name"/>
                        <result property="platformId" column="platform_id"/>
                        <result property="createDate" column="create_date"/>
                        <result property="createBy" column="create_by"/>
                        <result property="updateDate" column="update_date"/>
                        <result property="updateBy" column="update_by"/>
            </resultMap>
    <select id="getEmergencyPlanList" resultType="com.lutao.cloud.oil.pojo.vo.EmergencyPlanVO">
        SELECT
            er.id,
            er.record_date,
            er.nextrecord_date,
            er.record_code,
            er.personnel_lifeboat_quantity,
            er.app_id,
            er.platform_code,
            pi.platform_name,
            pi.oil_gas_name,
            pi.operating_company,
            ai.app_name
        FROM
            emergency_record er
                LEFT JOIN app_info ai ON er.app_id = ai.id
                LEFT JOIN platform_info pi ON er.platform_code = pi.platform_code
        <where>
            pi.delete_flag = '0'
            <if test="param.platformId != null and param.platformId != ''">
                AND er.platform_code = #{param.platformId}
            </if>
            <if test="param.appId != null and param.appId != ''">
                AND er.app_id = #{param.appId}
            </if>
            <if test="param.operatingCompany != null and param.operatingCompany != ''">
                AND pi.operating_company = #{param.operatingCompany}
            </if>
            <if test="param.oilGasName != null and param.oilGasName != ''">
                AND pi.oil_gas_name = #{param.oilGasName}
            </if>
            <if test="param.recordDate != null">
                AND er.record_date = #{param.recordDate}
            </if>
        </where>
        ORDER BY
            er.record_date DESC
    </select>
</mapper>
