FlowMapper.xml 3.56 KB
<?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.viontech.fanxing.query.mapper.FlowMapper">
    <resultMap id="dataMap" type="com.viontech.fanxing.query.model.TrafficFlowDataModel">
        <result column="flow_event_id" property="eventId"/>
        <result column="event_time" property="eventTime"/>
        <result column="road" property="road"/>
        <result column="device_name" property="deviceName"/>
        <result column="location_name" property="locationName"/>
        <result column="velocity" property="velocity"/>
        <result column="occupy" property="occupy"/>
        <result column="distance" property="distance"/>
        <result column="sample_dura" property="sampleDura"/>
        <result column="queue_length" property="queueLength"/>
        <result column="sample_num" property="sampleNum"/>
        <result column="direction" property="direction"/>
        <result column="time_occupy" property="timeOccupy"/>
        <result column="dist_time" property="distTime"/>
    </resultMap>

    <select id="counts" parameterType="com.viontech.fanxing.query.model.TrafficFlowRequestVo"
            resultType="java.lang.Integer">
        select count(*) as count  from (
                select 1
                from d_flow_event te,
                     d_flow_data td
        <where>
            te.id = td.flow_event_id
                    AND td.road_code != '0'
            <if test="task_id != null and task_id != ''">
                and te.task_id = #{task_id}
            </if>
            <if test="vchan_refid != null and vchan_refid != ''">
                and te.channel_unid = #{vchan_refid}
            </if>
            <if test="detection_type != null and detection_type.size > 0">
                and detection_type in
                <foreach item="item" index="index" collection="detection_type" open="(" separator="," close=")">
                    #{item}
                </foreach>
            </if>
            <if test="event_dt__gte != null and event_dt__lt != null">
                and te.event_time <![CDATA[>=]]> #{event_dt__gte}
                and te.event_time <![CDATA[<=]]> #{event_dt__lt}
            </if>
        </where>
        GROUP BY ${groupByClause}
                ) as con
    </select>

    <select id="flowstatistics" parameterType="com.viontech.fanxing.query.model.TrafficFlowRequestVo"
            resultMap="dataMap">
        select ${column_List}
        from d_flow_event te,
             d_flow_data td
        <where>
            te.id = td.flow_event_id
                    and road_code != '0'
            <if test="event_dt__gte != null and event_dt__lt != null">
                and te.event_time <![CDATA[>=]]> #{event_dt__gte}
                and te.event_time <![CDATA[<=]]> #{event_dt__lt}
            </if>
            <if test="task_id != null">
                and td.task_id = #{task_id}
            </if>
            <if test="vchan_refid != null and vchan_refid != ''">
                and te.channel_unid = #{vchan_refid}
            </if>
            <if test="detection_type != null and detection_type.size > 0">
                and detection_type in
                <foreach item="item" index="index" collection="detection_type" open="(" separator="," close=")">
                    #{item}
                </foreach>
            </if>
        </where>
        GROUP BY ${groupByClause}
        ORDER BY ${orderByClause}
        <if test="limit != null">
            LIMIT #{offset},#{limit}
        </if>
    </select>
</mapper>