<?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.MattersManagerMapper">

    <resultMap id="mattersManagerMap" type="com.lutao.entity.MattersManager">
        <id property="id" column="id"/>
        <result property="originId" column="origin_id"/>
        <result property="facilityName" column="facility_name"/>
        <result property="reportPersonId" column="report_person_id"/>
        <result property="receivePersonId" column="receive_person_id"/>
        <result property="reportTime" column="report_time"/>
        <result property="reportContent" column="report_content"/>
        <result property="reportType" column="report_type"/>
        <result property="reportFile" column="report_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="getMattersManagers" resultType="com.lutao.cloud.oil.pojo.vo.ScreenDisplayMattersVO">
        SELECT mm.facility_name AS facilityName,
        mm.report_content AS reportContent,
        ai.app_name AS appName,
        pi.oil_gas_name AS oilGasName,
        pi.operating_company AS operatingCompany,
        pi.platform_name AS platformName,
        mm.report_time AS reportTime
        FROM matters_manager mm LEFT JOIN app_info ai ON mm.app_id = ai.id
        LEFT JOIN platform_info pi ON mm.platform_code = pi.platform_code
        <where>
            pi.delete_flag = '0'
            <if test="param.platformId != null and param.platformId != ''">
               and  mm.platform_code = #{param.platformId}
            </if>
            <if test="param.appId != null and param.appId != ''">
               and mm.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>
        </where>
        ORDER BY reportTime DESC, mm.app_id,pi.oil_gas_name,pi.operating_company,pi.platform_name
    </select>
</mapper>
