TrafficEventMapper.xml 8.62 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.mapper.TrafficEventMapper">
    <resultMap id="LaneResultMap" type="com.viontech.vo.traffic.LaneModel">
        <result column="tollgate_id" jdbcType="VARCHAR" property="tollgateID"/>
        <result column="lane_id" jdbcType="INTEGER" property="laneId"/>
        <result column="lane_no" jdbcType="INTEGER" property="laneNo"/>
        <result column="name" jdbcType="VARCHAR" property="name"/>
        <result column="direction" jdbcType="VARCHAR" property="direction"/>
        <result column="ape_id" jdbcType="VARCHAR" property="apeID"/>
        <result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
        <result column="modify_time" jdbcType="TIMESTAMP" property="modifyTime"/>
    </resultMap>
    <!--  fetchSize="5000" -->
    <select id="selectJsonDatas" parameterType="com.viontech.vo.traffic.TrafficModel"
            resultType="java.lang.String" fetchSize="5000">
        <!-- select json_data from tb_traffic-->
        select json_data
        <!--||(select '{"unid":"'||unid||'"}' from tb_traffic as t1 where t1.unid=t2.unid )::jsonb as json_data -->
        from tb_traffic as t2
        <where>
            <!--            <if test="event_type != null and (event_type == 'pedestrian' or event_type == 'xcycle')">-->
            <if test="(sex != null and sex != '') or  (upbody_color != null and upbody_color != '') or (lobody_color != null and lobody_color != '')">
                and unid in(
                    select tb_face.traffic_unid
                    from tb_face where 1 = 1
                <if test="sex != null and sex != ''">
                    and tb_face.sex = #{sex}
                </if>
                <if test="upbody_color != null and upbody_color != ''">
                    and tb_face.upbody_color = #{upbody_color}
                </if>
                <if test="lobody_color != null and lobody_color != ''">
                    and tb_face.lobody_color = #{lobody_color}
                </if>)
            </if>
            <if test="subtaskIds != null and subtaskIds != ''">
                and EXISTS(select 1
                           from (values
                                   ${subtaskIds}
                                        ) as tt(ids)
                           where tt.ids = tb_traffic.subtask_id)
            </if>
            <if test="event_type != null and event_type != ''">
                and event_type = #{event_type}
            </if>
            <if test="with_hats != null">
                and with_hats = #{with_hats}
            </if>
            <if test="event_types != null">
                and event_type in
                <foreach item="item" index="index" collection="event_types"
                         open="(" separator="," close=")">
                    #{item}
                </foreach>
            </if>
            <if test="task_id != null and task_id != ''">
                and task_id = #{task_id}
            </if>
            <if test="subtask_id != null and subtask_id != ''">
                and subtask_id = #{subtask_id}
            </if>
            <if test="plate_text != null and plate_text != ''">
                and plate_text like '%' || #{plate_text} || '%'
            </if>
            <if test="task_type != null and task_type != ''">
                and task_type = #{task_type}
            </if>
            <if test="dev_unid != null and dev_unid != ''">
                and dev_unid = #{dev_unid}
            </if>

            <if test="vchan_refid != null and vchan_refid != ''">
                and vchan_refid = #{vchan_refid}
            </if>

            <if test="xcycle_type != null and xcycle_type != ''">
                and xcycle_type = #{xcycle_type}
            </if>
            <if test="vchan_duid != null and vchan_duid != ''">
                and vchan_duid = #{vchan_duid}
            </if>
            <if test="plate_color_code != null and plate_color_code != ''">
                and plate_color_code = #{plate_color_code}
            </if>
            <if test="location_code != null and location_code != ''">
                and location_code = #{location_code}
            </if>

            <if test="lane_code != null and lane_code != ''">
                and lane_code = #{lane_code}
            </if>

            <if test="direction_code != null and direction_code != ''">
                and direction_code = #{direction_code}
            </if>
            <if test="location_name != null and location_name != ''">
                and location_name = #{location_name}
            </if>


            <if test="body_type_code != null">
                and body_type_code = #{body_type_code}
            </if>
            <if test="body_type_codes != null">
                and body_type_code in
                <foreach item="item" index="index" collection="body_type_codes"
                         open="(" separator="," close=")">
                    #{item}
                </foreach>
            </if>
            <if test="device_name != null and device_name != ''">
                and device_name like '%' || #{device_name} || '%'
            </if>

            <if test="illegal_code != null and illegal_code != ''">
                and illegal_code = #{illegal_code}
            </if>
            <if test="illegal_codes != null">
                and illegal_code in
                <foreach item="item" index="index" collection="illegal_codes"
                         open="(" separator="," close=")">
                    #{item}
                </foreach>
            </if>
            <if test="illegal_state != null">
                and illegal_state = #{illegal_state}
            </if>

            <if test="body_color_code != null and body_color_code != ''">
                and body_color_code = #{body_color_code}
            </if>
            <if test="body_logo_code != null and body_logo_code != ''">
                and body_logo_code = #{body_logo_code}
            </if>

            <if test="refinedFeature_rAnnualInspection != null">
                and "refinedFeature_rAnnualInspection" = #{refinedFeature_rAnnualInspection}
            </if>

            <if test="refinedFeature_rDecoration != null">
                and "refinedFeature_rDecoration" = #{refinedFeature_rDecoration}
            </if>

            <if test="refinedFeature_rPendant != null">
                and "refinedFeature_rPendant" = #{refinedFeature_rPendant}
            </if>

            <if test="refinedFeature_rSunshading != null">
                and "refinedFeature_rSunshading" = #{refinedFeature_rSunshading}
            </if>

            <if test="company != null">
                and "company" = #{company}
            </if>

            and is_active = 'true'
            <if test="special_type != null and special_type != ''">
                and special_type = #{special_type}
            </if>
            <if test="event_dt__gte != null and event_dt__gte != ''">
                and shoot_dt > #{event_dt__gte,typeHandler=com.viontech.handler.MilliDateTypeHandler}
                <!--                and shoot_dtime >= #{event_dt__gte}-->
            </if>
            <if test="event_dt__lt != null and event_dt__lt != ''">
                and shoot_dt <![CDATA[<=]]> #{event_dt__lt,typeHandler=com.viontech.handler.MilliDateTypeHandler}
                <!--                and shoot_dtime <![CDATA[<]]> #{event_dt__lt}-->
            </if>
        </where>
        order by shoot_dt asc
        <if test="limit != null and offset != null">
            LIMIT #{limit} OFFSET #{offset}
        </if>
    </select>

    <select id="selectLaneDatas" parameterType="com.viontech.vo.traffic.LaneModel"
            resultMap="LaneResultMap" fetchSize="5000">
        select tollgate_id,lane_id,lane_no,`name`,direction,ape_id,create_time,modify_time
        from tb_lane
        <where>
            <if test="modifyTime_gte != null and modifyTime_gte != ''">
                and modify_time > #{modifyTime_gte,typeHandler=com.viontech.handler.MilliDateTypeHandler}
                <!--                and shoot_dtime >= #{modifyTime_gte}-->
            </if>
            <if test="modifyTime_lte != null and modifyTime_lte != ''">
                and modify_time <![CDATA[<=]]> #{modifyTime_lte,typeHandler=com.viontech.handler.MilliDateTypeHandler}
                <!--                and shoot_dtime <![CDATA[<]]> #{modifyTime_lte}-->
            </if>
        </where>
        order by modify_time asc
        <if test="limit != null and offset != null">
            LIMIT #{limit} OFFSET #{offset}
        </if>
    </select>
</mapper>