You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
477 lines
22 KiB
477 lines
22 KiB
<?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.zc.business.mapper.DcSdhsEventMapper">
|
|
|
|
<resultMap type="DcSdhsEvent" id="DcSdhsEventResult">
|
|
<result property="id" column="id" />
|
|
<result property="road" column="road" />
|
|
<result property="dept" column="dept" />
|
|
<result property="eventType" column="event_type" />
|
|
<result property="startTime" column="start_time" />
|
|
<result property="endTime" column="end_time" />
|
|
<result property="status" column="status" />
|
|
<result property="source" column="source" />
|
|
<result property="title" column="title" />
|
|
<result property="eventSubclass" column="event_subclass" />
|
|
<result property="carType" column="car_type" />
|
|
<result property="carNum" column="car_num" />
|
|
<result property="multiVehicle" column="multi_vehicle" />
|
|
<result property="direction" column="direction" />
|
|
<result property="stakeMark" column="stake_mark" />
|
|
<result property="weather" column="weather" />
|
|
</resultMap>
|
|
|
|
<sql id="selectDcSdhsEventVo">
|
|
select id, road, dept, event_type, start_time, end_time, status, source, title, event_subclass, car_type, car_num, multi_vehicle, direction, stake_mark, weather from dc_sdhs_event
|
|
</sql>
|
|
|
|
<select id="selectDcSdhsEventList" parameterType="DcSdhsEvent" resultMap="DcSdhsEventResult">
|
|
<include refid="selectDcSdhsEventVo"/>
|
|
<where>
|
|
<if test="road != null and road != ''"> and road = #{road}</if>
|
|
<if test="dept != null and dept != ''"> and dept = #{dept}</if>
|
|
<if test="eventType != null and eventType != ''"> and event_type = #{eventType}</if>
|
|
<if test="startTime != null "> and start_time = #{startTime}</if>
|
|
<if test="endTime != null "> and end_time = #{endTime}</if>
|
|
<if test="status != null and status != ''"> and status = #{status}</if>
|
|
<if test="source != null and source != ''"> and source = #{source}</if>
|
|
<if test="title != null and title != ''"> and title = #{title}</if>
|
|
<if test="eventSubclass != null and eventSubclass != ''"> and event_subclass = #{eventSubclass}</if>
|
|
<if test="carType != null and carType != ''"> and car_type = #{carType}</if>
|
|
<if test="carNum != null "> and car_num = #{carNum}</if>
|
|
<if test="multiVehicle != null and multiVehicle != ''"> and multi_vehicle = #{multiVehicle}</if>
|
|
<if test="direction != null and direction != ''"> and direction = #{direction}</if>
|
|
<if test="stakeMark != null and stakeMark != ''"> and stake_mark = #{stakeMark}</if>
|
|
<if test="weather != null and weather != ''"> and weather = #{weather}</if>
|
|
</where>
|
|
</select>
|
|
|
|
<select id="selectDcSdhsEventById" parameterType="Long" resultMap="DcSdhsEventResult">
|
|
<include refid="selectDcSdhsEventVo"/>
|
|
where id = #{id}
|
|
</select>
|
|
<select id="selectTimeList" resultType="java.util.Date">
|
|
select DISTINCT(start_time) from dc_sdhs_event
|
|
</select>
|
|
<select id="selectRegionAnalysis" resultType="java.util.Map">
|
|
|
|
select t1.city,IFNULL(t2.num,0) as #{thisTime}, IFNULL(t3.num,0) as #{lastTime}
|
|
from
|
|
(select '济南' city
|
|
union all select '泰安' city
|
|
union all select '济宁' city
|
|
union all select '菏泽' city) t1
|
|
left join
|
|
(SELECT
|
|
case when mileage >= 0 and mileage <= 132469 then '济南'
|
|
when mileage > 132469 and mileage <= 160708 then '泰安'
|
|
when mileage > 160708 and mileage <= 200752 then '济宁'
|
|
when mileage > 200752 then '菏泽' else '其他' end city,
|
|
count(*) num
|
|
FROM `dc_sdhs_event`
|
|
<where>
|
|
event_type = '交通事故'
|
|
<if test="type != null and type == '0'.toString">
|
|
and DATE_FORMAT(start_time,'%Y') = #{thisTime}
|
|
</if>
|
|
<if test="type != null and type == '1'.toString">
|
|
and DATE_FORMAT(start_time,'%Y-%m') = #{thisTime}
|
|
</if>
|
|
<if test="type != null and type == '2'.toString">
|
|
and DATE_FORMAT(start_time,'%Y-%m-%d') = #{thisTime}
|
|
</if>
|
|
</where>
|
|
GROUP BY city order by mileage asc) t2
|
|
on t1.city = t2.city
|
|
left join
|
|
(SELECT
|
|
case when mileage >= 0 and mileage <= 132469 then '济南'
|
|
when mileage > 132469 and mileage <= 160708 then '泰安'
|
|
when mileage > 160708 and mileage <= 200752 then '济宁'
|
|
when mileage > 200752 then '菏泽' else '其他' end city,
|
|
count(*) num
|
|
FROM `dc_sdhs_event`
|
|
<where>
|
|
event_type = '交通事故'
|
|
<if test="type != null and type == '0'.toString">
|
|
and DATE_FORMAT(start_time,'%Y') = #{lastTime}
|
|
</if>
|
|
<if test="type != null and type == '1'.toString">
|
|
and DATE_FORMAT(start_time,'%Y-%m') = #{lastTime}
|
|
</if>
|
|
<if test="type != null and type == '2'.toString">
|
|
and DATE_FORMAT(start_time,'%Y-%m-%d') = #{lastTime}
|
|
</if>
|
|
</where>
|
|
GROUP BY city order by mileage asc) t3
|
|
on t1.city = t3.city
|
|
|
|
</select>
|
|
|
|
<select id="selectEventRegionAnalysis" resultType="java.util.Map">
|
|
|
|
select t1.city,IFNULL(t2.num,0) as #{thisTime}, IFNULL(t3.num,0) as #{lastTime}
|
|
from
|
|
(select '济南' city
|
|
union all select '泰安' city
|
|
union all select '济宁' city
|
|
union all select '菏泽' city) t1
|
|
left join
|
|
(SELECT
|
|
case when mileage >= 0 and mileage <= 132469 then '济南'
|
|
when mileage > 132469 and mileage <= 160708 then '泰安'
|
|
when mileage > 160708 and mileage <= 200752 then '济宁'
|
|
when mileage > 200752 then '菏泽' else '其他' end city,
|
|
count(*) num
|
|
FROM `dc_sdhs_event`
|
|
<where>
|
|
<if test="type != null and type == '0'.toString">
|
|
and DATE_FORMAT(start_time,'%Y') = #{thisTime}
|
|
</if>
|
|
<if test="type != null and type == '1'.toString">
|
|
and DATE_FORMAT(start_time,'%Y-%m') = #{thisTime}
|
|
</if>
|
|
<if test="type != null and type == '2'.toString">
|
|
and DATE_FORMAT(start_time,'%Y-%m-%d') = #{thisTime}
|
|
</if>
|
|
</where>
|
|
GROUP BY city order by mileage asc) t2
|
|
on t1.city = t2.city
|
|
left join
|
|
(SELECT
|
|
case when mileage >= 0 and mileage <= 132469 then '济南'
|
|
when mileage > 132469 and mileage <= 160708 then '泰安'
|
|
when mileage > 160708 and mileage <= 200752 then '济宁'
|
|
when mileage > 200752 then '菏泽' else '其他' end city,
|
|
count(*) num
|
|
FROM `dc_sdhs_event`
|
|
<where>
|
|
<if test="type != null and type == '0'.toString">
|
|
and DATE_FORMAT(start_time,'%Y') = #{lastTime}
|
|
</if>
|
|
<if test="type != null and type == '1'.toString">
|
|
and DATE_FORMAT(start_time,'%Y-%m') = #{lastTime}
|
|
</if>
|
|
<if test="type != null and type == '2'.toString">
|
|
and DATE_FORMAT(start_time,'%Y-%m-%d') = #{lastTime}
|
|
</if>
|
|
</where>
|
|
GROUP BY city order by mileage asc) t3
|
|
on t1.city = t3.city
|
|
|
|
</select>
|
|
<select id="selectStationAnalysis" resultType="com.zc.business.domain.DcSdhsEvent">
|
|
SELECT * FROM `dc_sdhs_event`
|
|
<where>
|
|
event_type = '交通管制' and (event_subclass = '收费站封闭' or event_subclass = '收费站限行')
|
|
<if test="type != null and type == '0'.toString">
|
|
and DATE_FORMAT(start_time,'%Y') = #{time}
|
|
</if>
|
|
<if test="type != null and type == '1'.toString">
|
|
and DATE_FORMAT(start_time,'%Y-%m') = #{time}
|
|
</if>
|
|
<if test="type != null and type == '2'.toString">
|
|
and DATE_FORMAT(start_time,'%Y-%m-%d') = #{time}
|
|
</if>
|
|
</where>
|
|
|
|
</select>
|
|
<select id="selectAccidentType" resultType="java.util.Map">
|
|
SELECT t1.event_subclass eventSubclass,IFNULL(t2.num,0) as #{thisTime},IFNULL(t3.num,0) as #{lastTime}
|
|
from
|
|
(select '追尾' event_subclass
|
|
union all select '撞护栏' event_subclass
|
|
union all select '自燃' event_subclass
|
|
union all select '侧翻' event_subclass
|
|
union all select '货物洒落' event_subclass
|
|
union all select '撞障碍物' event_subclass) t1
|
|
LEFT JOIN
|
|
(SELECT
|
|
event_subclass,count(*) num
|
|
FROM `dc_sdhs_event`
|
|
<where>
|
|
event_type = '交通事故'
|
|
<if test="type != null and type == '0'.toString">
|
|
and DATE_FORMAT(start_time,'%Y') = #{thisTime}
|
|
</if>
|
|
<if test="type != null and type == '1'.toString">
|
|
and DATE_FORMAT(start_time,'%Y-%m') = #{thisTime}
|
|
</if>
|
|
<if test="type != null and type == '2'.toString">
|
|
and DATE_FORMAT(start_time,'%Y-%m-%d') = #{thisTime}
|
|
</if>
|
|
</where>
|
|
group by event_subclass) t2
|
|
on t1.event_subclass = t2.event_subclass
|
|
LEFT JOIN
|
|
(SELECT
|
|
event_subclass,count(*) num
|
|
FROM `dc_sdhs_event`
|
|
<where>
|
|
event_type = '交通事故'
|
|
<if test="type != null and type == '0'.toString">
|
|
and DATE_FORMAT(start_time,'%Y') = #{lastTime}
|
|
</if>
|
|
<if test="type != null and type == '1'.toString">
|
|
and DATE_FORMAT(start_time,'%Y-%m') = #{lastTime}
|
|
</if>
|
|
<if test="type != null and type == '2'.toString">
|
|
and DATE_FORMAT(start_time,'%Y-%m-%d') = #{lastTime}
|
|
</if>
|
|
</where>
|
|
group by event_subclass) t3
|
|
on t1.event_subclass = t3.event_subclass
|
|
</select>
|
|
<select id="accidentSectionAnalysis" resultType="java.util.HashMap">
|
|
SELECT stake_mark stakeMark FROM `dc_sdhs_event`
|
|
<where>
|
|
event_type = '交通事故'
|
|
<if test="type != null and type == '0'.toString">
|
|
and DATE_FORMAT(start_time,'%Y') = #{thisTime}
|
|
</if>
|
|
<if test="type != null and type == '1'.toString">
|
|
and DATE_FORMAT(start_time,'%Y-%m') = #{thisTime}
|
|
</if>
|
|
<if test="type != null and type == '2'.toString">
|
|
and DATE_FORMAT(start_time,'%Y-%m-%d') = #{thisTime}
|
|
</if>
|
|
</where>
|
|
</select>
|
|
<select id="sectionAnalysis" resultType="java.util.HashMap">
|
|
SELECT stake_mark stakeMark FROM `dc_sdhs_event`
|
|
<where>
|
|
<if test="type != null and type == '0'.toString">
|
|
and DATE_FORMAT(start_time,'%Y') = #{thisTime}
|
|
</if>
|
|
<if test="type != null and type == '1'.toString">
|
|
and DATE_FORMAT(start_time,'%Y-%m') = #{thisTime}
|
|
</if>
|
|
<if test="type != null and type == '2'.toString">
|
|
and DATE_FORMAT(start_time,'%Y-%m-%d') = #{thisTime}
|
|
</if>
|
|
</where>
|
|
</select>
|
|
<select id="accidentTypeAnalysis" resultType="java.util.HashMap">
|
|
SELECT e.event_type AS eventType,
|
|
IFNULL(t1.num, 0) as #{thisTime},
|
|
IFNULL(t2.num, 0) as #{lastTime}
|
|
FROM `dc_sdhs_event` e
|
|
LEFT JOIN (SELECT event_type,
|
|
COUNT(*) AS num FROM
|
|
`dc_sdhs_event`
|
|
<where>
|
|
<if test="type != null and type == '0'.toString">
|
|
and DATE_FORMAT(start_time,'%Y') = #{thisTime}
|
|
</if>
|
|
<if test="type != null and type == '1'.toString">
|
|
and DATE_FORMAT(start_time,'%Y-%m') = #{thisTime}
|
|
</if>
|
|
<if test="type != null and type == '2'.toString">
|
|
and DATE_FORMAT(start_time,'%Y-%m-%d') = #{thisTime}
|
|
</if>
|
|
</where>
|
|
GROUP BY event_type ) t1 ON e.event_type = t1.event_type
|
|
LEFT JOIN (SELECT
|
|
event_type, COUNT(*) AS num
|
|
FROM `dc_sdhs_event`
|
|
<where>
|
|
<if test="type != null and type == '0'.toString">
|
|
and DATE_FORMAT(start_time,'%Y') = #{lastTime}
|
|
</if>
|
|
<if test="type != null and type == '1'.toString">
|
|
and DATE_FORMAT(start_time,'%Y-%m') = #{lastTime}
|
|
</if>
|
|
<if test="type != null and type == '2'.toString">
|
|
and DATE_FORMAT(start_time,'%Y-%m-%d') = #{lastTime}
|
|
</if>
|
|
</where>
|
|
GROUP BY event_type ) t2 ON e.event_type = t2.event_type
|
|
GROUP BY e.event_type;
|
|
</select>
|
|
<select id="accidentCongestedTime" resultType="com.zc.business.domain.DcSdhsEvent">
|
|
SELECT stake_mark stakeMark,start_time startTime,end_time endTime,event_type eventType FROM `dc_sdhs_event`
|
|
<where>
|
|
event_type='交通拥堵'
|
|
<if test="type != null and type == '0'.toString">
|
|
and DATE_FORMAT(start_time,'%Y') = #{thisTime}
|
|
</if>
|
|
<if test="type != null and type == '1'.toString">
|
|
and DATE_FORMAT(start_time,'%Y-%m') = #{thisTime}
|
|
</if>
|
|
<if test="type != null and type == '2'.toString">
|
|
and DATE_FORMAT(start_time,'%Y-%m-%d') = #{thisTime}
|
|
</if>
|
|
</where>
|
|
</select>
|
|
|
|
<select id="accidentCongestedLocation" resultType="java.util.HashMap">
|
|
SELECT
|
|
e.event_subclass AS eventSubclass,
|
|
IFNULL(t1.num, 0) as #{thisTime},
|
|
IFNULL(t2.num, 0) as #{lastTime}
|
|
FROM `dc_sdhs_event` e
|
|
LEFT JOIN (SELECT event_subclass, COUNT(*) AS num
|
|
FROM `dc_sdhs_event`
|
|
<where>
|
|
<if test="type != null and type == '0'.toString">
|
|
and DATE_FORMAT(start_time,'%Y') = #{thisTime}
|
|
</if>
|
|
<if test="type != null and type == '1'.toString">
|
|
and DATE_FORMAT(start_time,'%Y-%m') = #{thisTime}
|
|
</if>
|
|
<if test="type != null and type == '2'.toString">
|
|
and DATE_FORMAT(start_time,'%Y-%m-%d') = #{thisTime}
|
|
</if>
|
|
</where>
|
|
GROUP BY event_subclass ) t1 ON e.event_subclass = t1.event_subclass
|
|
LEFT JOIN
|
|
(SELECT event_subclass, COUNT(*) AS num
|
|
FROM `dc_sdhs_event`
|
|
<where>
|
|
<if test="type != null and type == '0'.toString">
|
|
and DATE_FORMAT(start_time,'%Y') = #{lastTime}
|
|
</if>
|
|
<if test="type != null and type == '1'.toString">
|
|
and DATE_FORMAT(start_time,'%Y-%m') = #{lastTime}
|
|
</if>
|
|
<if test="type != null and type == '2'.toString">
|
|
and DATE_FORMAT(start_time,'%Y-%m-%d') = #{lastTime}
|
|
</if>
|
|
</where>
|
|
GROUP BY event_subclass
|
|
) t2 ON e.event_subclass = t2.event_subclass
|
|
where e .event_type='交通拥堵'
|
|
GROUP BY e.event_subclass;
|
|
</select>
|
|
<select id="getDataCalendar" resultType="java.lang.String">
|
|
SELECT DATE_FORMAT(start_time,'%Y-%m-%d') dateTime
|
|
FROM `dc_sdhs_event`
|
|
where DATE_FORMAT(start_time,'%Y-%m') = #{month}
|
|
GROUP BY dateTime
|
|
</select>
|
|
|
|
<insert id="insertDcSdhsEvent" parameterType="DcSdhsEvent" useGeneratedKeys="true" keyProperty="id">
|
|
insert into dc_sdhs_event
|
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
|
<if test="road != null">road,</if>
|
|
<if test="dept != null">dept,</if>
|
|
<if test="eventType != null">event_type,</if>
|
|
<if test="startTime != null">start_time,</if>
|
|
<if test="endTime != null">end_time,</if>
|
|
<if test="status != null">status,</if>
|
|
<if test="source != null">source,</if>
|
|
<if test="title != null">title,</if>
|
|
<if test="eventSubclass != null">event_subclass,</if>
|
|
<if test="carType != null">car_type,</if>
|
|
<if test="carNum != null">car_num,</if>
|
|
<if test="multiVehicle != null">multi_vehicle,</if>
|
|
<if test="direction != null">direction,</if>
|
|
<if test="stakeMark != null">stake_mark,</if>
|
|
<if test="weather != null">weather,</if>
|
|
</trim>
|
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
|
<if test="road != null">#{road},</if>
|
|
<if test="dept != null">#{dept},</if>
|
|
<if test="eventType != null">#{eventType},</if>
|
|
<if test="startTime != null">#{startTime},</if>
|
|
<if test="endTime != null">#{endTime},</if>
|
|
<if test="status != null">#{status},</if>
|
|
<if test="source != null">#{source},</if>
|
|
<if test="title != null">#{title},</if>
|
|
<if test="eventSubclass != null">#{eventSubclass},</if>
|
|
<if test="carType != null">#{carType},</if>
|
|
<if test="carNum != null">#{carNum},</if>
|
|
<if test="multiVehicle != null">#{multiVehicle},</if>
|
|
<if test="direction != null">#{direction},</if>
|
|
<if test="stakeMark != null">#{stakeMark},</if>
|
|
<if test="weather != null">#{weather},</if>
|
|
</trim>
|
|
</insert>
|
|
|
|
<insert id="batchInsert">
|
|
insert into dc_sdhs_event(road,dept,event_type,start_time,end_time,status,source,title,event_subclass,car_type,car_num,multi_vehicle,direction,stake_mark,weather,mileage) values
|
|
<foreach item="item" index="index" collection="list" separator=",">
|
|
(#{item.road},#{item.dept},#{item.eventType},#{item.startTime},#{item.endTime},#{item.status},#{item.source},#{item.title},#{item.eventSubclass},#{item.carType},#{item.carNum},#{item.multiVehicle},#{item.direction},#{item.stakeMark},#{item.weather},#{item.mileage})
|
|
</foreach>
|
|
</insert>
|
|
|
|
<update id="updateDcSdhsEvent" parameterType="DcSdhsEvent">
|
|
update dc_sdhs_event
|
|
<trim prefix="SET" suffixOverrides=",">
|
|
<if test="road != null">road = #{road},</if>
|
|
<if test="dept != null">dept = #{dept},</if>
|
|
<if test="eventType != null">event_type = #{eventType},</if>
|
|
<if test="startTime != null">start_time = #{startTime},</if>
|
|
<if test="endTime != null">end_time = #{endTime},</if>
|
|
<if test="status != null">status = #{status},</if>
|
|
<if test="source != null">source = #{source},</if>
|
|
<if test="title != null">title = #{title},</if>
|
|
<if test="eventSubclass != null">event_subclass = #{eventSubclass},</if>
|
|
<if test="carType != null">car_type = #{carType},</if>
|
|
<if test="carNum != null">car_num = #{carNum},</if>
|
|
<if test="multiVehicle != null">multi_vehicle = #{multiVehicle},</if>
|
|
<if test="direction != null">direction = #{direction},</if>
|
|
<if test="stakeMark != null">stake_mark = #{stakeMark},</if>
|
|
<if test="weather != null">weather = #{weather},</if>
|
|
</trim>
|
|
where id = #{id}
|
|
</update>
|
|
|
|
<delete id="deleteDcSdhsEventById" parameterType="Long">
|
|
delete from dc_sdhs_event where id = #{id}
|
|
</delete>
|
|
|
|
<delete id="deleteDcSdhsEventByIds" parameterType="String">
|
|
delete from dc_sdhs_event where id in
|
|
<foreach item="id" collection="array" open="(" separator="," close=")">
|
|
#{id}
|
|
</foreach>
|
|
</delete>
|
|
<delete id="deleteByTimeRange">
|
|
delete from dc_sdhs_event
|
|
where start_time >= #{startTime} and start_time <= #{endTime}
|
|
</delete>
|
|
|
|
<delete id="deleteDcSdhsEvent">
|
|
delete from dc_sdhs_event where id in
|
|
<foreach collection="eventList" item="item" index="index"
|
|
separator="," open="(" close=")">
|
|
#{item.id}
|
|
</foreach>
|
|
</delete>
|
|
|
|
<select id="selectAccidentModelAnalysis" resultType="com.zc.business.domain.DcSdhsEvent">
|
|
SELECT * FROM `dc_sdhs_event`
|
|
<where>
|
|
event_type = '交通事故'
|
|
<if test="type != null and type == '0'.toString">
|
|
and DATE_FORMAT(start_time,'%Y') = #{time}
|
|
</if>
|
|
<if test="type != null and type == '1'.toString">
|
|
and DATE_FORMAT(start_time,'%Y-%m') = #{time}
|
|
</if>
|
|
<if test="type != null and type == '2'.toString">
|
|
and DATE_FORMAT(start_time,'%Y-%m-%d') = #{time}
|
|
</if>
|
|
</where>
|
|
|
|
</select>
|
|
|
|
<select id="selectEventModelAnalysis" resultType="com.zc.business.domain.DcSdhsEvent">
|
|
SELECT * FROM `dc_sdhs_event`
|
|
<where>
|
|
<if test="type != null and type == '0'.toString">
|
|
and DATE_FORMAT(start_time,'%Y') = #{time}
|
|
</if>
|
|
<if test="type != null and type == '1'.toString">
|
|
and DATE_FORMAT(start_time,'%Y-%m') = #{time}
|
|
</if>
|
|
<if test="type != null and type == '2'.toString">
|
|
and DATE_FORMAT(start_time,'%Y-%m-%d') = #{time}
|
|
</if>
|
|
</where>
|
|
|
|
</select>
|
|
</mapper>
|
|
|