<?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.nantian.cloud.jljc.mapper.TProjectEnergySavingMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.nantian.cloud.jljc.entity.TProjectEnergySaving">
        <id column="id" property="id"/>
        <result column="userid" property="userid"/>
        <result column="update_time" property="updateTime"/>
        <result column="del_flag" property="delFlag"/>
        <result column="dept_id" property="deptId"/>
        <result column="project_type" property="projectType"/>
        <result column="project_name" property="projectName"/>
        <result column="project_desc" property="projectDesc"/>
        <result column="Investment_amount" property="investmentAmount"/>
        <result column="start_time" property="startTime"/>
        <result column="end_time" property="endTime"/>
        <result column="project_progress" property="projectProgress"/>
        <result column="departments" property="departments"/>
        <result column="epc" property="epc"/>
        <result column="epc_name" property="epcName"/>
        <result column="state" property="state"/>
        <result column="annual_production" property="annualProduction"/>
        <result column="application_form" property="applicationForm"/>
        <result column="energy_saving_project" property="energySavingProject"/>
        <result column="feasibility_study_report" property="feasibilityStudyReport"/>
        <result column="energy_year" property="energyYear"/>
        <result column="action" property="action"/>
        <result column="content" property="content" />
        <result column="front_energy" property="frontEnergy" />
        <result column="front_energy_equal" property="frontEnergyEqual" />
        <result column="after_energy" property="afterEnergy" />
        <result column="after_energy_equal" property="afterEnergyEqual" />
        <result column="product_energy_json" property="productEnergyJson" />
        <result column="energy_increment" property="energyIncrement" />
    </resultMap>

    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        id, userid, update_time, del_flag, dept_id, project_type, project_name, project_desc, Investment_amount, start_time,
         end_time, project_progress, departments, epc, epc_name, state, annual_production, application_form,
         energy_saving_project, feasibility_study_report, energy_year, action,
         content, front_energy, front_energy_equal, after_energy, after_energy_equal, product_energy_json, energy_increment
    </sql>

    <select id="getPageScope" resultType="com.nantian.cloud.jljc.entity.TProjectEnergySaving">
        select <include refid="Base_Column_List"></include>
        from t_project_energy_saving
        <trim prefix="where" prefixOverrides="and">
            <if test="query.projectName != null and query.projectName != ''">
                and project_name like concat("%",#{query.projectName},"%")
            </if>
            <if test="query.state != null and query.state != ''">
                and state = #{query.state}
            </if>
            <if test="query.epc != null and query.epc != ''">
                and epc = #{query.epc}
            </if>
            <if test="query.epcName != null and query.epcName != ''">
                and epc_name like concat("%",#{query.epcName},"%")
            </if>
            <if test="query.projectType != null and query.projectType != ''">
                and project_type like concat("%",#{query.projectType},"%")
            </if>
            <if test="query.action != null and query.action != ''">
                and action = #{action}
            </if>
            <if test="query.delFlag != null and query.delFlag != ''">
                and del_flag = #{query.delFlag}
            </if>
        </trim>
    </select>


    <select id="getPageScope2" resultType="com.nantian.cloud.jljc.entity.TProjectEnergySaving">
        select <include refid="Base_Column_List"></include>
        from t_project_energy_saving
        where state in (1,2,3,4) and del_flag = "1"
        <if test="query.projectName != null and query.projectName != ''">
            and project_name like concat("%",#{query.projectName},"%")
        </if>
        <if test="query.state != null and query.state != ''">
            and state = #{query.state}
        </if>
        <if test="query.epc != null and query.epc != ''">
            and epc = #{query.epc}
        </if>
        <if test="query.projectType != null and query.projectType != ''">
            and project_type like concat("%",#{query.projectType},"%")
        </if>
        <if test="query.action != null and query.action != ''">
            and action = #{action}
        </if>
        <if test="query.epcName != null and query.epcName != ''">
            and epc_name like concat("%",#{query.epcName},"%")
        </if>
    </select>

    <select id="queryListByCmp" resultType="com.nantian.cloud.jljc.entity.TProjectEnergySaving">
        select <include refid="Base_Column_List"></include>
        from t_project_energy_saving
        <trim prefix="where" prefixOverrides="and">
            <if test="query.projectName != null and query.projectName != ''">
                and project_name like concat("%",#{query.projectName},"%")
            </if>
            <if test="query.state != null and query.state != ''">
                and state = #{query.state}
            </if>
            <if test="query.epc != null and query.epc != ''">
                and epc = #{query.epc}
            </if>
            <if test="query.epcName != null and query.epcName != ''">
                and epc_name like concat("%",#{query.epcName},"%")
            </if>
            <if test="query.projectType != null and query.projectType != ''">
                and project_type like concat("%",#{query.projectType},"%")
            </if>
            <if test="query.action != null and query.action != ''">
                and action = #{action}
            </if>
            <if test="query.delFlag != null and query.delFlag != ''">
                and del_flag = #{query.delFlag}
            </if>
        </trim>
    </select>

</mapper>
