From 1e6372b5a57ddcd11e6a85b472aa7dd545fb143f Mon Sep 17 00:00:00 2001 From: zhangjianrock@163.com <zhangjianrock@163.com> Date: 星期六, 13 一月 2024 15:22:54 +0800 Subject: [PATCH] 无人机配置 --- .idea/jarRepositories.xml | 30 ++++++++++ .idea/vcs.xml | 6 ++ .idea/encodings.xml | 21 +++++++ ard-work/src/main/java/com/ruoyi/utils/forest/UavClient.java | 11 +-- ruoyi-admin/src/main/resources/application-dev-druid.yml | 4 .idea/compiler.xml | 20 ++++++ dump.rdb | 0 .idea/.gitignore | 8 ++ .idea/misc.xml | 13 ++++ ard-work/src/main/java/com/ruoyi/device/uav/service/UavService.java | 45 ++++++++++++-- 10 files changed, 142 insertions(+), 16 deletions(-) diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..13566b8 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/compiler.xml b/.idea/compiler.xml new file mode 100644 index 0000000..df3ec20 --- /dev/null +++ b/.idea/compiler.xml @@ -0,0 +1,20 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project version="4"> + <component name="CompilerConfiguration"> + <annotationProcessing> + <profile default="true" name="Default" enabled="true" /> + <profile name="Maven default annotation processors profile" enabled="true"> + <sourceOutputDir name="target/generated-sources/annotations" /> + <sourceTestOutputDir name="target/generated-test-sources/test-annotations" /> + <outputRelativeToContentRoot value="true" /> + <module name="ruoyi-framework" /> + <module name="ruoyi-system" /> + <module name="ard-work" /> + <module name="ruoyi-common" /> + <module name="ruoyi-generator" /> + <module name="ruoyi-quartz" /> + <module name="ruoyi-admin" /> + </profile> + </annotationProcessing> + </component> +</project> \ No newline at end of file diff --git a/.idea/encodings.xml b/.idea/encodings.xml new file mode 100644 index 0000000..33cbb2a --- /dev/null +++ b/.idea/encodings.xml @@ -0,0 +1,21 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project version="4"> + <component name="Encoding"> + <file url="file://$PROJECT_DIR$/ard-work/src/main/java" charset="UTF-8" /> + <file url="file://$PROJECT_DIR$/ard-work/src/main/resources" charset="UTF-8" /> + <file url="file://$PROJECT_DIR$/ruoyi-admin/src/main/java" charset="UTF-8" /> + <file url="file://$PROJECT_DIR$/ruoyi-admin/src/main/resources" charset="UTF-8" /> + <file url="file://$PROJECT_DIR$/ruoyi-common/src/main/java" charset="UTF-8" /> + <file url="file://$PROJECT_DIR$/ruoyi-common/src/main/resources" charset="UTF-8" /> + <file url="file://$PROJECT_DIR$/ruoyi-framework/src/main/java" charset="UTF-8" /> + <file url="file://$PROJECT_DIR$/ruoyi-framework/src/main/resources" charset="UTF-8" /> + <file url="file://$PROJECT_DIR$/ruoyi-generator/src/main/java" charset="UTF-8" /> + <file url="file://$PROJECT_DIR$/ruoyi-generator/src/main/resources" charset="UTF-8" /> + <file url="file://$PROJECT_DIR$/ruoyi-quartz/src/main/java" charset="UTF-8" /> + <file url="file://$PROJECT_DIR$/ruoyi-quartz/src/main/resources" charset="UTF-8" /> + <file url="file://$PROJECT_DIR$/ruoyi-system/src/main/java" charset="UTF-8" /> + <file url="file://$PROJECT_DIR$/ruoyi-system/src/main/resources" charset="UTF-8" /> + <file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" /> + <file url="file://$PROJECT_DIR$/src/main/resources" charset="UTF-8" /> + </component> +</project> \ No newline at end of file diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml new file mode 100644 index 0000000..bd3c83c --- /dev/null +++ b/.idea/jarRepositories.xml @@ -0,0 +1,30 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project version="4"> + <component name="RemoteRepositoriesConfiguration"> + <remote-repository> + <option name="id" value="public" /> + <option name="name" value="aliyun nexus" /> + <option name="url" value="https://maven.aliyun.com/repository/public" /> + </remote-repository> + <remote-repository> + <option name="id" value="central" /> + <option name="name" value="Central Repository" /> + <option name="url" value="https://repo.maven.apache.org/maven2" /> + </remote-repository> + <remote-repository> + <option name="id" value="central" /> + <option name="name" value="Maven Central repository" /> + <option name="url" value="https://repo1.maven.org/maven2" /> + </remote-repository> + <remote-repository> + <option name="id" value="jboss.community" /> + <option name="name" value="JBoss Community repository" /> + <option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" /> + </remote-repository> + <remote-repository> + <option name="id" value="central" /> + <option name="name" value="Central Repository" /> + <option name="url" value="https://maven.aliyun.com/repository/public" /> + </remote-repository> + </component> +</project> \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..d86cbdc --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project version="4"> + <component name="ExternalStorageConfigurationManager" enabled="true" /> + <component name="MavenProjectsManager"> + <option name="originalFiles"> + <list> + <option value="$PROJECT_DIR$/pom.xml" /> + </list> + </option> + <option name="workspaceImportForciblyTurnedOn" value="true" /> + </component> + <component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK" /> +</project> \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project version="4"> + <component name="VcsDirectoryMappings"> + <mapping directory="" vcs="Git" /> + </component> +</project> \ No newline at end of file diff --git a/ard-work/src/main/java/com/ruoyi/device/uav/service/UavService.java b/ard-work/src/main/java/com/ruoyi/device/uav/service/UavService.java index 079d5c8..dec574f 100644 --- a/ard-work/src/main/java/com/ruoyi/device/uav/service/UavService.java +++ b/ard-work/src/main/java/com/ruoyi/device/uav/service/UavService.java @@ -6,10 +6,13 @@ import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.ObjectMapper; import com.ruoyi.common.core.redis.RedisCache; +import com.ruoyi.common.utils.ConfigUtils; +import com.ruoyi.common.utils.StringUtils; import com.ruoyi.utils.forest.UavClient; import lombok.extern.slf4j.Slf4j; import org.apache.commons.codec.binary.Base64; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; import org.springframework.http.HttpMethod; import org.springframework.beans.factory.annotation.Autowired; @@ -26,9 +29,20 @@ @Service @Slf4j(topic = "uav") public class UavService { - public static final String USERNAME = "kaifabailu";//鐢ㄦ埛鍚� - public static final String PASSWORD = "ardkj@2014";//瀵嗙爜 - public static final String SALT = "0123456789012345";//鐩� + /*uav: + host: http://112.98.126.2:6100/ + username: kaifabailu + password: ardkj@2014 + salt: 0123456789012345 + */ + private String username;//鐢ㄦ埛鍚� + + private String password;//瀵嗙爜 + + private String salt; //鐩� + + private String host;//uav鏈嶅姟鍣� + private Map uavUser;//鐧诲綍鐨勭敤鎴蜂俊鎭� private ObjectMapper om = new ObjectMapper(); @@ -39,7 +53,19 @@ @PostConstruct public void created() { + + getUavConfig(); this.login(); + } + + private void getUavConfig() { + this.host = ConfigUtils.getConfigValue("uav_host"); + this.username = ConfigUtils.getConfigValue("uav_username"); + this.password = ConfigUtils.getConfigValue("uav_password"); + this.salt = ConfigUtils.getConfigValue("uav_salt"); + if (StringUtils.isEmpty(this.host) || StringUtils.isEmpty(this.username) || StringUtils.isEmpty(this.password) || StringUtils.isEmpty(this.salt)) { + throw new RuntimeException("鏃犱汉鏈哄弬鏁伴厤缃己澶�:"); + } } public String doUavRequest(HttpMethod method, String url, String data) { @@ -55,7 +81,7 @@ this.getToken();//鑾峰彇token楠岃瘉,楠岃瘉token鏈夋晥鎬� try { String token = this.getToken(); - res = (String) requestMethod.invoke(this.uavClient, url, token, data); + res = (String) requestMethod.invoke(this.uavClient, this.host + url, token, data); } catch (IllegalAccessException e) { System.out.println("doUavRequest 璁块棶澶辫触" + e.getMessage()); } catch (InvocationTargetException e) { @@ -76,7 +102,7 @@ String token = (String) uavUser.get("access_token"); //楠岃瘉token鏈夋晥鎬� try { - String res = uavClient.GET("manage/api/v1/devices", token, "{}"); + String res = uavClient.GET(this.host+"manage/api/v1/devices", token, "{}"); System.out.println(res); } catch (ForestNetworkException fe) { if (fe.getStatusCode() == 401) {//token澶辨晥,閲嶆柊鐧诲綍 @@ -91,12 +117,15 @@ } public void login() { + + getUavConfig(); log.debug("鐧诲綍鏃犱汉鏈哄閮ㄦ帴鍙�"); - String codedPassword = this.Encrypt(PASSWORD, SALT); - String body = "{\"username\":\"" + USERNAME + "\",\"password\":\"" + codedPassword + "\"}"; + String codedPassword = this.Encrypt(password, salt); + String body = "{\"username\":\"" + username + "\",\"password\":\"" + codedPassword + "\"}"; + System.out.println("body:" + body); try { //uavClient.GET("logout", null, "{}"); - String res = uavClient.POST("login", null, body); + String res = uavClient.POST(this.host+"login", null, body); Map resMap = om.readValue(res, Map.class); if (resMap != null) { redisCache.setCacheMap("uav:uavUser", (Map) resMap.get("data")); diff --git a/ard-work/src/main/java/com/ruoyi/utils/forest/UavClient.java b/ard-work/src/main/java/com/ruoyi/utils/forest/UavClient.java index b4011ef..427d056 100644 --- a/ard-work/src/main/java/com/ruoyi/utils/forest/UavClient.java +++ b/ard-work/src/main/java/com/ruoyi/utils/forest/UavClient.java @@ -1,23 +1,22 @@ package com.ruoyi.utils.forest; import com.dtflys.forest.annotation.*; +import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; import org.springframework.stereotype.Service; @Service public interface UavClient { - @Get("http://www.baidu.com") - String test(); - public static String IP = "http://112.98.126.2:6100/"; - @Get(IP + "${url}") + + @Get("${url}") String GET(@Var("url") String url, @Header("x-auth-token") String token, @JSONBody String body); - @Post(IP + "${url}") + @Post("${url}") String POST(@Var("url") String url, @Header("x-auth-token") String token, @JSONBody String body); - @Delete(IP + "${url}") + @Delete("${url}") String DELETE(@Var("url") String url, @Header("x-auth-token") String token, @JSONBody String body); diff --git a/dump.rdb b/dump.rdb new file mode 100644 index 0000000..8909115 --- /dev/null +++ b/dump.rdb Binary files differ diff --git a/ruoyi-admin/src/main/resources/application-dev-druid.yml b/ruoyi-admin/src/main/resources/application-dev-druid.yml index 737cda9..351d50e 100644 --- a/ruoyi-admin/src/main/resources/application-dev-druid.yml +++ b/ruoyi-admin/src/main/resources/application-dev-druid.yml @@ -6,7 +6,7 @@ # 涓诲簱鏁版嵁婧� master: driverClassName: org.postgresql.Driver - url: jdbc:postgresql://192.168.2.15:5432/ry-vue?stringtype=unspecified + url: jdbc:postgresql://192.168.1.14:5432/ry-vue?stringtype=unspecified username: postgres password: postgres # 浠庡簱鏁版嵁婧� @@ -55,4 +55,4 @@ merge-sql: true wall: config: - multi-statement-allow: true \ No newline at end of file + multi-statement-allow: true -- Gitblit v1.9.3