523096025 il y a 2 ans
commit
5eaebe9d24
21 fichiers modifiés avec 879 ajouts et 0 suppressions
  1. 33 0
      demo1/.gitignore
  2. 94 0
      demo1/pom.xml
  3. 27 0
      demo1/src/main/java/com/huimv/demo/DemoApplication.java
  4. 111 0
      demo1/src/main/java/com/huimv/demo/eartag/EartagServer.java
  5. 196 0
      demo1/src/main/java/com/huimv/demo/eartag/EartagServerHandler2.java
  6. 63 0
      demo1/src/main/java/com/huimv/demo/eartag/conifg/WebSocket.java
  7. 19 0
      demo1/src/main/java/com/huimv/demo/eartag/conifg/WebSocketConfig.java
  8. 44 0
      demo1/src/main/java/com/huimv/demo/eartag/controller/PliersDemoController.java
  9. 20 0
      demo1/src/main/java/com/huimv/demo/eartag/controller/StationLibController.java
  10. 30 0
      demo1/src/main/java/com/huimv/demo/eartag/entity/ChatMsg.java
  11. 45 0
      demo1/src/main/java/com/huimv/demo/eartag/entity/PliersDemo.java
  12. 43 0
      demo1/src/main/java/com/huimv/demo/eartag/entity/StationLib.java
  13. 16 0
      demo1/src/main/java/com/huimv/demo/eartag/mapper/PliersDemoMapper.java
  14. 16 0
      demo1/src/main/java/com/huimv/demo/eartag/mapper/StationLibMapper.java
  15. 16 0
      demo1/src/main/java/com/huimv/demo/eartag/service/IPliersDemoService.java
  16. 16 0
      demo1/src/main/java/com/huimv/demo/eartag/service/IStationLibService.java
  17. 20 0
      demo1/src/main/java/com/huimv/demo/eartag/service/impl/PliersDemoServiceImpl.java
  18. 20 0
      demo1/src/main/java/com/huimv/demo/eartag/service/impl/StationLibServiceImpl.java
  19. 22 0
      demo1/src/main/resources/application.yml
  20. 15 0
      demo1/src/main/resources/mapper/StationLibMapper.xml
  21. 13 0
      demo1/src/test/java/com/huimv/demo/DemoApplicationTests.java

+ 33 - 0
demo1/.gitignore

@@ -0,0 +1,33 @@
+HELP.md
+target/
+!.mvn/wrapper/maven-wrapper.jar
+!**/src/main/**/target/
+!**/src/test/**/target/
+
+### STS ###
+.apt_generated
+.classpath
+.factorypath
+.project
+.settings
+.springBeans
+.sts4-cache
+
+### IntelliJ IDEA ###
+.idea
+*.iws
+*.iml
+*.ipr
+
+### NetBeans ###
+/nbproject/private/
+/nbbuild/
+/dist/
+/nbdist/
+/.nb-gradle/
+build/
+!**/src/main/**/build/
+!**/src/test/**/build/
+
+### VS Code ###
+.vscode/

+ 94 - 0
demo1/pom.xml

@@ -0,0 +1,94 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.springframework.boot</groupId>
+        <artifactId>spring-boot-starter-parent</artifactId>
+        <version>2.7.0</version>
+        <relativePath/> <!-- lookup parent from repository -->
+    </parent>
+    <groupId>com.huimv.demo</groupId>
+    <artifactId>demo</artifactId>
+    <version>0.0.1-SNAPSHOT</version>
+    <name>demo</name>
+    <description>Demo project for Spring Boot</description>
+    <properties>
+        <java.version>1.8</java.version>
+    </properties>
+    <dependencies>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <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>
+        </dependency>
+        <dependency>
+            <groupId>org.projectlombok</groupId>
+            <artifactId>lombok</artifactId>
+            <version>1.16.18</version>
+            <scope>provided</scope>
+        </dependency>
+        <!--hutool-->
+        <dependency>
+            <groupId>cn.hutool</groupId>
+            <artifactId>hutool-all</artifactId>
+            <!--            <version>LATEST</version>-->
+            <version>5.6.5</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.httpcomponents</groupId>
+            <artifactId>httpclient</artifactId>
+            <version>4.5.5</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.commons</groupId>
+            <artifactId>commons-lang3</artifactId>
+            <version>3.7</version>
+        </dependency>
+
+        <!-- netty -->
+        <dependency>
+            <groupId>io.netty</groupId>
+            <artifactId>netty-all</artifactId>
+            <version>4.1.45.Final</version>
+        </dependency>
+        <dependency>
+            <groupId>com.baomidou</groupId>
+            <artifactId>mybatis-plus-boot-starter</artifactId>
+            <version>3.4.2</version>
+        </dependency>
+        <dependency>
+            <groupId>com.baomidou</groupId>
+            <artifactId>mybatis-plus-extension</artifactId>
+            <version>3.4.2</version>
+        </dependency>
+        <dependency>
+            <groupId>com.baomidou</groupId>
+            <artifactId>mybatis-plus-generator</artifactId>
+            <version>3.2.0</version>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-websocket</artifactId>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.springframework.boot</groupId>
+                <artifactId>spring-boot-maven-plugin</artifactId>
+            </plugin>
+        </plugins>
+    </build>
+
+</project>

