Commit 28ad6ef9 authored by 黄伟铭's avatar 黄伟铭

新增干线早晚高峰分析

parent a2d6a89b
...@@ -50,4 +50,13 @@ public enum GreenBeltDirEnum { ...@@ -50,4 +50,13 @@ public enum GreenBeltDirEnum {
} }
return ""; return "";
} }
public static String getCode(Integer dir) {
for (GreenBeltDirEnum value : GreenBeltDirEnum.values()) {
if (Objects.equals(dir, value.getInDir())) {
return value.getCode();
}
}
return "";
}
} }
...@@ -2,6 +2,7 @@ package net.wanji.opt.dao.mapper.judgeanalysis; ...@@ -2,6 +2,7 @@ package net.wanji.opt.dao.mapper.judgeanalysis;
import net.wanji.opt.controllerv2.report.vo.AnalysisGreenCongestionPeriodVO; import net.wanji.opt.controllerv2.report.vo.AnalysisGreenCongestionPeriodVO;
import net.wanji.opt.entity.judgeanalysis.AnalysisGreenCongestionPeriod; import net.wanji.opt.entity.judgeanalysis.AnalysisGreenCongestionPeriod;
import net.wanji.opt.entity.judgeanalysis.laneDataHist;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import java.util.List; import java.util.List;
...@@ -10,6 +11,10 @@ import java.util.Map; ...@@ -10,6 +11,10 @@ import java.util.Map;
public interface AnalysisGreenCongestionPeriodMapper { public interface AnalysisGreenCongestionPeriodMapper {
List<AnalysisGreenCongestionPeriod> selectGreenDataHist(@Param("date") String date); List<AnalysisGreenCongestionPeriod> selectGreenDataHist(@Param("date") String date);
void insertGreenCongestionPeriodData(Map<String, Object> map); void insertGreenCongestionPeriodData(Map<String, Object> map);
List<laneDataHist> selectGreenTrafficHist(@Param("date") String date);
List<laneDataHist> selectGreenTrafficThreshold(@Param("date") String date,@Param("greenId") String greenId,@Param("roadDirection") String roadDirection);
List<laneDataHist> selectCrossFlow(@Param("date") String date,@Param("crossId") String crossId,@Param("startTime") String startTime,@Param("endTime") String endTime);
void insertLaneDataHist(Map<String, Object> map);
List<AnalysisGreenCongestionPeriodVO> selectListByWeek(@Param("yearWeek") Integer yearWeek); List<AnalysisGreenCongestionPeriodVO> selectListByWeek(@Param("yearWeek") Integer yearWeek);
} }
package net.wanji.opt.entity.judgeanalysis;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
@ApiModel(value = "laneDataHist", description = "")
public class laneDataHist {
@ApiModelProperty(value = "干线ID")
private String greenId;
@ApiModelProperty(value = "车道ID")
private String id;
@ApiModelProperty(value = "路口ID")
private String crossId;
@ApiModelProperty(value = "交通指数阈值")
private Double trafficThreshold;
@ApiModelProperty(value = "交通指数")
private Double trafficIndex;
@ApiModelProperty(value = "方向")
private String dir;
@ApiModelProperty(value = "转向")
private String turn;
@ApiModelProperty(value = "开始时间")
private String startTime;
@ApiModelProperty(value = "流量")
private Integer flow;
@ApiModelProperty(value = "小时流量")
private Integer flowHour;
@ApiModelProperty(value = "干线道路方向")
private String roadDirection;
}
...@@ -9,6 +9,17 @@ ...@@ -9,6 +9,17 @@
<result column="status" property="status"/> <result column="status" property="status"/>
</resultMap> </resultMap>
<resultMap id="AnalysisLaneDataHistMap" type="net.wanji.opt.entity.judgeanalysis.laneDataHist">
<result column="green_id" property="greenId"/>
<result column="road_direction" property="roadDirection"/>
<result column="start_time" property="startTime"/>
<result column="cross_id" property="crossId"/>
<result column="dir" property="dir"/>
<result column="turn" property="turn"/>
<result column="traffic_index" property="trafficIndex"/>
<result column="flow" property="flow"/>
</resultMap>
<select id="selectGreenDataHist" parameterType="String" resultMap="AnalysisGreenCongestionPeriodMap"> <select id="selectGreenDataHist" parameterType="String" resultMap="AnalysisGreenCongestionPeriodMap">
SELECT a.green_id,a.road_direction,a.start_time,a.status FROM t_greenwave_hist a SELECT a.green_id,a.road_direction,a.start_time,a.status FROM t_greenwave_hist a
where a.start_time between DATE_FORMAT(#{date},'%Y-%m-%d 00:00:00') and DATE_FORMAT(#{date},'%Y-%m-%d 23:59:59') where a.start_time between DATE_FORMAT(#{date},'%Y-%m-%d 00:00:00') and DATE_FORMAT(#{date},'%Y-%m-%d 23:59:59')
...@@ -31,4 +42,50 @@ ...@@ -31,4 +42,50 @@
and a.road_direction = #{roadDirection} and a.road_direction = #{roadDirection}
</insert> </insert>
<select id="selectGreenTrafficHist" parameterType="String" resultMap="AnalysisLaneDataHistMap">
select t.green_id,t1.key_cross_id as cross_id, t1.road_direction,t1.dir,t1.turn,t.start_time,t.traffic_index
from t_greenwave_hist t
left join t_greenwave_key_cross_lane t1 on t.green_id = t1.green_id and t.road_direction = t1.road_direction
where t.start_time BETWEEN DATE_FORMAT(#{date},'%Y-%m-%d 00:00:00') and DATE_FORMAT(#{date},'%Y-%m-%d 23:59:59')
and t1.dir is not null
order by t.green_id,t1.road_direction,t1.dir,t1.turn,t.start_time
</select>
<select id="selectGreenTrafficThreshold" parameterType="String" resultMap="AnalysisLaneDataHistMap">
select t.green_id,t.traffic_index
from t_greenwave_hist t
where t.start_time BETWEEN DATE_FORMAT(#{date},'%Y-%m-%d 09:00:00') and DATE_FORMAT(#{date},'%Y-%m-%d 16:30:10')
and t.green_id = #{greenId}
and t.road_direction = #{roadDirection}
order by t.traffic_index desc
</select>
<select id="selectCrossFlow" parameterType="String" resultMap="AnalysisLaneDataHistMap">
select t4.cross_id,t4.start_time,sum(t4.flow) as flow from
(select t2.id , t3.key_cross_id as cross_id , t2.start_time , t2.flow from t_lane_data_hist t2
left join
(select t.id , t1.key_cross_id from t_base_lane_info t
left join t_greenwave_key_cross_lane t1 on t1.key_cross_id = t.cross_id and t1.dir = t.dir
where t1.key_cross_id is not null and t.type = 2) t3 on t2.id = t3.id
where t3.key_cross_id is not null and dt = #{date} ) t4
where t4.cross_id = #{crossId}
and t4.start_time between DATE_FORMAT(DATE_SUB(#{startTime},INTERVAL 10 MINUTE),'%Y-%m-%d %H:%i:00') and DATE_FORMAT(#{endTime},'%Y-%m-%d %H:%i:%s')
group by t4.cross_id,t4.start_time
</select>
<insert id="insertLaneDataHist" parameterType="map">
insert into t_analysis_green_wave_peak_detail (green_id,road_direction,week_day,peak_start_time,peak_end_time,
traffic_index,travel_time,speed,flow,max_flow,peak_type,year_week,week_start_time,week_end_time,insert_time,traffic_threshold )
select a.green_id,a.road_direction,#{weekDay} as week_day,DATE_FORMAT(#{startTime},'%Y-%m-%d %H:%i:%s') as peak_start_time,
DATE_FORMAT(#{endTime},'%Y-%m-%d %H:%i:%s') as peak_end_time, AVG(traffic_index),CEIL(AVG(trval_time)),AVG(speed),
#{avgFlow} as flow,#{maxFlow} as max_flow,#{peakType} as peak_type,#{weekNumber} as year_week,DATE_FORMAT(#{weekStartTime},'%Y-%m-%d') as week_start_time,
DATE_FORMAT(#{weekEndTime},'%Y-%m-%d') as week_end_time,now(),#{trafficThreshold} as traffic_threshold
from t_greenwave_hist a
where DATE_FORMAT(a.start_time,'%Y-%m-%d %H:%i:00') between DATE_FORMAT(#{startTime},'%Y-%m-%d %H:%i:%s') and DATE_FORMAT(DATE_SUB(#{endTime},INTERVAL 5 MINUTE),'%Y-%m-%d %H:%i:%s')
and a.green_id = #{greenId}
and a.road_direction = #{roadDirection}
</insert>
</mapper> </mapper>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment