Commit cee4bb11 authored by zhoushiguang's avatar zhoushiguang

出口道=》方向级指标、 车道级指标 统一接口

parent 68e7a695
......@@ -10,6 +10,7 @@ import org.joda.time.Days;
import org.joda.time.Hours;
import org.joda.time.Minutes;
import org.joda.time.Months;
import org.joda.time.format.DateTimeFormat;
import java.io.File;
import java.util.ArrayList;
......@@ -24,17 +25,45 @@ public class EsDateIndexUtil {
public static final String YMDHM_FORMATTER = "yyyyMMddHHmm";
public static final String YMDHMSFORMATTER = "yyyyMMddHHmmss";
public static final String YMD_HM_FORMATTER = "yyyy-MM-dd HH:mm:00";
public static final String YMD_HM_FORMATTER = "yyyy-MM-dd HH:mm:ss";
public static final String YMD_H_FORMATTER = "yyyyMMddHH";
public static final String YMD_FORMATTER = "yyyyMMdd";
public static final String YM_FORMATTER = "yyyyMM";
public static final String HMS_FORMATTER = "HH:mm:ss";
public static final String HMS_SSS_FORMATTER = "HH:mm:ss SSS";
public static final String HM_FORMATTER = "HH:mm";
public static final String H_FORMATTER = "HH";
public static final String H_FORMATTER = "HH:00";
private static final String FORMATSTR = "%s_%s";
/**
* 获取时段范围内不同时间粒度的时间轴
* @param groupType 0:5分钟 1:15分钟 2:30分钟 3:1小时 4:天粒度
* @param startTime 开始时间
* @param endTime 截止时间
* @return
*/
public static Set<String> getTimeGranularityAxis(String groupType,String startTime, String endTime) {
//存放时段
Set<String> sortedSet = new TreeSet<>();
//===========================根据开始、结束时间输出完整时刻点=================================================//
DateTime start = DateTime.parse(startTime, DateTimeFormat.forPattern(EsDateIndexUtil.YMD_HM_FORMATTER));
DateTime end = DateTime.parse(endTime, DateTimeFormat.forPattern(EsDateIndexUtil.YMD_HM_FORMATTER));
if (Objects.equals("0", groupType)) {
sortedSet.addAll(EsDateIndexUtil.getTimeScopeList(start, end, TimeGranularityEnum.FIVE_MINUTE, EsDateIndexUtil.HM_FORMATTER));
} else if (Objects.equals("1", groupType)) {
sortedSet.addAll(EsDateIndexUtil.getTimeScopeList(start, end, TimeGranularityEnum.FIFTEEN_MINUTE, EsDateIndexUtil.HM_FORMATTER));
} else if (Objects.equals("2", groupType)) {
sortedSet.addAll(EsDateIndexUtil.getTimeScopeList(start, end, TimeGranularityEnum.THIRTY_MINUTE, EsDateIndexUtil.HM_FORMATTER));
} else if (Objects.equals("3", groupType)) {
sortedSet.addAll(EsDateIndexUtil.getTimeScopeList(start, end, TimeGranularityEnum.ONE_HOUR, EsDateIndexUtil.H_FORMATTER));
} else if (Objects.equals("4", groupType)) {
sortedSet.addAll(EsDateIndexUtil.getTimeScopeList(start, end, TimeGranularityEnum.ONE_DAY, EsDateIndexUtil.YMD_FORMATTER));
}
return sortedSet;
}
/**
* 根据开始结束时间获取不同时间粒度的时刻点
*
......@@ -59,7 +88,7 @@ public class EsDateIndexUtil {
}else if (Objects.equals(TimeGranularityEnum.ONE_HOUR, timeGranularityEnum)) {
unitTime = 60;
}else if (Objects.equals(TimeGranularityEnum.ONE_DAY, timeGranularityEnum)) {
unitTime = 24*60*60;
unitTime = 24*60;
}
for (int i = 0; i <= diffNum; i=i+unitTime) {
......
......@@ -15,6 +15,7 @@ import net.wanji.common.framework.rest.AbstractRestServer;
import net.wanji.common.framework.rest.JsonViewObject;
import net.wanji.common.framework.rest.impl.AbstractRestServerImpl;
import net.wanji.opt.entity.GreenwaveHist;
import net.wanji.opt.po.base.CrossLaneDataHistPoExtend;
import net.wanji.opt.service.GreenwaveHistProvider;
import net.wanji.opt.vo.GreenWaveRunStateVO;
import net.wanji.opt.vo.GreenwaveCrossMetricsVO;
......@@ -55,14 +56,14 @@ public class GreenwaveHistRestServer {
@ApiImplicitParams({
@ApiImplicitParam(name = "greenId", value = "绿波ID", required = true, dataType = "Integer",defaultValue = "1"),
@ApiImplicitParam(name = "startTime", value = "截止时间,格式:yyyy-MM-dd HH:mm:ss", required = false, dataType = "String",defaultValue = "2024-12-04 00:00:00"),
@ApiImplicitParam(name = "endTime", value = "截止时间,格式:yyyy-MM-dd HH:mm:ss", required = false, dataType = "String",defaultValue = "2024-12-05 00:00:00")
@ApiImplicitParam(name = "endTime", value = "截止时间,格式:yyyy-MM-dd HH:mm:ss", required = false, dataType = "String",defaultValue = "2024-12-04 23:59:59")
})
@ApiResponses({
@ApiResponse(code = 200, message = "成功", response = GreenWaveRunStateVO.class,
responseHeaders = {@ResponseHeader(name = "Content-Type", description = "application/json")})
})
public JsonViewObject findGreenWaveRunState(Integer greenId,@RequestParam(defaultValue ="2024-12-04 00:00:00") String startTime,
@RequestParam(defaultValue ="2024-12-05 00:00:00") String endTime,
@RequestParam(defaultValue ="2024-12-04 23:59:59") String endTime,
@RequestParam(defaultValue ="705,706") String eventType) {
JsonViewObject jsonView = JsonViewObject.newInstance();
long start=System.currentTimeMillis();
......@@ -83,7 +84,7 @@ public class GreenwaveHistRestServer {
@ApiImplicitParams({
@ApiImplicitParam(name = "greenId", value = "绿波ID", required = true, dataType = "String",defaultValue = "1"),
@ApiImplicitParam(name = "startTime", value = "截止时间,格式:yyyy-MM-dd HH:mm:ss", required = false, dataType = "String",defaultValue = "2024-12-04 00:00:00"),
@ApiImplicitParam(name = "endTime", value = "截止时间,格式:yyyy-MM-dd HH:mm:ss", required = false, dataType = "String",defaultValue = "2024-12-05 00:00:00")
@ApiImplicitParam(name = "endTime", value = "截止时间,格式:yyyy-MM-dd HH:mm:ss", required = false, dataType = "String",defaultValue = "2024-12-04 23:59:59")
})
@ApiResponses({
@ApiResponse(code = 200, message = "成功", response = GreenwaveHist.class,
......@@ -187,7 +188,7 @@ public class GreenwaveHistRestServer {
@ApiImplicitParam(name = "crossId", value = "路口ID", required = true, dataType = "String",defaultValue = "13MOD0B5SI0"),
@ApiImplicitParam(name = "groupType", value = "时间粒度类型 0:5分钟粒度 1:15分钟粒度 2:30分钟粒度 3:小时粒度", required = true, dataType = "Integer",defaultValue = "1"),
@ApiImplicitParam(name = "startTime", value = "截止时间,格式:yyyy-MM-dd HH:mm:ss", required = false, dataType = "String",defaultValue = "2024-12-04 00:00:00"),
@ApiImplicitParam(name = "endTime", value = "截止时间,格式:yyyy-MM-dd HH:mm:ss", required = false, dataType = "String",defaultValue = "2024-12-05 00:00:00")
@ApiImplicitParam(name = "endTime", value = "截止时间,格式:yyyy-MM-dd HH:mm:ss", required = false, dataType = "String",defaultValue = "2024-12-04 23:59:59")
})
@ApiResponses({
@ApiResponse(code = 200, message = "成功", response = GreenwaveHist.class,
......@@ -207,18 +208,44 @@ public class GreenwaveHistRestServer {
return jsonView;
}
@GetMapping("/findGreenWaveCrossIndex")
@ApiOperation(httpMethod="GET",value="绿波路口级->分粒度指标趋势", notes="")
@ApiImplicitParams({
@ApiImplicitParam(name = "crossId", value = "路口ID", required = true, dataType = "String",defaultValue = "13MOD0B5SI0"),
@ApiImplicitParam(name = "groupType", value = "时间粒度类型 1:15分钟粒度 2:30分钟粒度 3:小时粒度", required = true, dataType = "Integer",defaultValue = "1"),
@ApiImplicitParam(name = "startTime", value = "截止时间,格式:yyyy-MM-dd HH:mm:ss", required = false, dataType = "String",defaultValue = "2024-12-04 00:00:00"),
@ApiImplicitParam(name = "endTime", value = "截止时间,格式:yyyy-MM-dd HH:mm:ss", required = false, dataType = "String",defaultValue = "2024-12-04 23:59:59")
})
@ApiResponses({
@ApiResponse(code = 200, message = "成功", response = GreenwaveHist.class,
responseHeaders = {@ResponseHeader(name = "Content-Type", description = "application/json")})
})
public JsonViewObject findGreenWaveCrossIndex(String crossId, String startTime, String endTime,String groupType) {
JsonViewObject jsonView = JsonViewObject.newInstance();
try {
JSONObject list = greenwaveHistProvider.findGreenWaveCrossIndex(crossId,startTime,endTime,groupType);
jsonView.success(list);
} catch (DubboProviderException e) {
jsonView.fail(I18nResourceBundle.getConstants("GET_FAILED_MSG"));
log.error("{} getAll error", this.getClass().getSimpleName(), e);
}
return jsonView;
}
@GetMapping("/findGreenWaveCrossObjectIndex")
@ApiOperation(httpMethod="GET",value="路口方向级、转向级、车道级->分粒度指标趋势", notes="")
@GetMapping("/findCrossObjectIndex")
@ApiOperation(httpMethod="GET",value="路口进口【方向级、转向级、车道级】->分粒度指标趋势", notes="")
@ApiImplicitParams({
@ApiImplicitParam(name = "crossId", value = "路口ID", required = true, dataType = "String",defaultValue = "13MOD0B5SI0"),
@ApiImplicitParam(name = "groupType", value = "时间粒度类型 0:5分钟粒度 1:15分钟粒度 2:30分钟粒度 3:小时粒度 4:天粒度", required = true, dataType = "Integer",defaultValue = "1"),
@ApiImplicitParam(name = "startTime", value = "截止时间,格式:yyyy-MM-dd HH:mm:ss", required = true, dataType = "String",defaultValue = "2024-12-04 00:00:00"),
@ApiImplicitParam(name = "endTime", value = "截止时间,格式:yyyy-MM-dd HH:mm:ss", required = true, dataType = "String",defaultValue = "2024-12-05 00:00:00"),
@ApiImplicitParam(name = "endTime", value = "截止时间,格式:yyyy-MM-dd HH:mm:ss", required = true, dataType = "String",defaultValue = "2024-12-04 23:59:59"),
@ApiImplicitParam(name = "objectType", value = "统计对象类型 1:方向级指标 2:转向级指标 3:车道级指标", required = true, dataType = "Integer",defaultValue = "1"),
})
@ApiResponses({
@ApiResponse(code = 200, message = "成功", response = GreenwaveHist.class,
@ApiResponse(code = 200, message = "成功", response = CrossLaneDataHistPoExtend.class,
responseHeaders = {@ResponseHeader(name = "Content-Type", description = "application/json")})
})
public JsonViewObject findGreenWaveCrossObjectIndex(String crossId, String startTime, String endTime,String groupType,Integer objectType) {
......@@ -236,23 +263,24 @@ public class GreenwaveHistRestServer {
}
@GetMapping("/findGreenWaveCrossIndex")
@ApiOperation(httpMethod="GET",value="绿波路口级->分粒度指标趋势", notes="")
@GetMapping("/findCrossExitRoadIndex")
@ApiOperation(httpMethod="GET",value="路口出口道【方向级/车道级】分粒度指标趋势", notes="")
@ApiImplicitParams({
@ApiImplicitParam(name = "crossId", value = "路口ID", required = true, dataType = "String",defaultValue = "13MOD0B5SI0"),
@ApiImplicitParam(name = "groupType", value = "时间粒度类型 1:15分钟粒度 2:30分钟粒度 3:小时粒度", required = true, dataType = "Integer",defaultValue = "1"),
@ApiImplicitParam(name = "startTime", value = "截止时间,格式:yyyy-MM-dd HH:mm:ss", required = false, dataType = "String",defaultValue = "2024-12-04 00:00:00"),
@ApiImplicitParam(name = "endTime", value = "截止时间,格式:yyyy-MM-dd HH:mm:ss", required = false, dataType = "String",defaultValue = "2024-12-05 00:00:00")
@ApiImplicitParam(name = "groupType", value = "时间粒度类型 0:5分钟粒度 1:15分钟粒度 2:30分钟粒度 3:小时粒度 4:天粒度", required = true, dataType = "Integer",defaultValue = "1"),
@ApiImplicitParam(name = "startTime", value = "截止时间,格式:yyyy-MM-dd HH:mm:ss", required = true, dataType = "String",defaultValue = "2024-12-04 00:00:00"),
@ApiImplicitParam(name = "endTime", value = "截止时间,格式:yyyy-MM-dd HH:mm:ss", required = true, dataType = "String",defaultValue = "2024-12-04 23:59:59"),
@ApiImplicitParam(name = "objectType", value = "统计对象类型 1:出口道方向级指标 2:出口道车道级指标", required = true, dataType = "Integer",defaultValue = "1"),
})
@ApiResponses({
@ApiResponse(code = 200, message = "成功", response = GreenwaveHist.class,
@ApiResponse(code = 200, message = "成功", response = CrossLaneDataHistPoExtend.class,
responseHeaders = {@ResponseHeader(name = "Content-Type", description = "application/json")})
})
public JsonViewObject findGreenWaveCrossIndex(String crossId, String startTime, String endTime,String groupType) {
public JsonViewObject findCrossExitRoadIndex(String crossId, String startTime, String endTime,String groupType,Integer objectType) {
JsonViewObject jsonView = JsonViewObject.newInstance();
try {
JSONObject list = greenwaveHistProvider.findGreenWaveCrossIndex(crossId,startTime,endTime,groupType);
JSONObject list = greenwaveHistProvider.findCrossExitRoadDirInfo(crossId,startTime,endTime,groupType,objectType);
jsonView.success(list);
} catch (DubboProviderException e) {
jsonView.fail(I18nResourceBundle.getConstants("GET_FAILED_MSG"));
......@@ -263,5 +291,4 @@ public class GreenwaveHistRestServer {
}
}
......@@ -79,5 +79,34 @@ public interface GreenwaveHistoryMapper extends BaseInterfaceMapper<GreenwaveHis
*/
List<CrossLaneDataHistPoExtend> findGreenWaveCrossLaneIndex(Map<String,Object> params);
/**
* 出口车道信息查询
* @param params
* @return
*/
List<Map<String,Object>> findCrossExitRoadLaneInfo(Map<String,Object> params);
/**
* 出口车道信息查询
* @param params
* @return
*/
List<Map<String,Object>> findCrossExitRoadDirInfo(Map<String,Object> params);
/**
* 出口车道信指标息查询
* @param params
* @return
*/
List<CrossLaneDataHistPoExtend> findCrossExitRoadLaneIndex(Map<String,Object> params);
/**
* 出口道方向指标数据查询
* @param params
* @return
*/
List<CrossLaneDataHistPoExtend> findCrossExitRoadIndex(Map<String,Object> params);
}
......@@ -14,7 +14,9 @@ import java.util.Date;
* @description
*/
@Data
public class CrossLaneDataHistPoExtend extends CrossLaneDataHistPO {
public class CrossLaneDataHistPoExtend {
@ApiModelProperty(name = "路口编号",notes = "")
private String crossId;
//车道ID
@ApiModelProperty(value = "车道ID", notes = "")
private String laneId;
......@@ -37,8 +39,22 @@ public class CrossLaneDataHistPoExtend extends CrossLaneDataHistPO {
@ApiModelProperty(value = "平均排队长度", notes = "")
private Integer avgQueueLength;
@ApiModelProperty(name = "交通流量(辆)",notes = "")
private Integer flow;
@ApiModelProperty(name = "平均速度(km/h)",notes = "")
private Double speed;
@ApiModelProperty(name = "停车次数",notes = "")
private Double stopTimes;
@ApiModelProperty(name = "延误时间",notes = "")
private Integer delayTime;
@ApiModelProperty(name = "饱和度",notes = "")
private Double sturation;
@ApiModelProperty(value = "开始时间:yyyy-MM-dd HH:mm:ss", notes = "")
@JSONField(format = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
public Date startTime;
@ApiModelProperty(value = "时间轴", notes = "")
public String timeAxis;
}
......@@ -5,6 +5,7 @@ import net.wanji.common.framework.dubbointerface.BaseDubboInterface;
import net.wanji.common.framework.exception.DubboProviderException;
import net.wanji.databus.po.CrossDirDataHistPO;
import net.wanji.opt.entity.GreenwaveHist;
import net.wanji.opt.po.base.CrossLaneDataHistPoExtend;
import net.wanji.opt.vo.GreenWaveRunStateVO;
import java.util.List;
......@@ -103,4 +104,28 @@ public interface GreenwaveHistProvider extends BaseDubboInterface<GreenwaveHist>
* @throws DubboProviderException
*/
JSONObject findGreenWaveCrossLaneIndex(String crossId, String startTime, String endTime, String groupType,Integer objectType) throws DubboProviderException;
/**
* 出口车道信指标息查询
* @param crossId
* @param startTime
* @param endTime
* @param groupType
* @return
* @throws DubboProviderException
*/
JSONObject findCrossExitRoadLaneInfo(String crossId, String startTime, String endTime, String groupType) throws DubboProviderException;
/**
* 出口道方向指标数据查询
* @param crossId
* @param startTime
* @param endTime
* @param groupType
* @param objectType 1:出口道方向级指标 2:出口道车道级指标
* @return
* @throws DubboProviderException
*/
JSONObject findCrossExitRoadDirInfo(String crossId, String startTime, String endTime, String groupType,Integer objectType) throws DubboProviderException;
}
......@@ -85,7 +85,7 @@ public class GreenwaveHistProviderImpl extends BaseDubboInterfaceImpl<GreenwaveH
//存放时段
Set<String> sortedSet = new TreeSet<>();
//存放所有进口数据
//存放所有数据
List<Map<String, Object>> allList = new ArrayList<>();
//按时间分组分组
Map<String, List<GreenwaveHist>> groupByDir = list.stream().collect(Collectors.groupingBy(o -> o.getRoadDirection(), TreeMap::new, Collectors.toList()));
......@@ -151,7 +151,7 @@ public class GreenwaveHistProviderImpl extends BaseDubboInterfaceImpl<GreenwaveH
//存放时段
Set<String> sortedSet = new TreeSet<>();
//存放所有进口数据
//存放所有数据
List<Map<String, Object>> allList = new ArrayList<>();
//按时间分组分组
Map<Integer, List<GreenwaveHist>> groupByDir = list.stream().collect(Collectors.groupingBy(o -> o.getDirection(), TreeMap::new, Collectors.toList()));
......@@ -203,7 +203,7 @@ public class GreenwaveHistProviderImpl extends BaseDubboInterfaceImpl<GreenwaveH
//存放时段
Set<String> sortedSet = new TreeSet<>();
//存放所有进口数据
//存放所有数据
List<Map<String, Object>> allList = new ArrayList<>();
//按时间分组分组
Map<Integer, List<CrossDirDataHistPO>> groupByDir = list.stream().collect(Collectors.groupingBy(o -> o.getDirType(), TreeMap::new, Collectors.toList()));
......@@ -322,27 +322,14 @@ public class GreenwaveHistProviderImpl extends BaseDubboInterfaceImpl<GreenwaveH
list = list.stream().sorted(Comparator.comparing(o -> o.getStartTime())).collect(Collectors.toList());
//存放时段
Set<String> sortedSet = new TreeSet<>();
//===========================根据开始、结束时间输出完整时刻点=================================================//
DateTime start = DateTime.parse(startTime, DateTimeFormat.forPattern(EsDateIndexUtil.YMD_HM_FORMATTER));
DateTime end = DateTime.parse(endTime, DateTimeFormat.forPattern(EsDateIndexUtil.YMD_HM_FORMATTER));
if (Objects.equals("0", groupType)) {
sortedSet.addAll(EsDateIndexUtil.getTimeScopeList(start, end, TimeGranularityEnum.FIVE_MINUTE,EsDateIndexUtil.YMD_HM_FORMATTER));
} else if (Objects.equals("1", groupType)) {
sortedSet.addAll(EsDateIndexUtil.getTimeScopeList(start, end, TimeGranularityEnum.FIFTEEN_MINUTE,EsDateIndexUtil.YMD_HM_FORMATTER));
} else if (Objects.equals("2", groupType)) {
sortedSet.addAll(EsDateIndexUtil.getTimeScopeList(start, end, TimeGranularityEnum.THIRTY_MINUTE,EsDateIndexUtil.YMD_HM_FORMATTER));
} else if (Objects.equals("3", groupType)) {
sortedSet.addAll(EsDateIndexUtil.getTimeScopeList(start, end, TimeGranularityEnum.ONE_HOUR,EsDateIndexUtil.YMD_HM_FORMATTER));
}
Set<String> sortedSet = EsDateIndexUtil.getTimeGranularityAxis(groupType, startTime, endTime);
//======================================================================================================//
//存放所有进口数据
//存放所有数据
List<Map<String, Object>> allList = new ArrayList<>();
//按时间分组分组
Map<String, List<CrossTurnDataHistPO>> groupByDir = list.stream().collect(Collectors.groupingBy(o -> o.getInDir() + "_" + o.getTurnType(), TreeMap::new, Collectors.toList()));
List<Map<String, Object>> turnList = new ArrayList<>();
for (Map.Entry<String, List<CrossTurnDataHistPO>> entry : groupByDir.entrySet()) {
String key = entry.getKey();
......@@ -355,12 +342,12 @@ public class GreenwaveHistProviderImpl extends BaseDubboInterfaceImpl<GreenwaveH
//按方向排序
List<CrossTurnDataHistPO> value = entry.getValue().stream().sorted(Comparator.comparing(o -> o.getStartTime())).collect(Collectors.toList());
//有实际数据的时刻点
Set<String> timeList = value.stream().map(po->DateUtil.formatDate(po.getStartTime(), EsDateIndexUtil.YMD_HM_FORMATTER)).collect(Collectors.toSet());
Set<String> timeList = value.stream().map(po -> DateUtil.formatDate(po.getStartTime(), EsDateIndexUtil.YMD_HM_FORMATTER)).collect(Collectors.toSet());
//补充缺少时段数据,保留时段字段默认值
for (String timeSec : sortedSet) {
if (!timeList.contains(timeSec)) {
CrossTurnDataHistPO tmp = new CrossTurnDataHistPO();
tmp.setStartTime(DateTime.parse(timeSec,DateTimeFormat.forPattern(EsDateIndexUtil.YMD_HM_FORMATTER)).toDate());
CrossTurnDataHistPO tmp = new CrossTurnDataHistPO();
tmp.setStartTime(DateTime.parse(timeSec, DateTimeFormat.forPattern(EsDateIndexUtil.YMD_HM_FORMATTER)).toDate());
value.add(tmp);
}
}
......@@ -378,7 +365,7 @@ public class GreenwaveHistProviderImpl extends BaseDubboInterfaceImpl<GreenwaveH
}
JSONObject jsonObject = new JSONObject();
jsonObject.put("timeList", sortedSet.stream().map(o->o.substring(o.indexOf(" ")+1,o.lastIndexOf(":"))));
jsonObject.put("timeList", sortedSet.stream().map(o -> o.substring(o.indexOf(" ") + 1, o.lastIndexOf(":"))));
jsonObject.put("dataList", allList);
jsonObject.put("dirList", groupByDir.keySet());
......@@ -387,7 +374,7 @@ public class GreenwaveHistProviderImpl extends BaseDubboInterfaceImpl<GreenwaveH
}
@Override
public JSONObject findGreenWaveCrossLaneIndex(String crossId, String startTime, String endTime, String groupType,Integer objectType) throws DubboProviderException {
public JSONObject findGreenWaveCrossLaneIndex(String crossId, String startTime, String endTime, String groupType, Integer objectType) throws DubboProviderException {
Map<String, Object> params = new HashMap<>();
params.put("crossId", crossId);
params.put("startDate", startTime);
......@@ -396,37 +383,22 @@ public class GreenwaveHistProviderImpl extends BaseDubboInterfaceImpl<GreenwaveH
params.put("objectType", objectType);
//存放时段
Set<String> sortedSet = new TreeSet<>();
//===========================根据开始、结束时间输出完整时刻点=================================================//
DateTime start = DateTime.parse(startTime, DateTimeFormat.forPattern(EsDateIndexUtil.YMD_HM_FORMATTER));
DateTime end = DateTime.parse(endTime, DateTimeFormat.forPattern(EsDateIndexUtil.YMD_HM_FORMATTER));
if (Objects.equals("0", groupType)) {
sortedSet.addAll(EsDateIndexUtil.getTimeScopeList(start, end, TimeGranularityEnum.FIVE_MINUTE,EsDateIndexUtil.YMD_HM_FORMATTER));
} else if (Objects.equals("1", groupType)) {
sortedSet.addAll(EsDateIndexUtil.getTimeScopeList(start, end, TimeGranularityEnum.FIFTEEN_MINUTE,EsDateIndexUtil.YMD_HM_FORMATTER));
} else if (Objects.equals("2", groupType)) {
sortedSet.addAll(EsDateIndexUtil.getTimeScopeList(start, end, TimeGranularityEnum.THIRTY_MINUTE,EsDateIndexUtil.YMD_HM_FORMATTER));
} else if (Objects.equals("3", groupType)) {
sortedSet.addAll(EsDateIndexUtil.getTimeScopeList(start, end, TimeGranularityEnum.ONE_HOUR,EsDateIndexUtil.YMD_HM_FORMATTER));
}else if (Objects.equals("4", groupType)) {
sortedSet.addAll(EsDateIndexUtil.getTimeScopeList(start, end, TimeGranularityEnum.ONE_DAY,EsDateIndexUtil.YMD_HM_FORMATTER));
}
Set<String> sortedSet = EsDateIndexUtil.getTimeGranularityAxis(groupType, startTime, endTime);
//======================================================================================================//
//存放所有进口数据
//存放所有数据
List<Map<String, Object>> allList = new ArrayList<>();
List<CrossLaneDataHistPoExtend> list = greenwaveHistoryMapper.findGreenWaveCrossLaneIndex(params);
list = list.stream().sorted(Comparator.comparing(o -> o.getStartTime())).collect(Collectors.toList());
//按时间分组分组
Map<String, List<CrossLaneDataHistPoExtend>> groupByDir = list.stream().collect(Collectors.groupingBy(o -> o.getCrossId()+"_"+ o.getLaneId()+"_"+o.getDirType()+"_"+o.getTurnType(), TreeMap::new, Collectors.toList()));
Map<String, List<CrossLaneDataHistPoExtend>> groupByDir = list.stream().collect(Collectors.groupingBy(o -> o.getCrossId() + "_" + o.getLaneId() + "_" + o.getDirType() + "_" + o.getTurnType(), TreeMap::new, Collectors.toList()));
for (Map.Entry<String, List<CrossLaneDataHistPoExtend>> entry : groupByDir.entrySet()) {
String key = entry.getKey();
String[] sps = key.split("_");
String laneId = sps[1];
String laneNo = laneId.substring(laneId.length()-2) ;
String laneNo = laneId.substring(laneId.length() - 2);
Integer dirType = Integer.parseInt(sps[2]);
String dirName = null;
String turnDesc = null;
......@@ -434,36 +406,24 @@ public class GreenwaveHistProviderImpl extends BaseDubboInterfaceImpl<GreenwaveH
Map<String, Object> mapList = new HashMap<>();
if (Objects.equals(3,objectType)) {
mapList.put("laneId",laneId);
mapList.put("laneNo",laneNo);
if (Objects.equals(3, objectType)) {
mapList.put("laneId", laneId);
mapList.put("laneNo", laneNo);
dirName = BaseEnum.SignalDirectionEnum.getNameByCode(dirType);
turnDesc = TurnConvertEnum.getDescByKey(Integer.valueOf(sps[3]));
dirTurnDesc = dirName + "进口" + turnDesc + laneNo + "车道";
}else if (Objects.equals(2,objectType)) {
} else if (Objects.equals(2, objectType)) {
dirName = BaseEnum.SignalDirectionEnum.getNameByCode(dirType);
turnDesc = TurnConvertEnum.getDescByKey(Integer.valueOf(sps[3]));
dirTurnDesc = dirName + "进口" + turnDesc;
} else if (Objects.equals(1,objectType)) {
} else if (Objects.equals(1, objectType)) {
dirName = BaseEnum.SignalDirectionEnum.getNameByCode(dirType);
dirTurnDesc = dirName + "进口";
}
//按方向排序
List<CrossLaneDataHistPoExtend> value = entry.getValue().stream().sorted(Comparator.comparing(o -> o.getStartTime())).collect(Collectors.toList());
//有实际数据的时刻点
Set<String> timeList = value.stream().map(po->DateUtil.formatDate(po.getStartTime(), EsDateIndexUtil.YMD_HM_FORMATTER)).collect(Collectors.toSet());
//补充缺少时段数据,保留时段字段默认值
for (String timeSec : sortedSet) {
if (!timeList.contains(timeSec)) {
CrossLaneDataHistPoExtend tmp = new CrossLaneDataHistPoExtend();
tmp.setStartTime(DateTime.parse(timeSec,DateTimeFormat.forPattern(EsDateIndexUtil.YMD_HM_FORMATTER)).toDate());
value.add(tmp);
}
}
value = value.stream().sorted(Comparator.comparing(CrossLaneDataHistPoExtend::getStartTime)).collect(Collectors.toList());
List<CrossLaneDataHistPoExtend> value = this.processData(entry, groupType, sortedSet, startTime);
mapList.put("scopeCode", key);
mapList.put("scopeName", dirTurnDesc);
......@@ -477,13 +437,195 @@ public class GreenwaveHistProviderImpl extends BaseDubboInterfaceImpl<GreenwaveH
List<String> scopeList = mainlineEvaluateService.bottomMenu(bo);
JSONObject jsonObject = new JSONObject();
jsonObject.put("timeList", sortedSet.stream().map(o->o.substring(o.indexOf(" ")+1,o.lastIndexOf(":"))));
jsonObject.put("timeList", sortedSet);
jsonObject.put("dataList", allList);
jsonObject.put("scopeList", scopeList);
return jsonObject;
}
@Override
public JSONObject findCrossExitRoadLaneInfo(String crossId, String startTime, String endTime, String groupType) {
Map<String, Object> params = new HashMap<>();
params.put("crossId", crossId);
params.put("startDate", startTime);
params.put("endDate", endTime);
params.put("groupType", groupType);
//存放时段
Set<String> sortedSet = EsDateIndexUtil.getTimeGranularityAxis(groupType, startTime, endTime);
//======================================================================================================//
//存放所有数据
List<Map<String, Object>> allList = new ArrayList<>();
List<CrossLaneDataHistPoExtend> list = greenwaveHistoryMapper.findCrossExitRoadLaneIndex(params);
list = list.stream().sorted(Comparator.comparing(o -> o.getStartTime())).collect(Collectors.toList());
//按时间分组分组
Map<String, List<CrossLaneDataHistPoExtend>> groupByDir = list.stream().collect(Collectors.groupingBy(o -> o.getCrossId() + "_" + o.getLaneId() + "_" + o.getDirType() + "_" + o.getTurnType(), TreeMap::new, Collectors.toList()));
Set<String> scopeList = new TreeSet<>();
for (Map.Entry<String, List<CrossLaneDataHistPoExtend>> entry : groupByDir.entrySet()) {
String key = entry.getKey();
String[] sps = key.split("_");
String laneId = sps[1];
String laneNo = laneId.substring(laneId.length() - 2);
Integer dirType = Integer.parseInt(sps[2]);
String dirName = null;
String turnDesc = null;
String dirTurnDesc = null;
Map<String, Object> mapList = new HashMap<>();
mapList.put("laneId", laneId);
mapList.put("laneNo", laneNo);
dirName = BaseEnum.SignalDirectionEnum.getNameByCode(dirType);
turnDesc = TurnConvertEnum.getDescByKey(Integer.valueOf(sps[3]));
dirTurnDesc = dirName + "出口" + turnDesc + laneNo + "车道";
scopeList.add(dirTurnDesc);
//补充缺少时段数据,保留时段字段默认值
List<CrossLaneDataHistPoExtend> value = this.processData(entry, groupType, sortedSet, startTime);
mapList.put("scopeCode", key);
mapList.put("scopeName", dirTurnDesc);
mapList.put("list", value);
allList.add(mapList);
}
JSONObject jsonObject = new JSONObject();
jsonObject.put("timeList", sortedSet);
jsonObject.put("dataList", allList);
jsonObject.put("scopeList", scopeList);
return jsonObject;
}
@Override
public JSONObject findCrossExitRoadDirInfo(String crossId, String startTime, String endTime, String groupType, Integer objectType) {
Map<String, Object> params = new HashMap<>();
params.put("crossId", crossId);
params.put("startDate", startTime);
params.put("endDate", endTime);
params.put("groupType", groupType);
//存放时段
Set<String> sortedSet = EsDateIndexUtil.getTimeGranularityAxis(groupType, startTime, endTime);
//======================================================================================================//
//存放所有数据
List<Map<String, Object>> allList = new ArrayList<>();
List<CrossLaneDataHistPoExtend> list = new ArrayList<>();
if (objectType == 1) {
list = greenwaveHistoryMapper.findCrossExitRoadIndex(params);
} else if (objectType == 2) {
list = greenwaveHistoryMapper.findCrossExitRoadLaneIndex(params);
}
list = list.stream().sorted(Comparator.comparing(o -> o.getStartTime())).collect(Collectors.toList());
//按时间分组分组
Map<String, List<CrossLaneDataHistPoExtend>> groupByDir = list.stream().collect(Collectors.groupingBy(o -> o.getCrossId() + "_" + o.getLaneId() + "_" + o.getDirType() + "_" + o.getTurnType(), TreeMap::new, Collectors.toList()));
Set<String> scopeList = new TreeSet<>();
for (Map.Entry<String, List<CrossLaneDataHistPoExtend>> entry : groupByDir.entrySet()) {
String key = entry.getKey();
String[] sps = key.split("_");
String laneId = sps[1];
String laneNo = laneId.substring(laneId.length() - 2);
Integer dirType = Integer.parseInt(sps[2]);
String dirName = null;
String turnDesc = null;
String dirTurnDesc = null;
Map<String, Object> mapList = new HashMap<>();
mapList.put("laneId", laneId);
mapList.put("laneNo", laneNo);
if (objectType == 1) {
dirName = BaseEnum.SignalDirectionEnum.getNameByCode(dirType);
dirTurnDesc = dirName + "出口";
} else if (objectType == 2) {
dirName = BaseEnum.SignalDirectionEnum.getNameByCode(dirType);
turnDesc = TurnConvertEnum.getDescByKey(Integer.valueOf(sps[3]));
dirTurnDesc = dirName + "出口" + turnDesc + laneNo + "车道";
}
scopeList.add(dirTurnDesc);
//补充缺少时段数据,保留时段字段默认值
List<CrossLaneDataHistPoExtend> value = this.processData(entry, groupType, sortedSet, startTime);
mapList.put("scopeCode", key);
mapList.put("scopeName", dirTurnDesc);
mapList.put("list", value);
allList.add(mapList);
}
JSONObject jsonObject = new JSONObject();
jsonObject.put("timeList", sortedSet);
jsonObject.put("dataList", allList);
jsonObject.put("scopeList", scopeList);
return jsonObject;
}
/**
* 补充缺少时段数据,保留时段字段默认值
*
* @param entry
* @param groupType
* @param sortedSet
* @param startTime
*/
private List<CrossLaneDataHistPoExtend> processData(Map.Entry<String, List<CrossLaneDataHistPoExtend>> entry, String groupType, Set<String> sortedSet, String startTime) {
//按方向排序
List<CrossLaneDataHistPoExtend> value = entry.getValue().stream().sorted(Comparator.comparing(o -> o.getStartTime())).collect(Collectors.toList());
//有实际数据的时刻点
Set<String> timeList = new HashSet<>();
if (Objects.equals("4", groupType)) {
//天粒度
timeList.addAll(value.stream().map(po -> DateUtil.formatDate(po.getStartTime(), EsDateIndexUtil.YMD_FORMATTER)).collect(Collectors.toSet()));
} else if (Objects.equals("3", groupType)) {
//小时粒度
timeList.addAll(value.stream().map(po -> DateUtil.formatDate(po.getStartTime(), EsDateIndexUtil.H_FORMATTER)).collect(Collectors.toSet()));
} else {
//小时分钟粒度
timeList.addAll(value.stream().map(po -> DateUtil.formatDate(po.getStartTime(), EsDateIndexUtil.HM_FORMATTER)).collect(Collectors.toSet()));
}
//补充缺少时段数据,保留时段字段默认值
for (String timeSec : sortedSet) {
if (!timeList.contains(timeSec)) {
CrossLaneDataHistPoExtend tmp = new CrossLaneDataHistPoExtend();
tmp.setTimeAxis(timeSec);
String parseTime = startTime.substring(0, startTime.lastIndexOf(" ") + 1) + timeSec;
if (Objects.equals("4", groupType)) {
tmp.setStartTime(DateTime.parse(timeSec, DateTimeFormat.forPattern(EsDateIndexUtil.YMD_FORMATTER)).toDate());
} else {
tmp.setStartTime(DateTime.parse(parseTime, DateTimeFormat.forPattern("yyyy-MM-dd HH:mm")).toDate());
}
value.add(tmp);
}
}
value = value.stream().sorted(Comparator.comparing(CrossLaneDataHistPoExtend::getStartTime)).collect(Collectors.toList());
//时间轴
value.forEach(o -> {
if (Objects.equals("4", groupType)) {
o.setTimeAxis(DateUtil.formatDate(o.getStartTime(), EsDateIndexUtil.YMD_FORMATTER));
} else if (Objects.equals("3", groupType)) {
o.setTimeAxis(DateUtil.formatDate(o.getStartTime(), EsDateIndexUtil.H_FORMATTER));
} else {
o.setTimeAxis(DateUtil.formatDate(o.getStartTime(), EsDateIndexUtil.HM_FORMATTER));
}
});
return value;
}
}
......@@ -97,7 +97,7 @@
<!-- 绿波路口级指标趋势,支持按5分钟、15分钟粒度、30分钟粒度、1小时粒度汇聚 -->
<select id="findGreenWaveCrossIndex" resultMap="net.wanji.databus.dao.mapper.CrossDataHistMapper.BaseResultMap">
SELECT MIN(start_time) start_time,
SELECT MIN(ifnull(t.unit_time,#{startDate})) start_time,
cross_id,
AVG(traffic_index) traffic_index,
SUM(flow) flow,
......@@ -110,9 +110,11 @@
(
SELECT start_time,
(case
when #{groupType}=1 then CEIL(UNIX_TIMESTAMP(DATE_ADD(t.start_time,INTERVAL 5 MINUTE)) / 900)
when #{groupType}=2 then CEIL(UNIX_TIMESTAMP(DATE_ADD(t.start_time,INTERVAL 5 MINUTE)) / 1800)
when #{groupType}=3 then CEIL(UNIX_TIMESTAMP(DATE_ADD(t.start_time,INTERVAL 5 MINUTE)) / 3600)
when #{groupType}=0 then start_time
when #{groupType}=1 then DATE_FORMAT(concat( date( start_time ), ' ', HOUR ( start_time ), ':', floor( MINUTE ( start_time ) / 15 ) * 15 ),'%Y-%m-%d %H:%i:00' )
when #{groupType}=2 then DATE_FORMAT(concat( date( start_time ), ' ', HOUR ( start_time ), ':', floor( MINUTE ( start_time ) / 30 ) * 30 ),'%Y-%m-%d %H:%i:00' )
when #{groupType}=3 then DATE_FORMAT(start_time,'%Y-%m-%d %H:00:00' )
when #{groupType}=4 then DATE_FORMAT(start_time,'%Y-%m-%d 00:00:00' )
end
) unit_time,
cross_id,
......@@ -138,7 +140,7 @@
<!-- 绿波路口方向级指标趋势,支持按5分钟粒度、15分钟粒度、30分钟粒度、1小时粒度汇聚 -->
<select id="findGreenWaveCrossDirIndex"
resultMap="net.wanji.databus.dao.mapper.CrossDirDataHistMapper.BaseResultMap">
SELECT MIN(start_time) start_time,
SELECT MIN(ifnull(t.unit_time,#{startDate})) start_time,
cross_id,
dir_type,
round(AVG(traffic_index),2) traffic_index,
......@@ -152,10 +154,11 @@
(
SELECT start_time,
(case
when #{groupType}=0 then CEIL(UNIX_TIMESTAMP(DATE_ADD(t.start_time,INTERVAL 5 MINUTE)))
when #{groupType}=1 then CEIL(UNIX_TIMESTAMP(DATE_ADD(t.start_time,INTERVAL 5 MINUTE)) / 900)
when #{groupType}=2 then CEIL(UNIX_TIMESTAMP(DATE_ADD(t.start_time,INTERVAL 5 MINUTE)) / 1800)
when #{groupType}=3 then CEIL(UNIX_TIMESTAMP(DATE_ADD(t.start_time,INTERVAL 5 MINUTE)) / 3600)
when #{groupType}=0 then start_time
when #{groupType}=1 then DATE_FORMAT(concat( date( start_time ), ' ', HOUR ( start_time ), ':', floor( MINUTE ( start_time ) / 15 ) * 15 ),'%Y-%m-%d %H:%i:00' )
when #{groupType}=2 then DATE_FORMAT(concat( date( start_time ), ' ', HOUR ( start_time ), ':', floor( MINUTE ( start_time ) / 30 ) * 30 ),'%Y-%m-%d %H:%i:00' )
when #{groupType}=3 then DATE_FORMAT(start_time,'%Y-%m-%d %H:00:00' )
when #{groupType}=4 then DATE_FORMAT(start_time,'%Y-%m-%d 00:00:00' )
end
) unit_time,
cross_id,
......@@ -182,7 +185,7 @@
<!-- 绿波路口转向级指标趋势,支持按5分钟粒度、15分钟粒度、30分钟粒度、1小时粒度汇聚 -->
<select id="findGreenWaveCrossTurnIndex"
resultMap="net.wanji.databus.dao.mapper.CrossTurnDataHistMapper.BaseResultMap">
SELECT MIN(start_time) start_time,
SELECT MIN(ifnull(t.unit_time,#{startDate})) start_time,
cross_id crossId,
in_dir,
turn_type,
......@@ -197,10 +200,11 @@
(
SELECT start_time,
(case
when #{groupType}=0 then CEIL(UNIX_TIMESTAMP(DATE_ADD(t.start_time,INTERVAL 5 MINUTE)))
when #{groupType}=1 then CEIL(UNIX_TIMESTAMP(DATE_ADD(t.start_time,INTERVAL 5 MINUTE)) / 900)
when #{groupType}=2 then CEIL(UNIX_TIMESTAMP(DATE_ADD(t.start_time,INTERVAL 5 MINUTE)) / 1800)
when #{groupType}=3 then CEIL(UNIX_TIMESTAMP(DATE_ADD(t.start_time,INTERVAL 5 MINUTE)) / 3600)
when #{groupType}=0 then start_time
when #{groupType}=1 then DATE_FORMAT(concat( date( start_time ), ' ', HOUR ( start_time ), ':', floor( MINUTE ( start_time ) / 15 ) * 15 ),'%Y-%m-%d %H:%i:00' )
when #{groupType}=2 then DATE_FORMAT(concat( date( start_time ), ' ', HOUR ( start_time ), ':', floor( MINUTE ( start_time ) / 30 ) * 30 ),'%Y-%m-%d %H:%i:00' )
when #{groupType}=3 then DATE_FORMAT(start_time,'%Y-%m-%d %H:00:00' )
when #{groupType}=4 then DATE_FORMAT(start_time,'%Y-%m-%d 00:00:00' )
end
) unit_time,
cross_id,
......@@ -225,10 +229,10 @@
GROUP BY t.cross_id,t.in_dir,t.turn_type,unit_time
</select>
<!-- 绿波路口车道级指标趋势,支持按5分钟粒度、15分钟粒度、30分钟粒度、1小时粒度汇聚 -->
<!-- 统一接口:绿波路口车道级指标趋势,支持按5分钟粒度、15分钟粒度、30分钟粒度、1小时粒度汇聚 -->
<select id="findGreenWaveCrossLaneIndex"
resultType="net.wanji.opt.po.base.CrossLaneDataHistPoExtend">
SELECT MIN(start_time) start_time ,
SELECT MIN(ifnull(t.unit_time,#{startDate})) start_time,
cross_id ,
lane_id ,
dir_type ,
......@@ -245,10 +249,11 @@
(
SELECT start_time,
(case
when #{groupType}=0 then CEIL(UNIX_TIMESTAMP(DATE_ADD(t.start_time,INTERVAL 5 MINUTE)))
when #{groupType}=1 then CEIL(UNIX_TIMESTAMP(DATE_ADD(t.start_time,INTERVAL 5 MINUTE)) / 900)
when #{groupType}=2 then CEIL(UNIX_TIMESTAMP(DATE_ADD(t.start_time,INTERVAL 5 MINUTE)) / 1800)
when #{groupType}=3 then CEIL(UNIX_TIMESTAMP(DATE_ADD(t.start_time,INTERVAL 5 MINUTE)) / 3600)
when #{groupType}=0 then start_time
when #{groupType}=1 then DATE_FORMAT(concat( date( start_time ), ' ', HOUR ( start_time ), ':', floor( MINUTE ( start_time ) / 15 ) * 15 ),'%Y-%m-%d %H:%i:00' )
when #{groupType}=2 then DATE_FORMAT(concat( date( start_time ), ' ', HOUR ( start_time ), ':', floor( MINUTE ( start_time ) / 30 ) * 30 ),'%Y-%m-%d %H:%i:00' )
when #{groupType}=3 then DATE_FORMAT(start_time,'%Y-%m-%d %H:00:00' )
when #{groupType}=4 then DATE_FORMAT(start_time,'%Y-%m-%d 00:00:00' )
end
) unit_time,
t.cross_id,
......@@ -269,7 +274,7 @@
<when test="objectType==3">
t.id as lane_id,
t2.dir as dir_type,
t2.sort as turn_type,
t2.turn as turn_type,
</when>
<otherwise>
</otherwise>
......@@ -324,9 +329,6 @@
</select>
<!-- 查看干线拥堵运行状态 -->
<select id="findGreenWaveRunState" resultType="net.wanji.opt.vo.GreenWaveRunStateVO">
select type as state,count(*) count,
......@@ -346,6 +348,119 @@
GROUP BY type
</select>
<!-- 查看路口出口道方向、出口车道信息 -->
<select id="findCrossExitRoadLaneInfo" resultType="map">
select t2.start_cross_id,t2.end_cross_id,t1.rid,t1.id lane_id,t1.type,t1.dir,t1.turn
from t_base_lane_info t1
JOIN (
select id,start_cross_id,end_cross_id,in_dir as dir, 2 as type
from t_base_rid_info
where 1=1
<if test="crossId!=null and crossId !=''">
and start_cross_id = #{crossId}
</if>
) t2 on t1.rid=t2.id and t1.type=t2.type
</select>
<!-- 查看路口出口道方向信息 -->
<select id="findCrossExitRoadDirInfo" resultType="map">
select id,start_cross_id,end_cross_id,in_dir as dir
from t_base_rid_info
where 1=1
<if test="crossId!=null and crossId !=''">
and start_cross_id = #{crossId}
</if>
</select>
<!-- 路口各出口方向路段指标 -->
<select id="findCrossExitRoadIndex"
resultType="net.wanji.opt.po.base.CrossLaneDataHistPoExtend">
select t1.start_cross_id as cross_id,
t1.dir as dir_type,
MIN(ifnull(t2.unit_time,#{startDate})) start_time,
round(AVG(t2.traffic_index),2) traffic_index,
SUM(t2.flow) flow,
round(AVG(t2.speed),2) speed,
MAX(t2.queue_length) max_queue_length,
MIN(t2.queue_length) min_queue_length,
round(AVG(t2.queue_length)) avg_queue_length,
round(AVG(t2.stop_times),2) stop_times,
round(AVG(t2.delay_time),2) delay_time,
round(AVG(t2.sturation),4) sturation
from
(
select id,start_cross_id,end_cross_id,in_dir as dir, 2 as type
from t_base_rid_info
where 1=1 <if test="crossId!=null and crossId !=''">
and start_cross_id = #{crossId}
</if>
) t1
left join (
SELECT cross_id,dir_type,start_time,flow,speed,queue_length,stop_times,delay_time,sturation ,traffic_index,
(case
when #{groupType}=0 then start_time
when #{groupType}=1 then DATE_FORMAT(concat( date( start_time ), ' ', HOUR ( start_time ), ':', floor( MINUTE ( start_time ) / 15 ) * 15 ),'%Y-%m-%d %H:%i:00' )
when #{groupType}=2 then DATE_FORMAT(concat( date( start_time ), ' ', HOUR ( start_time ), ':', floor( MINUTE ( start_time ) / 30 ) * 30 ),'%Y-%m-%d %H:%i:00' )
when #{groupType}=3 then DATE_FORMAT(start_time,'%Y-%m-%d %H:00:00' )
when #{groupType}=4 then DATE_FORMAT(start_time,'%Y-%m-%d 00:00:00' )
end
) unit_time
from t_cross_dir_data_hist
WHERE start_time > #{startDate} and start_time &lt; #{endDate}
) t2
on t2.cross_id=t1.end_cross_id and t2.dir_type=t1.dir
GROUP BY t1.start_cross_id,t1.dir,t2.unit_time
</select>
<!-- 路口各出口方向路段车道指标 -->
<select id="findCrossExitRoadLaneIndex"
resultType="net.wanji.opt.po.base.CrossLaneDataHistPoExtend">
select t1.end_cross_id as cross_id,
t1.dir as dir_type,
t1.lane_id,
t1.lane_no,
t1.turn as turn_type,
MIN(ifnull(t2.start_time,#{startDate})) start_time,
SUM(t2.flow) flow,
round(AVG(t2.speed),2) speed,
MAX(t2.queue_length) max_queue_length,
MIN(t2.queue_length) min_queue_length,
round(AVG(t2.queue_length)) avg_queue_length,
round(AVG(t2.stop_times),2) stop_times,
round(AVG(t2.delay_time),2) delay_time,
round(AVG(t2.sturation),4) sturation
from
(
select t2.start_cross_id,t2.end_cross_id,t1.rid,t1.id lane_id,sort as lane_no,t1.type,t1.dir,t1.turn
from t_base_lane_info t1
JOIN (
select id,start_cross_id,end_cross_id,out_dir as dir, 2 as type
from t_base_rid_info
where 1=1 <if test="crossId!=null and crossId !=''">
and start_cross_id = #{crossId}
</if>
) t2 on t1.cross_id=t2.end_cross_id and t1.type=t2.type and t1.dir=t2.dir
) t1
left join (
SELECT id as lane_id,cross_id,start_time,flow,speed,queue_length,stop_times,delay_time,sturation ,
(case
when #{groupType}=0 then CEIL(UNIX_TIMESTAMP(DATE_ADD(start_time,INTERVAL 5 MINUTE)))
when #{groupType}=1 then CEIL(UNIX_TIMESTAMP(DATE_ADD(start_time,INTERVAL 5 MINUTE)) / 900)
when #{groupType}=2 then CEIL(UNIX_TIMESTAMP(DATE_ADD(start_time,INTERVAL 5 MINUTE)) / 1800)
when #{groupType}=3 then CEIL(UNIX_TIMESTAMP(DATE_ADD(start_time,INTERVAL 5 MINUTE)) / 3600)
when #{groupType}=4 then CEIL(UNIX_TIMESTAMP(DATE_ADD(start_time,INTERVAL 5 MINUTE)) / (3600*24))
end
) unit_time
from t_lane_data_hist
WHERE start_time > #{startDate} and start_time &lt; #{endDate}
) t2
on t2.lane_id=t1.lane_id
GROUP BY t1.end_cross_id,t1.dir,t1.lane_id,t1.turn,t2.unit_time
ORDER BY t1.end_cross_id,t1.dir,t1.lane_no
</select>
<!--新增操作 -->
<insert id="save" parameterType="net.wanji.opt.entity.GreenwaveHist">
insert into
......
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