소스 검색

初始化提交

xucaiqin 6 달 전
커밋
046f9b0bd1
45개의 변경된 파일2338개의 추가작업 그리고 0개의 파일을 삭제
  1. 39 0
      .gitignore
  2. 278 0
      pom.xml
  3. 14 0
      src/main/java/com/sckw/robot/RobotApplication.java
  4. 12 0
      src/main/java/com/sckw/robot/config/MybatisPlusConfig.java
  5. 61 0
      src/main/java/com/sckw/robot/config/RabbitConfig.java
  6. 51 0
      src/main/java/com/sckw/robot/config/RedisConfig.java
  7. 141 0
      src/main/java/com/sckw/robot/controller/ApiController.java
  8. 23 0
      src/main/java/com/sckw/robot/controller/IndexController.java
  9. 39 0
      src/main/java/com/sckw/robot/exception/BusinessException.java
  10. 71 0
      src/main/java/com/sckw/robot/handler/GlobalExceptionHandler.java
  11. 14 0
      src/main/java/com/sckw/robot/pojo/constant/RabbitConstant.java
  12. 4 0
      src/main/java/com/sckw/robot/pojo/dto/CamCmdDto.java
  13. 20 0
      src/main/java/com/sckw/robot/pojo/dto/CamerasDto.java
  14. 4 0
      src/main/java/com/sckw/robot/pojo/dto/CaptureDto.java
  15. 77 0
      src/main/java/com/sckw/robot/pojo/dto/DiagDataDto.java
  16. 8 0
      src/main/java/com/sckw/robot/pojo/dto/ExecTaskNowDto.java
  17. 39 0
      src/main/java/com/sckw/robot/pojo/dto/LocDto.java
  18. 4 0
      src/main/java/com/sckw/robot/pojo/dto/MoveToNavPointDto.java
  19. 4 0
      src/main/java/com/sckw/robot/pojo/dto/MoveToPresetDto.java
  20. 19 0
      src/main/java/com/sckw/robot/pojo/dto/NavPointsDto.java
  21. 18 0
      src/main/java/com/sckw/robot/pojo/dto/PresetsDto.java
  22. 4 0
      src/main/java/com/sckw/robot/pojo/dto/PtzCmdDto.java
  23. 4 0
      src/main/java/com/sckw/robot/pojo/dto/PtzStopDto.java
  24. 4 0
      src/main/java/com/sckw/robot/pojo/dto/RechargeDto.java
  25. 8 0
      src/main/java/com/sckw/robot/pojo/dto/RobotCtrDto.java
  26. 17 0
      src/main/java/com/sckw/robot/pojo/dto/RobotStatusDetailDto.java
  27. 9 0
      src/main/java/com/sckw/robot/pojo/dto/SensorsDto.java
  28. 4 0
      src/main/java/com/sckw/robot/pojo/dto/SwitchModelDto.java
  29. 38 0
      src/main/java/com/sckw/robot/pojo/dto/TaskPlanListDto.java
  30. 9 0
      src/main/java/com/sckw/robot/pojo/dto/TaskReportDto.java
  31. 34 0
      src/main/java/com/sckw/robot/pojo/dto/TaskStepHistoryListDto.java
  32. 370 0
      src/main/java/com/sckw/robot/service/ApiService.java
  33. 16 0
      src/main/java/com/sckw/robot/service/BusinessService.java
  34. 30 0
      src/main/java/com/sckw/robot/service/QueueService.java
  35. 22 0
      src/main/java/com/sckw/robot/service/impl/BusinessServiceImpl.java
  36. 69 0
      src/main/java/com/sckw/robot/util/DateTimeUtil.java
  37. 18 0
      src/main/java/com/sckw/robot/util/IdUtil.java
  38. 159 0
      src/main/java/com/sckw/robot/util/MD5Util.java
  39. 212 0
      src/main/java/com/sckw/robot/util/OkHttpUtils.java
  40. 74 0
      src/main/java/com/sckw/robot/util/R.java
  41. 46 0
      src/main/resources/application-dev.yml
  42. 40 0
      src/main/resources/application-pro.yml
  43. 39 0
      src/main/resources/application-test.yml
  44. 19 0
      src/main/resources/application.yml
  45. 153 0
      src/main/resources/log4j2.xml

+ 39 - 0
.gitignore

@@ -0,0 +1,39 @@
+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/
+
+### logs
+logs
+
+### other
+.mvn

+ 278 - 0
pom.xml

@@ -0,0 +1,278 @@
+<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+
+    <groupId>com.sckw.robot</groupId>
+    <artifactId>orbital-robot</artifactId>
+    <version>1.0.0</version>
+
+    <properties>
+        <java.version>17</java.version>
+        <maven.compiler.source>17</maven.compiler.source>
+        <maven.compiler.target>17</maven.compiler.target>
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+        <spring-boot.version>3.4.7</spring-boot.version>
+        <maven-clean-plugin.version>3.2.0</maven-clean-plugin.version>
+        <start-class>com.sckw.robot.RobotApplication</start-class>
+        <maven-compiler-plugin.version>3.10.1</maven-compiler-plugin.version>
+        <maven-jar-plugin.version>3.3.0</maven-jar-plugin.version>
+        <maven-resources-plugin.version>3.3.0</maven-resources-plugin.version>
+        <maven-install-plugin.version>3.0.1</maven-install-plugin.version>
+        <maven-deploy-plugin.version>3.0.0</maven-deploy-plugin.version>
+    </properties>
+    <dependencyManagement>
+        <dependencies>
+            <dependency>
+                <groupId>org.springframework.boot</groupId>
+                <artifactId>spring-boot-dependencies</artifactId>
+                <version>${spring-boot.version}</version>
+                <type>pom</type>
+                <scope>import</scope>
+            </dependency>
+        </dependencies>
+    </dependencyManagement>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.projectlombok</groupId>
+            <artifactId>lombok</artifactId>
+            <optional>true</optional>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-validation</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter</artifactId>
+            <exclusions>
+                <exclusion>
+                    <groupId>org.springframework.boot</groupId>
+                    <artifactId>spring-boot-starter-logging</artifactId>
+                </exclusion>
+            </exclusions>
+        </dependency>
+        <!--log4j2日志框架-->
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-log4j2</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-web</artifactId>
+            <!--排除tomcat-->
+            <exclusions>
+                <exclusion>
+                    <artifactId>spring-boot-starter-tomcat</artifactId>
+                    <groupId>org.springframework.boot</groupId>
+                </exclusion>
+            </exclusions>
+        </dependency>
+        <!--undertow-->
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-undertow</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-jdbc</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.amqp</groupId>
+            <artifactId>spring-rabbit</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-test</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <!--commons-lang3-->
+        <dependency>
+            <groupId>org.apache.commons</groupId>
+            <artifactId>commons-lang3</artifactId>
+        </dependency>
+        <!--redis-->
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-data-redis</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.commons</groupId>
+            <artifactId>commons-pool2</artifactId>
+        </dependency>
+        <!--security-->
+        <dependency>
+            <groupId>org.springframework.security</groupId>
+            <artifactId>spring-security-crypto</artifactId>
+        </dependency>
+        <!--fastjson-->
+        <dependency>
+            <groupId>com.alibaba.fastjson2</groupId>
+            <artifactId>fastjson2</artifactId>
+            <version>2.0.57</version>
+        </dependency>
+        <!--druid-->
+        <dependency>
+            <groupId>com.alibaba</groupId>
+            <artifactId>druid-spring-boot-3-starter</artifactId>
+            <version>1.2.23</version>
+        </dependency>
+        <!--需要指定mysql连接器版本,内置版本过高(9.x.x),否则项目启动时,数据库连接池链接很久-->
+        <dependency>
+            <groupId>com.mysql</groupId>
+            <artifactId>mysql-connector-j</artifactId>
+            <version>8.2.0</version>
+        </dependency>
+        <!--mybatis-plus-->
+        <dependency>
+            <groupId>com.baomidou</groupId>
+            <artifactId>mybatis-plus-spring-boot3-starter</artifactId>
+            <version>3.5.12</version>
+        </dependency>
+        <dependency>
+            <groupId>com.squareup.okhttp3</groupId>
+            <artifactId>okhttp</artifactId>
+            <version>4.9.3</version>
+        </dependency>
+    </dependencies>
+
+    <repositories>
+        <repository>
+            <id>releases</id>
+            <name>Releases</name>
+            <url>https://oss.sonatype.org/content/repositories/releases/</url>
+        </repository>
+        <repository>
+            <id>snapshots</id>
+            <name>Snapshots</name>
+            <url>https://oss.sonatype.org/content/repositories/snapshots/</url>
+        </repository>
+    </repositories>
+
+    <build>
+        <pluginManagement>
+            <plugins>
+                <plugin>
+                    <groupId>org.apache.maven.plugins</groupId>
+                    <artifactId>maven-clean-plugin</artifactId>
+                    <version>${maven-clean-plugin.version}</version>
+                </plugin>
+                <plugin>
+                    <groupId>org.apache.maven.plugins</groupId>
+                    <artifactId>maven-compiler-plugin</artifactId>
+                    <version>${maven-compiler-plugin.version}</version>
+                </plugin>
+                <plugin>
+                    <groupId>org.apache.maven.plugins</groupId>
+                    <artifactId>maven-deploy-plugin</artifactId>
+                    <version>${maven-deploy-plugin.version}</version>
+                </plugin>
+                <plugin>
+                    <groupId>org.apache.maven.plugins</groupId>
+                    <artifactId>maven-install-plugin</artifactId>
+                    <version>${maven-install-plugin.version}</version>
+                </plugin>
+                <plugin>
+                    <groupId>org.apache.maven.plugins</groupId>
+                    <artifactId>maven-jar-plugin</artifactId>
+                    <version>${maven-jar-plugin.version}</version>
+                </plugin>
+                <plugin>
+                    <groupId>org.apache.maven.plugins</groupId>
+                    <artifactId>maven-resources-plugin</artifactId>
+                    <version>${maven-resources-plugin.version}</version>
+                    <configuration>
+                        <propertiesEncoding>${project.build.sourceEncoding}</propertiesEncoding>
+                        <delimiters>
+                            <delimiter>@</delimiter>
+                        </delimiters>
+                        <useDefaultDelimiters>false</useDefaultDelimiters>
+                    </configuration>
+                </plugin>
+                <plugin>
+                    <groupId>org.springframework.boot</groupId>
+                    <artifactId>spring-boot-maven-plugin</artifactId>
+                    <version>${spring-boot.version}</version>
+                </plugin>
+            </plugins>
+        </pluginManagement>
+        <plugins>
+            <plugin>
+                <groupId>org.springframework.boot</groupId>
+                <artifactId>spring-boot-maven-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <id>repackage</id>
+                        <goals>
+                            <goal>repackage</goal>
+                        </goals>
+                    </execution>
+                </executions>
+                <configuration>
+                    <excludes>
+                        <exclude>
+                            <groupId>org.projectlombok</groupId>
+                            <artifactId>lombok</artifactId>
+                        </exclude>
+                    </excludes>
+                    <mainClass>${start-class}</mainClass>
+                </configuration>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-compiler-plugin</artifactId>
+                <configuration>
+                    <source>17</source>
+                    <target>17</target>
+                </configuration>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-jar-plugin</artifactId>
+                <configuration>
+                    <archive>
+                        <manifest>
+                            <mainClass>${start-class}</mainClass>
+                            <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
+                        </manifest>
+                    </archive>
+                </configuration>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-resources-plugin</artifactId>
+                <configuration>
+                    <propertiesEncoding>${project.build.sourceEncoding}</propertiesEncoding>
+                    <delimiters>
+                        <delimiter>@</delimiter>
+                    </delimiters>
+                    <useDefaultDelimiters>false</useDefaultDelimiters>
+                </configuration>
+            </plugin>
+        </plugins>
+
+        <resources>
+            <resource>
+                <!-- xml放在java目录下-->
+                <directory>src/main/java</directory>
+                <includes>
+                    <include>**/*.xml</include>
+                </includes>
+            </resource>
+            <resource>
+                <directory>src/main/resources</directory>
+                <includes>
+                    <include>**/*.properties</include>
+                    <!-- 配置一下yml文件 -->
+                    <include>**/*.yml</include>
+                    <include>**/*.xml</include>
+                </includes>
+                <filtering>false</filtering>
+            </resource>
+        </resources>
+    </build>
+
+</project>

+ 14 - 0
src/main/java/com/sckw/robot/RobotApplication.java

@@ -0,0 +1,14 @@
+package com.sckw.robot;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.scheduling.annotation.EnableScheduling;
+
+@SpringBootApplication
+public class RobotApplication {
+
+    public static void main(String[] args) {
+        SpringApplication.run(RobotApplication.class, args);
+    }
+
+}

+ 12 - 0
src/main/java/com/sckw/robot/config/MybatisPlusConfig.java

@@ -0,0 +1,12 @@
+package com.sckw.robot.config;
+
+import org.springframework.context.annotation.Configuration;
+
+/**
+ * 分页配置
+ */
+@Configuration
+public class MybatisPlusConfig {
+
+
+}

+ 61 - 0
src/main/java/com/sckw/robot/config/RabbitConfig.java

@@ -0,0 +1,61 @@
+package com.sckw.robot.config;
+
+import com.sckw.robot.pojo.constant.RabbitConstant;
+import org.springframework.amqp.core.Binding;
+import org.springframework.amqp.core.BindingBuilder;
+import org.springframework.amqp.core.Queue;
+import org.springframework.amqp.core.TopicExchange;
+import org.springframework.amqp.rabbit.config.SimpleRabbitListenerContainerFactory;
+import org.springframework.amqp.rabbit.connection.ConnectionFactory;
+import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+/**
+ * @author xucaiqin
+ * @date 2024-04-01 19:46:34
+ */
+@Configuration
+public class RabbitConfig {
+    /**
+     * 数据处理交换机
+     *
+     * @return
+     */
+    @Bean
+    public TopicExchange dataExchange() {
+        return new TopicExchange(RabbitConstant.TOPIC_EXCHANGE_DATA, true, false);
+    }
+
+    @Bean
+    public SimpleRabbitListenerContainerFactory rabbitFactory(ConnectionFactory connectionFactory) {
+        SimpleRabbitListenerContainerFactory factory = new SimpleRabbitListenerContainerFactory();
+        factory.setConnectionFactory(connectionFactory);
+        //设置批量
+        factory.setBatchListener(true);
+        factory.setConsumerBatchEnabled(true);//设置BatchMessageListener生效
+        factory.setBatchSize(500);//设置监听器一次批量处理的消息数量
+        return factory;
+    }
+
+    @Bean
+    public Queue queue() {
+        return new Queue(RabbitConstant.QUEUE);
+    }
+
+
+    @Bean
+    public Binding binding(TopicExchange dataExchange, Queue queue) {
+        Binding binding = BindingBuilder
+                .bind(queue)
+                .to(dataExchange)
+                .with(RabbitConstant.ROUTER_KEY + queue.getName());
+        binding.addArgument(RabbitConstant.AUTO_DELETE, true);
+        return binding;
+    }
+    @Bean
+    public Jackson2JsonMessageConverter jackson2JsonMessageConverter() {
+        return new Jackson2JsonMessageConverter();
+    }
+
+}

+ 51 - 0
src/main/java/com/sckw/robot/config/RedisConfig.java

@@ -0,0 +1,51 @@
+package com.sckw.robot.config;
+
+import com.fasterxml.jackson.annotation.JsonAutoDetect;
+import com.fasterxml.jackson.annotation.PropertyAccessor;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.SerializationFeature;
+import com.fasterxml.jackson.databind.jsontype.impl.LaissezFaireSubTypeValidator;
+import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.data.redis.connection.RedisConnectionFactory;
+import org.springframework.data.redis.core.RedisTemplate;
+import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;
+import org.springframework.data.redis.serializer.StringRedisSerializer;
+
+/**
+ * @author xcq
+ * @date 2023-02-18 19:12:57
+ * @description
+ */
+@Configuration
+public class RedisConfig {
+
+    @Bean
+    public RedisTemplate<String, Object> redisTemplate(RedisConnectionFactory redisConnectionFactory) {
+        RedisTemplate<String, Object> redisTemplate = new RedisTemplate<>();
+        redisTemplate.setConnectionFactory(redisConnectionFactory);
+        redisTemplate.setKeySerializer(new StringRedisSerializer());
+        redisTemplate.setHashKeySerializer(new StringRedisSerializer());
+
+        redisTemplate.setValueSerializer(jackson2JsonRedisSerializer());
+        redisTemplate.setHashValueSerializer(jackson2JsonRedisSerializer());
+        redisTemplate.afterPropertiesSet();
+        return redisTemplate;
+    }
+
+    private Jackson2JsonRedisSerializer<Object> jackson2JsonRedisSerializer() {
+        // 使用Jackson2JsonRedisSerializer来序列化和反序列化redis的value值
+        ObjectMapper objectMapper = new ObjectMapper();
+        // 解决jackson2无法序列化LocalDateTime问题
+        objectMapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
+        objectMapper.registerModule(new JavaTimeModule());
+        // 指定要序列化的域,field,get和set,以及修饰符范围,ANY是都有包括private和public
+        objectMapper.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
+
+        // 指定序列化输入的类型,类必须是非final修饰的,final修饰的类,比如String,Integer等会跑出异常
+        objectMapper.activateDefaultTyping(LaissezFaireSubTypeValidator.instance, ObjectMapper.DefaultTyping.NON_FINAL);
+
+        return new Jackson2JsonRedisSerializer<>(objectMapper, Object.class);
+    }
+}

+ 141 - 0
src/main/java/com/sckw/robot/controller/ApiController.java

