|
|
@ -119,7 +119,7 @@ |
|
|
|
order by warning.warning_time desc |
|
|
|
</select> |
|
|
|
<select id="selectSectionPerceivedEventsList" resultType="hashmap"> |
|
|
|
SELECT s.section_name AS sectionName, COALESCE(w_count.number, 0) AS number2 |
|
|
|
SELECT s.section_name AS sectionName, COALESCE(w_count.number, 0) AS number |
|
|
|
FROM dc_road_section AS s |
|
|
|
LEFT JOIN ( SELECT mark.section_id, COUNT(1) AS number FROM dc_warning AS w JOIN |
|
|
|
dc_stake_mark AS mark ON mark.stake_mark = w.stake_mark AND mark.direction = w.direction |
|
|
@ -542,5 +542,141 @@ |
|
|
|
<!-- HAVING sectionNumber!=0--> |
|
|
|
<!-- </select>--> |
|
|
|
|
|
|
|
|
|
|
|
<select id="newSelectSectionDay" resultType="java.util.HashMap"> |
|
|
|
SELECT |
|
|
|
DATE_FORMAT(#{currently} + INTERVAL a.a HOUR, '%Y-%m-%d %H') AS time, |
|
|
|
IFNULL(SUM(CASE WHEN dw.warning_source != 6 AND |
|
|
|
CAST(SUBSTRING(SUBSTRING_INDEX(dw.stake_mark,'+',1),2)AS UNSIGNED)*1000 |
|
|
|
+ CAST(SUBSTRING_INDEX(dw.stake_mark, '+', -1) AS UNSIGNED)>#{startStakeMark} AND |
|
|
|
CAST(SUBSTRING(SUBSTRING_INDEX(dw.stake_mark,'+',1),2)AS UNSIGNED)*1000 |
|
|
|
+ CAST(SUBSTRING_INDEX(dw.stake_mark, '+', -1) AS UNSIGNED)<#{endStakeMark} |
|
|
|
THEN 1 ELSE 0 END), 0) AS number |
|
|
|
FROM ( |
|
|
|
SELECT 0 AS a |
|
|
|
UNION ALL SELECT 1 UNION ALL SELECT 2 UNION ALL SELECT 3 |
|
|
|
UNION ALL SELECT 4 UNION ALL SELECT 5 UNION ALL SELECT 6 |
|
|
|
UNION ALL SELECT 7 UNION ALL SELECT 8 UNION ALL SELECT 9 |
|
|
|
UNION ALL SELECT 10 UNION ALL SELECT 11 UNION ALL SELECT 12 |
|
|
|
UNION ALL SELECT 13 UNION ALL SELECT 14 UNION ALL SELECT 15 |
|
|
|
UNION ALL SELECT 16 UNION ALL SELECT 17 UNION ALL SELECT 18 |
|
|
|
UNION ALL SELECT 19 UNION ALL SELECT 20 UNION ALL SELECT 21 |
|
|
|
UNION ALL SELECT 22 UNION ALL SELECT 23 |
|
|
|
) AS a |
|
|
|
LEFT JOIN dc_warning dw ON DATE_FORMAT(dw.warning_time, '%Y-%m-%d %H') |
|
|
|
= DATE_FORMAT(#{currently} + INTERVAL a.a HOUR, '%Y-%m-%d %H') and dw.warning_source!=6 |
|
|
|
and dw.direction=#{direction} |
|
|
|
GROUP BY time |
|
|
|
ORDER BY time; |
|
|
|
</select> |
|
|
|
<select id="newSelectSectionMonth" resultType="java.util.HashMap"> |
|
|
|
SELECT |
|
|
|
h.hour_num AS time, |
|
|
|
COUNT(dw.warning_time) AS number |
|
|
|
FROM ( |
|
|
|
SELECT 0 AS hour_num UNION ALL |
|
|
|
SELECT 1 UNION ALL SELECT 2 UNION ALL SELECT 3 |
|
|
|
UNION ALL SELECT 4 UNION ALL SELECT 5 UNION ALL SELECT 6 |
|
|
|
UNION ALL SELECT 7 UNION ALL SELECT 8 UNION ALL SELECT 9 |
|
|
|
UNION ALL SELECT 10 UNION ALL SELECT 11 UNION ALL SELECT 12 |
|
|
|
UNION ALL SELECT 13 UNION ALL SELECT 14 UNION ALL SELECT 15 |
|
|
|
UNION ALL SELECT 16 UNION ALL SELECT 17 UNION ALL SELECT 18 |
|
|
|
UNION ALL SELECT 19 UNION ALL SELECT 20 UNION ALL SELECT 21 |
|
|
|
UNION ALL SELECT 22 UNION ALL SELECT 23 |
|
|
|
) h |
|
|
|
LEFT JOIN dc_warning dw ON HOUR(dw.warning_time) = h.hour_num |
|
|
|
AND DATE_FORMAT(dw.warning_time, '%Y-%m') = DATE_FORMAT(#{currently}, '%Y-%m') |
|
|
|
AND dw.warning_source != 6 |
|
|
|
AND ( |
|
|
|
CAST(SUBSTRING(SUBSTRING_INDEX(dw.stake_mark, '+', 1), 2) AS UNSIGNED) * 1000 + |
|
|
|
CAST(SUBSTRING_INDEX(dw.stake_mark, '+', -1) AS UNSIGNED) >= #{startStakeMark} AND |
|
|
|
CAST(SUBSTRING(SUBSTRING_INDEX(dw.stake_mark, '+', 1), 2) AS UNSIGNED) * 1000 + |
|
|
|
CAST(SUBSTRING_INDEX(dw.stake_mark, '+', -1) AS UNSIGNED) <#{endStakeMark} |
|
|
|
) and dw.direction=#{direction} |
|
|
|
GROUP BY h.hour_num |
|
|
|
ORDER BY h.hour_num; |
|
|
|
</select> |
|
|
|
<select id="newSelectSectionYear" resultType="java.util.HashMap"> |
|
|
|
SELECT |
|
|
|
h.hour_num AS time, |
|
|
|
COUNT(dw.warning_time) AS number |
|
|
|
FROM ( |
|
|
|
SELECT 0 AS hour_num UNION ALL |
|
|
|
SELECT 1 UNION ALL SELECT 2 UNION ALL SELECT 3 |
|
|
|
UNION ALL SELECT 4 UNION ALL SELECT 5 UNION ALL SELECT 6 |
|
|
|
UNION ALL SELECT 7 UNION ALL SELECT 8 UNION ALL SELECT 9 |
|
|
|
UNION ALL SELECT 10 UNION ALL SELECT 11 UNION ALL SELECT 12 |
|
|
|
UNION ALL SELECT 13 UNION ALL SELECT 14 UNION ALL SELECT 15 |
|
|
|
UNION ALL SELECT 16 UNION ALL SELECT 17 UNION ALL SELECT 18 |
|
|
|
UNION ALL SELECT 19 UNION ALL SELECT 20 UNION ALL SELECT 21 |
|
|
|
UNION ALL SELECT 22 UNION ALL SELECT 23 |
|
|
|
) h |
|
|
|
LEFT JOIN dc_warning dw ON HOUR(dw.warning_time) = h.hour_num |
|
|
|
AND YEAR(dw.warning_time) = YEAR(#{currently}) |
|
|
|
AND dw.warning_source != 6 |
|
|
|
AND ( |
|
|
|
CAST(SUBSTRING(SUBSTRING_INDEX(dw.stake_mark, '+', 1), 2) AS UNSIGNED) * 1000 + |
|
|
|
CAST(SUBSTRING_INDEX(dw.stake_mark, '+', -1) AS UNSIGNED) >= #{startStakeMark} AND |
|
|
|
CAST(SUBSTRING(SUBSTRING_INDEX(dw.stake_mark, '+', 1), 2) AS UNSIGNED) * 1000 + |
|
|
|
CAST(SUBSTRING_INDEX(dw.stake_mark, '+', -1) AS UNSIGNED)<#{endStakeMark} |
|
|
|
) and dw.direction=#{direction} |
|
|
|
GROUP BY h.hour_num |
|
|
|
ORDER BY h.hour_num; |
|
|
|
</select> |
|
|
|
<select id="newSelectWarningType" resultType="java.util.HashMap"> |
|
|
|
SELECT warning.warning_type warningType, |
|
|
|
COUNT(*) AS number |
|
|
|
FROM dc_warning as warning |
|
|
|
where |
|
|
|
<if test = 'type == "day"' > DATE_FORMAT(warning.warning_time,'%Y-%m-%d')=DATE_FORMAT(#{currently},'%Y-%m-%d')</if> |
|
|
|
<if test = 'type == "month"' > DATE_FORMAT(warning_time,'%Y-%m') =DATE_FORMAT(#{currently},'%Y-%m')</if> |
|
|
|
<if test = 'type == "year"' > YEAR(warning_time) =DATE_FORMAT(#{currently},'%Y')</if> |
|
|
|
AND warning.direction=#{direction} and warning.warning_source!=6 |
|
|
|
AND ( |
|
|
|
CAST(SUBSTRING(SUBSTRING_INDEX(warning.stake_mark, '+', 1), 2) AS UNSIGNED) * 1000 + |
|
|
|
CAST(SUBSTRING_INDEX(warning.stake_mark, '+', -1) AS UNSIGNED)>= #{startStakeMark} AND |
|
|
|
CAST(SUBSTRING(SUBSTRING_INDEX(warning.stake_mark, '+', 1), 2) AS UNSIGNED) * 1000 + |
|
|
|
CAST(SUBSTRING_INDEX(warning.stake_mark, '+', -1) AS UNSIGNED)<#{endStakeMark} |
|
|
|
) |
|
|
|
GROUP BY warning_type |
|
|
|
ORDER BY number DESC |
|
|
|
</select> |
|
|
|
<select id="newSelectSection" resultType="java.util.HashMap"> |
|
|
|
SELECT warning.stake_mark stakeMark, |
|
|
|
COUNT(*) AS number |
|
|
|
FROM dc_warning as warning |
|
|
|
where |
|
|
|
<if test = 'type == "day"' > DATE_FORMAT(warning.warning_time,'%Y-%m-%d')=DATE_FORMAT(#{currently},'%Y-%m-%d')</if> |
|
|
|
<if test = 'type == "month"' > DATE_FORMAT(warning_time,'%Y-%m') =DATE_FORMAT(#{currently},'%Y-%m')</if> |
|
|
|
<if test = 'type == "year"' > YEAR(warning_time) =DATE_FORMAT(#{currently},'%Y')</if> |
|
|
|
AND warning.direction=#{direction} and warning.warning_source!=6 |
|
|
|
AND ( |
|
|
|
CAST(SUBSTRING(SUBSTRING_INDEX(warning.stake_mark, '+', 1), 2) AS UNSIGNED) * 1000 + |
|
|
|
CAST(SUBSTRING_INDEX(warning.stake_mark, '+', -1) AS UNSIGNED) >= #{startStakeMark} AND |
|
|
|
CAST(SUBSTRING(SUBSTRING_INDEX(warning.stake_mark, '+', 1), 2) AS UNSIGNED) * 1000 + |
|
|
|
CAST(SUBSTRING_INDEX(warning.stake_mark, '+', -1) AS UNSIGNED)<#{endStakeMark} |
|
|
|
) |
|
|
|
GROUP BY stakeMark |
|
|
|
ORDER BY number DESC |
|
|
|
</select> |
|
|
|
<select id="newSelectStateType" resultType="java.util.HashMap"> |
|
|
|
SELECT s.section_name sectionName, w.warning_state AS warningState, COUNT(*) AS num |
|
|
|
FROM dc_warning AS w |
|
|
|
LEFT JOIN dc_stake_mark AS sm ON w.stake_mark = sm.stake_mark and w.direction=sm.direction |
|
|
|
LEFT JOIN dc_road_section AS s ON sm.section_id = s.id |
|
|
|
WHERE w.warning_source != 6 AND DATE_FORMAT(w.warning_time, '%Y-%m-%d') = DATE_FORMAT(#{currently}, '%Y-%m-%d') |
|
|
|
GROUP BY w.warning_state,sectionName |
|
|
|
ORDER BY sectionName |
|
|
|
</select> |
|
|
|
<select id="newStateDuration" resultType="java.util.HashMap"> |
|
|
|
SELECT s.section_name sectionName, s.id sectionId, |
|
|
|
ROUND(AVG(TIMESTAMPDIFF(MINUTE, w.warning_time, w.end_time)), 2) AS avg |
|
|
|
FROM dc_warning AS w |
|
|
|
LEFT JOIN |
|
|
|
dc_stake_mark AS sm ON w.stake_mark = sm.stake_mark AND w.direction = sm.direction |
|
|
|
LEFT JOIN |
|
|
|
dc_road_section AS s ON sm.section_id = s.id |
|
|
|
WHERE w.warning_source != 6 |
|
|
|
AND DATE_FORMAT(w.warning_time, '%Y-%m-%d') = DATE_FORMAT(#{currently}, '%Y-%m-%d') |
|
|
|
GROUP BY s.section_name; |
|
|
|
</select> |
|
|
|
</mapper> |
|
|
|