<?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.dxhy.jxpt.baseService.config.dao.BaseServiceTdxLqQllsfpcjKzDao">
    <update id="updateTdxLqQllsfpcjKz" databaseId="mysql">
        update t_dx_lq_qllsfpcj_kz
        <set>
            <if test="rwzxzt!=null and rwzxzt!=''">
                rwzxzt = #{rwzxzt},
            </if>
            update_time = now()
        </set>
        <where>
            <if test="nsrsbh!=null and nsrsbh!=''">
                and nsrsbh = #{nsrsbh}
            </if>
            <if test="fplx!=null and fplx!=''">
                and fplx = #{fplx}
            </if>
            <if test="rwlx!=null and rwlx!=''">
                and rwlx = #{rwlx}
            </if>
            <if test="sjlx!=null and sjlx!=''">
                and sjlx = #{sjlx}
            </if>
            <if test="cjkssj!=null and cjkssj!=''">
                and cjkssj = #{cjkssj}
            </if>
            <if test="cjjssj!=null and cjjssj!=''">
                and cjjssj = #{cjjssj}
            </if>
        </where>
    </update>

    <update id="updateTdxLqQllsfpcjKz" databaseId="oracle">
        update t_dx_lq_qllsfpcj_kz
        <set>
            <if test="rwzxzt!=null and rwzxzt!=''">
                rwzxzt = #{rwzxzt},
            </if>
            update_time = sysdate
        </set>
        <where>
            <if test="nsrsbh!=null and nsrsbh!=''">
                and nsrsbh = #{nsrsbh}
            </if>
            <if test="fplx!=null and fplx!=''">
                and fplx = #{fplx}
            </if>
            <if test="rwlx!=null and rwlx!=''">
                and rwlx = #{rwlx}
            </if>
            <if test="sjlx!=null and sjlx!=''">
                and sjlx = #{sjlx}
            </if>
            <if test="cjkssj!=null and cjkssj!=''">
                and cjkssj = #{cjkssj}
            </if>
            <if test="cjjssj!=null and cjjssj!=''">
                and cjjssj = #{cjjssj}
            </if>
        </where>
    </update>

    <select id="tdxLqQllsfpcjKzList" resultType="com.dxhy.api.model.config.sys.TdxLqQllsfpcjKzEntity"
            parameterType="java.util.Map">
        select * from t_dx_lq_qllsfpcj_kz
        <where>
            rwzxzt in ('0','4')
            <if test="nsrsbh!=null and nsrsbh!=''">
                and nsrsbh = #{nsrsbh}
            </if>
            <if test="sjlx!=null and sjlx!=''">
                and sjlx = #{sjlx}
            </if>
            <if test="cjkssj!=null and cjkssj!=''">
                and cjkssj = #{cjkssj}
            </if>
            <if test="cjjssj!=null and cjjssj!=''">
                and cjjssj = #{cjjssj}
            </if>
            <if test="fplx!=null and fplx!=''">
                and fplx = #{fplx}
            </if>
            <if test="rwlx!=null and rwlx!=''">
                and rwlx = #{rwlx}
            </if>
            <if test="rwzxzt!=null and rwzxzt!=''">
                and rwzxzt = #{rwzxzt}
            </if>
        </where>
    </select>
    <select id="selectCreatetime" resultType="java.lang.String" databaseId="mysql">
        SELECT DATE_FORMAT(create_time, "%Y%m%d") FROM t_dx_lq_qllsfpcj_kz
        <where>
            nsrsbh = #{nsrsbh} AND sjlx = #{sjlx} AND rwlx = #{rwlx} and fplx = #{fplx}
        </where>
        ORDER BY create_time DESC LIMIT 1
    </select>

    <select id="selectCreatetime" resultType="java.lang.String" databaseId="oracle">
        select a.createTime from (
            SELECT to_char(create_time, 'YYYYMMDD') createTime,rownum r FROM t_dx_lq_qllsfpcj_kz
            <where>
                nsrsbh = #{nsrsbh} AND sjlx = #{sjlx} AND rwlx = #{rwlx} and fplx = #{fplx}
            </where>
            ORDER BY create_time DESC
        ) a
        where a.r = 1
    </select>

    <select id="selectTdxLqQllsfpcjKz" resultType="com.dxhy.api.model.config.sys.TdxLqQllsfpcjKzEntity" databaseId="mysql">
        SELECT * FROM t_dx_lq_qllsfpcj_kz
        <where>
            <if test="nsrsbh!=null and nsrsbh!=''">
                and nsrsbh = #{nsrsbh}
            </if>
            <if test="sjlx!=null and sjlx!=''">
                and sjlx = #{sjlx}
            </if>
            <if test="cjkssj!=null and cjkssj!=''">
                and cjkssj = #{cjkssj}
            </if>
            <if test="cjjssj!=null and cjjssj!=''">
                and cjjssj = #{cjjssj}
            </if>
            <if test="fplx!=null and fplx!=''">
                and fplx = #{fplx}
            </if>
            <if test="rwlx!=null and rwlx!=''">
                and rwlx = #{rwlx}
            </if>
        </where>
        ORDER BY create_time DESC LIMIT 1
    </select>

    <select id="selectTdxLqQllsfpcjKz" resultType="com.dxhy.api.model.config.sys.TdxLqQllsfpcjKzEntity" databaseId="oracle">
        select a.* from (
            SELECT t.*,rownum r FROM t_dx_lq_qllsfpcj_kz t
            <where>
                <if test="nsrsbh!=null and nsrsbh!=''">
                    and t.nsrsbh = #{nsrsbh}
                </if>
                <if test="sjlx!=null and sjlx!=''">
                    and t.sjlx = #{sjlx}
                </if>
                <if test="cjkssj!=null and cjkssj!=''">
                    and t.cjkssj = #{cjkssj}
                </if>
                <if test="cjjssj!=null and cjjssj!=''">
                    and t.cjjssj = #{cjjssj}
                </if>
                <if test="fplx!=null and fplx!=''">
                    and t.fplx = #{fplx}
                </if>
                <if test="rwlx!=null and rwlx!=''">
                    and t.rwlx = #{rwlx}
                </if>
            </where>
            ORDER BY t.create_time DESC
        ) a
            where a.r = 1
    </select>

    <select id="getselFldmBysh" resultType="com.dxhy.api.model.config.sys.TdxLqQllsfpcjKzEntity">
        select DISTINCT nsrsbh,fplx from
        t_dx_lq_qllsfpcj_kz where nsrsbh = #{nsrsbh}
    </select>

</mapper>
