<?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.ruoyi.system.mapper.fgw.FgwJzqkMapper">
    
    <resultMap type="FgwJzqk" id="FgwJzqkResult">
        <result property="id"    column="id"    />
        <result property="jdId"    column="jd_id"    />
        <result property="xmId"    column="xm_id"    />
        <result property="xmbh"    column="xmbh"    />
        <result property="xmmc"    column="xmmc"    />
        <result property="deptId"    column="dept_id"    />
        <result property="deptName"    column="dept_name"    />
        <result property="isNt"    column="is_nt"    />
        <result property="isJs"    column="is_js"    />
        <result property="isJd"    column="is_jd"    />
        <result property="isJg"    column="is_jg"    />
        <result property="nttz"    column="nttz"    />
        <result property="jzqk"    column="jzqk"    />
        <result property="sgll"    column="sgll"    />
        <result property="hbTime"    column="hb_time"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="remark"    column="remark"    />
        <result property="isSh"    column="is_sh"    />
    </resultMap>

    <sql id="selectFgwJzqkVo">
        select id,jd_id, xm_id, xmbh,is_nt,is_js,is_jd,is_jg,nttz,is_sh, xmmc, dept_id, dept_name, jzqk, sgll, hb_time, create_by, create_time, update_by, update_time, remark from fgw_jzqk
    </sql>

    <select id="selectFgwJzqkList" parameterType="FgwJzqk" resultMap="FgwJzqkResult">
        <include refid="selectFgwJzqkVo"/>
        <where>
            <if test="jdId != null "> and jd_id = #{jdId}</if>
            <if test="xmId != null "> and xm_id = #{xmId}</if>
            <if test="xmbh != null  and xmbh != ''"> and xmbh = #{xmbh}</if>
            <if test="xmmc != null  and xmmc != ''"> and xmmc = #{xmmc}</if>
            <if test="isNt != null  and isNt != ''"> and is_nt = #{isNt}</if>
            <if test="isJs != null  and isJs != ''"> and is_js = #{isJs}</if>
            <if test="isSh != null  and isSh != ''"> and is_sh = #{isSh}</if>
            <if test="isJd != null  and isJd != ''"> and is_jd = #{isJd}</if>
            <if test="isJg != null  and isJg != ''"> and is_jg = #{isJg}</if>
            <if test="deptId != null "> and dept_id = #{deptId}</if>
            <if test="deptName != null  and deptName != ''"> and dept_name like concat('%', #{deptName}, '%')</if>
            <if test="jzqk != null  and jzqk != ''"> and jzqk = #{jzqk}</if>
            <if test="sgll != null  and sgll != ''"> and sgll = #{sgll}</if>
            <if test="hbTime != null "> and hb_time = #{hbTime}</if>
            <if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
                AND date_format(hb_time,'%Y%m') = date_format(#{params.beginTime},'%Y%m')
            </if>
        </where>
    </select>
    
    <select id="selectFgwJzqkById" parameterType="Long" resultMap="FgwJzqkResult">
        <include refid="selectFgwJzqkVo"/>
        where id = #{id}
    </select>
    <select id="selectFgwJzqkTj" parameterType="FgwJzqk" resultMap="FgwJzqkResult">
        <include refid="selectFgwJzqkVo"/>
        <where>
            <if test="jdId != null "> and jd_id = #{jdId}</if>
            <if test="xmId != null "> and xm_id = #{xmId}</if>
            <if test="xmbh != null  and xmbh != ''"> and xmbh = #{xmbh}</if>
            <if test="xmmc != null  and xmmc != ''"> and xmmc = #{xmmc}</if>
            <if test="isNt != null  and isNt != ''"> and is_nt = #{isNt}</if>
            <if test="isJs != null  and isJs != ''"> and is_js = #{isJs}</if>
            <if test="isSh != null  and isSh != ''"> and is_sh = #{isSh}</if>
            <if test="isJd != null  and isJd != ''"> and is_jd = #{isJd}</if>
            <if test="isJg != null  and isJg != ''"> and is_jg = #{isJg}</if>
            <if test="deptId != null "> and dept_id = #{deptId}</if>
            <if test="deptName != null  and deptName != ''"> and dept_name like concat('%', #{deptName}, '%')</if>
            <if test="jzqk != null  and jzqk != ''"> and jzqk = #{jzqk}</if>
            <if test="sgll != null  and sgll != ''"> and sgll = #{sgll}</if>
            <if test="hbTime != null "> and hb_time = #{hbTime}</if>
            <if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
                AND date_format(hb_time,'%Y%m%d') &gt;= date_format(#{params.beginTime},'%Y%m%d')
            </if>
            <if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
                AND date_format(hb_time,'%Y%m%d') &lt;= date_format(#{params.endTime},'%Y%m%d')
            </if>
        </where>
    </select>

    <insert id="insertFgwJzqk" parameterType="FgwJzqk" useGeneratedKeys="true" keyProperty="id">
        insert into fgw_jzqk
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="jdId != null "> jd_id,</if>
            <if test="xmId != null">xm_id,</if>
            <if test="xmbh != null">xmbh,</if>
            <if test="xmmc != null and xmmc != ''">xmmc,</if>
            <if test="deptId != null">dept_id,</if>
            <if test="deptName != null and deptName != ''">dept_name,</if>
            <if test="isNt != null and isNt != ''">is_nt,</if>
            <if test="isJs != null and isJs != ''">is_js,</if>
            <if test="isJd != null and isJd != ''">is_jd,</if>
            <if test="isJg != null and isJg != ''">is_jg,</if>
            <if test="nttz != null and nttz != ''">nttz,</if>
            <if test="isSh != null and isSh != ''">is_sh,</if>
            <if test="jzqk != null">jzqk,</if>
            <if test="sgll != null">sgll,</if>
            <if test="hbTime != null">hb_time,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="remark != null">remark,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="jdId != null ">#{jdId},</if>
            <if test="xmId != null">#{xmId},</if>
            <if test="xmbh != null">#{xmbh},</if>
            <if test="xmmc != null and xmmc != ''">#{xmmc},</if>
            <if test="deptId != null">#{deptId},</if>
            <if test="deptName != null and deptName != ''">#{deptName},</if>
            <if test="isNt != null and isNt != ''">#{isNt},</if>
            <if test="isJs != null and isJs != ''">#{isJs},</if>
            <if test="isJd != null and isJd != ''">#{isJd},</if>
            <if test="isJg != null and isJg != ''">#{isJg},</if>
            <if test="nttz != null and nttz != ''">#{nttz},</if>
            <if test="isSh != null and isSh != ''">#{isSh},</if>
            <if test="jzqk != null">#{jzqk},</if>
            <if test="sgll != null">#{sgll},</if>
            <if test="hbTime != null">#{hbTime},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="remark != null">#{remark},</if>
         </trim>
    </insert>

    <update id="updateFgwJzqk" parameterType="FgwJzqk">
        update fgw_jzqk
        <trim prefix="SET" suffixOverrides=",">
            <if test="jdId != null ">jd_id = #{jdId},</if>
            <if test="xmId != null">xm_id = #{xmId},</if>
            <if test="xmbh != null">xmbh = #{xmbh},</if>
            <if test="xmmc != null and xmmc != ''">xmmc = #{xmmc},</if>
            <if test="deptId != null">dept_id = #{deptId},</if>
            <if test="deptName != null and deptName != ''">dept_name = #{deptName},</if>
            <if test="isNt != null and isNt != ''">is_nt = #{isNt},</if>
            <if test="isJs != null and isJs != ''">is_js = #{isJs},</if>
            <if test="isJd != null and isJd != ''">is_jd = #{isJd},</if>
            <if test="isJg != null and isJg != ''">is_jg = #{isJg},</if>
            <if test="nttz != null and nttz != ''">nttz = #{nttz},</if>
            <if test="isSh != null and isSh != ''">is_sh = #{isSh},</if>
            <if test="jzqk != null">jzqk = #{jzqk},</if>
            <if test="sgll != null">sgll = #{sgll},</if>
            <if test="hbTime != null">hb_time = #{hbTime},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="remark != null">remark = #{remark},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteFgwJzqkById" parameterType="Long">
        delete from fgw_jzqk where id = #{id}
    </delete>

    <delete id="deleteFgwJzqkByIds" parameterType="String">
        delete from fgw_jzqk where id in 
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
</mapper>