Browse Source

去除非机预警

develop
wangsixiang 8 months ago
parent
commit
068e71a670
  1. 41
      zc-business/src/main/resources/mapper/business/DcPerceivedEventsWarningMapper.xml

41
zc-business/src/main/resources/mapper/business/DcPerceivedEventsWarningMapper.xml

@ -100,7 +100,8 @@
FROM dc_road_section AS s FROM dc_road_section AS s
LEFT JOIN ( SELECT mark.section_id, COUNT(1) AS number FROM dc_warning AS w JOIN 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 dc_stake_mark AS mark ON mark.stake_mark = w.stake_mark AND mark.direction = w.direction
WHERE mark.stake_mark IS NOT NULL AND DATE_FORMAT(w.warning_time, '%Y-%m-%d') = DATE_FORMAT(#{warningTime}, '%Y-%m-%d') WHERE mark.stake_mark IS NOT NULL AND DATE_FORMAT(w.warning_time, '%Y-%m-%d') = DATE_FORMAT(#{warningTime}, '%Y-%m-%d')
and w.warning_source!=6
GROUP BY mark.section_id ) AS w_count ON s.id = w_count.section_id GROUP BY mark.section_id ) AS w_count ON s.id = w_count.section_id
</select> </select>
<select id="selectDailyCumulative" resultType="java.util.HashMap"> <select id="selectDailyCumulative" resultType="java.util.HashMap">
@ -119,7 +120,7 @@
UNION ALL SELECT 22 UNION ALL SELECT 23 UNION ALL SELECT 22 UNION ALL SELECT 23
) AS a ) AS a
LEFT JOIN dc_warning dw ON DATE_FORMAT(dw.warning_time, '%Y-%m-%d %H') LEFT JOIN dc_warning dw ON DATE_FORMAT(dw.warning_time, '%Y-%m-%d %H')
= DATE_FORMAT(CURDATE() + INTERVAL a.a HOUR, '%Y-%m-%d %H') = DATE_FORMAT(CURDATE() + INTERVAL a.a HOUR, '%Y-%m-%d %H') and dw.warning_source!=6
GROUP BY time GROUP BY time
ORDER BY time; ORDER BY time;
</select> </select>
@ -127,18 +128,18 @@
SELECT HOUR(warning_time) AS time, COUNT(*) AS number SELECT HOUR(warning_time) AS time, COUNT(*) AS number
FROM dc_warning FROM dc_warning
WHERE MONTH(warning_time) = MONTH(CURDATE()) WHERE MONTH(warning_time) = MONTH(CURDATE())
AND YEAR(warning_time) = YEAR(CURDATE()) AND YEAR(warning_time) = YEAR(CURDATE()) and warning_source!=6
GROUP BY HOUR(warning_time) GROUP BY HOUR(warning_time)
ORDER BY HOUR(warning_time); ORDER BY HOUR(warning_time);
</select> </select>
<select id="selectWarningSourceGroup" resultType="java.util.HashMap"> <select id="selectWarningSourceGroup" resultType="java.util.HashMap">
SELECT warning_source warningSource,COUNT(*) AS number FROM dc_warning SELECT warning_source warningSource,COUNT(*) AS number FROM dc_warning
where DATE_FORMAT(warning_time,'%Y-%m-%d')=DATE_FORMAT(#{warningTime},'%Y-%m-%d') where DATE_FORMAT(warning_time,'%Y-%m-%d')=DATE_FORMAT(#{warningTime},'%Y-%m-%d') and warning_source!=6
GROUP BY warning_source GROUP BY warning_source
</select> </select>
<select id="selectWarningSourceGroupCount" resultType="java.lang.String"> <select id="selectWarningSourceGroupCount" resultType="java.lang.String">
SELECT COUNT(*) AS number FROM dc_warning SELECT COUNT(*) AS number FROM dc_warning
where DATE_FORMAT(warning_time,'%Y-%m-%d')=DATE_FORMAT(#{warningTime},'%Y-%m-%d') where DATE_FORMAT(warning_time,'%Y-%m-%d')=DATE_FORMAT(#{warningTime},'%Y-%m-%d') and warning_source!=6
</select> </select>
<select id="selectWarningStateDay" resultType="java.util.HashMap"> <select id="selectWarningStateDay" resultType="java.util.HashMap">
select t1.warningState,t1.warningStateName,IFNULL(t2.num,0)number from select t1.warningState,t1.warningStateName,IFNULL(t2.num,0)number from
@ -149,12 +150,13 @@
LEFT JOIN LEFT JOIN
(SELECT warning_state warningState,count(*) num (SELECT warning_state warningState,count(*) num
from dc_warning from dc_warning
where DATE_FORMAT(warning_time,'%Y-%m-%d')=DATE_FORMAT(now(),'%Y-%m-%d') where warning_source!=6 and DATE_FORMAT(warning_time,'%Y-%m-%d')=DATE_FORMAT(now(),'%Y-%m-%d')
GROUP BY warning_state)t2 GROUP BY warning_state)t2
on t1.warningState=t2.warningState on t1.warningState=t2.warningState
</select> </select>
<select id="selectWarningTypeDay" resultType="java.util.HashMap"> <select id="selectWarningTypeDay" resultType="java.util.HashMap">
SELECT warning_type warningType,COUNT(*) AS number FROM dc_warning SELECT warning_type warningType,COUNT(*) AS number FROM dc_warning
where warning_source!=6
GROUP BY warning_type GROUP BY warning_type
ORDER BY number DESC ORDER BY number DESC
</select> </select>
@ -169,7 +171,7 @@
) t1 ) t1
left join left join
(select HOUR(warning_time) hours,count(*) num from dc_warning t1 (select HOUR(warning_time) hours,count(*) num from dc_warning t1
left join dc_stake_mark t2 on t1.stake_mark = t2.stake_mark left join dc_stake_mark t2 on t1.stake_mark = t2.stake_mark and t1.warning_source!=6
and t1.direction = t2.direction where date_format(warning_time,'%Y-%m-%d') = date_format(#{warningTime},'%Y-%m-%d') and t1.direction = t2.direction where date_format(warning_time,'%Y-%m-%d') = date_format(#{warningTime},'%Y-%m-%d')
and t2.section_id = #{sectionId} and t2.section_id = #{sectionId}
and t1.direction=#{direction} and t2.direction=#{direction} and t1.direction=#{direction} and t2.direction=#{direction}
@ -182,7 +184,7 @@
LEFT JOIN dc_stake_mark AS mark ON warning.stake_mark=mark.stake_mark LEFT JOIN dc_stake_mark AS mark ON warning.stake_mark=mark.stake_mark
WHERE DATE_FORMAT(warning.warning_time,'%Y-%m') =DATE_FORMAT(#{warningTime},'%Y-%m') WHERE DATE_FORMAT(warning.warning_time,'%Y-%m') =DATE_FORMAT(#{warningTime},'%Y-%m')
AND warning.direction=#{direction} and mark.direction=#{direction} AND warning.direction=#{direction} and mark.direction=#{direction}
and mark.`section_id`=#{sectionId} and mark.`section_id`=#{sectionId} and warning.warning_source!=6
GROUP BY day GROUP BY day
ORDER BY day ORDER BY day
</select> </select>
@ -194,7 +196,7 @@
LEFT JOIN dc_stake_mark AS mark ON warning.stake_mark=mark.stake_mark LEFT JOIN dc_stake_mark AS mark ON warning.stake_mark=mark.stake_mark
WHERE QUARTER(warning.warning_time)=#{quarter} WHERE QUARTER(warning.warning_time)=#{quarter}
AND warning.direction=#{direction} and mark.direction=#{direction} AND warning.direction=#{direction} and mark.direction=#{direction}
and mark.`section_id`=#{sectionId} and mark.`section_id`=#{sectionId} and warning.warning_source!=6
GROUP BY MONTH GROUP BY MONTH
ORDER BY MONTH; ORDER BY MONTH;
@ -209,7 +211,7 @@
(select month(warning_time) hours,count(*) num from dc_warning t1 (select month(warning_time) hours,count(*) num from dc_warning t1
left join dc_stake_mark t2 on t1.stake_mark = t2.stake_mark and t1.direction = t2.direction where left join dc_stake_mark t2 on t1.stake_mark = t2.stake_mark and t1.direction = t2.direction where
DATE_FORMAT(t1.warning_time,'%Y')=DATE_FORMAT(#{warningTime},'%Y') and t2.section_id =#{sectionId} DATE_FORMAT(t1.warning_time,'%Y')=DATE_FORMAT(#{warningTime},'%Y') and t2.section_id =#{sectionId}
and t1.direction=#{direction} and t2.direction=#{direction} GROUP BY hours) t2 and t1.direction=#{direction} and t1.warning_source!=6 and t2.direction=#{direction} GROUP BY hours) t2
on t1.n = t2.hours on t1.n = t2.hours
</select> </select>
<select id="selectWarningSectionTypeDayCount" resultType="java.lang.String"> <select id="selectWarningSectionTypeDayCount" resultType="java.lang.String">
@ -217,7 +219,7 @@
LEFT JOIN dc_stake_mark as mark on warning.stake_mark=mark.stake_mark LEFT JOIN dc_stake_mark as mark on warning.stake_mark=mark.stake_mark
where DATE_FORMAT(warning.warning_time,'%Y-%m-%d')=DATE_FORMAT(#{warningTime},'%Y-%m-%d') where DATE_FORMAT(warning.warning_time,'%Y-%m-%d')=DATE_FORMAT(#{warningTime},'%Y-%m-%d')
AND warning.direction=#{direction} and mark.direction=#{direction} AND warning.direction=#{direction} and mark.direction=#{direction}
and mark.`section_id`=#{sectionId} and mark.`section_id`=#{sectionId} and warning.warning_source!=6
</select> </select>
<select id="selectWarningSectionTypeDay" resultType="java.util.HashMap"> <select id="selectWarningSectionTypeDay" resultType="java.util.HashMap">
SELECT warning.warning_type warningType, SELECT warning.warning_type warningType,
@ -226,7 +228,7 @@
LEFT JOIN dc_stake_mark as mark on warning.stake_mark=mark.stake_mark LEFT JOIN dc_stake_mark as mark on warning.stake_mark=mark.stake_mark
where DATE_FORMAT(warning.warning_time,'%Y-%m-%d')=DATE_FORMAT(#{warningTime},'%Y-%m-%d') where DATE_FORMAT(warning.warning_time,'%Y-%m-%d')=DATE_FORMAT(#{warningTime},'%Y-%m-%d')
AND warning.direction=#{direction} and mark.direction=#{direction} AND warning.direction=#{direction} and mark.direction=#{direction}
and mark.`section_id`=#{sectionId} and mark.`section_id`=#{sectionId} and warning.warning_source!=6
GROUP BY warning_type GROUP BY warning_type
ORDER BY number DESC ORDER BY number DESC
</select> </select>
@ -235,7 +237,7 @@
LEFT JOIN dc_stake_mark as mark on warning.stake_mark=mark.stake_mark LEFT JOIN dc_stake_mark as mark on warning.stake_mark=mark.stake_mark
where DATE_FORMAT(warning.warning_time,'%Y-%m') =DATE_FORMAT(#{warningTime},'%Y-%m') where DATE_FORMAT(warning.warning_time,'%Y-%m') =DATE_FORMAT(#{warningTime},'%Y-%m')
AND warning.direction=#{direction} and mark.direction=#{direction} AND warning.direction=#{direction} and mark.direction=#{direction}
and mark.`section_id`=#{sectionId} and mark.`section_id`=#{sectionId} and warning.warning_source!=6
</select> </select>
<select id="selectWarningSectionTypeMonth" resultType="java.util.HashMap"> <select id="selectWarningSectionTypeMonth" resultType="java.util.HashMap">
SELECT warning.warning_type warningType,COUNT(*) AS number SELECT warning.warning_type warningType,COUNT(*) AS number
@ -243,7 +245,7 @@
LEFT JOIN dc_stake_mark as mark on warning.stake_mark=mark.stake_mark LEFT JOIN dc_stake_mark as mark on warning.stake_mark=mark.stake_mark
where DATE_FORMAT(warning.warning_time,'%Y-%m') =DATE_FORMAT(#{warningTime},'%Y-%m') where DATE_FORMAT(warning.warning_time,'%Y-%m') =DATE_FORMAT(#{warningTime},'%Y-%m')
AND warning.direction=#{direction} and mark.direction=#{direction} AND warning.direction=#{direction} and mark.direction=#{direction}
and mark.`section_id`=#{sectionId} and mark.`section_id`=#{sectionId} and warning.warning_source!=6
GROUP BY warning_type GROUP BY warning_type
ORDER BY number DESC ORDER BY number DESC
</select> </select>
@ -254,7 +256,7 @@
LEFT JOIN dc_stake_mark AS mark ON warning.stake_mark=mark.stake_mark LEFT JOIN dc_stake_mark AS mark ON warning.stake_mark=mark.stake_mark
WHERE QUARTER(warning.warning_time)=#{quarter} WHERE QUARTER(warning.warning_time)=#{quarter}
AND warning.direction=#{direction} and mark.direction=#{direction} AND warning.direction=#{direction} and mark.direction=#{direction}
and mark.`section_id`=#{sectionId} and mark.`section_id`=#{sectionId} and warning.warning_source!=6
</select> </select>
<select id="selectWarningSectionTypeQuarter" resultType="java.util.HashMap"> <select id="selectWarningSectionTypeQuarter" resultType="java.util.HashMap">
SELECT SELECT
@ -264,7 +266,7 @@
LEFT JOIN dc_stake_mark AS mark ON warning.stake_mark=mark.stake_mark LEFT JOIN dc_stake_mark AS mark ON warning.stake_mark=mark.stake_mark
WHERE QUARTER(warning.warning_time)=#{quarter} WHERE QUARTER(warning.warning_time)=#{quarter}
AND warning.direction=#{direction} and mark.direction=#{direction} AND warning.direction=#{direction} and mark.direction=#{direction}
and mark.`section_id`=#{sectionId} and mark.`section_id`=#{sectionId} and warning.warning_source!=6
GROUP BY warningType GROUP BY warningType
</select> </select>
@ -273,7 +275,7 @@
LEFT JOIN dc_stake_mark AS mark ON warning.stake_mark=mark.stake_mark LEFT JOIN dc_stake_mark AS mark ON warning.stake_mark=mark.stake_mark
where mark.`section_id`=#{sectionId} AND warning.direction=#{direction} and mark.direction=#{direction} where mark.`section_id`=#{sectionId} AND warning.direction=#{direction} and mark.direction=#{direction}
and DATE_FORMAT(warning.warning_time,'%Y')=DATE_FORMAT(#{warningTime},'%Y') and DATE_FORMAT(warning.warning_time,'%Y')=DATE_FORMAT(#{warningTime},'%Y')
and warning.warning_source!=6
</select> </select>
<select id="selectWarningSectionTypeYear" resultType="java.util.HashMap"> <select id="selectWarningSectionTypeYear" resultType="java.util.HashMap">
SELECT warning.warning_type warningType, COUNT(*) AS number SELECT warning.warning_type warningType, COUNT(*) AS number
@ -281,6 +283,7 @@
LEFT JOIN dc_stake_mark AS mark ON warning.stake_mark=mark.stake_mark LEFT JOIN dc_stake_mark AS mark ON warning.stake_mark=mark.stake_mark
where mark.`section_id`=#{sectionId} AND warning.direction=#{direction} and mark.direction=#{direction} where mark.`section_id`=#{sectionId} AND warning.direction=#{direction} and mark.direction=#{direction}
and DATE_FORMAT(warning.warning_time,'%Y')=DATE_FORMAT(#{warningTime},'%Y') and DATE_FORMAT(warning.warning_time,'%Y')=DATE_FORMAT(#{warningTime},'%Y')
and warning.warning_source!=6
GROUP BY warningType GROUP BY warningType
</select> </select>
@ -356,7 +359,7 @@
<select id="selectWarningMarkQuarterOptimize" resultType="java.util.HashMap"> <select id="selectWarningMarkQuarterOptimize" resultType="java.util.HashMap">
SELECT DISTINCT m.stake_mark AS stakeMarkId,COALESCE(wc.count, 0) AS sectionNumber SELECT DISTINCT m.stake_mark AS stakeMarkId,COALESCE(wc.count, 0) AS sectionNumber
FROM dc_stake_mark AS m LEFT JOIN ( SELECT stake_mark, COUNT(0) AS count FROM dc_warning WHERE FROM dc_stake_mark AS m LEFT JOIN ( SELECT stake_mark, COUNT(0) AS count FROM dc_warning WHERE
QUARTER(warning_time) =#{quarter} AND direction = #{direction} GROUP BY stake_mark ) AS wc QUARTER(warning_time) =#{quarter} AND direction = #{direction} and warning_source!=6 GROUP BY stake_mark ) AS wc
ON m.stake_mark = wc.stake_mark WHERE m.section_id = #{sectionId} ON m.stake_mark = wc.stake_mark WHERE m.section_id = #{sectionId}
</select> </select>
<select id="selectWarningMarkDayOptimize" resultType="java.util.HashMap"> <select id="selectWarningMarkDayOptimize" resultType="java.util.HashMap">
@ -366,7 +369,7 @@
<if test = 'type == "day"' > DATE(warning_time)= DATE_FORMAT(#{warningTime},'%Y-%m-%d')</if> <if test = 'type == "day"' > DATE(warning_time)= DATE_FORMAT(#{warningTime},'%Y-%m-%d')</if>
<if test = 'type == "month"' > DATE_FORMAT(warning_time,'%Y-%m') =DATE_FORMAT(#{warningTime},'%Y-%m')</if> <if test = 'type == "month"' > DATE_FORMAT(warning_time,'%Y-%m') =DATE_FORMAT(#{warningTime},'%Y-%m')</if>
<if test = 'type == "year"' > YEAR(warning_time) =DATE_FORMAT(#{warningTime},'%Y')</if> <if test = 'type == "year"' > YEAR(warning_time) =DATE_FORMAT(#{warningTime},'%Y')</if>
AND direction = #{direction} GROUP BY stake_mark ) AS wc ON m.stake_mark = wc.stake_mark AND direction = #{direction} and warning_source!=6 GROUP BY stake_mark ) AS wc ON m.stake_mark = wc.stake_mark
WHERE m.section_id = #{sectionId} WHERE m.section_id = #{sectionId}
</select> </select>

Loading…
Cancel
Save