<?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.portal.entity.VRsSyZskMapper">

    <select id="getZskList" parameterType="com.zjrs.zwnw.portal.dto.ZskQueryDTO" resultType="map">
        SELECT RS_SY_ZSK_LSH "rssyzsklsh",bt "bt",strsplit2dict(ywzt, ',', 'RS_SY_ZSK_YWZT') "ywzt",
        fbzt "fbzt", TS_YXBZ "tsyxbz",
        f_common_getSSgUserOrg(bae001) as "bae001",
        f_common_getSSgUser(bae004) as "bae004", bae005 "bae005",
        f_common_getSSgUserOrg(bae006) as "bae006" FROM RS_SY_ZSK
        WHERE TS_YXBZ = '1'
        <if test="dto.qwss != null and dto.qwss != ''">
            and (ztc like '%'||#{dto.qwss}||'%' or bt like '%'||#{dto.qwss}||'%' or zw like '%'||#{dto.qwss}||'%')
        </if>
       ORDER BY bae005 DESC
    </select>

    <select id="getZskXxById" parameterType="java.lang.String" resultType="com.zjrs.zwnw.portal.po.VRsSyZskPO">
        SELECT RS_SY_ZSK_LSH "rssyzsklsh",bt "bt",ywzt "ywzt",zw "zw",ztc "ztc",
        fbzt "fbzt", TS_YXBZ "tsyxbz",
        f_common_getSSgUserOrg(bae001) as "bae001",
        f_common_getSSgUser(bae002) as "bae002",
        bae003 as "bae003",
        f_common_getSSgUser(bae004) as "bae004", bae005 "bae005",
        f_common_getSSgUserOrg(bae006) as "bae006" FROM RS_SY_ZSK
        WHERE RS_SY_ZSK_LSH = #{rssyzsklsh}
    </select>

    <select id="getzskExportList" parameterType="com.zjrs.zwnw.portal.dto.ZskQueryDTO" resultType="com.zjrs.zwnw.portal.dto.ZskDTO">
        SELECT RS_SY_ZSK_LSH "rssyzsklsh",bt "bt",strsplit2dict(ywzt, ',', 'RS_SY_ZSK_YWZT') "ywzt",zw "zw",ztc "ztc",
        f_common_getSSgUserOrg(bae001) as "bae001",
        f_common_getSSgUser(bae004) as "bae004", bae005 "bae005",
        f_common_getSSgUserOrg(bae006) as "bae006" FROM RS_SY_ZSK
        WHERE 
        <if test="dto.ywzt != null and dto.ywzt != ''">
             ywzt like '%'||#{dto.ywzt}||'%'
        </if>
        ORDER BY bae005 DESC
    </select>

    <select id="getZskFileList" resultType="java.util.Map" parameterType="list">
        select RS_WJ_LSH as "rswjlsh",
        RS_WJ_LSH || kzm as "tyccid",
        KZM as"kzm",
        WJM as"wjm",
        TS_CJSJ as"cjsj",
        (select ORG_NAME
        from s_sg_org
        where ID = (select ORG_ID
        from s_sg_user_org
        where user_id = a.TS_CJR
        and rownum = 1)) as "cjrjg",
        (select user_name
        from v_rs_sy_org_area
        where user_id = a.TS_CJR) as "cjr"
        from rs_wj a
        where 
        <if test="list !=null ">
             ywlsh in
            <foreach collection="list" index="index" item="item" open="(" separator="," close=")">
                #{item}
            </foreach>
        </if>
        order by TS_CJSJ desc
    </select>

    <select id="getZskIds" parameterType="com.zjrs.zwnw.portal.dto.ZskQueryDTO" resultType="map">
        SELECT LISTAGG(RS_SY_ZSK_LSH, ',') WITHIN GROUP(ORDER BY RS_SY_ZSK_LSH) "ids" FROM RS_SY_ZSK
        WHERE 
        <if test="dto.qwss != null and dto.qwss != ''">
             (ztc like '%'||#{dto.qwss}||'%' or bt like '%'||#{dto.qwss}||'%' or zw like '%'||#{dto.qwss}||'%')
        </if>
        ORDER BY bae005 DESC
    </select>
</mapper>
