<?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.zjrs.ggfw.rlzysc.entity.GwxxMapper">

    <select id="getGwxxList" parameterType="com.zjrs.ggfw.rlzysc.dto.GrqzGwxxQueryDTO"
            resultType="com.zjrs.ggfw.rlzysc.dto.GrqzGwxxListDTO">
        select d.*,
        g.aab022 as "sshy" from (select a.rs_rlzy_gwxx_lsh rsrlzygwxxlsh,
        a.rs_rlzy_zwxx_lsh rsrlzyzwxxlsh,
        a.rs_yhlsh rsyhlsh,
        c.rs_yhlsh qyxx_rsyhlsh,
        a.gwzt,
        a.tdjg,
        a.rs_lqtzs_lsh rslqtzslsh,
        b.rs_rlzy_qyxx_lsh rsrlzyqyxxlsh,
        b.zwmc,
        b.xz,
        b.zpgz,
        c.gsmc,
        c.gsgm,
        a.ts_cjsj tscjsj,
        b.gzdd dwdz
        from v_rs_rlzy_gwxx a, v_rs_rlzy_zwxx b, v_rs_rlzy_qyxx c
        where a.rs_rlzy_zwxx_lsh = b.rs_rlzy_zwxx_lsh
        and b.rs_rlzy_qyxx_lsh = c.rs_rlzy_qyxx_lsh
        and a.rs_yhlsh = #{dto.rsyhlsh}
        and a.gwzt = #{dto.gwzt}
        order by a.ts_xgsj desc)d,rs_ggfw_user e,v_ab01 g where d.qyxx_rsyhlsh = e.userid
        and e.fwdx = '2'
        and e.ztid = g.ztid
        <if test="dto.tdjg != null and dto.tdjg != ''">
            and d.tdjg = #{dto.tdjg}
        </if>
        <if test="dto.scsjc != null and dto.scsjc != ''">
            and d.tscjsj  <![CDATA[>=]]> '${dto.scsjc}'
        </if>
        <if test="dto.scsjz != null and dto.scsjz != ''">
            and d.tscjsj  <![CDATA[<=]]> '${dto.scsjz}'
        </if>
    </select>

</mapper>
