This commit is contained in:
caozehui
2024-12-23 14:42:27 +08:00
parent 8f0b923744
commit 5f694c88bf
4 changed files with 40 additions and 45 deletions

View File

@@ -41,39 +41,39 @@ public class WebSocketService {
@PostConstruct
public void start() {
new Thread(() -> {
//可以自定义线程的数量
bossGroup = new NioEventLoopGroup();
// 默认创建的线程数量 = CPU 处理器数量 *2
workerGroup = new NioEventLoopGroup();
try {
ServerBootstrap serverBootstrap = new ServerBootstrap();
serverBootstrap.group(bossGroup, workerGroup)
.channel(NioServerSocketChannel.class)
.handler(new LoggingHandler())
//当前连接被阻塞的时候BACKLOG代表的事 阻塞队列的长度
.option(ChannelOption.SO_BACKLOG, 128)
.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, 5000)
//设置连接保持为活动状态
.childOption(ChannelOption.SO_KEEPALIVE, true)
.childHandler(webSocketInitializer);
ChannelFuture future = serverBootstrap.bind(port).sync();
future.addListener(f -> {
if (future.isSuccess()) {
System.out.println("webSocket服务启动成功");
} else {
System.out.println("webSocket服务启动失败");
}
});
future.channel().closeFuture().sync();
} catch (InterruptedException e) {
e.printStackTrace();
} finally {
bossGroup.shutdownGracefully();
workerGroup.shutdownGracefully();
}
}).start();
// new Thread(() -> {
// //可以自定义线程的数量
// bossGroup = new NioEventLoopGroup();
// // 默认创建的线程数量 = CPU 处理器数量 *2
// workerGroup = new NioEventLoopGroup();
// try {
// ServerBootstrap serverBootstrap = new ServerBootstrap();
// serverBootstrap.group(bossGroup, workerGroup)
// .channel(NioServerSocketChannel.class)
// .handler(new LoggingHandler())
// //当前连接被阻塞的时候BACKLOG代表的事 阻塞队列的长度
// .option(ChannelOption.SO_BACKLOG, 128)
// .option(ChannelOption.CONNECT_TIMEOUT_MILLIS, 5000)
//
// //设置连接保持为活动状态
// .childOption(ChannelOption.SO_KEEPALIVE, true)
// .childHandler(webSocketInitializer);
// ChannelFuture future = serverBootstrap.bind(port).sync();
// future.addListener(f -> {
// if (future.isSuccess()) {
// System.out.println("webSocket服务启动成功");
// } else {
// System.out.println("webSocket服务启动失败");
// }
// });
// future.channel().closeFuture().sync();
// } catch (InterruptedException e) {
// e.printStackTrace();
// } finally {
// bossGroup.shutdownGracefully();
// workerGroup.shutdownGracefully();
// }
// }).start();
}

View File

@@ -22,19 +22,15 @@ public class PqErrSysDtlsParam {
private String type;
@ApiModelProperty(value = "误差判断起始值", required = true)
@NotNull(message = DevValidMessage.START_VALUE_NOT_NULL)
private Float startValue;
@ApiModelProperty(value = "是否包含起始值", required = true)
@NotNull(message = DevValidMessage.START_FLAG_NOT_NULL)
private Integer startFlag;
@ApiModelProperty(value = "误差判断结束值", required = true)
@NotNull(message = DevValidMessage.END_VALUE_NOT_NULL)
private Float endValue;
@ApiModelProperty(value = "是否包含结束值", required = true)
@NotNull(message = DevValidMessage.END_FLAG_NOT_NULL)
private Integer endFlag;
// @ApiModelProperty(value = "单位", required = true)
@@ -43,17 +39,14 @@ public class PqErrSysDtlsParam {
// private String unit;
@ApiModelProperty(value = "判断条件值类型", required = true)
@NotBlank(message = DevValidMessage.CONDITION_TYPE_NOT_BLANK)
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DevValidMessage.ERROR_VALUE_FORMAT_ERROR)
private String conditionType;
private Integer conditionType;
@ApiModelProperty(value = "最大值误差", required = true)
@NotNull(message = DevValidMessage.MAX_ERROR_VALUE_NOT_NULL)
private Float maxErrorValue;
@ApiModelProperty(value = "误差值类型", required = true)
@NotBlank(message = DevValidMessage.ERROR_VALUE_TYPE_NOT_BLANK)
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DevValidMessage.ERROR_VALUE_FORMAT_ERROR)
private String errorValueType;
@NotNull(message = DevValidMessage.ERROR_VALUE_TYPE_NOT_BLANK)
private Integer errorValueType;
}

View File

@@ -56,7 +56,7 @@ public class PqErrSysDtls implements Serializable {
/**
* 判断条件值类型(包括值类型,绝对值、相对值)
*/
private String conditionType;
private Integer conditionType;
/**
* 误差最大值
@@ -66,7 +66,7 @@ public class PqErrSysDtls implements Serializable {
/**
* 误差值类型
*/
private String errorValueType;
private Integer errorValueType;
}

View File

@@ -199,4 +199,6 @@ public interface DevValidMessage {
String TIMECHECK_NOT_BLANK = "是否做守时检测不能为空";
String FACTOR_FLAG_NOT_BLANK = "是否支持系数校准不能为空";
String CONDITION_TYPE_FORMAT_ERROR = "判断条件类型格式错误请检查conditionType参数";
}