@@ -0,0 +1,141 @@
+package com.sckw.robot.controller;
+
+import com.sckw.robot.pojo.dto.DiagDataDto;
+import com.sckw.robot.pojo.dto.RobotStatusDetailDto;
+import com.sckw.robot.pojo.dto.SensorsDto;
+import com.sckw.robot.pojo.dto.TaskPlanListDto;
+import com.sckw.robot.service.ApiService;
+import com.sckw.robot.service.BusinessService;
+import com.sckw.robot.util.R;
+import jakarta.annotation.Resource;
+import org.springframework.web.bind.annotation.*;
+
+/**
+ * api接口
+ *
+ * @author xucaiqin
+ */
+@RestController
+@RequestMapping("/api")
+public class ApiController {
+    @Resource
+    private BusinessService businessService;
+    @Resource
+    private ApiService apiService;
+
+    /**
+     * 校验token,轨道机器人三方调用
+     *
+     * @param token
+     * @return
+     */
+    @GetMapping("/checkToken")
+    public Boolean checkToken(@RequestParam("token") String token) {
+        return businessService.checkToken(token);
+    }
+
+    @GetMapping("/query/diag")
+    public R<DiagDataDto> getDiagData(@RequestParam("robotId") String robotId) {
+        return apiService.getDiagData(robotId);
+    }
+
+    @GetMapping("/robot/sensors/{robotId}")
+    public R<SensorsDto> getSensors(@PathVariable String robotId) {
+        return apiService.getSensors(robotId);
+    }
+
+    @GetMapping("/robot/status/{robotId}")
+    public R<RobotStatusDetailDto> getRobotStatusDetail(@PathVariable String robotId) {
+        return apiService.getRobotStatusDetail(robotId);
+    }
+
+    @GetMapping("/task/plan/list")
+    public R<TaskPlanListDto> getTaskPlanList(@RequestParam String deviceId, @RequestParam String deviceType, @RequestParam(required = false) Integer pageNum, @RequestParam(required = false) Integer pageSize) {
+        return apiService.getTaskPlanList(deviceId, deviceType, pageNum, pageSize);
+    }
+//
+//    @PostMapping("/task/plan/execNow")
+//    public R<ExecTaskNowDto> execTaskNow(@RequestBody ExecTaskNowDto dto) {
+//        return apiService.execTaskNow(dto.getTaskId());
+//    }
+//
+//    @GetMapping("/task/plan/report/{id}")
+//    public R<TaskReportDto> getTaskReport(@PathVariable String id) {
+//        return apiService.getTaskReport(id);
+//    }
+//
+//    @GetMapping("/task/step/history/list")
+//    public R<TaskStepHistoryListDto> getTaskStepHistoryList(@RequestParam String taskPlanHistoryId, @RequestParam(required = false) Integer pageNum, @RequestParam(required = false) Integer pageSize) {
+//        return apiService.getTaskStepHistoryList(taskPlanHistoryId, pageNum, pageSize);
+//    }
+//
+//    @PostMapping("/robot/recharge")
+//    public R<RechargeDto> recharge(@RequestBody RechargeDto dto) {
+//        return apiService.recharge(dto.getRobotId());
+//    }
+//
+//    @PostMapping("/robot/model_switch")
+//    public R<SwitchModelDto> switchModel(@RequestBody SwitchModelDto dto) {
+//        return apiService.switchModel(dto.getRobotId(), dto.getMode());
+//    }
+//
+//    @GetMapping("/robot/ctrl/getRobotCtr/{robotId}")
+//    public R<RobotCtrDto> getRobotCtr(@PathVariable String robotId) {
+//        return apiService.getRobotCtr(robotId);
+//    }
+//
+//    @PostMapping("/robot/ctrl/setRobotCtr")
+//    public R<RobotCtrDto> setRobotCtr(@RequestBody RobotCtrDto dto) {
+//        return apiService.setRobotCtr(dto.getRobotId());
+//    }
+//
+//    @PostMapping("/robot/ctrl/delRobotCtr")
+//    public R<RobotCtrDto> delRobotCtr(@RequestBody RobotCtrDto dto) {
+//        return apiService.delRobotCtr(dto.getRobotId());
+//    }
+//
+//    @GetMapping("/robot/nav_points")
+//    public R<NavPointsDto> getNavPoints(@RequestParam String robotId, @RequestParam(required = false) String presetId) {
+//        return apiService.getNavPoints(robotId, presetId);
+//    }
+//
+//    @GetMapping("/robot/presets")
+//    public R<PresetsDto> getPresets(@RequestParam String robotId, @RequestParam(required = false) String navPointId) {
+//        return apiService.getPresets(robotId, navPointId);
+//    }
+//
+//    @PostMapping("/robot/move_to_nav_point")
+//    public R<MoveToNavPointDto> moveToNavPoint(@RequestBody MoveToNavPointDto dto) {
+//        return apiService.moveToNavPoint(dto.getRobotId(), dto.getNavPoint(), dto.getSpeed());
+//    }
+//
+//    @PostMapping("/robot/move_to_preset")
+//    public R<MoveToPresetDto> moveToPreset(@RequestBody MoveToPresetDto dto) {
+//        return apiService.moveToPreset(dto.getRobotId(), dto.getPresetName(), dto.getSpeed());
+//    }
+//
+//    @PostMapping("/robot/ptz_cmd")
+//    public R<PtzCmdDto> ptzCmd(@RequestBody PtzCmdDto dto) {
+//        return apiService.ptzCmd(dto.getRobotId(), dto.getCommand(), dto.getSpeed(), dto.getPtzName());
+//    }
+//
+//    @PostMapping("/robot/ptz_stop")
+//    public R<PtzStopDto> ptzStop(@RequestBody PtzStopDto dto) {
+//        return apiService.ptzStop(dto.getRobotId());
+//    }
+//
+//    @PostMapping("/robot/cam_cmd")
+//    public R<CamCmdDto> camCmd(@RequestBody CamCmdDto dto) {
+//        return apiService.camCmd(dto.getRobotId(), dto.getCameraId(), dto.getCommand(), dto.getSpeed());
+//    }
+//
+//    @PostMapping("/robot/capture")
+//    public R<CaptureDto> capture(@RequestBody CaptureDto dto) {
+//        return apiService.capture(dto.getRobotId(), dto.getCameraId());
+//    }
+//
+//    @GetMapping("/robot/cameras/{robotId}")
+//    public R<CamerasDto> getCameras(@PathVariable String robotId) {
+//        return apiService.getCameras(robotId);
+//    }
+}

+ 23 - 0
src/main/java/com/sckw/robot/controller/IndexController.java

@@ -0,0 +1,23 @@
+package com.sckw.robot.controller;
+
+import com.sckw.robot.util.R;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.time.LocalDateTime;
+
+/**
+ * @Author xucaiqin
+ * @date 2023-03-27 15:05:31
+ */
+@RestController
+@RequestMapping("/index")
+public class IndexController {
+
+    @GetMapping("")
+    public R<Object> index() {
+        return R.ok(LocalDateTime.now());
+    }
+
+}

+ 39 - 0
src/main/java/com/sckw/robot/exception/BusinessException.java

@@ -0,0 +1,39 @@
+package com.sckw.robot.exception;
+
+/**
+ * 业务异常
+ *
+ * @author xcq
+ * @date 2023-02-22 13:54:05
+ **/
+public class BusinessException extends RuntimeException {
+    private int code;
+    private String message;
+
+    public int getCode() {
+        return code;
+    }
+
+    public void setCode(int code) {
+        this.code = code;
+    }
+
+    @Override
+    public String getMessage() {
+        return message;
+    }
+
+    public void setMessage(String message) {
+        this.message = message;
+    }
+
+    public BusinessException() {
+        this.code = 500;
+    }
+
+    public BusinessException(String message) {
+        super(message);
+        this.message = message;
+        this.code = 500;
+    }
+}

+ 71 - 0
src/main/java/com/sckw/robot/handler/GlobalExceptionHandler.java

@@ -0,0 +1,71 @@
+package com.sckw.robot.handler;
+
+
+import com.sckw.robot.exception.BusinessException;
+import com.sckw.robot.util.R;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.http.HttpStatus;
+import org.springframework.validation.BindException;
+import org.springframework.validation.BindingResult;
+import org.springframework.validation.FieldError;
+import org.springframework.web.bind.annotation.ExceptionHandler;
+import org.springframework.web.bind.annotation.ResponseStatus;
+import org.springframework.web.bind.annotation.RestControllerAdvice;
+
+/**
+ * API网关层,统一异常处理
+ *
+ * @author xcq
+ * @date 2023-02-17 16:07:15
+ * @description
+ **/
+@Slf4j
+@RestControllerAdvice
+public class GlobalExceptionHandler {
+    /**
+     * 全局异常处理 500
+     *
+     * @param ex
+     * @return
+     */
+    @ResponseStatus(code = HttpStatus.INTERNAL_SERVER_ERROR)
+    @ExceptionHandler(value = Exception.class)
+    public R<String> exceptionHandler(Exception ex) {
+        ex.printStackTrace();
+        log.error("全局异常处理:{}", ex.getMessage());
+        return R.failed("系统异常,请稍后重试!", ex.getMessage());
+    }
+
+    /**
+     * 业务异常处理 200
+     *
+     * @param ex
+     * @return
+     */
+    @ResponseStatus(code = HttpStatus.OK)
+    @ExceptionHandler(value = BusinessException.class)
+    public R<String> businessHandler(Exception ex) {
+        log.error("业务异常处理:{}", ex.getMessage());
+        return R.failed(ex.getMessage());
+    }
+
+    /**
+     * 参数异常 400
+     *
+     * @param ex
+     * @return
+     */
+    @ResponseStatus(code = HttpStatus.BAD_REQUEST)
+    @ExceptionHandler(value = BindException.class)
+    public R<Object> bindHandler(BindException ex) {
+        log.error("BindException :{}", ex.getMessage());
+        BindingResult bindingResult = ex.getBindingResult();
+        StringBuilder msg = new StringBuilder();
+        for (FieldError fieldError : bindingResult.getFieldErrors()) {
+            msg.append(fieldError.getDefaultMessage());
+        }
+        return R.failed(msg.toString());
+    }
+
+
+}

+ 14 - 0
src/main/java/com/sckw/robot/pojo/constant/RabbitConstant.java

@@ -0,0 +1,14 @@
+package com.sckw.robot.pojo.constant;
+
+/**
+ * @author xucaiqin
+ * @date 2024-04-01 19:50:29
+ */
+public class RabbitConstant {
+    public static final String AUTO_DELETE = "x-auto-delete";
+
+    public static final String TOPIC_EXCHANGE_DATA = "amq.topic";
+    public static final String ROUTER_KEY = ".robot.NOTICE.STATUS.*";
+    public static final String QUEUE = "queue";
+
+}

+ 4 - 0
src/main/java/com/sckw/robot/pojo/dto/CamCmdDto.java

@@ -0,0 +1,4 @@
+package com.sckw.robot.pojo.dto;
+
+public class CamCmdDto {
+} 

+ 20 - 0
src/main/java/com/sckw/robot/pojo/dto/CamerasDto.java

@@ -0,0 +1,20 @@
+package com.sckw.robot.pojo.dto;
+
+import lombok.Data;
+import java.util.List;
+
+@Data
+public class CamerasDto {
+    private List<Camera> data;
+
+    @Data
+    public static class Camera {
+        private String id;
+        private String robotId;
+        private String name;
+        private String token;
+        private String rtspUrl;
+        private String displayName;
+        private String type;
+    }
+} 

+ 4 - 0
src/main/java/com/sckw/robot/pojo/dto/CaptureDto.java

@@ -0,0 +1,4 @@
+package com.sckw.robot.pojo.dto;
+
+public class CaptureDto {
+} 

+ 77 - 0
src/main/java/com/sckw/robot/pojo/dto/DiagDataDto.java

@@ -0,0 +1,77 @@
+package com.sckw.robot.pojo.dto;
+
+import lombok.Data;
+
+@Data
+public class DiagDataDto {
+    private DevConnStates devConnStates;
+    private FaultStates faultStates;
+    private MotorErrcode motorErrcode;
+    private Vulnerable vulnerable;
+
+    @Data
+    public static class DevConnStates {
+        private Cam cam;
+        private Hardware hardware;
+        private Motor motor;
+        private Sensor sensor;
+        private Ultrasound ultrasound;
+
+        @Data
+        public static class Cam {
+            private int ircam;
+            private int vlcam;
+        }
+        @Data
+        public static class Hardware {
+            private int encoder;
+            private int mainboard;
+            private int pdd_com;
+            private int ptz_screen;
+        }
+        @Data
+        public static class Motor {
+            private int hptz;
+            private int ircam;
+            private int lift;
+            private int travel;
+            private int vlcam;
+        }
+        @Data
+        public static class Sensor {
+            private int lsl;
+            private int o2;
+            private int rfid;
+            private int sf6;
+            private int temp_humi;
+            private int toxic;
+        }
+        @Data
+        public static class Ultrasound {
+            private int back;
+            private int down;
+            private int front;
+        }
+    }
+
+    @Data
+    public static class FaultStates {
+        private int limit_fault;
+        private int winding_reverse;
+    }
+
+    @Data
+    public static class MotorErrcode {
+        private int hptz;
+        private int ircam;
+        private int lift;
+        private int travel;
+        private int vlcam;
+    }
+
+    @Data
+    public static class Vulnerable {
+        private int lift_count;
+        private int max_lift_count;
+    }
+} 

