Commit a74541ec authored by 黄伟铭's avatar 黄伟铭

新增干线缓行,拥堵的时段分析数据,周一统计上一周的数据

parent 5409c18c
package net.wanji.opt.dao.mapper.judgeanalysis;
import net.wanji.opt.entity.judgeanalysis.AnalysisGreenCongestionPeriod;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
public interface AnalysisGreenCongestionPeriodMapper {
List<AnalysisGreenCongestionPeriod> selectGreenDataHist(@Param("date") String date);
void insertGreenCongestionPeriodData(Map<String, Object> map);
}
package net.wanji.opt.entity.judgeanalysis;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
@ApiModel(value = "AnalysisGreenCongestionPeriod", description = "")
public class AnalysisGreenCongestionPeriod {
@ApiModelProperty(value = "干线ID")
private String greenId;
@ApiModelProperty(value = "道路方向")
private String roadDirection;
@ApiModelProperty(value = "开始时间")
private String startTime;
@ApiModelProperty(value = "状态")
private String status;
}
package net.wanji.opt.servicev2.judgeanalysis;
import java.text.ParseException;
public interface AnalysisGreenCongestionPeriodService {
public void selectCountByCongestionPeriod() throws ParseException;
}
package net.wanji.opt.task;
import lombok.extern.slf4j.Slf4j;
import net.wanji.opt.servicev2.judgeanalysis.AnalysisGreenCongestionPeriodService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Configurable;
import org.springframework.context.annotation.Profile;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import java.text.ParseException;
@Component
@Configurable
@EnableScheduling
@Slf4j
@Profile("docker")
public class AnalysisGreenCongestionPeriodWeekTask {
@Autowired
private AnalysisGreenCongestionPeriodService analysisGreenCongestionPeriodService;
@Scheduled(cron = "0 0 2 ? * 1")
public void task() throws ParseException {
analysisGreenCongestionPeriodService.selectCountByCongestionPeriod();
}
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="net.wanji.opt.dao.mapper.judgeanalysis.AnalysisGreenCongestionPeriodMapper">
<!-- 通用查询映射结果 -->
<resultMap id="AnalysisGreenCongestionPeriodMap" type="net.wanji.opt.entity.judgeanalysis.AnalysisGreenCongestionPeriod">
<result column="green_id" property="greenId"/>
<result column="road_direction" property="roadDirection"/>
<result column="start_time" property="startTime"/>
<result column="status" property="status"/>
</resultMap>
<select id="selectGreenDataHist" parameterType="String" resultMap="AnalysisGreenCongestionPeriodMap">
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')
and a.green_id is not null
order by a.green_id,a.road_direction,a.start_time
</select>
<insert id="insertGreenCongestionPeriodData" parameterType="map">
insert into t_analysis_green_wave_congest_time_span (green_id,road_direction,week_day,congest_start_time,congest_end_time,congest_index,status,travel_time,speed,peak_type,year_week,week_start_time,week_end_time,insert_time)
SELECT a.green_id,a.road_direction,#{weekDay} as week_day, DATE_FORMAT(#{startTime},'%Y-%m-%d %H:%i:%s') as congest_start_time,DATE_FORMAT(DATE_ADD(#{endTime},INTERVAL 5 MINUTE),'%Y-%m-%d %H:%i:%s') as congest_end_time,AVG(traffic_index),#{status} as status,CEIL(AVG(trval_time)),AVG(speed),
#{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()
FROM t_greenwave_hist a
where a.start_time between DATE_FORMAT(#{startTime},'%Y-%m-%d %H:%i:%s') and DATE_FORMAT(#{endTime},'%Y-%m-%d %H:%i:%s')
and a.green_id = #{greenId}
and a.road_direction = #{roadDirection}
</insert>
</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