523096025 3 роки тому
батько
коміт
83c2127bec

+ 6 - 59
huimv-massage-client/pom.xml

@@ -19,7 +19,7 @@
 
 
     <properties>
-        <java.version>1.8</java.version>
+        <java.version>11</java.version>
     </properties>
 
     <dependencies>
@@ -28,75 +28,22 @@
             <artifactId>spring-boot-starter-web</artifactId>
         </dependency>
 
-        <dependency>
-            <groupId>org.springframework.boot</groupId>
-            <artifactId>spring-boot-starter-test</artifactId>
-            <scope>test</scope>
-        </dependency>
+
         <dependency>
             <groupId>mysql</groupId>
             <artifactId>mysql-connector-java</artifactId>
             <scope>runtime</scope>
         </dependency>
-        <dependency>
-            <groupId>org.springframework.boot</groupId>
-            <artifactId>spring-boot-starter-data-jpa</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.projectlombok</groupId>
-            <artifactId>lombok</artifactId>
-        </dependency>
 
-        <dependency>
-            <groupId>com.baomidou</groupId>
-            <artifactId>mybatis-plus-boot-starter</artifactId>
-            <version>3.4.2</version>
-        </dependency>
 
-        <dependency>
-            <groupId>org.apache.commons</groupId>
-            <artifactId>commons-lang3</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>commons-lang</groupId>
-            <artifactId>commons-lang</artifactId>
-            <version>2.6</version>
-        </dependency>
 
-        <dependency>
-            <groupId>com.alibaba</groupId>
-            <artifactId>fastjson</artifactId>
-            <version>1.2.62</version>
-        </dependency>
-        <dependency>
-            <groupId>junit</groupId>
-            <artifactId>junit</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <!--JSR303校验validation-->
-        <dependency>
-            <groupId>org.springframework.boot</groupId>
-            <artifactId>spring-boot-starter-validation</artifactId>
-        </dependency>
 
-        <!--hutool-->
-        <dependency>
-            <groupId>cn.hutool</groupId>
-            <artifactId>hutool-all</artifactId>
-            <version>LATEST</version>
-        </dependency>
 
-        <dependency>
-            <groupId>com.zhenzikj</groupId>
-            <artifactId>zhenzisms</artifactId>
-            <version>2.0.2</version>
-        </dependency>
 
-        <dependency>
-            <groupId>com.zhenzikj</groupId>
-            <artifactId>zhenzisms</artifactId>
-            <version>2.0.2</version>
-        </dependency>
+
+
+
+
 
 
 

+ 16 - 0
huimv-massage-client/src/main/java/com/huimv/client/HuimvClientApplication.java

@@ -0,0 +1,16 @@
+package com.huimv.client;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.context.annotation.Bean;
+import org.springframework.scheduling.annotation.EnableScheduling;
+import org.springframework.web.client.RestTemplate;
+
+@SpringBootApplication
+@EnableScheduling
+public class HuimvClientApplication {
+
+    public static void main(String[] args) {
+        SpringApplication.run(HuimvClientApplication.class, args);
+    }
+}

+ 300 - 0
huimv-massage-client/src/main/java/com/huimv/client/controller/SimplenessClient.java

