<?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.tcZz.mapper.TcDbxtMapper">
    
    <resultMap type="TcDbxt" id="TcDbxtResult">
        <result property="id"    column="id"    />
        <result property="areaId"    column="area_id"    />
        <result property="systemName"    column="system_name"    />
        <result property="beianNum"    column="beian_num"    />
        <result property="safetyLevel"    column="safety_level"    />
        <result property="unitName"    column="unit_name"    />
        <result property="businessType"    column="business_type"    />
        <result property="serviceArea"    column="service_area"    />
        <result property="serviceObj"    column="service_obj"    />
        <result property="coverageArea"    column="coverage_area"    />
        <result property="networkProperty"    column="network_property"    />
        <result property="systemHlql"    column="system_hlql"    />
        <result property="startTime"    column="start_time"    />
        <result property="isLevel"    column="is_level"    />
        <result property="systemDjtime"    column="system_djtime"    />
        <result property="psQk"    column="ps_qk"    />
        <result property="isHavedep"    column="is_haveDep"    />
        <result property="systemDjbg"    column="system_djbg"    />
        <result property="systemState"    column="system_state"    />
        <result property="isStatus"    column="isStatus"    />
        <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="selectTcDbxtVo">
        select id, area_id, system_name, beian_num, safety_level, unit_name, business_type, service_area, service_obj, coverage_area, network_property, system_hlql, start_time, is_level, system_djtime, ps_qk, is_haveDep, system_djbg, system_state, isStatus, create_by, create_time, update_by, update_time, remark from tc_dbxt
    </sql>

    <select id="selectTcDbxtList" parameterType="TcDbxt" resultMap="TcDbxtResult">
        <include refid="selectTcDbxtVo"/>
        <where>  
            <if test="id != null "> and id = #{id}</if>
            <if test="areaId != null  and areaId != ''"> and area_id = #{areaId}</if>
            <if test="systemName != null  and systemName != ''"> and system_name like concat('%', #{systemName}, '%')</if>
            <if test="beianNum != null  and beianNum != ''"> and beian_num = #{beianNum}</if>
            <if test="safetyLevel != null  and safetyLevel != ''"> and safety_level = #{safetyLevel}</if>
            <if test="unitName != null  and unitName != ''"> and unit_name like concat('%', #{unitName}, '%')</if>
            <if test="businessType != null  and businessType != ''"> and business_type = #{businessType}</if>
            <if test="serviceArea != null  and serviceArea != ''"> and service_area = #{serviceArea}</if>
            <if test="serviceObj != null  and serviceObj != ''"> and service_obj = #{serviceObj}</if>
            <if test="coverageArea != null  and coverageArea != ''"> and coverage_area = #{coverageArea}</if>
            <if test="networkProperty != null  and networkProperty != ''"> and network_property = #{networkProperty}</if>
            <if test="systemHlql != null  and systemHlql != ''"> and system_hlql = #{systemHlql}</if>
            <if test="startTime != null "> and start_time = #{startTime}</if>
            <if test="isLevel != null  and isLevel != ''"> and is_level = #{isLevel}</if>
            <if test="systemDjtime != null "> and system_djtime = #{systemDjtime}</if>
            <if test="psQk != null  and psQk != ''"> and ps_qk = #{psQk}</if>
            <if test="isHavedep != null  and isHavedep != ''"> and is_haveDep = #{isHavedep}</if>
            <if test="systemDjbg != null  and systemDjbg != ''"> and system_djbg = #{systemDjbg}</if>
            <if test="systemState != null  and systemState != ''"> and system_state = #{systemState}</if>
            <if test="isStatus != null "> and isStatus = #{isStatus}</if>
            <if test="createBy != null  and createBy != ''"> and create_by = #{createBy}</if>
            <if test="params.beginCreateTime != null and params.beginCreateTime != '' and params.endCreateTime != null and params.endCreateTime != ''"> and create_time between #{params.beginCreateTime} and #{params.endCreateTime}</if>
            <if test="updateBy != null  and updateBy != ''"> and update_by = #{updateBy}</if>
            <if test="params.beginUpdateTime != null and params.beginUpdateTime != '' and params.endUpdateTime != null and params.endUpdateTime != ''"> and update_time between #{params.beginUpdateTime} and #{params.endUpdateTime}</if>
            <if test="remark != null  and remark != ''"> and remark = #{remark}</if>
        </where>
        order by create_time desc
    </select>
    
    <select id="selectTcDbxtById" parameterType="Long" resultMap="TcDbxtResult">
        <include refid="selectTcDbxtVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertTcDbxt" parameterType="TcDbxt" useGeneratedKeys="true" keyProperty="id">
        insert into tc_dbxt
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="areaId != null">area_id,</if>
            <if test="systemName != null">system_name,</if>
            <if test="beianNum != null">beian_num,</if>
            <if test="safetyLevel != null">safety_level,</if>
            <if test="unitName != null">unit_name,</if>
            <if test="businessType != null">business_type,</if>
            <if test="serviceArea != null">service_area,</if>
            <if test="serviceObj != null">service_obj,</if>
            <if test="coverageArea != null">coverage_area,</if>
            <if test="networkProperty != null">network_property,</if>
            <if test="systemHlql != null">system_hlql,</if>
            <if test="startTime != null">start_time,</if>
            <if test="isLevel != null">is_level,</if>
            <if test="systemDjtime != null">system_djtime,</if>
            <if test="psQk != null">ps_qk,</if>
            <if test="isHavedep != null">is_haveDep,</if>
            <if test="systemDjbg != null">system_djbg,</if>
            <if test="systemState != null">system_state,</if>
            <if test="isStatus != null">isStatus,</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="areaId != null">#{areaId},</if>
            <if test="systemName != null">#{systemName},</if>
            <if test="beianNum != null">#{beianNum},</if>
            <if test="safetyLevel != null">#{safetyLevel},</if>
            <if test="unitName != null">#{unitName},</if>
            <if test="businessType != null">#{businessType},</if>
            <if test="serviceArea != null">#{serviceArea},</if>
            <if test="serviceObj != null">#{serviceObj},</if>
            <if test="coverageArea != null">#{coverageArea},</if>
            <if test="networkProperty != null">#{networkProperty},</if>
            <if test="systemHlql != null">#{systemHlql},</if>
            <if test="startTime != null">#{startTime},</if>
            <if test="isLevel != null">#{isLevel},</if>
            <if test="systemDjtime != null">#{systemDjtime},</if>
            <if test="psQk != null">#{psQk},</if>
            <if test="isHavedep != null">#{isHavedep},</if>
            <if test="systemDjbg != null">#{systemDjbg},</if>
            <if test="systemState != null">#{systemState},</if>
            <if test="isStatus != null">#{isStatus},</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="updateTcDbxt" parameterType="TcDbxt">
        update tc_dbxt
        <trim prefix="SET" suffixOverrides=",">
            <if test="areaId != null">area_id = #{areaId},</if>
            <if test="systemName != null">system_name = #{systemName},</if>
            <if test="beianNum != null">beian_num = #{beianNum},</if>
            <if test="safetyLevel != null">safety_level = #{safetyLevel},</if>
            <if test="unitName != null">unit_name = #{unitName},</if>
            <if test="businessType != null">business_type = #{businessType},</if>
            <if test="serviceArea != null">service_area = #{serviceArea},</if>
            <if test="serviceObj != null">service_obj = #{serviceObj},</if>
            <if test="coverageArea != null">coverage_area = #{coverageArea},</if>
            <if test="networkProperty != null">network_property = #{networkProperty},</if>
            <if test="systemHlql != null">system_hlql = #{systemHlql},</if>
            <if test="startTime != null">start_time = #{startTime},</if>
            <if test="isLevel != null">is_level = #{isLevel},</if>
            <if test="systemDjtime != null">system_djtime = #{systemDjtime},</if>
            <if test="psQk != null">ps_qk = #{psQk},</if>
            <if test="isHavedep != null">is_haveDep = #{isHavedep},</if>
            <if test="systemDjbg != null">system_djbg = #{systemDjbg},</if>
            <if test="systemState != null">system_state = #{systemState},</if>
            <if test="isStatus != null">isStatus = #{isStatus},</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>
    <update id="updateByisStatus">
        UPDATE tc_dbxt
        SET isStatus = #{isStatus}
        WHERE id IN
        <foreach collection="ids" item="item" index="index" separator="," open="(" close=")">
            #{item}
        </foreach>
    </update>

    <delete id="deleteTcDbxtById" parameterType="Long">
        delete from tc_dbxt where id = #{id}
    </delete>

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