Commit 38abe07b authored by duanruiming's avatar duanruiming

[update] 运行状态

parent afb55782
...@@ -21,11 +21,13 @@ public class Constants { ...@@ -21,11 +21,13 @@ public class Constants {
public static final String COMMAND_QUERY_REPLY = "20"; public static final String COMMAND_QUERY_REPLY = "20";
public static final String COMMAND_PHASE_CONFIG = "0402"; public static final String COMMAND_PHASE_CONFIG = "0402";
public static final String COMMAND_LIGHT_CONFIG = "0302"; public static final String COMMAND_LIGHT_CONFIG = "0302";
public static final String COMMAND_LIGHT_STATUS = "0303";
public static final String COMMAND_PHASE_STAGE_CONFIG = "0602"; public static final String COMMAND_PHASE_STAGE_CONFIG = "0602";
public static final String COMMAND_SCHME_CONFIG = "0902"; public static final String COMMAND_SCHME_CONFIG = "0902";
public static final String COMMAND_DAILYPLAN_CONFIG = "0b02"; public static final String COMMAND_DAILYPLAN_CONFIG = "0b02";
public static final String COMMAND_SCHEDULE_CONFIG = "0c02"; public static final String COMMAND_SCHEDULE_CONFIG = "0c02";
public static final String COMMAND_RUNNING_STATUS = "0d02"; public static final String COMMAND_RUNNING_STATUS = "0d02";
public static final String COMMAND_FAULT_LIST = "1002";
......
...@@ -14,6 +14,7 @@ public enum CommandResultSign { ...@@ -14,6 +14,7 @@ public enum CommandResultSign {
GET_DEVICE_INFO("2001", "getDeviceInfoService"), GET_DEVICE_INFO("2001", "getDeviceInfoService"),
GET_SIGNAL_BASE_INFO("2002","getBaseInfoService"), GET_SIGNAL_BASE_INFO("2002","getBaseInfoService"),
GET_LIGHTS_GROUP_INFO("030220", "getLightsGroupInfoService"), GET_LIGHTS_GROUP_INFO("030220", "getLightsGroupInfoService"),
GET_LIGHTS_STATUS_INFO("030320", "getLightsStatusInfoService"),
GET_PHASE_INFO("040220", "getPhaseInfoService"), GET_PHASE_INFO("040220", "getPhaseInfoService"),
GET_DETECTOR_INFO("2005", "getDetectorInfoService"), GET_DETECTOR_INFO("2005", "getDetectorInfoService"),
GET_STAGE_INFO("060220", "getStageInfoService"), GET_STAGE_INFO("060220", "getStageInfoService"),
...@@ -24,7 +25,7 @@ public enum CommandResultSign { ...@@ -24,7 +25,7 @@ public enum CommandResultSign {
GET_RUNNING_STATE_INFO("0d0220", "getRunningStateInfoService"), GET_RUNNING_STATE_INFO("0d0220", "getRunningStateInfoService"),
GET_TRAFFIC_DATA_INFO("2014", "getTrafficDataInfoService"), GET_TRAFFIC_DATA_INFO("2014", "getTrafficDataInfoService"),
GET_ALARM_INFO("2015", "getAlarmInfoService"), GET_ALARM_INFO("2015", "getAlarmInfoService"),
GET_FAULT_INFO("2016", "getFaultInfoService"), GET_FAULT_INFO("100220", "getFaultInfoService"),
SET_DEVICE_INFO("3001", "setDeviceInfoService"), SET_DEVICE_INFO("3001", "setDeviceInfoService"),
SET_SIGNAL_BASE_INFO("3002","setBaseInfoService"), SET_SIGNAL_BASE_INFO("3002","setBaseInfoService"),
......
...@@ -44,6 +44,7 @@ public class SignalStatusController { ...@@ -44,6 +44,7 @@ public class SignalStatusController {
}) })
public JsonViewObject runningStatusAlarm() { public JsonViewObject runningStatusAlarm() {
List<SignalStatusLogPO> signalStatusLogPOList = signalStatusService.runningStatusAlarm(); List<SignalStatusLogPO> signalStatusLogPOList = signalStatusService.runningStatusAlarm();
signalStatusService.runningStatusAlarm("12F7L08J8S0");
JsonViewObject jsonViewObject = JsonViewObject.newInstance(); JsonViewObject jsonViewObject = JsonViewObject.newInstance();
return jsonViewObject.success(signalStatusLogPOList); return jsonViewObject.success(signalStatusLogPOList);
......
...@@ -22,7 +22,6 @@ import org.springframework.web.bind.annotation.RequestMapping; ...@@ -22,7 +22,6 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MediaType;
import java.util.Objects;
/** /**
* 静态信息接口 * 静态信息接口
...@@ -47,12 +46,8 @@ public class StaticInfoController { ...@@ -47,12 +46,8 @@ public class StaticInfoController {
@ApiResponse(code = 200, message = "OK", response = SchemePhaseLightsVO.class) @ApiResponse(code = 200, message = "OK", response = SchemePhaseLightsVO.class)
}) })
public JsonViewObject schemePhaseLights(@RequestBody @Validated SchemePhaseLightsDTO schemePhaseLightsDTO) throws Exception { public JsonViewObject schemePhaseLights(@RequestBody @Validated SchemePhaseLightsDTO schemePhaseLightsDTO) throws Exception {
// 命令调用 SchemePhaseLightsVO schemePhaseLightsVO = staticInfoService.schemePhaseLights(schemePhaseLightsDTO);
staticInfoService.schemePhaseLights(schemePhaseLightsDTO);
// 构造返回值
SchemePhaseLightsVO schemePhaseLightsVO = staticInfoService.buildSchemePhaseLightsResponse(schemePhaseLightsDTO);
JsonViewObject jsonViewObject = JsonViewObject.newInstance(); JsonViewObject jsonViewObject = JsonViewObject.newInstance();
return jsonViewObject.success(schemePhaseLightsVO); return jsonViewObject.success(schemePhaseLightsVO);
} }
...@@ -67,20 +62,9 @@ public class StaticInfoController { ...@@ -67,20 +62,9 @@ public class StaticInfoController {
public JsonViewObject planSection(@RequestBody @Validated PlanSectionDTO planSectionDTO) throws Exception { public JsonViewObject planSection(@RequestBody @Validated PlanSectionDTO planSectionDTO) throws Exception {
// 命令调用 // 命令调用
staticInfoService.planSection(planSectionDTO); staticInfoService.planSection(planSectionDTO);
// 构造返回值
String crossId = planSectionDTO.getCrossId();
Integer planNo = planSectionDTO.getPlanNo();
PlanSectionVO planSectionVO = new PlanSectionVO();
if (Objects.isNull(planNo) || planNo == -1) {
// 返回所有
planSectionVO = staticInfoService.buildPlanSectionResponse(crossId);
} else {
// 按计划号返回
planSectionVO = staticInfoService.buildPlanSectionResponse(crossId, planNo);
}
JsonViewObject jsonViewObject = JsonViewObject.newInstance(); JsonViewObject jsonViewObject = JsonViewObject.newInstance();
return jsonViewObject.success(planSectionVO); return jsonViewObject.success(null);
} }
@AspectLog(description = "时间表数据", operationType = BaseEnum.OperationTypeEnum.QUERY) @AspectLog(description = "时间表数据", operationType = BaseEnum.OperationTypeEnum.QUERY)
......
package net.wanji.com.netty.response.impl.get;
import net.wanji.com.netty.pojo.CommandPojo;
import net.wanji.com.netty.response.CommandResponseFactory;
import org.springframework.stereotype.Service;
/**
* @author duanruiming
* @date 2023/06/16 9:45
*/
@Service
public class GetLightsStatusInfoService implements CommandResponseFactory {
@Override
public String getCommandResponse(CommandPojo commandPojo) {
return commandPojo.getResponseMsg();
}
}
...@@ -11,7 +11,7 @@ import java.util.List; ...@@ -11,7 +11,7 @@ import java.util.List;
@Data @Data
public class DailyPlanInfoPojo { public class DailyPlanInfoPojo {
private Integer dailyPlanId; private Integer dailyPlanId;
private Integer crossId; private Integer controlCrossId;
private List<String> startTimeChain; private List<String> startTimeChain;
private List<Integer> schemeIdChain; private List<Integer> schemeIdChain;
private List<Integer> controlModelChain; private List<Integer> controlModelChain;
......
package net.wanji.com.pojo.dtconvert;
import lombok.Data;
/**
* @author duanruiming
* @date 2023/06/16 8:43
*/
@Data
public class FaultInfoPojo {
}
...@@ -11,4 +11,39 @@ public class LightsInfoPojo { ...@@ -11,4 +11,39 @@ public class LightsInfoPojo {
private Integer lightId; private Integer lightId;
// 1-机动车 2-非机动车 3-行人 4-车道 5-可变交通标志 6-公交车灯具 7-有轨电车专用灯 8-特殊灯 // 1-机动车 2-非机动车 3-行人 4-车道 5-可变交通标志 6-公交车灯具 7-有轨电车专用灯 8-特殊灯
private Integer type; private Integer type;
public static Integer getLightsDir(Integer lightId) {
// 万集 灯组放行方向:1北;2东北;3东;4东南;5南;6西南;7西;8西北
Integer dir = null;
if (lightId <= 4) {
dir = 1;
} else if (lightId <= 8) {
dir = 3;
} else if (lightId <= 12) {
dir = 5;
} else if (lightId <= 16) {
dir = 7;
}
return dir;
}
// 万集 灯组转向:1左转;2右转;3直行;4左掉头;5直左;6直右;7右掉头;8向左合流;9向右合流;10左转加掉头;11右转加掉头;
// 12直行加左掉头;13直行加右掉头;14左转右转;15左直右;16左转右转加掉头;17左直掉头;18左直右掉头;20行人
public static Integer getTurnDir(Integer lightId, Integer type) {
Integer turnDir = null;
if (type == 3) {
turnDir = 20;
return turnDir;
}
if (lightId % 4 == 1 && type ==1) {
turnDir = 1;
} else {
turnDir = 6;
}
return turnDir;
}
public static void main(String[] args) {
System.err.println(1 % 4 == 1);
}
} }
...@@ -3,6 +3,9 @@ package net.wanji.com.pojo.dtconvert; ...@@ -3,6 +3,9 @@ package net.wanji.com.pojo.dtconvert;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import java.util.List;
import java.util.Objects;
/** /**
* @author duanruiming * @author duanruiming
* @date 2023/06/13 14:21 * @date 2023/06/13 14:21
...@@ -12,14 +15,23 @@ import lombok.NoArgsConstructor; ...@@ -12,14 +15,23 @@ import lombok.NoArgsConstructor;
@NoArgsConstructor @NoArgsConstructor
public class PhaseInfoPojo { public class PhaseInfoPojo {
private Integer phaseId; private Integer phaseId;
private Integer lights; private Integer lightsId;
private Integer greenTime; private Integer greenTime;
private Integer greenFlashTime; private Integer greenFlashTime;
private Integer yellowTime; private Integer yellowTime;
private Integer redTime;
private Integer yellowFlashTime; private Integer yellowFlashTime;
private Integer redTime;
private Integer minGreenTime; private Integer minGreenTime;
private Integer maxGreenTime; private Integer maxGreenTime;
private Integer maxGreenTime2; private Integer maxGreenTime2;
private Integer extendGreenTime; private Integer extendGreenTime;
public static PhaseInfoPojo getPhaseInfoPojoByPhaseId(Integer phaseId, List<PhaseInfoPojo> phaseInfoPojos) {
for (PhaseInfoPojo phaseInfoPojo : phaseInfoPojos) {
if (Objects.equals(phaseInfoPojo.getPhaseId(), phaseId)) {
return phaseInfoPojo;
}
}
return null;
}
} }
package net.wanji.com.pojo.dtconvert;
import lombok.Data;
/**
* @author duanruiming
* @date 2023/06/16 10:00
*/
@Data
public class RunningStatusPojo {
private Integer controlCrossId;
private String controlMode;
private Integer schemeId;
private Integer phaseStageId;
}
...@@ -11,7 +11,7 @@ import java.util.List; ...@@ -11,7 +11,7 @@ import java.util.List;
@Data @Data
public class ScheduleInfoPojo { public class ScheduleInfoPojo {
private Integer scheduleId; private Integer scheduleId;
private Integer crossId; private Integer controlCrossId;
private Integer priority; private Integer priority;
private List<Integer> week; private List<Integer> week;
private List<Integer> month; private List<Integer> month;
......
...@@ -2,7 +2,9 @@ package net.wanji.com.pojo.dtconvert; ...@@ -2,7 +2,9 @@ package net.wanji.com.pojo.dtconvert;
import lombok.Data; import lombok.Data;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Objects;
/** /**
* @author duanruiming * @author duanruiming
...@@ -12,13 +14,37 @@ import java.util.List; ...@@ -12,13 +14,37 @@ import java.util.List;
public class SchemeInfoPojo { public class SchemeInfoPojo {
private Integer schemeId; private Integer schemeId;
// 所属方案序号 一台信号机控制多路口时使用 // 所属方案序号 一台信号机控制多路口时使用
private Integer crossId; private Integer controlCrossId;
// 单位s // 单位s
private Integer cycle; private Integer cycle;
// 方案协调序号 需要协调的相位序号 // 方案协调序号 需要协调的相位序号
private Integer harmonizeId; private Integer harmonizeId;
private Integer offset; private Integer offset;
private List<Integer> phaseList; private List<Integer> phaseStageChain;
private List<Integer> phaseTimeChain; private List<Integer> phaseStageTimeChain;
private List<Integer> phaseTypeChain; // 10 固定出现 20 检测器按需出现
private List<Integer> phaseStageTypeChain;
@Data
public static class SchemeStagePojo {
private Integer schemeId;
private Integer phaseStageId;
private Integer phaseStageTime;
private Integer phaseStageType;
}
public static List<SchemeStagePojo> getStageInfoList(SchemeInfoPojo schemeInfoPojo) {
if (Objects.nonNull(schemeInfoPojo)) {
List<SchemeStagePojo> schemeStagePojos = new ArrayList<>();
for (int i = 0; i < schemeInfoPojo.getPhaseStageChain().size(); i++) {
SchemeStagePojo schemeStagePojo = new SchemeStagePojo();
schemeStagePojo.setPhaseStageId(schemeInfoPojo.getPhaseStageChain().get(i));
schemeStagePojo.setPhaseStageTime(schemeInfoPojo.getPhaseStageTimeChain().get(i));
schemeStagePojo.setPhaseStageType(schemeInfoPojo.getPhaseStageTypeChain().get(i));
schemeStagePojos.add(schemeStagePojo);
}
return schemeStagePojos;
}
return null;
}
} }
...@@ -21,11 +21,4 @@ public interface StaticInfoService extends BeanMarkService { ...@@ -21,11 +21,4 @@ public interface StaticInfoService extends BeanMarkService {
List<CrossSchedulesPO> crossSchedules(CrossSchedulesDTO crossSchedulesDTO) throws Exception; List<CrossSchedulesPO> crossSchedules(CrossSchedulesDTO crossSchedulesDTO) throws Exception;
SchemePhaseLightsVO buildSchemePhaseLightsResponse(SchemePhaseLightsDTO schemePhaseLightsDTO);
PlanSectionVO buildPlanSectionResponse(String crossId);
PlanSectionVO buildPlanSectionResponse(String crossId, Integer planNo);
List<CrossSchedulesPO> buildCrossSchedulesResponse(List<String> crossIdList);
} }
package net.wanji.com.service.controller.impl; package net.wanji.com.service.controller.impl;
import cn.hutool.core.util.HexUtil;
import net.wanji.com.cache.CrossInfoCache;
import net.wanji.com.common.constants.Constants;
import net.wanji.com.netty.NettyClient;
import net.wanji.com.pojo.dtconvert.FaultInfoPojo;
import net.wanji.com.pojo.dtconvert.RunningStatusPojo;
import net.wanji.com.pojo.netty.MessageResultPojo;
import net.wanji.com.service.controller.SignalStatusService; import net.wanji.com.service.controller.SignalStatusService;
import net.wanji.common.enums.BaseEnum; import net.wanji.common.enums.BaseEnum;
import net.wanji.databus.po.CrossInfoPO;
import net.wanji.databus.po.SignalStatusLogPO; import net.wanji.databus.po.SignalStatusLogPO;
import net.wanji.databus.vo.LightsStatusVO; import net.wanji.databus.vo.LightsStatusVO;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Objects;
/** /**
* @author duanruiming * @author duanruiming
...@@ -15,6 +27,9 @@ import java.util.List; ...@@ -15,6 +27,9 @@ import java.util.List;
@Service @Service
public class DTSignalStatusServiceImpl implements SignalStatusService { public class DTSignalStatusServiceImpl implements SignalStatusService {
@Resource
private CrossInfoCache crossInfoCache;
@Override @Override
public String getBeanMark() { public String getBeanMark() {
return BaseEnum.VendorTypeEnum.DT.getNick(); return BaseEnum.VendorTypeEnum.DT.getNick();
...@@ -27,6 +42,88 @@ public class DTSignalStatusServiceImpl implements SignalStatusService { ...@@ -27,6 +42,88 @@ public class DTSignalStatusServiceImpl implements SignalStatusService {
@Override @Override
public List<SignalStatusLogPO> runningStatusAlarm(String crossId) { public List<SignalStatusLogPO> runningStatusAlarm(String crossId) {
List<FaultInfoPojo> faultInfoPojos = getFaultInfoPojos(crossId);
List<String> lightsStatus = getLightsStausInfoPojos(crossId);
List<RunningStatusPojo> runningStatusPojos = getRunningStatusPojos(crossId);
return null;
}
private List<RunningStatusPojo> getRunningStatusPojos(String crossId) {
List<RunningStatusPojo> runningStatusPojos = new ArrayList<>();
CrossInfoPO crossInfoPO = crossInfoCache.getCrossInfoCache().get(crossId);
String message = String.format(Constants.COMMAND_COMMON, Constants.COMMAND_QUERY, Constants.COMMAND_RUNNING_STATUS);
String runningStatusSign = Constants.COMMAND_RUNNING_STATUS.concat(Constants.COMMAND_QUERY_REPLY);
String runnningStatusHex = Constants.buildMessage(message);
MessageResultPojo resultPojo = NettyClient.sendMessage(crossInfoPO.getIp(), crossInfoPO.getPort(), runnningStatusHex, runningStatusSign, 300);
if (Objects.nonNull(resultPojo) && StringUtils.isNotBlank(resultPojo.getHexMessageResult())) {
String hexMessageResult = resultPojo.getHexMessageResult();
String body = hexMessageResult.substring(32, hexMessageResult.length() - 2);
int size = body.length() / 14;
List<String> paramList = new ArrayList<>();
for (int i = 0; i < size; i++) {
String param = body.substring(i * 14 + 6, i * 14 + 10);
if (!StringUtils.equalsIgnoreCase("0000", param)) {
paramList.add(param);
}
}
for (int i = 0; i < paramList.size() / 4; i++) {
RunningStatusPojo runningStatusPojo = new RunningStatusPojo();
runningStatusPojo.setControlCrossId(HexUtil.hexToInt(paramList.get(i * 4)));
runningStatusPojo.setControlMode(paramList.get(i * 4 + 1));
runningStatusPojo.setSchemeId(HexUtil.hexToInt(paramList.get(i * 4 + 2)));
runningStatusPojo.setPhaseStageId(HexUtil.hexToInt(paramList.get(i * 4 + 3)));
runningStatusPojos.add(runningStatusPojo);
}
}
return runningStatusPojos;
}
private List<String> getLightsStausInfoPojos(String crossId) {
List<String> lightsStatusList = new ArrayList<>();
CrossInfoPO crossInfoPO = crossInfoCache.getCrossInfoCache().get(crossId);
String message = String.format(Constants.COMMAND_COMMON, Constants.COMMAND_QUERY, Constants.COMMAND_LIGHT_STATUS);
String lightStatusSign = Constants.COMMAND_LIGHT_STATUS.concat(Constants.COMMAND_QUERY_REPLY);
String lightStatusHex = Constants.buildMessage(message);
MessageResultPojo resultPojo = NettyClient.sendMessage(crossInfoPO.getIp(), crossInfoPO.getPort(), lightStatusHex, lightStatusSign, 300);
if (Objects.nonNull(resultPojo) && StringUtils.isNotBlank(resultPojo.getHexMessageResult())) {
String hexMessageResult = resultPojo.getHexMessageResult();
String body = hexMessageResult.substring(32, hexMessageResult.length() - 2);
int lightsStatusSize = body.length() / 14;
for (int i = 0; i < lightsStatusSize; i++) {
String param = body.substring(i * 14 + 8, i * 14 +10);
if (!StringUtils.equalsIgnoreCase("00", param)) {
lightsStatusList.add(param);
}
}
}
return lightsStatusList;
}
public static void main(String[] args) {
String message = String.format("010001000000010001%s010105%s020000", Constants.COMMAND_QUERY, Constants.COMMAND_FAULT_LIST);
String faultHex = Constants.buildMessage(message);
System.err.println(faultHex);
}
private List<FaultInfoPojo> getFaultInfoPojos(String crossId) {
CrossInfoPO crossInfoPO = crossInfoCache.getCrossInfoCache().get(crossId);
String message = String.format(Constants.COMMAND_COMMON, Constants.COMMAND_QUERY, Constants.COMMAND_FAULT_LIST);
String faultSign = Constants.COMMAND_FAULT_LIST.concat(Constants.COMMAND_QUERY_REPLY);
String faultHex = Constants.buildMessage(message);
MessageResultPojo resultPojo = NettyClient.sendMessage(crossInfoPO.getIp(), crossInfoPO.getPort(), faultHex, faultSign, 300);
List<FaultInfoPojo> faultInfoPojos = new ArrayList<>();
if (Objects.nonNull(resultPojo) && StringUtils.isNotBlank(resultPojo.getHexMessageResult())) {
String hexMessageResult = resultPojo.getHexMessageResult();
String body = hexMessageResult.substring(32, hexMessageResult.length() - 2);
int lightsStatusSize = body.length() / 14 * 64;
int paramIndex = 8;
for (int i = 0; i < lightsStatusSize; i++) {
String param = body.substring(paramIndex * i, paramIndex * i + 8);
}
}
return null; return null;
} }
......
...@@ -10,7 +10,7 @@ import net.wanji.com.pojo.dtconvert.*; ...@@ -10,7 +10,7 @@ import net.wanji.com.pojo.dtconvert.*;
import net.wanji.com.pojo.netty.MessageResultPojo; import net.wanji.com.pojo.netty.MessageResultPojo;
import net.wanji.com.service.controller.StaticInfoService; import net.wanji.com.service.controller.StaticInfoService;
import net.wanji.common.enums.BaseEnum; import net.wanji.common.enums.BaseEnum;
import net.wanji.databus.dao.entity.CrossSchedulesPO; import net.wanji.databus.dao.entity.*;
import net.wanji.databus.dto.CrossInfoDTO; import net.wanji.databus.dto.CrossInfoDTO;
import net.wanji.databus.dto.CrossSchedulesDTO; import net.wanji.databus.dto.CrossSchedulesDTO;
import net.wanji.databus.dto.PlanSectionDTO; import net.wanji.databus.dto.PlanSectionDTO;
...@@ -48,16 +48,138 @@ public class DTStaticInfoServiceImpl implements StaticInfoService { ...@@ -48,16 +48,138 @@ public class DTStaticInfoServiceImpl implements StaticInfoService {
@Override @Override
public SchemePhaseLightsVO schemePhaseLights(SchemePhaseLightsDTO schemePhaseLightsDTO) throws Exception { public SchemePhaseLightsVO schemePhaseLights(SchemePhaseLightsDTO schemePhaseLightsDTO) throws Exception {
SchemePhaseLightsVO schemePhaseLightsVO = new SchemePhaseLightsVO();
String crossId = schemePhaseLightsDTO.getCrossId(); String crossId = schemePhaseLightsDTO.getCrossId();
CrossInfoPO crossInfo = crossInfoCache.getCrossInfoCache().get(crossId); CrossInfoPO crossInfo = crossInfoCache.getCrossInfoCache().get(crossId);
List<PhaseInfoPojo> phaseInfoPojos = getPhaseInfo(crossInfo); List<PhaseInfoPojo> phaseInfoPojos = getPhaseInfo(crossInfo);
List<LightsInfoPojo> lightsInfoPojos = getLightsInfo(crossInfo); List<LightsInfoPojo> lightsInfoPojos = getLightsInfo(crossInfo);
List<PhaseStageInfoPojo> phaseStageInfoPojos = getPhaseStageInfo(crossInfo); List<PhaseStageInfoPojo> phaseStageInfoPojos = getPhaseStageInfo(crossInfo);
List<SchemeInfoPojo> schemeInfoPojos = getSchemeInfo(crossInfo); List<SchemeInfoPojo> schemeInfoPojos = getSchemeInfo(crossInfo);
SchemePhaseLightsVO schemePhaseLightsVO = getSchemePhaseLightsVO(crossId, phaseInfoPojos, lightsInfoPojos, phaseStageInfoPojos, schemeInfoPojos);
return schemePhaseLightsVO;
}
private SchemePhaseLightsVO getSchemePhaseLightsVO(String crossId, List<PhaseInfoPojo> phaseInfoPojos, List<LightsInfoPojo> lightsInfoPojos, List<PhaseStageInfoPojo> phaseStageInfoPojos, List<SchemeInfoPojo> schemeInfoPojos) {
SchemePhaseLightsVO schemePhaseLightsVO = new SchemePhaseLightsVO();
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);
schemePhaseLightsVO.setCrossPhaseLightsPOList(crossPhaseLightsPOList);
schemePhaseLightsVO.setCrossPhaseList(crossPhaseList);
schemePhaseLightsVO.setCrossLightsList(crossLightsList);
schemePhaseLightsVO.setCrossSchemeList(crossSchemeList);
return schemePhaseLightsVO; return schemePhaseLightsVO;
} }
private List<CrossPhaseLightsPO> getCrossPhaseLightsList(String crossId, List<CrossPhasePO> crossPhaseList, List<PhaseInfoPojo> phaseInfoPojos) {
List<CrossPhaseLightsPO> crossPhaseLightsList = new ArrayList<>(crossPhaseList.size());
for (CrossPhasePO crossPhasePO : crossPhaseList) {
for (PhaseInfoPojo phaseInfoPojo : phaseInfoPojos) {
if (StringUtils.equals(crossPhasePO.getPhaseNo(), String.valueOf(phaseInfoPojo.getPhaseId()))) {
CrossPhaseLightsPO crossPhaseLightsPO = new CrossPhaseLightsPO();
crossPhaseLightsPO.setPhaseId(phaseInfoPojo.getPhaseId());
crossPhaseLightsPO.setLightsId(phaseInfoPojo.getLightsId());
crossPhaseLightsPO.setCrossId(crossId);
crossPhaseLightsList.add(crossPhaseLightsPO);
}
}
}
return crossPhaseLightsList.stream().distinct().collect(Collectors.toList());
}
private List<CrossLightsPO> getCrossLightsList(String crossId, List<CrossPhasePO> crossPhaseList, List<PhaseInfoPojo> phaseInfoPojos, List<LightsInfoPojo> lightsInfoPojos) {
List<CrossLightsPO> crossLightsList = new ArrayList<>();
for (CrossPhasePO crossPhasePO : crossPhaseList) {
for (PhaseInfoPojo phaseInfoPojo : phaseInfoPojos) {
if (StringUtils.equals(crossPhasePO.getPhaseNo(), String.valueOf(phaseInfoPojo.getPhaseId()))) {
CrossLightsPO crossLightsPO = new CrossLightsPO();
Integer phaseLightsId = phaseInfoPojo.getLightsId();
for (LightsInfoPojo lightsInfoPojo : lightsInfoPojos) {
Integer lightId = lightsInfoPojo.getLightId();
if (Objects.equals(phaseLightsId, lightId)) {
crossLightsPO.setLightsNo(String.valueOf(lightId));
crossLightsPO.setName(StringUtils.join("灯组", lightId));
Integer turnDir = LightsInfoPojo.getTurnDir(lightId, lightsInfoPojo.getType());
crossLightsPO.setTurn(turnDir);
crossLightsPO.setType(2);
if (turnDir == 20) {
crossLightsPO.setType(3);
}
crossLightsPO.setCrossId(crossId);
Integer dir = LightsInfoPojo.getLightsDir(lightId);
crossLightsPO.setDir(dir);
crossLightsPO.setInOutType(2);
crossLightsList.add(crossLightsPO);
break;
}
}
}
}
}
return crossLightsList.stream().distinct().collect(Collectors.toList());
}
private List<CrossPhasePO> getCrossPhaseList(String crossId, List<PhaseInfoPojo> phaseInfoPojos, List<PhaseStageInfoPojo> phaseStageInfoPojos, List<SchemeInfoPojo> schemeInfoPojos) {
List<CrossPhasePO> crossPhaseList = new ArrayList<>();
int sort = 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())) {
List<Integer> phaseList = phaseStageInfoPojo.getPhaseList();
for (Integer phaseId : phaseList) {
CrossPhasePO crossPhasePO = new CrossPhasePO();
crossPhasePO.setCrossId(crossId);
crossPhasePO.setPhaseNo(String.valueOf(phaseId));
crossPhasePO.setName(StringUtils.join("相位", phaseId));
++sort;
crossPhasePO.setSort(sort);
crossPhasePO.setPlanId(schemeInfoPojo.getSchemeId());
crossPhasePO.setRingNo(1);
crossPhasePO.setGroupNo(1);
crossPhasePO.setPhaseTime(phaseStageTime);
crossPhasePO.setControlMode(1);
crossPhasePO.setPhaseTime(schemeStagePojo.getPhaseStageTime());
PhaseInfoPojo phaseInfoPojo = PhaseInfoPojo.getPhaseInfoPojoByPhaseId(phaseId, phaseInfoPojos);
if (Objects.nonNull(phaseInfoPojo)) {
crossPhasePO.setGreenTime(phaseInfoPojo.getGreenTime());
crossPhasePO.setGreenFlashTime(phaseInfoPojo.getGreenFlashTime());
crossPhasePO.setYellowFlashTime(phaseInfoPojo.getYellowFlashTime());
crossPhasePO.setYellowTime(phaseInfoPojo.getYellowTime());
crossPhasePO.setRedTime(phaseInfoPojo.getRedTime());
crossPhasePO.setMinGreenTime(phaseInfoPojo.getMinGreenTime());
crossPhasePO.setMaxGreenTime(phaseInfoPojo.getMaxGreenTime());
}
crossPhaseList.add(crossPhasePO);
}
}
}
}
}
return crossPhaseList;
}
private List<BaseCrossSchemePO> getCrossSchemeList(String crossId, List<SchemeInfoPojo> schemeInfoPojos) {
List<BaseCrossSchemePO> crossSchemeList = new ArrayList<>();
for (SchemeInfoPojo schemeInfoPojo : schemeInfoPojos) {
BaseCrossSchemePO baseCrossSchemePO = new BaseCrossSchemePO();
baseCrossSchemePO.setSchemeNo(String.valueOf(schemeInfoPojo.getSchemeId()));
baseCrossSchemePO.setName(StringUtils.join("方案", schemeInfoPojo.getSchemeId()));
baseCrossSchemePO.setCrossId(crossId);
baseCrossSchemePO.setCycle(schemeInfoPojo.getCycle());
baseCrossSchemePO.setCoordPhase(schemeInfoPojo.getHarmonizeId());
baseCrossSchemePO.setOffset(schemeInfoPojo.getOffset());
baseCrossSchemePO.setSource(1);
baseCrossSchemePO.setIsDeleted(0);
crossSchemeList.add(baseCrossSchemePO);
}
return crossSchemeList;
}
private List<SchemeInfoPojo> getSchemeInfo(CrossInfoPO crossInfo) { private List<SchemeInfoPojo> getSchemeInfo(CrossInfoPO crossInfo) {
String message = String.format(Constants.COMMAND_COMMON, Constants.COMMAND_QUERY, Constants.COMMAND_SCHME_CONFIG); String message = String.format(Constants.COMMAND_COMMON, Constants.COMMAND_QUERY, Constants.COMMAND_SCHME_CONFIG);
String schemeSign = Constants.COMMAND_SCHME_CONFIG.concat(Constants.COMMAND_QUERY_REPLY); String schemeSign = Constants.COMMAND_SCHME_CONFIG.concat(Constants.COMMAND_QUERY_REPLY);
...@@ -83,21 +205,21 @@ public class DTStaticInfoServiceImpl implements StaticInfoService { ...@@ -83,21 +205,21 @@ public class DTStaticInfoServiceImpl implements StaticInfoService {
Integer schemeId = entry.getKey(); Integer schemeId = entry.getKey();
schemeInfoPojo.setSchemeId(schemeId); schemeInfoPojo.setSchemeId(schemeId);
List<String> value = entry.getValue(); List<String> value = entry.getValue();
schemeInfoPojo.setCrossId(HexUtil.hexToInt(value.get(0))); schemeInfoPojo.setControlCrossId(HexUtil.hexToInt(value.get(0)));
schemeInfoPojo.setCycle(HexUtil.hexToInt(value.get(1))); schemeInfoPojo.setCycle(HexUtil.hexToInt(value.get(1)));
schemeInfoPojo.setHarmonizeId(HexUtil.hexToInt(value.get(2))); schemeInfoPojo.setHarmonizeId(HexUtil.hexToInt(value.get(2)));
schemeInfoPojo.setOffset(HexUtil.hexToInt(value.get(3))); schemeInfoPojo.setOffset(HexUtil.hexToInt(value.get(3)));
String phaseChainHex = value.get(4); String phaseChainHex = value.get(4);
List<Integer> phaseList = getListFromHex(phaseChainHex, 2, "00"); List<Integer> phaseList = getListFromHex(phaseChainHex, 2, "00");
schemeInfoPojo.setPhaseList(phaseList); schemeInfoPojo.setPhaseStageChain(phaseList);
String phaseTimeChainHex = value.get(5); String phaseTimeChainHex = value.get(5);
List<Integer> phaseTimeList = getListFromHex(phaseTimeChainHex, 4, "0000"); List<Integer> phaseTimeList = getListFromHex(phaseTimeChainHex, 4, "0000");
schemeInfoPojo.setPhaseTimeChain(phaseTimeList); schemeInfoPojo.setPhaseStageTimeChain(phaseTimeList);
String phaseTypeChainHex = value.get(6); String phaseTypeChainHex = value.get(6);
List<Integer> phaseTypeList = getListFromHex(phaseTypeChainHex, 2, "00"); List<Integer> phaseTypeList = getListFromHex(phaseTypeChainHex, 2, "00");
schemeInfoPojo.setPhaseTypeChain(phaseTypeList); schemeInfoPojo.setPhaseStageTypeChain(phaseTypeList);
schemeInfoPojos.add(schemeInfoPojo); schemeInfoPojos.add(schemeInfoPojo);
} }
...@@ -254,12 +376,13 @@ public class DTStaticInfoServiceImpl implements StaticInfoService { ...@@ -254,12 +376,13 @@ public class DTStaticInfoServiceImpl implements StaticInfoService {
sb.append(StringUtils.leftPad(binary, 8, '0')); sb.append(StringUtils.leftPad(binary, 8, '0'));
} }
phaseInfoPojo.setPhaseId(phaseId); phaseInfoPojo.setPhaseId(phaseId);
phaseInfoPojo.setLights(sb.reverse().toString().indexOf("1")); phaseInfoPojo.setLightsId(sb.reverse().toString().indexOf("1") + 1);
phaseInfoPojo.setGreenTime(HexUtil.hexToInt(phaseParamList.get(2))); phaseInfoPojo.setGreenTime(HexUtil.hexToInt(phaseParamList.get(2)));
phaseInfoPojo.setGreenFlashTime(HexUtil.hexToInt(phaseParamList.get(4))); phaseInfoPojo.setGreenFlashTime(HexUtil.hexToInt(phaseParamList.get(4)));
phaseInfoPojo.setYellowTime(HexUtil.hexToInt(phaseParamList.get(6))); phaseInfoPojo.setYellowTime(HexUtil.hexToInt(phaseParamList.get(6)));
int redTime = HexUtil.hexToInt(phaseParamList.get(8)) - phaseInfoPojo.getGreenTime() - phaseInfoPojo.getGreenFlashTime() - phaseInfoPojo.getYellowTime();
phaseInfoPojo.setRedTime(HexUtil.hexToInt(phaseParamList.get(8))); phaseInfoPojo.setRedTime(HexUtil.hexToInt(phaseParamList.get(8)));
phaseInfoPojo.setYellowFlashTime(HexUtil.hexToInt(phaseParamList.get(13))); phaseInfoPojo.setYellowFlashTime(HexUtil.hexToInt(phaseParamList.get(14)));
phaseInfoPojo.setMinGreenTime(HexUtil.hexToInt(phaseParamList.get(25))); phaseInfoPojo.setMinGreenTime(HexUtil.hexToInt(phaseParamList.get(25)));
phaseInfoPojo.setMaxGreenTime(HexUtil.hexToInt(phaseParamList.get(26))); phaseInfoPojo.setMaxGreenTime(HexUtil.hexToInt(phaseParamList.get(26)));
phaseInfoPojo.setMaxGreenTime2(HexUtil.hexToInt(phaseParamList.get(27))); phaseInfoPojo.setMaxGreenTime2(HexUtil.hexToInt(phaseParamList.get(27)));
...@@ -364,7 +487,7 @@ public class DTStaticInfoServiceImpl implements StaticInfoService { ...@@ -364,7 +487,7 @@ public class DTStaticInfoServiceImpl implements StaticInfoService {
if (!CollectionUtils.isEmpty(value)) { if (!CollectionUtils.isEmpty(value)) {
DailyPlanInfoPojo dailyPlanInfoPojo = new DailyPlanInfoPojo(); DailyPlanInfoPojo dailyPlanInfoPojo = new DailyPlanInfoPojo();
dailyPlanInfoPojo.setDailyPlanId(dailyPlanId); dailyPlanInfoPojo.setDailyPlanId(dailyPlanId);
dailyPlanInfoPojo.setCrossId(HexUtil.hexToInt(value.get(0))); dailyPlanInfoPojo.setControlCrossId(HexUtil.hexToInt(value.get(0)));
List<Integer> listFromHex = getListFromHex(value.get(1), 2, ""); List<Integer> listFromHex = getListFromHex(value.get(1), 2, "");
Collections.reverse(listFromHex); Collections.reverse(listFromHex);
List<String> startTimeChain = new ArrayList<>(); List<String> startTimeChain = new ArrayList<>();
...@@ -443,7 +566,7 @@ public class DTStaticInfoServiceImpl implements StaticInfoService { ...@@ -443,7 +566,7 @@ public class DTStaticInfoServiceImpl implements StaticInfoService {
if (!CollectionUtils.isEmpty(value)) { if (!CollectionUtils.isEmpty(value)) {
ScheduleInfoPojo scheduleInfoPojo = new ScheduleInfoPojo(); ScheduleInfoPojo scheduleInfoPojo = new ScheduleInfoPojo();
scheduleInfoPojo.setScheduleId(scheduleId); scheduleInfoPojo.setScheduleId(scheduleId);
scheduleInfoPojo.setCrossId(HexUtil.hexToInt(value.get(0))); scheduleInfoPojo.setControlCrossId(HexUtil.hexToInt(value.get(0)));
scheduleInfoPojo.setPriority(HexUtil.hexToInt(value.get(1))); scheduleInfoPojo.setPriority(HexUtil.hexToInt(value.get(1)));
String weekStr = Integer.toBinaryString(HexUtil.hexToInt(value.get(2))); String weekStr = Integer.toBinaryString(HexUtil.hexToInt(value.get(2)));
List<Integer> weekList = new ArrayList<>(); List<Integer> weekList = new ArrayList<>();
...@@ -482,23 +605,4 @@ public class DTStaticInfoServiceImpl implements StaticInfoService { ...@@ -482,23 +605,4 @@ public class DTStaticInfoServiceImpl implements StaticInfoService {
return filter; return filter;
} }
@Override
public SchemePhaseLightsVO buildSchemePhaseLightsResponse(SchemePhaseLightsDTO schemePhaseLightsDTO) {
return null;
}
@Override
public PlanSectionVO buildPlanSectionResponse(String crossId) {
return null;
}
@Override
public PlanSectionVO buildPlanSectionResponse(String crossId, Integer planNo) {
return null;
}
@Override
public List<CrossSchedulesPO> buildCrossSchedulesResponse(List<String> crossIdList) {
return null;
}
} }
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