@@ -0,0 +1,300 @@
+package com.huimv.client.controller;
+
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.scheduling.annotation.Scheduled;
+import org.springframework.stereotype.Component;
+
+import java.io.*;
+import java.net.ServerSocket;
+import java.net.Socket;
+import java.util.Date;
+
+@Component
+public class SimplenessClient {
+    @Value("${farm.head}")
+    private String head;
+
+    @Value("${farm.cmd}")
+    private String cmd;
+
+    @Value("${farm.name}")
+    private String name;
+
+    @Value("${farm.end}")
+    private String end;
+
+    @Value("${farm.port}")
+    private Integer port;
+
+    @Value("${farm.ip}")
+    private String ip;
+
+    @Scheduled(cron = "0/20 * * * * ? ")
+    public void client() throws IOException {
+        System.out.println("start");
+        //建立socket向服务器发送连接请求
+        Socket socket = new Socket(ip,port);
+        InputStream inputStream;
+        inputStream = socket.getInputStream();
+        OutputStream outputStream = socket.getOutputStream();
+        //客户端向socket发送数据
+        PrintWriter printWriter = new PrintWriter(outputStream);
+        printWriter.println(head+"+"+  cmd+"+" + System.currentTimeMillis()+"+"  + name+"+" + end);
+        printWriter.flush();
+        //读取数据
+        BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
+        String readLine = bufferedReader.readLine();
+        System.out.println(readLine);
+        inputStream.close();
+        outputStream.close();
+        socket.close();
+    }
+
+    @Scheduled(cron = "0/20 * * * * ? ")
+    public void client1() throws IOException {
+        Integer status = 0;
+        ServerSocket s = null;
+        try {
+            s = new ServerSocket(9080);
+        } catch (IOException e) {
+            if (e instanceof java.net.BindException) {
+                //端口被占用
+                status = 1;
+            }
+        } finally {
+            try {
+                if(s!=null) {
+                    s.close();
+                }
+            } catch (Exception e) {
+                //e.printStackTrace();
+            }
+        }
+
+        try {
+            s = new ServerSocket(9100);
+        } catch (IOException e) {
+            if (e instanceof java.net.BindException) {
+                //端口被占用
+                status = 2;
+            }
+        } finally {
+            try {
+                if(s!=null) {
+                    s.close();
+                }
+            } catch (Exception e) {
+                //e.printStackTrace();
+            }
+        }
+
+
+
+
+        if (status == 1){
+            System.out.println("start111111111111");
+            //建立socket向服务器发送连接请求
+            Socket socket = new Socket(ip,port);
+            InputStream inputStream;
+            inputStream = socket.getInputStream();
+            OutputStream outputStream = socket.getOutputStream();
+            //客户端向socket发送数据
+            PrintWriter printWriter = new PrintWriter(outputStream);
+            printWriter.println(head+"+" + 2 +"+"+ System.currentTimeMillis()+"+"   + name+"+" + end);
+            printWriter.flush();
+            //读取数据
+            BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
+            String readLine = bufferedReader.readLine();
+            System.out.println(readLine);
+            inputStream.close();
+            outputStream.close();
+            socket.close();
+        }
+
+        if (status == 2){
+            System.out.println("video");
+            //建立socket向服务器发送连接请求
+            Socket socket = new Socket(ip,port);
+            InputStream inputStream;
+            inputStream = socket.getInputStream();
+            OutputStream outputStream = socket.getOutputStream();
+            //客户端向socket发送数据
+            PrintWriter printWriter = new PrintWriter(outputStream);
+            printWriter.println(head+"+" + 3 +"+"+ System.currentTimeMillis()+"+"   + name+"+" + end);
+            printWriter.flush();
+            //读取数据
+            BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
+            String readLine = bufferedReader.readLine();
+            System.out.println(readLine);
+            inputStream.close();
+            outputStream.close();
+            socket.close();
+        }
+
+    }
+
+    //监听video
+    // 8100	嘉兴市青莲养殖科技有限公司       3
+    //8101	武义本生农业开发有限公司	        4
+    //8103	黑猪场				            6
+    //8104	嘉兴青莲王江泾农业发展有限公司	7
+  /*  @Scheduled(cron = "0/20 * * * * ? ")
+    public void client1() throws IOException {
+        Integer status = 0;
+        ServerSocket s = null;
+        try {
+            s = new ServerSocket(8100);
+        } catch (IOException e) {
+            if (e instanceof java.net.BindException) {
+                //端口被占用
+                status = 3;
+            }
+        } finally {
+            try {
+                if(s!=null) {
+                    s.close();
+                }
+            } catch (Exception e) {
+                //e.printStackTrace();
+            }
+        }
+
+        try {
+            s = new ServerSocket(8101);
+        } catch (IOException e) {
+            if (e instanceof java.net.BindException) {
+                //端口被占用
+                status = 4;
+            }
+        } finally {
+            try {
+                if(s!=null) {
+                    s.close();
+                }
+            } catch (Exception e) {
+                //e.printStackTrace();
+            }
+        }
+
+        try {
+            s = new ServerSocket(8103);
+        } catch (IOException e) {
+            if (e instanceof java.net.BindException) {
+                //端口被占用
+                status = 6;
+            }
+        } finally {
+            try {
+                if(s!=null) {
+                    s.close();
+                }
+            } catch (Exception e) {
+                //e.printStackTrace();
+            }
+        }
+
+        try {
+            s = new ServerSocket(8104);
+        } catch (IOException e) {
+            if (e instanceof java.net.BindException) {
+                //端口被占用
+                status = 7;
+            }
+        } finally {
+            try {
+                if(s!=null) {
+                    s.close();
+                }
+            } catch (Exception e) {
+                //e.printStackTrace();
+            }
+        }
+
+
+
+
+        if (status == 3){
+            System.out.println("嘉兴市青莲养殖科技有限公司");
+            //建立socket向服务器发送连接请求
+            Socket socket = new Socket(ip,port);
+            InputStream inputStream;
+            inputStream = socket.getInputStream();
+            OutputStream outputStream = socket.getOutputStream();
+            //客户端向socket发送数据
+            PrintWriter printWriter = new PrintWriter(outputStream);
+            printWriter.println(head+"+" + 3 +"+"+ System.currentTimeMillis()+"+"   + 1234+"+" + end);
+            printWriter.flush();
+            //读取数据
+            BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
+            String readLine = bufferedReader.readLine();
+            System.out.println(readLine);
+            inputStream.close();
+            outputStream.close();
+            socket.close();
+        }
+
+        if (status == 4){
+            System.out.println("武义本生农业开发有限公司");
+            //建立socket向服务器发送连接请求
+            Socket socket = new Socket(ip,port);
+            InputStream inputStream;
+            inputStream = socket.getInputStream();
+            OutputStream outputStream = socket.getOutputStream();
+            //客户端向socket发送数据
+            PrintWriter printWriter = new PrintWriter(outputStream);
+            printWriter.println(head+"+" + 3 +"+"+ System.currentTimeMillis()+"+"   + 2345+"+" + end);
+            printWriter.flush();
+            //读取数据
+            BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
+            String readLine = bufferedReader.readLine();
+            System.out.println(readLine);
+            inputStream.close();
+            outputStream.close();
+            socket.close();
+        }
+
+        if (status == 6){
+            System.out.println("黑猪场");
+            //建立socket向服务器发送连接请求
+            Socket socket = new Socket(ip,port);
+            InputStream inputStream;
+            inputStream = socket.getInputStream();
+            OutputStream outputStream = socket.getOutputStream();
+            //客户端向socket发送数据
+            PrintWriter printWriter = new PrintWriter(outputStream);
+            printWriter.println(head+"+" + 3 +"+"+ System.currentTimeMillis()+"+"   + 8899+"+" + end);
+            printWriter.flush();
+            //读取数据
+            BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
+            String readLine = bufferedReader.readLine();
+            System.out.println(readLine);
+            inputStream.close();
+            outputStream.close();
+            socket.close();
+        }
+
+        if (status == 7){
+            System.out.println("嘉兴青莲王江泾农业发展有限公司");
+            //建立socket向服务器发送连接请求
+            Socket socket = new Socket(ip,port);
+            InputStream inputStream;
+            inputStream = socket.getInputStream();
+            OutputStream outputStream = socket.getOutputStream();
+            //客户端向socket发送数据
+            PrintWriter printWriter = new PrintWriter(outputStream);
+            printWriter.println(head+"+" + 3 +"+"+ System.currentTimeMillis()+"+"   + 3456+"+" + end);
+            printWriter.flush();
+            //读取数据
+            BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
+            String readLine = bufferedReader.readLine();
+            System.out.println(readLine);
+            inputStream.close();
+            outputStream.close();
+            socket.close();
+        }
+
+    }*/
+
+
+
+}

