From 8a2ef975eaafe0532c536d13db541bd71a2084d6 Mon Sep 17 00:00:00 2001 From: chendaofei <857448963@qq.com> Date: Tue, 21 Jan 2025 16:48:41 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gather/detection/handler/SocketDevResponseService.java | 2 +- .../gather/detection/util/socket/web/WebSocketHandler.java | 4 ++-- .../detection/util/socket/web/WebSocketInitializer.java | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/detection/src/main/java/com/njcn/gather/detection/handler/SocketDevResponseService.java b/detection/src/main/java/com/njcn/gather/detection/handler/SocketDevResponseService.java index fbc22d18..79958a7e 100644 --- a/detection/src/main/java/com/njcn/gather/detection/handler/SocketDevResponseService.java +++ b/detection/src/main/java/com/njcn/gather/detection/handler/SocketDevResponseService.java @@ -459,7 +459,7 @@ public class SocketDevResponseService { double diff = Math.abs(num1 - num2); double larger = Math.max(num1, num2); if(DicDataEnum.V.getCode().equals(type)){ - return BigDecimal.valueOf(diff / larger).setScale(4, RoundingMode.HALF_UP); + return BigDecimal.valueOf(num1 - num2).setScale(4, RoundingMode.HALF_UP); }else { return BigDecimal.valueOf(diff / larger).multiply(BigDecimal.valueOf(100)).setScale(4, RoundingMode.HALF_UP); } diff --git a/detection/src/main/java/com/njcn/gather/detection/util/socket/web/WebSocketHandler.java b/detection/src/main/java/com/njcn/gather/detection/util/socket/web/WebSocketHandler.java index 5d720081..31c0eabf 100644 --- a/detection/src/main/java/com/njcn/gather/detection/util/socket/web/WebSocketHandler.java +++ b/detection/src/main/java/com/njcn/gather/detection/util/socket/web/WebSocketHandler.java @@ -108,7 +108,7 @@ public class WebSocketHandler extends SimpleChannelInboundHandler { * 这个时候我们只需要访问 ws://127.0.0.1:7777/hello 就可以了 * 这个handler是将http协议升级为websocket 并且使用 101 作为响应码 * */ - pipeline.addLast(new IdleStateHandler(10, -1, -1, TimeUnit.SECONDS)); + pipeline.addLast(new IdleStateHandler(13, 0, 0, TimeUnit.SECONDS)); pipeline.addLast(new WebSocketHandler()); pipeline.addLast(new WebSocketServerProtocolHandler("/hello"));