Commit dba9312e authored by duanruiming's avatar duanruiming

[update] 优化相位转化逻辑,阶段号就是相位号

parent 21ce3fd2
......@@ -38,6 +38,7 @@ public class SchemeInfoPojo {
List<SchemeStagePojo> schemeStagePojos = new ArrayList<>();
for (int i = 0; i < schemeInfoPojo.getPhaseStageChain().size(); i++) {
SchemeStagePojo schemeStagePojo = new SchemeStagePojo();
schemeStagePojo.setSchemeId(schemeInfoPojo.getSchemeId());
schemeStagePojo.setPhaseStageId(schemeInfoPojo.getPhaseStageChain().get(i));
schemeStagePojo.setPhaseStageTime(schemeInfoPojo.getPhaseStageTimeChain().get(i));
schemeStagePojo.setPhaseStageType(schemeInfoPojo.getPhaseStageTypeChain().get(i));
......
......@@ -69,7 +69,7 @@ public class DTStaticInfoServiceImpl implements StaticInfoService {
List<BaseCrossSchemePO> crossSchemeList = getCrossSchemeList(crossId, schemeInfoPojos);
List<CrossPhasePO> crossPhaseList = getCrossPhaseList(crossId, phaseInfoPojos, phaseStageInfoPojos, schemeInfoPojos);
List<CrossLightsPO> crossLightsList = getCrossLightsList(crossId, crossPhaseList, phaseInfoPojos, lightsInfoPojos);
List<CrossPhaseLightsPO> crossPhaseLightsPOList = getCrossPhaseLightsList(crossId, crossPhaseList, phaseInfoPojos);
List<CrossPhaseLightsPO> crossPhaseLightsPOList = getCrossPhaseLightsList(crossId, crossPhaseList, phaseInfoPojos, phaseStageInfoPojos);
schemePhaseLightsVO.setCrossPhaseLightsPOList(crossPhaseLightsPOList);
schemePhaseLightsVO.setCrossPhaseList(crossPhaseList);
schemePhaseLightsVO.setCrossLightsList(crossLightsList);
......@@ -77,13 +77,20 @@ public class DTStaticInfoServiceImpl implements StaticInfoService {
return schemePhaseLightsVO;
}
private List<CrossPhaseLightsPO> getCrossPhaseLightsList(String crossId, List<CrossPhasePO> crossPhaseList, List<PhaseInfoPojo> phaseInfoPojos) {
private List<CrossPhaseLightsPO> getCrossPhaseLightsList(String crossId, List<CrossPhasePO> crossPhaseList, List<PhaseInfoPojo> phaseInfoPojos, List<PhaseStageInfoPojo> phaseStageInfoPojos) {
List<CrossPhaseLightsPO> crossPhaseLightsList = new ArrayList<>(crossPhaseList.size());
for (CrossPhasePO crossPhasePO : crossPhaseList) {
for (CrossPhasePO crossPhasePO : crossPhaseList) { // 当前相位号为阶段号
String phaseNo = crossPhasePO.getPhaseNo();
List<Integer> phaseList = new ArrayList<>();
for (PhaseStageInfoPojo phaseStageInfoPojo : phaseStageInfoPojos) {
if (StringUtils.equals(phaseNo, String.valueOf(phaseStageInfoPojo.getPhaseStageId()))) {
phaseList = phaseStageInfoPojo.getPhaseList();
}
}
for (PhaseInfoPojo phaseInfoPojo : phaseInfoPojos) {
if (StringUtils.equals(crossPhasePO.getPhaseNo(), String.valueOf(phaseInfoPojo.getPhaseId()))) {
if (phaseList.contains(phaseInfoPojo.getPhaseId())) {
CrossPhaseLightsPO crossPhaseLightsPO = new CrossPhaseLightsPO();
crossPhaseLightsPO.setPhaseId(phaseInfoPojo.getPhaseId());
crossPhaseLightsPO.setPhaseId(Integer.valueOf(phaseNo));
crossPhaseLightsPO.setLightsId(phaseInfoPojo.getLightsId());
crossPhaseLightsPO.setCrossId(crossId);
crossPhaseLightsList.add(crossPhaseLightsPO);
......@@ -125,31 +132,46 @@ public class DTStaticInfoServiceImpl implements StaticInfoService {
return crossLightsList.stream().distinct().collect(Collectors.toList());
}
/**
* 转化为万集单环模式,阶段号就是相位号
*
* @param crossId
* @param phaseInfoPojos
* @param phaseStageInfoPojos
* @param schemeInfoPojos
* @return
*/
private List<CrossPhasePO> getCrossPhaseList(String crossId, List<PhaseInfoPojo> phaseInfoPojos, List<PhaseStageInfoPojo> phaseStageInfoPojos, List<SchemeInfoPojo> schemeInfoPojos) {
List<CrossPhasePO> crossPhaseList = new ArrayList<>();
for (PhaseStageInfoPojo phaseStageInfoPojo : phaseStageInfoPojos) {
int sort = 0;
Integer phaseStageId = phaseStageInfoPojo.getPhaseStageId();
Integer schemeId = 0;
Integer phaseStageTime = 0;
for (SchemeInfoPojo schemeInfoPojo : schemeInfoPojos) {
List<SchemeInfoPojo.SchemeStagePojo> stageInfoList = SchemeInfoPojo.getStageInfoList(schemeInfoPojo);
for (SchemeInfoPojo.SchemeStagePojo schemeStagePojo : stageInfoList) {
Integer phaseStageId = schemeStagePojo.getPhaseStageId();
Integer phaseStageTime = schemeStagePojo.getPhaseStageTime();
for (PhaseStageInfoPojo phaseStageInfoPojo : phaseStageInfoPojos) {
if (Objects.equals(phaseStageId, phaseStageInfoPojo.getPhaseStageId())) {
if (Objects.equals(phaseStageId, schemeStagePojo.getPhaseStageId())) {
sort = stageInfoList.indexOf(schemeStagePojo) + 1;
schemeId = schemeStagePojo.getSchemeId();
phaseStageTime = schemeStagePojo.getPhaseStageTime();
}
}
}
List<Integer> phaseList = phaseStageInfoPojo.getPhaseList();
int ringNo = 0;
for (Integer phaseId : phaseList) {
CrossPhasePO crossPhasePO = new CrossPhasePO();
for (Integer phaseId : phaseList) {
crossPhasePO.setCrossId(crossId);
crossPhasePO.setPhaseNo(String.valueOf(phaseId));
crossPhasePO.setName(StringUtils.join("相位", phaseId));
++sort;
crossPhasePO.setPhaseNo(String.valueOf(phaseStageId));
crossPhasePO.setName(StringUtils.join("相位", phaseStageId));
crossPhasePO.setSort(sort);
crossPhasePO.setPlanId(schemeInfoPojo.getSchemeId());
crossPhasePO.setRingNo(++ringNo);
crossPhasePO.setPlanId(schemeId);
crossPhasePO.setRingNo(1);
crossPhasePO.setGroupNo(1);
crossPhasePO.setPhaseTime(phaseStageTime);
crossPhasePO.setControlMode(1);
crossPhasePO.setPhaseTime(schemeStagePojo.getPhaseStageTime());
crossPhasePO.setPhaseType(1);
crossPhasePO.setPhaseTime(phaseStageTime);
PhaseInfoPojo phaseInfoPojo = PhaseInfoPojo.getPhaseInfoPojoByPhaseId(phaseId, phaseInfoPojos);
if (Objects.nonNull(phaseInfoPojo)) {
crossPhasePO.setGreenTime(phaseInfoPojo.getGreenTime());
......@@ -163,11 +185,7 @@ public class DTStaticInfoServiceImpl implements StaticInfoService {
crossPhaseList.add(crossPhasePO);
}
}
}
}
}
return crossPhaseList;
return crossPhaseList.stream().distinct().collect(Collectors.toList());
}
private List<BaseCrossSchemePO> getCrossSchemeList(String crossId, List<SchemeInfoPojo> schemeInfoPojos) {
......@@ -251,6 +269,7 @@ public class DTStaticInfoServiceImpl implements StaticInfoService {
list.add(HexUtil.hexToInt(phaseTypeHex));
}
}
Collections.reverse(list);
return list;
}
......@@ -576,7 +595,7 @@ public class DTStaticInfoServiceImpl implements StaticInfoService {
return getCrossSchedulesPOs(crossId, scheduleInfoPojos);
}
private List<CrossSchedulesPO> getCrossSchedulesPOs(String crossId, List<ScheduleInfoPojo> scheduleInfoPojos) throws Exception{
private List<CrossSchedulesPO> getCrossSchedulesPOs(String crossId, List<ScheduleInfoPojo> scheduleInfoPojos) throws Exception {
List<CrossSchedulesPO> crossSchedulesPOS = new ArrayList<>(scheduleInfoPojos.size());
for (ScheduleInfoPojo scheduleInfoPojo : scheduleInfoPojos) {
List<Integer> week = scheduleInfoPojo.getWeek();
......
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