+ 27 - 0
demo1/src/main/java/com/huimv/demo/DemoApplication.java

@@ -0,0 +1,27 @@
+package com.huimv.demo;
+
+import com.huimv.demo.eartag.EartagServer;
+import org.mybatis.spring.annotation.MapperScan;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.annotation.Bean;
+import org.springframework.scheduling.annotation.EnableScheduling;
+import org.springframework.web.client.RestTemplate;
+
+@SpringBootApplication
+@MapperScan("com.huimv.demo.eartag.mapper")
+@EnableScheduling
+public class DemoApplication {
+
+    public static void main(String[] args) throws InterruptedException {
+        ApplicationContext applicationContext = SpringApplication.run(DemoApplication.class, args);
+        //
+        applicationContext.getBean(EartagServer.class).run();
+    }
+    @Bean
+    public static RestTemplate getRestTemplate(){
+        return new RestTemplate();
+    }
+
+}

+ 111 - 0
demo1/src/main/java/com/huimv/demo/eartag/EartagServer.java

@@ -0,0 +1,111 @@
+package com.huimv.demo.eartag;
+
+import io.netty.bootstrap.ServerBootstrap;
+import io.netty.buffer.ByteBuf;
+import io.netty.channel.*;
+import io.netty.channel.nio.NioEventLoopGroup;
+import io.netty.channel.socket.SocketChannel;
+import io.netty.channel.socket.nio.NioServerSocketChannel;
+import io.netty.handler.logging.LogLevel;
+import io.netty.handler.logging.LoggingHandler;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+/**
+ * @Project : huimv.shiwan
+ * @Package : com.huimv.biosafety.uface.controller
+ * @Description : TODO
+ * @Version : 1.0
+ * @Author : ZhuoNing
+ * @Create : 2020-12-25
+ **/
+@Component
+public class EartagServer {
+    @Autowired
+    private EartagServerHandler2 serverHandler;
+    //监听端口
+    private int port = 8012;
+    private int port2 = 8013;
+    //创建构造方法
+    public EartagServer(){
+    }
+
+    public static void main(String[] args) throws InterruptedException {
+        new EartagServer().run();
+    }
+/**
+ *
+ * 功能描述: 启动方法前台多个服务  处理多个线程
+ *
+ * @param:
+ * @return:
+ * @auther: LiGang
+ * @date: 2019/3/26 11:31
+ */
+    /**
+     * 启动流程
+     */
+    public void run() throws InterruptedException {
+        //配置服务端线程组
+        EventLoopGroup bossGroup=new NioEventLoopGroup();
+        EventLoopGroup workGroup=new NioEventLoopGroup();
+
+        try{
+            //引导整个server的启动
+            ServerBootstrap serverBootstrap = new ServerBootstrap();
+
+           serverBootstrap.group(bossGroup, workGroup)
+                    .channel(NioServerSocketChannel.class)    //指定处理的连接类型
+                    .option(ChannelOption.SO_REUSEADDR, true)
+                    .childHandler(new ChannelInitializer<SocketChannel>() {
+                        @Override
+                        protected void initChannel(SocketChannel socketChannel) throws Exception {
+                            socketChannel.pipeline().addLast(serverHandler);
+                        }
+                    });
+            System.out.println("# 耳标及采集器设备数据接收服务器已经启动。#");
+            System.out.println("# 准备接收数据:");
+            //绑定端口,同步等待成功
+            ChannelFuture cf = serverBootstrap.bind(port).sync();
+            ChannelFuture cf2 = serverBootstrap.bind(port2).sync();
+            // 等待服务端监听端口关闭
+            cf.channel().closeFuture().sync();
+            cf2.channel().closeFuture().sync();
+        }finally {
+            //优雅的退出
+            bossGroup.shutdownGracefully();
+            workGroup.shutdownGracefully();
+        }
+    }
+
+    public void run2() throws InterruptedException {
+        ServerBootstrap b = new ServerBootstrap();
+        EventLoopGroup bossGroup = new NioEventLoopGroup();
+        EventLoopGroup workerGroup = new NioEventLoopGroup();
+
+        b.group(bossGroup, workerGroup).channel(NioServerSocketChannel.class)
+                .option(ChannelOption.SO_REUSEADDR, true)
+                .childHandler(new ChannelInitializer() {
+                    @Override
+                    protected void initChannel(Channel ch) throws Exception {
+                        ch.pipeline()
+                                .addLast("logging", new LoggingHandler(LogLevel.INFO))
+                                .addLast(new SimpleChannelInboundHandler() {
+                                    @Override
+                                    protected void channelRead0(ChannelHandlerContext ctx, Object msg) throws Exception {
+                                        ByteBuf data = (ByteBuf) msg;
+                                        String clientAskText = data.toString(io.netty.util.CharsetUtil.UTF_8);
+//                                        String strMsg = msg.toString(CharsetUtil.UTF_8);
+                                        System.out.println("clientAskText>>"+clientAskText);
+                                    }
+                                });
+                    }
+                });
+
+//        b.bind(port).sync();
+//        System.out.println("tcp server("+port+") is started..");
+
+        b.bind(port2).sync();
+        System.out.println("tcp server("+port2+") is started..");
+    }
+}

