Commit eee0aa8c authored by zengtianlai3's avatar zengtianlai3

Merge remote-tracking branch 'remotes/origin/m33' into for-yx

parents 1694fe28 e1d56c3f
...@@ -27,29 +27,26 @@ public class TcpServer { ...@@ -27,29 +27,26 @@ public class TcpServer {
EventLoopGroup bossGroup = new NioEventLoopGroup(4); EventLoopGroup bossGroup = new NioEventLoopGroup(4);
EventLoopGroup workerGroup = new NioEventLoopGroup(4); EventLoopGroup workerGroup = new NioEventLoopGroup(4);
log.debug("Tcp服务,开始监听端口:{}",port); log.debug("Tcp服务,开始监听端口:{}",port);
//创建服务端的启动对象,设置参数
ServerBootstrap b = new ServerBootstrap();
//设置两个线程组boosGroup和workerGroup
b.group(bossGroup, workerGroup)
//设置服务端通道实现类型
.channel(NioServerSocketChannel.class)
// .handler(new LoggingHandler(LogLevel.INFO))
.childHandler(channelInitializer)
// 设置tcp缓冲区
.option(ChannelOption.SO_BACKLOG, 1024)
//设置保持活动连接状态
.childOption(ChannelOption.SO_KEEPALIVE, true);
ChannelFuture f;
try { try {
//创建服务端的启动对象,设置参数 f = b.bind(port).sync();
ServerBootstrap b = new ServerBootstrap(); f.channel().closeFuture().sync();
//设置两个线程组boosGroup和workerGroup } catch (InterruptedException e) {
b.group(bossGroup, workerGroup) // TODO Auto-generated catch block
//设置服务端通道实现类型 log.error("Tcp服务异常,端口:{}",port);
.channel(NioServerSocketChannel.class) }finally {
// .handler(new LoggingHandler(LogLevel.INFO))
.childHandler(channelInitializer)
// 设置tcp缓冲区
.option(ChannelOption.SO_BACKLOG, 1024)
//设置保持活动连接状态
.childOption(ChannelOption.SO_KEEPALIVE, true);
ChannelFuture f;
try {
f = b.bind(port).sync();
f.channel().closeFuture().sync();
} catch (InterruptedException e) {
// TODO Auto-generated catch block
log.error("Tcp服务异常,端口:{}",port);
}
} finally {
log.debug("Tcp服务,停止退出"); log.debug("Tcp服务,停止退出");
workerGroup.shutdownGracefully(); workerGroup.shutdownGracefully();
bossGroup.shutdownGracefully(); bossGroup.shutdownGracefully();
......
...@@ -22,7 +22,7 @@ public class ResourceManager { ...@@ -22,7 +22,7 @@ public class ResourceManager {
@Autowired @Autowired
ResourceService resourceService; ResourceService resourceService;
public void downloadDeviceInfoExcle(HttpServletResponse response, int userId){ public void downloadDeviceInfoExcle(HttpServletResponse response, int userId) throws IOException {
OutputStream os = null; OutputStream os = null;
HSSFWorkbook wb = null; HSSFWorkbook wb = null;
try { try {
...@@ -115,15 +115,11 @@ public class ResourceManager { ...@@ -115,15 +115,11 @@ public class ResourceManager {
} catch (IOException e) { } catch (IOException e) {
log.error("Excel表格信息下载异常,{}",e.getMessage()); log.error("Excel表格信息下载异常,{}",e.getMessage());
} finally { } finally {
try { if (os != null) {
if (os != null) { os.close();
os.close(); }
} if (wb != null) {
if (wb != null) { wb.close();
wb.close();
}
} catch (IOException e) {
log.error("Excel表格信息下载异常,{}",e.getMessage());
} }
} }
} }
......
...@@ -85,11 +85,14 @@ public class CommonUtil { ...@@ -85,11 +85,14 @@ public class CommonUtil {
public static String getLibFilePathByFileName(String fileName) { public static String getLibFilePathByFileName(String fileName) {
String os = System.getProperty("os.name"); String os = System.getProperty("os.name");
String serverParentDirectory = getServerParentDirectory(); String serverParentDirectory = getServerParentDirectory();
if (os.toLowerCase(Locale.ENGLISH).startsWith("win")) { if (os != null) {
return serverParentDirectory + File.separator + "lib" + File.separator + fileName + ".dll"; if (os.toLowerCase(Locale.ENGLISH).startsWith("win")) {
} else { return serverParentDirectory + File.separator + "lib" + File.separator + fileName + ".dll";
return serverParentDirectory + File.separator + "lib" + File.separator + fileName + ".so"; } else {
return serverParentDirectory + File.separator + "lib" + File.separator + fileName + ".so";
}
} }
return "";
} }
} }
...@@ -4,13 +4,13 @@ public class HexUtil { ...@@ -4,13 +4,13 @@ public class HexUtil {
public static String bytes2hex(byte[] bytes) { public static String bytes2hex(byte[] bytes) {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
String tmp; StringBuilder tmp;
sb.append("["); sb.append("[");
for (byte b : bytes) { for (byte b : bytes) {
// 将每个字节与0xFF进行与运算,然后转化为10进制,然后借助于Integer再转化为16进制 // 将每个字节与0xFF进行与运算,然后转化为10进制,然后借助于Integer再转化为16进制
tmp = Integer.toHexString(0xFF & b); tmp = new StringBuilder(Integer.toHexString(0xFF & b));
if (tmp.length() == 1) { if (tmp.length() == 1) {
tmp = "0" + tmp;//只有一位的前面补个0 tmp = tmp.insert(0, '0');//只有一位的前面补个0
} }
sb.append(tmp).append(" ");//每个字节用空格断开 sb.append(tmp).append(" ");//每个字节用空格断开
} }
...@@ -18,4 +18,4 @@ public class HexUtil { ...@@ -18,4 +18,4 @@ public class HexUtil {
sb.append("]"); sb.append("]");
return sb.toString(); return sb.toString();
} }
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment