<?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="org.springblade.modules.fxpc.mapper.FxpcMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="fxpcResultMap" type="org.springblade.modules.fxpc.entity.FxpcEntity">
        <result column="id" property="id"/>
        <result column="qymc" property="qymc"/>
        <result column="shtyxydm" property="shtyxydm"/>
        <result column="xcfzr" property="xcfzr"/>
        <result column="dhhm" property="dhhm"/>
        <result column="qyxxdz" property="qyxxdz"/>
        <result column="gsjyms" property="gsjyms"/>
        <result column="gsrcjyqk" property="gsrcjyqk"/>
        <result column="gswfwgqk" property="gswfwgqk"/>
        <result column="create_user" property="createUser"/>
        <result column="create_dept" property="createDept"/>
        <result column="create_time" property="createTime"/>
        <result column="update_user" property="updateUser"/>
        <result column="update_time" property="updateTime"/>
        <result column="status" property="status"/>
        <result column="is_deleted" property="isDeleted"/>
        <result column="fkjg" property="fkjg"/>
    </resultMap>


    <select id="selectFxpcPage" resultMap="fxpcResultMap">
        select
            jf.*
        from jdrh_fxpc jf
        left join jdrh.blade_dept bd on bd.id = jf.create_dept
        where jf.is_deleted = 0
        <if test="params.roleName != '经侦管理员'">
            and ((#{params.deptId} LIKE '%' || bd.id || '%') OR (bd.ancestors LIKE '%' || #{params.deptId} || '%'))
        </if>
        <if test="params.qymc != null and params.qymc != ''">
            and jf.qymc like '%' || #{params.qymc} || '%'
        </if>
        <if test="params.shtyxydm != null and params.shtyxydm != ''">
            and jf.shtyxydm = #{params.shtyxydm}
        </if>
        <if test="params.xcfzr != null and params.xcfzr != ''">
            and jf.xcfzr = #{params.xcfzr}
        </if>
        <if test="params.dhhm != null and params.dhhm != ''">
            and jf.dhhm = #{params.dhhm}
        </if>
        <if test="params.qyxxdz != null and params.qyxxdz != ''">
            and jf.qyxxdz = #{params.qyxxdz}
        </if>
        <if test="params.sssjBm !=null and params.sssjBm != ''">
            and bd.ancestors like '%' || #{params.sssjBm} || '%'
        </if>
        <if test="params.ssfjBm !=null and params.ssfjBm != ''">
            and bd.ancestors like '%' || #{params.ssfjBm} || '%'
        </if>
        <if test="params.sspcsBm != null and params.sspcsBm != ''">
            and bd.ancestors like '%' || #{params.sspcsBm} || '%'
        </if>
        <if test="params.sssqBm !=null and params.sssqBm != ''">
            and bd.ancestors like '%' || #{params.sssqBm} || '%'
        </if>
        <if test="params.startTime !=null and params.startTime != '' and params.endTime != null and params.endTime != ''">
          and jf.create_time between #{params.startTime}::timestamp and #{params.endTime}::timestamp
        </if>
        <if test="params.fkjg !=null and params.fkjg !=''">
            and jf.fkjg=#{params.fkjg}
        </if>
    </select>


    <select id="exportFxpc" resultType="org.springblade.modules.fxpc.excel.FxpcExcel">
        SELECT * FROM jdrh_fxpc ${ew.customSqlSegment}
        </select>

</mapper>