+ 196 - 0
demo1/src/main/java/com/huimv/demo/eartag/EartagServerHandler2.java

@@ -0,0 +1,196 @@
+package com.huimv.demo.eartag;
+
+import cn.hutool.core.util.ObjectUtil;
+import cn.hutool.json.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.huimv.demo.eartag.conifg.WebSocket;
+import com.huimv.demo.eartag.entity.PliersDemo;
+import com.huimv.demo.eartag.entity.StationLib;
+import com.huimv.demo.eartag.service.IPliersDemoService;
+import com.huimv.demo.eartag.service.IStationLibService;
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.Unpooled;
+import io.netty.channel.ChannelHandler;
+import io.netty.channel.ChannelHandlerContext;
+import io.netty.channel.ChannelInboundHandlerAdapter;
+import io.netty.util.CharsetUtil;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.http.ResponseEntity;
+import org.springframework.stereotype.Component;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.web.client.RestTemplate;
+
+import javax.sound.midi.Soundbank;
+import java.text.ParseException;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * @Project : huimv.shiwan
+ * @Package : com.huimv.biosafety.uface.controller
+ * @Description : TODO
+ * @Version : 1.0
+ * @Author : ZhuoNing
+ * @Create : 2020-12-25
+ **/
+@ChannelHandler.Sharable
+@Component
+@Slf4j
+public class EartagServerHandler2 extends ChannelInboundHandlerAdapter {
+    private StringBuilder askTextSb = null;
+
+    @Autowired
+    private IPliersDemoService pliersDemoService;
+
+    @Autowired
+    private IStationLibService stationLibService;
+
+    @Autowired
+    private RestTemplate restTemplate ;
+    //
+    public void appendClientAsk(String text){
+        if(this.askTextSb == null){
+            askTextSb = new StringBuilder();
+        }
+        askTextSb.append(text);
+    }
+
+    @Override
+    public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
+        ByteBuf data = (ByteBuf) msg;
+        String clientAskText = data.toString(CharsetUtil.UTF_8);
+//        System.out.println((++num)+"次, 客户端消息clientAskText>>"+clientAskText);
+        //保存实例内的客户端请求
+        appendClientAsk(clientAskText);
+    }
+
+    @Override
+    public void channelReadComplete(ChannelHandlerContext ctx) throws Exception {
+//        ctx.writeAndFlush("111");
+//        System.out.println("EchoServerHandle channelReadComplete");
+        if(askTextSb.toString().indexOf("end") != -1){
+//            System.out.println("askTextSb.内容()>>"+askTextSb.toString());
+//            System.out.println("askTextSb.内容长度>>"+askTextSb.length());
+//            System.out.println("输入完成.");
+            // 处理客户端消息
+            handleClientEartagMessage(askTextSb.toString(),ctx);
+            //清空重置;
+            askTextSb.delete(0,askTextSb.length());
+//            System.out.println("清空sb实例. 长度>>"+askTextSb.length());
+        }
+    }
+
+    @Override
+    public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
+//        System.out.println("cause.getMessage()>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"+cause.getMessage());
+        if(cause.getMessage().indexOf("Connection reset") != -1){
+            log.info("相关采集器设备正在重启:"+cause.toString());
+        }
+//        cause.printStackTrace();
+        ctx.close();
+    }
+
+    /**
+     * @Method      : handleClientMessage
+     * @Description : 处理请求小心
+     * @Params      : [clientAskText, ctx]
+     * @Return      : void
+     * 
+     * @Author      : ZhuoNing
+     * @Date        : 2022/3/28       
+     * @Time        : 17:36
+     */
+    private   void handleClientEartagMessage(String clientAskText, ChannelHandlerContext ctx) throws ParseException, JsonProcessingException {
+        clientAskText = clientAskText.replaceAll("\r","").replaceAll("\n","");
+        System.out.println("clientAskText--------------->" +clientAskText);
+//hm+7+868977051335099+122083123610011+0+end
+
+        String[] split = clientAskText.split("\\+");
+
+
+        if ("6".equals(split[1])){
+
+            System.out.println("pliersDemo------------->" +clientAskText);
+            ctx.writeAndFlush(Unpooled.copiedBuffer("hm+6+0+115.238.57.190+8013+8+end".getBytes()));
+        }
+
+        if ("7".equals(split[1])){
+
+            String eartag = split[3];
+            //hm+7+868977051335099+122083123610011+22450+184902913+0+end
+            String lac = split[4];
+            String ci = split[5];
+            StationLib stationLib = stationLibService.getOne(new QueryWrapper<StationLib>().eq("ci", ci).eq("lac", lac));
+            String lat ="";
+            String lon ="";
+            String address ="";
+
+            if (ObjectUtil.isEmpty(stationLib)){
+                ResponseEntity<JSONObject> forEntity = restTemplate.getForEntity("http://api.cellocation.com:82/cell/?mcc=460&mnc=1&lac="+lac+"&ci="+ci+"&output=json", JSONObject.class);
+                JSONObject body = forEntity.getBody();
+                lat = (String)body.get("lat");
+                lon =  (String)body.get("lon");
+                address = (String)body.get("address");
+                String    radius = (String)body.get("radius");
+                Integer  errcode = (Integer)body.get("errcode");
+
+                StationLib stationLib1 = new StationLib();
+                stationLib1.setAddress(address);
+                stationLib1.setCi(ci);
+                stationLib1.setErrcode(errcode+"");
+                stationLib1.setLac(lac);
+                stationLib1.setLat(lat);
+                stationLib1.setLon(lon);
+                stationLib1.setRadius(Integer.parseInt(radius));
+
+                stationLibService.save(stationLib1);
+
+
+            }else {
+                lat = stationLib.getLat();
+                lon = stationLib.getLon();
+                address = stationLib.getAddress();
+            }
+
+
+            int countEarmark = pliersDemoService.count(new QueryWrapper<PliersDemo>().eq("earmark", eartag));
+            PliersDemo pliersDemo = new PliersDemo();
+            pliersDemo.setEarmark(eartag);
+            pliersDemo.setPliersId(split[2]);
+            pliersDemo.setUpdateTime(new Date());
+            pliersDemo.setUsegeTimes(countEarmark+1);
+
+
+            pliersDemo.setLat(lat);
+            pliersDemo.setLon(lon);
+            pliersDemo.setAddress(address);
+
+
+            pliersDemoService.save(pliersDemo);
+
+
+            List<PliersDemo> id = pliersDemoService.list(new QueryWrapper<PliersDemo>().orderByDesc("id").last("limit 50"));
+            String resultJson= new ObjectMapper().writeValueAsString(id);
+            WebSocket.sendMessage(resultJson);
+            ctx.writeAndFlush(Unpooled.copiedBuffer("hm+7+8+end".getBytes()));
+
+        }
+
+
+
+    }
+
+
+//hm+7+868977051335099+122083123610011+0+end
+    //hm+6+868977051335099+0+end
+
+
+}

