Commit 2d8d14d1 authored by zhoushiguang's avatar zhoushiguang

场景详细评价平均指标

parent 92d4f9ad
...@@ -33,6 +33,7 @@ import org.springframework.web.bind.annotation.RestController; ...@@ -33,6 +33,7 @@ import org.springframework.web.bind.annotation.RestController;
import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MediaType;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Objects;
/** /**
* <p> * <p>
...@@ -239,10 +240,10 @@ public class GreenwaveHistRestServer { ...@@ -239,10 +240,10 @@ public class GreenwaveHistRestServer {
@GetMapping("/findCrossObjectIndex") @GetMapping("/findCrossObjectIndex")
@ApiOperation(httpMethod="GET",value="路口进口【方向级、转向级、车道级】->分粒度指标趋势", notes="") @ApiOperation(httpMethod="GET",value="路口进口【方向级、转向级、车道级】->分粒度指标趋势", notes="")
@ApiImplicitParams({ @ApiImplicitParams({
@ApiImplicitParam(name = "crossId", value = "路口ID", required = true, dataType = "String",defaultValue = "13MOD0B5SI0"), @ApiImplicitParam(name = "crossId", value = "路口ID", required = true, dataType = "String",defaultValue = "13O1V0B5SB0"),
@ApiImplicitParam(name = "groupType", value = "时间粒度类型 0:5分钟粒度 1:15分钟粒度 2:30分钟粒度 3:小时粒度 4:天粒度 5:按时间范围直接做平均【不分粒度】", required = true, dataType = "Integer",defaultValue = "1"), @ApiImplicitParam(name = "groupType", value = "时间粒度类型 0:5分钟粒度 1:15分钟粒度 2:30分钟粒度 3:小时粒度 4:天粒度 5:按时间范围直接做平均【不分粒度】", 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 = "startTime", value = "截止时间,格式:yyyy-MM-dd HH:mm:ss", required = true, dataType = "String",defaultValue = "2025-01-13 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 = "endTime", value = "截止时间,格式:yyyy-MM-dd HH:mm:ss", required = true, dataType = "String",defaultValue = "2025-01-13 23:59:59"),
@ApiImplicitParam(name = "objectType", value = "统计对象类型 1:方向级指标 2:转向级指标 3:车道级指标 4:路口级指标", required = true, dataType = "Integer",defaultValue = "1"), @ApiImplicitParam(name = "objectType", value = "统计对象类型 1:方向级指标 2:转向级指标 3:车道级指标 4:路口级指标", required = true, dataType = "Integer",defaultValue = "1"),
}) })
@ApiResponses({ @ApiResponses({
...@@ -253,7 +254,12 @@ public class GreenwaveHistRestServer { ...@@ -253,7 +254,12 @@ public class GreenwaveHistRestServer {
JsonViewObject jsonView = JsonViewObject.newInstance(); JsonViewObject jsonView = JsonViewObject.newInstance();
try { try {
JSONObject list = greenwaveHistProvider.findGreenWaveCrossLaneIndex(crossId,startTime,endTime,groupType,objectType); JSONObject list = null;
if (Objects.equals("5",groupType)) {
list = greenwaveHistProvider.findCrossAvgIndex(crossId,startTime,endTime,groupType,objectType);
}else {
list = greenwaveHistProvider.findGreenWaveCrossLaneIndex(crossId,startTime,endTime,groupType,objectType);
}
jsonView.success(list); jsonView.success(list);
} catch (DubboProviderException e) { } catch (DubboProviderException e) {
jsonView.fail(I18nResourceBundle.getConstants("GET_FAILED_MSG")); jsonView.fail(I18nResourceBundle.getConstants("GET_FAILED_MSG"));
......
...@@ -23,9 +23,13 @@ public class CrossLaneDataHistPoExtend { ...@@ -23,9 +23,13 @@ public class CrossLaneDataHistPoExtend {
//方向 //方向
@ApiModelProperty(value = "方向", notes = "") @ApiModelProperty(value = "方向", notes = "")
private Integer dirType; private Integer dirType;
@ApiModelProperty(value = "方向描述", notes = "")
private String dirTypeName;
//转向功能 //转向功能
@ApiModelProperty(value = "转向功能", notes = "") @ApiModelProperty(value = "转向功能", notes = "")
private Integer turnType; private Integer turnType;
@ApiModelProperty(value = "转向功能描述", notes = "")
private String turnTypeName;
//交通指数 //交通指数
@ApiModelProperty(value = "交通指数", notes = "") @ApiModelProperty(value = "交通指数", notes = "")
private Double trafficIndex; private Double trafficIndex;
......
...@@ -128,4 +128,16 @@ public interface GreenwaveHistProvider extends BaseDubboInterface<GreenwaveHist> ...@@ -128,4 +128,16 @@ public interface GreenwaveHistProvider extends BaseDubboInterface<GreenwaveHist>
* @throws DubboProviderException * @throws DubboProviderException
*/ */
JSONObject findCrossExitRoadDirInfo(String crossId, String startTime, String endTime, String groupType,Integer objectType) throws DubboProviderException; JSONObject findCrossExitRoadDirInfo(String crossId, String startTime, String endTime, String groupType,Integer objectType) throws DubboProviderException;
/**
*
* @param crossId
* @param startTime
* @param endTime
* @param groupType
* @param objectType
* @return
* @throws DubboProviderException
*/
JSONObject findCrossAvgIndex(String crossId, String startTime, String endTime, String groupType, Integer objectType) throws DubboProviderException;
} }
...@@ -2,6 +2,7 @@ package net.wanji.opt.service.impl; ...@@ -2,6 +2,7 @@ package net.wanji.opt.service.impl;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import io.swagger.models.auth.In;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import net.wanji.common.enums.BaseEnum; import net.wanji.common.enums.BaseEnum;
import net.wanji.common.enums.TurnConvertEnum; import net.wanji.common.enums.TurnConvertEnum;
...@@ -514,6 +515,85 @@ public class GreenwaveHistProviderImpl extends BaseDubboInterfaceImpl<GreenwaveH ...@@ -514,6 +515,85 @@ public class GreenwaveHistProviderImpl extends BaseDubboInterfaceImpl<GreenwaveH
return jsonObject; return jsonObject;
} }
@Override
public JSONObject findCrossAvgIndex(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);
params.put("endDate", endTime);
params.put("groupType", groupType);
params.put("objectType", objectType);
//存放时段
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.getDirType(), TreeMap::new, Collectors.toList()));
Set<String> hasDataScopeList = new HashSet<>();
BottomMenuBO bo = new BottomMenuBO();
bo.setCrossId(crossId);
bo.setScope(objectType);
List<String> scopeList = mainlineEvaluateService.bottomMenu(bo);
for (Map.Entry<String, List<CrossLaneDataHistPoExtend>> entry : groupByDir.entrySet()) {
String key = entry.getKey();
String[] sps = key.split("_");
String cid = sps[0];
String dirType = sps[1];
String dirName = BaseEnum.SignalDirectionEnum.getNameByCode(Integer.valueOf(dirType));
String dirTurnDesc = dirName + "进口";
Map<String, Object> mapList = new HashMap<>();
List<CrossLaneDataHistPoExtend> value = entry.getValue().stream().sorted(Comparator.comparing(o->o.getTurnType())).collect(Collectors.toList());
value.forEach(o->{
if (Objects.equals(2,objectType) || Objects.equals(3,objectType)) {
o.setTurnTypeName(TurnConvertEnum.getDescByKey(o.getTurnType()));
hasDataScopeList.add(dirTurnDesc+o.getTurnTypeName());
} else {
hasDataScopeList.add(dirTurnDesc);
}
});
if (Objects.nonNull(scopeList)) {
//补充
for (String scopeName1 : scopeList) {
if (!hasDataScopeList.contains(scopeName1) && scopeName1.indexOf(dirTurnDesc) > 0) {
CrossLaneDataHistPoExtend tmp = new CrossLaneDataHistPoExtend();
tmp.setTurnTypeName(scopeName1.substring(dirTurnDesc.length()));
tmp.setTurnType(TurnConvertEnum.getKeyByCode(tmp.getTurnTypeName()));
value.add(tmp);
}
}
}
value = value.stream().sorted(Comparator.comparing(o->o.getLaneId()+"_"+o.getTurnType())).collect(Collectors.toList());
mapList.put("scopeCode", key);
mapList.put("dirName", 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 @Override
public JSONObject findCrossExitRoadLaneInfo(String crossId, String startTime, String endTime, String groupType) { public JSONObject findCrossExitRoadLaneInfo(String crossId, String startTime, String endTime, String groupType) {
Map<String, Object> params = new HashMap<>(); Map<String, Object> params = new HashMap<>();
......
...@@ -284,7 +284,7 @@ ...@@ -284,7 +284,7 @@
</when> </when>
<!-- 转向级 --> <!-- 转向级 -->
<when test="objectType==2"> <when test="objectType==2">
t.in_dir as dir_type, t.in_dir+1 as dir_type,
t.turn_type, t.turn_type,
null as lane_id, null as lane_id,
null as service_level, null as service_level,
......
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