Compare commits
2
Commits
7659afe5d7
...
2e4e4ee8e1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2e4e4ee8e1 | ||
|
|
c19d760518 |
@@ -0,0 +1,32 @@
|
||||
package com.ai.trackwalker.config;
|
||||
|
||||
import io.swagger.v3.oas.models.Components;
|
||||
import io.swagger.v3.oas.models.OpenAPI;
|
||||
import io.swagger.v3.oas.models.info.Contact;
|
||||
import io.swagger.v3.oas.models.info.Info;
|
||||
import io.swagger.v3.oas.models.security.SecurityRequirement;
|
||||
import io.swagger.v3.oas.models.security.SecurityScheme;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration
|
||||
public class OpenApiConfiguration {
|
||||
private static final String BEARER_AUTH = "bearerAuth";
|
||||
|
||||
@Bean
|
||||
OpenAPI railInspectionOpenApi() {
|
||||
return new OpenAPI()
|
||||
.info(new Info()
|
||||
.title("铁路无人机智能巡检平台 API")
|
||||
.description("业务平台 REST API。调用受保护接口前,请在 Authorize 中填写访问令牌。")
|
||||
.version("v1")
|
||||
.contact(new Contact().name("AItrackwalker")))
|
||||
.components(new Components().addSecuritySchemes(BEARER_AUTH,
|
||||
new SecurityScheme()
|
||||
.name(BEARER_AUTH)
|
||||
.type(SecurityScheme.Type.HTTP)
|
||||
.scheme("bearer")
|
||||
.bearerFormat("JWT")))
|
||||
.addSecurityItem(new SecurityRequirement().addList(BEARER_AUTH));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,133 @@
|
||||
# Windows 脚本说明
|
||||
|
||||
本目录集中存放本地 CPU 环境、GPU 服务器环境、模型安装和回归验证脚本。除两个 `.sh` 脚本外,命令示例均在仓库根目录通过 PowerShell 执行。
|
||||
|
||||
## 前置条件
|
||||
|
||||
- Windows 10/11、PowerShell 5.1 或更高版本。
|
||||
- Docker Desktop 已启动,并支持 `docker compose`。
|
||||
- CPU 本地环境使用 `infra/docker-compose.yml` 和 `infra/docker-compose.cpu.yml`。
|
||||
- GPU 服务器环境还需要 NVIDIA 驱动、NVIDIA Container Toolkit、`nvidia-smi`,以及由 `infra/.env.server.example` 创建并替换密码后的 `infra/.env.server`。
|
||||
- 测试脚本默认访问 `http://localhost:8088`,默认本地账号为 `admin/admin`。可通过相应环境变量覆盖。
|
||||
- `.cmd` 文件只是同名 PowerShell 脚本的便捷入口,会临时绕过 PowerShell ExecutionPolicy。
|
||||
|
||||
## 快速开始
|
||||
|
||||
启动默认的本地 CPU 技术栈:
|
||||
|
||||
```powershell
|
||||
.\scripts\windows\start_stack.cmd
|
||||
```
|
||||
|
||||
跳过镜像构建,直接启动已有镜像:
|
||||
|
||||
```powershell
|
||||
.\scripts\windows\start_stack.ps1 -NoBuild
|
||||
```
|
||||
|
||||
运行基础冒烟测试:
|
||||
|
||||
```powershell
|
||||
.\scripts\windows\smoke_test.ps1
|
||||
```
|
||||
|
||||
停止基础 Compose 技术栈:
|
||||
|
||||
```powershell
|
||||
.\scripts\windows\stop_stack.ps1
|
||||
```
|
||||
|
||||
## 启停与构建脚本
|
||||
|
||||
| 脚本 | 作用 | 参数与说明 |
|
||||
| --- | --- | --- |
|
||||
| `start_stack.cmd` | 默认一键启动入口。 | 将所有参数传给 `start_stack.ps1`。适合双击或在 CMD 中运行。 |
|
||||
| `start_stack.ps1` | 默认启动本地 CPU 技术栈。 | 实际调用 `start_cpu_stack.ps1`;支持 `-NoBuild`。 |
|
||||
| `start_cpu_stack.cmd` | CPU 技术栈的 CMD 入口。 | 将参数原样传给 `start_cpu_stack.ps1`。 |
|
||||
| `start_cpu_stack.ps1` | 初始化并启动完整的本地 CPU 环境。 | 首次运行会生成 `infra/.env.local` 和随机开发密钥,补齐旧环境的本地登录配置,同步已有 PostgreSQL 卷中的 `rail` 用户密码,准备模型目录,启动 Compose 服务,等待平台、AI、边缘代理和媒体网关就绪,最后执行 CPU 运行态验证。`-NoBuild` 可跳过镜像构建。 |
|
||||
| `start_server_stack.cmd` | GPU 服务器技术栈的 CMD 入口。 | 将参数原样传给 `start_server_stack.ps1`。 |
|
||||
| `start_server_stack.ps1` | 启动 Windows GPU 服务器部署。 | 校验 `.env.server`、Docker 和 NVIDIA 环境,使用基础及 server Compose 文件启动服务并等待健康。`-NoBuild` 跳过构建;`-ActivateServerProfiles` 启用预置 GPU/服务器模型部署配置。 |
|
||||
| `start_server_stack.sh` | Linux/Unix GPU 服务器启动入口。 | 与 PowerShell 服务器启动脚本用途相近。支持 `--no-build` 和 `--activate-server-profiles`;依赖 `sh`、Docker、`nvidia-smi`、`curl`、`grep`。虽然放在 `windows` 目录中,但用于 Unix Shell。 |
|
||||
| `restart_frontend.cmd` | 前端重建脚本的 CMD 入口。 | 将参数原样传给 `restart_frontend.ps1`。 |
|
||||
| `restart_frontend.ps1` | 单独重建并替换前端容器,不重启依赖服务。 | 自动读取存在的 `infra/.env.local`,支持 `-NoCache` 强制无缓存构建;完成后检查 `http://127.0.0.1:8088/`。 |
|
||||
| `stop_stack.ps1` | 停止并删除基础 Compose 文件管理的容器和网络。 | 必须从仓库根目录运行;执行 `docker compose -f infra/docker-compose.yml down`。不会主动删除具名数据卷。 |
|
||||
|
||||
## 模型安装脚本
|
||||
|
||||
| 脚本 | 作用 | 参数与说明 |
|
||||
| --- | --- | --- |
|
||||
| `setup_cpu_models.ps1` | 查看 CPU 模型注册表的安装状态,或把本地 ONNX 模型安装到 `runtime/models` 的注册位置。 | 不传参数时只创建目录、输出状态并生成 `MODEL_LAYOUT.txt`。安装时使用 `-ModelGroup` 和 `-ModelPath`;部分模型可使用 `-SecondaryModelPath`,标签使用 `-LabelsPath`;`-Restart` 会重启两个 AI 服务。支持的组:`vision-detector`、`vision-segmenter`、`change-detector`、`thermal-analyzer`。 |
|
||||
| `setup_server_model.ps1` | 按服务器模型注册表安装指定版本的生产模型到 `runtime/server-models`。 | 必须指定 `-ModelGroup` 和 `-ModelVersion`(`v1.0.0` 或 `v1.1.0`)。除 `pointcloud-analyzer` 外需提供 `-ModelPath`;注册表要求标签时需 `-LabelsPath`,热成像模型还需 `-SecondaryModelPath`。复制后输出 SHA-256;`-Restart` 重启 AI 服务。 |
|
||||
| `setup_server_model.sh` | Linux/Unix 版服务器模型安装脚本。 | 用法:`sh scripts/windows/setup_server_model.sh <model-group> <version> [model.onnx] [labels.txt] [secondary.onnx]`。按固定目录名安装模型并计算 SHA-256;热成像模型要求第二个 PatchCore ONNX 文件。 |
|
||||
|
||||
CPU 模型安装示例:
|
||||
|
||||
```powershell
|
||||
.\scripts\windows\setup_cpu_models.ps1 `
|
||||
-ModelGroup vision-detector `
|
||||
-ModelPath D:\models\detector.onnx `
|
||||
-LabelsPath D:\models\labels.txt `
|
||||
-Restart
|
||||
```
|
||||
|
||||
服务器模型安装示例:
|
||||
|
||||
```powershell
|
||||
.\scripts\windows\setup_server_model.ps1 `
|
||||
-ModelGroup vision-detector `
|
||||
-ModelVersion v1.0.0 `
|
||||
-ModelPath D:\models\detector.onnx `
|
||||
-LabelsPath D:\models\labels.txt
|
||||
```
|
||||
|
||||
模型脚本不会自动下载铁路生产权重;模型文件和标签顺序需要由使用者自行确认。
|
||||
|
||||
## 检查与测试脚本
|
||||
|
||||
| 脚本 | 作用 | 是否写入业务数据 |
|
||||
| --- | --- | --- |
|
||||
| `run_static_checks.ps1` | 编译检查两个 FastAPI 服务的 Python 语法、校验前端 JSON 文件,并验证 Docker Compose 配置可解析。脚本中的 Python/Node 路径绑定当前 Codex 运行时,换机器时可能需要调整。 | 否,但 Python 会生成 `__pycache__`。 |
|
||||
| `verify_cpu_runtime.ps1` | 校验视觉和点云服务使用 `cpu-local` 配置、并发和模型加载上限正确、Open3D 可用、五类模型均已注册、平台聚合状态正常,并发送一次测试推理请求。 | 不写入平台业务数据;会触发一次 AI 测试推理。 |
|
||||
| `smoke_test.ps1` | 检查后端健康,启动并等待一条 12 阶段可视化全链路 Demo,校验事件顺序、步骤快照和实体索引,读取概览/工单,并检查前端可访问。 | **是**,会创建 Demo 运行及其关联数据。 |
|
||||
| `navigation_pages_test.ps1` | 检查 15 个前端路由和主要页面 API,随后验证任务创建、无人机任务状态回调、任务取消及告警处置操作。 | **是**,会创建任务并可能修改告警。 |
|
||||
| `full_chain_interaction_test.ps1` | 深度验证全链路交互:资源预览、AI 证据、告警证据链、告警复核、工单派发与复核、强制复检、样本决策、运行导出,以及取消后节点重试。 | **是**,会创建和修改 Demo、告警、工单、复检及样本数据。 |
|
||||
| `capability_completion_test.ps1` | 最完整的能力回归:GIS 权威数据、空间规则、线性参考、航线校准/审批/发布、计划任务、模拟器飞行、遥测、分片上传与预处理、工单闭环、证据上传、复检、归档和通知。 | **是,大量写入**。建议仅在独立测试环境运行。 |
|
||||
| `auth_test_helper.ps1` | 被其他测试脚本引用的认证辅助函数,不是独立测试。优先返回 `RAIL_TEST_ACCESS_TOKEN`;否则用本地用户名和密码调用 `/api/v1/auth/login` 获取令牌。 | 登录本身不写入业务数据。 |
|
||||
|
||||
建议按以下顺序执行回归,便于快速定位问题:
|
||||
|
||||
```powershell
|
||||
.\scripts\windows\run_static_checks.ps1
|
||||
.\scripts\windows\verify_cpu_runtime.ps1
|
||||
.\scripts\windows\smoke_test.ps1
|
||||
.\scripts\windows\navigation_pages_test.ps1
|
||||
.\scripts\windows\full_chain_interaction_test.ps1
|
||||
.\scripts\windows\capability_completion_test.ps1
|
||||
```
|
||||
|
||||
## 常用环境变量
|
||||
|
||||
| 环境变量 | 使用脚本 | 默认值/作用 |
|
||||
| --- | --- | --- |
|
||||
| `RAIL_TEST_ACCESS_TOKEN` | 所有引用认证辅助函数的测试 | 若设置则直接作为 Bearer Token,不再调用登录接口。 |
|
||||
| `RAIL_LOCAL_ADMIN_USERNAME` | 认证辅助函数 | 默认 `admin`。 |
|
||||
| `RAIL_LOCAL_ADMIN_PASSWORD` | 认证辅助函数 | 默认 `admin`。 |
|
||||
| `RAIL_API_BASE_URL` | `smoke_test.ps1`、`full_chain_interaction_test.ps1` | 默认 `http://localhost:8088`。 |
|
||||
| `RAIL_WEB_BASE_URL` | `navigation_pages_test.ps1`、`capability_completion_test.ps1` | 默认 `http://127.0.0.1:8088`。 |
|
||||
| `RAIL_FRONTEND_URL` | `smoke_test.ps1` | 默认 `http://localhost:8088`。 |
|
||||
|
||||
临时覆盖示例:
|
||||
|
||||
```powershell
|
||||
$env:RAIL_WEB_BASE_URL = "http://test-host:8088"
|
||||
$env:RAIL_TEST_ACCESS_TOKEN = "<access-token>"
|
||||
.\scripts\windows\navigation_pages_test.ps1
|
||||
```
|
||||
|
||||
## 注意事项
|
||||
|
||||
- 测试脚本采用“遇错即停”,任何 HTTP、应用状态或断言失败都会返回非零结果。
|
||||
- `navigation_pages_test.ps1`、`full_chain_interaction_test.ps1` 和 `capability_completion_test.ps1` 会改变环境中的业务数据;不要直接对生产环境运行。
|
||||
- `start_cpu_stack.ps1` 首次运行会写入 `infra/.env.local`,其中包含本地开发密钥。不要提交该文件。
|
||||
- `setup_*_model` 会复制并覆盖对应注册位置的模型文件,执行前确认模型组和版本正确。
|
||||
- 如果 PowerShell 阻止直接执行 `.ps1`,可使用相应 `.cmd` 入口;没有 `.cmd` 包装的脚本可在当前会话中按组织安全策略设置 ExecutionPolicy 后运行。
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
package com.ai.trackwalker.uavaccess.config;
|
||||
|
||||
import io.swagger.v3.oas.models.Components;
|
||||
import io.swagger.v3.oas.models.OpenAPI;
|
||||
import io.swagger.v3.oas.models.info.Contact;
|
||||
import io.swagger.v3.oas.models.info.Info;
|
||||
import io.swagger.v3.oas.models.security.SecurityRequirement;
|
||||
import io.swagger.v3.oas.models.security.SecurityScheme;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration
|
||||
public class OpenApiConfiguration {
|
||||
private static final String ACCESS_TOKEN = "accessToken";
|
||||
|
||||
@Bean
|
||||
OpenAPI uavAccessOpenApi() {
|
||||
return new OpenAPI()
|
||||
.info(new Info()
|
||||
.title("无人机接入服务 API")
|
||||
.description("厂商隔离的无人机接入 API。调用内部接口前,请在 Authorize 中填写访问令牌。")
|
||||
.version("v1")
|
||||
.contact(new Contact().name("AItrackwalker")))
|
||||
.components(new Components().addSecuritySchemes(ACCESS_TOKEN,
|
||||
new SecurityScheme()
|
||||
.name("X-Access-Token")
|
||||
.type(SecurityScheme.Type.APIKEY)
|
||||
.in(SecurityScheme.In.HEADER)))
|
||||
.addSecurityItem(new SecurityRequirement().addList(ACCESS_TOKEN));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user