+ 63 - 0
demo1/src/main/java/com/huimv/demo/eartag/conifg/WebSocket.java

@@ -0,0 +1,63 @@
+package com.huimv.demo.eartag.conifg;
+
+import com.huimv.demo.eartag.entity.PliersDemo;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Component;
+
+import javax.websocket.OnClose;
+import javax.websocket.OnMessage;
+import javax.websocket.OnOpen;
+import javax.websocket.Session;
+import javax.websocket.server.ServerEndpoint;
+import java.util.List;
+import java.util.concurrent.CopyOnWriteArraySet;
+
+//注册成组件
+@Component
+//定义websocket服务器端,它的功能主要是将目前的类定义成一个websocket服务器端。注解的值将被用于监听用户连接的终端访问URL地址
+@ServerEndpoint("/websocket")
+//如果不想每次都写private  final Logger logger = LoggerFactory.getLogger(当前类名.class); 可以用注解@Slf4j;可以直接调用log.info
+@Slf4j
+public class WebSocket {
+ 
+    //实例一个session,这个session是websocket的session
+    private Session session;
+ 
+    //存放websocket的集合(本次demo不会用到,聊天室的demo会用到)
+    private static CopyOnWriteArraySet<WebSocket> webSocketSet = new CopyOnWriteArraySet<>();
+ 
+    //前端请求时一个websocket时
+    @OnOpen
+    public void onOpen(Session session) {
+        this.session = session;
+        webSocketSet.add(this);
+        log.info("【websocket消息】有新的连接, 总数:{}", webSocketSet.size());
+    }
+ 
+    //前端关闭时一个websocket时
+    @OnClose
+    public void onClose() {
+        webSocketSet.remove(this);
+        log.info("【websocket消息】连接断开, 总数:{}", webSocketSet.size());
+    }
+ 
+    //前端向后端发送消息
+    @OnMessage
+    public void onMessage(String message) {
+        log.info("【websocket消息】收到客户端发来的消息:{}", message);
+    }
+
+    //新增一个方法用于主动向客户端发送消息
+    public static void sendMessage(String message) {
+        for (WebSocket webSocket: webSocketSet) {
+            log.info("【websocket消息】广播消息, message={}", message);
+            try {
+                webSocket.session.getBasicRemote().sendText(message);
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+        }
+    }
+
+
+}

+ 19 - 0
demo1/src/main/java/com/huimv/demo/eartag/conifg/WebSocketConfig.java

@@ -0,0 +1,19 @@
+package com.huimv.demo.eartag.conifg;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.web.socket.server.standard.ServerEndpointExporter;
+
+/**
+ * websocket
+ * 的配置信息
+ */
+@Configuration
+public class WebSocketConfig {
+
+    @Bean
+    public ServerEndpointExporter serverEndpointExporter() {
+
+        return new ServerEndpointExporter();
+    }
+}

+ 44 - 0
demo1/src/main/java/com/huimv/demo/eartag/controller/PliersDemoController.java

@@ -0,0 +1,44 @@
+package com.huimv.demo.eartag.controller;
+
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.huimv.demo.eartag.entity.PliersDemo;
+import com.huimv.demo.eartag.service.IPliersDemoService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.CrossOrigin;
+import org.springframework.web.bind.annotation.GetMapping;
+
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.List;
+
+/**
+ * <p>
+ *  前端控制器
+ * </p>
+ *
+ * @author author
+ * @since 2022-06-09
+ */
+@RestController
+@CrossOrigin
+public class PliersDemoController {
+        @Autowired
+        private IPliersDemoService pliersDemoService;
+
+
+//        @Scheduled(cron="10 * *  * * ? ")
+//        public void getPlierDemo() throws JsonProcessingException {
+//
+//          List<PliersDemo> id = pliersDemoService.list(new QueryWrapper<PliersDemo>().orderByDesc("id"));
+//            String resultJson= new ObjectMapper().writeValueAsString(id);
+//            WebSocket.sendMessage(resultJson);
+//        }
+
+    @GetMapping("/list")
+    public List<PliersDemo> getPlierDemo()   {
+
+       return pliersDemoService.list(new QueryWrapper<PliersDemo>().orderByDesc("id").last("limit 50"));
+
+    }
+}

+ 20 - 0
demo1/src/main/java/com/huimv/demo/eartag/controller/StationLibController.java

@@ -0,0 +1,20 @@
+package com.huimv.demo.eartag.controller;
+
+
+import org.springframework.web.bind.annotation.RequestMapping;
+
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * <p>
+ *  前端控制器
+ * </p>
+ *
+ * @author author
+ * @since 2022-06-11
+ */
+@RestController
+@RequestMapping("/station-lib")
+public class StationLibController {
+
+}

+ 30 - 0
demo1/src/main/java/com/huimv/demo/eartag/entity/ChatMsg.java

@@ -0,0 +1,30 @@
+package com.huimv.demo.eartag.entity;
+
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+
+import java.time.LocalDateTime;
+
+/**
+ * 消息
+ *
+ * @author liu xiang zheng
+ * @data 4.19 10:48
+ **/
+@Data
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain  = true)
+public class ChatMsg {
+
+    // 哪个人发的消息
+    private String from;
+    // 发到哪里去
+    private String to;
+    // 内容
+    private String content;
+    // 时间
+    private LocalDateTime date;
+    // 发送消息的昵称
+    private String formNickName;
+}

