<?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.zwnw.rlzysc.entity.RcqdMapper">

    <select id="getDwrcqdList" parameterType="com.zjrs.zwnw.rlzysc.dto.DwQdQueryDTO" resultType="HashMap">
        select zphbh  as "zphbh",
        gsmc   as "gsmc",
        hcbh   as "hcbh",
        zwwzmc as "zwwzmc",
        yyr    as "yyr",
        yyrq   as "yyrq",
        qdrq   as "qdrq"
        from (select (select zphbh
        from v_rs_rlzy_zphgl
        where rs_rlzy_zphgl_lsh = v.rs_rlzy_zphgl_lsh and ts_yxbz = '1') zphbh,
        (select tyrz.aab004
        from v_rs_rlzy_qyxx qyxx,v_tyrz_user_dwjbxx tyrz
        where qyxx.rs_rlzy_qyxx_lsh = v.rs_rlzy_qyxx_lsh and qyxx.rs_yhlsh = tyrz.useridcode) gsmc,
        (select hcbh
        from v_rs_rlzy_hcgl
        where rs_rlzy_hcgl_lsh = v.rs_rlzy_hcgl_lsh and ts_yxbz = '1') hcbh,
        (select tyrz.aab998
        from v_rs_rlzy_qyxx qyxx,v_tyrz_user_dwjbxx tyrz
        where qyxx.rs_rlzy_qyxx_lsh = v.rs_rlzy_qyxx_lsh and qyxx.rs_yhlsh = tyrz.useridcode) tyshxydm,
        f_rlzy_getAllZwwzmc(v.yypc) zwwzmc,
        w.yyr,
        w.yyrq,
        w.qdrq
        from (select rs_rlzy_zphgl_lsh,
        rs_rlzy_hcgl_lsh,
        rs_rlzy_qyxx_lsh,
        yypc,
        max(rs_zwwz_lsh) max_rs_zwwz_lsh
        from (select a.yypc, b.*
        from v_rs_rlzy_zwwzyysh a, v_rs_rlzy_dwrcdjgl b
        where a.rs_zwwz_lsh = b.rs_zwwz_lsh)
        where ts_yxbz = '1'
        group by rs_rlzy_zphgl_lsh,
        rs_rlzy_hcgl_lsh,
        rs_rlzy_qyxx_lsh,
        yypc) v,
        v_rs_rlzy_dwrcdjgl w
        where v.max_rs_zwwz_lsh = w.rs_zwwz_lsh)
        where 1=1
        <if test="dto.tyshxydm != null and dto.tyshxydm != ''">
            and tyshxydm = #{dto.tyshxydm}
        </if>
    </select>

    <select id="getGrrcqdList" parameterType="com.zjrs.zwnw.rlzysc.dto.GrQdQueryDTO" resultType="HashMap">
        select a.xm as "xm",
        a.msdw as "msdw",
        a.sfzhm as "sfzhm",
        a.zjlx as "zjlx",
        a.qzyx as "qzyx",
        a.qdrq as "qdrq"
        from v_rs_rlzy_grrcdjgl a
        where 1=1
        <if test="dto.sfzhm != null and dto.sfzhm != ''">
            and a.sfzhm = #{dto.sfzhm}
        </if>
        order by bae005 DESC
    </select>

</mapper>
