From f16cabbae89334d823ce22183d2de3dc62ee9574 Mon Sep 17 00:00:00 2001
From: zhoushihao <zsh19950802@163.com>
Date: 星期一, 02 九月 2024 16:50:49 +0800
Subject: [PATCH] 1、替换swagger,可直接 doc.html访问接口 2、提供socket获取扫码枪数据(待测试)

---
 hangzhoumesParent/moduleService/UnLoadGlassModule/src/main/java/com/mes/UnLoadGlassApplication.java                     |    4 
 hangzhoumesParent/common/pom.xml                                                                                        |   29 ++--
 hangzhoumesParent/moduleService/TemperingGlassModule/src/main/java/com/mes/TemperingGlassModuleApplication.java         |    4 
 hangzhoumesParent/pom.xml                                                                                               |    5 
 hangzhoumesParent/moduleService/UnLoadGlassModule/src/main/java/com/mes/tools/SocketUtil.java                           |  168 ++++++++++++++++++++++++
 hangzhoumesParent/moduleService/UnLoadGlassModule/src/main/java/com/mes/job/Downpush.java                               |   34 ++++
 hangzhoumesParent/moduleService/UnLoadGlassModule/src/main/java/com/mes/config/SocketConfig.java                        |   26 +++
 hangzhoumesParent/common/servicebase/src/main/java/com/mes/common/config/Swagger2Config.java                            |  117 +++++++++------
 hangzhoumesParent/moduleService/LoadGlassModule/src/main/java/com/mes/LoadGlassModuleApplication.java                   |    4 
 hangzhoumesParent/moduleService/CacheGlassModule/src/main/java/com/mes/CacheGlassModuleApplication.java                 |    4 
 hangzhoumesParent/moduleService/CacheVerticalGlassModule/src/main/java/com/mes/CacheVerticalClassModuleApplication.java |    4 
 hangzhoumesParent/moduleService/GlassStorageModule/src/main/java/com/mes/GlassStorageApplication.java                   |    4 
 hangzhoumesParent/moduleService/UnLoadGlassModule/src/main/resources/application.yml                                    |    3 
 13 files changed, 329 insertions(+), 77 deletions(-)

diff --git a/hangzhoumesParent/common/pom.xml b/hangzhoumesParent/common/pom.xml
index 9da0bc0..49ca831 100644
--- a/hangzhoumesParent/common/pom.xml
+++ b/hangzhoumesParent/common/pom.xml
@@ -136,23 +136,22 @@
                 </exclusion>
             </exclusions>
         </dependency>
-        <!--        2.0~2.2	Knife4j 2.0.0 ~ 2.0.6-->
+        <dependency>
+            <groupId>com.github.xiaoymin</groupId>
+            <artifactId>knife4j-spring-boot-starter</artifactId>
+            <version>2.0.9</version>
+        </dependency>
+        <!--                2.0~2.2	Knife4j 2.0.0 ~ 2.0.6-->
         <!--        <dependency>-->
-        <!--            <groupId>com.github.xiaoymin</groupId>-->
-        <!--            <artifactId>knife4j-spring-boot-starter</artifactId>-->
-        <!--            <version>2.0.6</version>-->
+        <!--            <groupId>io.springfox</groupId>-->
+        <!--            <artifactId>springfox-swagger2</artifactId>-->
+        <!--            <version>2.7.0</version>-->
         <!--        </dependency>-->
-
-        <dependency>
-            <groupId>io.springfox</groupId>
-            <artifactId>springfox-swagger2</artifactId>
-            <version>2.7.0</version>
-        </dependency>
-        <dependency>
-            <groupId>io.springfox</groupId>
-            <artifactId>springfox-swagger-ui</artifactId>
-            <version>2.7.0</version>
-        </dependency>
+        <!--        <dependency>-->
+        <!--            <groupId>io.springfox</groupId>-->
+        <!--            <artifactId>springfox-swagger-ui</artifactId>-->
+        <!--            <version>2.7.0</version>-->
+        <!--        </dependency>-->
 
         <!--hutool java楠岃瘉鏂规硶绫�-->
         <dependency>
diff --git a/hangzhoumesParent/common/servicebase/src/main/java/com/mes/common/config/Swagger2Config.java b/hangzhoumesParent/common/servicebase/src/main/java/com/mes/common/config/Swagger2Config.java
index 0062ed2..c0b8e1f 100644
--- a/hangzhoumesParent/common/servicebase/src/main/java/com/mes/common/config/Swagger2Config.java
+++ b/hangzhoumesParent/common/servicebase/src/main/java/com/mes/common/config/Swagger2Config.java
@@ -3,19 +3,12 @@
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
 import springfox.documentation.builders.ApiInfoBuilder;
-import springfox.documentation.builders.ParameterBuilder;
 import springfox.documentation.builders.PathSelectors;
 import springfox.documentation.builders.RequestHandlerSelectors;
-import springfox.documentation.schema.ModelRef;
-import springfox.documentation.service.*;
+import springfox.documentation.service.ApiInfo;
+import springfox.documentation.service.Contact;
 import springfox.documentation.spi.DocumentationType;
-import springfox.documentation.spi.service.contexts.SecurityContext;
 import springfox.documentation.spring.web.plugins.Docket;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
 
 /**
  * @author zhan_py
@@ -25,54 +18,82 @@
 @Configuration
 public class Swagger2Config {
 
+
     @Bean
-    public Docket webApiConfig() {
-        List<Parameter> pars = new ArrayList<>();
-        ParameterBuilder tokenPar = new ParameterBuilder();
-        tokenPar.name("userId")
-                .description("鐢ㄦ埛token")
-                //.defaultValue(JwtHelper.createToken(1L, "admin"))
-                .defaultValue("1")
-                .modelRef(new ModelRef("string"))
-                .parameterType("header")
-                .required(false)
-                .build();
-        pars.add(tokenPar.build());
+    public Docket moduleDocket() {
+        return docket("mes鎺ュ彛鏂囨。", "com.mes");
+    }
 
+
+    private Docket docket(String groupName, String basePackages) {
         return new Docket(DocumentationType.SWAGGER_2)
-                .groupName("webApi")
-                .apiInfo(webApiInfo())
+                .groupName(groupName)
+                .apiInfo(apiInfo())
                 .select()
-                //鍙樉绀篴pi璺緞涓嬬殑椤甸潰
-                .apis(RequestHandlerSelectors.basePackage("com.mes"))
+                .apis(RequestHandlerSelectors.basePackage(basePackages))
                 .paths(PathSelectors.any())
-                .build()
-                .globalOperationParameters(pars)
-                .securitySchemes(Collections.EMPTY_LIST)
-                .securityContexts(Arrays.asList(securityContext()));
-    }
-
-    private SecurityContext securityContext() {
-        return SecurityContext.builder()
-                .securityReferences(defaultAuth())
-                .forPaths(PathSelectors.any())
                 .build();
     }
 
-    private List<SecurityReference> defaultAuth() {
-        AuthorizationScope authorizationScope = new AuthorizationScope("global", "accessEverything");
-        AuthorizationScope[] authorizationScopes = new AuthorizationScope[1];
-        authorizationScopes[0] = authorizationScope;
-        return Arrays.asList(new SecurityReference("Authorization", authorizationScopes));
-    }
-
-
-    private ApiInfo webApiInfo() {
+    private ApiInfo apiInfo() {
         return new ApiInfoBuilder()
-                .title("缃戠珯-API鏂囨。")
-                .description("鏈枃妗f弿杩颁簡mes缃戠珯寰湇鍔℃帴鍙e畾涔�")
-                .version("1.0")
-                .contact(new Contact("zhan_py", "", ""))
+                .title("mes鎺ュ彛鏂囨。绯荤粺")
+                .description("mesApi鎺ュ彛鏂囨。绯荤粺")
+                .license("Powered By mes")
+                .licenseUrl("http://127.0.0.1")
+                .termsOfServiceUrl("http://127.0.0.1")
+                .contact(new Contact("mes", "http://127.0.0.1", "beibo@mes.com"))
+                .version("V1.0.0")
                 .build();
     }
+
+
+//    @Bean
+//    public Docket webApiConfig() {
+//        List<Parameter> pars = new ArrayList<>();
+//        ParameterBuilder tokenPar = new ParameterBuilder();
+//        tokenPar.name("userId")
+//                .description("鐢ㄦ埛token")
+//                .defaultValue("1")
+//                .modelRef(new ModelRef("string"))
+//                .parameterType("header")
+//                .required(false)
+//                .build();
+//        pars.add(tokenPar.build());
+//
+//        return new Docket(DocumentationType.SWAGGER_2)
+//                .apiInfo(webApiInfo())
+//                .select()
+//                //鍙樉绀篴pi璺緞涓嬬殑椤甸潰
+//                .apis(RequestHandlerSelectors.basePackage("com.mes"))
+//                .paths(PathSelectors.any())
+//                .build()
+//                .globalOperationParameters(pars)
+//                .securitySchemes(Collections.EMPTY_LIST)
+//                .securityContexts(Arrays.asList(securityContext()));
+//    }
+//
+//    private SecurityContext securityContext() {
+//        return SecurityContext.builder()
+//                .securityReferences(defaultAuth())
+//                .forPaths(PathSelectors.any())
+//                .build();
+//    }
+//
+//    private List<SecurityReference> defaultAuth() {
+//        AuthorizationScope authorizationScope = new AuthorizationScope("global", "accessEverything");
+//        AuthorizationScope[] authorizationScopes = new AuthorizationScope[1];
+//        authorizationScopes[0] = authorizationScope;
+//        return Arrays.asList(new SecurityReference("Authorization", authorizationScopes));
+//    }
+//
+//
+//    private ApiInfo webApiInfo() {
+//        return new ApiInfoBuilder()
+//                .title("缃戠珯-API鏂囨。")
+//                .description("鏈枃妗f弿杩颁簡mes缃戠珯寰湇鍔℃帴鍙e畾涔�")
+//                .version("1.0")
+//                .contact(new Contact("zhan_py", "", ""))
+//                .build();
+//    }
 }
diff --git a/hangzhoumesParent/moduleService/CacheGlassModule/src/main/java/com/mes/CacheGlassModuleApplication.java b/hangzhoumesParent/moduleService/CacheGlassModule/src/main/java/com/mes/CacheGlassModuleApplication.java
index 13cceb4..b3de82f 100644
--- a/hangzhoumesParent/moduleService/CacheGlassModule/src/main/java/com/mes/CacheGlassModuleApplication.java
+++ b/hangzhoumesParent/moduleService/CacheGlassModule/src/main/java/com/mes/CacheGlassModuleApplication.java
@@ -6,7 +6,7 @@
 import org.springframework.boot.autoconfigure.SpringBootApplication;
 import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
 import org.springframework.scheduling.annotation.EnableScheduling;
-import springfox.documentation.swagger2.annotations.EnableSwagger2;
+import springfox.documentation.swagger2.annotations.EnableSwagger2WebMvc;
 
 /**
  * @Author : zhoush
@@ -17,7 +17,7 @@
 @SpringBootApplication
 @MapperScan("com.mes.*.mapper")
 @EnableDiscoveryClient
-@EnableSwagger2
+@EnableSwagger2WebMvc
 @EnableScheduling
 public class CacheGlassModuleApplication {
 
diff --git a/hangzhoumesParent/moduleService/CacheVerticalGlassModule/src/main/java/com/mes/CacheVerticalClassModuleApplication.java b/hangzhoumesParent/moduleService/CacheVerticalGlassModule/src/main/java/com/mes/CacheVerticalClassModuleApplication.java
index bdd4e12..ecfee1f 100644
--- a/hangzhoumesParent/moduleService/CacheVerticalGlassModule/src/main/java/com/mes/CacheVerticalClassModuleApplication.java
+++ b/hangzhoumesParent/moduleService/CacheVerticalGlassModule/src/main/java/com/mes/CacheVerticalClassModuleApplication.java
@@ -6,7 +6,7 @@
 import org.springframework.boot.autoconfigure.SpringBootApplication;
 import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
 import org.springframework.scheduling.annotation.EnableScheduling;
-import springfox.documentation.swagger2.annotations.EnableSwagger2;
+import springfox.documentation.swagger2.annotations.EnableSwagger2WebMvc;
 
 /**
  * @Author : zhoush
@@ -15,7 +15,7 @@
  */
 @Slf4j
 @SpringBootApplication
-@EnableSwagger2
+@EnableSwagger2WebMvc
 @EnableDiscoveryClient
 @MapperScan(basePackages = "com.mes.*.mapper")
 @EnableScheduling
diff --git a/hangzhoumesParent/moduleService/GlassStorageModule/src/main/java/com/mes/GlassStorageApplication.java b/hangzhoumesParent/moduleService/GlassStorageModule/src/main/java/com/mes/GlassStorageApplication.java
index 1ac53de..1d461dc 100644
--- a/hangzhoumesParent/moduleService/GlassStorageModule/src/main/java/com/mes/GlassStorageApplication.java
+++ b/hangzhoumesParent/moduleService/GlassStorageModule/src/main/java/com/mes/GlassStorageApplication.java
@@ -6,7 +6,7 @@
 import org.springframework.boot.autoconfigure.SpringBootApplication;
 import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
 import org.springframework.scheduling.annotation.EnableScheduling;
-import springfox.documentation.swagger2.annotations.EnableSwagger2;
+import springfox.documentation.swagger2.annotations.EnableSwagger2WebMvc;
 
 /**
  * @Author : zhoush
@@ -15,7 +15,7 @@
  */
 @Slf4j
 @SpringBootApplication
-@EnableSwagger2
+@EnableSwagger2WebMvc
 @EnableDiscoveryClient
 @MapperScan(basePackages = "com.mes.*.mapper")
 @EnableScheduling
diff --git a/hangzhoumesParent/moduleService/LoadGlassModule/src/main/java/com/mes/LoadGlassModuleApplication.java b/hangzhoumesParent/moduleService/LoadGlassModule/src/main/java/com/mes/LoadGlassModuleApplication.java
index 593308c..5d05d8e 100644
--- a/hangzhoumesParent/moduleService/LoadGlassModule/src/main/java/com/mes/LoadGlassModuleApplication.java
+++ b/hangzhoumesParent/moduleService/LoadGlassModule/src/main/java/com/mes/LoadGlassModuleApplication.java
@@ -6,7 +6,7 @@
 import org.springframework.boot.autoconfigure.SpringBootApplication;
 import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
 import org.springframework.scheduling.annotation.EnableScheduling;
-import springfox.documentation.swagger2.annotations.EnableSwagger2;
+import springfox.documentation.swagger2.annotations.EnableSwagger2WebMvc;
 
 /**
  * @Author : zhoush
@@ -15,7 +15,7 @@
  */
 @Slf4j
 @SpringBootApplication
-@EnableSwagger2
+@EnableSwagger2WebMvc
 @EnableDiscoveryClient
 @EnableScheduling
 @MapperScan(basePackages = "com.mes.*.mapper")
diff --git a/hangzhoumesParent/moduleService/TemperingGlassModule/src/main/java/com/mes/TemperingGlassModuleApplication.java b/hangzhoumesParent/moduleService/TemperingGlassModule/src/main/java/com/mes/TemperingGlassModuleApplication.java
index 8fb3948..1538e9e 100644
--- a/hangzhoumesParent/moduleService/TemperingGlassModule/src/main/java/com/mes/TemperingGlassModuleApplication.java
+++ b/hangzhoumesParent/moduleService/TemperingGlassModule/src/main/java/com/mes/TemperingGlassModuleApplication.java
@@ -6,7 +6,7 @@
 import org.springframework.boot.autoconfigure.SpringBootApplication;
 import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
 import org.springframework.scheduling.annotation.EnableScheduling;
-import springfox.documentation.swagger2.annotations.EnableSwagger2;
+import springfox.documentation.swagger2.annotations.EnableSwagger2WebMvc;
 
 /**
  * @Author : zhoush
@@ -15,7 +15,7 @@
  */
 @Slf4j
 @SpringBootApplication
-@EnableSwagger2
+@EnableSwagger2WebMvc
 @EnableDiscoveryClient
 @EnableScheduling
 @MapperScan(basePackages = "com.mes.*.mapper")
diff --git a/hangzhoumesParent/moduleService/UnLoadGlassModule/src/main/java/com/mes/UnLoadGlassApplication.java b/hangzhoumesParent/moduleService/UnLoadGlassModule/src/main/java/com/mes/UnLoadGlassApplication.java
index fba11e1..6066c94 100644
--- a/hangzhoumesParent/moduleService/UnLoadGlassModule/src/main/java/com/mes/UnLoadGlassApplication.java
+++ b/hangzhoumesParent/moduleService/UnLoadGlassModule/src/main/java/com/mes/UnLoadGlassApplication.java
@@ -6,7 +6,7 @@
 import org.springframework.boot.autoconfigure.SpringBootApplication;
 import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
 import org.springframework.scheduling.annotation.EnableScheduling;
-import springfox.documentation.swagger2.annotations.EnableSwagger2;
+import springfox.documentation.swagger2.annotations.EnableSwagger2WebMvc;
 
 /**
  * @Author : zhoush
@@ -15,7 +15,7 @@
  */
 @Slf4j
 @SpringBootApplication
-@EnableSwagger2
+@EnableSwagger2WebMvc
 @EnableDiscoveryClient
 @MapperScan(basePackages = "com.mes.*.mapper")
 @EnableScheduling
diff --git a/hangzhoumesParent/moduleService/UnLoadGlassModule/src/main/java/com/mes/config/SocketConfig.java b/hangzhoumesParent/moduleService/UnLoadGlassModule/src/main/java/com/mes/config/SocketConfig.java
new file mode 100644
index 0000000..e5cfb80
--- /dev/null
+++ b/hangzhoumesParent/moduleService/UnLoadGlassModule/src/main/java/com/mes/config/SocketConfig.java
@@ -0,0 +1,26 @@
+package com.mes.config;
+
+import com.mes.tools.SocketUtil;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+/**
+ * @Author : zhoush
+ * @Date: 2024/9/2 15:42
+ * @Description:
+ */
+@Configuration
+public class SocketConfig {
+
+    @Value("${mes.scan.ip}")
+    private String scanIp;
+
+    @Value("${mes.scan.port}")
+    private Integer scanPort;
+
+    @Bean
+    public SocketUtil getSocketUtil() {
+        return new SocketUtil(scanIp, scanPort);
+    }
+}
diff --git a/hangzhoumesParent/moduleService/UnLoadGlassModule/src/main/java/com/mes/job/Downpush.java b/hangzhoumesParent/moduleService/UnLoadGlassModule/src/main/java/com/mes/job/Downpush.java
index 8503db8..a0c7b32 100644
--- a/hangzhoumesParent/moduleService/UnLoadGlassModule/src/main/java/com/mes/job/Downpush.java
+++ b/hangzhoumesParent/moduleService/UnLoadGlassModule/src/main/java/com/mes/job/Downpush.java
@@ -14,6 +14,7 @@
 import com.mes.downworkstation.entity.DownWorkstation;
 import com.mes.downworkstation.service.DownWorkstationService;
 import com.mes.tools.DateUtil;
+import com.mes.tools.SocketUtil;
 import com.mes.tools.WebSocketServer;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang.StringUtils;
@@ -38,8 +39,8 @@
     private DownGlassInfoService downGlassInfoService;
     @Autowired
     private DownGlassTaskService downGlassTaskService;
-
-
+    @Autowired
+    SocketUtil socketUtil;
     @Autowired
     private RedisUtil redisUtil;
 
@@ -188,4 +189,33 @@
             }
         }
     }
+
+    @Scheduled(fixedDelay = Long.MAX_VALUE)
+    public void scanCodeTask() {
+        while (true) {
+            try {
+                if (socketUtil.openSocket()) {
+                    String data = socketUtil.receiveData();
+                    if (StringUtils.isNotBlank(data)) {
+                        log.info("鎵弿鏁版嵁锛�" + data);
+                        //鍙戦�佹壂鎻忔暟鎹�
+                        //todo:鎸夌収鐜荤拑id鑾峰彇鐜荤拑淇℃伅杩斿洖缁欏墠绔晫闈紝鍏蜂綋闇�瑕佸摢浜涙暟鎹緟纭
+                        ArrayList<WebSocketServer> sendwServer = WebSocketServer.sessionMap.get("scanCode");
+                        if (sendwServer != null) {
+                            for (WebSocketServer webserver : sendwServer) {
+                                if (webserver != null && webserver.session.isOpen()) {
+                                    webserver.sendMessage(data);
+                                }
+                            }
+                        }
+                    }
+                } else {
+                    log.info("socket杩炴帴澶辫触");
+                }
+            } catch (Exception e) {
+                log.info("socke鎵ц杩囩▼涓彂鐢熷紓甯�");
+            }
+        }
+
+    }
 }
diff --git a/hangzhoumesParent/moduleService/UnLoadGlassModule/src/main/java/com/mes/tools/SocketUtil.java b/hangzhoumesParent/moduleService/UnLoadGlassModule/src/main/java/com/mes/tools/SocketUtil.java
new file mode 100644
index 0000000..cbed75a
--- /dev/null
+++ b/hangzhoumesParent/moduleService/UnLoadGlassModule/src/main/java/com/mes/tools/SocketUtil.java
@@ -0,0 +1,168 @@
+package com.mes.tools;
+
+import lombok.extern.slf4j.Slf4j;
+
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.net.InetSocketAddress;
+import java.net.Socket;
+
+/**
+ * @Author : zhoush
+ * @Date: 2024/9/2 15:32
+ * @Description:
+ */
+
+@Slf4j
+public class SocketUtil {
+    private final String host;
+    private final int port;
+
+    private final int connectionTimeout;
+    private final int soTimeout;
+
+    private Socket socket;
+
+    private DataOutputStream dataOutputStream;
+
+    private DataInputStream dataInputStream;
+
+    public SocketUtil(String host, int port) {
+        this(host, port, 5000, 5000);
+    }
+
+    public SocketUtil(String host, int port, int connectionTimeout, int soTimeout) {
+        this.host = host;
+        this.port = port;
+        this.connectionTimeout = connectionTimeout;
+        this.soTimeout = soTimeout;
+    }
+
+    /**
+     * 鎵撳紑Socket杩炴帴
+     *
+     * @return 鏄惁鎴愬姛鎵撳紑Socket杩炴帴
+     */
+    public boolean openSocket() {
+        try {
+            socket = new Socket();
+            InetSocketAddress socketAddress = new InetSocketAddress(host, port);
+            socket.setReuseAddress(true);
+            socket.setSoTimeout(soTimeout);
+            socket.connect(socketAddress, connectionTimeout);
+            dataOutputStream = new DataOutputStream(socket.getOutputStream());
+            dataInputStream = new DataInputStream(socket.getInputStream());
+        } catch (Exception e) {
+            log.error("鎵撳紑Socket杩炴帴澶辫触:", e);
+            return false;
+        }
+        return true;
+    }
+
+    public boolean sendData(String data) {
+        return sendData(data, "utf-8");
+    }
+
+    /**
+     * 鍙戦�佽姹傛暟鎹��
+     *
+     * @param data    鏁版嵁
+     * @param charset 瀛楃闆�
+     * @return 鏄惁鍙戦�佹垚鍔�
+     */
+    public boolean sendData(String data, String charset) {
+        boolean isSend = true;
+        try {
+            byte[] bytes = data.getBytes(charset);
+            dataOutputStream.writeInt(bytes.length);
+            dataOutputStream.write(bytes);
+        } catch (IOException e) {
+            log.error("鍙戦�佹暟鎹け璐�:", e);
+            isSend = false;
+        }
+        return isSend;
+    }
+
+    /**
+     * 鎺ユ敹鍝嶅簲鏁版嵁
+     */
+    public String receiveData() {
+        return receiveData("UTF-8");
+    }
+
+    /**
+     * 鎺ユ敹鍝嶅簲鏁版嵁
+     */
+    public String receiveData(String charset) {
+        String returnStr = null;
+        byte[] data;
+        try {
+            int length = dataInputStream.readInt();
+            if (length > 0) {
+                data = new byte[length];
+                dataInputStream.readFully(data);
+                returnStr = new String(data, charset);
+            }
+        } catch (IOException e) {
+            log.error("鎺ユ敹鏁版嵁澶辫触:", e);
+        }
+        return returnStr;
+    }
+
+    /**
+     * 鍏抽棴Socket杩炴帴鍜岃緭鍏ヨ緭鍑烘祦
+     */
+    public void close() {
+        try {
+            if (dataInputStream != null) {
+                dataInputStream.close();
+            }
+        } catch (IOException e) {
+            log.error("鍏抽棴杈撳叆娴佸け璐�:", e);
+        }
+        try {
+            if (dataOutputStream != null) {
+                dataOutputStream.close();
+            }
+        } catch (IOException e) {
+            log.error("鍏抽棴杈撳嚭娴佸け璐�:", e);
+        }
+        try {
+            if (socket != null) {
+                socket.close();
+            }
+        } catch (IOException e) {
+            log.error("鍏抽棴Socket澶辫触:", e);
+        }
+    }
+
+    /**
+     * Socket鐭繛鎺ュ彂閫佽姹傛暟鎹�
+     *
+     * @param host        host
+     * @param port        绔彛
+     * @param requestData 璇锋眰鏁版嵁
+     * @return 鍝嶅簲鏁版嵁
+     */
+    public static String send(String host, int port, String requestData) {
+        SocketUtil socketUtil = new SocketUtil(host, port);
+        String resp = null;
+        try {
+            if (socketUtil.openSocket()) {
+                if (socketUtil.sendData(requestData)) {
+                    resp = socketUtil.receiveData();
+                } else {
+                    log.error("SocketUtil.send鍙戦�佹暟鎹け璐�");
+                }
+            } else {
+                log.error("SocketUtil.openSocket鎵撳紑Socket澶辫触");
+            }
+        } catch (Exception e) {
+            log.error("SocketUtil.send鍙戦�佽姹傚け璐�:", e);
+        } finally {
+            socketUtil.close();
+        }
+        return resp;
+    }
+}
diff --git a/hangzhoumesParent/moduleService/UnLoadGlassModule/src/main/resources/application.yml b/hangzhoumesParent/moduleService/UnLoadGlassModule/src/main/resources/application.yml
index 9468ed9..6c89ab2 100644
--- a/hangzhoumesParent/moduleService/UnLoadGlassModule/src/main/resources/application.yml
+++ b/hangzhoumesParent/moduleService/UnLoadGlassModule/src/main/resources/application.yml
@@ -21,3 +21,6 @@
   throughWidth: 3000
   throughHeight: 2500
   threshold: 5      #涓嬬墖鐨勬渶澶ч槇鍊�
+  scan:
+    ip: 127.0.0.1
+    port: 5000
diff --git a/hangzhoumesParent/pom.xml b/hangzhoumesParent/pom.xml
index 9ef3261..a9b0a6b 100644
--- a/hangzhoumesParent/pom.xml
+++ b/hangzhoumesParent/pom.xml
@@ -42,6 +42,11 @@
                 <type>pom</type>
                 <scope>import</scope>
             </dependency>
+            <dependency>
+                <groupId>org.springframework.plugin</groupId>
+                <artifactId>spring-plugin-core</artifactId>
+                <version>2.0.0.RELEASE</version>
+            </dependency>
         </dependencies>
     </dependencyManagement>
 

--
Gitblit v1.8.0