Compare commits
4
Commits
test
..
feature_oss
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3f82024453 | ||
|
|
17c5d58439 | ||
|
|
6af9699389 | ||
|
|
785d0800ba |
@@ -1,120 +0,0 @@
|
||||
{
|
||||
"permissions": {
|
||||
"allow": [
|
||||
"Read(/F:\\project\\go-fly-platform-services\\zlt-doc/**)",
|
||||
"Read(/F:\\project\\go-fly-platform-services\\zlt-doc/**)",
|
||||
"Read(/F:\\project\\go-fly-platform-services\\zlt-doc/**)",
|
||||
"Read(/F:\\project\\go-fly-platform-services\\zlt-doc/**)",
|
||||
"Read(/F:\\project\\go-fly-platform-services\\zlt-doc/**)",
|
||||
"Read(/F:\\project\\go-fly-platform-services\\zlt-doc/**)",
|
||||
"Read(/F:\\project\\go-fly-platform-services\\zlt-doc/**)",
|
||||
"Read(/F:\\project\\go-fly-platform-services\\zlt-doc/**)",
|
||||
"Bash(mvn compile:*)",
|
||||
"Bash(java:*)",
|
||||
"Bash(mvn spring-boot:run:*)",
|
||||
"Bash(mvn clean:*)",
|
||||
"Bash(npm install:*)",
|
||||
"Bash(lsof:*)",
|
||||
"Bash(findstr:*)",
|
||||
"Bash(npm run start:*)",
|
||||
"Bash(npm start)",
|
||||
"Bash(npm run build:*)",
|
||||
"Bash(dir:*)",
|
||||
"Bash(git add:*)",
|
||||
"Bash(git commit -m \"$(cat <<''EOF''\nfix: 修复首页分账计算模块显示问题\n\n- 显示被隐藏的分账计算模块(移除 display: ''none'')\n- 调整 platformSharePercent 状态变量定义顺序\n- 优化 Slider 组件:\n - 设置标记文字颜色为深灰色 (#666),避免看不清\n - 添加 tooltip 提示框,拖动时显示当前百分比\n - 设置 tooltip 背景为深色,文字为白色,确保清晰可见\n- 移除重复的 90% 标记,只保留 0%、50%、100%\n\n🤖 Generated with Claude Code\n\nCo-Authored-By: Claude <noreply@anthropic.com>\nEOF\n)\")",
|
||||
"Bash(git commit:*)",
|
||||
"Read(//f/**)",
|
||||
"Bash(git checkout:*)",
|
||||
"Bash(git diff:*)",
|
||||
"Bash(grep:*)",
|
||||
"Bash(npm run tsc:*)",
|
||||
"Bash(node:*)",
|
||||
"Bash(javac:*)",
|
||||
"WebFetch(domain:github.com)",
|
||||
"WebFetch(domain:gitee.com)",
|
||||
"Bash(mkdir:*)",
|
||||
"Bash(rd /s /q scenic-3d-visualization)",
|
||||
"Bash(git clone:*)",
|
||||
"Bash(pnpm:*)",
|
||||
"Bash(npx tsc:*)",
|
||||
"WebSearch",
|
||||
"Bash(del srcmainjavacomcentraldevicewebsocketclientDeviceWebSocketClient.java)",
|
||||
"Bash(del \"F:\\project\\go-fly-platform-services\\zlt-business\\device-center\\src\\main\\java\\com\\central\\device\\websocket\\client\\DeviceWebSocketClient.java\")",
|
||||
"Bash(mvn dependency:resolve:*)",
|
||||
"Bash(mvn dependency:tree:*)",
|
||||
"Bash(ren:*)",
|
||||
"Bash(move FireAlarmEventMessage.java DeviceStateEventMessage.java)",
|
||||
"Bash(del TourismDevices.tsx TourismDevices.less DeviceDetail.tsx DeviceDetail.less)",
|
||||
"Bash(find:*)",
|
||||
"Bash(cat:*)",
|
||||
"Bash(cd:*)",
|
||||
"Bash(xcopy:*)",
|
||||
"Bash(robocopy:*)",
|
||||
"Bash(powershell:*)",
|
||||
"Bash(curl:*)",
|
||||
"Bash(del \"F:\\project\\go-fly-platform-services\\zlt-business\\device-center\\src\\main\\java\\com\\central\\device\\service\\MinioModelUploadService.java\")",
|
||||
"Bash(cmd /c \"dir /s /b \"\"D:\\模型\\新建模型重建-2025-09-29 20_24_08 (UTC+08)\\model\\download\"\"\")",
|
||||
"Bash(cmd /c \"dir \"\"D:\\模型\\新建模型重建-2025-09-29 20_24_08 (UTC+08)\\model\\download\"\"\")",
|
||||
"Bash(del \"F:\\project\\go-fly-platform-services\\zlt-business\\device-center\\src\\main\\java\\com\\central\\device\\websocket\\config\\DeviceControlWebSocketConfig.java\")",
|
||||
"Bash(del \"F:\\project\\go-fly-platform-services\\zlt-web\\react-web-next\\src\\services\\deviceControlWs.ts\")",
|
||||
"Bash(del:*)",
|
||||
"Bash(cmd /c del \"F:\\project\\go-fly-platform-services\\zlt-business\\device-center\\src\\main\\java\\com\\central\\device\\controller\\CdnProxyController.java\")",
|
||||
"Bash(cmd /c del \"F:\\project\\go-fly-platform-services\\zlt-business\\device-center\\src\\main\\java\\com\\central\\device\\websocket\\config\\DeviceControlWebSocketConfig.java\")",
|
||||
"Bash(cmd /c del \"F:\\project\\go-fly-platform-services\\zlt-business\\device-center\\src\\main\\java\\com\\central\\device\\websocket\\handler\\DeviceControlWebSocketHandler.java\")",
|
||||
"Bash(tree:*)",
|
||||
"Bash(move \"F:\\\\project\\\\go-fly-platform-services\\\\zlt-business\\\\order-center\\\\src\\\\main\\\\resources\\\\mapper\\\\mission\\\\MissionMapper.xml\" \"F:\\\\project\\\\go-fly-platform-services\\\\zlt-business\\\\order-center\\\\src\\\\main\\\\resources\\\\mapper\\\\MissionMapper.xml\")",
|
||||
"Bash(cmd /c move:*)",
|
||||
"Bash(set:*)",
|
||||
"Bash(copy \"F:\\\\project\\\\go-fly-platform-services\\\\zlt-web\\\\react-web-next\\\\src\\\\assets\\\\logo.png\" \"F:\\\\project\\\\go-fly-platform-services\\\\zlt-web\\\\yingyan\\\\src\\\\assets\\\\logo.png\")",
|
||||
"Bash(cmd /c copy \"F:\\\\project\\\\go-fly-platform-services\\\\zlt-web\\\\react-web-next\\\\src\\\\assets\\\\logo.png\" \"F:\\\\project\\\\go-fly-platform-services\\\\zlt-web\\\\yingyan\\\\src\\\\assets\\\\logo.png\")",
|
||||
"Bash(xargs find)",
|
||||
"Bash(for file in RouteToolbar.tsx RoutePreview.tsx WaypointEditor.tsx)",
|
||||
"Bash(do if [ -f \"$file\" ])",
|
||||
"Bash(else echo \"✗ $file NOT FOUND\")",
|
||||
"Bash(fi)",
|
||||
"Bash(done)",
|
||||
"Bash(tasklist:*)",
|
||||
"Bash(test:*)",
|
||||
"WebFetch(domain:dev.qweather.com)",
|
||||
"Bash(unzip:*)",
|
||||
"Bash(pip install:*)",
|
||||
"Bash(python3:*)",
|
||||
"Bash(npx:*)",
|
||||
"Bash(xargs head:*)",
|
||||
"Bash(for file in *.png)",
|
||||
"Bash(do echo \"=== $file ===\")",
|
||||
"Read(//f/project/go-fly-platform-services/**)",
|
||||
"Bash(find \"F:/project/go-fly-platform-services/zlt-web/react-web-next/src/pages/orders/VideoTemplate\" -type f \\\\\\( -name \"*.tsx\" -o -name \"*.ts\" -o -name \"*.jsx\" -o -name \"*.js\" -o -name \"*.json\" \\\\\\) 2>/dev/null | head -50)",
|
||||
"Bash(find \"F:/project/go-fly-platform-services/zlt-web/react-web-next/src/services\" -type f \\\\\\( -name \"*.ts\" -o -name \"*.tsx\" \\\\\\) 2>/dev/null | grep -i order)",
|
||||
"Bash(ls /f/project/go-fly-platform-services/zlt-business/device-center/src/main/java/com/central/device/controller/*.java)",
|
||||
"Bash(ls /f/project/go-fly-platform-services/zlt-business/device-center/src/main/java/com/central/device/service/*.java)",
|
||||
"Bash(ls /f/project/go-fly-platform-services/zlt-business/device-center/src/main/java/com/central/device/entity/*.java)",
|
||||
"Bash(xargs wc:*)",
|
||||
"Bash(ls -la zlt-web/yingyan/.env*)",
|
||||
"Bash(ls -d zlt-web/*/)",
|
||||
"Bash(git rm:*)",
|
||||
"Bash(claude mcp:*)",
|
||||
"WebFetch(domain:pixso.cn)",
|
||||
"Bash(awk '{print $2}')",
|
||||
"Bash(python -c \"print\\('hello'\\)\")",
|
||||
"Bash(grep -r \"RightPanel\" src/pages/client/index.tsx)",
|
||||
"Bash(grep \"statusBar\\\\|statusDot\" src/pages/client/index.tsx)",
|
||||
"Bash(grep \"routeActions\\\\|routeActionsTitle\" src/pages/client/components/CenterView/index.tsx)",
|
||||
"Read(//c/Users/10989/.m2/repository/com/alipay/**)",
|
||||
"Bash(\"/e/java/apache-maven-3.9.11-bin/apache-maven-3.9.11/bin/mvn.cmd\" -q -o -pl . compile)",
|
||||
"Bash(\"/e/java/apache-maven-3.9.11-bin/apache-maven-3.9.11/bin/mvn.cmd\" -q -pl zlt-commons/zlt-alipay-spring-boot-starter -am compile -DskipTests)",
|
||||
"Bash(grep -rn \"alipay\" zlt-business/order-center/src/main/resources/sql/)",
|
||||
"Bash(ls zlt-business/order-center/src/main/resources/sql/)",
|
||||
"WebFetch(domain:opendocs.alipay.com)",
|
||||
"Bash(mvn -v)",
|
||||
"WebFetch(domain:mvnrepository.com)",
|
||||
"WebFetch(domain:raw.githubusercontent.com)",
|
||||
"Bash(xargs -I{} jar tf {})",
|
||||
"Bash(locate alipay-sdk-java *)",
|
||||
"Bash(jar tf *)",
|
||||
"Bash(javap *)"
|
||||
],
|
||||
"deny": [],
|
||||
"ask": []
|
||||
}
|
||||
}
|
||||
-18
@@ -6,21 +6,3 @@ nacos/
|
||||
|
||||
*.iml
|
||||
*.versionsBackup
|
||||
|
||||
# Claude Code specific
|
||||
.claude/agents/
|
||||
.claude/team-collaboration-matrix.md
|
||||
|
||||
.reasonix
|
||||
reasonix.toml
|
||||
|
||||
# Cesium static assets (auto-generated by npm install)
|
||||
zlt-web/react-web-next/public/cesium/
|
||||
|
||||
|
||||
zlt-web/yingyan/public/cesium/
|
||||
|
||||
# 忽略 dist.zip 文件
|
||||
zlt-web/react-web-next/dist.zip
|
||||
|
||||
zlt-web/yingyan/dist.zip
|
||||
|
||||
@@ -1,832 +0,0 @@
|
||||
# go-fly-platform-services 项目 Skill
|
||||
|
||||
**⚠️ 强制规范:所有后台开发必须严格遵循本 Skill 文档中的所有规范、模式和最佳实践**
|
||||
|
||||
## 项目概览
|
||||
|
||||
**项目名称**: go-fly-platform-services (中央平台微服务)
|
||||
**技术栈**: Spring Boot 3.1 + Spring Cloud 2022 + MyBatis-Plus 3.x
|
||||
**Java 版本**: 17
|
||||
**构建工具**: Maven 3.8+
|
||||
**架构模式**: 微服务 + 多租户 + OAuth2 认证
|
||||
|
||||
### 核心特性
|
||||
- 多租户架构(租户级数据隔离 + 数据权限控制)
|
||||
- OAuth2 认证授权(支持密码、手机号、OpenID、第三方登录)
|
||||
- 分布式锁与幂等性保证
|
||||
- 全链路追踪(TraceId 跨服务传播)
|
||||
- 动态路由(Nacos 配置中心热更新)
|
||||
- 服务熔断降级(Sentinel + Feign Fallback)
|
||||
|
||||
---
|
||||
|
||||
## 常见问题
|
||||
|
||||
### 1. 如何添加新的业务模块?
|
||||
|
||||
1. 在 `zlt-business/` 下创建新模块
|
||||
2. 复制标准包结构(controller/service/mapper/model)
|
||||
3. 实体类继承 `SuperEntity`
|
||||
4. Mapper 继承 `SuperMapper<T>`
|
||||
5. Service 接口继承 `ISuperService<T>`
|
||||
6. Service 实现继承 `SuperServiceImpl<Mapper, Entity>`
|
||||
7. 配置 `bootstrap.yml` 设置服务名
|
||||
|
||||
### 2. 如何实现服务间调用?
|
||||
|
||||
```java
|
||||
// 1. 定义Feign客户端
|
||||
@FeignClient(name = "user-center", fallback = UserServiceFallback.class)
|
||||
public interface UserService {
|
||||
@GetMapping("/users/{id}")
|
||||
Result<SysUser> findById(@PathVariable Long id);
|
||||
}
|
||||
|
||||
// 2. 实现降级处理
|
||||
@Component
|
||||
public class UserServiceFallback implements UserService {
|
||||
@Override
|
||||
public Result<SysUser> findById(Long id) {
|
||||
return Result.failed("用户服务不可用");
|
||||
}
|
||||
}
|
||||
|
||||
// 3. 使用
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
```
|
||||
|
||||
### 3. 如何处理多租户数据?
|
||||
|
||||
**自动隔离**: 默认所有查询自动添加租户条件
|
||||
|
||||
**跳过隔离**: 使用 `@IgnoreTenantScope` 注解
|
||||
|
||||
**配置忽略表**: 在 `application.yml` 配置 `zlt.tenant.ignoreTables`
|
||||
|
||||
### 4. 如何实现分布式锁?
|
||||
|
||||
```java
|
||||
// 注解方式(推荐)
|
||||
@Lock(key = "order:create", waitTime = 5, leaseTime = 10)
|
||||
public void createOrder() { ... }
|
||||
|
||||
// 手动方式
|
||||
ZLock lock = distributedLock.tryLock("key", 5, 10, TimeUnit.SECONDS);
|
||||
try {
|
||||
// 业务逻辑
|
||||
} finally {
|
||||
distributedLock.unlock(lock);
|
||||
}
|
||||
```
|
||||
|
||||
### 5. 如何配置动态路由?
|
||||
|
||||
在 Nacos 配置中心创建配置:
|
||||
- Data ID: `scg-routes`
|
||||
- Group: `SCG_GATEWAY`
|
||||
- 格式: JSON 数组的 RouteDefinition
|
||||
|
||||
---
|
||||
|
||||
## 快速参考
|
||||
|
||||
### 端口分配
|
||||
- 认证中心: 8000
|
||||
- 网关: 9900
|
||||
- 用户中心: 7000
|
||||
- 文件中心: 5000
|
||||
- 日志中心: 7200
|
||||
- 应用监控: 6500
|
||||
- Nacos: 8848
|
||||
|
||||
### 关键配置项
|
||||
```yaml
|
||||
# 多租户
|
||||
zlt.tenant.enable: true
|
||||
|
||||
# URL权限
|
||||
zlt.security.auth.urlPermission.enable: false
|
||||
|
||||
# 动态路由
|
||||
zlt.gateway.dynamicRoute.enabled: true
|
||||
|
||||
# 单点登录
|
||||
zlt.security.auth.isSingleLogin: true
|
||||
```
|
||||
|
||||
### 核心依赖版本
|
||||
- Spring Boot: 3.1.6
|
||||
- Spring Cloud: 2022.0.4
|
||||
- Spring Cloud Alibaba: 2022.0.0.0
|
||||
- MyBatis-Plus: 3.5.4.1
|
||||
- Java: 17
|
||||
|
||||
---
|
||||
|
||||
## 项目文档位置
|
||||
|
||||
- **仓库指南**: `AGENTS.md`
|
||||
- **项目文档**: `zlt-doc/`
|
||||
- **API文档**: 启动服务后访问 `/doc.html`
|
||||
- **README**: `README.md`
|
||||
|
||||
---
|
||||
|
||||
## Git 操作限制
|
||||
|
||||
**重要**: 除非用户明确要求,否则不要执行任何 Git 操作:
|
||||
- 禁止自动 commit、push、pull、merge、rebase
|
||||
- 需要读取 Git 元数据时先获得用户确认
|
||||
- 破坏性操作(reset、force push)必须明确风险并征得同意
|
||||
|
||||
---
|
||||
|
||||
## Agent 使用建议
|
||||
|
||||
### 适合场景
|
||||
- 生成标准 CRUD 代码
|
||||
- 添加新的业务模块
|
||||
- 实现服务间调用
|
||||
- 配置多租户隔离
|
||||
- 添加缓存和分布式锁
|
||||
- 生成 API 文档
|
||||
|
||||
### 注意事项
|
||||
- 遵循现有代码风格和命名规范
|
||||
- 使用项目提供的基类和工具类
|
||||
- 添加适当的注释和文档
|
||||
- 考虑多租户和权限控制
|
||||
- 添加审计日志和链路追踪
|
||||
- 实现服务降级和熔断
|
||||
|
||||
---
|
||||
|
||||
*最后更新: 2026-04-01*
|
||||
|
||||
### 测试框架
|
||||
- JUnit 4 / JUnit 5(按模块)
|
||||
- 测试类命名: `*Test.java`
|
||||
- 测试类位置: `src/test/java`
|
||||
|
||||
### 测试要求
|
||||
- 为新增逻辑补充单测
|
||||
- 测试用例相互独立、可重复
|
||||
- 提PR前执行: `mvn -pl <module> -am test`
|
||||
|
||||
---
|
||||
|
||||
## 提交规范
|
||||
|
||||
### 约定式提交
|
||||
格式: `type(scope): 简要说明`
|
||||
|
||||
**类型**:
|
||||
- `feat` - 新功能
|
||||
- `fix` - 修复bug
|
||||
- `docs` - 文档
|
||||
- `refactor` - 重构
|
||||
- `test` - 测试
|
||||
- `chore` - 构建/工具
|
||||
|
||||
**示例**:
|
||||
```
|
||||
feat(订单中心): 添加订单导出功能
|
||||
fix(用户中心): 修复用户登录验证码失效问题
|
||||
docs(README): 更新部署文档
|
||||
```
|
||||
|
||||
### PR规范
|
||||
- 描述清晰:目的/影响/涉及模块
|
||||
- 包含测试说明
|
||||
- 前端改动附截图
|
||||
|
||||
---
|
||||
|
||||
|
||||
### Lombok
|
||||
```java
|
||||
@Slf4j // 自动注入logger
|
||||
@Data // getter/setter/toString
|
||||
@EqualsAndHashCode // equals/hashCode
|
||||
@AllArgsConstructor // 全参构造
|
||||
@NoArgsConstructor // 无参构造
|
||||
```
|
||||
|
||||
### MyBatis-Plus
|
||||
```java
|
||||
@TableName("table_name") // 表名映射
|
||||
@TableId // 主键
|
||||
@TableField(exist = false) // 非数据库字段
|
||||
@TableField(fill = FieldFill.INSERT) // 插入时填充
|
||||
@TableLogic // 逻辑删除
|
||||
```
|
||||
|
||||
### Spring
|
||||
```java
|
||||
@RestController // REST控制器
|
||||
@Service // 业务层
|
||||
@Transactional // 事务管理
|
||||
@Cacheable // 查询缓存
|
||||
@CachePut // 更新缓存
|
||||
@CacheEvict // 清除缓存
|
||||
@Async // 异步执行
|
||||
```
|
||||
|
||||
### 项目自定义
|
||||
```java
|
||||
@AuditLog(operation = "操作描述") // 审计日志
|
||||
@IgnoreTenantScope // 跳过租户隔离
|
||||
@Lock(key = "lock_key") // 分布式锁
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 开发最佳实践
|
||||
|
||||
**⚠️ 重要:所有后台开发必须严格遵循本 Skill 中的规范和模式**
|
||||
|
||||
### 1. 实体类设计
|
||||
- 继承 `SuperEntity` 获得id/createTime/updateTime
|
||||
- **必须为每个字段添加注释**,说明字段的业务含义
|
||||
- 枚举类型注明可选值,布尔类型注明 true/false 含义
|
||||
- 使用 `@TableLogic` 实现逻辑删除
|
||||
- 非数据库字段标记 `@TableField(exist = false)`
|
||||
|
||||
### 2. Service层规范
|
||||
- 接口继承 `ISuperService<T>`
|
||||
- 实现继承 `SuperServiceImpl<Mapper, Entity>`
|
||||
- **优先使用 MPJBaseMapper 的 Lambda 方式**,少用 XML
|
||||
- 只有复杂 SQL(多表关联、子查询、复杂统计)才使用 XML
|
||||
- 事务方法添加 `@Transactional(rollbackFor = Exception.class)`
|
||||
- 并发操作使用 `saveOrUpdateIdempotency()` 保证幂等性
|
||||
|
||||
### 3. 用户查询规范
|
||||
- **全局统一使用**: `SysUser sysUser = userService.findUserById(userId);`
|
||||
- 获取当前登录用户: `LoginUserContextHolder.getUser()`
|
||||
|
||||
### 4. 缓存使用
|
||||
- 查询使用 `@Cacheable`
|
||||
- 更新使用 `@CachePut`
|
||||
- 删除使用 `@CacheEvict`
|
||||
- 配置缓存过期时间
|
||||
|
||||
### 4. 异常处理
|
||||
- 业务异常抛出 `BusinessException`
|
||||
- 全局异常由 `DefaultExceptionAdvice` 统一处理
|
||||
- 返回统一格式 `Result<T>`
|
||||
|
||||
### 5. 日志规范
|
||||
- 使用 `@Slf4j` 注解
|
||||
- 关键操作添加 `@AuditLog`
|
||||
- 日志自动包含 TraceId
|
||||
|
||||
### 6. 安全规范
|
||||
- 禁止提交密钥和凭据
|
||||
- 使用环境变量或配置中心
|
||||
- 敏感操作添加审计日志
|
||||
|
||||
---
|
||||
|
||||
|
||||
### OAuth2 认证中心(zlt-uaa)
|
||||
|
||||
**支持的授权方式**:
|
||||
- `password` - 用户名密码
|
||||
- `password_code` - 密码+验证码
|
||||
- `mobile` - 手机号认证
|
||||
- `openid` - OpenID认证
|
||||
- `tencent` - 腾讯第三方登录
|
||||
|
||||
**Token生成流程**:
|
||||
```
|
||||
登录请求 → AuthenticationProvider → BaseAuthenticationProvider
|
||||
→ TokenGenerator (JWT + AccessToken + RefreshToken)
|
||||
→ 保存到Redis → 返回Token响应
|
||||
```
|
||||
|
||||
**Token增强**: 自动添加用户ID、用户名、账户类型等信息
|
||||
|
||||
**Token存储**: Redis(默认)或内存
|
||||
|
||||
### API网关(sc-gateway)
|
||||
|
||||
**动态路由**: Nacos配置中心热更新
|
||||
```yaml
|
||||
zlt:
|
||||
gateway:
|
||||
dynamicRoute:
|
||||
enabled: true
|
||||
dataType: nacos
|
||||
```
|
||||
|
||||
**过滤器链**:
|
||||
```
|
||||
请求 → TraceFilter(链路追踪) → RequestFilter(方法验证)
|
||||
→ ResourceServer(Token验证) → PermissionAuthManager(权限检查)
|
||||
→ 后端服务
|
||||
```
|
||||
|
||||
**权限检查**:
|
||||
- 超级管理员(admin)自动放行
|
||||
- 应用黑白名单控制
|
||||
- URL级别权限验证
|
||||
- 支持忽略列表配置
|
||||
|
||||
---
|
||||
|
||||
## 构建与运行
|
||||
|
||||
### 构建命令
|
||||
|
||||
```bash
|
||||
# 全量构建(跳过测试)
|
||||
mvn -q -DskipTests clean package
|
||||
|
||||
# 全量测试
|
||||
mvn -q test
|
||||
|
||||
# 指定模块构建+测试
|
||||
mvn -pl zlt-business/user-center -am clean verify
|
||||
```
|
||||
|
||||
### 本地运行
|
||||
|
||||
```bash
|
||||
# 运行网关
|
||||
mvn -pl zlt-gateway/sc-gateway -am spring-boot:run
|
||||
|
||||
# 运行认证中心
|
||||
mvn -pl zlt-uaa -am spring-boot:run
|
||||
|
||||
# 从JAR运行
|
||||
java -jar zlt-gateway/sc-gateway/target/*.jar
|
||||
```
|
||||
|
||||
**先决条件**: JDK 17、Maven 3.8+
|
||||
|
||||
### 配置文件
|
||||
|
||||
**bootstrap.yml** (服务启动配置):
|
||||
```yaml
|
||||
spring:
|
||||
application:
|
||||
name: user-center # 服务名
|
||||
```
|
||||
|
||||
**application.yml** (通常从Nacos读取):
|
||||
```yaml
|
||||
spring:
|
||||
datasource:
|
||||
url: jdbc:mysql://localhost/user-center
|
||||
username: root
|
||||
password: password
|
||||
|
||||
mybatis-plus:
|
||||
mapper-locations: classpath:/mapper/*Mapper.xml
|
||||
|
||||
zlt:
|
||||
tenant:
|
||||
enable: true
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
|
||||
### 核心基础库(zlt-common-core)
|
||||
|
||||
**通用返回模型**:
|
||||
```java
|
||||
Result<T> // API返回包装 {data, resp_code, resp_msg}
|
||||
PageResult<T> // 分页返回 {count, data, resp_code}
|
||||
```
|
||||
|
||||
**用户与租户上下文**:
|
||||
```java
|
||||
LoginUserContextHolder.getUser() // 获取当前登录用户
|
||||
TenantContextHolder.getTenantId() // 获取当前租户ID
|
||||
LoginUserUtils.getCurrentUser(true) // 从请求获取用户
|
||||
|
||||
// 全局根据userId获取用户的标准方法
|
||||
SysUser sysUser = userService.findUserById(userId);
|
||||
```
|
||||
|
||||
**常用工具类**:
|
||||
- `JsonUtil` - JSON序列化
|
||||
- `IdGenerator` - 分布式ID生成
|
||||
- `ExcelUtil` - Excel导入导出
|
||||
- `ResponseUtil` - HTTP响应工具
|
||||
|
||||
**异常处理**:
|
||||
- `BusinessException` - 业务异常
|
||||
- `DefaultExceptionAdvice` - 全局异常处理
|
||||
|
||||
### 分布式锁(zlt-redis-spring-boot-starter)
|
||||
|
||||
```java
|
||||
// 方式1: 注解驱动
|
||||
@Lock(key = "order:create", waitTime = 5, leaseTime = 10)
|
||||
public void createOrder() { ... }
|
||||
|
||||
// 方式2: 手动调用
|
||||
@Autowired
|
||||
private DistributedLock lock;
|
||||
|
||||
ZLock zlock = lock.tryLock("order:123", 5, 10, TimeUnit.SECONDS);
|
||||
try {
|
||||
// 业务逻辑
|
||||
} finally {
|
||||
lock.unlock(zlock);
|
||||
}
|
||||
```
|
||||
|
||||
### Redis 缓存
|
||||
|
||||
```java
|
||||
@Autowired
|
||||
private RedisRepository redisRepository;
|
||||
|
||||
// 基础操作
|
||||
redisRepository.set("key", value, 3600, TimeUnit.SECONDS);
|
||||
Object value = redisRepository.get("key");
|
||||
redisRepository.del("key");
|
||||
|
||||
// Hash操作
|
||||
redisRepository.hSet("hash:key", "field", value);
|
||||
Object field = redisRepository.hGet("hash:key", "field");
|
||||
```
|
||||
|
||||
### 审计日志
|
||||
|
||||
```java
|
||||
@AuditLog(operation = "'创建订单:' + #order.orderNo")
|
||||
public void createOrder(Order order) {
|
||||
// 自动记录: 操作时间、操作人、操作内容、IP地址
|
||||
}
|
||||
```
|
||||
|
||||
### 多租户隔离
|
||||
|
||||
**自动隔离**: SQL自动添加 `WHERE tenant_id = ?`
|
||||
|
||||
**跳过隔离**:
|
||||
```java
|
||||
@IgnoreTenantScope
|
||||
public List<SysUser> findAllUsers() {
|
||||
// 查询所有租户的用户
|
||||
}
|
||||
```
|
||||
|
||||
**配置忽略表**:
|
||||
```yaml
|
||||
zlt:
|
||||
tenant:
|
||||
enable: true
|
||||
ignoreTables:
|
||||
- sys_user
|
||||
- sys_role
|
||||
```
|
||||
|
||||
### 链路追踪
|
||||
|
||||
**自动传播**: TraceId 自动跨服务传递(Web → Feign → Dubbo)
|
||||
|
||||
**MDC集成**: 日志自动包含 TraceId
|
||||
```
|
||||
[TraceId: abc123] 用户登录成功
|
||||
```
|
||||
|
||||
### 对象存储(zlt-oss-spring-boot-starter)
|
||||
|
||||
```java
|
||||
@Autowired
|
||||
private IOssService ossService;
|
||||
|
||||
// 上传文件
|
||||
ObjectInfo info = ossService.upload(multipartFile);
|
||||
|
||||
// 上传流
|
||||
ObjectInfo info = ossService.upload("path/file.jpg", inputStream);
|
||||
|
||||
// 删除
|
||||
ossService.delete("path/file.jpg");
|
||||
```
|
||||
|
||||
支持: FastDFS、Amazon S3、阿里云OSS、腾讯云COS
|
||||
|
||||
---
|
||||
|
||||
|
||||
### Controller 层
|
||||
|
||||
```java
|
||||
@Slf4j
|
||||
@RestController
|
||||
@Tag(name = "用户管理")
|
||||
public class SysUserController {
|
||||
@Autowired
|
||||
private ISysUserService userService;
|
||||
|
||||
// 查询单条
|
||||
@GetMapping("/users/{id}")
|
||||
@Operation(summary = "根据ID查询用户")
|
||||
public Result<SysUser> findById(@PathVariable Long id) {
|
||||
return Result.succeed(userService.getById(id));
|
||||
}
|
||||
|
||||
// 分页查询
|
||||
@GetMapping("/users")
|
||||
public PageResult<SysUser> findUsers(@RequestParam Map<String, Object> params) {
|
||||
return userService.findUsers(params);
|
||||
}
|
||||
|
||||
// 新增或更新
|
||||
@PostMapping("/users/saveOrUpdate")
|
||||
@AuditLog(operation = "'保存用户:' + #user.username")
|
||||
public Result saveOrUpdate(@RequestBody SysUser user) {
|
||||
return userService.saveOrUpdateUser(user);
|
||||
}
|
||||
|
||||
// 删除
|
||||
@DeleteMapping("/users/{id}")
|
||||
public Result delete(@PathVariable Long id) {
|
||||
userService.delUser(id);
|
||||
return Result.succeed("删除成功");
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**关键注解**:
|
||||
- `@RestController` - REST控制器
|
||||
- `@Tag` / `@Operation` - Swagger 3.0文档
|
||||
- `@AuditLog` - 审计日志(自动记录操作)
|
||||
- `@CachePut` / `@Cacheable` - 缓存管理
|
||||
|
||||
### Service 层
|
||||
|
||||
```java
|
||||
// 接口
|
||||
public interface ISysUserService extends ISuperService<SysUser> {
|
||||
PageResult<SysUser> findUsers(Map<String, Object> params);
|
||||
Result saveOrUpdateUser(SysUser user);
|
||||
boolean delUser(Long id);
|
||||
}
|
||||
|
||||
// 实现
|
||||
@Slf4j
|
||||
@Service
|
||||
public class SysUserServiceImpl extends SuperServiceImpl<SysUserMapper, SysUser>
|
||||
implements ISysUserService {
|
||||
|
||||
@Autowired
|
||||
private DistributedLock lock;
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public Result saveOrUpdateUser(SysUser user) {
|
||||
// 幂等性保证
|
||||
boolean result = super.saveOrUpdateIdempotency(user, lock,
|
||||
"username:" + user.getUsername(),
|
||||
new QueryWrapper<SysUser>().eq("username", user.getUsername()),
|
||||
"用户名已存在"
|
||||
);
|
||||
return result ? Result.succeed(user) : Result.failed("操作失败");
|
||||
}
|
||||
|
||||
@Override
|
||||
@IgnoreTenantScope // 跳过租户隔离
|
||||
public List<SysRole> findRoles(Long userId) {
|
||||
return roleMapper.findByUserId(userId);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**关键点**:
|
||||
- 继承 `SuperServiceImpl<Mapper, Entity>`
|
||||
- `@Transactional` 事务管理
|
||||
- `saveOrUpdateIdempotency()` 幂等性操作
|
||||
- `@IgnoreTenantScope` 跳过多租户隔离
|
||||
|
||||
### Mapper 层
|
||||
|
||||
```java
|
||||
@Mapper
|
||||
public interface SysUserMapper extends SuperMapper<SysUser> {
|
||||
// 简单查询优先使用 MPJBaseMapper 的 Lambda 方式
|
||||
// 复杂查询才使用 XML
|
||||
List<SysUser> findList(Page<SysUser> page, @Param("u") Map<String, Object> params);
|
||||
}
|
||||
```
|
||||
|
||||
**重要规范**:
|
||||
- 继承 `SuperMapper<T>` (基于 MPJBaseMapper)
|
||||
- **优先使用 MPJBaseMapper 的 Lambda 方式**,少用 XML
|
||||
- 只有复杂 SQL(多表关联、子查询、复杂统计)才使用 `*Mapper.xml`
|
||||
|
||||
**MPJBaseMapper 使用示例**:
|
||||
```java
|
||||
// Service 实现中使用 MPJBaseMapper
|
||||
@Service
|
||||
public class OrderServiceImpl extends SuperServiceImpl<OrderMapper, Order> {
|
||||
|
||||
// 简单关联查询 - 使用 MPJBaseMapper
|
||||
public List<Order> findOrdersWithUser(Long userId) {
|
||||
return baseMapper.selectJoinList(Order.class,
|
||||
new MPJLambdaWrapper<Order>()
|
||||
.selectAll(Order.class)
|
||||
.select(SysUser::getUsername, SysUser::getNickname)
|
||||
.leftJoin(SysUser.class, SysUser::getId, Order::getUserId)
|
||||
.eq(Order::getUserId, userId)
|
||||
);
|
||||
}
|
||||
|
||||
// 复杂统计查询 - 使用 XML
|
||||
public List<OrderStatVO> getOrderStats(Map<String, Object> params) {
|
||||
return baseMapper.getOrderStats(params);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### 实体类
|
||||
|
||||
**重要规范**: 所有字段必须添加注释说明字段作用
|
||||
|
||||
```java
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@TableName("sys_user")
|
||||
public class SysUser extends SuperEntity {
|
||||
/** 用户名(登录账号) */
|
||||
private String username;
|
||||
|
||||
/** 密码(加密存储) */
|
||||
private String password;
|
||||
|
||||
/** 昵称(显示名称) */
|
||||
private String nickname;
|
||||
|
||||
/** 手机号 */
|
||||
private String mobile;
|
||||
|
||||
/** 是否启用(true=启用,false=禁用) */
|
||||
private Boolean enabled;
|
||||
|
||||
/** 用户类型(APP=移动端用户,BACKEND=后台用户) */
|
||||
private String type;
|
||||
|
||||
/** 逻辑删除标记(true=已删除,false=未删除) */
|
||||
@TableLogic
|
||||
private boolean isDel;
|
||||
|
||||
/** 用户角色列表(非数据库字段,用于传输) */
|
||||
@TableField(exist = false)
|
||||
private List<SysRole> roles;
|
||||
|
||||
/** 角色ID(非数据库字段,用于前端传参) */
|
||||
@TableField(exist = false)
|
||||
private String roleId;
|
||||
}
|
||||
```
|
||||
|
||||
**基类 SuperEntity**:
|
||||
```java
|
||||
public class SuperEntity {
|
||||
/** 主键ID(自增) */
|
||||
@TableId
|
||||
private Long id;
|
||||
|
||||
/** 创建时间(插入时自动填充) */
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
private Date createTime;
|
||||
|
||||
/** 更新时间(插入和更新时自动填充) */
|
||||
@TableField(fill = FieldFill.INSERT_UPDATE)
|
||||
private Date updateTime;
|
||||
}
|
||||
```
|
||||
|
||||
**字段注释规范**:
|
||||
- 必须说明字段的业务含义
|
||||
- 枚举类型需注明可选值
|
||||
- 布尔类型需注明 true/false 的含义
|
||||
- 关联字段需注明关联的表或实体
|
||||
|
||||
### Feign 服务调用
|
||||
|
||||
```java
|
||||
// 客户端定义
|
||||
@FeignClient(name = "order-center", fallback = OrderServiceFallback.class)
|
||||
public interface OrderCenterService {
|
||||
@DeleteMapping("/orders/user/{userId}")
|
||||
Result<String> deleteUserOrders(@PathVariable("userId") Long userId);
|
||||
}
|
||||
|
||||
// 熔断降级
|
||||
@Slf4j
|
||||
@Component
|
||||
public class OrderServiceFallback implements OrderCenterService {
|
||||
@Override
|
||||
public Result<String> deleteUserOrders(Long userId) {
|
||||
log.error("订单中心服务不可用,用户ID: {}", userId);
|
||||
return Result.failed("订单中心服务不可用");
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
|
||||
```
|
||||
central-platform
|
||||
├── zlt-commons/ # 公共模块(14个starter)
|
||||
│ ├── zlt-common-core # 核心基础库
|
||||
│ ├── zlt-db-spring-boot-starter # 数据库增强
|
||||
│ ├── zlt-redis-spring-boot-starter # Redis缓存
|
||||
│ ├── zlt-auth-client-spring-boot-starter # OAuth2客户端
|
||||
│ ├── zlt-log-spring-boot-starter # 日志链路追踪
|
||||
│ ├── zlt-oss-spring-boot-starter # 对象存储
|
||||
│ └── zlt-common-spring-boot-starter # 多租户过滤器
|
||||
├── zlt-uaa/ # 认证中心 [8000]
|
||||
├── zlt-gateway/sc-gateway/ # API网关 [9900]
|
||||
├── zlt-business/ # 业务服务
|
||||
│ ├── user-center # 用户中心 [7000]
|
||||
│ ├── order-center # 订单中心
|
||||
│ ├── device-center # 设备中心
|
||||
│ ├── file-center # 文件中心 [5000]
|
||||
│ ├── msg-center # 消息中心
|
||||
│ └── coupon-center # 优惠券中心
|
||||
├── zlt-monitor/ # 监控
|
||||
│ ├── sc-admin # 应用监控 [6500]
|
||||
│ └── log-center # 日志中心 [7200]
|
||||
└── zlt-web/ # 前端
|
||||
├── react-web-next # React前端
|
||||
└── yingyan # 鹰眼前端
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 语言与编码规范
|
||||
|
||||
### 交互语言
|
||||
- **所有回复、解释、建议、错误信息必须使用中文(简体)**
|
||||
- 代码注释、日志消息、文档内容使用中文
|
||||
- 编程关键字、API标识符保持原文
|
||||
- 提交信息、PR描述、Issue使用中文
|
||||
- 所有文本使用 UTF-8 编码
|
||||
|
||||
### 命名约定
|
||||
- **包名**: `com.central.*`
|
||||
- **模块名**: `zlt-*` 前缀
|
||||
- **类名**: PascalCase(如 `SysUserController`)
|
||||
- **方法/字段**: lowerCamelCase(如 `findUserById`)
|
||||
- **常量**: UPPER_SNAKE_CASE(如 `TOKEN_HEADER`)
|
||||
- **接口**: `I` 前缀(如 `ISysUserService`)
|
||||
- **实现类**: `Impl` 后缀(如 `SysUserServiceImpl`)
|
||||
- **测试类**: `*Test.java` 后缀
|
||||
|
||||
### 代码风格
|
||||
- 4空格缩进(Java)
|
||||
- 左大括号同一行
|
||||
- UTF-8 编码
|
||||
- 优先使用 Lombok 注解(`@Data`, `@Slf4j`)
|
||||
- 尽量不要controller层编写业务代码,在service层写业务代码
|
||||
|
||||
---
|
||||
|
||||
## 标准分层架构
|
||||
|
||||
### 四层分层模式
|
||||
|
||||
```
|
||||
Controller 层 (HTTP入口)
|
||||
↓
|
||||
Service 接口 (ISxxService)
|
||||
↓
|
||||
Service 实现 (SxxServiceImpl)
|
||||
↓
|
||||
Mapper 接口 (数据库访问)
|
||||
```
|
||||
|
||||
### 标准包结构
|
||||
|
||||
```java
|
||||
com.central.{module}/
|
||||
├── controller/ // HTTP入口层
|
||||
├── service/ // Service接口
|
||||
│ └── impl/ // Service实现
|
||||
├── mapper/ // MyBatis-Plus Mapper
|
||||
├── model/ // 实体类
|
||||
│ ├── dto/ // 数据传输对象
|
||||
│ └── vo/ // 值对象
|
||||
├── feign/ // Feign客户端
|
||||
│ └── fallback/ // 熔断降级
|
||||
├── config/ // 配置类
|
||||
├── constants/ // 常量
|
||||
├── enums/ // 枚举
|
||||
├── event/ // 事件
|
||||
├── listener/ // 监听器
|
||||
└── util/ // 工具类
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
@@ -1,466 +0,0 @@
|
||||
# react-web-next 项目 Skill
|
||||
|
||||
**适用范围**: `zlt-web/react-web-next`
|
||||
|
||||
**强制要求**: 在该项目中进行开发、修复、重构、迁移时,默认以本 Skill 为第一约束;除非用户明确要求,否则不要偏离这里定义的结构、边界和实现方式。
|
||||
|
||||
## 1. 项目一句话定义
|
||||
|
||||
`react-web-next` 是旧版 `zlt-web/react-web` 的重构版管理后台:
|
||||
|
||||
- 保持旧功能、旧接口、旧菜单路径兼容
|
||||
- 用更清晰的页面/组件/service/utils 分层重组代码
|
||||
- 把“租户过滤”沉淀为横切基础设施
|
||||
- 在不升级核心技术栈的前提下优化 UI 与维护性
|
||||
|
||||
## 2. 技术边界
|
||||
|
||||
### 必须遵守
|
||||
|
||||
- React 17
|
||||
- UmiJS 3.5
|
||||
- Ant Design 4
|
||||
- `@ant-design/pro-components` 1.x
|
||||
- `@ant-design/pro-layout` 7.x
|
||||
- TypeScript 4.5,且 `strict: true`
|
||||
- Less + 主题变量 + 运行时主题包装
|
||||
|
||||
### 不要擅自做的事
|
||||
|
||||
- 不要切 React 18 写法再反向污染项目
|
||||
- 不要引入 Ant Design 5 的 token/ConfigProvider 主题范式替换现有体系
|
||||
- 不要为了“现代化”重做路由、菜单、登录态、代理机制
|
||||
- 不要把页面请求逻辑重新散落回页面组件内部
|
||||
|
||||
## 3. 先认清这 5 个核心事实
|
||||
|
||||
### 3.1 这是兼容旧后台路径的重构工程
|
||||
|
||||
- 大量页面仍然保留 `*.html` 路径,例如 `/system/user.html`
|
||||
- 这是兼容旧菜单入口、部署方式、历史链接的刻意设计
|
||||
- **不要批量改路由风格,不要把 `.html` 路径私自改没**
|
||||
|
||||
### 3.2 开发态和构建态的 API 路径策略不同
|
||||
|
||||
- 开发态:靠 `config/proxy.ts` 转发
|
||||
- 构建态:靠 `process.env.API_PREFIX` 注入请求前缀
|
||||
- `APP_BASE` 同时影响 `base`、`publicPath` 和最终部署目录
|
||||
|
||||
### 3.3 租户过滤不是页面私有逻辑,而是全局基础设施
|
||||
|
||||
- 首选 `src/components/TenantScopeFilter/index.tsx`
|
||||
- 配套缓存与 Token 保护在 `src/utils/tenantCache.ts`
|
||||
- 页面如果天然受租户影响,默认要先判断是否应接入这套能力
|
||||
|
||||
### 3.4 应用层已经统一接管了认证行为
|
||||
|
||||
- 全局入口在 `src/app.tsx`
|
||||
- 会自动注入 `Authorization: Bearer <token>`
|
||||
- 会统一处理 401/403 与部分业务未授权码
|
||||
- 会统一清理:
|
||||
- `sessionStorage.access_token`
|
||||
- `sessionStorage.current_user`
|
||||
- 租户缓存
|
||||
|
||||
### 3.5 后端返回结构需要兼容 `resp_code`
|
||||
|
||||
默认优先兼容:
|
||||
|
||||
```json
|
||||
{
|
||||
"resp_code": 0,
|
||||
"resp_msg": "success",
|
||||
"data": {}
|
||||
}
|
||||
```
|
||||
|
||||
前端处理后的目标语义应尽量统一为:
|
||||
|
||||
```ts
|
||||
{
|
||||
success: true,
|
||||
code: 0,
|
||||
msg: 'success',
|
||||
data: {}
|
||||
}
|
||||
```
|
||||
|
||||
**结论**: 新增 service、下载、列表查询、提交保存时,都要先考虑这层兼容,不要重新定义另一套响应契约。
|
||||
|
||||
## 4. 目录落位规则
|
||||
|
||||
```text
|
||||
zlt-web/react-web-next/
|
||||
├─ config/
|
||||
│ ├─ config.ts
|
||||
│ ├─ proxy.ts
|
||||
│ └─ routes.ts
|
||||
├─ src/
|
||||
│ ├─ app.tsx
|
||||
│ ├─ global.less
|
||||
│ ├─ theme.tsx
|
||||
│ ├─ layouts/
|
||||
│ ├─ pages/
|
||||
│ ├─ services/
|
||||
│ ├─ components/
|
||||
│ ├─ hooks/
|
||||
│ ├─ utils/
|
||||
│ ├─ theme/
|
||||
│ ├─ types/
|
||||
│ └─ typings.d.ts
|
||||
```
|
||||
|
||||
### 你改代码前先判断放哪层
|
||||
|
||||
- 页面编排、状态、弹窗、列表交互:`src/pages/`
|
||||
- 复用 UI 或复用业务组件:`src/components/`
|
||||
- API 请求与协议适配:`src/services/`
|
||||
- 跨页面纯逻辑、下载、导出、安全、缓存:`src/utils/`
|
||||
- 与 React 生命周期强相关、可复用的逻辑:`src/hooks/`
|
||||
- 顶层壳层、菜单、头部、账户区:`src/layouts/`
|
||||
|
||||
### 默认禁止
|
||||
|
||||
- 不要把接口直接堆在页面里
|
||||
- 不要把页面专属状态机塞进 `utils`
|
||||
- 不要把通用组件又复制一份到页面目录
|
||||
|
||||
## 5. 配置层规则
|
||||
|
||||
### `config/config.ts`
|
||||
|
||||
你需要知道它控制了:
|
||||
|
||||
- 显式路由入口:`routes.ts`
|
||||
- 开发/生产差异化 `publicPath`
|
||||
- `base` 与部署子路径
|
||||
- Ant Design 4 主题变量
|
||||
- `dynamicImport.loading`
|
||||
- `process.env.API_PREFIX`
|
||||
- `process.env.APP_BASE`
|
||||
- `process.env.CESIUM_BASE_URL`
|
||||
|
||||
### 配置层修改原则
|
||||
|
||||
- 影响部署路径时,同时检查 `base`、`publicPath`、构建脚本
|
||||
- 影响 API 访问时,同时检查 `proxy.ts` 和 `src/app.tsx` 的 request prefix
|
||||
- 影响 Cesium 资源时,不要绕开 `CESIUM_BASE_URL` 另造路径机制
|
||||
|
||||
### `config/proxy.ts`
|
||||
|
||||
已存在的代理重点:
|
||||
|
||||
- `/api-`
|
||||
- `/goflymodel`
|
||||
- `/rtc`
|
||||
- `/terraform`
|
||||
|
||||
新增代理规则前先问自己:
|
||||
|
||||
- 是开发态临时代理,还是生产态正式访问路径?
|
||||
- 这条规则是否应该进网关,而不是前端本地代理?
|
||||
|
||||
### `config/routes.ts`
|
||||
|
||||
主要业务域:
|
||||
|
||||
- `system`
|
||||
- `orders`
|
||||
- `device`
|
||||
- `log`
|
||||
- `search`
|
||||
- `files`
|
||||
|
||||
新增页面时:
|
||||
|
||||
- 优先挂到已有业务域下
|
||||
- 保持与旧菜单 URL 兼容
|
||||
- 普通后台页面默认走 `@/layouts/BasicLayout`
|
||||
|
||||
## 6. 页面开发规则
|
||||
|
||||
### 页面职责
|
||||
|
||||
页面负责:
|
||||
|
||||
- 组织查询区、操作区、表格区、弹窗区
|
||||
- 管理页面级状态
|
||||
- 调用 service
|
||||
- 组合通用组件
|
||||
|
||||
页面不负责:
|
||||
|
||||
- 直接写大量裸请求
|
||||
- 复制通用下载/导出/加密逻辑
|
||||
- 重复实现租户缓存或登录态处理
|
||||
|
||||
### 列表页默认长相
|
||||
|
||||
- 优先 ProTable / Ant Design Pro 风格
|
||||
- 查询区、工具栏、表格区分层清晰
|
||||
- 批量操作与单行操作分离
|
||||
- 页面如果受租户影响,优先在工具栏接入 `TenantScopeFilter`
|
||||
|
||||
### 复杂页面建议拆法
|
||||
|
||||
优先拆成:
|
||||
|
||||
1. 页面容器
|
||||
2. 表格或主展示区
|
||||
3. 查询条件区
|
||||
4. 编辑弹窗/抽屉
|
||||
5. service
|
||||
6. 页面专属 hooks 或 utils
|
||||
|
||||
## 7. 组件开发规则
|
||||
|
||||
### 统一组件规范
|
||||
|
||||
- 一律函数组件 + Hooks
|
||||
- Props 必须显式定义 TypeScript 类型
|
||||
- 优先保持低副作用、低耦合、可复用
|
||||
- 页面通用视觉组件优先放到 `src/components/ui/`
|
||||
|
||||
### 优先复用的现成组件
|
||||
|
||||
- `TenantScopeFilter`
|
||||
- `ActionBar`
|
||||
- `GradientButton`
|
||||
- `GlassCard`
|
||||
- `ThemeSwitch`
|
||||
- `PageHeaderPlus`
|
||||
|
||||
### 组件设计原则
|
||||
|
||||
- 复用价值高的交互下沉到组件层
|
||||
- 单页面专属又很重的块,不要强行抽成“伪通用”组件
|
||||
- 组件内部不要私自接管全局登录态或全局路由行为
|
||||
|
||||
## 8. Service 层规则
|
||||
|
||||
### 基本要求
|
||||
|
||||
- 所有请求默认进入 `src/services/`
|
||||
- 一个文件对应一个业务域
|
||||
- 统一使用 `request('/api-xxx/...')`
|
||||
- 统一处理参数映射和返回兼容
|
||||
|
||||
### Service 层该做什么
|
||||
|
||||
- 管理接口路径
|
||||
- 管理请求方法和参数
|
||||
- 处理返回数据兼容
|
||||
- 隔离页面与后端协议细节
|
||||
|
||||
### Service 层不该做什么
|
||||
|
||||
- 不要掺杂大量页面状态
|
||||
- 不要做重 UI 的逻辑
|
||||
- 不要重新实现 token 注入
|
||||
|
||||
### 已有参考
|
||||
|
||||
- `src/services/login.ts`
|
||||
- `src/services/tenant.ts`
|
||||
- `src/services/orders.ts`
|
||||
|
||||
### 写新 service 的默认模板
|
||||
|
||||
```ts
|
||||
import { request } from 'umi';
|
||||
|
||||
export async function queryExample(params: Record<string, unknown>) {
|
||||
return request('/api-example/path', {
|
||||
method: 'GET',
|
||||
params,
|
||||
});
|
||||
}
|
||||
|
||||
export async function saveExample(data: Record<string, unknown>) {
|
||||
return request('/api-example/path', {
|
||||
method: 'POST',
|
||||
data,
|
||||
});
|
||||
}
|
||||
```
|
||||
|
||||
## 9. Utils 与 Hooks 规则
|
||||
|
||||
### `src/utils/` 已有重点能力
|
||||
|
||||
- `request.ts`
|
||||
- `download.ts`
|
||||
- `export.ts`
|
||||
- `rsaUtil.ts`
|
||||
- `securityUtil.ts`
|
||||
- `tenantCache.ts`
|
||||
|
||||
### 什么时候放 utils
|
||||
|
||||
- 与 React 生命周期无关
|
||||
- 跨页面可复用
|
||||
- 纯逻辑、下载、导出、加密、缓存工具
|
||||
|
||||
### 什么时候放 hooks
|
||||
|
||||
- 跟组件生命周期、effect、状态协同强相关
|
||||
- 需要被多个页面/组件复用
|
||||
- 典型例子:`src/hooks/useSecurity.ts`
|
||||
|
||||
### 不要放错层
|
||||
|
||||
- 单纯对象转换,不要写成 hook
|
||||
- 页面专属临时状态,不要塞进 utils
|
||||
|
||||
## 10. 布局与主题规则
|
||||
|
||||
### 布局
|
||||
|
||||
`src/layouts/BasicLayout.tsx` 负责:
|
||||
|
||||
- 主后台壳层
|
||||
- 菜单和路由联动
|
||||
- 面包屑
|
||||
- 账户区
|
||||
- 统一框架风格
|
||||
|
||||
规则:
|
||||
|
||||
- 普通后台页默认挂在 `BasicLayout` 下
|
||||
- 不要为普通业务页再造一层平行顶层布局
|
||||
|
||||
### 主题
|
||||
|
||||
这个项目是双层主题体系:
|
||||
|
||||
1. Umi `theme` 配置 Ant Design 4 基础 token
|
||||
2. `src/theme.tsx` + `src/theme/modern.less` + `src/global.less` 做增强和运行时切换
|
||||
|
||||
样式开发要求:
|
||||
|
||||
- 优先复用已有变量、阴影、渐变、间距
|
||||
- 不要到处写魔法色值
|
||||
- 保持现代后台而不是另起一套审美体系
|
||||
|
||||
## 11. 登录、安全、租户三条红线
|
||||
|
||||
### 登录与安全
|
||||
|
||||
- 登录页:`src/pages/user/Login`
|
||||
- 登录 service:`src/services/login.ts`
|
||||
- 前端密码加密:`jsencrypt`
|
||||
- Token 存储:
|
||||
- `sessionStorage.access_token`
|
||||
- `sessionStorage.current_user`
|
||||
|
||||
禁止:
|
||||
|
||||
- 裸写明文密码提交流程替换现有逻辑
|
||||
- 绕开全局 request 拦截器单独处理认证头
|
||||
|
||||
### 租户
|
||||
|
||||
默认判断:
|
||||
|
||||
- 该页面数据是否按租户隔离?
|
||||
- 如果是,优先接入 `TenantScopeFilter`
|
||||
|
||||
禁止:
|
||||
|
||||
- 页面自己维护另一份租户树缓存
|
||||
- 页面自己发明新的“包含子租户”参数语义
|
||||
- 每个接口手写重复租户拼接逻辑而不复用现有设施
|
||||
|
||||
## 12. 3D / 地图相关边界
|
||||
|
||||
虽然它是管理后台,但已内置 3D 能力:
|
||||
|
||||
- 路由:
|
||||
- `/device/3dModel.html`
|
||||
- `/device/mapDashboard.html`
|
||||
- 代理:
|
||||
- `/goflymodel`
|
||||
- `/rtc`
|
||||
- `/terraform`
|
||||
|
||||
规则:
|
||||
|
||||
- 资源路径走 `CESIUM_BASE_URL`
|
||||
- 模型/流媒体跨域优先沿用现有代理策略
|
||||
- 不要随意替换资源根路径方案
|
||||
|
||||
## 13. TypeScript 规则
|
||||
|
||||
- 必须尊重 `strict: true`
|
||||
- 优先写明确接口/类型
|
||||
- 路径别名统一使用 `@/`
|
||||
- 全局声明与补充类型优先查看:
|
||||
- `src/typings.d.ts`
|
||||
- `src/types/`
|
||||
|
||||
严格禁止:
|
||||
|
||||
- `as any`
|
||||
- `@ts-ignore`
|
||||
- `@ts-expect-error`
|
||||
|
||||
## 14. 典型工作流
|
||||
|
||||
### 新增后台页面
|
||||
|
||||
1. 在 `config/routes.ts` 补路由,优先挂已有业务域
|
||||
2. 在 `src/pages/<domain>/` 建页面目录
|
||||
3. 在 `src/services/<domain>.ts` 补接口
|
||||
4. 判断是否需要接入 `TenantScopeFilter`
|
||||
5. 优先复用 `src/components/ui/` 组件
|
||||
6. 样式继承现有主题变量
|
||||
7. 确保响应兼容 `resp_code`
|
||||
|
||||
### 从旧 `react-web` 迁移页面
|
||||
|
||||
1. 先保功能等价,不先追求重写
|
||||
2. 保持接口地址、菜单 URL、参数语义尽量不变
|
||||
3. 把旧页拆成:页面 / 组件 / service / utils
|
||||
4. 把租户过滤从页面私有逻辑改为基础设施接入
|
||||
5. 再做局部 UI 统一
|
||||
|
||||
## 15. 决策清单
|
||||
|
||||
动手前自检:
|
||||
|
||||
- 这次改动是否破坏旧菜单 URL 兼容?
|
||||
- 这个请求是否应该放进现有 `src/services/`?
|
||||
- 这个页面是否应该接入租户过滤?
|
||||
- 是否复用了已有下载/导出/安全/缓存工具?
|
||||
- 是否仍然处在 React 17 + Antd4 + Umi3 的边界内?
|
||||
- 是否兼容 `resp_code / resp_msg / data`?
|
||||
|
||||
## 16. 明确禁止事项
|
||||
|
||||
- 擅自升级 React 18 / Ant Design 5 写法
|
||||
- 在页面中大量内联请求绕开 service
|
||||
- 为普通页面重复造布局壳层
|
||||
- 绕开全局 request 拦截器自行接管授权
|
||||
- 批量移除 `.html` 路径兼容
|
||||
- 新造一套与现有主题冲突的视觉体系
|
||||
|
||||
## 17. 优先参考文件
|
||||
|
||||
- `zlt-web/react-web-next/config/config.ts`
|
||||
- `zlt-web/react-web-next/config/routes.ts`
|
||||
- `zlt-web/react-web-next/config/proxy.ts`
|
||||
- `zlt-web/react-web-next/src/app.tsx`
|
||||
- `zlt-web/react-web-next/src/layouts/BasicLayout.tsx`
|
||||
- `zlt-web/react-web-next/src/components/TenantScopeFilter/index.tsx`
|
||||
- `zlt-web/react-web-next/src/services/login.ts`
|
||||
- `zlt-web/react-web-next/src/services/tenant.ts`
|
||||
- `zlt-web/react-web-next/src/services/orders.ts`
|
||||
- `zlt-web/react-web-next/src/utils/tenantCache.ts`
|
||||
- `zlt-web/react-web-next/src/utils/download.ts`
|
||||
- `zlt-web/react-web-next/src/utils/export.ts`
|
||||
- `zlt-web/react-web-next/src/theme.tsx`
|
||||
- `zlt-web/react-web-next/src/theme/modern.less`
|
||||
|
||||
---
|
||||
|
||||
*最后更新: 2026-04-01*
|
||||
@@ -1,463 +0,0 @@
|
||||
# yingyan 项目 Skill
|
||||
|
||||
**适用范围**: `zlt-web/yingyan`
|
||||
|
||||
**强制要求**: 在该项目中进行 3D 可视化、监控大屏、客户端 Pad、海事场景、地图控制、实时通信相关开发时,默认以本 Skill 为第一约束;除非用户明确要求,否则不要偏离这里定义的结构、边界和实现方式。
|
||||
|
||||
## 1. 项目一句话定义
|
||||
|
||||
`yingyan` 是“鹰眼”3D 可视化管控平台,不是传统后台 CRUD 前端:
|
||||
|
||||
- 以监控大屏、海事场景、3D 地图、Pad 客户端为核心产品形态
|
||||
- 以 Cesium、SSE、WebSocket、深色科技风为核心实现特征
|
||||
- 复用管理端认证、租户、服务接口,但交互模型明显不同于普通后台
|
||||
- 重点不是表单堆砌,而是场景容器、可视化面板、实时状态与地图交互
|
||||
|
||||
## 2. 技术边界
|
||||
|
||||
### 必须遵守
|
||||
|
||||
- React 18
|
||||
- UmiJS 3.5
|
||||
- Ant Design 5
|
||||
- `@ant-design/pro-components` 2.x
|
||||
- TypeScript 5.9,且 `strict: true`
|
||||
- Ant Design 5 `ConfigProvider` 主题体系
|
||||
- Cesium 1.110
|
||||
- `dayjs`
|
||||
|
||||
### 不要擅自做的事
|
||||
|
||||
- 不要把 `react-web-next` 的 Ant Design 4 / Less token 方案直接搬进来
|
||||
- 不要把大屏/地图页改造成普通后台管理页布局
|
||||
- 不要绕开现有 Cesium hook、实时连接 hook、编辑器子系统另造平行实现
|
||||
- 不要把客户端 `/client` 的认证逻辑和管理端 token 逻辑混用
|
||||
|
||||
## 3. 先认清这 6 个核心事实
|
||||
|
||||
### 3.1 这不是普通后台,而是多形态可视化平台
|
||||
|
||||
- 路由同时覆盖管理登录、客户端登录、监控大屏、海事大屏、3D 地图
|
||||
- 页面差异很大,但底层仍共用 Umi、request、租户、部分服务接口
|
||||
- 你做功能前,先判断它属于后台管理、地图场景、客户端 Pad 还是大屏信息展示
|
||||
|
||||
### 3.2 主题体系是 Ant Design 5 + 深色科技风
|
||||
|
||||
- `config/config.ts` 中 `antd: false`
|
||||
- 主题由 `src/theme.tsx` 中的 `ConfigProvider` 接管
|
||||
- 主色、成功色、暗色算法都已统一设定
|
||||
- **不要回退到 Ant Design 4 的 Less 变量主题改法**
|
||||
|
||||
### 3.3 这是双登录体系,不是单一 token 模型
|
||||
|
||||
- 管理端使用:
|
||||
- `sessionStorage.access_token`
|
||||
- `sessionStorage.current_user`
|
||||
- 客户端 `/client` 使用:
|
||||
- `sessionStorage.client_device_sn`
|
||||
- 新逻辑必须先区分当前路径属于管理端还是客户端
|
||||
|
||||
### 3.4 实时数据是基础设施,不是页面临时能力
|
||||
|
||||
- 已有 SSE hook
|
||||
- 已有设备控制 WebSocket service
|
||||
- 已有视频流代理
|
||||
- 页面应消费状态,而不是在 JSX 内到处散写连接生命周期
|
||||
|
||||
### 3.5 3D 能力已经形成子系统,不要单文件硬写
|
||||
|
||||
- 已有 `MapContainer`
|
||||
- 已有 `CesiumContainer`
|
||||
- 已有 `RouteEditor`
|
||||
- 已有 `BoundaryEditor`
|
||||
- 已有 tileset / drone / boat / track / route renderer 等 hook
|
||||
|
||||
### 3.6 后端响应依然优先兼容 `resp_code`
|
||||
|
||||
默认优先兼容:
|
||||
|
||||
```json
|
||||
{
|
||||
"resp_code": 0,
|
||||
"resp_msg": "success",
|
||||
"data": {}
|
||||
}
|
||||
```
|
||||
|
||||
结论:
|
||||
|
||||
- 新增 service 时不要发明全新响应契约
|
||||
- 页面层不要直接假设所有接口都已经是纯前端理想结构
|
||||
|
||||
## 4. 目录落位规则
|
||||
|
||||
```text
|
||||
zlt-web/yingyan/
|
||||
├─ config/
|
||||
│ ├─ config.ts
|
||||
│ ├─ proxy.ts
|
||||
│ └─ routes.ts
|
||||
├─ src/
|
||||
│ ├─ app.tsx
|
||||
│ ├─ global.less
|
||||
│ ├─ theme.tsx
|
||||
│ ├─ layouts/
|
||||
│ ├─ pages/
|
||||
│ ├─ services/
|
||||
│ ├─ components/
|
||||
│ ├─ hooks/
|
||||
│ ├─ utils/
|
||||
│ ├─ types/
|
||||
│ └─ typings.d.ts
|
||||
```
|
||||
|
||||
### 你改代码前先判断放哪层
|
||||
|
||||
- 页面容器、页面状态、主交互编排:`src/pages/`
|
||||
- 复用组件、通用可视化面板、平台切换器:`src/components/`
|
||||
- API、实时控制协议、后端接口封装:`src/services/`
|
||||
- 纯工具、缓存、加密、协议辅助:`src/utils/`
|
||||
- 与 React 生命周期强相关的 Cesium / SSE / 状态逻辑:`hooks` 或页面子目录内 hooks
|
||||
- 顶层头部、布局槽位、统一壳层:`src/layouts/`
|
||||
|
||||
### 默认禁止
|
||||
|
||||
- 不要把 viewer 级逻辑直接堆进页面根组件
|
||||
- 不要把页面专属临时状态塞进全局 utils
|
||||
- 不要把通用面板复制到多个页面目录各自维护
|
||||
|
||||
## 5. 配置层规则
|
||||
|
||||
### `config/config.ts`
|
||||
|
||||
你需要知道它控制了:
|
||||
|
||||
- `antd: false`
|
||||
- `routes.ts`
|
||||
- 开发/生产差异化 `publicPath`
|
||||
- `base` 与部署子路径
|
||||
- `dynamicImport.loading`
|
||||
- `process.env.API_PREFIX`
|
||||
- `process.env.APP_BASE`
|
||||
- `process.env.CESIUM_BASE_URL`
|
||||
|
||||
### 配置层修改原则
|
||||
|
||||
- 改部署路径时,同时检查 `base`、`publicPath`、构建脚本
|
||||
- 改 API 访问时,同时检查 `proxy.ts` 与 `src/app.tsx` 中 request prefix
|
||||
- 改 Cesium 资源路径时,不要绕开 `CESIUM_BASE_URL`
|
||||
- 改主题时,优先改 `src/theme.tsx` 的 `ConfigProvider` 配置,而不是退回旧体系
|
||||
|
||||
### `config/proxy.ts`
|
||||
|
||||
已存在的代理重点:
|
||||
|
||||
- `/api-`
|
||||
- `/goflymodel`
|
||||
- `/rtc`
|
||||
- `/terraform`
|
||||
|
||||
新增代理前先问自己:
|
||||
|
||||
- 这是开发期代理,还是正式线上路径?
|
||||
- 是否应由网关、Nginx 或后端服务接管,而不是前端本地代理?
|
||||
|
||||
### `config/routes.ts`
|
||||
|
||||
核心页面包括:
|
||||
|
||||
- `/user/login`
|
||||
- `/client/login`
|
||||
- `/client`
|
||||
- `/dashboard`
|
||||
- `/maritime`
|
||||
- `/map3d`
|
||||
|
||||
规则:
|
||||
|
||||
- 管理登录与客户端登录不挂主布局
|
||||
- 主应用默认挂 `@/layouts/BlankLayout`
|
||||
- 不要把地图页和大屏页硬改造成 ProLayout 导航壳层
|
||||
|
||||
## 6. 页面开发规则
|
||||
|
||||
### 页面职责
|
||||
|
||||
页面负责:
|
||||
|
||||
- 组织场景容器、面板、头部插槽、可视化区块
|
||||
- 管理页面级状态
|
||||
- 组合 hook 与 service
|
||||
- 控制子组件装配关系
|
||||
|
||||
页面不负责:
|
||||
|
||||
- 直接维护大量 viewer 底层实体生命周期
|
||||
- 到处手搓 SSE / WebSocket 连接
|
||||
- 把复杂地图交互全部堆在单个组件中
|
||||
|
||||
### 不同页面类型的默认思路
|
||||
|
||||
#### 大屏页
|
||||
|
||||
- 强调信息区块、KPI、卡片、视觉层次
|
||||
- 组件通常拆在对应页面的 `components/`
|
||||
|
||||
#### 地图页
|
||||
|
||||
- 强调容器 + 面板 + hook 分层
|
||||
- viewer、实体、轨迹、绘制、加载逻辑优先下沉
|
||||
|
||||
#### 客户端页
|
||||
|
||||
- 强调沉浸式交互与状态联动
|
||||
- 登录、导航、遥测、路线预览优先在 `src/pages/client/` 内自洽管理
|
||||
|
||||
## 7. 组件开发规则
|
||||
|
||||
### 统一组件规范
|
||||
|
||||
- 一律函数组件 + Hooks
|
||||
- Props 必须显式定义 TypeScript 类型
|
||||
- 复杂视觉页面拆成容器层、面板层、hook 层
|
||||
- 复用价值高的场景组件优先抽离,不要复制实现
|
||||
|
||||
### 优先复用的现成组件
|
||||
|
||||
- `TenantScopeFilter`
|
||||
- `PlatformSwitcher`
|
||||
- `PageLoading`
|
||||
|
||||
### 地图/大屏组件设计原则
|
||||
|
||||
- 容器组件负责装配
|
||||
- 面板组件负责展示和局部交互
|
||||
- hook 负责副作用、场景对象、连接管理
|
||||
- service 负责远端协议与接口
|
||||
|
||||
## 8. Service 层规则
|
||||
|
||||
### 基本要求
|
||||
|
||||
- 所有接口默认进入 `src/services/`
|
||||
- 一个文件对应一个业务域
|
||||
- 统一封装请求、参数映射、返回兼容
|
||||
- 需要实时控制时,区分 HTTP service 和 WebSocket service
|
||||
|
||||
### 常见 service 领域
|
||||
|
||||
- `login.ts`
|
||||
- `device.ts`
|
||||
- `dashboard.ts`
|
||||
- `mission.ts`
|
||||
- `boatRoute.ts`
|
||||
- `waterBoundary.ts`
|
||||
- `threeDModel.ts`
|
||||
- `maritime.ts`
|
||||
- `tenant.ts`
|
||||
- `deviceControlWs.ts`
|
||||
|
||||
### Service 层该做什么
|
||||
|
||||
- 管理接口路径和请求方法
|
||||
- 隔离页面与后端协议细节
|
||||
- 统一兼容 `resp_code / resp_msg / data`
|
||||
- 为地图/航线/边界/模型等能力提供清晰 API
|
||||
|
||||
### Service 层不该做什么
|
||||
|
||||
- 不要塞入重 UI 逻辑
|
||||
- 不要接管页面状态机
|
||||
- 不要在 service 里重新实现布局或页面判断
|
||||
|
||||
## 9. Hooks 与实时通信规则
|
||||
|
||||
### 什么时候放 hooks
|
||||
|
||||
- 需要跟 React 生命周期绑定
|
||||
- 需要管理连接、清理、副作用
|
||||
- 需要复用 Cesium viewer、实体、轨迹、绘制逻辑
|
||||
|
||||
### 已有重点 hook 类型
|
||||
|
||||
- SSE:`useDroneSSE`、`useBoatSSE`、`useClientSSE`
|
||||
- Tileset:`useTilesetLoader`
|
||||
- 船舶/无人机轨迹与渲染:相关 Cesium hook
|
||||
- 路线编辑:`useRouteDrawing`、`useCesiumRouteRenderer`、`useRouteValidation`
|
||||
- 边界编辑:`useBoundaryDrawing`、`useCesiumBoundaryRenderer`
|
||||
|
||||
### 实时能力规则
|
||||
|
||||
- 建立连接、断线重连、释放资源必须封装在 hook 或 service 中
|
||||
- 页面只消费状态与回调,不要直接到处 new 连接
|
||||
- 组件卸载时必须有清理逻辑
|
||||
|
||||
## 10. 布局与主题规则
|
||||
|
||||
### 布局
|
||||
|
||||
`src/layouts/BlankLayout.tsx` 负责:
|
||||
|
||||
- 顶部栏
|
||||
- 平台切换
|
||||
- 租户过滤
|
||||
- 用户菜单
|
||||
- 大屏 / 海事 / 地图头部插槽
|
||||
|
||||
规则:
|
||||
|
||||
- `/dashboard`、`/maritime` 走大屏标题模式
|
||||
- `/map3d` 通过 header slot 注入地图专属头部内容
|
||||
- 不要把地图专属头部逻辑硬塞进普通布局分支
|
||||
|
||||
### 主题
|
||||
|
||||
主题核心在 `src/theme.tsx`:
|
||||
|
||||
- `ConfigProvider`
|
||||
- 深色算法 `antdTheme.darkAlgorithm`
|
||||
- 主色 `#00d4ff`
|
||||
- 成功色 `#00ff88`
|
||||
|
||||
样式开发要求:
|
||||
|
||||
- 保持深色科技风一致性
|
||||
- 强调玻璃面板、边框高亮、信息层次
|
||||
- 浮层和地图覆盖物要兼顾可读性与点击区域
|
||||
|
||||
## 11. 登录、租户、客户端三条红线
|
||||
|
||||
### 登录
|
||||
|
||||
- 管理端登录页:`src/pages/user/Login`
|
||||
- 客户端登录页:`src/pages/client/Login`
|
||||
- 管理端和客户端认证逻辑必须区分处理
|
||||
|
||||
禁止:
|
||||
|
||||
- 把 `/client` 也按后台 token 模式处理
|
||||
- 把后台未授权跳转逻辑直接复用到客户端页面
|
||||
|
||||
### 租户
|
||||
|
||||
- 管理端与大屏数据如果受租户影响,优先接入 `TenantScopeFilter`
|
||||
- 缓存与 Token 联动优先沿用 `tenantCache`
|
||||
|
||||
禁止:
|
||||
|
||||
- 每个页面各自维护租户树副本
|
||||
- 每个大屏组件私自再造租户过滤协议
|
||||
|
||||
### 客户端
|
||||
|
||||
- `/client` 下逻辑优先在该目录内部自洽封装
|
||||
- 导航、遥测、预览、设备态等优先下沉 hook
|
||||
|
||||
## 12. 3D / 地图子系统边界
|
||||
|
||||
### 重点目录
|
||||
|
||||
- `src/pages/map3d/components/MapContainer/3d/`
|
||||
- `src/pages/map3d/components/RouteEditor/`
|
||||
- `src/pages/map3d/components/BoundaryEditor/`
|
||||
- `src/services/threeDModel.ts`
|
||||
|
||||
### 已有核心能力
|
||||
|
||||
- 3D Tiles 模型加载
|
||||
- 路线绘制与渲染
|
||||
- 边界绘制与渲染
|
||||
- 船舶轨迹渲染
|
||||
- 相机飞行与聚焦
|
||||
- 实时点位刷新
|
||||
|
||||
### 开发规则
|
||||
|
||||
- viewer 级副作用优先集中在容器/hook 层
|
||||
- 不要在多个组件里重复创建全局场景逻辑
|
||||
- 先查现有 RouteEditor / BoundaryEditor 基础设施,再决定是否扩展
|
||||
|
||||
## 13. TypeScript 规则
|
||||
|
||||
- 必须尊重 `strict: true`
|
||||
- 复杂场景对象必须显式类型化
|
||||
- 航点、边界、模型、设备状态、导航状态优先抽到类型文件
|
||||
- 全局和场景类型优先查看:
|
||||
- `src/typings.d.ts`
|
||||
- `src/types/`
|
||||
- 各子系统自己的 `types.ts`
|
||||
|
||||
严格禁止:
|
||||
|
||||
- `as any`
|
||||
- `@ts-ignore`
|
||||
- `@ts-expect-error`
|
||||
|
||||
## 14. 典型工作流
|
||||
|
||||
### 新增地图/3D 功能
|
||||
|
||||
1. 先判断属于容器、面板、hook 还是 service
|
||||
2. 查现有 tileset / route / boundary / track 相关基础设施
|
||||
3. 优先复用已有 hook 与 renderer
|
||||
4. 补充必要的 service 封装
|
||||
5. 做好卸载清理、实体清理、事件解绑
|
||||
6. 保持深色科技风一致
|
||||
|
||||
### 新增大屏区块
|
||||
|
||||
1. 优先放对应页面 `components/`
|
||||
2. 保持卡片、信息带、面板的视觉语言统一
|
||||
3. 数据获取放 service,状态组装放页面或 hook
|
||||
|
||||
### 新增客户端能力
|
||||
|
||||
1. 优先放 `src/pages/client/` 内部
|
||||
2. 先判断是否依赖设备号登录态
|
||||
3. 导航/预览/遥测逻辑优先用 hook 管理
|
||||
|
||||
## 15. 决策清单
|
||||
|
||||
动手前自检:
|
||||
|
||||
- 当前逻辑是管理端、客户端、大屏还是地图页?
|
||||
- 是否误用了后台 token 逻辑到 `/client`?
|
||||
- 是否已有可复用的 Cesium hook、编辑器或 service?
|
||||
- 这段逻辑应放 panel、hook、service 还是页面容器?
|
||||
- 是否仍然在 Ant Design 5 + ConfigProvider + 深色科技风边界内?
|
||||
- 是否兼容 `resp_code / resp_msg / data`?
|
||||
- 是否考虑了连接清理、资源释放、viewer 生命周期?
|
||||
|
||||
## 16. 明确禁止事项
|
||||
|
||||
- 按 `react-web-next` 的 Antd4 思路改这个项目主题
|
||||
- 在地图页重复造 viewer 生命周期管理
|
||||
- 把 `/client` 与后台登录态混为一谈
|
||||
- 把复杂实时连接逻辑直接塞进 JSX 页面
|
||||
- 新增浅色后台风格破坏整体科技感
|
||||
- 绕过现有 Cesium hook 和编辑器基础设施重新手搓一套平行系统
|
||||
|
||||
## 17. 优先参考文件
|
||||
|
||||
- `zlt-web/yingyan/config/config.ts`
|
||||
- `zlt-web/yingyan/config/routes.ts`
|
||||
- `zlt-web/yingyan/config/proxy.ts`
|
||||
- `zlt-web/yingyan/src/app.tsx`
|
||||
- `zlt-web/yingyan/src/theme.tsx`
|
||||
- `zlt-web/yingyan/src/global.less`
|
||||
- `zlt-web/yingyan/src/layouts/BlankLayout.tsx`
|
||||
- `zlt-web/yingyan/src/components/TenantScopeFilter/index.tsx`
|
||||
- `zlt-web/yingyan/src/components/PlatformSwitcher/index.tsx`
|
||||
- `zlt-web/yingyan/src/services/device.ts`
|
||||
- `zlt-web/yingyan/src/services/threeDModel.ts`
|
||||
- `zlt-web/yingyan/src/services/deviceControlWs.ts`
|
||||
- `zlt-web/yingyan/src/services/boatRoute.ts`
|
||||
- `zlt-web/yingyan/src/services/waterBoundary.ts`
|
||||
- `zlt-web/yingyan/src/pages/map3d/components/MapContainer/CesiumContainer.tsx`
|
||||
- `zlt-web/yingyan/src/pages/map3d/components/RouteEditor/index.tsx`
|
||||
- `zlt-web/yingyan/src/pages/map3d/components/BoundaryEditor/index.tsx`
|
||||
- `zlt-web/yingyan/src/pages/client/index.tsx`
|
||||
|
||||
---
|
||||
|
||||
*最后更新: 2026-04-01*
|
||||
@@ -1,7 +0,0 @@
|
||||
{
|
||||
"permissions": {
|
||||
"allow": [
|
||||
"Agent(Explore)"
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -1,58 +0,0 @@
|
||||
<h2>哪种指点飞行操作流更顺手?</h2>
|
||||
<p class="subtitle">重点比较:从开始飞行到连续改点,需要多少次中断和确认。</p>
|
||||
|
||||
<div class="cards" style="grid-template-columns: repeat(3, minmax(0, 1fr));">
|
||||
<div class="card" data-choice="a" onclick="toggleSelect(this)">
|
||||
<div class="card-image" style="padding:16px;background:#122033;min-height:280px;color:#d9e8f5;">
|
||||
<div style="font-size:12px;color:#7f9bb5;margin-bottom:10px;">现有流程</div>
|
||||
<div style="background:#223754;padding:12px;border-radius:4px;margin:8px 0;">右侧面板<br><b>指点飞行</b></div>
|
||||
<div style="text-align:center;color:#65b8ff;">↓ 确认开始</div>
|
||||
<div style="background:#223754;padding:12px;border-radius:4px;margin:8px 0;">等待升空</div>
|
||||
<div style="text-align:center;color:#65b8ff;">↓ 点击地图</div>
|
||||
<div style="background:#f5f7fb;color:#14253b;padding:12px;border-radius:4px;margin:8px 0;">目标确认弹窗<br><small>高度、速度、确认</small></div>
|
||||
<div style="text-align:center;color:#65b8ff;">↓ 到达后才能再选点</div>
|
||||
<div style="background:#223754;padding:12px;border-radius:4px;margin:8px 0;">重复上述步骤</div>
|
||||
</div>
|
||||
<div class="card-body"><h3>A. 分步确认</h3><p>控制感强,但连续指点时被弹窗和状态等待反复打断。</p></div>
|
||||
</div>
|
||||
|
||||
<div class="card" data-choice="b" onclick="toggleSelect(this)" style="border-color:#1f8fff;">
|
||||
<div class="card-image" style="padding:16px;background:#10273a;min-height:280px;color:#d9e8f5;position:relative;">
|
||||
<div style="font-size:12px;color:#7fcaef;margin-bottom:10px;">推荐:地图优先</div>
|
||||
<div style="height:140px;border:1px solid #39769b;background:linear-gradient(135deg,#173c55,#1d5870);position:relative;border-radius:3px;">
|
||||
<div style="position:absolute;left:42%;top:38%;font-size:32px;color:#ffcf5c;">✦</div>
|
||||
<div style="position:absolute;right:10px;top:8px;background:#0b1925cc;padding:6px 8px;font-size:12px;">正在指点 · 5 m/s</div>
|
||||
<div style="position:absolute;left:15%;bottom:15%;color:#7ad5ff;font-size:22px;">✈</div>
|
||||
</div>
|
||||
<div style="margin-top:10px;background:#0b1925;padding:10px;border-left:3px solid #1f9fff;display:flex;justify-content:space-between;align-items:center;">
|
||||
<span><b>新目标</b><br><small>113.123456, 23.123456</small></span>
|
||||
<span style="color:#ffcf5c;">发送</span>
|
||||
</div>
|
||||
<div style="font-size:12px;color:#9bb8c9;margin-top:10px;line-height:1.5;">首次进入模式后,地图点击直接更新目标。高度和速度沿用上次值,可在紧凑工具条修改;短暂显示“撤销”而不是每次弹窗。</div>
|
||||
</div>
|
||||
<div class="card-body"><h3>B. 地图优先</h3><p>一次启用,连续点击连续改点。危险操作才二次确认,常规改点不打断地图。</p></div>
|
||||
</div>
|
||||
|
||||
<div class="card" data-choice="c" onclick="toggleSelect(this)">
|
||||
<div class="card-image" style="padding:16px;background:#17242b;min-height:280px;color:#d9e8f5;">
|
||||
<div style="font-size:12px;color:#a9c4b8;margin-bottom:10px;">精细作业模式</div>
|
||||
<div style="height:92px;border:1px solid #607d70;background:#283b35;border-radius:3px;position:relative;">
|
||||
<span style="position:absolute;left:25%;top:22%;font-size:22px;color:#f2d477;">①</span>
|
||||
<span style="position:absolute;left:58%;top:50%;font-size:22px;color:#f2d477;">②</span>
|
||||
<span style="position:absolute;left:12%;bottom:10%;color:#79c9ee;">✈</span>
|
||||
</div>
|
||||
<div style="margin-top:10px;background:#24332e;padding:10px;border-radius:3px;">
|
||||
<b>下一目标</b><span style="float:right;color:#f2d477;">②</span><br>
|
||||
<small>113.123456, 23.123456 · 120m</small>
|
||||
</div>
|
||||
<div style="display:flex;gap:6px;margin-top:8px;"><span style="background:#31463e;padding:5px 7px;font-size:12px;">添加目标</span><span style="background:#31463e;padding:5px 7px;font-size:12px;">确认发送</span></div>
|
||||
<div style="font-size:12px;color:#a9c4b8;margin-top:10px;line-height:1.5;">地图点击先加入临时队列,用户可以复核、排序或删除后发送。</div>
|
||||
</div>
|
||||
<div class="card-body"><h3>C. 目标队列</h3><p>适合测绘和有规划的巡查,但增加了一层操作,与即时指点的感觉相反。</p></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="section" style="margin-top:24px;">
|
||||
<p class="label">选择建议</p>
|
||||
<p>我建议选 <b>B</b>:首次启用和结束返航保留明确确认;飞行期间把地图点击变成主操作,避免“点一下、弹一次、等一次”。</p>
|
||||
</div>
|
||||
@@ -1,38 +0,0 @@
|
||||
<h2>点击建筑时,目标高度应该怎么计算?</h2>
|
||||
<p class="subtitle">现有代码把“模型命中高度 + 输入高度”直接下发;它不等于界面所说的“相对地面高度”。</p>
|
||||
|
||||
<div class="split">
|
||||
<div class="mockup" data-choice="surface" onclick="toggleSelect(this)">
|
||||
<div class="mockup-header">现有:相对点击表面</div>
|
||||
<div class="mockup-body" style="background:#132633;min-height:300px;position:relative;overflow:hidden;color:#e9f5fa;">
|
||||
<div style="position:absolute;left:12%;bottom:8%;width:78%;height:3px;background:#5e856a;"></div>
|
||||
<div style="position:absolute;left:52%;bottom:9%;width:22%;height:44%;background:#73808b;border:2px solid #aebac0;"><span style="position:absolute;top:8px;left:12px;font-size:12px;">楼</span></div>
|
||||
<div style="position:absolute;left:22%;bottom:12%;font-size:28px;">✈</div>
|
||||
<div style="position:absolute;left:63%;bottom:59%;font-size:26px;color:#ffca60;">✦</div>
|
||||
<div style="position:absolute;left:58%;bottom:72%;border-top:1px dashed #ffca60;width:10%;"></div>
|
||||
<div style="position:absolute;right:8%;top:9%;font-size:12px;background:#202f3b;padding:8px;line-height:1.5;">模型表面 40m<br>输入“120m”<br><b style="color:#ffca60;">目标 = 160m</b></div>
|
||||
<div style="position:absolute;left:7%;top:8%;font-size:12px;color:#ff9c9c;">问题:界面称“相对地面”,实际相对楼顶/立面;路径中的更高障碍也没有检查。</div>
|
||||
</div>
|
||||
<div style="padding:12px;"><b>方案 A:保留现状</b><br><small>实现最少,但语义误导,无法保证航线净空。</small></div>
|
||||
</div>
|
||||
|
||||
<div class="mockup" data-choice="safe-corridor" onclick="toggleSelect(this)" style="border-color:#1f8fff;">
|
||||
<div class="mockup-header">推荐:安全航高 + 净空保护</div>
|
||||
<div class="mockup-body" style="background:#132633;min-height:300px;position:relative;overflow:hidden;color:#e9f5fa;">
|
||||
<div style="position:absolute;left:12%;bottom:8%;width:78%;height:3px;background:#5e856a;"></div>
|
||||
<div style="position:absolute;left:52%;bottom:9%;width:22%;height:44%;background:#73808b;border:2px solid #aebac0;"><span style="position:absolute;top:8px;left:12px;font-size:12px;">楼</span></div>
|
||||
<div style="position:absolute;left:22%;bottom:12%;font-size:28px;">✈</div>
|
||||
<div style="position:absolute;left:63%;bottom:77%;font-size:26px;color:#75e5ff;">✦</div>
|
||||
<div style="position:absolute;left:26%;bottom:80%;width:42%;border-top:3px solid #4fc3f7;"></div>
|
||||
<div style="position:absolute;left:25%;bottom:74%;font-size:12px;color:#75e5ff;">安全飞行走廊:障碍物顶部 + 安全净空</div>
|
||||
<div style="position:absolute;right:7%;top:8%;font-size:12px;background:#163c4d;padding:8px;line-height:1.5;">地图点击只取经纬度<br>计划高度 = max:<br>· 当前安全航高<br>· 目标建筑顶部 + 净空<br>· 路径障碍顶部 + 净空</div>
|
||||
<div style="position:absolute;left:7%;top:8%;font-size:12px;color:#b8e8c5;">高度策略明确;无法可靠评估净空时,拒绝下发而不是猜测。</div>
|
||||
</div>
|
||||
<div style="padding:12px;"><b>方案 B:安全走廊(推荐)</b><br><small>点击只决定水平位置;系统决定或校验实际椭球目标高。</small></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="section" style="margin-top:22px;">
|
||||
<p class="label">建议交互</p>
|
||||
<p>把“飞行高度”改成“安全航高(相对起飞点)”,默认继承当前安全高度。点击楼顶时显示“目标位于建筑上方,系统已抬升至安全高度”;若无法验证模型/地形净空,则显示风险并禁止确认飞行。</p>
|
||||
</div>
|
||||
@@ -1,3 +0,0 @@
|
||||
<div style="display:flex;align-items:center;justify-content:center;min-height:60vh">
|
||||
<p class="subtitle">继续在终端确认安全策略...</p>
|
||||
</div>
|
||||
@@ -1,3 +0,0 @@
|
||||
<div style="display:flex;align-items:center;justify-content:center;min-height:60vh">
|
||||
<p class="subtitle">正在整理“预览后发送 + 安全航高”的交互方案...</p>
|
||||
</div>
|
||||
@@ -1 +0,0 @@
|
||||
{"reason":"idle timeout","timestamp":1784875445807}
|
||||
@@ -1 +0,0 @@
|
||||
628
|
||||
@@ -1,56 +0,0 @@
|
||||
# 仓库指南(Repository Guidelines)
|
||||
|
||||
## 语言与注释规范(Agent 专用)
|
||||
- 所有交互回答必须使用中文(简体),包括解释、建议与错误信息。
|
||||
- 代码片段中的注释、日志消息、文档内容与示例说明均应为中文;编程语言关键字与三方 API 标识符保持原文。
|
||||
- 提交信息(commit)、合并请求(PR)描述与 Issue 标题/内容默认使用中文;涉及外部专有名词可保留英文缩写。
|
||||
- 所有中文都使用utf-8
|
||||
|
||||
## 权限与执行策略
|
||||
- 默认权限:Codex 在本仓库内可直接读取与编辑文件,无需额外审批。
|
||||
- 命令执行:在具备网络访问权限时,可直接执行包含网络的命令(如依赖下载、API 请求、构建/测试脚本)。
|
||||
- 安全边界:遵循最小影响原则,避免破坏性操作(如强制删除、重置历史、批量改名)。如确需此类操作,请在回复中明确风险与范围,并征得用户同意。
|
||||
- 可追溯性:在回复或提交说明中简要标注关键命令、影响模块与文件路径,便于审计。
|
||||
- Git 操作限制:除非用户明确要求,否则不要执行任何 Git 相关操作(包括但不限于 `commit`、`push`、`pull`、`merge`、`rebase`、`tag`、`branch`、`reset` 等)。如需读取 Git 元数据(如 `git log`、`git status`),也需先获得用户确认。
|
||||
|
||||
## 项目结构与模块组织
|
||||
- 父聚合工程:`pom.xml`(Java 17,Spring Boot 3.1,Spring Cloud 2022)。
|
||||
- 核心模块:
|
||||
- `zlt-commons`(公共 starter、工具)
|
||||
- `zlt-uaa`(认证),`zlt-gateway/sc-gateway`(API 网关)
|
||||
- `zlt-business/*`(业务服务:用户/文件/订单等)
|
||||
- `zlt-monitor/sc-admin`(监控),`zlt-config`(配置),`zlt-web/*`(前端)
|
||||
- 标准目录:`src/main/java`、`src/main/resources`,单测放在 `src/test/java`。
|
||||
|
||||
## 构建、测试与本地运行
|
||||
- 全量构建:`mvn -q -DskipTests clean package`
|
||||
- 全量测试:`mvn -q test`
|
||||
- 指定模块构建+测试:`mvn -pl zlt-business/user-center -am clean verify`
|
||||
- 本地运行示例:
|
||||
- 网关:`mvn -pl zlt-gateway/sc-gateway -am spring-boot:run`
|
||||
- 认证:`mvn -pl zlt-uaa -am spring-boot:run`
|
||||
- 从 JAR 运行:`java -jar zlt-gateway/sc-gateway/target/*.jar`
|
||||
先决条件:JDK 17、Maven 3.8+。
|
||||
|
||||
## 编码风格与命名约定
|
||||
- Java 使用 4 空格缩进、UTF-8、同一行左大括号。
|
||||
- 包名使用 `com.central.*`;模块名称以 `zlt-*` 为前缀。
|
||||
- 已使用处优先采用 Lombok 注解(如 `@Data`、`@Slf4j`)。
|
||||
- 方法/字段使用 lowerCamelCase;类名使用 PascalCase。
|
||||
|
||||
## 测试规范
|
||||
- 测试框架:JUnit 4 与 JUnit 5(按模块而定)。
|
||||
- 用例命名以 `*Test.java` 结尾,放在 `src/test/java`。
|
||||
- 为新增逻辑与关键路径补充单测;保持可重复、相互独立。
|
||||
- 提 PR 前执行:`mvn -pl <module> -am test`。
|
||||
|
||||
## 提交与合并请求规范
|
||||
- 采用约定式提交:`type(scope): 简要说明`,示例:`fix(订单中心): 修复事件处理逻辑`。
|
||||
- 常见类型:`feat`、`fix`、`docs`、`refactor`、`test`、`chore`。
|
||||
- 小步且描述清晰;必要时关联 Issue。
|
||||
- PR 需包含:目的/影响、涉及模块、测试说明;前端改动请附截图(`zlt-web/*`)。
|
||||
|
||||
## 安全与配置提示
|
||||
- 多模块使用 Nacos。请在本地提供 `spring.cloud.nacos.server-addr`,或在 `bootstrap.yml` 注释相关配置以单机运行。
|
||||
- 外部依赖常见:MySQL/Redis/Elasticsearch。按模块检查 `application.yml` 的端口/连接串。
|
||||
- 禁止提交密钥与凭据;使用环境变量或本地覆盖配置。
|
||||
@@ -1,94 +0,0 @@
|
||||
# Go-Fly Platform Services - AI开发团队配置
|
||||
|
||||
## 项目概述
|
||||
**项目类型**: 企业级Spring Cloud微服务平台
|
||||
**主要业务**: 旅游景区管理 + IoT设备控制 + 支付分润系统
|
||||
**技术栈**: Java 17 + Spring Cloud + React + MySQL + Redis + Elasticsearch
|
||||
**复杂度**: Enterprise级 (8+专业领域)
|
||||
|
||||
## 专属AI代理团队
|
||||
|
||||
### 🏗️ 架构与基础设施层
|
||||
- **spring-cloud-microservice-architect** (opus) - 微服务架构设计与优化专家
|
||||
- **mysql-data-architect** (sonnet) - MySQL数据库架构与MyBatis Plus优化专家
|
||||
- **file-storage-specialist** (sonnet) - 多云存储与CDN集成专家
|
||||
|
||||
### 🎯 业务领域专家层
|
||||
- **tourism-business-specialist** (sonnet) - 旅游行业业务逻辑与景区管理专家
|
||||
- **iot-device-integration-specialist** (sonnet) - IoT设备管理与大疆无人机集成专家
|
||||
- **payment-system-specialist** (opus) - 微信支付服务商模式与分润系统专家
|
||||
|
||||
### 💻 前端与质量保障层
|
||||
- **react-dashboard-developer** (sonnet) - React + Ant Design Pro仪表板开发专家
|
||||
- **platform-testing-specialist** (sonnet) - 微服务平台综合测试策略专家
|
||||
|
||||
## 团队协作策略
|
||||
|
||||
### 🚀 智能任务分发规则
|
||||
**Level 1-2 任务**: 直接调用对应专业代理
|
||||
**Level 3-4 任务**: 根据依赖关系串行或并行调用
|
||||
**Level 5 任务**: 由task-dispatch-director协调分发
|
||||
|
||||
### ⚡ 关键协作流程
|
||||
1. **架构设计**: cto → spring-cloud-microservice-architect → mysql-data-architect
|
||||
2. **业务开发**: 业务专家并行 → react-dashboard-developer → platform-testing-specialist
|
||||
3. **集成测试**: 所有专家 → platform-testing-specialist → devops-engineer
|
||||
|
||||
### 🔧 依赖管理
|
||||
- **高依赖**: 架构 → 数据 → 业务 (必须串行)
|
||||
- **中等依赖**: 支付 ↔ 旅游, 设备 → 文件存储 (混合执行)
|
||||
- **零依赖**: React组件 + 测试编写 (完全并行)
|
||||
|
||||
## 开发工作流
|
||||
|
||||
### 🎯 新功能开发
|
||||
```bash
|
||||
# 示例: 景区门票预订功能
|
||||
/ai "开发景区门票在线预订和支付功能"
|
||||
→ tourism-business-specialist (业务逻辑)
|
||||
→ payment-system-specialist (支付集成)
|
||||
→ react-dashboard-developer (管理界面)
|
||||
→ platform-testing-specialist (端到端测试)
|
||||
```
|
||||
|
||||
### 🔧 系统优化
|
||||
```bash
|
||||
# 示例: 微服务性能优化
|
||||
/ai "优化微服务间通信性能和数据库查询效率"
|
||||
→ spring-cloud-microservice-architect (服务优化)
|
||||
→ mysql-data-architect (查询优化)
|
||||
→ platform-testing-specialist (性能测试)
|
||||
```
|
||||
|
||||
### 🚨 问题排查
|
||||
```bash
|
||||
# 示例: 支付异常排查
|
||||
/ai "排查订单支付失败和分润异常问题"
|
||||
→ payment-system-specialist (支付逻辑检查)
|
||||
→ mysql-data-architect (数据一致性验证)
|
||||
→ platform-testing-specialist (问题复现测试)
|
||||
```
|
||||
|
||||
## 技术规范
|
||||
|
||||
### 📋 开发标准
|
||||
- **后端**: Spring Boot 3.1.6 + MyBatis Plus 3.5.4 + Java 17
|
||||
- **前端**: React 17 + Ant Design 4.20 + UmiJS 3.5 + TypeScript
|
||||
- **数据库**: MySQL 8.0 + Redis 7.0 + Elasticsearch 7.13
|
||||
- **部署**: Docker + Kubernetes + Spring Cloud Gateway
|
||||
|
||||
### 🔒 安全要求
|
||||
- OAuth2 + JWT认证授权
|
||||
- 支付数据加密存储
|
||||
- 多租户数据隔离
|
||||
- API访问频率限制
|
||||
|
||||
### 📊 监控指标
|
||||
- 服务响应时间 < 200ms
|
||||
- 数据库查询优化 (N+1问题避免)
|
||||
- 支付成功率 > 99.9%
|
||||
- 设备连接稳定性 > 99%
|
||||
|
||||
---
|
||||
|
||||
**🚀 专属AI团队已就绪!使用 `/ai "具体任务描述"` 即可调用专业团队协作完成复杂任务。**
|
||||
@@ -1,45 +0,0 @@
|
||||
# 贡献指南 (Contributing Guide)
|
||||
|
||||
## 快速开始
|
||||
- Fork 本仓库(GitHub/Gitee),克隆到本地:`git clone <your_fork_url>`。
|
||||
- 目标分支:优先提交到 `develop`(如无则 `master`)。
|
||||
- 创建特性分支:`git checkout -b feature/<简要描述>`(缺陷用 `bugfix/`,文档用 `docs/`)。
|
||||
- 环境要求:JDK 17,Maven 3.8+。
|
||||
|
||||
## 构建与本地运行
|
||||
- 全量构建:`mvn -q -DskipTests clean package`
|
||||
- 全量测试:`mvn -q test`
|
||||
- 指定模块构建+测试:`mvn -pl zlt-business/user-center -am clean verify`
|
||||
- 本地运行示例:
|
||||
- 网关:`mvn -pl zlt-gateway/sc-gateway -am spring-boot:run`
|
||||
- 认证:`mvn -pl zlt-uaa -am spring-boot:run`
|
||||
- 从 JAR 运行:`java -jar zlt-gateway/sc-gateway/target/*.jar`
|
||||
|
||||
## 代码风格
|
||||
- Java:4 空格缩进、UTF-8、左大括号同行。
|
||||
- 包命名:`com.central.*`;模块命名:`zlt-*`。
|
||||
- 项目已使用 Lombok(如 `@Data`、`@Slf4j`),保持一致。
|
||||
|
||||
## 测试要求
|
||||
- 测试框架:JUnit 4/5(按模块而定)。
|
||||
- 测试类放在 `src/test/java`,命名以 `*Test.java` 结尾。
|
||||
- 为新增/变更逻辑补充单测;尽量使用 mock,避免依赖真实外部服务。
|
||||
- 提交前运行:`mvn -pl <module> -am test`,确保通过。
|
||||
|
||||
## 提交规范(Conventional Commits)
|
||||
- 格式:`type(scope): 简要说明`,示例:`fix(订单中心): 修复事件处理逻辑`。
|
||||
- 常用类型:`feat`、`fix`、`docs`、`refactor`、`test`、`chore`。
|
||||
- 正文可描述动机/实现要点;页脚关联问题:`Closes #123`。
|
||||
|
||||
## Pull Request 规范
|
||||
- 内容包含:变更目的与影响、涉及模块、测试方式与结果;前端改动(`zlt-web/*`)请附截图。
|
||||
- 保持 PR 粒度清晰、可审查;避免混入无关格式化改动。
|
||||
- 确保构建与测试通过,冲突已解决。
|
||||
|
||||
## 配置与安全
|
||||
- 多模块使用 Nacos;本地可提供 `spring.cloud.nacos.server-addr`,或在 `bootstrap.yml` 注释相关配置以单机运行。
|
||||
- 常见外部依赖:MySQL/Redis/Elasticsearch。按模块检查 `application.yml`。
|
||||
- 禁止提交密钥、证书与账户;使用环境变量或本地覆盖配置。
|
||||
|
||||
## 问题反馈
|
||||
- 提交 Issue 时请附:期望/实际结果、复现步骤、相关日志与环境信息(模块名、版本、OS、JDK)。
|
||||
@@ -1,4 +1,69 @@
|
||||
# zlt-microservices-platform
|
||||
|
||||
<p align="center">
|
||||
<img src="https://img.shields.io/badge/Version-6.0.0-critical" alt="Downloads"/>
|
||||
<img src="https://img.shields.io/badge/JDK-17-8A2BE2" alt="Downloads"/>
|
||||
<img src="https://img.shields.io/badge/Spring Authorization Server-1.1.3-40A24E" alt="Downloads"/>
|
||||
<img src="https://img.shields.io/badge/Spring%20Boot-3.1.6-blue" alt="Downloads"/>
|
||||
<img src="https://img.shields.io/badge/Spring%20Cloud-2022.0.4-blue" alt="Downloads"/>
|
||||
<img src="https://img.shields.io/badge/Spring%20Cloud%20Alibaba-2022.0.0.0-blue" alt="Downloads"/>
|
||||
<img src="https://img.shields.io/badge/Elasticsearch-7.x-34A2AE" alt="Downloads"/>
|
||||
<img src="https://img.shields.io/badge/Ant%20Design-pro-9cf" alt="Downloads"/>
|
||||
</p>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## 如果您觉得有帮助,请点右上角 "Star" 支持一下谢谢
|
||||
|
||||
## 1. 总体架构图
|
||||

|
||||
|
||||
|
||||
## 2. 功能介绍
|
||||

|
||||
|
||||
|
||||
## 3. 项目介绍
|
||||
* **技术交流群**
|
||||
<table>
|
||||
<tr>
|
||||
<td><center><strong><a href="https://qm.qq.com/cgi-bin/qm/qr?k=HntAHTirZwCEjF8PQpjDYkw37Zx5rJg8&jump_from=webapi" target="_blank">交流三群</a></strong></center></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="https://qm.qq.com/cgi-bin/qm/qr?k=HntAHTirZwCEjF8PQpjDYkw37Zx5rJg8&jump_from=webapi" target="_blank"><img width=250px height=300px alt="交流三群" src="https://gitee.com/zlt2000/images/raw/master/%E4%BA%A4%E6%B5%81%E4%B8%89%E7%BE%A4.png"/></a></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
|
||||
* **详细在线文档** :https://www.kancloud.cn/zlt2000/microservices-platform/919418
|
||||
* **[项目更新日志](https://www.kancloud.cn/zlt2000/microservices-platform/936235)**
|
||||
* **[文档更新日志](https://www.kancloud.cn/zlt2000/microservices-platform/936236)**
|
||||
* **演示环境地址**: [http://zlt2000.cn](http://zlt2000.cn/)
|
||||
* 账号密码:admin/admin
|
||||
* Grafana账号:zlt/zlt123
|
||||
* **演示环境有全方位的监控示例:日志系统 + APM系统 + GPE系统**
|
||||
* Gitee地址:https://gitee.com/zlt2000/microservices-platform
|
||||
* Github地址:https://github.com/zlt2000/microservices-platform
|
||||
* 前后端分离的企业级微服务架构
|
||||
* 主要针对解决微服务和业务开发时常见的**非功能性需求**
|
||||
* 基于 `Spring Authorization Server` 深度定制`Spring Security`真正实现了基于`RBAC`、`jwt`和`oauth2`的无状态统一权限认证的解决方案
|
||||
* 提供应用管理,方便第三方系统接入,**支持多租户(应用隔离)**
|
||||
* 引入组件化的思想实现高内聚低耦合并且高度可配置化
|
||||
* 注重代码规范,严格控制包依赖,每个工程基本都是最小依赖
|
||||
* 非常适合学习和企业中使用
|
||||
>重构于开源项目OCP&cp:https://gitee.com/owenwangwen/open-capacity-platform
|
||||
|
||||
|
||||
## 4. 分支说明
|
||||
| 分支名 | JDK | Spring Boot | Spring Cloud | Spring Security |
|
||||
| --- | --- | --- | --- |---|
|
||||
| master | 17 | 3.x | 2022.x | Spring Authorization Server |
|
||||
| 5.x | 1.8 | 2.5.x | 2020.x | Spring Security OAuth |
|
||||
| 4.x | 1.8 | 2.3.x | 2.2.x | Spring Security OAuth |
|
||||
|
||||
|
||||
## 5. 模块说明
|
||||
```lua
|
||||
central-platform -- 父项目,公共依赖
|
||||
@@ -43,5 +108,69 @@ central-platform -- 父项目,公共依赖
|
||||
│ │ ├─websocket-demo -- websocket demo
|
||||
```
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<td><a target="_blank" href="https://www.aliyun.com/minisite/goods?userCode=dickv1kw&share_source=copy_link"><img width="460px" height="177px" alt="阿里云" src="https://gitee.com/zlt2000/images/raw/master/aly.jpg"/></a></td>
|
||||
<td><a target="_blank" href="https://cloud.tencent.com/act/cps/redirect?redirect=1074&cps_key=5516bbd5876cd224d90bd41d53d3f7fe&from=console"><img width="460px" height="177px" alt="腾讯云" src="https://gitee.com/zlt2000/images/raw/master/txy.jpg"/></a></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
|
||||
## 6. 交流反馈
|
||||
* 有问题先看看 [F&Q](https://www.kancloud.cn/zlt2000/microservices-platform/981382) 中有没有相关的回答
|
||||
* 欢迎提交`ISSUS`,请写清楚问题的具体原因,重现步骤和环境(上下文)
|
||||
* 项目/微服务交流请进群:
|
||||
* 一群:[250883130(已满)](https://shang.qq.com/wpa/qunwpa?idkey=17544199255998bda0d938fb72b08d076c40c52c9904520b76eb5eb0585da71e)
|
||||
* 二群:[1041797659(已满)](https://shang.qq.com/wpa/qunwpa?idkey=41988facbc02f678942a7ee7ae03122f2ef0a10c948b3d07319f070bfb0d3a98)
|
||||
* 三群:[512637767](https://qm.qq.com/cgi-bin/qm/qr?k=HntAHTirZwCEjF8PQpjDYkw37Zx5rJg8&jump_from=webapi)
|
||||
* 个人博客:[http://zlt2000.gitee.io](http://zlt2000.gitee.io)
|
||||
* 个人邮箱:zltdiablo@163.com
|
||||
* 个人公众号:[陶陶技术笔记](http://qiniu.zlt2000.cn/blog/20190902/M56cWjw7uNsc.png?imageslim)
|
||||
* GitChat:[https://gitbook.cn/gitchat/author/5b2362320398d50d7b7ab29e](https://gitbook.cn/gitchat/author/5b2362320398d50d7b7ab29e)
|
||||
|
||||
|
||||
## 7. 截图(点击可大图预览)
|
||||
<table>
|
||||
<tr>
|
||||
<td><img alt="首页" src="https://gitee.com/zlt2000/images/raw/master/%E9%A6%96%E9%A1%B5.png"/></td>
|
||||
<td><img alt="用户搜索" src="https://gitee.com/zlt2000/images/raw/master/%E7%94%A8%E6%88%B7%E6%90%9C%E7%B4%A2.png"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><img alt="日志系统" src="https://gitee.com/zlt2000/images/raw/master/%E6%97%A5%E5%BF%97%E7%B3%BB%E7%BB%9F.png"/></td>
|
||||
<td><img alt="日志链路" src="https://gitee.com/zlt2000/images/raw/master/%E6%97%A5%E5%BF%97%E9%93%BE%E8%B7%AF.png"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><img alt="server_metrics" src="https://gitee.com/zlt2000/images/raw/master/server_metrics.png"/></td>
|
||||
<td><img alt="application_metrics" src="https://gitee.com/zlt2000/images/raw/master/application_metrics.png"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><img alt="skywalking首页.png" src="https://gitee.com/zlt2000/images/raw/master/skywalking%E9%A6%96%E9%A1%B5.png"/></td>
|
||||
<td><img alt="skywalking应用拓扑图" src="https://gitee.com/zlt2000/images/raw/master/skywalking%E5%BA%94%E7%94%A8%E6%8B%93%E6%89%91%E5%9B%BE.png"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><img alt="elk" src="https://gitee.com/zlt2000/images/raw/master/elk.png"/></td>
|
||||
<td><img alt="任务中心" src="https://gitee.com/zlt2000/images/raw/master/%E4%BB%BB%E5%8A%A1%E4%B8%AD%E5%BF%83.png"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><img alt="日志中心02" src="https://gitee.com/zlt2000/images/raw/master/%E6%97%A5%E5%BF%97%E4%B8%AD%E5%BF%8302.png"/></td>
|
||||
<td><img alt="慢查询sql" src="https://gitee.com/zlt2000/images/raw/master/%E6%85%A2%E6%9F%A5%E8%AF%A2sql.png"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><img alt="nacos-discovery" src="https://gitee.com/zlt2000/images/raw/master/nacos-discovery.png"/></td>
|
||||
<td><img alt="应用吞吐量监控" src="https://gitee.com/zlt2000/images/raw/master/%E5%BA%94%E7%94%A8%E5%90%9E%E5%90%90%E9%87%8F%E7%9B%91%E6%8E%A7.png"/></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
|
||||
## 8.友情链接
|
||||
|
||||
### flowsphere
|
||||
|
||||
云原生微服务流量治理解决方案,项目地址:https://github.com/flowsphere-projects/flowsphere
|
||||
|
||||
项目亮点:
|
||||
|
||||
1.全网唯一使用JavaAgent实现Http、MQ、Job全链路灰度
|
||||
|
||||
2.全网唯一支持JavaAgent接入Sentinel
|
||||
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
# 指点飞行交互与安全实现计划
|
||||
|
||||
## 目标
|
||||
|
||||
将指点飞行改为“点击产生候选点,明确发送后才改飞”的交互;防止把建筑或模型表面的命中高度直接作为飞行目标高度;记录每一次下发及风险确认。
|
||||
|
||||
## 第一版边界
|
||||
|
||||
- 点击模型表面仅作为目标位置与障碍物候选高度。
|
||||
- 目标椭球高度取当前无人机椭球高度与候选表面高度加净空的较大值。
|
||||
- 第一版不宣称已完成路径三维净空验证;路径未验证时必须由当前账户确认风险后才可发送。
|
||||
- 后端保存首次 `fly_to_point` 与后续 `fly_to_point_update` 的下发记录和风险审计信息。
|
||||
|
||||
## 实施步骤
|
||||
|
||||
1. 先为后端安全命令对象编写单元测试,覆盖“未验证净空必须确认风险”与“已验证净空不要求确认”两种行为。
|
||||
2. 新增安全命令对象、目标下发请求对象和 `mission_fly_to_point` 实体/Mapper;迁移脚本补充审计字段与唯一序号约束。
|
||||
3. 将任务更新接口改为强类型请求,后端从登录上下文取得确认人;对未验证风险但未确认的请求拒绝下发。
|
||||
4. 调整任务服务:根据目标历史决定首次命令或更新命令,设备命令成功后记录历史与最新任务目标;结束时先停止指点会话,再调用真实返航接口。
|
||||
5. 前端 Hook 分离候选目标和已发送目标;候选目标不会改变当前飞行目标,发送成功后才成为已发送目标。
|
||||
6. 前端 Cesium 点选在起飞、等待和飞行中均可用,候选点与已发送点使用不同标识;点选高度只用于净空计算和风险提示。
|
||||
7. 用紧凑浮层替代每次点选的大弹窗,提供发送、丢弃和风险确认;保留起飞、结束飞行的明确确认。
|
||||
|
||||
## 验证
|
||||
|
||||
- 后端:`mvn -pl zlt-business/order-center -am -Dtest=FlyToPointTargetCommandTest -Dsurefire.failIfNoSpecifiedTests=false test`
|
||||
- 前端:`npm run tsc`,随后执行 `npm run build`。
|
||||
- 人工:起飞后点 A 仅预览;发送 A 后飞行;飞往 A 时点 B 仅预览;发送 B 后才改飞;未勾选风险确认不可发送。
|
||||
@@ -0,0 +1,996 @@
|
||||
#
|
||||
# There is insufficient memory for the Java Runtime Environment to continue.
|
||||
# Native memory allocation (mmap) failed to map 734003200 bytes for G1 virtual space
|
||||
# Possible reasons:
|
||||
# The system is out of physical RAM or swap space
|
||||
# The process is running with CompressedOops enabled, and the Java Heap may be blocking the growth of the native heap
|
||||
# Possible solutions:
|
||||
# Reduce memory load on the system
|
||||
# Increase physical memory or swap space
|
||||
# Check if swap backing store is full
|
||||
# Decrease Java heap size (-Xmx/-Xms)
|
||||
# Decrease number of Java threads
|
||||
# Decrease Java thread stack sizes (-Xss)
|
||||
# Set larger code cache with -XX:ReservedCodeCacheSize=
|
||||
# JVM is running with Zero Based Compressed Oops mode in which the Java heap is
|
||||
# placed in the first 32GB address space. The Java Heap base address is the
|
||||
# maximum limit for the native heap growth. Please use -XX:HeapBaseMinAddress
|
||||
# to set the Java Heap base and to place the Java Heap above 32GB virtual address.
|
||||
# This output file may be truncated or incomplete.
|
||||
#
|
||||
# Out of Memory Error (os_windows.cpp:3548), pid=25368, tid=16648
|
||||
#
|
||||
# JRE version: Java(TM) SE Runtime Environment (17.0.13+10) (build 17.0.13+10-LTS-268)
|
||||
# Java VM: Java HotSpot(TM) 64-Bit Server VM (17.0.13+10-LTS-268, mixed mode, sharing, tiered, compressed oops, compressed class ptrs, g1 gc, windows-amd64)
|
||||
# No core dump will be written. Minidumps are not enabled by default on client versions of Windows
|
||||
#
|
||||
|
||||
--------------- S U M M A R Y ------------
|
||||
|
||||
Command Line: -Dmaven.multiModuleProjectDirectory=E:\Idea-project\ikingtec-new6.0\microservices-platform -Djansi.passthrough=true -Dmaven.home=D:\Program Files\JetBrains\IntelliJ IDEA 2024.3.1\plugins\maven\lib\maven3 -Dclassworlds.conf=D:\Program Files\JetBrains\IntelliJ IDEA 2024.3.1\plugins\maven\lib\maven3\bin\m2.conf -Dmaven.ext.class.path=D:\Program Files\JetBrains\IntelliJ IDEA 2024.3.1\plugins\maven\lib\maven-event-listener.jar -javaagent:D:\Program Files\JetBrains\IntelliJ IDEA 2024.3.1\lib\idea_rt.jar=58940:D:\Program Files\JetBrains\IntelliJ IDEA 2024.3.1\bin -Dfile.encoding=UTF-8 org.codehaus.classworlds.Launcher -Didea.version=2024.3.1 -T 8 -s D:\maven\apache-maven-3.5.2\conf\settings.xml package
|
||||
|
||||
Host: Intel(R) Core(TM) i7-9700F CPU @ 3.00GHz, 8 cores, 31G, Windows 10 , 64 bit Build 19041 (10.0.19041.5198)
|
||||
Time: Sun Jan 5 03:07:02 2025 Windows 10 , 64 bit Build 19041 (10.0.19041.5198) elapsed time: 21.807413 seconds (0d 0h 0m 21s)
|
||||
|
||||
--------------- T H R E A D ---------------
|
||||
|
||||
Current thread (0x000002577ec0ce20): VMThread "VM Thread" [stack: 0x000000a0c9200000,0x000000a0c9300000] [id=16648]
|
||||
|
||||
Stack: [0x000000a0c9200000,0x000000a0c9300000]
|
||||
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
|
||||
V [jvm.dll+0x67a23a]
|
||||
V [jvm.dll+0x7da96d]
|
||||
V [jvm.dll+0x7dc2b3]
|
||||
V [jvm.dll+0x7dc923]
|
||||
V [jvm.dll+0x2450ef]
|
||||
V [jvm.dll+0x677279]
|
||||
V [jvm.dll+0x66bf22]
|
||||
V [jvm.dll+0x302006]
|
||||
V [jvm.dll+0x3095a6]
|
||||
V [jvm.dll+0x359e9e]
|
||||
V [jvm.dll+0x35a0cf]
|
||||
V [jvm.dll+0x2d90d8]
|
||||
V [jvm.dll+0x2d750d]
|
||||
V [jvm.dll+0x2d6b5c]
|
||||
V [jvm.dll+0x31a6bb]
|
||||
V [jvm.dll+0x7e121b]
|
||||
V [jvm.dll+0x7e1f54]
|
||||
V [jvm.dll+0x7e246d]
|
||||
V [jvm.dll+0x7e2844]
|
||||
V [jvm.dll+0x7e2910]
|
||||
V [jvm.dll+0x78af1a]
|
||||
V [jvm.dll+0x679125]
|
||||
C [ucrtbase.dll+0x21bb2]
|
||||
C [KERNEL32.DLL+0x17374]
|
||||
C [ntdll.dll+0x4cc91]
|
||||
|
||||
VM_Operation (0x000000a0caffda70): G1CollectForAllocation, mode: safepoint, requested by thread 0x0000025747e837f0
|
||||
|
||||
|
||||
--------------- P R O C E S S ---------------
|
||||
|
||||
Threads class SMR info:
|
||||
_java_thread_list=0x0000025783920dc0, length=24, elements={
|
||||
0x00000257543ff050, 0x000002577ec11c60, 0x000002577ec127f0, 0x000002577ec2c960,
|
||||
0x000002577ec2f240, 0x000002577ec2fb10, 0x000002577ec31f60, 0x000002577ec32b60,
|
||||
0x000002577ec34090, 0x000002577ec3aa20, 0x000002577f560090, 0x000002577f6d0220,
|
||||
0x000002577f6d0700, 0x00000257472e95c0, 0x00000257477e9500, 0x0000025747e80550,
|
||||
0x0000025747e828c0, 0x0000025747e82dd0, 0x0000025747e832e0, 0x0000025747e80a60,
|
||||
0x0000025747e80f70, 0x0000025747e837f0, 0x0000025747e83d00, 0x0000025747e81990
|
||||
}
|
||||
|
||||
Java Threads: ( => current thread )
|
||||
0x00000257543ff050 JavaThread "main" [_thread_blocked, id=16164, stack(0x000000a0c8c00000,0x000000a0c8d00000)]
|
||||
0x000002577ec11c60 JavaThread "Reference Handler" daemon [_thread_blocked, id=30264, stack(0x000000a0c9300000,0x000000a0c9400000)]
|
||||
0x000002577ec127f0 JavaThread "Finalizer" daemon [_thread_blocked, id=25264, stack(0x000000a0c9400000,0x000000a0c9500000)]
|
||||
0x000002577ec2c960 JavaThread "Signal Dispatcher" daemon [_thread_blocked, id=28952, stack(0x000000a0c9500000,0x000000a0c9600000)]
|
||||
0x000002577ec2f240 JavaThread "Attach Listener" daemon [_thread_blocked, id=22620, stack(0x000000a0c9600000,0x000000a0c9700000)]
|
||||
0x000002577ec2fb10 JavaThread "Service Thread" daemon [_thread_blocked, id=19780, stack(0x000000a0c9700000,0x000000a0c9800000)]
|
||||
0x000002577ec31f60 JavaThread "Monitor Deflation Thread" daemon [_thread_blocked, id=16724, stack(0x000000a0c9800000,0x000000a0c9900000)]
|
||||
0x000002577ec32b60 JavaThread "C2 CompilerThread0" daemon [_thread_blocked, id=18424, stack(0x000000a0c9900000,0x000000a0c9a00000)]
|
||||
0x000002577ec34090 JavaThread "C1 CompilerThread0" daemon [_thread_blocked, id=26280, stack(0x000000a0c9a00000,0x000000a0c9b00000)]
|
||||
0x000002577ec3aa20 JavaThread "Sweeper thread" daemon [_thread_blocked, id=18348, stack(0x000000a0c9b00000,0x000000a0c9c00000)]
|
||||
0x000002577f560090 JavaThread "Common-Cleaner" daemon [_thread_blocked, id=31456, stack(0x000000a0c9c00000,0x000000a0c9d00000)]
|
||||
0x000002577f6d0220 JavaThread "Monitor Ctrl-Break" daemon [_thread_in_native, id=12312, stack(0x000000a0c9d00000,0x000000a0c9e00000)]
|
||||
0x000002577f6d0700 JavaThread "Notification Thread" daemon [_thread_blocked, id=27832, stack(0x000000a0c9e00000,0x000000a0c9f00000)]
|
||||
0x00000257472e95c0 JavaThread "C2 CompilerThread1" daemon [_thread_blocked, id=4900, stack(0x000000a0ca000000,0x000000a0ca100000)]
|
||||
0x00000257477e9500 JavaThread "C2 CompilerThread2" daemon [_thread_blocked, id=29180, stack(0x000000a0ca100000,0x000000a0ca200000)]
|
||||
0x0000025747e80550 JavaThread "Thread-1" daemon [_thread_blocked, id=25424, stack(0x000000a0ca900000,0x000000a0caa00000)]
|
||||
0x0000025747e828c0 JavaThread "BuilderThread 0" [_thread_blocked, id=30432, stack(0x000000a0caa00000,0x000000a0cab00000)]
|
||||
0x0000025747e82dd0 JavaThread "mvn-builder-user-center" [_thread_blocked, id=26920, stack(0x000000a0cab00000,0x000000a0cac00000)]
|
||||
0x0000025747e832e0 JavaThread "mvn-builder-device-center" [_thread_blocked, id=11224, stack(0x000000a0cac00000,0x000000a0cad00000)]
|
||||
0x0000025747e80a60 JavaThread "BuilderThread 3" [_thread_blocked, id=18428, stack(0x000000a0cad00000,0x000000a0cae00000)]
|
||||
0x0000025747e80f70 JavaThread "mvn-builder-search-server" [_thread_blocked, id=912, stack(0x000000a0cae00000,0x000000a0caf00000)]
|
||||
0x0000025747e837f0 JavaThread "mvn-builder-zlt-uaa" [_thread_blocked, id=19144, stack(0x000000a0caf00000,0x000000a0cb000000)]
|
||||
0x0000025747e83d00 JavaThread "mvn-builder-sc-gateway" [_thread_blocked, id=15892, stack(0x000000a0cb000000,0x000000a0cb100000)]
|
||||
0x0000025747e81990 JavaThread "mvn-builder-tourism-core" [_thread_blocked, id=11476, stack(0x000000a0cb100000,0x000000a0cb200000)]
|
||||
|
||||
Other Threads:
|
||||
=>0x000002577ec0ce20 VMThread "VM Thread" [stack: 0x000000a0c9200000,0x000000a0c9300000] [id=16648]
|
||||
0x000002577f73e060 WatcherThread [stack: 0x000000a0c9f00000,0x000000a0ca000000] [id=27448]
|
||||
0x000002575446c3e0 GCTaskThread "GC Thread#0" [stack: 0x000000a0c8d00000,0x000000a0c8e00000] [id=15572]
|
||||
0x00000257477e9a20 GCTaskThread "GC Thread#1" [stack: 0x000000a0ca200000,0x000000a0ca300000] [id=27424]
|
||||
0x0000025747647e60 GCTaskThread "GC Thread#2" [stack: 0x000000a0ca300000,0x000000a0ca400000] [id=27164]
|
||||
0x0000025747648120 GCTaskThread "GC Thread#3" [stack: 0x000000a0ca400000,0x000000a0ca500000] [id=27856]
|
||||
0x0000025747648bf0 GCTaskThread "GC Thread#4" [stack: 0x000000a0ca500000,0x000000a0ca600000] [id=24492]
|
||||
0x000002574775a1a0 GCTaskThread "GC Thread#5" [stack: 0x000000a0ca600000,0x000000a0ca700000] [id=22336]
|
||||
0x000002574775a460 GCTaskThread "GC Thread#6" [stack: 0x000000a0ca700000,0x000000a0ca800000] [id=23664]
|
||||
0x000002574775a720 GCTaskThread "GC Thread#7" [stack: 0x000000a0ca800000,0x000000a0ca900000] [id=3648]
|
||||
0x000002575447d0c0 ConcurrentGCThread "G1 Main Marker" [stack: 0x000000a0c8e00000,0x000000a0c8f00000] [id=30772]
|
||||
0x000002575447d8e0 ConcurrentGCThread "G1 Conc#0" [stack: 0x000000a0c8f00000,0x000000a0c9000000] [id=21488]
|
||||
0x00000257498e01e0 ConcurrentGCThread "G1 Conc#1" [stack: 0x000000a0cb200000,0x000000a0cb300000] [id=27744]
|
||||
0x00000257544ae530 ConcurrentGCThread "G1 Refine#0" [stack: 0x000000a0c9000000,0x000000a0c9100000] [id=27880]
|
||||
0x0000025749319780 ConcurrentGCThread "G1 Refine#1" [stack: 0x000000a0cb300000,0x000000a0cb400000] [id=668]
|
||||
0x000002574858b650 ConcurrentGCThread "G1 Refine#2" [stack: 0x000000a0cb400000,0x000000a0cb500000] [id=31388]
|
||||
0x000002574858b940 ConcurrentGCThread "G1 Refine#3" [stack: 0x000000a0cb500000,0x000000a0cb600000] [id=3292]
|
||||
0x000002574b98f880 ConcurrentGCThread "G1 Refine#4" [stack: 0x000000a0cb600000,0x000000a0cb700000] [id=30844]
|
||||
0x0000025750ddf500 ConcurrentGCThread "G1 Refine#5" [stack: 0x000000a0cb700000,0x000000a0cb800000] [id=18084]
|
||||
0x000002577eb45030 ConcurrentGCThread "G1 Service" [stack: 0x000000a0c9100000,0x000000a0c9200000] [id=26648]
|
||||
|
||||
Threads with active compile tasks:
|
||||
C2 CompilerThread0 21840 20058 4 lombok.core.AST::buildWithField (21 bytes)
|
||||
C2 CompilerThread1 21840 20070 ! 4 lombok.javac.JavacAST::drill (146 bytes)
|
||||
C2 CompilerThread2 21840 20059 ! 4 lombok.core.AST::buildWithField0 (121 bytes)
|
||||
|
||||
VM state: at safepoint (normal execution)
|
||||
|
||||
VM Mutex/Monitor currently owned by a thread: ([mutex/lock_event])
|
||||
[0x00000257543fc490] Threads_lock - owner thread: 0x000002577ec0ce20
|
||||
[0x00000257543fb4d0] Heap_lock - owner thread: 0x0000025747e837f0
|
||||
|
||||
Heap address: 0x0000000601000000, size: 8176 MB, Compressed Oops mode: Zero based, Oop shift amount: 3
|
||||
|
||||
CDS archive(s) mapped at: [0x0000025702000000-0x0000025702bd0000-0x0000025702bd0000), size 12386304, SharedBaseAddress: 0x0000025702000000, ArchiveRelocationMode: 1.
|
||||
Compressed class space mapped at: 0x0000025703000000-0x0000025743000000, reserved size: 1073741824
|
||||
Narrow klass base: 0x0000025702000000, Narrow klass shift: 0, Narrow klass range: 0x100000000
|
||||
|
||||
GC Precious Log:
|
||||
CPUs: 8 total, 8 available
|
||||
Memory: 32701M
|
||||
Large Page Support: Disabled
|
||||
NUMA Support: Disabled
|
||||
Compressed Oops: Enabled (Zero based)
|
||||
Heap Region Size: 4M
|
||||
Heap Min Capacity: 8M
|
||||
Heap Initial Capacity: 512M
|
||||
Heap Max Capacity: 8176M
|
||||
Pre-touch: Disabled
|
||||
Parallel Workers: 8
|
||||
Concurrent Workers: 2
|
||||
Concurrent Refinement Workers: 8
|
||||
Periodic GC: Disabled
|
||||
|
||||
Heap:
|
||||
garbage-first heap total 1400832K, used 464510K [0x0000000601000000, 0x0000000800000000)
|
||||
region size 4096K, 2 young (8192K), 2 survivors (8192K)
|
||||
Metaspace used 49364K, committed 56640K, reserved 1114112K
|
||||
class space used 5435K, committed 7168K, reserved 1048576K
|
||||
|
||||
Heap Regions: E=young(eden), S=young(survivor), O=old, HS=humongous(starts), HC=humongous(continues), CS=collection set, F=free, OA=open archive, CA=closed archive, TAMS=top-at-mark-start (previous, next)
|
||||
| 0|0x0000000601000000, 0x0000000601400000, 0x0000000601400000|100%| O| |TAMS 0x0000000601400000, 0x0000000601000000| Untracked
|
||||
| 1|0x0000000601400000, 0x0000000601800000, 0x0000000601800000|100%| O| |TAMS 0x0000000601800000, 0x0000000601400000| Untracked
|
||||
| 2|0x0000000601800000, 0x0000000601c00000, 0x0000000601c00000|100%| O| |TAMS 0x0000000601c00000, 0x0000000601800000| Untracked
|
||||
| 3|0x0000000601c00000, 0x0000000602000000, 0x0000000602000000|100%| O| |TAMS 0x0000000602000000, 0x0000000601c00000| Untracked
|
||||
| 4|0x0000000602000000, 0x0000000602400000, 0x0000000602400000|100%| O| |TAMS 0x0000000602400000, 0x0000000602000000| Untracked
|
||||
| 5|0x0000000602400000, 0x0000000602800000, 0x0000000602800000|100%| O| |TAMS 0x0000000602800000, 0x0000000602400000| Untracked
|
||||
| 6|0x0000000602800000, 0x0000000602c00000, 0x0000000602c00000|100%| O| |TAMS 0x0000000602800000, 0x0000000602800000| Untracked
|
||||
| 7|0x0000000602c00000, 0x0000000603000000, 0x0000000603000000|100%| O| |TAMS 0x0000000603000000, 0x0000000602c00000| Untracked
|
||||
| 8|0x0000000603000000, 0x0000000603400000, 0x0000000603400000|100%| O| |TAMS 0x0000000603400000, 0x0000000603000000| Untracked
|
||||
| 9|0x0000000603400000, 0x0000000603800000, 0x0000000603800000|100%| O| |TAMS 0x0000000603800000, 0x0000000603400000| Untracked
|
||||
| 10|0x0000000603800000, 0x0000000603c00000, 0x0000000603c00000|100%| O| |TAMS 0x0000000603c00000, 0x0000000603800000| Untracked
|
||||
| 11|0x0000000603c00000, 0x0000000604000000, 0x0000000604000000|100%| O| |TAMS 0x0000000604000000, 0x0000000603c00000| Untracked
|
||||
| 12|0x0000000604000000, 0x0000000604400000, 0x0000000604400000|100%| O| |TAMS 0x0000000604000000, 0x0000000604000000| Untracked
|
||||
| 13|0x0000000604400000, 0x0000000604671c00, 0x0000000604800000| 61%| O| |TAMS 0x0000000604400000, 0x0000000604400000| Untracked
|
||||
| 14|0x0000000604800000, 0x0000000604800000, 0x0000000604c00000| 0%| F| |TAMS 0x0000000604800000, 0x0000000604800000| Untracked
|
||||
| 15|0x0000000604c00000, 0x0000000605000000, 0x0000000605000000|100%| O| |TAMS 0x0000000605000000, 0x0000000604c00000| Untracked
|
||||
| 16|0x0000000605000000, 0x0000000605000000, 0x0000000605400000| 0%| F| |TAMS 0x0000000605000000, 0x0000000605000000| Untracked
|
||||
| 17|0x0000000605400000, 0x0000000605400000, 0x0000000605800000| 0%| F| |TAMS 0x0000000605400000, 0x0000000605400000| Untracked
|
||||
| 18|0x0000000605800000, 0x0000000605800000, 0x0000000605c00000| 0%| F| |TAMS 0x0000000605800000, 0x0000000605800000| Untracked
|
||||
| 19|0x0000000605c00000, 0x0000000605c00000, 0x0000000606000000| 0%| F| |TAMS 0x0000000605c00000, 0x0000000605c00000| Untracked
|
||||
| 20|0x0000000606000000, 0x0000000606000000, 0x0000000606400000| 0%| F| |TAMS 0x0000000606000000, 0x0000000606000000| Untracked
|
||||
| 21|0x0000000606400000, 0x0000000606400000, 0x0000000606800000| 0%| F| |TAMS 0x0000000606400000, 0x0000000606400000| Untracked
|
||||
| 22|0x0000000606800000, 0x0000000606c00000, 0x0000000606c00000|100%| O| |TAMS 0x0000000606c00000, 0x0000000606800000| Complete
|
||||
| 23|0x0000000606c00000, 0x0000000606c00000, 0x0000000607000000| 0%| F| |TAMS 0x0000000606c00000, 0x0000000606c00000| Untracked
|
||||
| 24|0x0000000607000000, 0x0000000607000000, 0x0000000607400000| 0%| F| |TAMS 0x0000000607000000, 0x0000000607000000| Untracked
|
||||
| 25|0x0000000607400000, 0x0000000607400000, 0x0000000607800000| 0%| F| |TAMS 0x0000000607400000, 0x0000000607400000| Untracked
|
||||
| 26|0x0000000607800000, 0x0000000607c00000, 0x0000000607c00000|100%| O| |TAMS 0x0000000607c00000, 0x0000000607800000| Complete
|
||||
| 27|0x0000000607c00000, 0x0000000607c00000, 0x0000000608000000| 0%| F| |TAMS 0x0000000607c00000, 0x0000000607c00000| Untracked
|
||||
| 28|0x0000000608000000, 0x0000000608400000, 0x0000000608400000|100%| O| |TAMS 0x0000000608400000, 0x0000000608000000| Complete
|
||||
| 29|0x0000000608400000, 0x0000000608800000, 0x0000000608800000|100%| O| |TAMS 0x0000000608800000, 0x0000000608400000| Complete
|
||||
| 30|0x0000000608800000, 0x0000000608c00000, 0x0000000608c00000|100%| O| |TAMS 0x0000000608c00000, 0x0000000608800000| Untracked
|
||||
| 31|0x0000000608c00000, 0x0000000609000000, 0x0000000609000000|100%| O| |TAMS 0x0000000609000000, 0x0000000608c00000| Complete
|
||||
| 32|0x0000000609000000, 0x0000000609000000, 0x0000000609400000| 0%| F| |TAMS 0x0000000609000000, 0x0000000609000000| Untracked
|
||||
| 33|0x0000000609400000, 0x0000000609400000, 0x0000000609800000| 0%| F| |TAMS 0x0000000609400000, 0x0000000609400000| Untracked
|
||||
| 34|0x0000000609800000, 0x0000000609800000, 0x0000000609c00000| 0%| F| |TAMS 0x0000000609800000, 0x0000000609800000| Untracked
|
||||
| 35|0x0000000609c00000, 0x0000000609c00000, 0x000000060a000000| 0%| F| |TAMS 0x0000000609c00000, 0x0000000609c00000| Untracked
|
||||
| 36|0x000000060a000000, 0x000000060a400000, 0x000000060a400000|100%|HS| |TAMS 0x000000060a400000, 0x000000060a000000| Complete
|
||||
| 37|0x000000060a400000, 0x000000060a800000, 0x000000060a800000|100%| O| |TAMS 0x000000060a800000, 0x000000060a400000| Complete
|
||||
| 38|0x000000060a800000, 0x000000060a800000, 0x000000060ac00000| 0%| F| |TAMS 0x000000060a800000, 0x000000060a800000| Untracked
|
||||
| 39|0x000000060ac00000, 0x000000060b000000, 0x000000060b000000|100%| O| |TAMS 0x000000060b000000, 0x000000060ac00000| Complete
|
||||
| 40|0x000000060b000000, 0x000000060b400000, 0x000000060b400000|100%| O| |TAMS 0x000000060b400000, 0x000000060b000000| Complete
|
||||
| 41|0x000000060b400000, 0x000000060b800000, 0x000000060b800000|100%| O| |TAMS 0x000000060b800000, 0x000000060b400000| Untracked
|
||||
| 42|0x000000060b800000, 0x000000060bc00000, 0x000000060bc00000|100%| O| |TAMS 0x000000060bc00000, 0x000000060b800000| Complete
|
||||
| 43|0x000000060bc00000, 0x000000060bc00000, 0x000000060c000000| 0%| F| |TAMS 0x000000060bc00000, 0x000000060bc00000| Untracked
|
||||
| 44|0x000000060c000000, 0x000000060c000000, 0x000000060c400000| 0%| F| |TAMS 0x000000060c000000, 0x000000060c000000| Untracked
|
||||
| 45|0x000000060c400000, 0x000000060c800000, 0x000000060c800000|100%| O| |TAMS 0x000000060c800000, 0x000000060c400000| Untracked
|
||||
| 46|0x000000060c800000, 0x000000060cc00000, 0x000000060cc00000|100%| O| |TAMS 0x000000060cc00000, 0x000000060c800000| Untracked
|
||||
| 47|0x000000060cc00000, 0x000000060cc00000, 0x000000060d000000| 0%| F| |TAMS 0x000000060cc00000, 0x000000060cc00000| Untracked
|
||||
| 48|0x000000060d000000, 0x000000060d000000, 0x000000060d400000| 0%| F| |TAMS 0x000000060d000000, 0x000000060d000000| Untracked
|
||||
| 49|0x000000060d400000, 0x000000060d400000, 0x000000060d800000| 0%| F| |TAMS 0x000000060d400000, 0x000000060d400000| Untracked
|
||||
| 50|0x000000060d800000, 0x000000060d800000, 0x000000060dc00000| 0%| F| |TAMS 0x000000060d800000, 0x000000060d800000| Untracked
|
||||
| 51|0x000000060dc00000, 0x000000060dc00000, 0x000000060e000000| 0%| F| |TAMS 0x000000060dc00000, 0x000000060dc00000| Untracked
|
||||
| 52|0x000000060e000000, 0x000000060e000000, 0x000000060e400000| 0%| F| |TAMS 0x000000060e000000, 0x000000060e000000| Untracked
|
||||
| 53|0x000000060e400000, 0x000000060e800000, 0x000000060e800000|100%| O| |TAMS 0x000000060e800000, 0x000000060e400000| Complete
|
||||
| 54|0x000000060e800000, 0x000000060e800000, 0x000000060ec00000| 0%| F| |TAMS 0x000000060e800000, 0x000000060e800000| Untracked
|
||||
| 55|0x000000060ec00000, 0x000000060ec00000, 0x000000060f000000| 0%| F| |TAMS 0x000000060ec00000, 0x000000060ec00000| Untracked
|
||||
| 56|0x000000060f000000, 0x000000060f400000, 0x000000060f400000|100%| O| |TAMS 0x000000060f400000, 0x000000060f000000| Untracked
|
||||
| 57|0x000000060f400000, 0x000000060f400000, 0x000000060f800000| 0%| F| |TAMS 0x000000060f400000, 0x000000060f400000| Untracked
|
||||
| 58|0x000000060f800000, 0x000000060f800000, 0x000000060fc00000| 0%| F| |TAMS 0x000000060f800000, 0x000000060f800000| Untracked
|
||||
| 59|0x000000060fc00000, 0x000000060fc00000, 0x0000000610000000| 0%| F| |TAMS 0x000000060fc00000, 0x000000060fc00000| Untracked
|
||||
| 60|0x0000000610000000, 0x0000000610000000, 0x0000000610400000| 0%| F| |TAMS 0x0000000610000000, 0x0000000610000000| Untracked
|
||||
| 61|0x0000000610400000, 0x0000000610400000, 0x0000000610800000| 0%| F| |TAMS 0x0000000610400000, 0x0000000610400000| Untracked
|
||||
| 62|0x0000000610800000, 0x0000000610800000, 0x0000000610c00000| 0%| F| |TAMS 0x0000000610800000, 0x0000000610800000| Untracked
|
||||
| 63|0x0000000610c00000, 0x0000000610c00000, 0x0000000611000000| 0%| F| |TAMS 0x0000000610c00000, 0x0000000610c00000| Untracked
|
||||
| 64|0x0000000611000000, 0x0000000611000000, 0x0000000611400000| 0%| F| |TAMS 0x0000000611000000, 0x0000000611000000| Untracked
|
||||
| 65|0x0000000611400000, 0x0000000611400000, 0x0000000611800000| 0%| F| |TAMS 0x0000000611400000, 0x0000000611400000| Untracked
|
||||
| 66|0x0000000611800000, 0x0000000611800000, 0x0000000611c00000| 0%| F| |TAMS 0x0000000611800000, 0x0000000611800000| Untracked
|
||||
| 67|0x0000000611c00000, 0x0000000611c00000, 0x0000000612000000| 0%| F| |TAMS 0x0000000611c00000, 0x0000000611c00000| Untracked
|
||||
| 68|0x0000000612000000, 0x0000000612000000, 0x0000000612400000| 0%| F| |TAMS 0x0000000612000000, 0x0000000612000000| Untracked
|
||||
| 69|0x0000000612400000, 0x0000000612800000, 0x0000000612800000|100%| O| |TAMS 0x0000000612800000, 0x0000000612400000| Complete
|
||||
| 70|0x0000000612800000, 0x0000000612800000, 0x0000000612c00000| 0%| F| |TAMS 0x0000000612800000, 0x0000000612800000| Untracked
|
||||
| 71|0x0000000612c00000, 0x0000000612c00000, 0x0000000613000000| 0%| F| |TAMS 0x0000000612c00000, 0x0000000612c00000| Untracked
|
||||
| 72|0x0000000613000000, 0x0000000613000000, 0x0000000613400000| 0%| F| |TAMS 0x0000000613000000, 0x0000000613000000| Untracked
|
||||
| 73|0x0000000613400000, 0x0000000613400000, 0x0000000613800000| 0%| F| |TAMS 0x0000000613400000, 0x0000000613400000| Untracked
|
||||
| 74|0x0000000613800000, 0x0000000613800000, 0x0000000613c00000| 0%| F| |TAMS 0x0000000613800000, 0x0000000613800000| Untracked
|
||||
| 75|0x0000000613c00000, 0x0000000613c00000, 0x0000000614000000| 0%| F| |TAMS 0x0000000613c00000, 0x0000000613c00000| Untracked
|
||||
| 76|0x0000000614000000, 0x0000000614000000, 0x0000000614400000| 0%| F| |TAMS 0x0000000614000000, 0x0000000614000000| Untracked
|
||||
| 77|0x0000000614400000, 0x0000000614400000, 0x0000000614800000| 0%| F| |TAMS 0x0000000614400000, 0x0000000614400000| Untracked
|
||||
| 78|0x0000000614800000, 0x0000000614800000, 0x0000000614c00000| 0%| F| |TAMS 0x0000000614800000, 0x0000000614800000| Untracked
|
||||
| 79|0x0000000614c00000, 0x0000000615000000, 0x0000000615000000|100%| O| |TAMS 0x0000000615000000, 0x0000000614c00000| Untracked
|
||||
| 80|0x0000000615000000, 0x0000000615400000, 0x0000000615400000|100%| O| |TAMS 0x0000000615400000, 0x0000000615000000| Untracked
|
||||
| 81|0x0000000615400000, 0x0000000615800000, 0x0000000615800000|100%| O| |TAMS 0x0000000615800000, 0x0000000615400000| Untracked
|
||||
| 82|0x0000000615800000, 0x0000000615c00000, 0x0000000615c00000|100%| O| |TAMS 0x0000000615c00000, 0x0000000615800000| Untracked
|
||||
| 83|0x0000000615c00000, 0x0000000616000000, 0x0000000616000000|100%| O| |TAMS 0x0000000616000000, 0x0000000615c00000| Complete
|
||||
| 84|0x0000000616000000, 0x0000000616400000, 0x0000000616400000|100%| O| |TAMS 0x0000000616400000, 0x0000000616000000| Complete
|
||||
| 85|0x0000000616400000, 0x0000000616800000, 0x0000000616800000|100%| O| |TAMS 0x0000000616800000, 0x0000000616400000| Complete
|
||||
| 86|0x0000000616800000, 0x0000000616c00000, 0x0000000616c00000|100%| O| |TAMS 0x0000000616c00000, 0x0000000616800000| Complete
|
||||
| 87|0x0000000616c00000, 0x0000000616c00000, 0x0000000617000000| 0%| F| |TAMS 0x0000000616c00000, 0x0000000616c00000| Untracked
|
||||
| 88|0x0000000617000000, 0x0000000617400000, 0x0000000617400000|100%| O| |TAMS 0x0000000617400000, 0x0000000617000000| Untracked
|
||||
| 89|0x0000000617400000, 0x0000000617800000, 0x0000000617800000|100%| O| |TAMS 0x0000000617800000, 0x0000000617400000| Untracked
|
||||
| 90|0x0000000617800000, 0x0000000617c00000, 0x0000000617c00000|100%| O| |TAMS 0x0000000617c00000, 0x0000000617800000| Untracked
|
||||
| 91|0x0000000617c00000, 0x0000000618000000, 0x0000000618000000|100%| O| |TAMS 0x0000000618000000, 0x0000000617c00000| Untracked
|
||||
| 92|0x0000000618000000, 0x0000000618000000, 0x0000000618400000| 0%| F| |TAMS 0x0000000618000000, 0x0000000618000000| Untracked
|
||||
| 93|0x0000000618400000, 0x0000000618400000, 0x0000000618800000| 0%| F| |TAMS 0x0000000618400000, 0x0000000618400000| Untracked
|
||||
| 94|0x0000000618800000, 0x0000000618800000, 0x0000000618c00000| 0%| F| |TAMS 0x0000000618800000, 0x0000000618800000| Untracked
|
||||
| 95|0x0000000618c00000, 0x0000000618c00000, 0x0000000619000000| 0%| F| |TAMS 0x0000000618c00000, 0x0000000618c00000| Untracked
|
||||
| 96|0x0000000619000000, 0x0000000619400000, 0x0000000619400000|100%|HS| |TAMS 0x0000000619400000, 0x0000000619000000| Complete
|
||||
| 97|0x0000000619400000, 0x0000000619800000, 0x0000000619800000|100%| O| |TAMS 0x0000000619800000, 0x0000000619400000| Complete
|
||||
| 98|0x0000000619800000, 0x0000000619800000, 0x0000000619c00000| 0%| F| |TAMS 0x0000000619800000, 0x0000000619800000| Untracked
|
||||
| 99|0x0000000619c00000, 0x0000000619c00000, 0x000000061a000000| 0%| F| |TAMS 0x0000000619c00000, 0x0000000619c00000| Untracked
|
||||
| 100|0x000000061a000000, 0x000000061a000000, 0x000000061a400000| 0%| F| |TAMS 0x000000061a000000, 0x000000061a000000| Untracked
|
||||
| 101|0x000000061a400000, 0x000000061a800000, 0x000000061a800000|100%| O| |TAMS 0x000000061a800000, 0x000000061a400000| Complete
|
||||
| 102|0x000000061a800000, 0x000000061a800000, 0x000000061ac00000| 0%| F| |TAMS 0x000000061a800000, 0x000000061a800000| Untracked
|
||||
| 103|0x000000061ac00000, 0x000000061ac00000, 0x000000061b000000| 0%| F| |TAMS 0x000000061ac00000, 0x000000061ac00000| Untracked
|
||||
| 104|0x000000061b000000, 0x000000061b000000, 0x000000061b400000| 0%| F| |TAMS 0x000000061b000000, 0x000000061b000000| Untracked
|
||||
| 105|0x000000061b400000, 0x000000061b800000, 0x000000061b800000|100%| O| |TAMS 0x000000061b800000, 0x000000061b400000| Complete
|
||||
| 106|0x000000061b800000, 0x000000061bc00000, 0x000000061bc00000|100%| O| |TAMS 0x000000061bc00000, 0x000000061b800000| Untracked
|
||||
| 107|0x000000061bc00000, 0x000000061c000000, 0x000000061c000000|100%| O| |TAMS 0x000000061c000000, 0x000000061bc00000| Untracked
|
||||
| 108|0x000000061c000000, 0x000000061c000000, 0x000000061c400000| 0%| F| |TAMS 0x000000061c000000, 0x000000061c000000| Untracked
|
||||
| 109|0x000000061c400000, 0x000000061c800000, 0x000000061c800000|100%| O| |TAMS 0x000000061c800000, 0x000000061c400000| Untracked
|
||||
| 110|0x000000061c800000, 0x000000061cc00000, 0x000000061cc00000|100%| O| |TAMS 0x000000061cc00000, 0x000000061c800000| Untracked
|
||||
| 111|0x000000061cc00000, 0x000000061cc00000, 0x000000061d000000| 0%| F| |TAMS 0x000000061cc00000, 0x000000061cc00000| Untracked
|
||||
| 112|0x000000061d000000, 0x000000061d400000, 0x000000061d400000|100%| O| |TAMS 0x000000061d400000, 0x000000061d000000| Untracked
|
||||
| 113|0x000000061d400000, 0x000000061d800000, 0x000000061d800000|100%| O| |TAMS 0x000000061d800000, 0x000000061d400000| Untracked
|
||||
| 114|0x000000061d800000, 0x000000061d800000, 0x000000061dc00000| 0%| F| |TAMS 0x000000061d800000, 0x000000061d800000| Untracked
|
||||
| 115|0x000000061dc00000, 0x000000061e000000, 0x000000061e000000|100%| O| |TAMS 0x000000061e000000, 0x000000061dc00000| Untracked
|
||||
| 116|0x000000061e000000, 0x000000061e400000, 0x000000061e400000|100%| O| |TAMS 0x000000061e400000, 0x000000061e000000| Untracked
|
||||
| 117|0x000000061e400000, 0x000000061e800000, 0x000000061e800000|100%| O| |TAMS 0x000000061e800000, 0x000000061e400000| Untracked
|
||||
| 118|0x000000061e800000, 0x000000061ec00000, 0x000000061ec00000|100%| O| |TAMS 0x000000061ec00000, 0x000000061e800000| Untracked
|
||||
| 119|0x000000061ec00000, 0x000000061f000000, 0x000000061f000000|100%| O| |TAMS 0x000000061f000000, 0x000000061ec00000| Untracked
|
||||
| 120|0x000000061f000000, 0x000000061f400000, 0x000000061f400000|100%| O| |TAMS 0x000000061f400000, 0x000000061f000000| Untracked
|
||||
| 121|0x000000061f400000, 0x000000061f800000, 0x000000061f800000|100%| O| |TAMS 0x000000061f800000, 0x000000061f400000| Untracked
|
||||
| 122|0x000000061f800000, 0x000000061f800000, 0x000000061fc00000| 0%| F| |TAMS 0x000000061f800000, 0x000000061f800000| Untracked
|
||||
| 123|0x000000061fc00000, 0x0000000620000000, 0x0000000620000000|100%| O| |TAMS 0x0000000620000000, 0x000000061fc00000| Complete
|
||||
| 124|0x0000000620000000, 0x0000000620400000, 0x0000000620400000|100%| O| |TAMS 0x0000000620400000, 0x0000000620000000| Complete
|
||||
| 125|0x0000000620400000, 0x0000000620800000, 0x0000000620800000|100%| O| |TAMS 0x0000000620800000, 0x0000000620400000| Untracked
|
||||
| 126|0x0000000620800000, 0x0000000620c00000, 0x0000000620c00000|100%| O| |TAMS 0x0000000620c00000, 0x0000000620800000| Untracked
|
||||
| 127|0x0000000620c00000, 0x0000000621000000, 0x0000000621000000|100%| O| |TAMS 0x0000000621000000, 0x0000000620c00000| Untracked
|
||||
| 128|0x0000000621000000, 0x0000000621400000, 0x0000000621400000|100%| O| |TAMS 0x0000000621400000, 0x0000000621000000| Untracked
|
||||
| 129|0x0000000621400000, 0x0000000621800000, 0x0000000621800000|100%| O| |TAMS 0x0000000621800000, 0x0000000621400000| Complete
|
||||
| 130|0x0000000621800000, 0x0000000621c00000, 0x0000000621c00000|100%| O| |TAMS 0x0000000621c00000, 0x0000000621800000| Untracked
|
||||
| 131|0x0000000621c00000, 0x0000000622000000, 0x0000000622000000|100%| O| |TAMS 0x0000000622000000, 0x0000000621c00000| Untracked
|
||||
| 132|0x0000000622000000, 0x0000000622400000, 0x0000000622400000|100%| O| |TAMS 0x0000000622400000, 0x0000000622000000| Untracked
|
||||
| 133|0x0000000622400000, 0x0000000622800000, 0x0000000622800000|100%| O| |TAMS 0x0000000622800000, 0x0000000622400000| Untracked
|
||||
| 134|0x0000000622800000, 0x0000000622c00000, 0x0000000622c00000|100%| O| |TAMS 0x0000000622c00000, 0x0000000622800000| Complete
|
||||
| 135|0x0000000622c00000, 0x0000000623000000, 0x0000000623000000|100%| O| |TAMS 0x0000000623000000, 0x0000000622c00000| Untracked
|
||||
| 136|0x0000000623000000, 0x0000000623400000, 0x0000000623400000|100%| O| |TAMS 0x0000000623400000, 0x0000000623000000| Untracked
|
||||
| 137|0x0000000623400000, 0x0000000623800000, 0x0000000623800000|100%| O| |TAMS 0x0000000623800000, 0x0000000623400000| Untracked
|
||||
| 138|0x0000000623800000, 0x0000000623c00000, 0x0000000623c00000|100%| O| |TAMS 0x0000000623c00000, 0x0000000623800000| Untracked
|
||||
| 139|0x0000000623c00000, 0x0000000624000000, 0x0000000624000000|100%| O| |TAMS 0x0000000624000000, 0x0000000623c00000| Complete
|
||||
| 140|0x0000000624000000, 0x0000000624000000, 0x0000000624400000| 0%| F| |TAMS 0x0000000624000000, 0x0000000624000000| Untracked
|
||||
| 141|0x0000000624400000, 0x0000000624400000, 0x0000000624800000| 0%| F| |TAMS 0x0000000624400000, 0x0000000624400000| Untracked
|
||||
| 142|0x0000000624800000, 0x0000000624c00000, 0x0000000624c00000|100%| O| |TAMS 0x0000000624c00000, 0x0000000624800000| Complete
|
||||
| 143|0x0000000624c00000, 0x0000000624c00000, 0x0000000625000000| 0%| F| |TAMS 0x0000000624c00000, 0x0000000624c00000| Untracked
|
||||
| 144|0x0000000625000000, 0x0000000625400000, 0x0000000625400000|100%| O| |TAMS 0x0000000625400000, 0x0000000625000000| Untracked
|
||||
| 145|0x0000000625400000, 0x0000000625800000, 0x0000000625800000|100%| O| |TAMS 0x0000000625800000, 0x0000000625400000| Untracked
|
||||
| 146|0x0000000625800000, 0x0000000625c00000, 0x0000000625c00000|100%| O| |TAMS 0x0000000625c00000, 0x0000000625800000| Untracked
|
||||
| 147|0x0000000625c00000, 0x0000000626000000, 0x0000000626000000|100%| O| |TAMS 0x0000000626000000, 0x0000000625c00000| Untracked
|
||||
| 148|0x0000000626000000, 0x0000000626400000, 0x0000000626400000|100%| O| |TAMS 0x0000000626400000, 0x0000000626000000| Untracked
|
||||
| 149|0x0000000626400000, 0x0000000626800000, 0x0000000626800000|100%| O| |TAMS 0x0000000626800000, 0x0000000626400000| Untracked
|
||||
| 150|0x0000000626800000, 0x0000000626800000, 0x0000000626c00000| 0%| F| |TAMS 0x0000000626800000, 0x0000000626800000| Untracked
|
||||
| 151|0x0000000626c00000, 0x0000000626c00000, 0x0000000627000000| 0%| F| |TAMS 0x0000000626c00000, 0x0000000626c00000| Untracked
|
||||
| 152|0x0000000627000000, 0x0000000627400000, 0x0000000627400000|100%| O| |TAMS 0x0000000627400000, 0x0000000627000000| Untracked
|
||||
| 153|0x0000000627400000, 0x0000000627800000, 0x0000000627800000|100%|HS| |TAMS 0x0000000627800000, 0x0000000627400000| Complete
|
||||
| 154|0x0000000627800000, 0x0000000627c00000, 0x0000000627c00000|100%| O| |TAMS 0x0000000627836400, 0x0000000627800000| Untracked
|
||||
| 155|0x0000000627c00000, 0x0000000628000000, 0x0000000628000000|100%|HS| |TAMS 0x0000000628000000, 0x0000000627c00000| Complete
|
||||
| 156|0x0000000628000000, 0x0000000628400000, 0x0000000628400000|100%| O| |TAMS 0x0000000628000000, 0x0000000628000000| Untracked
|
||||
| 157|0x0000000628400000, 0x0000000628800000, 0x0000000628800000|100%| O| |TAMS 0x0000000628400000, 0x0000000628400000| Untracked
|
||||
| 158|0x0000000628800000, 0x0000000628c00000, 0x0000000628c00000|100%| O| |TAMS 0x0000000628800000, 0x0000000628800000| Untracked
|
||||
| 159|0x0000000628c00000, 0x0000000629000000, 0x0000000629000000|100%| O| |TAMS 0x0000000628c00000, 0x0000000628c00000| Untracked
|
||||
| 160|0x0000000629000000, 0x0000000629400000, 0x0000000629400000|100%| O| |TAMS 0x0000000629000000, 0x0000000629000000| Untracked
|
||||
| 161|0x0000000629400000, 0x0000000629800000, 0x0000000629800000|100%| O| |TAMS 0x0000000629400000, 0x0000000629400000| Untracked
|
||||
| 162|0x0000000629800000, 0x0000000629c00000, 0x0000000629c00000|100%| O| |TAMS 0x0000000629800000, 0x0000000629800000| Untracked
|
||||
| 163|0x0000000629c00000, 0x000000062a000000, 0x000000062a000000|100%| O| |TAMS 0x0000000629c00000, 0x0000000629c00000| Untracked
|
||||
| 164|0x000000062a000000, 0x000000062a400000, 0x000000062a400000|100%| O| |TAMS 0x000000062a000000, 0x000000062a000000| Untracked
|
||||
| 165|0x000000062a400000, 0x000000062a800000, 0x000000062a800000|100%| O| |TAMS 0x000000062a400000, 0x000000062a400000| Untracked
|
||||
| 166|0x000000062a800000, 0x000000062ac00000, 0x000000062ac00000|100%| O| |TAMS 0x000000062a800000, 0x000000062a800000| Untracked
|
||||
| 167|0x000000062ac00000, 0x000000062b000000, 0x000000062b000000|100%| O| |TAMS 0x000000062ac00000, 0x000000062ac00000| Untracked
|
||||
| 168|0x000000062b000000, 0x000000062b400000, 0x000000062b400000|100%| O| |TAMS 0x000000062b000000, 0x000000062b000000| Untracked
|
||||
| 169|0x000000062b400000, 0x000000062b800000, 0x000000062b800000|100%| O| |TAMS 0x000000062b400000, 0x000000062b400000| Untracked
|
||||
| 170|0x000000062b800000, 0x000000062bc00000, 0x000000062bc00000|100%| O| |TAMS 0x000000062b800000, 0x000000062b800000| Untracked
|
||||
| 171|0x000000062bc00000, 0x000000062c000000, 0x000000062c000000|100%| O| |TAMS 0x000000062bc00000, 0x000000062bc00000| Untracked
|
||||
| 172|0x000000062c000000, 0x000000062c400000, 0x000000062c400000|100%| O| |TAMS 0x000000062c000000, 0x000000062c000000| Untracked
|
||||
| 173|0x000000062c400000, 0x000000062c800000, 0x000000062c800000|100%| O| |TAMS 0x000000062c400000, 0x000000062c400000| Untracked
|
||||
| 174|0x000000062c800000, 0x000000062cc00000, 0x000000062cc00000|100%| O| |TAMS 0x000000062c800000, 0x000000062c800000| Untracked
|
||||
| 175|0x000000062cc00000, 0x000000062d000000, 0x000000062d000000|100%| O| |TAMS 0x000000062cc00000, 0x000000062cc00000| Untracked
|
||||
| 176|0x000000062d000000, 0x000000062d400000, 0x000000062d400000|100%| O| |TAMS 0x000000062d000000, 0x000000062d000000| Untracked
|
||||
| 177|0x000000062d400000, 0x000000062d800000, 0x000000062d800000|100%| O| |TAMS 0x000000062d400000, 0x000000062d400000| Untracked
|
||||
| 178|0x000000062d800000, 0x000000062dc00000, 0x000000062dc00000|100%| O| |TAMS 0x000000062d800000, 0x000000062d800000| Untracked
|
||||
| 179|0x000000062dc00000, 0x000000062dc00000, 0x000000062e000000| 0%| F| |TAMS 0x000000062dc00000, 0x000000062dc00000| Untracked
|
||||
| 180|0x000000062e000000, 0x000000062e000000, 0x000000062e400000| 0%| F| |TAMS 0x000000062e000000, 0x000000062e000000| Untracked
|
||||
| 181|0x000000062e400000, 0x000000062e400000, 0x000000062e800000| 0%| F| |TAMS 0x000000062e400000, 0x000000062e400000| Untracked
|
||||
| 182|0x000000062e800000, 0x000000062e800000, 0x000000062ec00000| 0%| F| |TAMS 0x000000062e800000, 0x000000062e800000| Untracked
|
||||
| 183|0x000000062ec00000, 0x000000062ec00000, 0x000000062f000000| 0%| F| |TAMS 0x000000062ec00000, 0x000000062ec00000| Untracked
|
||||
| 184|0x000000062f000000, 0x000000062f000000, 0x000000062f400000| 0%| F| |TAMS 0x000000062f000000, 0x000000062f000000| Untracked
|
||||
| 185|0x000000062f400000, 0x000000062f400000, 0x000000062f800000| 0%| F| |TAMS 0x000000062f400000, 0x000000062f400000| Untracked
|
||||
| 186|0x000000062f800000, 0x000000062f800000, 0x000000062fc00000| 0%| F| |TAMS 0x000000062f800000, 0x000000062f800000| Untracked
|
||||
| 187|0x000000062fc00000, 0x000000062fc00000, 0x0000000630000000| 0%| F| |TAMS 0x000000062fc00000, 0x000000062fc00000| Untracked
|
||||
| 188|0x0000000630000000, 0x0000000630000000, 0x0000000630400000| 0%| F| |TAMS 0x0000000630000000, 0x0000000630000000| Untracked
|
||||
| 189|0x0000000630400000, 0x0000000630400000, 0x0000000630800000| 0%| F| |TAMS 0x0000000630400000, 0x0000000630400000| Untracked
|
||||
| 190|0x0000000630800000, 0x0000000630800000, 0x0000000630c00000| 0%| F| |TAMS 0x0000000630800000, 0x0000000630800000| Untracked
|
||||
| 191|0x0000000630c00000, 0x0000000630c00000, 0x0000000631000000| 0%| F| |TAMS 0x0000000630c00000, 0x0000000630c00000| Untracked
|
||||
| 192|0x0000000631000000, 0x0000000631000000, 0x0000000631400000| 0%| F| |TAMS 0x0000000631000000, 0x0000000631000000| Untracked
|
||||
| 193|0x0000000631400000, 0x0000000631400000, 0x0000000631800000| 0%| F| |TAMS 0x0000000631400000, 0x0000000631400000| Untracked
|
||||
| 194|0x0000000631800000, 0x0000000631800000, 0x0000000631c00000| 0%| F| |TAMS 0x0000000631800000, 0x0000000631800000| Untracked
|
||||
| 195|0x0000000631c00000, 0x0000000631c00000, 0x0000000632000000| 0%| F| |TAMS 0x0000000631c00000, 0x0000000631c00000| Untracked
|
||||
| 196|0x0000000632000000, 0x0000000632000000, 0x0000000632400000| 0%| F| |TAMS 0x0000000632000000, 0x0000000632000000| Untracked
|
||||
| 197|0x0000000632400000, 0x0000000632400000, 0x0000000632800000| 0%| F| |TAMS 0x0000000632400000, 0x0000000632400000| Untracked
|
||||
| 198|0x0000000632800000, 0x0000000632800000, 0x0000000632c00000| 0%| F| |TAMS 0x0000000632800000, 0x0000000632800000| Untracked
|
||||
| 199|0x0000000632c00000, 0x0000000632c00000, 0x0000000633000000| 0%| F| |TAMS 0x0000000632c00000, 0x0000000632c00000| Untracked
|
||||
| 200|0x0000000633000000, 0x0000000633000000, 0x0000000633400000| 0%| F| |TAMS 0x0000000633000000, 0x0000000633000000| Untracked
|
||||
| 201|0x0000000633400000, 0x0000000633400000, 0x0000000633800000| 0%| F| |TAMS 0x0000000633400000, 0x0000000633400000| Untracked
|
||||
| 202|0x0000000633800000, 0x0000000633800000, 0x0000000633c00000| 0%| F| |TAMS 0x0000000633800000, 0x0000000633800000| Untracked
|
||||
| 203|0x0000000633c00000, 0x0000000633c00000, 0x0000000634000000| 0%| F| |TAMS 0x0000000633c00000, 0x0000000633c00000| Untracked
|
||||
| 204|0x0000000634000000, 0x0000000634000000, 0x0000000634400000| 0%| F| |TAMS 0x0000000634000000, 0x0000000634000000| Untracked
|
||||
| 205|0x0000000634400000, 0x0000000634400000, 0x0000000634800000| 0%| F| |TAMS 0x0000000634400000, 0x0000000634400000| Untracked
|
||||
| 206|0x0000000634800000, 0x0000000634800000, 0x0000000634c00000| 0%| F| |TAMS 0x0000000634800000, 0x0000000634800000| Untracked
|
||||
| 207|0x0000000634c00000, 0x0000000634c00000, 0x0000000635000000| 0%| F| |TAMS 0x0000000634c00000, 0x0000000634c00000| Untracked
|
||||
| 208|0x0000000635000000, 0x0000000635000000, 0x0000000635400000| 0%| F| |TAMS 0x0000000635000000, 0x0000000635000000| Untracked
|
||||
| 209|0x0000000635400000, 0x0000000635400000, 0x0000000635800000| 0%| F| |TAMS 0x0000000635400000, 0x0000000635400000| Untracked
|
||||
| 210|0x0000000635800000, 0x0000000635800000, 0x0000000635c00000| 0%| F| |TAMS 0x0000000635800000, 0x0000000635800000| Untracked
|
||||
| 211|0x0000000635c00000, 0x0000000635c00000, 0x0000000636000000| 0%| F| |TAMS 0x0000000635c00000, 0x0000000635c00000| Untracked
|
||||
| 212|0x0000000636000000, 0x0000000636000000, 0x0000000636400000| 0%| F| |TAMS 0x0000000636000000, 0x0000000636000000| Untracked
|
||||
| 213|0x0000000636400000, 0x0000000636400000, 0x0000000636800000| 0%| F| |TAMS 0x0000000636400000, 0x0000000636400000| Untracked
|
||||
| 214|0x0000000636800000, 0x0000000636800000, 0x0000000636c00000| 0%| F| |TAMS 0x0000000636800000, 0x0000000636800000| Untracked
|
||||
| 215|0x0000000636c00000, 0x0000000636c00000, 0x0000000637000000| 0%| F| |TAMS 0x0000000636c00000, 0x0000000636c00000| Untracked
|
||||
| 216|0x0000000637000000, 0x0000000637000000, 0x0000000637400000| 0%| F| |TAMS 0x0000000637000000, 0x0000000637000000| Untracked
|
||||
| 217|0x0000000637400000, 0x0000000637400000, 0x0000000637800000| 0%| F| |TAMS 0x0000000637400000, 0x0000000637400000| Untracked
|
||||
| 218|0x0000000637800000, 0x0000000637800000, 0x0000000637c00000| 0%| F| |TAMS 0x0000000637800000, 0x0000000637800000| Untracked
|
||||
| 219|0x0000000637c00000, 0x0000000637c00000, 0x0000000638000000| 0%| F| |TAMS 0x0000000637c00000, 0x0000000637c00000| Untracked
|
||||
| 220|0x0000000638000000, 0x0000000638000000, 0x0000000638400000| 0%| F| |TAMS 0x0000000638000000, 0x0000000638000000| Untracked
|
||||
| 221|0x0000000638400000, 0x0000000638400000, 0x0000000638800000| 0%| F| |TAMS 0x0000000638400000, 0x0000000638400000| Untracked
|
||||
| 222|0x0000000638800000, 0x0000000638800000, 0x0000000638c00000| 0%| F| |TAMS 0x0000000638800000, 0x0000000638800000| Untracked
|
||||
| 223|0x0000000638c00000, 0x0000000638c00000, 0x0000000639000000| 0%| F| |TAMS 0x0000000638c00000, 0x0000000638c00000| Untracked
|
||||
| 224|0x0000000639000000, 0x0000000639000000, 0x0000000639400000| 0%| F| |TAMS 0x0000000639000000, 0x0000000639000000| Untracked
|
||||
| 225|0x0000000639400000, 0x0000000639400000, 0x0000000639800000| 0%| F| |TAMS 0x0000000639400000, 0x0000000639400000| Untracked
|
||||
| 226|0x0000000639800000, 0x0000000639800000, 0x0000000639c00000| 0%| F| |TAMS 0x0000000639800000, 0x0000000639800000| Untracked
|
||||
| 227|0x0000000639c00000, 0x0000000639c00000, 0x000000063a000000| 0%| F| |TAMS 0x0000000639c00000, 0x0000000639c00000| Untracked
|
||||
| 228|0x000000063a000000, 0x000000063a000000, 0x000000063a400000| 0%| F| |TAMS 0x000000063a000000, 0x000000063a000000| Untracked
|
||||
| 229|0x000000063a400000, 0x000000063a400000, 0x000000063a800000| 0%| F| |TAMS 0x000000063a400000, 0x000000063a400000| Untracked
|
||||
| 230|0x000000063a800000, 0x000000063a800000, 0x000000063ac00000| 0%| F| |TAMS 0x000000063a800000, 0x000000063a800000| Untracked
|
||||
| 231|0x000000063ac00000, 0x000000063ac00000, 0x000000063b000000| 0%| F| |TAMS 0x000000063ac00000, 0x000000063ac00000| Untracked
|
||||
| 232|0x000000063b000000, 0x000000063b000000, 0x000000063b400000| 0%| F| |TAMS 0x000000063b000000, 0x000000063b000000| Untracked
|
||||
| 233|0x000000063b400000, 0x000000063b400000, 0x000000063b800000| 0%| F| |TAMS 0x000000063b400000, 0x000000063b400000| Untracked
|
||||
| 234|0x000000063b800000, 0x000000063b800000, 0x000000063bc00000| 0%| F| |TAMS 0x000000063b800000, 0x000000063b800000| Untracked
|
||||
| 235|0x000000063bc00000, 0x000000063bc00000, 0x000000063c000000| 0%| F| |TAMS 0x000000063bc00000, 0x000000063bc00000| Untracked
|
||||
| 236|0x000000063c000000, 0x000000063c000000, 0x000000063c400000| 0%| F| |TAMS 0x000000063c000000, 0x000000063c000000| Untracked
|
||||
| 237|0x000000063c400000, 0x000000063c400000, 0x000000063c800000| 0%| F| |TAMS 0x000000063c400000, 0x000000063c400000| Untracked
|
||||
| 238|0x000000063c800000, 0x000000063c800000, 0x000000063cc00000| 0%| F| |TAMS 0x000000063c800000, 0x000000063c800000| Untracked
|
||||
| 239|0x000000063cc00000, 0x000000063cc00000, 0x000000063d000000| 0%| F| |TAMS 0x000000063cc00000, 0x000000063cc00000| Untracked
|
||||
| 240|0x000000063d000000, 0x000000063d000000, 0x000000063d400000| 0%| F| |TAMS 0x000000063d000000, 0x000000063d000000| Untracked
|
||||
| 241|0x000000063d400000, 0x000000063d400000, 0x000000063d800000| 0%| F| |TAMS 0x000000063d400000, 0x000000063d400000| Untracked
|
||||
| 242|0x000000063d800000, 0x000000063d800000, 0x000000063dc00000| 0%| F| |TAMS 0x000000063d800000, 0x000000063d800000| Untracked
|
||||
| 243|0x000000063dc00000, 0x000000063dc00000, 0x000000063e000000| 0%| F| |TAMS 0x000000063dc00000, 0x000000063dc00000| Untracked
|
||||
| 244|0x000000063e000000, 0x000000063e000000, 0x000000063e400000| 0%| F| |TAMS 0x000000063e000000, 0x000000063e000000| Untracked
|
||||
| 245|0x000000063e400000, 0x000000063e400000, 0x000000063e800000| 0%| F| |TAMS 0x000000063e400000, 0x000000063e400000| Untracked
|
||||
| 246|0x000000063e800000, 0x000000063e800000, 0x000000063ec00000| 0%| F| |TAMS 0x000000063e800000, 0x000000063e800000| Untracked
|
||||
| 247|0x000000063ec00000, 0x000000063ec00000, 0x000000063f000000| 0%| F| |TAMS 0x000000063ec00000, 0x000000063ec00000| Untracked
|
||||
| 248|0x000000063f000000, 0x000000063f000000, 0x000000063f400000| 0%| F| |TAMS 0x000000063f000000, 0x000000063f000000| Untracked
|
||||
| 249|0x000000063f400000, 0x000000063f400000, 0x000000063f800000| 0%| F| |TAMS 0x000000063f400000, 0x000000063f400000| Untracked
|
||||
| 250|0x000000063f800000, 0x000000063f800000, 0x000000063fc00000| 0%| F| |TAMS 0x000000063f800000, 0x000000063f800000| Untracked
|
||||
| 251|0x000000063fc00000, 0x000000063fc00000, 0x0000000640000000| 0%| F| |TAMS 0x000000063fc00000, 0x000000063fc00000| Untracked
|
||||
| 252|0x0000000640000000, 0x0000000640000000, 0x0000000640400000| 0%| F| |TAMS 0x0000000640000000, 0x0000000640000000| Untracked
|
||||
| 253|0x0000000640400000, 0x0000000640400000, 0x0000000640800000| 0%| F| |TAMS 0x0000000640400000, 0x0000000640400000| Untracked
|
||||
| 254|0x0000000640800000, 0x0000000640800000, 0x0000000640c00000| 0%| F| |TAMS 0x0000000640800000, 0x0000000640800000| Untracked
|
||||
| 255|0x0000000640c00000, 0x0000000640c00000, 0x0000000641000000| 0%| F| |TAMS 0x0000000640c00000, 0x0000000640c00000| Untracked
|
||||
| 256|0x0000000641000000, 0x0000000641000000, 0x0000000641400000| 0%| F| |TAMS 0x0000000641000000, 0x0000000641000000| Untracked
|
||||
| 257|0x0000000641400000, 0x0000000641400000, 0x0000000641800000| 0%| F| |TAMS 0x0000000641400000, 0x0000000641400000| Untracked
|
||||
| 258|0x0000000641800000, 0x0000000641800000, 0x0000000641c00000| 0%| F| |TAMS 0x0000000641800000, 0x0000000641800000| Untracked
|
||||
| 259|0x0000000641c00000, 0x0000000641c00000, 0x0000000642000000| 0%| F| |TAMS 0x0000000641c00000, 0x0000000641c00000| Untracked
|
||||
| 260|0x0000000642000000, 0x0000000642000000, 0x0000000642400000| 0%| F| |TAMS 0x0000000642000000, 0x0000000642000000| Untracked
|
||||
| 261|0x0000000642400000, 0x0000000642400000, 0x0000000642800000| 0%| F| |TAMS 0x0000000642400000, 0x0000000642400000| Untracked
|
||||
| 262|0x0000000642800000, 0x0000000642800000, 0x0000000642c00000| 0%| F| |TAMS 0x0000000642800000, 0x0000000642800000| Untracked
|
||||
| 263|0x0000000642c00000, 0x0000000642c00000, 0x0000000643000000| 0%| F| |TAMS 0x0000000642c00000, 0x0000000642c00000| Untracked
|
||||
| 264|0x0000000643000000, 0x0000000643000000, 0x0000000643400000| 0%| F| |TAMS 0x0000000643000000, 0x0000000643000000| Untracked
|
||||
| 265|0x0000000643400000, 0x0000000643400000, 0x0000000643800000| 0%| F| |TAMS 0x0000000643400000, 0x0000000643400000| Untracked
|
||||
| 266|0x0000000643800000, 0x0000000643800000, 0x0000000643c00000| 0%| F| |TAMS 0x0000000643800000, 0x0000000643800000| Untracked
|
||||
| 267|0x0000000643c00000, 0x0000000643c00000, 0x0000000644000000| 0%| F| |TAMS 0x0000000643c00000, 0x0000000643c00000| Untracked
|
||||
| 268|0x0000000644000000, 0x0000000644000000, 0x0000000644400000| 0%| F| |TAMS 0x0000000644000000, 0x0000000644000000| Untracked
|
||||
| 269|0x0000000644400000, 0x0000000644400000, 0x0000000644800000| 0%| F| |TAMS 0x0000000644400000, 0x0000000644400000| Untracked
|
||||
| 270|0x0000000644800000, 0x0000000644800000, 0x0000000644c00000| 0%| F| |TAMS 0x0000000644800000, 0x0000000644800000| Untracked
|
||||
| 271|0x0000000644c00000, 0x0000000644c00000, 0x0000000645000000| 0%| F| |TAMS 0x0000000644c00000, 0x0000000644c00000| Untracked
|
||||
| 272|0x0000000645000000, 0x0000000645000000, 0x0000000645400000| 0%| F| |TAMS 0x0000000645000000, 0x0000000645000000| Untracked
|
||||
| 273|0x0000000645400000, 0x0000000645400000, 0x0000000645800000| 0%| F| |TAMS 0x0000000645400000, 0x0000000645400000| Untracked
|
||||
| 274|0x0000000645800000, 0x0000000645800000, 0x0000000645c00000| 0%| F| |TAMS 0x0000000645800000, 0x0000000645800000| Untracked
|
||||
| 275|0x0000000645c00000, 0x0000000645c00000, 0x0000000646000000| 0%| F| |TAMS 0x0000000645c00000, 0x0000000645c00000| Untracked
|
||||
| 276|0x0000000646000000, 0x0000000646000000, 0x0000000646400000| 0%| F| |TAMS 0x0000000646000000, 0x0000000646000000| Untracked
|
||||
| 277|0x0000000646400000, 0x0000000646400000, 0x0000000646800000| 0%| F| |TAMS 0x0000000646400000, 0x0000000646400000| Untracked
|
||||
| 278|0x0000000646800000, 0x0000000646800000, 0x0000000646c00000| 0%| F| |TAMS 0x0000000646800000, 0x0000000646800000| Untracked
|
||||
| 279|0x0000000646c00000, 0x0000000646c00000, 0x0000000647000000| 0%| F| |TAMS 0x0000000646c00000, 0x0000000646c00000| Untracked
|
||||
| 280|0x0000000647000000, 0x0000000647000000, 0x0000000647400000| 0%| F| |TAMS 0x0000000647000000, 0x0000000647000000| Untracked
|
||||
| 281|0x0000000647400000, 0x0000000647400000, 0x0000000647800000| 0%| F| |TAMS 0x0000000647400000, 0x0000000647400000| Untracked
|
||||
| 282|0x0000000647800000, 0x0000000647800000, 0x0000000647c00000| 0%| F| |TAMS 0x0000000647800000, 0x0000000647800000| Untracked
|
||||
| 283|0x0000000647c00000, 0x0000000647c00000, 0x0000000648000000| 0%| F| |TAMS 0x0000000647c00000, 0x0000000647c00000| Untracked
|
||||
| 284|0x0000000648000000, 0x0000000648000000, 0x0000000648400000| 0%| F| |TAMS 0x0000000648000000, 0x0000000648000000| Untracked
|
||||
| 285|0x0000000648400000, 0x0000000648400000, 0x0000000648800000| 0%| F| |TAMS 0x0000000648400000, 0x0000000648400000| Untracked
|
||||
| 286|0x0000000648800000, 0x0000000648800000, 0x0000000648c00000| 0%| F| |TAMS 0x0000000648800000, 0x0000000648800000| Untracked
|
||||
| 287|0x0000000648c00000, 0x0000000648c00000, 0x0000000649000000| 0%| F| |TAMS 0x0000000648c00000, 0x0000000648c00000| Untracked
|
||||
| 288|0x0000000649000000, 0x0000000649000000, 0x0000000649400000| 0%| F| |TAMS 0x0000000649000000, 0x0000000649000000| Untracked
|
||||
| 289|0x0000000649400000, 0x0000000649400000, 0x0000000649800000| 0%| F| |TAMS 0x0000000649400000, 0x0000000649400000| Untracked
|
||||
| 290|0x0000000649800000, 0x0000000649800000, 0x0000000649c00000| 0%| F| |TAMS 0x0000000649800000, 0x0000000649800000| Untracked
|
||||
| 291|0x0000000649c00000, 0x0000000649c00000, 0x000000064a000000| 0%| F| |TAMS 0x0000000649c00000, 0x0000000649c00000| Untracked
|
||||
| 292|0x000000064a000000, 0x000000064a000000, 0x000000064a400000| 0%| F| |TAMS 0x000000064a000000, 0x000000064a000000| Untracked
|
||||
| 293|0x000000064a400000, 0x000000064a400000, 0x000000064a800000| 0%| F| |TAMS 0x000000064a400000, 0x000000064a400000| Untracked
|
||||
| 294|0x000000064a800000, 0x000000064a800000, 0x000000064ac00000| 0%| F| |TAMS 0x000000064a800000, 0x000000064a800000| Untracked
|
||||
| 295|0x000000064ac00000, 0x000000064ac00000, 0x000000064b000000| 0%| F| |TAMS 0x000000064ac00000, 0x000000064ac00000| Untracked
|
||||
| 296|0x000000064b000000, 0x000000064b000000, 0x000000064b400000| 0%| F| |TAMS 0x000000064b000000, 0x000000064b000000| Untracked
|
||||
| 297|0x000000064b400000, 0x000000064b400000, 0x000000064b800000| 0%| F| |TAMS 0x000000064b400000, 0x000000064b400000| Untracked
|
||||
| 298|0x000000064b800000, 0x000000064b800000, 0x000000064bc00000| 0%| F| |TAMS 0x000000064b800000, 0x000000064b800000| Untracked
|
||||
| 299|0x000000064bc00000, 0x000000064bc00000, 0x000000064c000000| 0%| F| |TAMS 0x000000064bc00000, 0x000000064bc00000| Untracked
|
||||
| 300|0x000000064c000000, 0x000000064c000000, 0x000000064c400000| 0%| F| |TAMS 0x000000064c000000, 0x000000064c000000| Untracked
|
||||
| 301|0x000000064c400000, 0x000000064c400000, 0x000000064c800000| 0%| F| |TAMS 0x000000064c400000, 0x000000064c400000| Untracked
|
||||
| 302|0x000000064c800000, 0x000000064c800000, 0x000000064cc00000| 0%| F| |TAMS 0x000000064c800000, 0x000000064c800000| Untracked
|
||||
| 303|0x000000064cc00000, 0x000000064cc00000, 0x000000064d000000| 0%| F| |TAMS 0x000000064cc00000, 0x000000064cc00000| Untracked
|
||||
| 304|0x000000064d000000, 0x000000064d000000, 0x000000064d400000| 0%| F| |TAMS 0x000000064d000000, 0x000000064d000000| Untracked
|
||||
| 305|0x000000064d400000, 0x000000064d400000, 0x000000064d800000| 0%| F| |TAMS 0x000000064d400000, 0x000000064d400000| Untracked
|
||||
| 306|0x000000064d800000, 0x000000064d800000, 0x000000064dc00000| 0%| F| |TAMS 0x000000064d800000, 0x000000064d800000| Untracked
|
||||
| 307|0x000000064dc00000, 0x000000064dc00000, 0x000000064e000000| 0%| F| |TAMS 0x000000064dc00000, 0x000000064dc00000| Untracked
|
||||
| 308|0x000000064e000000, 0x000000064e000000, 0x000000064e400000| 0%| F| |TAMS 0x000000064e000000, 0x000000064e000000| Untracked
|
||||
| 309|0x000000064e400000, 0x000000064e400000, 0x000000064e800000| 0%| F| |TAMS 0x000000064e400000, 0x000000064e400000| Untracked
|
||||
| 310|0x000000064e800000, 0x000000064e800000, 0x000000064ec00000| 0%| F| |TAMS 0x000000064e800000, 0x000000064e800000| Untracked
|
||||
| 311|0x000000064ec00000, 0x000000064ec00000, 0x000000064f000000| 0%| F| |TAMS 0x000000064ec00000, 0x000000064ec00000| Untracked
|
||||
| 312|0x000000064f000000, 0x000000064f000000, 0x000000064f400000| 0%| F| |TAMS 0x000000064f000000, 0x000000064f000000| Untracked
|
||||
| 313|0x000000064f400000, 0x000000064f400000, 0x000000064f800000| 0%| F| |TAMS 0x000000064f400000, 0x000000064f400000| Untracked
|
||||
| 314|0x000000064f800000, 0x000000064f800000, 0x000000064fc00000| 0%| F| |TAMS 0x000000064f800000, 0x000000064f800000| Untracked
|
||||
| 315|0x000000064fc00000, 0x000000064fc00000, 0x0000000650000000| 0%| F| |TAMS 0x000000064fc00000, 0x000000064fc00000| Untracked
|
||||
| 316|0x0000000650000000, 0x0000000650000000, 0x0000000650400000| 0%| F| |TAMS 0x0000000650000000, 0x0000000650000000| Untracked
|
||||
| 317|0x0000000650400000, 0x0000000650400000, 0x0000000650800000| 0%| F| |TAMS 0x0000000650400000, 0x0000000650400000| Untracked
|
||||
| 318|0x0000000650800000, 0x0000000650800000, 0x0000000650c00000| 0%| F| |TAMS 0x0000000650800000, 0x0000000650800000| Untracked
|
||||
| 319|0x0000000650c00000, 0x0000000650c00000, 0x0000000651000000| 0%| F| |TAMS 0x0000000650c00000, 0x0000000650c00000| Untracked
|
||||
| 320|0x0000000651000000, 0x0000000651000000, 0x0000000651400000| 0%| F| |TAMS 0x0000000651000000, 0x0000000651000000| Untracked
|
||||
| 321|0x0000000651400000, 0x0000000651400000, 0x0000000651800000| 0%| F| |TAMS 0x0000000651400000, 0x0000000651400000| Untracked
|
||||
| 322|0x0000000651800000, 0x0000000651800000, 0x0000000651c00000| 0%| F| |TAMS 0x0000000651800000, 0x0000000651800000| Untracked
|
||||
| 323|0x0000000651c00000, 0x0000000651f2dc78, 0x0000000652000000| 79%| S|CS|TAMS 0x0000000651c00000, 0x0000000651c00000| Complete
|
||||
| 324|0x0000000652000000, 0x0000000652400000, 0x0000000652400000|100%| S|CS|TAMS 0x0000000652000000, 0x0000000652000000| Complete
|
||||
| 325|0x0000000652400000, 0x0000000652400000, 0x0000000652800000| 0%| F| |TAMS 0x0000000652400000, 0x0000000652400000| Untracked
|
||||
| 326|0x0000000652800000, 0x0000000652800000, 0x0000000652c00000| 0%| F| |TAMS 0x0000000652800000, 0x0000000652800000| Untracked
|
||||
| 327|0x0000000652c00000, 0x0000000652c00000, 0x0000000653000000| 0%| F| |TAMS 0x0000000652c00000, 0x0000000652c00000| Untracked
|
||||
| 328|0x0000000653000000, 0x0000000653000000, 0x0000000653400000| 0%| F| |TAMS 0x0000000653000000, 0x0000000653000000| Untracked
|
||||
| 329|0x0000000653400000, 0x0000000653400000, 0x0000000653800000| 0%| F| |TAMS 0x0000000653400000, 0x0000000653400000| Untracked
|
||||
| 330|0x0000000653800000, 0x0000000653800000, 0x0000000653c00000| 0%| F| |TAMS 0x0000000653800000, 0x0000000653800000| Untracked
|
||||
| 331|0x0000000653c00000, 0x0000000653c00000, 0x0000000654000000| 0%| F| |TAMS 0x0000000653c00000, 0x0000000653c00000| Untracked
|
||||
| 332|0x0000000654000000, 0x0000000654000000, 0x0000000654400000| 0%| F| |TAMS 0x0000000654000000, 0x0000000654000000| Untracked
|
||||
| 333|0x0000000654400000, 0x0000000654400000, 0x0000000654800000| 0%| F| |TAMS 0x0000000654400000, 0x0000000654400000| Untracked
|
||||
| 334|0x0000000654800000, 0x0000000654800000, 0x0000000654c00000| 0%| F| |TAMS 0x0000000654800000, 0x0000000654800000| Untracked
|
||||
| 335|0x0000000654c00000, 0x0000000654c00000, 0x0000000655000000| 0%| F| |TAMS 0x0000000654c00000, 0x0000000654c00000| Untracked
|
||||
| 336|0x0000000655000000, 0x0000000655000000, 0x0000000655400000| 0%| F| |TAMS 0x0000000655000000, 0x0000000655000000| Untracked
|
||||
| 337|0x0000000655400000, 0x0000000655400000, 0x0000000655800000| 0%| F| |TAMS 0x0000000655400000, 0x0000000655400000| Untracked
|
||||
| 338|0x0000000655800000, 0x0000000655800000, 0x0000000655c00000| 0%| F| |TAMS 0x0000000655800000, 0x0000000655800000| Untracked
|
||||
| 339|0x0000000655c00000, 0x0000000655c00000, 0x0000000656000000| 0%| F| |TAMS 0x0000000655c00000, 0x0000000655c00000| Untracked
|
||||
| 340|0x0000000656000000, 0x0000000656000000, 0x0000000656400000| 0%| F| |TAMS 0x0000000656000000, 0x0000000656000000| Untracked
|
||||
| 341|0x0000000656400000, 0x0000000656400000, 0x0000000656800000| 0%| F| |TAMS 0x0000000656400000, 0x0000000656400000| Untracked
|
||||
|
||||
Card table byte_map: [0x000002576ca50000,0x000002576da50000] _byte_map_base: 0x0000025769a48000
|
||||
|
||||
Marking Bits (Prev, Next): (CMBitMap*) 0x000002575446c810, (CMBitMap*) 0x000002575446c850
|
||||
Prev Bits: [0x000002576ea50000, 0x0000025776a10000)
|
||||
Next Bits: [0x0000025776a10000, 0x000002577e9d0000)
|
||||
|
||||
Polling page: 0x0000025752b40000
|
||||
|
||||
Metaspace:
|
||||
|
||||
Usage:
|
||||
Non-class: 42.90 MB used.
|
||||
Class: 5.31 MB used.
|
||||
Both: 48.21 MB used.
|
||||
|
||||
Virtual space:
|
||||
Non-class space: 64.00 MB reserved, 48.31 MB ( 75%) committed, 1 nodes.
|
||||
Class space: 1.00 GB reserved, 7.00 MB ( <1%) committed, 1 nodes.
|
||||
Both: 1.06 GB reserved, 55.31 MB ( 5%) committed.
|
||||
|
||||
Chunk freelists:
|
||||
Non-Class: 20.77 MB
|
||||
Class: 10.33 MB
|
||||
Both: 31.11 MB
|
||||
|
||||
MaxMetaspaceSize: unlimited
|
||||
CompressedClassSpaceSize: 1.00 GB
|
||||
Initial GC threshold: 21.00 MB
|
||||
Current GC threshold: 92.19 MB
|
||||
CDS: on
|
||||
MetaspaceReclaimPolicy: balanced
|
||||
- commit_granule_bytes: 65536.
|
||||
- commit_granule_words: 8192.
|
||||
- virtual_space_node_default_size: 8388608.
|
||||
- enlarge_chunks_in_place: 1.
|
||||
- new_chunks_are_fully_committed: 0.
|
||||
- uncommit_free_chunks: 1.
|
||||
- use_allocation_guard: 0.
|
||||
- handle_deallocations: 1.
|
||||
|
||||
|
||||
Internal statistics:
|
||||
|
||||
num_allocs_failed_limit: 17.
|
||||
num_arena_births: 758.
|
||||
num_arena_deaths: 140.
|
||||
num_vsnodes_births: 2.
|
||||
num_vsnodes_deaths: 0.
|
||||
num_space_committed: 1232.
|
||||
num_space_uncommitted: 347.
|
||||
num_chunks_returned_to_freelist: 2252.
|
||||
num_chunks_taken_from_freelist: 5191.
|
||||
num_chunk_merges: 689.
|
||||
num_chunk_splits: 2844.
|
||||
num_chunks_enlarged: 1361.
|
||||
num_inconsistent_stats: 0.
|
||||
|
||||
CodeHeap 'non-profiled nmethods': size=120000Kb used=13845Kb max_used=14768Kb free=106154Kb
|
||||
bounds [0x0000025763ac0000, 0x0000025764930000, 0x000002576aff0000]
|
||||
CodeHeap 'profiled nmethods': size=120000Kb used=25344Kb max_used=29850Kb free=94655Kb
|
||||
bounds [0x000002575bff0000, 0x000002575dd20000, 0x0000025763520000]
|
||||
CodeHeap 'non-nmethods': size=5760Kb used=1250Kb max_used=1534Kb free=4509Kb
|
||||
bounds [0x0000025763520000, 0x0000025763790000, 0x0000025763ac0000]
|
||||
total_blobs=13033 nmethods=12471 adapters=473
|
||||
compilation: enabled
|
||||
stopped_count=0, restarted_count=0
|
||||
full_count=0
|
||||
|
||||
Compilation events (20 events):
|
||||
Event: 21.747 Thread 0x000002577ec34090 20241 3 com.sun.tools.javac.comp.TypeEnter$HierarchyPhase::clearTypeParams (38 bytes)
|
||||
Event: 21.747 Thread 0x000002577ec34090 nmethod 20241 0x000002575ccc7b90 code [0x000002575ccc7d60, 0x000002575ccc8108]
|
||||
Event: 21.747 Thread 0x000002577ec34090 20242 3 com.sun.tools.javac.comp.Check$CycleChecker::visitIdent (13 bytes)
|
||||
Event: 21.747 Thread 0x000002577ec34090 nmethod 20242 0x000002575ce5fb10 code [0x000002575ce5fcc0, 0x000002575ce5fee8]
|
||||
Event: 21.747 Thread 0x000002577ec34090 20243 2 lombok.javac.JavacASTAdapter::endVisitCompilationUnit (1 bytes)
|
||||
Event: 21.747 Thread 0x000002577ec34090 nmethod 20243 0x000002575d125290 code [0x000002575d125420, 0x000002575d125518]
|
||||
Event: 21.749 Thread 0x000002577ec34090 20244 2 lombok.javac.handlers.HandleVal::eq (58 bytes)
|
||||
Event: 21.749 Thread 0x000002577ec34090 nmethod 20244 0x000002575c759710 code [0x000002575c759940, 0x000002575c759d48]
|
||||
Event: 21.750 Thread 0x000002577ec34090 20245 2 lombok.javac.JavacASTAdapter::visitAnnotationOnMethod (1 bytes)
|
||||
Event: 21.750 Thread 0x000002577ec34090 nmethod 20245 0x000002575d379f90 code [0x000002575d37a120, 0x000002575d37a218]
|
||||
Event: 21.751 Thread 0x000002577ec34090 20246 ! 2 lombok.javac.handlers.HandleVal::endVisitLocal (993 bytes)
|
||||
Event: 21.755 Thread 0x000002577ec34090 nmethod 20246 0x000002575d413b90 code [0x000002575d4143e0, 0x000002575d417218]
|
||||
Event: 21.755 Thread 0x000002577ec34090 20247 2 lombok.permit.Permit::setAccessible (27 bytes)
|
||||
Event: 21.755 Thread 0x000002577ec34090 nmethod 20247 0x000002575d486d10 code [0x000002575d486ea0, 0x000002575d486f98]
|
||||
Event: 21.759 Thread 0x000002577ec34090 20248 ! 2 lombok.javac.JavacAST::getBodyMethod (64 bytes)
|
||||
Event: 21.759 Thread 0x000002577ec34090 nmethod 20248 0x000002575c3f6d90 code [0x000002575c3f6f80, 0x000002575c3f7368]
|
||||
Event: 21.760 Thread 0x000002577ec34090 20249 2 com.sun.tools.javac.comp.TypeEnter::ensureImportsChecked (62 bytes)
|
||||
Event: 21.761 Thread 0x000002577ec34090 nmethod 20249 0x000002575c7ad110 code [0x000002575c7ad320, 0x000002575c7ad8c8]
|
||||
Event: 21.772 Thread 0x000002577ec34090 20255 2 com.sun.tools.javac.comp.Check::checkRefType (26 bytes)
|
||||
Event: 21.772 Thread 0x000002577ec34090 nmethod 20255 0x000002575c9d3c10 code [0x000002575c9d3de0, 0x000002575c9d3fc8]
|
||||
|
||||
GC Heap History (20 events):
|
||||
Event: 14.570 GC heap after
|
||||
{Heap after GC invocations=35 (full 0):
|
||||
garbage-first heap total 1167360K, used 424005K [0x0000000601000000, 0x0000000800000000)
|
||||
region size 4096K, 8 young (32768K), 8 survivors (32768K)
|
||||
Metaspace used 61566K, committed 62592K, reserved 1114112K
|
||||
class space used 6957K, committed 7424K, reserved 1048576K
|
||||
}
|
||||
Event: 16.908 GC heap before
|
||||
{Heap before GC invocations=35 (full 0):
|
||||
garbage-first heap total 1167360K, used 862277K [0x0000000601000000, 0x0000000800000000)
|
||||
region size 4096K, 115 young (471040K), 8 survivors (32768K)
|
||||
Metaspace used 62236K, committed 63232K, reserved 1114112K
|
||||
class space used 7020K, committed 7488K, reserved 1048576K
|
||||
}
|
||||
Event: 16.929 GC heap after
|
||||
{Heap after GC invocations=36 (full 0):
|
||||
garbage-first heap total 1167360K, used 495229K [0x0000000601000000, 0x0000000800000000)
|
||||
region size 4096K, 15 young (61440K), 15 survivors (61440K)
|
||||
Metaspace used 62236K, committed 63232K, reserved 1114112K
|
||||
class space used 7020K, committed 7488K, reserved 1048576K
|
||||
}
|
||||
Event: 17.969 GC heap before
|
||||
{Heap before GC invocations=36 (full 0):
|
||||
garbage-first heap total 1167360K, used 863869K [0x0000000601000000, 0x0000000800000000)
|
||||
region size 4096K, 106 young (434176K), 15 survivors (61440K)
|
||||
Metaspace used 63393K, committed 64512K, reserved 1114112K
|
||||
class space used 7148K, committed 7616K, reserved 1048576K
|
||||
}
|
||||
Event: 18.001 GC heap after
|
||||
{Heap after GC invocations=37 (full 0):
|
||||
garbage-first heap total 1167360K, used 588618K [0x0000000601000000, 0x0000000800000000)
|
||||
region size 4096K, 14 young (57344K), 14 survivors (57344K)
|
||||
Metaspace used 63393K, committed 64512K, reserved 1114112K
|
||||
class space used 7148K, committed 7616K, reserved 1048576K
|
||||
}
|
||||
Event: 18.755 GC heap before
|
||||
{Heap before GC invocations=37 (full 0):
|
||||
garbage-first heap total 1167360K, used 879434K [0x0000000601000000, 0x0000000800000000)
|
||||
region size 4096K, 86 young (352256K), 14 survivors (57344K)
|
||||
Metaspace used 68268K, committed 69376K, reserved 1114112K
|
||||
class space used 7712K, committed 8192K, reserved 1048576K
|
||||
}
|
||||
Event: 18.777 GC heap after
|
||||
{Heap after GC invocations=38 (full 0):
|
||||
garbage-first heap total 1167360K, used 621836K [0x0000000601000000, 0x0000000800000000)
|
||||
region size 4096K, 8 young (32768K), 8 survivors (32768K)
|
||||
Metaspace used 68268K, committed 69376K, reserved 1114112K
|
||||
class space used 7712K, committed 8192K, reserved 1048576K
|
||||
}
|
||||
Event: 19.223 GC heap before
|
||||
{Heap before GC invocations=38 (full 0):
|
||||
garbage-first heap total 1167360K, used 904460K [0x0000000601000000, 0x0000000800000000)
|
||||
region size 4096K, 78 young (319488K), 8 survivors (32768K)
|
||||
Metaspace used 69902K, committed 71104K, reserved 1114112K
|
||||
class space used 7909K, committed 8448K, reserved 1048576K
|
||||
}
|
||||
Event: 19.236 GC heap after
|
||||
{Heap after GC invocations=39 (full 0):
|
||||
garbage-first heap total 1167360K, used 636231K [0x0000000601000000, 0x0000000800000000)
|
||||
region size 4096K, 3 young (12288K), 3 survivors (12288K)
|
||||
Metaspace used 69902K, committed 71104K, reserved 1114112K
|
||||
class space used 7909K, committed 8448K, reserved 1048576K
|
||||
}
|
||||
Event: 19.750 GC heap before
|
||||
{Heap before GC invocations=39 (full 0):
|
||||
garbage-first heap total 1167360K, used 922951K [0x0000000601000000, 0x0000000800000000)
|
||||
region size 4096K, 74 young (303104K), 3 survivors (12288K)
|
||||
Metaspace used 70950K, committed 72064K, reserved 1114112K
|
||||
class space used 8006K, committed 8512K, reserved 1048576K
|
||||
}
|
||||
Event: 19.765 GC heap after
|
||||
{Heap after GC invocations=40 (full 0):
|
||||
garbage-first heap total 1400832K, used 652012K [0x0000000601000000, 0x0000000800000000)
|
||||
region size 4096K, 7 young (28672K), 7 survivors (28672K)
|
||||
Metaspace used 70950K, committed 72064K, reserved 1114112K
|
||||
class space used 8006K, committed 8512K, reserved 1048576K
|
||||
}
|
||||
Event: 20.441 GC heap before
|
||||
{Heap before GC invocations=40 (full 0):
|
||||
garbage-first heap total 1400832K, used 1086188K [0x0000000601000000, 0x0000000800000000)
|
||||
region size 4096K, 113 young (462848K), 7 survivors (28672K)
|
||||
Metaspace used 71423K, committed 72576K, reserved 1114112K
|
||||
class space used 8062K, committed 8576K, reserved 1048576K
|
||||
}
|
||||
Event: 20.465 GC heap after
|
||||
{Heap after GC invocations=41 (full 0):
|
||||
garbage-first heap total 1400832K, used 692441K [0x0000000601000000, 0x0000000800000000)
|
||||
region size 4096K, 15 young (61440K), 15 survivors (61440K)
|
||||
Metaspace used 71423K, committed 72576K, reserved 1114112K
|
||||
class space used 8062K, committed 8576K, reserved 1048576K
|
||||
}
|
||||
Event: 20.964 GC heap before
|
||||
{Heap before GC invocations=41 (full 0):
|
||||
garbage-first heap total 1400832K, used 1069273K [0x0000000601000000, 0x0000000800000000)
|
||||
region size 4096K, 108 young (442368K), 15 survivors (61440K)
|
||||
Metaspace used 72709K, committed 73856K, reserved 1114112K
|
||||
class space used 8207K, committed 8768K, reserved 1048576K
|
||||
}
|
||||
Event: 20.987 GC heap after
|
||||
{Heap after GC invocations=42 (full 0):
|
||||
garbage-first heap total 1400832K, used 720801K [0x0000000601000000, 0x0000000800000000)
|
||||
region size 4096K, 7 young (28672K), 7 survivors (28672K)
|
||||
Metaspace used 72709K, committed 73856K, reserved 1114112K
|
||||
class space used 8207K, committed 8768K, reserved 1048576K
|
||||
}
|
||||
Event: 21.637 GC heap before
|
||||
{Heap before GC invocations=43 (full 0):
|
||||
garbage-first heap total 1400832K, used 1122209K [0x0000000601000000, 0x0000000800000000)
|
||||
region size 4096K, 106 young (434176K), 7 survivors (28672K)
|
||||
Metaspace used 49336K, committed 56640K, reserved 1114112K
|
||||
class space used 5434K, committed 7168K, reserved 1048576K
|
||||
}
|
||||
Event: 21.648 GC heap after
|
||||
{Heap after GC invocations=44 (full 0):
|
||||
garbage-first heap total 1400832K, used 723685K [0x0000000601000000, 0x0000000800000000)
|
||||
region size 4096K, 7 young (28672K), 7 survivors (28672K)
|
||||
Metaspace used 49336K, committed 56640K, reserved 1114112K
|
||||
class space used 5434K, committed 7168K, reserved 1048576K
|
||||
}
|
||||
Event: 21.701 GC heap before
|
||||
{Heap before GC invocations=44 (full 0):
|
||||
garbage-first heap total 1400832K, used 760549K [0x0000000601000000, 0x0000000800000000)
|
||||
region size 4096K, 17 young (69632K), 7 survivors (28672K)
|
||||
Metaspace used 49343K, committed 56640K, reserved 1114112K
|
||||
class space used 5435K, committed 7168K, reserved 1048576K
|
||||
}
|
||||
Event: 21.712 GC heap after
|
||||
{Heap after GC invocations=45 (full 0):
|
||||
garbage-first heap total 1400832K, used 591919K [0x0000000601000000, 0x0000000800000000)
|
||||
region size 4096K, 2 young (8192K), 2 survivors (8192K)
|
||||
Metaspace used 49343K, committed 56640K, reserved 1114112K
|
||||
class space used 5435K, committed 7168K, reserved 1048576K
|
||||
}
|
||||
Event: 21.792 GC heap before
|
||||
{Heap before GC invocations=45 (full 0):
|
||||
garbage-first heap total 1400832K, used 653359K [0x0000000601000000, 0x0000000800000000)
|
||||
region size 4096K, 17 young (69632K), 2 survivors (8192K)
|
||||
Metaspace used 49364K, committed 56640K, reserved 1114112K
|
||||
class space used 5435K, committed 7168K, reserved 1048576K
|
||||
}
|
||||
|
||||
Deoptimization events (20 events):
|
||||
Event: 21.736 Thread 0x0000025747e837f0 Uncommon trap: trap_request=0xffffffc6 fr.pc=0x0000025763fe00f0 relative=0x0000000000000ff0
|
||||
Event: 21.736 Thread 0x0000025747e837f0 Uncommon trap: reason=bimorphic_or_optimized_type_check action=maybe_recompile pc=0x0000025763fe00f0 method=lombok.javac.JavacNode.traverse(Llombok/javac/JavacASTVisitor;)V @ 490 c2
|
||||
Event: 21.736 Thread 0x0000025747e837f0 DEOPT PACKING pc=0x0000025763fe00f0 sp=0x000000a0caffd680
|
||||
Event: 21.736 Thread 0x0000025747e837f0 DEOPT UNPACKING pc=0x00000257635723a3 sp=0x000000a0caffd600 mode 2
|
||||
Event: 21.781 Thread 0x0000025747e83d00 Uncommon trap: trap_request=0xffffffde fr.pc=0x00000257648c60f4 relative=0x00000000000000d4
|
||||
Event: 21.781 Thread 0x0000025747e83d00 Uncommon trap: reason=class_check action=maybe_recompile pc=0x00000257648c60f4 method=java.lang.Character.toLowerCase(I)I @ 5 c2
|
||||
Event: 21.781 Thread 0x0000025747e83d00 DEOPT PACKING pc=0x00000257648c60f4 sp=0x000000a0cb0fe0e0
|
||||
Event: 21.781 Thread 0x0000025747e83d00 DEOPT UNPACKING pc=0x00000257635723a3 sp=0x000000a0cb0fe078 mode 2
|
||||
Event: 21.781 Thread 0x0000025747e83d00 Uncommon trap: trap_request=0xffffffde fr.pc=0x00000257648c60f4 relative=0x00000000000000d4
|
||||
Event: 21.781 Thread 0x0000025747e83d00 Uncommon trap: reason=class_check action=maybe_recompile pc=0x00000257648c60f4 method=java.lang.Character.toLowerCase(I)I @ 5 c2
|
||||
Event: 21.781 Thread 0x0000025747e83d00 DEOPT PACKING pc=0x00000257648c60f4 sp=0x000000a0cb0fe0e0
|
||||
Event: 21.781 Thread 0x0000025747e83d00 DEOPT UNPACKING pc=0x00000257635723a3 sp=0x000000a0cb0fe078 mode 2
|
||||
Event: 21.781 Thread 0x0000025747e83d00 Uncommon trap: trap_request=0xffffffde fr.pc=0x00000257648c60f4 relative=0x00000000000000d4
|
||||
Event: 21.781 Thread 0x0000025747e83d00 Uncommon trap: reason=class_check action=maybe_recompile pc=0x00000257648c60f4 method=java.lang.Character.toLowerCase(I)I @ 5 c2
|
||||
Event: 21.781 Thread 0x0000025747e83d00 DEOPT PACKING pc=0x00000257648c60f4 sp=0x000000a0cb0fe0e0
|
||||
Event: 21.781 Thread 0x0000025747e83d00 DEOPT UNPACKING pc=0x00000257635723a3 sp=0x000000a0cb0fe078 mode 2
|
||||
Event: 21.781 Thread 0x0000025747e83d00 Uncommon trap: trap_request=0xffffffde fr.pc=0x00000257648c60f4 relative=0x00000000000000d4
|
||||
Event: 21.781 Thread 0x0000025747e83d00 Uncommon trap: reason=class_check action=maybe_recompile pc=0x00000257648c60f4 method=java.lang.Character.toLowerCase(I)I @ 5 c2
|
||||
Event: 21.781 Thread 0x0000025747e83d00 DEOPT PACKING pc=0x00000257648c60f4 sp=0x000000a0cb0fe0e0
|
||||
Event: 21.781 Thread 0x0000025747e83d00 DEOPT UNPACKING pc=0x00000257635723a3 sp=0x000000a0cb0fe078 mode 2
|
||||
|
||||
Classes unloaded (20 events):
|
||||
Event: 21.132 Thread 0x000002577ec0ce20 Unloading class 0x00000257034d1808 'org/springframework/boot/configurationprocessor/MetadataGenerationEnvironment'
|
||||
Event: 21.132 Thread 0x000002577ec0ce20 Unloading class 0x00000257034d15e8 'org/springframework/boot/configurationprocessor/TypeUtils$$Lambda$694+0x00000257034d15e8'
|
||||
Event: 21.132 Thread 0x000002577ec0ce20 Unloading class 0x00000257034d12c8 'org/springframework/boot/configurationprocessor/TypeUtils$TypeExtractor'
|
||||
Event: 21.132 Thread 0x000002577ec0ce20 Unloading class 0x00000257034d1098 'org/springframework/boot/configurationprocessor/TypeUtils$$Lambda$688+0x00000257034d1098'
|
||||
Event: 21.132 Thread 0x000002577ec0ce20 Unloading class 0x00000257034d0e40 'org/springframework/boot/configurationprocessor/TypeUtils'
|
||||
Event: 21.132 Thread 0x000002577ec0ce20 Unloading class 0x00000257034d0c08 'org/springframework/boot/configurationprocessor/metadata/ConfigurationMetadata$$Lambda$687+0x00000257034d0c08'
|
||||
Event: 21.132 Thread 0x000002577ec0ce20 Unloading class 0x00000257034d09e8 'org/springframework/boot/configurationprocessor/metadata/ItemMetadata'
|
||||
Event: 21.132 Thread 0x000002577ec0ce20 Unloading class 0x00000257034d07e8 'org/springframework/boot/configurationprocessor/json/JSON'
|
||||
Event: 21.132 Thread 0x000002577ec0ce20 Unloading class 0x00000257034d05a8 'org/springframework/boot/configurationprocessor/metadata/ItemMetadata$ItemType'
|
||||
Event: 21.132 Thread 0x000002577ec0ce20 Unloading class 0x00000257034d0270 'org/springframework/boot/configurationprocessor/json/JSONArray'
|
||||
Event: 21.132 Thread 0x000002577ec0ce20 Unloading class 0x00000257034d0000 'org/springframework/boot/configurationprocessor/json/JSONTokener'
|
||||
Event: 21.132 Thread 0x000002577ec0ce20 Unloading class 0x00000257034ccc08 'org/springframework/boot/configurationprocessor/json/JSONObject$1'
|
||||
Event: 21.132 Thread 0x000002577ec0ce20 Unloading class 0x00000257034cc9b0 'org/springframework/boot/configurationprocessor/json/JSONException'
|
||||
Event: 21.132 Thread 0x000002577ec0ce20 Unloading class 0x00000257034cc678 'org/springframework/boot/configurationprocessor/json/JSONObject'
|
||||
Event: 21.132 Thread 0x000002577ec0ce20 Unloading class 0x00000257034cc438 'org/springframework/boot/configurationprocessor/metadata/ConfigurationMetadata'
|
||||
Event: 21.132 Thread 0x000002577ec0ce20 Unloading class 0x00000257034cc228 'org/springframework/boot/configurationprocessor/metadata/JsonMarshaller'
|
||||
Event: 21.132 Thread 0x000002577ec0ce20 Unloading class 0x00000257034cc000 'org/springframework/boot/configurationprocessor/MetadataCollector'
|
||||
Event: 21.132 Thread 0x000002577ec0ce20 Unloading class 0x0000025703364530 'org/springframework/boot/configurationprocessor/MetadataStore'
|
||||
Event: 21.132 Thread 0x000002577ec0ce20 Unloading class 0x00000257033642d0 'org/springframework/boot/configurationprocessor/metadata/InvalidConfigurationMetadataException'
|
||||
Event: 21.132 Thread 0x000002577ec0ce20 Unloading class 0x0000025703364000 'org/springframework/boot/configurationprocessor/ConfigurationMetadataAnnotationProcessor'
|
||||
|
||||
Classes redefined (0 events):
|
||||
No events
|
||||
|
||||
Internal exceptions (20 events):
|
||||
Event: 21.715 Thread 0x0000025747e83d00 Exception <a 'sun/nio/fs/WindowsException'{0x00000006566273d0}> (0x00000006566273d0)
|
||||
thrown [s\open\src\hotspot\share\prims\jni.cpp, line 516]
|
||||
Event: 21.716 Thread 0x0000025747e837f0 Exception <a 'sun/nio/fs/WindowsException'{0x000000065666ab88}> (0x000000065666ab88)
|
||||
thrown [s\open\src\hotspot\share\prims\jni.cpp, line 516]
|
||||
Event: 21.716 Thread 0x0000025747e837f0 Exception <a 'sun/nio/fs/WindowsException'{0x000000065666ad40}> (0x000000065666ad40)
|
||||
thrown [s\open\src\hotspot\share\prims\jni.cpp, line 516]
|
||||
Event: 21.716 Thread 0x0000025747e837f0 Exception <a 'sun/nio/fs/WindowsException'{0x000000065666bcb8}> (0x000000065666bcb8)
|
||||
thrown [s\open\src\hotspot\share\prims\jni.cpp, line 516]
|
||||
Event: 21.716 Thread 0x0000025747e837f0 Exception <a 'sun/nio/fs/WindowsException'{0x000000065666beb8}> (0x000000065666beb8)
|
||||
thrown [s\open\src\hotspot\share\prims\jni.cpp, line 516]
|
||||
Event: 21.716 Thread 0x0000025747e837f0 Exception <a 'sun/nio/fs/WindowsException'{0x000000065666cf18}> (0x000000065666cf18)
|
||||
thrown [s\open\src\hotspot\share\prims\jni.cpp, line 516]
|
||||
Event: 21.716 Thread 0x0000025747e837f0 Exception <a 'sun/nio/fs/WindowsException'{0x000000065666d0e0}> (0x000000065666d0e0)
|
||||
thrown [s\open\src\hotspot\share\prims\jni.cpp, line 516]
|
||||
Event: 21.720 Thread 0x0000025747e83d00 Exception <a 'sun/nio/fs/WindowsException'{0x00000006567f6850}> (0x00000006567f6850)
|
||||
thrown [s\open\src\hotspot\share\prims\jni.cpp, line 516]
|
||||
Event: 21.720 Thread 0x0000025747e83d00 Exception <a 'sun/nio/fs/WindowsException'{0x00000006567f6f40}> (0x00000006567f6f40)
|
||||
thrown [s\open\src\hotspot\share\prims\jni.cpp, line 516]
|
||||
Event: 21.720 Thread 0x0000025747e83d00 Exception <a 'sun/nio/fs/WindowsException'{0x00000006567f78d0}> (0x00000006567f78d0)
|
||||
thrown [s\open\src\hotspot\share\prims\jni.cpp, line 516]
|
||||
Event: 21.725 Thread 0x0000025747e83d00 Exception <a 'sun/nio/fs/WindowsException'{0x0000000655e1fb00}> (0x0000000655e1fb00)
|
||||
thrown [s\open\src\hotspot\share\prims\jni.cpp, line 516]
|
||||
Event: 21.725 Thread 0x0000025747e83d00 Exception <a 'sun/nio/fs/WindowsException'{0x0000000655e20220}> (0x0000000655e20220)
|
||||
thrown [s\open\src\hotspot\share\prims\jni.cpp, line 516]
|
||||
Event: 21.725 Thread 0x0000025747e83d00 Exception <a 'sun/nio/fs/WindowsException'{0x0000000655e20cb8}> (0x0000000655e20cb8)
|
||||
thrown [s\open\src\hotspot\share\prims\jni.cpp, line 516]
|
||||
Event: 21.725 Thread 0x0000025747e83d00 Exception <a 'sun/nio/fs/WindowsException'{0x0000000655e21458}> (0x0000000655e21458)
|
||||
thrown [s\open\src\hotspot\share\prims\jni.cpp, line 516]
|
||||
Event: 21.766 Thread 0x0000025747e837f0 Exception <a 'sun/nio/fs/WindowsException'{0x00000006541cbb00}> (0x00000006541cbb00)
|
||||
thrown [s\open\src\hotspot\share\prims\jni.cpp, line 516]
|
||||
Event: 21.766 Thread 0x0000025747e837f0 Exception <a 'sun/nio/fs/WindowsException'{0x00000006541cbcb8}> (0x00000006541cbcb8)
|
||||
thrown [s\open\src\hotspot\share\prims\jni.cpp, line 516]
|
||||
Event: 21.766 Thread 0x0000025747e837f0 Exception <a 'sun/nio/fs/WindowsException'{0x00000006541ccc30}> (0x00000006541ccc30)
|
||||
thrown [s\open\src\hotspot\share\prims\jni.cpp, line 516]
|
||||
Event: 21.766 Thread 0x0000025747e837f0 Exception <a 'sun/nio/fs/WindowsException'{0x00000006541cce30}> (0x00000006541cce30)
|
||||
thrown [s\open\src\hotspot\share\prims\jni.cpp, line 516]
|
||||
Event: 21.766 Thread 0x0000025747e837f0 Exception <a 'sun/nio/fs/WindowsException'{0x00000006541cde90}> (0x00000006541cde90)
|
||||
thrown [s\open\src\hotspot\share\prims\jni.cpp, line 516]
|
||||
Event: 21.767 Thread 0x0000025747e837f0 Exception <a 'sun/nio/fs/WindowsException'{0x00000006541ce058}> (0x00000006541ce058)
|
||||
thrown [s\open\src\hotspot\share\prims\jni.cpp, line 516]
|
||||
|
||||
VM Operations (20 events):
|
||||
Event: 20.989 Executing VM operation: CollectForMetadataAllocation done
|
||||
Event: 21.085 Executing VM operation: CollectForMetadataAllocation
|
||||
Event: 21.085 Executing VM operation: CollectForMetadataAllocation done
|
||||
Event: 21.113 Executing VM operation: G1Concurrent
|
||||
Event: 21.154 Executing VM operation: G1Concurrent done
|
||||
Event: 21.154 Executing VM operation: HandshakeAllThreads
|
||||
Event: 21.209 Executing VM operation: HandshakeAllThreads done
|
||||
Event: 21.232 Executing VM operation: HandshakeAllThreads
|
||||
Event: 21.233 Executing VM operation: HandshakeAllThreads done
|
||||
Event: 21.239 Executing VM operation: G1Concurrent
|
||||
Event: 21.242 Executing VM operation: G1Concurrent done
|
||||
Event: 21.624 Executing VM operation: ICBufferFull
|
||||
Event: 21.624 Executing VM operation: ICBufferFull done
|
||||
Event: 21.637 Executing VM operation: G1CollectForAllocation
|
||||
Event: 21.648 Executing VM operation: G1CollectForAllocation done
|
||||
Event: 21.701 Executing VM operation: G1CollectForAllocation
|
||||
Event: 21.713 Executing VM operation: G1CollectForAllocation done
|
||||
Event: 21.745 Executing VM operation: HandshakeAllThreads
|
||||
Event: 21.745 Executing VM operation: HandshakeAllThreads done
|
||||
Event: 21.792 Executing VM operation: G1CollectForAllocation
|
||||
|
||||
Events (20 events):
|
||||
Event: 21.764 Thread 0x000002577ec3aa20 flushing nmethod 0x000002575db72390
|
||||
Event: 21.764 Thread 0x000002577ec3aa20 flushing nmethod 0x000002575db78210
|
||||
Event: 21.764 Thread 0x000002577ec3aa20 flushing nmethod 0x000002575db86710
|
||||
Event: 21.764 Thread 0x000002577ec3aa20 flushing nmethod 0x000002575db86c10
|
||||
Event: 21.764 Thread 0x000002577ec3aa20 flushing nmethod 0x000002575db9c110
|
||||
Event: 21.764 Thread 0x000002577ec3aa20 flushing nmethod 0x000002575db9cd10
|
||||
Event: 21.764 Thread 0x000002577ec3aa20 flushing nmethod 0x000002575db9d110
|
||||
Event: 21.764 Thread 0x000002577ec3aa20 flushing nmethod 0x000002575db9d710
|
||||
Event: 21.764 Thread 0x000002577ec3aa20 flushing nmethod 0x000002575db9f490
|
||||
Event: 21.764 Thread 0x000002577ec3aa20 flushing nmethod 0x000002575dbb2110
|
||||
Event: 21.764 Thread 0x000002577ec3aa20 flushing nmethod 0x000002575dbb7010
|
||||
Event: 21.764 Thread 0x000002577ec3aa20 flushing nmethod 0x000002575dbb7390
|
||||
Event: 21.764 Thread 0x000002577ec3aa20 flushing nmethod 0x000002575dbe5990
|
||||
Event: 21.764 Thread 0x000002577ec3aa20 flushing nmethod 0x000002575dc2a290
|
||||
Event: 21.764 Thread 0x000002577ec3aa20 flushing nmethod 0x000002575dc58490
|
||||
Event: 21.764 Thread 0x000002577ec3aa20 flushing nmethod 0x000002575dc5b890
|
||||
Event: 21.764 Thread 0x000002577ec3aa20 flushing nmethod 0x000002575dc5c090
|
||||
Event: 21.764 Thread 0x000002577ec3aa20 flushing nmethod 0x000002575dc5d090
|
||||
Event: 21.764 Thread 0x000002577ec3aa20 flushing nmethod 0x000002575dc5e190
|
||||
Event: 21.764 Thread 0x000002577ec3aa20 flushing nmethod 0x000002575dc5e910
|
||||
|
||||
|
||||
Dynamic libraries:
|
||||
0x00007ff7ebc30000 - 0x00007ff7ebc40000 D:\Program Files\Java\jdk-17\bin\java.exe
|
||||
0x00007ffc3de30000 - 0x00007ffc3e028000 C:\WINDOWS\SYSTEM32\ntdll.dll
|
||||
0x00007ffc3caf0000 - 0x00007ffc3cbb2000 C:\WINDOWS\System32\KERNEL32.DLL
|
||||
0x00007ffc3b630000 - 0x00007ffc3b92e000 C:\WINDOWS\System32\KERNELBASE.dll
|
||||
0x00007ffc3b930000 - 0x00007ffc3ba30000 C:\WINDOWS\System32\ucrtbase.dll
|
||||
0x00007ffc36620000 - 0x00007ffc3663b000 D:\Program Files\Java\jdk-17\bin\VCRUNTIME140.dll
|
||||
0x00007ffc2e970000 - 0x00007ffc2e989000 D:\Program Files\Java\jdk-17\bin\jli.dll
|
||||
0x00007ffc3c010000 - 0x00007ffc3c0c1000 C:\WINDOWS\System32\ADVAPI32.dll
|
||||
0x00007ffc3c1f0000 - 0x00007ffc3c28e000 C:\WINDOWS\System32\msvcrt.dll
|
||||
0x00007ffc3cbd0000 - 0x00007ffc3cc6f000 C:\WINDOWS\System32\sechost.dll
|
||||
0x00007ffc3be50000 - 0x00007ffc3bf73000 C:\WINDOWS\System32\RPCRT4.dll
|
||||
0x00007ffc3bd60000 - 0x00007ffc3bd87000 C:\WINDOWS\System32\bcrypt.dll
|
||||
0x00007ffc3c800000 - 0x00007ffc3c99d000 C:\WINDOWS\System32\USER32.dll
|
||||
0x00007ffc3be20000 - 0x00007ffc3be42000 C:\WINDOWS\System32\win32u.dll
|
||||
0x00007ffc3bf80000 - 0x00007ffc3bfab000 C:\WINDOWS\System32\GDI32.dll
|
||||
0x00007ffc3bb80000 - 0x00007ffc3bc97000 C:\WINDOWS\System32\gdi32full.dll
|
||||
0x00007ffc26790000 - 0x00007ffc26a2a000 C:\WINDOWS\WinSxS\amd64_microsoft.windows.common-controls_6595b64144ccf1df_6.0.19041.4355_none_60b8b9eb71f62e16\COMCTL32.dll
|
||||
0x00007ffc3ba30000 - 0x00007ffc3bacd000 C:\WINDOWS\System32\msvcp_win.dll
|
||||
0x00007ffc3afe0000 - 0x00007ffc3afea000 C:\WINDOWS\SYSTEM32\VERSION.dll
|
||||
0x00007ffc3c0e0000 - 0x00007ffc3c10f000 C:\WINDOWS\System32\IMM32.DLL
|
||||
0x000000005ca60000 - 0x000000005ca6d000 D:\Program Files (x86)\360\360SAFE\safemon\SafeWrapper.dll
|
||||
0x00007ffc2e060000 - 0x00007ffc2e165000 D:\Program Files (x86)\360\360SAFE\safemon\libzdtp64.dll
|
||||
0x00007ffc3cc70000 - 0x00007ffc3d3dd000 C:\WINDOWS\System32\SHELL32.dll
|
||||
0x00007ffc3c190000 - 0x00007ffc3c1e5000 C:\WINDOWS\System32\SHLWAPI.dll
|
||||
0x00007ffc36610000 - 0x00007ffc3661c000 D:\Program Files\Java\jdk-17\bin\vcruntime140_1.dll
|
||||
0x00007ffc03e10000 - 0x00007ffc03e9e000 D:\Program Files\Java\jdk-17\bin\msvcp140.dll
|
||||
0x00007ffbe4ab0000 - 0x00007ffbe5691000 D:\Program Files\Java\jdk-17\bin\server\jvm.dll
|
||||
0x00007ffc3c0d0000 - 0x00007ffc3c0d8000 C:\WINDOWS\System32\PSAPI.DLL
|
||||
0x00007ffc27990000 - 0x00007ffc27999000 C:\WINDOWS\SYSTEM32\WSOCK32.dll
|
||||
0x00007ffc32310000 - 0x00007ffc32337000 C:\WINDOWS\SYSTEM32\WINMM.dll
|
||||
0x00007ffc3ca80000 - 0x00007ffc3caeb000 C:\WINDOWS\System32\WS2_32.dll
|
||||
0x00007ffc39cc0000 - 0x00007ffc39cd2000 C:\WINDOWS\SYSTEM32\kernel.appcore.dll
|
||||
0x00007ffc2e880000 - 0x00007ffc2e88a000 D:\Program Files\Java\jdk-17\bin\jimage.dll
|
||||
0x00007ffc397f0000 - 0x00007ffc399d4000 C:\WINDOWS\SYSTEM32\DBGHELP.DLL
|
||||
0x00007ffc2d790000 - 0x00007ffc2d7c4000 C:\WINDOWS\SYSTEM32\dbgcore.DLL
|
||||
0x00007ffc3bd90000 - 0x00007ffc3be12000 C:\WINDOWS\System32\bcryptPrimitives.dll
|
||||
0x00007ffc27490000 - 0x00007ffc2749e000 D:\Program Files\Java\jdk-17\bin\instrument.dll
|
||||
0x00007ffc27460000 - 0x00007ffc27485000 D:\Program Files\Java\jdk-17\bin\java.dll
|
||||
0x00007ffbfa7d0000 - 0x00007ffbfa8a7000 D:\Program Files\Java\jdk-17\bin\jsvml.dll
|
||||
0x00007ffc38f70000 - 0x00007ffc39714000 C:\WINDOWS\SYSTEM32\windows.storage.dll
|
||||
0x00007ffc3da90000 - 0x00007ffc3dde3000 C:\WINDOWS\System32\combase.dll
|
||||
0x00007ffc3ae40000 - 0x00007ffc3ae6e000 C:\WINDOWS\SYSTEM32\Wldp.dll
|
||||
0x00007ffc3d640000 - 0x00007ffc3d70d000 C:\WINDOWS\System32\OLEAUT32.dll
|
||||
0x00007ffc3d9e0000 - 0x00007ffc3da8d000 C:\WINDOWS\System32\SHCORE.dll
|
||||
0x00007ffc3b400000 - 0x00007ffc3b424000 C:\WINDOWS\SYSTEM32\profapi.dll
|
||||
0x00007ffc25b50000 - 0x00007ffc25b68000 D:\Program Files\Java\jdk-17\bin\zip.dll
|
||||
0x00007ffc25e90000 - 0x00007ffc25ea9000 D:\Program Files\Java\jdk-17\bin\net.dll
|
||||
0x00007ffc34d20000 - 0x00007ffc34e2d000 C:\WINDOWS\SYSTEM32\WINHTTP.dll
|
||||
0x00007ffc3aba0000 - 0x00007ffc3ac0a000 C:\WINDOWS\system32\mswsock.dll
|
||||
0x00007ffc25bd0000 - 0x00007ffc25be6000 D:\Program Files\Java\jdk-17\bin\nio.dll
|
||||
0x00007ffc25ef0000 - 0x00007ffc25f0a000 D:\Program Files\JetBrains\IntelliJ IDEA 2024.3.1\bin\breakgen64.dll
|
||||
0x00007ffc2ccf0000 - 0x00007ffc2cd14000 C:\Users\ADAM5\AppData\Local\Temp\jansi-2.4.1-b87462ac789684e0-jansi.dll
|
||||
0x00007ffc27a20000 - 0x00007ffc27a30000 D:\Program Files\Java\jdk-17\bin\verify.dll
|
||||
0x00007ffc3a6e0000 - 0x00007ffc3a713000 C:\WINDOWS\SYSTEM32\ntmarta.dll
|
||||
|
||||
dbghelp: loaded successfully - version: 4.0.5 - missing functions: none
|
||||
symbol engine: initialized successfully - sym options: 0x614 - pdb path: .;D:\Program Files\Java\jdk-17\bin;C:\WINDOWS\SYSTEM32;C:\WINDOWS\WinSxS\amd64_microsoft.windows.common-controls_6595b64144ccf1df_6.0.19041.4355_none_60b8b9eb71f62e16;D:\Program Files (x86)\360\360SAFE\safemon;D:\Program Files\Java\jdk-17\bin\server;D:\Program Files\JetBrains\IntelliJ IDEA 2024.3.1\bin;C:\Users\ADAM5\AppData\Local\Temp
|
||||
|
||||
VM Arguments:
|
||||
jvm_args: -Dmaven.multiModuleProjectDirectory=E:\Idea-project\ikingtec-new6.0\microservices-platform -Djansi.passthrough=true -Dmaven.home=D:\Program Files\JetBrains\IntelliJ IDEA 2024.3.1\plugins\maven\lib\maven3 -Dclassworlds.conf=D:\Program Files\JetBrains\IntelliJ IDEA 2024.3.1\plugins\maven\lib\maven3\bin\m2.conf -Dmaven.ext.class.path=D:\Program Files\JetBrains\IntelliJ IDEA 2024.3.1\plugins\maven\lib\maven-event-listener.jar -javaagent:D:\Program Files\JetBrains\IntelliJ IDEA 2024.3.1\lib\idea_rt.jar=58940:D:\Program Files\JetBrains\IntelliJ IDEA 2024.3.1\bin -Dfile.encoding=UTF-8
|
||||
java_command: org.codehaus.classworlds.Launcher -Didea.version=2024.3.1 -T 8 -s D:\maven\apache-maven-3.5.2\conf\settings.xml package
|
||||
java_class_path (initial): D:\Program Files\JetBrains\IntelliJ IDEA 2024.3.1\plugins\maven\lib\maven3\boot\plexus-classworlds-2.8.0.jar;D:\Program Files\JetBrains\IntelliJ IDEA 2024.3.1\plugins\maven\lib\maven3\boot\plexus-classworlds.license
|
||||
Launcher Type: SUN_STANDARD
|
||||
|
||||
[Global flags]
|
||||
intx CICompilerCount = 4 {product} {ergonomic}
|
||||
uint ConcGCThreads = 2 {product} {ergonomic}
|
||||
uint G1ConcRefinementThreads = 8 {product} {ergonomic}
|
||||
size_t G1HeapRegionSize = 4194304 {product} {ergonomic}
|
||||
uintx GCDrainStackTargetSize = 64 {product} {ergonomic}
|
||||
size_t InitialHeapSize = 536870912 {product} {ergonomic}
|
||||
size_t MarkStackSize = 4194304 {product} {ergonomic}
|
||||
size_t MaxHeapSize = 8573157376 {product} {ergonomic}
|
||||
size_t MaxNewSize = 5142216704 {product} {ergonomic}
|
||||
size_t MinHeapDeltaBytes = 4194304 {product} {ergonomic}
|
||||
size_t MinHeapSize = 8388608 {product} {ergonomic}
|
||||
uintx NonNMethodCodeHeapSize = 5839372 {pd product} {ergonomic}
|
||||
uintx NonProfiledCodeHeapSize = 122909434 {pd product} {ergonomic}
|
||||
uintx ProfiledCodeHeapSize = 122909434 {pd product} {ergonomic}
|
||||
uintx ReservedCodeCacheSize = 251658240 {pd product} {ergonomic}
|
||||
bool SegmentedCodeCache = true {product} {ergonomic}
|
||||
size_t SoftMaxHeapSize = 8573157376 {manageable} {ergonomic}
|
||||
bool UseCompressedClassPointers = true {product lp64_product} {ergonomic}
|
||||
bool UseCompressedOops = true {product lp64_product} {ergonomic}
|
||||
bool UseG1GC = true {product} {ergonomic}
|
||||
bool UseLargePagesIndividualAllocation = false {pd product} {ergonomic}
|
||||
|
||||
Logging:
|
||||
Log output configuration:
|
||||
#0: stdout all=warning uptime,level,tags
|
||||
#1: stderr all=off uptime,level,tags
|
||||
|
||||
Environment Variables:
|
||||
JAVA_HOME=D:\Program Files\Java\jdk-17
|
||||
PATH=C:\Program Files\Common Files\Oracle\Java\javapath;D:\Python39\Scripts\;D:\Python39\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;D:\Program Files\Java\jdk-17\bin;node_global;D:\maven\apache-maven-3.5.2\bin;D:\Program Files\nodejs\node_global\node_modules;E:\gradle\gradle-5.2.1-all\gradle-5.2.1\bin;C:\Users\ADAM5\.windows-build-tools\python27;D:\Program Files (x86)\Yarn\bin\;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;node_global;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;D:\Program Files\Microsoft VS Code\bin;D:\P;ogram Files\Git\cmd;C:\Program Files\dotnet\;C:\Program Files\GitHub CLI\;D:\nvm;D:\Program Files\nodejs;D:\Program Files\apache-ant-1.10.15-bin\apache-ant-1.10.15\bin;D:\Program Files (x86)\Tencent\΢ÐÅweb¿ª·¢Õß¹¤¾ß\dll;;;D:\Program Files\Git\cmd;C:\Users\ADAM5\AppData\Local\Microsoft\WindowsApps;D:\Program Files (x86)\SSH Communications Security\SSH Secure Shell;C:\Users\ADAM5\AppData\Roaming\npm;C:\Users\ADAM5\AppData\Local\Yarn\bin;D:\Program Files\JetBrains\PyCharm Community Edition 2020.3.2\bin;C:\Users\ADAM5\AppData\Local\Programs\Fiddler;D:\Program Files (x86)\GitHub CLI\;C:\Users\ADAM5\AppData\Local\Microsoft\WindowsApps;D:\Program Files (x86)\nvm;D:\Program Files\nodejs;D:\Program Files (x86)\Fiddler2\Fiddler;D:\nvm;D:\Program Files\nodejs;D:\Program Files\JetBrains\IntelliJ IDEA 2024.3.1\bin;
|
||||
USERNAME=ADAM5
|
||||
OS=Windows_NT
|
||||
PROCESSOR_IDENTIFIER=Intel64 Family 6 Model 158 Stepping 13, GenuineIntel
|
||||
|
||||
|
||||
|
||||
--------------- S Y S T E M ---------------
|
||||
|
||||
OS:
|
||||
Windows 10 , 64 bit Build 19041 (10.0.19041.5198)
|
||||
OS uptime: 6 days 7:35 hours
|
||||
|
||||
CPU: total 8 (initial active 8) (8 cores per cpu, 1 threads per core) family 6 model 158 stepping 13 microcode 0xb8, cx8, cmov, fxsr, mmx, 3dnowpref, sse, sse2, sse3, ssse3, sse4.1, sse4.2, popcnt, lzcnt, tsc, tscinvbit, avx, avx2, aes, erms, clmul, bmi1, bmi2, rtm, adx, fma, vzeroupper, clflush, clflushopt
|
||||
|
||||
Memory: 4k page, system-wide physical 32701M (5698M free)
|
||||
TotalPageFile size 54576M (AvailPageFile size 117M)
|
||||
current process WorkingSet (physical memory assigned to process): 1750M, peak: 1755M
|
||||
current process commit charge ("private bytes"): 1812M, peak: 2516M
|
||||
|
||||
vm_info: Java HotSpot(TM) 64-Bit Server VM (17.0.13+10-LTS-268) for windows-amd64 JRE (17.0.13+10-LTS-268), built on Sep 30 2024 06:33:13 by "mach5one" with MS VC++ 17.6 (VS2022)
|
||||
|
||||
END.
|
||||
@@ -0,0 +1,221 @@
|
||||
#
|
||||
# There is insufficient memory for the Java Runtime Environment to continue.
|
||||
# Native memory allocation (mmap) failed to map 536870912 bytes for G1 virtual space
|
||||
# Possible reasons:
|
||||
# The system is out of physical RAM or swap space
|
||||
# The process is running with CompressedOops enabled, and the Java Heap may be blocking the growth of the native heap
|
||||
# Possible solutions:
|
||||
# Reduce memory load on the system
|
||||
# Increase physical memory or swap space
|
||||
# Check if swap backing store is full
|
||||
# Decrease Java heap size (-Xmx/-Xms)
|
||||
# Decrease number of Java threads
|
||||
# Decrease Java thread stack sizes (-Xss)
|
||||
# Set larger code cache with -XX:ReservedCodeCacheSize=
|
||||
# JVM is running with Zero Based Compressed Oops mode in which the Java heap is
|
||||
# placed in the first 32GB address space. The Java Heap base address is the
|
||||
# maximum limit for the native heap growth. Please use -XX:HeapBaseMinAddress
|
||||
# to set the Java Heap base and to place the Java Heap above 32GB virtual address.
|
||||
# This output file may be truncated or incomplete.
|
||||
#
|
||||
# Out of Memory Error (os_windows.cpp:3548), pid=8960, tid=12132
|
||||
#
|
||||
# JRE version: (17.0.13+10) (build )
|
||||
# Java VM: Java HotSpot(TM) 64-Bit Server VM (17.0.13+10-LTS-268, mixed mode, emulated-client, sharing, tiered, compressed oops, compressed class ptrs, g1 gc, windows-amd64)
|
||||
# No core dump will be written. Minidumps are not enabled by default on client versions of Windows
|
||||
#
|
||||
|
||||
--------------- S U M M A R Y ------------
|
||||
|
||||
Command Line: -XX:TieredStopAtLevel=1 -Dspring.output.ansi.enabled=always -Dcom.sun.management.jmxremote -Dspring.jmx.enabled=true -Dspring.liveBeansView.mbeanDomain -Dspring.application.admin.enabled=true -Dmanagement.endpoints.jmx.exposure.include=* -javaagent:D:\Program Files\JetBrains\IntelliJ IDEA 2024.3.1\lib\idea_rt.jar=55248:D:\Program Files\JetBrains\IntelliJ IDEA 2024.3.1\bin -Dfile.encoding=UTF-8 com.zlt.tourism.CulturalTourismApplication
|
||||
|
||||
Host: Intel(R) Core(TM) i7-9700F CPU @ 3.00GHz, 8 cores, 31G, Windows 10 , 64 bit Build 19041 (10.0.19041.5198)
|
||||
Time: Sun Jan 5 15:41:20 2025 Windows 10 , 64 bit Build 19041 (10.0.19041.5198) elapsed time: 0.016570 seconds (0d 0h 0m 0s)
|
||||
|
||||
--------------- T H R E A D ---------------
|
||||
|
||||
Current thread (0x000001d97c4e6800): JavaThread "Unknown thread" [_thread_in_vm, id=12132, stack(0x0000004a1ad00000,0x0000004a1ae00000)]
|
||||
|
||||
Stack: [0x0000004a1ad00000,0x0000004a1ae00000]
|
||||
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
|
||||
V [jvm.dll+0x67a23a]
|
||||
V [jvm.dll+0x7da96d]
|
||||
V [jvm.dll+0x7dc2b3]
|
||||
V [jvm.dll+0x7dc923]
|
||||
V [jvm.dll+0x2450ef]
|
||||
V [jvm.dll+0x677279]
|
||||
V [jvm.dll+0x66bf22]
|
||||
V [jvm.dll+0x302006]
|
||||
V [jvm.dll+0x3095a6]
|
||||
V [jvm.dll+0x359e9e]
|
||||
V [jvm.dll+0x35a0cf]
|
||||
V [jvm.dll+0x2d90d8]
|
||||
V [jvm.dll+0x2da044]
|
||||
V [jvm.dll+0x7ace81]
|
||||
V [jvm.dll+0x367701]
|
||||
V [jvm.dll+0x78bcc9]
|
||||
V [jvm.dll+0x3ec9bf]
|
||||
V [jvm.dll+0x3ee5f1]
|
||||
C [jli.dll+0x5297]
|
||||
C [ucrtbase.dll+0x21bb2]
|
||||
C [KERNEL32.DLL+0x17374]
|
||||
C [ntdll.dll+0x4cc91]
|
||||
|
||||
|
||||
--------------- P R O C E S S ---------------
|
||||
|
||||
Threads class SMR info:
|
||||
_java_thread_list=0x00007ffbe5568a18, length=0, elements={
|
||||
}
|
||||
|
||||
Java Threads: ( => current thread )
|
||||
|
||||
Other Threads:
|
||||
0x000001d97c554a50 GCTaskThread "GC Thread#0" [stack: 0x0000004a1ae00000,0x0000004a1af00000] [id=3964]
|
||||
0x000001d97c565820 ConcurrentGCThread "G1 Main Marker" [stack: 0x0000004a1af00000,0x0000004a1b000000] [id=28228]
|
||||
0x000001d97c5668d0 ConcurrentGCThread "G1 Conc#0" [stack: 0x0000004a1b000000,0x0000004a1b100000] [id=4148]
|
||||
|
||||
[error occurred during error reporting (printing all threads), id 0xc0000005, EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x00007ffbe4d99bc7]
|
||||
|
||||
VM state: not at safepoint (not fully initialized)
|
||||
|
||||
VM Mutex/Monitor currently owned by a thread: ([mutex/lock_event])
|
||||
[0x000001d97c4e37c0] Heap_lock - owner thread: 0x000001d97c4e6800
|
||||
|
||||
Heap address: 0x0000000601000000, size: 8176 MB, Compressed Oops mode: Zero based, Oop shift amount: 3
|
||||
|
||||
CDS archive(s) mapped at: [0x0000000000000000-0x0000000000000000-0x0000000000000000), size 0, SharedBaseAddress: 0x0000000800000000, ArchiveRelocationMode: 1.
|
||||
Narrow klass base: 0x0000000000000000, Narrow klass shift: 0, Narrow klass range: 0x0
|
||||
|
||||
GC Precious Log:
|
||||
<Empty>
|
||||
|
||||
Heap:
|
||||
garbage-first heap total 0K, used 0K [0x0000000601000000, 0x0000000800000000)
|
||||
region size 4096K, 0 young (0K), 0 survivors (0K)
|
||||
|
||||
[error occurred during error reporting (printing heap information), id 0xc0000005, EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x00007ffbe5183a29]
|
||||
|
||||
GC Heap History (0 events):
|
||||
No events
|
||||
|
||||
Deoptimization events (0 events):
|
||||
No events
|
||||
|
||||
Classes unloaded (0 events):
|
||||
No events
|
||||
|
||||
Classes redefined (0 events):
|
||||
No events
|
||||
|
||||
Internal exceptions (0 events):
|
||||
No events
|
||||
|
||||
VM Operations (0 events):
|
||||
No events
|
||||
|
||||
Events (1 events):
|
||||
Event: 0.011 Loaded shared library D:\Program Files\Java\jdk-17\bin\java.dll
|
||||
|
||||
|
||||
Dynamic libraries:
|
||||
0x00007ff7ebc30000 - 0x00007ff7ebc40000 D:\Program Files\Java\jdk-17\bin\java.exe
|
||||
0x00007ffc3de30000 - 0x00007ffc3e028000 C:\WINDOWS\SYSTEM32\ntdll.dll
|
||||
0x00007ffc3caf0000 - 0x00007ffc3cbb2000 C:\WINDOWS\System32\KERNEL32.DLL
|
||||
0x00007ffc3b630000 - 0x00007ffc3b92e000 C:\WINDOWS\System32\KERNELBASE.dll
|
||||
0x00007ffc3b930000 - 0x00007ffc3ba30000 C:\WINDOWS\System32\ucrtbase.dll
|
||||
0x00007ffc36620000 - 0x00007ffc3663b000 D:\Program Files\Java\jdk-17\bin\VCRUNTIME140.dll
|
||||
0x00007ffc2e970000 - 0x00007ffc2e989000 D:\Program Files\Java\jdk-17\bin\jli.dll
|
||||
0x00007ffc3c010000 - 0x00007ffc3c0c1000 C:\WINDOWS\System32\ADVAPI32.dll
|
||||
0x00007ffc3c1f0000 - 0x00007ffc3c28e000 C:\WINDOWS\System32\msvcrt.dll
|
||||
0x00007ffc3cbd0000 - 0x00007ffc3cc6f000 C:\WINDOWS\System32\sechost.dll
|
||||
0x00007ffc3be50000 - 0x00007ffc3bf73000 C:\WINDOWS\System32\RPCRT4.dll
|
||||
0x00007ffc3bd60000 - 0x00007ffc3bd87000 C:\WINDOWS\System32\bcrypt.dll
|
||||
0x00007ffc3c800000 - 0x00007ffc3c99d000 C:\WINDOWS\System32\USER32.dll
|
||||
0x00007ffc3be20000 - 0x00007ffc3be42000 C:\WINDOWS\System32\win32u.dll
|
||||
0x00007ffc3bf80000 - 0x00007ffc3bfab000 C:\WINDOWS\System32\GDI32.dll
|
||||
0x00007ffc3bb80000 - 0x00007ffc3bc97000 C:\WINDOWS\System32\gdi32full.dll
|
||||
0x00007ffc26790000 - 0x00007ffc26a2a000 C:\WINDOWS\WinSxS\amd64_microsoft.windows.common-controls_6595b64144ccf1df_6.0.19041.4355_none_60b8b9eb71f62e16\COMCTL32.dll
|
||||
0x00007ffc3ba30000 - 0x00007ffc3bacd000 C:\WINDOWS\System32\msvcp_win.dll
|
||||
0x00007ffc3afe0000 - 0x00007ffc3afea000 C:\WINDOWS\SYSTEM32\VERSION.dll
|
||||
0x00007ffc3c0e0000 - 0x00007ffc3c10f000 C:\WINDOWS\System32\IMM32.DLL
|
||||
0x000000005ca60000 - 0x000000005ca6d000 D:\Program Files (x86)\360\360SAFE\safemon\SafeWrapper.dll
|
||||
0x00007ffc2e060000 - 0x00007ffc2e165000 D:\Program Files (x86)\360\360SAFE\safemon\libzdtp64.dll
|
||||
0x00007ffc3cc70000 - 0x00007ffc3d3dd000 C:\WINDOWS\System32\SHELL32.dll
|
||||
0x00007ffc3c190000 - 0x00007ffc3c1e5000 C:\WINDOWS\System32\SHLWAPI.dll
|
||||
0x00007ffc36610000 - 0x00007ffc3661c000 D:\Program Files\Java\jdk-17\bin\vcruntime140_1.dll
|
||||
0x00007ffc03e10000 - 0x00007ffc03e9e000 D:\Program Files\Java\jdk-17\bin\msvcp140.dll
|
||||
0x00007ffbe4ab0000 - 0x00007ffbe5691000 D:\Program Files\Java\jdk-17\bin\server\jvm.dll
|
||||
0x00007ffc3c0d0000 - 0x00007ffc3c0d8000 C:\WINDOWS\System32\PSAPI.DLL
|
||||
0x00007ffc32310000 - 0x00007ffc32337000 C:\WINDOWS\SYSTEM32\WINMM.dll
|
||||
0x00007ffc27990000 - 0x00007ffc27999000 C:\WINDOWS\SYSTEM32\WSOCK32.dll
|
||||
0x00007ffc3ca80000 - 0x00007ffc3caeb000 C:\WINDOWS\System32\WS2_32.dll
|
||||
0x00007ffc39cc0000 - 0x00007ffc39cd2000 C:\WINDOWS\SYSTEM32\kernel.appcore.dll
|
||||
0x00007ffc2e880000 - 0x00007ffc2e88a000 D:\Program Files\Java\jdk-17\bin\jimage.dll
|
||||
0x00007ffc397f0000 - 0x00007ffc399d4000 C:\WINDOWS\SYSTEM32\DBGHELP.DLL
|
||||
0x00007ffc2d790000 - 0x00007ffc2d7c4000 C:\WINDOWS\SYSTEM32\dbgcore.DLL
|
||||
0x00007ffc3bd90000 - 0x00007ffc3be12000 C:\WINDOWS\System32\bcryptPrimitives.dll
|
||||
0x00007ffc27490000 - 0x00007ffc2749e000 D:\Program Files\Java\jdk-17\bin\instrument.dll
|
||||
0x00007ffc27460000 - 0x00007ffc27485000 D:\Program Files\Java\jdk-17\bin\java.dll
|
||||
|
||||
dbghelp: loaded successfully - version: 4.0.5 - missing functions: none
|
||||
symbol engine: initialized successfully - sym options: 0x614 - pdb path: .;D:\Program Files\Java\jdk-17\bin;C:\WINDOWS\SYSTEM32;C:\WINDOWS\WinSxS\amd64_microsoft.windows.common-controls_6595b64144ccf1df_6.0.19041.4355_none_60b8b9eb71f62e16;D:\Program Files (x86)\360\360SAFE\safemon;D:\Program Files\Java\jdk-17\bin\server
|
||||
|
||||
VM Arguments:
|
||||
jvm_args: -XX:TieredStopAtLevel=1 -Dspring.output.ansi.enabled=always -Dcom.sun.management.jmxremote -Dspring.jmx.enabled=true -Dspring.liveBeansView.mbeanDomain -Dspring.application.admin.enabled=true -Dmanagement.endpoints.jmx.exposure.include=* -javaagent:D:\Program Files\JetBrains\IntelliJ IDEA 2024.3.1\lib\idea_rt.jar=55248:D:\Program Files\JetBrains\IntelliJ IDEA 2024.3.1\bin -Dfile.encoding=UTF-8
|
||||
java_command: com.zlt.tourism.CulturalTourismApplication
|
||||
java_class_path (initial): E:\Idea-project\ikingtec-new6.0\microservices-platform\zlt-business\tourism-center\tourism-service\target\classes;E:\Idea-project\ikingtec-new6.0\microservices-platform\zlt-business\tourism-center\tourism-core\target\classes;D:\maven\ikingtec-repo\com\github\pagehelper\pagehelper-spring-boot-starter\1.4.6\pagehelper-spring-boot-starter-1.4.6.jar;D:\maven\ikingtec-repo\org\mybatis\spring\boot\mybatis-spring-boot-starter\2.2.2\mybatis-spring-boot-starter-2.2.2.jar;D:\maven\ikingtec-repo\org\mybatis\spring\boot\mybatis-spring-boot-autoconfigure\2.2.2\mybatis-spring-boot-autoconfigure-2.2.2.jar;D:\maven\ikingtec-repo\com\github\pagehelper\pagehelper-spring-boot-autoconfigure\1.4.6\pagehelper-spring-boot-autoconfigure-1.4.6.jar;D:\maven\ikingtec-repo\com\github\pagehelper\pagehelper\5.3.2\pagehelper-5.3.2.jar;D:\maven\ikingtec-repo\org\springframework\statemachine\spring-statemachine-core\2.5.1\spring-statemachine-core-2.5.1.jar;D:\maven\ikingtec-repo\org\springframework\spring-tx\6.0.14\spring-tx-6.0.14.jar;D:\maven\ikingtec-repo\org\springframework\spring-messaging\6.0.14\spring-messaging-6.0.14.jar;D:\maven\ikingtec-repo\javax\servlet\javax.servlet-api\3.1.0\javax.servlet-api-3.1.0.jar;D:\maven\ikingtec-repo\com\alibaba\fastjson\1.2.83\fastjson-1.2.83.jar;E:\Idea-project\ikingtec-new6.0\microservices-platform\zlt-config\target\classes;D:\maven\ikingtec-repo\com\alibaba\cloud\spring-cloud-starter-alibaba-nacos-config\2022.0.0.0\spring-cloud-starter-alibaba-nacos-config-2022.0.0.0.jar;D:\maven\ikingtec-repo\org\slf4j\slf4j-api\2.0.9\slf4j-api-2.0.9.jar;D:\maven\ikingtec-repo\jakarta\annotation\jakarta.annotation-api\2.1.1\jakarta.annotation-api-2.1.1.jar;E:\Idea-project\ikingtec-new6.0\microservices-platform\zlt-commons\zlt-common-spring-boot-starter\target\classes;E:\Idea-project\ikingtec-new6.0\microservices-platform\zlt-commons\zlt-common-core\target\classes;D:\maven\ikingtec-repo\com\baomidou\mybatis-plus-extension\3.5.4.1\mybatis-plus-e
|
||||
Launcher Type: SUN_STANDARD
|
||||
|
||||
[Global flags]
|
||||
intx CICompilerCount = 4 {product} {ergonomic}
|
||||
uint ConcGCThreads = 2 {product} {ergonomic}
|
||||
uint G1ConcRefinementThreads = 8 {product} {ergonomic}
|
||||
size_t G1HeapRegionSize = 4194304 {product} {ergonomic}
|
||||
uintx GCDrainStackTargetSize = 64 {product} {ergonomic}
|
||||
size_t InitialHeapSize = 536870912 {product} {ergonomic}
|
||||
bool ManagementServer = true {product} {command line}
|
||||
size_t MarkStackSize = 4194304 {product} {ergonomic}
|
||||
size_t MaxHeapSize = 8573157376 {product} {ergonomic}
|
||||
size_t MinHeapDeltaBytes = 4194304 {product} {ergonomic}
|
||||
size_t MinHeapSize = 8388608 {product} {ergonomic}
|
||||
uintx NonProfiledCodeHeapSize = 0 {pd product} {ergonomic}
|
||||
bool ProfileInterpreter = false {pd product} {command line}
|
||||
uintx ProfiledCodeHeapSize = 0 {pd product} {ergonomic}
|
||||
size_t SoftMaxHeapSize = 8573157376 {manageable} {ergonomic}
|
||||
intx TieredStopAtLevel = 1 {product} {command line}
|
||||
bool UseCompressedClassPointers = true {product lp64_product} {ergonomic}
|
||||
bool UseCompressedOops = true {product lp64_product} {ergonomic}
|
||||
bool UseG1GC = true {product} {ergonomic}
|
||||
bool UseLargePagesIndividualAllocation = false {pd product} {ergonomic}
|
||||
|
||||
Logging:
|
||||
Log output configuration:
|
||||
#0: stdout all=warning uptime,level,tags
|
||||
#1: stderr all=off uptime,level,tags
|
||||
|
||||
Environment Variables:
|
||||
JAVA_HOME=D:\Program Files\Java\jdk-17
|
||||
PATH=C:\Program Files\Common Files\Oracle\Java\javapath;D:\Python39\Scripts\;D:\Python39\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;D:\Program Files\Java\jdk-17\bin;node_global;D:\maven\apache-maven-3.5.2\bin;D:\Program Files\nodejs\node_global\node_modules;E:\gradle\gradle-5.2.1-all\gradle-5.2.1\bin;C:\Users\ADAM5\.windows-build-tools\python27;D:\Program Files (x86)\Yarn\bin\;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;node_global;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;D:\Program Files\Microsoft VS Code\bin;D:\P;ogram Files\Git\cmd;C:\Program Files\dotnet\;C:\Program Files\GitHub CLI\;D:\nvm;D:\Program Files\nodejs;D:\Program Files\apache-ant-1.10.15-bin\apache-ant-1.10.15\bin;D:\Program Files (x86)\Tencent\΢ÐÅweb¿ª·¢Õß¹¤¾ß\dll;;;D:\Program Files\Git\cmd;C:\Users\ADAM5\AppData\Local\Microsoft\WindowsApps;D:\Program Files (x86)\SSH Communications Security\SSH Secure Shell;C:\Users\ADAM5\AppData\Roaming\npm;C:\Users\ADAM5\AppData\Local\Yarn\bin;D:\Program Files\JetBrains\PyCharm Community Edition 2020.3.2\bin;C:\Users\ADAM5\AppData\Local\Programs\Fiddler;D:\Program Files (x86)\GitHub CLI\;C:\Users\ADAM5\AppData\Local\Microsoft\WindowsApps;D:\Program Files (x86)\nvm;D:\Program Files\nodejs;D:\Program Files (x86)\Fiddler2\Fiddler;D:\nvm;D:\Program Files\nodejs;D:\Program Files\JetBrains\IntelliJ IDEA 2024.3.1\bin;
|
||||
USERNAME=ADAM5
|
||||
OS=Windows_NT
|
||||
PROCESSOR_IDENTIFIER=Intel64 Family 6 Model 158 Stepping 13, GenuineIntel
|
||||
|
||||
|
||||
|
||||
--------------- S Y S T E M ---------------
|
||||
|
||||
OS:
|
||||
Windows 10 , 64 bit Build 19041 (10.0.19041.5198)
|
||||
OS uptime: 6 days 20:09 hours
|
||||
|
||||
CPU: total 8 (initial active 8) (8 cores per cpu, 1 threads per core) family 6 model 158 stepping 13 microcode 0xb8, cx8, cmov, fxsr, mmx, 3dnowpref, sse, sse2, sse3, ssse3, sse4.1, sse4.2, popcnt, lzcnt, tsc, tscinvbit, avx, avx2, aes, erms, clmul, bmi1, bmi2, rtm, adx, fma, vzeroupper, clflush, clflushopt
|
||||
|
||||
Memory: 4k page, system-wide physical 32701M (6439M free)
|
||||
TotalPageFile size 54576M (AvailPageFile size 25M)
|
||||
current process WorkingSet (physical memory assigned to process): 12M, peak: 12M
|
||||
current process commit charge ("private bytes"): 56M, peak: 568M
|
||||
|
||||
vm_info: Java HotSpot(TM) 64-Bit Server VM (17.0.13+10-LTS-268) for windows-amd64 JRE (17.0.13+10-LTS-268), built on Sep 30 2024 06:33:13 by "mach5one" with MS VC++ 17.6 (VS2022)
|
||||
|
||||
END.
|
||||
@@ -454,19 +454,6 @@
|
||||
</build>
|
||||
|
||||
<repositories>
|
||||
|
||||
<!-- <!– 添加本地仓库,优先级最高 –>
|
||||
<repository>
|
||||
<id>local</id>
|
||||
<name>Local Repository</name>
|
||||
<url>file:${user.home}/.m2/repository</url>
|
||||
<releases>
|
||||
<enabled>true</enabled>
|
||||
</releases>
|
||||
<snapshots>
|
||||
<enabled>true</enabled>
|
||||
</snapshots>
|
||||
</repository>-->
|
||||
<repository>
|
||||
<id>aliyun-repos</id>
|
||||
<url>https://maven.aliyun.com/repository/public</url>
|
||||
|
||||
Binary file not shown.
@@ -1,201 +0,0 @@
|
||||
# 酒店优惠券二维码需求实现方案
|
||||
|
||||
## 1. 背景与目标
|
||||
- 为协商酒店提供一次性实体二维码优惠券,入住绑定用户后可在设备端免支付下单。
|
||||
- 确保券码唯一、不可重复使用,订单需区分优惠券订单类型,保证业务闭环(生成-发放-绑定-核销-订单-设备任务)。
|
||||
- 方案部署在 coupon-center 模块,可扩展到其他券类型/渠道。
|
||||
|
||||
## 2. 业务角色与定义
|
||||
- 协商酒店:已签约的酒店实体,负责发放线下券。
|
||||
- 优惠券批次:一次生成的一组券码,绑定同一酒店、有效期、面值规则。
|
||||
- 优惠券券码/二维码:携带唯一券码和签名的二维码图片,实体印刷,状态流转 UNBOUND -> BOUND -> USED/VOID/EXPIRED。
|
||||
- 用户:入住客人,登录后绑定券码;同一用户同一酒店默认仅可绑定一张(可配置)。
|
||||
- 设备端:自助设备/终端,负责扫码下单并执行任务。
|
||||
- 订单类型:`NORMAL` 普通订单;`HOTEL_COUPON_FREE` 酒店券免单订单;预留 `HOTEL_COUPON_DEDUCTION` 抵扣类。
|
||||
|
||||
## 3. 流程说明
|
||||
### 3.1 券码生成与发放
|
||||
- 管理端选择酒店、配置面值(默认免单0元)、有效期、单用户限领数、生成数量。
|
||||
- 系统创建批次,生成唯一 `coupon_code`,写入券码表,构造绑定入口 `https://xxx/h5/hotel-coupon/bind?code=...&hotelId=...&ts=...&sign=...`,生成二维码图片并打包 zip 提供下载。
|
||||
- 下载记录写入事件表,批次状态从 `GENERATED` -> `FINISHED`,券码状态初始为 `UNBOUND`。
|
||||
|
||||
### 3.2 入住绑定
|
||||
- 前台发放实体码,用户扫码进入 H5,登录后调用绑定接口。
|
||||
- 校验:有效期、券码状态=UNBOUND、酒店匹配、用户在同酒店限领数未超限;签名校验防伪。
|
||||
- 事务内执行:`UPDATE t_hotel_coupon_code SET status='BOUND', bind_user_id=?, bind_time=NOW(), version=version+1 WHERE coupon_code=? AND status='UNBOUND'`;写入事件流水。
|
||||
- 返回成功页并展示可用状态;重复提交按幂等返回已绑定信息。
|
||||
|
||||
### 3.3 设备扫码下单与核销
|
||||
- 设备端通过用户身份/手机号调用“查询可用券”接口,若存在 BOUND 且未过期券,前端金额置零并将 `orderType=HOTEL_COUPON_FREE`。
|
||||
- 下单接口在同一事务内写入订单表、将券码从 BOUND 更新为 USED,落订单-券码关联,推送设备执行任务。
|
||||
- 同步返回订单号;失败时回滚券状态,设备收到失败提示继续正常付费路径。
|
||||
- 若用户无绑定券或券不可用,则按 `NORMAL` 下单,不影响其他流程。
|
||||
|
||||
### 3.4 异常/风控
|
||||
- 管理端支持作废券码/批次(status->VOID),并记录原因;VOID 后绑定/核销均拒绝。
|
||||
- 定时任务每日凌晨标记过期,写事件流水;订单幂等使用 `requestId`/`orderNo` 双重校验。
|
||||
- 券码字符串含签名与时间戳,服务端校验防止伪造;绑定、核销接口限流并记录审计。
|
||||
|
||||
## 4. 数据库表设计(coupon-center)
|
||||
### 4.1 协商酒店表 t_partner_hotel
|
||||
```sql
|
||||
CREATE TABLE `t_partner_hotel` (
|
||||
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键',
|
||||
`hotel_code` varchar(64) NOT NULL COMMENT '酒店编码(对外展示/查询)',
|
||||
`hotel_name` varchar(100) NOT NULL COMMENT '酒店名称',
|
||||
`contact_name` varchar(50) DEFAULT NULL COMMENT '联系人',
|
||||
`contact_phone` varchar(20) DEFAULT NULL COMMENT '联系电话',
|
||||
`address` varchar(255) DEFAULT NULL COMMENT '地址',
|
||||
`status` varchar(20) DEFAULT 'ENABLED' COMMENT 'ENABLED/ DISABLED',
|
||||
`remark` varchar(255) DEFAULT NULL,
|
||||
`create_time` datetime DEFAULT CURRENT_TIMESTAMP,
|
||||
`update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||
`deleted` tinyint(1) DEFAULT 0,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `uk_hotel_code` (`hotel_code`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='协商酒店';
|
||||
```
|
||||
|
||||
### 4.2 优惠券批次表 t_hotel_coupon_batch
|
||||
```sql
|
||||
CREATE TABLE `t_hotel_coupon_batch` (
|
||||
`id` bigint NOT NULL AUTO_INCREMENT,
|
||||
`batch_no` varchar(64) NOT NULL COMMENT '批次号',
|
||||
`hotel_id` bigint NOT NULL COMMENT '关联酒店',
|
||||
`coupon_type` varchar(20) NOT NULL COMMENT 'FREE_ORDER/DEDUCTION',
|
||||
`face_value` decimal(10,2) NOT NULL DEFAULT 0 COMMENT '面值,免单为0',
|
||||
`quantity` int NOT NULL COMMENT '生成数量',
|
||||
`valid_start_time` datetime NOT NULL,
|
||||
`valid_end_time` datetime NOT NULL,
|
||||
`per_user_limit` int NOT NULL DEFAULT 1 COMMENT '同酒店同用户限领数',
|
||||
`order_type` varchar(20) NOT NULL DEFAULT 'HOTEL_COUPON_FREE' COMMENT '下单类型标识',
|
||||
`qr_payload_prefix` varchar(255) NOT NULL COMMENT '绑定入口前缀/域名',
|
||||
`download_url` varchar(500) DEFAULT NULL COMMENT '二维码zip存储路径',
|
||||
`status` varchar(20) DEFAULT 'GENERATED' COMMENT 'GENERATED/PROCESSING/FINISHED/CLOSED',
|
||||
`created_by` varchar(50) DEFAULT NULL,
|
||||
`create_time` datetime DEFAULT CURRENT_TIMESTAMP,
|
||||
`update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||
`deleted` tinyint(1) DEFAULT 0,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `uk_batch_no` (`batch_no`),
|
||||
KEY `idx_hotel` (`hotel_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='酒店优惠券批次';
|
||||
```
|
||||
|
||||
### 4.3 券码表 t_hotel_coupon_code
|
||||
```sql
|
||||
CREATE TABLE `t_hotel_coupon_code` (
|
||||
`id` bigint NOT NULL AUTO_INCREMENT,
|
||||
`batch_id` bigint NOT NULL,
|
||||
`hotel_id` bigint NOT NULL,
|
||||
`coupon_code` varchar(128) NOT NULL COMMENT '唯一券码',
|
||||
`qr_content` varchar(500) NOT NULL COMMENT '二维码携带内容(含签名)',
|
||||
`qr_image_url` varchar(500) DEFAULT NULL COMMENT '二维码图片地址',
|
||||
`status` varchar(20) NOT NULL DEFAULT 'UNBOUND' COMMENT 'UNBOUND/BOUND/USED/EXPIRED/VOID',
|
||||
`bind_user_id` bigint DEFAULT NULL,
|
||||
`bind_user_name` varchar(50) DEFAULT NULL,
|
||||
`bind_user_phone` varchar(20) DEFAULT NULL,
|
||||
`bind_time` datetime DEFAULT NULL,
|
||||
`bind_channel` varchar(30) DEFAULT NULL COMMENT 'H5/MINI/FRONT_DESK',
|
||||
`use_time` datetime DEFAULT NULL,
|
||||
`use_order_no` varchar(64) DEFAULT NULL,
|
||||
`use_device_code` varchar(64) DEFAULT NULL,
|
||||
`order_type` varchar(20) DEFAULT NULL COMMENT '下单类型冗余',
|
||||
`expire_time` datetime DEFAULT NULL,
|
||||
`version` int NOT NULL DEFAULT 0 COMMENT '乐观锁',
|
||||
`deleted` tinyint(1) DEFAULT 0,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `uk_coupon_code` (`coupon_code`),
|
||||
KEY `idx_batch` (`batch_id`),
|
||||
KEY `idx_hotel_status` (`hotel_id`,`status`),
|
||||
KEY `idx_user` (`bind_user_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='酒店优惠券券码';
|
||||
```
|
||||
|
||||
### 4.4 事件流水表 t_hotel_coupon_event
|
||||
```sql
|
||||
CREATE TABLE `t_hotel_coupon_event` (
|
||||
`id` bigint NOT NULL AUTO_INCREMENT,
|
||||
`coupon_code` varchar(128) NOT NULL,
|
||||
`hotel_id` bigint NOT NULL,
|
||||
`batch_id` bigint NOT NULL,
|
||||
`user_id` bigint DEFAULT NULL,
|
||||
`device_code` varchar(64) DEFAULT NULL,
|
||||
`event_type` varchar(30) NOT NULL COMMENT 'GENERATE/BIND/USE/EXPIRE/VOID/DOWNLOAD',
|
||||
`request_id` varchar(64) DEFAULT NULL COMMENT '幂等/追踪ID',
|
||||
`remark` varchar(500) DEFAULT NULL,
|
||||
`create_time` datetime DEFAULT CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `idx_coupon_event` (`coupon_code`,`event_type`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='券码事件流水';
|
||||
```
|
||||
|
||||
### 4.5 订单表 t_hotel_coupon_order
|
||||
```sql
|
||||
CREATE TABLE `t_hotel_coupon_order` (
|
||||
`id` bigint NOT NULL AUTO_INCREMENT,
|
||||
`order_no` varchar(64) NOT NULL,
|
||||
`user_id` bigint NOT NULL,
|
||||
`user_phone` varchar(20) DEFAULT NULL,
|
||||
`hotel_id` bigint NOT NULL,
|
||||
`device_code` varchar(64) NOT NULL,
|
||||
`coupon_code` varchar(128) DEFAULT NULL,
|
||||
`order_type` varchar(20) NOT NULL COMMENT 'NORMAL/HOTEL_COUPON_FREE/HOTEL_COUPON_DEDUCTION',
|
||||
`origin_amount` decimal(10,2) NOT NULL COMMENT '原价',
|
||||
`pay_amount` decimal(10,2) NOT NULL COMMENT '实付,免单为0',
|
||||
`status` varchar(20) NOT NULL DEFAULT 'CREATED' COMMENT 'CREATED/DOING/DONE/CANCELLED/FAILED',
|
||||
`task_payload` json DEFAULT NULL COMMENT '下发设备任务数据',
|
||||
`remark` varchar(255) DEFAULT NULL,
|
||||
`create_time` datetime DEFAULT CURRENT_TIMESTAMP,
|
||||
`update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `uk_order_no` (`order_no`),
|
||||
KEY `idx_user_type` (`user_id`,`order_type`),
|
||||
KEY `idx_coupon` (`coupon_code`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='设备订单(含优惠券)';
|
||||
```
|
||||
|
||||
## 5. 接口设计(关键)
|
||||
### 5.1 管理端(需认证)
|
||||
- `POST /admin/hotel` 创建/编辑酒店;`GET /admin/hotel` 列表筛选,`PUT /admin/hotel/{id}/status` 启停。
|
||||
- `POST /admin/hotel/{hotelId}/coupon-batches` 创建批次(quantity/validity/perUserLimit/faceValue/orderType);异步生成券码。
|
||||
- `GET /admin/coupon-batches` 按酒店/时间查询;`GET /admin/coupon-batches/{id}/download` 下载二维码zip;`POST /admin/coupon-batches/{id}/close` 关闭批次。
|
||||
- `GET /admin/coupons` 券码明细分页;`POST /admin/coupons/{code}/void` 作废单码;导出报表。
|
||||
|
||||
### 5.2 H5 绑定
|
||||
- `GET /public/hotel-coupon/{code}/precheck?hotelId=...&ts=...&sign=...` 校验二维码、返回酒店名/有效期/状态。
|
||||
- `POST /public/hotel-coupon/bind` 绑定券码,入参:`code, hotelId, userId, userPhone, deviceCode(optional)`;返回绑定结果和可用状态。
|
||||
|
||||
### 5.3 设备侧下单/核销
|
||||
- `GET /device/hotel-coupon/available?userId=...&hotelId=...` 返回可用券及订单类型;无券时返回空。
|
||||
- `POST /device/hotel-coupon/use` 入参:`code/orderNo/userId/userPhone/hotelId/deviceCode/orderAmount/requestId`;事务化校验并落订单,成功返回免单订单号,失败返回原因。
|
||||
- `POST /device/hotel-coupon/order` 可直接创建订单(包含 taskPayload),内部调用 use 接口扣券并设置 `orderType`。
|
||||
|
||||
### 5.4 运维/风控
|
||||
- 事件列表接口:根据券码/用户/时间查询绑定、核销流水。
|
||||
- 定时任务/手动触发接口:补偿过期、批量作废、重新生成二维码。
|
||||
|
||||
## 6. 核心实现要点
|
||||
- 一次性二维码:券码唯一+签名+状态机控制;绑定/核销均通过 `status` + `version` 条件更新,避免并发复用。
|
||||
- 订单类型:下单时写入 `t_hotel_coupon_order.order_type` 与设备任务记录,用于报表、风控、资金对账。
|
||||
- 扩展性:`coupon_type/order_type` 预留,订单表 `task_payload`、券码表 `qr_content` 可存 JSON 扩展;批次/券码表均含 `deleted/status` 便于软删除和扩展。
|
||||
- 监控审计:事件流水表记录全链路;关键接口打印 `requestId`;Prometheus/日志可按券码/酒店打标签。
|
||||
- 定时任务:复用 `CouponExpireTask` 思路新增批次/券码过期处理;对过期券写事件并禁止绑定/核销。
|
||||
|
||||
## 7. 前端管理页面方案(zlt-web/react-web)
|
||||
- 新增菜单「酒店优惠券」下包含:
|
||||
- 「协商酒店管理」:列表/搜索/启停,表单字段:酒店名称、编码、联系人、电话、地址、备注。
|
||||
- 「优惠券批次」:表单配置酒店、面值/类型、有效期、生成数量、单用户限领、二维码域名;表格展示状态、下载、关闭、查看日志。
|
||||
- 「券码明细」:按批次/状态/用户过滤,支持导出、作废单码,展示绑定人、绑定时间、使用订单、设备号。
|
||||
- H5 绑定页:展示酒店名称、有效期、状态文案;登录校验后点击「立即绑定」,提示绑定成功/失败原因。
|
||||
- 交互提示:批次生成异步轮询,下载二维码给出 zip 地址;作废操作二次确认并展示影响范围。
|
||||
|
||||
## 8. 测试验证
|
||||
- 单测/接口测试:批次生成数量正确、二维码签名校验、绑定幂等、并发绑定/核销互斥、过期/作废拦截。
|
||||
- 联调:H5 绑定 -> 设备查询可用券 -> 免单下单 -> 设备任务执行 -> 订单状态回写。
|
||||
- 回归:无券用户正常下单流程不受影响;报表统计区分订单类型。
|
||||
|
||||
## 9. 上线与配置
|
||||
- SQL:新增表写入 `coupon-center/sql`,发布前执行;确保 DB 字符集 utf8mb4。
|
||||
- 配置:新增二维码生成域名、OSS/本地存储路径、签名密钥;绑定/核销接口在网关配置白名单/限流。
|
||||
- 发布:优先低峰期启用新定时任务,观察事件流水与日志;确认前端菜单、H5 入口发布同步。
|
||||
@@ -1,772 +0,0 @@
|
||||
# 发明专利申请书
|
||||
|
||||
## 一、发明名称
|
||||
|
||||
**一种基于实体二维码的酒店优惠券发放与自动核销系统及方法**
|
||||
|
||||
---
|
||||
|
||||
## 二、技术领域
|
||||
|
||||
本发明涉及电子商务与旅游信息化技术领域,尤其涉及一种基于实体二维码的酒店优惠券发放与自动核销系统及方法。
|
||||
|
||||
---
|
||||
|
||||
## 三、背景技术
|
||||
|
||||
随着旅游行业的快速发展,景区与酒店的合作营销成为重要的获客渠道。酒店作为游客集中的场所,具有天然的流量优势,如何有效地将酒店住客引流至合作景区成为行业关注的重点。
|
||||
|
||||
然而,现有的酒店与景区合作营销方案存在以下技术问题:
|
||||
|
||||
1. **优惠券发放效率低**:传统纸质优惠券需要人工发放,容易遗失、伪造,且无法精准追踪发放和使用情况。
|
||||
|
||||
2. **优惠券核销流程繁琐**:用户使用优惠券时需要手动出示、人工核验,影响用户体验,增加景区运营成本。
|
||||
|
||||
3. **缺乏一码一用机制**:传统优惠券容易被复制传播,难以控制实际使用量,造成营销成本失控。
|
||||
|
||||
4. **数据追踪困难**:无法准确统计优惠券的发放、绑定、使用情况,难以评估合作效果和优化营销策略。
|
||||
|
||||
5. **系统对接复杂**:优惠券系统与订单系统分离,需要人工核对,容易出现核销遗漏或重复核销问题。
|
||||
|
||||
6. **有效期管理粗放**:无法支持灵活的有效期策略(如固定时间或绑定后N天有效),用户体验欠佳。
|
||||
|
||||
因此,亟需一种能够实现优惠券自动化发放、一码一用、自动核销的技术方案。
|
||||
|
||||
---
|
||||
|
||||
## 四、发明内容
|
||||
|
||||
### 4.1 发明目的
|
||||
|
||||
本发明的目的在于提供一种基于实体二维码的酒店优惠券发放与自动核销系统及方法,解决现有技术中优惠券发放效率低、核销流程繁琐、缺乏一码一用机制、数据追踪困难等技术问题。
|
||||
|
||||
### 4.2 技术方案
|
||||
|
||||
为实现上述目的,本发明提供以下技术方案:
|
||||
|
||||
#### 4.2.1 一种基于实体二维码的酒店优惠券发放与自动核销系统
|
||||
|
||||
所述系统包括:
|
||||
|
||||
**合作酒店管理模块**,用于管理与景区建立合作关系的酒店信息,包括:
|
||||
- 酒店基本信息(名称、地址、联系人等);
|
||||
- 合作有效期管理;
|
||||
- 酒店状态管理(启用/禁用);
|
||||
|
||||
**优惠券批量生成模块**,用于为指定酒店批量生成带有唯一标识码的优惠券,包括:
|
||||
- 生成唯一的批次号标识同一批次优惠券;
|
||||
- 为每张优惠券生成全局唯一的优惠券码;
|
||||
- 根据优惠券码生成对应的二维码图片;
|
||||
- 支持配置优惠券类型(免费体验券、折扣券、满减券);
|
||||
- 支持配置适用范围(指定景区、指定设备);
|
||||
- 支持配置有效期策略(固定时间或绑定后N天);
|
||||
|
||||
**二维码图片管理模块**,用于管理优惠券二维码图片,包括:
|
||||
- 将二维码图片上传至云存储服务;
|
||||
- 支持按批次或按条件批量下载二维码图片;
|
||||
- 将二维码打包为压缩文件供酒店打印制作实体二维码;
|
||||
|
||||
**用户扫码绑定模块**,用于处理用户扫描实体二维码后的绑定请求,包括:
|
||||
- 解析二维码获取优惠券码;
|
||||
- 校验优惠券状态(是否存在、是否已绑定、是否已过期、是否已作废);
|
||||
- 采用分布式锁机制确保一码只能被一个用户绑定;
|
||||
- 创建优惠券与用户的绑定关系;
|
||||
- 根据有效期策略计算优惠券的实际生效时间;
|
||||
- 更新优惠券状态为已绑定;
|
||||
|
||||
**用户优惠券查询模块**,用于为用户提供已绑定优惠券的查询功能,包括:
|
||||
- 展示用户所有已绑定的优惠券列表;
|
||||
- 支持按状态筛选(可用、已使用、已过期);
|
||||
- 展示优惠券详情和适用范围;
|
||||
|
||||
**可用优惠券检测模块**,用于在用户下单前检测是否有可用优惠券,包括:
|
||||
- 根据当前景区和设备信息查询用户的可用优惠券;
|
||||
- 校验优惠券是否在有效期内;
|
||||
- 校验优惠券是否适用于当前景区和设备;
|
||||
- 返回可用优惠券信息供下单使用;
|
||||
|
||||
**自动核销模块**,用于在订单创建时自动完成优惠券核销,包括:
|
||||
- 在订单创建流程中嵌入优惠券核销逻辑;
|
||||
- 根据优惠券类型计算优惠金额;
|
||||
- 创建零金额订单(免费体验券)或优惠后金额订单;
|
||||
- 更新优惠券状态和绑定记录状态为已使用;
|
||||
- 创建详细的核销记录用于数据追踪;
|
||||
|
||||
**订单类型标记模块**,用于在订单中标记优惠券使用信息,包括:
|
||||
- 订单类型标记(普通订单/优惠券订单);
|
||||
- 关联的优惠券标识;
|
||||
- 原始金额、优惠金额、实付金额;
|
||||
|
||||
**过期处理模块**,用于定时处理过期的优惠券,包括:
|
||||
- 定时扫描超过有效期的优惠券;
|
||||
- 更新未使用的过期优惠券状态;
|
||||
- 更新过期的绑定记录状态;
|
||||
|
||||
**数据统计模块**,用于统计优惠券的发放和使用情况,包括:
|
||||
- 按酒店统计优惠券发放数量;
|
||||
- 统计已绑定、已使用、已过期数量;
|
||||
- 支持按批次、按时间维度统计;
|
||||
|
||||
#### 4.2.2 一种基于实体二维码的酒店优惠券发放与自动核销方法
|
||||
|
||||
所述方法包括以下步骤:
|
||||
|
||||
**步骤S1:酒店合作关系建立**
|
||||
- S1.1:在系统中录入合作酒店基本信息;
|
||||
- S1.2:设置合作有效期;
|
||||
- S1.3:生成酒店唯一编码;
|
||||
|
||||
**步骤S2:优惠券批量生成**
|
||||
- S2.1:选择目标酒店,配置优惠券参数;
|
||||
- S2.2:系统生成批次号,格式为:B + 年月日 + 4位序号;
|
||||
- S2.3:循环生成指定数量的优惠券码,格式为:HC + 批次号 + 6位序号;
|
||||
- S2.4:为每个优惠券码生成二维码图片,二维码内容为小程序页面路径加优惠券码参数;
|
||||
- S2.5:将二维码图片上传至云存储;
|
||||
- S2.6:批量写入优惠券记录至数据库,初始状态为未绑定;
|
||||
|
||||
**步骤S3:实体二维码制作与投放**
|
||||
- S3.1:管理人员按批次下载二维码图片压缩包;
|
||||
- S3.2:将二维码图片打印制作成实体二维码卡片或海报;
|
||||
- S3.3:将实体二维码投放至合作酒店指定位置;
|
||||
|
||||
**步骤S4:用户扫码绑定**
|
||||
- S4.1:用户在酒店扫描实体二维码;
|
||||
- S4.2:小程序打开优惠券绑定页面,获取优惠券码参数;
|
||||
- S4.3:调用绑定接口,系统获取分布式锁防止并发绑定;
|
||||
- S4.4:校验优惠券状态,确保未被绑定、未过期、未作废;
|
||||
- S4.5:根据有效期策略计算优惠券的实际生效开始时间和结束时间;
|
||||
- S4.6:创建优惠券与用户的绑定记录;
|
||||
- S4.7:更新优惠券状态为已绑定;
|
||||
- S4.8:释放分布式锁,返回绑定成功信息;
|
||||
|
||||
**步骤S5:设备端下单检测**
|
||||
- S5.1:用户在景区设备端准备下单;
|
||||
- S5.2:系统调用可用优惠券检测接口;
|
||||
- S5.3:查询用户已绑定且状态为有效的优惠券;
|
||||
- S5.4:过滤出适用于当前景区和设备的优惠券;
|
||||
- S5.5:过滤出在有效期内的优惠券;
|
||||
- S5.6:若存在可用优惠券,前端展示免费体验或优惠信息;
|
||||
|
||||
**步骤S6:订单创建与自动核销**
|
||||
- S6.1:用户确认使用优惠券下单;
|
||||
- S6.2:创建订单,设置订单类型为优惠券订单;
|
||||
- S6.3:根据优惠券类型计算优惠金额:
|
||||
- 免费体验券:优惠金额等于订单原始金额,实付金额为0;
|
||||
- 折扣券:优惠金额等于原始金额乘以折扣率,实付金额为原始金额减优惠金额;
|
||||
- 满减券:满足最低消费条件时,优惠金额等于满减金额;
|
||||
- S6.4:在订单中记录优惠券标识和优惠金额;
|
||||
- S6.5:调用核销接口完成优惠券核销;
|
||||
- S6.6:更新优惠券状态为已使用;
|
||||
- S6.7:更新绑定记录状态为已使用;
|
||||
- S6.8:创建核销记录,记录核销详情;
|
||||
- S6.9:触发设备执行任务;
|
||||
|
||||
**步骤S7:过期优惠券处理**
|
||||
- S7.1:定时任务每日扫描所有优惠券;
|
||||
- S7.2:将超过有效期且状态仍为未绑定的优惠券状态更新为已过期;
|
||||
- S7.3:将超过有效期且状态仍为已绑定的绑定记录状态更新为已过期;
|
||||
|
||||
### 4.3 有益效果
|
||||
|
||||
本发明与现有技术相比,具有以下有益效果:
|
||||
|
||||
1. **一码一用防滥用**:每个优惠券码全局唯一,通过分布式锁确保同一时刻只有一个用户能成功绑定,有效防止优惠券被复制滥用。
|
||||
|
||||
2. **自动核销提效率**:优惠券核销与订单创建流程无缝集成,用户下单时自动完成核销,无需人工核验,提升用户体验和运营效率。
|
||||
|
||||
3. **实体二维码易投放**:将优惠券二维码制作成实体卡片或海报投放至酒店,无需酒店培训人员发放,降低合作门槛。
|
||||
|
||||
4. **灵活的有效期策略**:支持固定时间有效期和绑定后N天有效期两种策略,满足不同营销场景需求。
|
||||
|
||||
5. **精准的适用范围控制**:可配置优惠券仅适用于指定景区或指定设备,实现精细化营销。
|
||||
|
||||
6. **完整的数据追踪链路**:从发放、绑定、使用到过期,全链路数据可追溯,便于评估营销效果和优化策略。
|
||||
|
||||
7. **多类型优惠券支持**:支持免费体验券、折扣券、满减券等多种类型,可根据营销目标灵活配置。
|
||||
|
||||
8. **批量操作高效率**:支持批量生成优惠券、批量下载二维码,满足大规模投放需求。
|
||||
|
||||
---
|
||||
|
||||
## 五、附图说明
|
||||
|
||||
### 图1:系统整体架构图
|
||||
|
||||
```
|
||||
┌─────────────────────────────────────────────────────────────────────┐
|
||||
│ 前端应用层 │
|
||||
├────────────────┬────────────────┬────────────────────────────────────┤
|
||||
│ 管理后台 │ 用户小程序 │ 设备端 │
|
||||
│ (优惠券管理) │ (扫码绑定) │ (自动核销) │
|
||||
└───────┬────────┴───────┬────────┴───────────────┬────────────────────┘
|
||||
│ │ │
|
||||
▼ ▼ ▼
|
||||
┌─────────────────────────────────────────────────────────────────────┐
|
||||
│ 业务服务层 │
|
||||
├─────────────────────────────────────────────────────────────────────┤
|
||||
│ 合作酒店 优惠券生成 扫码绑定 可用检测 自动核销 过期处理 │
|
||||
│ 管理 模块 模块 模块 模块 模块 │
|
||||
└─────────────────────────────────────────────────────────────────────┘
|
||||
│ │ │
|
||||
▼ ▼ ▼
|
||||
┌─────────────────────────────────────────────────────────────────────┐
|
||||
│ 数据存储层 │
|
||||
├─────────────────────────────────────────────────────────────────────┤
|
||||
│ 合作酒店表 优惠券表 绑定记录表 核销记录表 订单表 │
|
||||
└─────────────────────────────────────────────────────────────────────┘
|
||||
│
|
||||
▼
|
||||
┌─────────────────────────────────────────────────────────────────────┐
|
||||
│ 基础设施层 │
|
||||
├─────────────────────────────────────────────────────────────────────┤
|
||||
│ 云存储(二维码图片) │ 分布式锁(Redis) │
|
||||
└─────────────────────────────────────────────────────────────────────┘
|
||||
```
|
||||
|
||||
### 图2:优惠券生命周期状态图
|
||||
|
||||
```
|
||||
┌─────────────────────────────────────────────────────────────────────┐
|
||||
│ 优惠券状态流转 │
|
||||
├─────────────────────────────────────────────────────────────────────┤
|
||||
│ │
|
||||
│ ┌───────────┐ │
|
||||
│ │ 生成优惠券 │ │
|
||||
│ └─────┬─────┘ │
|
||||
│ │ │
|
||||
│ ▼ │
|
||||
│ ┌───────────┐ │
|
||||
│ ┌─────────│ 未绑定(0) │─────────┐ │
|
||||
│ │ └─────┬─────┘ │ │
|
||||
│ │ │ │ │
|
||||
│ ▼ ▼ ▼ │
|
||||
│ ┌───────────┐ ┌───────────┐ ┌───────────┐ │
|
||||
│ │ 已作废(4) │ │ 已绑定(1) │ │ 已过期(3) │ │
|
||||
│ └───────────┘ └─────┬─────┘ └───────────┘ │
|
||||
│ │ │
|
||||
│ ┌─────────┼─────────┐ │
|
||||
│ │ │ │ │
|
||||
│ ▼ ▼ ▼ │
|
||||
│ ┌───────────┐ ┌───────────┐ │
|
||||
│ │ 已过期(3) │ │ 已使用(2) │ │
|
||||
│ └───────────┘ └───────────┘ │
|
||||
│ │
|
||||
└─────────────────────────────────────────────────────────────────────┘
|
||||
```
|
||||
|
||||
### 图3:核心业务流程图
|
||||
|
||||
```
|
||||
┌─────────────┐ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐
|
||||
│ 创建合作酒店 │ ──> │ 生成优惠券码 │ ──> │ 用户扫码绑定 │ ──> │ 设备端核销 │
|
||||
└─────────────┘ └─────────────┘ └─────────────┘ └─────────────┘
|
||||
│ │ │ │
|
||||
▼ ▼ ▼ ▼
|
||||
酒店基本信息 批量生成二维码 一码一用 订单金额为0
|
||||
合作有效期 可批量下载 绑定用户ID 区分订单类型
|
||||
```
|
||||
|
||||
### 图4:用户扫码绑定流程图
|
||||
|
||||
```
|
||||
┌─────────────────────────────────────────────────────────────────┐
|
||||
│ 用户扫码绑定流程 │
|
||||
├─────────────────────────────────────────────────────────────────┤
|
||||
│ 1. 用户在酒店扫描实体二维码 │
|
||||
│ ↓ │
|
||||
│ 2. 小程序打开绑定页面,获取优惠券码 │
|
||||
│ ↓ │
|
||||
│ 3. 调用绑定接口,获取分布式锁 │
|
||||
│ ↓ │
|
||||
│ 4. 后端校验: │
|
||||
│ ├─ 优惠券是否存在 │
|
||||
│ ├─ 优惠券是否已被绑定 │
|
||||
│ ├─ 优惠券是否已过期 │
|
||||
│ └─ 优惠券是否已作废 │
|
||||
│ ↓ │
|
||||
│ 5. 创建绑定记录 │
|
||||
│ - 计算生效时间(固定时间或绑定后N天) │
|
||||
│ ↓ │
|
||||
│ 6. 更新优惠券状态为"已绑定" │
|
||||
│ ↓ │
|
||||
│ 7. 释放分布式锁,返回绑定成功信息 │
|
||||
└─────────────────────────────────────────────────────────────────┘
|
||||
```
|
||||
|
||||
### 图5:自动核销流程图
|
||||
|
||||
```
|
||||
┌─────────────────────────────────────────────────────────────────┐
|
||||
│ 优惠券核销流程 │
|
||||
├─────────────────────────────────────────────────────────────────┤
|
||||
│ 1. 用户在设备端扫码准备下单 │
|
||||
│ ↓ │
|
||||
│ 2. 前端调用检查可用优惠券接口 │
|
||||
│ ↓ │
|
||||
│ 3. 后端查询用户绑定的有效优惠券 │
|
||||
│ - 状态为有效 │
|
||||
│ - 在有效期内 │
|
||||
│ - 适用于当前景区/设备 │
|
||||
│ ↓ │
|
||||
│ 4. 如有可用优惠券,前端展示"免费体验" │
|
||||
│ ↓ │
|
||||
│ 5. 用户确认下单 │
|
||||
│ ↓ │
|
||||
│ 6. 创建订单 │
|
||||
│ - order_type = 2(优惠券订单) │
|
||||
│ - pay_type = 2(优惠券支付) │
|
||||
│ - order_amount = 0 │
|
||||
│ - coupon_id = 优惠券ID │
|
||||
│ ↓ │
|
||||
│ 7. 调用优惠券核销接口 │
|
||||
│ ↓ │
|
||||
│ 8. 更新优惠券状态和绑定记录状态为"已使用" │
|
||||
│ ↓ │
|
||||
│ 9. 创建核销记录 │
|
||||
│ ↓ │
|
||||
│ 10. 触发设备执行任务 │
|
||||
└─────────────────────────────────────────────────────────────────┘
|
||||
```
|
||||
|
||||
### 图6:数据表关系图
|
||||
|
||||
```
|
||||
┌──────────────────┐ ┌──────────────────┐ ┌──────────────────┐
|
||||
│ partner_hotel │ │ hotel_coupon │ │ coupon_binding │
|
||||
│ (合作酒店表) │ 1───n │ (优惠券表) │ 1───1 │ (绑定记录表) │
|
||||
├──────────────────┤ ├──────────────────┤ ├──────────────────┤
|
||||
│ id (PK) │ │ id (PK) │ │ id (PK) │
|
||||
│ hotel_code (UQ) │◄──────│ hotel_id (FK) │◄──────│ coupon_id (FK) │
|
||||
│ hotel_name │ │ coupon_code (UQ) │ │ coupon_code │
|
||||
│ contact_name │ │ batch_no │ │ user_id │
|
||||
│ cooperation_ │ │ coupon_type │ │ bind_time │
|
||||
│ start_date │ │ valid_start_time │ │ effective_ │
|
||||
│ cooperation_ │ │ valid_end_time │ │ start_time │
|
||||
│ end_date │ │ status │ │ effective_ │
|
||||
│ status │ │ qrcode_url │ │ end_time │
|
||||
│ ... │ │ ... │ │ status │
|
||||
└──────────────────┘ └──────────────────┘ └──────────────────┘
|
||||
│ │
|
||||
│ │
|
||||
▼ ▼
|
||||
┌──────────────────┐ ┌──────────────────┐
|
||||
│ coupon_usage │ │ orders │
|
||||
│ (核销记录表) │ │ (订单表) │
|
||||
├──────────────────┤ ├──────────────────┤
|
||||
│ id (PK) │ │ id (PK) │
|
||||
│ coupon_id │ │ order_no (UQ) │
|
||||
│ binding_id │ │ order_type │
|
||||
│ user_id │ │ coupon_id │
|
||||
│ order_id │───────│ coupon_code │
|
||||
│ order_no │ │ original_amount │
|
||||
│ original_amount │ │ discount_amount │
|
||||
│ discount_amount │ │ order_amount │
|
||||
│ actual_amount │ │ ... │
|
||||
│ usage_time │ └──────────────────┘
|
||||
│ ... │
|
||||
└──────────────────┘
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 六、具体实施方式
|
||||
|
||||
### 6.1 实施例一:优惠券批量生成
|
||||
|
||||
本实施例描述为合作酒店批量生成优惠券的过程:
|
||||
|
||||
**步骤1**:管理员在后台选择合作酒店"XX国际酒店"(ID=1),配置优惠券参数:
|
||||
- 优惠券名称:酒店住客免费体验券
|
||||
- 优惠券类型:免费体验券
|
||||
- 生成数量:1000张
|
||||
- 有效期类型:固定时间
|
||||
- 有效期:2024-11-25 至 2025-11-25
|
||||
- 适用景区:景区A、景区B
|
||||
|
||||
**步骤2**:系统生成批次号:
|
||||
```
|
||||
批次号 = "B" + "20241125" + "0001" = "B202411250001"
|
||||
```
|
||||
|
||||
**步骤3**:循环生成1000个优惠券码:
|
||||
```
|
||||
优惠券码1 = "HC" + "202411250001" + "000001" = "HC202411250001000001"
|
||||
优惠券码2 = "HC" + "202411250001" + "000002" = "HC202411250001000002"
|
||||
...
|
||||
优惠券码1000 = "HC" + "202411250001" + "001000" = "HC202411250001001000"
|
||||
```
|
||||
|
||||
**步骤4**:为每个优惠券码生成二维码,二维码内容:
|
||||
```
|
||||
pages/coupon/bind?code=HC202411250001000001
|
||||
```
|
||||
|
||||
**步骤5**:将二维码图片上传至云存储,保存访问URL。
|
||||
|
||||
**步骤6**:批量插入优惠券记录到数据库:
|
||||
```
|
||||
{
|
||||
coupon_code: "HC202411250001000001",
|
||||
hotel_id: 1,
|
||||
batch_no: "B202411250001",
|
||||
coupon_name: "酒店住客免费体验券",
|
||||
coupon_type: 1,
|
||||
valid_start_time: "2024-11-25 00:00:00",
|
||||
valid_end_time: "2025-11-25 23:59:59",
|
||||
status: 0, // 未绑定
|
||||
applicable_tourism_ids: "1,2",
|
||||
qrcode_url: "https://oss.xxx.com/coupon/HC202411250001000001.png"
|
||||
}
|
||||
```
|
||||
|
||||
### 6.2 实施例二:用户扫码绑定
|
||||
|
||||
本实施例描述用户在酒店扫描实体二维码绑定优惠券的过程:
|
||||
|
||||
**前置条件**:酒店已投放优惠券二维码海报,用户已登录小程序。
|
||||
|
||||
**步骤1**:用户张三(user_id=10001)在酒店前台扫描二维码海报。
|
||||
|
||||
**步骤2**:小程序解析二维码获取页面路径:
|
||||
```
|
||||
pages/coupon/bind?code=HC202411250001000001
|
||||
```
|
||||
|
||||
**步骤3**:小程序打开绑定页面,提取优惠券码,调用绑定接口:
|
||||
```
|
||||
POST /coupon/user/bind
|
||||
{
|
||||
"couponCode": "HC202411250001000001"
|
||||
}
|
||||
```
|
||||
|
||||
**步骤4**:后端获取分布式锁,锁键值:
|
||||
```
|
||||
coupon:bind:HC202411250001000001
|
||||
```
|
||||
|
||||
**步骤5**:后端查询优惠券信息并校验:
|
||||
- 优惠券存在 ✓
|
||||
- 状态为未绑定(0) ✓
|
||||
- 在有效期内 ✓
|
||||
- 未被作废 ✓
|
||||
|
||||
**步骤6**:创建绑定记录:
|
||||
```
|
||||
{
|
||||
coupon_id: 1,
|
||||
coupon_code: "HC202411250001000001",
|
||||
user_id: 10001,
|
||||
user_openid: "oXXXXX",
|
||||
bind_time: "2024-11-26 10:30:00",
|
||||
bind_source: 1, // 扫码绑定
|
||||
effective_start_time: "2024-11-25 00:00:00",
|
||||
effective_end_time: "2025-11-25 23:59:59",
|
||||
status: 1 // 有效
|
||||
}
|
||||
```
|
||||
|
||||
**步骤7**:更新优惠券状态为已绑定:
|
||||
```
|
||||
UPDATE hotel_coupon SET status = 1 WHERE id = 1
|
||||
```
|
||||
|
||||
**步骤8**:释放分布式锁,返回绑定成功:
|
||||
```
|
||||
{
|
||||
"code": 0,
|
||||
"msg": "绑定成功",
|
||||
"data": {
|
||||
"couponName": "酒店住客免费体验券",
|
||||
"effectiveEndTime": "2025-11-25 23:59:59",
|
||||
"applicableTourisms": ["景区A", "景区B"]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### 6.3 实施例三:设备端自动核销
|
||||
|
||||
本实施例描述用户在景区设备端使用优惠券下单的自动核销过程:
|
||||
|
||||
**前置条件**:用户张三已绑定优惠券,现在景区A的设备DEVICE001前准备下单。
|
||||
|
||||
**步骤1**:用户扫描设备二维码进入下单页面。
|
||||
|
||||
**步骤2**:前端调用可用优惠券检测接口:
|
||||
```
|
||||
GET /coupon/user/check-available?tourismId=1&deviceSn=DEVICE001
|
||||
```
|
||||
|
||||
**步骤3**:后端查询用户可用优惠券:
|
||||
```sql
|
||||
SELECT cb.*, hc.* FROM coupon_binding cb
|
||||
JOIN hotel_coupon hc ON cb.coupon_id = hc.id
|
||||
WHERE cb.user_id = 10001
|
||||
AND cb.status = 1
|
||||
AND cb.effective_end_time > NOW()
|
||||
AND (hc.applicable_tourism_ids IS NULL
|
||||
OR FIND_IN_SET('1', hc.applicable_tourism_ids))
|
||||
```
|
||||
|
||||
**步骤4**:返回可用优惠券信息:
|
||||
```
|
||||
{
|
||||
"hasCoupon": true,
|
||||
"coupon": {
|
||||
"couponId": 1,
|
||||
"couponName": "酒店住客免费体验券",
|
||||
"couponType": 1,
|
||||
"discountValue": 0
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**步骤5**:前端展示"您有可用的免费体验券",用户点击确认使用。
|
||||
|
||||
**步骤6**:创建订单,设置订单类型为优惠券订单:
|
||||
```
|
||||
{
|
||||
order_no: "ORD202411260001",
|
||||
order_type: 2, // 优惠券订单
|
||||
pay_type: 2, // 优惠券支付
|
||||
coupon_id: 1,
|
||||
coupon_code: "HC202411250001000001",
|
||||
original_amount: 99.00,
|
||||
discount_amount: 99.00,
|
||||
order_amount: 0.00, // 实付金额为0
|
||||
order_status: 2 // 已支付(无需支付)
|
||||
}
|
||||
```
|
||||
|
||||
**步骤7**:调用优惠券核销接口:
|
||||
```
|
||||
POST /coupon/internal/use
|
||||
{
|
||||
"userId": 10001,
|
||||
"couponId": 1,
|
||||
"orderId": 1,
|
||||
"orderNo": "ORD202411260001",
|
||||
"tourismId": 1,
|
||||
"tourismName": "景区A",
|
||||
"deviceSn": "DEVICE001",
|
||||
"originalAmount": 99.00
|
||||
}
|
||||
```
|
||||
|
||||
**步骤8**:更新优惠券和绑定记录状态为已使用:
|
||||
```sql
|
||||
UPDATE hotel_coupon SET status = 2 WHERE id = 1;
|
||||
UPDATE coupon_binding SET status = 2 WHERE coupon_id = 1;
|
||||
```
|
||||
|
||||
**步骤9**:创建核销记录:
|
||||
```
|
||||
{
|
||||
coupon_id: 1,
|
||||
coupon_code: "HC202411250001000001",
|
||||
binding_id: 1,
|
||||
user_id: 10001,
|
||||
order_id: 1,
|
||||
order_no: "ORD202411260001",
|
||||
tourism_id: 1,
|
||||
tourism_name: "景区A",
|
||||
device_sn: "DEVICE001",
|
||||
original_amount: 99.00,
|
||||
discount_amount: 99.00,
|
||||
actual_amount: 0.00,
|
||||
usage_time: "2024-11-26 14:30:00",
|
||||
usage_type: 1 // 自动核销
|
||||
}
|
||||
```
|
||||
|
||||
**步骤10**:触发设备执行任务,完成服务交付。
|
||||
|
||||
### 6.4 实施例四:绑定后N天有效期计算
|
||||
|
||||
本实施例描述"绑定后N天有效"类型优惠券的有效期计算:
|
||||
|
||||
**配置**:优惠券配置为"绑定后30天有效"。
|
||||
|
||||
**绑定时间**:2024-11-26 10:30:00
|
||||
|
||||
**有效期计算**:
|
||||
```
|
||||
effective_start_time = 绑定时间 = 2024-11-26 10:30:00
|
||||
effective_end_time = 绑定时间 + 30天 = 2024-12-26 10:30:00
|
||||
```
|
||||
|
||||
**存储的绑定记录**:
|
||||
```
|
||||
{
|
||||
bind_time: "2024-11-26 10:30:00",
|
||||
effective_start_time: "2024-11-26 10:30:00",
|
||||
effective_end_time: "2024-12-26 10:30:00"
|
||||
}
|
||||
```
|
||||
|
||||
### 6.5 实施例五:并发绑定控制
|
||||
|
||||
本实施例描述两个用户同时扫描同一优惠券二维码时的处理:
|
||||
|
||||
**场景**:用户A和用户B同时扫描优惠券码HC202411250001000001。
|
||||
|
||||
**时序**:
|
||||
```
|
||||
T1: 用户A调用绑定接口
|
||||
T2: 用户A尝试获取分布式锁,成功
|
||||
T3: 用户B调用绑定接口
|
||||
T4: 用户B尝试获取分布式锁,等待
|
||||
T5: 用户A完成绑定,释放锁
|
||||
T6: 用户B获取到锁
|
||||
T7: 用户B查询优惠券状态,发现已被绑定
|
||||
T8: 用户B返回错误:优惠券已被其他用户绑定
|
||||
T9: 用户B释放锁
|
||||
```
|
||||
|
||||
**结果**:只有用户A成功绑定优惠券,用户B收到"优惠券已被其他用户绑定"的提示。
|
||||
|
||||
---
|
||||
|
||||
## 七、权利要求书
|
||||
|
||||
### 权利要求1
|
||||
|
||||
一种基于实体二维码的酒店优惠券发放与自动核销系统,其特征在于,包括:
|
||||
|
||||
合作酒店管理模块,用于管理与景区建立合作关系的酒店信息;
|
||||
|
||||
优惠券批量生成模块,用于为指定酒店批量生成带有唯一标识码的优惠券,并为每张优惠券生成对应的二维码图片;
|
||||
|
||||
二维码图片管理模块,用于将二维码图片上传至云存储并支持批量下载,供酒店制作实体二维码投放;
|
||||
|
||||
用户扫码绑定模块,用于处理用户扫描实体二维码后的绑定请求,采用分布式锁机制确保一码只能被一个用户绑定;
|
||||
|
||||
可用优惠券检测模块,用于在用户下单前根据当前景区和设备信息检测是否有可用优惠券;
|
||||
|
||||
自动核销模块,用于在订单创建时自动完成优惠券核销,更新优惠券状态并创建核销记录。
|
||||
|
||||
### 权利要求2
|
||||
|
||||
根据权利要求1所述的系统,其特征在于,所述优惠券批量生成模块支持配置多种优惠券类型,包括免费体验券、折扣券和满减券,并支持配置适用范围包括指定景区和指定设备。
|
||||
|
||||
### 权利要求3
|
||||
|
||||
根据权利要求1所述的系统,其特征在于,所述优惠券批量生成模块支持两种有效期策略:固定时间有效期和绑定后N天有效期,所述用户扫码绑定模块根据有效期策略计算优惠券的实际生效时间。
|
||||
|
||||
### 权利要求4
|
||||
|
||||
根据权利要求1所述的系统,其特征在于,所述用户扫码绑定模块的具体处理过程为:
|
||||
|
||||
解析二维码获取优惠券码;
|
||||
|
||||
获取分布式锁;
|
||||
|
||||
校验优惠券状态,确保未被绑定、未过期、未作废;
|
||||
|
||||
根据有效期策略计算优惠券的实际生效开始时间和结束时间;
|
||||
|
||||
创建优惠券与用户的绑定记录;
|
||||
|
||||
更新优惠券状态为已绑定;
|
||||
|
||||
释放分布式锁。
|
||||
|
||||
### 权利要求5
|
||||
|
||||
根据权利要求1所述的系统,其特征在于,所述自动核销模块在订单创建流程中嵌入核销逻辑,根据优惠券类型计算优惠金额,创建标记为优惠券订单的订单记录,并在订单中记录优惠券标识和优惠金额。
|
||||
|
||||
### 权利要求6
|
||||
|
||||
根据权利要求1所述的系统,其特征在于,还包括:
|
||||
|
||||
过期处理模块,用于定时扫描超过有效期的优惠券,更新未使用的过期优惠券状态和过期的绑定记录状态;
|
||||
|
||||
数据统计模块,用于按酒店、按批次统计优惠券的发放、绑定、使用、过期数量。
|
||||
|
||||
### 权利要求7
|
||||
|
||||
一种基于实体二维码的酒店优惠券发放与自动核销方法,其特征在于,包括以下步骤:
|
||||
|
||||
S1:为合作酒店批量生成带有唯一标识码的优惠券,并为每张优惠券生成对应的二维码图片上传至云存储;
|
||||
|
||||
S2:将二维码图片批量下载并制作成实体二维码投放至酒店;
|
||||
|
||||
S3:用户扫描实体二维码后,系统获取分布式锁,校验优惠券状态后创建用户与优惠券的绑定关系;
|
||||
|
||||
S4:用户在景区设备端下单时,系统检测用户是否有适用于当前景区和设备的可用优惠券;
|
||||
|
||||
S5:若有可用优惠券,创建优惠券订单,根据优惠券类型计算优惠金额,自动完成优惠券核销。
|
||||
|
||||
### 权利要求8
|
||||
|
||||
根据权利要求7所述的方法,其特征在于,步骤S3中获取分布式锁的锁键值为优惠券码,确保同一优惠券在同一时刻只能被一个用户绑定。
|
||||
|
||||
### 权利要求9
|
||||
|
||||
根据权利要求7所述的方法,其特征在于,步骤S3中根据优惠券配置的有效期策略计算实际生效时间:若为固定时间策略,使用配置的有效期;若为绑定后N天策略,以绑定时间为起点计算有效期。
|
||||
|
||||
### 权利要求10
|
||||
|
||||
根据权利要求7所述的方法,其特征在于,步骤S5中自动核销的具体过程为:
|
||||
|
||||
在订单中设置订单类型为优惠券订单;
|
||||
|
||||
根据优惠券类型计算优惠金额和实付金额;
|
||||
|
||||
记录优惠券标识和优惠金额到订单;
|
||||
|
||||
更新优惠券状态和绑定记录状态为已使用;
|
||||
|
||||
创建包含核销详情的核销记录。
|
||||
|
||||
---
|
||||
|
||||
## 八、摘要
|
||||
|
||||
### 说明书摘要
|
||||
|
||||
本发明公开了一种基于实体二维码的酒店优惠券发放与自动核销系统及方法,涉及电子商务与旅游信息化技术领域。系统包括合作酒店管理模块、优惠券批量生成模块、二维码图片管理模块、用户扫码绑定模块、可用优惠券检测模块和自动核销模块。通过为每张优惠券生成唯一标识码和对应二维码,制作成实体二维码投放至酒店,用户扫码后完成绑定,在景区设备端下单时自动检测并核销优惠券。本发明采用分布式锁机制确保一码一用,支持多种优惠券类型和灵活的有效期策略,将核销逻辑嵌入订单创建流程实现自动核销,具有发放效率高、核销自动化、防滥用、数据可追溯等优点。
|
||||
|
||||
### 摘要附图
|
||||
|
||||
(选用图3:核心业务流程图)
|
||||
|
||||
---
|
||||
|
||||
## 九、附加说明
|
||||
|
||||
### 9.1 技术关键点
|
||||
|
||||
1. **一码一用机制**:每个优惠券码全局唯一,通过分布式锁防止并发绑定,确保一个优惠券只能被一个用户使用。
|
||||
|
||||
2. **实体二维码投放**:将数字优惠券转化为实体二维码,无需酒店人员培训,降低合作门槛。
|
||||
|
||||
3. **自动核销集成**:核销逻辑与订单创建流程无缝集成,用户无感知完成核销,提升体验。
|
||||
|
||||
4. **灵活有效期策略**:支持固定时间和绑定后N天两种策略,适应不同营销场景。
|
||||
|
||||
5. **精准适用范围**:可限定优惠券适用的景区和设备,实现精细化营销。
|
||||
|
||||
### 9.2 应用场景
|
||||
|
||||
- 酒店与景区合作营销
|
||||
- 酒店与游乐园合作营销
|
||||
- 民宿与周边景点合作营销
|
||||
- 其他需要线下发放、线上核销的优惠券场景
|
||||
|
||||
### 9.3 技术创新点
|
||||
|
||||
1. 首次提出将实体二维码与一码一用机制结合的酒店优惠券发放方案
|
||||
2. 首次实现优惠券核销与订单创建流程的无缝集成
|
||||
3. 首次提出支持"绑定后N天有效"的动态有效期计算机制
|
||||
4. 首次将分布式锁应用于优惠券绑定场景防止并发滥用
|
||||
|
||||
---
|
||||
|
||||
**申请人**:湖北高飞智航科技有限责任公司
|
||||
|
||||
**发明人**:杜志超
|
||||
|
||||
**申请日期**:2025年12月01日
|
||||
|
||||
**文档版本**:v1.0
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,75 +0,0 @@
|
||||
-- 携程退款功能表结构更新脚本
|
||||
-- 执行前请备份数据
|
||||
|
||||
USE `coupon-center`;
|
||||
|
||||
-- 更新 t_ctrip_refund 表结构(如果表已存在则修改,否则创建)
|
||||
DROP TABLE IF EXISTS `t_ctrip_refund_backup`;
|
||||
|
||||
-- 检查表是否存在,如果存在则备份
|
||||
CREATE TABLE IF NOT EXISTS `t_ctrip_refund_backup` AS SELECT * FROM `t_ctrip_refund` WHERE 1=0;
|
||||
INSERT INTO `t_ctrip_refund_backup` SELECT * FROM `t_ctrip_refund` WHERE 1=1;
|
||||
|
||||
-- 删除旧表并重建
|
||||
DROP TABLE IF EXISTS `t_ctrip_refund`;
|
||||
|
||||
CREATE TABLE `t_ctrip_refund` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键ID',
|
||||
`ota_order_id` varchar(100) NOT NULL COMMENT '携程订单号',
|
||||
`supplier_order_id` varchar(100) DEFAULT NULL COMMENT '供应商订单号',
|
||||
`sequence_id` varchar(100) NOT NULL COMMENT '携程批次流水号',
|
||||
`refund_amount` decimal(10,2) NOT NULL COMMENT '退款金额',
|
||||
`currency` varchar(10) DEFAULT 'CNY' COMMENT '货币类型',
|
||||
`refund_status` int(11) DEFAULT 0 COMMENT '退款状态:0-待确认,1-已确认,2-已拒绝',
|
||||
`confirm_result_code` varchar(50) DEFAULT NULL COMMENT '确认结果码',
|
||||
`confirm_result_message` varchar(500) DEFAULT NULL COMMENT '确认结果信息',
|
||||
`last_confirm_time` datetime DEFAULT NULL COMMENT '最晚确认时间',
|
||||
`create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
`update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||
`create_by` varchar(50) DEFAULT NULL COMMENT '创建人',
|
||||
`update_by` varchar(50) DEFAULT NULL COMMENT '更新人',
|
||||
`remark` varchar(500) DEFAULT NULL COMMENT '备注',
|
||||
`tenant_id` varchar(12) DEFAULT '000000' COMMENT '租户ID',
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `uk_sequence_id` (`sequence_id`),
|
||||
KEY `idx_ota_order_id` (`ota_order_id`),
|
||||
KEY `idx_supplier_order_id` (`supplier_order_id`),
|
||||
KEY `idx_refund_status` (`refund_status`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='携程退款表';
|
||||
|
||||
-- 更新 t_ctrip_refund_item 表结构
|
||||
DROP TABLE IF EXISTS `t_ctrip_refund_item_backup`;
|
||||
|
||||
-- 检查表是否存在,如果存在则备份
|
||||
CREATE TABLE IF NOT EXISTS `t_ctrip_refund_item_backup` AS SELECT * FROM `t_ctrip_refund_item` WHERE 1=0;
|
||||
INSERT INTO `t_ctrip_refund_item_backup` SELECT * FROM `t_ctrip_refund_item` WHERE 1=1;
|
||||
|
||||
-- 删除旧表并重建
|
||||
DROP TABLE IF EXISTS `t_ctrip_refund_item`;
|
||||
|
||||
CREATE TABLE `t_ctrip_refund_item` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键ID',
|
||||
`refund_id` bigint(20) NOT NULL COMMENT '退款ID',
|
||||
`item_id` varchar(100) DEFAULT NULL COMMENT '订单项编号',
|
||||
`plu` varchar(100) DEFAULT NULL COMMENT '供应商产品最小单位',
|
||||
`refund_amount` decimal(10,2) DEFAULT NULL COMMENT '退款金额',
|
||||
`currency` varchar(10) DEFAULT 'CNY' COMMENT '货币类型',
|
||||
`create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
`update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||
`deleted` tinyint(1) DEFAULT 0 COMMENT '是否删除:0-未删除,1-已删除',
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `idx_refund_id` (`refund_id`),
|
||||
KEY `idx_item_id` (`item_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='携程退款项表';
|
||||
|
||||
-- 确保 t_ctrip_order 表有 status 字段(整数类型)
|
||||
-- 订单状态:0-待确认,1-已确认,2-已取消,3-已过期,4-退款中,5-已退款
|
||||
ALTER TABLE `t_ctrip_order`
|
||||
MODIFY COLUMN `status` int(11) DEFAULT 0 COMMENT '订单状态:0-待确认,1-已确认,2-已取消,3-已过期,4-退款中,5-已退款';
|
||||
|
||||
-- 如果 status 字段不存在,则添加
|
||||
-- ALTER TABLE `t_ctrip_order` ADD COLUMN `status` int(11) DEFAULT 0 COMMENT '订单状态:0-待确认,1-已确认,2-已取消,3-已过期,4-退款中,5-已退款';
|
||||
|
||||
-- 清理备份表(可选,确认数据无误后执行)
|
||||
-- DROP TABLE IF EXISTS `t_ctrip_refund_backup`;
|
||||
-- DROP TABLE IF EXISTS `t_ctrip_refund_item_backup`;
|
||||
@@ -11,6 +11,7 @@ import org.springframework.stereotype.Component;
|
||||
@Component
|
||||
@ConfigurationProperties(prefix = "ctrip")
|
||||
public class CtripApiConfig {
|
||||
|
||||
/**
|
||||
* AES加密配置
|
||||
*/
|
||||
|
||||
-123
@@ -1,123 +0,0 @@
|
||||
package com.central.coupon.config;
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 携程分销商配置
|
||||
*/
|
||||
@Data
|
||||
@Component
|
||||
@ConfigurationProperties(prefix = "ctrip.distributor")
|
||||
public class CtripDistributorConfig {
|
||||
|
||||
/**
|
||||
* 分销商AID
|
||||
*/
|
||||
private Long aid;
|
||||
|
||||
/**
|
||||
* 分销商SID
|
||||
*/
|
||||
private Long sid;
|
||||
|
||||
/**
|
||||
* 分销商密钥
|
||||
*/
|
||||
private String key;
|
||||
|
||||
/**
|
||||
* 认证URL
|
||||
*/
|
||||
private String authUrl;
|
||||
|
||||
/**
|
||||
* 刷新Token URL
|
||||
*/
|
||||
private String refreshUrl;
|
||||
|
||||
/**
|
||||
* 业务API URL
|
||||
*/
|
||||
private String apiUrl;
|
||||
|
||||
/**
|
||||
* 语言地区
|
||||
*/
|
||||
private String locale;
|
||||
|
||||
/**
|
||||
* 货币代码
|
||||
*/
|
||||
private String currency;
|
||||
|
||||
/**
|
||||
* 各接口icode配置
|
||||
*/
|
||||
private IcodeConfig icode;
|
||||
|
||||
@Data
|
||||
public static class IcodeConfig {
|
||||
|
||||
/**
|
||||
* 产品详情接口icode
|
||||
*/
|
||||
private String productDetail;
|
||||
|
||||
/**
|
||||
* 获取下单填写信息接口icode
|
||||
*/
|
||||
private String bookInfo;
|
||||
|
||||
/**
|
||||
* 创建订单接口icode
|
||||
*/
|
||||
private String book;
|
||||
|
||||
/**
|
||||
* 取消验证接口icode
|
||||
*/
|
||||
private String cancelVerify;
|
||||
|
||||
/**
|
||||
* 取消订单接口icode
|
||||
*/
|
||||
private String cancel;
|
||||
|
||||
/**
|
||||
* 订单详情查询接口icode
|
||||
*/
|
||||
private String bookingDetail;
|
||||
|
||||
/**
|
||||
* 可订检查接口icode
|
||||
*/
|
||||
private String checkAvailability;
|
||||
|
||||
/**
|
||||
* 沙箱测试-订单退订(携程发起)接口icode
|
||||
*/
|
||||
private String simulateCancel;
|
||||
|
||||
/**
|
||||
* 沙箱测试-人工出票/退订确认/凭证变更接口icode
|
||||
*/
|
||||
private String simulateConfirm;
|
||||
|
||||
/**
|
||||
* 产品列表接口icode
|
||||
*/
|
||||
private String productList;
|
||||
|
||||
/**
|
||||
* 位置列表接口icode
|
||||
*/
|
||||
private String locationList;
|
||||
|
||||
/**
|
||||
* 产品全量列表接口icode
|
||||
*/
|
||||
private String allProducts;
|
||||
}
|
||||
}
|
||||
-334
@@ -1,334 +0,0 @@
|
||||
package com.central.coupon.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.central.common.model.Result;
|
||||
import com.central.coupon.entity.CtripContact;
|
||||
import com.central.coupon.entity.CtripOrder;
|
||||
import com.central.coupon.entity.CtripRefund;
|
||||
import com.central.coupon.enums.CtripOrderStatus;
|
||||
import com.central.coupon.mapper.CtripContactMapper;
|
||||
import com.central.coupon.mapper.CtripOrderMapper;
|
||||
import com.central.coupon.mapper.CtripRefundMapper;
|
||||
import com.central.coupon.model.CtripAdminRefundRequest;
|
||||
import com.central.coupon.service.ICtripAdminRefundService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 携程管理后台退款控制器
|
||||
* 用于管理后台发起携程订单退款
|
||||
*/
|
||||
@Slf4j
|
||||
@Tag(name = "携程管理后台退款接口")
|
||||
@RestController
|
||||
@RequestMapping("/coupon/ctrip/admin/refund")
|
||||
public class CtripAdminRefundController {
|
||||
|
||||
@Autowired
|
||||
private ICtripAdminRefundService ctripAdminRefundService;
|
||||
|
||||
@Autowired
|
||||
private CtripOrderMapper ctripOrderMapper;
|
||||
|
||||
@Autowired
|
||||
private CtripRefundMapper ctripRefundMapper;
|
||||
|
||||
@Autowired
|
||||
private CtripContactMapper ctripContactMapper;
|
||||
|
||||
/**
|
||||
* 管理后台发起携程退款
|
||||
*/
|
||||
@Operation(summary = "管理后台发起携程退款")
|
||||
@PostMapping("/apply")
|
||||
public Result<String> applyRefund(@RequestBody CtripAdminRefundRequest request) {
|
||||
log.info("管理后台发起携程退款请求,orderNo: {}, refundAmount: {}",
|
||||
request.getOrderNo(), request.getRefundAmount());
|
||||
|
||||
try {
|
||||
return ctripAdminRefundService.processAdminRefund(request);
|
||||
} catch (Exception e) {
|
||||
log.error("管理后台携程退款异常,orderNo: {}", request.getOrderNo(), e);
|
||||
return Result.failed("退款处理异常: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取可退金额
|
||||
*/
|
||||
@Operation(summary = "获取订单可退金额")
|
||||
@GetMapping("/available/{orderNo}")
|
||||
public Result<Map<String, Object>> getAvailableRefundAmount(
|
||||
@Parameter(description = "订单中心订单号") @PathVariable String orderNo) {
|
||||
log.info("获取订单可退金额,orderNo: {}", orderNo);
|
||||
|
||||
try {
|
||||
// 根据orderNo查询携程订单
|
||||
CtripOrder ctripOrder = ctripOrderMapper.selectByOrderNo(orderNo);
|
||||
if (ctripOrder == null) {
|
||||
return Result.failed("未找到关联的携程订单");
|
||||
}
|
||||
|
||||
BigDecimal availableAmount = ctripAdminRefundService.getAvailableRefundAmount(orderNo);
|
||||
boolean canRefund = ctripAdminRefundService.canRefund(orderNo);
|
||||
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
result.put("orderNo", orderNo);
|
||||
result.put("otaOrderId", ctripOrder.getOtaOrderId());
|
||||
result.put("totalAmount", ctripOrder.getTotalAmount());
|
||||
result.put("availableRefundAmount", availableAmount);
|
||||
result.put("canRefund", canRefund);
|
||||
result.put("orderStatus", ctripOrder.getStatus());
|
||||
result.put("orderStatusDesc", getOrderStatusDesc(ctripOrder.getStatus()));
|
||||
|
||||
return Result.succeed(result);
|
||||
} catch (Exception e) {
|
||||
log.error("获取可退金额异常,orderNo: {}", orderNo, e);
|
||||
return Result.failed("获取可退金额异常: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查订单是否可退款
|
||||
*/
|
||||
@Operation(summary = "检查订单是否可退款")
|
||||
@GetMapping("/check/{orderNo}")
|
||||
public Result<Map<String, Object>> checkCanRefund(
|
||||
@Parameter(description = "订单中心订单号") @PathVariable String orderNo) {
|
||||
log.info("检查订单是否可退款,orderNo: {}", orderNo);
|
||||
|
||||
try {
|
||||
CtripOrder ctripOrder = ctripOrderMapper.selectByOrderNo(orderNo);
|
||||
if (ctripOrder == null) {
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
result.put("orderNo", orderNo);
|
||||
result.put("canRefund", false);
|
||||
result.put("reason", "未找到关联的携程订单");
|
||||
return Result.succeed(result);
|
||||
}
|
||||
|
||||
boolean canRefund = ctripAdminRefundService.canRefund(orderNo);
|
||||
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
result.put("orderNo", orderNo);
|
||||
result.put("otaOrderId", ctripOrder.getOtaOrderId());
|
||||
result.put("canRefund", canRefund);
|
||||
result.put("orderStatus", ctripOrder.getStatus());
|
||||
result.put("orderStatusDesc", getOrderStatusDesc(ctripOrder.getStatus()));
|
||||
if (!canRefund) {
|
||||
result.put("reason", "订单状态不支持退款,当前状态: " + getOrderStatusDesc(ctripOrder.getStatus()));
|
||||
}
|
||||
|
||||
return Result.succeed(result);
|
||||
} catch (Exception e) {
|
||||
log.error("检查订单是否可退款异常,orderNo: {}", orderNo, e);
|
||||
return Result.failed("检查失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询退款记录
|
||||
*/
|
||||
@Operation(summary = "查询订单退款记录")
|
||||
@GetMapping("/records/{orderNo}")
|
||||
public Result<List<CtripRefund>> getRefundRecords(
|
||||
@Parameter(description = "订单中心订单号") @PathVariable String orderNo) {
|
||||
log.info("查询订单退款记录,orderNo: {}", orderNo);
|
||||
|
||||
try {
|
||||
// 根据orderNo查询携程订单
|
||||
CtripOrder ctripOrder = ctripOrderMapper.selectByOrderNo(orderNo);
|
||||
if (ctripOrder == null) {
|
||||
return Result.failed("未找到关联的携程订单");
|
||||
}
|
||||
|
||||
List<CtripRefund> refunds = ctripRefundMapper.selectByOtaOrderId(ctripOrder.getOtaOrderId());
|
||||
return Result.succeed(refunds);
|
||||
} catch (Exception e) {
|
||||
log.error("查询退款记录异常,orderNo: {}", orderNo, e);
|
||||
return Result.failed("查询失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取订单状态描述
|
||||
*/
|
||||
private String getOrderStatusDesc(Integer status) {
|
||||
if (status == null) {
|
||||
return "未知";
|
||||
}
|
||||
try {
|
||||
return CtripOrderStatus.fromNumericValue(status).getDescription();
|
||||
} catch (IllegalArgumentException e) {
|
||||
return "未知状态";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取退款状态描述
|
||||
*/
|
||||
private String getRefundStatusDesc(Integer status) {
|
||||
if (status == null) {
|
||||
return "未知";
|
||||
}
|
||||
switch (status) {
|
||||
case 0:
|
||||
return "待确认";
|
||||
case 1:
|
||||
return "已确认";
|
||||
case 2:
|
||||
return "已拒绝";
|
||||
default:
|
||||
return "未知状态";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询携程订单列表
|
||||
*/
|
||||
@Operation(summary = "分页查询携程订单列表")
|
||||
@GetMapping("/orders")
|
||||
public Result<Map<String, Object>> getCtripOrderList(
|
||||
@Parameter(description = "页码") @RequestParam(defaultValue = "1") Integer page,
|
||||
@Parameter(description = "每页数量") @RequestParam(defaultValue = "20") Integer limit,
|
||||
@Parameter(description = "携程订单号") @RequestParam(required = false) String otaOrderId,
|
||||
@Parameter(description = "关联订单号") @RequestParam(required = false) String orderNo,
|
||||
@Parameter(description = "订单状态") @RequestParam(required = false) Integer status,
|
||||
@Parameter(description = "联系人姓名") @RequestParam(required = false) String contactName,
|
||||
@Parameter(description = "联系人手机号") @RequestParam(required = false) String contactMobile) {
|
||||
log.info("分页查询携程订单列表,page: {}, limit: {}, otaOrderId: {}, orderNo: {}, status: {}, contactName: {}, contactMobile: {}",
|
||||
page, limit, otaOrderId, orderNo, status, contactName, contactMobile);
|
||||
|
||||
try {
|
||||
LambdaQueryWrapper<CtripOrder> queryWrapper = new LambdaQueryWrapper<>();
|
||||
if (StringUtils.hasText(otaOrderId)) {
|
||||
queryWrapper.like(CtripOrder::getOtaOrderId, otaOrderId);
|
||||
}
|
||||
if (StringUtils.hasText(orderNo)) {
|
||||
queryWrapper.like(CtripOrder::getOrderNo, orderNo);
|
||||
}
|
||||
if (status != null) {
|
||||
queryWrapper.eq(CtripOrder::getStatus, status);
|
||||
}
|
||||
queryWrapper.orderByDesc(CtripOrder::getCreateTime);
|
||||
|
||||
Page<CtripOrder> pageParam = new Page<>(page, limit);
|
||||
IPage<CtripOrder> pageResult = ctripOrderMapper.selectPage(pageParam, queryWrapper);
|
||||
|
||||
// 关联查询联系人信息
|
||||
List<Map<String, Object>> dataWithContact = new ArrayList<>();
|
||||
for (CtripOrder order : pageResult.getRecords()) {
|
||||
Map<String, Object> orderMap = new HashMap<>();
|
||||
orderMap.put("id", order.getId());
|
||||
orderMap.put("otaOrderId", order.getOtaOrderId());
|
||||
orderMap.put("orderNo", order.getOrderNo());
|
||||
orderMap.put("supplierOrderId", order.getSupplierOrderId());
|
||||
orderMap.put("sequenceId", order.getSequenceId());
|
||||
orderMap.put("confirmType", order.getConfirmType());
|
||||
orderMap.put("orderLastConfirmTime", order.getOrderLastConfirmTime());
|
||||
orderMap.put("status", order.getStatus());
|
||||
orderMap.put("totalAmount", order.getTotalAmount());
|
||||
orderMap.put("currency", order.getCurrency());
|
||||
orderMap.put("createTime", order.getCreateTime());
|
||||
orderMap.put("updateTime", order.getUpdateTime());
|
||||
orderMap.put("remark", order.getRemark());
|
||||
orderMap.put("tenantId", order.getTenantId());
|
||||
|
||||
// 查询联系人信息
|
||||
List<CtripContact> contacts = ctripContactMapper.selectByOrderId(order.getId());
|
||||
if (contacts != null && !contacts.isEmpty()) {
|
||||
CtripContact contact = contacts.get(0); // 取第一个联系人
|
||||
orderMap.put("contactName", contact.getName());
|
||||
orderMap.put("contactMobile", contact.getMobile());
|
||||
orderMap.put("contactEmail", contact.getEmail());
|
||||
} else {
|
||||
orderMap.put("contactName", null);
|
||||
orderMap.put("contactMobile", null);
|
||||
orderMap.put("contactEmail", null);
|
||||
}
|
||||
|
||||
// 如果有联系人筛选条件,进行过滤
|
||||
if (StringUtils.hasText(contactName) || StringUtils.hasText(contactMobile)) {
|
||||
String name = (String) orderMap.get("contactName");
|
||||
String mobile = (String) orderMap.get("contactMobile");
|
||||
boolean matchName = !StringUtils.hasText(contactName) || (name != null && name.contains(contactName));
|
||||
boolean matchMobile = !StringUtils.hasText(contactMobile) || (mobile != null && mobile.contains(contactMobile));
|
||||
if (matchName && matchMobile) {
|
||||
dataWithContact.add(orderMap);
|
||||
}
|
||||
} else {
|
||||
dataWithContact.add(orderMap);
|
||||
}
|
||||
}
|
||||
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
result.put("data", dataWithContact);
|
||||
// 如果有联系人筛选,总数需要重新计算(简化处理,返回当前页数量)
|
||||
result.put("count", (StringUtils.hasText(contactName) || StringUtils.hasText(contactMobile))
|
||||
? dataWithContact.size() : pageResult.getTotal());
|
||||
result.put("page", page);
|
||||
result.put("limit", limit);
|
||||
|
||||
return Result.succeed(result);
|
||||
} catch (Exception e) {
|
||||
log.error("查询携程订单列表异常", e);
|
||||
return Result.failed("查询失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询携程退款列表
|
||||
*/
|
||||
@Operation(summary = "分页查询携程退款列表")
|
||||
@GetMapping("/refunds")
|
||||
public Result<Map<String, Object>> getCtripRefundList(
|
||||
@Parameter(description = "页码") @RequestParam(defaultValue = "1") Integer page,
|
||||
@Parameter(description = "每页数量") @RequestParam(defaultValue = "20") Integer limit,
|
||||
@Parameter(description = "携程订单号") @RequestParam(required = false) String otaOrderId,
|
||||
@Parameter(description = "供应商订单号") @RequestParam(required = false) String supplierOrderId,
|
||||
@Parameter(description = "退款状态") @RequestParam(required = false) Integer refundStatus) {
|
||||
log.info("分页查询携程退款列表,page: {}, limit: {}, otaOrderId: {}, supplierOrderId: {}, refundStatus: {}",
|
||||
page, limit, otaOrderId, supplierOrderId, refundStatus);
|
||||
|
||||
try {
|
||||
LambdaQueryWrapper<CtripRefund> queryWrapper = new LambdaQueryWrapper<>();
|
||||
if (StringUtils.hasText(otaOrderId)) {
|
||||
queryWrapper.like(CtripRefund::getOtaOrderId, otaOrderId);
|
||||
}
|
||||
if (StringUtils.hasText(supplierOrderId)) {
|
||||
queryWrapper.like(CtripRefund::getSupplierOrderId, supplierOrderId);
|
||||
}
|
||||
if (refundStatus != null) {
|
||||
queryWrapper.eq(CtripRefund::getRefundStatus, refundStatus);
|
||||
}
|
||||
queryWrapper.orderByDesc(CtripRefund::getCreateTime);
|
||||
|
||||
Page<CtripRefund> pageParam = new Page<>(page, limit);
|
||||
IPage<CtripRefund> pageResult = ctripRefundMapper.selectPage(pageParam, queryWrapper);
|
||||
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
result.put("data", pageResult.getRecords());
|
||||
result.put("count", pageResult.getTotal());
|
||||
result.put("page", page);
|
||||
result.put("limit", limit);
|
||||
|
||||
return Result.succeed(result);
|
||||
} catch (Exception e) {
|
||||
log.error("查询携程退款列表异常", e);
|
||||
return Result.failed("查询失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
-293
@@ -1,293 +0,0 @@
|
||||
package com.central.coupon.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.central.common.model.Result;
|
||||
import com.central.coupon.entity.CtripContact;
|
||||
import com.central.coupon.entity.CtripDistOrder;
|
||||
import com.central.coupon.entity.CtripOrder;
|
||||
import com.central.coupon.entity.CtripOrderItem;
|
||||
import com.central.coupon.mapper.CtripContactMapper;
|
||||
import com.central.coupon.mapper.CtripDistOrderMapper;
|
||||
import com.central.coupon.mapper.CtripOrderItemMapper;
|
||||
import com.central.coupon.mapper.CtripOrderMapper;
|
||||
import com.central.coupon.model.CtripConsumedNoticeResponse;
|
||||
import com.central.coupon.service.CtripConsumedService;
|
||||
import com.central.coupon.service.ICtripDistOrderService;
|
||||
import com.central.coupon.service.IOrderDetailService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/ctrip/dist/order")
|
||||
@Tag(name = "携程分销订单管理")
|
||||
public class CtripDistOrderController {
|
||||
|
||||
@Autowired
|
||||
private ICtripDistOrderService ctripDistOrderService;
|
||||
|
||||
@Autowired
|
||||
private CtripDistOrderMapper ctripDistOrderMapper;
|
||||
|
||||
@Autowired
|
||||
private CtripContactMapper ctripContactMapper;
|
||||
|
||||
@Autowired
|
||||
private CtripOrderMapper ctripOrderMapper;
|
||||
|
||||
@Autowired
|
||||
private CtripOrderItemMapper ctripOrderItemMapper;
|
||||
|
||||
@Autowired
|
||||
private CtripConsumedService ctripConsumedService;
|
||||
|
||||
@Autowired
|
||||
private IOrderDetailService orderDetailService;
|
||||
|
||||
/**
|
||||
* 分页查询携程分销订单列表
|
||||
*/
|
||||
@Operation(summary = "分页查询携程分销订单列表")
|
||||
@GetMapping("/list")
|
||||
public Result<Map<String, Object>> listCtripDistOrders(
|
||||
@Parameter(description = "页码") @RequestParam(defaultValue = "1") Integer page,
|
||||
@Parameter(description = "每页数量") @RequestParam(defaultValue = "20") Integer limit,
|
||||
@Parameter(description = "本地订单号") @RequestParam(required = false) String orderNo,
|
||||
@Parameter(description = "携程订单ID") @RequestParam(required = false) Long ctripOrderId,
|
||||
@Parameter(description = "携程产品ID") @RequestParam(required = false) Long ctripProductId,
|
||||
@Parameter(description = "携程订单状态") @RequestParam(required = false) String ctripOrderStatus,
|
||||
@Parameter(description = "核销状态") @RequestParam(required = false) Integer consumeStatus,
|
||||
@Parameter(description = "退款状态") @RequestParam(required = false) Integer refundStatus,
|
||||
@Parameter(description = "租户ID") @RequestParam(required = false) String tenantId) {
|
||||
log.info("分页查询携程分销订单列表,page: {}, limit: {}, orderNo: {}", page, limit, orderNo);
|
||||
try {
|
||||
LambdaQueryWrapper<CtripDistOrder> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(CtripDistOrder::getDeleted, 0);
|
||||
if (StringUtils.hasText(orderNo)) {
|
||||
queryWrapper.like(CtripDistOrder::getOrderNo, orderNo);
|
||||
}
|
||||
if (ctripOrderId != null) {
|
||||
queryWrapper.eq(CtripDistOrder::getCtripOrderId, ctripOrderId);
|
||||
}
|
||||
if (ctripProductId != null) {
|
||||
queryWrapper.eq(CtripDistOrder::getCtripProductId, ctripProductId);
|
||||
}
|
||||
if (StringUtils.hasText(ctripOrderStatus)) {
|
||||
queryWrapper.eq(CtripDistOrder::getCtripOrderStatus, ctripOrderStatus);
|
||||
}
|
||||
if (consumeStatus != null) {
|
||||
queryWrapper.eq(CtripDistOrder::getConsumeStatus, consumeStatus);
|
||||
}
|
||||
if (refundStatus != null) {
|
||||
queryWrapper.eq(CtripDistOrder::getRefundStatus, refundStatus);
|
||||
}
|
||||
if (StringUtils.hasText(tenantId)) {
|
||||
queryWrapper.eq(CtripDistOrder::getTenantId, tenantId);
|
||||
}
|
||||
queryWrapper.orderByDesc(CtripDistOrder::getCreateTime);
|
||||
|
||||
Page<CtripDistOrder> pageParam = new Page<>(page, limit);
|
||||
IPage<CtripDistOrder> pageResult = ctripDistOrderMapper.selectPage(pageParam, queryWrapper);
|
||||
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
result.put("data", pageResult.getRecords());
|
||||
result.put("count", pageResult.getTotal());
|
||||
result.put("page", page);
|
||||
result.put("limit", limit);
|
||||
return Result.succeed(result);
|
||||
} catch (Exception e) {
|
||||
log.error("查询携程分销订单列表异常", e);
|
||||
return Result.failed("查询失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建携程分销订单(被order-center通过Feign调用)
|
||||
*/
|
||||
@PostMapping("/create")
|
||||
public Result<String> createCtripDistOrder(@RequestBody Map<String, Object> params) {
|
||||
String orderNo = (String) params.get("orderNo");
|
||||
String orderAmount = (String) params.get("orderAmount");
|
||||
Long ctripProductId = Long.valueOf(params.get("ctripProductId").toString());
|
||||
String tenantId = (String) params.get("tenantId");
|
||||
String mobile = params.get("mobile") != null ? params.get("mobile").toString() : null;
|
||||
if (mobile == null || mobile.isEmpty()) {
|
||||
String[] prefixes = {"130","131","132","133","134","135","136","137","138","139",
|
||||
"150","151","152","153","155","156","157","158","159",
|
||||
"170","171","172","173","175","176","177","178",
|
||||
"180","181","182","183","184","185","186","187","188","189",
|
||||
"191","193","195","196","197","198","199"};
|
||||
String prefix = prefixes[ThreadLocalRandom.current().nextInt(prefixes.length)];
|
||||
mobile = prefix + String.format("%08d", ThreadLocalRandom.current().nextInt(100000000));
|
||||
}
|
||||
|
||||
try {
|
||||
ctripDistOrderService.createCtripDistOrder(orderNo, orderAmount, ctripProductId, tenantId, mobile);
|
||||
return Result.succeed("携程分销订单创建成功");
|
||||
} catch (Exception e) {
|
||||
log.error("创建携程分销订单失败", e);
|
||||
return Result.failed("创建失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 退订携程分销订单
|
||||
*/
|
||||
@PostMapping("/cancel/{orderNo}")
|
||||
public Result<String> cancelCtripDistOrder(
|
||||
@PathVariable String orderNo,
|
||||
@RequestParam(defaultValue = "用户申请退订") String reason) {
|
||||
boolean success = ctripDistOrderService.cancelCtripDistOrder(orderNo, reason);
|
||||
return success ? Result.succeed("退订成功") : Result.failed("退订失败");
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询携程分销订单详情
|
||||
*/
|
||||
@GetMapping("/{orderNo}")
|
||||
public Result<CtripDistOrder> getCtripDistOrder(@PathVariable String orderNo) {
|
||||
return Result.succeed(ctripDistOrderService.getByOrderNo(orderNo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 手动核销携程分销订单
|
||||
*/
|
||||
@Operation(summary = "手动核销携程分销订单")
|
||||
@PostMapping("/consume/{ctripOrderId}")
|
||||
public Result<String> consumeCtripDistOrder(
|
||||
@Parameter(description = "携程订单ID") @PathVariable Long ctripOrderId) {
|
||||
log.info("手动核销携程分销订单,ctripOrderId: {}", ctripOrderId);
|
||||
try {
|
||||
// 1. 查找CtripDistOrder
|
||||
LambdaQueryWrapper<CtripDistOrder> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(CtripDistOrder::getCtripOrderId, ctripOrderId)
|
||||
.eq(CtripDistOrder::getDeleted, 0);
|
||||
CtripDistOrder distOrder = ctripDistOrderMapper.selectOne(queryWrapper);
|
||||
if (distOrder == null) {
|
||||
return Result.failed("未找到携程分销订单,ctripOrderId: " + ctripOrderId);
|
||||
}
|
||||
if (distOrder.getConsumeStatus() != null && distOrder.getConsumeStatus() == 1) {
|
||||
return Result.failed("该订单已核销,无需重复核销");
|
||||
}
|
||||
|
||||
// 2. 获取手机号,根据手机号通过联系人表查找CtripOrder
|
||||
String mobile = distOrder.getMobile();
|
||||
if (mobile == null || mobile.isEmpty()) {
|
||||
return Result.failed("分销订单手机号为空,无法核销");
|
||||
}
|
||||
|
||||
List<CtripContact> contacts = ctripContactMapper.selectByMobile(mobile);
|
||||
if (contacts == null || contacts.isEmpty()) {
|
||||
distOrder.setConsumeStatus(2);
|
||||
distOrder.setErrorMsg("未找到手机号对应的携程联系人记录");
|
||||
ctripDistOrderMapper.updateById(distOrder);
|
||||
return Result.failed("未找到手机号对应的携程联系人记录");
|
||||
}
|
||||
|
||||
List<Long> orderIds = contacts.stream()
|
||||
.map(CtripContact::getOrderId)
|
||||
.distinct()
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// 筛选状态为PAYMENT_CONFIRMED(13)的订单
|
||||
List<CtripOrder> confirmedOrders = new ArrayList<>();
|
||||
for (Long orderId : orderIds) {
|
||||
CtripOrder ctripOrder = ctripOrderMapper.selectById(orderId);
|
||||
if (ctripOrder != null && Integer.valueOf(13).equals(ctripOrder.getStatus())) {
|
||||
confirmedOrders.add(ctripOrder);
|
||||
}
|
||||
}
|
||||
|
||||
if (confirmedOrders.isEmpty()) {
|
||||
distOrder.setConsumeStatus(2);
|
||||
distOrder.setErrorMsg("未找到状态为PAYMENT_CONFIRMED的携程订单");
|
||||
ctripDistOrderMapper.updateById(distOrder);
|
||||
return Result.failed("未找到状态为PAYMENT_CONFIRMED的携程订单");
|
||||
}
|
||||
|
||||
// 3. 对每个符合条件的CtripOrder执行核销
|
||||
boolean anySuccess = false;
|
||||
StringBuilder errorMsgs = new StringBuilder();
|
||||
|
||||
for (CtripOrder ctripOrder : confirmedOrders) {
|
||||
try {
|
||||
// 建立订单关联关系
|
||||
if (ctripOrder.getOrderNo() == null || ctripOrder.getOrderNo().trim().isEmpty()) {
|
||||
ctripOrder.setOrderNo(distOrder.getOrderNo());
|
||||
ctripOrderMapper.updateById(ctripOrder);
|
||||
}
|
||||
|
||||
if (!orderDetailService.validateOrderForConsume(ctripOrder.getOtaOrderId())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
List<CtripOrderItem> orderItems = ctripOrderItemMapper.selectByOrderId(ctripOrder.getId());
|
||||
if (orderItems == null || orderItems.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (CtripOrderItem item : orderItems) {
|
||||
if (item.getQuantity() == null || item.getQuantity() <= 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
CtripConsumedController.CtripConsumeRequest request = new CtripConsumedController.CtripConsumeRequest();
|
||||
request.setOtaOrderId(ctripOrder.getOtaOrderId());
|
||||
request.setSupplierOrderId(ctripOrder.getSupplierOrderId());
|
||||
request.setItemId(item.getItemId());
|
||||
request.setUseQuantity(item.getQuantity());
|
||||
request.setRemark("手动核销分销订单,orderNo: " + distOrder.getOrderNo());
|
||||
|
||||
CtripConsumedNoticeResponse response = ctripConsumedService.consumeOrder(request);
|
||||
boolean success = response != null && "0000".equals(response.getHeader().getResultCode());
|
||||
|
||||
if (success) {
|
||||
anySuccess = true;
|
||||
} else {
|
||||
String errMsg = response != null ? response.getHeader().getResultMessage() : "未知错误";
|
||||
errorMsgs.append("otaOrderId=").append(ctripOrder.getOtaOrderId())
|
||||
.append(",itemId=").append(item.getItemId())
|
||||
.append(":").append(errMsg).append("; ");
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
errorMsgs.append("otaOrderId=").append(ctripOrder.getOtaOrderId())
|
||||
.append(":").append(e.getMessage()).append("; ");
|
||||
}
|
||||
}
|
||||
|
||||
// 4. 更新CtripDistOrder状态
|
||||
if (anySuccess) {
|
||||
distOrder.setConsumeStatus(1);
|
||||
distOrder.setConsumeTime(LocalDateTime.now());
|
||||
distOrder.setCtripOrderStatus("CONSUMED");
|
||||
distOrder.setErrorMsg(errorMsgs.length() > 0 ? "部分核销异常: " + errorMsgs : null);
|
||||
ctripDistOrderMapper.updateById(distOrder);
|
||||
return Result.succeed("核销成功");
|
||||
} else {
|
||||
distOrder.setConsumeStatus(2);
|
||||
distOrder.setErrorMsg(errorMsgs.length() > 0 ? errorMsgs.toString() : "所有订单核销均失败");
|
||||
ctripDistOrderMapper.updateById(distOrder);
|
||||
return Result.failed("核销失败: " + distOrder.getErrorMsg());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("手动核销携程分销订单异常,ctripOrderId: {}", ctripOrderId, e);
|
||||
return Result.failed("核销异常: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
-919
@@ -1,919 +0,0 @@
|
||||
package com.central.coupon.controller;
|
||||
|
||||
import com.central.common.model.Result;
|
||||
import com.central.coupon.model.CtripDistBookRequest;
|
||||
import com.central.coupon.model.CtripDistBookResponse;
|
||||
import com.central.coupon.model.CtripDistBookingDetailResponse;
|
||||
import com.central.coupon.model.CtripDistCancelResponse;
|
||||
import com.central.coupon.model.CtripDistCancelVerifyResponse;
|
||||
import com.central.coupon.service.ICtripDistApiService;
|
||||
import com.central.coupon.service.ICtripDistTokenService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
/**
|
||||
* 携程分销商接口沙箱测试
|
||||
* 用途:逐个调试携程分销商API,确认连通性和返回格式
|
||||
* 注意:仅用于测试环境,生产环境应禁用或加权限控制
|
||||
*
|
||||
* 核心设计:
|
||||
* - 调用 bookInfo 接口后,问卷模板按 productId 缓存
|
||||
* - 后续的可订检查/创建订单自动从缓存中取问卷模板
|
||||
* - 用户只需传 questionCode → 答案值,系统自动匹配 questionID/questionTitle
|
||||
* - 不同产品的测试步骤差异(字段不同、数量不同)全部通过参数控制
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/ctrip/dist/test")
|
||||
@Tag(name = "携程分销商接口测试")
|
||||
public class CtripDistTestController {
|
||||
|
||||
@Autowired
|
||||
private ICtripDistApiService ctripDistApiService;
|
||||
|
||||
@Autowired
|
||||
private ICtripDistTokenService ctripDistTokenService;
|
||||
|
||||
@Autowired
|
||||
private com.central.coupon.config.CtripDistributorConfig ctripDistributorConfig;
|
||||
|
||||
/**
|
||||
* bookInfo 缓存:key=productId, value=bookInfo完整返回
|
||||
* 调用 bookInfo 接口后自动缓存,后续接口直接使用
|
||||
*/
|
||||
private final Map<Long, Map<String, Object>> bookInfoCache = new ConcurrentHashMap<>();
|
||||
|
||||
// ==================== -1. 配置诊断 ====================
|
||||
|
||||
/**
|
||||
* 诊断当前分销商配置
|
||||
* 用途:确认Nacos配置是否被正确注入(key脱敏显示)
|
||||
*
|
||||
* 调用示例:GET /ctrip/dist/test/config
|
||||
*/
|
||||
@GetMapping("/config")
|
||||
@Operation(summary = "诊断分销商配置")
|
||||
public Result<Map<String, Object>> testConfig() {
|
||||
Map<String, Object> data = new LinkedHashMap<>();
|
||||
data.put("aid", ctripDistributorConfig.getAid());
|
||||
data.put("sid", ctripDistributorConfig.getSid());
|
||||
data.put("key", ctripDistributorConfig.getKey() != null
|
||||
? ctripDistributorConfig.getKey().substring(0, Math.min(4, ctripDistributorConfig.getKey().length())) + "****"
|
||||
: "null");
|
||||
data.put("authUrl", ctripDistributorConfig.getAuthUrl());
|
||||
data.put("refreshUrl", ctripDistributorConfig.getRefreshUrl());
|
||||
data.put("apiUrl", ctripDistributorConfig.getApiUrl());
|
||||
data.put("locale", ctripDistributorConfig.getLocale());
|
||||
data.put("currency", ctripDistributorConfig.getCurrency());
|
||||
if (ctripDistributorConfig.getIcode() != null) {
|
||||
Map<String, Object> icode = new LinkedHashMap<>();
|
||||
icode.put("productDetail", ctripDistributorConfig.getIcode().getProductDetail());
|
||||
icode.put("bookInfo", ctripDistributorConfig.getIcode().getBookInfo());
|
||||
icode.put("book", ctripDistributorConfig.getIcode().getBook());
|
||||
icode.put("cancelVerify", ctripDistributorConfig.getIcode().getCancelVerify());
|
||||
icode.put("cancel", ctripDistributorConfig.getIcode().getCancel());
|
||||
icode.put("bookingDetail", ctripDistributorConfig.getIcode().getBookingDetail());
|
||||
icode.put("allProducts",ctripDistributorConfig.getIcode().getAllProducts());
|
||||
data.put("icode", icode);
|
||||
} else {
|
||||
data.put("icode", "null - icode未配置!");
|
||||
}
|
||||
return Result.succeed(data, "当前分销商配置");
|
||||
}
|
||||
|
||||
// ==================== 0. Token测试 ====================
|
||||
|
||||
/**
|
||||
* 测试获取Token
|
||||
* 用途:验证aid/sid/key配置是否正确,Token能否正常获取
|
||||
*
|
||||
* 调用示例:POST /ctrip/dist/test/token
|
||||
*/
|
||||
@PostMapping("/token")
|
||||
@Operation(summary = "测试获取Token")
|
||||
public Result<Map<String, Object>> testGetToken() {
|
||||
log.info("===== 测试获取携程分销商Token =====");
|
||||
try {
|
||||
String token = ctripDistTokenService.getAccessToken();
|
||||
Map<String, Object> data = new LinkedHashMap<>();
|
||||
data.put("accessToken", token);
|
||||
data.put("tokenLength", token != null ? token.length() : 0);
|
||||
data.put("message", "Token获取成功");
|
||||
log.info("Token获取成功,长度: {}", token != null ? token.length() : 0);
|
||||
return Result.succeed(data, "Token获取成功");
|
||||
} catch (Exception e) {
|
||||
log.error("Token获取失败", e);
|
||||
return Result.failed("Token获取失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
// ==================== 1. 获取产品详情 ====================
|
||||
|
||||
/**
|
||||
* 测试获取产品详情
|
||||
* 用途:根据productId获取产品信息,包含packageID和resourceID
|
||||
* 后续下单需要用到返回的packageID和resourceID
|
||||
*
|
||||
* 调用示例:GET /ctrip/dist/test/product-detail?productId=12345678
|
||||
*/
|
||||
@GetMapping("/product-detail")
|
||||
@Operation(summary = "1.获取产品详情")
|
||||
public Result<Map<String, Object>> testProductDetail(@RequestParam Long productId) {
|
||||
log.info("===== 测试获取产品详情,productId: {} =====", productId);
|
||||
try {
|
||||
Map<String, Object> result = ctripDistApiService.getProductDetail(productId);
|
||||
log.info("产品详情返回: {}", result);
|
||||
return Result.succeed(result, "获取产品详情成功");
|
||||
} catch (Exception e) {
|
||||
log.error("获取产品详情失败,productId: {}", productId, e);
|
||||
return Result.failed("获取产品详情失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
// ==================== 2. 获取下单填写信息(会自动缓存) ====================
|
||||
|
||||
/**
|
||||
* 测试获取下单填写信息
|
||||
* 用途:下单前查询该产品需要填写哪些字段(如手机号、身份证、英文姓名等)
|
||||
* 调用成功后会按 productId 缓存结果,后续可订检查/创建订单自动使用
|
||||
* 需要先调用接口1获取packageId和resourceId
|
||||
*
|
||||
* 调用示例:GET /ctrip/dist/test/book-info?productId=12345678&packageId=37326707&resourceId=37326710
|
||||
*/
|
||||
@GetMapping("/book-info")
|
||||
@Operation(summary = "2.获取下单填写信息(自动缓存)")
|
||||
public Result<Map<String, Object>> testBookInfo(
|
||||
@RequestParam Long productId,
|
||||
@RequestParam Long packageId,
|
||||
@RequestParam Long resourceId) {
|
||||
log.info("===== 测试获取下单填写信息,productId: {}, packageId: {}, resourceId: {} =====",
|
||||
productId, packageId, resourceId);
|
||||
try {
|
||||
Map<String, Object> result = ctripDistApiService.getBookInfo(productId, packageId, resourceId);
|
||||
log.info("下单填写信息返回: {}", result);
|
||||
|
||||
// 缓存 bookInfo 结果
|
||||
bookInfoCache.put(productId, result);
|
||||
log.info("bookInfo已缓存,productId: {},后续接口将自动使用", productId);
|
||||
|
||||
return Result.succeed(result, "获取下单填写信息成功(已缓存)");
|
||||
} catch (Exception e) {
|
||||
log.error("获取下单填写信息失败", e);
|
||||
return Result.failed("获取下单填写信息失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 查看当前缓存的bookInfo
|
||||
* 用途:查看某个产品已缓存的问卷模板,方便确认需要填哪些字段
|
||||
*
|
||||
* 调用示例:GET /ctrip/dist/test/book-info/cache?productId=39098283
|
||||
*/
|
||||
@GetMapping("/book-info/cache")
|
||||
@Operation(summary = "2.1 查看缓存的bookInfo")
|
||||
public Result<Map<String, Object>> getCachedBookInfo(@RequestParam Long productId) {
|
||||
Map<String, Object> cached = bookInfoCache.get(productId);
|
||||
if (cached == null) {
|
||||
return Result.failed("productId=" + productId + " 的bookInfo未缓存,请先调用接口2获取");
|
||||
}
|
||||
// 额外提取问卷模板摘要方便查看
|
||||
Map<String, Object> result = new LinkedHashMap<>();
|
||||
result.put("productId", productId);
|
||||
result.put("questionTemplate", extractQuestionTemplate(cached));
|
||||
result.put("fullResponse", cached);
|
||||
return Result.succeed(result, "缓存的bookInfo");
|
||||
}
|
||||
|
||||
// ==================== 2.5 可订检查 ====================
|
||||
|
||||
/**
|
||||
* 测试可订检查
|
||||
* 用途:下单前检查资源是否可预订
|
||||
* 前提:必须先调用接口2获取bookInfo(已自动缓存)
|
||||
*
|
||||
* passengers中每个出行人只需传 questionCode → 答案值,
|
||||
* 系统会自动从缓存的bookInfo中匹配questionID和questionTitle
|
||||
*
|
||||
* 调用示例:POST /ctrip/dist/test/check-availability
|
||||
*
|
||||
* 产品2示例(如果模板里是 P_NAME,最终会按 P_CNAME 下发,2出行人):
|
||||
* {
|
||||
* "productId": xxx,
|
||||
* "packageId": xxx,
|
||||
* "resourceId": xxx,
|
||||
* "price": 68.00,
|
||||
* "quantity": 2,
|
||||
* "passengers": [
|
||||
* {"P_NAME": "杜超", "P_ID_CARD": "120101199003076531"},
|
||||
* {"P_NAME": "张三", "P_ID_CARD": "120101199003076532"}
|
||||
* ]
|
||||
* }
|
||||
*
|
||||
* 产品3示例(姓名字段会优先匹配中文姓名题;若模板为 P_NAME,也会改成 P_CNAME):
|
||||
* {
|
||||
* "productId": 39098283,
|
||||
* "packageId": xxx,
|
||||
* "resourceId": xxx,
|
||||
* "price": 68.00,
|
||||
* "quantity": 2,
|
||||
* "passengers": [
|
||||
* {"name": "张三"}
|
||||
* ]
|
||||
* }
|
||||
*/
|
||||
@PostMapping("/check-availability")
|
||||
@Operation(summary = "2.5 可订检查")
|
||||
@SuppressWarnings("unchecked")
|
||||
public Result<Map<String, Object>> testCheckAvailability(@RequestBody Map<String, Object> params) {
|
||||
log.info("===== 测试可订检查,params: {} =====", params);
|
||||
try {
|
||||
Long productId = Long.valueOf(params.get("productId").toString());
|
||||
Long packageId = Long.valueOf(params.get("packageId").toString());
|
||||
Long resourceId = Long.valueOf(params.get("resourceId").toString());
|
||||
BigDecimal price = new BigDecimal(params.get("price").toString());
|
||||
String contactName = params.getOrDefault("contactName", "杜超").toString();
|
||||
String contactMobile = params.getOrDefault("contactMobile", "18222892722").toString();
|
||||
String contactEmail = params.getOrDefault("contactEmail", "1098974449@qq.com").toString();
|
||||
|
||||
// 从缓存获取问卷模板
|
||||
List<Map<String, Object>> questionTemplate = getQuestionTemplate(productId);
|
||||
|
||||
// 解析出行人问卷答案
|
||||
List<List<CtripDistBookRequest.QuestionAnswer>> passengerAnswers =
|
||||
parsePassengerAnswers(params, questionTemplate);
|
||||
|
||||
// quantity 独立于出行人数量
|
||||
int quantity = params.get("quantity") != null
|
||||
? Integer.parseInt(params.get("quantity").toString())
|
||||
: passengerAnswers.size();
|
||||
|
||||
String useDate = params.getOrDefault("useDate",
|
||||
LocalDate.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"))).toString();
|
||||
|
||||
String distributorOrderId = "CHECK_" + System.currentTimeMillis();
|
||||
CtripDistBookRequest request = buildTestBookRequest(
|
||||
distributorOrderId, productId, packageId, resourceId,
|
||||
price, quantity, useDate, contactName, contactMobile, contactEmail,
|
||||
passengerAnswers);
|
||||
|
||||
boolean available = ctripDistApiService.checkAvailability(request);
|
||||
Map<String, Object> data = new LinkedHashMap<>();
|
||||
data.put("available", available);
|
||||
data.put("quantity", quantity);
|
||||
data.put("passengerCount", passengerAnswers.size());
|
||||
data.put("message", available ? "可预订" : "不可预订");
|
||||
log.info("可订检查结果: {}, 购买数量: {}, 出行人数: {}", available, quantity, passengerAnswers.size());
|
||||
return Result.succeed(data, available ? "可预订" : "不可预订");
|
||||
} catch (Exception e) {
|
||||
log.error("可订检查失败", e);
|
||||
return Result.failed("可订检查失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
// ==================== 3. 创建携程订单 ====================
|
||||
|
||||
/**
|
||||
* 测试创建携程订单
|
||||
* 前提:必须先调用接口2获取bookInfo(已自动缓存)
|
||||
* 参数格式与可订检查完全一致
|
||||
*
|
||||
* 调用示例:POST /ctrip/dist/test/book
|
||||
* Body: 与可订检查接口相同
|
||||
*/
|
||||
@PostMapping("/book")
|
||||
@Operation(summary = "3.创建携程订单")
|
||||
@SuppressWarnings("unchecked")
|
||||
public Result<CtripDistBookResponse> testCreateOrder(@RequestBody Map<String, Object> params) {
|
||||
log.info("===== 测试创建携程订单,params: {} =====", params);
|
||||
try {
|
||||
Long productId = Long.valueOf(params.get("productId").toString());
|
||||
Long packageId = Long.valueOf(params.get("packageId").toString());
|
||||
Long resourceId = Long.valueOf(params.get("resourceId").toString());
|
||||
BigDecimal price = new BigDecimal(params.get("price").toString());
|
||||
String contactName = params.getOrDefault("contactName", "杜超").toString();
|
||||
String contactMobile = params.getOrDefault("contactMobile", "18222892722").toString();
|
||||
String contactEmail = params.getOrDefault("contactEmail", "1098974449@qq.com").toString();
|
||||
|
||||
// 从缓存获取问卷模板
|
||||
List<Map<String, Object>> questionTemplate = getQuestionTemplate(productId);
|
||||
|
||||
// 解析出行人问卷答案
|
||||
List<List<CtripDistBookRequest.QuestionAnswer>> passengerAnswers =
|
||||
parsePassengerAnswers(params, questionTemplate);
|
||||
|
||||
// quantity 独立于出行人数量
|
||||
int quantity = params.get("quantity") != null
|
||||
? Integer.parseInt(params.get("quantity").toString())
|
||||
: passengerAnswers.size();
|
||||
|
||||
String useDate = params.getOrDefault("useDate",
|
||||
LocalDate.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"))).toString();
|
||||
|
||||
String distributorOrderId = "TEST_" + System.currentTimeMillis();
|
||||
CtripDistBookRequest request = buildTestBookRequest(
|
||||
distributorOrderId, productId, packageId, resourceId,
|
||||
price, quantity, useDate, contactName, contactMobile, contactEmail,
|
||||
passengerAnswers);
|
||||
|
||||
log.info("下单请求 distributorOrderId: {}, 购买数量: {}, 出行人数: {}",
|
||||
distributorOrderId, quantity, passengerAnswers.size());
|
||||
CtripDistBookResponse response = ctripDistApiService.createOrder(request);
|
||||
log.info("创建订单返回: success={}, orderId={}", response.isSuccess(),
|
||||
response.getData() != null ? response.getData().getOrderId() : "null");
|
||||
return Result.succeed(response, "创建订单调用完成");
|
||||
} catch (Exception e) {
|
||||
log.error("创建携程订单失败", e);
|
||||
return Result.failed("创建携程订单失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 测试创建携程订单(直接传完整请求体)
|
||||
* 用途:如果需要精确控制所有字段,直接传CtripDistBookRequest JSON
|
||||
*
|
||||
* 调用示例:POST /ctrip/dist/test/book/raw
|
||||
* Body: 完整的CtripDistBookRequest JSON
|
||||
*/
|
||||
@PostMapping("/book/raw")
|
||||
@Operation(summary = "3.创建携程订单(原始请求体)")
|
||||
public Result<CtripDistBookResponse> testCreateOrderRaw(@RequestBody CtripDistBookRequest request) {
|
||||
log.info("===== 测试创建携程订单(raw),distributorOrderID: {} =====", request.getDistributorOrderID());
|
||||
try {
|
||||
CtripDistBookResponse response = ctripDistApiService.createOrder(request);
|
||||
log.info("创建订单返回: success={}", response.isSuccess());
|
||||
return Result.succeed(response, "创建订单调用完成");
|
||||
} catch (Exception e) {
|
||||
log.error("创建携程订单失败", e);
|
||||
return Result.failed("创建携程订单失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
// ==================== 4. 可退检查 ====================
|
||||
|
||||
/**
|
||||
* 测试取消验证(可退检查)
|
||||
* 用途:检查某个携程订单是否可以取消/退订
|
||||
* 需要先通过接口3创建订单获得ctripOrderId
|
||||
*
|
||||
* 调用示例:GET /ctrip/dist/test/cancel-verify?ctripOrderId=123456789
|
||||
*/
|
||||
@GetMapping("/cancel-verify")
|
||||
@Operation(summary = "4.可退检查")
|
||||
public Result<CtripDistCancelVerifyResponse> testCancelVerify(@RequestParam Long ctripOrderId) {
|
||||
log.info("===== 测试取消验证,ctripOrderId: {} =====", ctripOrderId);
|
||||
try {
|
||||
CtripDistCancelVerifyResponse response = ctripDistApiService.cancelVerify(ctripOrderId);
|
||||
log.info("取消验证返回: success={}, cancelVerifyStatus={}",
|
||||
response.isSuccess(),
|
||||
response.getCancelVerifyData() != null
|
||||
? response.getCancelVerifyData().getCancelVerifyStatus() : "null");
|
||||
return Result.succeed(response, "取消验证调用完成");
|
||||
} catch (Exception e) {
|
||||
log.error("取消验证失败,ctripOrderId: {}", ctripOrderId, e);
|
||||
return Result.failed("取消验证失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
// ==================== 5. 退订(全部退订) ====================
|
||||
|
||||
/**
|
||||
* 测试退订(全部取消订单)
|
||||
* 用途:取消携程订单,需先通过接口4确认可退
|
||||
*
|
||||
* 调用示例:POST /ctrip/dist/test/cancel?ctripOrderId=123456789&reason=测试退订
|
||||
*/
|
||||
@PostMapping("/cancel")
|
||||
@Operation(summary = "5.退订(全部取消订单)")
|
||||
public Result<CtripDistCancelResponse> testCancelOrder(
|
||||
@RequestParam Long ctripOrderId,
|
||||
@RequestParam(defaultValue = "沙箱测试退订") String reason) {
|
||||
log.info("===== 测试全部退订,ctripOrderId: {}, reason: {} =====", ctripOrderId, reason);
|
||||
try {
|
||||
CtripDistCancelResponse response = ctripDistApiService.cancelOrder(ctripOrderId, reason);
|
||||
log.info("退订返回: success={}", response.isSuccess());
|
||||
return Result.succeed(response, "退订调用完成");
|
||||
} catch (Exception e) {
|
||||
log.error("退订失败,ctripOrderId: {}", ctripOrderId, e);
|
||||
return Result.failed("退订失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
// ==================== 5.5 部分退订 ====================
|
||||
|
||||
/**
|
||||
* 测试部分退订
|
||||
* 用途:部分取消携程订单(如购买2张退1张),需先通过接口4确认可部分退
|
||||
*
|
||||
* 调用示例:POST /ctrip/dist/test/cancel-partial
|
||||
* Body:
|
||||
* {
|
||||
* "ctripOrderId": 123456789,
|
||||
* "reason": "沙箱测试部分退订",
|
||||
* "cancelOrderItems": [
|
||||
* {
|
||||
* "itemID": 1001,
|
||||
* "quantity": 1
|
||||
* }
|
||||
* ]
|
||||
* }
|
||||
*/
|
||||
@PostMapping("/cancel-partial")
|
||||
@Operation(summary = "5.5 部分退订")
|
||||
@SuppressWarnings("unchecked")
|
||||
public Result<CtripDistCancelResponse> testCancelOrderPartial(@RequestBody Map<String, Object> params) {
|
||||
Long ctripOrderId = Long.valueOf(params.get("ctripOrderId").toString());
|
||||
String reason = params.getOrDefault("reason", "沙箱测试部分退订").toString();
|
||||
List<Map<String, Object>> cancelOrderItems = (List<Map<String, Object>>) params.get("cancelOrderItems");
|
||||
log.info("===== 测试部分退订,ctripOrderId: {}, reason: {}, cancelOrderItems: {} =====",
|
||||
ctripOrderId, reason, cancelOrderItems);
|
||||
try {
|
||||
CtripDistCancelResponse response = ctripDistApiService.cancelOrderPartial(ctripOrderId, reason, cancelOrderItems);
|
||||
log.info("部分退订返回: success={}", response.isSuccess());
|
||||
return Result.succeed(response, "部分退订调用完成");
|
||||
} catch (Exception e) {
|
||||
log.error("部分退订失败,ctripOrderId: {}", ctripOrderId, e);
|
||||
return Result.failed("部分退订失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
// ==================== 6. 订单详情 ====================
|
||||
|
||||
/**
|
||||
* 测试查询携程订单详情
|
||||
* 用途:根据携程订单ID查询订单状态和详细信息
|
||||
*
|
||||
* 调用示例:GET /ctrip/dist/test/booking-detail?ctripOrderId=123456789
|
||||
*/
|
||||
@GetMapping("/booking-detail")
|
||||
@Operation(summary = "6.携程订单详情")
|
||||
public Result<CtripDistBookingDetailResponse> testBookingDetail(@RequestParam Long ctripOrderId) {
|
||||
log.info("===== 测试查询订单详情,ctripOrderId: {} =====", ctripOrderId);
|
||||
try {
|
||||
CtripDistBookingDetailResponse response = ctripDistApiService.getOrderDetail(ctripOrderId);
|
||||
log.info("订单详情返回: success={}, orderStatus={}",
|
||||
response.isSuccess(),
|
||||
response.getData() != null && response.getData().getOrder() != null
|
||||
? response.getData().getOrder().getOrderStatus() : "null");
|
||||
return Result.succeed(response, "查询订单详情完成");
|
||||
} catch (Exception e) {
|
||||
log.error("查询订单详情失败,ctripOrderId: {}", ctripOrderId, e);
|
||||
return Result.failed("查询订单详情失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
// ==================== 7. 沙箱-模拟携程发起退订(Part M 11.2) ====================
|
||||
|
||||
/**
|
||||
* 模拟携程侧发起退订
|
||||
* 用途:沙箱测试时模拟携程侧退订(非分销商发起),退订后可调接口6查看订单状态
|
||||
*
|
||||
* 整单退示例:POST /ctrip/dist/test/simulate-cancel
|
||||
* Body: {"orderId": "1128170608930095"}
|
||||
*
|
||||
* 部分退示例(一张一人的订单,传clientId):
|
||||
* Body:
|
||||
* {
|
||||
* "orderId": "1128170612314784",
|
||||
* "quantity": 1,
|
||||
* "clientInfoList": [
|
||||
* {"clientId": "1756725089476701"}
|
||||
* ]
|
||||
* }
|
||||
* 注意:clientId 从订单详情接口(接口6)返回的出行人 P_CLIENTID 获取
|
||||
*/
|
||||
@PostMapping("/simulate-cancel")
|
||||
@Operation(summary = "7.沙箱-模拟携程发起退订")
|
||||
public Result<Map<String, Object>> testSimulateCtripCancel(@RequestBody Map<String, Object> params) {
|
||||
log.info("===== 沙箱-模拟携程发起退订,params: {} =====", params);
|
||||
try {
|
||||
Map<String, Object> response = ctripDistApiService.simulateCtripCancel(params);
|
||||
log.info("模拟携程退订返回: {}", response);
|
||||
return Result.succeed(response, "模拟携程退订调用完成");
|
||||
} catch (Exception e) {
|
||||
log.error("模拟携程退订失败", e);
|
||||
return Result.failed("模拟携程退订失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
// ==================== 8. 沙箱-人工出票/退订确认/退订拒绝/凭证变更(Part M 11.3) ====================
|
||||
|
||||
/**
|
||||
* 沙箱测试-人工出票/退订确认/退订拒绝/凭证变更
|
||||
* 用途:对卡在出票中/退订中的订单进行人工操作
|
||||
*
|
||||
* type说明:
|
||||
* 1 = 人工出票(对卡在出票中或需人工确认的订单)
|
||||
* 2 = 退订确认(对卡在退订中的订单)
|
||||
* 3 = 退订拒绝(模拟携程侧拒绝退订)
|
||||
* 4 = 凭证变更
|
||||
*
|
||||
* 调用示例:POST /ctrip/dist/test/simulate-confirm
|
||||
* Body: {"orderId": "1128170612557359", "type": 1}
|
||||
*/
|
||||
@PostMapping("/simulate-confirm")
|
||||
@Operation(summary = "8.沙箱-人工出票/退订确认/退订拒绝/凭证变更")
|
||||
public Result<Map<String, Object>> testSimulateConfirm(@RequestBody Map<String, Object> params) {
|
||||
Object type = params.get("type");
|
||||
String[] typeNames = {"", "人工出票", "退订确认", "退订拒绝", "凭证变更"};
|
||||
String typeName = type != null && Integer.parseInt(type.toString()) >= 1 && Integer.parseInt(type.toString()) <= 4
|
||||
? typeNames[Integer.parseInt(type.toString())] : "未知类型";
|
||||
log.info("===== 沙箱-{},params: {} =====", typeName, params);
|
||||
try {
|
||||
Map<String, Object> response = ctripDistApiService.simulateConfirm(params);
|
||||
log.info("沙箱-{}返回: {}", typeName, response);
|
||||
return Result.succeed(response, typeName + "调用完成");
|
||||
} catch (Exception e) {
|
||||
log.error("沙箱-{}失败", typeName, e);
|
||||
return Result.failed(typeName + "失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
// ==================== 9. 获取位置列表 ====================
|
||||
|
||||
/**
|
||||
* 获取位置列表
|
||||
* 用途:查询可用城市/地区列表,获取locationID和locationType供产品列表接口使用
|
||||
* locale固定为zh-CN
|
||||
*
|
||||
* 调用示例:GET /ctrip/dist/test/location-list?pageIndex=1&pageSize=20
|
||||
*/
|
||||
@GetMapping("/location-list")
|
||||
@Operation(summary = "9.获取位置列表")
|
||||
public Result<Map<String, Object>> testLocationList(
|
||||
@RequestParam(defaultValue = "1") int pageIndex,
|
||||
@RequestParam(defaultValue = "20") int pageSize) {
|
||||
log.info("===== 获取位置列表,pageIndex: {}, pageSize: {} =====", pageIndex, pageSize);
|
||||
try {
|
||||
Map<String, Object> result = ctripDistApiService.getLocationList(pageIndex, pageSize);
|
||||
log.info("位置列表返回: {}", result);
|
||||
return Result.succeed(result, "获取位置列表成功");
|
||||
} catch (Exception e) {
|
||||
log.error("获取位置列表失败", e);
|
||||
return Result.failed("获取位置列表失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
// ==================== 10. 获取产品列表 ====================
|
||||
|
||||
/**
|
||||
* 获取产品列表
|
||||
* 用途:查询产品列表,site和destination的locationID/locationType自动从位置列表接口获取
|
||||
* 可通过locationIndex指定使用位置列表中的第几个位置(0-based,默认0)
|
||||
*
|
||||
* 调用示例:POST /ctrip/dist/test/product-list
|
||||
* Body:
|
||||
* {
|
||||
* "locale": "zh-HK",
|
||||
* "currency": "HKD",
|
||||
* "categoryIDList": [1, 2],
|
||||
* "sortOrder": "ID_A",
|
||||
* "pageIndex": 1,
|
||||
* "pageSize": 10,
|
||||
* "imageSize": "500_280",
|
||||
* "poiIDList": [],
|
||||
* "keyWord": "",
|
||||
* "lastUpdateProductID": 0,
|
||||
* "business": "ACTIVITY",
|
||||
* "locationIndex": 0
|
||||
* }
|
||||
*/
|
||||
@PostMapping("/product-list")
|
||||
@Operation(summary = "10.获取产品列表(自动填充位置)")
|
||||
@SuppressWarnings("unchecked")
|
||||
public Result<Map<String, Object>> testProductList(@RequestBody Map<String, Object> params) {
|
||||
log.info("===== 获取产品列表,params: {} =====", params);
|
||||
try {
|
||||
// 提取locationIndex并从请求体中移除(不传给产品列表接口)
|
||||
int locationIndex = params.containsKey("locationIndex")
|
||||
? Integer.parseInt(params.get("locationIndex").toString()) : 0;
|
||||
Map<String, Object> productListRequest = new java.util.LinkedHashMap<>(params);
|
||||
productListRequest.remove("locationIndex");
|
||||
|
||||
// 第一步:调用位置列表接口获取locationID和locationType
|
||||
log.info("第一步:调用位置列表接口,locale=zh-CN,取第{}个位置", locationIndex);
|
||||
Map<String, Object> locationResult = ctripDistApiService.getLocationList(1, 20);
|
||||
Object locationData = locationResult.get("data");
|
||||
if (locationData == null) {
|
||||
return Result.failed("位置列表接口返回data为空,无法获取locationID");
|
||||
}
|
||||
List<Map<String, Object>> locationList =
|
||||
(List<Map<String, Object>>) ((Map<String, Object>) locationData).get("locationList");
|
||||
if (locationList == null || locationList.isEmpty()) {
|
||||
return Result.failed("位置列表为空,无法获取locationID");
|
||||
}
|
||||
if (locationIndex >= locationList.size()) {
|
||||
return Result.failed("locationIndex=" + locationIndex + " 超出位置列表范围(共" + locationList.size() + "个位置)");
|
||||
}
|
||||
Map<String, Object> location = locationList.get(locationIndex);
|
||||
Object locationID = location.get("locationID");
|
||||
Object locationType = location.get("type");
|
||||
log.info("获取到位置:locationID={}, type={}, name={}", locationID, locationType, location.get("name"));
|
||||
|
||||
// 第二步:用获取到的locationID和locationType填充site和destination
|
||||
Map<String, Object> siteMap = new java.util.LinkedHashMap<>();
|
||||
siteMap.put("locationID", locationID);
|
||||
siteMap.put("locationType", locationType);
|
||||
Map<String, Object> destinationMap = new java.util.LinkedHashMap<>();
|
||||
destinationMap.put("locationID", locationID);
|
||||
destinationMap.put("locationType", locationType);
|
||||
productListRequest.put("site", siteMap);
|
||||
productListRequest.put("destination", destinationMap);
|
||||
|
||||
log.info("第二步:调用产品列表接口,site/destination locationID={}, locationType={}", locationID, locationType);
|
||||
|
||||
// 第三步:调用产品列表接口
|
||||
Map<String, Object> result = ctripDistApiService.getProductList(productListRequest);
|
||||
log.info("产品列表返回: {}", result);
|
||||
|
||||
// 在返回结果中附加使用的位置信息,方便调试
|
||||
Map<String, Object> response = new java.util.LinkedHashMap<>();
|
||||
response.put("usedLocation", location);
|
||||
response.put("productListResult", result);
|
||||
return Result.succeed(response, "获取产品列表成功");
|
||||
} catch (Exception e) {
|
||||
log.error("获取产品列表失败", e);
|
||||
return Result.failed("获取产品列表失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
// ==================== 11. 获取产品全量列表 ====================
|
||||
|
||||
/**
|
||||
* 获取产品全量列表
|
||||
* 用途:分批拉取指定业务类型下的全量产品ID及销售状态
|
||||
* 首次调用 lastMaxId 传 "0",后续将上次返回的 maxId 作为 lastMaxId 继续翻页,
|
||||
* 直到返回的 productList 为空或数量小于 limit 为止
|
||||
*
|
||||
* 调用示例:GET /ctrip/dist/test/all-products?business=ACTIVITY&lastMaxId=0&limit=50
|
||||
*/
|
||||
@GetMapping("/all-products")
|
||||
@Operation(summary = "11.获取产品全量列表")
|
||||
public Result<Map<String, Object>> testAllProducts(
|
||||
@RequestParam(defaultValue = "ACTIVITY") String business,
|
||||
@RequestParam(defaultValue = "0") String lastMaxId,
|
||||
@RequestParam(defaultValue = "50") int limit) {
|
||||
log.info("===== 获取产品全量列表,business: {}, lastMaxId: {}, limit: {} =====",
|
||||
business, lastMaxId, limit);
|
||||
try {
|
||||
Map<String, Object> result = ctripDistApiService.getAllProducts(business, lastMaxId, limit);
|
||||
log.info("产品全量列表返回: success={}, maxId={}, productList size={}",
|
||||
result.get("success"), result.get("maxId"),
|
||||
result.get("productList") instanceof java.util.List
|
||||
? ((java.util.List<?>) result.get("productList")).size() : 0);
|
||||
return Result.succeed(result, "获取产品全量列表成功");
|
||||
} catch (Exception e) {
|
||||
log.error("获取产品全量列表失败", e);
|
||||
return Result.failed("获取产品全量列表失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
// ==================== 辅助方法 ====================
|
||||
|
||||
/**
|
||||
* 从缓存获取产品的问卷模板
|
||||
* 如果未缓存,提示用户先调用接口2
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
private List<Map<String, Object>> getQuestionTemplate(Long productId) {
|
||||
Map<String, Object> bookInfo = bookInfoCache.get(productId);
|
||||
if (bookInfo == null) {
|
||||
throw new RuntimeException("productId=" + productId + " 的bookInfo未缓存,请先调用接口2(GET /ctrip/dist/test/book-info)");
|
||||
}
|
||||
return extractQuestionTemplate(bookInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 从 bookInfo 响应中提取问卷模板列表
|
||||
* bookInfo 结构: { success: true, data: { passengerQuestionList: [...] } }
|
||||
* 每个问卷项: { questionID: 3, questionCode: "P_NAME", questionTitle: "UserName", ... }
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
private List<Map<String, Object>> extractQuestionTemplate(Map<String, Object> bookInfo) {
|
||||
if (bookInfo == null || bookInfo.get("data") == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
Map<String, Object> data = (Map<String, Object>) bookInfo.get("data");
|
||||
Object questionList = data.get("passengerQuestionList");
|
||||
if (questionList instanceof List) {
|
||||
return (List<Map<String, Object>>) questionList;
|
||||
}
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析出行人问卷答案
|
||||
*
|
||||
* passengers中每个出行人是一个Map,key可以直接传questionCode,也可以传通用姓名字段
|
||||
* 示例: {"name": "张三"} 或 {"P_NAME": "张三"}
|
||||
*
|
||||
* 系统自动从缓存的问卷模板中匹配questionID和questionTitle
|
||||
*
|
||||
* 如果没有传passengers,则返回空的单个出行人(无问卷答案)
|
||||
*
|
||||
* @param params 请求参数
|
||||
* @param questionTemplate 从bookInfo缓存中获取的问卷模板
|
||||
* @return 每个出行人的问卷答案列表
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
private List<List<CtripDistBookRequest.QuestionAnswer>> parsePassengerAnswers(
|
||||
Map<String, Object> params, List<Map<String, Object>> questionTemplate) {
|
||||
|
||||
List<List<CtripDistBookRequest.QuestionAnswer>> result = new ArrayList<>();
|
||||
Object passengersObj = params.get("passengers");
|
||||
|
||||
if (passengersObj instanceof List) {
|
||||
List<Map<String, Object>> passengers = (List<Map<String, Object>>) passengersObj;
|
||||
// 构建 questionCode → 模板 的映射
|
||||
// 携程返回的字段名是 "code"(不是 "questionCode")
|
||||
Map<String, Map<String, Object>> templateMap = buildQuestionTemplateMap(questionTemplate);
|
||||
|
||||
for (Map<String, Object> passengerMap : passengers) {
|
||||
Map<String, CtripDistBookRequest.QuestionAnswer> answersByCode = new LinkedHashMap<>();
|
||||
for (Map.Entry<String, Object> entry : passengerMap.entrySet()) {
|
||||
String inputKey = entry.getKey();
|
||||
String answerValue = entry.getValue() != null ? entry.getValue().toString() : "";
|
||||
|
||||
// 从模板匹配 questionID 和 questionTitle
|
||||
Map<String, Object> template = resolveQuestionTemplate(inputKey, questionTemplate, templateMap);
|
||||
if (template != null) {
|
||||
CtripDistBookRequest.QuestionAnswer answer = buildQuestionAnswer(template, answerValue);
|
||||
if (answer.getQuestionCode() == null || answer.getQuestionCode().isEmpty()) {
|
||||
log.warn("questionCode={} 未能从问卷模板解析出实际 code,跳过", inputKey);
|
||||
} else {
|
||||
answersByCode.put(answer.getQuestionCode(), answer);
|
||||
}
|
||||
} else {
|
||||
log.warn("questionCode={} 在问卷模板中未找到,跳过", inputKey);
|
||||
}
|
||||
}
|
||||
result.add(new ArrayList<>(answersByCode.values()));
|
||||
}
|
||||
}
|
||||
|
||||
if (result.isEmpty()) {
|
||||
// 没有传passengers,返回一个无答案的出行人
|
||||
result.add(new ArrayList<>());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private Map<String, Map<String, Object>> buildQuestionTemplateMap(List<Map<String, Object>> questionTemplate) {
|
||||
Map<String, Map<String, Object>> templateMap = new LinkedHashMap<>();
|
||||
for (Map<String, Object> template : questionTemplate) {
|
||||
String code = getFieldValue(template, "code", "questionCode");
|
||||
if (code != null && !code.isEmpty()) {
|
||||
templateMap.put(code, template);
|
||||
}
|
||||
}
|
||||
return templateMap;
|
||||
}
|
||||
|
||||
private Map<String, Object> resolveQuestionTemplate(String inputKey,
|
||||
List<Map<String, Object>> questionTemplate,
|
||||
Map<String, Map<String, Object>> templateMap) {
|
||||
Map<String, Object> directTemplate = templateMap.get(inputKey);
|
||||
if (directTemplate != null) {
|
||||
return directTemplate;
|
||||
}
|
||||
if (isPassengerNameKey(inputKey)) {
|
||||
return findPreferredChineseNameTemplate(questionTemplate, templateMap);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private Map<String, Object> findPreferredChineseNameTemplate(List<Map<String, Object>> questionTemplate,
|
||||
Map<String, Map<String, Object>> templateMap) {
|
||||
return findQuestionTemplateByCodes(questionTemplate, templateMap, "P_CNAME", "P_NAME");
|
||||
}
|
||||
|
||||
private Map<String, Object> findQuestionTemplateByCodes(List<Map<String, Object>> questionTemplate,
|
||||
Map<String, Map<String, Object>> templateMap,
|
||||
String... preferredCodes) {
|
||||
for (String preferredCode : preferredCodes) {
|
||||
Map<String, Object> template = templateMap.get(preferredCode);
|
||||
if (template != null) {
|
||||
return template;
|
||||
}
|
||||
}
|
||||
for (Map<String, Object> template : questionTemplate) {
|
||||
String code = getFieldValue(template, "code", "questionCode");
|
||||
for (String preferredCode : preferredCodes) {
|
||||
if (preferredCode.equalsIgnoreCase(code)) {
|
||||
return template;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private boolean isPassengerNameKey(String inputKey) {
|
||||
if (inputKey == null) {
|
||||
return false;
|
||||
}
|
||||
return Arrays.asList("name", "passengerName", "passengerCname", "cname", "P_NAME", "P_CNAME")
|
||||
.contains(inputKey);
|
||||
}
|
||||
|
||||
private CtripDistBookRequest.QuestionAnswer buildQuestionAnswer(Map<String, Object> template, String answerValue) {
|
||||
CtripDistBookRequest.QuestionAnswer answer = new CtripDistBookRequest.QuestionAnswer();
|
||||
String questionId = getFieldValue(template, "questionID", "id");
|
||||
if (questionId != null && !questionId.isEmpty()) {
|
||||
answer.setQuestionID(Long.valueOf(questionId));
|
||||
}
|
||||
String questionCode = getFieldValue(template, "code", "questionCode");
|
||||
answer.setQuestionCode(normalizeQuestionCode(questionCode));
|
||||
String title = getFieldValue(template, "title", "questionTitle");
|
||||
answer.setQuestionTitle(title != null ? title : "");
|
||||
answer.setAnswerList(Collections.singletonList(answerValue));
|
||||
return answer;
|
||||
}
|
||||
|
||||
private String normalizeQuestionCode(String questionCode) {
|
||||
if ("P_NAME".equalsIgnoreCase(questionCode)) {
|
||||
return "P_CNAME";
|
||||
}
|
||||
return questionCode != null ? questionCode : "";
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建测试下单请求(通用版)
|
||||
*
|
||||
* @param passengerAnswers 每个出行人的问卷答案(从parsePassengerAnswers得到)
|
||||
* @param quantity 购买数量(与出行人数量解耦)
|
||||
* @param useDate 使用日期
|
||||
*/
|
||||
private CtripDistBookRequest buildTestBookRequest(String distributorOrderId, Long productId,
|
||||
Long packageId, Long resourceId,
|
||||
BigDecimal price, int quantity,
|
||||
String useDate,
|
||||
String contactName, String contactMobile,
|
||||
String contactEmail,
|
||||
List<List<CtripDistBookRequest.QuestionAnswer>> passengerAnswers) {
|
||||
CtripDistBookRequest request = new CtripDistBookRequest();
|
||||
request.setLocale("zh-CN");
|
||||
request.setCurrency("CNY");
|
||||
request.setDistributorOrderID(distributorOrderId);
|
||||
|
||||
// 联系人
|
||||
CtripDistBookRequest.Contact contact = new CtripDistBookRequest.Contact();
|
||||
contact.setName(contactName);
|
||||
CtripDistBookRequest.Mobile mobile = new CtripDistBookRequest.Mobile();
|
||||
mobile.setInternationalTelephoneCode("86");
|
||||
mobile.setMobileNumber(contactMobile);
|
||||
contact.setMobile(mobile);
|
||||
contact.setEmail(contactEmail);
|
||||
request.setContact(contact);
|
||||
|
||||
// 为每个出行人构建Passenger对象
|
||||
List<CtripDistBookRequest.Passenger> passengerList = new ArrayList<>();
|
||||
for (List<CtripDistBookRequest.QuestionAnswer> answers : passengerAnswers) {
|
||||
CtripDistBookRequest.Passenger passenger = new CtripDistBookRequest.Passenger();
|
||||
passenger.setPackageID(packageId);
|
||||
passenger.setResourceID(resourceId);
|
||||
passenger.setQuestionAnswerList(answers);
|
||||
passengerList.add(passenger);
|
||||
}
|
||||
request.setPassengerList(passengerList);
|
||||
|
||||
// 订单资源
|
||||
CtripDistBookRequest.OrderResource orderResource = new CtripDistBookRequest.OrderResource();
|
||||
orderResource.setResourceID(resourceId);
|
||||
orderResource.setUseDate(useDate);
|
||||
orderResource.setQuantity(quantity);
|
||||
orderResource.setPrice(price);
|
||||
|
||||
// 基本订单信息
|
||||
BigDecimal totalAmount = price.multiply(new BigDecimal(quantity));
|
||||
CtripDistBookRequest.BasicOrder basicOrder = new CtripDistBookRequest.BasicOrder();
|
||||
basicOrder.setProductID(productId);
|
||||
basicOrder.setAmount(totalAmount);
|
||||
basicOrder.setPackageID(packageId);
|
||||
basicOrder.setOrderResourceList(Collections.singletonList(orderResource));
|
||||
request.setBasicOrder(basicOrder);
|
||||
|
||||
return request;
|
||||
}
|
||||
|
||||
/**
|
||||
* 从Map中按优先级获取字段值
|
||||
* 携程接口返回的字段名可能与文档不一致(如 "code" vs "questionCode","title" vs "questionTitle")
|
||||
*/
|
||||
private String getFieldValue(Map<String, Object> map, String... keys) {
|
||||
for (String key : keys) {
|
||||
Object val = map.get(key);
|
||||
if (val != null) {
|
||||
return val.toString();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
-86
@@ -1,86 +0,0 @@
|
||||
package com.central.coupon.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@TableName("t_ctrip_dist_order")
|
||||
public class CtripDistOrder {
|
||||
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
@TableField("tenant_id")
|
||||
private String tenantId;
|
||||
|
||||
@TableField("order_no")
|
||||
private String orderNo;
|
||||
|
||||
@TableField("ctrip_order_id")
|
||||
private Long ctripOrderId;
|
||||
|
||||
@TableField("ctrip_product_id")
|
||||
private Long ctripProductId;
|
||||
|
||||
@TableField("ctrip_package_id")
|
||||
private Long ctripPackageId;
|
||||
|
||||
@TableField("ctrip_resource_id")
|
||||
private Long ctripResourceId;
|
||||
|
||||
@TableField("distributor_order_id")
|
||||
private String distributorOrderId;
|
||||
|
||||
@TableField("mobile")
|
||||
private String mobile;
|
||||
|
||||
@TableField("order_amount")
|
||||
private BigDecimal orderAmount;
|
||||
|
||||
@TableField("currency")
|
||||
private String currency;
|
||||
|
||||
@TableField("ctrip_order_status")
|
||||
private String ctripOrderStatus;
|
||||
|
||||
@TableField("consume_status")
|
||||
private Integer consumeStatus;
|
||||
|
||||
@TableField("consume_time")
|
||||
private LocalDateTime consumeTime;
|
||||
|
||||
@TableField("refund_status")
|
||||
private Integer refundStatus;
|
||||
|
||||
@TableField("refund_time")
|
||||
private LocalDateTime refundTime;
|
||||
|
||||
@TableField("refund_amount")
|
||||
private BigDecimal refundAmount;
|
||||
|
||||
@TableField("error_msg")
|
||||
private String errorMsg;
|
||||
|
||||
@TableField("retry_count")
|
||||
private Integer retryCount;
|
||||
|
||||
@TableField("remark")
|
||||
private String remark;
|
||||
|
||||
@TableField(value = "create_time", fill = FieldFill.INSERT)
|
||||
private LocalDateTime createTime;
|
||||
|
||||
@TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE)
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
@TableField("deleted")
|
||||
private Integer deleted;
|
||||
}
|
||||
+1
-5
@@ -21,11 +21,7 @@ public enum CtripOrderStatus {
|
||||
WAITING_PAYMENT(11, "WAITING_PAYMENT", "待支付"),
|
||||
PAYMENT_PENDING(12, "PAYMENT_PENDING", "支付待确认"),
|
||||
PAYMENT_CONFIRMED(13, "PAYMENT_CONFIRMED", "支付已确认"),
|
||||
PRE_ORDER_CANCELLED(14, "PRE_ORDER_CANCELLED", "预下单取消成功"),
|
||||
// 管理后台主动发起退款的状态
|
||||
ADMIN_REFUNDING(15, "ADMIN_REFUNDING", "退款中"),
|
||||
ADMIN_REFUNDED(16, "ADMIN_REFUNDED", "已退款"),
|
||||
ADMIN_PART_REFUNDED(17, "ADMIN_PART_REFUNDED", "部分退款");
|
||||
PRE_ORDER_CANCELLED(14, "PRE_ORDER_CANCELLED", "预下单取消成功");
|
||||
|
||||
private final int numericValue;
|
||||
private final String stringValue;
|
||||
|
||||
-21
@@ -9,9 +9,6 @@ import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@FeignClient(name = ServiceNameConstants.ORDER_SERVICE, dismiss404 = true)
|
||||
public interface OrderCenterService {
|
||||
@@ -29,22 +26,4 @@ public interface OrderCenterService {
|
||||
*/
|
||||
@PostMapping("/order/{orderNo}/status/paid")
|
||||
Result<String> updateOrderStatusToPaid(@PathVariable("orderNo") String orderNo);
|
||||
|
||||
/**
|
||||
* 更新订单状态为退款中
|
||||
*/
|
||||
@PostMapping("/order/{orderNo}/status/refunding")
|
||||
Result<String> updateOrderStatusToRefunding(@PathVariable("orderNo") String orderNo);
|
||||
|
||||
/**
|
||||
* 更新订单状态为已退款
|
||||
*/
|
||||
@PostMapping("/order/{orderNo}/status/refunded")
|
||||
Result<String> updateOrderStatusToRefunded(@PathVariable("orderNo") String orderNo);
|
||||
|
||||
/**
|
||||
* 创建退款记录
|
||||
*/
|
||||
@PostMapping("/refund/ctrip/{orderNo}")
|
||||
Result<String> createCtripRefund(@PathVariable("orderNo") String orderNo, @RequestBody Map<String, Object> refundInfo);
|
||||
}
|
||||
-20
@@ -1,20 +0,0 @@
|
||||
package com.central.coupon.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.central.coupon.entity.CtripDistOrder;
|
||||
import java.util.List;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
@Mapper
|
||||
public interface CtripDistOrderMapper extends BaseMapper<CtripDistOrder> {
|
||||
|
||||
// 根据本地订单号查询
|
||||
CtripDistOrder selectByOrderNo(@Param("orderNo") String orderNo);
|
||||
|
||||
// 查询 N 天前创建、已确认且未核销的订单
|
||||
List<CtripDistOrder> selectPendingConsumeOrders(@Param("daysAgo") int daysAgo);
|
||||
|
||||
// 根据分销商订单 ID 查询
|
||||
CtripDistOrder selectByDistributorOrderId(@Param("distributorOrderId") String distributorOrderId);
|
||||
}
|
||||
-59
@@ -1,59 +0,0 @@
|
||||
package com.central.coupon.model;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 管理后台携程退款请求
|
||||
*/
|
||||
@Data
|
||||
public class CtripAdminRefundRequest {
|
||||
|
||||
/**
|
||||
* 订单中心订单号
|
||||
*/
|
||||
private String orderNo;
|
||||
|
||||
/**
|
||||
* 退款金额
|
||||
*/
|
||||
private BigDecimal refundAmount;
|
||||
|
||||
/**
|
||||
* 退款原因
|
||||
*/
|
||||
private String refundReason;
|
||||
|
||||
/**
|
||||
* 退款项列表(可选)
|
||||
*/
|
||||
private List<RefundItem> items;
|
||||
|
||||
/**
|
||||
* 退款项
|
||||
*/
|
||||
@Data
|
||||
public static class RefundItem {
|
||||
/**
|
||||
* 订单项编号
|
||||
*/
|
||||
private String itemId;
|
||||
|
||||
/**
|
||||
* PLU编码
|
||||
*/
|
||||
private String plu;
|
||||
|
||||
/**
|
||||
* 退款金额
|
||||
*/
|
||||
private BigDecimal amount;
|
||||
|
||||
/**
|
||||
* 货币类型
|
||||
*/
|
||||
private String amountCurrency;
|
||||
}
|
||||
}
|
||||
-68
@@ -1,68 +0,0 @@
|
||||
package com.central.coupon.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class CtripDistBookRequest {
|
||||
|
||||
private String locale;
|
||||
private String currency;
|
||||
private String distributorOrderID;
|
||||
private Contact contact;
|
||||
private List<Passenger> passengerList;
|
||||
private BasicOrder basicOrder;
|
||||
|
||||
@Data
|
||||
public static class Contact {
|
||||
|
||||
private String name;
|
||||
private Mobile mobile;
|
||||
private String email;
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class Mobile {
|
||||
|
||||
private String internationalTelephoneCode;
|
||||
private String mobileNumber;
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class Passenger {
|
||||
|
||||
private Long packageID;
|
||||
private Long resourceID;
|
||||
private List<QuestionAnswer> questionAnswerList;
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class QuestionAnswer {
|
||||
|
||||
private Long questionID;
|
||||
private String questionCode;
|
||||
private String questionTitle;
|
||||
private List<String> answerList;
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class BasicOrder {
|
||||
|
||||
private Long productID;
|
||||
private BigDecimal amount;
|
||||
private Long packageID;
|
||||
private List<OrderResource> orderResourceList;
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class OrderResource {
|
||||
|
||||
private Long resourceID;
|
||||
private String useDate;
|
||||
private Integer quantity;
|
||||
private BigDecimal price;
|
||||
}
|
||||
}
|
||||
-24
@@ -1,24 +0,0 @@
|
||||
package com.central.coupon.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import java.math.BigDecimal;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class CtripDistBookResponse {
|
||||
|
||||
private boolean success;
|
||||
private String errcode;
|
||||
private String errmsg;
|
||||
private BookData data;
|
||||
|
||||
@Data
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public static class BookData {
|
||||
|
||||
private Long orderId;
|
||||
private BigDecimal orderAmount;
|
||||
private Integer payTimeOutMinutes;
|
||||
}
|
||||
}
|
||||
-33
@@ -1,33 +0,0 @@
|
||||
package com.central.coupon.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import java.math.BigDecimal;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class CtripDistBookingDetailResponse {
|
||||
|
||||
private boolean success;
|
||||
private String errcode;
|
||||
private String errmsg;
|
||||
private OrderData data;
|
||||
|
||||
@Data
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public static class OrderData {
|
||||
|
||||
private OrderDetail order;
|
||||
}
|
||||
|
||||
@Data
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public static class OrderDetail {
|
||||
|
||||
private Long orderId;
|
||||
// PENDING_BOOKING, CONFIRMED, CANCELLED, etc.
|
||||
private String orderStatus;
|
||||
private BigDecimal amount;
|
||||
private String distributorOrderID;
|
||||
}
|
||||
}
|
||||
-13
@@ -1,13 +0,0 @@
|
||||
package com.central.coupon.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class CtripDistCancelResponse {
|
||||
|
||||
private boolean success;
|
||||
private String errcode;
|
||||
private String errmsg;
|
||||
}
|
||||
-26
@@ -1,26 +0,0 @@
|
||||
package com.central.coupon.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import java.math.BigDecimal;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class CtripDistCancelVerifyResponse {
|
||||
|
||||
private boolean success;
|
||||
private String errcode;
|
||||
private String errmsg;
|
||||
private CancelVerifyData cancelVerifyData;
|
||||
|
||||
@Data
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public static class CancelVerifyData {
|
||||
|
||||
// 0=不可取消, 1=可取消, 3=部分退订
|
||||
private Integer cancelVerifyStatus;
|
||||
private BigDecimal refundAmount;
|
||||
// 1=允许部分退, 2=不允许
|
||||
private Integer canPartRefund;
|
||||
}
|
||||
}
|
||||
-36
@@ -1,36 +0,0 @@
|
||||
package com.central.coupon.service;
|
||||
|
||||
import com.central.common.model.Result;
|
||||
import com.central.coupon.model.CtripAdminRefundRequest;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* 携程管理后台退款服务接口
|
||||
*/
|
||||
public interface ICtripAdminRefundService {
|
||||
|
||||
/**
|
||||
* 管理后台发起携程退款
|
||||
*
|
||||
* @param request 退款请求
|
||||
* @return 退款结果
|
||||
*/
|
||||
Result<String> processAdminRefund(CtripAdminRefundRequest request);
|
||||
|
||||
/**
|
||||
* 根据订单中心订单号获取可退金额
|
||||
*
|
||||
* @param orderNo 订单中心订单号
|
||||
* @return 可退金额
|
||||
*/
|
||||
BigDecimal getAvailableRefundAmount(String orderNo);
|
||||
|
||||
/**
|
||||
* 检查订单是否可以退款
|
||||
*
|
||||
* @param orderNo 订单中心订单号
|
||||
* @return 是否可退款
|
||||
*/
|
||||
boolean canRefund(String orderNo);
|
||||
}
|
||||
-14
@@ -51,18 +51,4 @@ public interface ICtripApiService {
|
||||
* @return 取消结果
|
||||
*/
|
||||
boolean cancelCoupon(String ctripCouponId, String userPhone, String reason);
|
||||
|
||||
/**
|
||||
* 调用携程退款接口
|
||||
*
|
||||
* @param otaOrderId 携程订单号
|
||||
* @param supplierOrderId 供应商订单号
|
||||
* @param totalAmount 退款总金额
|
||||
* @param currency 货币类型
|
||||
* @param items 退款项列表(可选)
|
||||
* @return 退款结果:1-退款已确认,2-退款待确认,0-退款失败
|
||||
*/
|
||||
int sendRefundOrder(String otaOrderId, String supplierOrderId,
|
||||
java.math.BigDecimal totalAmount, String currency,
|
||||
java.util.List<java.util.Map<String, Object>> items);
|
||||
}
|
||||
-128
@@ -1,128 +0,0 @@
|
||||
package com.central.coupon.service;
|
||||
|
||||
import com.central.coupon.model.CtripDistBookRequest;
|
||||
import com.central.coupon.model.CtripDistBookResponse;
|
||||
import com.central.coupon.model.CtripDistBookingDetailResponse;
|
||||
import com.central.coupon.model.CtripDistCancelResponse;
|
||||
import com.central.coupon.model.CtripDistCancelVerifyResponse;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 携程分销商API服务
|
||||
*/
|
||||
public interface ICtripDistApiService {
|
||||
|
||||
/**
|
||||
* 查询产品详情
|
||||
*
|
||||
* @param productId 产品ID
|
||||
* @return 产品详情
|
||||
*/
|
||||
Map<String, Object> getProductDetail(Long productId);
|
||||
|
||||
/**
|
||||
* 获取下单填写信息
|
||||
*
|
||||
* @param productId 产品ID
|
||||
* @param packageId 套餐ID
|
||||
* @param resourceId 资源ID
|
||||
* @return 下单填写信息
|
||||
*/
|
||||
Map<String, Object> getBookInfo(Long productId, Long packageId, Long resourceId);
|
||||
|
||||
/**
|
||||
* 创建订单
|
||||
*
|
||||
* @param request 下单请求
|
||||
* @return 下单响应
|
||||
*/
|
||||
CtripDistBookResponse createOrder(CtripDistBookRequest request);
|
||||
|
||||
/**
|
||||
* 取消验证
|
||||
*
|
||||
* @param ctripOrderId 携程订单ID
|
||||
* @return 取消验证结果
|
||||
*/
|
||||
CtripDistCancelVerifyResponse cancelVerify(Long ctripOrderId);
|
||||
|
||||
/**
|
||||
* 取消订单(全部退订)
|
||||
*
|
||||
* @param ctripOrderId 携程订单ID
|
||||
* @param reason 取消原因
|
||||
* @return 取消结果
|
||||
*/
|
||||
CtripDistCancelResponse cancelOrder(Long ctripOrderId, String reason);
|
||||
|
||||
/**
|
||||
* 部分退订
|
||||
*
|
||||
* @param ctripOrderId 携程订单ID
|
||||
* @param reason 取消原因
|
||||
* @param cancelOrderItems 部分取消的订单项列表
|
||||
* @return 取消结果
|
||||
*/
|
||||
CtripDistCancelResponse cancelOrderPartial(Long ctripOrderId, String reason, List<Map<String, Object>> cancelOrderItems);
|
||||
|
||||
/**
|
||||
* 查询订单详情
|
||||
*
|
||||
* @param ctripOrderId 携程订单ID
|
||||
* @return 订单详情
|
||||
*/
|
||||
CtripDistBookingDetailResponse getOrderDetail(Long ctripOrderId);
|
||||
|
||||
/**
|
||||
* 可订检查(下单前调用,确认资源可预订)
|
||||
* 请求参数与下单接口一致
|
||||
*
|
||||
* @param request 下单请求(与book接口相同)
|
||||
* @return 是否可订
|
||||
*/
|
||||
boolean checkAvailability(CtripDistBookRequest request);
|
||||
|
||||
/**
|
||||
* 沙箱测试-模拟携程发起退订(Part M 11.2)
|
||||
*
|
||||
* @param requestBody 请求体(orderId必填,部分退时含quantity和clientInfoList)
|
||||
* @return 响应
|
||||
*/
|
||||
Map<String, Object> simulateCtripCancel(Map<String, Object> requestBody);
|
||||
|
||||
/**
|
||||
* 沙箱测试-人工出票/退订确认/退订拒绝/凭证变更(Part M 11.3)
|
||||
*
|
||||
* @param requestBody 请求体(orderId + type: 1=人工出票, 2=退订确认, 3=退订拒绝, 4=凭证变更)
|
||||
* @return 响应
|
||||
*/
|
||||
Map<String, Object> simulateConfirm(Map<String, Object> requestBody);
|
||||
|
||||
/**
|
||||
* 获取位置列表
|
||||
*
|
||||
* @param pageIndex 页码
|
||||
* @param pageSize 每页数量
|
||||
* @return 位置列表
|
||||
*/
|
||||
Map<String, Object> getLocationList(int pageIndex, int pageSize);
|
||||
|
||||
/**
|
||||
* 获取产品列表
|
||||
*
|
||||
* @param request 请求参数
|
||||
* @return 产品列表
|
||||
*/
|
||||
Map<String, Object> getProductList(Map<String, Object> request);
|
||||
|
||||
/**
|
||||
* 获取产品全量列表
|
||||
*
|
||||
* @param business 业务类型(如 ACTIVITY)
|
||||
* @param lastMaxId 上次返回的maxId,首次传"0"
|
||||
* @param limit 每页条数
|
||||
* @return 产品全量列表
|
||||
*/
|
||||
Map<String, Object> getAllProducts(String business, String lastMaxId, int limit);
|
||||
}
|
||||
-37
@@ -1,37 +0,0 @@
|
||||
package com.central.coupon.service;
|
||||
|
||||
import com.central.coupon.entity.CtripDistOrder;
|
||||
|
||||
/**
|
||||
* 携程分销商订单服务
|
||||
*/
|
||||
public interface ICtripDistOrderService {
|
||||
|
||||
/**
|
||||
* 创建携程分销商订单
|
||||
*
|
||||
* @param orderNo 本地订单号
|
||||
* @param orderAmount 订单金额,单位分
|
||||
* @param ctripProductId 携程产品ID
|
||||
* @param tenantId 租户ID
|
||||
* @param mobile 用户手机号(可为null,为null时使用默认值)
|
||||
*/
|
||||
void createCtripDistOrder(String orderNo, String orderAmount, Long ctripProductId, String tenantId, String mobile);
|
||||
|
||||
/**
|
||||
* 取消携程分销商订单
|
||||
*
|
||||
* @param orderNo 本地订单号
|
||||
* @param reason 取消原因
|
||||
* @return 是否取消成功
|
||||
*/
|
||||
boolean cancelCtripDistOrder(String orderNo, String reason);
|
||||
|
||||
/**
|
||||
* 根据订单号查询订单
|
||||
*
|
||||
* @param orderNo 本地订单号
|
||||
* @return 分销商订单
|
||||
*/
|
||||
CtripDistOrder getByOrderNo(String orderNo);
|
||||
}
|
||||
-14
@@ -1,14 +0,0 @@
|
||||
package com.central.coupon.service;
|
||||
|
||||
/**
|
||||
* 携程分销商Token管理服务
|
||||
*/
|
||||
public interface ICtripDistTokenService {
|
||||
|
||||
/**
|
||||
* 获取有效的AccessToken(自动刷新)
|
||||
*
|
||||
* @return 有效的AccessToken
|
||||
*/
|
||||
String getAccessToken();
|
||||
}
|
||||
-372
@@ -1,372 +0,0 @@
|
||||
package com.central.coupon.service.impl;
|
||||
|
||||
import com.central.common.model.Result;
|
||||
import com.central.coupon.entity.CtripOrder;
|
||||
import com.central.coupon.entity.CtripOrderItem;
|
||||
import com.central.coupon.entity.CtripRefund;
|
||||
import com.central.coupon.entity.CtripRefundItem;
|
||||
import com.central.coupon.enums.CtripOrderStatus;
|
||||
import com.central.coupon.feign.OrderCenterService;
|
||||
import com.central.coupon.mapper.CtripOrderItemMapper;
|
||||
import com.central.coupon.mapper.CtripOrderMapper;
|
||||
import com.central.coupon.mapper.CtripRefundItemMapper;
|
||||
import com.central.coupon.mapper.CtripRefundMapper;
|
||||
import com.central.coupon.model.CtripAdminRefundRequest;
|
||||
import com.central.coupon.service.ICtripAdminRefundService;
|
||||
import com.central.coupon.service.ICtripApiService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* 携程管理后台退款服务实现
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class CtripAdminRefundServiceImpl implements ICtripAdminRefundService {
|
||||
|
||||
@Autowired
|
||||
private CtripOrderMapper ctripOrderMapper;
|
||||
|
||||
@Autowired
|
||||
private CtripOrderItemMapper ctripOrderItemMapper;
|
||||
|
||||
@Autowired
|
||||
private CtripRefundMapper ctripRefundMapper;
|
||||
|
||||
@Autowired
|
||||
private CtripRefundItemMapper ctripRefundItemMapper;
|
||||
|
||||
@Autowired
|
||||
private ICtripApiService ctripApiService;
|
||||
|
||||
@Autowired
|
||||
private OrderCenterService orderCenterService;
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Result<String> processAdminRefund(CtripAdminRefundRequest request) {
|
||||
log.info("管理后台发起携程退款,orderNo: {}, refundAmount: {}",
|
||||
request.getOrderNo(), request.getRefundAmount());
|
||||
|
||||
// 1. 验证参数
|
||||
if (request.getOrderNo() == null || request.getOrderNo().trim().isEmpty()) {
|
||||
return Result.failed("订单号不能为空");
|
||||
}
|
||||
if (request.getRefundAmount() == null || request.getRefundAmount().compareTo(BigDecimal.ZERO) <= 0) {
|
||||
return Result.failed("退款金额必须大于0");
|
||||
}
|
||||
|
||||
// 2. 根据orderNo查询携程订单
|
||||
CtripOrder ctripOrder = ctripOrderMapper.selectByOrderNo(request.getOrderNo());
|
||||
if (ctripOrder == null) {
|
||||
return Result.failed("未找到关联的携程订单,orderNo: " + request.getOrderNo());
|
||||
}
|
||||
|
||||
log.info("找到携程订单,otaOrderId: {}, orderNo: {}", ctripOrder.getOtaOrderId(), ctripOrder.getOrderNo());
|
||||
|
||||
// 3. 检查订单状态是否可退款
|
||||
if (!canRefundByCtripOrder(ctripOrder)) {
|
||||
return Result.failed("订单状态不支持退款,当前状态: " + getOrderStatusDesc(ctripOrder.getStatus()));
|
||||
}
|
||||
|
||||
// 4. 验证退款金额
|
||||
BigDecimal availableAmount = getAvailableRefundAmountByCtripOrder(ctripOrder);
|
||||
if (request.getRefundAmount().compareTo(availableAmount) > 0) {
|
||||
return Result.failed("退款金额超过可退金额,可退金额: " + availableAmount);
|
||||
}
|
||||
|
||||
// 5. 生成sequenceId
|
||||
String sequenceId = LocalDateTime.now().format(java.time.format.DateTimeFormatter.ofPattern("yyyyMMdd"))
|
||||
+ UUID.randomUUID().toString().replace("-", "");
|
||||
|
||||
// 6. 构建退款项参数(用于调用携程API)
|
||||
List<Map<String, Object>> refundItems = new ArrayList<>();
|
||||
List<CtripOrderItem> orderItems = ctripOrderItemMapper.selectByOrderId(ctripOrder.getId());
|
||||
if (request.getItems() != null && !request.getItems().isEmpty()) {
|
||||
for (CtripAdminRefundRequest.RefundItem item : request.getItems()) {
|
||||
Map<String, Object> itemMap = new HashMap<>();
|
||||
itemMap.put("itemId", item.getItemId());
|
||||
if (item.getPlu() != null) {
|
||||
itemMap.put("PLU", item.getPlu());
|
||||
}
|
||||
itemMap.put("amount", item.getAmount());
|
||||
itemMap.put("amountCurrency", item.getAmountCurrency() != null ? item.getAmountCurrency() : "CNY");
|
||||
refundItems.add(itemMap);
|
||||
}
|
||||
} else if (orderItems != null && !orderItems.isEmpty()) {
|
||||
for (CtripOrderItem orderItem : orderItems) {
|
||||
BigDecimal itemRefundAmount = request.getRefundAmount();
|
||||
if (ctripOrder.getTotalAmount() != null && ctripOrder.getTotalAmount().compareTo(BigDecimal.ZERO) > 0
|
||||
&& orderItem.getTotalPrice() != null) {
|
||||
itemRefundAmount = request.getRefundAmount()
|
||||
.multiply(orderItem.getTotalPrice())
|
||||
.divide(ctripOrder.getTotalAmount(), 2, BigDecimal.ROUND_HALF_UP);
|
||||
}
|
||||
Map<String, Object> itemMap = new HashMap<>();
|
||||
itemMap.put("itemId", orderItem.getItemId());
|
||||
if (orderItem.getPlu() != null) {
|
||||
itemMap.put("PLU", orderItem.getPlu());
|
||||
}
|
||||
itemMap.put("amount", itemRefundAmount);
|
||||
itemMap.put("amountCurrency", "CNY");
|
||||
refundItems.add(itemMap);
|
||||
}
|
||||
}
|
||||
|
||||
// 7. 先调用携程退款API(API调用失败则不保存数据库记录)
|
||||
log.info("开始调用携程退款API,otaOrderId: {}", ctripOrder.getOtaOrderId());
|
||||
int refundResult = ctripApiService.sendRefundOrder(
|
||||
ctripOrder.getOtaOrderId(),
|
||||
ctripOrder.getSupplierOrderId(),
|
||||
request.getRefundAmount(),
|
||||
"CNY",
|
||||
refundItems.isEmpty() ? null : refundItems
|
||||
);
|
||||
|
||||
if (refundResult == 0) {
|
||||
log.error("调用携程退款API失败,otaOrderId: {}", ctripOrder.getOtaOrderId());
|
||||
return Result.failed("调用携程退款接口失败");
|
||||
}
|
||||
log.info("携程退款API调用成功,refundResult: {}", refundResult);
|
||||
|
||||
// 8. API调用成功后,创建退款记录 t_ctrip_refund
|
||||
CtripRefund ctripRefund = new CtripRefund();
|
||||
ctripRefund.setOtaOrderId(ctripOrder.getOtaOrderId());
|
||||
ctripRefund.setSupplierOrderId(ctripOrder.getSupplierOrderId());
|
||||
ctripRefund.setSequenceId(sequenceId);
|
||||
ctripRefund.setRefundAmount(request.getRefundAmount());
|
||||
ctripRefund.setCurrency("CNY");
|
||||
ctripRefund.setCreateTime(LocalDateTime.now());
|
||||
ctripRefund.setUpdateTime(LocalDateTime.now());
|
||||
ctripRefund.setCreateBy("ADMIN");
|
||||
ctripRefund.setUpdateBy("ADMIN");
|
||||
ctripRefund.setRemark(request.getRefundReason() != null ? request.getRefundReason() : "管理后台发起退款");
|
||||
ctripRefund.setTenantId(ctripOrder.getTenantId());
|
||||
|
||||
// 根据API返回结果设置退款状态
|
||||
if (refundResult == 1) {
|
||||
ctripRefund.setRefundStatus(1); // 已确认
|
||||
ctripRefund.setConfirmResultCode("0000");
|
||||
ctripRefund.setConfirmResultMessage("退款已确认");
|
||||
} else {
|
||||
ctripRefund.setRefundStatus(0); // 待确认
|
||||
ctripRefund.setConfirmResultCode("0000");
|
||||
ctripRefund.setConfirmResultMessage("退款待确认");
|
||||
}
|
||||
|
||||
int insertResult = ctripRefundMapper.insert(ctripRefund);
|
||||
if (insertResult <= 0) {
|
||||
log.error("创建退款记录失败");
|
||||
throw new RuntimeException("创建退款记录失败");
|
||||
}
|
||||
log.info("创建携程退款记录成功,refundId: {}", ctripRefund.getId());
|
||||
|
||||
// 9. 创建退款项记录 t_ctrip_refund_item
|
||||
if (request.getItems() != null && !request.getItems().isEmpty()) {
|
||||
for (CtripAdminRefundRequest.RefundItem item : request.getItems()) {
|
||||
CtripRefundItem refundItem = new CtripRefundItem();
|
||||
refundItem.setRefundId(ctripRefund.getId());
|
||||
refundItem.setItemId(item.getItemId());
|
||||
refundItem.setPlu(item.getPlu());
|
||||
refundItem.setRefundAmount(item.getAmount());
|
||||
refundItem.setCurrency(item.getAmountCurrency() != null ? item.getAmountCurrency() : "CNY");
|
||||
refundItem.setCreateTime(LocalDateTime.now());
|
||||
refundItem.setUpdateTime(LocalDateTime.now());
|
||||
refundItem.setDeleted(0);
|
||||
ctripRefundItemMapper.insert(refundItem);
|
||||
}
|
||||
} else if (orderItems != null && !orderItems.isEmpty()) {
|
||||
for (CtripOrderItem orderItem : orderItems) {
|
||||
BigDecimal itemRefundAmount = request.getRefundAmount();
|
||||
if (ctripOrder.getTotalAmount() != null && ctripOrder.getTotalAmount().compareTo(BigDecimal.ZERO) > 0
|
||||
&& orderItem.getTotalPrice() != null) {
|
||||
itemRefundAmount = request.getRefundAmount()
|
||||
.multiply(orderItem.getTotalPrice())
|
||||
.divide(ctripOrder.getTotalAmount(), 2, BigDecimal.ROUND_HALF_UP);
|
||||
}
|
||||
CtripRefundItem refundItem = new CtripRefundItem();
|
||||
refundItem.setRefundId(ctripRefund.getId());
|
||||
refundItem.setItemId(orderItem.getItemId());
|
||||
refundItem.setPlu(orderItem.getPlu());
|
||||
refundItem.setRefundAmount(itemRefundAmount);
|
||||
refundItem.setCurrency("CNY");
|
||||
refundItem.setCreateTime(LocalDateTime.now());
|
||||
refundItem.setUpdateTime(LocalDateTime.now());
|
||||
refundItem.setDeleted(0);
|
||||
ctripRefundItemMapper.insert(refundItem);
|
||||
}
|
||||
}
|
||||
log.info("创建携程退款项记录成功");
|
||||
|
||||
// 10. 更新携程订单状态(使用管理后台退款专用状态)
|
||||
if (refundResult == 1) {
|
||||
// 判断是全额退款还是部分退款
|
||||
if (request.getRefundAmount().compareTo(ctripOrder.getTotalAmount()) >= 0) {
|
||||
ctripOrder.setStatus(CtripOrderStatus.ADMIN_REFUNDED.getNumericValue()); // 16-已退款(管理后台)
|
||||
} else {
|
||||
ctripOrder.setStatus(CtripOrderStatus.ADMIN_PART_REFUNDED.getNumericValue()); // 17-部分退款(管理后台)
|
||||
}
|
||||
} else {
|
||||
ctripOrder.setStatus(CtripOrderStatus.ADMIN_REFUNDING.getNumericValue()); // 15-退款中(管理后台)
|
||||
}
|
||||
ctripOrder.setUpdateTime(LocalDateTime.now());
|
||||
ctripOrder.setUpdateBy("ADMIN");
|
||||
ctripOrderMapper.updateById(ctripOrder);
|
||||
|
||||
// 11. 更新order-center的订单和退款表状态
|
||||
try {
|
||||
if (refundResult == 1) {
|
||||
Result<String> orderResult = orderCenterService.updateOrderStatusToRefunded(request.getOrderNo());
|
||||
if (orderResult != null && orderResult.getResp_code() == 0) {
|
||||
log.info("更新order-center订单状态为已退款成功,orderNo: {}", request.getOrderNo());
|
||||
} else {
|
||||
log.warn("更新order-center订单状态失败,orderNo: {}", request.getOrderNo());
|
||||
}
|
||||
} else {
|
||||
Result<String> orderResult = orderCenterService.updateOrderStatusToRefunding(request.getOrderNo());
|
||||
if (orderResult != null && orderResult.getResp_code() == 0) {
|
||||
log.info("更新order-center订单状态为退款中成功,orderNo: {}", request.getOrderNo());
|
||||
} else {
|
||||
log.warn("更新order-center订单状态失败,orderNo: {}", request.getOrderNo());
|
||||
}
|
||||
}
|
||||
// 创建退款记录
|
||||
Map<String, Object> refundInfo = new HashMap<>();
|
||||
refundInfo.put("refundAmount", request.getRefundAmount().toString());
|
||||
refundInfo.put("refundReason", request.getRefundReason() != null ? request.getRefundReason() : "携程退款");
|
||||
refundInfo.put("refundStatus", refundResult == 1 ? 1 : 0);
|
||||
Result<String> refundRecordResult = orderCenterService.createCtripRefund(request.getOrderNo(), refundInfo);
|
||||
if (refundRecordResult != null && refundRecordResult.getResp_code() == 0) {
|
||||
log.info("创建order-center退款记录成功,orderNo: {}", request.getOrderNo());
|
||||
} else {
|
||||
log.warn("创建order-center退款记录失败,orderNo: {}", request.getOrderNo());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("更新order-center状态异常,orderNo: {}", request.getOrderNo(), e);
|
||||
// 不影响主流程
|
||||
}
|
||||
|
||||
String message = refundResult == 1 ? "退款成功" : "退款申请已提交,等待携程确认";
|
||||
log.info("管理后台携程退款处理完成,orderNo: {}, otaOrderId: {}, result: {}",
|
||||
request.getOrderNo(), ctripOrder.getOtaOrderId(), message);
|
||||
return Result.succeed(message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BigDecimal getAvailableRefundAmount(String orderNo) {
|
||||
log.info("获取可退金额,orderNo: {}", orderNo);
|
||||
|
||||
try {
|
||||
// 根据orderNo查询携程订单
|
||||
CtripOrder ctripOrder = ctripOrderMapper.selectByOrderNo(orderNo);
|
||||
if (ctripOrder == null) {
|
||||
log.warn("未找到关联的携程订单,orderNo: {}", orderNo);
|
||||
return BigDecimal.ZERO;
|
||||
}
|
||||
|
||||
return getAvailableRefundAmountByCtripOrder(ctripOrder);
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("获取可退金额异常,orderNo: {}", orderNo, e);
|
||||
return BigDecimal.ZERO;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canRefund(String orderNo) {
|
||||
try {
|
||||
CtripOrder ctripOrder = ctripOrderMapper.selectByOrderNo(orderNo);
|
||||
if (ctripOrder == null) {
|
||||
return false;
|
||||
}
|
||||
return canRefundByCtripOrder(ctripOrder);
|
||||
} catch (Exception e) {
|
||||
log.error("检查订单是否可退款异常,orderNo: {}", orderNo, e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据携程订单获取可退金额
|
||||
*/
|
||||
private BigDecimal getAvailableRefundAmountByCtripOrder(CtripOrder ctripOrder) {
|
||||
// 检查订单状态
|
||||
if (!canRefundByCtripOrder(ctripOrder)) {
|
||||
log.warn("订单状态不支持退款,otaOrderId: {}, status: {}", ctripOrder.getOtaOrderId(), ctripOrder.getStatus());
|
||||
return BigDecimal.ZERO;
|
||||
}
|
||||
|
||||
// 计算已退款金额
|
||||
BigDecimal refundedAmount = getRefundedAmount(ctripOrder.getOtaOrderId());
|
||||
|
||||
// 可退金额 = 订单总金额 - 已退款金额
|
||||
BigDecimal totalAmount = ctripOrder.getTotalAmount() != null ? ctripOrder.getTotalAmount() : BigDecimal.ZERO;
|
||||
BigDecimal availableAmount = totalAmount.subtract(refundedAmount);
|
||||
|
||||
log.info("可退金额计算: 订单总金额={}, 已退款金额={}, 可退金额={}",
|
||||
totalAmount, refundedAmount, availableAmount);
|
||||
|
||||
return availableAmount.compareTo(BigDecimal.ZERO) > 0 ? availableAmount : BigDecimal.ZERO;
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查携程订单是否可退款
|
||||
*/
|
||||
private boolean canRefundByCtripOrder(CtripOrder ctripOrder) {
|
||||
if (ctripOrder.getStatus() == null) {
|
||||
return false;
|
||||
}
|
||||
int status = ctripOrder.getStatus();
|
||||
// 可退款的状态:已确认、部分使用、全部使用、部分退款(管理后台)
|
||||
return status == CtripOrderStatus.CONFIRMED.getNumericValue()
|
||||
|| status == CtripOrderStatus.PARTIAL_USED.getNumericValue()
|
||||
|| status == CtripOrderStatus.FULLY_USED.getNumericValue()
|
||||
|| status == CtripOrderStatus.ADMIN_PART_REFUNDED.getNumericValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取已退款金额
|
||||
*/
|
||||
private BigDecimal getRefundedAmount(String otaOrderId) {
|
||||
try {
|
||||
List<CtripRefund> refunds = ctripRefundMapper.selectByOtaOrderId(otaOrderId);
|
||||
BigDecimal totalRefunded = BigDecimal.ZERO;
|
||||
|
||||
for (CtripRefund refund : refunds) {
|
||||
// 只计算已确认的退款
|
||||
if (refund.getRefundStatus() != null && refund.getRefundStatus() == 1) {
|
||||
totalRefunded = totalRefunded.add(refund.getRefundAmount());
|
||||
}
|
||||
}
|
||||
|
||||
return totalRefunded;
|
||||
} catch (Exception e) {
|
||||
log.error("获取已退款金额异常,otaOrderId: {}", otaOrderId, e);
|
||||
return BigDecimal.ZERO;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取订单状态描述
|
||||
*/
|
||||
private String getOrderStatusDesc(Integer status) {
|
||||
if (status == null) {
|
||||
return "未知";
|
||||
}
|
||||
try {
|
||||
return CtripOrderStatus.fromNumericValue(status).getDescription();
|
||||
} catch (IllegalArgumentException e) {
|
||||
return "未知状态";
|
||||
}
|
||||
}
|
||||
}
|
||||
+40
-165
@@ -1,6 +1,5 @@
|
||||
package com.central.coupon.service.impl;
|
||||
|
||||
import com.central.coupon.config.CtripApiConfig;
|
||||
import com.central.coupon.service.ICtripApiService;
|
||||
import com.central.coupon.util.CtripDecryptUtil;
|
||||
import com.central.coupon.mapper.CtripOrderItemMapper;
|
||||
@@ -10,6 +9,7 @@ import com.central.coupon.entity.CtripOrder;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.http.*;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
@@ -42,8 +42,20 @@ public class CtripApiServiceImpl implements ICtripApiService {
|
||||
@Autowired
|
||||
private CtripOrderMapper ctripOrderMapper;
|
||||
|
||||
@Autowired
|
||||
private CtripApiConfig ctripApiConfig;
|
||||
@Value("${ctrip.api.base-url:https://api.ctrip.com}")
|
||||
private String baseUrl;
|
||||
|
||||
@Value("${ctrip.api.timeout:30000}")
|
||||
private int timeout;
|
||||
|
||||
@Value("${ctrip.api.retry-times:3}")
|
||||
private int retryTimes;
|
||||
|
||||
@Value("${ctrip.account.id:your-account-id}")
|
||||
private String accountId;
|
||||
|
||||
@Value("${ctrip.account.secret:your-account-secret}")
|
||||
private String accountSecret;
|
||||
|
||||
@Override
|
||||
public boolean sendOrderConsumedNotice(String ctripCouponId, String orderNo) {
|
||||
@@ -114,7 +126,7 @@ public class CtripApiServiceImpl implements ICtripApiService {
|
||||
|
||||
// 构建header
|
||||
Map<String, Object> header = new HashMap<>();
|
||||
header.put("accountId", ctripApiConfig.getAccount().getId());
|
||||
header.put("accountId", accountId);
|
||||
header.put("serviceName", "OrderConsumedNotice");
|
||||
header.put("requestTime", java.time.LocalDateTime.now().format(java.time.format.DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
|
||||
header.put("version", "1.0");
|
||||
@@ -127,7 +139,7 @@ public class CtripApiServiceImpl implements ICtripApiService {
|
||||
return false;
|
||||
}
|
||||
|
||||
String sign = ctripDecryptUtil.generateSign(ctripApiConfig.getAccount().getId(), "OrderConsumedNotice",
|
||||
String sign = ctripDecryptUtil.generateSign(accountId, "OrderConsumedNotice",
|
||||
header.get("requestTime").toString(), encryptedBody, "1.0");
|
||||
header.put("sign", sign);
|
||||
|
||||
@@ -140,7 +152,7 @@ public class CtripApiServiceImpl implements ICtripApiService {
|
||||
try {
|
||||
String requestJson = objectMapper.writeValueAsString(request);
|
||||
log.info("=== Postman测试用请求体 ===");
|
||||
log.info("URL: {}", ctripApiConfig.getApi().getBaseUrl() + "/order/notice.do");
|
||||
log.info("URL: {}", baseUrl + "/order/notice.do");
|
||||
log.info("Method: POST");
|
||||
log.info("Headers: Content-Type: application/json");
|
||||
log.info("Body: {}", requestJson);
|
||||
@@ -150,7 +162,7 @@ public class CtripApiServiceImpl implements ICtripApiService {
|
||||
}
|
||||
|
||||
// 发送HTTP请求到携程API
|
||||
String url = ctripApiConfig.getApi().getBaseUrl() + "/order/notice.do";
|
||||
String url = baseUrl + "/order/notice.do";
|
||||
log.info("准备发送请求到URL: {}", url);
|
||||
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
@@ -162,7 +174,7 @@ public class CtripApiServiceImpl implements ICtripApiService {
|
||||
// 恢复实际网络调用
|
||||
log.info("开始发送实际网络请求到携程API");
|
||||
// 重试机制
|
||||
for (int i = 0; i < ctripApiConfig.getApi().getRetryTimes(); i++) {
|
||||
for (int i = 0; i < retryTimes; i++) {
|
||||
try {
|
||||
log.info("第{}次尝试调用携程API,URL: {}", i + 1, url);
|
||||
ResponseEntity<Map> response = restTemplate.postForEntity(url, httpRequest, Map.class);
|
||||
@@ -191,7 +203,7 @@ public class CtripApiServiceImpl implements ICtripApiService {
|
||||
log.error("携程订单核销通知接口调用异常,第{}次重试,ctripCouponId: {}, orderNo: {}", i + 1, ctripCouponId, orderNo, e);
|
||||
|
||||
// 如果是最后一次重试,记录详细错误信息
|
||||
if (i == ctripApiConfig.getApi().getRetryTimes() - 1) {
|
||||
if (i == retryTimes - 1) {
|
||||
log.error("所有重试都失败了,最后一次错误详情: {}", e.getMessage());
|
||||
throw e;
|
||||
}
|
||||
@@ -209,7 +221,7 @@ public class CtripApiServiceImpl implements ICtripApiService {
|
||||
}
|
||||
}
|
||||
|
||||
log.error("携程订单核销通知接口调用失败,已重试{}次,ctripCouponId: {}, orderNo: {}", ctripApiConfig.getApi().getRetryTimes(), ctripCouponId, orderNo);
|
||||
log.error("携程订单核销通知接口调用失败,已重试{}次,ctripCouponId: {}, orderNo: {}", retryTimes, ctripCouponId, orderNo);
|
||||
return false;
|
||||
|
||||
} catch (Exception e) {
|
||||
@@ -233,14 +245,14 @@ public class CtripApiServiceImpl implements ICtripApiService {
|
||||
log.info("携程查询请求参数: {}", requestParams);
|
||||
|
||||
// 发送HTTP请求到携程API
|
||||
String url = ctripApiConfig.getApi().getBaseUrl() + "/coupon/status";
|
||||
String url = baseUrl + "/coupon/status";
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.setContentType(MediaType.APPLICATION_JSON);
|
||||
headers.set("X-CTRIP-ACCOUNT-ID", ctripApiConfig.getAccount().getId());
|
||||
headers.set("X-CTRIP-ACCOUNT-ID", accountId);
|
||||
headers.set("X-CTRIP-TIMESTAMP", String.valueOf(System.currentTimeMillis()));
|
||||
|
||||
// 生成签名
|
||||
String sign = ctripDecryptUtil.generateSign(ctripApiConfig.getAccount().getId(), "GetCouponStatus",
|
||||
String sign = ctripDecryptUtil.generateSign(accountId, "GetCouponStatus",
|
||||
java.time.LocalDateTime.now().format(java.time.format.DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")),
|
||||
requestParams.toString(), "1.0");
|
||||
headers.set("X-CTRIP-SIGN", sign);
|
||||
@@ -248,7 +260,7 @@ public class CtripApiServiceImpl implements ICtripApiService {
|
||||
HttpEntity<Map<String, Object>> request = new HttpEntity<>(requestParams, headers);
|
||||
|
||||
// 重试机制
|
||||
for (int i = 0; i < ctripApiConfig.getApi().getRetryTimes(); i++) {
|
||||
for (int i = 0; i < retryTimes; i++) {
|
||||
try {
|
||||
ResponseEntity<Map> response = restTemplate.getForEntity(url, Map.class);
|
||||
|
||||
@@ -266,7 +278,7 @@ public class CtripApiServiceImpl implements ICtripApiService {
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("携程查询接口调用异常,第{}次重试,ctripCouponId: {}", i + 1, ctripCouponId, e);
|
||||
if (i == ctripApiConfig.getApi().getRetryTimes() - 1) {
|
||||
if (i == retryTimes - 1) {
|
||||
throw e;
|
||||
}
|
||||
// 等待后重试
|
||||
@@ -279,7 +291,7 @@ public class CtripApiServiceImpl implements ICtripApiService {
|
||||
}
|
||||
}
|
||||
|
||||
log.error("携程查询接口调用失败,已重试{}次,ctripCouponId: {}", ctripApiConfig.getApi().getRetryTimes(), ctripCouponId);
|
||||
log.error("携程查询接口调用失败,已重试{}次,ctripCouponId: {}", retryTimes, ctripCouponId);
|
||||
return "UNKNOWN";
|
||||
|
||||
} catch (Exception e) {
|
||||
@@ -314,14 +326,14 @@ public class CtripApiServiceImpl implements ICtripApiService {
|
||||
log.info("携程创建优惠券请求参数: {}", requestParams);
|
||||
|
||||
// 发送HTTP请求到携程API
|
||||
String url = ctripApiConfig.getApi().getBaseUrl() + "/coupon/create";
|
||||
String url = baseUrl + "/coupon/create";
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.setContentType(MediaType.APPLICATION_JSON);
|
||||
headers.set("X-CTRIP-ACCOUNT-ID", ctripApiConfig.getAccount().getId());
|
||||
headers.set("X-CTRIP-ACCOUNT-ID", accountId);
|
||||
headers.set("X-CTRIP-TIMESTAMP", String.valueOf(System.currentTimeMillis()));
|
||||
|
||||
// 生成签名
|
||||
String sign = ctripDecryptUtil.generateSign(ctripApiConfig.getAccount().getId(), "CreateCoupon",
|
||||
String sign = ctripDecryptUtil.generateSign(accountId, "CreateCoupon",
|
||||
java.time.LocalDateTime.now().format(java.time.format.DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")),
|
||||
requestParams.toString(), "1.0");
|
||||
headers.set("X-CTRIP-SIGN", sign);
|
||||
@@ -329,7 +341,7 @@ public class CtripApiServiceImpl implements ICtripApiService {
|
||||
HttpEntity<Map<String, Object>> request = new HttpEntity<>(requestParams, headers);
|
||||
|
||||
// 重试机制
|
||||
for (int i = 0; i < ctripApiConfig.getApi().getRetryTimes(); i++) {
|
||||
for (int i = 0; i < retryTimes; i++) {
|
||||
try {
|
||||
ResponseEntity<Map> response = restTemplate.postForEntity(url, request, Map.class);
|
||||
|
||||
@@ -346,7 +358,7 @@ public class CtripApiServiceImpl implements ICtripApiService {
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("携程创建优惠券接口调用异常,第{}次重试,ctripCouponId: {}, userPhone: {}", i + 1, ctripCouponId, userPhone, e);
|
||||
if (i == ctripApiConfig.getApi().getRetryTimes() - 1) {
|
||||
if (i == retryTimes - 1) {
|
||||
throw e;
|
||||
}
|
||||
// 等待后重试
|
||||
@@ -359,7 +371,7 @@ public class CtripApiServiceImpl implements ICtripApiService {
|
||||
}
|
||||
}
|
||||
|
||||
log.error("携程创建优惠券接口调用失败,已重试{}次,ctripCouponId: {}, userPhone: {}", ctripApiConfig.getApi().getRetryTimes(), ctripCouponId, userPhone);
|
||||
log.error("携程创建优惠券接口调用失败,已重试{}次,ctripCouponId: {}, userPhone: {}", retryTimes, ctripCouponId, userPhone);
|
||||
return false;
|
||||
|
||||
} catch (Exception e) {
|
||||
@@ -386,14 +398,14 @@ public class CtripApiServiceImpl implements ICtripApiService {
|
||||
log.info("携程取消优惠券请求参数: {}", requestParams);
|
||||
|
||||
// 发送HTTP请求到携程API
|
||||
String url = ctripApiConfig.getApi().getBaseUrl() + "/coupon/cancel";
|
||||
String url = baseUrl + "/coupon/cancel";
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.setContentType(MediaType.APPLICATION_JSON);
|
||||
headers.set("X-CTRIP-ACCOUNT-ID", ctripApiConfig.getAccount().getId());
|
||||
headers.set("X-CTRIP-ACCOUNT-ID", accountId);
|
||||
headers.set("X-CTRIP-TIMESTAMP", String.valueOf(System.currentTimeMillis()));
|
||||
|
||||
// 生成签名
|
||||
String sign = ctripDecryptUtil.generateSign(ctripApiConfig.getAccount().getId(), "CancelCoupon",
|
||||
String sign = ctripDecryptUtil.generateSign(accountId, "CancelCoupon",
|
||||
java.time.LocalDateTime.now().format(java.time.format.DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")),
|
||||
requestParams.toString(), "1.0");
|
||||
headers.set("X-CTRIP-SIGN", sign);
|
||||
@@ -401,7 +413,7 @@ public class CtripApiServiceImpl implements ICtripApiService {
|
||||
HttpEntity<Map<String, Object>> request = new HttpEntity<>(requestParams, headers);
|
||||
|
||||
// 重试机制
|
||||
for (int i = 0; i < ctripApiConfig.getApi().getRetryTimes(); i++) {
|
||||
for (int i = 0; i < retryTimes; i++) {
|
||||
try {
|
||||
ResponseEntity<Map> response = restTemplate.postForEntity(url, request, Map.class);
|
||||
|
||||
@@ -418,7 +430,7 @@ public class CtripApiServiceImpl implements ICtripApiService {
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("携程取消优惠券接口调用异常,第{}次重试,ctripCouponId: {}, userPhone: {}", i + 1, ctripCouponId, userPhone, e);
|
||||
if (i == ctripApiConfig.getApi().getRetryTimes() - 1) {
|
||||
if (i == retryTimes - 1) {
|
||||
throw e;
|
||||
}
|
||||
// 等待后重试
|
||||
@@ -431,7 +443,7 @@ public class CtripApiServiceImpl implements ICtripApiService {
|
||||
}
|
||||
}
|
||||
|
||||
log.error("携程取消优惠券接口调用失败,已重试{}次,ctripCouponId: {}, userPhone: {}", ctripApiConfig.getApi().getRetryTimes(), ctripCouponId, userPhone);
|
||||
log.error("携程取消优惠券接口调用失败,已重试{}次,ctripCouponId: {}, userPhone: {}", retryTimes, ctripCouponId, userPhone);
|
||||
return false;
|
||||
|
||||
} catch (Exception e) {
|
||||
@@ -545,141 +557,4 @@ public class CtripApiServiceImpl implements ICtripApiService {
|
||||
return true; // 临时返回true,避免阻塞业务逻辑
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int sendRefundOrder(String otaOrderId, String supplierOrderId,
|
||||
java.math.BigDecimal totalAmount, String currency,
|
||||
List<Map<String, Object>> items) {
|
||||
log.info("调用携程退款接口,otaOrderId: {}, supplierOrderId: {}, totalAmount: {}, currency: {}",
|
||||
otaOrderId, supplierOrderId, totalAmount, currency);
|
||||
|
||||
// 网络连接测试
|
||||
// if (!testNetworkConnection()) {
|
||||
// log.error("网络连接测试失败,无法访问携程API");
|
||||
// return 0;
|
||||
// }
|
||||
|
||||
try {
|
||||
// 构建请求体
|
||||
Map<String, Object> requestBody = new HashMap<>();
|
||||
// 生成sequenceId: 处理日期(yyyyMMdd) + 32位去分隔符的GUID
|
||||
String sequenceId = java.time.LocalDate.now().format(java.time.format.DateTimeFormatter.ofPattern("yyyyMMdd"))
|
||||
+ java.util.UUID.randomUUID().toString().replace("-", "");
|
||||
requestBody.put("sequenceId", sequenceId);
|
||||
requestBody.put("otaOrderId", otaOrderId);
|
||||
requestBody.put("supplierOrderId", supplierOrderId);
|
||||
requestBody.put("totalAmount", totalAmount);
|
||||
requestBody.put("totalAmountCurrency", currency != null ? currency : "CNY");
|
||||
|
||||
// 添加退款项(如果有)
|
||||
if (items != null && !items.isEmpty()) {
|
||||
requestBody.put("items", items);
|
||||
}
|
||||
|
||||
log.info("携程退款请求参数: {}", requestBody);
|
||||
|
||||
// 构建完整的请求(包含header和body)
|
||||
Map<String, Object> request = new HashMap<>();
|
||||
|
||||
// 构建header
|
||||
Map<String, Object> header = new HashMap<>();
|
||||
header.put("accountId", ctripApiConfig.getAccount().getId());
|
||||
header.put("serviceName", "RefundOrder");
|
||||
String requestTime = java.time.LocalDateTime.now().format(java.time.format.DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
||||
header.put("requestTime", requestTime);
|
||||
header.put("version", "1.0");
|
||||
|
||||
// 生成签名和加密body
|
||||
String bodyJson = objectMapper.writeValueAsString(requestBody);
|
||||
String encryptedBody = ctripDecryptUtil.encryptAES(bodyJson);
|
||||
if (encryptedBody == null) {
|
||||
log.error("加密请求body失败");
|
||||
return 0;
|
||||
}
|
||||
|
||||
String sign = ctripDecryptUtil.generateSign(ctripApiConfig.getAccount().getId(), "RefundOrder",
|
||||
requestTime, encryptedBody, "1.0");
|
||||
header.put("sign", sign);
|
||||
|
||||
request.put("header", header);
|
||||
request.put("body", encryptedBody);
|
||||
|
||||
log.info("携程退款完整请求: {}", request);
|
||||
|
||||
// 发送HTTP请求到携程API
|
||||
String url = ctripApiConfig.getApi().getBaseUrl() + "/order/notice.do";
|
||||
log.info("准备发送退款请求到URL: {}", url);
|
||||
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.setContentType(MediaType.APPLICATION_JSON);
|
||||
headers.set("User-Agent", "CouponCenter/1.0");
|
||||
|
||||
HttpEntity<Map<String, Object>> httpRequest = new HttpEntity<>(request, headers);
|
||||
|
||||
// 重试机制
|
||||
for (int i = 0; i < ctripApiConfig.getApi().getRetryTimes(); i++) {
|
||||
try {
|
||||
log.info("第{}次尝试调用携程退款API,URL: {}", i + 1, url);
|
||||
ResponseEntity<Map> response = restTemplate.postForEntity(url, httpRequest, Map.class);
|
||||
|
||||
log.info("携程退款API响应状态码: {}", response.getStatusCode());
|
||||
|
||||
if (response.getStatusCode() == HttpStatus.OK) {
|
||||
Map<String, Object> responseBody = response.getBody();
|
||||
log.info("携程退款API响应内容: {}", responseBody);
|
||||
|
||||
if (responseBody != null) {
|
||||
Map<String, Object> responseHeader = (Map<String, Object>) responseBody.get("header");
|
||||
if (responseHeader != null && "0000".equals(responseHeader.get("resultCode"))) {
|
||||
// 解密响应body
|
||||
Object encryptedResponseBody = responseBody.get("body");
|
||||
if (encryptedResponseBody != null) {
|
||||
String decryptedBody = ctripDecryptUtil.decryptAES(encryptedResponseBody.toString());
|
||||
if (decryptedBody != null) {
|
||||
Map<String, Object> bodyMap = objectMapper.readValue(decryptedBody, Map.class);
|
||||
Integer supplierConfirmType = (Integer) bodyMap.get("supplierConfirmType");
|
||||
log.info("携程退款接口调用成功,supplierConfirmType: {}", supplierConfirmType);
|
||||
return supplierConfirmType != null ? supplierConfirmType : 1;
|
||||
}
|
||||
}
|
||||
log.info("携程退款接口调用成功,otaOrderId: {}", otaOrderId);
|
||||
return 1; // 默认返回已确认
|
||||
} else {
|
||||
String resultCode = responseHeader != null ? (String) responseHeader.get("resultCode") : "null";
|
||||
String resultMessage = responseHeader != null ? (String) responseHeader.get("resultMessage") : "null";
|
||||
log.warn("携程退款接口返回失败,resultCode: {}, resultMessage: {}", resultCode, resultMessage);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
log.warn("携程退款接口HTTP状态码异常,status: {}", response.getStatusCode());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("携程退款接口调用异常,第{}次重试,otaOrderId: {}", i + 1, otaOrderId, e);
|
||||
|
||||
if (i == ctripApiConfig.getApi().getRetryTimes() - 1) {
|
||||
log.error("所有重试都失败了,最后一次错误详情: {}", e.getMessage());
|
||||
throw e;
|
||||
}
|
||||
|
||||
// 等待后重试,使用指数退避
|
||||
int waitTime = 1000 * (i + 1) * (i + 1);
|
||||
log.info("等待{}毫秒后进行第{}次重试", waitTime, i + 2);
|
||||
try {
|
||||
Thread.sleep(waitTime);
|
||||
} catch (InterruptedException ie) {
|
||||
Thread.currentThread().interrupt();
|
||||
log.warn("重试等待被中断");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
log.error("携程退款接口调用失败,已重试{}次,otaOrderId: {}", ctripApiConfig.getApi().getRetryTimes(), otaOrderId);
|
||||
return 0;
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("携程退款接口调用失败,otaOrderId: {}", otaOrderId, e);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
-177
@@ -1,177 +0,0 @@
|
||||
package com.central.coupon.service.impl;
|
||||
|
||||
import com.central.common.utils.http.SimpleHttpRequest;
|
||||
import com.central.coupon.config.CtripDistributorConfig;
|
||||
import com.central.coupon.model.CtripDistBookRequest;
|
||||
import com.central.coupon.model.CtripDistBookResponse;
|
||||
import com.central.coupon.model.CtripDistBookingDetailResponse;
|
||||
import com.central.coupon.model.CtripDistCancelResponse;
|
||||
import com.central.coupon.model.CtripDistCancelVerifyResponse;
|
||||
import com.central.coupon.service.ICtripDistApiService;
|
||||
import com.central.coupon.service.ICtripDistTokenService;
|
||||
import com.central.coupon.util.SslUtil;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* 携程分销商API服务实现
|
||||
* 使用SimpleHttpRequest替代RestTemplate,解决HTTPS连接兼容性问题
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class CtripDistApiServiceImpl implements ICtripDistApiService {
|
||||
|
||||
@Autowired
|
||||
private CtripDistributorConfig config;
|
||||
|
||||
@Autowired
|
||||
private ICtripDistTokenService tokenService;
|
||||
|
||||
@Autowired
|
||||
private ObjectMapper objectMapper;
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getProductDetail(Long productId) {
|
||||
Map<String, Object> requestBody = new HashMap<>();
|
||||
requestBody.put("locale", config.getLocale());
|
||||
requestBody.put("currency", config.getCurrency());
|
||||
requestBody.put("productIDList", Collections.singletonList(productId));
|
||||
return callApi(config.getIcode().getProductDetail(), requestBody, Map.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getBookInfo(Long productId, Long packageId, Long resourceId) {
|
||||
Map<String, Object> requestBody = new HashMap<>();
|
||||
requestBody.put("locale", config.getLocale());
|
||||
requestBody.put("currency", config.getCurrency());
|
||||
requestBody.put("productID", productId);
|
||||
requestBody.put("packageID", packageId);
|
||||
requestBody.put("resourceID", resourceId);
|
||||
return callApi(config.getIcode().getBookInfo(), requestBody, Map.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CtripDistBookResponse createOrder(CtripDistBookRequest request) {
|
||||
return callApi(config.getIcode().getBook(), request, CtripDistBookResponse.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CtripDistCancelVerifyResponse cancelVerify(Long ctripOrderId) {
|
||||
Map<String, Object> requestBody = new HashMap<>();
|
||||
requestBody.put("orderId", ctripOrderId);
|
||||
requestBody.put("locale", config.getLocale());
|
||||
return callApi(config.getIcode().getCancelVerify(), requestBody, CtripDistCancelVerifyResponse.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CtripDistCancelResponse cancelOrder(Long ctripOrderId, String reason) {
|
||||
Map<String, Object> requestBody = new HashMap<>();
|
||||
requestBody.put("orderId", ctripOrderId);
|
||||
requestBody.put("reason", reason);
|
||||
return callApi(config.getIcode().getCancel(), requestBody, CtripDistCancelResponse.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CtripDistCancelResponse cancelOrderPartial(Long ctripOrderId, String reason, java.util.List<Map<String, Object>> cancelOrderItems) {
|
||||
Map<String, Object> requestBody = new HashMap<>();
|
||||
requestBody.put("orderId", ctripOrderId);
|
||||
requestBody.put("reason", reason);
|
||||
requestBody.put("cancelOrderItems", cancelOrderItems);
|
||||
return callApi(config.getIcode().getCancel(), requestBody, CtripDistCancelResponse.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CtripDistBookingDetailResponse getOrderDetail(Long ctripOrderId) {
|
||||
Map<String, Object> requestBody = new HashMap<>();
|
||||
requestBody.put("orderID", ctripOrderId);
|
||||
return callApi(config.getIcode().getBookingDetail(), requestBody, CtripDistBookingDetailResponse.class);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public boolean checkAvailability(CtripDistBookRequest request) {
|
||||
Map<String, Object> response = callApi(config.getIcode().getCheckAvailability(), request, Map.class);
|
||||
log.info("可订检查完整响应: {}", response);
|
||||
Object success = response.get("success");
|
||||
if (success == null || !Boolean.parseBoolean(success.toString())) {
|
||||
log.warn("可订检查失败, success={}, errcode={}, errmsg={}",
|
||||
success, response.get("errcode"), response.get("errmsg"));
|
||||
}
|
||||
return success != null && Boolean.parseBoolean(success.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> simulateCtripCancel(Map<String, Object> requestBody) {
|
||||
return callApi(config.getIcode().getSimulateCancel(), requestBody, Map.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> simulateConfirm(Map<String, Object> requestBody) {
|
||||
return callApi(config.getIcode().getSimulateConfirm(), requestBody, Map.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getLocationList(int pageIndex, int pageSize) {
|
||||
Map<String, Object> requestBody = new HashMap<>();
|
||||
requestBody.put("locale", "zh-CN");
|
||||
requestBody.put("pageIndex", pageIndex);
|
||||
requestBody.put("pageSize", pageSize);
|
||||
return callApi(config.getIcode().getLocationList(), requestBody, Map.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getProductList(Map<String, Object> request) {
|
||||
return callApi(config.getIcode().getProductList(), request, Map.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getAllProducts(String business, String lastMaxId, int limit) {
|
||||
Map<String, Object> requestBody = new HashMap<>();
|
||||
requestBody.put("business", business);
|
||||
requestBody.put("lastMaxId", lastMaxId);
|
||||
requestBody.put("limit", limit);
|
||||
return callApi(config.getIcode().getAllProducts(), requestBody, Map.class);
|
||||
}
|
||||
|
||||
private <T> T callApi(String icode, Object requestBody, Class<T> responseType) {
|
||||
String token = tokenService.getAccessToken();
|
||||
String uuid = UUID.randomUUID().toString().replace("-", "");
|
||||
String url = String.format("%s?aid=%s&sid=%s&icode=%s&uuid=%s&token=%s",
|
||||
config.getApiUrl(), config.getAid(), config.getSid(), icode, uuid, token);
|
||||
log.info("请求地址是:{}",url);
|
||||
String requestJson;
|
||||
try {
|
||||
requestJson = objectMapper.writeValueAsString(requestBody);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("请求体序列化失败: " + e.getMessage(), e);
|
||||
}
|
||||
|
||||
log.info("调用携程分销商接口,icode: {}, uuid: {}, requestBody: {}", icode, uuid, requestJson);
|
||||
|
||||
String responseBody;
|
||||
try {
|
||||
SimpleHttpRequest request = new SimpleHttpRequest(url, SslUtil.createTrustAllHttpClient());
|
||||
request.requestBody(requestJson);
|
||||
byte[] bytes = request.post().asBytes();
|
||||
request.close();
|
||||
responseBody = new String(bytes, "UTF-8");
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("携程分销商接口HTTP请求失败: " + e.getMessage(), e);
|
||||
}
|
||||
|
||||
log.info("携程分销商接口响应,icode: {}, response: {}", icode, responseBody);
|
||||
|
||||
try {
|
||||
return objectMapper.readValue(responseBody, responseType);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("携程分销商接口响应反序列化失败: " + e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
-343
@@ -1,343 +0,0 @@
|
||||
package com.central.coupon.service.impl;
|
||||
|
||||
import com.central.coupon.config.CtripDistributorConfig;
|
||||
import com.central.coupon.entity.CtripDistOrder;
|
||||
import com.central.coupon.mapper.CtripDistOrderMapper;
|
||||
import com.central.coupon.model.CtripDistBookRequest;
|
||||
import com.central.coupon.model.CtripDistBookResponse;
|
||||
import com.central.coupon.model.CtripDistCancelResponse;
|
||||
import com.central.coupon.model.CtripDistCancelVerifyResponse;
|
||||
import com.central.coupon.service.ICtripDistApiService;
|
||||
import com.central.coupon.service.ICtripDistOrderService;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
/**
|
||||
* 携程分销商订单服务实现
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class CtripDistOrderServiceImpl implements ICtripDistOrderService {
|
||||
|
||||
private static final DateTimeFormatter USE_DATE_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
||||
|
||||
@Autowired
|
||||
private ICtripDistApiService ctripDistApiService;
|
||||
|
||||
@Autowired
|
||||
private CtripDistOrderMapper ctripDistOrderMapper;
|
||||
|
||||
@Autowired
|
||||
private CtripDistributorConfig config;
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void createCtripDistOrder(String orderNo, String orderAmount, Long ctripProductId, String tenantId, String mobile) {
|
||||
CtripDistOrder existingOrder = ctripDistOrderMapper.selectByOrderNo(orderNo);
|
||||
if (existingOrder != null) {
|
||||
log.info("携程分销商订单已存在,orderNo: {}", orderNo);
|
||||
return;
|
||||
}
|
||||
|
||||
Map<String, Object> productDetail = ctripDistApiService.getProductDetail(ctripProductId);
|
||||
Long packageId = extractPackageId(productDetail);
|
||||
Long resourceId = extractResourceId(productDetail);
|
||||
Map<String, Object> bookInfo = ctripDistApiService.getBookInfo(ctripProductId, packageId, resourceId);
|
||||
log.info("携程分销商下单填写信息,orderNo: {}, bookInfo: {}", orderNo, bookInfo);
|
||||
|
||||
// 校验问卷是否属于当前支持自动填充的范围
|
||||
validateBookInfo(bookInfo, orderNo);
|
||||
|
||||
String distributorOrderId = orderNo;
|
||||
BigDecimal amountYuan = new BigDecimal(orderAmount).divide(new BigDecimal(100), 2, RoundingMode.HALF_UP);
|
||||
CtripDistBookRequest checkRequest = buildBookRequest(
|
||||
distributorOrderId, ctripProductId, packageId, resourceId, amountYuan, mobile, bookInfo, false);
|
||||
|
||||
// 可订检查:下单前确认资源可预订
|
||||
boolean available = ctripDistApiService.checkAvailability(checkRequest);
|
||||
if (!available) {
|
||||
throw new RuntimeException("携程可订检查失败,资源不可预订,orderNo: " + orderNo);
|
||||
}
|
||||
log.info("携程可订检查通过,orderNo: {}", orderNo);
|
||||
|
||||
CtripDistBookRequest createRequest = buildBookRequest(
|
||||
distributorOrderId, ctripProductId, packageId, resourceId, amountYuan, mobile, bookInfo, true);
|
||||
|
||||
CtripDistOrder order = new CtripDistOrder();
|
||||
order.setTenantId(tenantId);
|
||||
order.setOrderNo(orderNo);
|
||||
order.setCtripProductId(ctripProductId);
|
||||
order.setCtripPackageId(packageId);
|
||||
order.setCtripResourceId(resourceId);
|
||||
order.setDistributorOrderId(distributorOrderId);
|
||||
order.setMobile(mobile);
|
||||
order.setOrderAmount(amountYuan);
|
||||
order.setCurrency(config.getCurrency());
|
||||
order.setCtripOrderStatus("CREATING");
|
||||
order.setConsumeStatus(0);
|
||||
order.setRefundStatus(0);
|
||||
order.setRetryCount(0);
|
||||
order.setDeleted(0);
|
||||
ctripDistOrderMapper.insert(order);
|
||||
|
||||
try {
|
||||
CtripDistBookResponse response = ctripDistApiService.createOrder(createRequest);
|
||||
if (response != null && response.isSuccess() && response.getData() != null && response.getData().getOrderId() != null) {
|
||||
order.setCtripOrderId(response.getData().getOrderId());
|
||||
order.setCtripOrderStatus("CONFIRMED");
|
||||
order.setErrorMsg(null);
|
||||
} else {
|
||||
order.setCtripOrderStatus("CREATE_FAILED");
|
||||
order.setErrorMsg(response == null ? "携程分销商下单返回为空" : response.getErrmsg());
|
||||
}
|
||||
ctripDistOrderMapper.updateById(order);
|
||||
} catch (Exception e) {
|
||||
log.error("创建携程分销商订单异常,orderNo: {}", orderNo, e);
|
||||
order.setCtripOrderStatus("CREATE_FAILED");
|
||||
order.setErrorMsg(e.getMessage());
|
||||
order.setRetryCount(order.getRetryCount() == null ? 1 : order.getRetryCount() + 1);
|
||||
ctripDistOrderMapper.updateById(order);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean cancelCtripDistOrder(String orderNo, String reason) {
|
||||
CtripDistOrder order = ctripDistOrderMapper.selectByOrderNo(orderNo);
|
||||
if (order == null) {
|
||||
log.warn("未找到携程分销商订单,orderNo: {}", orderNo);
|
||||
return false;
|
||||
}
|
||||
if (Integer.valueOf(1).equals(order.getConsumeStatus())) {
|
||||
log.warn("订单已核销不可退,orderNo: {}", orderNo);
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
CtripDistCancelVerifyResponse verifyResponse = ctripDistApiService.cancelVerify(order.getCtripOrderId());
|
||||
if (verifyResponse == null || verifyResponse.getCancelVerifyData() == null
|
||||
|| verifyResponse.getCancelVerifyData().getCancelVerifyStatus() == null
|
||||
|| verifyResponse.getCancelVerifyData().getCancelVerifyStatus() == 0) {
|
||||
order.setRefundStatus(2);
|
||||
order.setErrorMsg(verifyResponse == null ? "退订验证失败" : verifyResponse.getErrmsg());
|
||||
ctripDistOrderMapper.updateById(order);
|
||||
return false;
|
||||
}
|
||||
|
||||
CtripDistCancelResponse cancelResponse = ctripDistApiService.cancelOrder(order.getCtripOrderId(), reason);
|
||||
if (cancelResponse != null && cancelResponse.isSuccess()) {
|
||||
order.setCtripOrderStatus("CANCELLED");
|
||||
order.setRefundStatus(1);
|
||||
order.setRefundTime(LocalDateTime.now());
|
||||
order.setRefundAmount(verifyResponse.getCancelVerifyData().getRefundAmount());
|
||||
order.setErrorMsg(null);
|
||||
ctripDistOrderMapper.updateById(order);
|
||||
return true;
|
||||
}
|
||||
|
||||
order.setRefundStatus(2);
|
||||
order.setErrorMsg(cancelResponse == null ? "携程分销商取消订单失败" : cancelResponse.getErrmsg());
|
||||
ctripDistOrderMapper.updateById(order);
|
||||
return false;
|
||||
} catch (Exception e) {
|
||||
log.error("取消携程分销商订单异常,orderNo: {}", orderNo, e);
|
||||
order.setRefundStatus(2);
|
||||
order.setErrorMsg(e.getMessage());
|
||||
ctripDistOrderMapper.updateById(order);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public CtripDistOrder getByOrderNo(String orderNo) {
|
||||
return ctripDistOrderMapper.selectByOrderNo(orderNo);
|
||||
}
|
||||
|
||||
private static final String DEFAULT_CONTACT_NAME = "杜超";
|
||||
private static final String DEFAULT_CONTACT_MOBILE = "18222892722";
|
||||
private static final String DEFAULT_CONTACT_EMAIL = "1098974448@qq.com";
|
||||
|
||||
private CtripDistBookRequest buildBookRequest(String distributorOrderId, Long productId, Long packageId,
|
||||
Long resourceId, BigDecimal amountYuan, String userMobile,
|
||||
Map<String, Object> bookInfo, boolean includeAreaCode) {
|
||||
CtripDistBookRequest request = new CtripDistBookRequest();
|
||||
request.setLocale(config.getLocale());
|
||||
request.setCurrency(config.getCurrency());
|
||||
request.setDistributorOrderID(distributorOrderId);
|
||||
|
||||
// 联系人:优先使用真实手机号,没有则用默认值
|
||||
String contactMobile = (userMobile != null && !userMobile.isEmpty()) ? userMobile : DEFAULT_CONTACT_MOBILE;
|
||||
CtripDistBookRequest.Contact contact = new CtripDistBookRequest.Contact();
|
||||
contact.setName(DEFAULT_CONTACT_NAME);
|
||||
CtripDistBookRequest.Mobile mobile = new CtripDistBookRequest.Mobile();
|
||||
mobile.setInternationalTelephoneCode("86");
|
||||
mobile.setMobileNumber(contactMobile);
|
||||
contact.setMobile(mobile);
|
||||
contact.setEmail(DEFAULT_CONTACT_EMAIL);
|
||||
request.setContact(contact);
|
||||
|
||||
CtripDistBookRequest.Passenger passenger = new CtripDistBookRequest.Passenger();
|
||||
passenger.setPackageID(packageId);
|
||||
passenger.setResourceID(resourceId);
|
||||
passenger.setQuestionAnswerList(buildPassengerQuestionAnswers(bookInfo, contactMobile, includeAreaCode));
|
||||
request.setPassengerList(Collections.singletonList(passenger));
|
||||
|
||||
CtripDistBookRequest.OrderResource orderResource = new CtripDistBookRequest.OrderResource();
|
||||
orderResource.setResourceID(resourceId);
|
||||
orderResource.setUseDate(LocalDate.now().format(USE_DATE_FORMATTER));
|
||||
orderResource.setQuantity(1);
|
||||
orderResource.setPrice(amountYuan);
|
||||
|
||||
CtripDistBookRequest.BasicOrder basicOrder = new CtripDistBookRequest.BasicOrder();
|
||||
basicOrder.setProductID(productId);
|
||||
basicOrder.setAmount(amountYuan);
|
||||
basicOrder.setPackageID(packageId);
|
||||
basicOrder.setOrderResourceList(Collections.singletonList(orderResource));
|
||||
request.setBasicOrder(basicOrder);
|
||||
return request;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private List<CtripDistBookRequest.QuestionAnswer> buildPassengerQuestionAnswers(Map<String, Object> bookInfo,
|
||||
String contactMobile,
|
||||
boolean includeAreaCode) {
|
||||
List<CtripDistBookRequest.QuestionAnswer> answers = new ArrayList<>();
|
||||
if (bookInfo == null || bookInfo.get("data") == null) {
|
||||
return answers;
|
||||
}
|
||||
Map<String, Object> data = (Map<String, Object>) bookInfo.get("data");
|
||||
Object questionList = data.get("passengerQuestionList");
|
||||
if (!(questionList instanceof List)) {
|
||||
return answers;
|
||||
}
|
||||
for (Object item : (List<?>) questionList) {
|
||||
if (!(item instanceof Map)) {
|
||||
continue;
|
||||
}
|
||||
Map<String, Object> question = (Map<String, Object>) item;
|
||||
String answerValue = resolvePassengerAnswerValue(question, contactMobile, includeAreaCode);
|
||||
if (answerValue == null) {
|
||||
continue;
|
||||
}
|
||||
answers.add(buildQuestionAnswer(question, answerValue));
|
||||
}
|
||||
return answers;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private Long extractPackageId(Map<String, Object> productDetail) {
|
||||
Map<String, Object> data = (Map<String, Object>) productDetail.get("data");
|
||||
List<Map<String, Object>> productList = (List<Map<String, Object>>) data.get("productList");
|
||||
Map<String, Object> product = productList.get(0);
|
||||
List<Map<String, Object>> packageList = (List<Map<String, Object>>) product.get("packageList");
|
||||
Map<String, Object> pkg = packageList.get(0);
|
||||
return Long.valueOf(pkg.get("packageID").toString());
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private Long extractResourceId(Map<String, Object> productDetail) {
|
||||
Map<String, Object> data = (Map<String, Object>) productDetail.get("data");
|
||||
List<Map<String, Object>> productList = (List<Map<String, Object>>) data.get("productList");
|
||||
Map<String, Object> product = productList.get(0);
|
||||
List<Map<String, Object>> packageList = (List<Map<String, Object>>) product.get("packageList");
|
||||
Map<String, Object> pkg = packageList.get(0);
|
||||
List<Map<String, Object>> resourceList = (List<Map<String, Object>>) pkg.get("resourceList");
|
||||
Map<String, Object> resource = resourceList.get(0);
|
||||
return Long.valueOf(resource.get("resourceID").toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验下单填写信息
|
||||
* 当前仅支持自动填充姓名、手机号和手机号区号
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
private void validateBookInfo(Map<String, Object> bookInfo, String orderNo) {
|
||||
if (bookInfo == null || bookInfo.get("data") == null) {
|
||||
log.warn("获取下单填写信息为空,orderNo: {},继续尝试下单", orderNo);
|
||||
return;
|
||||
}
|
||||
Map<String, Object> data = (Map<String, Object>) bookInfo.get("data");
|
||||
Object questionList = data.get("passengerQuestionList");
|
||||
if (questionList instanceof List) {
|
||||
Set<String> unsupportedCodes = new LinkedHashSet<>();
|
||||
for (Object item : (List<?>) questionList) {
|
||||
if (!(item instanceof Map)) {
|
||||
continue;
|
||||
}
|
||||
Map<String, Object> question = (Map<String, Object>) item;
|
||||
String questionCode = normalizeQuestionCode(getFieldValue(question, "code", "questionCode"));
|
||||
if (!isSupportedPassengerQuestion(questionCode)) {
|
||||
unsupportedCodes.add(questionCode);
|
||||
}
|
||||
}
|
||||
if (!unsupportedCodes.isEmpty()) {
|
||||
throw new RuntimeException("该携程产品包含暂不支持自动填写的乘客信息,questionCode="
|
||||
+ unsupportedCodes + ",orderNo: " + orderNo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isSupportedPassengerQuestion(String questionCode) {
|
||||
return "P_CNAME".equalsIgnoreCase(questionCode)
|
||||
|| "P_TELPHONE".equalsIgnoreCase(questionCode)
|
||||
|| "P_TELPHONE_AREA_CODE".equalsIgnoreCase(questionCode);
|
||||
}
|
||||
|
||||
private String resolvePassengerAnswerValue(Map<String, Object> question, String contactMobile,
|
||||
boolean includeAreaCode) {
|
||||
String questionCode = normalizeQuestionCode(getFieldValue(question, "code", "questionCode"));
|
||||
if ("P_CNAME".equalsIgnoreCase(questionCode)) {
|
||||
return DEFAULT_CONTACT_NAME;
|
||||
}
|
||||
if ("P_TELPHONE".equalsIgnoreCase(questionCode)) {
|
||||
return contactMobile;
|
||||
}
|
||||
if ("P_TELPHONE_AREA_CODE".equalsIgnoreCase(questionCode)) {
|
||||
return includeAreaCode ? "+86" : null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private CtripDistBookRequest.QuestionAnswer buildQuestionAnswer(Map<String, Object> question, String answerValue) {
|
||||
CtripDistBookRequest.QuestionAnswer answer = new CtripDistBookRequest.QuestionAnswer();
|
||||
String questionId = getFieldValue(question, "questionID", "id");
|
||||
if (questionId != null && !questionId.isEmpty()) {
|
||||
answer.setQuestionID(Long.valueOf(questionId));
|
||||
}
|
||||
answer.setQuestionCode(normalizeQuestionCode(getFieldValue(question, "code", "questionCode")));
|
||||
String title = getFieldValue(question, "title", "questionTitle");
|
||||
answer.setQuestionTitle(title != null ? title : "");
|
||||
answer.setAnswerList(Collections.singletonList(answerValue));
|
||||
return answer;
|
||||
}
|
||||
|
||||
private String normalizeQuestionCode(String questionCode) {
|
||||
if ("P_NAME".equalsIgnoreCase(questionCode)) {
|
||||
return "P_CNAME";
|
||||
}
|
||||
return questionCode != null ? questionCode : "";
|
||||
}
|
||||
|
||||
private String getFieldValue(Map<String, Object> map, String... keys) {
|
||||
for (String key : keys) {
|
||||
Object value = map.get(key);
|
||||
if (value != null) {
|
||||
return value.toString();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
-127
@@ -1,127 +0,0 @@
|
||||
package com.central.coupon.service.impl;
|
||||
|
||||
import com.central.common.utils.http.SimpleHttpRequest;
|
||||
import com.central.coupon.config.CtripDistributorConfig;
|
||||
import com.central.coupon.service.ICtripDistTokenService;
|
||||
import com.central.coupon.util.SslUtil;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 携程分销商Token管理服务实现
|
||||
* 使用SimpleHttpRequest替代RestTemplate,解决HTTPS连接兼容性问题
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class CtripDistTokenServiceImpl implements ICtripDistTokenService {
|
||||
|
||||
private static final long TOKEN_BUFFER_SECONDS = 60L;
|
||||
|
||||
@Autowired
|
||||
private CtripDistributorConfig config;
|
||||
|
||||
@Autowired
|
||||
private ObjectMapper objectMapper;
|
||||
|
||||
private volatile String accessToken;
|
||||
private volatile String refreshToken;
|
||||
private volatile LocalDateTime tokenExpireTime;
|
||||
|
||||
@Override
|
||||
public synchronized String getAccessToken() {
|
||||
if (isTokenValid()) {
|
||||
return accessToken;
|
||||
}
|
||||
|
||||
if (refreshToken != null && !refreshToken.isEmpty()) {
|
||||
try {
|
||||
refreshAccessToken();
|
||||
if (isTokenValid()) {
|
||||
return accessToken;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.warn("刷新携程分销商Token失败,将重新获取新Token", e);
|
||||
}
|
||||
}
|
||||
|
||||
fetchNewToken();
|
||||
if (!isTokenValid()) {
|
||||
throw new RuntimeException("获取携程分销商AccessToken失败");
|
||||
}
|
||||
return accessToken;
|
||||
}
|
||||
|
||||
private boolean isTokenValid() {
|
||||
return accessToken != null
|
||||
&& tokenExpireTime != null
|
||||
&& LocalDateTime.now().plusSeconds(TOKEN_BUFFER_SECONDS).isBefore(tokenExpireTime);
|
||||
}
|
||||
|
||||
private void fetchNewToken() {
|
||||
String url = String.format("%s?aid=%s&sid=%s&key=%s",
|
||||
config.getAuthUrl(), config.getAid(), config.getSid(), config.getKey());
|
||||
log.info("获取新的携程分销商Token,请求URL: {}", url);
|
||||
String responseBody = doGet(url);
|
||||
log.info("携程分销商Token接口原始响应: {}", responseBody);
|
||||
parseTokenResponse(responseBody);
|
||||
}
|
||||
|
||||
private void refreshAccessToken() {
|
||||
String url = String.format("%s?aid=%s&sid=%s&refresh_token=%s",
|
||||
config.getRefreshUrl(), config.getAid(), config.getSid(), refreshToken);
|
||||
log.info("刷新携程分销商Token,请求URL: {}", url);
|
||||
String responseBody = doGet(url);
|
||||
log.info("携程分销商Token刷新响应: {}", responseBody);
|
||||
parseTokenResponse(responseBody);
|
||||
}
|
||||
|
||||
/**
|
||||
* 使用SimpleHttpRequest发起GET请求
|
||||
*/
|
||||
private String doGet(String url) {
|
||||
try {
|
||||
SimpleHttpRequest request = new SimpleHttpRequest(url, SslUtil.createTrustAllHttpClient());
|
||||
request.resultAsJsonString();
|
||||
byte[] bytes = request.get().asBytes();
|
||||
request.close();
|
||||
return new String(bytes, "UTF-8");
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("携程分销商HTTP请求失败: " + e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private void parseTokenResponse(String responseBody) {
|
||||
if (responseBody == null || responseBody.isEmpty()) {
|
||||
throw new RuntimeException("携程分销商Token接口返回为空");
|
||||
}
|
||||
|
||||
Map<String, Object> response;
|
||||
try {
|
||||
response = objectMapper.readValue(responseBody, Map.class);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("携程分销商Token响应解析失败: " + responseBody, e);
|
||||
}
|
||||
|
||||
Object errCode = response.get("ErrCode");
|
||||
int code = errCode == null ? 0 : Integer.parseInt(errCode.toString());
|
||||
if (code != 0) {
|
||||
throw new RuntimeException("携程分销商Token接口调用失败: " + response.get("ErrMsg"));
|
||||
}
|
||||
|
||||
Object expiresIn = response.get("Expires_In");
|
||||
if (response.get("Access_Token") == null || response.get("Refresh_Token") == null || expiresIn == null) {
|
||||
throw new RuntimeException("携程分销商Token响应缺少必要字段: " + responseBody);
|
||||
}
|
||||
|
||||
this.accessToken = response.get("Access_Token").toString();
|
||||
this.refreshToken = response.get("Refresh_Token").toString();
|
||||
this.tokenExpireTime = LocalDateTime.now().plusSeconds(Long.parseLong(expiresIn.toString()));
|
||||
log.info("携程分销商Token更新成功,过期时间: {}", tokenExpireTime);
|
||||
}
|
||||
}
|
||||
-191
@@ -1,191 +0,0 @@
|
||||
package com.central.coupon.task;
|
||||
|
||||
import com.central.coupon.controller.CtripConsumedController;
|
||||
import com.central.coupon.entity.CtripContact;
|
||||
import com.central.coupon.entity.CtripDistOrder;
|
||||
import com.central.coupon.entity.CtripOrder;
|
||||
import com.central.coupon.entity.CtripOrderItem;
|
||||
import com.central.coupon.mapper.CtripContactMapper;
|
||||
import com.central.coupon.mapper.CtripDistOrderMapper;
|
||||
import com.central.coupon.mapper.CtripOrderItemMapper;
|
||||
import com.central.coupon.mapper.CtripOrderMapper;
|
||||
import com.central.coupon.model.CtripConsumedNoticeResponse;
|
||||
import com.central.coupon.service.CtripConsumedService;
|
||||
import com.central.coupon.service.IOrderDetailService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class CtripDistConsumeTask {
|
||||
|
||||
@Autowired
|
||||
private CtripDistOrderMapper ctripDistOrderMapper;
|
||||
|
||||
@Autowired
|
||||
private CtripContactMapper ctripContactMapper;
|
||||
|
||||
@Autowired
|
||||
private CtripOrderMapper ctripOrderMapper;
|
||||
|
||||
@Autowired
|
||||
private CtripOrderItemMapper ctripOrderItemMapper;
|
||||
|
||||
@Autowired
|
||||
private CtripConsumedService ctripConsumedService;
|
||||
|
||||
@Autowired
|
||||
private IOrderDetailService orderDetailService;
|
||||
|
||||
/**
|
||||
* 每天凌晨3点执行:核销2天前创建且未核销的携程分销订单
|
||||
*/
|
||||
@Scheduled(cron = "0 0 3 * * ?")
|
||||
public void autoConsumeCtripDistOrders() {
|
||||
log.info("开始自动核销携程分销订单");
|
||||
try {
|
||||
// 1. 查询2天前创建且未核销的CtripDistOrder
|
||||
List<CtripDistOrder> pendingOrders = ctripDistOrderMapper.selectPendingConsumeOrders(3);
|
||||
log.info("待核销的携程分销订单数量: {}", pendingOrders.size());
|
||||
|
||||
for (CtripDistOrder distOrder : pendingOrders) {
|
||||
try {
|
||||
consumeOrder(distOrder);
|
||||
} catch (Exception e) {
|
||||
log.error("核销携程分销订单失败,orderNo: {}", distOrder.getOrderNo(), e);
|
||||
distOrder.setConsumeStatus(2);
|
||||
distOrder.setErrorMsg("核销失败: " + e.getMessage());
|
||||
ctripDistOrderMapper.updateById(distOrder);
|
||||
}
|
||||
}
|
||||
log.info("携程分销订单自动核销完成");
|
||||
} catch (Exception e) {
|
||||
log.error("自动核销携程分销订单任务异常", e);
|
||||
}
|
||||
}
|
||||
|
||||
private void consumeOrder(CtripDistOrder distOrder) {
|
||||
String mobile = distOrder.getMobile();
|
||||
log.info("开始核销携程分销订单,orderNo: {}, mobile: {}", distOrder.getOrderNo(), mobile);
|
||||
|
||||
if (mobile == null || mobile.isEmpty()) {
|
||||
distOrder.setConsumeStatus(2);
|
||||
distOrder.setErrorMsg("分销订单手机号为空,无法核销");
|
||||
ctripDistOrderMapper.updateById(distOrder);
|
||||
log.warn("分销订单手机号为空,跳过核销,orderNo: {}", distOrder.getOrderNo());
|
||||
return;
|
||||
}
|
||||
|
||||
// 2. 根据手机号通过联系人表查找CtripOrder
|
||||
List<CtripContact> contacts = ctripContactMapper.selectByMobile(mobile);
|
||||
if (contacts == null || contacts.isEmpty()) {
|
||||
distOrder.setConsumeStatus(2);
|
||||
distOrder.setErrorMsg("未找到手机号对应的携程联系人记录");
|
||||
ctripDistOrderMapper.updateById(distOrder);
|
||||
log.warn("未找到手机号 {} 对应的联系人记录,orderNo: {}", mobile, distOrder.getOrderNo());
|
||||
return;
|
||||
}
|
||||
|
||||
List<Long> orderIds = contacts.stream()
|
||||
.map(CtripContact::getOrderId)
|
||||
.distinct()
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// 筛选状态为PAYMENT_CONFIRMED(13)的订单
|
||||
List<CtripOrder> confirmedOrders = new ArrayList<>();
|
||||
for (Long orderId : orderIds) {
|
||||
CtripOrder ctripOrder = ctripOrderMapper.selectById(orderId);
|
||||
if (ctripOrder != null && Integer.valueOf(13).equals(ctripOrder.getStatus())) {
|
||||
confirmedOrders.add(ctripOrder);
|
||||
}
|
||||
}
|
||||
|
||||
if (confirmedOrders.isEmpty()) {
|
||||
distOrder.setConsumeStatus(2);
|
||||
distOrder.setErrorMsg("未找到状态为PAYMENT_CONFIRMED的携程订单");
|
||||
ctripDistOrderMapper.updateById(distOrder);
|
||||
log.warn("手机号 {} 无PAYMENT_CONFIRMED状态的订单,orderNo: {}", mobile, distOrder.getOrderNo());
|
||||
return;
|
||||
}
|
||||
|
||||
// 3. 对每个符合条件的CtripOrder执行核销
|
||||
boolean anySuccess = false;
|
||||
StringBuilder errorMsgs = new StringBuilder();
|
||||
|
||||
for (CtripOrder ctripOrder : confirmedOrders) {
|
||||
try {
|
||||
// 建立订单关联关系
|
||||
if (ctripOrder.getOrderNo() == null || ctripOrder.getOrderNo().trim().isEmpty()) {
|
||||
ctripOrder.setOrderNo(distOrder.getOrderNo());
|
||||
ctripOrderMapper.updateById(ctripOrder);
|
||||
log.info("建立订单关联关系,otaOrderId: {}, orderNo: {}", ctripOrder.getOtaOrderId(), distOrder.getOrderNo());
|
||||
}
|
||||
|
||||
// 验证订单是否可核销
|
||||
if (!orderDetailService.validateOrderForConsume(ctripOrder.getOtaOrderId())) {
|
||||
log.warn("订单不可核销,otaOrderId: {}", ctripOrder.getOtaOrderId());
|
||||
continue;
|
||||
}
|
||||
|
||||
// 查询订单项,逐项核销
|
||||
List<CtripOrderItem> orderItems = ctripOrderItemMapper.selectByOrderId(ctripOrder.getId());
|
||||
if (orderItems == null || orderItems.isEmpty()) {
|
||||
log.warn("订单无订单项,otaOrderId: {}", ctripOrder.getOtaOrderId());
|
||||
continue;
|
||||
}
|
||||
|
||||
for (CtripOrderItem item : orderItems) {
|
||||
if (item.getQuantity() == null || item.getQuantity() <= 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
CtripConsumedController.CtripConsumeRequest request = new CtripConsumedController.CtripConsumeRequest();
|
||||
request.setOtaOrderId(ctripOrder.getOtaOrderId());
|
||||
request.setSupplierOrderId(ctripOrder.getSupplierOrderId());
|
||||
request.setItemId(item.getItemId());
|
||||
request.setUseQuantity(item.getQuantity());
|
||||
request.setRemark("分销订单自动核销,orderNo: " + distOrder.getOrderNo());
|
||||
|
||||
CtripConsumedNoticeResponse response = ctripConsumedService.consumeOrder(request);
|
||||
boolean success = response != null && "0000".equals(response.getHeader().getResultCode());
|
||||
|
||||
if (success) {
|
||||
log.info("核销成功,otaOrderId: {}, itemId: {}", ctripOrder.getOtaOrderId(), item.getItemId());
|
||||
anySuccess = true;
|
||||
} else {
|
||||
String errMsg = response != null ? response.getHeader().getResultMessage() : "未知错误";
|
||||
log.error("核销失败,otaOrderId: {}, itemId: {}, error: {}", ctripOrder.getOtaOrderId(), item.getItemId(), errMsg);
|
||||
errorMsgs.append("otaOrderId=").append(ctripOrder.getOtaOrderId())
|
||||
.append(",itemId=").append(item.getItemId())
|
||||
.append(":").append(errMsg).append("; ");
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("核销携程订单异常,otaOrderId: {}", ctripOrder.getOtaOrderId(), e);
|
||||
errorMsgs.append("otaOrderId=").append(ctripOrder.getOtaOrderId())
|
||||
.append(":").append(e.getMessage()).append("; ");
|
||||
}
|
||||
}
|
||||
|
||||
// 4. 更新CtripDistOrder状态
|
||||
if (anySuccess) {
|
||||
distOrder.setConsumeStatus(1);
|
||||
distOrder.setConsumeTime(LocalDateTime.now());
|
||||
distOrder.setCtripOrderStatus("CONSUMED");
|
||||
distOrder.setErrorMsg(errorMsgs.length() > 0 ? "部分核销异常: " + errorMsgs : null);
|
||||
log.info("携程分销订单核销成功,orderNo: {}", distOrder.getOrderNo());
|
||||
} else {
|
||||
distOrder.setConsumeStatus(2);
|
||||
distOrder.setErrorMsg(errorMsgs.length() > 0 ? errorMsgs.toString() : "所有订单核销均失败");
|
||||
log.warn("携程分销订单核销失败,orderNo: {}", distOrder.getOrderNo());
|
||||
}
|
||||
ctripDistOrderMapper.updateById(distOrder);
|
||||
}
|
||||
}
|
||||
@@ -1,70 +0,0 @@
|
||||
package com.central.coupon.util;
|
||||
|
||||
import org.apache.http.client.HttpClient;
|
||||
import org.apache.http.client.config.RequestConfig;
|
||||
import org.apache.http.conn.ssl.NoopHostnameVerifier;
|
||||
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
|
||||
import org.apache.http.impl.client.HttpClients;
|
||||
|
||||
import javax.net.ssl.SSLContext;
|
||||
import javax.net.ssl.TrustManager;
|
||||
import javax.net.ssl.X509TrustManager;
|
||||
import java.security.cert.X509Certificate;
|
||||
|
||||
/**
|
||||
* SSL工具类
|
||||
* 提供信任所有证书的HttpClient,解决携程HTTPS证书信任链问题
|
||||
*/
|
||||
public class SslUtil {
|
||||
|
||||
private SslUtil() {}
|
||||
|
||||
/** 默认超时时间:15秒(携程可订/下单接口要求15s超时) */
|
||||
private static final int DEFAULT_TIMEOUT_MS = 15000;
|
||||
|
||||
/**
|
||||
* 创建信任所有证书的HttpClient(使用默认15秒超��)
|
||||
*/
|
||||
public static HttpClient createTrustAllHttpClient() {
|
||||
return createTrustAllHttpClient(DEFAULT_TIMEOUT_MS);
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建信任所有证书的HttpClient(自定义超时)
|
||||
*
|
||||
* @param timeoutMs 超时时间(毫秒),同时设置连接超时和读取超时
|
||||
*/
|
||||
public static HttpClient createTrustAllHttpClient(int timeoutMs) {
|
||||
try {
|
||||
SSLContext sslContext = SSLContext.getInstance("TLS");
|
||||
sslContext.init(null, 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];
|
||||
}
|
||||
}}, new java.security.SecureRandom());
|
||||
|
||||
SSLConnectionSocketFactory sslFactory = new SSLConnectionSocketFactory(
|
||||
sslContext, NoopHostnameVerifier.INSTANCE);
|
||||
|
||||
RequestConfig requestConfig = RequestConfig.custom()
|
||||
.setConnectTimeout(timeoutMs)
|
||||
.setSocketTimeout(timeoutMs)
|
||||
.setConnectionRequestTimeout(timeoutMs)
|
||||
.build();
|
||||
|
||||
return HttpClients.custom()
|
||||
.setSSLSocketFactory(sslFactory)
|
||||
.setDefaultRequestConfig(requestConfig)
|
||||
.build();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("创建信任所有证书的HttpClient失败", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,66 +1,69 @@
|
||||
#spring:
|
||||
# datasource:
|
||||
# # url: jdbc:mysql://${zlt.datasource.ip}:3306/device-center?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&useSSL=false&zeroDateTimeBehavior=convertToNull&serverTimezone=Asia/Shanghai
|
||||
# url: jdbc:mysql://${zlt.datasource.ip}/coupon-center-test?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&useSSL=false&zeroDateTimeBehavior=convertToNull&serverTimezone=Asia/Shanghai&allowMultiQueries=true
|
||||
# username: ${zlt.datasource.username}
|
||||
# password: ${zlt.datasource.password}
|
||||
# driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
#
|
||||
#mybatis-plus:
|
||||
# mapper-locations: classpath:/mapper/*Mapper.xml
|
||||
# #实体扫描,多个package用逗号或者分号分隔
|
||||
# typeAliasesPackage: com.central.coupon.model
|
||||
# # configuration:
|
||||
# # log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
|
||||
# global-config:
|
||||
# db-config:
|
||||
# id-type: auto
|
||||
#
|
||||
#springdoc:
|
||||
# group-configs:
|
||||
# - group: 'default'
|
||||
# paths-to-match: '/**'
|
||||
# packages-to-scan: com.central.coupon.controller
|
||||
#
|
||||
#knife4j:
|
||||
# enable: true
|
||||
# setting:
|
||||
# swagger-model-name: 优惠券中心接口文档
|
||||
#zlt:
|
||||
# #多租户配置
|
||||
# tenant:
|
||||
# enable: false
|
||||
# ignoreTables:
|
||||
# ignoreSqls:
|
||||
# # 禁用分布式锁
|
||||
# lock:
|
||||
# lockerType: NONE
|
||||
#
|
||||
## 日志配置
|
||||
#logging:
|
||||
# level:
|
||||
# com.central.order.controller.OrderFileController: DEBUG
|
||||
# com.central.coupon.util.CtripDecryptUtil: DEBUG
|
||||
# com.central.coupon.service.impl.OrderDetailServiceImpl: DEBUG
|
||||
#
|
||||
## 携程API配置
|
||||
#ctrip:
|
||||
# # AES加密配置
|
||||
# aes:
|
||||
# key: 6196f64f4f6e5dca # 为实际的AES密钥
|
||||
# iv: 28405d20246ecccd # 为实际的AES IV
|
||||
# # 签名配置(使用账户密钥进行签名计算)
|
||||
# # API配置
|
||||
# api:
|
||||
# # 测试环境URL
|
||||
# test-url: https://ttdopen.ctrip.com/api
|
||||
# # 生产环境URL
|
||||
# prod-url: https://ttdentry.ctrip.com/ttd-connect-orderentryapi/supplier
|
||||
# # 当前环境(test/prod)
|
||||
# environment: prod
|
||||
# timeout: 30000 # 请求超时时间(毫秒)
|
||||
# retry-times: 3 # 重试次数
|
||||
# # 账户配置
|
||||
# account:
|
||||
# id: e02647943fdfb4c5 # 为实际的账户ID
|
||||
# secret: 0b4f4dabb50999cb04a773fc96f81499 # 实际的账户密钥
|
||||
spring:
|
||||
datasource:
|
||||
# url: jdbc:mysql://${zlt.datasource.ip}:3306/device-center?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&useSSL=false&zeroDateTimeBehavior=convertToNull&serverTimezone=Asia/Shanghai
|
||||
url: jdbc:mysql://${zlt.datasource.ip}/coupon-center?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&useSSL=false&zeroDateTimeBehavior=convertToNull&serverTimezone=Asia/Shanghai&allowMultiQueries=true
|
||||
username: ${zlt.datasource.username}
|
||||
password: ${zlt.datasource.password}
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
# 环境配置:test(测试环境) / prod(生产环境)
|
||||
profiles:
|
||||
active: test
|
||||
|
||||
mybatis-plus:
|
||||
mapper-locations: classpath:/mapper/*Mapper.xml
|
||||
#实体扫描,多个package用逗号或者分号分隔
|
||||
typeAliasesPackage: com.central.coupon.model
|
||||
# configuration:
|
||||
# log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
|
||||
global-config:
|
||||
db-config:
|
||||
id-type: auto
|
||||
|
||||
springdoc:
|
||||
group-configs:
|
||||
- group: 'default'
|
||||
paths-to-match: '/**'
|
||||
packages-to-scan: com.central.coupon.controller
|
||||
|
||||
knife4j:
|
||||
enable: true
|
||||
setting:
|
||||
swagger-model-name: 优惠券中心接口文档
|
||||
zlt:
|
||||
#多租户配置
|
||||
tenant:
|
||||
enable: false
|
||||
ignoreTables:
|
||||
ignoreSqls:
|
||||
# 禁用分布式锁
|
||||
lock:
|
||||
lockerType: NONE
|
||||
|
||||
# 日志配置
|
||||
logging:
|
||||
level:
|
||||
com.central.order.controller.OrderFileController: DEBUG
|
||||
com.central.coupon.util.CtripDecryptUtil: DEBUG
|
||||
com.central.coupon.service.impl.OrderDetailServiceImpl: DEBUG
|
||||
|
||||
# 携程API配置
|
||||
ctrip:
|
||||
# AES加密配置
|
||||
aes:
|
||||
key: 6196f64f4f6e5dca # 为实际的AES密钥
|
||||
iv: 28405d20246ecccd # 为实际的AES IV
|
||||
# 签名配置(使用账户密钥进行签名计算)
|
||||
# API配置
|
||||
api:
|
||||
# 测试环境URL
|
||||
test-url: https://ttdopen.ctrip.com/api
|
||||
# 生产环境URL
|
||||
prod-url: https://ttdentry.ctrip.com/ttd-connect-orderentryapi/supplier
|
||||
# 当前环境(test/prod)
|
||||
environment: prod
|
||||
timeout: 30000 # 请求超时时间(毫秒)
|
||||
retry-times: 3 # 重试次数
|
||||
# 账户配置
|
||||
account:
|
||||
id: e02647943fdfb4c5 # 为实际的账户ID
|
||||
secret: 0b4f4dabb50999cb04a773fc96f81499 # 实际的账户密钥
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
server:
|
||||
port: 8002
|
||||
|
||||
spring:
|
||||
application:
|
||||
name: coupon-center
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.central.coupon.mapper.CtripDistOrderMapper">
|
||||
|
||||
<select id="selectByOrderNo" resultType="com.central.coupon.entity.CtripDistOrder">
|
||||
SELECT *
|
||||
FROM t_ctrip_dist_order
|
||||
WHERE order_no = #{orderNo}
|
||||
AND deleted = 0
|
||||
LIMIT 1
|
||||
</select>
|
||||
|
||||
<select id="selectPendingConsumeOrders" resultType="com.central.coupon.entity.CtripDistOrder">
|
||||
SELECT *
|
||||
FROM t_ctrip_dist_order
|
||||
WHERE ctrip_order_status = 'CONFIRMED'
|
||||
AND consume_status = 0
|
||||
AND deleted = 0
|
||||
AND create_time <= DATE_SUB(NOW(), INTERVAL #{daysAgo} DAY)
|
||||
ORDER BY create_time ASC
|
||||
</select>
|
||||
|
||||
<select id="selectByDistributorOrderId" resultType="com.central.coupon.entity.CtripDistOrder">
|
||||
SELECT *
|
||||
FROM t_ctrip_dist_order
|
||||
WHERE distributor_order_id = #{distributorOrderId}
|
||||
AND deleted = 0
|
||||
LIMIT 1
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -8,17 +8,20 @@
|
||||
<result column="refund_id" property="refundId" jdbcType="BIGINT"/>
|
||||
<result column="item_id" property="itemId" jdbcType="VARCHAR"/>
|
||||
<result column="plu" property="plu" jdbcType="VARCHAR"/>
|
||||
<result column="refund_amount" property="refundAmount" jdbcType="DECIMAL"/>
|
||||
<result column="currency" property="currency" jdbcType="VARCHAR"/>
|
||||
<result column="amount" property="amount" jdbcType="DECIMAL"/>
|
||||
<result column="amount_currency" property="amountCurrency" jdbcType="VARCHAR"/>
|
||||
<result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
|
||||
<result column="update_time" property="updateTime" jdbcType="TIMESTAMP"/>
|
||||
<result column="deleted" property="deleted" jdbcType="INTEGER"/>
|
||||
<result column="create_by" property="createBy" jdbcType="VARCHAR"/>
|
||||
<result column="update_by" property="updateBy" jdbcType="VARCHAR"/>
|
||||
<result column="remark" property="remark" jdbcType="VARCHAR"/>
|
||||
<result column="tenant_id" property="tenantId" jdbcType="VARCHAR"/>
|
||||
</resultMap>
|
||||
|
||||
<!-- 基础字段 -->
|
||||
<sql id="Base_Column_List">
|
||||
id, refund_id, item_id, plu, refund_amount, currency,
|
||||
create_time, update_time, deleted
|
||||
id, refund_id, item_id, plu, amount, amount_currency,
|
||||
create_time, update_time, create_by, update_by, remark, tenant_id
|
||||
</sql>
|
||||
|
||||
<!-- 根据退款ID查询退款项列表 -->
|
||||
@@ -27,17 +30,6 @@
|
||||
<include refid="Base_Column_List"/>
|
||||
FROM t_ctrip_refund_item
|
||||
WHERE refund_id = #{refundId,jdbcType=BIGINT}
|
||||
AND (deleted = 0 OR deleted IS NULL)
|
||||
ORDER BY create_time ASC
|
||||
</select>
|
||||
|
||||
<!-- 根据订单项编号查询退款项 -->
|
||||
<select id="selectByItemId" parameterType="string" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List"/>
|
||||
FROM t_ctrip_refund_item
|
||||
WHERE item_id = #{itemId,jdbcType=VARCHAR}
|
||||
AND (deleted = 0 OR deleted IS NULL)
|
||||
ORDER BY create_time ASC
|
||||
</select>
|
||||
|
||||
|
||||
@@ -8,12 +8,12 @@
|
||||
<result column="ota_order_id" property="otaOrderId" jdbcType="VARCHAR"/>
|
||||
<result column="supplier_order_id" property="supplierOrderId" jdbcType="VARCHAR"/>
|
||||
<result column="sequence_id" property="sequenceId" jdbcType="VARCHAR"/>
|
||||
<result column="refund_amount" property="refundAmount" jdbcType="DECIMAL"/>
|
||||
<result column="currency" property="currency" jdbcType="VARCHAR"/>
|
||||
<result column="refund_status" property="refundStatus" jdbcType="INTEGER"/>
|
||||
<result column="total_amount" property="totalAmount" jdbcType="DECIMAL"/>
|
||||
<result column="total_amount_currency" property="totalAmountCurrency" jdbcType="VARCHAR"/>
|
||||
<result column="last_confirm_time" property="lastConfirmTime" jdbcType="TIMESTAMP"/>
|
||||
<result column="status" property="status" jdbcType="INTEGER"/>
|
||||
<result column="confirm_result_code" property="confirmResultCode" jdbcType="VARCHAR"/>
|
||||
<result column="confirm_result_message" property="confirmResultMessage" jdbcType="VARCHAR"/>
|
||||
<result column="last_confirm_time" property="lastConfirmTime" jdbcType="TIMESTAMP"/>
|
||||
<result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
|
||||
<result column="update_time" property="updateTime" jdbcType="TIMESTAMP"/>
|
||||
<result column="create_by" property="createBy" jdbcType="VARCHAR"/>
|
||||
@@ -24,8 +24,8 @@
|
||||
|
||||
<!-- 基础字段 -->
|
||||
<sql id="Base_Column_List">
|
||||
id, ota_order_id, supplier_order_id, sequence_id, refund_amount, currency,
|
||||
refund_status, confirm_result_code, confirm_result_message, last_confirm_time,
|
||||
id, ota_order_id, supplier_order_id, sequence_id, total_amount, total_amount_currency,
|
||||
last_confirm_time, status, confirm_result_code, confirm_result_message,
|
||||
create_time, update_time, create_by, update_by, remark, tenant_id
|
||||
</sql>
|
||||
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
-- 携程分销订单关联表(我方订单 ↔ 携程订单)
|
||||
-- 用途:记录本地订单与携程分销订单的对应关系,跟踪核销和退款状态
|
||||
CREATE TABLE IF NOT EXISTS `t_ctrip_dist_order` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键ID',
|
||||
`tenant_id` varchar(12) DEFAULT '000000' COMMENT '租户ID',
|
||||
`order_no` varchar(100) NOT NULL COMMENT '本地订单号(order-center的订单号)',
|
||||
`ctrip_order_id` bigint(20) DEFAULT NULL COMMENT '携程订单ID(/book返回的orderId)',
|
||||
`ctrip_product_id` bigint(20) NOT NULL COMMENT '携程产品ID',
|
||||
`ctrip_package_id` bigint(20) DEFAULT NULL COMMENT '携程套餐ID',
|
||||
`ctrip_resource_id` bigint(20) DEFAULT NULL COMMENT '携程资源ID',
|
||||
`distributor_order_id` varchar(100) NOT NULL COMMENT '分销商订单ID(传给携程的唯一标识)',
|
||||
`order_amount` decimal(10,2) DEFAULT NULL COMMENT '订单金额',
|
||||
`currency` varchar(10) DEFAULT 'CNY' COMMENT '货币类型',
|
||||
`ctrip_order_status` varchar(50) DEFAULT 'PENDING' COMMENT '携程订单状态',
|
||||
`consume_status` tinyint(1) DEFAULT 0 COMMENT '核销状态(0:未核销,1:已核销,2:核销失败)',
|
||||
`consume_time` datetime DEFAULT NULL COMMENT '核销时间',
|
||||
`refund_status` tinyint(1) DEFAULT 0 COMMENT '退款状态(0:未退款,1:已退款,2:退款失败)',
|
||||
`refund_time` datetime DEFAULT NULL COMMENT '退款时间',
|
||||
`refund_amount` decimal(10,2) DEFAULT NULL COMMENT '退款金额',
|
||||
`error_msg` varchar(500) DEFAULT NULL COMMENT '错误信息(创建失败/核销失败/退款失败时记录)',
|
||||
`retry_count` int(11) DEFAULT 0 COMMENT '重试次数',
|
||||
`remark` varchar(500) DEFAULT NULL COMMENT '备注',
|
||||
`create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
`update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||
`deleted` tinyint(1) DEFAULT 0 COMMENT '是否删除',
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `uk_order_no` (`order_no`),
|
||||
UNIQUE KEY `uk_distributor_order_id` (`distributor_order_id`),
|
||||
KEY `idx_ctrip_order_id` (`ctrip_order_id`),
|
||||
KEY `idx_consume_status` (`consume_status`),
|
||||
KEY `idx_create_time` (`create_time`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='携程分销订单关联表';
|
||||
@@ -100,32 +100,6 @@
|
||||
<version>5.8.25</version>
|
||||
</dependency>
|
||||
|
||||
<!-- OkHttp -->
|
||||
<dependency>
|
||||
<groupId>com.squareup.okhttp3</groupId>
|
||||
<artifactId>okhttp</artifactId>
|
||||
<version>4.12.0</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Jsoup HTML解析器 -->
|
||||
<dependency>
|
||||
<groupId>org.jsoup</groupId>
|
||||
<artifactId>jsoup</artifactId>
|
||||
<version>1.17.2</version>
|
||||
</dependency>
|
||||
|
||||
<!-- WebSocket支持(客户端和服务端) -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-websocket</artifactId>
|
||||
</dependency>
|
||||
<!-- Jakarta Servlet API (Spring Boot 3.x 使用 Jakarta 命名空间) -->
|
||||
<dependency>
|
||||
<groupId>jakarta.servlet</groupId>
|
||||
<artifactId>jakarta.servlet-api</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
||||
@@ -5,7 +5,6 @@ import com.central.search.annotation.EnableSearchClient;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
|
||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||
|
||||
/**
|
||||
@@ -15,7 +14,6 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||
@EnableSearchClient
|
||||
@EnableTransactionManagement
|
||||
@EnableFeignInterceptor
|
||||
@EnableScheduling
|
||||
@SpringBootApplication
|
||||
public class DeviceCenterApp {
|
||||
public static void main(String[] args) {
|
||||
|
||||
-261
@@ -1,261 +0,0 @@
|
||||
package com.central.device.boat.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 无人船航线实体
|
||||
*
|
||||
* @author dzc
|
||||
* @date 2026-01-05
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@TableName("boat_route")
|
||||
public class BoatRoute implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 主键ID
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 航线唯一标识(UUID)
|
||||
*/
|
||||
@TableField("route_id")
|
||||
private String routeId;
|
||||
|
||||
/**
|
||||
* 航线名称
|
||||
*/
|
||||
@TableField("route_name")
|
||||
private String routeName;
|
||||
|
||||
/**
|
||||
* 绑定设备SN
|
||||
*/
|
||||
@TableField("device_sn")
|
||||
private String deviceSn;
|
||||
|
||||
/**
|
||||
* 设备名称
|
||||
*/
|
||||
@TableField("device_name")
|
||||
private String deviceName;
|
||||
|
||||
/**
|
||||
* 所属景区ID
|
||||
*/
|
||||
@TableField("scenic_id")
|
||||
private Long scenicId;
|
||||
|
||||
/**
|
||||
* 租户ID
|
||||
*/
|
||||
@TableField("tenant_id")
|
||||
private String tenantId;
|
||||
|
||||
// ========== 航线统计信息 ==========
|
||||
|
||||
/**
|
||||
* 航点数量
|
||||
*/
|
||||
@TableField("waypoint_count")
|
||||
private Integer waypointCount;
|
||||
|
||||
/**
|
||||
* 总航程(米)
|
||||
*/
|
||||
@TableField("total_distance")
|
||||
private BigDecimal totalDistance;
|
||||
|
||||
/**
|
||||
* 预计时长(秒)
|
||||
*/
|
||||
@TableField("total_duration")
|
||||
private Integer totalDuration;
|
||||
|
||||
/**
|
||||
* 巡航速度(m/s)
|
||||
*/
|
||||
@TableField("cruise_speed")
|
||||
private BigDecimal cruiseSpeed;
|
||||
|
||||
// ========== 航线边界 ==========
|
||||
|
||||
/**
|
||||
* 水域边界多边形(GeoJSON)
|
||||
*/
|
||||
@TableField("boundary_polygon")
|
||||
private String boundaryPolygon;
|
||||
|
||||
/**
|
||||
* 规划水域边界ID
|
||||
*/
|
||||
@TableField("boundary_id")
|
||||
private String boundaryId;
|
||||
|
||||
/**
|
||||
* 起点坐标(lng,lat)
|
||||
*/
|
||||
@TableField("start_point")
|
||||
private String startPoint;
|
||||
|
||||
/**
|
||||
* 终点坐标(lng,lat)
|
||||
*/
|
||||
@TableField("end_point")
|
||||
private String endPoint;
|
||||
|
||||
// ========== 航线配置 ==========
|
||||
|
||||
/**
|
||||
* 是否循环航行:0-否,1-是
|
||||
*/
|
||||
@TableField("loop_enabled")
|
||||
private Boolean loopEnabled;
|
||||
|
||||
/**
|
||||
* 循环次数(-1无限循环)
|
||||
*/
|
||||
@TableField("loop_count")
|
||||
private Integer loopCount;
|
||||
|
||||
/**
|
||||
* 结束动作:return_start-返回起点,stay-原地停留
|
||||
*/
|
||||
@TableField("return_mode")
|
||||
private String returnMode;
|
||||
|
||||
/**
|
||||
* 安全距离(米)
|
||||
*/
|
||||
@TableField("safe_distance")
|
||||
private BigDecimal safeDistance;
|
||||
|
||||
// ========== 状态字段 ==========
|
||||
|
||||
/**
|
||||
* 状态:0-草稿,1-已发布,2-执行中,3-已完成
|
||||
*/
|
||||
@TableField("status")
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 是否为模板:0-否,1-是
|
||||
*/
|
||||
@TableField("is_template")
|
||||
private Boolean isTemplate;
|
||||
|
||||
/**
|
||||
* 是否在模型中显示航线:0-否,1-是
|
||||
*/
|
||||
@TableField("show_in_model")
|
||||
private Integer showInModel;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
@TableField("remark")
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@TableField(value = "create_time", fill = FieldFill.INSERT)
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE)
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
@TableField(value = "create_by", fill = FieldFill.INSERT)
|
||||
private String createBy;
|
||||
|
||||
/**
|
||||
* 航线JSON文件URL(S3)
|
||||
*/
|
||||
@TableField("route_file_url")
|
||||
private String routeFileUrl;
|
||||
|
||||
/**
|
||||
* 删除标记
|
||||
*/
|
||||
@TableLogic
|
||||
@TableField("deleted")
|
||||
private Integer deleted;
|
||||
|
||||
// ========== 状态枚举 ==========
|
||||
|
||||
/**
|
||||
* 航线状态枚举
|
||||
*/
|
||||
public enum RouteStatus {
|
||||
DRAFT(0, "草稿"),
|
||||
PUBLISHED(1, "已发布"),
|
||||
EXECUTING(2, "执行中"),
|
||||
COMPLETED(3, "已完成");
|
||||
|
||||
private final Integer code;
|
||||
private final String desc;
|
||||
|
||||
RouteStatus(Integer code, String desc) {
|
||||
this.code = code;
|
||||
this.desc = desc;
|
||||
}
|
||||
|
||||
public Integer getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public String getDesc() {
|
||||
return desc;
|
||||
}
|
||||
|
||||
public static RouteStatus fromCode(Integer code) {
|
||||
for (RouteStatus status : values()) {
|
||||
if (status.getCode().equals(code)) {
|
||||
return status;
|
||||
}
|
||||
}
|
||||
return DRAFT;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 结束动作枚举
|
||||
*/
|
||||
public enum ReturnMode {
|
||||
RETURN_START("return_start", "返回起点"),
|
||||
STAY("stay", "原地停留");
|
||||
|
||||
private final String code;
|
||||
private final String desc;
|
||||
|
||||
ReturnMode(String code, String desc) {
|
||||
this.code = code;
|
||||
this.desc = desc;
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public String getDesc() {
|
||||
return desc;
|
||||
}
|
||||
}
|
||||
}
|
||||
-115
@@ -1,115 +0,0 @@
|
||||
package com.central.device.boat.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 无人船轨迹实体
|
||||
*
|
||||
* @author dzc
|
||||
* @date 2026-01-05
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@TableName("boat_track")
|
||||
public class BoatTrack implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 主键ID
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 设备SN
|
||||
*/
|
||||
@TableField("device_sn")
|
||||
private String deviceSn;
|
||||
|
||||
/**
|
||||
* 执行的航线ID
|
||||
*/
|
||||
@TableField("route_id")
|
||||
private String routeId;
|
||||
|
||||
/**
|
||||
* 任务ID(mission_code)
|
||||
*/
|
||||
@TableField("task_id")
|
||||
private String taskId;
|
||||
|
||||
// ========== 位置信息 ==========
|
||||
|
||||
/**
|
||||
* 经度
|
||||
*/
|
||||
@TableField("longitude")
|
||||
private BigDecimal longitude;
|
||||
|
||||
/**
|
||||
* 纬度
|
||||
*/
|
||||
@TableField("latitude")
|
||||
private BigDecimal latitude;
|
||||
|
||||
// ========== 航行状态 ==========
|
||||
|
||||
/**
|
||||
* 当前速度(m/s)
|
||||
*/
|
||||
@TableField("speed")
|
||||
private BigDecimal speed;
|
||||
|
||||
/**
|
||||
* 航向角(度)
|
||||
*/
|
||||
@TableField("heading")
|
||||
private BigDecimal heading;
|
||||
|
||||
/**
|
||||
* 电池电量(%)
|
||||
*/
|
||||
@TableField("battery_percent")
|
||||
private Integer batteryPercent;
|
||||
|
||||
// ========== 偏离检测 ==========
|
||||
|
||||
/**
|
||||
* 偏离航线距离(米)
|
||||
*/
|
||||
@TableField("deviation_distance")
|
||||
private BigDecimal deviationDistance;
|
||||
|
||||
/**
|
||||
* 是否偏离:0-否,1-是
|
||||
*/
|
||||
@TableField("is_deviation")
|
||||
private Boolean isDeviation;
|
||||
|
||||
/**
|
||||
* 最近航点序号
|
||||
*/
|
||||
@TableField("nearest_waypoint_index")
|
||||
private Integer nearestWaypointIndex;
|
||||
|
||||
// ========== 时间戳 ==========
|
||||
|
||||
/**
|
||||
* 设备上报时间
|
||||
*/
|
||||
@TableField("record_time")
|
||||
private LocalDateTime recordTime;
|
||||
|
||||
/**
|
||||
* 入库时间
|
||||
*/
|
||||
@TableField(value = "create_time", fill = FieldFill.INSERT)
|
||||
private LocalDateTime createTime;
|
||||
}
|
||||
-207
@@ -1,207 +0,0 @@
|
||||
package com.central.device.boat.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 无人船航点实体
|
||||
*
|
||||
* @author dzc
|
||||
* @date 2026-01-05
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@TableName(value = "boat_waypoint", autoResultMap = true)
|
||||
public class BoatWaypoint implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 主键ID
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 航点唯一标识
|
||||
*/
|
||||
@TableField("waypoint_id")
|
||||
private String waypointId;
|
||||
|
||||
/**
|
||||
* 关联航线ID
|
||||
*/
|
||||
@TableField("route_id")
|
||||
private String routeId;
|
||||
|
||||
/**
|
||||
* 航点序号(从0开始)
|
||||
*/
|
||||
@TableField("waypoint_index")
|
||||
private Integer waypointIndex;
|
||||
|
||||
// ========== 位置信息 ==========
|
||||
|
||||
/**
|
||||
* 经度
|
||||
*/
|
||||
@TableField("longitude")
|
||||
private BigDecimal longitude;
|
||||
|
||||
/**
|
||||
* 纬度
|
||||
*/
|
||||
@TableField("latitude")
|
||||
private BigDecimal latitude;
|
||||
|
||||
// ========== 航行参数 ==========
|
||||
|
||||
/**
|
||||
* 到达此点的速度(m/s),null使用航线默认
|
||||
*/
|
||||
@TableField("speed")
|
||||
private BigDecimal speed;
|
||||
|
||||
/**
|
||||
* 停留时长(秒)
|
||||
*/
|
||||
@TableField("stay_duration")
|
||||
private Integer stayDuration;
|
||||
|
||||
/**
|
||||
* 航向角(度,0-360,null自动计算)
|
||||
*/
|
||||
@TableField("heading_angle")
|
||||
private BigDecimal headingAngle;
|
||||
|
||||
/**
|
||||
* 转弯模式:smooth-平滑,sharp-急转
|
||||
*/
|
||||
@TableField("turn_mode")
|
||||
private String turnMode;
|
||||
|
||||
// ========== 航点动作 ==========
|
||||
|
||||
/**
|
||||
* 航点动作配置(JSON数组)
|
||||
*/
|
||||
@TableField(value = "actions", typeHandler = JacksonTypeHandler.class)
|
||||
private List<WaypointAction> actions;
|
||||
|
||||
// ========== 标记 ==========
|
||||
|
||||
/**
|
||||
* 是否关键点:0-否,1-是
|
||||
*/
|
||||
@TableField("is_key_point")
|
||||
private Boolean isKeyPoint;
|
||||
|
||||
/**
|
||||
* 航点名称
|
||||
*/
|
||||
@TableField("point_name")
|
||||
private String pointName;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
@TableField("remark")
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@TableField(value = "create_time", fill = FieldFill.INSERT)
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE)
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
// ========== 内嵌类 ==========
|
||||
|
||||
/**
|
||||
* 航点动作
|
||||
*/
|
||||
@Data
|
||||
public static class WaypointAction implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 动作类型: photo/video_start/video_stop/horn/light
|
||||
*/
|
||||
private String actionType;
|
||||
|
||||
/**
|
||||
* 动作持续时间(秒)
|
||||
*/
|
||||
private Integer duration;
|
||||
|
||||
/**
|
||||
* 动作参数
|
||||
*/
|
||||
private Object params;
|
||||
}
|
||||
|
||||
// ========== 枚举 ==========
|
||||
|
||||
/**
|
||||
* 转弯模式枚举
|
||||
*/
|
||||
public enum TurnMode {
|
||||
SMOOTH("smooth", "平滑转弯"),
|
||||
SHARP("sharp", "急转弯");
|
||||
|
||||
private final String code;
|
||||
private final String desc;
|
||||
|
||||
TurnMode(String code, String desc) {
|
||||
this.code = code;
|
||||
this.desc = desc;
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public String getDesc() {
|
||||
return desc;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 动作类型枚举
|
||||
*/
|
||||
public enum ActionType {
|
||||
PHOTO("photo", "拍照"),
|
||||
VIDEO_START("video_start", "开始录像"),
|
||||
VIDEO_STOP("video_stop", "停止录像"),
|
||||
HORN("horn", "鸣笛"),
|
||||
LIGHT("light", "灯光控制");
|
||||
|
||||
private final String code;
|
||||
private final String desc;
|
||||
|
||||
ActionType(String code, String desc) {
|
||||
this.code = code;
|
||||
this.desc = desc;
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public String getDesc() {
|
||||
return desc;
|
||||
}
|
||||
}
|
||||
}
|
||||
-190
@@ -1,190 +0,0 @@
|
||||
package com.central.device.boat.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 飞行轨迹实体
|
||||
*
|
||||
* @author dzc
|
||||
* @date 2025-12-17
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@TableName("drone_flight_track")
|
||||
public class DroneFlightTrack implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 主键ID
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 设备SN
|
||||
*/
|
||||
@TableField("device_sn")
|
||||
private String deviceSn;
|
||||
|
||||
/**
|
||||
* 任务ID(关联wayline_job.job_id)
|
||||
*/
|
||||
@TableField("job_id")
|
||||
private String jobId;
|
||||
|
||||
/**
|
||||
* 航线任务ID(关联wayline_route.route_id)
|
||||
*/
|
||||
@TableField("route_id")
|
||||
private String routeId;
|
||||
|
||||
/**
|
||||
* 经度
|
||||
*/
|
||||
@TableField("longitude")
|
||||
private BigDecimal longitude;
|
||||
|
||||
/**
|
||||
* 纬度
|
||||
*/
|
||||
@TableField("latitude")
|
||||
private BigDecimal latitude;
|
||||
|
||||
/**
|
||||
* 海拔高度(m)
|
||||
*/
|
||||
@TableField("altitude")
|
||||
private BigDecimal altitude;
|
||||
|
||||
/**
|
||||
* 相对高度(m)
|
||||
*/
|
||||
@TableField("height")
|
||||
private BigDecimal height;
|
||||
|
||||
/**
|
||||
* 水平速度(m/s)
|
||||
*/
|
||||
@TableField("horizontal_speed")
|
||||
private BigDecimal horizontalSpeed;
|
||||
|
||||
/**
|
||||
* 垂直速度(m/s)
|
||||
*/
|
||||
@TableField("vertical_speed")
|
||||
private BigDecimal verticalSpeed;
|
||||
|
||||
/**
|
||||
* 航向角(度)
|
||||
*/
|
||||
@TableField("heading")
|
||||
private BigDecimal heading;
|
||||
|
||||
/**
|
||||
* 俯仰角(度)
|
||||
*/
|
||||
@TableField("pitch")
|
||||
private BigDecimal pitch;
|
||||
|
||||
/**
|
||||
* 横滚角(度)
|
||||
*/
|
||||
@TableField("roll")
|
||||
private BigDecimal roll;
|
||||
|
||||
/**
|
||||
* 飞行模式
|
||||
*/
|
||||
@TableField("flight_mode")
|
||||
private Integer flightMode;
|
||||
|
||||
/**
|
||||
* 电池电量(%)
|
||||
*/
|
||||
@TableField("battery_percent")
|
||||
private Integer batteryPercent;
|
||||
|
||||
/**
|
||||
* 偏离距离(m)-与计划航线的偏离
|
||||
*/
|
||||
@TableField("deviation_distance")
|
||||
private BigDecimal deviationDistance;
|
||||
|
||||
/**
|
||||
* 是否偏离:0-否,1-是
|
||||
*/
|
||||
@TableField("is_deviation")
|
||||
private Integer isDeviation;
|
||||
|
||||
/**
|
||||
* 记录时间(无人机上报时间)
|
||||
*/
|
||||
@TableField("record_time")
|
||||
private LocalDateTime recordTime;
|
||||
|
||||
/**
|
||||
* 租户ID
|
||||
*/
|
||||
@TableField("tenant_id")
|
||||
private String tenantId;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@TableField(value = "create_time", fill = FieldFill.INSERT)
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/**
|
||||
* 飞行模式枚举(参考大疆飞行模式)
|
||||
*/
|
||||
public enum FlightMode {
|
||||
MANUAL(0, "手动模式"),
|
||||
ATTI(1, "姿态模式"),
|
||||
P_GPS(2, "P-GPS模式"),
|
||||
F_GPS(3, "F-GPS模式"),
|
||||
SPORT(4, "运动模式"),
|
||||
TRIPOD(5, "三脚架模式"),
|
||||
CINEMATIC(6, "平滑模式"),
|
||||
SMART(7, "智能模式"),
|
||||
BOUNCE(8, "弹跳模式"),
|
||||
WAYPOINT(9, "航线模式"),
|
||||
POI(10, "兴趣点环绕"),
|
||||
FOLLOW(11, "智能跟随"),
|
||||
FPV(12, "FPV模式"),
|
||||
ACTIVE_TRACK(13, "智能拍摄"),
|
||||
TAP_FLY(14, "点击飞行"),
|
||||
QUICK_SHOT(15, "快拍模式");
|
||||
|
||||
private final Integer code;
|
||||
private final String desc;
|
||||
|
||||
FlightMode(Integer code, String desc) {
|
||||
this.code = code;
|
||||
this.desc = desc;
|
||||
}
|
||||
|
||||
public Integer getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public String getDesc() {
|
||||
return desc;
|
||||
}
|
||||
|
||||
public static FlightMode fromCode(Integer code) {
|
||||
for (FlightMode mode : values()) {
|
||||
if (mode.getCode().equals(code)) {
|
||||
return mode;
|
||||
}
|
||||
}
|
||||
return MANUAL;
|
||||
}
|
||||
}
|
||||
}
|
||||
-193
@@ -1,193 +0,0 @@
|
||||
package com.central.device.boat.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 水域边界实体
|
||||
*
|
||||
* @author dzc
|
||||
* @date 2026-01-05
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@TableName("water_boundary")
|
||||
public class WaterBoundary implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 主键ID
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 边界唯一标识
|
||||
*/
|
||||
@TableField("boundary_id")
|
||||
private String boundaryId;
|
||||
|
||||
/**
|
||||
* 边界名称
|
||||
*/
|
||||
@TableField("boundary_name")
|
||||
private String boundaryName;
|
||||
|
||||
/**
|
||||
* 绑定设备SN
|
||||
*/
|
||||
@TableField("device_sn")
|
||||
private String deviceSn;
|
||||
|
||||
/**
|
||||
* 所属景区ID
|
||||
*/
|
||||
@TableField("scenic_id")
|
||||
private Long scenicId;
|
||||
|
||||
/**
|
||||
* 租户ID
|
||||
*/
|
||||
@TableField("tenant_id")
|
||||
private String tenantId;
|
||||
|
||||
// ========== 边界数据 ==========
|
||||
|
||||
/**
|
||||
* 边界类型:navigable-可航行,obstacle-障碍物,restricted-禁行区
|
||||
*/
|
||||
@TableField("boundary_type")
|
||||
private String boundaryType;
|
||||
|
||||
/**
|
||||
* 多边形坐标(GeoJSON)
|
||||
*/
|
||||
@TableField("polygon_data")
|
||||
private String polygonData;
|
||||
|
||||
/**
|
||||
* 中心点坐标
|
||||
*/
|
||||
@TableField("center_point")
|
||||
private String centerPoint;
|
||||
|
||||
/**
|
||||
* 面积(平方米)
|
||||
*/
|
||||
@TableField("area")
|
||||
private BigDecimal area;
|
||||
|
||||
// ========== 来源 ==========
|
||||
|
||||
/**
|
||||
* 来源:manual-手动绘制,model-模型识别,import-导入
|
||||
*/
|
||||
@TableField("source_type")
|
||||
private String sourceType;
|
||||
|
||||
/**
|
||||
* 关联3D模型ID
|
||||
*/
|
||||
@TableField("model_id")
|
||||
private String modelId;
|
||||
|
||||
/**
|
||||
* 是否在模型中显示标绘:0-否,1-是
|
||||
*/
|
||||
@TableField("show_in_model")
|
||||
private Integer showInModel;
|
||||
|
||||
// ========== 状态 ==========
|
||||
|
||||
/**
|
||||
* 状态:0-禁用,1-启用
|
||||
*/
|
||||
@TableField("status")
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@TableField(value = "create_time", fill = FieldFill.INSERT)
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE)
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
/**
|
||||
* 删除标记
|
||||
*/
|
||||
@TableLogic
|
||||
@TableField("deleted")
|
||||
private Integer deleted;
|
||||
|
||||
// ========== 枚举 ==========
|
||||
|
||||
/**
|
||||
* 边界类型枚举
|
||||
*/
|
||||
public enum BoundaryType {
|
||||
NAVIGABLE("navigable", "可航行区域"),
|
||||
OBSTACLE("obstacle", "障碍物"),
|
||||
RESTRICTED("restricted", "禁行区");
|
||||
|
||||
private final String code;
|
||||
private final String desc;
|
||||
|
||||
BoundaryType(String code, String desc) {
|
||||
this.code = code;
|
||||
this.desc = desc;
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public String getDesc() {
|
||||
return desc;
|
||||
}
|
||||
|
||||
public static BoundaryType fromCode(String code) {
|
||||
for (BoundaryType type : values()) {
|
||||
if (type.getCode().equals(code)) {
|
||||
return type;
|
||||
}
|
||||
}
|
||||
return NAVIGABLE;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 来源类型枚举
|
||||
*/
|
||||
public enum SourceType {
|
||||
MANUAL("manual", "手动绘制"),
|
||||
MODEL("model", "模型识别"),
|
||||
IMPORT("import", "导入");
|
||||
|
||||
private final String code;
|
||||
private final String desc;
|
||||
|
||||
SourceType(String code, String desc) {
|
||||
this.code = code;
|
||||
this.desc = desc;
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public String getDesc() {
|
||||
return desc;
|
||||
}
|
||||
}
|
||||
}
|
||||
-153
@@ -1,153 +0,0 @@
|
||||
package com.central.device.boat.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 航点动作实体
|
||||
*
|
||||
* @author dzc
|
||||
* @date 2025-12-17
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@TableName("wayline_action")
|
||||
public class WaylineAction implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 主键ID
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 航点ID(关联wayline_waypoint.id)
|
||||
*/
|
||||
@TableField("waypoint_id")
|
||||
private Long waypointId;
|
||||
|
||||
/**
|
||||
* 航线任务ID(冗余字段,便于查询)
|
||||
*/
|
||||
@TableField("route_id")
|
||||
private String routeId;
|
||||
|
||||
/**
|
||||
* 动作组ID
|
||||
*/
|
||||
@TableField("action_group_id")
|
||||
private Integer actionGroupId;
|
||||
|
||||
/**
|
||||
* 动作序号(组内)
|
||||
*/
|
||||
@TableField("action_index")
|
||||
private Integer actionIndex;
|
||||
|
||||
/**
|
||||
* 动作类型
|
||||
*/
|
||||
@TableField("action_type")
|
||||
private String actionType;
|
||||
|
||||
/**
|
||||
* 动作参数(JSON格式)
|
||||
*/
|
||||
@TableField("action_params")
|
||||
private String actionParams;
|
||||
|
||||
/**
|
||||
* 触发类型:reachPoint-到达航点,betweenAdjacentPoints-航点间
|
||||
*/
|
||||
@TableField("trigger_type")
|
||||
private String triggerType;
|
||||
|
||||
/**
|
||||
* 租户ID
|
||||
*/
|
||||
@TableField("tenant_id")
|
||||
private String tenantId;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@TableField("create_time")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/**
|
||||
* 动作类型枚举
|
||||
*/
|
||||
public enum ActionType {
|
||||
TAKE_PHOTO("takePhoto", "拍照"),
|
||||
START_RECORD("startRecord", "开始录像"),
|
||||
STOP_RECORD("stopRecord", "停止录像"),
|
||||
HOVER("hover", "悬停"),
|
||||
ZOOM("zoom", "变焦"),
|
||||
GIMBAL_ROTATE("gimbalRotate", "云台旋转"),
|
||||
ROTATE_YAW("rotateYaw", "飞机旋转"),
|
||||
MEGAPHONE("megaphone", "喊话器"),
|
||||
FOCUS("focus", "对焦"),
|
||||
GIMBAL_EVENLY_ROTATE("gimbalEvenlyRotate", "云台均匀旋转"),
|
||||
FLIGHT_PATH_ROTATE_YAW("flightPathRotateYaw", "飞行路径旋转"),
|
||||
LOOK_AT("lookAt", "查看目标"),
|
||||
LOOK_AT_TARGET("lookAtTarget", "查看特定目标");
|
||||
|
||||
private final String code;
|
||||
private final String desc;
|
||||
|
||||
ActionType(String code, String desc) {
|
||||
this.code = code;
|
||||
this.desc = desc;
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public String getDesc() {
|
||||
return desc;
|
||||
}
|
||||
|
||||
public static ActionType fromCode(String code) {
|
||||
for (ActionType type : values()) {
|
||||
if (type.getCode().equals(code)) {
|
||||
return type;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 触发类型枚举
|
||||
*/
|
||||
public enum TriggerType {
|
||||
REACH_POINT("reachPoint", "到达航点"),
|
||||
BETWEEN_ADJACENT_POINTS("betweenAdjacentPoints", "航点间"),
|
||||
AFTER_FINISHED_WAYPOINT("afterFinishedWaypoint", "完成航点后"),
|
||||
BEFORE_FINISHED_WAYPOINT("beforeFinishedWaypoint", "完成航点前"),
|
||||
IMMEDIATELY("immediately", "立即触发");
|
||||
|
||||
private final String code;
|
||||
private final String desc;
|
||||
|
||||
TriggerType(String code, String desc) {
|
||||
this.code = code;
|
||||
this.desc = desc;
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public String getDesc() {
|
||||
return desc;
|
||||
}
|
||||
}
|
||||
}
|
||||
-245
@@ -1,245 +0,0 @@
|
||||
package com.central.device.boat.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 航线任务实体
|
||||
*
|
||||
* @author dzc
|
||||
* @date 2025-12-17
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@TableName("wayline_route")
|
||||
public class WaylineRoute implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 主键ID
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 航线任务ID(UUID)
|
||||
*/
|
||||
@TableField("route_id")
|
||||
private String routeId;
|
||||
|
||||
/**
|
||||
* 航线任务名称
|
||||
*/
|
||||
@TableField("route_name")
|
||||
private String routeName;
|
||||
|
||||
/**
|
||||
* 关联航迹文件ID(wayline_file.wayline_id)
|
||||
*/
|
||||
@TableField("file_wayline_id")
|
||||
private String fileWaylineId;
|
||||
|
||||
/**
|
||||
* 绑定设备SN
|
||||
*/
|
||||
@TableField("device_sn")
|
||||
private String deviceSn;
|
||||
|
||||
/**
|
||||
* 设备名称(冗余)
|
||||
*/
|
||||
@TableField("device_name")
|
||||
private String deviceName;
|
||||
|
||||
/**
|
||||
* 解析状态:0-未解析,1-解析中,2-已解析,3-解析失败
|
||||
*/
|
||||
@TableField("parse_status")
|
||||
private Integer parseStatus;
|
||||
|
||||
/**
|
||||
* 解析错误信息
|
||||
*/
|
||||
@TableField("parse_error")
|
||||
private String parseError;
|
||||
|
||||
/**
|
||||
* 航点数量
|
||||
*/
|
||||
@TableField("waypoint_count")
|
||||
private Integer waypointCount;
|
||||
|
||||
/**
|
||||
* 动作总数
|
||||
*/
|
||||
@TableField("action_count")
|
||||
private Integer actionCount;
|
||||
|
||||
/**
|
||||
* 总航程(m)
|
||||
*/
|
||||
@TableField("total_distance")
|
||||
private BigDecimal totalDistance;
|
||||
|
||||
/**
|
||||
* 预计时长(s)
|
||||
*/
|
||||
@TableField("total_duration")
|
||||
private BigDecimal totalDuration;
|
||||
|
||||
/**
|
||||
* 自动飞行速度(m/s)
|
||||
*/
|
||||
@TableField("auto_flight_speed")
|
||||
private BigDecimal autoFlightSpeed;
|
||||
|
||||
/**
|
||||
* 起飞点坐标(经度,纬度,高度)
|
||||
*/
|
||||
@TableField("take_off_point")
|
||||
private String takeOffPoint;
|
||||
|
||||
/**
|
||||
* 完成动作:goHome/hover/landing
|
||||
*/
|
||||
@TableField("finish_action")
|
||||
private String finishAction;
|
||||
|
||||
/**
|
||||
* 遥控器失联动作
|
||||
*/
|
||||
@TableField("exit_on_rc_lost")
|
||||
private String exitOnRcLost;
|
||||
|
||||
/**
|
||||
* 全局返航高度(m)
|
||||
*/
|
||||
@TableField("global_rth_height")
|
||||
private BigDecimal globalRthHeight;
|
||||
|
||||
/**
|
||||
* 坐标系
|
||||
*/
|
||||
@TableField("coordinate_mode")
|
||||
private String coordinateMode;
|
||||
|
||||
/**
|
||||
* 高度模式
|
||||
*/
|
||||
@TableField("height_mode")
|
||||
private String heightMode;
|
||||
|
||||
/**
|
||||
* 状态:0-禁用,1-启用
|
||||
*/
|
||||
@TableField("status")
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
@TableField("remark")
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 工作空间ID
|
||||
*/
|
||||
@TableField("workspace_id")
|
||||
private String workspaceId;
|
||||
|
||||
/**
|
||||
* 租户ID
|
||||
*/
|
||||
@TableField("tenant_id")
|
||||
private String tenantId;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
@TableField(value = "create_by", fill = FieldFill.INSERT)
|
||||
private String createBy;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@TableField(value = "create_time", fill = FieldFill.INSERT)
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/**
|
||||
* 更新人
|
||||
*/
|
||||
@TableField(value = "update_by", fill = FieldFill.INSERT_UPDATE)
|
||||
private String updateBy;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE)
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
/**
|
||||
* 解析状态枚举
|
||||
*/
|
||||
public enum ParseStatus {
|
||||
NOT_PARSED(0, "未解析"),
|
||||
PARSING(1, "解析中"),
|
||||
PARSED(2, "已解析"),
|
||||
FAILED(3, "解析失败");
|
||||
|
||||
private final Integer code;
|
||||
private final String desc;
|
||||
|
||||
ParseStatus(Integer code, String desc) {
|
||||
this.code = code;
|
||||
this.desc = desc;
|
||||
}
|
||||
|
||||
public Integer getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public String getDesc() {
|
||||
return desc;
|
||||
}
|
||||
|
||||
public static ParseStatus fromCode(Integer code) {
|
||||
for (ParseStatus status : values()) {
|
||||
if (status.getCode().equals(code)) {
|
||||
return status;
|
||||
}
|
||||
}
|
||||
return NOT_PARSED;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 完成动作枚举
|
||||
*/
|
||||
public enum FinishAction {
|
||||
GO_HOME("goHome", "自动返航"),
|
||||
HOVER("hover", "原地悬停"),
|
||||
LANDING("landing", "原地降落");
|
||||
|
||||
private final String code;
|
||||
private final String desc;
|
||||
|
||||
FinishAction(String code, String desc) {
|
||||
this.code = code;
|
||||
this.desc = desc;
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public String getDesc() {
|
||||
return desc;
|
||||
}
|
||||
}
|
||||
}
|
||||
-195
@@ -1,195 +0,0 @@
|
||||
package com.central.device.boat.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 航点实体
|
||||
*
|
||||
* @author dzc
|
||||
* @date 2025-12-17
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@TableName("wayline_waypoint")
|
||||
public class WaylineWaypoint implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 主键ID
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 航线任务ID(关联wayline_route.route_id)
|
||||
*/
|
||||
@TableField("route_id")
|
||||
private String routeId;
|
||||
|
||||
/**
|
||||
* 航点序号(从0开始)
|
||||
*/
|
||||
@TableField("waypoint_index")
|
||||
private Integer waypointIndex;
|
||||
|
||||
/**
|
||||
* 经度
|
||||
*/
|
||||
@TableField("longitude")
|
||||
private BigDecimal longitude;
|
||||
|
||||
/**
|
||||
* 纬度
|
||||
*/
|
||||
@TableField("latitude")
|
||||
private BigDecimal latitude;
|
||||
|
||||
/**
|
||||
* 相对高度(m)-相对起飞点
|
||||
*/
|
||||
@TableField("height")
|
||||
private BigDecimal height;
|
||||
|
||||
/**
|
||||
* 执行高度(m)
|
||||
*/
|
||||
@TableField("execute_height")
|
||||
private BigDecimal executeHeight;
|
||||
|
||||
/**
|
||||
* 椭球高度(m)
|
||||
*/
|
||||
@TableField("ellipsoid_height")
|
||||
private BigDecimal ellipsoidHeight;
|
||||
|
||||
/**
|
||||
* 飞行速度(m/s)
|
||||
*/
|
||||
@TableField("speed")
|
||||
private BigDecimal speed;
|
||||
|
||||
/**
|
||||
* 航向模式
|
||||
*/
|
||||
@TableField("heading_mode")
|
||||
private String headingMode;
|
||||
|
||||
/**
|
||||
* 航向角(度)
|
||||
*/
|
||||
@TableField("heading_angle")
|
||||
private BigDecimal headingAngle;
|
||||
|
||||
/**
|
||||
* 云台俯仰角(度)
|
||||
*/
|
||||
@TableField("gimbal_pitch_angle")
|
||||
private BigDecimal gimbalPitchAngle;
|
||||
|
||||
/**
|
||||
* 转弯模式
|
||||
*/
|
||||
@TableField("turn_mode")
|
||||
private String turnMode;
|
||||
|
||||
/**
|
||||
* 转弯阻尼距离(m)
|
||||
*/
|
||||
@TableField("turn_damping_dist")
|
||||
private BigDecimal turnDampingDist;
|
||||
|
||||
/**
|
||||
* 是否直线飞行:0-否,1-是
|
||||
*/
|
||||
@TableField("use_straight_line")
|
||||
private Integer useStraightLine;
|
||||
|
||||
/**
|
||||
* 是否风险点:0-否,1-是
|
||||
*/
|
||||
@TableField("is_risky")
|
||||
private Integer isRisky;
|
||||
|
||||
/**
|
||||
* 动作组数量
|
||||
*/
|
||||
@TableField("action_group_count")
|
||||
private Integer actionGroupCount;
|
||||
|
||||
/**
|
||||
* 租户ID
|
||||
*/
|
||||
@TableField("tenant_id")
|
||||
private String tenantId;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@TableField(value = "create_time", fill = FieldFill.INSERT)
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE)
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
/**
|
||||
* 航向模式枚举
|
||||
*/
|
||||
public enum HeadingMode {
|
||||
AUTO("auto", "自动"),
|
||||
MANUAL("manual", "手动"),
|
||||
TOWARD_POINT_OF_INTEREST("towardPointOfInterest", "朝向兴趣点"),
|
||||
RC_CONTROL("rcControl", "遥控器控制");
|
||||
|
||||
private final String code;
|
||||
private final String desc;
|
||||
|
||||
HeadingMode(String code, String desc) {
|
||||
this.code = code;
|
||||
this.desc = desc;
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public String getDesc() {
|
||||
return desc;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 转弯模式枚举
|
||||
*/
|
||||
public enum TurnMode {
|
||||
TO_POINT_AND_STOP("toPointAndStop", "到点停止"),
|
||||
TO_POINT_AND_GO_WITH_STOP("toPointAndGoWithStop", "到点不停"),
|
||||
COORDINATE_TURN("coordinateTurn", "协调转弯"),
|
||||
MANUAL_CONTROL("manualControl", "手动控制");
|
||||
|
||||
private final String code;
|
||||
private final String desc;
|
||||
|
||||
TurnMode(String code, String desc) {
|
||||
this.code = code;
|
||||
this.desc = desc;
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public String getDesc() {
|
||||
return desc;
|
||||
}
|
||||
}
|
||||
}
|
||||
-369
@@ -1,369 +0,0 @@
|
||||
package com.central.device.boat.manager;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.central.device.websocket.client.JetLinksWebSocketClient;
|
||||
import com.central.device.websocket.config.WebSocketProperties;
|
||||
import com.central.device.websocket.model.CommandStatus;
|
||||
import com.central.device.websocket.model.DeviceCommand;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.*;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
/**
|
||||
* 无人船命令管理器
|
||||
* 负责无人船命令队列管理、发送、重试、超时处理
|
||||
* 复用全局JetLinksWebSocketClient发送命令,使用 ship 产品标识
|
||||
*
|
||||
* @author dzc
|
||||
* @date 2026-04-07
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class BoatCommandManager {
|
||||
|
||||
@Autowired
|
||||
private WebSocketProperties properties;
|
||||
|
||||
@Autowired
|
||||
private JetLinksWebSocketClient jetLinksWebSocketClient;
|
||||
|
||||
/** 无人船产品标识 */
|
||||
public static final String PRODUCT_BOAT = "ship";
|
||||
|
||||
/** 待发送命令队列: deviceSn -> Queue<DeviceCommand> */
|
||||
private final ConcurrentHashMap<String, ConcurrentLinkedQueue<DeviceCommand>> commandQueues = new ConcurrentHashMap<>();
|
||||
|
||||
/** 已发送等待响应的命令: commandId -> DeviceCommand */
|
||||
private final ConcurrentHashMap<String, DeviceCommand> pendingCommands = new ConcurrentHashMap<>();
|
||||
|
||||
/** 延迟执行器(用于重试) */
|
||||
private final ScheduledExecutorService retryExecutor = Executors.newScheduledThreadPool(2);
|
||||
|
||||
/**
|
||||
* 发送命令
|
||||
*
|
||||
* @param deviceSn 设备SN
|
||||
* @param commandType 命令类型(flighttask_prepare/flighttask_pause/flighttask_recovery/flighttask_undo)
|
||||
* @param params 命令参数
|
||||
* @return 命令ID
|
||||
*/
|
||||
public String sendCommand(String deviceSn, String commandType, JSONObject params) {
|
||||
DeviceCommand command = DeviceCommand.builder()
|
||||
.commandId(UUID.randomUUID().toString())
|
||||
.deviceSn(deviceSn)
|
||||
.commandType(commandType)
|
||||
.params(params != null ? params : new JSONObject())
|
||||
.status(CommandStatus.PENDING)
|
||||
.createTime(System.currentTimeMillis())
|
||||
.sendTime(0)
|
||||
.expireTime(System.currentTimeMillis() + properties.getCommand().getDefaultTimeout())
|
||||
.retryCount(0)
|
||||
.maxRetry(properties.getCommand().getMaxRetry())
|
||||
.build();
|
||||
|
||||
log.info("[无人船] 创建命令: commandId={}, device={}, type={}",
|
||||
command.getCommandId(), deviceSn, commandType);
|
||||
|
||||
// 检查全局WebSocket连接状态,未连接则自动连接
|
||||
if (!jetLinksWebSocketClient.isConnected()) {
|
||||
log.info("[无人船] WebSocket未连接,自动建立连接: commandId={}", command.getCommandId());
|
||||
jetLinksWebSocketClient.connect();
|
||||
|
||||
int waitCount = 0;
|
||||
while (!jetLinksWebSocketClient.isConnected() && waitCount < 50) {
|
||||
try {
|
||||
Thread.sleep(100);
|
||||
waitCount++;
|
||||
} catch (InterruptedException e) {
|
||||
Thread.currentThread().interrupt();
|
||||
log.error("[无人船] 等待连接被中断");
|
||||
addToQueue(command);
|
||||
return command.getCommandId();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (jetLinksWebSocketClient.isConnected()) {
|
||||
sendCommandImmediately(command);
|
||||
} else {
|
||||
log.warn("[无人船] WebSocket连接失败,命令加入队列: commandId={}, device={}",
|
||||
command.getCommandId(), deviceSn);
|
||||
addToQueue(command);
|
||||
}
|
||||
|
||||
return command.getCommandId();
|
||||
}
|
||||
|
||||
/**
|
||||
* 立即发送命令(通过全局WebSocket客户端)
|
||||
* topic 使用 /device-message-sender/ship/{deviceSn}
|
||||
*/
|
||||
private void sendCommandImmediately(DeviceCommand command) {
|
||||
try {
|
||||
command.setStatus(CommandStatus.SENDING);
|
||||
command.setSendTime(System.currentTimeMillis());
|
||||
|
||||
// 构造指令内容 (properties)
|
||||
JSONObject cmdProperties = buildCommandProperties(command);
|
||||
|
||||
// 构造 parameter
|
||||
JSONObject parameter = new JSONObject();
|
||||
parameter.put("messageType", "WRITE_PROPERTY");
|
||||
parameter.put("properties", cmdProperties);
|
||||
|
||||
JSONObject headers = new JSONObject();
|
||||
headers.put("async", false);
|
||||
parameter.put("headers", headers);
|
||||
|
||||
// 构造完整消息(使用 ship 产品标识)
|
||||
JSONObject message = new JSONObject();
|
||||
message.put("type", "sub");
|
||||
message.put("topic", "/device-message-sender/" + PRODUCT_BOAT + "/" + command.getDeviceSn());
|
||||
message.put("parameter", parameter);
|
||||
message.put("id", command.getCommandId());
|
||||
|
||||
String messageJson = message.toJSONString();
|
||||
log.info("[无人船] 发送命令消息: {}", messageJson);
|
||||
jetLinksWebSocketClient.send(messageJson);
|
||||
|
||||
command.setStatus(CommandStatus.SENT);
|
||||
pendingCommands.put(command.getCommandId(), command);
|
||||
|
||||
log.info("[无人船] 命令发送成功: commandId={}, device={}, type={}",
|
||||
command.getCommandId(), command.getDeviceSn(), command.getCommandType());
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("[无人船] 命令发送失败: commandId={}, error={}", command.getCommandId(), e.getMessage());
|
||||
command.setStatus(CommandStatus.FAILED);
|
||||
command.setErrorMsg(e.getMessage());
|
||||
retryCommand(command);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据命令类型构造 properties 内容(无人船专用)
|
||||
*
|
||||
* 与无人机的关键区别:
|
||||
* 1. 无人船的暂停/恢复/终止都需要 order_no 参数
|
||||
* 2. 无人船的开始任务需要 order_no、wayline_link_url、file_md5、stream_urls
|
||||
*/
|
||||
private JSONObject buildCommandProperties(DeviceCommand command) {
|
||||
JSONObject cmdProperties = new JSONObject();
|
||||
JSONObject data = new JSONObject();
|
||||
String method = command.getCommandType();
|
||||
JSONObject params = command.getParams();
|
||||
|
||||
switch (method) {
|
||||
case "flighttask_prepare":
|
||||
// 开始任务
|
||||
data.put("order_no", params.getString("order_no"));
|
||||
data.put("wayline_link_url", params.getString("wayline_link_url"));
|
||||
data.put("file_md5", params.getString("file_md5"));
|
||||
if (params.containsKey("stream_urls")) {
|
||||
data.put("stream_urls", params.get("stream_urls"));
|
||||
}
|
||||
break;
|
||||
|
||||
case "flighttask_pause":
|
||||
// 暂停任务
|
||||
data.put("order_no", params.getString("order_no"));
|
||||
break;
|
||||
|
||||
case "flighttask_recovery":
|
||||
// 恢复任务
|
||||
data.put("order_no", params.getString("order_no"));
|
||||
break;
|
||||
|
||||
case "flighttask_undo":
|
||||
// 终止任务
|
||||
if (params.containsKey("order_no")) {
|
||||
data.put("order_no", params.getString("order_no"));
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
data = params;
|
||||
break;
|
||||
}
|
||||
|
||||
cmdProperties.put("method", method);
|
||||
cmdProperties.put("data", data);
|
||||
return cmdProperties;
|
||||
}
|
||||
|
||||
/**
|
||||
* 加入队列
|
||||
*/
|
||||
private void addToQueue(DeviceCommand command) {
|
||||
ConcurrentLinkedQueue<DeviceCommand> queue = commandQueues
|
||||
.computeIfAbsent(command.getDeviceSn(), k -> new ConcurrentLinkedQueue<>());
|
||||
|
||||
if (queue.size() >= properties.getCommand().getQueueMaxSize()) {
|
||||
log.error("[无人船] 设备 {} 命令队列已满({}), 拒绝新命令: {}",
|
||||
command.getDeviceSn(), properties.getCommand().getQueueMaxSize(), command.getCommandId());
|
||||
command.setStatus(CommandStatus.FAILED);
|
||||
command.setErrorMsg("命令队列已满");
|
||||
return;
|
||||
}
|
||||
|
||||
queue.offer(command);
|
||||
log.info("[无人船] 命令已加入队列: commandId={}, device={}, 队列长度={}",
|
||||
command.getCommandId(), command.getDeviceSn(), queue.size());
|
||||
}
|
||||
|
||||
/**
|
||||
* WebSocket重连后处理所有队列
|
||||
* 由外部在 WebSocket 重连成功后调用
|
||||
*/
|
||||
public void onWebSocketReconnected() {
|
||||
log.info("[无人船] WebSocket重连成功,开始处理命令队列");
|
||||
|
||||
if (commandQueues.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
int totalProcessed = 0;
|
||||
int totalExpired = 0;
|
||||
|
||||
for (String deviceSn : commandQueues.keySet()) {
|
||||
ConcurrentLinkedQueue<DeviceCommand> queue = commandQueues.get(deviceSn);
|
||||
if (queue == null || queue.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
while (!queue.isEmpty()) {
|
||||
DeviceCommand command = queue.poll();
|
||||
|
||||
if (System.currentTimeMillis() > command.getExpireTime()) {
|
||||
command.setStatus(CommandStatus.EXPIRED);
|
||||
totalExpired++;
|
||||
log.warn("[无人船] 命令已过期: commandId={}, device={}", command.getCommandId(), deviceSn);
|
||||
continue;
|
||||
}
|
||||
|
||||
sendCommandImmediately(command);
|
||||
totalProcessed++;
|
||||
|
||||
try {
|
||||
Thread.sleep(100);
|
||||
} catch (InterruptedException e) {
|
||||
Thread.currentThread().interrupt();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (totalProcessed > 0 || totalExpired > 0) {
|
||||
log.info("[无人船] 命令队列处理完成: 重发={}, 过期={}", totalProcessed, totalExpired);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 命令重试
|
||||
*/
|
||||
private void retryCommand(DeviceCommand command) {
|
||||
if (command.getRetryCount() >= command.getMaxRetry()) {
|
||||
log.error("[无人船] 命令重试次数超限: commandId={}, device={}",
|
||||
command.getCommandId(), command.getDeviceSn());
|
||||
command.setStatus(CommandStatus.FAILED);
|
||||
return;
|
||||
}
|
||||
|
||||
command.setRetryCount(command.getRetryCount() + 1);
|
||||
log.info("[无人船] 命令准备重试 ({}/{}): commandId={}",
|
||||
command.getRetryCount(), command.getMaxRetry(), command.getCommandId());
|
||||
|
||||
long delay = (long) Math.pow(2, command.getRetryCount()) * properties.getCommand().getRetryDelayBase();
|
||||
|
||||
retryExecutor.schedule(() -> {
|
||||
if (jetLinksWebSocketClient.isConnected()) {
|
||||
sendCommandImmediately(command);
|
||||
} else {
|
||||
addToQueue(command);
|
||||
}
|
||||
}, delay, TimeUnit.MILLISECONDS);
|
||||
}
|
||||
|
||||
/**
|
||||
* 接收设备命令响应
|
||||
*/
|
||||
public void handleCommandResponse(String commandId, boolean success, String message) {
|
||||
DeviceCommand command = pendingCommands.remove(commandId);
|
||||
if (command == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (success) {
|
||||
command.setStatus(CommandStatus.SUCCESS);
|
||||
log.info("[无人船] 命令执行成功: commandId={}, device={}, type={}",
|
||||
commandId, command.getDeviceSn(), command.getCommandType());
|
||||
} else {
|
||||
command.setStatus(CommandStatus.FAILED);
|
||||
command.setErrorMsg(message);
|
||||
log.error("[无人船] 命令执行失败: commandId={}, device={}, type={}, error={}",
|
||||
commandId, command.getDeviceSn(), command.getCommandType(), message);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 定时清理过期命令
|
||||
*/
|
||||
@Scheduled(fixedRateString = "${device.websocket.command.cleanup-interval:10000}")
|
||||
public void cleanupExpiredCommands() {
|
||||
long now = System.currentTimeMillis();
|
||||
int queueExpiredCount = 0;
|
||||
AtomicInteger pendingTimeoutCount = new AtomicInteger(0);
|
||||
|
||||
for (ConcurrentLinkedQueue<DeviceCommand> queue : commandQueues.values()) {
|
||||
for (DeviceCommand command : queue) {
|
||||
if (now > command.getExpireTime()) {
|
||||
if (queue.remove(command)) {
|
||||
command.setStatus(CommandStatus.EXPIRED);
|
||||
queueExpiredCount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pendingCommands.entrySet().removeIf(entry -> {
|
||||
DeviceCommand command = entry.getValue();
|
||||
if (now > command.getExpireTime()) {
|
||||
command.setStatus(CommandStatus.TIMEOUT);
|
||||
pendingTimeoutCount.incrementAndGet();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
if (queueExpiredCount > 0 || pendingTimeoutCount.get() > 0) {
|
||||
log.info("[无人船] 清理过期命令: 队列过期={}, 响应超时={}", queueExpiredCount, pendingTimeoutCount.get());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询命令状态
|
||||
*/
|
||||
public CommandStatus getCommandStatus(String commandId) {
|
||||
DeviceCommand command = pendingCommands.get(commandId);
|
||||
if (command != null) {
|
||||
return command.getStatus();
|
||||
}
|
||||
|
||||
for (ConcurrentLinkedQueue<DeviceCommand> queue : commandQueues.values()) {
|
||||
Optional<DeviceCommand> found = queue.stream()
|
||||
.filter(cmd -> cmd.getCommandId().equals(commandId))
|
||||
.findFirst();
|
||||
if (found.isPresent()) {
|
||||
return found.get().getStatus();
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
-158
@@ -1,158 +0,0 @@
|
||||
package com.central.device.boat.manager;
|
||||
|
||||
import com.central.device.boat.model.BoatSubscriptionTopic;
|
||||
import com.central.device.websocket.client.JetLinksWebSocketClient;
|
||||
import com.central.device.websocket.handler.DeviceMessageHandler;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 无人船设备订阅管理器
|
||||
* 管理无人船设备的 WebSocket 主题订阅/取消订阅
|
||||
* 使用 BoatSubscriptionTopic(ship 产品),通过 JetLinksWebSocketClient 的 subscribeRawTopic/unsubscribeRawTopic 方法
|
||||
* 确保 topic 被纳入 subscribedTopics 跟踪,消息路由不被过滤
|
||||
*
|
||||
* @author dzc
|
||||
* @date 2026-04-07
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class BoatSubscriptionManager {
|
||||
|
||||
@Autowired
|
||||
private JetLinksWebSocketClient jetLinksWebSocketClient;
|
||||
|
||||
@Autowired
|
||||
private DeviceMessageHandler messageHandler;
|
||||
|
||||
/**
|
||||
* 订阅无人船设备(上线、离线、状态事件)
|
||||
*
|
||||
* @param deviceSn 设备SN
|
||||
* @param tenantId 租户ID
|
||||
*/
|
||||
public void subscribeBoatDevice(String deviceSn, String tenantId) {
|
||||
if (deviceSn == null || deviceSn.trim().isEmpty()) {
|
||||
log.warn("[无人船] 设备SN为空,无法订阅");
|
||||
return;
|
||||
}
|
||||
|
||||
log.info("[无人船] 订阅设备: deviceSn={}, tenantId={}", deviceSn, tenantId);
|
||||
|
||||
try {
|
||||
ensureConnected();
|
||||
|
||||
messageHandler.addDevice(deviceSn, 0L, tenantId);
|
||||
|
||||
jetLinksWebSocketClient.subscribeRawTopic(
|
||||
BoatSubscriptionTopic.BOAT_ONLINE.getTopic(deviceSn), deviceSn);
|
||||
jetLinksWebSocketClient.subscribeRawTopic(
|
||||
BoatSubscriptionTopic.BOAT_OFFLINE.getTopic(deviceSn), deviceSn);
|
||||
jetLinksWebSocketClient.subscribeRawTopic(
|
||||
BoatSubscriptionTopic.BOAT_EVENT_FIRE_ALARM.getTopic(deviceSn), deviceSn);
|
||||
|
||||
log.info("[无人船] 设备 {} 订阅成功", deviceSn);
|
||||
} catch (Exception e) {
|
||||
log.error("[无人船] 设备 {} 订阅失败: {}", deviceSn, e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 订阅无人船遥测数据(进入操控台时调用)
|
||||
*
|
||||
* @param deviceSn 设备SN
|
||||
*/
|
||||
public void subscribeBoatTelemetry(String deviceSn) {
|
||||
if (deviceSn == null || deviceSn.trim().isEmpty()) {
|
||||
log.warn("[无人船] 设备SN为空,无法订阅遥测");
|
||||
return;
|
||||
}
|
||||
|
||||
log.info("[无人船] 订阅遥测数据: deviceSn={}", deviceSn);
|
||||
|
||||
try {
|
||||
ensureConnected();
|
||||
jetLinksWebSocketClient.subscribeRawTopic(
|
||||
BoatSubscriptionTopic.BOAT_EVENT_MSG_ALARM.getTopic(deviceSn), deviceSn);
|
||||
log.info("[无人船] 遥测数据 {} 订阅成功", deviceSn);
|
||||
} catch (Exception e) {
|
||||
log.error("[无人船] 订阅遥测数据 {} 失败: {}", deviceSn, e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 取消订阅无人船设备
|
||||
*
|
||||
* @param deviceSn 设备SN
|
||||
*/
|
||||
public void unsubscribeBoatDevice(String deviceSn) {
|
||||
if (deviceSn == null || deviceSn.trim().isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
log.info("[无人船] 取消订阅设备: deviceSn={}", deviceSn);
|
||||
|
||||
try {
|
||||
jetLinksWebSocketClient.unsubscribeRawTopic(
|
||||
BoatSubscriptionTopic.BOAT_ONLINE.getTopic(deviceSn), deviceSn);
|
||||
jetLinksWebSocketClient.unsubscribeRawTopic(
|
||||
BoatSubscriptionTopic.BOAT_OFFLINE.getTopic(deviceSn), deviceSn);
|
||||
jetLinksWebSocketClient.unsubscribeRawTopic(
|
||||
BoatSubscriptionTopic.BOAT_EVENT_FIRE_ALARM.getTopic(deviceSn), deviceSn);
|
||||
jetLinksWebSocketClient.unsubscribeRawTopic(
|
||||
BoatSubscriptionTopic.BOAT_EVENT_MSG_ALARM.getTopic(deviceSn), deviceSn);
|
||||
|
||||
messageHandler.removeDevice(deviceSn);
|
||||
log.info("[无人船] 设备 {} 订阅已取消", deviceSn);
|
||||
} catch (Exception e) {
|
||||
log.error("[无人船] 取消订阅设备 {} 失败: {}", deviceSn, e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 取消订阅无人船遥测数据(退出操控台时调用)
|
||||
*
|
||||
* @param deviceSn 设备SN
|
||||
*/
|
||||
public void unsubscribeBoatTelemetry(String deviceSn) {
|
||||
if (deviceSn == null || deviceSn.trim().isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
log.info("[无人船] 取消订阅遥测数据: deviceSn={}", deviceSn);
|
||||
|
||||
try {
|
||||
jetLinksWebSocketClient.unsubscribeRawTopic(
|
||||
BoatSubscriptionTopic.BOAT_EVENT_MSG_ALARM.getTopic(deviceSn), deviceSn);
|
||||
log.info("[无人船] 遥测数据 {} 订阅已取消", deviceSn);
|
||||
} catch (Exception e) {
|
||||
log.error("[无人船] 取消订阅遥测数据 {} 失败: {}", deviceSn, e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 确保 WebSocket 已连接
|
||||
*/
|
||||
private void ensureConnected() {
|
||||
if (!jetLinksWebSocketClient.isConnected()) {
|
||||
log.info("[无人船] WebSocket未连接,自动建立连接");
|
||||
jetLinksWebSocketClient.connect();
|
||||
|
||||
int waitCount = 0;
|
||||
while (!jetLinksWebSocketClient.isConnected() && waitCount < 50) {
|
||||
try {
|
||||
Thread.sleep(100);
|
||||
waitCount++;
|
||||
} catch (InterruptedException e) {
|
||||
Thread.currentThread().interrupt();
|
||||
throw new RuntimeException("等待WebSocket连接被中断");
|
||||
}
|
||||
}
|
||||
|
||||
if (!jetLinksWebSocketClient.isConnected()) {
|
||||
throw new RuntimeException("WebSocket连接超时");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
-46
@@ -1,46 +0,0 @@
|
||||
package com.central.device.boat.model;
|
||||
|
||||
/**
|
||||
* 无人船WebSocket订阅主题
|
||||
* 基于JetLinks平台的主题订阅模式,使用 ship 产品标识
|
||||
*
|
||||
* @author dzc
|
||||
* @date 2026-04-07
|
||||
*/
|
||||
public enum BoatSubscriptionTopic {
|
||||
|
||||
/** 无人船设备上线 */
|
||||
BOAT_ONLINE("/device/ship/{deviceSn}/online"),
|
||||
|
||||
/** 无人船设备离线 */
|
||||
BOAT_OFFLINE("/device/ship/{deviceSn}/offline"),
|
||||
|
||||
/** 无人船设备状态事件 */
|
||||
BOAT_EVENT_FIRE_ALARM("/device/ship/{deviceSn}/message/event/fire_alarm"),
|
||||
|
||||
/** 无人船遥测数据事件 */
|
||||
BOAT_EVENT_MSG_ALARM("/device/ship/{deviceSn}/message/event/msg_alarm"),
|
||||
|
||||
/** 无人船属性上报 */
|
||||
BOAT_PROPERTY_REPORT("/device/ship/{deviceSn}/message/property/report");
|
||||
|
||||
private final String topicPattern;
|
||||
|
||||
BoatSubscriptionTopic(String topicPattern) {
|
||||
this.topicPattern = topicPattern;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取主题(替换deviceSn占位符)
|
||||
*/
|
||||
public String getTopic(String deviceSn) {
|
||||
return topicPattern.replace("{deviceSn}", deviceSn);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取主题模式
|
||||
*/
|
||||
public String getTopicPattern() {
|
||||
return topicPattern;
|
||||
}
|
||||
}
|
||||
-316
@@ -1,316 +0,0 @@
|
||||
package com.central.device.boat.sse;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.central.device.boat.manager.BoatSubscriptionManager;
|
||||
import com.central.device.model.vo.BoatRealtimeVO;
|
||||
import com.central.device.service.IBoatTrackService;
|
||||
import com.central.device.sse.model.EmitterWrapper;
|
||||
import com.central.device.websocket.handler.DeviceMessageHandler;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.servlet.mvc.method.annotation.SseEmitter;
|
||||
|
||||
import jakarta.annotation.PostConstruct;
|
||||
import jakarta.annotation.PreDestroy;
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* 无人船SSE发射器管理器(独立模块,不与无人机/机库混用)
|
||||
*
|
||||
* 职责:
|
||||
* 1. 管理所有无人船SSE连接(admin + client)
|
||||
* 2. 按设备SN引用计数,懒加载/卸载 JetLinks WebSocket 订阅
|
||||
* 3. 接收 DeviceMessageHandler 的 boatFireAlarm 回调,转换并推送 boat-telemetry 事件
|
||||
*
|
||||
* 数据流:
|
||||
* JetLinks fire_alarm → DeviceMessageHandler.handleDeviceStateEvent()
|
||||
* → navMode 检测 → boatFireAlarmCallback
|
||||
* → handleBoatFireAlarm() → sendBoatDataUpdate() → SSE 客户端
|
||||
*
|
||||
* @author dzc
|
||||
* @date 2026-04-07
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class BoatSseEmitterManager {
|
||||
|
||||
@Autowired
|
||||
private BoatSubscriptionManager boatSubscriptionManager;
|
||||
|
||||
@Autowired
|
||||
private DeviceMessageHandler messageHandler;
|
||||
|
||||
@Autowired
|
||||
private IBoatTrackService boatTrackService;
|
||||
|
||||
/** SSE连接池: sessionId → EmitterWrapper */
|
||||
private final ConcurrentHashMap<String, EmitterWrapper> emitters = new ConcurrentHashMap<>();
|
||||
|
||||
/** 设备引用计数: deviceSn → 当前连接数(归零时取消订阅) */
|
||||
private final ConcurrentHashMap<String, Integer> deviceRefCount = new ConcurrentHashMap<>();
|
||||
|
||||
private ScheduledExecutorService heartbeatExecutor;
|
||||
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
startHeartbeat();
|
||||
}
|
||||
|
||||
@PreDestroy
|
||||
public void destroy() {
|
||||
if (heartbeatExecutor != null) {
|
||||
heartbeatExecutor.shutdownNow();
|
||||
}
|
||||
}
|
||||
|
||||
// ==================== 连接管理 ====================
|
||||
|
||||
/**
|
||||
* 添加无人船SSE连接
|
||||
*/
|
||||
public SseEmitter addEmitter(String sessionId, String deviceSn, String tenantId) {
|
||||
// 移除重复连接
|
||||
if (emitters.containsKey(sessionId)) {
|
||||
log.warn("[无人船SSE] 检测到重复连接,先移除: sessionId={}", sessionId);
|
||||
removeEmitter(sessionId, deviceSn);
|
||||
}
|
||||
|
||||
SseEmitter emitter = new SseEmitter(0L);
|
||||
|
||||
emitter.onCompletion(() -> {
|
||||
log.info("[无人船SSE] 连接完成: session={}, deviceSn={}", sessionId, deviceSn);
|
||||
removeEmitter(sessionId, deviceSn);
|
||||
});
|
||||
emitter.onTimeout(() -> {
|
||||
log.warn("[无人船SSE] 连接超时: session={}, deviceSn={}", sessionId, deviceSn);
|
||||
removeEmitter(sessionId, deviceSn);
|
||||
});
|
||||
emitter.onError(ex -> {
|
||||
log.error("[无人船SSE] 连接错误: session={}, deviceSn={}, error={}",
|
||||
sessionId, deviceSn, ex.getMessage());
|
||||
removeEmitter(sessionId, deviceSn);
|
||||
});
|
||||
|
||||
EmitterWrapper wrapper = new EmitterWrapper(emitter, 0L, tenantId, sessionId, deviceSn);
|
||||
emitters.put(sessionId, wrapper);
|
||||
|
||||
// 发送连接确认
|
||||
try {
|
||||
emitter.send(SseEmitter.event()
|
||||
.name("connected")
|
||||
.data("{\"status\":\"connected\",\"deviceSn\":\"" + deviceSn + "\"}"));
|
||||
} catch (Exception e) {
|
||||
log.error("[无人船SSE] 发送连接确认失败: session={}", sessionId, e);
|
||||
}
|
||||
|
||||
// 引用计数 +1,首次订阅时触发 WebSocket 订阅 + 注册回调
|
||||
int refCount = deviceRefCount.compute(deviceSn, (k, v) -> v == null ? 1 : v + 1);
|
||||
if (refCount == 1) {
|
||||
log.info("[无人船SSE] 设备 {} 首次订阅,触发 WebSocket 订阅", deviceSn);
|
||||
try {
|
||||
boatSubscriptionManager.subscribeBoatDevice(deviceSn, tenantId);
|
||||
messageHandler.registerBoatFireAlarmCallback(deviceSn, (sn, data) -> handleBoatFireAlarm(sn, data));
|
||||
} catch (Exception e) {
|
||||
log.error("[无人船SSE] 设备 {} WebSocket 订阅失败,SSE连接已建立但暂无数据: {}", deviceSn, e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
log.info("[无人船SSE] 新增连接: session={}, deviceSn={}, 设备引用={}, 总连接数={}",
|
||||
sessionId, deviceSn, refCount, emitters.size());
|
||||
|
||||
return emitter;
|
||||
}
|
||||
|
||||
/**
|
||||
* 移除SSE连接
|
||||
*/
|
||||
private void removeEmitter(String sessionId, String deviceSn) {
|
||||
EmitterWrapper wrapper = emitters.remove(sessionId);
|
||||
if (wrapper == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
wrapper.getEmitter().complete();
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
|
||||
// 引用计数 -1,归零时取消 WebSocket 订阅 + 移除回调
|
||||
Integer remaining = deviceRefCount.compute(deviceSn, (k, v) -> {
|
||||
if (v == null || v <= 1) return null;
|
||||
return v - 1;
|
||||
});
|
||||
|
||||
if (remaining == null) {
|
||||
log.info("[无人船SSE] 设备 {} 最后一个订阅者离开,取消 WebSocket 订阅", deviceSn);
|
||||
messageHandler.removeBoatFireAlarmCallback(deviceSn);
|
||||
boatSubscriptionManager.unsubscribeBoatDevice(deviceSn);
|
||||
}
|
||||
|
||||
log.info("[无人船SSE] 移除连接: session={}, deviceSn={}, 剩余连接数={}",
|
||||
sessionId, deviceSn, emitters.size());
|
||||
}
|
||||
|
||||
/**
|
||||
* 主动移除SSE连接(供控制器调用)
|
||||
*/
|
||||
public boolean removeEmitterBySessionId(String sessionId, String deviceSn) {
|
||||
if (!emitters.containsKey(sessionId)) {
|
||||
return false;
|
||||
}
|
||||
removeEmitter(sessionId, deviceSn);
|
||||
return true;
|
||||
}
|
||||
|
||||
// ==================== 数据处理 ====================
|
||||
|
||||
/**
|
||||
* 处理无人船 fire_alarm 回调
|
||||
*/
|
||||
private void handleBoatFireAlarm(String deviceSn, JSONObject rawData) {
|
||||
JSONObject boatData = rawData.getJSONObject("boatData");
|
||||
if (boatData == null || boatData.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
Long timestamp = rawData.getLong("timestamp");
|
||||
|
||||
// log.info("[无人船SSE] 收到设备遥测: deviceSn={}, lng={}, lat={}, speed={}, heading={}, battery={}, status={}",
|
||||
// deviceSn,
|
||||
// boatData.getDouble("longitude"),
|
||||
// boatData.getDouble("latitude"),
|
||||
// boatData.getDouble("speed"),
|
||||
// boatData.getDouble("heading"),
|
||||
// boatData.getInteger("battery"),
|
||||
// boatData.getString("deviceStatus"));
|
||||
|
||||
// 转换为前端 BoatTelemetryData 格式并推送 SSE
|
||||
JSONObject telemetry = toFrontendJson(deviceSn, boatData, timestamp);
|
||||
sendBoatDataUpdate(deviceSn, telemetry);
|
||||
|
||||
// 更新实时缓存
|
||||
BoatRealtimeVO vo = toRealtimeVO(deviceSn, boatData, timestamp);
|
||||
boatTrackService.pushTelemetryData(deviceSn, vo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设备上报字段 → 前端 BoatTelemetryData JSON
|
||||
*/
|
||||
private JSONObject toFrontendJson(String deviceSn, JSONObject boatData, Long timestamp) {
|
||||
JSONObject t = new JSONObject();
|
||||
t.put("deviceSn", deviceSn);
|
||||
t.put("longitude", boatData.getDouble("longitude"));
|
||||
t.put("latitude", boatData.getDouble("latitude"));
|
||||
t.put("heading", boatData.getDouble("heading"));
|
||||
t.put("speed", boatData.getDouble("speed"));
|
||||
t.put("battery", boatData.getInteger("battery"));
|
||||
t.put("status", boatData.getString("deviceStatus"));
|
||||
t.put("online", true);
|
||||
|
||||
String signal = boatData.getString("signal");
|
||||
t.put("signalStrength", "5G".equals(signal) ? 95 : "4G".equals(signal) ? 75 : 0);
|
||||
|
||||
t.put("recordTime", timestamp != null
|
||||
? Instant.ofEpochMilli(timestamp).toString()
|
||||
: Instant.now().toString());
|
||||
|
||||
Integer wp = boatData.getInteger("waypointIndex");
|
||||
if (wp != null && wp >= 0) {
|
||||
t.put("currentWaypointIndex", wp);
|
||||
}
|
||||
return t;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设备上报字段 → BoatRealtimeVO(供缓存/持久化)
|
||||
*/
|
||||
private BoatRealtimeVO toRealtimeVO(String deviceSn, JSONObject boatData, Long timestamp) {
|
||||
BoatRealtimeVO vo = new BoatRealtimeVO();
|
||||
vo.setDeviceSn(deviceSn);
|
||||
vo.setLongitude(boatData.getBigDecimal("longitude"));
|
||||
vo.setLatitude(boatData.getBigDecimal("latitude"));
|
||||
vo.setSpeed(boatData.getBigDecimal("speed"));
|
||||
vo.setHeading(boatData.getBigDecimal("heading"));
|
||||
vo.setBatteryPercent(boatData.getInteger("battery"));
|
||||
vo.setStatus(boatData.getString("deviceStatus"));
|
||||
vo.setOnline(true);
|
||||
|
||||
Integer wp = boatData.getInteger("waypointIndex");
|
||||
if (wp != null && wp >= 0) {
|
||||
vo.setNearestWaypointIndex(wp);
|
||||
}
|
||||
|
||||
vo.setRecordTime(timestamp != null
|
||||
? LocalDateTime.ofInstant(Instant.ofEpochMilli(timestamp), ZoneId.systemDefault())
|
||||
: LocalDateTime.now());
|
||||
return vo;
|
||||
}
|
||||
|
||||
// ==================== SSE 推送 ====================
|
||||
|
||||
/**
|
||||
* 推送数据到所有匹配 deviceSn 的 SSE 连接
|
||||
*/
|
||||
private void sendBoatDataUpdate(String deviceSn, JSONObject data) {
|
||||
List<String> deadEmitters = new ArrayList<>();
|
||||
|
||||
emitters.forEach((sessionId, wrapper) -> {
|
||||
if (deviceSn.equals(wrapper.getDeviceSn())) {
|
||||
try {
|
||||
wrapper.getEmitter().send(SseEmitter.event()
|
||||
.name("boat-telemetry")
|
||||
.data(data.toJSONString()));
|
||||
} catch (Exception e) {
|
||||
log.warn("[无人船SSE] 推送失败: session={}, error={}", sessionId, e.getMessage());
|
||||
deadEmitters.add(sessionId);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
deadEmitters.forEach(sid -> {
|
||||
EmitterWrapper w = emitters.get(sid);
|
||||
if (w != null) removeEmitter(sid, w.getDeviceSn());
|
||||
});
|
||||
}
|
||||
|
||||
// ==================== 心跳 ====================
|
||||
|
||||
private void startHeartbeat() {
|
||||
heartbeatExecutor = Executors.newSingleThreadScheduledExecutor();
|
||||
heartbeatExecutor.scheduleAtFixedRate(() -> {
|
||||
if (emitters.isEmpty()) return;
|
||||
|
||||
List<String> dead = new ArrayList<>();
|
||||
emitters.forEach((sessionId, wrapper) -> {
|
||||
try {
|
||||
wrapper.getEmitter().send(SseEmitter.event()
|
||||
.name("heartbeat").data("ping"));
|
||||
} catch (Exception e) {
|
||||
dead.add(sessionId);
|
||||
}
|
||||
});
|
||||
|
||||
if (!dead.isEmpty()) {
|
||||
log.info("[无人船SSE] 心跳检测到 {} 个断连", dead.size());
|
||||
dead.forEach(sid -> {
|
||||
EmitterWrapper w = emitters.get(sid);
|
||||
if (w != null) removeEmitter(sid, w.getDeviceSn());
|
||||
});
|
||||
}
|
||||
}, 15, 15, TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
/** 获取当前连接数 */
|
||||
public int getConnectionCount() {
|
||||
return emitters.size();
|
||||
}
|
||||
}
|
||||
@@ -1,59 +0,0 @@
|
||||
package com.central.device.config;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.scheduling.annotation.EnableAsync;
|
||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
|
||||
/**
|
||||
* 异步任务配置
|
||||
*
|
||||
* @author dzc
|
||||
* @date 2025-12-17
|
||||
*/
|
||||
@Slf4j
|
||||
@Configuration
|
||||
@EnableAsync
|
||||
public class AsyncConfig {
|
||||
|
||||
/**
|
||||
* 航线解析专用线程池
|
||||
*/
|
||||
@Bean("waylineParseExecutor")
|
||||
public Executor waylineParseExecutor() {
|
||||
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
|
||||
|
||||
// 核心线程数
|
||||
executor.setCorePoolSize(2);
|
||||
|
||||
// 最大线程数
|
||||
executor.setMaxPoolSize(5);
|
||||
|
||||
// 队列容量
|
||||
executor.setQueueCapacity(100);
|
||||
|
||||
// 线程名前缀
|
||||
executor.setThreadNamePrefix("wayline-parse-");
|
||||
|
||||
// 拒绝策略:由调用线程处理
|
||||
executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
|
||||
|
||||
// 线程空闲时间
|
||||
executor.setKeepAliveSeconds(60);
|
||||
|
||||
// 等待所有任务结束后再关闭线程池
|
||||
executor.setWaitForTasksToCompleteOnShutdown(true);
|
||||
|
||||
// 等待时间
|
||||
executor.setAwaitTerminationSeconds(60);
|
||||
|
||||
executor.initialize();
|
||||
log.info("航线解析线程池初始化完成");
|
||||
|
||||
return executor;
|
||||
}
|
||||
}
|
||||
-82
@@ -6,10 +6,7 @@ import com.alibaba.excel.support.ExcelTypeEnum;
|
||||
import com.central.common.model.PageResult;
|
||||
import com.central.common.model.Result;
|
||||
import com.central.device.model.AgeDevice;
|
||||
import com.central.device.model.dto.DeviceStatusDTO;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import com.central.device.model.excel.AgeDeviceExcel;
|
||||
import com.central.device.model.vo.AgeDeviceLocationVO;
|
||||
import com.central.device.service.IAgeDeviceService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
@@ -28,7 +25,6 @@ import java.io.IOException;
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -94,24 +90,6 @@ public class AgeDeviceController {
|
||||
return Result.succeed("删除成功");
|
||||
}
|
||||
|
||||
@Operation(summary = "根据设备SN获取设备经纬度")
|
||||
@GetMapping("/location/{deviceSn}")
|
||||
public Result<AgeDeviceLocationVO> getLocationByDeviceSn(@PathVariable String deviceSn) {
|
||||
if (deviceSn == null || deviceSn.trim().isEmpty()) {
|
||||
return Result.failed("deviceSn不能为空");
|
||||
}
|
||||
AgeDevice device = ageDeviceService.getByDeviceSn(deviceSn);
|
||||
if (device == null) {
|
||||
return Result.succeed(null, "暂无数据");
|
||||
}
|
||||
AgeDeviceLocationVO vo = new AgeDeviceLocationVO();
|
||||
vo.setDeviceSn(deviceSn);
|
||||
vo.setLongitude(device.getLongitude());
|
||||
vo.setLatitude(device.getLatitude());
|
||||
vo.setWeatherBlockEnabled(device.getWeatherBlockEnabled());
|
||||
return Result.succeed(vo, "查询成功");
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出设备信息
|
||||
*/
|
||||
@@ -292,64 +270,4 @@ public class AgeDeviceController {
|
||||
return excel;
|
||||
}).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新设备天气阻飞开关
|
||||
*/
|
||||
@Operation(summary = "更新设备天气阻飞开关")
|
||||
@PutMapping("/weather-block")
|
||||
public Result updateWeatherBlock(@RequestBody Map<String, Object> params) {
|
||||
try {
|
||||
String deviceSn = (String) params.get("deviceSn");
|
||||
Integer weatherBlockEnabled = (Integer) params.get("weatherBlockEnabled");
|
||||
|
||||
if (deviceSn == null || deviceSn.trim().isEmpty()) {
|
||||
return Result.failed("deviceSn参数不能为空");
|
||||
}
|
||||
if (weatherBlockEnabled == null) {
|
||||
return Result.failed("weatherBlockEnabled参数不能为空");
|
||||
}
|
||||
|
||||
log.info("更新设备天气阻飞开关,deviceSn: {}, weatherBlockEnabled: {}", deviceSn, weatherBlockEnabled);
|
||||
|
||||
AgeDevice device = ageDeviceService.getByDeviceSn(deviceSn);
|
||||
if (device == null) {
|
||||
return Result.failed("设备不存在");
|
||||
}
|
||||
|
||||
device.setWeatherBlockEnabled(weatherBlockEnabled);
|
||||
boolean result = ageDeviceService.updateById(device);
|
||||
|
||||
return result ? Result.succeed("更新成功") : Result.failed("更新失败");
|
||||
} catch (Exception e) {
|
||||
log.error("更新设备天气阻飞开关失败", e);
|
||||
return Result.failed("更新失败:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改设备状态(在线/离线)
|
||||
* deviceStatus: 0-在线,1-离线
|
||||
*/
|
||||
@Operation(summary = "修改设备状态")
|
||||
@PostMapping("/updateDeviceStatus")
|
||||
public Result updateDeviceStatus(@Validated @RequestBody DeviceStatusDTO dto) {
|
||||
try {
|
||||
log.info("修改设备状态,deviceSn: {}, deviceStatus: {}", dto.getDeviceSn(), dto.getDeviceStatus());
|
||||
|
||||
AgeDevice device = ageDeviceService.getByDeviceSn(dto.getDeviceSn());
|
||||
if (device == null) {
|
||||
return Result.failed("设备不存在");
|
||||
}
|
||||
|
||||
device.setBoundStatus(dto.getDeviceStatus());
|
||||
device.setBoundTime(new Date());
|
||||
boolean result = ageDeviceService.updateById(device);
|
||||
|
||||
return result ? Result.succeed("更新成功") : Result.failed("更新失败");
|
||||
} catch (Exception e) {
|
||||
log.error("修改设备状态失败", e);
|
||||
return Result.failed("更新失败:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
-104
@@ -1,104 +0,0 @@
|
||||
package com.central.device.controller;
|
||||
|
||||
import com.central.common.model.Result;
|
||||
import com.central.device.model.dto.BoatManualControlDTO;
|
||||
import com.central.device.service.IBoatControlService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
/**
|
||||
* 无人船控制命令Controller
|
||||
*
|
||||
* @author dzc
|
||||
* @date 2026-01-05
|
||||
*/
|
||||
@Tag(name = "无人船控制命令")
|
||||
@RestController
|
||||
@RequestMapping("/device/boat/command")
|
||||
@RequiredArgsConstructor
|
||||
public class BoatCommandController {
|
||||
|
||||
private final IBoatControlService boatControlService;
|
||||
|
||||
@Operation(summary = "执行航线任务")
|
||||
@PostMapping("/route/execute")
|
||||
public Result<String> executeRoute(
|
||||
@Parameter(description = "设备SN") @RequestParam String deviceSn,
|
||||
@Parameter(description = "航线ID") @RequestParam String boatRouteId,
|
||||
@Parameter(description = "任务编码") @RequestParam String missionCode) {
|
||||
String commandId = boatControlService.executeRoute(deviceSn, boatRouteId, missionCode);
|
||||
return Result.succeed(commandId, "任务已下发");
|
||||
}
|
||||
|
||||
@Operation(summary = "暂停航行")
|
||||
@PostMapping("/pause")
|
||||
public Result<Void> pause(
|
||||
@Parameter(description = "设备SN") @RequestParam String deviceSn,
|
||||
@Parameter(description = "任务编码") @RequestParam String missionCode) {
|
||||
boatControlService.pause(deviceSn, missionCode);
|
||||
return Result.succeed(null, "暂停指令已下发");
|
||||
}
|
||||
|
||||
@Operation(summary = "恢复航行")
|
||||
@PostMapping("/resume")
|
||||
public Result<Void> resume(
|
||||
@Parameter(description = "设备SN") @RequestParam String deviceSn,
|
||||
@Parameter(description = "任务编码") @RequestParam String missionCode) {
|
||||
boatControlService.resume(deviceSn, missionCode);
|
||||
return Result.succeed(null, "恢复指令已下发");
|
||||
}
|
||||
|
||||
@Operation(summary = "终止任务")
|
||||
@PostMapping("/undo")
|
||||
public Result<Void> undoTask(
|
||||
@Parameter(description = "设备SN") @RequestParam String deviceSn,
|
||||
@Parameter(description = "任务编码") @RequestParam String missionCode) {
|
||||
boatControlService.undoTask(deviceSn, missionCode);
|
||||
return Result.succeed(null, "终止任务指令已下发");
|
||||
}
|
||||
|
||||
@Operation(summary = "返回起点")
|
||||
@PostMapping("/return")
|
||||
public Result<Void> returnToStart(
|
||||
@Parameter(description = "设备SN") @RequestParam String deviceSn) {
|
||||
boatControlService.returnToStart(deviceSn);
|
||||
return Result.succeed(null, "返航指令已下发");
|
||||
}
|
||||
|
||||
@Operation(summary = "紧急停止")
|
||||
@PostMapping("/emergency-stop")
|
||||
public Result<Void> emergencyStop(
|
||||
@Parameter(description = "设备SN") @RequestParam String deviceSn) {
|
||||
boatControlService.emergencyStop(deviceSn);
|
||||
return Result.succeed(null, "紧急停止指令已下发");
|
||||
}
|
||||
|
||||
@Operation(summary = "手动控制")
|
||||
@PostMapping("/manual")
|
||||
public Result<Void> manualControl(
|
||||
@Parameter(description = "设备SN") @RequestParam String deviceSn,
|
||||
@RequestBody @Validated BoatManualControlDTO dto) {
|
||||
boatControlService.manualControl(deviceSn, dto);
|
||||
return Result.succeed(null, "控制指令已发送");
|
||||
}
|
||||
|
||||
@Operation(summary = "检查设备是否在线")
|
||||
@GetMapping("/online/{deviceSn}")
|
||||
public Result<Boolean> isDeviceOnline(
|
||||
@Parameter(description = "设备SN") @PathVariable String deviceSn) {
|
||||
boolean online = boatControlService.isDeviceOnline(deviceSn);
|
||||
return Result.succeed(online);
|
||||
}
|
||||
|
||||
@Operation(summary = "获取设备状态")
|
||||
@GetMapping("/status/{deviceSn}")
|
||||
public Result<String> getDeviceStatus(
|
||||
@Parameter(description = "设备SN") @PathVariable String deviceSn) {
|
||||
String status = boatControlService.getDeviceStatus(deviceSn);
|
||||
return Result.succeed(status);
|
||||
}
|
||||
}
|
||||
-143
@@ -1,143 +0,0 @@
|
||||
package com.central.device.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.central.common.model.Result;
|
||||
import com.central.device.model.dto.BoatRouteCreateDTO;
|
||||
import com.central.device.model.dto.BoatRouteDisplayUpdateDTO;
|
||||
import com.central.device.model.dto.BoatRouteUpdateDTO;
|
||||
import com.central.device.model.vo.BoatRouteDetailVO;
|
||||
import com.central.device.model.vo.BoatRouteListVO;
|
||||
import com.central.device.model.vo.RouteValidateResultVO;
|
||||
import com.central.device.service.IBoatRouteService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 无人船航线管理Controller
|
||||
*
|
||||
* @author dzc
|
||||
* @date 2026-01-05
|
||||
*/
|
||||
@Tag(name = "无人船航线管理")
|
||||
@RestController
|
||||
@RequestMapping("/device/boat/route")
|
||||
@RequiredArgsConstructor
|
||||
public class BoatRouteController {
|
||||
|
||||
private final IBoatRouteService boatRouteService;
|
||||
|
||||
@Operation(summary = "创建航线")
|
||||
@PostMapping("/create")
|
||||
public Result<String> createRoute(@RequestBody @Validated BoatRouteCreateDTO dto) {
|
||||
String routeId = boatRouteService.createRoute(dto);
|
||||
return Result.succeed(routeId, "航线创建成功");
|
||||
}
|
||||
|
||||
@Operation(summary = "更新航线")
|
||||
@PutMapping("/{routeId}")
|
||||
public Result<Void> updateRoute(
|
||||
@Parameter(description = "航线ID") @PathVariable String routeId,
|
||||
@RequestBody @Validated BoatRouteUpdateDTO dto) {
|
||||
boatRouteService.updateRoute(routeId, dto);
|
||||
return Result.succeed(null, "航线更新成功");
|
||||
}
|
||||
|
||||
@Operation(summary = "获取航线详情")
|
||||
@GetMapping("/{routeId}")
|
||||
public Result<BoatRouteDetailVO> getRouteDetail(
|
||||
@Parameter(description = "航线ID") @PathVariable String routeId) {
|
||||
BoatRouteDetailVO detail = boatRouteService.getRouteDetail(routeId);
|
||||
return Result.succeed(detail);
|
||||
}
|
||||
|
||||
@Operation(summary = "获取设备绑定的航线列表")
|
||||
@GetMapping("/list/device/{deviceSn}")
|
||||
public Result<List<BoatRouteListVO>> listByDeviceSn(
|
||||
@Parameter(description = "设备SN") @PathVariable String deviceSn) {
|
||||
List<BoatRouteListVO> list = boatRouteService.listByDeviceSn(deviceSn);
|
||||
return Result.succeed(list);
|
||||
}
|
||||
|
||||
@Operation(summary = "获取景区航线列表(分页)")
|
||||
@GetMapping("/list/scenic/{scenicId}")
|
||||
public Result<Page<BoatRouteListVO>> listByScenicId(
|
||||
@Parameter(description = "景区ID") @PathVariable Long scenicId,
|
||||
@Parameter(description = "页码") @RequestParam(defaultValue = "1") Integer page,
|
||||
@Parameter(description = "每页数量") @RequestParam(defaultValue = "10") Integer size) {
|
||||
Page<BoatRouteListVO> pageResult = boatRouteService.listByScenicId(scenicId, page, size);
|
||||
return Result.succeed(pageResult);
|
||||
}
|
||||
|
||||
@Operation(summary = "绑定航线到设备")
|
||||
@PostMapping("/{routeId}/bind")
|
||||
public Result<Void> bindToDevice(
|
||||
@Parameter(description = "航线ID") @PathVariable String routeId,
|
||||
@Parameter(description = "设备SN") @RequestParam String deviceSn) {
|
||||
boatRouteService.bindToDevice(routeId, deviceSn);
|
||||
return Result.succeed(null, "绑定成功");
|
||||
}
|
||||
|
||||
@Operation(summary = "解绑航线和设备")
|
||||
@PostMapping("/{routeId}/unbind")
|
||||
public Result<Void> unbindDevice(
|
||||
@Parameter(description = "航线ID") @PathVariable String routeId) {
|
||||
boatRouteService.unbindDevice(routeId);
|
||||
return Result.succeed(null, "解绑成功");
|
||||
}
|
||||
|
||||
@Operation(summary = "校验航线")
|
||||
@PostMapping("/validate")
|
||||
public Result<RouteValidateResultVO> validateRoute(
|
||||
@RequestBody @Validated BoatRouteCreateDTO dto,
|
||||
@Parameter(description = "边界ID(可选)") @RequestParam(required = false) String boundaryId) {
|
||||
RouteValidateResultVO result = boatRouteService.validateRoute(dto, boundaryId);
|
||||
return Result.succeed(result);
|
||||
}
|
||||
|
||||
@Operation(summary = "删除航线")
|
||||
@DeleteMapping("/{routeId}")
|
||||
public Result<Void> deleteRoute(
|
||||
@Parameter(description = "航线ID") @PathVariable String routeId) {
|
||||
boatRouteService.deleteRoute(routeId);
|
||||
return Result.succeed(null, "删除成功");
|
||||
}
|
||||
|
||||
@Operation(summary = "保存为模板")
|
||||
@PostMapping("/{routeId}/template")
|
||||
public Result<String> saveAsTemplate(
|
||||
@Parameter(description = "航线ID") @PathVariable String routeId,
|
||||
@Parameter(description = "模板名称") @RequestParam String templateName) {
|
||||
String newRouteId = boatRouteService.saveAsTemplate(routeId, templateName);
|
||||
return Result.succeed(newRouteId, "保存模板成功");
|
||||
}
|
||||
|
||||
@Operation(summary = "获取模板列表")
|
||||
@GetMapping("/templates")
|
||||
public Result<List<BoatRouteListVO>> listTemplates() {
|
||||
List<BoatRouteListVO> list = boatRouteService.listTemplates();
|
||||
return Result.succeed(list);
|
||||
}
|
||||
|
||||
@Operation(summary = "发布航线")
|
||||
@PostMapping("/{routeId}/publish")
|
||||
public Result<Void> publishRoute(
|
||||
@Parameter(description = "航线ID") @PathVariable String routeId) {
|
||||
boatRouteService.publishRoute(routeId);
|
||||
return Result.succeed(null, "发布成功");
|
||||
}
|
||||
|
||||
@Operation(summary = "按设备批量更新航线模型显示状态")
|
||||
@PutMapping("/display/device/{deviceSn}")
|
||||
public Result<Void> updateShowInModelByDeviceSn(
|
||||
@Parameter(description = "设备SN") @PathVariable String deviceSn,
|
||||
@RequestBody @Validated BoatRouteDisplayUpdateDTO dto) {
|
||||
boatRouteService.updateShowInModelByDeviceSn(deviceSn, dto.getRouteIds());
|
||||
return Result.succeed(null, "航线模型显示状态更新成功");
|
||||
}
|
||||
}
|
||||
-57
@@ -1,57 +0,0 @@
|
||||
package com.central.device.controller;
|
||||
|
||||
import com.central.common.model.Result;
|
||||
import com.central.device.model.vo.BoatRealtimeVO;
|
||||
import com.central.device.model.vo.TaskTrackVO;
|
||||
import com.central.device.model.vo.TrackPointVO;
|
||||
import com.central.device.service.IBoatTrackService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 无人船轨迹Controller
|
||||
*
|
||||
* @author dzc
|
||||
* @date 2026-01-05
|
||||
*/
|
||||
@Tag(name = "无人船轨迹")
|
||||
@RestController
|
||||
@RequestMapping("/device/boat/track")
|
||||
@RequiredArgsConstructor
|
||||
public class BoatTrackController {
|
||||
|
||||
private final IBoatTrackService boatTrackService;
|
||||
|
||||
@Operation(summary = "获取实时位置")
|
||||
@GetMapping("/realtime/{deviceSn}")
|
||||
public Result<BoatRealtimeVO> getRealtimePosition(
|
||||
@Parameter(description = "设备SN") @PathVariable String deviceSn) {
|
||||
BoatRealtimeVO realtime = boatTrackService.getRealtimePosition(deviceSn);
|
||||
return Result.succeed(realtime);
|
||||
}
|
||||
|
||||
@Operation(summary = "获取历史轨迹")
|
||||
@GetMapping("/history/{deviceSn}")
|
||||
public Result<List<TrackPointVO>> getHistoryTrack(
|
||||
@Parameter(description = "设备SN") @PathVariable String deviceSn,
|
||||
@Parameter(description = "开始时间") @RequestParam @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") LocalDateTime startTime,
|
||||
@Parameter(description = "结束时间") @RequestParam @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") LocalDateTime endTime) {
|
||||
List<TrackPointVO> track = boatTrackService.getHistoryTrack(deviceSn, startTime, endTime);
|
||||
return Result.succeed(track);
|
||||
}
|
||||
|
||||
@Operation(summary = "获取任务执行轨迹")
|
||||
@GetMapping("/task/{taskId}")
|
||||
public Result<TaskTrackVO> getTaskTrack(
|
||||
@Parameter(description = "任务ID") @PathVariable String taskId) {
|
||||
TaskTrackVO taskTrack = boatTrackService.getTaskTrack(taskId);
|
||||
return Result.succeed(taskTrack);
|
||||
}
|
||||
}
|
||||
-81
@@ -1,81 +0,0 @@
|
||||
package com.central.device.controller;
|
||||
|
||||
import com.central.common.model.Result;
|
||||
import com.central.device.model.AgeDevice;
|
||||
import com.central.device.model.vo.BoatRouteListVO;
|
||||
import com.central.device.model.vo.ThreeDModelFileVO;
|
||||
import com.central.device.service.IAgeDeviceService;
|
||||
import com.central.device.service.IBoatRouteService;
|
||||
import com.central.device.service.IThreeDModelFileService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 客户端Pad页面专用接口
|
||||
* Gateway放行 /client/**,无需认证
|
||||
*
|
||||
* @author dzc
|
||||
* @date 2026-03-11
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/client")
|
||||
@Tag(name = "客户端Pad接口")
|
||||
@RequiredArgsConstructor
|
||||
public class ClientController {
|
||||
|
||||
private final IAgeDeviceService ageDeviceService;
|
||||
private final IBoatRouteService boatRouteService;
|
||||
private final IThreeDModelFileService threeDModelFileService;
|
||||
|
||||
/**
|
||||
* 校验设备SN是否存在
|
||||
*/
|
||||
@Operation(summary = "设备SN校验登录")
|
||||
@GetMapping("/auth/check")
|
||||
public Result<?> checkDeviceSn(
|
||||
@Parameter(description = "设备SN", required = true)
|
||||
@RequestParam String deviceSn) {
|
||||
AgeDevice device = ageDeviceService.getByDeviceSn(deviceSn);
|
||||
if (device == null) {
|
||||
return Result.failed("设备不存在或未绑定");
|
||||
}
|
||||
Map<String, Object> info = new HashMap<>();
|
||||
info.put("deviceSn", device.getDeviceSn());
|
||||
info.put("deviceName", device.getDeviceName());
|
||||
info.put("deviceType", device.getDeviceType());
|
||||
return Result.succeed(info, "验证成功");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取设备航线列表
|
||||
*/
|
||||
@Operation(summary = "获取设备航线列表")
|
||||
@GetMapping("/routes")
|
||||
public Result<List<BoatRouteListVO>> getRoutes(
|
||||
@Parameter(description = "设备SN", required = true)
|
||||
@RequestParam String deviceSn) {
|
||||
List<BoatRouteListVO> routes = boatRouteService.listByDeviceSn(deviceSn);
|
||||
return Result.succeed(routes, "查询成功");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取设备关联的3D模型
|
||||
*/
|
||||
@Operation(summary = "获取设备3D模型列表")
|
||||
@GetMapping("/models")
|
||||
public Result<List<ThreeDModelFileVO>> getModels(
|
||||
@Parameter(description = "设备SN", required = true)
|
||||
@RequestParam String deviceSn) {
|
||||
List<ThreeDModelFileVO> models = threeDModelFileService.getByDeviceSn(deviceSn);
|
||||
return Result.succeed(models, "查询成功");
|
||||
}
|
||||
}
|
||||
-88
@@ -1,88 +0,0 @@
|
||||
package com.central.device.controller;
|
||||
|
||||
import com.central.device.boat.sse.BoatSseEmitterManager;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.servlet.mvc.method.annotation.SseEmitter;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* 客户端SSE遥测数据控制器
|
||||
* Gateway放行 /client/**,无需认证
|
||||
*
|
||||
* 数据流:
|
||||
* 客户端连接 → BoatSseEmitterManager(管理订阅+推送)→ fire_alarm → SSE boat-telemetry 事件
|
||||
*
|
||||
* @author dzc
|
||||
* @date 2026-03-11
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/client/sse")
|
||||
@Tag(name = "客户端SSE遥测接口")
|
||||
@RequiredArgsConstructor
|
||||
public class ClientSseController {
|
||||
|
||||
private final BoatSseEmitterManager boatSseEmitterManager;
|
||||
|
||||
@Operation(summary = "客户端订阅设备遥测数据")
|
||||
@GetMapping(value = "/telemetry/{deviceSn}", produces = MediaType.TEXT_EVENT_STREAM_VALUE)
|
||||
public ResponseEntity<SseEmitter> subscribeTelemetry(
|
||||
@Parameter(description = "设备SN", required = true)
|
||||
@PathVariable String deviceSn,
|
||||
@Parameter(description = "客户端会话ID(可选)")
|
||||
@RequestHeader(value = "X-Client-Session-Id", required = false) String clientSessionId) {
|
||||
|
||||
String connectionId;
|
||||
if (clientSessionId != null && !clientSessionId.trim().isEmpty()) {
|
||||
connectionId = "client_" + clientSessionId + "_" + deviceSn;
|
||||
} else {
|
||||
connectionId = "client_" + UUID.randomUUID().toString() + "_" + deviceSn;
|
||||
}
|
||||
|
||||
log.info("[ClientSSE] 客户端订阅遥测: connectionId={}, deviceSn={}", connectionId, deviceSn);
|
||||
|
||||
// 委托给 BoatSseEmitterManager 管理连接和订阅
|
||||
SseEmitter emitter = boatSseEmitterManager.addEmitter(connectionId, deviceSn, null);
|
||||
|
||||
return ResponseEntity.ok()
|
||||
.header("Cache-Control", "no-cache, no-transform")
|
||||
.header("Connection", "keep-alive")
|
||||
.header("X-Accel-Buffering", "no")
|
||||
.contentType(MediaType.TEXT_EVENT_STREAM)
|
||||
.body(emitter);
|
||||
}
|
||||
|
||||
@Operation(summary = "客户端断开SSE连接")
|
||||
@DeleteMapping("/telemetry/{deviceSn}")
|
||||
public ResponseEntity<Void> disconnect(
|
||||
@PathVariable String deviceSn,
|
||||
@RequestHeader(value = "X-Client-Session-Id", required = false) String clientSessionId) {
|
||||
if (clientSessionId != null) {
|
||||
String connectionId = "client_" + clientSessionId + "_" + deviceSn;
|
||||
boatSseEmitterManager.removeEmitterBySessionId(connectionId, deviceSn);
|
||||
}
|
||||
return ResponseEntity.ok().build();
|
||||
}
|
||||
|
||||
@Operation(summary = "客户端断开SSE连接(Beacon)")
|
||||
@PostMapping("/telemetry/{deviceSn}/disconnect")
|
||||
public ResponseEntity<Void> disconnectBeacon(
|
||||
@PathVariable String deviceSn,
|
||||
@RequestBody(required = false) Map<String, String> body) {
|
||||
String sessionId = body != null ? body.get("sessionId") : null;
|
||||
if (sessionId != null) {
|
||||
String connectionId = "client_" + sessionId + "_" + deviceSn;
|
||||
boatSseEmitterManager.removeEmitterBySessionId(connectionId, deviceSn);
|
||||
}
|
||||
return ResponseEntity.ok().build();
|
||||
}
|
||||
}
|
||||
-346
@@ -1,346 +0,0 @@
|
||||
package com.central.device.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.central.common.model.Result;
|
||||
import com.central.device.service.DeviceAlarmDataService;
|
||||
import com.central.device.service.OneTimeSubscriptionService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
/**
|
||||
* 设备告警数据接口
|
||||
* 提供一次性订阅获取设备 fire_alarm 和 msg_alarm 数据的接口
|
||||
* 使用独立 WebSocket 连接,用完即关,不影响其他业务
|
||||
*
|
||||
* @author lishilin
|
||||
* @date 2025-01-19
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/device/alarm")
|
||||
@Tag(name = "设备告警数据接口")
|
||||
public class DeviceAlarmController {
|
||||
|
||||
@Autowired
|
||||
private OneTimeSubscriptionService oneTimeSubscriptionService;
|
||||
|
||||
@Autowired
|
||||
private DeviceAlarmDataService alarmDataService;
|
||||
|
||||
// ==================== 独立订阅接口 ====================
|
||||
|
||||
/**
|
||||
* 一次性订阅获取 fire_alarm 数据(机库状态数据)
|
||||
* 使用独立的 WebSocket 连接,不影响其他 SSE 订阅
|
||||
* 默认超时10秒,响应快速
|
||||
*
|
||||
* @param deviceSn 设备SN
|
||||
* @return fire_alarm 数据
|
||||
*/
|
||||
@GetMapping("/fire-alarm/{deviceSn}")
|
||||
@Operation(summary = "一次性获取机库状态数据", description = "独立 WebSocket 连接获取 fire_alarm,用完即关,不影响其他业务")
|
||||
public Result<SingleAlarmResponse> getFireAlarm(
|
||||
@Parameter(description = "设备SN", required = true) @PathVariable String deviceSn) {
|
||||
log.info("请求获取 fire_alarm: deviceSn={}", deviceSn);
|
||||
|
||||
if (deviceSn == null || deviceSn.trim().isEmpty()) {
|
||||
return Result.failed("设备SN不能为空");
|
||||
}
|
||||
|
||||
try {
|
||||
OneTimeSubscriptionService.SingleAlarmResult alarmResult =
|
||||
oneTimeSubscriptionService.subscribeFireAlarmOnce(deviceSn);
|
||||
|
||||
SingleAlarmResponse response = new SingleAlarmResponse();
|
||||
response.setDeviceSn(alarmResult.getDeviceSn());
|
||||
response.setAlarmType(alarmResult.getAlarmType());
|
||||
response.setSuccess(alarmResult.isSuccess());
|
||||
response.setMessage(alarmResult.getMessage());
|
||||
response.setData(alarmResult.getData());
|
||||
response.setFromCache(alarmResult.isFromCache());
|
||||
|
||||
if (alarmResult.isSuccess()) {
|
||||
return Result.succeed(response, "获取成功");
|
||||
} else {
|
||||
return Result.succeed(response, "未获取到数据");
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("获取 fire_alarm 失败: deviceSn={}, error={}", deviceSn, e.getMessage(), e);
|
||||
return Result.failed("获取失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 一次性订阅获取 fire_alarm 数据(带超时参数)
|
||||
*
|
||||
* @param deviceSn 设备SN
|
||||
* @param timeoutSeconds 超时时间(秒)
|
||||
* @return fire_alarm 数据
|
||||
*/
|
||||
@GetMapping("/fire-alarm/{deviceSn}/timeout/{timeoutSeconds}")
|
||||
@Operation(summary = "一次性获取机库状态数据(带超时)", description = "可自定义超时时间")
|
||||
public Result<SingleAlarmResponse> getFireAlarmWithTimeout(
|
||||
@Parameter(description = "设备SN", required = true) @PathVariable String deviceSn,
|
||||
@Parameter(description = "超时时间(秒)", required = true) @PathVariable int timeoutSeconds) {
|
||||
log.info("请求获取 fire_alarm(带超时): deviceSn={}, timeout={}s", deviceSn, timeoutSeconds);
|
||||
|
||||
if (deviceSn == null || deviceSn.trim().isEmpty()) {
|
||||
return Result.failed("设备SN不能为空");
|
||||
}
|
||||
|
||||
if (timeoutSeconds < 1 || timeoutSeconds > 60) {
|
||||
return Result.failed("超时时间必须在1-60秒之间");
|
||||
}
|
||||
|
||||
try {
|
||||
OneTimeSubscriptionService.SingleAlarmResult alarmResult =
|
||||
oneTimeSubscriptionService.subscribeFireAlarmOnce(deviceSn, timeoutSeconds);
|
||||
|
||||
SingleAlarmResponse response = new SingleAlarmResponse();
|
||||
response.setDeviceSn(alarmResult.getDeviceSn());
|
||||
response.setAlarmType(alarmResult.getAlarmType());
|
||||
response.setSuccess(alarmResult.isSuccess());
|
||||
response.setMessage(alarmResult.getMessage());
|
||||
response.setData(alarmResult.getData());
|
||||
response.setFromCache(alarmResult.isFromCache());
|
||||
|
||||
if (alarmResult.isSuccess()) {
|
||||
return Result.succeed(response, "获取成功");
|
||||
} else {
|
||||
return Result.succeed(response, "未获取到数据");
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("获取 fire_alarm 失败: deviceSn={}, error={}", deviceSn, e.getMessage(), e);
|
||||
return Result.failed("获取失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 一次性订阅获取 msg_alarm 数据(无人机遥测数据)
|
||||
* 使用独立的 WebSocket 连接,不影响其他 SSE 订阅
|
||||
* 默认超时10秒
|
||||
*
|
||||
* 注意:msg_alarm 只有无人机开机才有消息,如果无人机未开机则不会有数据
|
||||
*
|
||||
* @param deviceSn 设备SN
|
||||
* @return msg_alarm 数据
|
||||
*/
|
||||
@GetMapping("/msg-alarm/{deviceSn}")
|
||||
@Operation(summary = "一次性获取无人机遥测数据", description = "独立 WebSocket 连接获取 msg_alarm,用完即关。注意:无人机需开机才有数据")
|
||||
public Result<SingleAlarmResponse> getMsgAlarm(
|
||||
@Parameter(description = "设备SN", required = true) @PathVariable String deviceSn) {
|
||||
log.info("请求获取 msg_alarm: deviceSn={}", deviceSn);
|
||||
|
||||
if (deviceSn == null || deviceSn.trim().isEmpty()) {
|
||||
return Result.failed("设备SN不能为空");
|
||||
}
|
||||
|
||||
try {
|
||||
OneTimeSubscriptionService.SingleAlarmResult alarmResult =
|
||||
oneTimeSubscriptionService.subscribeMsgAlarmOnce(deviceSn);
|
||||
|
||||
SingleAlarmResponse response = new SingleAlarmResponse();
|
||||
response.setDeviceSn(alarmResult.getDeviceSn());
|
||||
response.setAlarmType(alarmResult.getAlarmType());
|
||||
response.setSuccess(alarmResult.isSuccess());
|
||||
response.setMessage(alarmResult.getMessage());
|
||||
response.setData(alarmResult.getData());
|
||||
response.setFromCache(alarmResult.isFromCache());
|
||||
|
||||
if (alarmResult.isSuccess()) {
|
||||
return Result.succeed(response, "获取成功");
|
||||
} else {
|
||||
return Result.succeed(response, "未获取到数据(无人机可能未开机)");
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("获取 msg_alarm 失败: deviceSn={}, error={}", deviceSn, e.getMessage(), e);
|
||||
return Result.failed("获取失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 一次性订阅获取 msg_alarm 数据(带超时参数)
|
||||
*
|
||||
* @param deviceSn 设备SN
|
||||
* @param timeoutSeconds 超时时间(秒)
|
||||
* @return msg_alarm 数据
|
||||
*/
|
||||
@GetMapping("/msg-alarm/{deviceSn}/timeout/{timeoutSeconds}")
|
||||
@Operation(summary = "一次性获取无人机遥测数据(带超时)", description = "可自定义超时时间。注意:无人机需开机才有数据")
|
||||
public Result<SingleAlarmResponse> getMsgAlarmWithTimeout(
|
||||
@Parameter(description = "设备SN", required = true) @PathVariable String deviceSn,
|
||||
@Parameter(description = "超时时间(秒)", required = true) @PathVariable int timeoutSeconds) {
|
||||
log.info("请求获取 msg_alarm(带超时): deviceSn={}, timeout={}s", deviceSn, timeoutSeconds);
|
||||
|
||||
if (deviceSn == null || deviceSn.trim().isEmpty()) {
|
||||
return Result.failed("设备SN不能为空");
|
||||
}
|
||||
|
||||
if (timeoutSeconds < 1 || timeoutSeconds > 60) {
|
||||
return Result.failed("超时时间必须在1-60秒之间");
|
||||
}
|
||||
|
||||
try {
|
||||
OneTimeSubscriptionService.SingleAlarmResult alarmResult =
|
||||
oneTimeSubscriptionService.subscribeMsgAlarmOnce(deviceSn, timeoutSeconds);
|
||||
|
||||
SingleAlarmResponse response = new SingleAlarmResponse();
|
||||
response.setDeviceSn(alarmResult.getDeviceSn());
|
||||
response.setAlarmType(alarmResult.getAlarmType());
|
||||
response.setSuccess(alarmResult.isSuccess());
|
||||
response.setMessage(alarmResult.getMessage());
|
||||
response.setData(alarmResult.getData());
|
||||
response.setFromCache(alarmResult.isFromCache());
|
||||
|
||||
if (alarmResult.isSuccess()) {
|
||||
return Result.succeed(response, "获取成功");
|
||||
} else {
|
||||
return Result.succeed(response, "未获取到数据(无人机可能未开机)");
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("获取 msg_alarm 失败: deviceSn={}, error={}", deviceSn, e.getMessage(), e);
|
||||
return Result.failed("获取失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
// ==================== 缓存相关接口 ====================
|
||||
|
||||
/**
|
||||
* 从 Redis 缓存获取 fire_alarm 数据(不进行实时订阅)
|
||||
*
|
||||
* @param deviceSn 设备SN
|
||||
* @return 缓存的 fire_alarm 数据
|
||||
*/
|
||||
@GetMapping("/cache/fire-alarm/{deviceSn}")
|
||||
@Operation(summary = "从缓存获取机库状态数据", description = "仅从 Redis 缓存获取,不进行实时订阅")
|
||||
public Result<SingleAlarmResponse> getFireAlarmFromCache(
|
||||
@Parameter(description = "设备SN", required = true) @PathVariable String deviceSn) {
|
||||
log.info("从缓存获取 fire_alarm 数据: deviceSn={}", deviceSn);
|
||||
|
||||
if (deviceSn == null || deviceSn.trim().isEmpty()) {
|
||||
return Result.failed("设备SN不能为空");
|
||||
}
|
||||
|
||||
try {
|
||||
JSONObject data = alarmDataService.getFireAlarmData(deviceSn);
|
||||
|
||||
SingleAlarmResponse response = new SingleAlarmResponse();
|
||||
response.setDeviceSn(deviceSn);
|
||||
response.setAlarmType("fire_alarm");
|
||||
response.setData(data);
|
||||
response.setFromCache(true);
|
||||
response.setSuccess(data != null);
|
||||
response.setMessage(data != null ? "缓存数据存在" : "缓存中无数据");
|
||||
|
||||
return Result.succeed(response);
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("从缓存获取 fire_alarm 失败: deviceSn={}, error={}", deviceSn, e.getMessage(), e);
|
||||
return Result.failed("获取缓存失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 从 Redis 缓存获取 msg_alarm 数据(不进行实时订阅)
|
||||
*
|
||||
* @param deviceSn 设备SN
|
||||
* @return 缓存的 msg_alarm 数据
|
||||
*/
|
||||
@GetMapping("/cache/msg-alarm/{deviceSn}")
|
||||
@Operation(summary = "从缓存获取无人机遥测数据", description = "仅从 Redis 缓存获取,不进行实时订阅")
|
||||
public Result<SingleAlarmResponse> getMsgAlarmFromCache(
|
||||
@Parameter(description = "设备SN", required = true) @PathVariable String deviceSn) {
|
||||
log.info("从缓存获取 msg_alarm 数据: deviceSn={}", deviceSn);
|
||||
|
||||
if (deviceSn == null || deviceSn.trim().isEmpty()) {
|
||||
return Result.failed("设备SN不能为空");
|
||||
}
|
||||
|
||||
try {
|
||||
JSONObject data = alarmDataService.getMsgAlarmData(deviceSn);
|
||||
|
||||
SingleAlarmResponse response = new SingleAlarmResponse();
|
||||
response.setDeviceSn(deviceSn);
|
||||
response.setAlarmType("msg_alarm");
|
||||
response.setData(data);
|
||||
response.setFromCache(true);
|
||||
response.setSuccess(data != null);
|
||||
response.setMessage(data != null ? "缓存数据存在" : "缓存中无数据");
|
||||
|
||||
return Result.succeed(response);
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("从缓存获取 msg_alarm 失败: deviceSn={}, error={}", deviceSn, e.getMessage(), e);
|
||||
return Result.failed("获取缓存失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除设备告警数据缓存
|
||||
*
|
||||
* @param deviceSn 设备SN
|
||||
* @return 操作结果
|
||||
*/
|
||||
@DeleteMapping("/cache/{deviceSn}")
|
||||
@Operation(summary = "删除设备告警数据缓存", description = "删除 Redis 中指定设备的告警数据缓存")
|
||||
public Result<Void> deleteCache(
|
||||
@Parameter(description = "设备SN", required = true) @PathVariable String deviceSn) {
|
||||
log.info("删除设备告警数据缓存: deviceSn={}", deviceSn);
|
||||
|
||||
if (deviceSn == null || deviceSn.trim().isEmpty()) {
|
||||
return Result.failed("设备SN不能为空");
|
||||
}
|
||||
|
||||
try {
|
||||
alarmDataService.deleteAlarmData(deviceSn);
|
||||
return Result.succeed(null, "删除成功");
|
||||
} catch (Exception e) {
|
||||
log.error("删除缓存失败: deviceSn={}, error={}", deviceSn, e.getMessage(), e);
|
||||
return Result.failed("删除缓存失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 单一告警数据响应
|
||||
*/
|
||||
@lombok.Data
|
||||
public static class SingleAlarmResponse {
|
||||
/**
|
||||
* 设备SN
|
||||
*/
|
||||
private String deviceSn;
|
||||
|
||||
/**
|
||||
* 告警类型(fire_alarm 或 msg_alarm)
|
||||
*/
|
||||
private String alarmType;
|
||||
|
||||
/**
|
||||
* 是否成功
|
||||
*/
|
||||
private boolean success;
|
||||
|
||||
/**
|
||||
* 结果消息
|
||||
*/
|
||||
private String message;
|
||||
|
||||
/**
|
||||
* 告警数据
|
||||
*/
|
||||
private JSONObject data;
|
||||
|
||||
/**
|
||||
* 数据是否来自缓存
|
||||
*/
|
||||
private boolean fromCache;
|
||||
}
|
||||
}
|
||||
-831
@@ -1,831 +0,0 @@
|
||||
package com.central.device.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.alibaba.nacos.shaded.com.google.gson.Gson;
|
||||
import com.alibaba.nacos.shaded.com.google.gson.JsonElement;
|
||||
import com.alibaba.nacos.shaded.com.google.gson.JsonObject;
|
||||
import com.central.common.model.Result;
|
||||
import com.central.device.boat.entity.WaylineRoute;
|
||||
import com.central.device.feign.FileCenterService;
|
||||
import com.central.device.message.ControlMessageConstant;
|
||||
import com.central.device.model.AgeDevice;
|
||||
import com.central.device.model.LineFile;
|
||||
import com.central.device.service.IAgeDeviceService;
|
||||
import com.central.device.service.ILineFileService;
|
||||
import com.central.device.service.IWaylineRouteService;
|
||||
import com.central.device.util.IotRequestResult;
|
||||
import com.central.device.util.RequestUtils;
|
||||
import com.central.device.websocket.manager.DeviceCommandManager;
|
||||
import com.central.device.websocket.model.CommandStatus;
|
||||
import com.central.device.websocket.model.DeviceCommand;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.Data;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 设备命令控制器
|
||||
* 提供HTTP接口接收前端命令请求,发送命令到设备
|
||||
*
|
||||
* @author dzc
|
||||
* @date 2025-01-01
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/device/command")
|
||||
@Tag(name = "设备命令控制")
|
||||
public class DeviceCommandController {
|
||||
|
||||
@Value("${jetlinks.server.baseUrl}")
|
||||
private String baseUrl;
|
||||
|
||||
@Autowired
|
||||
private DeviceCommandManager commandManager;
|
||||
|
||||
@Autowired
|
||||
private ILineFileService lineFileService;
|
||||
|
||||
@Autowired
|
||||
private FileCenterService fileCenterService;
|
||||
|
||||
@Autowired
|
||||
private IWaylineRouteService iWaylineRouteService;
|
||||
|
||||
@Autowired
|
||||
private RequestUtils requestUtils;
|
||||
|
||||
@Resource
|
||||
private IAgeDeviceService iAgeDeviceService;
|
||||
|
||||
private final ControlMessageConstant controlMessageConstant = new ControlMessageConstant();
|
||||
|
||||
/**
|
||||
* 发送设备命令
|
||||
*/
|
||||
@Operation(summary = "发送设备命令")
|
||||
@PostMapping("/send")
|
||||
public Result<String> sendCommand(@RequestBody SendCommandRequest request) {
|
||||
log.info("收到设备命令请求: device={}, type={}",
|
||||
request.getDeviceSn(), request.getCommandType());
|
||||
|
||||
try {
|
||||
String commandId = commandManager.sendCommand(
|
||||
request.getDeviceSn(),
|
||||
request.getCommandType(),
|
||||
request.getParams()
|
||||
);
|
||||
return Result.succeed(commandId, "命令已提交");
|
||||
} catch (Exception e) {
|
||||
log.error("发送命令失败: device={}, error={}", request.getDeviceSn(), e.getMessage());
|
||||
return Result.failed("命令发送失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询命令状态
|
||||
*/
|
||||
@Operation(summary = "查询命令状态")
|
||||
@GetMapping("/status/{commandId}")
|
||||
public Result<CommandStatusDTO> getCommandStatus(@PathVariable String commandId) {
|
||||
CommandStatus status = commandManager.getCommandStatus(commandId);
|
||||
|
||||
if (status == null) {
|
||||
return Result.failed("命令不存在");
|
||||
}
|
||||
|
||||
CommandStatusDTO dto = new CommandStatusDTO();
|
||||
dto.setCommandId(commandId);
|
||||
dto.setStatus(status.name());
|
||||
dto.setStatusDesc(getStatusDescription(status));
|
||||
|
||||
// 获取命令详情
|
||||
DeviceCommand command = commandManager.getCommand(commandId);
|
||||
if (command != null) {
|
||||
dto.setDeviceSn(command.getDeviceSn());
|
||||
dto.setCommandType(command.getCommandType());
|
||||
dto.setCreateTime(command.getCreateTime());
|
||||
dto.setSendTime(command.getSendTime());
|
||||
dto.setRetryCount(command.getRetryCount());
|
||||
dto.setErrorMsg(command.getErrorMsg());
|
||||
}
|
||||
|
||||
return Result.succeed(dto);
|
||||
}
|
||||
|
||||
/**
|
||||
* 一键起飞(飞向指定点)
|
||||
*/
|
||||
@Operation(summary = "无人机一键起飞")
|
||||
@PostMapping("/takeoff")
|
||||
public Result<String> takeoff(@RequestBody TakeoffRequest request) {
|
||||
log.info("收到起飞命令: device={}, target=({}, {}), height={}",
|
||||
request.getDeviceSn(), request.getTargetLatitude(), request.getTargetLongitude(), request.getTargetHeight());
|
||||
|
||||
try {
|
||||
// 验证必要参数
|
||||
if (request.getDeviceSn() == null || request.getDeviceSn().isEmpty()) {
|
||||
return Result.failed("设备SN不能为空");
|
||||
}
|
||||
if (request.getTargetLatitude() == null || request.getTargetLongitude() == null) {
|
||||
return Result.failed("目标点经纬度不能为空");
|
||||
}
|
||||
// 构建参数
|
||||
JSONObject params = new JSONObject();
|
||||
params.put("target_latitude", request.getTargetLatitude());
|
||||
params.put("target_longitude", request.getTargetLongitude());
|
||||
params.put("target_height", request.getTargetHeight() != null ? request.getTargetHeight() : 100f);
|
||||
params.put("security_takeoff_height", request.getSecurityTakeoffHeight() != null ? request.getSecurityTakeoffHeight() : 50f);
|
||||
params.put("rth_mode", request.getRthMode() != null ? request.getRthMode() : 1); // 默认设定高度模式
|
||||
params.put("rth_altitude", request.getRthAltitude() != null ? request.getRthAltitude() : 50);
|
||||
params.put("rc_lost_action", request.getRcLostAction() != null ? request.getRcLostAction() : 2); // 默认返航
|
||||
params.put("commander_mode_lost_action", request.getCommanderModeLostAction() != null ? request.getCommanderModeLostAction() : 1);
|
||||
params.put("commander_flight_mode", request.getCommanderFlightMode() != null ? request.getCommanderFlightMode() : 1); // 默认设定高度飞行
|
||||
params.put("commander_flight_height", request.getCommanderFlightHeight() != null ? request.getCommanderFlightHeight() : 50f);
|
||||
params.put("flight_id", request.getFlightId() != null ? request.getFlightId() : java.util.UUID.randomUUID().toString().replace("-", "").toUpperCase());
|
||||
params.put("max_speed", request.getMaxSpeed() != null ? request.getMaxSpeed() : 5);
|
||||
params.put("flight_safety_advance_check", request.getFlightSafetyAdvanceCheck() != null ? request.getFlightSafetyAdvanceCheck() : 0);
|
||||
params.put("stream_urls", getStreamUrls(request.getDeviceSn()));
|
||||
String commandId = commandManager.sendCommand(
|
||||
request.getDeviceSn(),
|
||||
"takeoff_to_point",
|
||||
params
|
||||
);
|
||||
|
||||
return Result.succeed(commandId, "起飞命令已发送");
|
||||
} catch (Exception e) {
|
||||
log.error("发送起飞命令失败: device={}, error={}", request.getDeviceSn(), e.getMessage());
|
||||
return Result.failed("命令发送失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 一键返航
|
||||
*/
|
||||
@Operation(summary = "无人机一键返航")
|
||||
@PostMapping("/return")
|
||||
public Result<String> returnHome(@RequestParam String deviceSn) {
|
||||
log.info("收到返航命令: device={}", deviceSn);
|
||||
|
||||
try {
|
||||
String commandId = commandManager.sendCommand(
|
||||
deviceSn,
|
||||
"return_home",
|
||||
new JSONObject()
|
||||
);
|
||||
|
||||
return Result.succeed(commandId, "返航命令已发送");
|
||||
} catch (Exception e) {
|
||||
log.error("发送返航命令失败: device={}, error={}", deviceSn, e.getMessage());
|
||||
return Result.failed("命令发送失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 取消返航
|
||||
*/
|
||||
@Operation(summary = "取消返航")
|
||||
@PostMapping("/return/cancel")
|
||||
public Result<String> cancelReturnHome(@RequestParam String deviceSn) {
|
||||
log.info("收到取消返航命令: device={}", deviceSn);
|
||||
|
||||
try {
|
||||
String commandId = commandManager.sendCommand(
|
||||
deviceSn,
|
||||
"return_home_cancel",
|
||||
new JSONObject()
|
||||
);
|
||||
|
||||
return Result.succeed(commandId, "取消返航命令已发送");
|
||||
} catch (Exception e) {
|
||||
log.error("发送取消返航命令失败: device={}, error={}", deviceSn, e.getMessage());
|
||||
return Result.failed("命令发送失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 航线暂停(紧急悬停)
|
||||
*/
|
||||
@Operation(summary = "航线暂停/紧急悬停")
|
||||
@PostMapping("/pause")
|
||||
public Result<String> pause(@RequestParam String deviceSn) {
|
||||
log.info("收到暂停命令: device={}", deviceSn);
|
||||
|
||||
try {
|
||||
String commandId = commandManager.sendCommand(
|
||||
deviceSn,
|
||||
"flighttask_pause",
|
||||
new JSONObject()
|
||||
);
|
||||
|
||||
return Result.succeed(commandId, "暂停命令已发送");
|
||||
} catch (Exception e) {
|
||||
log.error("发送暂停命令失败: device={}, error={}", deviceSn, e.getMessage());
|
||||
return Result.failed("命令发送失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 航线恢复
|
||||
*/
|
||||
@Operation(summary = "航线恢复")
|
||||
@PostMapping("/resume")
|
||||
public Result<String> resume(@RequestParam String deviceSn) {
|
||||
log.info("收到恢复命令: device={}", deviceSn);
|
||||
|
||||
try {
|
||||
String commandId = commandManager.sendCommand(
|
||||
deviceSn,
|
||||
"flighttask_recovery",
|
||||
new JSONObject()
|
||||
);
|
||||
|
||||
return Result.succeed(commandId, "恢复命令已发送");
|
||||
} catch (Exception e) {
|
||||
log.error("发送恢复命令失败: device={}, error={}", deviceSn, e.getMessage());
|
||||
return Result.failed("命令发送失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 拍照
|
||||
*/
|
||||
@Operation(summary = "无人机拍照")
|
||||
@PostMapping("/photo")
|
||||
public Result<String> takePhoto(@RequestParam String deviceSn) {
|
||||
log.info("收到拍照命令: device={}", deviceSn);
|
||||
|
||||
try {
|
||||
String commandId = commandManager.sendCommand(
|
||||
deviceSn,
|
||||
"camera_photo_take",
|
||||
new JSONObject()
|
||||
);
|
||||
|
||||
return Result.succeed(commandId, "拍照命令已发送");
|
||||
} catch (Exception e) {
|
||||
log.error("发送拍照命令失败: device={}, error={}", deviceSn, e.getMessage());
|
||||
return Result.failed("命令发送失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 指点飞行 - 首次飞向目标点
|
||||
* 创建 fly_to_point 会话,flyToId = missionCode
|
||||
*/
|
||||
@Operation(summary = "无人机指点飞行 - 飞向目标")
|
||||
@PostMapping("/flyToPoint")
|
||||
public Result<String> flyToPoint(@RequestBody FlyToPointRequest request) {
|
||||
log.info("收到指点飞行(首次)命令: device={}, flyToId={}, target=({}, {}, {})",
|
||||
request.getDeviceSn(), request.getFlyToId(),
|
||||
request.getLatitude(), request.getLongitude(), request.getHeight());
|
||||
|
||||
try {
|
||||
JSONObject params = new JSONObject();
|
||||
params.put("fly_to_id", request.getFlyToId());
|
||||
params.put("latitude", request.getLatitude());
|
||||
params.put("longitude", request.getLongitude());
|
||||
params.put("height", request.getHeight() != null ? request.getHeight() : 100f);
|
||||
params.put("max_speed", request.getMaxSpeed() != null ? request.getMaxSpeed() : 12f);
|
||||
|
||||
String commandId = commandManager.sendCommand(
|
||||
request.getDeviceSn(),
|
||||
"fly_to_point",
|
||||
params
|
||||
);
|
||||
return Result.succeed(commandId, "指点飞行命令已发送");
|
||||
} catch (Exception e) {
|
||||
log.error("发送指点飞行命令失败: device={}, error={}", request.getDeviceSn(), e.getMessage());
|
||||
return Result.failed("命令发送失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 指点飞行 - 更新目标点(连续指点)
|
||||
* 打断当前飞行,立即转向新目标;设备协议不含 fly_to_id,仅传 max_speed + points
|
||||
*/
|
||||
@Operation(summary = "无人机指点飞行 - 更新目标点")
|
||||
@PostMapping("/flyToPointUpdate")
|
||||
public Result<String> flyToPointUpdate(@RequestBody FlyToPointUpdateRequest request) {
|
||||
log.info("收到指点飞行(更新)命令: device={}, target=({}, {}, {})",
|
||||
request.getDeviceSn(), request.getLatitude(), request.getLongitude(), request.getHeight());
|
||||
|
||||
try {
|
||||
JSONObject params = new JSONObject();
|
||||
params.put("latitude", request.getLatitude());
|
||||
params.put("longitude", request.getLongitude());
|
||||
params.put("height", request.getHeight() != null ? request.getHeight() : 100f);
|
||||
params.put("max_speed", request.getMaxSpeed() != null ? request.getMaxSpeed() : 12f);
|
||||
|
||||
String commandId = commandManager.sendCommand(
|
||||
request.getDeviceSn(),
|
||||
"fly_to_point_update",
|
||||
params
|
||||
);
|
||||
return Result.succeed(commandId, "目标更新命令已发送");
|
||||
} catch (Exception e) {
|
||||
log.error("发送目标更新命令失败: device={}, error={}", request.getDeviceSn(), e.getMessage());
|
||||
return Result.failed("命令发送失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 指点飞行 - 停止指点飞行
|
||||
*/
|
||||
@Operation(summary = "无人机指点飞行 - 停止")
|
||||
@PostMapping("/flyToPointStop")
|
||||
public Result<String> flyToPointStop(@RequestParam String deviceSn) {
|
||||
log.info("收到停止指点飞行命令: device={}", deviceSn);
|
||||
|
||||
try {
|
||||
String commandId = commandManager.sendCommand(
|
||||
deviceSn,
|
||||
"fly_to_point_stop",
|
||||
new JSONObject()
|
||||
);
|
||||
return Result.succeed(commandId, "停止指点飞行命令已发送");
|
||||
} catch (Exception e) {
|
||||
log.error("发送停止指点飞行命令失败: device={}, error={}", deviceSn, e.getMessage());
|
||||
return Result.failed("命令发送失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 开始录像
|
||||
*/
|
||||
@Operation(summary = "开始录像")
|
||||
@PostMapping("/recording/start")
|
||||
public Result<String> startRecording(@RequestParam String deviceSn) {
|
||||
log.info("收到开始录像命令: device={}", deviceSn);
|
||||
|
||||
try {
|
||||
String commandId = commandManager.sendCommand(
|
||||
deviceSn,
|
||||
"camera_recording_start",
|
||||
new JSONObject()
|
||||
);
|
||||
|
||||
return Result.succeed(commandId, "开始录像命令已发送");
|
||||
} catch (Exception e) {
|
||||
log.error("发送开始录像命令失败: device={}, error={}", deviceSn, e.getMessage());
|
||||
return Result.failed("命令发送失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 停止录像
|
||||
*/
|
||||
@Operation(summary = "停止录像")
|
||||
@PostMapping("/recording/stop")
|
||||
public Result<String> stopRecording(@RequestParam String deviceSn) {
|
||||
log.info("收到停止录像命令: device={}", deviceSn);
|
||||
|
||||
try {
|
||||
String commandId = commandManager.sendCommand(
|
||||
deviceSn,
|
||||
"camera_recording_stop",
|
||||
new JSONObject()
|
||||
);
|
||||
|
||||
return Result.succeed(commandId, "停止录像命令已发送");
|
||||
} catch (Exception e) {
|
||||
log.error("发送停止录像命令失败: device={}, error={}", deviceSn, e.getMessage());
|
||||
return Result.failed("命令发送失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 切换相机模式
|
||||
*/
|
||||
@Operation(summary = "切换相机模式")
|
||||
@PostMapping("/camera/mode")
|
||||
public Result<String> switchCameraMode(@RequestParam String deviceSn, @RequestParam Integer cameraMode) {
|
||||
log.info("收到切换相机模式命令: device={}, mode={}", deviceSn, cameraMode);
|
||||
|
||||
try {
|
||||
JSONObject params = new JSONObject();
|
||||
// camera_mode: 0=拍照模式, 1=录像模式
|
||||
params.put("camera_mode", cameraMode != null ? cameraMode : 0);
|
||||
|
||||
String commandId = commandManager.sendCommand(
|
||||
deviceSn,
|
||||
"camera_mode_switch",
|
||||
params
|
||||
);
|
||||
|
||||
return Result.succeed(commandId, "切换相机模式命令已发送");
|
||||
} catch (Exception e) {
|
||||
log.error("发送切换相机模式命令失败: device={}, error={}", deviceSn, e.getMessage());
|
||||
return Result.failed("命令发送失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 进入指令飞行模式(DRC模式)
|
||||
*/
|
||||
@Operation(summary = "进入指令飞行模式")
|
||||
@PostMapping("/drc/enter")
|
||||
public Result<String> enterDrcMode(@RequestParam String deviceSn) {
|
||||
log.info("收到进入DRC模式命令: device={}", deviceSn);
|
||||
|
||||
try {
|
||||
String commandId = commandManager.sendCommand(
|
||||
deviceSn,
|
||||
"drc_mode_enter",
|
||||
new JSONObject()
|
||||
);
|
||||
|
||||
return Result.succeed(commandId, "进入DRC模式命令已发送");
|
||||
} catch (Exception e) {
|
||||
log.error("发送进入DRC模式命令失败: device={}, error={}", deviceSn, e.getMessage());
|
||||
return Result.failed("命令发送失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* DRC杆量控制
|
||||
*/
|
||||
@Operation(summary = "DRC杆量控制")
|
||||
@PostMapping("/drc/stick")
|
||||
public Result<String> stickControl(@RequestBody StickControlRequest request) {
|
||||
log.info("收到杆量控制命令: device={}, roll={}, pitch={}, throttle={}, yaw={}, gimbalPitch={}",
|
||||
request.getDeviceSn(), request.getRoll(), request.getPitch(), request.getThrottle(), request.getYaw(), request.getGimbalPitch());
|
||||
|
||||
try {
|
||||
JSONObject params = new JSONObject();
|
||||
params.put("roll", request.getRoll() != null ? request.getRoll() : 1024);
|
||||
params.put("pitch", request.getPitch() != null ? request.getPitch() : 1024);
|
||||
params.put("throttle", request.getThrottle() != null ? request.getThrottle() : 1024);
|
||||
params.put("yaw", request.getYaw() != null ? request.getYaw() : 1024);
|
||||
params.put("gimbal_pitch", request.getGimbalPitch() != null ? request.getGimbalPitch() : 1024);
|
||||
|
||||
String commandId = commandManager.sendCommand(
|
||||
request.getDeviceSn(),
|
||||
"stick_control",
|
||||
params
|
||||
);
|
||||
|
||||
return Result.succeed(commandId, "杆量控制命令已发送");
|
||||
} catch (Exception e) {
|
||||
log.error("发送杆量控制命令失败: device={}, error={}", request.getDeviceSn(), e.getMessage());
|
||||
return Result.failed("命令发送失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 云台控制
|
||||
*/
|
||||
@Operation(summary = "云台控制")
|
||||
@PostMapping("/gimbal")
|
||||
public Result<String> gimbalControl(@RequestBody GimbalControlRequest request) {
|
||||
log.info("收到云台控制命令: device={}, pitchSpeed={}, yawSpeed={}, locked={}",
|
||||
request.getDeviceSn(), request.getPitchSpeed(), request.getYawSpeed(), request.getLocked());
|
||||
|
||||
try {
|
||||
JSONObject params = new JSONObject();
|
||||
params.put("pitch_speed", request.getPitchSpeed() != null ? request.getPitchSpeed() : 0);
|
||||
params.put("yaw_speed", request.getYawSpeed() != null ? request.getYawSpeed() : 0);
|
||||
params.put("locked", request.getLocked() != null ? request.getLocked() : false);
|
||||
|
||||
String commandId = commandManager.sendCommand(
|
||||
request.getDeviceSn(),
|
||||
"camera_screen_drag",
|
||||
params
|
||||
);
|
||||
|
||||
return Result.succeed(commandId, "云台控制命令已发送");
|
||||
} catch (Exception e) {
|
||||
log.error("发送云台控制命令失败: device={}, error={}", request.getDeviceSn(), e.getMessage());
|
||||
return Result.failed("命令发送失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 切换直播镜头(如切换到变焦镜头)
|
||||
*/
|
||||
@Operation(summary = "切换直播镜头")
|
||||
@PostMapping("/liveLensChange")
|
||||
public Result<String> liveLensChange(@RequestBody Map<String, Object> request) {
|
||||
String deviceSn = (String) request.get("deviceSn");
|
||||
String videoType = (String) request.get("videoType");
|
||||
|
||||
log.info("切换直播镜头: device={}, videoType={}", deviceSn, videoType);
|
||||
|
||||
try {
|
||||
JSONObject params = new JSONObject();
|
||||
params.put("video_type", videoType != null ? videoType : "zoom");
|
||||
|
||||
String commandId = commandManager.sendCommand(deviceSn, "live_lens_change", params);
|
||||
return Result.succeed(commandId, "镜头切换命令已发送");
|
||||
} catch (Exception e) {
|
||||
log.error("切换镜头失败: device={}, error={}", deviceSn, e.getMessage());
|
||||
return Result.failed("命令发送失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置变焦倍数
|
||||
*/
|
||||
@Operation(summary = "设置变焦倍数")
|
||||
@PostMapping("/cameraFocalLengthSet")
|
||||
public Result<String> cameraFocalLengthSet(@RequestBody Map<String, Object> request) {
|
||||
String deviceSn = (String) request.get("deviceSn");
|
||||
Double zoomFactor = request.get("zoomFactor") != null ?
|
||||
Double.parseDouble(request.get("zoomFactor").toString()) : 2.0;
|
||||
|
||||
// 范围限制 2~200
|
||||
zoomFactor = Math.max(2, Math.min(200, zoomFactor));
|
||||
|
||||
log.info("设置变焦: device={}, zoomFactor={}", deviceSn, zoomFactor);
|
||||
|
||||
try {
|
||||
JSONObject params = new JSONObject();
|
||||
params.put("camera_type", "zoom");
|
||||
params.put("zoom_factor", zoomFactor);
|
||||
|
||||
String commandId = commandManager.sendCommand(deviceSn, "camera_focal_length_set", params);
|
||||
return Result.succeed(commandId, "变焦命令已发送");
|
||||
} catch (Exception e) {
|
||||
log.error("设置变焦失败: device={}, error={}", deviceSn, e.getMessage());
|
||||
return Result.failed("命令发送失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 执行航线任务
|
||||
* 参考writeProperties逻辑,用于航线任务执行(不包含订单业务逻辑和幂等性检查)
|
||||
*/
|
||||
@Operation(summary = "执行航线任务")
|
||||
@PostMapping("/wayline/execute")
|
||||
public Result<String> executeWayline(@RequestParam("deviceSn") String deviceSn,
|
||||
@RequestParam("waylineId") String waylineId,
|
||||
@RequestParam("missionCode") String missionCode) {
|
||||
log.info("开始执行航线任务: deviceSn={}, waylineId={}, missionCode={}", deviceSn, waylineId, missionCode);
|
||||
try {
|
||||
// 1. 参数校验
|
||||
if (deviceSn == null || deviceSn.isEmpty()) {
|
||||
return Result.failed("设备SN不能为空");
|
||||
}
|
||||
if (waylineId == null || waylineId.isEmpty()) {
|
||||
return Result.failed("航线ID不能为空");
|
||||
}
|
||||
if (missionCode == null || missionCode.isEmpty()) {
|
||||
return Result.failed("任务编码不能为空");
|
||||
}
|
||||
|
||||
//根据routeid去获取航迹文件
|
||||
WaylineRoute route = iWaylineRouteService.getByRouteId(waylineId);
|
||||
if(route==null){
|
||||
return Result.failed("航线文件不存在");
|
||||
}
|
||||
// 2. 获取航线文件信息
|
||||
LineFile lineFile = lineFileService.findLineFileByWaylineId(route.getFileWaylineId());
|
||||
if (lineFile == null) {
|
||||
log.error("航线文件不存在: waylineId={}", waylineId);
|
||||
return Result.failed("航线文件不存在");
|
||||
}
|
||||
|
||||
// 3. 构建控制消息
|
||||
JsonObject controlMessage = buildWaylineControlMessage(deviceSn, waylineId, missionCode, lineFile);
|
||||
if (controlMessage == null) {
|
||||
return Result.failed("构建航线控制消息失败");
|
||||
}
|
||||
// 4. 发送设备控制请求到IoT平台
|
||||
String url = baseUrl + "/device/instance/" + deviceSn + "/property";
|
||||
log.info("发送航线任务到IoT平台: url={}, message={}", url, controlMessage);
|
||||
java.util.Map<String, String> result = requestUtils.getPostRequestResultMap(url, controlMessage.toString());
|
||||
// 5. 处理响应结果
|
||||
return handleWaylineResponse(result, missionCode, deviceSn);
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("执行航线任务异常: deviceSn={}, waylineId={}, missionCode={}, error={}",
|
||||
deviceSn, waylineId, missionCode, e.getMessage(), e);
|
||||
return Result.failed("执行航线任务异常: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建航线控制消息
|
||||
*/
|
||||
private JsonObject buildWaylineControlMessage(String deviceSn, String waylineId, String missionCode, LineFile lineFile) {
|
||||
try {
|
||||
Gson gson = new Gson();
|
||||
// 使用 flighttask_prepare 命令模板
|
||||
JsonObject jsonObject = gson.fromJson(controlMessageConstant.CONTROL_MESSAGE_MAP.get("flighttask_prepare"), JsonObject.class);
|
||||
JsonObject data = jsonObject.getAsJsonObject("data");
|
||||
|
||||
// 设置任务编码(代替订单号)
|
||||
data.addProperty("order_no", missionCode);
|
||||
|
||||
// 设置航线文件路径(从objectKey获取完整URL)
|
||||
String waylineFilePath = fileCenterService.getFileViewUrl(lineFile.getWaylineId());
|
||||
data.addProperty("wayline_link_url", waylineFilePath);
|
||||
// 设置航线文件MD5签名
|
||||
data.addProperty("file_md5", lineFile.getSign());
|
||||
// 设置设备视频流地址
|
||||
try {
|
||||
data.add("stream_urls", gson.fromJson(getStreamUrls(deviceSn).toJSONString(), JsonElement.class));
|
||||
} catch (Exception e) {
|
||||
log.error("生成设备推流/拉流地址异常: deviceSn={}, error={}", deviceSn, e.getMessage(), e);
|
||||
data.addProperty("stream_urls", "{}");
|
||||
}
|
||||
log.info("构建航线控制消息完成: deviceSn={}, waylineId={}, missionCode={}", deviceSn, waylineId, missionCode);
|
||||
return jsonObject;
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("构建航线控制消息失败: deviceSn={}, waylineId={}, error={}", deviceSn, waylineId, e.getMessage(), e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理航线任务响应结果
|
||||
*/
|
||||
private Result<String> handleWaylineResponse(java.util.Map<String, String> result, String missionCode, String deviceSn) throws JsonProcessingException {
|
||||
com.alibaba.fastjson.JSONObject object = com.alibaba.fastjson.JSONObject.parseObject(result.get(""));
|
||||
if (object == null) {
|
||||
log.error("请求IoT平台异常,返回结果为空: missionCode={}", missionCode);
|
||||
return Result.failed("请求IoT平台异常");
|
||||
}
|
||||
IotRequestResult requestResult = IotRequestResult.getInstance(object);
|
||||
log.info("航线任务IoT响应: missionCode={}, status={}, message={}", missionCode, requestResult.getStatus(), requestResult.getMessage());
|
||||
|
||||
if (requestResult.getStatus() == 200) {
|
||||
log.info("航线任务下发成功: missionCode={}, deviceSn={}", missionCode, deviceSn);
|
||||
return Result.succeed(missionCode, "航线任务执行成功");
|
||||
} else if (requestResult.getStatus() == 500) {
|
||||
if ("Device is offline".equals(requestResult.getMessage())) {
|
||||
log.warn("设备离线,无法执行航线任务: missionCode={}, deviceSn={}", missionCode, deviceSn);
|
||||
return Result.failed("设备已离线,无法执行航线任务");
|
||||
}
|
||||
log.error("航线任务执行失败: missionCode={}, message={}", missionCode, requestResult.getMessage());
|
||||
return Result.failed("航线任务执行失败: " + requestResult.getMessage());
|
||||
}
|
||||
|
||||
return Result.failed("航线任务执行失败,请重试");
|
||||
}
|
||||
|
||||
|
||||
public JSONObject getStreamUrls(String deviceId) {
|
||||
JSONObject result = new JSONObject();
|
||||
AgeDevice device = iAgeDeviceService.getByDeviceSn(deviceId);
|
||||
if(Objects.nonNull(device)){
|
||||
result.put("pushUrl", device.getPushStreamUrl());
|
||||
}
|
||||
result.put("playRtmpUrl", "");
|
||||
result.put("playFlvUrl", "");
|
||||
result.put("playM3u8Url", "");
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取状态描述
|
||||
*/
|
||||
private String getStatusDescription(CommandStatus status) {
|
||||
return switch (status) {
|
||||
case PENDING -> "等待发送";
|
||||
case SENDING -> "发送中";
|
||||
case SENT -> "已发送,等待设备响应";
|
||||
case SUCCESS -> "执行成功";
|
||||
case FAILED -> "执行失败";
|
||||
case TIMEOUT -> "响应超时";
|
||||
case EXPIRED -> "命令已过期";
|
||||
};
|
||||
}
|
||||
|
||||
// ========== DTO类 ==========
|
||||
|
||||
@Data
|
||||
public static class SendCommandRequest {
|
||||
private String deviceSn;
|
||||
private String commandType;
|
||||
private JSONObject params;
|
||||
}
|
||||
|
||||
/**
|
||||
* 一键起飞请求参数
|
||||
*/
|
||||
@Data
|
||||
public static class TakeoffRequest {
|
||||
/** 设备SN */
|
||||
private String deviceSn;
|
||||
/** 目标点纬度 */
|
||||
private Double targetLatitude;
|
||||
/** 目标点经度 */
|
||||
private Double targetLongitude;
|
||||
/** 目标点高度(椭球高),使用 WGS84 模型 */
|
||||
private Float targetHeight;
|
||||
/** 安全起飞高度,相对起飞点的高度 */
|
||||
private Float securityTakeoffHeight;
|
||||
/** 返航模式:0=智能高度,1=设定高度 */
|
||||
private Integer rthMode;
|
||||
/** 返航高度,相对起飞点的高度 */
|
||||
private Integer rthAltitude;
|
||||
/** 遥控器失控动作:0=悬停,1=降落,2=返航 */
|
||||
private Integer rcLostAction;
|
||||
/** 指点飞行失控动作:0=继续执行,1=退出任务 */
|
||||
private Integer commanderModeLostAction;
|
||||
/** 指点飞行模式:0=智能高度飞行,1=设定高度飞行 */
|
||||
private Integer commanderFlightMode;
|
||||
/** 指点飞行高度,相对起飞点的高度 */
|
||||
private Float commanderFlightHeight;
|
||||
/** 一键起飞任务UUID */
|
||||
private String flightId;
|
||||
/** 最大飞行速度(m/s),范围1-15 */
|
||||
private Integer maxSpeed;
|
||||
/** 飞行安全预检查:0=关闭,1=开启 */
|
||||
private Integer flightSafetyAdvanceCheck;
|
||||
}
|
||||
|
||||
/**
|
||||
* DRC杆量控制请求参数
|
||||
*/
|
||||
@Data
|
||||
public static class StickControlRequest {
|
||||
/** 设备SN */
|
||||
private String deviceSn;
|
||||
/** 横滚通道(624-1424,1024为中值) */
|
||||
private Integer roll;
|
||||
/** 俯仰通道(624-1424,1024为中值) */
|
||||
private Integer pitch;
|
||||
/** 升降通道(624-1424,1024为悬停) */
|
||||
private Integer throttle;
|
||||
/** 偏航通道(624-1424,1024为中值) */
|
||||
private Integer yaw;
|
||||
/** 云台俯仰(624-1424,1024为中值) */
|
||||
private Integer gimbalPitch;
|
||||
}
|
||||
|
||||
/**
|
||||
* 云台控制请求参数
|
||||
*/
|
||||
@Data
|
||||
public static class GimbalControlRequest {
|
||||
/** 设备SN */
|
||||
private String deviceSn;
|
||||
/** 云台 pitch 速度(度/秒) */
|
||||
private Double pitchSpeed;
|
||||
/** 云台 yaw 速度(度/秒) */
|
||||
private Double yawSpeed;
|
||||
/** 是否锁定机头:false=仅云台转,true=机身一起转 */
|
||||
private Boolean locked;
|
||||
}
|
||||
|
||||
/**
|
||||
* 指点飞行(首次飞向目标)请求参数
|
||||
*/
|
||||
@Data
|
||||
public static class FlyToPointRequest {
|
||||
/** 设备SN */
|
||||
private String deviceSn;
|
||||
/** 飞行会话ID(= missionCode) */
|
||||
private String flyToId;
|
||||
/** 目标纬度 */
|
||||
private Double latitude;
|
||||
/** 目标经度 */
|
||||
private Double longitude;
|
||||
/** 目标椭球高(前端计算:Cartographic.height + 用户飞行高度) */
|
||||
private Float height;
|
||||
/** 最大飞行速度(m/s),默认 12 */
|
||||
private Float maxSpeed;
|
||||
}
|
||||
|
||||
/**
|
||||
* 指点飞行更新目标(连续指点)请求参数
|
||||
* 注意:设备协议不含 fly_to_id,仅传 max_speed + points
|
||||
*/
|
||||
@Data
|
||||
public static class FlyToPointUpdateRequest {
|
||||
/** 设备SN */
|
||||
private String deviceSn;
|
||||
/** 目标纬度 */
|
||||
private Double latitude;
|
||||
/** 目标经度 */
|
||||
private Double longitude;
|
||||
/** 目标椭球高 */
|
||||
private Float height;
|
||||
/** 最大飞行速度(m/s),默认 12 */
|
||||
private Float maxSpeed;
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class CommandStatusDTO {
|
||||
private String commandId;
|
||||
private String deviceSn;
|
||||
private String commandType;
|
||||
private String status;
|
||||
private String statusDesc;
|
||||
private Long createTime;
|
||||
private Long sendTime;
|
||||
private Integer retryCount;
|
||||
private String errorMsg;
|
||||
}
|
||||
}
|
||||
-178
@@ -1,178 +0,0 @@
|
||||
package com.central.device.controller;
|
||||
|
||||
import com.central.common.model.Result;
|
||||
import com.central.device.boat.entity.DroneFlightTrack;
|
||||
import com.central.device.model.vo.FlightTrackVO;
|
||||
import com.central.device.service.IDroneFlightTrackService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 飞行轨迹Controller
|
||||
*
|
||||
* @author dzc
|
||||
* @date 2025-12-17
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/api/device/drone/track")
|
||||
@Tag(name = "飞行轨迹管理", description = "飞行轨迹相关接口")
|
||||
@Slf4j
|
||||
public class DroneFlightTrackController {
|
||||
|
||||
@Autowired
|
||||
private IDroneFlightTrackService flightTrackService;
|
||||
|
||||
@Operation(summary = "获取飞行轨迹", description = "获取指定设备的飞行轨迹数据")
|
||||
@GetMapping("/{deviceSn}")
|
||||
public Result<FlightTrackVO> getFlightTrack(
|
||||
@Parameter(description = "设备SN", required = true)
|
||||
@PathVariable String deviceSn,
|
||||
@Parameter(description = "任务ID")
|
||||
@RequestParam(required = false) String jobId,
|
||||
@Parameter(description = "航线任务ID")
|
||||
@RequestParam(required = false) String routeId,
|
||||
@Parameter(description = "开始时间")
|
||||
@RequestParam(required = false) @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") LocalDateTime startTime,
|
||||
@Parameter(description = "结束时间")
|
||||
@RequestParam(required = false) @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") LocalDateTime endTime,
|
||||
@Parameter(description = "限制数量")
|
||||
@RequestParam(required = false, defaultValue = "1000") Integer limit) {
|
||||
|
||||
try {
|
||||
List<DroneFlightTrack> trackPoints = flightTrackService.getTrackPoints(
|
||||
deviceSn, jobId, routeId, startTime, endTime, limit);
|
||||
|
||||
FlightTrackVO vo = new FlightTrackVO();
|
||||
vo.setDeviceSn(deviceSn);
|
||||
vo.setJobId(jobId);
|
||||
vo.setRouteId(routeId);
|
||||
|
||||
if (trackPoints != null && !trackPoints.isEmpty()) {
|
||||
// 转换轨迹点
|
||||
List<FlightTrackVO.TrackPointVO> pointVOs = trackPoints.stream()
|
||||
.map(this::convertToTrackPointVO)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
vo.setTrackPoints(pointVOs);
|
||||
vo.setTotalPoints(pointVOs.size());
|
||||
|
||||
// 计算飞行时长(秒)
|
||||
LocalDateTime firstTime = trackPoints.get(0).getRecordTime();
|
||||
LocalDateTime lastTime = trackPoints.get(trackPoints.size() - 1).getRecordTime();
|
||||
if (firstTime != null && lastTime != null) {
|
||||
vo.setDuration(java.time.Duration.between(firstTime, lastTime).getSeconds());
|
||||
}
|
||||
} else {
|
||||
vo.setTrackPoints(new ArrayList<>());
|
||||
vo.setTotalPoints(0);
|
||||
vo.setDuration(0L);
|
||||
}
|
||||
|
||||
return Result.succeed(vo);
|
||||
} catch (Exception e) {
|
||||
log.error("获取飞行轨迹失败: deviceSn={}", deviceSn, e);
|
||||
return Result.failed("获取失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Operation(summary = "获取最新轨迹点", description = "获取指定设备的最新轨迹点")
|
||||
@GetMapping("/latest/{deviceSn}")
|
||||
public Result<FlightTrackVO.TrackPointVO> getLatestTrackPoint(
|
||||
@Parameter(description = "设备SN", required = true)
|
||||
@PathVariable String deviceSn) {
|
||||
if (!StringUtils.hasText(deviceSn)) {
|
||||
return Result.failed("设备SN不能为空");
|
||||
}
|
||||
|
||||
try {
|
||||
DroneFlightTrack track = flightTrackService.getLatestTrackPoint(deviceSn);
|
||||
if (track != null) {
|
||||
FlightTrackVO.TrackPointVO vo = convertToTrackPointVO(track);
|
||||
return Result.succeed(vo);
|
||||
} else {
|
||||
return Result.succeed(null, "暂无轨迹数据");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("获取最新轨迹点失败: deviceSn={}", deviceSn, e);
|
||||
return Result.failed("获取失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Operation(summary = "删除历史轨迹", description = "删除指定时间之前的飞行轨迹数据")
|
||||
@DeleteMapping("/history/{deviceSn}")
|
||||
public Result<Integer> deleteHistoryTracks(
|
||||
@Parameter(description = "设备SN", required = true)
|
||||
@PathVariable String deviceSn,
|
||||
@Parameter(description = "删除此时间之前的轨迹", required = true)
|
||||
@RequestParam @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") LocalDateTime beforeTime) {
|
||||
if (!StringUtils.hasText(deviceSn)) {
|
||||
return Result.failed("设备SN不能为空");
|
||||
}
|
||||
|
||||
try {
|
||||
int count = flightTrackService.deleteTrackPointsBefore(deviceSn, beforeTime);
|
||||
return Result.succeed(count, "成功删除 " + count + " 条轨迹记录");
|
||||
} catch (Exception e) {
|
||||
log.error("删除历史轨迹失败: deviceSn={}", deviceSn, e);
|
||||
return Result.failed("删除失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Operation(summary = "统计轨迹点数量", description = "统计指定条件的轨迹点数量")
|
||||
@GetMapping("/count/{deviceSn}")
|
||||
public Result<Long> countTrackPoints(
|
||||
@Parameter(description = "设备SN", required = true)
|
||||
@PathVariable String deviceSn,
|
||||
@Parameter(description = "任务ID")
|
||||
@RequestParam(required = false) String jobId,
|
||||
@Parameter(description = "航线任务ID")
|
||||
@RequestParam(required = false) String routeId,
|
||||
@Parameter(description = "开始时间")
|
||||
@RequestParam(required = false) @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") LocalDateTime startTime,
|
||||
@Parameter(description = "结束时间")
|
||||
@RequestParam(required = false) @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") LocalDateTime endTime) {
|
||||
|
||||
try {
|
||||
Long count = flightTrackService.countTrackPoints(deviceSn, jobId, routeId, startTime, endTime);
|
||||
return Result.succeed(count);
|
||||
} catch (Exception e) {
|
||||
log.error("统计轨迹点数量失败", e);
|
||||
return Result.failed("统计失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为轨迹点VO
|
||||
*/
|
||||
private FlightTrackVO.TrackPointVO convertToTrackPointVO(DroneFlightTrack track) {
|
||||
FlightTrackVO.TrackPointVO vo = new FlightTrackVO.TrackPointVO();
|
||||
|
||||
vo.setLng(track.getLongitude() != null ? track.getLongitude().doubleValue() : 0);
|
||||
vo.setLat(track.getLatitude() != null ? track.getLatitude().doubleValue() : 0);
|
||||
vo.setAlt(track.getAltitude() != null ? track.getAltitude().doubleValue() : 0);
|
||||
vo.setHeight(track.getHeight() != null ? track.getHeight().doubleValue() : 0);
|
||||
|
||||
vo.setSpeed(track.getHorizontalSpeed() != null ? track.getHorizontalSpeed().doubleValue() : 0);
|
||||
vo.setHeading(track.getHeading() != null ? track.getHeading().doubleValue() : 0);
|
||||
|
||||
vo.setBatteryPercent(track.getBatteryPercent());
|
||||
vo.setTime(track.getRecordTime());
|
||||
|
||||
// 偏离信息
|
||||
vo.setDeviationDistance(track.getDeviationDistance() != null ? track.getDeviationDistance().doubleValue() : 0);
|
||||
vo.setIsDeviation(track.getIsDeviation() != null && track.getIsDeviation() == 1);
|
||||
|
||||
return vo;
|
||||
}
|
||||
}
|
||||
-246
@@ -1,246 +0,0 @@
|
||||
package com.central.device.controller;
|
||||
|
||||
import com.central.common.model.PageResult;
|
||||
import com.central.common.model.Result;
|
||||
import com.central.device.model.IotCard;
|
||||
import com.central.device.model.vo.IccidFlowVO;
|
||||
import com.central.device.service.IIotCardService;
|
||||
import com.central.device.util.http.SimpleHttpRequest;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Parameters;
|
||||
import io.swagger.v3.oas.annotations.enums.ParameterIn;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.jsoup.Jsoup;
|
||||
import org.jsoup.nodes.Document;
|
||||
import org.jsoup.nodes.Element;
|
||||
import org.jsoup.select.Elements;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 物联网卡管理
|
||||
*
|
||||
* @author system
|
||||
* @date 2026-03-27
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/iot-card")
|
||||
@Tag(name = "物联网卡管理")
|
||||
@RequiredArgsConstructor
|
||||
public class IotCardController {
|
||||
|
||||
private final IIotCardService iotCardService;
|
||||
|
||||
/**
|
||||
* 分页列表
|
||||
*/
|
||||
@Operation(summary = "查询物联网卡列表")
|
||||
@Parameters({
|
||||
@Parameter(name = "page", description = "页码", required = true, in = ParameterIn.QUERY),
|
||||
@Parameter(name = "limit", description = "每页条数", required = true, in = ParameterIn.QUERY),
|
||||
@Parameter(name = "cardNumber", description = "卡号", in = ParameterIn.QUERY),
|
||||
@Parameter(name = "deviceSn", description = "设备SN", in = ParameterIn.QUERY),
|
||||
@Parameter(name = "enabled", description = "启用状态", in = ParameterIn.QUERY),
|
||||
@Parameter(name = "carrier", description = "运营商", in = ParameterIn.QUERY)
|
||||
})
|
||||
@GetMapping
|
||||
public PageResult<IotCard> list(@RequestParam Map<String, Object> params) {
|
||||
return iotCardService.findList(params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据ID查询
|
||||
*/
|
||||
@Operation(summary = "查询物联网卡详情")
|
||||
@GetMapping("/{id}")
|
||||
public Result<IotCard> findById(@PathVariable Long id) {
|
||||
IotCard model = iotCardService.getById(id);
|
||||
return Result.succeed(model, "查询成功");
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增或更新
|
||||
*/
|
||||
@Operation(summary = "新增/更新物联网卡")
|
||||
@PostMapping
|
||||
public Result<String> save(@RequestBody IotCard iotCard) {
|
||||
// 新增时校验卡号唯一
|
||||
if (iotCard.getId() == null && iotCard.getCardNumber() != null) {
|
||||
if (iotCardService.checkCardNumberExists(iotCard.getCardNumber())) {
|
||||
return Result.failed("卡号已存在");
|
||||
}
|
||||
}
|
||||
iotCardService.saveOrUpdate(iotCard);
|
||||
return Result.succeed("保存成功");
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
@Operation(summary = "删除物联网卡")
|
||||
@Parameter(name = "id", description = "物联网卡ID", in = ParameterIn.PATH, required = true)
|
||||
@DeleteMapping("/{id}")
|
||||
public Result<String> delete(@PathVariable Long id) {
|
||||
iotCardService.removeById(id);
|
||||
return Result.succeed("删除成功");
|
||||
}
|
||||
|
||||
/**
|
||||
* 绑定设备
|
||||
*/
|
||||
@Operation(summary = "绑定设备")
|
||||
@PostMapping("/{id}/bind")
|
||||
public Result<String> bindDevice(@PathVariable Long id, @RequestParam String deviceSn) {
|
||||
try {
|
||||
boolean result = iotCardService.bindDevice(id, deviceSn);
|
||||
return result ? Result.succeed("绑定成功") : Result.failed("绑定失败");
|
||||
} catch (IllegalArgumentException e) {
|
||||
return Result.failed(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 解绑设备
|
||||
*/
|
||||
@Operation(summary = "解绑设备")
|
||||
@PostMapping("/{id}/unbind")
|
||||
public Result<String> unbindDevice(@PathVariable Long id) {
|
||||
try {
|
||||
boolean result = iotCardService.unbindDevice(id);
|
||||
return result ? Result.succeed("解绑成功") : Result.failed("解绑失败");
|
||||
} catch (IllegalArgumentException e) {
|
||||
return Result.failed(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 启用/停用
|
||||
*/
|
||||
@Operation(summary = "启用/停用物联网卡")
|
||||
@PutMapping("/{id}/toggle")
|
||||
public Result<String> toggleEnabled(@PathVariable Long id, @RequestParam Integer enabled) {
|
||||
try {
|
||||
boolean result = iotCardService.toggleEnabled(id, enabled);
|
||||
return result ? Result.succeed("操作成功") : Result.failed("操作失败");
|
||||
} catch (IllegalArgumentException e) {
|
||||
return Result.failed(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询物联网卡流量信息
|
||||
*/
|
||||
@Operation(summary = "查询物联网卡流量信息")
|
||||
@Parameter(name = "iccid", description = "ICCID卡号", required = true, in = ParameterIn.QUERY)
|
||||
@GetMapping("/flow-info")
|
||||
public Result<IccidFlowVO> queryFlowInfo(@RequestParam String iccid) {
|
||||
try {
|
||||
// 构建第三方查询URL
|
||||
String url = String.format(
|
||||
"http://api.slwul.com/yjiot/wxapi/action/searchcharge?appId=wx22f2a856e6286b28&openId=oA7vc59BnABsWZeXZzI6pbX0j0EM&iccid=%s&wx_exhibition_fieid=iccid",
|
||||
iccid
|
||||
);
|
||||
|
||||
// 发起HTTP请求获取HTML页面
|
||||
SimpleHttpRequest request = new SimpleHttpRequest(url);
|
||||
byte[] responseBytes = request.get().asBytes();
|
||||
String htmlContent = new String(responseBytes, "UTF-8");
|
||||
|
||||
// 解析HTML并提取关键数据
|
||||
IccidFlowVO flowVO = parseHtmlToVO(htmlContent, iccid);
|
||||
|
||||
return Result.succeed(flowVO, "查询成功");
|
||||
} catch (Exception e) {
|
||||
log.error("查询物联网卡流量信息失败, iccid={}", iccid, e);
|
||||
return Result.failed("查询失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析HTML页面为实体对象
|
||||
*/
|
||||
private IccidFlowVO parseHtmlToVO(String htmlContent, String iccid) {
|
||||
IccidFlowVO flowVO = new IccidFlowVO();
|
||||
flowVO.setIccid(iccid);
|
||||
|
||||
try {
|
||||
Document doc = Jsoup.parse(htmlContent);
|
||||
|
||||
// 解析激活状态和实名状态
|
||||
Elements statusButtons = doc.select(".weui_card_btn_left button");
|
||||
if (statusButtons.size() >= 1) {
|
||||
flowVO.setActiveStatus(statusButtons.get(0).text().trim());
|
||||
}
|
||||
if (statusButtons.size() >= 2) {
|
||||
flowVO.setRealNameStatus(statusButtons.get(1).text().trim());
|
||||
}
|
||||
|
||||
// 解析总流量
|
||||
Element totalFlowElement = doc.select(".weui_card_data_left span").first();
|
||||
if (totalFlowElement != null) {
|
||||
String totalFlowText = totalFlowElement.text().replace("MB", "").trim();
|
||||
flowVO.setTotalFlow(new BigDecimal(totalFlowText));
|
||||
}
|
||||
|
||||
// 解析截止时间
|
||||
Element expireTimeElement = doc.select(".weui_card_remain_days").first();
|
||||
if (expireTimeElement != null) {
|
||||
flowVO.setExpireTime(expireTimeElement.text().trim());
|
||||
}
|
||||
|
||||
// 解析剩余流量
|
||||
Element remainFlowElement = doc.select(".weui_card_remain_data span").first();
|
||||
if (remainFlowElement != null) {
|
||||
String remainFlowText = remainFlowElement.text().replace("MB", "").trim();
|
||||
flowVO.setRemainFlow(new BigDecimal(remainFlowText));
|
||||
}
|
||||
|
||||
// 解析当前套餐列表
|
||||
List<IccidFlowVO.FlowPackage> packageList = new ArrayList<>();
|
||||
Elements packageElements = doc.select(".currqrycard .qry");
|
||||
for (Element pkgElement : packageElements) {
|
||||
IccidFlowVO.FlowPackage pkg = new IccidFlowVO.FlowPackage();
|
||||
|
||||
// 解析套餐名称和状态
|
||||
Elements spans = pkgElement.select("span");
|
||||
if (spans.size() >= 1) {
|
||||
pkg.setPackageName(spans.get(0).text().trim());
|
||||
}
|
||||
if (spans.size() >= 2) {
|
||||
pkg.setStatus(spans.get(1).text().trim());
|
||||
}
|
||||
|
||||
// 解析生效时间和截止时间
|
||||
Element timeElement = pkgElement.select("p.weui_card_font_color").first();
|
||||
if (timeElement != null) {
|
||||
String timeText = timeElement.text();
|
||||
// 格式:生效时间2025-10-01~截止时间2026-09-30
|
||||
if (timeText.contains("生效时间") && timeText.contains("截止时间")) {
|
||||
String[] timeParts = timeText.replace("生效时间", "").split("~截止时间");
|
||||
if (timeParts.length == 2) {
|
||||
pkg.setStartTime(timeParts[0].trim());
|
||||
pkg.setEndTime(timeParts[1].trim());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
packageList.add(pkg);
|
||||
}
|
||||
flowVO.setPackageList(packageList);
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("解析HTML失败", e);
|
||||
}
|
||||
|
||||
return flowVO;
|
||||
}
|
||||
}
|
||||
+1
-12
@@ -1,11 +1,8 @@
|
||||
package com.central.device.controller;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.central.common.model.PageResult;
|
||||
import com.central.common.model.Result;
|
||||
import com.central.device.feign.FileCenterService;
|
||||
import com.central.device.model.LineFile;
|
||||
import com.central.device.model.vo.WaypointInfoVO;
|
||||
import com.central.device.service.ILineFileService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
@@ -16,7 +13,6 @@ import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import jakarta.annotation.Resource;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -36,9 +32,6 @@ import java.util.stream.Collectors;
|
||||
public class LineFileController {
|
||||
private final ILineFileService lineFileService;
|
||||
|
||||
@Resource
|
||||
private FileCenterService fileCenterService;
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*/
|
||||
@@ -63,11 +56,7 @@ public class LineFileController {
|
||||
if (model == null) {
|
||||
return Result.failed("未找到对应的航线文件信息");
|
||||
}
|
||||
String fileurl = fileCenterService.getFileViewUrl(model.getWaylineId());
|
||||
WaypointInfoVO infoVO = new WaypointInfoVO();
|
||||
BeanUtil.copyProperties(model,infoVO);
|
||||
infoVO.setFileUrl(fileurl);
|
||||
return Result.succeed(infoVO, "查询成功");
|
||||
return Result.succeed(model, "查询成功");
|
||||
} catch (Exception e) {
|
||||
log.error("查询航线文件失败,id: {}", id, e);
|
||||
return Result.failed("查询航线文件失败:" + e.getMessage());
|
||||
|
||||
-78
@@ -1,78 +0,0 @@
|
||||
package com.central.device.controller;
|
||||
|
||||
import com.central.device.sse.manager.SseEmitterManager;
|
||||
import com.central.device.websocket.manager.SubscriptionPoolService;
|
||||
import com.central.common.model.Result;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* SSE 连接管理控制器
|
||||
* 提供管理员手动管理 SSE 连接和 WebSocket 订阅的接口
|
||||
*
|
||||
* @author dzc
|
||||
* @date 2025-01-20
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/admin/sse")
|
||||
@Tag(name = "SSE管理接口", description = "管理员手动管理SSE连接和订阅")
|
||||
public class SseAdminController {
|
||||
|
||||
@Autowired
|
||||
private SseEmitterManager sseEmitterManager;
|
||||
|
||||
@Autowired
|
||||
private SubscriptionPoolService subscriptionPoolService;
|
||||
|
||||
/**
|
||||
* 查看当前连接状态
|
||||
*/
|
||||
@GetMapping("/status")
|
||||
@Operation(summary = "查看SSE连接状态", description = "获取当前所有SSE连接和WebSocket订阅状态")
|
||||
public Result<Map<String, Object>> getStatus() {
|
||||
Map<String, Object> status = sseEmitterManager.getConnectionStatus();
|
||||
|
||||
// 打印 Redis 订阅状态
|
||||
subscriptionPoolService.printSubscriptionStatus();
|
||||
|
||||
return Result.succeed(status, "查询成功");
|
||||
}
|
||||
|
||||
/**
|
||||
* 强制断开所有连接
|
||||
*/
|
||||
@PostMapping("/disconnect-all")
|
||||
@Operation(summary = "断开所有SSE连接", description = "强制断开所有SSE连接,清理Redis订阅,关闭WebSocket")
|
||||
public Result<String> disconnectAll() {
|
||||
log.warn("【管理员操作】收到断开所有连接请求");
|
||||
|
||||
int disconnected = sseEmitterManager.disconnectAll();
|
||||
|
||||
String msg = String.format("已断开 %d 个SSE连接,已清理Redis订阅,已关闭WebSocket", disconnected);
|
||||
log.info(msg);
|
||||
|
||||
return Result.succeed(msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* 仅清理 Redis 订阅(不断开 SSE)
|
||||
*/
|
||||
@PostMapping("/clear-redis")
|
||||
@Operation(summary = "清理Redis订阅", description = "仅清理Redis中的订阅记录,不断开SSE连接")
|
||||
public Result<String> clearRedis() {
|
||||
log.warn("【管理员操作】收到清理Redis订阅请求");
|
||||
|
||||
int cleared = subscriptionPoolService.clearAllSubscriptions();
|
||||
|
||||
String msg = String.format("已清理 %d 个Redis订阅记录", cleared);
|
||||
log.info(msg);
|
||||
|
||||
return Result.succeed(msg);
|
||||
}
|
||||
}
|
||||
-188
@@ -1,188 +0,0 @@
|
||||
package com.central.device.controller;
|
||||
|
||||
import com.central.common.model.PageResult;
|
||||
import com.central.common.model.Result;
|
||||
import com.central.device.model.dto.ThreeDModelFileDTO;
|
||||
import com.central.device.model.vo.ThreeDModelFileVO;
|
||||
import com.central.device.service.IThreeDModelFileService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 3D模型文件管理Controller
|
||||
*
|
||||
* @author claude
|
||||
* @date 2024-12-08
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/3d-model")
|
||||
@RequiredArgsConstructor
|
||||
@Tag(name = "3D模型文件管理")
|
||||
public class ThreeDModelFileController {
|
||||
|
||||
private final IThreeDModelFileService modelFileService;
|
||||
|
||||
/**
|
||||
* 分页查询模型列表
|
||||
*/
|
||||
@GetMapping
|
||||
@Operation(summary = "分页查询模型列表")
|
||||
public PageResult<ThreeDModelFileVO> list(@RequestParam Map<String, Object> params) {
|
||||
return modelFileService.findList(params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取模型详情
|
||||
*/
|
||||
@GetMapping("/{id}")
|
||||
@Operation(summary = "获取模型详情")
|
||||
public Result<ThreeDModelFileVO> getById(
|
||||
@Parameter(description = "模型ID") @PathVariable Long id) {
|
||||
ThreeDModelFileVO vo = modelFileService.getDetailById(id);
|
||||
return vo != null ? Result.succeed(vo) : Result.failed("模型不存在");
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据景区ID获取模型列表
|
||||
*/
|
||||
@GetMapping("/tourism/{tourismId}")
|
||||
@Operation(summary = "根据景区ID获取模型列表")
|
||||
public Result<List<ThreeDModelFileVO>> getByTourismId(
|
||||
@Parameter(description = "景区ID") @PathVariable Long tourismId) {
|
||||
return Result.succeed(modelFileService.getByTourismId(tourismId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据设备SN获取模型列表
|
||||
*/
|
||||
@GetMapping("/device/{deviceSn}")
|
||||
@Operation(summary = "根据设备SN获取模型列表")
|
||||
public Result<List<ThreeDModelFileVO>> getByDeviceSn(
|
||||
@Parameter(description = "设备SN") @PathVariable String deviceSn) {
|
||||
return Result.succeed(modelFileService.getByDeviceSn(deviceSn));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取所有可用模型(用于3D地图加载)
|
||||
*/
|
||||
@GetMapping("/available")
|
||||
@Operation(summary = "获取所有可用模型")
|
||||
public Result<List<ThreeDModelFileVO>> getAllAvailable() {
|
||||
return Result.succeed(modelFileService.getAllAvailableModels());
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建模型记录
|
||||
*/
|
||||
@PostMapping
|
||||
@Operation(summary = "创建模型记录")
|
||||
public Result<Long> create(@Valid @RequestBody ThreeDModelFileDTO dto) {
|
||||
Long id = modelFileService.create(dto);
|
||||
return Result.succeed(id, "创建成功");
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新模型信息
|
||||
*/
|
||||
@PutMapping
|
||||
@Operation(summary = "更新模型信息")
|
||||
public Result<Void> update(@Valid @RequestBody ThreeDModelFileDTO dto) {
|
||||
boolean success = modelFileService.update(dto);
|
||||
return success ? Result.succeed("更新成功") : Result.failed("更新失败");
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除模型
|
||||
*/
|
||||
@DeleteMapping("/{id}")
|
||||
@Operation(summary = "删除模型")
|
||||
public Result<Void> delete(
|
||||
@Parameter(description = "模型ID") @PathVariable Long id) {
|
||||
boolean success = modelFileService.delete(id);
|
||||
return success ? Result.succeed("删除成功") : Result.failed("删除失败");
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量上传模型文件
|
||||
*/
|
||||
@PostMapping("/{modelId}/upload")
|
||||
@Operation(summary = "批量上传模型文件")
|
||||
public Result<Map<String, Object>> uploadFiles(
|
||||
@Parameter(description = "模型ID") @PathVariable Long modelId,
|
||||
@Parameter(description = "文件列表") @RequestParam("files") MultipartFile[] files,
|
||||
@Parameter(description = "基础路径") @RequestParam(value = "basePath", required = false) String basePath) {
|
||||
Map<String, Object> result = modelFileService.uploadModelFiles(modelId, files, basePath);
|
||||
return Result.succeed(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传单个文件
|
||||
*/
|
||||
@PostMapping("/{modelId}/upload/single")
|
||||
@Operation(summary = "上传单个模型文件")
|
||||
public Result<String> uploadSingleFile(
|
||||
@Parameter(description = "模型ID") @PathVariable Long modelId,
|
||||
@Parameter(description = "文件") @RequestParam("file") MultipartFile file,
|
||||
@Parameter(description = "文件相对路径") @RequestParam("filePath") String filePath) {
|
||||
String url = modelFileService.uploadSingleFile(modelId, file, filePath);
|
||||
return Result.succeed(url, "上传成功");
|
||||
}
|
||||
|
||||
/**
|
||||
* 完成上传
|
||||
*/
|
||||
@PostMapping("/{modelId}/complete")
|
||||
@Operation(summary = "完成上传(更新状态)")
|
||||
public Result<Void> completeUpload(
|
||||
@Parameter(description = "模型ID") @PathVariable Long modelId) {
|
||||
boolean success = modelFileService.completeUpload(modelId);
|
||||
return success ? Result.succeed("完成") : Result.failed("操作失败");
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新上传进度
|
||||
*/
|
||||
@PostMapping("/{modelId}/progress")
|
||||
@Operation(summary = "更新上传进度")
|
||||
public Result<Void> updateProgress(
|
||||
@Parameter(description = "模型ID") @PathVariable Long modelId,
|
||||
@Parameter(description = "进度(0-100)") @RequestParam Integer progress) {
|
||||
modelFileService.updateProgress(modelId, progress);
|
||||
return Result.succeed("上传完成");
|
||||
}
|
||||
|
||||
/**
|
||||
* 启用/禁用模型
|
||||
*/
|
||||
@PutMapping("/{id}/status")
|
||||
@Operation(summary = "启用/禁用模型")
|
||||
public Result<Void> updateStatus(
|
||||
@Parameter(description = "模型ID") @PathVariable Long id,
|
||||
@Parameter(description = "状态: 0-禁用 1-启用") @RequestParam Integer status) {
|
||||
boolean success = modelFileService.updateStatus(id, status);
|
||||
return success ? Result.succeed("操作成功") : Result.failed("操作失败");
|
||||
}
|
||||
|
||||
/**
|
||||
* 关联景区
|
||||
*/
|
||||
@PutMapping("/{id}/bindTourism")
|
||||
@Operation(summary = "关联景区")
|
||||
public Result<Void> bindTourism(
|
||||
@Parameter(description = "模型ID") @PathVariable Long id,
|
||||
@Parameter(description = "景区ID") @RequestParam Long tourismId,
|
||||
@Parameter(description = "景区名称") @RequestParam(required = false) String tourismName) {
|
||||
boolean success = modelFileService.bindTourism(id, tourismId, tourismName);
|
||||
return success ? Result.succeed("关联成功") : Result.failed("关联失败");
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user