Browse Source

优化感知统计和分析

develop
wangsixiang 4 months ago
parent
commit
28ce1b2fbf
  1. 30
      zc-business/src/main/java/com/zc/business/service/impl/DcPerceivedEventsWarningServiceImpl.java
  2. 54
      zc-business/src/main/resources/mapper/business/DcPerceivedEventsWarningMapper.xml

30
zc-business/src/main/java/com/zc/business/service/impl/DcPerceivedEventsWarningServiceImpl.java

@ -327,24 +327,17 @@ public class DcPerceivedEventsWarningServiceImpl implements IDCPerceivedEventsWa
switch (type){ switch (type){
case "day": case "day":
hashMap.put("currentlyMap", perceivedEventsWarningMapper.newSelectSectionDay(dcWarning)); hashMap.put("currentlyMap", perceivedEventsWarningMapper.newSelectSectionDay(dcWarning));
break; dcWarning.setCurrently(dcWarning.getLastYear());
case "month":
hashMap.put("currentlyMap", perceivedEventsWarningMapper.newSelectSectionMonth(dcWarning));
break;
case "year":
hashMap.put("currentlyMap", perceivedEventsWarningMapper.newSelectSectionYear(dcWarning));
break;
}
dcWarning.setCurrently(dcWarning.getLastYear());//把传入的去年的时间参数,转为当下时间作为查询参数(因为mapper中的查询提交参数是当下时间)
switch (type) {
case "day":
hashMap.put("lastYearMap", perceivedEventsWarningMapper.newSelectSectionDay(dcWarning)); hashMap.put("lastYearMap", perceivedEventsWarningMapper.newSelectSectionDay(dcWarning));
break; break;
case "month": case "month":
hashMap.put("currentlyMap", perceivedEventsWarningMapper.newSelectSectionMonth(dcWarning));
dcWarning.setCurrently(dcWarning.getLastYear());
hashMap.put("lastYearMap", perceivedEventsWarningMapper.newSelectSectionMonth(dcWarning)); hashMap.put("lastYearMap", perceivedEventsWarningMapper.newSelectSectionMonth(dcWarning));
break; break;
case "year": case "year":
hashMap.put("currentlyMap", perceivedEventsWarningMapper.newSelectSectionYear(dcWarning));
dcWarning.setCurrently(dcWarning.getLastYear());
hashMap.put("lastYearMap", perceivedEventsWarningMapper.newSelectSectionYear(dcWarning)); hashMap.put("lastYearMap", perceivedEventsWarningMapper.newSelectSectionYear(dcWarning));
break; break;
} }
@ -368,10 +361,15 @@ public class DcPerceivedEventsWarningServiceImpl implements IDCPerceivedEventsWa
@Override @Override
public HashMap<String, Object> newSelectSection(DcWarning dcWarning) { public HashMap<String, Object> newSelectSection(DcWarning dcWarning) {
HashMap<String, Object> hashMap = new HashMap<>(); HashMap<String, Object> hashMap = new HashMap<>();
String startStakeMark = StakeMarkUtils.formatMetre(dcWarning.getStartStakeMark()); if (StringUtils.isNotEmpty(dcWarning.getStartStakeMark())){
dcWarning.setStartStakeMark(startStakeMark); String startStakeMark = StakeMarkUtils.formatMetre(dcWarning.getStartStakeMark());
String endStakeMark = StakeMarkUtils.formatMetre(dcWarning.getEndStakeMark()); dcWarning.setStartStakeMark(startStakeMark);
dcWarning.setEndStakeMark(endStakeMark); }
if (StringUtils.isNotEmpty(dcWarning.getEndStakeMark())){
String endStakeMark = StakeMarkUtils.formatMetre(dcWarning.getEndStakeMark());
dcWarning.setEndStakeMark(endStakeMark);
}
hashMap.put("currentlyMap", selectSectionUtils(dcWarning)); hashMap.put("currentlyMap", selectSectionUtils(dcWarning));
dcWarning.setCurrently(dcWarning.getLastYear());//时间参数转换,把去年的时间替换为查询时间参数 dcWarning.setCurrently(dcWarning.getLastYear());//时间参数转换,把去年的时间替换为查询时间参数
hashMap.put("lastYearMap", selectSectionUtils(dcWarning)); hashMap.put("lastYearMap", selectSectionUtils(dcWarning));

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

@ -28,15 +28,13 @@
where warning.`id`=#{id} where warning.`id`=#{id}
</select> </select>
<select id="selectPerceivedEventsList" resultType="com.zc.business.domain.DcWarning"> <select id="selectPerceivedEventsList" resultType="com.zc.business.domain.DcWarning">
SELECT facility.facility_name, warning.`id`,warning.`stake_mark`, warning.`direction`, SELECT warning.`id`,warning.`stake_mark`, warning.`direction`,
mark.longitude,mark.latitude,warning.lane,duration, warning.lane,duration,
warning.`dept_id`,warning.`warning_state`,warning.`warning_time`, warning.`dept_id`,warning.`warning_state`,warning.`warning_time`,
warning.`user_id`, warning.`warning_source`,warning.`warning_level`, warning.`user_id`, warning.`warning_source`,warning.`warning_level`,
warning.`remark`, warning.`create_time`,warning.`update_time`, warning.`remark`, warning.`create_time`,warning.`update_time`,
warning.`warning_type`,warning.`warning_subclass`,warning.`warning_title`, warning.`warning_type`,warning.`warning_subclass`,warning.`warning_title`,
warning.`other_config` FROM dc_warning AS warning warning.`other_config` FROM dc_warning AS warning
left JOIN dc_stake_mark AS mark ON mark.stake_mark=warning.stake_mark and mark.direction=warning.direction
left join dc_facility as facility on facility.stake_mark=warning.stake_mark and facility.facility_type=1
<where> <where>
<if test="warningSource == null || warningSource == ''"> and warning.warning_source !=6</if> <if test="warningSource == null || warningSource == ''"> and warning.warning_source !=6</if>
<if test="warningSource != null and warningSource != ''"> and warning.warning_source = #{warningSource}</if> <if test="warningSource != null and warningSource != ''"> and warning.warning_source = #{warningSource}</if>
@ -587,9 +585,12 @@
UNION ALL SELECT 19 UNION ALL SELECT 20 UNION ALL SELECT 21 UNION ALL SELECT 19 UNION ALL SELECT 20 UNION ALL SELECT 21
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 dw.warning_time >= DATE_ADD(#{currently}, INTERVAL a.a HOUR)
= DATE_FORMAT(#{currently} + INTERVAL a.a HOUR, '%Y-%m-%d %H') and dw.warning_source!=6 AND dw.warning_time &lt; DATE_ADD(#{currently}, INTERVAL a.a + 1 HOUR)
and dw.warning_source!=6
and dw.direction=#{direction} and dw.direction=#{direction}
where dw.warning_time >= #{currently}
AND dw.warning_time &lt; DATE_ADD( #{currently}, INTERVAL 1 DAY)
GROUP BY time GROUP BY time
ORDER BY time; ORDER BY time;
</select> </select>
@ -598,8 +599,7 @@
h.hour_num AS time, h.hour_num AS time,
COUNT(dw.warning_time) AS number COUNT(dw.warning_time) AS number
FROM ( FROM (
SELECT 0 AS hour_num UNION ALL SELECT 0 AS hour_num UNION ALL SELECT 1 UNION ALL SELECT 2 UNION ALL SELECT 3
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 4 UNION ALL SELECT 5 UNION ALL SELECT 6
UNION ALL SELECT 7 UNION ALL SELECT 8 UNION ALL SELECT 9 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 10 UNION ALL SELECT 11 UNION ALL SELECT 12
@ -608,15 +608,16 @@
UNION ALL SELECT 19 UNION ALL SELECT 20 UNION ALL SELECT 21 UNION ALL SELECT 19 UNION ALL SELECT 20 UNION ALL SELECT 21
UNION ALL SELECT 22 UNION ALL SELECT 23 UNION ALL SELECT 22 UNION ALL SELECT 23
) h ) h
LEFT JOIN dc_warning dw ON HOUR(dw.warning_time) = h.hour_num INNER JOIN dc_warning dw
AND DATE_FORMAT(dw.warning_time, '%Y-%m') = DATE_FORMAT(#{currently}, '%Y-%m') ON HOUR(dw.warning_time) = h.hour_num
AND dw.warning_time >= DATE_FORMAT(#{currently}, '%Y-%m-01 00:00:00')
AND dw.warning_time &lt; DATE_FORMAT(DATE_ADD(#{currently}, INTERVAL 1 MONTH), '%Y-%m-01')
AND dw.warning_source != 6 AND dw.warning_source != 6
AND ( AND (
CAST(SUBSTRING(SUBSTRING_INDEX(dw.stake_mark, '+', 1), 2) AS UNSIGNED) * 1000 + 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_INDEX(dw.stake_mark, '+', -1) AS UNSIGNED) BETWEEN #{startStakeMark} AND #{endStakeMark} - 1
CAST(SUBSTRING(SUBSTRING_INDEX(dw.stake_mark, '+', 1), 2) AS UNSIGNED) * 1000 + )
CAST(SUBSTRING_INDEX(dw.stake_mark, '+', -1) AS UNSIGNED) &lt;#{endStakeMark} AND dw.direction = #{direction}
) and dw.direction=#{direction}
GROUP BY h.hour_num GROUP BY h.hour_num
ORDER BY h.hour_num; ORDER BY h.hour_num;
</select> </select>
@ -652,8 +653,9 @@
COUNT(*) AS number COUNT(*) AS number
FROM dc_warning as warning FROM dc_warning as warning
where where
<if test = 'type == "day"' > DATE_FORMAT(warning.warning_time,'%Y-%m-%d')=DATE_FORMAT(#{currently},'%Y-%m-%d')</if> <if test = 'type == "day"' > warning_time >= #{currently} AND warning_time &lt; #{currently} + INTERVAL 1 DAY</if>
<if test = 'type == "month"' > DATE_FORMAT(warning_time,'%Y-%m') =DATE_FORMAT(#{currently},'%Y-%m')</if> <if test = 'type == "month"' > warning.warning_time >= #{currently}
AND warning.warning_time &lt; DATE_ADD( #{currently}, INTERVAL 1 month)</if>
<if test = 'type == "year"' > YEAR(warning_time) =DATE_FORMAT(#{currently},'%Y')</if> <if test = 'type == "year"' > YEAR(warning_time) =DATE_FORMAT(#{currently},'%Y')</if>
AND warning.direction=#{direction} and warning.warning_source!=6 AND warning.direction=#{direction} and warning.warning_source!=6
AND ( AND (
@ -670,15 +672,16 @@
COUNT(*) AS number COUNT(*) AS number
FROM dc_warning as warning FROM dc_warning as warning
where where
<if test = 'type == "day"' > DATE_FORMAT(warning.warning_time,'%Y-%m-%d')=DATE_FORMAT(#{currently},'%Y-%m-%d')</if> <if test = 'type == "day"' > warning_time >= #{currently} AND warning_time &lt; #{currently} + INTERVAL 1 DAY</if>
<if test = 'type == "month"' > DATE_FORMAT(warning_time,'%Y-%m') =DATE_FORMAT(#{currently},'%Y-%m')</if> <if test = 'type == "month"' > warning.warning_time >= #{currently}
AND warning.warning_time &lt; DATE_ADD( #{currently}, INTERVAL 1 month)</if>
<if test = 'type == "year"' > YEAR(warning_time) =DATE_FORMAT(#{currently},'%Y')</if> <if test = 'type == "year"' > YEAR(warning_time) =DATE_FORMAT(#{currently},'%Y')</if>
AND warning.direction=#{direction} and warning.warning_source!=6 AND warning.direction=#{direction} and warning.warning_source!=6
AND ( AND (
CAST(SUBSTRING(SUBSTRING_INDEX(warning.stake_mark, '+', 1), 2) AS UNSIGNED) * 1000 + 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_INDEX(warning.stake_mark, '+', -1) AS UNSIGNED)&gt;#{startStakeMark} AND
CAST(SUBSTRING(SUBSTRING_INDEX(warning.stake_mark, '+', 1), 2) AS UNSIGNED) * 1000 + CAST(SUBSTRING(SUBSTRING_INDEX(warning.stake_mark,'+',1),2)AS UNSIGNED)*1000
CAST(SUBSTRING_INDEX(warning.stake_mark, '+', -1) AS UNSIGNED)&lt;#{endStakeMark} +CAST(SUBSTRING_INDEX(warning.stake_mark, '+', -1) AS UNSIGNED)&lt;#{endStakeMark}
) )
GROUP BY stakeMark GROUP BY stakeMark
ORDER BY number DESC ORDER BY number DESC
@ -688,8 +691,8 @@
FROM dc_warning AS w 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_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 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') WHERE w.warning_source != 6 AND DATE(w.warning_time) = DATE(#{currently})
GROUP BY w.warning_state,sectionName GROUP BY w.warning_state,s.section_name
ORDER BY s.start_stake_mark ORDER BY s.start_stake_mark
</select> </select>
<select id="newStateDuration" resultType="java.util.HashMap"> <select id="newStateDuration" resultType="java.util.HashMap">
@ -701,7 +704,8 @@
LEFT JOIN LEFT JOIN
dc_road_section AS s ON sm.section_id = s.id dc_road_section AS s ON sm.section_id = s.id
WHERE w.warning_source != 6 WHERE w.warning_source != 6
AND DATE_FORMAT(w.warning_time, '%Y-%m-%d') = DATE_FORMAT(#{currently}, '%Y-%m-%d') AND w.warning_time >= #{currently}
AND w.warning_time &lt; DATE_ADD(#{currently}, INTERVAL 1 DAY)
GROUP BY s.section_name; GROUP BY s.section_name;
</select> </select>
</mapper> </mapper>

Loading…
Cancel
Save