<?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.GxygMapper">

    <select id="getGxygList" parameterType="com.zjrs.ggfw.rlzysc.dto.GxygQueryDTO"
            resultType="com.zjrs.ggfw.rlzysc.dto.GxygDTO">
        SELECT a.rs_rlzy_gxyg_lsh "rsrlzygxyglsh", b.gsmc "qymc",
        a.qyygqk "qyygqk", a.gxrs "gxrs", a.gxyy "gxyy",
        a.gxkssj "gxkssj", a.gxjssj "gxjssj"
        ,a.lxr "lxr", a.lxdh "lxdh", '02' "shzt", a.fbzt "fbzt",
        a.shyj "shyj", '01' "tjzt"
        FROM v_rs_rlzy_gxyg a, v_rs_rlzy_qyxx b
        WHERE a.rs_rlzy_qyxx_lsh = b.rs_rlzy_qyxx_lsh
        and b.rs_yhlsh = #{dto.rsyhlsh}
        <if test="dto.qymc != null and dto.qymc != ''">
            and  b.gsmc like '%'||#{dto.qymc}||'%'
        </if>
        <if test="dto.qyygqk != null and dto.qyygqk != ''">
            and a.qyygqk = #{dto.qyygqk}
        </if>
        <if test="dto.shzt != null and dto.shzt != ''">
            and '02' = #{dto.shzt}
        </if>

        <if test="dto.gxkssjc != null and dto.gxkssjc != ''">
            and gxkssj <![CDATA[ >= ]]> #{dto.gxkssjc}
        </if>

        <if test="dto.cxzt != null and dto.cxzt != ''">
            and gxkssj <![CDATA[ <= ]]> to_char(sysdate,'YYYY-MM-DD') and gxjssj <![CDATA[ <= ]]> to_char(sysdate,'YYYY-MM-DD')
        </if>
        and a.ts_yxbz = '1'
        order by gxkssj desc
    </select>

    <select id="getAllGxygList" parameterType="com.zjrs.ggfw.rlzysc.dto.GxygQueryDTO"
            resultType="com.zjrs.ggfw.rlzysc.dto.GxygDTO">
        SELECT a.rs_rlzy_gxyg_lsh "rsrlzygxyglsh", b.gsmc "qymc",
        a.qyygqk "qyygqk", a.gxrs "gxrs", a.gxyy "gxyy",
        a.gxkssj "gxkssj", a.gxjssj "gxjssj"
        ,a.lxr "lxr", a.lxdh "lxdh", '02' "shzt", a.fbzt "fbzt",
        a.shyj "shyj", '01' "tjzt"
        FROM v_rs_rlzy_gxyg a, v_rs_rlzy_qyxx b
        WHERE a.rs_rlzy_qyxx_lsh = b.rs_rlzy_qyxx_lsh
        <if test="dto.qymc != null and dto.qymc != ''">
            and  b.gsmc like '%'||#{dto.qymc}||'%'
        </if>
        <if test="dto.qyygqk != null and dto.qyygqk != ''">
            and a.qyygqk = #{dto.qyygqk}
        </if>
        <if test="dto.gxrs != null and dto.gxrs != ''">
            and a.gxrs like '%'||#{dto.gxrs}||'%'
        </if>

        <if test="dto.gxkssjc != null and dto.gxkssjc != ''">
            and gxkssj <![CDATA[ >= ]]> #{dto.gxkssjc}
        </if>

        <if test="dto.gxkssjz != null and dto.gxkssjz != ''">
            and gxkssj <![CDATA[ <= ]]> #{dto.gxkssjz}
        </if>

        <if test="dto.gxjssjc != null and dto.gxjssjc != ''">
            and gxjssj <![CDATA[ >= ]]> #{dto.gxjssjc}
        </if>

        <if test="dto.gxjssjz != null and dto.gxjssjz != ''">
            and gxjssj <![CDATA[ <= ]]> #{dto.gxjssjz}
        </if>

        and a.gxjssj <![CDATA[ >= ]]> to_char(sysdate, 'yyyy-MM-dd')
        order by a.gxkssj desc
    </select>

    <select id="getGxygStatus" resultType="String">
        SELECT AAA005 CODE FROM AA01 WHERE AAA001 = 'RS_RLZY_SGXYGZT'
    </select>

</mapper>
