Browse Source

请求热成像改成15秒

logistics
zy_Java 4 years ago
parent
commit
cec34fc2d4
  1. 2
      logistics/src/main/java/com/ccsens/logistics/Netty/NettyClient.java
  2. 6
      logistics/src/main/java/com/ccsens/logistics/Netty/SimpleClientHandler.java
  3. 6
      util/src/test/java/com/ccsens/util/OtherTest.java

2
logistics/src/main/java/com/ccsens/logistics/Netty/NettyClient.java

@ -72,7 +72,7 @@ public class NettyClient {
ScheduledExecutorService service = Executors ScheduledExecutorService service = Executors
.newSingleThreadScheduledExecutor(); .newSingleThreadScheduledExecutor();
// 第二个参数为首次执行的延时时间,第三个参数为定时执行的间隔时间 // 第二个参数为首次执行的延时时间,第三个参数为定时执行的间隔时间
service.scheduleAtFixedRate(runnable, 2, 5, TimeUnit.SECONDS); service.scheduleAtFixedRate(runnable, 2, 15, TimeUnit.SECONDS);
// 创建并执行在给定延迟后启用的 ScheduledFuture。 // 创建并执行在给定延迟后启用的 ScheduledFuture。
// 参数: // 参数:

6
logistics/src/main/java/com/ccsens/logistics/Netty/SimpleClientHandler.java

@ -6,6 +6,7 @@ import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandler; import io.netty.channel.ChannelHandler;
import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter; import io.netty.channel.ChannelInboundHandlerAdapter;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import javax.annotation.Resource; import javax.annotation.Resource;
@ -14,6 +15,7 @@ import java.nio.charset.Charset;
/** /**
* @author * @author
*/ */
@Slf4j
@ChannelHandler.Sharable @ChannelHandler.Sharable
@Component @Component
public class SimpleClientHandler extends ChannelInboundHandlerAdapter{ public class SimpleClientHandler extends ChannelInboundHandlerAdapter{
@ -24,7 +26,9 @@ public class SimpleClientHandler extends ChannelInboundHandlerAdapter{
public void channelRead(ChannelHandlerContext ctx, Object msg) { public void channelRead(ChannelHandlerContext ctx, Object msg) {
if (msg instanceof ByteBuf) { if (msg instanceof ByteBuf) {
String value = ((ByteBuf) msg).toString(Charset.defaultCharset()); String value = ((ByteBuf) msg).toString(Charset.defaultCharset());
System.out.println("服务器端返回的数据:" + value.substring(value.length()-3,value.length()));
log.info("服务器端返回的数据:{}",value.substring(value.length() > 500 ? value.length()-300 : 0));
if(StrUtil.isNotEmpty(value) && value.lastIndexOf("not online") == -1) { if(StrUtil.isNotEmpty(value) && value.lastIndexOf("not online") == -1) {
thermalImageryService.disposeMessage(value); thermalImageryService.disposeMessage(value);
} }

6
util/src/test/java/com/ccsens/util/OtherTest.java

@ -125,9 +125,9 @@ public class OtherTest {
public void test9(){ public void test9(){
String s = "050005BD: The device is not online"; String s = "050005BD: The device is not online";
String as = "55"; String as = "55";
System.out.println(s.substring(s.length() > 200 ? s.length()-190 : 0));
System.out.println(s.lastIndexOf("not online")); // System.out.println(s.lastIndexOf("not online"));
System.out.println(as.lastIndexOf("not online")); // System.out.println(as.lastIndexOf("not online"));
} }
@Test @Test
public void test10(){ public void test10(){

Loading…
Cancel
Save