<?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.psam.entity.RsPsamAzfkxxbMapper">

    <select id="getList" parameterType="com.zjrs.zwnw.psam.dto.PsamKglDTO" resultType="com.zjrs.zwnw.psam.dto.PsamDcDTO">
        SELECT '湛江市' "sscs",b.shbh "shbh",
        aa.aab004 "shmc",b.shlx "shlx",a.zdhm "zdhm",c.psambh "psambh",
        '' "lxr",
        '' "bgdh",
        aa.AAE005 "sjhm",aa.aae006 "shdz",a.ZJRQ "zjrq",a.SHZT "shzt"
        FROM RS_PSAM_AZFKXXB a,RS_PSAM_YWXX_SQB b,RS_PSAM_RKXXB c,ab01 aa
        WHERE a.rs_psam_ywxx_sqb_lsh=b.rs_psam_ywxx_sqb_lsh AND a.rs_psam_rkxxb_lsh=c.rs_psam_rkxxb_lsh
        <if test="dto.shlx != null and dto.shlx != ''">
            and b.shlx = #{ dto.shlx }
        </if>
        <if test="dto.zjrqEnd != null and dto.zjrqEnd != ''">
            and a.ZJRQ &lt;=#{ dto.zjrqEnd }
        </if>
        ORDER BY a.cjsj DESC,c.psambh
    </select>
    <select id="getListExcel" parameterType="com.zjrs.zwnw.psam.dto.PsamKglDTO" resultType="com.zjrs.zwnw.psam.dto.PsamDcDTO">
        SELECT '湛江市' "sscs",b.shbh "shbh",
        aa.aab004 "shmc",
               '' "shlx",a.zdhm "zdhm",c.psambh "psambh",
        '' "lxr",
        '' "bgdh",
        aa.AAE005 "sjhm",aa.aae006 "shdz",a.ZJRQ "zjrq",
        '' "shzt"
        FROM RS_PSAM_AZFKXXB a,RS_PSAM_YWXX_SQB b,RS_PSAM_RKXXB c,ab01 aa
        WHERE a.rs_psam_ywxx_sqb_lsh=b.rs_psam_ywxx_sqb_lsh AND a.rs_psam_rkxxb_lsh=c.rs_psam_rkxxb_lsh
         <if test="dto.shlx != null and dto.shlx != ''">
            and b.shlx = #{ dto.shlx }
        </if>
        <if test="dto.zjrqEnd != null and dto.zjrqEnd != ''">
            and a.ZJRQ &lt;=#{ dto.zjrqEnd }
        </if>
        ORDER BY a.cjsj DESC,c.psambh
    </select>
    <select id="dcList" parameterType="com.zjrs.zwnw.psam.dto.PsamKglDTO"
            resultType="com.zjrs.zwnw.psam.dto.PsamDcDTO">
        SELECT '440800' "sscs",b.shbh "shbh",
        aa.aab004 "shmc",b.shlx "shlx",a.zdhm "zdhm",c.psambh "psambh",
        '' "lxr",
        '' "bgdh",
        aa.AAE005 "sjhm",aa.aae006 "shdz",replace(a.ZJRQ,'-','') "zjrq",a.SHZT "shzt"
        FROM RS_PSAM_AZFKXXB a,RS_PSAM_YWXX_SQB b,RS_PSAM_RKXXB c,ab01 aa
        WHERE a.rs_psam_ywxx_sqb_lsh=b.rs_psam_ywxx_sqb_lsh AND a.rs_psam_rkxxb_lsh=c.rs_psam_rkxxb_lsh
        <if test="dto.shlx != null and dto.shlx != ''">
            and b.shlx = #{ dto.shlx }
        </if>
        <if test="dto.zjrqBegin != null and dto.zjrqBegin != ''">
            and a.ZJRQ &gt;=#{ dto.zjrqBegin }
        </if>
        <if test="dto.zjrqEnd != null and dto.zjrqEnd != ''">
            and a.ZJRQ &lt;=#{ dto.zjrqEnd }
        </if>
        ORDER BY a.cjsj DESC,c.psambh
    </select>
</mapper>