+ 8 - 0
src/main/java/com/sckw/robot/pojo/dto/ExecTaskNowDto.java

@@ -0,0 +1,8 @@
+package com.sckw.robot.pojo.dto;
+
+import lombok.Data;
+
+@Data
+public class ExecTaskNowDto {
+    private String taskHistoryAllId;
+} 

+ 39 - 0
src/main/java/com/sckw/robot/pojo/dto/LocDto.java

@@ -0,0 +1,39 @@
+package com.sckw.robot.pojo.dto;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import lombok.Data;
+import lombok.Getter;
+import lombok.Setter;
+
+import java.util.List;
+
+/**
+ * @author xucaiqin
+ * @date 2025-07-08 16:00:00
+ */
+@Getter
+@Setter
+public class LocDto {
+    private Body body;
+
+    @Data
+    public static class Body {
+        @JsonProperty("part_status")
+        private List<PartStatus> partStatus;
+    }
+
+    @Data
+    public static class PartStatus {
+        private String name;
+        private Status status;
+    }
+
+    @Data
+    public static class Status {
+        @JsonProperty("pos_x")
+        private int posX;
+        @JsonProperty("pos_y")
+        private int posY;
+        private int theta;
+    }
+}

+ 4 - 0
src/main/java/com/sckw/robot/pojo/dto/MoveToNavPointDto.java

@@ -0,0 +1,4 @@
+package com.sckw.robot.pojo.dto;
+
+public class MoveToNavPointDto {
+} 

+ 4 - 0
src/main/java/com/sckw/robot/pojo/dto/MoveToPresetDto.java

@@ -0,0 +1,4 @@
+package com.sckw.robot.pojo.dto;
+
+public class MoveToPresetDto {
+} 

+ 19 - 0
src/main/java/com/sckw/robot/pojo/dto/NavPointsDto.java

@@ -0,0 +1,19 @@
+package com.sckw.robot.pojo.dto;
+
+import lombok.Data;
+import java.util.List;
+
+@Data
+public class NavPointsDto {
+    private List<NavPoint> data;
+
+    @Data
+    public static class NavPoint {
+        private String id;
+        private String robotId;
+        private String mapId;
+        private String pointName;
+        private String displayName;
+        private Integer seqNum;
+    }
+} 

+ 18 - 0
src/main/java/com/sckw/robot/pojo/dto/PresetsDto.java

@@ -0,0 +1,18 @@
+package com.sckw.robot.pojo.dto;
+
+import lombok.Data;
+import java.util.List;
+
+@Data
+public class PresetsDto {
+    private List<Preset> data;
+
+    @Data
+    public static class Preset {
+        private String id;
+        private String robotId;
+        private String preset;
+        private String displayName;
+        private Integer seqNum;
+    }
+} 

+ 4 - 0
src/main/java/com/sckw/robot/pojo/dto/PtzCmdDto.java

@@ -0,0 +1,4 @@
+package com.sckw.robot.pojo.dto;
+
+public class PtzCmdDto {
+} 

+ 4 - 0
src/main/java/com/sckw/robot/pojo/dto/PtzStopDto.java

@@ -0,0 +1,4 @@
+package com.sckw.robot.pojo.dto;
+
+public class PtzStopDto {
+} 

+ 4 - 0
src/main/java/com/sckw/robot/pojo/dto/RechargeDto.java

@@ -0,0 +1,4 @@
+package com.sckw.robot.pojo.dto;
+
+public class RechargeDto {
+} 

+ 8 - 0
src/main/java/com/sckw/robot/pojo/dto/RobotCtrDto.java

@@ -0,0 +1,8 @@
+package com.sckw.robot.pojo.dto;
+
+import lombok.Data;
+
+@Data
+public class RobotCtrDto {
+    private Boolean robotCtrFlag;
+} 

+ 17 - 0
src/main/java/com/sckw/robot/pojo/dto/RobotStatusDetailDto.java

@@ -0,0 +1,17 @@
+package com.sckw.robot.pojo.dto;
+
+import lombok.Data;
+import java.util.List;
+
+@Data
+public class RobotStatusDetailDto {
+    private List<PartStatus> partStatus;
+
+    @Data
+    public static class PartStatus {
+        private String name;
+        private Double posX;
+        private Double poxY;
+        private Double theta;
+    }
+} 

+ 9 - 0
src/main/java/com/sckw/robot/pojo/dto/SensorsDto.java

@@ -0,0 +1,9 @@
+package com.sckw.robot.pojo.dto;
+
+import lombok.Data;
+
+@Data
+public class SensorsDto {
+    private String sensor;
+    private Double value;
+} 

+ 4 - 0
src/main/java/com/sckw/robot/pojo/dto/SwitchModelDto.java

@@ -0,0 +1,4 @@
+package com.sckw.robot.pojo.dto;
+
+public class SwitchModelDto {
+} 

+ 38 - 0
src/main/java/com/sckw/robot/pojo/dto/TaskPlanListDto.java

@@ -0,0 +1,38 @@
+package com.sckw.robot.pojo.dto;
+
+import lombok.Data;
+import java.util.List;
+
+@Data
+public class TaskPlanListDto {
+    private Integer total;
+    private List<Row> rows;
+
+    @Data
+    public static class Row {
+        private String id;
+        private String name;
+        private String beforeAction;
+        private String afterAction;
+        private String taskType;
+        private String inspectionType;
+        private String tpl;
+        private String tplId;
+        private String fixDate;
+        private String startTime;
+        private String endTime;
+        private String cycleMonth;
+        private String cycleWeek;
+        private Integer intervalNumber;
+        private String intervalExecuteTime;
+        private String status;
+        private String recentExecuteTime;
+        private String targetPoints;
+        private String invalidStartTime;
+        private String invalidEndTime;
+        private String taskValidStatus;
+        private String executeTime;
+        private String lastExecuteTime;
+        private String stepChangeStatus;
+    }
+} 

+ 9 - 0
src/main/java/com/sckw/robot/pojo/dto/TaskReportDto.java

@@ -0,0 +1,9 @@
+package com.sckw.robot.pojo.dto;
+
+import lombok.Data;
+
+@Data
+public class TaskReportDto {
+    private String reportFile;
+    private String status;
+} 

+ 34 - 0
src/main/java/com/sckw/robot/pojo/dto/TaskStepHistoryListDto.java

@@ -0,0 +1,34 @@
+package com.sckw.robot.pojo.dto;
+
+import lombok.Data;
+import java.util.List;
+
+@Data
+public class TaskStepHistoryListDto {
+    private Integer total;
+    private List<Row> rows;
+    private Integer code;
+    private String msg;
+
+    @Data
+    public static class Row {
+        private String id;
+        private String pointName;
+        private String checkType;
+        private String checkValue;
+        private String unit;
+        private String createTime;
+        private String alarmLevel;
+        private String auditResult;
+        private String auditStatus;
+        private String thermalPicUrl;
+        private String recognizeImagePicUrl;
+        private String videoUrl;
+        private String audioUrl;
+        private String originValue;
+        private String translateCheckValue;
+        private String pointId;
+        private String correctValue;
+        private Integer status;
+    }
+} 

+ 370 - 0
src/main/java/com/sckw/robot/service/ApiService.java

