<?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.projectV2.ZsyzDbdMapper">
    
    <resultMap type="ZsyzDbd" id="ZsyzDbdResult">
        <result property="id"    column="id"    />
        <result property="dh"    column="dh"    />
        <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="isHf"    column="is_hf"    />
        <result property="dbTime"    column="db_time"    />
        <result property="blsx"    column="blsx"    />
        <result property="dbsx"    column="dbsx"    />
        <result property="jzqk"    column="jzqk"    />
        <result property="czwt"    column="czwt"    />
        <result property="jjjy"    column="jjjy"    />
        <result property="gzjh"    column="gzjh"    />
        <result property="tbr"    column="tbr"    />
        <result property="phone"    column="phone"    />
        <result property="tbTime"    column="tb_time"    />
        <result property="dbType"    column="db_type"    />
        <result property="progress"    column="progress"    />
        <result property="xmStatus"    column="xm_status"    />
        <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"    />
    </resultMap>

    <sql id="selectZsyzDbdVo">
        select id, dh, xm_id, xmbh, xmmc, dept_id, dept_name, is_hf, db_time, blsx, dbsx, jzqk, czwt, jjjy, gzjh, tbr, phone, tb_time,db_type,progress,xm_status, create_by, create_time, update_by, update_time, remark from zsyz_dbd
    </sql>

    <select id="selectZsyzDbdList" parameterType="ZsyzDbd" resultMap="ZsyzDbdResult">
        <include refid="selectZsyzDbdVo"/>
        <where>  
            <if test="dh != null  and dh != ''"> and dh = #{dh}</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 like concat('%', #{xmmc}, '%')</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="isHf != null  and isHf != ''"> and is_hf = #{isHf}</if>
            <if test="dbTime != null "> and db_time = #{dbTime}</if>
            <if test="blsx != null  and blsx != ''"> and blsx = #{blsx}</if>
            <if test="dbsx != null  and dbsx != ''"> and dbsx = #{dbsx}</if>
            <if test="jzqk != null  and jzqk != ''"> and jzqk = #{jzqk}</if>
            <if test="czwt != null  and czwt != ''"> and czwt = #{czwt}</if>
            <if test="jjjy != null  and jjjy != ''"> and jjjy = #{jjjy}</if>
            <if test="gzjh != null  and gzjh != ''"> and gzjh = #{gzjh}</if>
            <if test="tbr != null  and tbr != ''"> and tbr = #{tbr}</if>
            <if test="phone != null  and phone != ''"> and phone = #{phone}</if>
            <if test="tbTime != null "> and tb_time = #{tbTime}</if>
            <if test="dbType != null "> and db_type = #{dbType}</if>
            <if test="progress != null "> and progress = #{progress}</if>
            <if test="xmStatus != null "> and xm_status = #{xmStatus}</if>
        </where>
        order by db_time desc
    </select>
    
    <select id="selectZsyzDbdById" parameterType="Long" resultMap="ZsyzDbdResult">
        <include refid="selectZsyzDbdVo"/>
        where id = #{id}
    </select>
    <select id="number" resultType="java.lang.Long">
        select count(1) from zsyz_dbd
        <where>
            is_hf = 'N'
            <if test="dh != null  and dh != ''"> and dh = #{dh}</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="deptId != null "> and dept_id = #{deptId}</if>
            <if test="deptName != null  and deptName != ''"> and dept_name like concat('%', #{deptName}, '%')</if>
            <if test="isHf != null  and isHf != ''"> and is_hf = #{isHf}</if>
            <if test="dbTime != null "> and db_time = #{dbTime}</if>
            <if test="blsx != null  and blsx != ''"> and blsx = #{blsx}</if>
            <if test="dbsx != null  and dbsx != ''"> and dbsx = #{dbsx}</if>
            <if test="jzqk != null  and jzqk != ''"> and jzqk = #{jzqk}</if>
            <if test="czwt != null  and czwt != ''"> and czwt = #{czwt}</if>
            <if test="jjjy != null  and jjjy != ''"> and jjjy = #{jjjy}</if>
            <if test="gzjh != null  and gzjh != ''"> and gzjh = #{gzjh}</if>
            <if test="tbr != null  and tbr != ''"> and tbr = #{tbr}</if>
            <if test="phone != null  and phone != ''"> and phone = #{phone}</if>
            <if test="tbTime != null "> and tb_time = #{tbTime}</if>
            <if test="dbType != null "> and db_type = #{dbType}</if>
            <if test="progress != null "> and progress = #{progress}</if>
            <if test="xmStatus != null "> and xm_status = #{xmStatus}</if>
        </where>
    </select>

    <insert id="insertZsyzDbd" parameterType="ZsyzDbd" useGeneratedKeys="true" keyProperty="id">
        insert into zsyz_dbd
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="dh != null and dh != ''">dh,</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="isHf != null and isHf != ''">is_hf,</if>
            <if test="dbTime != null">db_time,</if>
            <if test="blsx != null">blsx,</if>
            <if test="dbsx != null">dbsx,</if>
            <if test="jzqk != null">jzqk,</if>
            <if test="czwt != null">czwt,</if>
            <if test="jjjy != null">jjjy,</if>
            <if test="gzjh != null">gzjh,</if>
            <if test="tbr != null">tbr,</if>
            <if test="phone != null">phone,</if>
            <if test="tbTime != null">tb_time,</if>
            <if test="dbType != null">db_type,</if>
            <if test="progress != null">progress,</if>
            <if test="xmStatus != null">xm_status,</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="dh != null and dh != ''">#{dh},</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="isHf != null and isHf != ''">#{isHf},</if>
            <if test="dbTime != null">#{dbTime},</if>
            <if test="blsx != null">#{blsx},</if>
            <if test="dbsx != null">#{dbsx},</if>
            <if test="jzqk != null">#{jzqk},</if>
            <if test="czwt != null">#{czwt},</if>
            <if test="jjjy != null">#{jjjy},</if>
            <if test="gzjh != null">#{gzjh},</if>
            <if test="tbr != null">#{tbr},</if>
            <if test="phone != null">#{phone},</if>
            <if test="tbTime != null">#{tbTime},</if>
            <if test="dbType != null">#{dbType},</if>
            <if test="progress != null">#{progress},</if>
            <if test="xmStatus != null">#{xmStatus},</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="updateZsyzDbd" parameterType="ZsyzDbd">
        update zsyz_dbd
        <trim prefix="SET" suffixOverrides=",">
            <if test="dh != null and dh != ''">dh = #{dh},</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="isHf != null and isHf != ''">is_hf = #{isHf},</if>
            <if test="dbTime != null">db_time = #{dbTime},</if>
            <if test="blsx != null">blsx = #{blsx},</if>
            <if test="dbsx != null">dbsx = #{dbsx},</if>
            <if test="jzqk != null">jzqk = #{jzqk},</if>
            <if test="czwt != null">czwt = #{czwt},</if>
            <if test="jjjy != null">jjjy = #{jjjy},</if>
            <if test="gzjh != null">gzjh = #{gzjh},</if>
            <if test="tbr != null">tbr = #{tbr},</if>
            <if test="phone != null">phone = #{phone},</if>
            <if test="tbTime != null">tb_time = #{tbTime},</if>
            <if test="dbType != null">db_type = #{dbType},</if>
            <if test="progress != null">progress = #{progress},</if>
            <if test="xmStatus != null">xm_status = #{xmStatus},</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="deleteZsyzDbdById" parameterType="Long">
        delete from zsyz_dbd where id = #{id}
    </delete>

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