Commit ae02b901 authored by zhouleilei's avatar zhouleilei

Merge remote-tracking branch 'origin/master'

parents ca067886 c6c0433d
...@@ -58,12 +58,13 @@ public class EsDateIndexUtil { ...@@ -58,12 +58,13 @@ public class EsDateIndexUtil {
unitTime = 30; unitTime = 30;
}else if (Objects.equals(TimeGranularityEnum.ONE_HOUR, timeGranularityEnum)) { }else if (Objects.equals(TimeGranularityEnum.ONE_HOUR, timeGranularityEnum)) {
unitTime = 60; unitTime = 60;
}else if (Objects.equals(TimeGranularityEnum.ONE_DAY, timeGranularityEnum)) {
unitTime = 24*60*60;
} }
for (int i = 0; i <= diffNum; i=i+unitTime) { for (int i = 0; i <= diffNum; i=i+unitTime) {
String format = start.plusMinutes(i).toString(dateFormat); String format = start.plusMinutes(i).toString(dateFormat);
indexList.add(format); indexList.add(format);
} }
return indexList; return indexList;
} }
......
...@@ -208,6 +208,34 @@ public class GreenwaveHistRestServer { ...@@ -208,6 +208,34 @@ public class GreenwaveHistRestServer {
} }
@GetMapping("/findGreenWaveCrossObjectIndex")
@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 = "objectType", value = "统计对象类型 1:方向级指标 2:转向级指标 3:车道级指标", required = true, dataType = "Integer",defaultValue = "1"),
})
@ApiResponses({
@ApiResponse(code = 200, message = "成功", response = GreenwaveHist.class,
responseHeaders = {@ResponseHeader(name = "Content-Type", description = "application/json")})
})
public JsonViewObject findGreenWaveCrossObjectIndex(String crossId, String startTime, String endTime,String groupType,Integer objectType) {
JsonViewObject jsonView = JsonViewObject.newInstance();
try {
JSONObject list = greenwaveHistProvider.findGreenWaveCrossLaneIndex(crossId,startTime,endTime,groupType,objectType);
jsonView.success(list);
} catch (DubboProviderException e) {
jsonView.fail(I18nResourceBundle.getConstants("GET_FAILED_MSG"));
log.error("{} getAll error", this.getClass().getSimpleName(), e);
}
return jsonView;
}
@GetMapping("/findGreenWaveCrossIndex") @GetMapping("/findGreenWaveCrossIndex")
@ApiOperation(httpMethod="GET",value="绿波路口级->分粒度指标趋势", notes="") @ApiOperation(httpMethod="GET",value="绿波路口级->分粒度指标趋势", notes="")
@ApiImplicitParams({ @ApiImplicitParams({
......
...@@ -6,6 +6,7 @@ import net.wanji.databus.po.CrossDataHistPO; ...@@ -6,6 +6,7 @@ import net.wanji.databus.po.CrossDataHistPO;
import net.wanji.databus.po.CrossDirDataHistPO; import net.wanji.databus.po.CrossDirDataHistPO;
import net.wanji.databus.po.CrossTurnDataHistPO; import net.wanji.databus.po.CrossTurnDataHistPO;
import net.wanji.opt.entity.GreenwaveHist; import net.wanji.opt.entity.GreenwaveHist;
import net.wanji.opt.po.base.CrossLaneDataHistPoExtend;
import net.wanji.opt.vo.GreenWaveRunStateVO; import net.wanji.opt.vo.GreenWaveRunStateVO;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
...@@ -70,5 +71,13 @@ public interface GreenwaveHistoryMapper extends BaseInterfaceMapper<GreenwaveHis ...@@ -70,5 +71,13 @@ public interface GreenwaveHistoryMapper extends BaseInterfaceMapper<GreenwaveHis
*/ */
List<CrossTurnDataHistPO> findGreenWaveCrossTurnIndex(Map<String,Object> params); List<CrossTurnDataHistPO> findGreenWaveCrossTurnIndex(Map<String,Object> params);
/**
* 路口车道指标趋势数据据
* @param params
* @return
*/
List<CrossLaneDataHistPoExtend> findGreenWaveCrossLaneIndex(Map<String,Object> params);
} }
package net.wanji.opt.po.base;
import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import net.wanji.databus.po.CrossLaneDataHistPO;
import java.util.Date;
/**
* @author fengyi
* @date 2024/12/24
* @description
*/
@Data
public class CrossLaneDataHistPoExtend extends CrossLaneDataHistPO {
//车道ID
@ApiModelProperty(value = "车道ID", notes = "")
private String laneId;
//方向
@ApiModelProperty(value = "方向", notes = "")
private Integer dirType;
//转向功能
@ApiModelProperty(value = "转向功能", notes = "")
private Integer turnType;
//交通指数
@ApiModelProperty(value = "交通指数", notes = "")
private Double trafficIndex;
//最大排队长度
@ApiModelProperty(value = "最大排队长度", notes = "")
private Integer maxQueueLength;
//最小排队长度
@ApiModelProperty(value = "最小排队长度", notes = "")
private Integer minQueueLength;
//平均排队长度
@ApiModelProperty(value = "平均排队长度", notes = "")
private Integer avgQueueLength;
@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;
}
...@@ -91,4 +91,16 @@ public interface GreenwaveHistProvider extends BaseDubboInterface<GreenwaveHist> ...@@ -91,4 +91,16 @@ public interface GreenwaveHistProvider extends BaseDubboInterface<GreenwaveHist>
* @throws DubboProviderException * @throws DubboProviderException
*/ */
JSONObject findGreenWaveCrossTurnIndex(String crossId, String startTime, String endTime, String groupType) throws DubboProviderException; JSONObject findGreenWaveCrossTurnIndex(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 findGreenWaveCrossLaneIndex(String crossId, String startTime, String endTime, String groupType,Integer objectType) throws DubboProviderException;
} }
...@@ -14,11 +14,14 @@ import net.wanji.databus.po.CrossDataHistPO; ...@@ -14,11 +14,14 @@ import net.wanji.databus.po.CrossDataHistPO;
import net.wanji.databus.po.CrossDirDataHistPO; import net.wanji.databus.po.CrossDirDataHistPO;
import net.wanji.databus.po.CrossTurnDataHistPO; import net.wanji.databus.po.CrossTurnDataHistPO;
import net.wanji.databus.po.CrossTurnInfoPO; import net.wanji.databus.po.CrossTurnInfoPO;
import net.wanji.opt.bo.BottomMenuBO;
import net.wanji.opt.common.EsDateIndexUtil; import net.wanji.opt.common.EsDateIndexUtil;
import net.wanji.opt.common.enums.TimeGranularityEnum; import net.wanji.opt.common.enums.TimeGranularityEnum;
import net.wanji.opt.dao.mapper.GreenwaveHistoryMapper; import net.wanji.opt.dao.mapper.GreenwaveHistoryMapper;
import net.wanji.opt.entity.GreenwaveHist; import net.wanji.opt.entity.GreenwaveHist;
import net.wanji.opt.po.base.CrossLaneDataHistPoExtend;
import net.wanji.opt.service.GreenwaveHistProvider; import net.wanji.opt.service.GreenwaveHistProvider;
import net.wanji.opt.service.MainlineEvaluateService;
import net.wanji.opt.vo.GreenWaveRunStateVO; import net.wanji.opt.vo.GreenWaveRunStateVO;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.dubbo.config.annotation.DubboService; import org.apache.dubbo.config.annotation.DubboService;
...@@ -60,6 +63,8 @@ public class GreenwaveHistProviderImpl extends BaseDubboInterfaceImpl<GreenwaveH ...@@ -60,6 +63,8 @@ public class GreenwaveHistProviderImpl extends BaseDubboInterfaceImpl<GreenwaveH
@Resource @Resource
private GreenwaveHistoryMapper greenwaveHistoryMapper; private GreenwaveHistoryMapper greenwaveHistoryMapper;
@Resource
private MainlineEvaluateService mainlineEvaluateService;
@Override @Override
public BaseInterfaceMapper<GreenwaveHist> getBaseInterfaceMapper() { public BaseInterfaceMapper<GreenwaveHist> getBaseInterfaceMapper() {
...@@ -350,7 +355,7 @@ public class GreenwaveHistProviderImpl extends BaseDubboInterfaceImpl<GreenwaveH ...@@ -350,7 +355,7 @@ public class GreenwaveHistProviderImpl extends BaseDubboInterfaceImpl<GreenwaveH
//按方向排序 //按方向排序
List<CrossTurnDataHistPO> value = entry.getValue().stream().sorted(Comparator.comparing(o -> o.getStartTime())).collect(Collectors.toList()); 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(), "HH:mm")).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) { for (String timeSec : sortedSet) {
if (!timeList.contains(timeSec)) { if (!timeList.contains(timeSec)) {
...@@ -377,20 +382,108 @@ public class GreenwaveHistProviderImpl extends BaseDubboInterfaceImpl<GreenwaveH ...@@ -377,20 +382,108 @@ public class GreenwaveHistProviderImpl extends BaseDubboInterfaceImpl<GreenwaveH
jsonObject.put("dataList", allList); jsonObject.put("dataList", allList);
jsonObject.put("dirList", groupByDir.keySet()); jsonObject.put("dirList", groupByDir.keySet());
return jsonObject; return jsonObject;
} }
/** @Override
* 获取随机数 public JSONObject findGreenWaveCrossLaneIndex(String crossId, String startTime, String endTime, String groupType,Integer objectType) throws DubboProviderException {
* Map<String, Object> params = new HashMap<>();
* @param max params.put("crossId", crossId);
* @param min params.put("startDate", startTime);
* @return params.put("endDate", endTime);
*/ params.put("groupType", groupType);
public static int getRandomValue(int max, int min) { params.put("objectType", objectType);
Random random = new Random();
int num = random.nextInt(max + 1 - min) + min; //存放时段
return num; 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));
}
//======================================================================================================//
//存放所有进口数据
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()));
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<>();
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)) {
dirName = BaseEnum.SignalDirectionEnum.getNameByCode(dirType);
turnDesc = TurnConvertEnum.getDescByKey(Integer.valueOf(sps[3]));
dirTurnDesc = dirName + "进口" + turnDesc;
} 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());
mapList.put("scopeCode", key);
mapList.put("scopeName", dirTurnDesc);
mapList.put("list", value);
allList.add(mapList);
}
BottomMenuBO bo = new BottomMenuBO();
bo.setCrossId(crossId);
bo.setScope(objectType);
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("dataList", allList);
jsonObject.put("scopeList", scopeList);
return jsonObject;
} }
} }
...@@ -452,9 +452,9 @@ public class TrendServiceImpl implements TrendService { ...@@ -452,9 +452,9 @@ public class TrendServiceImpl implements TrendService {
abnormalCrossDetailVO.setCrossStopTimes(crossDataRealtimePO.getStopTimes()); abnormalCrossDetailVO.setCrossStopTimes(crossDataRealtimePO.getStopTimes());
abnormalCrossDetailVO.setSpeed(crossDataRealtimePO.getSpeed()); abnormalCrossDetailVO.setSpeed(crossDataRealtimePO.getSpeed());
Double sturation = crossDataRealtimePO.getSturation(); Double sturation = crossDataRealtimePO.getSturation();
abnormalCrossDetailVO.setSturation((double) Math.round(sturation) * 100); abnormalCrossDetailVO.setSturation((int)(sturation * 100));
String serviceLevel = CrossUtil.getServiceLevel(sturation); //String serviceLevel = CrossUtil.getServiceLevel(sturation);
abnormalCrossDetailVO.setServiceLevel(serviceLevel); abnormalCrossDetailVO.setServiceLevel(crossDataRealtimePO.getServiceLevel());
abnormalCrossDetailVO.setHourFlow(crossDataRealtimePO.getFlow() * 12); abnormalCrossDetailVO.setHourFlow(crossDataRealtimePO.getFlow() * 12);
BigDecimal bigDecimal = BigDecimal.valueOf(crossDataRealtimePO.getTrafficIndex()).setScale(2, RoundingMode.HALF_UP); BigDecimal bigDecimal = BigDecimal.valueOf(crossDataRealtimePO.getTrafficIndex()).setScale(2, RoundingMode.HALF_UP);
abnormalCrossDetailVO.setCongestionIndex(bigDecimal); abnormalCrossDetailVO.setCongestionIndex(bigDecimal);
......
...@@ -120,9 +120,14 @@ public class GreenBeltServiceImpl implements GreenBeltInfoService { ...@@ -120,9 +120,14 @@ public class GreenBeltServiceImpl implements GreenBeltInfoService {
int end = (int) (System.currentTimeMillis() / 1000) + 300; int end = (int) (System.currentTimeMillis() / 1000) + 300;
List<CrossDirDataHistPO> dirDataHistPOS = crossDirDataHistMapper.selectDirDataList(crossId, dirList, start, end); List<CrossDirDataHistPO> dirDataHistPOS = crossDirDataHistMapper.selectDirDataList(crossId, dirList, start, end);
if (!CollectionUtils.isEmpty(dirDataHistPOS)) { if (!CollectionUtils.isEmpty(dirDataHistPOS)) {
Map<Integer, List<CrossDirDataHistPO>> dirHistMap = dirDataHistPOS.stream().collect(Collectors.groupingBy(CrossDirDataHistPO::getDirType));
Integer dir = null;
for (Map.Entry<Integer, List<CrossDirDataHistPO>> entry : dirHistMap.entrySet()) {
dir = entry.getKey();
List<CrossDirDataHistPO> value = entry.getValue();
Double greenTimeRatio = 0.0; Double greenTimeRatio = 0.0;
List<GreenBeltKeyCrossFlowTimeVO.Detail> details = new ArrayList<>(); List<GreenBeltKeyCrossFlowTimeVO.Detail> details = new ArrayList<>();
for (CrossDirDataHistPO dirDataHistPO : dirDataHistPOS) { for (CrossDirDataHistPO dirDataHistPO : value) {
GreenBeltKeyCrossFlowTimeVO.Detail detail = new GreenBeltKeyCrossFlowTimeVO.Detail(); GreenBeltKeyCrossFlowTimeVO.Detail detail = new GreenBeltKeyCrossFlowTimeVO.Detail();
detail.setCrossId(crossId); detail.setCrossId(crossId);
String crossName = baseCrossInfoCache.getCrossName(crossId); String crossName = baseCrossInfoCache.getCrossName(crossId);
...@@ -140,34 +145,29 @@ public class GreenBeltServiceImpl implements GreenBeltInfoService { ...@@ -140,34 +145,29 @@ public class GreenBeltServiceImpl implements GreenBeltInfoService {
} }
if (StringUtils.equalsIgnoreCase(crossId, optResult.getCrossId()) && Objects.equals(curDir, dirType) if (StringUtils.equalsIgnoreCase(crossId, optResult.getCrossId()) && Objects.equals(curDir, dirType)
&& dirDataHistPO.getStartTime().getTime() == optResult.getStartTime().getTime()) { && dirDataHistPO.getStartTime().getTime() == optResult.getStartTime().getTime()) {
detail.setGreenTimeRatio(optResult.getGreenTimeRatio()); detail.setGreenTimeRatio(optResult.getGreenTimeRatio() * 100);
greenTimeRatio = optResult.getGreenTimeRatio(); greenTimeRatio = optResult.getGreenTimeRatio() * 100;
} }
} }
details.add(detail); details.add(detail);
} }
if (!CollectionUtils.isEmpty(details)) { if (!CollectionUtils.isEmpty(details)) {
Map<String, List<GreenBeltKeyCrossFlowTimeVO.Detail>> dirMap = details.stream().collect(Collectors.groupingBy(GreenBeltKeyCrossFlowTimeVO.Detail::getDir));
for (Map.Entry<String, List<GreenBeltKeyCrossFlowTimeVO.Detail>> entry : dirMap.entrySet()) {
String dir = entry.getKey();
GreenBeltKeyCrossFlowTimeVO greenBeltKeyCrossFlowTimeVO = new GreenBeltKeyCrossFlowTimeVO(); GreenBeltKeyCrossFlowTimeVO greenBeltKeyCrossFlowTimeVO = new GreenBeltKeyCrossFlowTimeVO();
List<GreenBeltKeyCrossFlowTimeVO.Detail> value = entry.getValue();
String crossName = ""; String crossName = "";
if (!CollectionUtils.isEmpty(value)) { if (!CollectionUtils.isEmpty(value)) {
GreenBeltKeyCrossFlowTimeVO.Detail detail = value.get(0); GreenBeltKeyCrossFlowTimeVO.Detail detail = details.get(0);
crossName = detail.getCrossName(); crossName = detail.getCrossName();
} }
greenBeltKeyCrossFlowTimeVO.setCrossName(crossName); greenBeltKeyCrossFlowTimeVO.setCrossName(crossName);
greenBeltKeyCrossFlowTimeVO.setDirName(GreenBeltDirEnum.getInDirName(Integer.valueOf(dir))); greenBeltKeyCrossFlowTimeVO.setDirName(GreenBeltDirEnum.getInDirName(Integer.valueOf(dir)));
List<GreenBeltKeyCrossFlowTimeVO.Detail> collect = value.stream().sorted(Comparator.comparing(GreenBeltKeyCrossFlowTimeVO.Detail::getStartTime)).collect(Collectors.toList()); List<GreenBeltKeyCrossFlowTimeVO.Detail> collect = details.stream().sorted(Comparator.comparing(GreenBeltKeyCrossFlowTimeVO.Detail::getStartTime)).collect(Collectors.toList());
greenBeltKeyCrossFlowTimeVO.setDetailList(collect); greenBeltKeyCrossFlowTimeVO.setDetailList(collect);
results.add(greenBeltKeyCrossFlowTimeVO); results.add(greenBeltKeyCrossFlowTimeVO);
} }
} }
} }
// 关键路口历史数据
return results; return results;
} catch (Exception e) { } catch (Exception e) {
log.error("绿波关键路口流量绿信比查询异常:", e); log.error("绿波关键路口流量绿信比查询异常:", e);
......
package net.wanji.opt.vo; package net.wanji.opt.vo;
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
...@@ -21,10 +22,13 @@ public class AbnormalCrossDetailVO { ...@@ -21,10 +22,13 @@ public class AbnormalCrossDetailVO {
@ApiModelProperty(value = "路口状态:0正常;1失衡;2拥堵;3溢出") @ApiModelProperty(value = "路口状态:0正常;1失衡;2拥堵;3溢出")
private Integer crossStatus; private Integer crossStatus;
@ApiModelProperty(value = "最大排队") @ApiModelProperty(value = "最大排队")
@JsonSerialize(using = net.wanji.common.framework.DoubleSerialize.class)
private Double crossQueueLength; private Double crossQueueLength;
@ApiModelProperty(value = "流率") @ApiModelProperty(value = "流率")
@JsonSerialize(using = net.wanji.common.framework.DoubleSerialize.class)
private Double crossFlowRate; private Double crossFlowRate;
@ApiModelProperty(value = "平均停车次数") @ApiModelProperty(value = "平均停车次数")
@JsonSerialize(using = net.wanji.common.framework.DoubleSerialize.class)
private Double crossStopTimes; private Double crossStopTimes;
@ApiModelProperty(value = "拥堵指数") @ApiModelProperty(value = "拥堵指数")
private BigDecimal congestionIndex; private BigDecimal congestionIndex;
...@@ -35,9 +39,10 @@ public class AbnormalCrossDetailVO { ...@@ -35,9 +39,10 @@ public class AbnormalCrossDetailVO {
@ApiModelProperty(value = "方向实时数据") @ApiModelProperty(value = "方向实时数据")
private List<DirDataElement> dirData; private List<DirDataElement> dirData;
@ApiModelProperty(value = "平均速度") @ApiModelProperty(value = "平均速度")
@JsonSerialize(using = net.wanji.common.framework.DoubleSerialize.class)
private Double speed; private Double speed;
@ApiModelProperty(value = "饱和度") @ApiModelProperty(value = "饱和度")
private Double sturation; private Integer sturation;
@ApiModelProperty(value = "路口服务水平") @ApiModelProperty(value = "路口服务水平")
private String serviceLevel; private String serviceLevel;
@ApiModelProperty(value = "小时流量") @ApiModelProperty(value = "小时流量")
......
...@@ -94,6 +94,47 @@ ...@@ -94,6 +94,47 @@
GROUP BY t.cross_id, DATE_FORMAT(start_time, '%Y-%m-%d %H:%i:00') GROUP BY t.cross_id, DATE_FORMAT(start_time, '%Y-%m-%d %H:%i:00')
; ;
</select> </select>
<!-- 绿波路口级指标趋势,支持按5分钟、15分钟粒度、30分钟粒度、1小时粒度汇聚 -->
<select id="findGreenWaveCrossIndex" resultMap="net.wanji.databus.dao.mapper.CrossDataHistMapper.BaseResultMap">
SELECT MIN(start_time) start_time,
cross_id,
AVG(traffic_index) traffic_index,
SUM(flow) flow,
round(AVG(speed),2) speed,
MAX(queue_length) queue_length,
round(AVG(stop_times),2) stop_times,
round(AVG(delay_time),0) delay_time,
round(AVG(sturation),4) sturation
FROM
(
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)
end
) unit_time,
cross_id,
(traffic_index) traffic_index,
(flow) flow,
(speed) speed,
(queue_length) queue_length,
(stop_times) stop_times,
(delay_time) delay_time,
(sturation) sturation
FROM t_cross_data_hist t
where 1=1
<if test="crossId!=null and crossId !=''">
and cross_id = #{crossId}
</if>
<if test="startDate !=null and endDate !=null">
AND start_time >= #{startDate} and start_time &lt; #{endDate}
</if>
) t
GROUP BY t.cross_id,unit_time
</select>
<!-- 绿波路口方向级指标趋势,支持按5分钟粒度、15分钟粒度、30分钟粒度、1小时粒度汇聚 --> <!-- 绿波路口方向级指标趋势,支持按5分钟粒度、15分钟粒度、30分钟粒度、1小时粒度汇聚 -->
<select id="findGreenWaveCrossDirIndex" <select id="findGreenWaveCrossDirIndex"
resultMap="net.wanji.databus.dao.mapper.CrossDirDataHistMapper.BaseResultMap"> resultMap="net.wanji.databus.dao.mapper.CrossDirDataHistMapper.BaseResultMap">
...@@ -138,11 +179,11 @@ ...@@ -138,11 +179,11 @@
GROUP BY t.cross_id,t.dir_type,unit_time GROUP BY t.cross_id,t.dir_type,unit_time
</select> </select>
<!-- 绿波路口向级指标趋势,支持按5分钟粒度、15分钟粒度、30分钟粒度、1小时粒度汇聚 --> <!-- 绿波路口向级指标趋势,支持按5分钟粒度、15分钟粒度、30分钟粒度、1小时粒度汇聚 -->
<select id="findGreenWaveCrossTurnIndex" <select id="findGreenWaveCrossTurnIndex"
resultMap="net.wanji.databus.dao.mapper.CrossTurnDataHistMapper.BaseResultMap"> resultMap="net.wanji.databus.dao.mapper.CrossTurnDataHistMapper.BaseResultMap">
SELECT MIN(start_time) start_time, SELECT MIN(start_time) start_time,
cross_id, cross_id crossId,
in_dir, in_dir,
turn_type, turn_type,
round(AVG(traffic_index),2) traffic_index, round(AVG(traffic_index),2) traffic_index,
...@@ -184,47 +225,108 @@ ...@@ -184,47 +225,108 @@
GROUP BY t.cross_id,t.in_dir,t.turn_type,unit_time GROUP BY t.cross_id,t.in_dir,t.turn_type,unit_time
</select> </select>
<!-- 绿波路口车道级指标趋势,支持按5分钟粒度、15分钟粒度、30分钟粒度、1小时粒度汇聚 -->
<!-- 绿波路口级指标趋势,支持按5分钟、15分钟粒度、30分钟粒度、1小时粒度汇聚 --> <select id="findGreenWaveCrossLaneIndex"
<select id="findGreenWaveCrossIndex" resultMap="net.wanji.databus.dao.mapper.CrossDataHistMapper.BaseResultMap"> resultType="net.wanji.opt.po.base.CrossLaneDataHistPoExtend">
SELECT MIN(start_time) start_time, SELECT MIN(start_time) start_time ,
cross_id, cross_id ,
AVG(traffic_index), lane_id ,
dir_type ,
turn_type ,
SUM(flow) flow, SUM(flow) flow,
round(AVG(speed),2) speed, round(AVG(speed),2) speed,
MAX(queue_length) queue_length, MAX(queue_length) max_queue_length,
MIN(queue_length) min_queue_length,
round(AVG(queue_length)) avg_queue_length,
round(AVG(stop_times),2) stop_times, round(AVG(stop_times),2) stop_times,
round(AVG(delay_time),0) delay_time, round(AVG(delay_time),2) delay_time,
round(AVG(sturation),4) sturation round(AVG(sturation),4) sturation
FROM FROM
( (
SELECT start_time, SELECT start_time,
(case (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}=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}=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}=3 then CEIL(UNIX_TIMESTAMP(DATE_ADD(t.start_time,INTERVAL 5 MINUTE)) / 3600)
end end
) unit_time, ) unit_time,
cross_id, t.cross_id,
(traffic_index) traffic_index, <choose>
(flow) flow, <!-- 方向级 -->
(speed) speed, <when test="objectType==1">
(queue_length) queue_length, dir_type,
(stop_times) stop_times, null as lane_id,
(delay_time) delay_time, null as turn_type,
(sturation) sturation </when>
FROM t_cross_data_hist t <!-- 转向级 -->
<when test="objectType==2">
t.in_dir as dir_type,
t.turn_type,
null as lane_id,
</when>
<!-- 车道级 -->
<when test="objectType==3">
t.id as lane_id,
t2.dir as dir_type,
t2.sort as turn_type,
</when>
<otherwise>
</otherwise>
</choose>
flow,
speed,
queue_length,
stop_times,
delay_time,
sturation
<choose>
<!-- 方向级 -->
<when test="objectType==1">
FROM t_cross_dir_data_hist t
</when>
<!-- 转向级 -->
<when test="objectType==2">
FROM t_cross_turn_data_hist t
</when>
<!-- 车道级 -->
<when test="objectType==3">
FROM t_lane_data_hist t join t_base_lane_info t2 on t.id=t2.id
</when>
<!-- 路口级 -->
<otherwise>
</otherwise>
</choose>
where 1=1 where 1=1
<if test="crossId!=null and crossId !=''"> <if test="crossId!=null and crossId !=''">
and cross_id = #{crossId} and t.cross_id = #{crossId}
</if> </if>
<if test="startDate !=null and endDate !=null"> <if test="startDate !=null and endDate !=null">
AND start_time >= #{startDate} and start_time &lt; #{endDate} AND start_time >= #{startDate} and start_time &lt; #{endDate}
</if> </if>
) t ) t
GROUP BY t.cross_id,unit_time <choose>
<!-- 方向级 -->
<when test="objectType==1">
GROUP BY t.cross_id,t.dir_type,unit_time
</when>
<!-- 转向级 -->
<when test="objectType==2">
GROUP BY t.cross_id,t.dir_type,t.turn_type,unit_time
</when>
<!-- 车道级 -->
<when test="objectType==3">
GROUP BY t.cross_id,t.lane_id,t.dir_type,t.turn_type,unit_time
</when>
<otherwise>
</otherwise>
</choose>
</select> </select>
<!-- 查看干线拥堵运行状态 --> <!-- 查看干线拥堵运行状态 -->
<select id="findGreenWaveRunState" resultType="net.wanji.opt.vo.GreenWaveRunStateVO"> <select id="findGreenWaveRunState" resultType="net.wanji.opt.vo.GreenWaveRunStateVO">
select type as state,count(*) count, select type as state,count(*) count,
......
...@@ -26,6 +26,10 @@ public enum DataBrainControlModeEnum { ...@@ -26,6 +26,10 @@ public enum DataBrainControlModeEnum {
SELF_ADAPTION(20, 23, "单点自适应控制"), SELF_ADAPTION(20, 23, "单点自适应控制"),
LINE_COORDINATE(21, 31, "线协调控制"), LINE_COORDINATE(21, 31, "线协调控制"),
REGION_COORDINATE(21, 41, "区域协调控制"), REGION_COORDINATE(21, 41, "区域协调控制"),
MANUAL_CONTROL(31, 51, "手动控制"),
MANUAL_LOCK(31, 52, "手动控制-锁定阶段"),
MANUAL_TEMP_SCHEME(31, 53, "手动控制-指定方案"),
MANUAL_LOCK_CHANNEL(31, 54, "手动控制-锁定通道"),
TEMP_PLAN(255, 53, "临时方案"); TEMP_PLAN(255, 53, "临时方案");
private Integer wjControl; private Integer wjControl;
......
...@@ -16,7 +16,8 @@ import java.util.Map; ...@@ -16,7 +16,8 @@ import java.util.Map;
@ApiModel(value = "LightsStatusVO", description = "实时灯态信息实体") @ApiModel(value = "LightsStatusVO", description = "实时灯态信息实体")
public class LightsStatusVO extends BaseCrossInfo { public class LightsStatusVO extends BaseCrossInfo {
@ApiModelProperty(value = "运行模式 `2=手动锁定当前相位`,`3=手动全红`,`4=手动黄闪`,`5=手动关灯`," + @ApiModelProperty(value = "运行模式 `2=手动锁定当前相位`,`3=手动全红`,`4=手动黄闪`,`5=手动关灯`," +
"`6=全红闪控制`,`7=全黄控制`,`8=正常按计划运行`,`9=手动步进控制`,`10=自动步进控制`,`11=恢复时间表`,`255=临时控制方案`") "`6=全红闪控制`,`7=全黄控制`,`8=正常按计划运行`,`9=手动步进控制`,`10=自动步进控制`,`11=恢复时间表`," +
"`20=单点自适应控制`,`21=绿波协调`,`31=手动控制`,`255=临时控制方案`")
private String runMode; private String runMode;
@ApiModelProperty(value = "控制模式") @ApiModelProperty(value = "控制模式")
private String controlMode; private String controlMode;
......
...@@ -18,7 +18,8 @@ import java.util.List; ...@@ -18,7 +18,8 @@ import java.util.List;
@ApiModel(value = "LightsStatusVO2", description = "实时灯态信息实体版本2") @ApiModel(value = "LightsStatusVO2", description = "实时灯态信息实体版本2")
public class LightsStatusVO2 extends BaseCrossInfo { public class LightsStatusVO2 extends BaseCrossInfo {
@ApiModelProperty(value = "运行模式 `2=手动锁定当前相位`,`3=手动全红`,`4=手动黄闪`,`5=手动关灯`," + @ApiModelProperty(value = "运行模式 `2=手动锁定当前相位`,`3=手动全红`,`4=手动黄闪`,`5=手动关灯`," +
"`6=全红闪控制`,`7=全黄控制`,`8=正常按计划运行`,`9=手动步进控制`,`10=自动步进控制`,`11=恢复时间表`,`20=单点自适应控制`,`21=绿波协调`,`255=临时控制方案`") "`6=全红闪控制`,`7=全黄控制`,`8=正常按计划运行`,`9=手动步进控制`,`10=自动步进控制`,`11=恢复时间表`," +
"`20=单点自适应控制`,`21=绿波协调`,`31=手动控制`,`255=临时控制方案`")
private String runMode; private String runMode;
@ApiModelProperty(value = "控制模式") @ApiModelProperty(value = "控制模式")
private String controlMode; private String controlMode;
......
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