Commit 9eb73a08 authored by hanbing's avatar hanbing

[update] 绿波时距图速度,转换协调方向

parent ab70db29
...@@ -683,11 +683,11 @@ public class MainlineEvaluateServiceImpl implements MainlineEvaluateService { ...@@ -683,11 +683,11 @@ public class MainlineEvaluateServiceImpl implements MainlineEvaluateService {
.collect(Collectors.toList()); .collect(Collectors.toList());
MainlineSchemeAnalysisVO res = new MainlineSchemeAnalysisVO(); MainlineSchemeAnalysisVO res = new MainlineSchemeAnalysisVO();
res.setSceneData(calcSceneData(filteredList));
fillLineSchemeBuffer(filteredList, lineSchemeBuffer); fillLineSchemeBuffer(filteredList, lineSchemeBuffer);
res.setCrossData(calcCrossData(filteredList)); res.setCrossData(calcCrossData(filteredList));
// 时段合并 // 时段合并
mergeLineSchemeBuffer(lineSchemeBuffer, mainlineName); mergeLineSchemeBuffer(lineSchemeBuffer, mainlineName);
res.setSceneData(calcSceneData(lineSchemeBuffer));
res.setEvaluateData(calcEvaluateData(filteredList, lineSchemeBuffer, poStartTimeStamp, poEndTimeStamp)); res.setEvaluateData(calcEvaluateData(filteredList, lineSchemeBuffer, poStartTimeStamp, poEndTimeStamp));
res.setGreenwaveData(buildGreenwaveData(lineSchemeBuffer)); res.setGreenwaveData(buildGreenwaveData(lineSchemeBuffer));
...@@ -1918,15 +1918,18 @@ public class MainlineEvaluateServiceImpl implements MainlineEvaluateService { ...@@ -1918,15 +1918,18 @@ public class MainlineEvaluateServiceImpl implements MainlineEvaluateService {
return (histTime.equals(startDate) || histTime.after(startDate)) && histTime.before(endDate); return (histTime.equals(startDate) || histTime.after(startDate)) && histTime.before(endDate);
} }
private List<MainlineSchemeAnalysisVO.DirectionData> calcSceneData(List<GreenwaveHistPO> filteredList) { private List<MainlineSchemeAnalysisVO.DirectionData> calcSceneData(Map<String, LineSchemeDTO> lineSchemeBuffer) {
List<MainlineSchemeAnalysisVO.DirectionData> res = new ArrayList<>(); List<MainlineSchemeAnalysisVO.DirectionData> res = new ArrayList<>();
Set<String> greenwaveSchemes = lineSchemeBuffer.keySet();
HashMap<String, Integer> map = new HashMap<>(); HashMap<String, Integer> map = new HashMap<>();
for (GreenwaveHistPO greenwaveHistPO : filteredList) { for (String greenwaveScheme : greenwaveSchemes) {
Integer dir = greenwaveHistPO.getDir(); String[] split = greenwaveScheme.split(":"); // 旅游路东向西转山西路至霞景路路段:正向绿波 工作日 23:00-24:00
if (dir == 0) { // 正向 String firstChar = split[1].substring(0, 1);
if (firstChar.equals("正")) { // 正向
map.put("单向绿波上行", map.getOrDefault("单向绿波上行", 0) + 1); map.put("单向绿波上行", map.getOrDefault("单向绿波上行", 0) + 1);
} else if (dir == 1) { // 反向 } else if (firstChar.equals("反")) { // 反向
map.put("单向绿波下行", map.getOrDefault("单向绿波下行", 0) + 1); map.put("单向绿波下行", map.getOrDefault("单向绿波下行", 0) + 1);
} else { // 双向 } else { // 双向
map.put("双向绿波", map.getOrDefault("双向绿波", 0) + 1); map.put("双向绿波", map.getOrDefault("双向绿波", 0) + 1);
......
...@@ -586,7 +586,9 @@ public class TrendServiceImpl implements TrendService { ...@@ -586,7 +586,9 @@ public class TrendServiceImpl implements TrendService {
return greenwavePoint; return greenwavePoint;
} }
private List<GreenwaveDetailVO.GreenwaveCross> buildGreenwaveCrossList(Integer greenwaveId, String greenwaveName, String startDate, String endDate) { private List<GreenwaveDetailVO.GreenwaveCross> buildGreenwaveCrossList(
Integer greenwaveId, String greenwaveName, String startDate, String endDate) {
String[] split = greenwaveName.split(" "); // 旅游路 东向西 转山西路至霞景路路段:正向绿波 工作日 19:00-20:00 String[] split = greenwaveName.split(" "); // 旅游路 东向西 转山西路至霞景路路段:正向绿波 工作日 19:00-20:00
String s = split[4]; // 19:00-20:00 String s = split[4]; // 19:00-20:00
String[] split1 = s.split("-"); String[] split1 = s.split("-");
...@@ -648,7 +650,7 @@ public class TrendServiceImpl implements TrendService { ...@@ -648,7 +650,7 @@ public class TrendServiceImpl implements TrendService {
GreenwaveCrossPO nextCrossPO = filteredList.get(i + 1); GreenwaveCrossPO nextCrossPO = filteredList.get(i + 1);
String nextCrossId = nextCrossPO.getCrossId(); String nextCrossId = nextCrossPO.getCrossId();
speed = calcSpeed(greenwaveCrossPO, nextCrossId, startTime, endTime, startDate, endDate); speed = calcSpeed(greenwaveName, nextCrossId, startTime, endTime, startDate, endDate);
} }
greenwaveCross.setDistanceToNextCross(distanceToNextCross); greenwaveCross.setDistanceToNextCross(distanceToNextCross);
greenwaveCross.setSpeed(speed); greenwaveCross.setSpeed(speed);
...@@ -658,7 +660,8 @@ public class TrendServiceImpl implements TrendService { ...@@ -658,7 +660,8 @@ public class TrendServiceImpl implements TrendService {
// 获取当前方案ID // 获取当前方案ID
BaseCrossPlanPO baseCrossPlanPO = baseCrossPlanMapper.selectByCrossIdAndName(crossId, planName); BaseCrossPlanPO baseCrossPlanPO = baseCrossPlanMapper.selectByCrossIdAndName(crossId, planName);
Integer planId = baseCrossPlanPO.getId(); Integer planId = baseCrossPlanPO.getId();
CrossSectionPO crossSectionPO = baseCrossSectionMapper.selectbyStartTimeCrossIdPlanId(startTime, crossId, planId); CrossSectionPO crossSectionPO = baseCrossSectionMapper.
selectbyStartTimeCrossIdPlanId(startTime, crossId, planId);
if (crossSectionPO == null) { if (crossSectionPO == null) {
throw new RuntimeException("无当前时段方案信息"); throw new RuntimeException("无当前时段方案信息");
} }
...@@ -752,18 +755,45 @@ public class TrendServiceImpl implements TrendService { ...@@ -752,18 +755,45 @@ public class TrendServiceImpl implements TrendService {
return i - 1; return i - 1;
} }
private Double calcSpeed(GreenwaveCrossPO greenwaveCrossPO, String crossId, private Double calcSpeed(String greenwaveName, String crossId,
String startTime, String endTime, String startDate, String endDate) { String startTime, String endTime, String startDate, String endDate) {
// 确定协调方向
String[] split = greenwaveName.split(" ");
String dirStr = split[1];
String[] split1 = dirStr.split("向");
String lineName = split[0] + " " + split[1] + " " + split[2];
GreenwaveInfoPO greenwaveInfoPO = greenwaveInfoMapper.selectByName(lineName);
Integer dir = greenwaveInfoPO.getDir();
Integer inDir = greenwaveCrossPO.getInDir(); List<Integer> coordDirCodeList = new ArrayList<>();
if (dir == 0) { // 正向
String dirStr1 = split1[0];
Integer dirCode = BaseEnum.SignalDirectionEnum.getCodeByName(dirStr1);
dirCode = convertDirCode(dirStr1, crossId, dirCode);
coordDirCodeList.add(dirCode);
} else if (dir == 1) { // 反向
String dirStr1 = split1[1];
Integer dirCode = BaseEnum.SignalDirectionEnum.getCodeByName(dirStr1);
dirCode = convertDirCode(dirStr1, crossId, dirCode);
coordDirCodeList.add(dirCode);
} else { // 双向
String dirStr1 = split1[0];
Integer dirCode1 = BaseEnum.SignalDirectionEnum.getCodeByName(dirStr1);
dirCode1 = convertDirCode(dirStr1, crossId, dirCode1);
coordDirCodeList.add(dirCode1);
String dirStr2 = split1[1];
Integer dirCode2 = BaseEnum.SignalDirectionEnum.getCodeByName(dirStr2);
dirCode2 = convertDirCode(dirStr2, crossId, dirCode2);
coordDirCodeList.add(dirCode2);
}
if (ObjectUtil.isEmpty(startDate)) { // 查询实时数据 if (ObjectUtil.isEmpty(startDate)) { // 查询实时数据
CrossDirDataRealtimePO crossDirDataRealtimePO = CrossDirDataRealtimePO crossDirDataRealtimePO =
crossDirDataRealtimeMapper.selectByCrossIdAndDirType(crossId, inDir); crossDirDataRealtimeMapper.selectByCrossIdAndDirs(crossId, coordDirCodeList);
return crossDirDataRealtimePO.getSpeed(); return crossDirDataRealtimePO.getSpeed();
} else { // 查询历史数据 } else { // 查询历史数据
List<CrossDirDataHistPO> crossDirDataHistPOList = crossDirDataHistMapper.selectByCrossDirAndTimeSection( List<CrossDirDataHistPO> crossDirDataHistPOList = crossDirDataHistMapper.selectByCrossDirsAndTimeSection(
crossId, inDir, startDate, endDate, startTime, endTime); crossId, coordDirCodeList, startDate, endDate, startTime, endTime);
double v = crossDirDataHistPOList.stream() double v = crossDirDataHistPOList.stream()
.mapToDouble(CrossDirDataHistPO::getSpeed) .mapToDouble(CrossDirDataHistPO::getSpeed)
......
...@@ -26,4 +26,6 @@ public interface CrossDirDataRealtimeMapper extends BaseMapper<CrossDirDataRealt ...@@ -26,4 +26,6 @@ public interface CrossDirDataRealtimeMapper extends BaseMapper<CrossDirDataRealt
List<CrossDirDataRealtimePO> selectBycrossId(String crossId); List<CrossDirDataRealtimePO> selectBycrossId(String crossId);
CrossDirDataRealtimePO selectByInDir(String currentCrossId, Integer key); CrossDirDataRealtimePO selectByInDir(String currentCrossId, Integer key);
CrossDirDataRealtimePO selectByCrossIdAndDirs(String crossId, List<Integer> dirCodeList);
} }
...@@ -86,4 +86,15 @@ ...@@ -86,4 +86,15 @@
where cross_id = #{currentCrossId} and dir_type = #{key} and in_out_type = 1 where cross_id = #{currentCrossId} and dir_type = #{key} and in_out_type = 1
</select> </select>
<select id="selectByCrossIdAndDirs" resultType="net.wanji.databus.po.CrossDirDataRealtimePO">
select <include refid="Base_Column_List"/>
from t_cross_dir_data_realtime
where cross_id = #{crossId}
and dir_type in
<foreach collection="dirCodeList" item="dirCode" separator="," open="(" close=")">
#{dirCode}
</foreach>
and in_out_type = 1
</select>
</mapper> </mapper>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment