Commit ca0a46e3 authored by zhoushiguang's avatar zhoushiguang

场景详细评价平均指标

parent b141f49a
...@@ -18,8 +18,8 @@ public class CrossLaneDataHistPoExtend { ...@@ -18,8 +18,8 @@ public class CrossLaneDataHistPoExtend {
@ApiModelProperty(name = "路口编号",notes = "") @ApiModelProperty(name = "路口编号",notes = "")
private String crossId; private String crossId;
//车道ID //车道ID
@ApiModelProperty(value = "车道ID", notes = "") @ApiModelProperty(value = "车道", notes = "")
private String laneId; private Integer laneNo;
//方向 //方向
@ApiModelProperty(value = "方向", notes = "") @ApiModelProperty(value = "方向", notes = "")
private Integer dirType; private Integer dirType;
......
...@@ -53,6 +53,8 @@ import java.util.Random; ...@@ -53,6 +53,8 @@ import java.util.Random;
import java.util.Set; import java.util.Set;
import java.util.TreeMap; import java.util.TreeMap;
import java.util.TreeSet; import java.util.TreeSet;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -75,8 +77,7 @@ public class GreenwaveHistProviderImpl extends BaseDubboInterfaceImpl<GreenwaveH ...@@ -75,8 +77,7 @@ public class GreenwaveHistProviderImpl extends BaseDubboInterfaceImpl<GreenwaveH
private MainlineEvaluateService mainlineEvaluateService; private MainlineEvaluateService mainlineEvaluateService;
@Resource @Resource
BaseCrossInfoMapper baseCrossInfoMapper BaseCrossInfoMapper baseCrossInfoMapper;
;
@Override @Override
public BaseInterfaceMapper<GreenwaveHist> getBaseInterfaceMapper() { public BaseInterfaceMapper<GreenwaveHist> getBaseInterfaceMapper() {
...@@ -156,36 +157,36 @@ public class GreenwaveHistProviderImpl extends BaseDubboInterfaceImpl<GreenwaveH ...@@ -156,36 +157,36 @@ public class GreenwaveHistProviderImpl extends BaseDubboInterfaceImpl<GreenwaveH
params.put("endDate", endTime); params.put("endDate", endTime);
params.put("greenDir", greenDir); params.put("greenDir", greenDir);
List<Map<String,Object>> getList = greenwaveHistoryMapper.findUnCoordinateCrossIndex(params); List<Map<String, Object>> getList = greenwaveHistoryMapper.findUnCoordinateCrossIndex(params);
List<GreenwaveCrossTrendPo> list = new ArrayList<>(); List<GreenwaveCrossTrendPo> list = new ArrayList<>();
//存放时段 //存放时段
Set<String> sortedSet = new TreeSet<>(); Set<String> sortedSet = new TreeSet<>();
for (Map<String,Object> map : getList) { for (Map<String, Object> map : getList) {
GreenwaveCrossTrendPo po = new GreenwaveCrossTrendPo(); GreenwaveCrossTrendPo po = new GreenwaveCrossTrendPo();
String crossNo = map.get("cross_id").toString(); String crossNo = map.get("cross_id").toString();
String st = map.get("start_time").toString(); String st = map.get("start_time").toString();
po.setCrossId(crossNo); po.setCrossId(crossNo);
po.setStartTime(DateTime.parse(st,DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss")).toDate()); po.setStartTime(DateTime.parse(st, DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss")).toDate());
//提取时间 //提取时间
sortedSet.add(DateUtil.formatDate(po.getStartTime(), "HH:mm")); sortedSet.add(DateUtil.formatDate(po.getStartTime(), "HH:mm"));
String indexList = map.get("index_list").toString(); String indexList = map.get("index_list").toString();
List<GreenwaveCrossTrendPo> finalList = new ArrayList<>(); List<GreenwaveCrossTrendPo> finalList = new ArrayList<>();
Arrays.stream(indexList.split("@")).forEach(o->{ Arrays.stream(indexList.split("@")).forEach(o -> {
String[] sps = o.split(","); String[] sps = o.split(",");
String type = sps[0]; String type = sps[0];
String queueLength = sps[1]; String queueLength = sps[1];
String stopTimes = sps[2]; String stopTimes = sps[2];
String flow = sps[3]; String flow = sps[3];
if (Objects.equals("1",type)) { if (Objects.equals("1", type)) {
//非协调方向 //非协调方向
po.setFlow(new BigDecimal(flow)); po.setFlow(new BigDecimal(flow));
po.setQueueLength(new BigDecimal(queueLength)); po.setQueueLength(new BigDecimal(queueLength));
po.setStopTimes(new BigDecimal(stopTimes)); po.setStopTimes(new BigDecimal(stopTimes));
} else if (Objects.equals("2",type)){ } else if (Objects.equals("2", type)) {
//协调方向 //协调方向
po.setCordFlow(new BigDecimal(flow)); po.setCordFlow(new BigDecimal(flow));
po.setCordQueueLength(new BigDecimal(queueLength)); po.setCordQueueLength(new BigDecimal(queueLength));
...@@ -417,29 +418,26 @@ public class GreenwaveHistProviderImpl extends BaseDubboInterfaceImpl<GreenwaveH ...@@ -417,29 +418,26 @@ public class GreenwaveHistProviderImpl extends BaseDubboInterfaceImpl<GreenwaveH
List<CrossLaneDataHistPoExtend> list = greenwaveHistoryMapper.findGreenWaveCrossLaneIndex(params); List<CrossLaneDataHistPoExtend> list = greenwaveHistoryMapper.findGreenWaveCrossLaneIndex(params);
list = list.stream().sorted(Comparator.comparing(o -> o.getStartTime())).collect(Collectors.toList()); 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.getLaneNo() + "_" + o.getDirType() + "_" + o.getTurnType(), TreeMap::new, Collectors.toList()));
Set<String> hasDataScopeList = new HashSet<>(); Set<String> hasDataScopeList = new HashSet<>();
for (Map.Entry<String, List<CrossLaneDataHistPoExtend>> entry : groupByDir.entrySet()) { for (Map.Entry<String, List<CrossLaneDataHistPoExtend>> entry : groupByDir.entrySet()) {
String key = entry.getKey(); String key = entry.getKey();
String[] sps = key.split("_"); String[] sps = key.split("_");
String laneId = sps[1]; String laneNo = sps[1];
String laneNo = laneId.substring(laneId.length() - 2);
Integer dirType = null; Integer dirType = null;
String dirName = null; String dirName = null;
String turnDesc = null; String turnDesc = null;
String dirTurnDesc = null; String dirTurnDesc = null;
Map<String, Object> mapList = new HashMap<>(); Map<String, Object> mapList = new HashMap<>();
if (Objects.equals(4,objectType)){ if (Objects.equals(4, objectType)) {
TBaseCrossInfo tBaseCrossInfo = baseCrossInfoMapper.selectByPrimaryKey(sps[0]); TBaseCrossInfo tBaseCrossInfo = baseCrossInfoMapper.selectByPrimaryKey(sps[0]);
dirTurnDesc = tBaseCrossInfo.getName(); dirTurnDesc = tBaseCrossInfo.getName();
}else if (Objects.equals(3, objectType)) { } else if (Objects.equals(3, objectType)) {
mapList.put("laneId", laneId);
mapList.put("laneNo", laneNo); mapList.put("laneNo", laneNo);
dirType = Integer.parseInt(sps[2]); dirType = Integer.parseInt(sps[2]);
dirName = BaseEnum.SignalDirectionEnum.getNameByCode(dirType); dirName = BaseEnum.SignalDirectionEnum.getNameByCode(dirType);
...@@ -462,7 +460,6 @@ public class GreenwaveHistProviderImpl extends BaseDubboInterfaceImpl<GreenwaveH ...@@ -462,7 +460,6 @@ public class GreenwaveHistProviderImpl extends BaseDubboInterfaceImpl<GreenwaveH
List<CrossLaneDataHistPoExtend> value = this.processData(entry, groupType, sortedSet, startTime); List<CrossLaneDataHistPoExtend> value = this.processData(entry, groupType, sortedSet, startTime);
mapList.put("scopeCode", key); mapList.put("scopeCode", key);
mapList.put("scopeName", dirTurnDesc); mapList.put("scopeName", dirTurnDesc);
mapList.put("list", value); mapList.put("list", value);
...@@ -535,10 +532,11 @@ public class GreenwaveHistProviderImpl extends BaseDubboInterfaceImpl<GreenwaveH ...@@ -535,10 +532,11 @@ public class GreenwaveHistProviderImpl extends BaseDubboInterfaceImpl<GreenwaveH
list = list.stream().sorted(Comparator.comparing(o -> o.getStartTime())).collect(Collectors.toList()); 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())); Map<String, List<CrossLaneDataHistPoExtend>> groupByDir = list.stream().collect(Collectors.groupingBy(o -> o.getCrossId() + "_" + o.getDirType(), TreeMap::new, Collectors.toList()));
Set<String> hasDataScopeList = new HashSet<>(); Set<String> hasDataScopeList = new HashSet<>();
BottomMenuBO bo = new BottomMenuBO(); BottomMenuBO bo = new BottomMenuBO();
bo.setCrossId(crossId); bo.setCrossId(crossId);
bo.setScope(objectType); bo.setScope(objectType);
...@@ -551,40 +549,130 @@ public class GreenwaveHistProviderImpl extends BaseDubboInterfaceImpl<GreenwaveH ...@@ -551,40 +549,130 @@ public class GreenwaveHistProviderImpl extends BaseDubboInterfaceImpl<GreenwaveH
String cid = sps[0]; String cid = sps[0];
String dirType = sps[1]; String dirType = sps[1];
String dirName = BaseEnum.SignalDirectionEnum.getNameByCode(Integer.valueOf(dirType)); String dirName = null;
if (!Objects.equals("null",dirType)) {
dirName = BaseEnum.SignalDirectionEnum.getNameByCode(Integer.valueOf(dirType));
}
String dirTurnDesc = dirName + "进口"; String dirTurnDesc = dirName + "进口";
Map<String, Object> mapList = new HashMap<>(); Map<String, Object> mapList = new HashMap<>();
List<CrossLaneDataHistPoExtend> value = entry.getValue().stream().sorted(Comparator.comparing(o->o.getTurnType())).collect(Collectors.toList()); List<CrossLaneDataHistPoExtend> value = entry.getValue().stream().sorted(Comparator.comparing(o -> o.getTurnType())).collect(Collectors.toList());
value.forEach(o->{ //========================路口级服务水平加权平均 start=================================================================//
if (Objects.equals(2,objectType) || Objects.equals(3,objectType)) { String serviceLevelList = value.get(0).getServiceLevel();
StringBuilder serviceLevelBuf = new StringBuilder();
if (serviceLevelList != null) {
Map<String, Long> serviceGroup = Arrays.stream(serviceLevelList.split(",")).collect(Collectors.groupingBy(String::valueOf, Collectors.counting()));
double total = 0;
for (Map.Entry<String, Long> entry1 : serviceGroup.entrySet()) {
String key1 = entry1.getKey();
total += ServiceLevelEnum.getByType(key1).getVal() * entry1.getValue();
}
//服务水平加权平均计算:给服务水平(等级得分*该等级的数量)累加/总数量
int avgService = (int) Math.round(total / value.size());
String avgServiceLevel = ServiceLevelEnum.getByVal(avgService) == null ? "A" : ServiceLevelEnum.getByVal(avgService).getType();
serviceLevelBuf.append(avgServiceLevel);
}
//========================路口级服务水平加权平均 end=================================================================//
value.forEach(o -> {
o.setServiceLevel(serviceLevelBuf.toString());
o.setDirTypeName(dirTurnDesc);
if (Objects.equals(2, objectType)) {
o.setTurnTypeName(TurnConvertEnum.getDescByKey(o.getTurnType())); o.setTurnTypeName(TurnConvertEnum.getDescByKey(o.getTurnType()));
hasDataScopeList.add(dirTurnDesc+o.getTurnTypeName()); hasDataScopeList.add(dirTurnDesc + o.getTurnTypeName());
} else if (Objects.equals(3, objectType)) {
o.setTurnTypeName(TurnConvertEnum.getDescByKey(o.getTurnType())+ o.getLaneNo() + "车道");
hasDataScopeList.add(dirTurnDesc + o.getTurnTypeName() + o.getLaneNo() + "车道");
} else { } else {
hasDataScopeList.add(dirTurnDesc); hasDataScopeList.add(dirTurnDesc);
} }
}); });
//===============补充某个方向有数据但是不完整的================================================================================//
if (Objects.nonNull(scopeList)) { if (Objects.nonNull(scopeList)) {
//补充 //补充
for (String scopeName1 : scopeList) { for (String scopeName1 : scopeList) {
if (!hasDataScopeList.contains(scopeName1) && scopeName1.contains(dirTurnDesc)) { if (!hasDataScopeList.contains(scopeName1) && scopeName1.contains(dirTurnDesc)) {
CrossLaneDataHistPoExtend tmp = new CrossLaneDataHistPoExtend(); CrossLaneDataHistPoExtend tmp = new CrossLaneDataHistPoExtend();
tmp.setCrossId(cid);
tmp.setDirType(BaseEnum.SignalDirectionEnum.getCodeByName(scopeName1.substring(0,scopeName1.indexOf("进口"))));
tmp.setDirTypeName(dirTurnDesc);
tmp.setTurnTypeName(scopeName1.substring(dirTurnDesc.length())); tmp.setTurnTypeName(scopeName1.substring(dirTurnDesc.length()));
tmp.setTurnType(TurnConvertEnum.getKeyByDesc(tmp.getTurnTypeName())); tmp.setTurnType(TurnConvertEnum.getKeyByDesc(tmp.getTurnTypeName()));
//利用正则表达式取车道号
if (Objects.equals(3, objectType)) {
Pattern pattern = Pattern.compile("\\d+");
Matcher matcher = pattern.matcher(scopeName1);
if (matcher.find()) {
Integer laneNo = Integer.valueOf(matcher.group());
tmp.setLaneNo(laneNo);
tmp.setTurnType(TurnConvertEnum.getKeyByDesc(tmp.getTurnTypeName().substring(0,tmp.getTurnTypeName().indexOf(laneNo.toString()))));
hasDataScopeList.add(tmp.getDirTypeName()+tmp.getTurnTypeName());
}
}
value.add(tmp); value.add(tmp);
} }
} }
} }
value = value.stream().sorted(Comparator.comparing(o->o.getLaneId()+"_"+o.getTurnType())).collect(Collectors.toList()); //===============补充某个方向有数据但是不完整的================================================================================//
if (Objects.equals(2, objectType)) {
value = value.stream().sorted(Comparator.comparing(o -> o.getTurnType())).collect(Collectors.toList());
} else if (Objects.equals(3, objectType)) {
value = value.stream().sorted(Comparator.comparing(o -> o.getLaneNo())).collect(Collectors.toList());
}
mapList.put("scopeCode", key); mapList.put("scopeCode", key);
mapList.put("dirName", dirTurnDesc); mapList.put("dirName", dirTurnDesc);
mapList.put("dirType", BaseEnum.SignalDirectionEnum.getCodeByName(dirTurnDesc.substring(0,dirTurnDesc.indexOf("进口"))));
mapList.put("list", value); mapList.put("list", value);
allList.add(mapList); allList.add(mapList);
} }
//====================补充方向上无任何车道数据====================================================================================//
if (Objects.nonNull(scopeList)) {
Map<Integer,List<CrossLaneDataHistPoExtend>> tmpListMap = new TreeMap<>();
for (String scopeName1 : scopeList) {
if (!hasDataScopeList.contains(scopeName1)) {
Pattern pattern = Pattern.compile("\\d+");
Matcher matcher = pattern.matcher(scopeName1);
String dirName = scopeName1.substring(0,scopeName1.indexOf("进口")+2);
String turnDesc = scopeName1.substring(dirName.length());
CrossLaneDataHistPoExtend tmp = new CrossLaneDataHistPoExtend();
tmp.setCrossId(crossId);
tmp.setDirType(BaseEnum.SignalDirectionEnum.getCodeByName(scopeName1.substring(0,scopeName1.indexOf("进口"))));
tmp.setDirTypeName(dirName);
tmp.setTurnTypeName(turnDesc);
if (matcher.find()) {
Integer laneNo = Integer.valueOf(matcher.group());
tmp.setTurnType(TurnConvertEnum.getKeyByDesc(tmp.getTurnTypeName().substring(0,tmp.getTurnTypeName().indexOf(laneNo.toString()))));
} else {
tmp.setTurnType(TurnConvertEnum.getKeyByDesc(tmp.getTurnTypeName()));
}
List<CrossLaneDataHistPoExtend> tmpList = tmpListMap.get(tmp.getDirType());
if (tmpList==null){
tmpList = new ArrayList<>();
}
tmpList.add(tmp);
tmpListMap.put(tmp.getDirType(),tmpList);
}
}
for (Map.Entry<Integer,List<CrossLaneDataHistPoExtend>> tmpEntry : tmpListMap.entrySet()) {
Map<String, Object> mapList = new HashMap<>();
String dirDesc = BaseEnum.SignalDirectionEnum.getNameByCode(tmpEntry.getKey());
mapList.put("scopeCode", null);
mapList.put("isLost", true);
mapList.put("dirName", dirDesc+"进口");
mapList.put("dirType", tmpEntry.getKey());
mapList.put("list", tmpEntry.getValue());
allList.add(mapList);
}
}
//=========================================================================================================================================================//
allList = allList.stream().sorted(Comparator.comparing(o->Integer.valueOf(o.get("dirType").toString()))).collect(Collectors.toList());
JSONObject jsonObject = new JSONObject(); JSONObject jsonObject = new JSONObject();
jsonObject.put("timeList", sortedSet); jsonObject.put("timeList", sortedSet);
...@@ -612,16 +700,14 @@ public class GreenwaveHistProviderImpl extends BaseDubboInterfaceImpl<GreenwaveH ...@@ -612,16 +700,14 @@ public class GreenwaveHistProviderImpl extends BaseDubboInterfaceImpl<GreenwaveH
list = list.stream().sorted(Comparator.comparing(o -> o.getStartTime())).collect(Collectors.toList()); 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.getLaneNo() + "_" + o.getDirType() + "_" + o.getTurnType(), TreeMap::new, Collectors.toList()));
Set<String> scopeList = new TreeSet<>(); Set<String> scopeList = new TreeSet<>();
for (Map.Entry<String, List<CrossLaneDataHistPoExtend>> entry : groupByDir.entrySet()) { for (Map.Entry<String, List<CrossLaneDataHistPoExtend>> entry : groupByDir.entrySet()) {
String key = entry.getKey(); String key = entry.getKey();
String[] sps = key.split("_"); String[] sps = key.split("_");
String laneNo = sps[1];
String laneId = sps[1];
String laneNo = laneId.substring(laneId.length() - 2);
Integer dirType = Integer.parseInt(sps[2]); Integer dirType = Integer.parseInt(sps[2]);
String dirName = null; String dirName = null;
String turnDesc = null; String turnDesc = null;
...@@ -629,7 +715,6 @@ public class GreenwaveHistProviderImpl extends BaseDubboInterfaceImpl<GreenwaveH ...@@ -629,7 +715,6 @@ public class GreenwaveHistProviderImpl extends BaseDubboInterfaceImpl<GreenwaveH
Map<String, Object> mapList = new HashMap<>(); Map<String, Object> mapList = new HashMap<>();
mapList.put("laneId", laneId);
mapList.put("laneNo", laneNo); mapList.put("laneNo", laneNo);
dirName = BaseEnum.SignalDirectionEnum.getNameByCode(dirType); dirName = BaseEnum.SignalDirectionEnum.getNameByCode(dirType);
turnDesc = TurnConvertEnum.getDescByKey(Integer.valueOf(sps[3])); turnDesc = TurnConvertEnum.getDescByKey(Integer.valueOf(sps[3]));
...@@ -679,16 +764,14 @@ public class GreenwaveHistProviderImpl extends BaseDubboInterfaceImpl<GreenwaveH ...@@ -679,16 +764,14 @@ public class GreenwaveHistProviderImpl extends BaseDubboInterfaceImpl<GreenwaveH
list = list.stream().sorted(Comparator.comparing(o -> o.getStartTime())).collect(Collectors.toList()); 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.getLaneNo() + "_" + o.getDirType() + "_" + o.getTurnType(), TreeMap::new, Collectors.toList()));
Set<String> scopeList = new TreeSet<>(); Set<String> scopeList = new TreeSet<>();
for (Map.Entry<String, List<CrossLaneDataHistPoExtend>> entry : groupByDir.entrySet()) { for (Map.Entry<String, List<CrossLaneDataHistPoExtend>> entry : groupByDir.entrySet()) {
String key = entry.getKey(); String key = entry.getKey();
String[] sps = key.split("_"); String[] sps = key.split("_");
String laneNo = sps[1];
String laneId = sps[1];
String laneNo = laneId.substring(laneId.length() - 2);
Integer dirType = Integer.parseInt(sps[2]); Integer dirType = Integer.parseInt(sps[2]);
String dirName = null; String dirName = null;
String turnDesc = null; String turnDesc = null;
...@@ -696,7 +779,6 @@ public class GreenwaveHistProviderImpl extends BaseDubboInterfaceImpl<GreenwaveH ...@@ -696,7 +779,6 @@ public class GreenwaveHistProviderImpl extends BaseDubboInterfaceImpl<GreenwaveH
Map<String, Object> mapList = new HashMap<>(); Map<String, Object> mapList = new HashMap<>();
mapList.put("laneId", laneId);
mapList.put("laneNo", laneNo); mapList.put("laneNo", laneNo);
if (objectType == 1) { if (objectType == 1) {
dirName = BaseEnum.SignalDirectionEnum.getNameByCode(dirType); dirName = BaseEnum.SignalDirectionEnum.getNameByCode(dirType);
...@@ -711,6 +793,7 @@ public class GreenwaveHistProviderImpl extends BaseDubboInterfaceImpl<GreenwaveH ...@@ -711,6 +793,7 @@ public class GreenwaveHistProviderImpl extends BaseDubboInterfaceImpl<GreenwaveH
//补充缺少时段数据,保留时段字段默认值 //补充缺少时段数据,保留时段字段默认值
List<CrossLaneDataHistPoExtend> value = this.processData(entry, groupType, sortedSet, startTime); List<CrossLaneDataHistPoExtend> value = this.processData(entry, groupType, sortedSet, startTime);
mapList.put("scopeCode", key); mapList.put("scopeCode", key);
mapList.put("scopeName", dirTurnDesc); mapList.put("scopeName", dirTurnDesc);
mapList.put("list", value); mapList.put("list", value);
...@@ -740,15 +823,15 @@ public class GreenwaveHistProviderImpl extends BaseDubboInterfaceImpl<GreenwaveH ...@@ -740,15 +823,15 @@ public class GreenwaveHistProviderImpl extends BaseDubboInterfaceImpl<GreenwaveH
String serviceLevelList = value.get(0).getServiceLevel(); String serviceLevelList = value.get(0).getServiceLevel();
StringBuilder serviceLevelBuf = new StringBuilder(); StringBuilder serviceLevelBuf = new StringBuilder();
if (serviceLevelList != null) { if (serviceLevelList != null) {
Map<String,Long> serviceGroup = Arrays.stream(serviceLevelList.split(",")).collect(Collectors.groupingBy(String::valueOf,Collectors.counting())); Map<String, Long> serviceGroup = Arrays.stream(serviceLevelList.split(",")).collect(Collectors.groupingBy(String::valueOf, Collectors.counting()));
double total = 0; double total = 0;
for (Map.Entry<String, Long> entry1 : serviceGroup.entrySet()) { for (Map.Entry<String, Long> entry1 : serviceGroup.entrySet()) {
String key = entry1.getKey(); String key = entry1.getKey();
total += ServiceLevelEnum.getByType(key).getVal() * entry1.getValue(); total += ServiceLevelEnum.getByType(key).getVal() * entry1.getValue();
} }
//服务水平加权平均计算:给服务水平(等级得分*该等级的数量)累加/总数量 //服务水平加权平均计算:给服务水平(等级得分*该等级的数量)累加/总数量
int avgService = (int) Math.round(total/value.size()); int avgService = (int) Math.round(total / value.size());
String avgServiceLevel = ServiceLevelEnum.getByVal(avgService)==null?"A":ServiceLevelEnum.getByVal(avgService).getType(); String avgServiceLevel = ServiceLevelEnum.getByVal(avgService) == null ? "A" : ServiceLevelEnum.getByVal(avgService).getType();
serviceLevelBuf.append(avgServiceLevel); serviceLevelBuf.append(avgServiceLevel);
} }
...@@ -782,7 +865,6 @@ public class GreenwaveHistProviderImpl extends BaseDubboInterfaceImpl<GreenwaveH ...@@ -782,7 +865,6 @@ public class GreenwaveHistProviderImpl extends BaseDubboInterfaceImpl<GreenwaveH
value = value.stream().sorted(Comparator.comparing(CrossLaneDataHistPoExtend::getStartTime)).collect(Collectors.toList()); value = value.stream().sorted(Comparator.comparing(CrossLaneDataHistPoExtend::getStartTime)).collect(Collectors.toList());
//==========================================================================================================// //==========================================================================================================//
//时间轴 //时间轴
value.forEach(o -> { value.forEach(o -> {
......
...@@ -249,7 +249,7 @@ ...@@ -249,7 +249,7 @@
resultType="net.wanji.opt.po.base.CrossLaneDataHistPoExtend"> resultType="net.wanji.opt.po.base.CrossLaneDataHistPoExtend">
SELECT MIN(ifnull(t.unit_time,#{startDate})) start_time, SELECT MIN(ifnull(t.unit_time,#{startDate})) start_time,
cross_id , cross_id ,
lane_id , lane_no ,
dir_type , dir_type ,
turn_type , turn_type ,
SUM(flow) flow, SUM(flow) flow,
...@@ -278,7 +278,7 @@ ...@@ -278,7 +278,7 @@
<!-- 方向级 --> <!-- 方向级 -->
<when test="objectType==1"> <when test="objectType==1">
dir_type, dir_type,
null as lane_id, null as lane_no,
null as turn_type, null as turn_type,
null as service_level, null as service_level,
</when> </when>
...@@ -286,19 +286,19 @@ ...@@ -286,19 +286,19 @@
<when test="objectType==2"> <when test="objectType==2">
t.in_dir+1 as dir_type, t.in_dir+1 as dir_type,
t.turn_type, t.turn_type,
null as lane_id, null as lane_no,
null as service_level, null as service_level,
</when> </when>
<!-- 车道级 --> <!-- 车道级 -->
<when test="objectType==3"> <when test="objectType==3">
t.id as lane_id, t2.sort as lane_no,
t2.dir as dir_type, t2.dir as dir_type,
t2.turn as turn_type, t2.turn as turn_type,
null as service_level, null as service_level,
</when> </when>
<!-- 路口级 --> <!-- 路口级 -->
<when test="objectType==4"> <when test="objectType==4">
null as lane_id, null as lane_no,
null as dir_type, null as dir_type,
null as turn_type, null as turn_type,
ifnull(service_level,'A') service_level, ifnull(service_level,'A') service_level,
...@@ -352,7 +352,7 @@ ...@@ -352,7 +352,7 @@
</when> </when>
<!-- 车道级 --> <!-- 车道级 -->
<when test="objectType==3"> <when test="objectType==3">
GROUP BY t.cross_id,t.lane_id,t.dir_type,t.turn_type,unit_time GROUP BY t.cross_id,t.lane_no,t.dir_type,t.turn_type,unit_time
</when> </when>
<!-- 路口级 --> <!-- 路口级 -->
<when test="objectType==4"> <when test="objectType==4">
......
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