@@ -0,0 +1,370 @@
+package com.sckw.robot.service;
+
+import com.alibaba.fastjson2.JSONObject;
+import com.alibaba.fastjson2.TypeReference;
+import com.sckw.robot.pojo.dto.*;
+import com.sckw.robot.util.IdUtil;
+import com.sckw.robot.util.OkHttpUtils;
+import com.sckw.robot.util.R;
+import jakarta.annotation.Resource;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.data.redis.core.RedisTemplate;
+import org.springframework.stereotype.Service;
+
+import java.util.concurrent.TimeUnit;
+
+/**
+ * @author xucaiqin
+ * @date 2025-07-08 14:12:45
+ */
+@Service
+public class ApiService {
+    // ================== 机器人相关API ==================
+    private static final String BASE_URL = "http://your-robot-api-base-url"; // TODO: 替换为实际baseUrl,可通过配置注入
+    @Resource
+    private RedisTemplate<String, Object> redisTemplate;
+
+    /**
+     * 获取thirdToken,优先查缓存,无则生成并写入缓存
+     */
+    private String getToken() {
+        String cacheKey = "thirdToken";
+        String cached = (String) redisTemplate.opsForValue().get(cacheKey);
+        if (StringUtils.isNotBlank(cached)) {
+            return cached;
+        }
+        String token = IdUtil.UUID();
+        redisTemplate.opsForValue().set(cacheKey, token, 24, TimeUnit.HOURS);
+        return token;
+    }
+
+    /**
+     * 获取自检数据
+     */
+    public R<DiagDataDto> getDiagData(String robotId) {
+        String url = BASE_URL + "/robot/ctrl/" + robotId + "/diag";
+        String result = OkHttpUtils.builder()
+                .url(url)
+                .addHeader("content-type", "application/json")
+                .addHeader("thirdToken", getToken())
+                .post(true)
+                .sync();
+        return JSONObject.parseObject(result, new TypeReference<>() {
+        });
+    }
+
+    /**
+     * 获取传感器数据
+     */
+    public R<SensorsDto> getSensors(String robotId) {
+        String url = BASE_URL + "/robot/" + robotId + "/sensors";
+        String result = OkHttpUtils.builder()
+                .url(url)
+                .addHeader("thirdToken", getToken())
+                .get()
+                .sync();
+        return JSONObject.parseObject(result, new TypeReference<>() {
+        });
+    }
+
+    /**
+     * 获取机器人实时状态(包含位置数据)
+     */
+    public R<RobotStatusDetailDto> getRobotStatusDetail(String robotId) {
+        String url = BASE_URL + "/robot/" + robotId + "/getRobotStatusDetail";
+        String result = OkHttpUtils.builder()
+                .url(url)
+                .addHeader("thirdToken", getToken())
+                .get()
+                .sync();
+        return JSONObject.parseObject(result, new TypeReference<>() {
+        });
+    }
+
+    /**
+     * 任务计划列表
+     */
+    public R<TaskPlanListDto> getTaskPlanList(String deviceId, String deviceType, Integer pageNum, Integer pageSize) {
+        String url = BASE_URL + "/task/plan/list";
+        OkHttpUtils builder = OkHttpUtils.builder()
+                .url(url)
+                .addHeader("thirdToken", getToken())
+                .addPara("deviceId", deviceId)
+                .addPara("deviceType", deviceType);
+        if (pageNum != null) builder.addPara("pageNum", String.valueOf(pageNum));
+        if (pageSize != null) builder.addPara("pageSize", String.valueOf(pageSize));
+        String result = builder.get().sync();
+        return JSONObject.parseObject(result, new TypeReference<>() {
+        });
+    }
+
+    /**
+     * 任务执行
+     */
+    public R<ExecTaskNowDto> execTaskNow(String taskId) {
+        String url = BASE_URL + "/task/plan/execNow/" + taskId;
+        String result = OkHttpUtils.builder()
+                .url(url)
+                .addHeader("content-type", "application/json")
+                .addHeader("thirdToken", getToken())
+                .post(true)
+                .sync();
+        return JSONObject.parseObject(result, new TypeReference<>() {
+        });
+    }
+
+    /**
+     * 获取任务报告
+     */
+    public R<TaskReportDto> getTaskReport(String id) {
+        String url = BASE_URL + "/task/plan/history/" + id;
+        String result = OkHttpUtils.builder()
+                .url(url)
+                .addHeader("thirdToken", getToken())
+                .get()
+                .sync();
+        return JSONObject.parseObject(result, new TypeReference<>() {
+        });
+    }
+
+    /**
+     * 获取任务结果列表
+     */
+    public R<TaskStepHistoryListDto> getTaskStepHistoryList(String taskPlanHistoryId, Integer pageNum, Integer pageSize) {
+        String url = BASE_URL + "/task/step/history/list";
+        OkHttpUtils builder = OkHttpUtils.builder()
+                .url(url)
+                .addHeader("thirdToken", getToken())
+                .addPara("taskPlanHistoryId", taskPlanHistoryId);
+        if (pageNum != null) builder.addPara("pageNum", String.valueOf(pageNum));
+        if (pageSize != null) builder.addPara("pageSize", String.valueOf(pageSize));
+        String result = builder.get().sync();
+        return JSONObject.parseObject(result, new TypeReference<>() {
+        });
+    }
+
+    /**
+     * 一键回充
+     */
+    public R<RechargeDto> recharge(String robotId) {
+        String url = BASE_URL + "/robot/ctrl/" + robotId + "/recharge";
+        String result = OkHttpUtils.builder()
+                .url(url)
+                .addHeader("thirdToken", getToken())
+                .get()
+                .sync();
+        return JSONObject.parseObject(result, new TypeReference<>() {
+        });
+    }
+
+    /**
+     * 机器人模式切换
+     */
+    public R<SwitchModelDto> switchModel(String robotId, String mode) {
+        String url = BASE_URL + "/robot/ctrl/" + robotId + "/model_switch";
+        JSONObject body = new JSONObject();
+        body.put("mode", mode);
+        String result = OkHttpUtils.builder()
+                .url(url)
+                .addHeader("thirdToken", getToken())
+                .addBodyJsonStr(body.toJSONString())
+                .post(true)
+                .sync();
+        return JSONObject.parseObject(result, new TypeReference<>() {
+        });
+    }
+
+    /**
+     * 查询是否有控制权
+     */
+    public R<RobotCtrDto> getRobotCtr(String robotId) {
+        String url = BASE_URL + "/robot/ctrl/" + robotId + "/getRobotCtr";
+        String result = OkHttpUtils.builder()
+                .url(url)
+                .addHeader("thirdToken", getToken())
+                .post(true)
+                .sync();
+        return JSONObject.parseObject(result, new TypeReference<>() {
+        });
+    }
+
+    /**
+     * 获取控制权
+     */
+    public R<RobotCtrDto> setRobotCtr(String robotId) {
+        String url = BASE_URL + "/robot/ctrl/" + robotId + "/setRobotCtr";
+        String result = OkHttpUtils.builder()
+                .url(url)
+                .addHeader("thirdToken", getToken())
+                .post(true)
+                .sync();
+        return JSONObject.parseObject(result, new TypeReference<>() {
+        });
+    }
+
+    /**
+     * 释放控制权
+     */
+    public R<RobotCtrDto> delRobotCtr(String robotId) {
+        String url = BASE_URL + "/robot/ctrl/" + robotId + "/delRobotCtr";
+        String result = OkHttpUtils.builder()
+                .url(url)
+                .addHeader("thirdToken", getToken())
+                .post(true)
+                .sync();
+        return JSONObject.parseObject(result, new TypeReference<>() {
+        });
+    }
+
+    /**
+     * 机器人导航点列表
+     */
+    public R<NavPointsDto> getNavPoints(String robotId,  String presetId) {
+        String url = BASE_URL + "/robot/" + robotId + "/nav_points";
+        OkHttpUtils builder = OkHttpUtils.builder()
+                .url(url)
+                .addHeader("thirdToken", getToken());
+        if (presetId != null) builder.addPara("presetId", presetId);
+        String result = builder.get().sync();
+        return JSONObject.parseObject(result, new TypeReference<>() {
+        });
+    }
+
+    /**
+     * 机器人预置位列表
+     */
+    public R<PresetsDto> getPresets(String robotId,  String navPointId) {
+        String url = BASE_URL + "/robot/" + robotId + "/presets";
+        OkHttpUtils builder = OkHttpUtils.builder()
+                .url(url)
+                .addHeader("thirdToken", getToken());
+        if (navPointId != null) builder.addPara("navPointId", navPointId);
+        String result = builder.get().sync();
+        return JSONObject.parseObject(result, new TypeReference<>() {
+        });
+    }
+
+    /**
+     * 移动到导航点
+     */
+    public R<MoveToNavPointDto> moveToNavPoint(String robotId, String navPoint, int speed) {
+        String url = BASE_URL + "/robot/ctrl/" + robotId + "/move_to";
+        JSONObject body = new JSONObject();
+        body.put("nav_point", navPoint);
+        body.put("speed", speed);
+        String result = OkHttpUtils.builder()
+                .url(url)
+                .addHeader("content-type", "application/json")
+                .addHeader("thirdToken", getToken())
+                .addBodyJsonStr(body.toJSONString())
+                .post(true)
+                .sync();
+        return JSONObject.parseObject(result, new TypeReference<>() {
+        });
+    }
+
+    /**
+     * 移动到预置位
+     */
+    public R<MoveToPresetDto> moveToPreset(String robotId, String presetName, int speed) {
+        String url = BASE_URL + "/robot/ctrl/" + robotId + "/moveToPreset";
+        JSONObject body = new JSONObject();
+        body.put("preset_name", presetName);
+        body.put("speed", speed);
+        String result = OkHttpUtils.builder()
+                .url(url)
+                .addHeader("content-type", "application/json")
+                .addHeader("thirdToken", getToken())
+                .addBodyJsonStr(body.toJSONString())
+                .post(true)
+                .sync();
+        return JSONObject.parseObject(result, new TypeReference<>() {
+        });
+    }
+
+    /**
+     * 机器人云台控制
+     */
+    public R<PtzCmdDto> ptzCmd(String robotId, String command, int speed, String ptzName) {
+        String url = BASE_URL + "/robot/ctrl/" + robotId + "/cmd/ptz";
+        JSONObject body = new JSONObject();
+        body.put("command", command);
+        body.put("speed", speed);
+        if (ptzName != null) body.put("ptzName", ptzName);
+        String result = OkHttpUtils.builder()
+                .url(url)
+                .addHeader("content-type", "application/json")
+                .addHeader("thirdToken", getToken())
+                .addBodyJsonStr(body.toJSONString())
+                .post(true)
+                .sync();
+        return JSONObject.parseObject(result, new TypeReference<>() {
+        });
+    }
+
+    /**
+     * 停止云台运动
+     */
+    public R<PtzStopDto> ptzStop(String robotId) {
+        String url = BASE_URL + "/robot/ctrl/" + robotId + "/ptzStop";
+        String result = OkHttpUtils.builder()
+                .url(url)
+                .addHeader("content-type", "application/json")
+                .addHeader("thirdToken", getToken())
+                .post(true)
+                .sync();
+        return JSONObject.parseObject(result, new TypeReference<>() {
+        });
+    }
+
+    /**
+     * 相机控制
+     */
+    public R<CamCmdDto> camCmd(String robotId, String cameraId, String command, int speed) {
+        String url = BASE_URL + "/robot/ctrl/" + robotId + "/cmd/cam";
+        JSONObject control = new JSONObject();
+        control.put("speed", speed);
+        JSONObject body = new JSONObject();
+        body.put("cameraId", cameraId);
+        body.put("command", command);
+        body.put("control", control);
+        String result = OkHttpUtils.builder()
+                .url(url)
+                .addHeader("content-type", "application/json")
+                .addHeader("thirdToken", getToken())
+                .addBodyJsonStr(body.toJSONString())
+                .post(true)
+                .sync();
+        return JSONObject.parseObject(result, new TypeReference<>() {
+        });
+    }
+
+    /**
+     * 拍照
+     */
+    public R<CaptureDto> capture(String robotId, String cameraId) {
+        String url = BASE_URL + "/robot/ctrl/" + robotId + "/capture?cameraId=" + cameraId;
+        String result = OkHttpUtils.builder()
+                .url(url)
+                .addHeader("content-type", "application/json")
+                .addHeader("thirdToken", getToken())
+                .post(true)
+                .sync();
+        return JSONObject.parseObject(result, new TypeReference<>() {
+        });
+    }
+
+    /**
+     * 获取机器人相机列表
+     */
+    public R<CamerasDto> getCameras(String robotId) {
+        String url = BASE_URL + "/robot/" + robotId + "/cameras";
+        String result = OkHttpUtils.builder()
+                .url(url)
+                .addHeader("thirdToken", getToken())
+                .get()
+                .sync();
+        return JSONObject.parseObject(result, new TypeReference<>() {
+        });
+    }
+}

