Commit eeb9d45d authored by duanruiming's avatar duanruiming

[update] 代码优化

parent 9c528862
......@@ -11,7 +11,8 @@ import java.util.Objects;
*/
@Getter
public enum CommandResultSignEnum {
GET_RUNNING_STATE_INFO(RunningLightsStatusPojo.class, "getRunningStateInfoService");
GET_RUNNING_STATE_INFO(RunningLightsStatusPojo.class, "getRunningStateInfoService"),
GET_RUNNING_SCHEME_NO(RunningLightsStatusPojo.class, "getSchemeNoService");
private final Object resultPojo;
private final String className;
......
......@@ -65,19 +65,16 @@ public class TcpClient {
}
//public static void sendMessage(String ip, Integer port, String msg) {
// byte[] bytes = HexUtil.decodeHex(msg);
// try {
// if (channelFutureMap.isEmpty()) {
// return;
// }
// tcpChannelFuture.channel()
// .writeAndFlush(new DatagramPacket(Unpooled.copiedBuffer(bytes), new InetSocketAddress(ip, port))).sync();
// log.debug("发送信号机:{}/{}命令消息:{}", ip, port, msg);
// } catch (InterruptedException e) {
// log.error("sendMsg is error", e);
// }
//}
public static void sendMessage(Object msg) {
try {
ChannelFuture sync = tcpChannelFuture.channel().writeAndFlush(msg).sync();
if (sync.isSuccess()) {
log.debug("发送信号机命令消息:{}", msg);
}
} catch (Exception e) {
log.error("sendMsg is error", e);
}
}
//public static MessageResultPojo sendMessage(String ip, Integer port, String msg, String command, int timeout) {
// try {
......
......@@ -107,7 +107,7 @@ public class TcpClientHandler extends SimpleChannelInboundHandler<DatagramPacket
commandPojo.setSignalId(crossInfo.getCode());
commandPojo.setSignalIp(crossInfo.getIp());
commandPojo.setPort(crossInfo.getPort());
commandPojo.setResponseMsg(data);
commandPojo.setMsg(data);
return commandPojo;
}
......
......@@ -83,7 +83,7 @@ public class UdpClientHandler extends SimpleChannelInboundHandler<DatagramPacket
commandPojo.setSignalId(crossInfo.getCode());
commandPojo.setSignalIp(crossInfo.getIp());
commandPojo.setPort(crossInfo.getPort());
commandPojo.setResponseMsg(data);
commandPojo.setMsg(data);
return commandPojo;
}
......
......@@ -12,5 +12,5 @@ public class CommandPojo {
private String signalId;
private String signalIp;
private Integer port;
private Object responseMsg;
private Object msg;
}
package net.wanji.utc.hisense.netty.request;
import net.wanji.utc.hisense.netty.pojo.CommandPojo;
/**
* @author duanruiming
* @date 2024/11/02 20:15
*/
public interface CommandRequestFactory {
/**
* 发送海信请求
*/
void sendCommandRequest(CommandPojo commandPojo);
}
......@@ -7,5 +7,6 @@ import net.wanji.utc.hisense.netty.pojo.CommandPojo;
* @date 2023/05/10 10:07
*/
public interface CommandResponseFactory {
Object getCommandResponse(CommandPojo commandPojo);
}
......@@ -17,7 +17,7 @@ public class HeartBeatService implements CommandResponseFactory {
@Override
public Object getCommandResponse(CommandPojo commandPojo) {
return commandPojo.getResponseMsg();
return commandPojo.getMsg();
}
}
......@@ -12,6 +12,6 @@ import org.springframework.stereotype.Service;
public class GetAlarmInfoService implements CommandResponseFactory {
@Override
public Object getCommandResponse(CommandPojo commandPojo) {
return commandPojo.getResponseMsg();
return commandPojo.getMsg();
}
}
......@@ -12,6 +12,6 @@ import org.springframework.stereotype.Service;
public class GetBaseInfoService implements CommandResponseFactory {
@Override
public Object getCommandResponse(CommandPojo commandPojo) {
return commandPojo.getResponseMsg();
return commandPojo.getMsg();
}
}
......@@ -12,6 +12,6 @@ import org.springframework.stereotype.Service;
public class GetDailyPlanInfoService implements CommandResponseFactory {
@Override
public Object getCommandResponse(CommandPojo commandPojo) {
return commandPojo.getResponseMsg();
return commandPojo.getMsg();
}
}
......@@ -12,6 +12,6 @@ import org.springframework.stereotype.Service;
public class GetDetectorInfoService implements CommandResponseFactory {
@Override
public Object getCommandResponse(CommandPojo commandPojo) {
return commandPojo.getResponseMsg();
return commandPojo.getMsg();
}
}
......@@ -13,6 +13,6 @@ import org.springframework.stereotype.Service;
public class GetDeviceInfoService implements CommandResponseFactory {
@Override
public Object getCommandResponse(CommandPojo commandPojo) {
return commandPojo.getResponseMsg();
return commandPojo.getMsg();
}
}
......@@ -12,6 +12,6 @@ import org.springframework.stereotype.Service;
public class GetFaultInfoService implements CommandResponseFactory {
@Override
public Object getCommandResponse(CommandPojo commandPojo) {
return commandPojo.getResponseMsg();
return commandPojo.getMsg();
}
}
......@@ -12,6 +12,6 @@ import org.springframework.stereotype.Service;
public class GetLightsGroupInfoService implements CommandResponseFactory {
@Override
public Object getCommandResponse(CommandPojo commandPojo) {
return commandPojo.getResponseMsg();
return commandPojo.getMsg();
}
}
......@@ -12,6 +12,6 @@ import org.springframework.stereotype.Service;
public class GetLightsStatusInfoService implements CommandResponseFactory {
@Override
public Object getCommandResponse(CommandPojo commandPojo) {
return commandPojo.getResponseMsg();
return commandPojo.getMsg();
}
}
......@@ -12,6 +12,6 @@ import org.springframework.stereotype.Service;
public class GetPhaseInfoService implements CommandResponseFactory {
@Override
public Object getCommandResponse(CommandPojo commandPojo) {
return commandPojo.getResponseMsg();
return commandPojo.getMsg();
}
}
......@@ -12,6 +12,6 @@ import org.springframework.stereotype.Service;
public class GetPhaseSecurityInfoService implements CommandResponseFactory {
@Override
public Object getCommandResponse(CommandPojo commandPojo) {
return commandPojo.getResponseMsg();
return commandPojo.getMsg();
}
}
......@@ -16,7 +16,7 @@ import org.springframework.stereotype.Service;
public class GetRunningStateInfoService implements CommandResponseFactory {
@Override
public Object getCommandResponse(CommandPojo commandPojo) {
SignalDataCache.runningStateInfoCacheUdp.put(commandPojo.getCrossId(), (RunningLightsStatusPojo) commandPojo.getResponseMsg());
SignalDataCache.runningStateInfoCacheUdp.put(commandPojo.getCrossId(), (RunningLightsStatusPojo) commandPojo.getMsg());
return commandPojo;
}
......
......@@ -12,6 +12,6 @@ import org.springframework.stereotype.Service;
public class GetSchedulesInfoService implements CommandResponseFactory {
@Override
public Object getCommandResponse(CommandPojo commandPojo) {
return commandPojo.getResponseMsg();
return commandPojo.getMsg();
}
}
......@@ -12,6 +12,6 @@ import org.springframework.stereotype.Service;
public class GetSchemeInfoService implements CommandResponseFactory {
@Override
public Object getCommandResponse(CommandPojo commandPojo) {
return commandPojo.getResponseMsg();
return commandPojo.getMsg();
}
}
package net.wanji.utc.hisense.netty.response.impl.get;
import net.wanji.utc.hisense.netty.TcpClient;
import net.wanji.utc.hisense.netty.pojo.CommandPojo;
import net.wanji.utc.hisense.netty.request.CommandRequestFactory;
import net.wanji.utc.hisense.netty.response.CommandResponseFactory;
import net.wanji.utc.hisense.pojo.xml.pojo.messagecontent.get.GetSchemeNoRequest;
import org.springframework.stereotype.Service;
/**
* @author duanruiming
* @date 2024/11/02 19:51
* @description 获取海信当前运行方案号,对应【协调状态】
*/
@Service
public class GetSchemeNoService implements CommandResponseFactory, CommandRequestFactory {
@Override
public void sendCommandRequest(CommandPojo commandPojo) {
GetSchemeNoRequest request = new GetSchemeNoRequest();
GetSchemeNoRequest.Content content = new GetSchemeNoRequest.Content();
content.setSpot(String.valueOf(commandPojo.getMsg()));
request.setMessageContent(content);
TcpClient.sendMessage(request);
}
@Override
public Object getCommandResponse(CommandPojo commandPojo) {
return commandPojo.getMsg();
}
}
\ No newline at end of file
......@@ -12,6 +12,6 @@ import org.springframework.stereotype.Service;
public class GetStageInfoService implements CommandResponseFactory {
@Override
public Object getCommandResponse(CommandPojo commandPojo) {
return commandPojo.getResponseMsg();
return commandPojo.getMsg();
}
}
......@@ -12,6 +12,6 @@ import org.springframework.stereotype.Service;
public class GetStageStatusService implements CommandResponseFactory {
@Override
public Object getCommandResponse(CommandPojo commandPojo) {
return commandPojo.getResponseMsg();
return commandPojo.getMsg();
}
}
......@@ -12,6 +12,6 @@ import org.springframework.stereotype.Service;
public class GetTrafficDataInfoService implements CommandResponseFactory {
@Override
public Object getCommandResponse(CommandPojo commandPojo) {
return commandPojo.getResponseMsg();
return commandPojo.getMsg();
}
}
......@@ -12,6 +12,6 @@ import org.springframework.stereotype.Service;
public class SetAlarmInfoService implements CommandResponseFactory {
@Override
public Object getCommandResponse(CommandPojo commandPojo) {
return commandPojo.getResponseMsg();
return commandPojo.getMsg();
}
}
......@@ -12,6 +12,6 @@ import org.springframework.stereotype.Service;
public class SetBaseInfoService implements CommandResponseFactory {
@Override
public Object getCommandResponse(CommandPojo commandPojo) {
return commandPojo.getResponseMsg();
return commandPojo.getMsg();
}
}
......@@ -12,6 +12,6 @@ import org.springframework.stereotype.Service;
public class SetControlInfoService implements CommandResponseFactory {
@Override
public Object getCommandResponse(CommandPojo commandPojo) {
return commandPojo.getResponseMsg();
return commandPojo.getMsg();
}
}
......@@ -12,6 +12,6 @@ import org.springframework.stereotype.Service;
public class SetDailyPlanInfoService implements CommandResponseFactory {
@Override
public Object getCommandResponse(CommandPojo commandPojo) {
return commandPojo.getResponseMsg();
return commandPojo.getMsg();
}
}
......@@ -12,6 +12,6 @@ import org.springframework.stereotype.Service;
public class SetDetectorInfoService implements CommandResponseFactory {
@Override
public Object getCommandResponse(CommandPojo commandPojo) {
return commandPojo.getResponseMsg();
return commandPojo.getMsg();
}
}
......@@ -12,6 +12,6 @@ import org.springframework.stereotype.Service;
public class SetDeviceInfoService implements CommandResponseFactory {
@Override
public Object getCommandResponse(CommandPojo commandPojo) {
return commandPojo.getResponseMsg();
return commandPojo.getMsg();
}
}
......@@ -12,6 +12,6 @@ import org.springframework.stereotype.Service;
public class SetFaultInfoService implements CommandResponseFactory {
@Override
public Object getCommandResponse(CommandPojo commandPojo) {
return commandPojo.getResponseMsg();
return commandPojo.getMsg();
}
}
......@@ -12,6 +12,6 @@ import org.springframework.stereotype.Service;
public class SetLightsGroupInfoService implements CommandResponseFactory {
@Override
public Object getCommandResponse(CommandPojo commandPojo) {
return commandPojo.getResponseMsg();
return commandPojo.getMsg();
}
}
......@@ -12,6 +12,6 @@ import org.springframework.stereotype.Service;
public class SetPhaseInfoService implements CommandResponseFactory {
@Override
public Object getCommandResponse(CommandPojo commandPojo) {
return commandPojo.getResponseMsg();
return commandPojo.getMsg();
}
}
......@@ -12,6 +12,6 @@ import org.springframework.stereotype.Service;
public class SetPhaseSecurityInfoService implements CommandResponseFactory {
@Override
public Object getCommandResponse(CommandPojo commandPojo) {
return commandPojo.getResponseMsg();
return commandPojo.getMsg();
}
}
......@@ -12,6 +12,6 @@ import org.springframework.stereotype.Service;
public class SetSchedulesInfoService implements CommandResponseFactory {
@Override
public Object getCommandResponse(CommandPojo commandPojo) {
return commandPojo.getResponseMsg();
return commandPojo.getMsg();
}
}
......@@ -12,6 +12,6 @@ import org.springframework.stereotype.Service;
public class SetSchemeInfoService implements CommandResponseFactory {
@Override
public Object getCommandResponse(CommandPojo commandPojo) {
return commandPojo.getResponseMsg();
return commandPojo.getMsg();
}
}
......@@ -12,6 +12,6 @@ import org.springframework.stereotype.Service;
public class SetStageInfoService implements CommandResponseFactory {
@Override
public Object getCommandResponse(CommandPojo commandPojo) {
return commandPojo.getResponseMsg();
return commandPojo.getMsg();
}
}
......@@ -12,6 +12,6 @@ import org.springframework.stereotype.Service;
public class SetTrafficDataInfoService implements CommandResponseFactory {
@Override
public Object getCommandResponse(CommandPojo commandPojo) {
return commandPojo.getResponseMsg();
return commandPojo.getMsg();
}
}
......@@ -12,6 +12,7 @@ import java.io.Serializable;
* @author duanruiming
* @date 2024/01/08 10:03
*/
@SuppressWarnings("SpellCheckingInspection")
@Data
@XmlAccessorType(XmlAccessType.FIELD)
@XmlRootElement(name = "systemScription")
......
......@@ -16,11 +16,11 @@ import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement(name = "systemScription")
public class LogOnRequest extends SystemScriptionRequest {
private LogOnContent messageContent;
private Content messageContent;
@Data
@XmlAccessorType(XmlAccessType.FIELD)
public static class LogOnContent {
public static class Content {
private String user;
private String password;
}
......
package net.wanji.utc.hisense.pojo.xml.pojo.messagecontent;
import lombok.Data;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
/**
* @author duanruiming
* @date 2024/10/29 17:22
*/
@Data
@XmlAccessorType(XmlAccessType.FIELD)
@XmlRootElement(name = "systemScription")
public class StepControlMultiPhaseRequest {
private Content messageContent;
@Data
@XmlAccessorType(XmlAccessType.FIELD)
public static class Content {
private String spot;
/** 相位数量 */
private int count;
/** 相位号 */
private String holdPhase;
private String holdPhase1;
private String holdPhase2;
private String holdPhase3;
private String holdPhase4;
private String holdPhase5;
}
}
package net.wanji.utc.hisense.pojo.xml.pojo.messagecontent;
import lombok.Data;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
/**
* @author duanruiming
* @date 2024/10/29 16:56
*/
@Data
@XmlAccessorType(XmlAccessType.FIELD)
@XmlRootElement(name = "systemScription")
public class StepControlRequest {
private Content messageContent;
@Data
@XmlAccessorType(XmlAccessType.FIELD)
public static class Content {
private String spot;
/** 1-开始步进 0-取消 */
private String command;
/** 0 顺序步进,仅支持顺序 */
private String ctrlStep;
}
}
package net.wanji.utc.hisense.pojo.xml.pojo.messagecontent.get;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import net.wanji.utc.hisense.pojo.xml.pojo.SystemScriptionRequest;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
/**
* @author duanruiming
* @date 2024/11/02 20:00
* @description 获取海信方案号请求实体,
*/
@Data
@XmlAccessorType(XmlAccessType.FIELD)
@XmlRootElement(name = "systemScription")
@AllArgsConstructor
@NoArgsConstructor
public class GetSchemeNoRequest extends SystemScriptionRequest {
private Content messageContent;
@Data
@XmlAccessorType(XmlAccessType.FIELD)
@AllArgsConstructor
@NoArgsConstructor
public static class Content {
private String spot;
}
}
......@@ -61,7 +61,7 @@ public class XMLUtils {
System.err.println("================");
LogOnRequest logOnMessageContent = new LogOnRequest();
LogOnRequest.LogOnContent body = new LogOnRequest.LogOnContent();
LogOnRequest.Content body = new LogOnRequest.Content();
body.setUser("user");
body.setPassword("123456");
logOnMessageContent.setMessageContent(body);
......
spring:
application:
# dubbo启动需要程序名称
name: utc-hisense
main:
allow-circular-references: true
cloud:
nacos:
config:
server-addr: 173.17.0.1:8848
file-extension: yaml
group: signal
namespace: signal
username: nacos
password: nacos
\ No newline at end of file
#spring:
# cloud:
# nacos:
# config:
# server-addr: 10.102.1.182:8848
# file-extension: yaml
# group: signal
# namespace: signal
# username: nacos
# password: nacos
# application:
# # dubbo启动需要程序名称
# name: utc-hisense
# main:
# allow-circular-references: true
\ No newline at end of file
spring:
profiles:
active: dev
\ No newline at end of file
active: docker
\ No newline at end of file
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