<?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="cn.com.tenlion.systembase.dao.comprehensivemsgcenter.IComprehensiveMsgCenterDao">

    <resultMap id="comprehensiveMsgCenterDTO" type="cn.com.tenlion.systembase.pojo.dtos.comprehensivemsgcenter.ComprehensiveMsgCenterDTO">
        <result column="comprehensive_msg_center_id" property="comprehensiveMsgCenterId"/>
        <result column="center_name" property="centerName"/>
        <result column="center_phone" property="centerPhone"/>
        <result column="center_level" property="centerLevel"/>
        <result column="center_level_name" property="centerLevelName"/>
        <result column="center_level_code" property="centerLevelCode"/>
        <result column="link_man" property="linkMan"/>
        <result column="worker_count" property="workerCount"/>
        <result column="area" property="area"/>
        <result column="year_funds" property="yearFunds"/>
        <result column="camera_count" property="cameraCount"/>
        <result column="is_guard" property="isGuard"/>
        <result column="location" property="location"/>
        <result column="location_name" property="locationName"/>
        <result column="location_code" property="locationCode"/>
        <result column="grid" property="grid"/>
        <result column="address" property="address"/>
        <result column="longitude" property="longitude"/>
        <result column="latitude" property="latitude"/>
    </resultMap>

    <resultMap id="comprehensiveMsgCenterBO" type="cn.com.tenlion.systembase.pojo.bos.comprehensivemsgcenter.ComprehensiveMsgCenterBO">
        <result column="comprehensive_msg_center_id" property="comprehensiveMsgCenterId"/>
        <result column="center_name" property="centerName"/>
        <result column="center_phone" property="centerPhone"/>
        <result column="center_level" property="centerLevel"/>
        <result column="center_level_name" property="centerLevelName"/>
        <result column="center_level_code" property="centerLevelCode"/>
        <result column="link_man" property="linkMan"/>
        <result column="worker_count" property="workerCount"/>
        <result column="area" property="area"/>
        <result column="year_funds" property="yearFunds"/>
        <result column="camera_count" property="cameraCount"/>
        <result column="is_guard" property="isGuard"/>
        <result column="location" property="location"/>
        <result column="location_name" property="locationName"/>
        <result column="location_code" property="locationCode"/>
        <result column="address" property="address"/>
        <result column="longitude" property="longitude"/>
        <result column="latitude" property="latitude"/>
    </resultMap>

    <resultMap id="comprehensiveMsgCenterPO" type="cn.com.tenlion.systembase.pojo.pos.comprehensivemsgcenter.ComprehensiveMsgCenterPO">
        <result column="comprehensive_msg_center_id" property="comprehensiveMsgCenterId"/>
        <result column="center_name" property="centerName"/>
        <result column="center_phone" property="centerPhone"/>
        <result column="center_level" property="centerLevel"/>
        <result column="center_level_name" property="centerLevelName"/>
        <result column="center_level_code" property="centerLevelCode"/>
        <result column="link_man" property="linkMan"/>
        <result column="worker_count" property="workerCount"/>
        <result column="area" property="area"/>
        <result column="year_funds" property="yearFunds"/>
        <result column="camera_count" property="cameraCount"/>
        <result column="is_guard" property="isGuard"/>
        <result column="location" property="location"/>
        <result column="location_name" property="locationName"/>
        <result column="location_code" property="locationCode"/>
        <result column="address" property="address"/>
        <result column="longitude" property="longitude"/>
        <result column="latitude" property="latitude"/>
    </resultMap>

    <!-- 新增综治视联网信息中心 -->
    <insert id="save" parameterType="map">
        INSERT INTO data_comprehensive_msg_center(
            comprehensive_msg_center_id,
            center_name,
            center_phone,
            center_level,
            center_level_name,
            center_level_code,
            link_man,
            worker_count,
            area,
            year_funds,
            camera_count,
            is_guard,
            location,
            location_name,
            location_code,
            grid,
            address,
            longitude,
            latitude,
            creator,
            gmt_create,
            modifier,
            gmt_modified,
            is_delete
        ) VALUES(
            #{comprehensiveMsgCenterId},
            #{centerName},
            #{centerPhone},
            #{centerLevel},
            #{centerLevelName},
            #{centerLevelCode},
            #{linkMan},
            #{workerCount},
            #{area},
            #{yearFunds},
            #{cameraCount},
            #{isGuard},
            #{location},
            #{locationName},
            #{locationCode},
            #{grid},
            #{address},
            #{longitude},
            #{latitude},
            #{creator},
            #{gmtCreate},
            #{modifier},
            #{gmtModified},
            #{isDelete}
        )
    </insert>

    <!-- 删除综治视联网信息中心 -->
    <update id="remove" parameterType="map">
        UPDATE
            data_comprehensive_msg_center
        SET
            gmt_modified = #{gmtModified},
            modifier = #{modifier},
            is_delete = 1
        WHERE
            comprehensive_msg_center_id IN
        <foreach collection="comprehensiveMsgCenterIds" index="index" open="(" separator="," close=")">
            #{comprehensiveMsgCenterIds[${index}]}
        </foreach>
    </update>

    <!-- 删除综治视联网信息中心（物理） -->
    <update id="delete" parameterType="map">
        DELETE FROM
            data_comprehensive_msg_center
        WHERE
            comprehensive_msg_center_id IN
        <foreach collection="comprehensiveMsgCenterIds" index="index" open="(" separator="," close=")">
            #{comprehensiveMsgCenterIds[${index}]}
        </foreach>
    </update>

    <!-- 修改综治视联网信息中心 -->
    <update id="update" parameterType="map">
        UPDATE
            data_comprehensive_msg_center
        SET
        <if test="centerName != null and centerName != ''">
            center_name = #{centerName},
        </if>
        <if test="centerPhone != null and centerPhone != ''">
            center_phone = #{centerPhone},
        </if>
        <if test="centerLevel != null">
            center_level = #{centerLevel},
        </if>
        <if test="centerLevelName != null and centerLevelName != ''">
            center_level_name = #{centerLevelName},
        </if>
        <if test="centerLevelCode != null and centerLevelCode != ''">
            center_level_code = #{centerLevelCode},
        </if>
        <if test="linkMan != null and linkMan != ''">
            link_man = #{linkMan},
        </if>
        <if test="workerCount != null">
            worker_count = #{workerCount},
        </if>
        <if test="area != null">
            area = #{area},
        </if>
        <if test="yearFunds != null">
            year_funds = #{yearFunds},
        </if>
        <if test="cameraCount != null">
            camera_count = #{cameraCount},
        </if>
        <if test="isGuard != null">
            is_guard = #{isGuard},
        </if>
        <if test="location != null and location != ''">
            location = #{location},
        </if>
        <if test="locationName != null and locationName != ''">
            location_name = #{locationName},
        </if>
        <if test="locationCode != null and locationCode != ''">
            location_code = #{locationCode},
        </if>
        <if test="grid != null and grid != ''">
            grid = #{grid},
        </if>
        <if test="address != null and address != ''">
            address = #{address},
        </if>
        <if test="longitude != null">
            longitude = #{longitude},
        </if>
        <if test="latitude != null">
            latitude = #{latitude},
        </if>
            gmt_modified = #{gmtModified},
            modifier = #{modifier},
            comprehensive_msg_center_id = comprehensive_msg_center_id
        WHERE
            comprehensive_msg_center_id = #{comprehensiveMsgCenterId}
    </update>

    <!-- 综治视联网信息中心详情 -->
    <select id="get" parameterType="map" resultMap="comprehensiveMsgCenterDTO">
        SELECT
            t1.center_name,
            t1.center_phone,
            t1.center_level,
            t1.center_level_name,
            t1.center_level_code,
            t1.link_man,
            t1.worker_count,
            t1.area,
            t1.year_funds,
            t1.camera_count,
            t1.is_guard,
            t1.location,
            t1.location_name,
            t1.location_code,
            t1.grid,
            t1.address,
            t1.longitude,
            t1.latitude,
            t1.comprehensive_msg_center_id
        FROM
            data_comprehensive_msg_center t1
        WHERE
            t1.is_delete = 0
            <if test="comprehensiveMsgCenterId != null and comprehensiveMsgCenterId != ''">
        AND
            t1.comprehensive_msg_center_id = #{comprehensiveMsgCenterId}
            </if>
    </select>

    <!-- 综治视联网信息中心详情 -->
    <select id="getBO" parameterType="map" resultMap="comprehensiveMsgCenterBO">
        SELECT
            t1.comprehensive_msg_center_id,
            t1.center_name,
            t1.center_phone,
            t1.center_level,
            t1.center_level_name,
            t1.center_level_code,
            t1.link_man,
            t1.worker_count,
            t1.area,
            t1.year_funds,
            t1.camera_count,
            t1.is_guard,
            t1.location,
            t1.location_name,
            t1.location_code,
            t1.address,
            t1.longitude,
            t1.latitude
        FROM
            data_comprehensive_msg_center t1
        WHERE
            t1.is_delete = 0
            <if test="comprehensiveMsgCenterId != null and comprehensiveMsgCenterId != ''">
        AND
            t1.comprehensive_msg_center_id = #{comprehensiveMsgCenterId}
            </if>
    </select>

    <!-- 综治视联网信息中心详情 -->
    <select id="getPO" parameterType="map" resultMap="comprehensiveMsgCenterPO">
        SELECT
            t1.comprehensive_msg_center_id,
            t1.center_name,
            t1.center_phone,
            t1.center_level,
            t1.center_level_name,
            t1.center_level_code,
            t1.link_man,
            t1.worker_count,
            t1.area,
            t1.year_funds,
            t1.camera_count,
            t1.is_guard,
            t1.location,
            t1.location_name,
            t1.location_code,
            t1.address,
            t1.longitude,
            t1.latitude
        FROM
            data_comprehensive_msg_center t1
        WHERE
            t1.is_delete = 0
            <if test="comprehensiveMsgCenterId != null and comprehensiveMsgCenterId != ''">
        AND
            t1.comprehensive_msg_center_id = #{comprehensiveMsgCenterId}
            </if>
    </select>

    <!-- 综治视联网信息中心列表 -->
    <select id="list" parameterType="map" resultMap="comprehensiveMsgCenterDTO">
        SELECT
            t1.comprehensive_msg_center_id,
            t1.center_name,
            t1.center_phone,
            t1.center_level,
            t1.center_level_name,
            t1.center_level_code,
            t1.link_man,
            t1.worker_count,
            t1.area,
            t1.year_funds,
            t1.camera_count,
            t1.is_guard,
            t1.location,
            t1.location_name,
            t1.location_code,
            t1.grid,
            t1.address,
            t1.longitude,
            t1.latitude,
            1
        FROM
            data_comprehensive_msg_center t1
        WHERE
            t1.is_delete = 0
        <if test="keywords != null and keywords != ''">
        AND (
            <!-- 这里添加其他条件 -->
            t1.id LIKE CONCAT('%', #{keywords}, '%')
        )
        </if>
        <if test="startTime != null and startTime != ''">
        AND
            LEFT(t1.gmt_create, 10) <![CDATA[ >= ]]> #{startTime}
        </if>
        <if test="endTime != null and endTime != ''">
            AND
            LEFT(t1.gmt_create, 10) <![CDATA[ <= ]]> #{endTime}
        </if>
        <if test="comprehensiveMsgCenterIds != null and comprehensiveMsgCenterIds.size > 0">
        AND
            t1.comprehensive_msg_center_id IN
            <foreach collection="comprehensiveMsgCenterIds" index="index" open="(" separator="," close=")">
                #{comprehensiveMsgCenterIds[${index}]}
            </foreach>
        </if>
    </select>

    <!-- 综治视联网信息中心列表 -->
    <select id="listBO" parameterType="map" resultMap="comprehensiveMsgCenterBO">
        SELECT
            t1.comprehensive_msg_center_id,
            t1.center_name,
            t1.center_phone,
            t1.center_level,
            t1.center_level_name,
            t1.center_level_code,
            t1.link_man,
            t1.worker_count,
            t1.area,
            t1.year_funds,
            t1.camera_count,
            t1.is_guard,
            t1.location,
            t1.location_name,
            t1.location_code,
            t1.address,
            t1.longitude,
            t1.latitude
        FROM
            data_comprehensive_msg_center t1
        WHERE
            t1.is_delete = 0
        <if test="keywords != null and keywords != ''">
        AND (
            <!-- 这里添加其他条件 -->
            t1.id LIKE CONCAT('%', #{keywords}, '%')
        )
        </if>
        <if test="startTime != null and startTime != ''">
        AND
            LEFT(t1.gmt_create, 10) <![CDATA[ >= ]]> #{startTime}
        </if>
        <if test="endTime != null and endTime != ''">
        AND
            LEFT(t1.gmt_create, 10) <![CDATA[ <= ]]> #{endTime}
        </if>
        <if test="comprehensiveMsgCenterIds != null and comprehensiveMsgCenterIds.size > 0">
        AND
            t1.comprehensive_msg_center_id IN
            <foreach collection="comprehensiveMsgCenterIds" index="index" open="(" separator="," close=")">
                #{comprehensiveMsgCenterIds[${index}]}
            </foreach>
        </if>
    </select>

    <!-- 综治视联网信息中心列表 -->
    <select id="listPO" parameterType="map" resultMap="comprehensiveMsgCenterPO">
        SELECT
            t1.comprehensive_msg_center_id,
            t1.center_name,
            t1.center_phone,
            t1.center_level,
            t1.center_level_name,
            t1.center_level_code,
            t1.link_man,
            t1.worker_count,
            t1.area,
            t1.year_funds,
            t1.camera_count,
            t1.is_guard,
            t1.location,
            t1.location_name,
            t1.location_code,
            t1.address,
            t1.longitude,
            t1.latitude
        FROM
            data_comprehensive_msg_center t1
        WHERE
            t1.is_delete = 0
        <if test="keywords != null and keywords != ''">
        AND (
            <!-- 这里添加其他条件 -->
            t1.id LIKE CONCAT('%', #{keywords}, '%')
        )
        </if>
        <if test="startTime != null and startTime != ''">
        AND
            LEFT(t1.gmt_create, 10) <![CDATA[ >= ]]> #{startTime}
        </if>
        <if test="endTime != null and endTime != ''">
        AND
            LEFT(t1.gmt_create, 10) <![CDATA[ <= ]]> #{endTime}
        </if>
        <if test="comprehensiveMsgCenterIds != null and comprehensiveMsgCenterIds.size > 0">
        AND
            t1.comprehensive_msg_center_id IN
            <foreach collection="comprehensiveMsgCenterIds" index="index" open="(" separator="," close=")">
                #{comprehensiveMsgCenterIds[${index}]}
            </foreach>
        </if>
    </select>

    <!-- 综治视联网信息中心统计  -->
    <select id="count" parameterType="map" resultType="Integer">
        SELECT
            COUNT(*)
        FROM
            data_comprehensive_msg_center t1
        WHERE
            t1.is_delete = 0
    </select>

</mapper>