+ 45 - 0
demo1/src/main/java/com/huimv/demo/eartag/entity/PliersDemo.java

@@ -0,0 +1,45 @@
+package com.huimv.demo.eartag.entity;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import java.time.LocalDateTime;
+import java.io.Serializable;
+import java.util.Date;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+
+/**
+ * <p>
+ * 
+ * </p>
+ *
+ * @author author
+ * @since 2022-06-09
+ */
+@Data
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@TableName("pliers_demo")
+public class PliersDemo implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @TableId(value = "id", type = IdType.AUTO)
+    private Integer id;
+
+    private String earmark;
+
+    private String pliersId;
+    @JsonFormat(pattern = "MM-dd HH:mm:ss",timezone = "GMT+8")
+    private Date updateTime;
+    private Integer usegeTimes;
+    private String lat;
+    private String lon;
+    private String address;
+
+
+}

+ 43 - 0
demo1/src/main/java/com/huimv/demo/eartag/entity/StationLib.java

@@ -0,0 +1,43 @@
+package com.huimv.demo.eartag.entity;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import java.io.Serializable;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+
+/**
+ * <p>
+ * 
+ * </p>
+ *
+ * @author author
+ * @since 2022-06-11
+ */
+@Data
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@TableName("station_lib")
+public class StationLib implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @TableId(value = "id", type = IdType.AUTO)
+    private Integer id;
+
+    private String errcode;
+
+    private String lat;
+
+    private String lon;
+
+    private Integer radius;
+
+    private String address;
+    private String lac;
+    private String ci;
+
+
+}

