[add] 新增无人机模块后端项目

[refactor] 重构后端项目
This commit is contained in:
lcj
2025-05-21 11:30:59 +08:00
parent 4c238435d8
commit dc1de34116
1699 changed files with 54361 additions and 325 deletions

View File

@ -0,0 +1,63 @@
package com.ruoyi.wayline.utils;
import cn.hutool.core.lang.Console;
import cn.hutool.core.thread.ConcurrencyTester;
import cn.hutool.core.thread.ThreadUtil;
import cn.hutool.http.HttpRequest;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.file.Path;
import java.nio.file.Paths;
public class FileUtil {
private static final String FILE_EXTENSION = ".kmz";
/**
* 获取文件名并拼接后缀
* @param path 文件的路径
* @return 完整的文件名
*/
public static String getFileName(Path path) {
String fileName = path.getFileName().toString();
if (!fileName.endsWith(FILE_EXTENSION)) {
fileName += FILE_EXTENSION;
}
return fileName;
}
/**
* 获取文件所在的目录路径
* @param path 文件的完整路径
* @return 目录路径
*/
public static Path getDirectoryPath(Path path) {
return path.getParent();
}
/**
* 把 byte[] 中的内容写入指定路径的文件
* @param path 文件路径
* @param bytes 要写入的字节数据
* @throws IOException
*/
public static void transferStreamToFile(Path path, byte[] bytes) throws IOException {
try (FileOutputStream fileOutputStream = new FileOutputStream(path.toFile())) {
fileOutputStream.write(bytes);
}
}
public static void main(String[] args) {
ConcurrencyTester tester = ThreadUtil.concurrencyTest(10000, () -> {
String body = HttpRequest.get("http://192.168.110.23:9099/ruoyi/system/books/list")
.header("authorization",
"eyJhbGciOiJIUzUxMiJ9.eyJsb2dpbl91c2VyX2tleSI6IjVkMjNlZWFjLTQ5MmItNDIyZS1hMzBhLWM1MzZjNDU5OGQyZiJ9._UQYWmYQGddpgjzhczoh_C5HpxMVUUKJRIPvVOQFsrfHIG8-EBMwW7VM3pS6yaQwjzOCE-upSX1JwTa86LdAbw")
.execute().body();
Console.log(body);
});
// 获取总的执行时间,单位毫秒
Console.log(tester.getInterval());
}
}

View File

@ -0,0 +1,100 @@
package com.ruoyi.wayline.utils;
import lombok.Data;
import java.util.HashMap;
import java.util.Map;
/**
* @author ZZX
*/
@Data
public class HttpResult {
private Boolean success;
private Integer code;
private String message;
private Map<String, Object> data = new HashMap<>();
/**
* 成功,缺乏数据
*
* @return
*/
public static HttpResult ok() {
HttpResult httpResult = new HttpResult();
httpResult.setSuccess(HttpResultEnum.SUCCESS.getSuccess());
httpResult.setCode(HttpResultEnum.SUCCESS.getCode());
httpResult.setMessage(HttpResultEnum.SUCCESS.getMessage());
return httpResult;
}
/**
* 失败,缺乏数据
*
* @return
*/
public static HttpResult error() {
HttpResult httpResult = new HttpResult();
httpResult.setSuccess(HttpResultEnum.FAIL.getSuccess());
httpResult.setCode(HttpResultEnum.FAIL.getCode());
httpResult.setMessage(HttpResultEnum.FAIL.getMessage());
return httpResult;
}
/**
* 设置泛型,缺乏数据
*
* @param httpResultEnum
* @return
*/
public static HttpResult setResult(HttpResultEnum httpResultEnum) {
HttpResult httpResult = new HttpResult();
httpResult.setSuccess(httpResultEnum.getSuccess());
httpResult.setCode(httpResultEnum.getCode());
httpResult.setMessage(httpResultEnum.getMessage());
return httpResult;
}
/**
* 设置成功标志位
*
* @return
*/
public HttpResult success() {
this.setSuccess(HttpResultEnum.SUCCESS.getSuccess());
return this;
}
/**
* 设置失败标志位
*
* @return
*/
public HttpResult fail() {
this.setSuccess(HttpResultEnum.FAIL.getSuccess());
return this;
}
/**
* 添加单个键值对数据
*
* @param key
* @param value
* @return
*/
public HttpResult data(String key, Object value) {
this.data.put(key, value);
return this;
}
/**
* 添加集合数据
*
* @param map
* @return
*/
public HttpResult data(Map<String, Object> map) {
this.setData(map);
return this;
}
}

View File

@ -0,0 +1,44 @@
package com.ruoyi.wayline.utils;
/**
* @author ZZX
*/
public enum HttpResultEnum {
SUCCESS(true, 200, "成功"),
FAIL(false, 500, "失败");
private Boolean success;
private Integer code;
private String message;
HttpResultEnum(Boolean success, Integer code, String message) {
this.success = success;
this.code = code;
this.message = message;
}
public Boolean getSuccess() {
return success;
}
public void setSuccess(Boolean success) {
this.success = success;
}
public Integer getCode() {
return code;
}
public void setCode(Integer code) {
this.code = code;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
}

View File

@ -0,0 +1,34 @@
package com.ruoyi.wayline.utils;
import lombok.extern.slf4j.Slf4j;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.*;
import java.util.Collections;
import java.util.Enumeration;
/**
* @auther 周志雄
* @date 2024/7/12 18:55
*/
@Slf4j
public class IpUtil {
public static String getSystemIP() {
try {
Enumeration<NetworkInterface> networkInterfaces = NetworkInterface.getNetworkInterfaces();
for (NetworkInterface ni : Collections.list(networkInterfaces)) {
Enumeration<InetAddress> inetAddresses = ni.getInetAddresses();
while (inetAddresses.hasMoreElements()) {
InetAddress ia = inetAddresses.nextElement();
if (!ia.isLoopbackAddress() && ia.isSiteLocalAddress()) {
return ia.getHostAddress();
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
return "127.0.0.1"; // 默认回退到本地地址
}
}

View File

@ -0,0 +1,42 @@
package com.ruoyi.wayline.utils;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
/**
* @Author zhouzhixiong
* @Date 2023/12/12 11:33
*/
public class MD5Util {
/**
* 将字符串转换为MD5哈希。
*
* @param input 需要转换的字符串
* @return MD5哈希字符串
*/
public static String getMD5(String input) {
try {
// 创建MD5摘要算法实例
MessageDigest md = MessageDigest.getInstance("MD5");
// 对字符串进行哈希处理
byte[] messageDigest = md.digest(input.getBytes());
// 将哈希值转换为十六进制数
StringBuilder hexString = new StringBuilder();
for (byte b : messageDigest) {
String hex = Integer.toHexString(0xff & b);
if (hex.length() == 1) {
hexString.append('0');
}
hexString.append(hex);
}
return hexString.toString();
}
// 处理NoSuchAlgorithmException异常
catch (NoSuchAlgorithmException e) {
throw new RuntimeException(e);
}
}
}