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

  <resultMap id="changeInfoMap" type="com.lutao.entity.ChangeInfo">
                  <id property="id" column="id"/>
                        <result property="originId" column="origin_id"/>
                        <result property="facilityName" column="facility_name"/>
                        <result property="positionCode" column="position_code"/>
                        <result property="applyPersonName" column="apply_person_name"/>
                        <result property="applyTime" column="apply_time"/>
                        <result property="changeReason" column="change_reason"/>
                        <result property="workLimit" column="work_limit"/>
                        <result property="changeFile" column="change_file"/>
                        <result property="changeType" column="change_type"/>
                        <result property="urgentChange" column="urgent_change"/>
                        <result property="urgentChangeTime" column="urgent_change_time"/>
                        <result property="changeLevel" column="change_level"/>
                        <result property="changeDepartCode" column="change_depart_code"/>
                        <result property="changeProcess" column="change_process"/>
                        <result property="changeProcessStatus" column="change_process_status"/>
                        <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="getChangeSituationList" resultType="com.lutao.cloud.oil.pojo.vo.ChangeInfoVO">
        SELECT
            ci.id,
            ci.facility_name,
            ci.position_code,
            ci.apply_person_name,
            ci.apply_time,
            ci.change_reason,
            ci.work_limit,
            ci.change_file,
            ci.change_type,
            ci.urgent_change,
            ci.urgent_change_time,
            ci.change_level,
            ci.change_depart_code,
            ci.change_process,
            ci.change_process_status,
            ci.app_id,
            ci.platform_code,
            pi.platform_name,
            pi.oil_gas_name,
            pi.operating_company,
            ai.app_name
        FROM
            change_info ci
                LEFT JOIN app_info ai ON ci.app_id = ai.id
                LEFT JOIN platform_info pi ON ci.platform_code = pi.platform_code
        <where>
            pi.delete_flag = '0'
            <if test="param.platformId != null and param.platformId != ''">
                AND ci.platform_code = #{param.platformId}
            </if>
            <if test="param.appId != null and param.appId != ''">
                AND ci.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.applyTime != null">
                AND ci.apply_time = #{param.applyTime}
            </if>
        </where>
        ORDER BY ci.apply_time DESC
    </select>
</mapper>
