|
|
@ -107,9 +107,31 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" |
|
|
|
|
|
|
|
<select id="selectSpeed" resultType="com.zc.business.domain.DcTrafficSpeedData"> |
|
|
|
select *, |
|
|
|
round((t1.inAndSmallAverageVehicleSpeed + t1.averageSpeedOfBus + t1.smallTrucksAverageVehicleSpeed + |
|
|
|
t1.averageSpeedOfMediumSizeTrucks + t1.averageSpeedOfLargeTrucks + t1.averageSpeedOfExtraLargeTrucks + |
|
|
|
t1.averageSpeedOfContainerTruck + t1.averageSpeedOfMotorcycle + t1.averageSpeedOfTractor) / 9, 0) avgSpeed |
|
|
|
ROUND( |
|
|
|
( |
|
|
|
t1.inAndSmallAverageVehicleSpeed + |
|
|
|
t1.averageSpeedOfBus + |
|
|
|
t1.smallTrucksAverageVehicleSpeed + |
|
|
|
t1.averageSpeedOfMediumSizeTrucks + |
|
|
|
t1.averageSpeedOfLargeTrucks + |
|
|
|
t1.averageSpeedOfExtraLargeTrucks + |
|
|
|
t1.averageSpeedOfContainerTruck + |
|
|
|
t1.averageSpeedOfMotorcycle + |
|
|
|
t1.averageSpeedOfTractor |
|
|
|
) / |
|
|
|
NULLIF( |
|
|
|
CASE WHEN t1.inAndSmallAverageVehicleSpeed = 0 THEN 0 ELSE 1 END + |
|
|
|
CASE WHEN t1.averageSpeedOfBus = 0 THEN 0 ELSE 1 END + |
|
|
|
CASE WHEN t1.smallTrucksAverageVehicleSpeed = 0 THEN 0 ELSE 1 END + |
|
|
|
CASE WHEN t1.averageSpeedOfMediumSizeTrucks = 0 THEN 0 ELSE 1 END + |
|
|
|
CASE WHEN t1.averageSpeedOfLargeTrucks = 0 THEN 0 ELSE 1 END + |
|
|
|
CASE WHEN t1.averageSpeedOfExtraLargeTrucks = 0 THEN 0 ELSE 1 END + |
|
|
|
CASE WHEN t1.averageSpeedOfContainerTruck = 0 THEN 0 ELSE 1 END + |
|
|
|
CASE WHEN t1.averageSpeedOfMotorcycle = 0 THEN 0 ELSE 1 END + |
|
|
|
CASE WHEN t1.averageSpeedOfTractor = 0 THEN 0 ELSE 1 END, |
|
|
|
0 |
|
|
|
) |
|
|
|
,0) AS avgSpeed |
|
|
|
from |
|
|
|
(select direction, |
|
|
|
<choose> |
|
|
@ -123,15 +145,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" |
|
|
|
date_format(`timestamp`, '%Y-%m') |
|
|
|
</when> |
|
|
|
</choose> time, |
|
|
|
round(avg(in_and_small_average_vehicle_speed),0) inAndSmallAverageVehicleSpeed, |
|
|
|
round(avg(average_speed_of_bus),0) averageSpeedOfBus, |
|
|
|
round(avg(small_trucks_average_vehicle_speed),0) smallTrucksAverageVehicleSpeed, |
|
|
|
round(avg(average_speed_of_medium_size_trucks),0) averageSpeedOfMediumSizeTrucks, |
|
|
|
round(avg(average_speed_of_large_trucks),0) averageSpeedOfLargeTrucks, |
|
|
|
round(avg(average_speed_of_extra_large_trucks),0) averageSpeedOfExtraLargeTrucks, |
|
|
|
round(avg(average_speed_of_container_truck),0) averageSpeedOfContainerTruck, |
|
|
|
round(avg(average_speed_of_motorcycle),0) averageSpeedOfMotorcycle, |
|
|
|
round(avg(average_speed_of_tractor),0) averageSpeedOfTractor |
|
|
|
ROUND(IFNULL(AVG(NULLIF(in_and_small_average_vehicle_speed, 0)),0), 0) AS inAndSmallAverageVehicleSpeed, |
|
|
|
ROUND(IFNULL(AVG(NULLIF(average_speed_of_bus, 0)),0), 0) AS averageSpeedOfBus, |
|
|
|
ROUND(IFNULL(AVG(NULLIF(small_trucks_average_vehicle_speed, 0)),0), 0) AS smallTrucksAverageVehicleSpeed, |
|
|
|
ROUND(IFNULL(AVG(NULLIF(average_speed_of_medium_size_trucks, 0)),0), 0) AS averageSpeedOfMediumSizeTrucks, |
|
|
|
ROUND(IFNULL(AVG(NULLIF(average_speed_of_large_trucks, 0)),0), 0) AS averageSpeedOfLargeTrucks, |
|
|
|
ROUND(IFNULL(AVG(NULLIF(average_speed_of_extra_large_trucks, 0)),0), 0) AS averageSpeedOfExtraLargeTrucks, |
|
|
|
ROUND(IFNULL(AVG(NULLIF(average_speed_of_container_truck, 0)),0), 0) AS averageSpeedOfContainerTruck, |
|
|
|
ROUND(IFNULL(AVG(NULLIF(average_speed_of_motorcycle, 0)),0), 0) AS averageSpeedOfMotorcycle, |
|
|
|
ROUND(IFNULL(AVG(NULLIF(average_speed_of_tractor, 0)),0), 0) AS averageSpeedOfTractor |
|
|
|
FROM `dc_traffic_survey_data` |
|
|
|
<where> |
|
|
|
<if test="iotDeviceId != null and iotDeviceId != ''"> |
|
|
|