Ver Fonte

链接管理调整

chudk há 7 anos atrás
pai
commit
f27baf11fb

+ 3 - 4
pom.xml

@@ -37,7 +37,7 @@
         <dependency>  
             <groupId>org.springframework.boot</groupId>  
             <artifactId>spring-boot-starter-web</artifactId>  
-        </dependency> 
+        </dependency>
 		<dependency>
 			<groupId>org.springframework.boot</groupId>
 			<artifactId>spring-boot-starter-test</artifactId>
@@ -46,9 +46,8 @@
 		<dependency>
             <groupId>org.springframework.boot</groupId>
             <artifactId>spring-boot-starter-data-redis</artifactId>
-            <version>1.4.6.RELEASE</version>
         </dependency>
-		<dependency>
+	    <!-- <dependency>
 	        <groupId>io.springfox</groupId>
 	    	<artifactId>springfox-swagger2</artifactId>
 	    	    <version>2.2.2</version>
@@ -57,7 +56,7 @@
 	    	<groupId>io.springfox</groupId>
 	    	<artifactId>springfox-swagger-ui</artifactId>
 	    	    <version>2.2.2</version>
-		</dependency>
+		</dependency> -->
 		<dependency>
 			<groupId>com.tidecloud</groupId>
 			<artifactId>common-util</artifactId>

+ 40 - 40
src/main/java/com/tidecloud/dataacceptance/bean/SwaggerConfig.java

@@ -1,40 +1,40 @@
-package com.tidecloud.dataacceptance.bean;
-
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-
-import springfox.documentation.builders.ApiInfoBuilder;
-import springfox.documentation.builders.PathSelectors;
-import springfox.documentation.builders.RequestHandlerSelectors;
-import springfox.documentation.service.ApiInfo;
-import springfox.documentation.spi.DocumentationType;
-import springfox.documentation.spring.web.plugins.Docket;
-import springfox.documentation.swagger2.annotations.EnableSwagger2;
-
-/**   
- * @author: chudk 
- * @date:   2017年9月28日 上午11:23:52   
- */
-@Configuration
-@EnableSwagger2
-public class SwaggerConfig {
-    
-    @Bean
-    public Docket createRestApi(){
-        return new Docket(DocumentationType.SWAGGER_2)
-                .apiInfo(apiInfo())
-                .select()
-                .apis(RequestHandlerSelectors.basePackage("com.tidecloud.dataacceptance.web"))
-                .paths(PathSelectors.any())
-                .build();
-    }
-
-    private ApiInfo apiInfo() {
-        return new ApiInfoBuilder()
-                .title("手表调节RESTful API")
-                .description("----------")
-                .termsOfServiceUrl("--------termOfServiceUrl-----------")
-                .contact("contact")
-                .build();
-    }
-}
+//package com.tidecloud.dataacceptance.bean;
+//
+//import org.springframework.context.annotation.Bean;
+//import org.springframework.context.annotation.Configuration;
+//
+//import springfox.documentation.builders.ApiInfoBuilder;
+//import springfox.documentation.builders.PathSelectors;
+//import springfox.documentation.builders.RequestHandlerSelectors;
+//import springfox.documentation.service.ApiInfo;
+//import springfox.documentation.spi.DocumentationType;
+//import springfox.documentation.spring.web.plugins.Docket;
+//import springfox.documentation.swagger2.annotations.EnableSwagger2;
+//
+///**   
+// * @author: chudk 
+// * @date:   2017年9月28日 上午11:23:52   
+// */
+//@Configuration
+//@EnableSwagger2
+//public class SwaggerConfig {
+//    
+//    @Bean
+//    public Docket createRestApi(){
+//        return new Docket(DocumentationType.SWAGGER_2)
+//                .apiInfo(apiInfo())
+//                .select()
+//                .apis(RequestHandlerSelectors.basePackage("com.tidecloud.dataacceptance.web"))
+//                .paths(PathSelectors.any())
+//                .build();
+//    }
+//
+//    private ApiInfo apiInfo() {
+//        return new ApiInfoBuilder()
+//                .title("手表调节RESTful API")
+//                .description("----------")
+//                .termsOfServiceUrl("--------termOfServiceUrl-----------")
+//                .contact("contact")
+//                .build();
+//    }
+//}

+ 1 - 2
src/main/java/com/tidecloud/dataacceptance/schedule/DeviceControlSchedule.java

@@ -14,7 +14,6 @@ import com.smartsanitation.common.util.RequestUtil;
 import com.tidecloud.dataacceptance.service.impl.DiscardServerHandler;
 
 import io.netty.channel.Channel;
-import io.netty.channel.ChannelHandler.Sharable;
 
 /**   
  * @author: chudk 
@@ -25,7 +24,7 @@ public class DeviceControlSchedule {
 
     private static final Logger logger = LoggerFactory.getLogger(DeviceControlSchedule.class);
     
-    @Scheduled(cron = "0 0/1 * * ?")
+  //  @Scheduled(cron = "0 0/1 * * * ?")
     public void settingUploadTime(){
         Map<String, Channel> commandCopy = DiscardServerHandler.manageChannelMap;
         Map<Channel, String> channelMap = DiscardServerHandler.channelMap;

+ 28 - 22
src/main/java/com/tidecloud/dataacceptance/service/AcceptanceService.java

@@ -31,27 +31,33 @@ public class AcceptanceService {
     
     @PostConstruct
     public void run() throws Exception {
-        EventLoopGroup bossGroup = new NioEventLoopGroup();
-        EventLoopGroup workerGroup = new NioEventLoopGroup();
-        try {
-            ServerBootstrap b = new ServerBootstrap();
-            b.group(bossGroup, workerGroup).channel(NioServerSocketChannel.class).
-                    childHandler(new ChannelInitializer<SocketChannel>() {
-                        @Override
-                        protected void initChannel(SocketChannel ch) throws Exception {
-                            ch.pipeline().addLast(watchServcie);
-                        }
-                    })
-                    .option(ChannelOption.SO_BACKLOG, 128)
-                    .childOption(ChannelOption.SO_KEEPALIVE, true);
-
-            ChannelFuture f = b.bind(port).sync();
-            f.channel().closeFuture().sync();
-        } finally {
-            workerGroup.shutdownGracefully();
-            bossGroup.shutdownGracefully();
-
-        }
-    }
+        new Thread(new Runnable() {
+            @Override
+            public void run() {
+                EventLoopGroup bossGroup = new NioEventLoopGroup();
+                EventLoopGroup workerGroup = new NioEventLoopGroup();
+                try {
+                    ServerBootstrap b = new ServerBootstrap();
+                    b.group(bossGroup, workerGroup).channel(NioServerSocketChannel.class).
+                            childHandler(new ChannelInitializer<SocketChannel>() {
+                                @Override
+                                protected void initChannel(SocketChannel ch) throws Exception {
+                                    ch.pipeline().addLast(watchServcie);
+                                }
+                            })
+                            .option(ChannelOption.SO_BACKLOG, 128)
+                            .childOption(ChannelOption.SO_KEEPALIVE, true);
+
+                    ChannelFuture f = b.bind(port).sync();
+                    f.channel().closeFuture().sync();
+                } catch (InterruptedException e) {
+                    e.printStackTrace();
+                } finally {
+                    workerGroup.shutdownGracefully();
+                    bossGroup.shutdownGracefully();
+                }
+            }
+        }).start();
+      }
 
 }