tcp打印日志修改
This commit is contained in:
parent
d7a3343e7d
commit
03c7733fae
@ -31,35 +31,32 @@ public class TcpNettyHandler extends SimpleChannelInboundHandler<Object> {
|
||||
@Override
|
||||
public void channelRead0(ChannelHandlerContext ctx, Object msg) {
|
||||
byte[] bytes = readBytes(msg);
|
||||
|
||||
//字符串判断
|
||||
String str = getString(bytes);
|
||||
str = str.trim();
|
||||
log.info("channelRead0 str >>> \r\n {} ", str);
|
||||
log.info("tcp接收数据 >>> {} ", str);
|
||||
if (StringUtils.startsWith(str, HighFormworkSupport.TCP_DATA_PREFIX) && StringUtils.endsWith(str, HighFormworkSupport.TCP_DATA_END)) {
|
||||
log.info("高支模接收数据 >>> {} ", str);
|
||||
//接收高支模数据保存到mysql中
|
||||
try {
|
||||
highFormworkSupportService.saveTcpData(str);
|
||||
} catch (Exception e) {
|
||||
log.error("error:接收高支模数据保存到mysql中exception: >>> \r\n ", e);
|
||||
log.error("error:接收高支模数据保存到mysql中exception: >>> ", e);
|
||||
} finally {
|
||||
highFormworkSupportResponseOk(ctx);
|
||||
}
|
||||
return;
|
||||
}
|
||||
} else if (StringUtils.startsWith(str, "##")) {
|
||||
log.info("有毒气体接收数据 >>> {} ", str);
|
||||
//有毒气体
|
||||
if (StringUtils.startsWith(str, "##")) {
|
||||
poisonousGasDevCurrentDataService.addDataFromTcpFor212Protocol(str);
|
||||
return;
|
||||
}
|
||||
|
||||
} else {
|
||||
//16进制判断
|
||||
String hexString = readToHexString(bytes);
|
||||
log.info("channelRead0 hexString >>> \r\n {} ", hexString);
|
||||
log.info("tcp接收数据(16进制转字符串) >>> {} ", hexString);
|
||||
if (StringUtils.startsWith(hexString, "7E")) {
|
||||
//有害气体
|
||||
poisonousGasDevCurrentDataService.addDataFromTcp(hexString.trim());
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user