Commit 9c35f355 authored by hanbing's avatar hanbing

[update] 信号优化,干线评价-绿波关键路口修改

parent 07b428c9
......@@ -684,7 +684,8 @@ public class MainlineEvaluateServiceImpl implements MainlineEvaluateService {
MainlineSchemeAnalysisVO res = new MainlineSchemeAnalysisVO();
res.setSceneData(calcSceneData(filteredList));
res.setCrossData(calcCrossData(filteredList, lineSchemeBuffer));
fillLineSchemeBuffer(filteredList, lineSchemeBuffer);
res.setCrossData(calcCrossData(filteredList));
res.setEvaluateData(calcEvaluateData(filteredList, lineSchemeBuffer, poStartTimeStamp, poEndTimeStamp));
// 时段合并
mergeLineSchemeBuffer(lineSchemeBuffer, mainlineName);
......@@ -693,9 +694,47 @@ public class MainlineEvaluateServiceImpl implements MainlineEvaluateService {
return res;
}
private void fillLineSchemeBuffer(List<GreenwaveHistPO> filteredList, Map<String, LineSchemeDTO> lineSchemeBuffer)
throws ParseException {
for (GreenwaveHistPO greenwaveHistPO : filteredList) {
Integer histGreenwaveId = greenwaveHistPO.getId();
Date histGreenwaveGmtModified = greenwaveHistPO.getGmtModified();
List<GreenwaveCrossPO> greenwaveCrossPOList = greenwaveCrossMapper.selectAll();
List<CrossSectionPO> baseCrossSectionPOList = baseCrossSectionMapper.selectAll();
List<BaseCrossPlanPO> baseCrossPlanPOList = baseCrossPlanMapper.selectAll();
for (GreenwaveCrossPO greenwaveCrossPO : greenwaveCrossPOList) {
Integer sectionId = greenwaveCrossPO.getSectionId();
// 判断绿波历史发生时间是否在时段内
GreenwaveInSectionDTO greenwaveInSectionDTO = isGreenwaveInSection(
histGreenwaveGmtModified, sectionId, baseCrossSectionPOList, baseCrossPlanPOList);
if (greenwaveInSectionDTO.isGreenwaveInSection()) {
String greenwaveName = greenwaveHistPO.getGreenwaveName();
Integer greenwaveId = greenwaveHistPO.getId();
String planName = greenwaveInSectionDTO.getPlanName();
Integer planId = greenwaveInSectionDTO.getPlanId();
String startTime = greenwaveInSectionDTO.getStartTime();
String endTime = greenwaveInSectionDTO.getEndTime();
String lineSchemeName = greenwaveName + " " + planName + " " + startTime + "-" + endTime;
LineSchemeDTO lineSchemeDTO = lineSchemeBuffer.getOrDefault(lineSchemeName, new LineSchemeDTO());
List<GreenwaveHistPO> greenwaveHistPOList = lineSchemeDTO.getGreenwaveHistPOList();
greenwaveHistPOList.add(greenwaveHistPO);
lineSchemeDTO.setSectionId(sectionId);
lineSchemeDTO.setPlanId(planId);
lineSchemeDTO.setGreenwaveId(greenwaveId);
lineSchemeBuffer.put(lineSchemeName, lineSchemeDTO);
}
}
}
}
private void mergeLineSchemeBuffer(Map<String, LineSchemeDTO> lineSchemeBuffer, String mainlineName) {
if (mainlineName.contains("转山西路至霞景路")) {
// 工作日合并 07:00-09:30,09:30-16:30,21:30-23:59
// 工作日合并 07:00-09:30,09:30-16:30,16:30-19:00,21:30-23:59
// 周末和节假日合并 13:30-20:00,21:30-23:59
Map<String, LineSchemeDTO> mergedRecords = new HashMap<>();
......@@ -742,6 +781,7 @@ public class MainlineEvaluateServiceImpl implements MainlineEvaluateService {
return Arrays.asList(
new int[] {timeToInt("07:00"), timeToInt("09:30")},
new int[] {timeToInt("09:30"), timeToInt("16:30")},
new int[] {timeToInt("16:30"), timeToInt("19:00")},
new int[] {timeToInt("21:30"), timeToInt("23:59")}
);
} else {
......@@ -1742,10 +1782,9 @@ public class MainlineEvaluateServiceImpl implements MainlineEvaluateService {
return calendar.getTime();
}
private List<MainlineSchemeAnalysisVO.CrossData> calcCrossData(
List<GreenwaveHistPO> filteredList, Map<String, LineSchemeDTO> lineSchemeBuffer)
private List<MainlineSchemeAnalysisVO.CrossData> calcCrossData(List<GreenwaveHistPO> filteredList)
throws ParseException {
List<MainlineSchemeAnalysisVO.CrossData> res = new ArrayList<>();
Map<String, Integer> crossTimesMap = new HashMap<>();
......@@ -1769,23 +1808,6 @@ public class MainlineEvaluateServiceImpl implements MainlineEvaluateService {
histGreenwaveGmtModified, sectionId, baseCrossSectionPOList, baseCrossPlanPOList);
if (greenwaveInSectionDTO.isGreenwaveInSection()) {
crossTimesMap.put(crossId, crossTimesMap.getOrDefault(crossId, 0) + 1);
String greenwaveName = greenwaveHistPO.getGreenwaveName();
Integer greenwaveId = greenwaveHistPO.getId();
String planName = greenwaveInSectionDTO.getPlanName();
Integer planId = greenwaveInSectionDTO.getPlanId();
String startTime = greenwaveInSectionDTO.getStartTime();
String endTime = greenwaveInSectionDTO.getEndTime();
String lineSchemeName = greenwaveName + " " + planName + " " + startTime + "-" + endTime;
LineSchemeDTO lineSchemeDTO = lineSchemeBuffer.getOrDefault(lineSchemeName, new LineSchemeDTO());
List<GreenwaveHistPO> greenwaveHistPOList = lineSchemeDTO.getGreenwaveHistPOList();
greenwaveHistPOList.add(greenwaveHistPO);
lineSchemeDTO.setSectionId(sectionId);
lineSchemeDTO.setPlanId(planId);
lineSchemeDTO.setGreenwaveId(greenwaveId);
lineSchemeBuffer.put(lineSchemeName, lineSchemeDTO);
}
}
}
......
......@@ -581,16 +581,35 @@ public class TrendServiceImpl implements TrendService {
}
private List<GreenwaveDetailVO.GreenwaveCross> buildGreenwaveCrossList(Integer greenwaveId, String greenwaveName) {
String[] split = greenwaveName.split(" "); // 旅游路 东向西 转山西路至霞景路路段:正向绿波 工作日 19:00-20:00
String s = split[4];
String[] split1 = s.split("-");
String startTime = split1[0];
String planName = split[3];
List<GreenwaveDetailVO.GreenwaveCross> res = new ArrayList<>();
List<GreenwaveCrossPO> greenwaveCrossList = greenwaveCrossMapper.selectByGreenwaveId(greenwaveId);
Map<String, GreenwaveCrossPO> uniqueCrossIdMap = greenwaveCrossList.stream()
.collect(Collectors.toMap(
GreenwaveCrossPO::getCrossId,
Function.identity(),
(existing, replacement) -> existing
));
List<GreenwaveCrossPO> filteredList = new ArrayList<>(uniqueCrossIdMap.values());
// 获取绿波的路口ID列表
List<String> crossList = greenwaveCrossList.stream()
.map(GreenwaveCrossPO::getCrossId)
.distinct()
.collect(Collectors.toList());
// 查询路口时段表基础数据
List<CrossSectionPOExt> crossSectionPoExtList =
baseCrossSectionMapper.selectByCrossIdsAndStartTime(startTime, crossList);
// 根据方案名和开始时间过滤
List<Integer> sectionIdList = crossSectionPoExtList.stream()
.filter(poExt -> planName.equals(poExt.getPlanName()) && startTime.equals(poExt.getStartTime()))
.map(CrossSectionPOExt::getId)
.collect(Collectors.toList());
// 根据时段ID过滤数据
List<GreenwaveCrossPO> filteredList = greenwaveCrossList.stream()
.filter(greenwaveCross -> sectionIdList.contains(greenwaveCross.getSectionId()))
.collect(Collectors.toList());
filteredList.sort(Comparator.comparing(GreenwaveCrossPO::getSort));
// 相对相位差列表
......@@ -626,13 +645,7 @@ public class TrendServiceImpl implements TrendService {
// 相位差
greenwaveCross.setOffset(greenwaveCrossPO.getOffset());
// 获取当前方案
String[] split = greenwaveName.split(" "); // 旅游路 东向西 转山西路至霞景路路段:正向绿波 工作日 19:00-20:00
String s = split[4];
String[] split1 = s.split("-");
String startTime = split1[0];
// 获取 planId
String planName = split[3];
// 获取当前方案ID
BaseCrossPlanPO baseCrossPlanPO = baseCrossPlanMapper.selectByCrossIdAndName(crossId, planName);
Integer planId = baseCrossPlanPO.getId();
CrossSectionPO crossSectionPO = baseCrossSectionMapper.selectbyStartTimeCrossIdPlanId(startTime, crossId, planId);
......
package net.wanji.databus.dao.entity;
import lombok.Data;
/**
* @author Kent HAN
* @date 2022/11/18 16:14
*/
@Data
public class CrossSectionPOExt extends CrossSectionPO{
private String planName; // 计划名称,如 周末、工作日
}
package net.wanji.databus.dao.mapper;
import net.wanji.databus.dao.entity.CrossSectionPO;
import net.wanji.databus.dao.entity.CrossSectionPOExt;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
......@@ -38,4 +39,6 @@ public interface BaseCrossSectionMapper {
List<CrossSectionPO> selectAll();
CrossSectionPO selectbyStartTimeCrossIdPlanId(String startTime, String crossId, Integer planId);
List<CrossSectionPOExt> selectByCrossIdsAndStartTime(String startTime, List<String> crossList);
}
......@@ -104,5 +104,15 @@
where start_time = #{startTime} and cross_id = #{crossId} and plan_id = #{planId}
</select>
<select id="selectByCrossIdsAndStartTime" resultType="net.wanji.databus.dao.entity.CrossSectionPOExt">
select t1.id, t1.start_time, t1.cross_id, t1.plan_id, t1.scheme_id, t2.name as planName
from t_base_cross_section t1 join t_base_cross_plan t2
on t1.plan_id = t2.id
where t1.cross_id in
<foreach collection="crossList" item="id" separator="," open="(" close=")">
#{id}
</foreach>
</select>
</mapper>
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