+ 16 - 0
demo1/src/main/java/com/huimv/demo/eartag/mapper/PliersDemoMapper.java

@@ -0,0 +1,16 @@
+package com.huimv.demo.eartag.mapper;
+
+import com.huimv.demo.eartag.entity.PliersDemo;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * <p>
+ *  Mapper 接口
+ * </p>
+ *
+ * @author author
+ * @since 2022-06-09
+ */
+public interface PliersDemoMapper extends BaseMapper<PliersDemo> {
+
+}

+ 16 - 0
demo1/src/main/java/com/huimv/demo/eartag/mapper/StationLibMapper.java

@@ -0,0 +1,16 @@
+package com.huimv.demo.eartag.mapper;
+
+import com.huimv.demo.eartag.entity.StationLib;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * <p>
+ *  Mapper 接口
+ * </p>
+ *
+ * @author author
+ * @since 2022-06-11
+ */
+public interface StationLibMapper extends BaseMapper<StationLib> {
+
+}

+ 16 - 0
demo1/src/main/java/com/huimv/demo/eartag/service/IPliersDemoService.java

@@ -0,0 +1,16 @@
+package com.huimv.demo.eartag.service;
+
+import com.huimv.demo.eartag.entity.PliersDemo;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * <p>
+ *  服务类
+ * </p>
+ *
+ * @author author
+ * @since 2022-06-09
+ */
+public interface IPliersDemoService extends IService<PliersDemo> {
+
+}

