Commit 489e3f6f authored by fengyasheng's avatar fengyasheng

交通分析报告-周总体拥堵概况-拥堵次数计算修改,注释掉启动时运行

parent cb2d36ed
......@@ -36,6 +36,26 @@ public class GreenWaveCrossRidController {
@ApiOperation(httpMethod="GET",value="干线拥堵信息", notes="")
@ApiImplicitParams({
@ApiImplicitParam(name = "ids", value = "干线ID,多个id用','分隔", required = true, dataType = "String",defaultValue = "1,2"),
@ApiImplicitParam(name = "dayType", value = "高峰类型 1早高峰 2晚高峰 3全天", required = true, dataType = "String",defaultValue = "1"),
})
@GetMapping(value = "/getGreenWeekDataList")
public JsonViewObject getGreenWeekDataList(@RequestParam(value = "ids", required = false, defaultValue = "2") String ids,
@RequestParam(value = "type", required = false, defaultValue = "2") String type
) {
JsonViewObject jsonViewObject = JsonViewObject.newInstance();
try {
JSONObject object = greenWaveCrossRidService.getGreenInfoList(ids);
jsonViewObject.success(object);
} catch (Exception e) {
jsonViewObject.fail(I18nResourceBundle.getConstants("GET_FAILED_MSG"));
log.error("{} getAll error", this.getClass().getSimpleName(), e);
}
return jsonViewObject;
}
@ApiOperation(httpMethod="GET",value="干线基础信息", notes="")
@ApiImplicitParams({
@ApiImplicitParam(name = "ids", value = "干线ID,多个id用','分隔", required = true, dataType = "String",defaultValue = "1,2"),
......
package net.wanji.opt.dao.mapper.report;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import net.wanji.databus.dao.entity.GreenwaveHistPO;
import net.wanji.opt.entity.report.ConfigPeakHours;
import net.wanji.opt.entity.report.GreenWaveWeekData;
import net.wanji.opt.servicev2.report.GreenWaveWeekDataService;
......@@ -22,5 +23,7 @@ public interface GreenWaveWeekDataMapper extends BaseMapper<GreenWaveWeekData> {
Integer getFlowByTime(@Param("greenId") Integer greenId,@Param("dir") Integer dir,@Param("startDate") String startDate,@Param("endDate") String endDate,@Param("startTime") String startTime,@Param("endTime") String endTime);
void insertOrUpdateBatch(@Param("list") List<GreenWaveWeekData> greenWaveWeekDataList);
List<GreenwaveHistPO> selectAllByTime(@Param("greenId") Integer greenId,@Param("roadDirection") String roadDirection,@Param("startDate") String startDate,@Param("endDate") String endDate,@Param("startTime") String startTime,@Param("endTime") String endTime);
// MyBatis-Plus 提供了基本的 CRUD 方法,这里无需额外定义
}
\ No newline at end of file
......@@ -29,7 +29,10 @@ public class GreenWaveWeekData {
private Integer congestCount; // 拥堵次数
@ApiModelProperty(value = "拥堵总时长,单位秒")
private Double congestDuration; // 拥堵总时长,单位秒
private Double congestDuration;
@ApiModelProperty(value = "最大拥堵持续时长,单位秒")
private Double maxCongestDuration;
@ApiModelProperty(value = "总流量")
private Integer flow; // 总流量
......@@ -40,11 +43,17 @@ public class GreenWaveWeekData {
@ApiModelProperty(value = "平均速度")
private Double speed; // 平均速度
@ApiModelProperty(value = "高峰类型 1早高峰 2晚高峰 3全天")
private String peakType;
@ApiModelProperty(value = "类型:1工作日 2节假日")
private String peakType; // 类型:1工作日 2节假日
private String dayType;
@ApiModelProperty(value = "高峰类型 1早高峰 2晚高峰 3全天")
private String dayType; // 高峰类型 1早高峰 2晚高峰 3全天
@ApiModelProperty(value = "最大拥堵时段")
private String maxCongestionPeriod;
@ApiModelProperty(value = "第二大拥堵时段")
private String secondCongestionPeriod;
@ApiModelProperty(value = "数据统计范围的开始时间")
private String startTime; // 数据统计范围的开始时间
......
......@@ -21,7 +21,7 @@ public class GreenWaveWeekDataTask implements ApplicationRunner {
log.info("服务启动时--周总体拥堵概况更新--任务执行时间:" + LocalDateTime.now());
// 周总体拥堵概况更新
try {
greenWaveWeekDataService.insertGreenWaveWeekData();
// greenWaveWeekDataService.insertGreenWaveWeekData();
}catch (Exception e){
log.error("服务启动时--周总体拥堵概况更新--任务执行错误" + e);
}
......@@ -34,7 +34,7 @@ public class GreenWaveWeekDataTask implements ApplicationRunner {
@Scheduled(cron = "0 30 0 ? * MON")
public void executeWeeklyTask() {
//周总体拥堵概况更新
log.info("定时任务--周总体拥堵概况更新--执行结束时间:" + LocalDateTime.now());
log.info("定时任务--周总体拥堵概况更新--执行开始时间:" + LocalDateTime.now());
try {
greenWaveWeekDataService.insertGreenWaveWeekData();
}catch (Exception e){
......
......@@ -6,7 +6,7 @@
<insert id="insertOrUpdateBatch">
INSERT INTO t_analysis_green_wave_week_data (
green_id, road_direction, congest_index, max_congest_index, congest_count,
congest_duration, flow, travel_time, speed, peak_type, day_type,
congest_duration, max_congest_duration, flow, travel_time, speed, peak_type, max_congestion_period, second_congestion_period, day_type,
start_time, end_time, year_week, insert_time
)
VALUES
......@@ -18,10 +18,13 @@
#{item.maxCongestIndex},
#{item.congestCount},
#{item.congestDuration},
#{item.maxCongestDuration},
#{item.flow},
#{item.travelTime},
#{item.speed},
#{item.peakType},
#{item.maxCongestionPeriod},
#{item.secondCongestionPeriod},
#{item.dayType},
#{item.startTime},
#{item.endTime},
......@@ -34,9 +37,12 @@
max_congest_index = VALUES(max_congest_index),
congest_count = VALUES(congest_count),
congest_duration = VALUES(congest_duration),
max_congest_duration = VALUES(max_congest_duration),
flow = VALUES(flow),
travel_time = VALUES(travel_time),
speed = VALUES(speed),
max_congestion_period = VALUES(max_congestion_period),
second_congestion_period = VALUES(second_congestion_period),
start_time = VALUES(start_time),
end_time = VALUES(end_time),
insert_time = VALUES(insert_time);
......@@ -48,25 +54,33 @@
select * from t_config_peak_hours;
</select>
<select id="selectGreenWaveWeekDataByTime" resultType="net.wanji.opt.entity.report.GreenWaveWeekData">
SELECT green_id,road_direction,max(traffic_index) max_congest_index,avg(traffic_index) congest_index,sum(status>=3) congest_count,sum(status>=3)*60*5 congest_duration,avg(speed) speed,sum(trval_time) travel_time
from t_greenwave_hist where start_time BETWEEN #{startDate} and #{endDate} AND TIME( start_time ) BETWEEN #{startTime} AND #{endTime} GROUP BY green_id,road_direction
SELECT green_id,road_direction,max(traffic_index) max_congest_index,avg(traffic_index) congest_index,sum(status>=3)*60*5 congest_duration,avg(speed) speed,sum(trval_time) travel_time
from t_greenwave_hist where start_time BETWEEN #{startDate} AND #{endDate} AND TIME( start_time ) BETWEEN #{startTime} AND #{endTime} GROUP BY green_id,road_direction
</select>
<select id="selectGreenWaveWeekData" resultType="net.wanji.opt.entity.report.GreenWaveWeekData">
SELECT green_id,road_direction,max(traffic_index) max_congest_index,avg(traffic_index) congest_index,sum(status>=3) congest_count,sum(status>=3)*60*5 congest_duration,avg(speed) speed,sum(trval_time) travel_time
from t_greenwave_hist where start_time BETWEEN #{startDate} and #{endDate} GROUP BY green_id,road_direction
SELECT green_id,road_direction,max(traffic_index) max_congest_index,avg(traffic_index) congest_index,sum(status>=3)*60*5 congest_duration,avg(speed) speed,sum(trval_time) travel_time
from t_greenwave_hist where start_time BETWEEN #{startDate} AND #{endDate} GROUP BY green_id,road_direction
</select>
<select id="getFlow" resultType="java.lang.Integer">
SELECT COALESCE(flow, 0) from
(select cross_id from t_greenwave_cross where green_id = #{greenId} and sort = 1) cross_data
left join
(SELECT sum(flow) as flow,cross_id from t_cross_dir_data_hist where start_time BETWEEN #{startDate} and #{endDate} and dir_type = #{dir} GROUP BY cross_id) cross_flow on cross_data.cross_id = cross_flow.cross_id
(SELECT sum(flow) as flow,cross_id from t_cross_dir_data_hist where start_time BETWEEN #{startDate} AND #{endDate} and dir_type = #{dir} GROUP BY cross_id) cross_flow on cross_data.cross_id = cross_flow.cross_id
</select>
<select id="getFlowByTime" resultType="java.lang.Integer">
SELECT COALESCE(flow, 0) from
(select cross_id from t_greenwave_cross where green_id = #{greenId} and sort = 1) cross_data
left join
(SELECT sum(flow) as flow,cross_id from t_cross_dir_data_hist where start_time BETWEEN #{startDate} and #{endDate} AND TIME( start_time ) BETWEEN #{startTime} AND #{endTime} and dir_type = #{dir} GROUP BY cross_id) cross_flow on cross_data.cross_id = cross_flow.cross_id
(SELECT sum(flow) as flow,cross_id from t_cross_dir_data_hist where start_time BETWEEN #{startDate} AND #{endDate} AND TIME( start_time ) BETWEEN #{startTime} AND #{endTime} and dir_type = #{dir} GROUP BY cross_id) cross_flow on cross_data.cross_id = cross_flow.cross_id
</select>
<select id="selectAllByTime" resultType="net.wanji.databus.dao.entity.GreenwaveHistPO">
select * from t_greenwave_hist where start_time BETWEEN #{startDate} AND #{endDate}
<if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
and TIME( start_time ) BETWEEN #{startTime} AND #{endTime}
</if>
and green_id = #{greenId}
and status >= 3 and road_direction = #{roadDirection} order by start_time
</select>
</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