+ 16 - 0
src/main/java/com/sckw/robot/service/BusinessService.java

@@ -0,0 +1,16 @@
+package com.sckw.robot.service;
+
+/**
+ * @Author xucaiqin
+ * @date 2023-04-13 14:50:08
+ */
+public interface BusinessService {
+
+    /**
+     * 校验token
+     *
+     * @param token
+     * @return
+     */
+    Boolean checkToken(String token);
+}

+ 30 - 0
src/main/java/com/sckw/robot/service/QueueService.java

@@ -0,0 +1,30 @@
+package com.sckw.robot.service;
+
+import com.alibaba.fastjson2.JSONObject;
+import com.sckw.robot.pojo.constant.RabbitConstant;
+import com.sckw.robot.pojo.dto.LocDto;
+import lombok.AllArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.amqp.rabbit.annotation.RabbitListener;
+import org.springframework.messaging.handler.annotation.Header;
+import org.springframework.messaging.handler.annotation.Payload;
+import org.springframework.stereotype.Service;
+
+/**
+ * @author xucaiqin
+ * @date 2024-03-08 17:35:57
+ */
+@Service
+@AllArgsConstructor
+@Slf4j
+public class QueueService {
+
+
+    @RabbitListener(queues = RabbitConstant.QUEUE)
+    public void rawQueue(@Payload LocDto data, @Header("amqp_receivedRoutingKey") String routingKey) {
+        log.info("data {}", JSONObject.toJSONString(data));
+        log.info("收到路由键:{}", routingKey);
+    }
+
+
+}

+ 22 - 0
src/main/java/com/sckw/robot/service/impl/BusinessServiceImpl.java

@@ -0,0 +1,22 @@
+package com.sckw.robot.service.impl;
+
+import com.sckw.robot.service.BusinessService;
+import lombok.AllArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Service;
+
+/**
+ * @Author xucaiqin
+ * @date 2023-04-13 14:50:25
+ */
+@Service
+@Slf4j
+@AllArgsConstructor
+public class BusinessServiceImpl implements BusinessService {
+
+    @Override
+    public Boolean checkToken(String token) {
+        log.info("token {}", token);
+        return true;
+    }
+}

+ 69 - 0
src/main/java/com/sckw/robot/util/DateTimeUtil.java

@@ -0,0 +1,69 @@
+package com.sckw.robot.util;
+
+import java.time.LocalDateTime;
+import java.time.ZoneOffset;
+import java.time.format.DateTimeFormatter;
+
+/**
+ * @author xcq
+ * @date 2022年07月29日 18:06
+ */
+public class DateTimeUtil {
+    /**
+     * 格林威治时间
+     *
+     * @return
+     */
+    public static LocalDateTime getGMT() {
+        return LocalDateTime.of(1970, 1, 1, 0, 0, 0);
+    }
+
+    public static long getSecond() {
+        return LocalDateTime.now().toEpochSecond(ZoneOffset.UTC);
+    }
+
+    public static String formatDateTime(LocalDateTime localDateTime) {
+        DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
+        return localDateTime.format(dateTimeFormatter);
+    }
+
+    /**
+     * 获取日
+     *
+     * @return
+     */
+    public static int getDayOfMonth(LocalDateTime now) {
+        return now.getDayOfMonth();
+    }
+
+    /**
+     * 获取今天在这个月所在的日
+     *
+     * @return 1-31
+     */
+    public static int getDayOfMonth() {
+        return getDayOfMonth(LocalDateTime.now());
+    }
+
+    /**
+     * 格式化当前日期
+     *
+     * @return yyyy-MM
+     */
+    public static String formatCurrentDate(String pattern) {
+        DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern(pattern);
+        return dateTimeFormatter.format(LocalDateTime.now());
+    }
+
+    public static LocalDateTime getYYYYMM(String yyyyMM) {
+        String[] split = yyyyMM.split("-");
+        return LocalDateTime.of(Integer.parseInt(split[0]), Integer.parseInt(split[1]), 1, 0, 0);
+    }
+
+    public static String formatYYYYMM() {
+        return formatCurrentDate("yyyy-MM");
+    }
+
+
+
+}

+ 18 - 0
src/main/java/com/sckw/robot/util/IdUtil.java

@@ -0,0 +1,18 @@
+package com.sckw.robot.util;
+
+import java.util.UUID;
+
+public class IdUtil {
+    public static String UUID() {
+        return UUID.randomUUID().toString().replaceAll("-", "");
+    }
+
+    public static String UUID(int len) {
+        String uuid = UUID();
+        return uuid.substring(0, Math.min(len, 32));
+    }
+
+    public static String UUID(String prefix) {
+        return prefix + "-" + UUID(6) + "-" + System.currentTimeMillis();
+    }
+}

+ 159 - 0
src/main/java/com/sckw/robot/util/MD5Util.java

