Commit c10bb800 authored by duanruiming's avatar duanruiming

[update] 下发调度

parent 56b9b8e7
...@@ -15,6 +15,8 @@ public class Constants { ...@@ -15,6 +15,8 @@ public class Constants {
public static final String COMMAND_TAIL = "7d"; public static final String COMMAND_TAIL = "7d";
// 操作类型, 数据对象id替换 // 操作类型, 数据对象id替换
public static final String COMMAND_COMMON = "010001000000010001%s010105%s000000"; public static final String COMMAND_COMMON = "010001000000010001%s010105%s000000";
public static final String COMMAND_SET_COMMON = "010001000000010001%s%s0105%s";
public static final String COMMAND_CENTER_COMMON = "010001000000010001%s010105%s%s";
public static final String COMMAND_HEART_BEAT_QUERY = "01000100000001000170"; public static final String COMMAND_HEART_BEAT_QUERY = "01000100000001000170";
public static final String COMMAND_HEART_BEAT_REPLY = "80"; public static final String COMMAND_HEART_BEAT_REPLY = "80";
public static final String COMMAND_QUERY = "10"; public static final String COMMAND_QUERY = "10";
...@@ -30,6 +32,14 @@ public class Constants { ...@@ -30,6 +32,14 @@ public class Constants {
public static final String COMMAND_DEVICE_STATUS = "0d01"; public static final String COMMAND_DEVICE_STATUS = "0d01";
public static final String COMMAND_RUNNING_STATUS = "0d02"; public static final String COMMAND_RUNNING_STATUS = "0d02";
public static final String COMMAND_FAULT_LIST = "1001"; public static final String COMMAND_FAULT_LIST = "1001";
public static final String COMMAND_SET = "30";
public static final String COMMAND_SET_REPLY = "40";
public static final String COMMAND_CENTER_COMMON_SIGN = "1101";
public static final String COMMAND_CENTER_CONTROL_STAGE = "11010201";
public static final String COMMAND_CENTER_CONTROL_SCHEME = "11010301";
public static final String COMMAND_CENTER_CONTROL_MODEL = "11010401";
public static final String COMMAND_CENTER_CHANNEL_MODEL = "1201";
/** /**
* 通过发送报文内容,添加报文长度,crc校验,报文头尾 * 通过发送报文内容,添加报文长度,crc校验,报文头尾
......
...@@ -37,11 +37,11 @@ public enum CommandResultSign { ...@@ -37,11 +37,11 @@ public enum CommandResultSign {
SET_PHASE_SECURITY_INFO("3007", "setPhaseSecurityInfoService"), SET_PHASE_SECURITY_INFO("3007", "setPhaseSecurityInfoService"),
SET_SCHEME_INFO("3009", "setSchemeInfoService"), SET_SCHEME_INFO("3009", "setSchemeInfoService"),
SET_DAILY_PLAN_INFO("3011", "setDailyPlanInfoService"), SET_DAILY_PLAN_INFO("3011", "setDailyPlanInfoService"),
SET_SCHEDULES_INFO("3012", "setSchedulesInfoService"), SET_SCHEDULES_INFO("090240", "setSchedulesInfoService"),
SET_TRAFFIC_DATA_INFO("3014", "setTrafficDataInfoService"), SET_TRAFFIC_DATA_INFO("3014", "setTrafficDataInfoService"),
SET_ALARM_INFO("3015", "setAlarmInfoService"), SET_ALARM_INFO("3015", "setAlarmInfoService"),
SET_FAULT_INFO("3016", "setFaultInfoService"), SET_FAULT_INFO("3016", "setFaultInfoService"),
SET_CONTROL_INFO("4017", "setControlInfoService"); SET_CONTROL_INFO("110140", "setControlInfoService");
private String hexSign; private String hexSign;
......
...@@ -5,7 +5,6 @@ import io.swagger.annotations.ApiImplicitParam; ...@@ -5,7 +5,6 @@ import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import net.wanji.com.common.constants.Constants;
import net.wanji.com.service.controller.ControlCommandService; import net.wanji.com.service.controller.ControlCommandService;
import net.wanji.common.annotation.aspect.AspectLog; import net.wanji.common.annotation.aspect.AspectLog;
import net.wanji.common.enums.BaseEnum; import net.wanji.common.enums.BaseEnum;
...@@ -90,7 +89,7 @@ public class ControlCommandController { ...@@ -90,7 +89,7 @@ public class ControlCommandController {
@ApiOperation(value = "全红控制-路口全红控制/恢复", notes = "全红控制-路口全红控制/恢复") @ApiOperation(value = "全红控制-路口全红控制/恢复", notes = "全红控制-路口全红控制/恢复")
@PostMapping("/allRedControl") @PostMapping("/allRedControl")
public JsonViewObject allRedControl(@RequestBody @Validated ControlCommandVO commandVO) throws Exception { public JsonViewObject allRedControl(@RequestBody @Validated ControlCommandVO commandVO) throws Exception {
return controlCommandService.setSignalControl(commandVO.getCrossCode(), commandVO.getCommand(), Constants.ALL_RED_CONTROL); return controlCommandService.setSignalControl(commandVO);
} }
/** /**
...@@ -104,7 +103,7 @@ public class ControlCommandController { ...@@ -104,7 +103,7 @@ public class ControlCommandController {
@ApiOperation(value = "黄闪控制-路口黄闪控制/恢复", notes = "黄闪控制-路口黄闪控制/恢复") @ApiOperation(value = "黄闪控制-路口黄闪控制/恢复", notes = "黄闪控制-路口黄闪控制/恢复")
@PostMapping("/yellowLightControl") @PostMapping("/yellowLightControl")
public JsonViewObject yellowLightControl(@RequestBody @Validated ControlCommandVO commandVO) throws Exception { public JsonViewObject yellowLightControl(@RequestBody @Validated ControlCommandVO commandVO) throws Exception {
return controlCommandService.setSignalControl(commandVO.getCrossCode(), commandVO.getCommand(), Constants.YELLOW_LIGHT_CONTROL); return controlCommandService.setSignalControl(commandVO);
} }
/** /**
...@@ -118,7 +117,7 @@ public class ControlCommandController { ...@@ -118,7 +117,7 @@ public class ControlCommandController {
@ApiOperation(value = "关灯控制-路口关灯控制/开灯", notes = "关灯控制-路口关灯控制/开灯") @ApiOperation(value = "关灯控制-路口关灯控制/开灯", notes = "关灯控制-路口关灯控制/开灯")
@PostMapping("/closeLightControl") @PostMapping("/closeLightControl")
public JsonViewObject closeLightControl(@RequestBody @Validated ControlCommandVO commandVO) throws Exception { public JsonViewObject closeLightControl(@RequestBody @Validated ControlCommandVO commandVO) throws Exception {
return controlCommandService.setSignalControl(commandVO.getCrossCode(), commandVO.getCommand(), Constants.CLOSE_LIGHT_CONTROL); return controlCommandService.setSignalControl(commandVO);
} }
/** /**
......
package net.wanji.com.netty.commandsign; package net.wanji.com.netty.commandsign;
import net.wanji.common.utils.tool.StringUtils; import org.apache.commons.lang3.StringUtils;
/** /**
* @author duanruiming * @author duanruiming
...@@ -12,7 +12,7 @@ public class CommandResultSign { ...@@ -12,7 +12,7 @@ public class CommandResultSign {
String sign = null; String sign = null;
if (StringUtils.isNotBlank(data)) { if (StringUtils.isNotBlank(data)) {
sign = data.substring(24, 26); sign = data.substring(24, 26);
if (StringUtils.equalsIgnoreCase("80", sign)) { if (StringUtils.equals("80", sign)) {
return sign; return sign;
} }
sign = data.substring(32, 36).concat(sign); sign = data.substring(32, 36).concat(sign);
......
...@@ -12,6 +12,6 @@ import org.springframework.stereotype.Service; ...@@ -12,6 +12,6 @@ import org.springframework.stereotype.Service;
public class SetAlarmInfoService implements CommandResponseFactory { public class SetAlarmInfoService implements CommandResponseFactory {
@Override @Override
public String getCommandResponse(CommandPojo commandPojo) { public String getCommandResponse(CommandPojo commandPojo) {
return null; return commandPojo.getResponseMsg();
} }
} }
...@@ -12,6 +12,6 @@ import org.springframework.stereotype.Service; ...@@ -12,6 +12,6 @@ import org.springframework.stereotype.Service;
public class SetBaseInfoService implements CommandResponseFactory { public class SetBaseInfoService implements CommandResponseFactory {
@Override @Override
public String getCommandResponse(CommandPojo commandPojo) { public String getCommandResponse(CommandPojo commandPojo) {
return null; return commandPojo.getResponseMsg();
} }
} }
...@@ -12,6 +12,6 @@ import org.springframework.stereotype.Service; ...@@ -12,6 +12,6 @@ import org.springframework.stereotype.Service;
public class SetControlInfoService implements CommandResponseFactory { public class SetControlInfoService implements CommandResponseFactory {
@Override @Override
public String getCommandResponse(CommandPojo commandPojo) { public String getCommandResponse(CommandPojo commandPojo) {
return null; return commandPojo.getResponseMsg();
} }
} }
...@@ -12,6 +12,6 @@ import org.springframework.stereotype.Service; ...@@ -12,6 +12,6 @@ import org.springframework.stereotype.Service;
public class SetDailyPlanInfoService implements CommandResponseFactory { public class SetDailyPlanInfoService implements CommandResponseFactory {
@Override @Override
public String getCommandResponse(CommandPojo commandPojo) { public String getCommandResponse(CommandPojo commandPojo) {
return null; return commandPojo.getResponseMsg();
} }
} }
...@@ -12,6 +12,6 @@ import org.springframework.stereotype.Service; ...@@ -12,6 +12,6 @@ import org.springframework.stereotype.Service;
public class SetDetectorInfoService implements CommandResponseFactory { public class SetDetectorInfoService implements CommandResponseFactory {
@Override @Override
public String getCommandResponse(CommandPojo commandPojo) { public String getCommandResponse(CommandPojo commandPojo) {
return null; return commandPojo.getResponseMsg();
} }
} }
...@@ -12,6 +12,6 @@ import org.springframework.stereotype.Service; ...@@ -12,6 +12,6 @@ import org.springframework.stereotype.Service;
public class SetDeviceInfoService implements CommandResponseFactory { public class SetDeviceInfoService implements CommandResponseFactory {
@Override @Override
public String getCommandResponse(CommandPojo commandPojo) { public String getCommandResponse(CommandPojo commandPojo) {
return null; return commandPojo.getResponseMsg();
} }
} }
...@@ -12,6 +12,6 @@ import org.springframework.stereotype.Service; ...@@ -12,6 +12,6 @@ import org.springframework.stereotype.Service;
public class SetFaultInfoService implements CommandResponseFactory { public class SetFaultInfoService implements CommandResponseFactory {
@Override @Override
public String getCommandResponse(CommandPojo commandPojo) { public String getCommandResponse(CommandPojo commandPojo) {
return null; return commandPojo.getResponseMsg();
} }
} }
...@@ -12,6 +12,6 @@ import org.springframework.stereotype.Service; ...@@ -12,6 +12,6 @@ import org.springframework.stereotype.Service;
public class SetLightsGroupInfoService implements CommandResponseFactory { public class SetLightsGroupInfoService implements CommandResponseFactory {
@Override @Override
public String getCommandResponse(CommandPojo commandPojo) { public String getCommandResponse(CommandPojo commandPojo) {
return null; return commandPojo.getResponseMsg();
} }
} }
...@@ -12,6 +12,6 @@ import org.springframework.stereotype.Service; ...@@ -12,6 +12,6 @@ import org.springframework.stereotype.Service;
public class SetPhaseInfoService implements CommandResponseFactory { public class SetPhaseInfoService implements CommandResponseFactory {
@Override @Override
public String getCommandResponse(CommandPojo commandPojo) { public String getCommandResponse(CommandPojo commandPojo) {
return null; return commandPojo.getResponseMsg();
} }
} }
...@@ -12,6 +12,6 @@ import org.springframework.stereotype.Service; ...@@ -12,6 +12,6 @@ import org.springframework.stereotype.Service;
public class SetPhaseSecurityInfoService implements CommandResponseFactory { public class SetPhaseSecurityInfoService implements CommandResponseFactory {
@Override @Override
public String getCommandResponse(CommandPojo commandPojo) { public String getCommandResponse(CommandPojo commandPojo) {
return null; return commandPojo.getResponseMsg();
} }
} }
...@@ -12,6 +12,6 @@ import org.springframework.stereotype.Service; ...@@ -12,6 +12,6 @@ import org.springframework.stereotype.Service;
public class SetSchedulesInfoService implements CommandResponseFactory { public class SetSchedulesInfoService implements CommandResponseFactory {
@Override @Override
public String getCommandResponse(CommandPojo commandPojo) { public String getCommandResponse(CommandPojo commandPojo) {
return null; return commandPojo.getResponseMsg();
} }
} }
...@@ -12,6 +12,6 @@ import org.springframework.stereotype.Service; ...@@ -12,6 +12,6 @@ import org.springframework.stereotype.Service;
public class SetSchemeInfoService implements CommandResponseFactory { public class SetSchemeInfoService implements CommandResponseFactory {
@Override @Override
public String getCommandResponse(CommandPojo commandPojo) { public String getCommandResponse(CommandPojo commandPojo) {
return null; return commandPojo.getResponseMsg();
} }
} }
...@@ -12,6 +12,6 @@ import org.springframework.stereotype.Service; ...@@ -12,6 +12,6 @@ import org.springframework.stereotype.Service;
public class SetStageInfoService implements CommandResponseFactory { public class SetStageInfoService implements CommandResponseFactory {
@Override @Override
public String getCommandResponse(CommandPojo commandPojo) { public String getCommandResponse(CommandPojo commandPojo) {
return null; return commandPojo.getResponseMsg();
} }
} }
...@@ -12,6 +12,6 @@ import org.springframework.stereotype.Service; ...@@ -12,6 +12,6 @@ import org.springframework.stereotype.Service;
public class SetTrafficDataInfoService implements CommandResponseFactory { public class SetTrafficDataInfoService implements CommandResponseFactory {
@Override @Override
public String getCommandResponse(CommandPojo commandPojo) { public String getCommandResponse(CommandPojo commandPojo) {
return null; return commandPojo.getResponseMsg();
} }
} }
...@@ -53,13 +53,11 @@ public interface ControlCommandService extends BeanMarkService{ ...@@ -53,13 +53,11 @@ public interface ControlCommandService extends BeanMarkService{
/** /**
* 设置信号机控制模式 * 设置信号机控制模式
* *
* @param code 信号机编号 * @param commandVO 信号机编号
* @param command 指令 1 开 0 关
* @param commandType 命令类型
* @return * @return
* @throws Exception 异常 * @throws Exception 异常
*/ */
JsonViewObject setSignalControl(String code, Integer command, Integer commandType) throws Exception; JsonViewObject setSignalControl(ControlCommandVO commandVO) throws Exception;
/** /**
* 恢复时间表 * 恢复时间表
......
package net.wanji.com.service.controller.impl; package net.wanji.com.service.controller.impl;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import net.wanji.com.cache.CrossInfoCache;
import net.wanji.com.common.constants.Constants;
import net.wanji.com.common.enums.ControlModelEnum;
import net.wanji.com.netty.NettyClient; import net.wanji.com.netty.NettyClient;
import net.wanji.com.pojo.netty.MessageResultPojo; import net.wanji.com.pojo.netty.MessageResultPojo;
import net.wanji.com.service.controller.ControlCommandService; import net.wanji.com.service.controller.ControlCommandService;
import net.wanji.com.util.CommonUtils;
import net.wanji.common.enums.BaseEnum; import net.wanji.common.enums.BaseEnum;
import net.wanji.common.framework.rest.JsonViewObject; import net.wanji.common.framework.rest.JsonViewObject;
import net.wanji.databus.po.CrossInfoPO;
import net.wanji.databus.vo.*; import net.wanji.databus.vo.*;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.util.Comparator;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
/** /**
* @author duanruiming * @author duanruiming
* @date 2023/05/08 10:43 * @date 2023/05/08 10:43
*/ */
@Service @Service
@RequiredArgsConstructor
@Slf4j
public class DTControlCommandServiceImpl implements ControlCommandService { public class DTControlCommandServiceImpl implements ControlCommandService {
private final CrossInfoCache crossInfoCache;
@Override @Override
public String getBeanMark() { public String getBeanMark() {
return BaseEnum.VendorTypeEnum.DT.getNick(); return BaseEnum.VendorTypeEnum.DT.getNick();
...@@ -34,12 +52,106 @@ public class DTControlCommandServiceImpl implements ControlCommandService { ...@@ -34,12 +52,106 @@ public class DTControlCommandServiceImpl implements ControlCommandService {
@Override @Override
public JsonViewObject scheduleSend(ScheduleSendVO scheduleSendVO) throws Exception { public JsonViewObject scheduleSend(ScheduleSendVO scheduleSendVO) throws Exception {
return null; String crossId = scheduleSendVO.getCrossCode();
CrossInfoPO crossInfoPO = crossInfoCache.getCrossInfoCache().get(crossId);
List<ScheduleSendVO.Schedule> schedules = scheduleSendVO.getSchedules();
StringBuilder sb = new StringBuilder();
for (ScheduleSendVO.Schedule schedule : schedules) {
sb.append(buildScheduleHex(schedule));
}
String bodyValueLeght = String.format("%02x", schedules.size() * 6); // 调度数量 * 属性数量
String message = String.format(Constants.COMMAND_SET_COMMON, Constants.COMMAND_SET, bodyValueLeght, sb.toString());
String scheduleSign = StringUtils.join(Constants.COMMAND_SCHEDULE_CONFIG, Constants.COMMAND_SET_REPLY);
String scheduleMessage = Constants.buildMessage(message);
MessageResultPojo resultPojo = NettyClient.sendMessage(crossInfoPO.getIp(), crossInfoPO.getPort(), scheduleMessage, scheduleSign, 300);
if (Objects.nonNull(resultPojo) && StringUtils.isNotBlank(resultPojo.getHexMessageResult())) {
return JsonViewObject.newInstance().success("下发调度成功");
}
return JsonViewObject.newInstance().success("下发调度异常");
}
private String buildScheduleHex(ScheduleSendVO.Schedule schedule) {
String scheduleNo = schedule.getScheduleNo();
Integer planNo = 0;
String weekHex = "00";
List<ScheduleSendVO.Schedule.Week> weeks = schedule.getWeeks();
if (!CollectionUtils.isEmpty(weeks)) {
List<ScheduleSendVO.Schedule.Week> weekSort = weeks.stream().sorted(Comparator.comparingInt(ScheduleSendVO.Schedule.Week::getWeekNum)).collect(Collectors.toList());
int[] weekArray = new int[7];
for (ScheduleSendVO.Schedule.Week week : weekSort) {
Integer weekNum = week.getWeekNum();
weekArray[weekNum - 1] = 1;
planNo = week.getPlanNo();
}
weekHex = CommonUtils.getHex4Array(weekArray);
}
String monthHex = "0000";
String dayHex = "00000000";
List<ScheduleSendVO.Schedule.SpecialDay> specialDays = schedule.getSpecialDays();
if (!CollectionUtils.isEmpty(specialDays)) {
int[] monthArray = new int[12];
int[] dayArray = new int[31];
for (ScheduleSendVO.Schedule.SpecialDay specialDay : specialDays) {
String dateStr = specialDay.getDateStr();
monthArray[Integer.valueOf(dateStr.substring(5, 7)) - 1] = 1;
dayArray[Integer.valueOf(dateStr.substring(8, 10)) - 1] = 1;
}
monthHex = CommonUtils.getHex4Array(monthArray);
dayHex = CommonUtils.getHex4Array(dayArray);
}
String matchStr = "0c02%s%s";
StringBuffer sb = new StringBuffer();
for (int i = 2; i < 8; i++) { // 数据对象从2-7
sb.append(String.format(matchStr, String.format("%02x", i), String.format("%02x", Integer.valueOf(scheduleNo))));
if (i == 2) {
sb.append("01");// 一代多路口编号
sb.append(String.format("%02x", i)).append("05");
}
if (i == 3) {
sb.append("00"); // 优先级
sb.append(String.format("%02x", i)).append("05");
}
if (i == 4) {
sb.append(weekHex); // 星期二进制转16
sb.append(String.format("%02x", i)).append("06");
}
if (i == 5) {
sb.append(StringUtils.leftPad(monthHex, 4, "0"));
sb.append(String.format("%02x", i)).append("08");
}
if (i == 6) {
sb.append(StringUtils.leftPad(dayHex, 8, "0"));
sb.append(String.format("%02x", i)).append("05");
}
if (i == 7) {
sb.append(String.format("%02x", planNo));
sb.append(String.format("%02x", i)).append("05");
}
}
return sb.toString().substring(0, sb.length() - 4);
} }
@Override @Override
public JsonViewObject lockControl(ControlCommandVO commandVO) throws Exception { public JsonViewObject lockControl(ControlCommandVO commandVO) throws Exception {
return null; if (commandVO.getCommand() == 0) {
setSignalControl(commandVO);
} else {
List<Integer> phaseList = commandVO.getPhaseList();
int stageId = 0;
if (!CollectionUtils.isEmpty(phaseList)) {
stageId = phaseList.get(0);
} // 锁定阶段,目前锁定成功,但是阶段还在跳
CrossInfoPO crossInfoPO = crossInfoCache.getCrossInfoCache().get(commandVO.getCrossCode());
String message = String.format(Constants.COMMAND_CENTER_COMMON, Constants.COMMAND_SET, Constants.COMMAND_CENTER_CONTROL_STAGE, String.format("%02x", stageId));
String lockSign = StringUtils.join(Constants.COMMAND_CENTER_COMMON_SIGN, Constants.COMMAND_SET_REPLY);
String lockMessage = Constants.buildMessage(message);
MessageResultPojo resultPojo = NettyClient.sendMessage(crossInfoPO.getIp(), crossInfoPO.getPort(), lockMessage, lockSign, 300);
if (Objects.nonNull(resultPojo) && StringUtils.isNotBlank(resultPojo.getHexMessageResult())) {
log.info("锁定相位成功");
}
}
return JsonViewObject.newInstance().success("锁定相位成功");
} }
@Override @Override
...@@ -48,13 +160,43 @@ public class DTControlCommandServiceImpl implements ControlCommandService { ...@@ -48,13 +160,43 @@ public class DTControlCommandServiceImpl implements ControlCommandService {
} }
@Override @Override
public JsonViewObject setSignalControl(String code, Integer command, Integer commandType) throws Exception { public JsonViewObject setSignalControl(ControlCommandVO commandVO) throws Exception {
return null; String controlmodel = null;
if (commandVO.getCommand() == 0) {
controlmodel = ControlModelEnum.FIXED_CYCLE.getDtControlHex(); // 取消控制,设置为固定配时
} else {
if (commandVO.getControlType() == 1) { // 全红
controlmodel = ControlModelEnum.RED_CONTROL.getDtControlHex();
}
if (commandVO.getControlType() == 2) { // 黄闪
controlmodel = ControlModelEnum.YELLOW_CONTROL.getDtControlHex();
}
if (commandVO.getControlType() == 3) { // 关灯
controlmodel = ControlModelEnum.CLOSED_CONTROL.getDtControlHex();
}
}
CrossInfoPO crossInfoPO = crossInfoCache.getCrossInfoCache().get(commandVO.getCrossCode());
String message = String.format(Constants.COMMAND_CENTER_COMMON, Constants.COMMAND_SET, Constants.COMMAND_CENTER_CONTROL_MODEL, controlmodel);
String controlSign = StringUtils.join(Constants.COMMAND_CENTER_COMMON_SIGN, Constants.COMMAND_SET_REPLY);
String controlMessageHex = Constants.buildMessage(message);
MessageResultPojo resultPojo = NettyClient.sendMessage(crossInfoPO.getIp(), crossInfoPO.getPort(), controlMessageHex, controlSign, 300);
if (Objects.nonNull(resultPojo) && StringUtils.isNotBlank(resultPojo.getHexMessageResult())) {
log.info("特殊控制成功,当前控制模式: {}", controlmodel);
}
return JsonViewObject.newInstance().success("特殊控制成功");
} }
@Override @Override
public JsonViewObject recoverSchedule(String code) throws Exception { public JsonViewObject recoverSchedule(String code) throws Exception {
return null; CrossInfoPO crossInfoPO = crossInfoCache.getCrossInfoCache().get(code);
String message = String.format(Constants.COMMAND_CENTER_COMMON, Constants.COMMAND_SET, Constants.COMMAND_CENTER_CONTROL_MODEL, ControlModelEnum.FIXED_CYCLE.getDtControlHex());
String controlSign = StringUtils.join(Constants.COMMAND_CENTER_COMMON_SIGN, Constants.COMMAND_SET_REPLY);
String controlMessageHex = Constants.buildMessage(message);
MessageResultPojo resultPojo = NettyClient.sendMessage(crossInfoPO.getIp(), crossInfoPO.getPort(), controlMessageHex, controlSign, 300);
if (Objects.nonNull(resultPojo) && StringUtils.isNotBlank(resultPojo.getHexMessageResult())) {
log.info("恢复时间表");
}
return JsonViewObject.newInstance().success("恢复时间表");
} }
@Override @Override
......
package net.wanji.com.util;
import cn.hutool.core.util.HexUtil;
/**
* @author duanruiming
* @date 2023/06/20 15:07
*/
public class CommonUtils {
public static String getHex4Array(int[] array) {
StringBuilder sb = new StringBuilder();
for (int i : array) {
sb.append(i);
}
Integer binary = Integer.valueOf(sb.reverse().toString(), 2);
return HexUtil.toHex(binary);
}
}
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