Commit b897f229 authored by zhouleilei's avatar zhouleilei

优化灯组

parent ca26b13f
...@@ -111,10 +111,13 @@ public class StaticInfoServiceImpl implements StaticInfoService { ...@@ -111,10 +111,13 @@ public class StaticInfoServiceImpl implements StaticInfoService {
LambdaQueryWrapper<VNtcipPatternView> queryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<VNtcipPatternView> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(VNtcipPatternView::getCIntsID, crossInfoPO.getCode()); queryWrapper.eq(VNtcipPatternView::getCIntsID, crossInfoPO.getCode());
List<VNtcipPatternView> vNtcipPatternViews = vNtcipPatternMapper.selectList(queryWrapper); List<VNtcipPatternView> vNtcipPatternViews = vNtcipPatternMapper.selectList(queryWrapper);
AtomicInteger lightNum = new AtomicInteger(0);
//灯组缓存
Map<String, Integer> lightsMap = new HashMap<>();
for (VNtcipPatternView vNtcipPatternView : vNtcipPatternViews) { for (VNtcipPatternView vNtcipPatternView : vNtcipPatternViews) {
CrossSchemeRingsDTO crossSchemeRingsDTO = new CrossSchemeRingsDTO(); CrossSchemeRingsDTO crossSchemeRingsDTO = new CrossSchemeRingsDTO();
crossSchemeRingsDTO.setCrossId(crossId); crossSchemeRingsDTO.setCrossId(crossId);
crossSchemeRingsDTO.setPattern(vNtcipPatternView.getNPatternNumber()+""); crossSchemeRingsDTO.setPattern(vNtcipPatternView.getNPatternNumber() + "");
//查询方案环图请求 //查询方案环图请求
CrossSchemeRings crossSchemeRings = crossSchemeRings(crossSchemeRingsDTO); CrossSchemeRings crossSchemeRings = crossSchemeRings(crossSchemeRingsDTO);
if (Optional.ofNullable(crossSchemeRings).isPresent()) { if (Optional.ofNullable(crossSchemeRings).isPresent()) {
...@@ -164,7 +167,7 @@ public class StaticInfoServiceImpl implements StaticInfoService { ...@@ -164,7 +167,7 @@ public class StaticInfoServiceImpl implements StaticInfoService {
//16 个相位的放行方向,每个相位由 8 字节整型值存储(最多支持 7 个放行方向),每个字节表示一个放行方向, //16 个相位的放行方向,每个相位由 8 字节整型值存储(最多支持 7 个放行方向),每个字节表示一个放行方向,
String[] channelDim = phase.getChannelDim().split(" "); String[] channelDim = phase.getChannelDim().split(" ");
//数据处理 //数据处理
getStagesByRings(cycle, ringCount, crossId, schemeNo, ringPhasesMap, crossLightsList, crossPhaseList, crossPhaseLightsPOList, channelDim); getStagesByRings(lightsMap, lightNum, cycle, ringCount, crossId, schemeNo, ringPhasesMap, crossLightsList, crossPhaseList, crossPhaseLightsPOList, channelDim);
} }
} }
...@@ -308,7 +311,7 @@ public class StaticInfoServiceImpl implements StaticInfoService { ...@@ -308,7 +311,7 @@ public class StaticInfoServiceImpl implements StaticInfoService {
* @Param ringPhaseMap 环包含的相位 * @Param ringPhaseMap 环包含的相位
* @Param phasesTime 各个相位的红绿黄时间和 * @Param phasesTime 各个相位的红绿黄时间和
**/ **/
private void getStagesByRings(int cycle, int ringCount, String crossId, int schemeNo, Map<Integer, List<RingPhaseDTO>> ringPhasesMap, List<CrossLightsPO> crossLightsList, List<CrossPhasePO> crossPhaseList, List<CrossPhaseLightsPO> crossPhaseLightsPOList, String[] channelDim) { private void getStagesByRings(Map<String, Integer> lightsMap, AtomicInteger lightNum, int cycle, int ringCount, String crossId, int schemeNo, Map<Integer, List<RingPhaseDTO>> ringPhasesMap, List<CrossLightsPO> crossLightsList, List<CrossPhasePO> crossPhaseList, List<CrossPhaseLightsPO> crossPhaseLightsPOList, String[] channelDim) {
//已经计算的阶段时长 //已经计算的阶段时长
int stageTime = 0; int stageTime = 0;
//循环次数,也代表阶段号 //循环次数,也代表阶段号
...@@ -419,8 +422,9 @@ public class StaticInfoServiceImpl implements StaticInfoService { ...@@ -419,8 +422,9 @@ public class StaticInfoServiceImpl implements StaticInfoService {
count++; count++;
} }
if (CollectionUtil.isNotEmpty(stagePhaseList)) { if (CollectionUtil.isNotEmpty(stagePhaseList)) {
//将结果组装到结果集 //将结果组装到结果集
doView(cycle, ringCount, crossId, schemeNo, stagePhaseList, crossLightsList, crossPhaseList, crossPhaseLightsPOList, channelDim); doView(lightsMap, lightNum, cycle, ringCount, crossId, schemeNo, stagePhaseList, crossLightsList, crossPhaseList, crossPhaseLightsPOList, channelDim);
} }
} }
...@@ -429,9 +433,8 @@ public class StaticInfoServiceImpl implements StaticInfoService { ...@@ -429,9 +433,8 @@ public class StaticInfoServiceImpl implements StaticInfoService {
* @Description 组装结果集 * @Description 组装结果集
* @Param [cycle, ringCount, crossId, schemeNo, crossLightsList, crossPhaseList, crossPhaseLightsPOList, channelDim] * @Param [cycle, ringCount, crossId, schemeNo, crossLightsList, crossPhaseList, crossPhaseLightsPOList, channelDim]
**/ **/
private void doView(int cycle, int ringCount, String crossId, int schemeNo, List<StagePhaseDTO> stagePhaseList, List<CrossLightsPO> crossLightsList, List<CrossPhasePO> crossPhaseList, List<CrossPhaseLightsPO> crossPhaseLightsPOList, String[] channelDim) { private void doView(Map<String, Integer> lightsMap, AtomicInteger lightNum, int cycle, int ringCount, String crossId, int schemeNo, List<StagePhaseDTO> stagePhaseList, List<CrossLightsPO> crossLightsList, List<CrossPhasePO> crossPhaseList, List<CrossPhaseLightsPO> crossPhaseLightsPOList, String[] channelDim) {
AtomicInteger phaseNum = new AtomicInteger(0); AtomicInteger phaseNum = new AtomicInteger(0);
AtomicInteger lightNum = new AtomicInteger(0);
//遍历阶段 //遍历阶段
for (StagePhaseDTO stagePhaseDTO : stagePhaseList) { for (StagePhaseDTO stagePhaseDTO : stagePhaseList) {
Integer stageId = stagePhaseDTO.getStageId(); Integer stageId = stagePhaseDTO.getStageId();
...@@ -483,9 +486,7 @@ public class StaticInfoServiceImpl implements StaticInfoService { ...@@ -483,9 +486,7 @@ public class StaticInfoServiceImpl implements StaticInfoService {
Integer wjPerson = HisensePersonEntranceAndExitEnum.getWjperson(Integer.parseInt(turn, 2)); Integer wjPerson = HisensePersonEntranceAndExitEnum.getWjperson(Integer.parseInt(turn, 2));
//灯组 //灯组
CrossLightsPO crossLightsPO = new CrossLightsPO(); CrossLightsPO crossLightsPO = new CrossLightsPO();
lightNum.getAndIncrement();
crossLightsPO.setLightsNo(schemeNo+ ""+lightNum.get() );
crossLightsPO.setName("灯组" + schemeNo+lightNum.get());
//默认0 //默认0
crossLightsPO.setType(0); crossLightsPO.setType(0);
if (wjPerson != 0) { if (wjPerson != 0) {
...@@ -493,22 +494,32 @@ public class StaticInfoServiceImpl implements StaticInfoService { ...@@ -493,22 +494,32 @@ public class StaticInfoServiceImpl implements StaticInfoService {
} else if (wjPerson == 0 && wjLightsDir > 0) { } else if (wjPerson == 0 && wjLightsDir > 0) {
crossLightsPO.setType(1); crossLightsPO.setType(1);
} }
crossLightsPO.setDir(wjLightsDir); //key
crossLightsPO.setTurn(wjLightsTurn); String lightMapKey = dir + turn + crossLightsPO.getType();
crossLightsPO.setCrossId(crossId); if (!lightsMap.containsKey(lightMapKey)){
crossLightsPO.setInOutType(wjPerson); lightNum.getAndIncrement();
crossLightsPO.setGmtCreate(null); lightsMap.put(lightMapKey, lightNum.get());
crossLightsPO.setGmtModified(null); crossLightsPO.setLightsNo(String.valueOf(lightsMap.get(lightMapKey)));
crossLightsList.add(crossLightsPO); crossLightsPO.setName("灯组" + lightsMap.get(lightMapKey));
crossLightsPO.setDir(wjLightsDir);
//灯组与相位关系 crossLightsPO.setTurn(wjLightsTurn);
CrossPhaseLightsPO crossPhaseLightsPO = new CrossPhaseLightsPO(); crossLightsPO.setCrossId(crossId);
crossPhaseLightsPO.setLightsId(Integer.valueOf(schemeNo+""+lightNum.get())); crossLightsPO.setInOutType(wjPerson);
crossPhaseLightsPO.setPhaseId(phaseNum.get()); crossLightsPO.setGmtCreate(null);
crossPhaseLightsPO.setCrossId(crossId); crossLightsPO.setGmtModified(null);
crossPhaseLightsPO.setGmtCreate(null); crossLightsList.add(crossLightsPO);
crossPhaseLightsPO.setGmtModified(null);
crossPhaseLightsPOList.add(crossPhaseLightsPO); //灯组与相位关系
CrossPhaseLightsPO crossPhaseLightsPO = new CrossPhaseLightsPO();
crossPhaseLightsPO.setLightsId(lightsMap.get(lightMapKey));
crossPhaseLightsPO.setPhaseId(phaseNum.get());
crossPhaseLightsPO.setCrossId(crossId);
crossPhaseLightsPO.setGmtCreate(null);
crossPhaseLightsPO.setGmtModified(null);
crossPhaseLightsPOList.add(crossPhaseLightsPO);
}
} }
} }
} }
......
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