<?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.TFaFixedAssetsMapper">
    <resultMap id="tFaFixedAssetsMap" type="com.nantian.cloud.jljc.entity.TFaFixedAssets">
        <result property="id" column="id"/>
        <result property="projectName" column="project_name"/>
        <result property="projectAddr" column="project_addr"/>
        <result property="projectLeader" column="project_leader"/>
        <result property="affiliatedCompanies" column="affiliated_companies"/>
        <result property="creditCode" column="credit_code"/>
        <result property="industry" column="industry"/>
        <result property="tel" column="tel"/>
        <result property="projectEnergy" column="project_energy"/>
        <result property="projectStatus" column="project_status"/>
        <result property="delFlag" column="del_flag"/>
        <result property="userId" column="user_id"/>
        <result property="deptId" column="dept_id"/>
        <result property="updateTime" column="update_time"/>
    </resultMap>

    <sql id="Base_Column_List">
        id,project_name,project_addr,project_leader,affiliated_companies,credit_code,industry,tel,project_energy,project_status,status_data,del_flag,user_id,dept_id,update_time,cause,project_time
    </sql>
    <select id="getPage" resultType="com.nantian.cloud.jljc.entity.TFaFixedAssets">
        select <include refid="Base_Column_List"></include>
        from t_fa_fixed_assets
        where del_flag = "1"
        <if test="query.projectName != null and query.projectName != ''">
            and project_name like concat("%",#{query.projectName},"%")
        </if>
        <if test="query.affiliatedCompanies != null and query.affiliatedCompanies != ''">
            and affiliated_companies like concat("%",#{query.affiliatedCompanies},"%")
        </if>
        <if test="query.projectAddr != null and query.projectAddr != ''">
            and project_addr like concat("%",#{query.projectAddr},"%")
        </if>
        <if test="query.projectStatus != null and query.projectStatus != ''">
            and project_status = #{query.projectStatus}
        </if>
        order by project_status asc
    </select>
    <select id="getProjectInfo" resultType="com.nantian.cloud.jljc.vo.TFaProjectVO">
        SELECT
        fa.id,fa.project_name,
        fa.update_time AS update_time,
        fa.dept_id AS dept_id,
        ab.id AS accrediting_id,
        ab.suspend_time AS suspend_time,
        ab.restart_time AS restart_time,
        it.id AS investment_id,
        pc.id AS inProcess_id,
        pc.supervise_time AS inpro_time,
        ca.id AS eventAfter_id,
        ca.new_file_name AS event_name
        FROM
        t_fa_fixed_assets fa
        LEFT JOIN t_fa_accrediting_body ab ON fa.id = ab.project_id
        LEFT JOIN t_fa_investment it ON fa.id = it.project_id
        LEFT JOIN t_fa_process_control pc ON fa.id = pc.project_id
        LEFT JOIN t_fa_check_accept ca ON fa.id = ca.project_id
        WHERE
        fa.del_flag = 1
        AND fa.project_status != 0
        AND fa.status_data != 0
        order by update_time desc
    </select>


</mapper>
