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