@@ -0,0 +1,159 @@
+package com.sckw.robot.util;
+
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
+
+import java.nio.charset.StandardCharsets;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+
+/**
+ * MD5 消息摘要算法(利用哈希算法来加密的)
+ *
+ * @author xcq
+ * @date 2022年07月27日 20:04
+ */
+@Slf4j
+public class MD5Util {
+    //十六进制下数字到字符的映射数组
+    private final static String[] HEX_DIGITS = {"0", "1", "2", "3", "4",
+            "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f"};
+
+    /**
+     * md5加密算法 返回String
+     *
+     * @param originString
+     * @return
+     */
+    public static String encodeByMD5(String originString) {
+        if (originString != null) {
+            try {
+                //创建具有指定算法名称的信息摘要
+                MessageDigest md = MessageDigest.getInstance("MD5");
+                //使用指定的字节数组对摘要进行最后更新,然后完成摘要计算
+                byte[] results = md.digest(originString.getBytes());
+                //将得到的字节数组变成字符串返回
+                StringBuilder sb = new StringBuilder();
+                for (int j : results) {
+                    int n = j;
+                    if (n < 0) {
+                        n = 256 + n;
+                    }
+                    int d1 = n / 16;
+                    int d2 = n % 16;
+                    sb.append(HEX_DIGITS[d1]).append(HEX_DIGITS[d2]);
+                }
+                return sb.toString();
+            } catch (Exception ex) {
+                ex.printStackTrace();
+            }
+        }
+        return null;
+    }
+
+    /**
+     * 计算字符串的MD5值
+     *
+     * @param string 明文
+     * @return 字符串的MD5值
+     */
+    public static String md5(String string) {
+        if (string.isEmpty()) {
+            return "";
+        }
+        MessageDigest md5;
+        try {
+            md5 = MessageDigest.getInstance("MD5");
+            byte[] bytes = md5.digest(string.getBytes(StandardCharsets.UTF_8));
+            StringBuilder result = new StringBuilder();
+            for (byte b : bytes) {
+                /* & 0xff 可以将负数转为正数*/
+                String temp = Integer.toHexString(b & 0xff);
+                // 16进制数 temp小于16
+                if (temp.length() == 1) {
+                    temp = "0" + temp;
+                }
+                result.append(temp);
+            }
+            return result.toString();
+        } catch (NoSuchAlgorithmException e) {
+            e.printStackTrace();
+        }
+        return null;
+    }
+
+    /*其它方法*/
+
+    /**
+     * md5摘要
+     *
+     * @param s 需要转换的字符串
+     * @return 返回字节形式的md5摘要数据
+     */
+    public static byte[] byteMD5(String s) {
+        MessageDigest md;
+        try {
+            md = MessageDigest.getInstance("MD5");
+            md.reset();
+            md.update(s.getBytes(StandardCharsets.UTF_8));
+            return md.digest();
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return null;
+    }
+
+    /**
+     * 将字节数据转换为16进制的字符串数据
+     *
+     * @param hash 转换后的字节数组
+     * @return 返回16进制的字符串
+     */
+    public static String byteToHex(byte[] hash) {
+        if (hash == null) {
+            return null;
+        }
+        StringBuffer buf = new StringBuffer(hash.length * 2);
+        int i;
+
+        for (i = 0; i < hash.length; i++) {
+            /* & 0xff 可以将负数转为正数*/
+            /* <0x10 表示小于16,需要进行补零*/
+            if ((hash[i] & 0xff) < 0x10) {
+                buf.append("0");
+            }
+            buf.append(Long.toString(hash[i] & 0xff, 16));
+        }
+        return buf.toString();
+    }
+
+    /**
+     * 将字节数组转换为十六进制字符串
+     *
+     * @param data 待转换的字节数组
+     * @return 转换后的十六进制字符串
+     */
+    private static String toHexString(byte[] data) {
+        StringBuilder sb = new StringBuilder();
+        for (byte b : data) {
+            sb.append(String.format("%02X", b));
+        }
+        return sb.toString();
+    }
+
+    /**
+     * 验证MD5校验值是否正确
+     *
+     * @param data       待验证的数据
+     * @param md5ToCheck 待验证的MD5校验值
+     * @return true表示校验通过,false表示校验失败
+     */
+    public static boolean verifyMD5(String data, String md5ToCheck) {
+        String check = md5(data);
+        log.info("我方签名:{}", check);
+        log.info("来访者签名:{}", md5ToCheck);
+        return StringUtils.equals(check, md5ToCheck);
+    }
+
+
+}

+ 212 - 0
src/main/java/com/sckw/robot/util/OkHttpUtils.java

@@ -0,0 +1,212 @@
+package com.sckw.robot.util;
+
+import com.alibaba.fastjson2.JSONObject;
+import lombok.extern.slf4j.Slf4j;
+import okhttp3.*;
+import org.apache.commons.lang3.StringUtils;
+
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.SSLSocketFactory;
+import javax.net.ssl.TrustManager;
+import javax.net.ssl.X509TrustManager;
+import java.io.IOException;
+import java.net.URLEncoder;
+import java.nio.charset.StandardCharsets;
+import java.security.SecureRandom;
+import java.security.cert.X509Certificate;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.concurrent.Semaphore;
+import java.util.concurrent.TimeUnit;
+
+@Slf4j
+public class OkHttpUtils {
+
+    private static volatile OkHttpClient okHttpClient;
+    private static final Semaphore semaphore = new Semaphore(0);
+
+    private final Map<String, String> headerMap = new LinkedHashMap<>();
+    private final Map<String, String> paraMap = new LinkedHashMap<>();
+    private final Map<String, String> bodyParaMap = new LinkedHashMap<>();
+    private String bodyParaString;
+    private String url;
+    private Request.Builder request;
+
+    static {
+        try {
+            TrustManager[] trustManagers = buildTrustManagers();
+            okHttpClient = new OkHttpClient.Builder()
+                    .connectTimeout(15, TimeUnit.SECONDS)
+                    .writeTimeout(20, TimeUnit.SECONDS)
+                    .readTimeout(20, TimeUnit.SECONDS)
+                    .sslSocketFactory(createSSLSocketFactory(trustManagers), (X509TrustManager) trustManagers[0])
+                    .hostnameVerifier((hostName, session) -> true)
+                    .retryOnConnectionFailure(true)
+                    .build();
+        } catch (Exception e) {
+            log.error("Failed to initialize OkHttpClient", e);
+        }
+    }
+
+    public static OkHttpUtils builder() {
+        return new OkHttpUtils();
+    }
+
+    public OkHttpUtils url(String url) {
+        this.url = url;
+        return this;
+    }
+
+    public OkHttpUtils addPara(String key, String value) {
+        this.paraMap.put(key, value);
+        return this;
+    }
+
+    public OkHttpUtils addBodyPara(String key, String value) {
+        this.bodyParaMap.put(key, value);
+        return this;
+    }
+
+    public OkHttpUtils addBodyJsonStr(String string) {
+        this.bodyParaString = string;
+        return this;
+    }
+
+    public OkHttpUtils addHeader(String key, String value) {
+        this.headerMap.put(key, value);
+        return this;
+    }
+
+    public OkHttpUtils addHeaderMap(Map<String, String> map) {
+        this.headerMap.putAll(map);
+        return this;
+    }
+
+    public OkHttpUtils get() {
+        this.request = new Request.Builder().get().url(buildUrl());
+        return this;
+    }
+
+    public OkHttpUtils post(boolean isJsonPost) {
+        RequestBody requestBody;
+        if (isJsonPost) {
+            String json = StringUtils.isNotBlank(bodyParaString) ? bodyParaString : JSONObject.toJSONString(bodyParaMap);
+            requestBody = RequestBody.create(json, MediaType.parse("application/json; charset=utf-8"));
+        } else {
+            FormBody.Builder formBody = new FormBody.Builder();
+            bodyParaMap.forEach(formBody::add);
+            requestBody = formBody.build();
+        }
+        this.request = new Request.Builder().post(requestBody).url(buildUrl());
+        return this;
+    }
+
+    private String buildUrl() {
+        if (paraMap.isEmpty()) return this.url;
+
+        StringBuilder urlBuilder = new StringBuilder(this.url).append("?");
+        paraMap.forEach((key, value) -> {
+            try {
+                urlBuilder.append(URLEncoder.encode(key, StandardCharsets.UTF_8))
+                        .append("=")
+                        .append(URLEncoder.encode(value, StandardCharsets.UTF_8))
+                        .append("&");
+            } catch (Exception e) {
+                log.warn("Parameter encoding failed: {}={}", key, value, e);
+            }
+        });
+        urlBuilder.deleteCharAt(urlBuilder.length() - 1);
+        return urlBuilder.toString();
+    }
+
+    public String sync() {
+        setHeaders();
+        try (Response response = okHttpClient.newCall(request.build()).execute()) {
+            if (response.body() != null) {
+                return response.body().string();
+            }
+        } catch (IOException e) {
+            log.error("Sync request failed", e);
+        }
+        return null;
+    }
+
+    public String async() {
+        final StringBuilder buffer = new StringBuilder();
+        setHeaders();
+        okHttpClient.newCall(request.build()).enqueue(new Callback() {
+            @Override
+            public void onFailure(Call call, IOException e) {
+                log.error("Async request failed", e);
+                buffer.append("请求失败:").append(e.getMessage());
+                semaphore.release();
+            }
+
+            @Override
+            public void onResponse(Call call, Response response) throws IOException {
+                if (response.body() != null) {
+                    buffer.append(response.body().string());
+                }
+                semaphore.release();
+            }
+        });
+
+        try {
+            semaphore.acquire();
+        } catch (InterruptedException e) {
+            Thread.currentThread().interrupt();
+            log.error("Semaphore interrupted", e);
+        }
+        return buffer.toString();
+    }
+
+    public void async(ICallBack callBack) {
+        setHeaders();
+        okHttpClient.newCall(request.build()).enqueue(new Callback() {
+            @Override
+            public void onFailure(Call call, IOException e) {
+                callBack.onFailure(call, e.getMessage());
+            }
+
+            @Override
+            public void onResponse(Call call, Response response) throws IOException {
+                if (response.body() != null) {
+                    callBack.onSuccessful(call, response.body().string());
+                }
+            }
+        });
+    }
+
+    private void setHeaders() {
+        headerMap.forEach((k, v) -> request.addHeader(k, v));
+    }
+
+    private static SSLSocketFactory createSSLSocketFactory(TrustManager[] trustAllCerts) throws Exception {
+        SSLContext sc = SSLContext.getInstance("SSL");
+        sc.init(null, trustAllCerts, new SecureRandom());
+        return sc.getSocketFactory();
+    }
+
+    private static TrustManager[] buildTrustManagers() {
+        return new TrustManager[]{
+                new X509TrustManager() {
+                    @Override
+                    public void checkClientTrusted(X509Certificate[] chain, String authType) {}
+
+                    @Override
+                    public void checkServerTrusted(X509Certificate[] chain, String authType) {}
+
+                    @Override
+                    public X509Certificate[] getAcceptedIssuers() {
+                        return new X509Certificate[0];
+                    }
+                }
+        };
+    }
+
+    public interface ICallBack {
+        void onSuccessful(Call call, String data);
+
+        void onFailure(Call call, String errorMsg);
+    }
+}

+ 74 - 0
src/main/java/com/sckw/robot/util/R.java

@@ -0,0 +1,74 @@
+package com.sckw.robot.util;
+
+import lombok.*;
+import lombok.experimental.Accessors;
+
+import java.io.Serial;
+import java.io.Serializable;
+
+/**
+ * @author xcq
+ * @date 2022年06月14日 13:41
+ */
+@ToString
+@NoArgsConstructor
+@AllArgsConstructor
+@Accessors(chain = true)
+public class R<T> implements Serializable {
+    @Serial
+    private static final long serialVersionUID = 1L;
+    /**
+     * 200-成功 500-失败
+     */
+    @Getter
+    @Setter
+    private int code;
+
+    @Getter
+    @Setter
+    private String msg;
+
+    @Getter
+    @Setter
+    private T data;
+
+    public static <T> R<T> ok() {
+        return restResult(null, 200, null);
+    }
+
+    public static <T> R<T> ok(T data) {
+        return restResult(data, 200, null);
+    }
+
+    public static <T> R<T> ok(T data, String msg) {
+        return restResult(data, 200, msg);
+    }
+
+    public static <T> R<T> failed() {
+        return restResult(null, 500, null);
+    }
+
+    public static <T> R<T> failed(String msg) {
+        return restResult(null, 500, msg);
+    }
+
+    public static <T> R<T> failed(T data) {
+        return restResult(data, 500, null);
+    }
+
+    public static <T> R<T> failed(T data, String msg) {
+        return restResult(data, 500, msg);
+    }
+
+    public static <T> R<T> failed(T data, String msg, int code) {
+        return restResult(data, code, msg);
+    }
+
+    private static <T> R<T> restResult(T data, int code, String msg) {
+        R<T> apiResult = new R<>();
+        apiResult.setCode(code);
+        apiResult.setData(data);
+        apiResult.setMsg(msg);
+        return apiResult;
+    }
+}

+ 46 - 0
src/main/resources/application-dev.yml

@@ -0,0 +1,46 @@
+spring:
+  datasource:
+    driver-class-name: com.mysql.cj.jdbc.Driver
+    type: com.alibaba.druid.pool.DruidDataSource
+    username: push
+    password: push
+    url: jdbc:mysql://10.10.10.230:3306/push
+    druid:
+      # 初始连接数
+      initialSize: 5
+      # 最小连接池数量
+      minIdle: 10
+      # 最大连接池数量
+      maxActive: 20
+      # 配置获取连接等待超时的时间
+      maxWait: 60000
+  data:
+    redis:
+      host: 10.10.10.230
+      password: test
+      port: 6379
+      database: 12
+      lettuce:
+        pool:
+          enabled: true
+          max-active: 8
+          max-idle: 16
+          min-idle: 1
+  rabbitmq:
+    host: dynamic.dcm360.com.cn
+    port: 15672
+    username: admin
+    password: dcm360.com
+
+# 日志级别
+logging:
+  level:
+    root: debug
+    com.sckw.robot: debug
+
+
+# mybatis-plus 打印sql
+mybatis-plus:
+  configuration:
+    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
+

+ 40 - 0
src/main/resources/application-pro.yml

@@ -0,0 +1,40 @@
+spring:
+  datasource:
+    driver-class-name: com.mysql.cj.jdbc.Driver
+    type: com.alibaba.druid.pool.DruidDataSource
+    username: push
+    password: nzwA3HQLX5yNJh53
+    url: jdbc:mysql://rm-2vcw922e20158115l.mysql.cn-chengdu.rds.aliyuncs.com:3306/push?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=Asia/Shanghai&zeroDateTimeBehavior=convertToNull
+    druid:
+      # 初始连接数
+      initialSize: 5
+      # 最小连接池数量
+      minIdle: 10
+      # 最大连接池数量
+      maxActive: 20
+      # 配置获取连接等待超时的时间
+      maxWait: 60000
+  data:
+    redis:
+      host: r-2vcqhixqvh8gwzj3by.redis.cn-chengdu.rds.aliyuncs.com
+      password: mCFEETDwBhgB29y2
+      port: 6379
+      database: 13
+      lettuce:
+        pool:
+          enabled: true
+          max-active: 8
+          max-idle: 16
+          min-idle: 1
+
+
+# 日志级别
+logging:
+  level:
+    root: info
+
+
+# mybatis-plus 打印sql
+mybatis-plus:
+  configuration:
+    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl

+ 39 - 0
src/main/resources/application-test.yml

@@ -0,0 +1,39 @@
+spring:
+  datasource:
+    driver-class-name: com.mysql.cj.jdbc.Driver
+    type: com.alibaba.druid.pool.DruidDataSource
+    username: push
+    password: push
+    url: jdbc:mysql://10.10.10.221:3306/push?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=Asia/Shanghai&zeroDateTimeBehavior=convertToNull
+    druid:
+      # 初始连接数
+      initialSize: 5
+      # 最小连接池数量
+      minIdle: 10
+      # 最大连接池数量
+      maxActive: 20
+      # 配置获取连接等待超时的时间
+      maxWait: 60000
+  data:
+    redis:
+      host: 10.10.10.221
+      password: test
+      port: 6379
+      database: 12
+      lettuce:
+        pool:
+          enabled: true
+          max-active: 8
+          max-idle: 16
+          min-idle: 1
+
+
+# 日志级别
+logging:
+  level:
+    root: info
+    com.sckw.robot: debug
+# mybatis-plus 打印sql
+mybatis-plus:
+  configuration:
+    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl

+ 19 - 0
src/main/resources/application.yml

@@ -0,0 +1,19 @@
+server:
+  port: 8860
+
+spring:
+  application:
+    name: OrbitalRobot
+  profiles:
+    active: dev
+  jackson:
+    date-format: yyyy-MM-dd HH:mm:ss
+    locale: zh
+    time-zone: GMT+8
+    serialization:
+      write-dates-as-timestamps: true
+    default-leniency: true
+  servlet:
+    multipart:
+      max-file-size: 20MB
+      max-request-size: 100MB

+ 153 - 0
src/main/resources/log4j2.xml

@@ -0,0 +1,153 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<configuration status="info" monitorInterval="30">
+    <properties>
+        <!-- 格式化输出:%date表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度 %msg:日志消息,%n是换行符 -->
+        <!-- %logger{36} 表示 Logger 名字最长36个字符 -->
+        <property name="LOG_PATTERN"
+                  value="%clr{%d{yyyy-MM-dd HH:mm:ss.SSS}}{faint} %clr{%5p} %clr{${sys:PID}}{magenta} %clr{---}{faint} %clr{[%t]}{faint} %clr{%c{1.}}{cyan} %clr{:}{faint} %m%n%xwEx"/>
+        <property name="LOG_WITHOUT_COLOR_PATTERN"
+                  value="%d{yyyy-MM-dd HH:mm:ss.SSS} %5p ${sys:PID}--- [%t] %c{1.} : %m%n%xwEx"/>
+        <property name="LOG_PATH" value="logs"/>
+    </properties>
+
+    <!-- 先定义所有的appender(附加器)-->
+    <appenders>
+        <!-- 输出控制台的配置 -->
+        <Console name="Console" target="SYSTEM_OUT">
+            <!-- 输出日志的格式 -->
+            <PatternLayout pattern="${LOG_PATTERN}"/>
+        </Console>
+
+        <!--all级别日志-->
+        <RollingFile name="allFileAppender"
+                     fileName="${LOG_PATH}/all.log"
+                     filePattern="${LOG_PATH}/$${date:yyyy-MM}/all-%d{yyyy-MM-dd}-%i.log.gz">
+            <PatternLayout pattern="${LOG_WITHOUT_COLOR_PATTERN}"/>
+
+            <Policies>
+                <!-- 设置日志文件切分参数 -->
+                <!--<OnStartupTriggeringPolicy/>-->
+                <!--设置日志基础文件大小,超过该大小就触发日志文件滚动更新-->
+                <SizeBasedTriggeringPolicy size="100 MB"/>
+                <!--设置日志文件滚动更新的时间,依赖于文件命名filePattern的设置-->
+                <TimeBasedTriggeringPolicy/>
+            </Policies>
+            <!--设置日志的文件个数上限,不设置默认为7个,超过大小后会被覆盖;依赖于filePattern中的%i-->
+            <DefaultRolloverStrategy max="100"/>
+        </RollingFile>
+
+        <!--debug级别日志-->
+        <RollingFile name="debugFileAppender"
+                     fileName="${LOG_PATH}/debug.log"
+                     filePattern="${LOG_PATH}/$${date:yyyy-MM}/debug-%d{yyyy-MM-dd}-%i.log.gz">
+            <Filters>
+                <!--过滤掉info及更高级别日志-->
+                <ThresholdFilter level="info" onMatch="DENY" onMismatch="NEUTRAL"/>
+            </Filters>
+            <!--设置日志格式-->
+            <PatternLayout pattern="${LOG_WITHOUT_COLOR_PATTERN}"/>
+
+            <Policies>
+                <!-- 设置日志文件切分参数 -->
+                <!--<OnStartupTriggeringPolicy/>-->
+                <!--设置日志基础文件大小,超过该大小就触发日志文件滚动更新-->
+                <SizeBasedTriggeringPolicy size="100 MB"/>
+                <!--设置日志文件滚动更新的时间,依赖于文件命名filePattern的设置-->
+                <TimeBasedTriggeringPolicy/>
+            </Policies>
+            <!--设置日志的文件个数上限,不设置默认为7个,超过大小后会被覆盖;依赖于filePattern中的%i-->
+            <DefaultRolloverStrategy max="100"/>
+        </RollingFile>
+
+        <!--info级别日志-->
+        <RollingFile name="infoFileAppender"
+                     fileName="${LOG_PATH}/info.log"
+                     filePattern="${LOG_PATH}/$${date:yyyy-MM}/info-%d{yyyy-MM-dd}-%i.log.gz">
+            <Filters>
+                <!--过滤掉warn及更高级别日志-->
+                <ThresholdFilter level="warn" onMatch="DENY" onMismatch="NEUTRAL"/>
+            </Filters>
+            <!--设置日志格式-->
+            <PatternLayout pattern="${LOG_WITHOUT_COLOR_PATTERN}"/>
+
+            <Policies>
+                <!-- 设置日志文件切分参数 -->
+                <!--<OnStartupTriggeringPolicy/>-->
+                <!--设置日志基础文件大小,超过该大小就触发日志文件滚动更新-->
+                <SizeBasedTriggeringPolicy size="100 MB"/>
+                <!--设置日志文件滚动更新的时间,依赖于文件命名filePattern的设置-->
+                <TimeBasedTriggeringPolicy interval="1" modulate="true"/>
+            </Policies>
+            <!--设置日志的文件个数上限,不设置默认为7个,超过大小后会被覆盖;依赖于filePattern中的%i-->
+            <!--<DefaultRolloverStrategy max="100"/>-->
+        </RollingFile>
+
+        <!--warn级别日志-->
+        <RollingFile name="warnFileAppender"
+                     fileName="${LOG_PATH}/warn.log"
+                     filePattern="${LOG_PATH}/$${date:yyyy-MM}/warn-%d{yyyy-MM-dd}-%i.log.gz">
+            <Filters>
+                <!--过滤掉error及更高级别日志-->
+                <ThresholdFilter level="error" onMatch="DENY" onMismatch="NEUTRAL"/>
+            </Filters>
+            <!--设置日志格式-->
+            <PatternLayout pattern="${LOG_WITHOUT_COLOR_PATTERN}"/>
+
+            <Policies>
+                <!-- 设置日志文件切分参数 -->
+                <!--<OnStartupTriggeringPolicy/>-->
+                <!--设置日志基础文件大小,超过该大小就触发日志文件滚动更新-->
+                <SizeBasedTriggeringPolicy size="100 MB"/>
+                <!--设置日志文件滚动更新的时间,依赖于文件命名filePattern的设置-->
+                <TimeBasedTriggeringPolicy/>
+            </Policies>
+            <!--设置日志的文件个数上限,不设置默认为7个,超过大小后会被覆盖;依赖于filePattern中的%i-->
+            <DefaultRolloverStrategy max="100"/>
+        </RollingFile>
+
+        <!--error及更高级别日志-->
+        <RollingFile name="errorFileAppender"
+                     fileName="${LOG_PATH}/error.log"
+                     filePattern="${LOG_PATH}/$${date:yyyy-MM}/error-%d{yyyy-MM-dd}-%i.log.gz">
+            <!--设置日志格式-->
+            <PatternLayout pattern="${LOG_WITHOUT_COLOR_PATTERN}"/>
+            <Policies>
+                <!-- 设置日志文件切分参数 -->
+                <!--<OnStartupTriggeringPolicy/>-->
+                <!--设置日志基础文件大小,超过该大小就触发日志文件滚动更新-->
+                <SizeBasedTriggeringPolicy size="100 MB"/>
+                <!--设置日志文件滚动更新的时间,依赖于文件命名filePattern的设置-->
+                <TimeBasedTriggeringPolicy/>
+            </Policies>
+            <!--设置日志的文件个数上限,不设置默认为7个,超过大小后会被覆盖;依赖于filePattern中的%i-->
+            <DefaultRolloverStrategy max="100"/>
+        </RollingFile>
+
+        <!--json格式error级别日志-->
+        <RollingFile name="errorJsonAppender"
+                     fileName="${LOG_PATH}/error-json.log"
+                     filePattern="${LOG_PATH}/$${date:yyyy-MM}/error-json-%d{yyyy-MM-dd}-%i.log.gz">
+            <JSONLayout compact="true" eventEol="true" locationInfo="true"/>
+            <Policies>
+                <SizeBasedTriggeringPolicy size="100 MB"/>
+                <TimeBasedTriggeringPolicy interval="1" modulate="true"/>
+            </Policies>
+        </RollingFile>
+
+    </appenders>
+
+    <loggers>
+
+        <!-- 建立一个默认的root的logger -->
+        <root level="DEBUG">
+            <AppenderRef ref="allFileAppender" level="all"/>
+            <AppenderRef ref="debugFileAppender" level="debug"/>
+            <AppenderRef ref="infoFileAppender" level="info"/>
+            <AppenderRef ref="warnFileAppender" level="warn"/>
+            <AppenderRef ref="errorFileAppender" level="error"/>
+            <AppenderRef ref="errorJsonAppender" level="error"/>
+            <appender-ref ref="Console" level="info"/>
+        </root>
+    </loggers>
+
+</configuration>