+ 29 - 29
huimv-massage-client/src/main/java/com/huimv/client/controller/ss.java

@@ -1,29 +1,29 @@
-package com.huimv.client.controller;
-
-import com.zhenzi.sms.ZhenziSmsClient;
-
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * @Author Anchor
- * @Date 2021/9/6 11:13
- * @Version 1.0.1
- */
-public class ss {
-
-    public static void main(String[] args) throws Exception {
-        ZhenziSmsClient client = new ZhenziSmsClient("https://sms_developer.zhenzikj.com",
-                "109928", "2684d129-1946-43fc-9074-93cee1687eb7");
-        Map<String, Object> params = new HashMap<String, Object>();
-        params.put("number", "15171709851");
-        params.put("templateId", "6655");
-        String[] templateParams = new String[2];
-        templateParams[0] = "问一下";
-        templateParams[1] = "余学轩你中午吃啥";
-        params.put("templateParams", templateParams);
-        String result = client.send(params);
-        String balance = client.balance();
-        System.out.println(result+balance);
-    }
-}
+//package com.huimv.client.controller;
+//
+//import com.zhenzi.sms.ZhenziSmsClient;
+//
+//import java.util.HashMap;
+//import java.util.Map;
+//
+///**
+// * @Author Anchor
+// * @Date 2021/9/6 11:13
+// * @Version 1.0.1
+// */
+//public class ss {
+//
+//    public static void main(String[] args) throws Exception {
+//        ZhenziSmsClient client = new ZhenziSmsClient("https://sms_developer.zhenzikj.com",
+//                "109928", "2684d129-1946-43fc-9074-93cee1687eb7");
+//        Map<String, Object> params = new HashMap<String, Object>();
+//        params.put("number", "15171709851");
+//        params.put("templateId", "6655");
+//        String[] templateParams = new String[2];
+//        templateParams[0] = "问一下";
+//        templateParams[1] = "余学轩你中午吃啥";
+//        params.put("templateParams", templateParams);
+//        String result = client.send(params);
+//        String balance = client.balance();
+//        System.out.println(result+balance);
+//    }
+//}

+ 30 - 0
huimv-massage-client/src/main/resources/application-dev.yml

@@ -0,0 +1,30 @@
+server:
+  port: 8013
+#spring:
+#  application:
+#    name: environment
+#
+#  datasource:
+#    url: jdbc:mysql://192.168.1.7:3306/huimv_ql_farm?useUnicode=true&characterEncoding=UTF-8&useSSL=false&autoReconnect=true&serverTimezone=Asia/Shanghai
+#    username: root
+#    password: hm123456
+#    driver-class-name: com.mysql.cj.jdbc.Driver
+#  jpa:
+#    show-sql: true
+#    database: mysql
+#    hibernate:
+#      ddl-auto: update
+#    database-platform: org.hibernate.dialect.MySQL5InnoDBDialect
+#    open-in-view: true
+#  redis:
+#    database: 0
+#    host: 122.112.224.199
+#    password: hm123456
+#    port: 6379
+#    jedis:
+#      pool:
+#        max-active: 20
+#        max-wait: -1
+#        max-idle: 10
+#        min-idle: 0
+#    connect-timeout:  5000

+ 14 - 0
huimv-massage-client/src/main/resources/application.properties

@@ -0,0 +1,14 @@
+spring.profiles.active=dev
+farm.head=hm
+farm.cmd=1
+farm.name=5678
+farm.end=end
+farm.port=8975
+#farm.ip=115.238.57.190
+farm.ip=122.112.224.199
+
+#海盐1234
+#武义牧场2345
+#王江泾牧场3456
+#大观山牧场4567
+#油车港牧场5678