+ 16 - 0
demo1/src/main/java/com/huimv/demo/eartag/service/IStationLibService.java

@@ -0,0 +1,16 @@
+package com.huimv.demo.eartag.service;
+
+import com.huimv.demo.eartag.entity.StationLib;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * <p>
+ *  服务类
+ * </p>
+ *
+ * @author author
+ * @since 2022-06-11
+ */
+public interface IStationLibService extends IService<StationLib> {
+
+}

+ 20 - 0
demo1/src/main/java/com/huimv/demo/eartag/service/impl/PliersDemoServiceImpl.java

@@ -0,0 +1,20 @@
+package com.huimv.demo.eartag.service.impl;
+
+import com.huimv.demo.eartag.entity.PliersDemo;
+import com.huimv.demo.eartag.mapper.PliersDemoMapper;
+import com.huimv.demo.eartag.service.IPliersDemoService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+
+/**
+ * <p>
+ *  服务实现类
+ * </p>
+ *
+ * @author author
+ * @since 2022-06-09
+ */
+@Service
+public class PliersDemoServiceImpl extends ServiceImpl<PliersDemoMapper, PliersDemo> implements IPliersDemoService {
+
+}

+ 20 - 0
demo1/src/main/java/com/huimv/demo/eartag/service/impl/StationLibServiceImpl.java

@@ -0,0 +1,20 @@
+package com.huimv.demo.eartag.service.impl;
+
+import com.huimv.demo.eartag.entity.StationLib;
+import com.huimv.demo.eartag.mapper.StationLibMapper;
+import com.huimv.demo.eartag.service.IStationLibService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+
+/**
+ * <p>
+ *  服务实现类
+ * </p>
+ *
+ * @author author
+ * @since 2022-06-11
+ */
+@Service
+public class StationLibServiceImpl extends ServiceImpl<StationLibMapper, StationLib> implements IStationLibService {
+
+}

+ 22 - 0
demo1/src/main/resources/application.yml

@@ -0,0 +1,22 @@
+server:
+  port: 8085
+spring:
+  datasource:
+    driver-class-name: com.mysql.jdbc.Driver
+    url: jdbc:mysql://115.238.57.190:3306/huimv_demo?serverTimezone=UTC
+    username: root
+    password: hm123456
+  jpa:
+    hibernate:
+      ddl-auto: update
+    show-sql: true
+  application:
+    name: test-thymelead
+  thymeleaf:
+    cache: false
+  main:
+    allow-bean-definition-overriding: true
+
+
+
+

+ 15 - 0
demo1/src/main/resources/mapper/StationLibMapper.xml

@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.huimv.demo.eartag.mapper.StationLibMapper">
+
+    <!-- 通用查询映射结果 -->
+    <resultMap id="BaseResultMap" type="com.huimv.demo.eartag.entity.StationLib">
+        <id column="id" property="id" />
+        <result column="errcode" property="errcode" />
+        <result column="lat" property="lat" />
+        <result column="lon" property="lon" />
+        <result column="radius" property="radius" />
+        <result column="address" property="address" />
+    </resultMap>
+
+</mapper>

+ 13 - 0
demo1/src/test/java/com/huimv/demo/DemoApplicationTests.java

@@ -0,0 +1,13 @@
+package com.huimv.demo;
+
+import org.junit.jupiter.api.Test;
+import org.springframework.boot.test.context.SpringBootTest;
+
+@SpringBootTest
+class DemoApplicationTests {
+
+    @Test
+    void contextLoads() {
+    }
+
+}