Merge pull request '合并到生产环境' (#39) from test into prod
Reviewed-on: http://220.205.16.27:18081/goflytec/GoFly-platform-services/pulls/39
This commit is contained in:
@@ -72,7 +72,9 @@
|
|||||||
"Bash(do if [ -f \"$file\" ])",
|
"Bash(do if [ -f \"$file\" ])",
|
||||||
"Bash(else echo \"✗ $file NOT FOUND\")",
|
"Bash(else echo \"✗ $file NOT FOUND\")",
|
||||||
"Bash(fi)",
|
"Bash(fi)",
|
||||||
"Bash(done)"
|
"Bash(done)",
|
||||||
|
"Bash(tasklist:*)",
|
||||||
|
"Bash(test:*)"
|
||||||
],
|
],
|
||||||
"deny": [],
|
"deny": [],
|
||||||
"ask": []
|
"ask": []
|
||||||
|
|||||||
Binary file not shown.
@@ -0,0 +1,13 @@
|
|||||||
|
FROM openjdk:8u292
|
||||||
|
|
||||||
|
LABEL MAINTAINER=Andy
|
||||||
|
WORKDIR /apps
|
||||||
|
ADD target/msg-center.jar /apps/
|
||||||
|
CMD ["java","-jar","msg-center.jar"]
|
||||||
|
# docker run --name msg-center \
|
||||||
|
# -e spring_cloud_nacos_server_addr=10.0.0.12:8848 \
|
||||||
|
# -e zlt_datasource_ip=10.0.0.12 \
|
||||||
|
# -e zlt_datasource_username=root \
|
||||||
|
# -e zlt_datasource_password=redhat \
|
||||||
|
# -e spring_redis_host=10.0.0.12 \
|
||||||
|
# -d msg-center:6.0.0
|
||||||
@@ -0,0 +1,563 @@
|
|||||||
|
# 消息中心 (msg-center)
|
||||||
|
|
||||||
|
消息中心是一个独立的微服务模块,提供短信、邮件、推送等消息发送功能。
|
||||||
|
|
||||||
|
## 功能特性
|
||||||
|
|
||||||
|
### 已实现功能
|
||||||
|
- ✅ 腾讯云短信发送
|
||||||
|
- ✅ 阿里云短信发送
|
||||||
|
- ✅ **阿里云和腾讯云独立API接口(可分别调用)**
|
||||||
|
- ✅ 多服务商切换(支持动态配置)
|
||||||
|
- ✅ 短信发送记录保存到数据库
|
||||||
|
- ✅ 验证码短信发送
|
||||||
|
- ✅ RESTful API接口
|
||||||
|
- ✅ 短信发送记录查询
|
||||||
|
|
||||||
|
### 计划功能
|
||||||
|
- 📋 邮件发送
|
||||||
|
- 📋 站内消息
|
||||||
|
- 📋 APP推送通知
|
||||||
|
- 📋 短信发送统计
|
||||||
|
|
||||||
|
## 快速开始
|
||||||
|
|
||||||
|
### 1. 数据库初始化
|
||||||
|
|
||||||
|
执行数据库初始化脚本创建短信发送记录表:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
mysql -u root -p your_database < db/init.sql
|
||||||
|
```
|
||||||
|
|
||||||
|
或手动执行 `db/init.sql` 中的SQL语句。
|
||||||
|
|
||||||
|
### 2. 配置短信服务商
|
||||||
|
|
||||||
|
支持两种短信服务商:**腾讯云** 和 **阿里云**。
|
||||||
|
|
||||||
|
**重要更新:** 现在支持**同时配置两个服务商**,并通过不同的API接口分别调用,无需切换配置!
|
||||||
|
|
||||||
|
#### 同时配置腾讯云和阿里云
|
||||||
|
|
||||||
|
在 `application.yml` 中配置:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
spring:
|
||||||
|
datasource:
|
||||||
|
url: jdbc:mysql://${zlt.datasource.ip}/msg-center?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&useSSL=false&zeroDateTimeBehavior=convertToNull&serverTimezone=Asia/Shanghai
|
||||||
|
username: ${zlt.datasource.username}
|
||||||
|
password: ${zlt.datasource.password}
|
||||||
|
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||||
|
|
||||||
|
sms:
|
||||||
|
# 默认服务商(用于通用接口 /sms/send)
|
||||||
|
provider: TENCENT
|
||||||
|
|
||||||
|
# 腾讯云短信配置
|
||||||
|
tencent:
|
||||||
|
app-id: 1400xxxxxx # 在腾讯云短信控制台获取
|
||||||
|
secret-id: AKIDxxxxxxxx # 在腾讯云控制台获取
|
||||||
|
secret-key: xxxxxxxx # 在腾讯云控制台获取
|
||||||
|
sign-name: 您的签名 # 在腾讯云短信控制台配置
|
||||||
|
verify-code-template-id: 1234567 # 腾讯云验证码模板ID
|
||||||
|
|
||||||
|
# 阿里云短信配置
|
||||||
|
aliyun:
|
||||||
|
access-key-id: LTAIxxxxxxxx # 在阿里云控制台获取
|
||||||
|
access-key-secret: xxxxxxxx # 在阿里云控制台获取
|
||||||
|
sign-name: 您的签名 # 在阿里云短信控制台配置
|
||||||
|
verify-code-template-id: SMS_123456789 # 阿里云验证码模板CODE
|
||||||
|
|
||||||
|
# 是否保存短信发送记录到数据库
|
||||||
|
save-log: true
|
||||||
|
```
|
||||||
|
|
||||||
|
**环境变量配置(推荐):**
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# 数据库配置
|
||||||
|
export zlt.datasource.ip=localhost:3306
|
||||||
|
export zlt.datasource.username=root
|
||||||
|
export zlt.datasource.password=yourpassword
|
||||||
|
|
||||||
|
# 默认服务商
|
||||||
|
export SMS_PROVIDER=TENCENT
|
||||||
|
|
||||||
|
# 腾讯云配置
|
||||||
|
export SMS_TENCENT_APP_ID=1400xxxxxx
|
||||||
|
export SMS_TENCENT_SECRET_ID=AKIDxxxxxxxxxxxxxxxx
|
||||||
|
export SMS_TENCENT_SECRET_KEY=xxxxxxxxxxxxxxxx
|
||||||
|
export SMS_TENCENT_SIGN_NAME=您的签名
|
||||||
|
export SMS_TENCENT_VERIFY_CODE_TEMPLATE_ID=1234567
|
||||||
|
|
||||||
|
# 阿里云配置
|
||||||
|
export SMS_ALIYUN_ACCESS_KEY_ID=LTAIxxxxxxxx
|
||||||
|
export SMS_ALIYUN_ACCESS_KEY_SECRET=xxxxxxxxxxxxxxxx
|
||||||
|
export SMS_ALIYUN_SIGN_NAME=您的签名
|
||||||
|
export SMS_ALIYUN_VERIFY_CODE_TEMPLATE_ID=SMS_123456789
|
||||||
|
```
|
||||||
|
|
||||||
|
### 3. 获取配置参数
|
||||||
|
|
||||||
|
#### 腾讯云短信配置参数获取
|
||||||
|
|
||||||
|
1. 登录 [腾讯云短信控制台](https://console.cloud.tencent.com/smsv2)
|
||||||
|
2. 创建短信应用,获取 `app-id`
|
||||||
|
3. 前往 [API密钥管理](https://console.cloud.tencent.com/cam/capi) 获取 `secret-id` 和 `secret-key`
|
||||||
|
4. 在短信控制台配置短信签名,获取 `sign-name`
|
||||||
|
5. 创建短信模板,获取 `template-id`
|
||||||
|
|
||||||
|
#### 阿里云短信配置参数获取
|
||||||
|
|
||||||
|
1. 登录 [阿里云短信控制台](https://dysms.console.aliyun.com/)
|
||||||
|
2. 前往 [AccessKey管理](https://ram.console.aliyun.com/manage/ak) 创建AccessKey,获取 `access-key-id` 和 `access-key-secret`
|
||||||
|
3. 在短信控制台申请短信签名,获取 `sign-name`
|
||||||
|
4. 创建短信模板,获取模板CODE(即 `template-id`,如:SMS_123456789)
|
||||||
|
|
||||||
|
### 4. 启动服务
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cd zlt-business/msg-center
|
||||||
|
mvn spring-boot:run
|
||||||
|
```
|
||||||
|
|
||||||
|
## API接口文档
|
||||||
|
|
||||||
|
服务启动后,访问 Swagger 文档:
|
||||||
|
```
|
||||||
|
http://localhost:8080/doc.html
|
||||||
|
```
|
||||||
|
|
||||||
|
### 主要接口
|
||||||
|
|
||||||
|
#### 1. 发送短信(使用默认服务商)
|
||||||
|
|
||||||
|
**接口地址:** `POST /sms/send`
|
||||||
|
|
||||||
|
**说明:** 使用配置文件中 `sms.provider` 指定的默认服务商发送短信
|
||||||
|
|
||||||
|
**请求参数:**
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"phone": "13800138000",
|
||||||
|
"templateId": "1234567",
|
||||||
|
"params": {
|
||||||
|
"code": "123456",
|
||||||
|
"time": "5"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
**响应示例:**
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"resp_code": 0,
|
||||||
|
"resp_msg": "success",
|
||||||
|
"datas": {
|
||||||
|
"success": true,
|
||||||
|
"message": "短信发送成功"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
#### 2. 发送阿里云短信
|
||||||
|
|
||||||
|
**接口地址:** `POST /sms/aliyun/send`
|
||||||
|
|
||||||
|
**说明:** 强制使用阿里云发送短信,不受默认配置影响
|
||||||
|
|
||||||
|
**请求参数:**
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"phone": "13800138000",
|
||||||
|
"templateId": "SMS_123456789",
|
||||||
|
"params": {
|
||||||
|
"code": "123456",
|
||||||
|
"time": "5"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
**响应示例:**
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"resp_code": 0,
|
||||||
|
"resp_msg": "success",
|
||||||
|
"datas": {
|
||||||
|
"success": true,
|
||||||
|
"message": "阿里云短信发送成功"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
#### 3. 发送腾讯云短信
|
||||||
|
|
||||||
|
**接口地址:** `POST /sms/tencent/send`
|
||||||
|
|
||||||
|
**说明:** 强制使用腾讯云发送短信,不受默认配置影响
|
||||||
|
|
||||||
|
**请求参数:**
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"phone": "13800138000",
|
||||||
|
"templateId": "1234567",
|
||||||
|
"params": {
|
||||||
|
"code": "123456",
|
||||||
|
"time": "5"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
**响应示例:**
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"resp_code": 0,
|
||||||
|
"resp_msg": "success",
|
||||||
|
"datas": {
|
||||||
|
"success": true,
|
||||||
|
"message": "腾讯云短信发送成功"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
#### 4. 发送验证码(使用默认服务商)
|
||||||
|
|
||||||
|
**接口地址:** `POST /sms/send-verify-code`
|
||||||
|
|
||||||
|
**请求参数:**
|
||||||
|
- `phone`: 手机号(必填)
|
||||||
|
- `code`: 验证码(必填)
|
||||||
|
|
||||||
|
**示例:**
|
||||||
|
```
|
||||||
|
POST /sms/send-verify-code?phone=13800138000&code=123456
|
||||||
|
```
|
||||||
|
|
||||||
|
**响应示例:**
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"resp_code": 0,
|
||||||
|
"resp_msg": "success",
|
||||||
|
"datas": {
|
||||||
|
"success": true,
|
||||||
|
"message": "验证码发送成功"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
#### 5. 发送阿里云验证码
|
||||||
|
|
||||||
|
**接口地址:** `POST /sms/aliyun/send-verify-code`
|
||||||
|
|
||||||
|
**说明:** 强制使用阿里云发送验证码,使用阿里云配置的验证码模板
|
||||||
|
|
||||||
|
**请求参数:**
|
||||||
|
- `phone`: 手机号(必填)
|
||||||
|
- `code`: 验证码(必填)
|
||||||
|
|
||||||
|
**示例:**
|
||||||
|
```
|
||||||
|
POST /sms/aliyun/send-verify-code?phone=13800138000&code=123456
|
||||||
|
```
|
||||||
|
|
||||||
|
#### 6. 发送腾讯云验证码
|
||||||
|
|
||||||
|
**接口地址:** `POST /sms/tencent/send-verify-code`
|
||||||
|
|
||||||
|
**说明:** 强制使用腾讯云发送验证码,使用腾讯云配置的验证码模板
|
||||||
|
|
||||||
|
**请求参数:**
|
||||||
|
- `phone`: 手机号(必填)
|
||||||
|
- `code`: 验证码(必填)
|
||||||
|
|
||||||
|
**示例:**
|
||||||
|
```
|
||||||
|
POST /sms/tencent/send-verify-code?phone=13800138000&code=123456
|
||||||
|
```
|
||||||
|
|
||||||
|
#### 7. 查询短信发送记录
|
||||||
|
|
||||||
|
**接口地址:** `GET /sms/logs`
|
||||||
|
|
||||||
|
**请求参数:**
|
||||||
|
- `page`: 当前页(默认1)
|
||||||
|
- `size`: 每页大小(默认10)
|
||||||
|
- `phone`: 手机号(可选,模糊查询)
|
||||||
|
- `status`: 状态(可选,0-失败, 1-成功, 2-发送中)
|
||||||
|
|
||||||
|
**示例:**
|
||||||
|
```
|
||||||
|
GET /sms/logs?page=1&size=10&phone=138&status=1
|
||||||
|
```
|
||||||
|
|
||||||
|
**响应示例:**
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"resp_code": 0,
|
||||||
|
"resp_msg": "success",
|
||||||
|
"datas": {
|
||||||
|
"records": [...],
|
||||||
|
"total": 100,
|
||||||
|
"size": 10,
|
||||||
|
"current": 1,
|
||||||
|
"pages": 10
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## 短信模板参数说明
|
||||||
|
|
||||||
|
### 腾讯云模板示例
|
||||||
|
|
||||||
|
**模板内容:**
|
||||||
|
```
|
||||||
|
{1}为您的登录验证码,请于{2}分钟内填写。如非本人操作,请忽略本短信。
|
||||||
|
```
|
||||||
|
|
||||||
|
**对应参数:**
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"params": {
|
||||||
|
"code": "123456", // {1} 验证码
|
||||||
|
"time": "5" // {2} 有效期(分钟)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### 阿里云模板示例
|
||||||
|
|
||||||
|
**模板内容:**
|
||||||
|
```
|
||||||
|
验证码${code},您正在进行身份验证,打死不告诉别人哦!有效期${time}分钟。
|
||||||
|
```
|
||||||
|
|
||||||
|
**对应参数:**
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"params": {
|
||||||
|
"code": "123456", // ${code} 验证码
|
||||||
|
"time": "5" // ${time} 有效期(分钟)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
**注意事项:**
|
||||||
|
- 腾讯云使用 `{1}`, `{2}` 这样的占位符,参数按顺序传入
|
||||||
|
- 阿里云使用 `${变量名}` 这样的占位符,参数需要使用JSON格式的key-value对
|
||||||
|
|
||||||
|
## 数据库表结构
|
||||||
|
|
||||||
|
### sms_send_log - 短信发送记录表
|
||||||
|
|
||||||
|
| 字段 | 类型 | 说明 |
|
||||||
|
|------|------|------|
|
||||||
|
| id | bigint | 主键ID |
|
||||||
|
| phone | varchar(20) | 手机号 |
|
||||||
|
| template_id | varchar(50) | 短信模板ID |
|
||||||
|
| template_params | varchar(500) | 模板参数(JSON格式) |
|
||||||
|
| content | varchar(500) | 短信内容 |
|
||||||
|
| status | tinyint | 发送状态: 0-失败, 1-成功, 2-发送中 |
|
||||||
|
| provider | varchar(20) | 服务商: TENCENT, ALIYUN |
|
||||||
|
| request_id | varchar(100) | 服务商返回的请求ID |
|
||||||
|
| response_code | varchar(50) | 服务商返回的状态码 |
|
||||||
|
| response_message | varchar(200) | 服务商返回的消息 |
|
||||||
|
| error_message | varchar(500) | 错误信息 |
|
||||||
|
| tenant_id | varchar(32) | 租户ID |
|
||||||
|
| create_time | datetime | 创建时间 |
|
||||||
|
| update_time | datetime | 更新时间 |
|
||||||
|
|
||||||
|
## 项目结构
|
||||||
|
|
||||||
|
```
|
||||||
|
msg-center/
|
||||||
|
├── db/
|
||||||
|
│ └── init.sql # 数据库初始化脚本
|
||||||
|
├── src/
|
||||||
|
│ └── main/
|
||||||
|
│ ├── java/com/central/
|
||||||
|
│ │ ├── MsgCenterApp.java # 启动类
|
||||||
|
│ │ └── msg/
|
||||||
|
│ │ ├── config/
|
||||||
|
│ │ │ └── SmsConfig.java
|
||||||
|
│ │ ├── controller/
|
||||||
|
│ │ │ └── SmsController.java
|
||||||
|
│ │ ├── mapper/
|
||||||
|
│ │ │ └── SmsSendLogMapper.java
|
||||||
|
│ │ ├── model/
|
||||||
|
│ │ │ ├── dto/
|
||||||
|
│ │ │ │ ├── SmsRequest.java
|
||||||
|
│ │ │ │ └── SmsResponse.java
|
||||||
|
│ │ │ └── entity/
|
||||||
|
│ │ │ └── SmsSendLog.java
|
||||||
|
│ │ └── service/
|
||||||
|
│ │ ├── MsgSmsService.java
|
||||||
|
│ │ └── impl/
|
||||||
|
│ │ └── MsgSmsServiceImpl.java
|
||||||
|
│ └── resources/
|
||||||
|
│ ├── application.yml # 配置文件
|
||||||
|
│ ├── bootstrap.yml # 服务名称配置
|
||||||
|
│ └── mapper/
|
||||||
|
│ └── SmsSendLogMapper.xml
|
||||||
|
├── Dockerfile # Docker镜像构建文件
|
||||||
|
├── pom.xml # Maven配置
|
||||||
|
└── README.md # 本文档
|
||||||
|
```
|
||||||
|
|
||||||
|
## 常见问题
|
||||||
|
|
||||||
|
### 1. 短信发送失败
|
||||||
|
|
||||||
|
**可能原因:**
|
||||||
|
- 配置参数错误(检查各项配置是否正确)
|
||||||
|
- 签名未审核通过
|
||||||
|
- 模板未审核通过
|
||||||
|
- 账户余额不足
|
||||||
|
- 手机号格式错误
|
||||||
|
- 发送频率过高(部分运营商有限制)
|
||||||
|
|
||||||
|
**解决方法:**
|
||||||
|
- 查看日志中的详细错误信息
|
||||||
|
- 登录服务商控制台检查签名和模板审核状态
|
||||||
|
- 确认账户余额充足
|
||||||
|
- 检查手机号格式是否正确
|
||||||
|
- 调整发送频率
|
||||||
|
|
||||||
|
### 2. 数据库连接失败
|
||||||
|
|
||||||
|
确保在 `application.yml` 或 Nacos 配置中心配置了正确的数据库连接信息。
|
||||||
|
|
||||||
|
### 3. 如何在运行时切换短信服务商
|
||||||
|
|
||||||
|
**新版本:无需切换!**
|
||||||
|
|
||||||
|
现在你可以**同时使用阿里云和腾讯云**,只需调用不同的API接口即可:
|
||||||
|
|
||||||
|
- **阿里云短信:** `POST /sms/aliyun/send` 或 `POST /sms/aliyun/send-verify-code`
|
||||||
|
- **腾讯云短信:** `POST /sms/tencent/send` 或 `POST /sms/tencent/send-verify-code`
|
||||||
|
- **默认服务商:** `POST /sms/send` 或 `POST /sms/send-verify-code`(使用配置文件中的 `sms.provider`)
|
||||||
|
|
||||||
|
**使用场景示例:**
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# 某个服务需要使用阿里云发送营销短信
|
||||||
|
curl -X POST http://localhost:8080/sms/aliyun/send \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
-d '{
|
||||||
|
"phone": "13800138000",
|
||||||
|
"templateId": "SMS_123456789",
|
||||||
|
"params": {"code": "123456", "time": "5"}
|
||||||
|
}'
|
||||||
|
|
||||||
|
# 另一个服务需要使用腾讯云发送验证码
|
||||||
|
curl -X POST http://localhost:8080/sms/tencent/send-verify-code \
|
||||||
|
-d "phone=13900139000&code=654321"
|
||||||
|
```
|
||||||
|
|
||||||
|
**旧方法(仍然支持):**
|
||||||
|
|
||||||
|
如果你只想使用一个服务商,可以通过修改配置切换:
|
||||||
|
|
||||||
|
**方法一:修改配置文件**
|
||||||
|
```yaml
|
||||||
|
sms:
|
||||||
|
provider: ALIYUN # 将 TENCENT 改为 ALIYUN
|
||||||
|
```
|
||||||
|
|
||||||
|
**方法二:使用环境变量(推荐)**
|
||||||
|
```bash
|
||||||
|
export SMS_PROVIDER=ALIYUN
|
||||||
|
```
|
||||||
|
|
||||||
|
重启服务后生效。
|
||||||
|
|
||||||
|
### 4. 腾讯云和阿里云的区别
|
||||||
|
|
||||||
|
| 特性 | 腾讯云 | 阿里云 |
|
||||||
|
|------|--------|--------|
|
||||||
|
| 模板格式 | {1}, {2}, {3}... | ${变量名} |
|
||||||
|
| 参数格式 | 数组形式,按顺序 | JSON键值对 |
|
||||||
|
| 手机号格式 | 需要+86前缀 | 直接手机号 |
|
||||||
|
| SDK包名 | tencentcloud-sdk-java | aliyun-java-sdk-dysmsapi |
|
||||||
|
|
||||||
|
### 5. 如何同时配置两个服务商并分别调用
|
||||||
|
|
||||||
|
**现在已经默认支持!** 无需任何特殊配置。
|
||||||
|
|
||||||
|
只需在配置文件中同时配置腾讯云和阿里云的参数:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
sms:
|
||||||
|
provider: TENCENT # 默认服务商(用于 /sms/send 接口)
|
||||||
|
|
||||||
|
tencent:
|
||||||
|
app-id: xxx
|
||||||
|
secret-id: xxx
|
||||||
|
secret-key: xxx
|
||||||
|
sign-name: xxx
|
||||||
|
verify-code-template-id: xxx
|
||||||
|
|
||||||
|
aliyun:
|
||||||
|
access-key-id: xxx
|
||||||
|
access-key-secret: xxx
|
||||||
|
sign-name: xxx
|
||||||
|
verify-code-template-id: xxx
|
||||||
|
```
|
||||||
|
|
||||||
|
**然后直接调用对应的API接口:**
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# 使用阿里云发送
|
||||||
|
POST /sms/aliyun/send
|
||||||
|
|
||||||
|
# 使用腾讯云发送
|
||||||
|
POST /sms/tencent/send
|
||||||
|
|
||||||
|
# 使用默认服务商(TENCENT)发送
|
||||||
|
POST /sms/send
|
||||||
|
```
|
||||||
|
|
||||||
|
**优势:**
|
||||||
|
- ✅ 不同服务可以选择不同的短信服务商
|
||||||
|
- ✅ 无需重启服务即可使用不同的服务商
|
||||||
|
- ✅ 可以根据成本、到达率等因素灵活选择
|
||||||
|
- ✅ 支持灾备切换(一个服务商故障时使用另一个)
|
||||||
|
|
||||||
|
**实际应用场景:**
|
||||||
|
|
||||||
|
```java
|
||||||
|
// 服务A:使用阿里云发送营销短信
|
||||||
|
POST /sms/aliyun/send
|
||||||
|
|
||||||
|
// 服务B:使用腾讯云发送验证码
|
||||||
|
POST /sms/tencent/send-verify-code
|
||||||
|
|
||||||
|
// 服务C:使用默认配置发送通知短信
|
||||||
|
POST /sms/send
|
||||||
|
```
|
||||||
|
|
||||||
|
## 开发计划
|
||||||
|
|
||||||
|
- [ ] 添加短信发送频率限制(防刷)
|
||||||
|
- [ ] 添加短信发送统计报表
|
||||||
|
- [ ] 支持批量发送短信
|
||||||
|
- [ ] 添加短信发送队列(异步发送)
|
||||||
|
- [ ] 支持更多短信服务商(华为云、七牛云等)
|
||||||
|
- [ ] 添加邮件发送功能
|
||||||
|
- [ ] 添加消息模板管理
|
||||||
|
- [ ] 添加短信发送失败重试机制
|
||||||
|
|
||||||
|
## 技术栈
|
||||||
|
|
||||||
|
- Spring Boot 3.1.6
|
||||||
|
- Spring Cloud
|
||||||
|
- MyBatis Plus 3.5.4
|
||||||
|
- 腾讯云短信 SDK 3.1.1040
|
||||||
|
- 阿里云短信 SDK 2.1.0
|
||||||
|
- MySQL 8.0
|
||||||
|
- Redis 7.0
|
||||||
|
- Nacos (服务注册与配置中心)
|
||||||
|
|
||||||
|
## 联系方式
|
||||||
|
|
||||||
|
如有问题,请提交 Issue 或联系开发团队。
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
-- =============================================
|
||||||
|
-- 消息中心 - 短信发送记录表
|
||||||
|
-- =============================================
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS `sms_send_log` (
|
||||||
|
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键ID',
|
||||||
|
`phone` varchar(20) NOT NULL COMMENT '手机号',
|
||||||
|
`template_id` varchar(50) NOT NULL COMMENT '短信模板ID',
|
||||||
|
`template_params` varchar(500) DEFAULT NULL COMMENT '模板参数(JSON格式)',
|
||||||
|
`content` varchar(500) DEFAULT NULL COMMENT '短信内容',
|
||||||
|
`status` tinyint(4) NOT NULL DEFAULT '2' COMMENT '发送状态: 0-失败, 1-成功, 2-发送中',
|
||||||
|
`provider` varchar(20) NOT NULL DEFAULT 'TENCENT' COMMENT '服务商: TENCENT, ALIYUN',
|
||||||
|
`request_id` varchar(100) DEFAULT NULL COMMENT '服务商返回的请求ID',
|
||||||
|
`response_code` varchar(50) DEFAULT NULL COMMENT '服务商返回的状态码',
|
||||||
|
`response_message` varchar(200) DEFAULT NULL COMMENT '服务商返回的消息',
|
||||||
|
`error_message` varchar(500) DEFAULT NULL COMMENT '错误信息',
|
||||||
|
`tenant_id` varchar(32) DEFAULT NULL COMMENT '租户ID',
|
||||||
|
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||||
|
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||||
|
PRIMARY KEY (`id`),
|
||||||
|
KEY `idx_phone` (`phone`),
|
||||||
|
KEY `idx_template_id` (`template_id`),
|
||||||
|
KEY `idx_create_time` (`create_time`),
|
||||||
|
KEY `idx_status` (`status`),
|
||||||
|
KEY `idx_tenant_id` (`tenant_id`)
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='短信发送记录表';
|
||||||
@@ -0,0 +1,130 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<parent>
|
||||||
|
<groupId>com.zlt</groupId>
|
||||||
|
<artifactId>zlt-business</artifactId>
|
||||||
|
<version>6.0.0</version>
|
||||||
|
</parent>
|
||||||
|
<artifactId>msg-center</artifactId>
|
||||||
|
<description>消息中心</description>
|
||||||
|
<dependencies>
|
||||||
|
<!-- 公共实体类模块 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.zlt</groupId>
|
||||||
|
<artifactId>zlt-config</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.zlt</groupId>
|
||||||
|
<artifactId>zlt-log-spring-boot-starter</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.zlt</groupId>
|
||||||
|
<artifactId>zlt-common-spring-boot-starter</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.zlt</groupId>
|
||||||
|
<artifactId>zlt-db-spring-boot-starter</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.zlt</groupId>
|
||||||
|
<artifactId>zlt-redis-spring-boot-starter</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.zlt</groupId>
|
||||||
|
<artifactId>zlt-loadbalancer-spring-boot-starter</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.zlt</groupId>
|
||||||
|
<artifactId>zlt-sentinel-spring-boot-starter</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<!-- swagger -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.xiaoymin</groupId>
|
||||||
|
<artifactId>knife4j-openapi3-jakarta-spring-boot-starter</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-web</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>mysql</groupId>
|
||||||
|
<artifactId>mysql-connector-java</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.micrometer</groupId>
|
||||||
|
<artifactId>micrometer-registry-prometheus</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>junit</groupId>
|
||||||
|
<artifactId>junit</artifactId>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.hibernate</groupId>
|
||||||
|
<artifactId>hibernate-validator</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- 短信服务 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.zlt</groupId>
|
||||||
|
<artifactId>zlt-sms-spring-boot-starter</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<goals>
|
||||||
|
<goal>repackage</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>com.spotify</groupId>
|
||||||
|
<artifactId>docker-maven-plugin</artifactId>
|
||||||
|
<configuration>
|
||||||
|
<imageName>${docker.image.prefix}/${project.artifactId}</imageName>
|
||||||
|
<imageTags>
|
||||||
|
<imageTag>${project.version}</imageTag>
|
||||||
|
<imageTag>latest</imageTag>
|
||||||
|
</imageTags>
|
||||||
|
<forceTags>true</forceTags>
|
||||||
|
<baseImage>${docker.baseImage}</baseImage>
|
||||||
|
<volumes>${docker.volumes}</volumes>
|
||||||
|
<env>
|
||||||
|
<JAVA_OPTS>${docker.java.opts}</JAVA_OPTS>
|
||||||
|
</env>
|
||||||
|
<entryPoint>["sh","-c","java $JAVA_OPTS ${docker.java.security.egd} -jar /${project.build.finalName}.jar"]</entryPoint>
|
||||||
|
<resources>
|
||||||
|
<resource>
|
||||||
|
<targetPath>/</targetPath>
|
||||||
|
<directory>${project.build.directory}</directory>
|
||||||
|
<include>${project.build.finalName}.jar</include>
|
||||||
|
</resource>
|
||||||
|
</resources>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
<finalName>${project.artifactId}</finalName>
|
||||||
|
</build>
|
||||||
|
</project>
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
package com.central;
|
||||||
|
|
||||||
|
import com.central.common.lb.annotation.EnableFeignInterceptor;
|
||||||
|
import org.springframework.boot.SpringApplication;
|
||||||
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
|
||||||
|
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 消息中心启动类
|
||||||
|
* @author system
|
||||||
|
*/
|
||||||
|
@EnableDiscoveryClient
|
||||||
|
@EnableTransactionManagement
|
||||||
|
@EnableFeignInterceptor
|
||||||
|
@SpringBootApplication
|
||||||
|
public class MsgCenterApp {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
SpringApplication.run(MsgCenterApp.class, args);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
package com.central.msg.config;
|
||||||
|
|
||||||
|
import com.central.sms.config.SmsProperties;
|
||||||
|
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 短信配置类
|
||||||
|
* @author system
|
||||||
|
*/
|
||||||
|
@Configuration
|
||||||
|
@EnableConfigurationProperties(SmsProperties.class)
|
||||||
|
public class SmsConfig {
|
||||||
|
}
|
||||||
@@ -0,0 +1,220 @@
|
|||||||
|
package com.central.msg.controller;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.central.common.model.Result;
|
||||||
|
import com.central.msg.model.dto.SmsRequest;
|
||||||
|
import com.central.msg.model.dto.SmsResponse;
|
||||||
|
import com.central.msg.model.entity.SmsSendLog;
|
||||||
|
import com.central.msg.service.MsgSmsService;
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
import io.swagger.v3.oas.annotations.Parameter;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import jakarta.validation.Valid;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 短信发送Controller
|
||||||
|
* @author system
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/sms")
|
||||||
|
@Tag(name = "短信服务", description = "短信发送相关接口")
|
||||||
|
public class SmsController {
|
||||||
|
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger(SmsController.class);
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private MsgSmsService msgSmsService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发送短信(使用默认服务商)
|
||||||
|
*/
|
||||||
|
@PostMapping("/send")
|
||||||
|
@Operation(summary = "发送短信", description = "使用默认服务商发送模板短信")
|
||||||
|
public Result<SmsResponse> sendSms(@Valid @RequestBody SmsRequest request) {
|
||||||
|
logger.info("收到短信发送请求: {}", request);
|
||||||
|
|
||||||
|
try {
|
||||||
|
boolean success = msgSmsService.sendSms(
|
||||||
|
request.getPhone(),
|
||||||
|
request.getTemplateId(),
|
||||||
|
request.getParams()
|
||||||
|
);
|
||||||
|
|
||||||
|
if (success) {
|
||||||
|
SmsResponse response = new SmsResponse(true, "短信发送成功");
|
||||||
|
return Result.succeed(response);
|
||||||
|
} else {
|
||||||
|
SmsResponse response = new SmsResponse(false, "短信发送失败");
|
||||||
|
return Result.failed(response,"短信发送失败!");
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("短信发送异常: {}", e.getMessage(), e);
|
||||||
|
SmsResponse response = new SmsResponse(false, "短信发送异常: " + e.getMessage());
|
||||||
|
return Result.failed(response,"短信发送失败!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发送阿里云短信
|
||||||
|
*/
|
||||||
|
@PostMapping("/aliyun/send")
|
||||||
|
@Operation(summary = "发送阿里云短信", description = "使用阿里云发送模板短信")
|
||||||
|
public Result<SmsResponse> sendAliyunSms(@Valid @RequestBody SmsRequest request) {
|
||||||
|
logger.info("收到阿里云短信发送请求: {}", request);
|
||||||
|
|
||||||
|
try {
|
||||||
|
boolean success = msgSmsService.sendAliyunSms(
|
||||||
|
request.getPhone(),
|
||||||
|
request.getTemplateId(),
|
||||||
|
request.getParams()
|
||||||
|
);
|
||||||
|
|
||||||
|
if (success) {
|
||||||
|
SmsResponse response = new SmsResponse(true, "阿里云短信发送成功");
|
||||||
|
return Result.succeed(response);
|
||||||
|
} else {
|
||||||
|
SmsResponse response = new SmsResponse(false, "阿里云短信发送失败");
|
||||||
|
return Result.failed(response,"短信发送失败!");
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("阿里云短信发送异常: {}", e.getMessage(), e);
|
||||||
|
SmsResponse response = new SmsResponse(false, "阿里云短信发送异常: " + e.getMessage());
|
||||||
|
return Result.failed(response,"短信发送失败!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发送腾讯云短信
|
||||||
|
*/
|
||||||
|
@PostMapping("/tencent/send")
|
||||||
|
@Operation(summary = "发送腾讯云短信", description = "使用腾讯云发送模板短信")
|
||||||
|
public Result<SmsResponse> sendTencentSms(@Valid @RequestBody SmsRequest request) {
|
||||||
|
logger.info("收到腾讯云短信发送请求: {}", request);
|
||||||
|
|
||||||
|
try {
|
||||||
|
boolean success = msgSmsService.sendTencentSms(
|
||||||
|
request.getPhone(),
|
||||||
|
request.getTemplateId(),
|
||||||
|
request.getParams()
|
||||||
|
);
|
||||||
|
|
||||||
|
if (success) {
|
||||||
|
SmsResponse response = new SmsResponse(true, "腾讯云短信发送成功");
|
||||||
|
return Result.succeed(response);
|
||||||
|
} else {
|
||||||
|
SmsResponse response = new SmsResponse(false, "腾讯云短信发送失败");
|
||||||
|
return Result.failed(response,"短信发送失败!");
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("腾讯云短信发送异常: {}", e.getMessage(), e);
|
||||||
|
SmsResponse response = new SmsResponse(false, "腾讯云短信发送异常: " + e.getMessage());
|
||||||
|
return Result.failed(response,"短信发送失败!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发送验证码(使用默认服务商)
|
||||||
|
*/
|
||||||
|
@PostMapping("/send-verify-code")
|
||||||
|
@Operation(summary = "发送验证码", description = "使用默认服务商发送验证码短信")
|
||||||
|
public Result<SmsResponse> sendVerifyCode(
|
||||||
|
@Parameter(description = "手机号", required = true) @RequestParam("phone") String phone,
|
||||||
|
@Parameter(description = "验证码", required = true) @RequestParam("code") String code) {
|
||||||
|
logger.info("收到验证码发送请求: phone={}, code={}", phone, code);
|
||||||
|
|
||||||
|
try {
|
||||||
|
boolean success = msgSmsService.sendVerifyCode(phone, code);
|
||||||
|
|
||||||
|
if (success) {
|
||||||
|
SmsResponse response = new SmsResponse(true, "验证码发送成功");
|
||||||
|
return Result.succeed(response);
|
||||||
|
} else {
|
||||||
|
SmsResponse response = new SmsResponse(false, "验证码发送失败");
|
||||||
|
return Result.failed(response,"短信发送失败!");
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("验证码发送异常: {}", e.getMessage(), e);
|
||||||
|
SmsResponse response = new SmsResponse(false, "验证码发送异常: " + e.getMessage());
|
||||||
|
return Result.failed(response,"短信发送失败!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发送阿里云验证码
|
||||||
|
*/
|
||||||
|
@PostMapping("/aliyun/send-verify-code")
|
||||||
|
@Operation(summary = "发送阿里云验证码", description = "使用阿里云发送验证码短信")
|
||||||
|
public Result<SmsResponse> sendAliyunVerifyCode(
|
||||||
|
@Parameter(description = "手机号", required = true) @RequestParam("phone") String phone,
|
||||||
|
@Parameter(description = "验证码", required = true) @RequestParam("code") String code) {
|
||||||
|
logger.info("收到阿里云验证码发送请求: phone={}, code={}", phone, code);
|
||||||
|
|
||||||
|
try {
|
||||||
|
boolean success = msgSmsService.sendAliyunVerifyCode(phone, code);
|
||||||
|
|
||||||
|
if (success) {
|
||||||
|
SmsResponse response = new SmsResponse(true, "阿里云验证码发送成功");
|
||||||
|
return Result.succeed(response);
|
||||||
|
} else {
|
||||||
|
SmsResponse response = new SmsResponse(false, "阿里云验证码发送失败");
|
||||||
|
return Result.failed(response,"短信发送失败!");
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("阿里云验证码发送异常: {}", e.getMessage(), e);
|
||||||
|
SmsResponse response = new SmsResponse(false, "阿里云验证码发送异常: " + e.getMessage());
|
||||||
|
return Result.failed(response,"短信发送失败!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发送腾讯云验证码
|
||||||
|
*/
|
||||||
|
@PostMapping("/tencent/send-verify-code")
|
||||||
|
@Operation(summary = "发送腾讯云验证码", description = "使用腾讯云发送验证码短信")
|
||||||
|
public Result<SmsResponse> sendTencentVerifyCode(
|
||||||
|
@Parameter(description = "手机号", required = true) @RequestParam("phone") String phone,
|
||||||
|
@Parameter(description = "验证码", required = true) @RequestParam("code") String code) {
|
||||||
|
logger.info("收到腾讯云验证码发送请求: phone={}, code={}", phone, code);
|
||||||
|
|
||||||
|
try {
|
||||||
|
boolean success = msgSmsService.sendTencentVerifyCode(phone, code);
|
||||||
|
|
||||||
|
if (success) {
|
||||||
|
SmsResponse response = new SmsResponse(true, "腾讯云验证码发送成功");
|
||||||
|
return Result.succeed(response);
|
||||||
|
} else {
|
||||||
|
SmsResponse response = new SmsResponse(false, "腾讯云验证码发送失败");
|
||||||
|
return Result.failed(response,"短信发送失败!");
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("腾讯云验证码发送异常: {}", e.getMessage(), e);
|
||||||
|
SmsResponse response = new SmsResponse(false, "腾讯云验证码发送异常: " + e.getMessage());
|
||||||
|
return Result.failed(response,"短信发送失败!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询短信发送记录
|
||||||
|
*/
|
||||||
|
@GetMapping("/logs")
|
||||||
|
@Operation(summary = "查询短信发送记录", description = "分页查询短信发送记录")
|
||||||
|
public Result<Page<SmsSendLog>> querySmsSendLog(
|
||||||
|
@Parameter(description = "当前页", required = true) @RequestParam(value = "page", defaultValue = "1") int page,
|
||||||
|
@Parameter(description = "每页大小", required = true) @RequestParam(value = "size", defaultValue = "10") int size,
|
||||||
|
@Parameter(description = "手机号") @RequestParam(value = "phone", required = false) String phone,
|
||||||
|
@Parameter(description = "状态: 0-失败, 1-成功, 2-发送中") @RequestParam(value = "status", required = false) Integer status) {
|
||||||
|
logger.info("查询短信发送记录: page={}, size={}, phone={}, status={}", page, size, phone, status);
|
||||||
|
|
||||||
|
try {
|
||||||
|
Page<SmsSendLog> result = msgSmsService.querySmsSendLog(page, size, phone, status);
|
||||||
|
return Result.succeed(result);
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("查询短信发送记录异常: {}", e.getMessage(), e);
|
||||||
|
return Result.failed("查询失败: " + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
package com.central.msg.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.central.msg.model.entity.SmsSendLog;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 短信发送记录Mapper
|
||||||
|
* @author system
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface SmsSendLogMapper extends BaseMapper<SmsSendLog> {
|
||||||
|
}
|
||||||
@@ -0,0 +1,60 @@
|
|||||||
|
package com.central.msg.model.dto;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import jakarta.validation.constraints.NotBlank;
|
||||||
|
import jakarta.validation.constraints.Pattern;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 短信发送请求DTO
|
||||||
|
* @author system
|
||||||
|
*/
|
||||||
|
@Schema(description = "短信发送请求")
|
||||||
|
public class SmsRequest {
|
||||||
|
|
||||||
|
@Schema(description = "手机号", required = true, example = "13800138000")
|
||||||
|
@NotBlank(message = "手机号不能为空")
|
||||||
|
@Pattern(regexp = "^1[3-9]\\d{9}$", message = "手机号格式不正确")
|
||||||
|
private String phone;
|
||||||
|
|
||||||
|
@Schema(description = "短信模板ID", required = true, example = "123456")
|
||||||
|
@NotBlank(message = "模板ID不能为空")
|
||||||
|
private String templateId;
|
||||||
|
|
||||||
|
@Schema(description = "模板参数", example = "{\"code\":\"1234\",\"time\":\"5\"}")
|
||||||
|
private Map<String, String> params;
|
||||||
|
|
||||||
|
public String getPhone() {
|
||||||
|
return phone;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPhone(String phone) {
|
||||||
|
this.phone = phone;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTemplateId() {
|
||||||
|
return templateId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTemplateId(String templateId) {
|
||||||
|
this.templateId = templateId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<String, String> getParams() {
|
||||||
|
return params;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setParams(Map<String, String> params) {
|
||||||
|
this.params = params;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "SmsRequest{" +
|
||||||
|
"phone='" + phone + '\'' +
|
||||||
|
", templateId='" + templateId + '\'' +
|
||||||
|
", params=" + params +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,67 @@
|
|||||||
|
package com.central.msg.model.dto;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 短信发送响应DTO
|
||||||
|
* @author system
|
||||||
|
*/
|
||||||
|
@Schema(description = "短信发送响应")
|
||||||
|
public class SmsResponse {
|
||||||
|
|
||||||
|
@Schema(description = "是否成功")
|
||||||
|
private boolean success;
|
||||||
|
|
||||||
|
@Schema(description = "消息")
|
||||||
|
private String message;
|
||||||
|
|
||||||
|
@Schema(description = "请求ID")
|
||||||
|
private String requestId;
|
||||||
|
|
||||||
|
public SmsResponse() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public SmsResponse(boolean success, String message) {
|
||||||
|
this.success = success;
|
||||||
|
this.message = message;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SmsResponse(boolean success, String message, String requestId) {
|
||||||
|
this.success = success;
|
||||||
|
this.message = message;
|
||||||
|
this.requestId = requestId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isSuccess() {
|
||||||
|
return success;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSuccess(boolean success) {
|
||||||
|
this.success = success;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMessage() {
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMessage(String message) {
|
||||||
|
this.message = message;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getRequestId() {
|
||||||
|
return requestId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRequestId(String requestId) {
|
||||||
|
this.requestId = requestId;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "SmsResponse{" +
|
||||||
|
"success=" + success +
|
||||||
|
", message='" + message + '\'' +
|
||||||
|
", requestId='" + requestId + '\'' +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,91 @@
|
|||||||
|
package com.central.msg.model.entity;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 短信发送记录实体
|
||||||
|
* @author system
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@TableName("sms_send_log")
|
||||||
|
public class SmsSendLog implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 主键ID
|
||||||
|
*/
|
||||||
|
@TableId(value = "id", type = IdType.AUTO)
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 手机号
|
||||||
|
*/
|
||||||
|
private String phone;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 短信模板ID
|
||||||
|
*/
|
||||||
|
private String templateId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 模板参数(JSON格式)
|
||||||
|
*/
|
||||||
|
private String templateParams;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 短信内容
|
||||||
|
*/
|
||||||
|
private String content;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发送状态: 0-失败, 1-成功, 2-发送中
|
||||||
|
*/
|
||||||
|
private Integer status;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 服务商: TENCENT, ALIYUN
|
||||||
|
*/
|
||||||
|
private String provider;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 服务商返回的请求ID
|
||||||
|
*/
|
||||||
|
private String requestId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 服务商返回的状态码
|
||||||
|
*/
|
||||||
|
private String responseCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 服务商返回的消息
|
||||||
|
*/
|
||||||
|
private String responseMessage;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 错误信息
|
||||||
|
*/
|
||||||
|
private String errorMessage;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 租户ID
|
||||||
|
*/
|
||||||
|
private String tenantId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建时间
|
||||||
|
*/
|
||||||
|
private Date createTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新时间
|
||||||
|
*/
|
||||||
|
private Date updateTime;
|
||||||
|
}
|
||||||
@@ -0,0 +1,94 @@
|
|||||||
|
package com.central.msg.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.central.msg.model.entity.SmsSendLog;
|
||||||
|
import com.central.sms.enums.SmsProviderType;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 消息中心短信服务接口
|
||||||
|
* @author system
|
||||||
|
*/
|
||||||
|
public interface MsgSmsService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发送短信(使用默认服务商)
|
||||||
|
* @param phone 手机号
|
||||||
|
* @param templateId 模板ID
|
||||||
|
* @param params 模板参数
|
||||||
|
* @return 是否发送成功
|
||||||
|
*/
|
||||||
|
boolean sendSms(String phone, String templateId, Map<String, String> params);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发送短信(指定服务商)
|
||||||
|
* @param phone 手机号
|
||||||
|
* @param templateId 模板ID
|
||||||
|
* @param params 模板参数
|
||||||
|
* @param provider 服务商类型
|
||||||
|
* @return 是否发送成功
|
||||||
|
*/
|
||||||
|
boolean sendSms(String phone, String templateId, Map<String, String> params, SmsProviderType provider);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发送阿里云短信
|
||||||
|
* @param phone 手机号
|
||||||
|
* @param templateId 模板ID
|
||||||
|
* @param params 模板参数
|
||||||
|
* @return 是否发送成功
|
||||||
|
*/
|
||||||
|
boolean sendAliyunSms(String phone, String templateId, Map<String, String> params);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发送腾讯云短信
|
||||||
|
* @param phone 手机号
|
||||||
|
* @param templateId 模板ID
|
||||||
|
* @param params 模板参数
|
||||||
|
* @return 是否发送成功
|
||||||
|
*/
|
||||||
|
boolean sendTencentSms(String phone, String templateId, Map<String, String> params);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发送验证码短信(使用默认服务商)
|
||||||
|
* @param phone 手机号
|
||||||
|
* @param code 验证码
|
||||||
|
* @return 是否发送成功
|
||||||
|
*/
|
||||||
|
boolean sendVerifyCode(String phone, String code);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发送验证码短信(指定服务商)
|
||||||
|
* @param phone 手机号
|
||||||
|
* @param code 验证码
|
||||||
|
* @param provider 服务商类型
|
||||||
|
* @return 是否发送成功
|
||||||
|
*/
|
||||||
|
boolean sendVerifyCode(String phone, String code, SmsProviderType provider);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发送阿里云验证码
|
||||||
|
* @param phone 手机号
|
||||||
|
* @param code 验证码
|
||||||
|
* @return 是否发送成功
|
||||||
|
*/
|
||||||
|
boolean sendAliyunVerifyCode(String phone, String code);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发送腾讯云验证码
|
||||||
|
* @param phone 手机号
|
||||||
|
* @param code 验证码
|
||||||
|
* @return 是否发送成功
|
||||||
|
*/
|
||||||
|
boolean sendTencentVerifyCode(String phone, String code);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页查询短信发送记录
|
||||||
|
* @param page 当前页
|
||||||
|
* @param size 每页大小
|
||||||
|
* @param phone 手机号(可选)
|
||||||
|
* @param status 状态(可选)
|
||||||
|
* @return 分页数据
|
||||||
|
*/
|
||||||
|
Page<SmsSendLog> querySmsSendLog(int page, int size, String phone, Integer status);
|
||||||
|
}
|
||||||
+205
@@ -0,0 +1,205 @@
|
|||||||
|
package com.central.msg.service.impl;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.central.msg.mapper.SmsSendLogMapper;
|
||||||
|
import com.central.msg.model.entity.SmsSendLog;
|
||||||
|
import com.central.msg.service.MsgSmsService;
|
||||||
|
import com.central.sms.config.SmsProperties;
|
||||||
|
import com.central.sms.enums.SmsProviderType;
|
||||||
|
import com.central.sms.service.ISmsService;
|
||||||
|
import com.central.sms.service.impl.AliyunSmsService;
|
||||||
|
import com.central.sms.service.impl.TencentSmsService;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 消息中心短信服务实现类
|
||||||
|
* @author system
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class MsgSmsServiceImpl implements MsgSmsService {
|
||||||
|
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger(MsgSmsServiceImpl.class);
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private AliyunSmsService aliyunSmsService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private TencentSmsService tencentSmsService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SmsSendLogMapper smsSendLogMapper;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SmsProperties smsProperties;
|
||||||
|
|
||||||
|
@Value("${sms.save-log:true}")
|
||||||
|
private boolean saveLog;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean sendSms(String phone, String templateId, Map<String, String> params) {
|
||||||
|
return sendSms(phone, templateId, params, smsProperties.getProvider());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean sendSms(String phone, String templateId, Map<String, String> params, SmsProviderType provider) {
|
||||||
|
SmsSendLog log = new SmsSendLog();
|
||||||
|
log.setPhone(phone);
|
||||||
|
log.setTemplateId(templateId);
|
||||||
|
log.setTemplateParams(params != null ? JSON.toJSONString(params) : null);
|
||||||
|
log.setProvider(provider.name());
|
||||||
|
log.setCreateTime(new Date());
|
||||||
|
log.setUpdateTime(new Date());
|
||||||
|
|
||||||
|
try {
|
||||||
|
logger.info("开始发送短信: phone={}, templateId={}, params={}, provider={}",
|
||||||
|
phone, templateId, params, provider);
|
||||||
|
log.setStatus(2); // 发送中
|
||||||
|
|
||||||
|
ISmsService smsService = getSmsService(provider);
|
||||||
|
boolean result = smsService.sendSms(phone, templateId, params);
|
||||||
|
|
||||||
|
if (result) {
|
||||||
|
logger.info("短信发送成功: phone={}, templateId={}, provider={}", phone, templateId, provider);
|
||||||
|
log.setStatus(1); // 成功
|
||||||
|
log.setResponseCode("Ok");
|
||||||
|
log.setResponseMessage("发送成功");
|
||||||
|
} else {
|
||||||
|
logger.warn("短信发送失败: phone={}, templateId={}, provider={}", phone, templateId, provider);
|
||||||
|
log.setStatus(0); // 失败
|
||||||
|
log.setResponseCode("Failed");
|
||||||
|
log.setResponseMessage("发送失败");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 保存发送记录
|
||||||
|
if (saveLog) {
|
||||||
|
saveSendLog(log);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("短信发送异常: phone={}, templateId={}, provider={}, error={}",
|
||||||
|
phone, templateId, provider, e.getMessage(), e);
|
||||||
|
log.setStatus(0); // 失败
|
||||||
|
log.setErrorMessage(e.getMessage());
|
||||||
|
log.setResponseMessage("发送异常: " + e.getMessage());
|
||||||
|
|
||||||
|
// 保存发送记录
|
||||||
|
if (saveLog) {
|
||||||
|
saveSendLog(log);
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean sendAliyunSms(String phone, String templateId, Map<String, String> params) {
|
||||||
|
return sendSms(phone, templateId, params, SmsProviderType.ALIYUN);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean sendTencentSms(String phone, String templateId, Map<String, String> params) {
|
||||||
|
return sendSms(phone, templateId, params, SmsProviderType.TENCENT);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean sendVerifyCode(String phone, String code) {
|
||||||
|
return sendVerifyCode(phone, code, smsProperties.getProvider());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean sendVerifyCode(String phone, String code, SmsProviderType provider) {
|
||||||
|
String templateId = getVerifyCodeTemplateId(provider);
|
||||||
|
if (templateId == null || templateId.isEmpty()) {
|
||||||
|
logger.error("{}验证码模板ID未配置,无法发送验证码短信", provider.name());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, String> params = new HashMap<>();
|
||||||
|
params.put("code", code);
|
||||||
|
params.put("time", "5"); // 默认5分钟有效期
|
||||||
|
|
||||||
|
return sendSms(phone, templateId, params, provider);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean sendAliyunVerifyCode(String phone, String code) {
|
||||||
|
return sendVerifyCode(phone, code, SmsProviderType.ALIYUN);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean sendTencentVerifyCode(String phone, String code) {
|
||||||
|
return sendVerifyCode(phone, code, SmsProviderType.TENCENT);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Page<SmsSendLog> querySmsSendLog(int page, int size, String phone, Integer status) {
|
||||||
|
Page<SmsSendLog> pageParam = new Page<>(page, size);
|
||||||
|
|
||||||
|
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper<SmsSendLog> wrapper =
|
||||||
|
new com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper<>();
|
||||||
|
|
||||||
|
// 手机号模糊查询
|
||||||
|
if (phone != null && !phone.isEmpty()) {
|
||||||
|
wrapper.like(SmsSendLog::getPhone, phone);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 状态查询
|
||||||
|
if (status != null) {
|
||||||
|
wrapper.eq(SmsSendLog::getStatus, status);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 按创建时间倒序
|
||||||
|
wrapper.orderByDesc(SmsSendLog::getCreateTime);
|
||||||
|
|
||||||
|
return smsSendLogMapper.selectPage(pageParam, wrapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据服务商类型获取短信服务实例
|
||||||
|
*/
|
||||||
|
private ISmsService getSmsService(SmsProviderType provider) {
|
||||||
|
switch (provider) {
|
||||||
|
case ALIYUN:
|
||||||
|
return aliyunSmsService;
|
||||||
|
case TENCENT:
|
||||||
|
default:
|
||||||
|
return tencentSmsService;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取验证码模板ID
|
||||||
|
*/
|
||||||
|
private String getVerifyCodeTemplateId(SmsProviderType provider) {
|
||||||
|
switch (provider) {
|
||||||
|
case ALIYUN:
|
||||||
|
return smsProperties.getAliyun().getVerifyCodeTemplateId();
|
||||||
|
case TENCENT:
|
||||||
|
return smsProperties.getTencent().getVerifyCodeTemplateId();
|
||||||
|
default:
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 保存短信发送记录
|
||||||
|
*/
|
||||||
|
private void saveSendLog(SmsSendLog log) {
|
||||||
|
try {
|
||||||
|
smsSendLogMapper.insert(log);
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("保存短信发送记录失败: {}", e.getMessage(), e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,65 @@
|
|||||||
|
已配置在nacos中,此配置文件作废
|
||||||
|
# 消息中心配置文件
|
||||||
|
#spring:
|
||||||
|
# datasource:
|
||||||
|
# url: jdbc:mysql://${zlt.datasource.ip}/msg-center?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&useSSL=false&zeroDateTimeBehavior=convertToNull&serverTimezone=Asia/Shanghai
|
||||||
|
# username: ${zlt.datasource.username}
|
||||||
|
# password: ${zlt.datasource.password}
|
||||||
|
# driver-class-name: com.mysql.cj.jdbc.Driver
|
||||||
|
#
|
||||||
|
#mybatis-plus:
|
||||||
|
# mapper-locations: classpath:/mapper/*Mapper.xml
|
||||||
|
# type-aliases-package: com.central.msg.model.entity
|
||||||
|
# global-config:
|
||||||
|
# db-config:
|
||||||
|
# id-type: auto
|
||||||
|
#
|
||||||
|
#springdoc:
|
||||||
|
# group-configs:
|
||||||
|
# - group: 'default'
|
||||||
|
# paths-to-match: '/**'
|
||||||
|
# packages-to-scan: com.central.msg.controller
|
||||||
|
#
|
||||||
|
#knife4j:
|
||||||
|
# enable: true
|
||||||
|
# setting:
|
||||||
|
# swagger-model-name: 消息中心接口文档
|
||||||
|
#
|
||||||
|
## 短信服务配置
|
||||||
|
#sms:
|
||||||
|
# # 短信服务提供商: TENCENT(腾讯云) 或 ALIYUN(阿里云)
|
||||||
|
# # 默认提供商,用于未指定提供商的接口
|
||||||
|
# provider: ${SMS_PROVIDER :TENCENT}
|
||||||
|
#
|
||||||
|
# # 腾讯云短信配置
|
||||||
|
# tencent:
|
||||||
|
# # 腾讯云短信应用ID (在腾讯云短信控制台获取)
|
||||||
|
# app-id: 1401077992
|
||||||
|
# # 腾讯云SecretId (在腾讯云控制台获取)
|
||||||
|
# secret-id: AKIDuiNrAF7mETXO5au1vgFbjfOuCIG3cx62
|
||||||
|
# # 腾讯云SecretKey (在腾讯云控制台获取)
|
||||||
|
# secret-key: nMkvsb6OSJwQjphLlxxmQsAGF6kBGF3d
|
||||||
|
# # 短信签名 (在腾讯云短信控制台配置)
|
||||||
|
# sign-name: 北京高飞智航科技
|
||||||
|
# # 验证码模板ID
|
||||||
|
# verify-code-template-id: 2589777
|
||||||
|
#
|
||||||
|
# # 阿里云短信配置
|
||||||
|
# aliyun:
|
||||||
|
# # 阿里云AccessKeyId (在阿里云控制台获取)
|
||||||
|
# access-key-id: LTAI5tS3aRqJ4Et55s1g3Bkw
|
||||||
|
# # 阿里云AccessKeySecret (在阿里云控制台获取)
|
||||||
|
# access-key-secret: 0A7SumjhpzRmHEhK5aOkcysLu3zAcq
|
||||||
|
# # 短信签名 (在阿里云短信控制台配置)
|
||||||
|
# sign-name: 阿里云短信测试
|
||||||
|
# # 验证码模板ID
|
||||||
|
# verify-code-template-id: SMS_154950909
|
||||||
|
#
|
||||||
|
# # 是否保存短信发送记录到数据库
|
||||||
|
# save-log: ${SMS_SAVE_LOG:true}
|
||||||
|
#
|
||||||
|
## 多租户配置
|
||||||
|
#zlt:
|
||||||
|
# tenant:
|
||||||
|
# enable: true
|
||||||
|
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
spring:
|
||||||
|
application:
|
||||||
|
name: msg-center
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
<?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.msg.mapper.SmsSendLogMapper">
|
||||||
|
|
||||||
|
<resultMap id="BaseResultMap" type="com.central.msg.model.entity.SmsSendLog">
|
||||||
|
<id column="id" property="id"/>
|
||||||
|
<result column="phone" property="phone"/>
|
||||||
|
<result column="template_id" property="templateId"/>
|
||||||
|
<result column="template_params" property="templateParams"/>
|
||||||
|
<result column="content" property="content"/>
|
||||||
|
<result column="status" property="status"/>
|
||||||
|
<result column="provider" property="provider"/>
|
||||||
|
<result column="request_id" property="requestId"/>
|
||||||
|
<result column="response_code" property="responseCode"/>
|
||||||
|
<result column="response_message" property="responseMessage"/>
|
||||||
|
<result column="error_message" property="errorMessage"/>
|
||||||
|
<result column="tenant_id" property="tenantId"/>
|
||||||
|
<result column="create_time" property="createTime"/>
|
||||||
|
<result column="update_time" property="updateTime"/>
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
|
</mapper>
|
||||||
@@ -22,5 +22,7 @@
|
|||||||
<module>order-center</module>
|
<module>order-center</module>
|
||||||
<!-- 优惠券中心 -->
|
<!-- 优惠券中心 -->
|
||||||
<module>coupon-center</module>
|
<module>coupon-center</module>
|
||||||
|
<!-- 消息中心 -->
|
||||||
|
<module>msg-center</module>
|
||||||
</modules>
|
</modules>
|
||||||
</project>
|
</project>
|
||||||
|
|||||||
+12
@@ -120,6 +120,18 @@ public class SysUserController {
|
|||||||
return appUserService.findByOpenId(openId);
|
return appUserService.findByOpenId(openId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过手机号注册用户
|
||||||
|
*
|
||||||
|
* @param mobile 手机号
|
||||||
|
* @return 注册后的用户信息(包含openId)
|
||||||
|
*/
|
||||||
|
@PostMapping(value = "/users-anon/register/mobile")
|
||||||
|
@Operation(summary = "通过手机号注册用户")
|
||||||
|
public SysUser registerByMobile(@RequestParam("mobile") String mobile) throws Exception {
|
||||||
|
return appUserService.registerByMobile(mobile);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据WxOpenId查询用户信息
|
* 根据WxOpenId查询用户信息
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -116,4 +116,12 @@ public interface ISysUserService extends ISuperService<SysUser> {
|
|||||||
* @return 删除结果
|
* @return 删除结果
|
||||||
*/
|
*/
|
||||||
boolean completelyDeleteUser(Long userId);
|
boolean completelyDeleteUser(Long userId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过手机号注册用户
|
||||||
|
* @param mobile 手机号
|
||||||
|
* @return 注册后的用户信息(包含openId)
|
||||||
|
* @throws Exception 注册异常
|
||||||
|
*/
|
||||||
|
SysUser registerByMobile(String mobile) throws Exception;
|
||||||
}
|
}
|
||||||
|
|||||||
+37
@@ -449,4 +449,41 @@ public class SysUserServiceImpl extends SuperServiceImpl<SysUserMapper, SysUser>
|
|||||||
}
|
}
|
||||||
return sysUserExcels;
|
return sysUserExcels;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public SysUser registerByMobile(String mobile) throws Exception {
|
||||||
|
// 先检查手机号是否已注册
|
||||||
|
SysUser existUser = this.selectByMobile(mobile);
|
||||||
|
if (existUser != null) {
|
||||||
|
// 已存在,直接返回
|
||||||
|
return existUser;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 生成openId(使用UUID)
|
||||||
|
String openId = java.util.UUID.randomUUID().toString().replace("-", "");
|
||||||
|
|
||||||
|
// 创建新用户
|
||||||
|
SysUser sysUser = new SysUser();
|
||||||
|
sysUser.setMobile(mobile);
|
||||||
|
sysUser.setUsername(mobile); // 使用手机号作为用户名
|
||||||
|
sysUser.setOpenId(openId);
|
||||||
|
sysUser.setType(UserType.APP.name());
|
||||||
|
sysUser.setPassword(passwordEncoder.encode(openId)); // 使用openId作为初始密码
|
||||||
|
sysUser.setEnabled(Boolean.TRUE);
|
||||||
|
|
||||||
|
String username = sysUser.getUsername();
|
||||||
|
boolean result = super.saveOrUpdateIdempotency(sysUser, lock,
|
||||||
|
LOCK_KEY_USERNAME + username,
|
||||||
|
new QueryWrapper<SysUser>().eq("username", username),
|
||||||
|
username + "已存在");
|
||||||
|
|
||||||
|
if (result) {
|
||||||
|
log.info("通过手机号注册用户成功,mobile:{}, openId:{}", mobile, openId);
|
||||||
|
return sysUser;
|
||||||
|
} else {
|
||||||
|
log.error("通过手机号注册用户失败,mobile:{}", mobile);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+5
@@ -24,4 +24,9 @@ public interface ServiceNameConstants {
|
|||||||
String FILE_SERVICE = "file-center";
|
String FILE_SERVICE = "file-center";
|
||||||
|
|
||||||
String ORDER_SERVICE = "order-center";
|
String ORDER_SERVICE = "order-center";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 消息中心服务
|
||||||
|
*/
|
||||||
|
String MSG_SERVICE = "msg-center";
|
||||||
}
|
}
|
||||||
|
|||||||
+45
@@ -0,0 +1,45 @@
|
|||||||
|
package com.central.common.feign;
|
||||||
|
|
||||||
|
import com.central.common.constant.ServiceNameConstants;
|
||||||
|
import com.central.common.feign.fallback.MsgCenterServiceFallbackFactory;
|
||||||
|
import com.central.common.model.Result;
|
||||||
|
import org.springframework.cloud.openfeign.FeignClient;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 消息中心服务 Feign客户端
|
||||||
|
*/
|
||||||
|
@FeignClient(name = ServiceNameConstants.MSG_SERVICE, fallbackFactory = MsgCenterServiceFallbackFactory.class, dismiss404 = true)
|
||||||
|
public interface MsgCenterService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发送验证码短信(使用默认服务商)
|
||||||
|
*
|
||||||
|
* @param phone 手机号
|
||||||
|
* @param code 验证码
|
||||||
|
* @return 发送结果
|
||||||
|
*/
|
||||||
|
@PostMapping("/sms/send-verify-code")
|
||||||
|
Result<?> sendVerifyCode(@RequestParam("phone") String phone, @RequestParam("code") String code);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发送验证码短信(使用腾讯云)
|
||||||
|
*
|
||||||
|
* @param phone 手机号
|
||||||
|
* @param code 验证码
|
||||||
|
* @return 发送结果
|
||||||
|
*/
|
||||||
|
@PostMapping("/sms/tencent/send-verify-code")
|
||||||
|
Result<?> sendTencentVerifyCode(@RequestParam("phone") String phone, @RequestParam("code") String code);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发送验证码短信(使用阿里云)
|
||||||
|
*
|
||||||
|
* @param phone 手机号
|
||||||
|
* @param code 验证码
|
||||||
|
* @return 发送结果
|
||||||
|
*/
|
||||||
|
@PostMapping("/sms/aliyun/send-verify-code")
|
||||||
|
Result<?> sendAliyunVerifyCode(@RequestParam("phone") String phone, @RequestParam("code") String code);
|
||||||
|
}
|
||||||
@@ -8,6 +8,7 @@ import com.central.common.model.SysUser;
|
|||||||
import org.springframework.cloud.openfeign.FeignClient;
|
import org.springframework.cloud.openfeign.FeignClient;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -91,4 +92,13 @@ public interface UserService {
|
|||||||
*/
|
*/
|
||||||
@GetMapping(value = "/tenant/hierarchy/son/tenantId", params = "tenantId")
|
@GetMapping(value = "/tenant/hierarchy/son/tenantId", params = "tenantId")
|
||||||
List<String> getSonTenantIds(@RequestParam("tenantId") String tenantId);
|
List<String> getSonTenantIds(@RequestParam("tenantId") String tenantId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过手机号注册用户(返回用户信息,包含openId)
|
||||||
|
*
|
||||||
|
* @param mobile 手机号
|
||||||
|
* @return 注册后的用户信息
|
||||||
|
*/
|
||||||
|
@PostMapping(value = "/users-anon/register/mobile")
|
||||||
|
SysUser registerByMobile(@RequestParam("mobile") String mobile);
|
||||||
}
|
}
|
||||||
|
|||||||
+35
@@ -0,0 +1,35 @@
|
|||||||
|
package com.central.common.feign.fallback;
|
||||||
|
|
||||||
|
import com.central.common.feign.MsgCenterService;
|
||||||
|
import com.central.common.model.Result;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.cloud.openfeign.FallbackFactory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* MsgCenterService降级工厂
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
public class MsgCenterServiceFallbackFactory implements FallbackFactory<MsgCenterService> {
|
||||||
|
@Override
|
||||||
|
public MsgCenterService create(Throwable throwable) {
|
||||||
|
return new MsgCenterService() {
|
||||||
|
@Override
|
||||||
|
public Result<?> sendVerifyCode(String phone, String code) {
|
||||||
|
log.error("发送验证码短信异常, phone:{}", phone, throwable);
|
||||||
|
return Result.failed("短信服务不可用");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Result<?> sendTencentVerifyCode(String phone, String code) {
|
||||||
|
log.error("发送腾讯云验证码短信异常, phone:{}", phone, throwable);
|
||||||
|
return Result.failed("腾讯云短信服务不可用");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Result<?> sendAliyunVerifyCode(String phone, String code) {
|
||||||
|
log.error("发送阿里云验证码短信异常, phone:{}", phone, throwable);
|
||||||
|
return Result.failed("阿里云短信服务不可用");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
+6
@@ -89,6 +89,12 @@ public class UserServiceFallbackFactory implements FallbackFactory<UserService>
|
|||||||
log.error("获取自己以及子孙租户列表异常:{}", tenantId, throwable);
|
log.error("获取自己以及子孙租户列表异常:{}", tenantId, throwable);
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SysUser registerByMobile(String mobile) {
|
||||||
|
log.error("通过手机号注册用户异常:{}", mobile, throwable);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
@@ -1,2 +1,3 @@
|
|||||||
com.central.common.feign.fallback.UserServiceFallbackFactory
|
com.central.common.feign.fallback.UserServiceFallbackFactory
|
||||||
|
com.central.common.feign.fallback.MsgCenterServiceFallbackFactory
|
||||||
com.central.common.lock.LockAspect
|
com.central.common.lock.LockAspect
|
||||||
+12
@@ -21,6 +21,8 @@ public class SmsProperties {
|
|||||||
private String secretId;
|
private String secretId;
|
||||||
private String secretKey;
|
private String secretKey;
|
||||||
private String signName;
|
private String signName;
|
||||||
|
private String verifyCodeTemplateId;
|
||||||
|
|
||||||
public String getAppId() { return appId; }
|
public String getAppId() { return appId; }
|
||||||
public void setAppId(String appId) { this.appId = appId; }
|
public void setAppId(String appId) { this.appId = appId; }
|
||||||
public String getSecretId() { return secretId; }
|
public String getSecretId() { return secretId; }
|
||||||
@@ -29,17 +31,27 @@ public class SmsProperties {
|
|||||||
public void setSecretKey(String secretKey) { this.secretKey = secretKey; }
|
public void setSecretKey(String secretKey) { this.secretKey = secretKey; }
|
||||||
public String getSignName() { return signName; }
|
public String getSignName() { return signName; }
|
||||||
public void setSignName(String signName) { this.signName = signName; }
|
public void setSignName(String signName) { this.signName = signName; }
|
||||||
|
public String getVerifyCodeTemplateId() { return verifyCodeTemplateId; }
|
||||||
|
public void setVerifyCodeTemplateId(String verifyCodeTemplateId) {
|
||||||
|
this.verifyCodeTemplateId = verifyCodeTemplateId;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class AliyunConfig {
|
public static class AliyunConfig {
|
||||||
private String accessKeyId;
|
private String accessKeyId;
|
||||||
private String accessKeySecret;
|
private String accessKeySecret;
|
||||||
private String signName;
|
private String signName;
|
||||||
|
private String verifyCodeTemplateId;
|
||||||
|
|
||||||
public String getAccessKeyId() { return accessKeyId; }
|
public String getAccessKeyId() { return accessKeyId; }
|
||||||
public void setAccessKeyId(String accessKeyId) { this.accessKeyId = accessKeyId; }
|
public void setAccessKeyId(String accessKeyId) { this.accessKeyId = accessKeyId; }
|
||||||
public String getAccessKeySecret() { return accessKeySecret; }
|
public String getAccessKeySecret() { return accessKeySecret; }
|
||||||
public void setAccessKeySecret(String accessKeySecret) { this.accessKeySecret = accessKeySecret; }
|
public void setAccessKeySecret(String accessKeySecret) { this.accessKeySecret = accessKeySecret; }
|
||||||
public String getSignName() { return signName; }
|
public String getSignName() { return signName; }
|
||||||
public void setSignName(String signName) { this.signName = signName; }
|
public void setSignName(String signName) { this.signName = signName; }
|
||||||
|
public String getVerifyCodeTemplateId() { return verifyCodeTemplateId; }
|
||||||
|
public void setVerifyCodeTemplateId(String verifyCodeTemplateId) {
|
||||||
|
this.verifyCodeTemplateId = verifyCodeTemplateId;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+26
-6
@@ -1,5 +1,6 @@
|
|||||||
package com.central.sms.service.impl;
|
package com.central.sms.service.impl;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.aliyuncs.DefaultAcsClient;
|
import com.aliyuncs.DefaultAcsClient;
|
||||||
import com.aliyuncs.IAcsClient;
|
import com.aliyuncs.IAcsClient;
|
||||||
import com.aliyuncs.dysmsapi.model.v20170525.SendSmsRequest;
|
import com.aliyuncs.dysmsapi.model.v20170525.SendSmsRequest;
|
||||||
@@ -16,6 +17,10 @@ import org.springframework.stereotype.Service;
|
|||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 阿里云短信服务实现
|
||||||
|
* @author system
|
||||||
|
*/
|
||||||
@Service
|
@Service
|
||||||
public class AliyunSmsService implements ISmsService {
|
public class AliyunSmsService implements ISmsService {
|
||||||
|
|
||||||
@@ -26,30 +31,45 @@ public class AliyunSmsService implements ISmsService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean sendSms(String phone, String templateId, Map<String, String> params) {
|
public boolean sendSms(String phone, String templateId, Map<String, String> params) {
|
||||||
|
try {
|
||||||
SmsProperties.AliyunConfig config = smsProperties.getAliyun();
|
SmsProperties.AliyunConfig config = smsProperties.getAliyun();
|
||||||
|
logger.info("[短信发送][服务商:ALIYUN] 手机号={}, 模板ID={}, 参数={}", phone, templateId, params);
|
||||||
|
|
||||||
|
// 创建DefaultAcsClient实例并初始化
|
||||||
DefaultProfile profile = DefaultProfile.getProfile(
|
DefaultProfile profile = DefaultProfile.getProfile(
|
||||||
"cn-hangzhou", // 地域ID
|
"cn-hangzhou", // 地域ID,固定值
|
||||||
config.getAccessKeyId(),
|
config.getAccessKeyId(),
|
||||||
config.getAccessKeySecret()
|
config.getAccessKeySecret()
|
||||||
);
|
);
|
||||||
IAcsClient client = new DefaultAcsClient(profile);
|
IAcsClient client = new DefaultAcsClient(profile);
|
||||||
|
|
||||||
|
// 组装请求对象
|
||||||
SendSmsRequest request = new SendSmsRequest();
|
SendSmsRequest request = new SendSmsRequest();
|
||||||
request.setPhoneNumbers(phone);
|
request.setPhoneNumbers(phone);
|
||||||
request.setSignName(config.getSignName());
|
request.setSignName(config.getSignName());
|
||||||
request.setTemplateCode(templateId);
|
request.setTemplateCode(templateId);
|
||||||
|
|
||||||
// 阿里云短信模板参数为JSON字符串
|
// 阿里云短信模板参数为JSON字符串
|
||||||
if (params != null && !params.isEmpty()) {
|
if (params != null && !params.isEmpty()) {
|
||||||
request.setTemplateParam(com.alibaba.fastjson.JSON.toJSONString(params));
|
String templateParam = JSON.toJSONString(params);
|
||||||
|
request.setTemplateParam(templateParam);
|
||||||
|
logger.debug("[短信发送][服务商:ALIYUN] 模板参数JSON: {}", templateParam);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
// 发送短信
|
||||||
logger.info("[阿里云短信] 发送请求: 手机号={}, 模板={}, 参数={}", phone, templateId, params);
|
|
||||||
SendSmsResponse response = client.getAcsResponse(request);
|
SendSmsResponse response = client.getAcsResponse(request);
|
||||||
logger.info("[阿里云短信] 发送结果: {}", response.getMessage());
|
|
||||||
|
logger.info("[短信发送][服务商:ALIYUN] 响应: code={}, message={}, requestId={}, bizId={}",
|
||||||
|
response.getCode(), response.getMessage(), response.getRequestId(), response.getBizId());
|
||||||
|
|
||||||
return "OK".equalsIgnoreCase(response.getCode());
|
return "OK".equalsIgnoreCase(response.getCode());
|
||||||
} catch (ClientException e) {
|
} catch (ClientException e) {
|
||||||
logger.error("[阿里云短信] 发送失败,手机号:{},模板:{},参数:{},异常:{}", phone, templateId, params, e.getMessage(), e);
|
logger.error("[短信发送][服务商:ALIYUN] SDK异常,手机号:{},模板ID:{},参数:{},错误码:{},异常:{}",
|
||||||
|
phone, templateId, params, e.getErrCode(), e.getMessage(), e);
|
||||||
|
throw new SmsSendException("阿里云短信发送失败: " + e.getMessage(), e);
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("[短信发送][服务商:ALIYUN] 失败,手机号:{},模板ID:{},参数:{},异常:{}",
|
||||||
|
phone, templateId, params, e.getMessage(), e);
|
||||||
throw new SmsSendException("阿里云短信发送失败", e);
|
throw new SmsSendException("阿里云短信发送失败", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+42
-7
@@ -4,8 +4,13 @@ import com.central.sms.config.SmsProperties;
|
|||||||
import com.central.sms.exception.SmsSendException;
|
import com.central.sms.exception.SmsSendException;
|
||||||
import com.central.sms.service.ISmsService;
|
import com.central.sms.service.ISmsService;
|
||||||
import com.tencentcloudapi.common.Credential;
|
import com.tencentcloudapi.common.Credential;
|
||||||
|
import com.tencentcloudapi.common.exception.TencentCloudSDKException;
|
||||||
import com.tencentcloudapi.common.profile.ClientProfile;
|
import com.tencentcloudapi.common.profile.ClientProfile;
|
||||||
import com.tencentcloudapi.common.profile.HttpProfile;
|
import com.tencentcloudapi.common.profile.HttpProfile;
|
||||||
|
import com.tencentcloudapi.sms.v20210111.SmsClient;
|
||||||
|
import com.tencentcloudapi.sms.v20210111.models.SendSmsRequest;
|
||||||
|
import com.tencentcloudapi.sms.v20210111.models.SendSmsResponse;
|
||||||
|
import com.tencentcloudapi.sms.v20210111.models.SendStatus;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@@ -26,26 +31,56 @@ public class TencentSmsService implements ISmsService {
|
|||||||
try {
|
try {
|
||||||
SmsProperties.TencentConfig config = smsProperties.getTencent();
|
SmsProperties.TencentConfig config = smsProperties.getTencent();
|
||||||
logger.info("[短信发送][服务商:TENCENT] 手机号={}, 模板ID={}, 参数={}", phone, templateId, params);
|
logger.info("[短信发送][服务商:TENCENT] 手机号={}, 模板ID={}, 参数={}", phone, templateId, params);
|
||||||
|
|
||||||
|
// 实例化认证对象
|
||||||
Credential cred = new Credential(config.getSecretId(), config.getSecretKey());
|
Credential cred = new Credential(config.getSecretId(), config.getSecretKey());
|
||||||
|
|
||||||
|
// 实例化http配置
|
||||||
HttpProfile httpProfile = new HttpProfile();
|
HttpProfile httpProfile = new HttpProfile();
|
||||||
httpProfile.setEndpoint("sms.tencentcloudapi.com");
|
httpProfile.setEndpoint("sms.tencentcloudapi.com");
|
||||||
|
|
||||||
|
// 实例化客户端配置
|
||||||
ClientProfile clientProfile = new ClientProfile();
|
ClientProfile clientProfile = new ClientProfile();
|
||||||
clientProfile.setHttpProfile(httpProfile);
|
clientProfile.setHttpProfile(httpProfile);
|
||||||
/*SmsClient client = new SmsClient(cred, "ap-guangzhou", clientProfile);
|
|
||||||
|
|
||||||
|
// 实例化SMS客户端
|
||||||
|
SmsClient client = new SmsClient(cred, "ap-guangzhou", clientProfile);
|
||||||
|
|
||||||
|
// 实例化请求对象
|
||||||
SendSmsRequest req = new SendSmsRequest();
|
SendSmsRequest req = new SendSmsRequest();
|
||||||
req.setSmsSdkAppId(config.getAppId());
|
req.setSmsSdkAppId(config.getAppId());
|
||||||
req.setSignName(config.getSignName());
|
req.setSignName(config.getSignName());
|
||||||
req.setTemplateId(templateId);
|
req.setTemplateId(templateId);
|
||||||
req.setPhoneNumberSet(new String[]{phone});
|
|
||||||
req.setTemplateParamSet(params.values().toArray(new String[0]));
|
|
||||||
|
|
||||||
|
// 设置手机号(需要加+86前缀)
|
||||||
|
String[] phoneNumbers = new String[]{"+86" + phone};
|
||||||
|
req.setPhoneNumberSet(phoneNumbers);
|
||||||
|
|
||||||
|
// 设置模板参数
|
||||||
|
if (params != null && !params.isEmpty()) {
|
||||||
|
req.setTemplateParamSet(params.values().toArray(new String[0]));
|
||||||
|
}
|
||||||
|
|
||||||
|
// 发送短信
|
||||||
SendSmsResponse resp = client.SendSms(req);
|
SendSmsResponse resp = client.SendSms(req);
|
||||||
logger.info("[短信发送][服务商:TENCENT] 响应: code={}, message={}", resp.getSendStatusSet()[0].getCode(), resp.getSendStatusSet()[0].getMessage());
|
SendStatus[] statusSet = resp.getSendStatusSet();
|
||||||
return "Ok".equalsIgnoreCase(resp.getSendStatusSet()[0].getCode());*/
|
|
||||||
return true;
|
if (statusSet != null && statusSet.length > 0) {
|
||||||
|
SendStatus status = statusSet[0];
|
||||||
|
logger.info("[短信发送][服务商:TENCENT] 响应: code={}, message={}, requestId={}",
|
||||||
|
status.getCode(), status.getMessage(), resp.getRequestId());
|
||||||
|
return "Ok".equalsIgnoreCase(status.getCode());
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.warn("[短信发送][服务商:TENCENT] 响应状态集为空");
|
||||||
|
return false;
|
||||||
|
} catch (TencentCloudSDKException e) {
|
||||||
|
logger.error("[短信发送][服务商:TENCENT] SDK异常,手机号:{},模板ID:{},参数:{},错误码:{},异常:{}",
|
||||||
|
phone, templateId, params, e.getErrorCode(), e.getMessage(), e);
|
||||||
|
throw new SmsSendException("腾讯云短信发送失败: " + e.getMessage(), e);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error("[短信发送][服务商:TENCENT] 失败,手机号:{},模板ID:{},参数:{},异常:{}", phone, templateId, params, e.getMessage(), e);
|
logger.error("[短信发送][服务商:TENCENT] 失败,手机号:{},模板ID:{},参数:{},异常:{}",
|
||||||
|
phone, templateId, params, e.getMessage(), e);
|
||||||
throw new SmsSendException("腾讯云短信发送失败", e);
|
throw new SmsSendException("腾讯云短信发送失败", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
package com.central.oauth.controller;
|
package com.central.oauth.controller;
|
||||||
|
|
||||||
import com.central.common.constant.SecurityConstants;
|
import com.central.common.constant.SecurityConstants;
|
||||||
|
import com.central.common.feign.MsgCenterService;
|
||||||
import com.central.common.model.CodeEnum;
|
import com.central.common.model.CodeEnum;
|
||||||
import com.central.common.model.Result;
|
import com.central.common.model.Result;
|
||||||
|
import com.central.common.model.SysUser;
|
||||||
import com.central.common.utils.RSAUtil;
|
import com.central.common.utils.RSAUtil;
|
||||||
import com.central.common.utils.StringUtils;
|
import com.central.common.utils.StringUtils;
|
||||||
import com.central.oauth.model.Client;
|
import com.central.oauth.model.Client;
|
||||||
@@ -21,11 +23,14 @@ import com.central.oauth2.common.properties.SecurityProperties;
|
|||||||
import com.central.oauth2.common.token.OpenIdAuthenticationToken;
|
import com.central.oauth2.common.token.OpenIdAuthenticationToken;
|
||||||
import com.central.oauth2.common.token.TencentAuthenticationToken;
|
import com.central.oauth2.common.token.TencentAuthenticationToken;
|
||||||
import com.central.oauth2.common.util.AuthUtils;
|
import com.central.oauth2.common.util.AuthUtils;
|
||||||
|
import com.central.common.feign.UserService;
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
import jakarta.servlet.http.HttpServletRequest;
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
import jakarta.servlet.http.HttpServletRequestWrapper;
|
import jakarta.servlet.http.HttpServletRequestWrapper;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.context.annotation.Lazy;
|
import org.springframework.context.annotation.Lazy;
|
||||||
|
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||||
import org.springframework.security.oauth2.core.AuthorizationGrantType;
|
import org.springframework.security.oauth2.core.AuthorizationGrantType;
|
||||||
import org.springframework.security.oauth2.core.ClientAuthenticationMethod;
|
import org.springframework.security.oauth2.core.ClientAuthenticationMethod;
|
||||||
@@ -48,6 +53,8 @@ import java.time.temporal.ChronoUnit;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
import java.util.Random;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
@Tag(name = "登录接口")
|
@Tag(name = "登录接口")
|
||||||
@RestController
|
@RestController
|
||||||
@@ -86,6 +93,31 @@ public class LoginController {
|
|||||||
@Resource
|
@Resource
|
||||||
private UnifiedLogoutService unifiedLogoutService;
|
private UnifiedLogoutService unifiedLogoutService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private StringRedisTemplate stringRedisTemplate;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private MsgCenterService msgCenterService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private UserService userService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 短信验证码Redis Key前缀
|
||||||
|
*/
|
||||||
|
private static final String SMS_CODE_PREFIX = "sms:code:";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 短信验证码有效期(分钟)
|
||||||
|
*/
|
||||||
|
private static final long SMS_CODE_EXPIRE_MINUTES = 5;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 短信服务商类型:tencent-腾讯云, aliyun-阿里云
|
||||||
|
*/
|
||||||
|
@org.springframework.beans.factory.annotation.Value("${sms.provider:tencent}")
|
||||||
|
private String smsProvider;
|
||||||
|
|
||||||
@PostMapping(value = "/login")
|
@PostMapping(value = "/login")
|
||||||
public Result<Map<String, Object>> login(@RequestBody LoginReq req) {
|
public Result<Map<String, Object>> login(@RequestBody LoginReq req) {
|
||||||
try {
|
try {
|
||||||
@@ -133,6 +165,148 @@ public class LoginController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发送手机验证码
|
||||||
|
*
|
||||||
|
* @param mobile 手机号
|
||||||
|
* @return 发送结果
|
||||||
|
*/
|
||||||
|
@Operation(summary = "发送手机验证码")
|
||||||
|
@PostMapping(value = "/sendSmsCode")
|
||||||
|
public Result<String> sendSmsCode(@RequestParam("mobile") String mobile) {
|
||||||
|
try {
|
||||||
|
// 1) 校验手机号格式
|
||||||
|
if (StringUtils.isBlank(mobile) || !mobile.matches("^1[3-9]\\d{9}$")) {
|
||||||
|
return Result.failed("手机号格式不正确");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2) 检查是否频繁发送(防刷)
|
||||||
|
String redisKey = SMS_CODE_PREFIX + mobile;
|
||||||
|
String existCode = stringRedisTemplate.opsForValue().get(redisKey);
|
||||||
|
if (StringUtils.isNotBlank(existCode)) {
|
||||||
|
Long ttl = stringRedisTemplate.getExpire(redisKey, TimeUnit.SECONDS);
|
||||||
|
if (ttl != null && ttl > (SMS_CODE_EXPIRE_MINUTES - 1) * 60) {
|
||||||
|
return Result.failed("验证码发送过于频繁,请稍后再试");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 3) 生成4位随机验证码
|
||||||
|
String code = String.format("%04d", new Random().nextInt(10000));
|
||||||
|
|
||||||
|
// 4) 根据配置选择短信服务商发送短信
|
||||||
|
Result<?> sendResult;
|
||||||
|
if ("aliyun".equalsIgnoreCase(smsProvider)) {
|
||||||
|
log.info("使用阿里云发送验证码,mobile:{}", mobile);
|
||||||
|
sendResult = msgCenterService.sendAliyunVerifyCode(mobile, code);
|
||||||
|
} else {
|
||||||
|
// 默认使用腾讯云
|
||||||
|
log.info("使用腾讯云发送验证码,mobile:{}", mobile);
|
||||||
|
sendResult = msgCenterService.sendTencentVerifyCode(mobile, code);
|
||||||
|
}
|
||||||
|
if (sendResult == null || sendResult.getResp_code() != 0) {
|
||||||
|
log.error("发送短信验证码失败,mobile:{}, result:{}", mobile, sendResult);
|
||||||
|
return Result.failed("短信发送失败,请稍后重试");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 5) 发送成功后存入Redis,设置有效期
|
||||||
|
stringRedisTemplate.opsForValue().set(redisKey, code, SMS_CODE_EXPIRE_MINUTES, TimeUnit.MINUTES);
|
||||||
|
log.info("短信验证码发送成功,mobile:{}", mobile);
|
||||||
|
|
||||||
|
return Result.succeed("验证码发送成功");
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("发送短信验证码异常,mobile:{}", mobile, e);
|
||||||
|
return Result.failed("短信发送失败:" + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 手机号验证码登录
|
||||||
|
*
|
||||||
|
* @param mobile 手机号
|
||||||
|
* @param smsCode 短信验证码
|
||||||
|
* @param clientId 客户端ID
|
||||||
|
* @return 登录结果(token)
|
||||||
|
*/
|
||||||
|
@Operation(summary = "手机号验证码登录")
|
||||||
|
@PostMapping(value = "/loginBySmsCode")
|
||||||
|
public Result<Map<String, Object>> loginBySmsCode(
|
||||||
|
@RequestParam("mobile") String mobile,
|
||||||
|
@RequestParam("smsCode") String smsCode,
|
||||||
|
@RequestParam("clientId") String clientId) {
|
||||||
|
try {
|
||||||
|
// 1) 校验参数
|
||||||
|
if (StringUtils.isBlank(mobile) || !mobile.matches("^1[3-9]\\d{9}$")) {
|
||||||
|
return Result.failed("手机号格式不正确");
|
||||||
|
}
|
||||||
|
if (StringUtils.isBlank(smsCode)) {
|
||||||
|
return Result.failed("验证码不能为空");
|
||||||
|
}
|
||||||
|
if (StringUtils.isBlank(clientId)) {
|
||||||
|
return Result.failed("客户端ID不能为空");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2) 从Redis获取验证码并校验
|
||||||
|
String redisKey = SMS_CODE_PREFIX + mobile;
|
||||||
|
String cachedCode = stringRedisTemplate.opsForValue().get(redisKey);
|
||||||
|
if (StringUtils.isBlank(cachedCode)) {
|
||||||
|
return Result.failed("验证码已过期,请重新获取");
|
||||||
|
}
|
||||||
|
if (!cachedCode.equals(smsCode)) {
|
||||||
|
return Result.failed("验证码错误");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 3) 验证码校验成功后删除
|
||||||
|
stringRedisTemplate.delete(redisKey);
|
||||||
|
|
||||||
|
// 4) 查询用户是否已注册
|
||||||
|
SysUser sysUser = userService.findByMobile(mobile);
|
||||||
|
String openId;
|
||||||
|
if (sysUser == null || sysUser.getId() == null) {
|
||||||
|
// 用户不存在,先注册
|
||||||
|
log.info("用户不存在,进行注册,mobile:{}", mobile);
|
||||||
|
SysUser newUser = userService.registerByMobile(mobile);
|
||||||
|
if (newUser == null || StringUtils.isBlank(newUser.getOpenId())) {
|
||||||
|
return Result.failed("用户注册失败,请重试");
|
||||||
|
}
|
||||||
|
openId = newUser.getOpenId();
|
||||||
|
log.info("用户注册成功,mobile:{}, openId:{}", mobile, openId);
|
||||||
|
} else {
|
||||||
|
// 用户已存在
|
||||||
|
openId = sysUser.getOpenId();
|
||||||
|
if (StringUtils.isBlank(openId)) {
|
||||||
|
return Result.failed("用户信息异常,缺少openId");
|
||||||
|
}
|
||||||
|
log.info("用户已存在,直接登录,mobile:{}, openId:{}", mobile, openId);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 5) 使用openId进行登录
|
||||||
|
LoginReq loginReq = new LoginReq();
|
||||||
|
loginReq.setGrantType("openId");
|
||||||
|
loginReq.setOpenId(openId);
|
||||||
|
loginReq.setClientId(clientId);
|
||||||
|
|
||||||
|
// 6) 客户端校验
|
||||||
|
Client client = clientService.loadClientByClientId(clientId);
|
||||||
|
if (client == null) {
|
||||||
|
return Result.failed("所属客户端不存在");
|
||||||
|
}
|
||||||
|
RegisteredClient registeredClient = registeredClientRepository.findByClientId(client.getClientId());
|
||||||
|
if (registeredClient == null) {
|
||||||
|
return Result.failed("未注册的客户端");
|
||||||
|
}
|
||||||
|
AuthorizationGrantType grantTypeToUse = new AuthorizationGrantType("openId");
|
||||||
|
if (!registeredClient.getAuthorizationGrantTypes().contains(grantTypeToUse)) {
|
||||||
|
return Result.failed("客户端未开通openId授权类型");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 7) 颁发令牌
|
||||||
|
return issueTokenInternally(loginReq, registeredClient, null);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("手机号验证码登录异常,mobile:{}", mobile, e);
|
||||||
|
return Result.failed("登录失败:" + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@PostMapping(value = "/logout")
|
@PostMapping(value = "/logout")
|
||||||
public Result<String> logOut(HttpServletRequest request) {
|
public Result<String> logOut(HttpServletRequest request) {
|
||||||
String token = AuthUtils.extractHeaderToken(request);
|
String token = AuthUtils.extractHeaderToken(request);
|
||||||
|
|||||||
@@ -63,3 +63,5 @@ zlt:
|
|||||||
# 鍏煎榛樿琛ㄥ崟鐧诲綍涓庡唴缃櫥鍑?
|
# 鍏煎榛樿琛ㄥ崟鐧诲綍涓庡唴缃櫥鍑?
|
||||||
- /user/login
|
- /user/login
|
||||||
- /oauth/remove/token
|
- /oauth/remove/token
|
||||||
|
- /oauth/sendSmsCode
|
||||||
|
- /oauth/loginBySmsCode
|
||||||
|
|||||||
@@ -1,69 +0,0 @@
|
|||||||
# 通用大屏 → 无人机智慧城市管控平台(重构计划表)
|
|
||||||
|
|
||||||
> 目标:在不改变现有功能与数据接口的前提下,把 `/dashboard` 的“通用监控大屏”升级为更符合“无人机赋能智慧城市”的首页大屏:维度更丰富、信息架构更清晰、视觉更高级、交互更顺手。
|
|
||||||
|
|
||||||
## 0. 约束与边界(必须遵守)
|
|
||||||
- 不改路由与入口:仍然使用 `/dashboard`,`进入监控视图` 仍然跳转 `/map3d?from=dashboard`。
|
|
||||||
- 不改现有接口/聚合逻辑:继续使用 `src/services/dashboard.ts` 的 `getDeviceStats/getTaskStats/getTrendData` 等(允许新增“可选增强”接口或派生数据)。
|
|
||||||
- 不影响海事行业:`/maritime` 不做联动修改(仅做必要的“命名展示”区分时除外)。
|
|
||||||
- 无数据也要好看:任何新模块在数据缺失时要有优雅的“空态/占位”,避免空白或布局塌陷。
|
|
||||||
|
|
||||||
## 1. 目标体验(验收口径)
|
|
||||||
1. 首页一眼看懂:顶部为“城市态势总览”,中间为“数字孪生/空域态势”,两侧为“运行体征/事件处置”。
|
|
||||||
2. 统计维度丰富:至少覆盖「设备运行」「任务执行」「城市网格治理」「AI识别事件」「环境/交通态势(可派生/可模拟)」五大类。
|
|
||||||
3. 视觉统一:同一套色板、间距、描边、阴影、字体层级,避免“拼贴感”。
|
|
||||||
4. 交互轻快:鼠标悬停、点击、筛选都有明确反馈;滚动区域可控且不抢焦点。
|
|
||||||
|
|
||||||
## 2. 信息架构与模块清单(Dashboard)
|
|
||||||
|
|
||||||
### 2.1 顶部(Header)
|
|
||||||
- 平台命名:`无人机智慧城市管控平台`
|
|
||||||
- 状态条:当前租户/范围、在线率、告警等级概览、当前时间(若页面本身不显示则放入大屏 Header)
|
|
||||||
- 快捷入口:进入 3D 监控、任务/设备(保持现有入口,不新增强绑定)
|
|
||||||
|
|
||||||
### 2.2 左侧(城市运行体征)
|
|
||||||
- 城市网格治理(Radar):巡检覆盖、问题发现、处置效率、复核通过、重点区域关注
|
|
||||||
- 环境感知(Line/Gauge/Liquid):PM2.5、噪声、热源异常趋势(允许派生/模拟,但要“稳定”)
|
|
||||||
- 交通与人流(Area/Heatmap):拥堵指数趋势、重点区域热度 TopN
|
|
||||||
|
|
||||||
### 2.3 中间(全域态势 / 数字孪生入口)
|
|
||||||
- 核心态势 KPI(数字+发光强调):城市安全指数、今日识别事件、平均响应时长、闭环率
|
|
||||||
- 数字孪生入口卡(保留进入 `/map3d`):升级为更“城市中枢”风格,增加图层提示文案(电子围栏/事件点位/航线)
|
|
||||||
- AI抓拍与隐患快照(Carousel/卡片流):违停、烟火、占道、河道漂浮物、工地未戴帽等(点击可弹出详情抽屉/弹窗)
|
|
||||||
|
|
||||||
### 2.4 右侧(事件处置与运行调度)
|
|
||||||
- 事件类型分布(Pie/RadialBar):按“城市治理事件”分类统计(与告警/任务派生映射)
|
|
||||||
- 实时事件流(List):分级(一般/重要/紧急)+ 来源(无人机/摄像头/机库)+ 处理状态(待确认/已派单/处理中/已闭环)
|
|
||||||
- 任务执行(保留原筛选逻辑):日/月/年切换 + 状态占比 + 近 7 日趋势 + 异常原因分析(原模块“换皮+换语义”)
|
|
||||||
|
|
||||||
## 3. 数据策略(不改功能前提下“做出新维度”)
|
|
||||||
|
|
||||||
### 3.1 直接复用(已有)
|
|
||||||
- 设备:`DeviceStats.total/online/offline/fault/byType/onlineRate`
|
|
||||||
- 任务:`TaskStats.pending/running/completed/failed/successRate/todayNew`
|
|
||||||
- 趋势:`getTrendData(7)`(现为模拟,后续可接真实接口)
|
|
||||||
- 告警:`getMockAlerts()`(现为模拟)
|
|
||||||
|
|
||||||
### 3.2 派生增强(推荐落地)
|
|
||||||
- 城市安全指数:由 `告警数量/等级` + `任务成功率` + `在线率` 计算得到(可解释、可复现)。
|
|
||||||
- 事件类型分布:把告警/任务映射到“城市治理事件”类别(如:离线→关键设施告警、低电→保障能力风险)。
|
|
||||||
- 网格治理/环境/交通:使用“可复现的稳定模拟”(基于 tenantId + 日期 hash),保证刷新时不跳变、截图时稳定。
|
|
||||||
|
|
||||||
## 4. 设计系统(落地规则)
|
|
||||||
- 色板:以 `--accent-blue/green/yellow/red` 为主,新增 1~2 个辅助色(紫/青)但必须有统一用途。
|
|
||||||
- 卡片:统一玻璃拟态 + 细描边 + 角落高光;标题区高度统一;内容区保持最小可视高度。
|
|
||||||
- 字体层级:KPI 数字使用等宽/半等宽(更有“仪表感”);正文保持 12~13px,标题 14~15px。
|
|
||||||
- 动效:只用“微动效”(呼吸光、扫光、hover 抬升),避免大幅炫技影响可读性。
|
|
||||||
|
|
||||||
## 5. 实施里程碑(建议按顺序做)
|
|
||||||
|
|
||||||
| 里程碑 | 目标 | 产出 | 涉及文件(示例) | 验收点 |
|
|
||||||
|---|---|---|---|---|
|
|
||||||
| M1 | 结构拆分 + 新布局骨架 | `Dashboard` 拆组件、三栏网格稳定 | `src/pages/dashboard/index.tsx`、`src/pages/dashboard/index.less`、`src/pages/dashboard/components/*` | 1920×1080 无挤压、无滚动条乱跳 |
|
|
||||||
| M2 | 智慧城市模块落地 | 城市 KPI/网格治理/环境交通/AI快照 | `src/services/dashboard.ts`(新增派生/稳定模拟)、`src/pages/dashboard/components/*` | 统计维度明显增加,空态不丑 |
|
|
||||||
| M3 | 视觉与交互精修 | 统一色板、排版、hover、空态、细节 | `src/global.less`(少量)、`src/pages/dashboard/*` | 一致性强、截图“像产品” |
|
|
||||||
| M4(可选) | 设备操控页 HUD 化 | 不改控制逻辑,只换布局与皮肤 |(按现有控制页位置确定)| 操控入口/功能不变、观感升级 |
|
|
||||||
|
|
||||||
## 6. 风险与回退
|
|
||||||
- 风险:新增模块依赖“模拟/派生数据”可能被误认为真实数据;处理:在不显眼处提供“数据口径说明”(抽屉/帮助提示)。
|
|
||||||
- 回退:保留原统计卡片/图表配置为独立组件,可随时切回(通过组件替换,不删代码)。
|
|
||||||
@@ -14,10 +14,10 @@ export default [
|
|||||||
path: '/',
|
path: '/',
|
||||||
component: '@/layouts/BlankLayout',
|
component: '@/layouts/BlankLayout',
|
||||||
routes: [
|
routes: [
|
||||||
// 默认跳转海事大屏
|
// 默认跳转智慧城市大屏
|
||||||
{
|
{
|
||||||
path: '/',
|
path: '/',
|
||||||
redirect: '/maritime',
|
redirect: '/dashboard',
|
||||||
},
|
},
|
||||||
// 通用监控大屏首页
|
// 通用监控大屏首页
|
||||||
{
|
{
|
||||||
|
|||||||
Binary file not shown.
@@ -57,12 +57,21 @@ body {
|
|||||||
/* Ant Design 覆盖 */
|
/* Ant Design 覆盖 */
|
||||||
.ant-layout {
|
.ant-layout {
|
||||||
background: var(--bg-primary) !important;
|
background: var(--bg-primary) !important;
|
||||||
|
height: 100%;
|
||||||
|
min-height: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.ant-layout-header {
|
.ant-layout-header {
|
||||||
|
flex: 0 0 auto;
|
||||||
background: var(--bg-secondary) !important;
|
background: var(--bg-secondary) !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.ant-layout-content {
|
||||||
|
flex: 1;
|
||||||
|
min-height: 0;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
.ant-card {
|
.ant-card {
|
||||||
background: var(--bg-card) !important;
|
background: var(--bg-card) !important;
|
||||||
border-color: var(--border-color) !important;
|
border-color: var(--border-color) !important;
|
||||||
|
|||||||
@@ -1,7 +1,13 @@
|
|||||||
.blank-layout {
|
.blank-layout {
|
||||||
min-height: 100vh;
|
height: 100vh;
|
||||||
|
height: 100dvh;
|
||||||
|
max-height: 100vh;
|
||||||
|
max-height: 100dvh;
|
||||||
|
overflow: hidden;
|
||||||
background: var(--bg-primary);
|
background: var(--bg-primary);
|
||||||
/* Dashboard 高度自适应:同一份变量同时驱动 Header 与 Content,避免“减去固定像素”导致不同屏幕被遮挡 */
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
/* Dashboard 高度自适应:同一份变量同时驱动 Header 与 Content,避免"减去固定像素"导致不同屏幕被遮挡 */
|
||||||
--dashboard-header-h: 80px;
|
--dashboard-header-h: 80px;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -18,6 +24,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.blank-header {
|
.blank-header {
|
||||||
|
flex: 0 0 auto;
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
@@ -27,8 +34,7 @@
|
|||||||
background: linear-gradient(180deg, rgba(19, 26, 61, 0.98) 0%, rgba(10, 14, 39, 0.95) 100%) !important;
|
background: linear-gradient(180deg, rgba(19, 26, 61, 0.98) 0%, rgba(10, 14, 39, 0.95) 100%) !important;
|
||||||
border-bottom: 1px solid var(--border-color);
|
border-bottom: 1px solid var(--border-color);
|
||||||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
|
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
|
||||||
position: sticky;
|
position: relative;
|
||||||
top: 0;
|
|
||||||
z-index: 100;
|
z-index: 100;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -100,18 +106,16 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.blank-content {
|
.blank-content {
|
||||||
height: calc(100vh - 56px);
|
flex: 1;
|
||||||
height: calc(100dvh - 56px);
|
min-height: 0;
|
||||||
overflow: auto;
|
overflow: auto;
|
||||||
background: var(--bg-primary);
|
background: var(--bg-primary);
|
||||||
min-height: 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.blank-content--dashboard {
|
.blank-content--dashboard {
|
||||||
height: calc(100vh - var(--dashboard-header-h));
|
flex: 1;
|
||||||
height: calc(100dvh - var(--dashboard-header-h));
|
|
||||||
overflow: hidden;
|
|
||||||
min-height: 0;
|
min-height: 0;
|
||||||
|
overflow: hidden;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
|
||||||
@@ -209,6 +213,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.blank-header--dashboard {
|
.blank-header--dashboard {
|
||||||
|
flex: 0 0 var(--dashboard-header-h);
|
||||||
height: var(--dashboard-header-h);
|
height: var(--dashboard-header-h);
|
||||||
line-height: var(--dashboard-header-h);
|
line-height: var(--dashboard-header-h);
|
||||||
padding: 0 22px;
|
padding: 0 22px;
|
||||||
@@ -218,7 +223,7 @@
|
|||||||
box-shadow:
|
box-shadow:
|
||||||
0 2px 12px rgba(0, 0, 0, 0.28),
|
0 2px 12px rgba(0, 0, 0, 0.28),
|
||||||
inset 0 -1px 0 rgba(0, 212, 255, 0.18);
|
inset 0 -1px 0 rgba(0, 212, 255, 0.18);
|
||||||
position: sticky;
|
position: relative;
|
||||||
|
|
||||||
&::before {
|
&::before {
|
||||||
content: '';
|
content: '';
|
||||||
@@ -596,13 +601,25 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.blank-content--maritime {
|
.blank-content--maritime {
|
||||||
|
/* 参考智慧城市大屏:用明确高度约束内容区,保证子 Grid 的 fr 高度计算为“确定值”,避免卡片把容器撑高导致后续面板被裁剪 */
|
||||||
height: calc(100vh - 88px);
|
height: calc(100vh - 88px);
|
||||||
|
height: calc(100dvh - 88px);
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
|
min-height: 0;
|
||||||
|
width: 100%;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
background: linear-gradient(180deg,
|
background: linear-gradient(180deg,
|
||||||
#020c1b 0%,
|
#020c1b 0%,
|
||||||
#071a2f 30%,
|
#071a2f 30%,
|
||||||
#0c2340 60%,
|
#0c2340 60%,
|
||||||
#0f2847 100%);
|
#0f2847 100%);
|
||||||
|
|
||||||
|
> * {
|
||||||
|
flex: 1;
|
||||||
|
min-height: 0;
|
||||||
|
min-width: 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@keyframes maritimeSweep {
|
@keyframes maritimeSweep {
|
||||||
|
|||||||
@@ -0,0 +1,84 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import { Card, Tabs } from 'antd';
|
||||||
|
import { RadarChartOutlined } from '@ant-design/icons';
|
||||||
|
import { Radar, Line, Heatmap } from '@ant-design/plots';
|
||||||
|
|
||||||
|
interface CityVitalCardProps {
|
||||||
|
radarConfig: any;
|
||||||
|
envLineConfig: any;
|
||||||
|
trafficHeatmapConfig: any;
|
||||||
|
}
|
||||||
|
|
||||||
|
const CityVitalCard: React.FC<CityVitalCardProps> = ({
|
||||||
|
radarConfig,
|
||||||
|
envLineConfig,
|
||||||
|
trafficHeatmapConfig,
|
||||||
|
}) => {
|
||||||
|
return (
|
||||||
|
<Card
|
||||||
|
title={
|
||||||
|
<span style={{ color: 'rgba(255,255,255,0.92)', display: 'flex', alignItems: 'center', gap: 8 }}>
|
||||||
|
<RadarChartOutlined style={{ color: 'rgba(0,212,255,0.95)' }} /> 城市运行体征
|
||||||
|
</span>
|
||||||
|
}
|
||||||
|
style={{
|
||||||
|
height: '100%',
|
||||||
|
background: 'rgba(19, 26, 61, 0.7)',
|
||||||
|
border: '1px solid rgba(0, 212, 255, 0.15)',
|
||||||
|
borderRadius: 8,
|
||||||
|
display: 'flex',
|
||||||
|
flexDirection: 'column',
|
||||||
|
}}
|
||||||
|
styles={{
|
||||||
|
header: { flex: '0 0 auto', minHeight: 40, padding: '0 12px', borderBottom: '1px solid rgba(0, 212, 255, 0.1)' },
|
||||||
|
body: { flex: 1, padding: 12, overflow: 'hidden', display: 'flex', flexDirection: 'column', minHeight: 0 },
|
||||||
|
}}
|
||||||
|
size="small"
|
||||||
|
>
|
||||||
|
<Tabs
|
||||||
|
size="small"
|
||||||
|
style={{ height: '100%', display: 'flex', flexDirection: 'column' }}
|
||||||
|
items={[
|
||||||
|
{
|
||||||
|
key: 'grid',
|
||||||
|
label: '网格治理',
|
||||||
|
children: (
|
||||||
|
<div style={{ height: '100%', display: 'flex', flexDirection: 'column', overflow: 'hidden' }}>
|
||||||
|
<div style={{ fontSize: 12, color: 'rgba(255,255,255,0.55)', marginBottom: 8 }}>覆盖、发现、处置、复核一体化评分</div>
|
||||||
|
<div style={{ flex: 1, minHeight: 0 }}>
|
||||||
|
<Radar {...radarConfig} />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'env',
|
||||||
|
label: '环境感知',
|
||||||
|
children: (
|
||||||
|
<div style={{ height: '100%', display: 'flex', flexDirection: 'column', overflow: 'hidden' }}>
|
||||||
|
<div style={{ fontSize: 12, color: 'rgba(255,255,255,0.55)', marginBottom: 8 }}>空地协同采集 · 24 小时滚动</div>
|
||||||
|
<div style={{ flex: 1, minHeight: 0 }}>
|
||||||
|
<Line {...envLineConfig} />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'traffic',
|
||||||
|
label: '交通热力',
|
||||||
|
children: (
|
||||||
|
<div style={{ height: '100%', display: 'flex', flexDirection: 'column', overflow: 'hidden' }}>
|
||||||
|
<div style={{ fontSize: 12, color: 'rgba(255,255,255,0.55)', marginBottom: 8 }}>重点片区热度分布(网格化)</div>
|
||||||
|
<div style={{ flex: 1, minHeight: 0 }}>
|
||||||
|
<Heatmap {...trafficHeatmapConfig} />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
),
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
/>
|
||||||
|
</Card>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default CityVitalCard;
|
||||||
@@ -0,0 +1,149 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import { Card, Space, Segmented, DatePicker } from 'antd';
|
||||||
|
import { RocketOutlined } from '@ant-design/icons';
|
||||||
|
import { Line } from '@ant-design/plots';
|
||||||
|
import dayjs from 'dayjs';
|
||||||
|
import './card.less';
|
||||||
|
|
||||||
|
interface TaskStats {
|
||||||
|
pending: number;
|
||||||
|
running: number;
|
||||||
|
completed: number;
|
||||||
|
failed: number;
|
||||||
|
successRate: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface TrendItem {
|
||||||
|
date: string;
|
||||||
|
type: string;
|
||||||
|
value: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface DispatchCardProps {
|
||||||
|
taskStats: TaskStats | null;
|
||||||
|
taskTrendData: TrendItem[];
|
||||||
|
taskStatType: 'day' | 'month' | 'year';
|
||||||
|
taskStatDate: dayjs.Dayjs;
|
||||||
|
onStatTypeChange: (type: 'day' | 'month' | 'year') => void;
|
||||||
|
onDateChange: (date: dayjs.Dayjs) => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
const DispatchCard: React.FC<DispatchCardProps> = ({
|
||||||
|
taskStats,
|
||||||
|
taskTrendData,
|
||||||
|
taskStatType,
|
||||||
|
taskStatDate,
|
||||||
|
onStatTypeChange,
|
||||||
|
onDateChange,
|
||||||
|
}) => {
|
||||||
|
const taskPeriodText = React.useMemo(() => {
|
||||||
|
if (taskStatType === 'day') return '当日';
|
||||||
|
if (taskStatType === 'month') return '当月';
|
||||||
|
return '当年';
|
||||||
|
}, [taskStatType]);
|
||||||
|
|
||||||
|
const datePickerFormat = React.useMemo(() => {
|
||||||
|
if (taskStatType === 'day') return 'YYYY-MM-DD';
|
||||||
|
if (taskStatType === 'month') return 'YYYY-MM';
|
||||||
|
return 'YYYY';
|
||||||
|
}, [taskStatType]);
|
||||||
|
|
||||||
|
const dispatchTrendConfig: any = React.useMemo(() => {
|
||||||
|
return {
|
||||||
|
data: taskTrendData,
|
||||||
|
xField: 'date',
|
||||||
|
yField: 'value',
|
||||||
|
seriesField: 'type',
|
||||||
|
appendPadding: [2, 6, 6, 4],
|
||||||
|
smooth: true,
|
||||||
|
color: ['#00d4ff', '#00ff88', '#ffb800'],
|
||||||
|
xAxis: {
|
||||||
|
label: { style: { fill: 'rgba(255,255,255,0.62)', fontSize: 10 } },
|
||||||
|
grid: null,
|
||||||
|
},
|
||||||
|
yAxis: {
|
||||||
|
label: { style: { fill: 'rgba(255,255,255,0.62)', fontSize: 10 } },
|
||||||
|
grid: { line: { style: { stroke: 'rgba(255,255,255,0.08)' } } },
|
||||||
|
},
|
||||||
|
legend: {
|
||||||
|
position: 'top-right',
|
||||||
|
itemName: { style: { fill: 'rgba(255,255,255,0.72)', fontSize: 10 } },
|
||||||
|
itemSpacing: 8,
|
||||||
|
marker: { symbol: 'circle', style: { r: 4 } },
|
||||||
|
},
|
||||||
|
tooltip: { showMarkers: true },
|
||||||
|
autoFit: true,
|
||||||
|
};
|
||||||
|
}, [taskTrendData]);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Card
|
||||||
|
title={
|
||||||
|
<span className="panel-title">
|
||||||
|
<RocketOutlined /> {taskPeriodText}运行调度
|
||||||
|
</span>
|
||||||
|
}
|
||||||
|
className="dashboard-card glass-panel"
|
||||||
|
size="small"
|
||||||
|
style={{ height: '100%', minHeight: 0, maxHeight: '100%' }}
|
||||||
|
styles={{
|
||||||
|
header: { flex: '0 0 auto', minHeight: 40, padding: '0 12px', borderBottom: '1px solid rgba(0, 212, 255, 0.1)' },
|
||||||
|
body: { flex: 1, padding: 12, overflow: 'hidden', display: 'flex', flexDirection: 'column', minHeight: 0 },
|
||||||
|
}}
|
||||||
|
extra={
|
||||||
|
<Space size={8} className="task-filter">
|
||||||
|
<Segmented
|
||||||
|
size="small"
|
||||||
|
options={[
|
||||||
|
{ label: '日', value: 'day' },
|
||||||
|
{ label: '月', value: 'month' },
|
||||||
|
{ label: '年', value: 'year' },
|
||||||
|
]}
|
||||||
|
value={taskStatType}
|
||||||
|
onChange={(v) => onStatTypeChange(v as any)}
|
||||||
|
/>
|
||||||
|
<DatePicker
|
||||||
|
size="small"
|
||||||
|
value={taskStatDate}
|
||||||
|
onChange={(v) => v && onDateChange(v)}
|
||||||
|
picker={taskStatType === 'day' ? 'date' : taskStatType}
|
||||||
|
allowClear={false}
|
||||||
|
format={datePickerFormat}
|
||||||
|
disabledDate={(d) => !!d && d.isAfter(dayjs(), 'day')}
|
||||||
|
/>
|
||||||
|
</Space>
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<div className="dispatch-grid">
|
||||||
|
<div className="dispatch-stat">
|
||||||
|
<div className="dispatch-stat__val dispatch-stat__val--pending">{taskStats?.pending || 0}</div>
|
||||||
|
<div className="dispatch-stat__lbl">待执行</div>
|
||||||
|
</div>
|
||||||
|
<div className="dispatch-stat">
|
||||||
|
<div className="dispatch-stat__val dispatch-stat__val--running">{taskStats?.running || 0}</div>
|
||||||
|
<div className="dispatch-stat__lbl">执行中</div>
|
||||||
|
</div>
|
||||||
|
<div className="dispatch-stat">
|
||||||
|
<div className="dispatch-stat__val dispatch-stat__val--done">{taskStats?.completed || 0}</div>
|
||||||
|
<div className="dispatch-stat__lbl">已完成</div>
|
||||||
|
</div>
|
||||||
|
<div className="dispatch-stat">
|
||||||
|
<div className="dispatch-stat__val dispatch-stat__val--fail">{taskStats?.failed || 0}</div>
|
||||||
|
<div className="dispatch-stat__lbl">异常</div>
|
||||||
|
</div>
|
||||||
|
<div className="dispatch-highlight">
|
||||||
|
<div className="dispatch-highlight__val">{taskStats?.successRate || 0}%</div>
|
||||||
|
<div className="dispatch-highlight__lbl">成功率</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="dispatch-trend">
|
||||||
|
<div className="dispatch-trend__title">近 7 日任务趋势</div>
|
||||||
|
<div className="chart-wrapper">
|
||||||
|
<Line {...dispatchTrendConfig} />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</Card>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default DispatchCard;
|
||||||
@@ -0,0 +1,303 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import { Card, Tabs, Carousel, Empty, Tag, Progress } from 'antd';
|
||||||
|
import { AlertOutlined } from '@ant-design/icons';
|
||||||
|
import { Pie } from '@ant-design/plots';
|
||||||
|
import './card.less';
|
||||||
|
|
||||||
|
interface AiSnapshot {
|
||||||
|
id: string;
|
||||||
|
tag: string;
|
||||||
|
timeText: string;
|
||||||
|
title: string;
|
||||||
|
location: string;
|
||||||
|
confidence: number;
|
||||||
|
severity: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface RegionCoverage {
|
||||||
|
id: string;
|
||||||
|
name: string;
|
||||||
|
coverage: number;
|
||||||
|
pending: number;
|
||||||
|
risk: string;
|
||||||
|
updatedAt: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface DroneInsightCardProps {
|
||||||
|
aiSnapshots: AiSnapshot[];
|
||||||
|
fleet: {
|
||||||
|
avgBattery: number;
|
||||||
|
lowBatteryAlerts: number;
|
||||||
|
flightHoursToday: number;
|
||||||
|
flightMileageToday: number;
|
||||||
|
dockOnline: number;
|
||||||
|
dockTotal: number;
|
||||||
|
droneInFlight: number;
|
||||||
|
droneStandby: number;
|
||||||
|
droneMaintenance: number;
|
||||||
|
droneOnline: number;
|
||||||
|
droneTotal: number;
|
||||||
|
};
|
||||||
|
airspace: {
|
||||||
|
complianceIndex: number;
|
||||||
|
safetyIndex: number;
|
||||||
|
geofenceTriggers: number;
|
||||||
|
noFlyWarnings: number;
|
||||||
|
approvalsToday: number;
|
||||||
|
approvalsPassRate: number;
|
||||||
|
};
|
||||||
|
regionCoverage: RegionCoverage[];
|
||||||
|
compactLevel: 0 | 1 | 2;
|
||||||
|
snapshotsPerPage: number;
|
||||||
|
airspaceGaugeSize: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
const regionRiskColor = (risk: string) => {
|
||||||
|
if (risk === 'critical') return '#ff4757';
|
||||||
|
if (risk === 'warning') return '#ffb800';
|
||||||
|
return '#00ff88';
|
||||||
|
};
|
||||||
|
|
||||||
|
const DroneInsightCard: React.FC<DroneInsightCardProps> = ({
|
||||||
|
aiSnapshots,
|
||||||
|
fleet,
|
||||||
|
airspace,
|
||||||
|
regionCoverage,
|
||||||
|
compactLevel,
|
||||||
|
snapshotsPerPage,
|
||||||
|
airspaceGaugeSize,
|
||||||
|
}) => {
|
||||||
|
const droneStatusPieConfig: any = React.useMemo(() => {
|
||||||
|
const total = fleet.droneInFlight + fleet.droneStandby + fleet.droneMaintenance;
|
||||||
|
if (!total) return {};
|
||||||
|
return {
|
||||||
|
data: [
|
||||||
|
{ type: '在飞', value: fleet.droneInFlight },
|
||||||
|
{ type: '待命', value: fleet.droneStandby },
|
||||||
|
{ type: '维护', value: fleet.droneMaintenance },
|
||||||
|
],
|
||||||
|
angleField: 'value',
|
||||||
|
colorField: 'type',
|
||||||
|
radius: 0.92,
|
||||||
|
innerRadius: 0.62,
|
||||||
|
color: ['rgba(157, 78, 221, 0.95)', 'rgba(0, 212, 255, 0.9)', 'rgba(255, 184, 0, 0.92)'],
|
||||||
|
legend: false,
|
||||||
|
label: false,
|
||||||
|
statistic: {
|
||||||
|
title: false,
|
||||||
|
content: {
|
||||||
|
style: { color: 'rgba(255,255,255,0.88)', fontSize: 18, fontWeight: 700, whiteSpace: 'pre-line' },
|
||||||
|
content: `${fleet.droneOnline}/${fleet.droneTotal}\n在线`,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
autoFit: true,
|
||||||
|
};
|
||||||
|
}, [fleet]);
|
||||||
|
|
||||||
|
const visibleRegionCoverage = React.useMemo(() => {
|
||||||
|
const max = compactLevel === 2 ? 2 : compactLevel === 1 ? 4 : 6;
|
||||||
|
return regionCoverage.slice(0, max);
|
||||||
|
}, [regionCoverage, compactLevel]);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Card
|
||||||
|
title={
|
||||||
|
<span className="panel-title">
|
||||||
|
<AlertOutlined /> 无人机态势与AI洞察
|
||||||
|
</span>
|
||||||
|
}
|
||||||
|
className="dashboard-card glass-panel"
|
||||||
|
size="small"
|
||||||
|
style={{ height: '100%', minHeight: 0, maxHeight: '100%' }}
|
||||||
|
styles={{
|
||||||
|
header: { flex: '0 0 auto', minHeight: 40, padding: '0 12px', borderBottom: '1px solid rgba(0, 212, 255, 0.1)' },
|
||||||
|
body: { flex: 1, padding: 12, overflow: 'hidden', display: 'flex', flexDirection: 'column', minHeight: 0 },
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Tabs
|
||||||
|
size="small"
|
||||||
|
className="dash-tabs"
|
||||||
|
defaultActiveKey="fleet"
|
||||||
|
items={[
|
||||||
|
{
|
||||||
|
key: 'fleet',
|
||||||
|
label: '机队态势',
|
||||||
|
children: (
|
||||||
|
<div className="tab-pane fleet-pane">
|
||||||
|
<div className="fleet-metrics">
|
||||||
|
<div className="fleet-metric">
|
||||||
|
<div className="fleet-metric__label">平均电量</div>
|
||||||
|
<div className="fleet-metric__value">{fleet.avgBattery}%</div>
|
||||||
|
<div className="fleet-metric__sub">低电 {fleet.lowBatteryAlerts} 起</div>
|
||||||
|
</div>
|
||||||
|
<div className="fleet-metric">
|
||||||
|
<div className="fleet-metric__label">飞行时长</div>
|
||||||
|
<div className="fleet-metric__value">{fleet.flightHoursToday}h</div>
|
||||||
|
<div className="fleet-metric__sub">今日累计</div>
|
||||||
|
</div>
|
||||||
|
<div className="fleet-metric">
|
||||||
|
<div className="fleet-metric__label">飞行里程</div>
|
||||||
|
<div className="fleet-metric__value">{fleet.flightMileageToday}km</div>
|
||||||
|
<div className="fleet-metric__sub">含航线复飞</div>
|
||||||
|
</div>
|
||||||
|
<div className="fleet-metric">
|
||||||
|
<div className="fleet-metric__label">可用机库</div>
|
||||||
|
<div className="fleet-metric__value">
|
||||||
|
{fleet.dockOnline}/{fleet.dockTotal}
|
||||||
|
</div>
|
||||||
|
<div className="fleet-metric__sub">在线/总量</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="fleet-split">
|
||||||
|
<div className="fleet-split__left">
|
||||||
|
<div className="panel-subtitle">机队状态占比</div>
|
||||||
|
<div className="chart-wrapper">
|
||||||
|
{Object.keys(droneStatusPieConfig).length ? (
|
||||||
|
<Pie {...droneStatusPieConfig} />
|
||||||
|
) : (
|
||||||
|
<Empty image={Empty.PRESENTED_IMAGE_SIMPLE} description="暂无无人机数据" />
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="fleet-split__right">
|
||||||
|
<div className="panel-subtitle">重点区域覆盖</div>
|
||||||
|
<div className="region-list">
|
||||||
|
{visibleRegionCoverage.map((r) => (
|
||||||
|
<div key={r.id} className="region-item">
|
||||||
|
<div className="region-item__head">
|
||||||
|
<span className="region-item__name">{r.name}</span>
|
||||||
|
<span className="region-item__meta">
|
||||||
|
<Tag className="region-item__tag" color={regionRiskColor(r.risk)}>
|
||||||
|
{r.risk === 'critical' ? '高风险' : r.risk === 'warning' ? '关注' : '正常'}
|
||||||
|
</Tag>
|
||||||
|
<span className="region-item__time">{r.updatedAt}</span>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div className="region-item__bar">
|
||||||
|
<Progress
|
||||||
|
percent={r.coverage}
|
||||||
|
size="small"
|
||||||
|
showInfo={false}
|
||||||
|
strokeColor={regionRiskColor(r.risk)}
|
||||||
|
trailColor="rgba(255,255,255,0.08)"
|
||||||
|
/>
|
||||||
|
<span className="region-item__pct">{r.coverage}%</span>
|
||||||
|
<span className="region-item__pending">待处置 {r.pending}</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'snap',
|
||||||
|
label: 'AI快照',
|
||||||
|
children: (
|
||||||
|
<div className="tab-pane">
|
||||||
|
<Carousel autoplay autoplaySpeed={5500} dots className="snapshot-carousel">
|
||||||
|
{new Array(Math.max(1, Math.ceil(aiSnapshots.length / snapshotsPerPage)))
|
||||||
|
.fill(0)
|
||||||
|
.map((_, pageIdx) => {
|
||||||
|
const start = pageIdx * snapshotsPerPage;
|
||||||
|
const page = aiSnapshots.slice(start, start + snapshotsPerPage);
|
||||||
|
return (
|
||||||
|
<div key={`page-${pageIdx}`} className="snapshot-page">
|
||||||
|
<div className="snapshot-grid">
|
||||||
|
{page.map((s) => (
|
||||||
|
<div key={s.id} className={`snapshot-card snapshot-card--${s.severity}`}>
|
||||||
|
<div className="snapshot-card__head">
|
||||||
|
<span className="snapshot-card__tag">{s.tag}</span>
|
||||||
|
<span className="snapshot-card__time">{s.timeText}</span>
|
||||||
|
</div>
|
||||||
|
<div className="snapshot-card__title">{s.title}</div>
|
||||||
|
<div className="snapshot-card__meta">
|
||||||
|
<span className="snapshot-card__loc">{s.location}</span>
|
||||||
|
<span className="snapshot-card__conf">置信度 {s.confidence}%</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</Carousel>
|
||||||
|
</div>
|
||||||
|
),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'airspace',
|
||||||
|
label: '空域合规',
|
||||||
|
children: (
|
||||||
|
<div className="tab-pane airspace-pane">
|
||||||
|
<div className="airspace-top">
|
||||||
|
<div className="airspace-score">
|
||||||
|
<Progress
|
||||||
|
type="dashboard"
|
||||||
|
percent={airspace.complianceIndex}
|
||||||
|
strokeColor={{
|
||||||
|
'0%': 'rgba(255, 71, 87, 0.95)',
|
||||||
|
'55%': 'rgba(255, 184, 0, 0.95)',
|
||||||
|
'100%': 'rgba(0, 255, 136, 0.95)',
|
||||||
|
}}
|
||||||
|
trailColor="rgba(255,255,255,0.08)"
|
||||||
|
size={airspaceGaugeSize}
|
||||||
|
/>
|
||||||
|
<div className="airspace-score__meta">
|
||||||
|
<div className="airspace-score__title">合规指数</div>
|
||||||
|
<div className="airspace-score__sub">围栏/禁飞/审批综合</div>
|
||||||
|
<div className="airspace-score__sub">城市安全指数 {airspace.safetyIndex}</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="airspace-metrics">
|
||||||
|
<div className="airspace-metric">
|
||||||
|
<div className="airspace-metric__val">{airspace.geofenceTriggers}</div>
|
||||||
|
<div className="airspace-metric__lbl">围栏触发</div>
|
||||||
|
</div>
|
||||||
|
<div className="airspace-metric">
|
||||||
|
<div className="airspace-metric__val">{airspace.noFlyWarnings}</div>
|
||||||
|
<div className="airspace-metric__lbl">禁飞预警</div>
|
||||||
|
</div>
|
||||||
|
<div className="airspace-metric">
|
||||||
|
<div className="airspace-metric__val">{airspace.approvalsToday}</div>
|
||||||
|
<div className="airspace-metric__lbl">今日审批</div>
|
||||||
|
</div>
|
||||||
|
<div className="airspace-metric">
|
||||||
|
<div className="airspace-metric__val">{airspace.approvalsPassRate}%</div>
|
||||||
|
<div className="airspace-metric__lbl">通过率</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="airspace-notes">
|
||||||
|
<div className="airspace-note">
|
||||||
|
<span className="airspace-note__dot" />
|
||||||
|
<span className="airspace-note__text">重点区域启用"低空走廊",优先保障应急任务快速通行。</span>
|
||||||
|
</div>
|
||||||
|
{compactLevel === 2 ? null : (
|
||||||
|
<>
|
||||||
|
<div className="airspace-note">
|
||||||
|
<span className="airspace-note__dot airspace-note__dot--warn" />
|
||||||
|
<span className="airspace-note__text">围栏触发或禁飞预警上升时,建议自动降级为"复核模式"。</span>
|
||||||
|
</div>
|
||||||
|
<div className="airspace-note">
|
||||||
|
<span className="airspace-note__dot airspace-note__dot--ok" />
|
||||||
|
<span className="airspace-note__text">审批通过率稳定后,可扩大夜航与多机协同策略的投放比例。</span>
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
),
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
/>
|
||||||
|
</Card>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default DroneInsightCard;
|
||||||
@@ -0,0 +1,260 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import { Card, Tabs, Empty } from 'antd';
|
||||||
|
import { EnvironmentOutlined } from '@ant-design/icons';
|
||||||
|
import { Funnel, RadialBar, Pie, Column, Rose, Line } from '@ant-design/plots';
|
||||||
|
import './card.less';
|
||||||
|
|
||||||
|
interface EventInsightCardProps {
|
||||||
|
eventFunnelData: any[];
|
||||||
|
eventTypeData: any[];
|
||||||
|
terminalPieData: any[];
|
||||||
|
taskTypeData: any[];
|
||||||
|
failureAnalysisData: any[];
|
||||||
|
annualData: any[];
|
||||||
|
}
|
||||||
|
|
||||||
|
const EventInsightCard: React.FC<EventInsightCardProps> = ({
|
||||||
|
eventFunnelData,
|
||||||
|
eventTypeData,
|
||||||
|
terminalPieData,
|
||||||
|
taskTypeData,
|
||||||
|
failureAnalysisData,
|
||||||
|
annualData,
|
||||||
|
}) => {
|
||||||
|
const funnelConfig: any = React.useMemo(() => {
|
||||||
|
return {
|
||||||
|
data: eventFunnelData,
|
||||||
|
xField: 'stage',
|
||||||
|
yField: 'value',
|
||||||
|
legend: false,
|
||||||
|
conversionTag: false,
|
||||||
|
tooltip: {
|
||||||
|
formatter: (d: any) => ({ name: d?.stage ?? d?.name ?? '阶段', value: d?.value ?? 0 }),
|
||||||
|
},
|
||||||
|
label: {
|
||||||
|
formatter: (d: any) => {
|
||||||
|
const stage = d?.stage ?? d?.name ?? d?.type ?? '阶段';
|
||||||
|
const value = d?.value ?? d?.count ?? 0;
|
||||||
|
return `${stage} ${value}`;
|
||||||
|
},
|
||||||
|
content: (d: any) => {
|
||||||
|
const stage = d?.stage ?? d?.name ?? d?.type ?? '阶段';
|
||||||
|
const value = d?.value ?? d?.count ?? 0;
|
||||||
|
return `${stage} ${value}`;
|
||||||
|
},
|
||||||
|
style: { fill: 'rgba(255,255,255,0.78)', fontSize: 12 },
|
||||||
|
},
|
||||||
|
color: ['#00d4ff', '#00ff88', '#ffb800', '#9d4edd', '#00d4ff'],
|
||||||
|
autoFit: true,
|
||||||
|
};
|
||||||
|
}, [eventFunnelData]);
|
||||||
|
|
||||||
|
const eventRadialConfig: any = React.useMemo(() => {
|
||||||
|
return {
|
||||||
|
data: eventTypeData,
|
||||||
|
xField: 'type',
|
||||||
|
yField: 'value',
|
||||||
|
radius: 0.88,
|
||||||
|
innerRadius: 0.25,
|
||||||
|
colorField: 'type',
|
||||||
|
color: ['#00d4ff', '#00ff88', '#ffb800', '#9d4edd', '#ff4757', '#13c2c2'],
|
||||||
|
legend: false,
|
||||||
|
label: { style: { fill: 'rgba(255,255,255,0.72)' } },
|
||||||
|
autoFit: true,
|
||||||
|
};
|
||||||
|
}, [eventTypeData]);
|
||||||
|
|
||||||
|
const terminalPieConfig: any = React.useMemo(() => {
|
||||||
|
const data = terminalPieData || [];
|
||||||
|
return {
|
||||||
|
data,
|
||||||
|
angleField: 'count',
|
||||||
|
colorField: 'name',
|
||||||
|
radius: 0.8,
|
||||||
|
innerRadius: 0.58,
|
||||||
|
label: {
|
||||||
|
text: (datum: any) => {
|
||||||
|
const total = data.reduce((sum, d) => sum + (d.count || 0), 0);
|
||||||
|
const count = datum?.count ?? 0;
|
||||||
|
const percent = total > 0 ? ((count / total) * 100).toFixed(0) : '0';
|
||||||
|
return `${datum?.name || ''} ${percent}%`;
|
||||||
|
},
|
||||||
|
style: { fill: 'rgba(255,255,255,0.7)' },
|
||||||
|
},
|
||||||
|
legend: false,
|
||||||
|
autoFit: true,
|
||||||
|
};
|
||||||
|
}, [terminalPieData]);
|
||||||
|
|
||||||
|
const taskTypeColumnConfig: any = React.useMemo(() => {
|
||||||
|
return {
|
||||||
|
data: taskTypeData,
|
||||||
|
xField: 'type',
|
||||||
|
yField: 'value',
|
||||||
|
columnWidthRatio: 0.55,
|
||||||
|
color: ['#00d4ff'],
|
||||||
|
label: { style: { fill: 'rgba(255,255,255,0.85)' } },
|
||||||
|
xAxis: { label: { style: { fill: 'rgba(255,255,255,0.62)' } } },
|
||||||
|
yAxis: {
|
||||||
|
label: { style: { fill: 'rgba(255,255,255,0.62)' } },
|
||||||
|
grid: { line: { style: { stroke: 'rgba(255,255,255,0.08)' } } },
|
||||||
|
},
|
||||||
|
legend: false,
|
||||||
|
autoFit: true,
|
||||||
|
};
|
||||||
|
}, [taskTypeData]);
|
||||||
|
|
||||||
|
const riskRoseConfig: any = React.useMemo(() => {
|
||||||
|
return {
|
||||||
|
data: failureAnalysisData,
|
||||||
|
xField: 'type',
|
||||||
|
yField: 'value',
|
||||||
|
seriesField: 'type',
|
||||||
|
radius: 0.85,
|
||||||
|
innerRadius: 0.25,
|
||||||
|
colorField: 'type',
|
||||||
|
color: ['#ffb800', '#00d4ff', '#00ff88', '#9d4edd', '#ff4757', '#13c2c2'],
|
||||||
|
label: {
|
||||||
|
content: (d: any) => `${d.type}\n${d.value}`,
|
||||||
|
style: { fill: 'rgba(255,255,255,0.72)' },
|
||||||
|
},
|
||||||
|
legend: false,
|
||||||
|
autoFit: true,
|
||||||
|
};
|
||||||
|
}, [failureAnalysisData]);
|
||||||
|
|
||||||
|
const annualLineConfig: any = React.useMemo(() => {
|
||||||
|
return {
|
||||||
|
data: annualData,
|
||||||
|
xField: 'month',
|
||||||
|
yField: 'value',
|
||||||
|
seriesField: 'type',
|
||||||
|
smooth: true,
|
||||||
|
color: ['#00d4ff', '#00ff88'],
|
||||||
|
areaStyle: { fillOpacity: 0.12 },
|
||||||
|
xAxis: { label: { style: { fill: 'rgba(255,255,255,0.62)' } } },
|
||||||
|
yAxis: {
|
||||||
|
label: { style: { fill: 'rgba(255,255,255,0.62)' } },
|
||||||
|
grid: { line: { style: { stroke: 'rgba(255,255,255,0.08)' } } },
|
||||||
|
},
|
||||||
|
legend: { position: 'top', itemName: { style: { fill: 'rgba(255,255,255,0.72)' } } },
|
||||||
|
autoFit: true,
|
||||||
|
};
|
||||||
|
}, [annualData]);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Card
|
||||||
|
title={
|
||||||
|
<span className="panel-title">
|
||||||
|
<EnvironmentOutlined /> 事件处置与洞察
|
||||||
|
</span>
|
||||||
|
}
|
||||||
|
className="dashboard-card glass-panel"
|
||||||
|
size="small"
|
||||||
|
style={{ height: '100%', minHeight: 0, maxHeight: '100%' }}
|
||||||
|
styles={{
|
||||||
|
header: { flex: '0 0 auto', minHeight: 40, padding: '0 12px', borderBottom: '1px solid rgba(0, 212, 255, 0.1)' },
|
||||||
|
body: { flex: 1, padding: 12, overflow: 'hidden', display: 'flex', flexDirection: 'column', minHeight: 0 },
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Tabs
|
||||||
|
size="small"
|
||||||
|
className="dash-tabs"
|
||||||
|
items={[
|
||||||
|
{
|
||||||
|
key: 'funnel',
|
||||||
|
label: '处置闭环',
|
||||||
|
children: (
|
||||||
|
<div className="tab-pane">
|
||||||
|
<div className="chart-wrapper">
|
||||||
|
<Funnel {...funnelConfig} />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'types',
|
||||||
|
label: '类型分布',
|
||||||
|
children: (
|
||||||
|
<div className="tab-pane">
|
||||||
|
<div className="chart-wrapper">
|
||||||
|
<RadialBar {...eventRadialConfig} />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'asset',
|
||||||
|
label: '资产构成',
|
||||||
|
children: terminalPieData?.length ? (
|
||||||
|
<div className="tab-pane">
|
||||||
|
<div className="chart-wrapper">
|
||||||
|
<Pie {...terminalPieConfig} />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
) : (
|
||||||
|
<div className="tab-pane">
|
||||||
|
<div className="empty-holder">
|
||||||
|
<Empty image={Empty.PRESENTED_IMAGE_SIMPLE} description="暂无资产数据" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'capacity',
|
||||||
|
label: '作业结构',
|
||||||
|
children: taskTypeData?.length ? (
|
||||||
|
<div className="tab-pane">
|
||||||
|
<div className="chart-wrapper">
|
||||||
|
<Column {...taskTypeColumnConfig} />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
) : (
|
||||||
|
<div className="tab-pane">
|
||||||
|
<div className="empty-holder">
|
||||||
|
<Empty image={Empty.PRESENTED_IMAGE_SIMPLE} description="暂无结构数据" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'risk',
|
||||||
|
label: '风险画像',
|
||||||
|
children: failureAnalysisData?.length ? (
|
||||||
|
<div className="tab-pane">
|
||||||
|
<div className="chart-wrapper">
|
||||||
|
<Rose {...riskRoseConfig} />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
) : (
|
||||||
|
<div className="tab-pane">
|
||||||
|
<div className="empty-holder">
|
||||||
|
<Empty image={Empty.PRESENTED_IMAGE_SIMPLE} description="暂无风险数据" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'year',
|
||||||
|
label: '年度趋势',
|
||||||
|
children: annualData?.length ? (
|
||||||
|
<div className="tab-pane">
|
||||||
|
<div className="chart-wrapper">
|
||||||
|
<Line {...annualLineConfig} />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
) : (
|
||||||
|
<div className="tab-pane">
|
||||||
|
<div className="empty-holder">
|
||||||
|
<Empty image={Empty.PRESENTED_IMAGE_SIMPLE} description="暂无年度数据" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
),
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
/>
|
||||||
|
</Card>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default EventInsightCard;
|
||||||
@@ -0,0 +1,93 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import { Card, List, Tag, Empty } from 'antd';
|
||||||
|
import { AlertOutlined } from '@ant-design/icons';
|
||||||
|
|
||||||
|
interface EventItem {
|
||||||
|
id: string;
|
||||||
|
title: string;
|
||||||
|
timeText: string;
|
||||||
|
location: string;
|
||||||
|
status: string;
|
||||||
|
source: string;
|
||||||
|
desc: string;
|
||||||
|
severity: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface EventStreamCardProps {
|
||||||
|
events: EventItem[];
|
||||||
|
}
|
||||||
|
|
||||||
|
const severityColor = (severity: string) => {
|
||||||
|
if (severity === 'critical') return '#ff4757';
|
||||||
|
if (severity === 'warning') return '#ffb800';
|
||||||
|
return '#00d4ff';
|
||||||
|
};
|
||||||
|
|
||||||
|
const statusTagColor = (status: string) => {
|
||||||
|
if (status === '已闭环') return '#00ff88';
|
||||||
|
if (status === '处理中') return '#9d4edd';
|
||||||
|
if (status === '已派单') return '#00d4ff';
|
||||||
|
return 'rgba(255,255,255,0.25)';
|
||||||
|
};
|
||||||
|
|
||||||
|
const EventStreamCard: React.FC<EventStreamCardProps> = ({ events }) => {
|
||||||
|
return (
|
||||||
|
<Card
|
||||||
|
title={
|
||||||
|
<span style={{ color: 'rgba(255,255,255,0.92)', display: 'flex', alignItems: 'center', gap: 8 }}>
|
||||||
|
<AlertOutlined style={{ color: 'rgba(0,212,255,0.95)' }} /> 城市事件流
|
||||||
|
</span>
|
||||||
|
}
|
||||||
|
extra={<Tag color="cyan">实时</Tag>}
|
||||||
|
style={{
|
||||||
|
height: '100%',
|
||||||
|
background: 'rgba(19, 26, 61, 0.7)',
|
||||||
|
border: '1px solid rgba(0, 212, 255, 0.15)',
|
||||||
|
borderRadius: 8,
|
||||||
|
display: 'flex',
|
||||||
|
flexDirection: 'column',
|
||||||
|
}}
|
||||||
|
styles={{
|
||||||
|
header: { flex: '0 0 auto', minHeight: 40, padding: '0 12px', borderBottom: '1px solid rgba(0, 212, 255, 0.1)' },
|
||||||
|
body: { flex: 1, padding: 12, overflow: 'hidden', display: 'flex', flexDirection: 'column', minHeight: 0 },
|
||||||
|
}}
|
||||||
|
size="small"
|
||||||
|
>
|
||||||
|
<div style={{ flex: 1, minHeight: 0, overflowY: 'auto', overflowX: 'hidden' }}>
|
||||||
|
<List
|
||||||
|
dataSource={events}
|
||||||
|
split={false}
|
||||||
|
locale={{ emptyText: <Empty image={Empty.PRESENTED_IMAGE_SIMPLE} description="暂无事件" /> }}
|
||||||
|
renderItem={(item) => (
|
||||||
|
<List.Item style={{ padding: '10px 0', borderBottom: '1px solid rgba(255,255,255,0.06)' }}>
|
||||||
|
<div style={{ display: 'flex', gap: 10, alignItems: 'flex-start', width: '100%' }}>
|
||||||
|
<div style={{
|
||||||
|
width: 8,
|
||||||
|
height: 8,
|
||||||
|
borderRadius: '50%',
|
||||||
|
marginTop: 6,
|
||||||
|
background: severityColor(item.severity),
|
||||||
|
flexShrink: 0,
|
||||||
|
}} />
|
||||||
|
<div style={{ flex: 1, minWidth: 0 }}>
|
||||||
|
<div style={{ display: 'flex', justifyContent: 'space-between', gap: 10, marginBottom: 4 }}>
|
||||||
|
<span style={{ fontSize: 13, fontWeight: 600, color: 'rgba(255,255,255,0.92)', overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}>{item.title}</span>
|
||||||
|
<span style={{ fontSize: 12, color: 'rgba(255,255,255,0.55)', fontFamily: 'monospace' }}>{item.timeText}</span>
|
||||||
|
</div>
|
||||||
|
<div style={{ display: 'flex', flexWrap: 'wrap', gap: 6, alignItems: 'center', marginBottom: 4 }}>
|
||||||
|
<span style={{ fontSize: 12, color: 'rgba(255,255,255,0.65)' }}>{item.location}</span>
|
||||||
|
<Tag color={statusTagColor(item.status)} style={{ marginRight: 0 }}>{item.status}</Tag>
|
||||||
|
<Tag color="rgba(0,212,255,0.18)" style={{ marginRight: 0 }}>{item.source}</Tag>
|
||||||
|
</div>
|
||||||
|
<div style={{ fontSize: 12, color: 'rgba(255,255,255,0.56)', lineHeight: 1.3 }}>{item.desc}</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</List.Item>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</Card>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default EventStreamCard;
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import './card.less';
|
||||||
|
|
||||||
|
interface KpiItem {
|
||||||
|
key: string;
|
||||||
|
label: string;
|
||||||
|
value: string | number;
|
||||||
|
unit?: string;
|
||||||
|
sub?: string;
|
||||||
|
accent?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface KpiStripProps {
|
||||||
|
kpis: KpiItem[];
|
||||||
|
}
|
||||||
|
|
||||||
|
const KpiStrip: React.FC<KpiStripProps> = ({ kpis }) => {
|
||||||
|
return (
|
||||||
|
<div className="kpi-strip">
|
||||||
|
{kpis.map((kpi) => (
|
||||||
|
<div key={kpi.key} className={`kpi-tile kpi-tile--${kpi.accent || 'blue'}`}>
|
||||||
|
<div className="kpi-tile__head">
|
||||||
|
<span className="kpi-tile__label">{kpi.label}</span>
|
||||||
|
<span className="kpi-tile__dot" />
|
||||||
|
</div>
|
||||||
|
<div className="kpi-tile__value">
|
||||||
|
<span className="kpi-tile__num">{kpi.value}</span>
|
||||||
|
{kpi.unit ? <span className="kpi-tile__unit">{kpi.unit}</span> : null}
|
||||||
|
</div>
|
||||||
|
{kpi.sub ? <div className="kpi-tile__sub">{kpi.sub}</div> : null}
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default KpiStrip;
|
||||||
@@ -0,0 +1,99 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import { Button, Tag } from 'antd';
|
||||||
|
import { SafetyCertificateOutlined, AimOutlined, EnvironmentOutlined } from '@ant-design/icons';
|
||||||
|
import { history } from 'umi';
|
||||||
|
import './card.less';
|
||||||
|
|
||||||
|
interface TwinPortalProps {
|
||||||
|
fleet: {
|
||||||
|
droneOnline: number;
|
||||||
|
droneInFlight: number;
|
||||||
|
dockOnline: number;
|
||||||
|
};
|
||||||
|
airspace: {
|
||||||
|
complianceIndex: number;
|
||||||
|
};
|
||||||
|
compactLevel: 0 | 1 | 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
const TwinPortal: React.FC<TwinPortalProps> = ({ fleet, airspace, compactLevel }) => {
|
||||||
|
const goTo3D = () => {
|
||||||
|
history.push('/map3d?from=dashboard');
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="twin-portal">
|
||||||
|
<div className="twin-portal__grid" />
|
||||||
|
<div className="twin-portal__sweep" />
|
||||||
|
<div className="twin-portal__overlay">
|
||||||
|
<div className="twin-portal__top">
|
||||||
|
{compactLevel === 2 ? (
|
||||||
|
<div className="twin-portal__tags">
|
||||||
|
<Tag color="cyan">事件点位</Tag>
|
||||||
|
<Tag color="green">AI识别</Tag>
|
||||||
|
</div>
|
||||||
|
) : (
|
||||||
|
<>
|
||||||
|
<div className="twin-portal__tags">
|
||||||
|
<Tag color="cyan">事件点位</Tag>
|
||||||
|
<Tag color="geekblue">航线叠加</Tag>
|
||||||
|
<Tag color="purple">电子围栏</Tag>
|
||||||
|
<Tag color="green">AI识别</Tag>
|
||||||
|
</div>
|
||||||
|
<div className="twin-portal__chips">
|
||||||
|
<span className="chip">
|
||||||
|
<SafetyCertificateOutlined /> 安全态势
|
||||||
|
</span>
|
||||||
|
<span className="chip">
|
||||||
|
<AimOutlined /> 空域管理
|
||||||
|
</span>
|
||||||
|
<span className="chip">
|
||||||
|
<EnvironmentOutlined /> 数字孪生
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="twin-portal__center">
|
||||||
|
<div className="twin-portal__title">全域数字孪生中枢</div>
|
||||||
|
<div className="twin-portal__desc">空地协同巡检 · 城市事件识别 · 应急快速响应</div>
|
||||||
|
<Button type="primary" shape="round" size="large" onClick={goTo3D} className="twin-portal__btn">
|
||||||
|
进入 3D 监控视图
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="twin-portal__bottom">
|
||||||
|
<div className="mini-metric">
|
||||||
|
<span className="mini-metric__label">在线无人机</span>
|
||||||
|
<span className="mini-metric__value">{fleet.droneOnline}</span>
|
||||||
|
</div>
|
||||||
|
<div className="mini-metric">
|
||||||
|
<span className="mini-metric__label">在飞架次</span>
|
||||||
|
<span className="mini-metric__value">{fleet.droneInFlight}</span>
|
||||||
|
</div>
|
||||||
|
{compactLevel === 2 ? null : (
|
||||||
|
<>
|
||||||
|
<div className="mini-metric">
|
||||||
|
<span className="mini-metric__label">可用机库</span>
|
||||||
|
<span className="mini-metric__value">{fleet.dockOnline}</span>
|
||||||
|
</div>
|
||||||
|
<div className="mini-metric">
|
||||||
|
<span className="mini-metric__label">合规指数</span>
|
||||||
|
<span
|
||||||
|
className={`mini-metric__value${
|
||||||
|
airspace.complianceIndex < 85 ? ' mini-metric__value--warn' : ''
|
||||||
|
}`}
|
||||||
|
>
|
||||||
|
{airspace.complianceIndex}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default TwinPortal;
|
||||||
@@ -0,0 +1,733 @@
|
|||||||
|
/* 组件级样式 - 每个卡片独立管理高度 */
|
||||||
|
|
||||||
|
.dashboard-card {
|
||||||
|
height: 100%;
|
||||||
|
min-height: 0;
|
||||||
|
max-height: 100%;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
background: transparent !important;
|
||||||
|
border-radius: 8px;
|
||||||
|
overflow: hidden;
|
||||||
|
|
||||||
|
&.glass-panel {
|
||||||
|
position: relative;
|
||||||
|
background: rgba(19, 26, 61, 0.7) !important;
|
||||||
|
border: 1px solid rgba(0, 212, 255, 0.15) !important;
|
||||||
|
backdrop-filter: blur(8px);
|
||||||
|
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
|
||||||
|
|
||||||
|
&::before {
|
||||||
|
content: '';
|
||||||
|
position: absolute;
|
||||||
|
inset: 0;
|
||||||
|
pointer-events: none;
|
||||||
|
background:
|
||||||
|
linear-gradient(90deg, rgba(0, 212, 255, 0.6), transparent 60px) top left / 60px 2px no-repeat,
|
||||||
|
linear-gradient(180deg, rgba(0, 212, 255, 0.6), transparent 60px) top left / 2px 60px no-repeat,
|
||||||
|
linear-gradient(270deg, rgba(0, 212, 255, 0.6), transparent 60px) top right / 60px 2px no-repeat,
|
||||||
|
linear-gradient(180deg, rgba(0, 212, 255, 0.6), transparent 60px) top right / 2px 60px no-repeat,
|
||||||
|
linear-gradient(90deg, rgba(0, 212, 255, 0.6), transparent 60px) bottom left / 60px 2px no-repeat,
|
||||||
|
linear-gradient(0deg, rgba(0, 212, 255, 0.6), transparent 60px) bottom left / 2px 60px no-repeat,
|
||||||
|
linear-gradient(270deg, rgba(0, 212, 255, 0.6), transparent 60px) bottom right / 60px 2px no-repeat,
|
||||||
|
linear-gradient(0deg, rgba(0, 212, 255, 0.6), transparent 60px) bottom right / 2px 60px no-repeat;
|
||||||
|
opacity: 0.35;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
:global(.ant-card-head) {
|
||||||
|
min-height: 40px;
|
||||||
|
padding: 0 12px;
|
||||||
|
border-bottom: 1px solid rgba(0, 212, 255, 0.1);
|
||||||
|
flex: 0 0 auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
:global(.ant-card-body) {
|
||||||
|
flex: 1;
|
||||||
|
padding: 12px;
|
||||||
|
overflow: hidden;
|
||||||
|
position: relative;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
min-height: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 事件列表滚动容器 */
|
||||||
|
.event-list-scroll {
|
||||||
|
flex: 1;
|
||||||
|
min-height: 0;
|
||||||
|
overflow-x: hidden;
|
||||||
|
overflow-y: auto;
|
||||||
|
padding-right: 4px;
|
||||||
|
|
||||||
|
&::-webkit-scrollbar {
|
||||||
|
width: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
&::-webkit-scrollbar-thumb {
|
||||||
|
background: rgba(0, 212, 255, 0.22);
|
||||||
|
border-radius: 2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
:global(.ant-list) {
|
||||||
|
height: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
:global(.ant-spin-nested-loading),
|
||||||
|
:global(.ant-spin-container) {
|
||||||
|
height: auto;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 通用样式复用 */
|
||||||
|
.panel-title {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
|
color: rgba(255, 255, 255, 0.92);
|
||||||
|
|
||||||
|
:global(.anticon) {
|
||||||
|
color: rgba(0, 212, 255, 0.95);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.panel-subtitle {
|
||||||
|
margin: -2px 0 8px;
|
||||||
|
font-size: 12px;
|
||||||
|
color: rgba(255, 255, 255, 0.55);
|
||||||
|
letter-spacing: 0.2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chart-wrapper {
|
||||||
|
flex: 1;
|
||||||
|
width: 100%;
|
||||||
|
min-height: 0;
|
||||||
|
overflow: hidden;
|
||||||
|
|
||||||
|
> div {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
:global(canvas) {
|
||||||
|
max-width: 100%;
|
||||||
|
max-height: 100%;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Tabs 样式 */
|
||||||
|
.dash-tabs {
|
||||||
|
height: 100%;
|
||||||
|
min-height: 0;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
overflow: hidden;
|
||||||
|
|
||||||
|
:global(.ant-tabs-nav) {
|
||||||
|
margin: 0 0 8px;
|
||||||
|
flex: 0 0 auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
:global(.ant-tabs-nav::before) {
|
||||||
|
border-bottom-color: rgba(0, 212, 255, 0.12);
|
||||||
|
}
|
||||||
|
|
||||||
|
:global(.ant-tabs-tab) {
|
||||||
|
color: rgba(255, 255, 255, 0.62);
|
||||||
|
}
|
||||||
|
|
||||||
|
:global(.ant-tabs-tab.ant-tabs-tab-active .ant-tabs-tab-btn) {
|
||||||
|
color: rgba(255, 255, 255, 0.92);
|
||||||
|
}
|
||||||
|
|
||||||
|
:global(.ant-tabs-ink-bar) {
|
||||||
|
background: rgba(0, 212, 255, 0.9);
|
||||||
|
}
|
||||||
|
|
||||||
|
:global(.ant-tabs-content-holder) {
|
||||||
|
flex: 1;
|
||||||
|
min-height: 0;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
:global(.ant-tabs-content) {
|
||||||
|
height: 100%;
|
||||||
|
min-height: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
:global(.ant-tabs-tabpane) {
|
||||||
|
height: 100%;
|
||||||
|
min-height: 0;
|
||||||
|
padding: 0;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.tab-pane {
|
||||||
|
height: 100%;
|
||||||
|
min-height: 0;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.empty-holder {
|
||||||
|
height: 100%;
|
||||||
|
flex: 1;
|
||||||
|
min-height: 0;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
color: rgba(255, 255, 255, 0.55);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 事件列表项样式 */
|
||||||
|
.event-item {
|
||||||
|
padding: 10px 0 !important;
|
||||||
|
border-bottom: 1px solid rgba(255, 255, 255, 0.06) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.event-item__row {
|
||||||
|
display: flex;
|
||||||
|
gap: 10px;
|
||||||
|
align-items: flex-start;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.event-item__badge {
|
||||||
|
width: 8px;
|
||||||
|
height: 8px;
|
||||||
|
border-radius: 50%;
|
||||||
|
margin-top: 6px;
|
||||||
|
box-shadow: 0 0 12px rgba(0, 0, 0, 0.22);
|
||||||
|
flex: 0 0 auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.event-item__content {
|
||||||
|
flex: 1;
|
||||||
|
min-width: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.event-item__head {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
gap: 10px;
|
||||||
|
margin-bottom: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.event-item__title {
|
||||||
|
font-size: 13px;
|
||||||
|
font-weight: 600;
|
||||||
|
color: rgba(255, 255, 255, 0.92);
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.event-item__time {
|
||||||
|
font-size: 12px;
|
||||||
|
color: rgba(255, 255, 255, 0.55);
|
||||||
|
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
|
||||||
|
}
|
||||||
|
|
||||||
|
.event-item__meta {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
gap: 6px;
|
||||||
|
align-items: center;
|
||||||
|
margin-bottom: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.event-item__loc {
|
||||||
|
font-size: 12px;
|
||||||
|
color: rgba(255, 255, 255, 0.65);
|
||||||
|
}
|
||||||
|
|
||||||
|
.event-item__tag {
|
||||||
|
margin-inline-end: 0 !important;
|
||||||
|
border: 1px solid rgba(255, 255, 255, 0.12) !important;
|
||||||
|
color: rgba(255, 255, 255, 0.82) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.event-item__desc {
|
||||||
|
font-size: 12px;
|
||||||
|
color: rgba(255, 255, 255, 0.56);
|
||||||
|
line-height: 1.3;
|
||||||
|
display: -webkit-box;
|
||||||
|
-webkit-box-orient: vertical;
|
||||||
|
-webkit-line-clamp: 2;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 任务筛选器样式 */
|
||||||
|
.task-filter {
|
||||||
|
:global(.ant-segmented) {
|
||||||
|
background: rgba(0, 212, 255, 0.06);
|
||||||
|
border: 1px solid rgba(0, 212, 255, 0.18);
|
||||||
|
}
|
||||||
|
|
||||||
|
:global(.ant-segmented-item-label) {
|
||||||
|
color: rgba(255, 255, 255, 0.75);
|
||||||
|
font-size: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
:global(.ant-segmented-item-selected) {
|
||||||
|
background: rgba(0, 212, 255, 0.22) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
:global(.ant-picker) {
|
||||||
|
background: rgba(0, 212, 255, 0.06);
|
||||||
|
border: 1px solid rgba(0, 212, 255, 0.18);
|
||||||
|
color: rgba(255, 255, 255, 0.85);
|
||||||
|
}
|
||||||
|
|
||||||
|
:global(.ant-picker-input > input) {
|
||||||
|
color: rgba(255, 255, 255, 0.85);
|
||||||
|
font-size: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
:global(.ant-picker-suffix) {
|
||||||
|
color: rgba(255, 255, 255, 0.55);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Dispatch 样式 */
|
||||||
|
.dispatch-grid {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: 1fr 1fr;
|
||||||
|
gap: 8px;
|
||||||
|
flex: 0 0 auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dispatch-stat {
|
||||||
|
padding: 8px 10px;
|
||||||
|
border-radius: 10px;
|
||||||
|
background: rgba(255, 255, 255, 0.04);
|
||||||
|
border: 1px solid rgba(255, 255, 255, 0.08);
|
||||||
|
}
|
||||||
|
|
||||||
|
.dispatch-stat__val {
|
||||||
|
font-size: 18px;
|
||||||
|
font-weight: 800;
|
||||||
|
color: rgba(255, 255, 255, 0.92);
|
||||||
|
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dispatch-stat__lbl {
|
||||||
|
margin-top: 2px;
|
||||||
|
font-size: 11px;
|
||||||
|
color: rgba(255, 255, 255, 0.55);
|
||||||
|
}
|
||||||
|
|
||||||
|
.dispatch-stat__val--pending { color: rgba(255, 184, 0, 0.92); }
|
||||||
|
.dispatch-stat__val--running { color: rgba(0, 212, 255, 0.92); }
|
||||||
|
.dispatch-stat__val--done { color: rgba(0, 255, 136, 0.92); }
|
||||||
|
.dispatch-stat__val--fail { color: rgba(255, 71, 87, 0.92); }
|
||||||
|
|
||||||
|
.dispatch-highlight {
|
||||||
|
grid-column: 1 / -1;
|
||||||
|
padding: 8px 12px;
|
||||||
|
border-radius: 10px;
|
||||||
|
border: 1px solid rgba(0, 255, 136, 0.18);
|
||||||
|
background:
|
||||||
|
radial-gradient(circle at 20% 20%, rgba(0, 255, 136, 0.12), transparent 55%),
|
||||||
|
linear-gradient(180deg, rgba(19, 26, 61, 0.78), rgba(10, 14, 39, 0.62));
|
||||||
|
display: flex;
|
||||||
|
align-items: baseline;
|
||||||
|
justify-content: space-between;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dispatch-highlight__val {
|
||||||
|
font-size: clamp(20px, 3vh, 28px);
|
||||||
|
font-weight: 900;
|
||||||
|
color: rgba(0, 255, 136, 0.92);
|
||||||
|
letter-spacing: 1px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dispatch-highlight__lbl {
|
||||||
|
font-size: 11px;
|
||||||
|
color: rgba(255, 255, 255, 0.60);
|
||||||
|
}
|
||||||
|
|
||||||
|
.dispatch-trend {
|
||||||
|
margin-top: 8px;
|
||||||
|
min-height: 0;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
flex: 1;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dispatch-trend .chart-wrapper {
|
||||||
|
flex: 1;
|
||||||
|
min-height: 80px;
|
||||||
|
padding: 0 4px 4px;
|
||||||
|
box-sizing: border-box;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dispatch-trend__title {
|
||||||
|
margin-bottom: 4px;
|
||||||
|
font-size: 11px;
|
||||||
|
color: rgba(255, 255, 255, 0.56);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 机队态势样式 */
|
||||||
|
.fleet-pane {
|
||||||
|
gap: 12px;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fleet-metrics {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(4, 1fr);
|
||||||
|
gap: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fleet-metric {
|
||||||
|
padding: 10px 12px;
|
||||||
|
border-radius: 12px;
|
||||||
|
border: 1px solid rgba(255, 255, 255, 0.10);
|
||||||
|
background:
|
||||||
|
radial-gradient(circle at 25% 20%, rgba(0, 212, 255, 0.14), transparent 55%),
|
||||||
|
linear-gradient(180deg, rgba(19, 26, 61, 0.74), rgba(10, 14, 39, 0.62));
|
||||||
|
}
|
||||||
|
|
||||||
|
.fleet-metric__label {
|
||||||
|
font-size: 12px;
|
||||||
|
color: rgba(255, 255, 255, 0.58);
|
||||||
|
}
|
||||||
|
|
||||||
|
.fleet-metric__value {
|
||||||
|
margin-top: 6px;
|
||||||
|
font-size: 22px;
|
||||||
|
font-weight: 800;
|
||||||
|
color: rgba(255, 255, 255, 0.92);
|
||||||
|
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fleet-metric__sub {
|
||||||
|
margin-top: 4px;
|
||||||
|
font-size: 12px;
|
||||||
|
color: rgba(255, 255, 255, 0.52);
|
||||||
|
}
|
||||||
|
|
||||||
|
.fleet-split {
|
||||||
|
flex: 1;
|
||||||
|
min-height: 0;
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.05fr);
|
||||||
|
gap: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fleet-split__left,
|
||||||
|
.fleet-split__right {
|
||||||
|
min-height: 0;
|
||||||
|
border-radius: 12px;
|
||||||
|
border: 1px solid rgba(255, 255, 255, 0.10);
|
||||||
|
background: rgba(255, 255, 255, 0.03);
|
||||||
|
padding: 10px 12px;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
}
|
||||||
|
|
||||||
|
.region-list {
|
||||||
|
flex: 1;
|
||||||
|
min-height: 0;
|
||||||
|
overflow: hidden;
|
||||||
|
padding-right: 2px;
|
||||||
|
|
||||||
|
&::-webkit-scrollbar {
|
||||||
|
width: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
&::-webkit-scrollbar-thumb {
|
||||||
|
background: rgba(0, 212, 255, 0.18);
|
||||||
|
border-radius: 2px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.region-item {
|
||||||
|
padding: 8px 10px 6px;
|
||||||
|
border-radius: 10px;
|
||||||
|
background: rgba(255, 255, 255, 0.02);
|
||||||
|
border: 1px solid rgba(255, 255, 255, 0.06);
|
||||||
|
margin-bottom: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.region-item__head {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
gap: 10px;
|
||||||
|
margin-bottom: 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.region-item__name {
|
||||||
|
flex: 1;
|
||||||
|
min-width: 0;
|
||||||
|
font-size: 13px;
|
||||||
|
font-weight: 600;
|
||||||
|
color: rgba(255, 255, 255, 0.88);
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.region-item__meta {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
|
flex: 0 0 auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.region-item__tag {
|
||||||
|
margin-inline-end: 0 !important;
|
||||||
|
border: 1px solid rgba(255, 255, 255, 0.12) !important;
|
||||||
|
color: rgba(255, 255, 255, 0.86) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.region-item__time {
|
||||||
|
font-size: 12px;
|
||||||
|
color: rgba(255, 255, 255, 0.55);
|
||||||
|
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
|
||||||
|
}
|
||||||
|
|
||||||
|
.region-item__bar {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: 1fr auto auto;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
|
|
||||||
|
:global(.ant-progress) {
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.region-item__pct {
|
||||||
|
width: 48px;
|
||||||
|
text-align: right;
|
||||||
|
font-size: 12px;
|
||||||
|
color: rgba(255, 255, 255, 0.72);
|
||||||
|
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
|
||||||
|
}
|
||||||
|
|
||||||
|
.region-item__pending {
|
||||||
|
font-size: 12px;
|
||||||
|
color: rgba(255, 255, 255, 0.52);
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 空域合规样式 */
|
||||||
|
.airspace-pane {
|
||||||
|
gap: 12px;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.airspace-top {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: 1.1fr 1fr;
|
||||||
|
gap: 12px;
|
||||||
|
min-height: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.airspace-score {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 12px;
|
||||||
|
padding: 10px 12px;
|
||||||
|
border-radius: 12px;
|
||||||
|
border: 1px solid rgba(255, 255, 255, 0.10);
|
||||||
|
background:
|
||||||
|
radial-gradient(circle at 18% 24%, rgba(0, 255, 136, 0.10), transparent 55%),
|
||||||
|
linear-gradient(180deg, rgba(19, 26, 61, 0.72), rgba(10, 14, 39, 0.62));
|
||||||
|
|
||||||
|
:global(.ant-progress) {
|
||||||
|
flex: 0 0 auto;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.airspace-score__meta {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 4px;
|
||||||
|
min-width: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.airspace-score__title {
|
||||||
|
font-size: 14px;
|
||||||
|
font-weight: 700;
|
||||||
|
color: rgba(255, 255, 255, 0.9);
|
||||||
|
}
|
||||||
|
|
||||||
|
.airspace-score__sub {
|
||||||
|
font-size: 12px;
|
||||||
|
color: rgba(255, 255, 255, 0.55);
|
||||||
|
}
|
||||||
|
|
||||||
|
.airspace-metrics {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(2, 1fr);
|
||||||
|
gap: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.airspace-metric {
|
||||||
|
padding: 10px 12px;
|
||||||
|
border-radius: 12px;
|
||||||
|
border: 1px solid rgba(255, 255, 255, 0.10);
|
||||||
|
background: rgba(255, 255, 255, 0.03);
|
||||||
|
}
|
||||||
|
|
||||||
|
.airspace-metric__val {
|
||||||
|
font-size: 22px;
|
||||||
|
font-weight: 800;
|
||||||
|
color: rgba(255, 255, 255, 0.92);
|
||||||
|
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
|
||||||
|
}
|
||||||
|
|
||||||
|
.airspace-metric__lbl {
|
||||||
|
margin-top: 4px;
|
||||||
|
font-size: 12px;
|
||||||
|
color: rgba(255, 255, 255, 0.55);
|
||||||
|
}
|
||||||
|
|
||||||
|
.airspace-notes {
|
||||||
|
flex: 1;
|
||||||
|
min-height: 0;
|
||||||
|
padding: 10px 12px;
|
||||||
|
border-radius: 12px;
|
||||||
|
border: 1px solid rgba(255, 255, 255, 0.10);
|
||||||
|
background: rgba(255, 255, 255, 0.03);
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.airspace-note {
|
||||||
|
display: flex;
|
||||||
|
gap: 10px;
|
||||||
|
align-items: flex-start;
|
||||||
|
}
|
||||||
|
|
||||||
|
.airspace-note__dot {
|
||||||
|
width: 8px;
|
||||||
|
height: 8px;
|
||||||
|
border-radius: 50%;
|
||||||
|
margin-top: 6px;
|
||||||
|
background: rgba(0, 212, 255, 0.9);
|
||||||
|
box-shadow: 0 0 10px rgba(0, 212, 255, 0.25);
|
||||||
|
flex: 0 0 auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.airspace-note__dot--warn {
|
||||||
|
background: rgba(255, 184, 0, 0.92);
|
||||||
|
box-shadow: 0 0 10px rgba(255, 184, 0, 0.25);
|
||||||
|
}
|
||||||
|
|
||||||
|
.airspace-note__dot--ok {
|
||||||
|
background: rgba(0, 255, 136, 0.92);
|
||||||
|
box-shadow: 0 0 10px rgba(0, 255, 136, 0.25);
|
||||||
|
}
|
||||||
|
|
||||||
|
.airspace-note__text {
|
||||||
|
font-size: 12px;
|
||||||
|
color: rgba(255, 255, 255, 0.62);
|
||||||
|
line-height: 1.35;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* AI快照样式 */
|
||||||
|
.snapshot-carousel {
|
||||||
|
height: 100%;
|
||||||
|
flex: 1;
|
||||||
|
min-height: 0;
|
||||||
|
|
||||||
|
:global(.slick-dots) {
|
||||||
|
bottom: -2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
:global(.slick-dots li button) {
|
||||||
|
background: rgba(255, 255, 255, 0.25) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
:global(.slick-dots li.slick-active button) {
|
||||||
|
background: rgba(0, 212, 255, 0.85) !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.snapshot-grid {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(2, 1fr);
|
||||||
|
gap: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.snapshot-card {
|
||||||
|
border-radius: 12px;
|
||||||
|
padding: 12px 12px 10px;
|
||||||
|
border: 1px solid rgba(0, 212, 255, 0.16);
|
||||||
|
background:
|
||||||
|
radial-gradient(circle at 20% 10%, rgba(0, 212, 255, 0.16), transparent 55%),
|
||||||
|
linear-gradient(180deg, rgba(19, 26, 61, 0.78), rgba(10, 14, 39, 0.62));
|
||||||
|
box-shadow: 0 10px 26px rgba(0, 0, 0, 0.22);
|
||||||
|
transition: transform 0.18s ease, border-color 0.18s ease;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
transform: translateY(-2px);
|
||||||
|
border-color: rgba(0, 212, 255, 0.28);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.snapshot-card__head {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
margin-bottom: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.snapshot-card__tag {
|
||||||
|
font-size: 12px;
|
||||||
|
color: rgba(255, 255, 255, 0.72);
|
||||||
|
padding: 2px 8px;
|
||||||
|
border-radius: 999px;
|
||||||
|
background: rgba(0, 212, 255, 0.10);
|
||||||
|
border: 1px solid rgba(0, 212, 255, 0.18);
|
||||||
|
}
|
||||||
|
|
||||||
|
.snapshot-card__time {
|
||||||
|
font-size: 12px;
|
||||||
|
color: rgba(255, 255, 255, 0.55);
|
||||||
|
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
|
||||||
|
}
|
||||||
|
|
||||||
|
.snapshot-card__title {
|
||||||
|
font-size: clamp(13px, 1.8vh, 16px);
|
||||||
|
font-weight: 700;
|
||||||
|
color: rgba(255, 255, 255, 0.92);
|
||||||
|
margin-bottom: 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.snapshot-card__meta {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
gap: 10px;
|
||||||
|
font-size: 12px;
|
||||||
|
color: rgba(255, 255, 255, 0.62);
|
||||||
|
}
|
||||||
|
|
||||||
|
.snapshot-card--critical { border-color: rgba(255, 71, 87, 0.26); }
|
||||||
|
.snapshot-card--warning { border-color: rgba(255, 184, 0, 0.24); }
|
||||||
|
.snapshot-card--normal { border-color: rgba(0, 212, 255, 0.16); }
|
||||||
|
|
||||||
|
@media (max-width: 1440px) {
|
||||||
|
.fleet-metrics {
|
||||||
|
grid-template-columns: repeat(2, 1fr);
|
||||||
|
}
|
||||||
|
|
||||||
|
.fleet-split {
|
||||||
|
grid-template-columns: 1fr;
|
||||||
|
}
|
||||||
|
|
||||||
|
.airspace-top {
|
||||||
|
grid-template-columns: 1fr;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
export { default as CityVitalCard } from './CityVitalCard';
|
||||||
|
export { default as EventStreamCard } from './EventStreamCard';
|
||||||
|
export { default as KpiStrip } from './KpiStrip';
|
||||||
|
export { default as TwinPortal } from './TwinPortal';
|
||||||
|
export { default as DroneInsightCard } from './DroneInsightCard';
|
||||||
|
export { default as DispatchCard } from './DispatchCard';
|
||||||
|
export { default as EventInsightCard } from './EventInsightCard';
|
||||||
@@ -0,0 +1,507 @@
|
|||||||
|
// 旧版通用监控大屏(留档备查)
|
||||||
|
import React, { useState, useEffect, useCallback, useMemo } from 'react';
|
||||||
|
import { Card, Button, List, Tag, Spin, message, DatePicker, Segmented, Space } from 'antd';
|
||||||
|
import {
|
||||||
|
DesktopOutlined,
|
||||||
|
WarningOutlined,
|
||||||
|
RocketOutlined,
|
||||||
|
EnvironmentOutlined,
|
||||||
|
PieChartOutlined,
|
||||||
|
FieldTimeOutlined
|
||||||
|
} from '@ant-design/icons';
|
||||||
|
import { Line, Pie, Column, Area, Rose } from '@ant-design/plots';
|
||||||
|
import { history } from 'umi';
|
||||||
|
import dayjs from 'dayjs';
|
||||||
|
import {
|
||||||
|
getDeviceStats,
|
||||||
|
getTaskStats,
|
||||||
|
getTrendData,
|
||||||
|
getMockAlerts,
|
||||||
|
DeviceStats,
|
||||||
|
TaskStats,
|
||||||
|
TrendItem,
|
||||||
|
AlertItem,
|
||||||
|
} from '@/services/dashboard';
|
||||||
|
import './index.less';
|
||||||
|
|
||||||
|
const Dashboard: React.FC = () => {
|
||||||
|
const [loading, setLoading] = useState(true);
|
||||||
|
const [deviceStats, setDeviceStats] = useState<DeviceStats | null>(null);
|
||||||
|
const [taskStats, setTaskStats] = useState<TaskStats | null>(null);
|
||||||
|
const [taskTrend, setTaskTrend] = useState<TrendItem[]>([]);
|
||||||
|
const [alerts, setAlerts] = useState<AlertItem[]>([]);
|
||||||
|
const [annualData, setAnnualData] = useState<any[]>([]);
|
||||||
|
const [failureAnalysisData, setFailureAnalysisData] = useState<any[]>([]);
|
||||||
|
const [taskTypeData, setTaskTypeData] = useState<any[]>([]);
|
||||||
|
const [taskStatType, setTaskStatType] = useState<'day' | 'month' | 'year'>('day');
|
||||||
|
const [taskStatDate, setTaskStatDate] = useState(dayjs());
|
||||||
|
const [tenantId, setTenantId] = useState<string | undefined>();
|
||||||
|
const [includeChildren, setIncludeChildren] = useState<boolean>(true);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
// 模拟年度数据
|
||||||
|
const mockAnnual: any[] = [];
|
||||||
|
for (let i = 1; i <= 12; i++) {
|
||||||
|
mockAnnual.push({
|
||||||
|
month: `${i}月`,
|
||||||
|
value: Math.floor(Math.random() * 500) + 100,
|
||||||
|
type: '任务总数',
|
||||||
|
});
|
||||||
|
mockAnnual.push({
|
||||||
|
month: `${i}月`,
|
||||||
|
value: Math.floor(Math.random() * 450) + 80,
|
||||||
|
type: '成功任务',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
setAnnualData(mockAnnual);
|
||||||
|
|
||||||
|
// 模拟失败原因数据
|
||||||
|
setFailureAnalysisData([
|
||||||
|
{ type: '信号丢失', value: 27 },
|
||||||
|
{ type: '电池不足', value: 25 },
|
||||||
|
{ type: '天气原因', value: 18 },
|
||||||
|
{ type: '机械故障', value: 15 },
|
||||||
|
{ type: '人为取消', value: 10 },
|
||||||
|
{ type: '其他', value: 5 },
|
||||||
|
]);
|
||||||
|
|
||||||
|
// 任务类型分布数据
|
||||||
|
setTaskTypeData([
|
||||||
|
{ type: '航线任务', value: 156 },
|
||||||
|
{ type: '一键起飞', value: 89 },
|
||||||
|
{ type: '手动控制', value: 45 },
|
||||||
|
]);
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const handler = (e: any) => {
|
||||||
|
const nextTenantId = e?.detail?.tenantId as string | undefined;
|
||||||
|
const nextIncludeChildren = !!e?.detail?.includeChildren;
|
||||||
|
setTenantId(nextTenantId);
|
||||||
|
setIncludeChildren(nextIncludeChildren);
|
||||||
|
};
|
||||||
|
window.addEventListener('tenant-change', handler as any);
|
||||||
|
return () => window.removeEventListener('tenant-change', handler as any);
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const fetchData = useCallback(async () => {
|
||||||
|
setLoading(true);
|
||||||
|
try {
|
||||||
|
const [deviceRes, taskRes, trendRes] = await Promise.all([
|
||||||
|
getDeviceStats({ tenantId, includeChildren }),
|
||||||
|
getTaskStats({
|
||||||
|
tenantId,
|
||||||
|
includeChildren,
|
||||||
|
statType: taskStatType,
|
||||||
|
date:
|
||||||
|
taskStatType === 'day'
|
||||||
|
? taskStatDate.format('YYYY-MM-DD')
|
||||||
|
: taskStatType === 'month'
|
||||||
|
? taskStatDate.format('YYYY-MM')
|
||||||
|
: taskStatDate.format('YYYY'),
|
||||||
|
}),
|
||||||
|
getTrendData(7),
|
||||||
|
]);
|
||||||
|
setDeviceStats(deviceRes);
|
||||||
|
setTaskStats(taskRes);
|
||||||
|
setTaskTrend(trendRes.taskTrend);
|
||||||
|
setAlerts(getMockAlerts());
|
||||||
|
} catch (error) {
|
||||||
|
console.error('获取数据失败:', error);
|
||||||
|
message.error('数据加载异常');
|
||||||
|
} finally {
|
||||||
|
setLoading(false);
|
||||||
|
}
|
||||||
|
}, [includeChildren, taskStatDate, taskStatType, tenantId]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!tenantId) return;
|
||||||
|
fetchData();
|
||||||
|
}, [fetchData]);
|
||||||
|
|
||||||
|
// 定时刷新和时间更新
|
||||||
|
useEffect(() => {
|
||||||
|
const dataTimer = setInterval(fetchData, 30000);
|
||||||
|
return () => {
|
||||||
|
clearInterval(dataTimer);
|
||||||
|
};
|
||||||
|
}, [fetchData]);
|
||||||
|
|
||||||
|
const goTo3D = () => {
|
||||||
|
// 传递来源页面,以便从map3d返回时能回到正确的大屏
|
||||||
|
history.push('/map3d?from=dashboard');
|
||||||
|
};
|
||||||
|
|
||||||
|
// --- 图表配置 ---
|
||||||
|
|
||||||
|
const taskTrendSeriesData = useMemo(() => {
|
||||||
|
return taskTrend.flatMap((t) => [
|
||||||
|
{ date: t.date, type: '创建', value: t.created || 0 },
|
||||||
|
{ date: t.date, type: '完成', value: t.completed || 0 },
|
||||||
|
{ date: t.date, type: '失败', value: t.failed || 0 },
|
||||||
|
]);
|
||||||
|
}, [taskTrend]);
|
||||||
|
|
||||||
|
// 近7日任务完成数趋势数据
|
||||||
|
const taskCompleteTrendData = useMemo(() => {
|
||||||
|
return taskTrend.map((t) => ({
|
||||||
|
date: t.date,
|
||||||
|
value: t.completed || 0,
|
||||||
|
}));
|
||||||
|
}, [taskTrend]);
|
||||||
|
|
||||||
|
const taskTrendConfig: any = {
|
||||||
|
data: taskTrendSeriesData,
|
||||||
|
xField: 'date',
|
||||||
|
yField: 'value',
|
||||||
|
seriesField: 'type',
|
||||||
|
smooth: true,
|
||||||
|
color: ['#00d4ff', '#00ff88', '#ffb800'],
|
||||||
|
areaStyle: {
|
||||||
|
fill: 'l(270) 0:#ffffff 0.5:#7ec2f3 1:#1890ff',
|
||||||
|
fillOpacity: 0.1,
|
||||||
|
},
|
||||||
|
xAxis: { label: { style: { fill: 'rgba(255,255,255,0.65)' } }, grid: null },
|
||||||
|
yAxis: { label: { style: { fill: 'rgba(255,255,255,0.65)' } }, grid: { line: { style: { stroke: 'rgba(255,255,255,0.1)' } } } },
|
||||||
|
tooltip: { showMarkers: true },
|
||||||
|
height: 180,
|
||||||
|
};
|
||||||
|
|
||||||
|
const pieConfig: any = {
|
||||||
|
data: deviceStats?.byType || [],
|
||||||
|
angleField: 'count',
|
||||||
|
colorField: 'name',
|
||||||
|
radius: 0.7,
|
||||||
|
innerRadius: 0.5,
|
||||||
|
label: {
|
||||||
|
text: (datum: any) => {
|
||||||
|
const name = datum?.name || '';
|
||||||
|
const count = datum?.count ?? 0;
|
||||||
|
const data = (deviceStats?.byType || []) as { name: string; count: number }[];
|
||||||
|
const total = data.reduce((sum, d) => sum + (d.count || 0), 0);
|
||||||
|
const percent = total > 0 ? ((count / total) * 100).toFixed(1) : 0;
|
||||||
|
return `${name} ${percent}%`;
|
||||||
|
},
|
||||||
|
style: { fill: 'rgba(255,255,255,0.65)' },
|
||||||
|
},
|
||||||
|
legend: { position: 'bottom', itemValue: { style: { fill: 'rgba(255,255,255,0.65)' } }, itemName: { style: { fill: 'rgba(255,255,255,0.65)' } } },
|
||||||
|
height: 200,
|
||||||
|
};
|
||||||
|
|
||||||
|
const columnConfig: any = {
|
||||||
|
data: taskTypeData,
|
||||||
|
xField: 'type',
|
||||||
|
yField: 'value',
|
||||||
|
seriesField: 'type',
|
||||||
|
color: ({ type }: any) => {
|
||||||
|
if(type === '航线任务') return '#00d4ff';
|
||||||
|
if(type === '一键起飞') return '#00ff88';
|
||||||
|
return '#ffb800';
|
||||||
|
},
|
||||||
|
label: {
|
||||||
|
text: (datum: any) => datum?.value?.toString() || '0',
|
||||||
|
style: { fill: '#fff' },
|
||||||
|
},
|
||||||
|
xAxis: { label: { style: { fill: 'rgba(255,255,255,0.65)' } } },
|
||||||
|
yAxis: { label: { style: { fill: 'rgba(255,255,255,0.65)' } }, grid: { line: { style: { stroke: 'rgba(255,255,255,0.1)' } } } },
|
||||||
|
legend: false,
|
||||||
|
height: 180,
|
||||||
|
};
|
||||||
|
|
||||||
|
const taskCompleteTrendConfig: any = {
|
||||||
|
data: taskCompleteTrendData,
|
||||||
|
xField: 'date',
|
||||||
|
yField: 'value',
|
||||||
|
smooth: true,
|
||||||
|
color: '#00ff88',
|
||||||
|
areaStyle: { fillOpacity: 0.15 },
|
||||||
|
xAxis: { label: { style: { fill: 'rgba(255,255,255,0.65)' } }, grid: null },
|
||||||
|
yAxis: {
|
||||||
|
label: { style: { fill: 'rgba(255,255,255,0.65)' } },
|
||||||
|
grid: { line: { style: { stroke: 'rgba(255,255,255,0.08)' } } },
|
||||||
|
},
|
||||||
|
tooltip: { showMarkers: true },
|
||||||
|
height: 160,
|
||||||
|
};
|
||||||
|
|
||||||
|
const areaConfig: any = {
|
||||||
|
data: annualData,
|
||||||
|
xField: 'month',
|
||||||
|
yField: 'value',
|
||||||
|
seriesField: 'type',
|
||||||
|
color: ['#00d4ff', '#00ff88'],
|
||||||
|
areaStyle: { fillOpacity: 0.3 },
|
||||||
|
xAxis: { label: { style: { fill: 'rgba(255,255,255,0.65)' } } },
|
||||||
|
yAxis: { label: { style: { fill: 'rgba(255,255,255,0.65)' } }, grid: { line: { style: { stroke: 'rgba(255,255,255,0.1)' } } } },
|
||||||
|
legend: { position: 'top-right', itemName: { style: { fill: '#fff' } } },
|
||||||
|
smooth: true,
|
||||||
|
height: 220,
|
||||||
|
};
|
||||||
|
|
||||||
|
const roseConfig: any = {
|
||||||
|
data: failureAnalysisData,
|
||||||
|
xField: 'type',
|
||||||
|
yField: 'value',
|
||||||
|
seriesField: 'type',
|
||||||
|
radius: 0.9,
|
||||||
|
label: {
|
||||||
|
text: (datum: any) => datum?.type || '',
|
||||||
|
style: { fill: '#fff' },
|
||||||
|
},
|
||||||
|
legend: { position: 'bottom', itemName: { style: { fill: 'rgba(255,255,255,0.65)' } } },
|
||||||
|
height: 200,
|
||||||
|
};
|
||||||
|
|
||||||
|
const taskStatusPieConfig: any = {
|
||||||
|
data: [
|
||||||
|
{ name: '待执行', value: taskStats?.pending || 0 },
|
||||||
|
{ name: '执行中', value: taskStats?.running || 0 },
|
||||||
|
{ name: '已完成', value: taskStats?.completed || 0 },
|
||||||
|
{ name: '已失败', value: taskStats?.failed || 0 },
|
||||||
|
],
|
||||||
|
angleField: 'value',
|
||||||
|
colorField: 'name',
|
||||||
|
radius: 0.85,
|
||||||
|
innerRadius: 0.55,
|
||||||
|
label: {
|
||||||
|
text: (datum: any) => {
|
||||||
|
const name = datum?.name || '';
|
||||||
|
const value = datum?.value ?? 0;
|
||||||
|
const total = (taskStats?.pending || 0) + (taskStats?.running || 0) + (taskStats?.completed || 0) + (taskStats?.failed || 0);
|
||||||
|
const percent = total > 0 ? ((value / total) * 100).toFixed(1) : 0;
|
||||||
|
return `${name} ${percent}%`;
|
||||||
|
},
|
||||||
|
style: { fill: 'rgba(255,255,255,0.65)' },
|
||||||
|
},
|
||||||
|
legend: { position: 'bottom', itemValue: { style: { fill: 'rgba(255,255,255,0.65)' } }, itemName: { style: { fill: 'rgba(255,255,255,0.65)' } } },
|
||||||
|
height: 190,
|
||||||
|
};
|
||||||
|
|
||||||
|
const getAlertColor = (level: string) => {
|
||||||
|
switch (level) {
|
||||||
|
case 'critical': return 'red';
|
||||||
|
case 'error': return 'orange';
|
||||||
|
case 'warning': return 'gold';
|
||||||
|
default: return 'blue';
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const taskPeriodText = useMemo(() => {
|
||||||
|
if (taskStatType === 'day') return '当日';
|
||||||
|
if (taskStatType === 'month') return '当月';
|
||||||
|
return '当年';
|
||||||
|
}, [taskStatType]);
|
||||||
|
|
||||||
|
const taskNewLabel = useMemo(() => {
|
||||||
|
if (taskStatType === 'day') return '当日任务';
|
||||||
|
if (taskStatType === 'month') return '当月任务';
|
||||||
|
return '当年任务';
|
||||||
|
}, [taskStatType]);
|
||||||
|
|
||||||
|
const datePickerFormat = useMemo(() => {
|
||||||
|
if (taskStatType === 'day') return 'YYYY-MM-DD';
|
||||||
|
if (taskStatType === 'month') return 'YYYY-MM';
|
||||||
|
return 'YYYY';
|
||||||
|
}, [taskStatType]);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="dashboard-page">
|
||||||
|
<div className="dashboard-bg-animation"></div>
|
||||||
|
|
||||||
|
<Spin spinning={loading} wrapperClassName="dashboard-spin">
|
||||||
|
<div className="dashboard-content">
|
||||||
|
<div className="dashboard-grid">
|
||||||
|
|
||||||
|
{/* 左侧栏:设备态势 */}
|
||||||
|
<div className="grid-col left-col">
|
||||||
|
<Card title="设备类型分布" className="panel-card glass-panel" size="small">
|
||||||
|
<div className="chart-wrapper">
|
||||||
|
<Pie {...pieConfig} />
|
||||||
|
</div>
|
||||||
|
</Card>
|
||||||
|
|
||||||
|
<Card title="任务类型统计" className="panel-card glass-panel" size="small">
|
||||||
|
<div className="chart-wrapper">
|
||||||
|
<Column {...columnConfig} />
|
||||||
|
</div>
|
||||||
|
</Card>
|
||||||
|
|
||||||
|
<Card title="近7日任务完成趋势" className="panel-card glass-panel" size="small">
|
||||||
|
<div className="chart-wrapper">
|
||||||
|
<Area {...taskCompleteTrendConfig} />
|
||||||
|
</div>
|
||||||
|
</Card>
|
||||||
|
|
||||||
|
<Card
|
||||||
|
title={<span><WarningOutlined className="icon-warning" /> 实时告警</span>}
|
||||||
|
className="panel-card glass-panel flex-grow"
|
||||||
|
size="small"
|
||||||
|
extra={<Tag color="#f50">Live</Tag>}
|
||||||
|
>
|
||||||
|
<div className="alert-list-container">
|
||||||
|
<List
|
||||||
|
dataSource={alerts}
|
||||||
|
split={false}
|
||||||
|
renderItem={(item) => (
|
||||||
|
<List.Item className="alert-item">
|
||||||
|
<div className="alert-row">
|
||||||
|
<div className="alert-badge">
|
||||||
|
<Tag color={getAlertColor(item.level)}>{item.level.toUpperCase().slice(0,1)}</Tag>
|
||||||
|
</div>
|
||||||
|
<div className="alert-content">
|
||||||
|
<div className="alert-head">
|
||||||
|
<span className="alert-name">{item.deviceName || item.taskName}</span>
|
||||||
|
<span className="alert-time">{dayjs(item.timestamp).format('HH:mm')}</span>
|
||||||
|
</div>
|
||||||
|
<div className="alert-msg">{item.message}</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</List.Item>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</Card>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* 中间栏:核心监控 */}
|
||||||
|
<div className="grid-col center-col">
|
||||||
|
{/* 顶部KPI */}
|
||||||
|
<div className="kpi-row">
|
||||||
|
<div className="kpi-card">
|
||||||
|
<div className="kpi-icon blue"><DesktopOutlined /></div>
|
||||||
|
<div className="kpi-info">
|
||||||
|
<div className="label">设备总数</div>
|
||||||
|
<div className="value">{deviceStats?.total || 0}</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="kpi-card">
|
||||||
|
<div className="kpi-icon green"><EnvironmentOutlined /></div>
|
||||||
|
<div className="kpi-info">
|
||||||
|
<div className="label">景区总数</div>
|
||||||
|
<div className="value">{deviceStats?.tourismCount || 0}</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="kpi-card">
|
||||||
|
<div className="kpi-icon yellow"><RocketOutlined /></div>
|
||||||
|
<div className="kpi-info">
|
||||||
|
<div className="label">{taskNewLabel}</div>
|
||||||
|
<div className="value">{taskStats?.todayNew || 0}</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="kpi-card">
|
||||||
|
<div className="kpi-icon purple"><PieChartOutlined /></div>
|
||||||
|
<div className="kpi-info">
|
||||||
|
<div className="label">执行成功率</div>
|
||||||
|
<div className="value">{taskStats?.successRate || 0}<small>%</small></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* 地图/3D入口 */}
|
||||||
|
<div className="map-portal-wrapper">
|
||||||
|
<div className="map-bg-grid"></div>
|
||||||
|
<div className="radar-sweep"></div>
|
||||||
|
<div className="map-content">
|
||||||
|
<div className="portal-center">
|
||||||
|
<EnvironmentOutlined style={{ fontSize: 56, color: '#00d4ff', marginBottom: 20 }} />
|
||||||
|
<h2 className="portal-title">全域数字孪生监控中心</h2>
|
||||||
|
<Button type="primary" shape="round" size="large" onClick={goTo3D} className="portal-btn">
|
||||||
|
立即进入监控视图
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* 底部年度统计 */}
|
||||||
|
<Card title="年度任务执行趋势分析" className="panel-card glass-panel fill-bottom" size="small">
|
||||||
|
<div className="chart-wrapper">
|
||||||
|
<Area {...areaConfig} />
|
||||||
|
</div>
|
||||||
|
</Card>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* 右侧栏:任务与运维 */}
|
||||||
|
<div className="grid-col right-col">
|
||||||
|
<Card
|
||||||
|
title={`${taskPeriodText}任务统计`}
|
||||||
|
className="panel-card glass-panel"
|
||||||
|
size="small"
|
||||||
|
extra={
|
||||||
|
<Space size={8} className="task-filter">
|
||||||
|
<Segmented
|
||||||
|
size="small"
|
||||||
|
options={[
|
||||||
|
{ label: '日', value: 'day' },
|
||||||
|
{ label: '月', value: 'month' },
|
||||||
|
{ label: '年', value: 'year' },
|
||||||
|
]}
|
||||||
|
value={taskStatType}
|
||||||
|
onChange={(v) => setTaskStatType(v as any)}
|
||||||
|
/>
|
||||||
|
<DatePicker
|
||||||
|
size="small"
|
||||||
|
value={taskStatDate}
|
||||||
|
onChange={(v) => v && setTaskStatDate(v)}
|
||||||
|
picker={taskStatType === 'day' ? 'date' : taskStatType}
|
||||||
|
allowClear={false}
|
||||||
|
format={datePickerFormat}
|
||||||
|
disabledDate={(d) => !!d && d.isAfter(dayjs(), 'day')}
|
||||||
|
/>
|
||||||
|
</Space>
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<div className="task-overview-grid">
|
||||||
|
<div className="task-stat-box">
|
||||||
|
<div className="val pending">{taskStats?.pending || 0}</div>
|
||||||
|
<div className="lbl">待执行</div>
|
||||||
|
</div>
|
||||||
|
<div className="task-stat-box">
|
||||||
|
<div className="val running">{taskStats?.running || 0}</div>
|
||||||
|
<div className="lbl">执行中</div>
|
||||||
|
</div>
|
||||||
|
<div className="task-stat-box">
|
||||||
|
<div className="val completed">{taskStats?.completed || 0}</div>
|
||||||
|
<div className="lbl">已完成</div>
|
||||||
|
</div>
|
||||||
|
<div className="task-stat-box">
|
||||||
|
<div className="val failed">{taskStats?.failed || 0}</div>
|
||||||
|
<div className="lbl">已失败</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div style={{ marginTop: 16, textAlign: 'center' }}>
|
||||||
|
<div style={{ fontSize: '32px', fontWeight: 'bold', color: '#00ff88' }}>
|
||||||
|
{taskStats?.successRate || 0}%
|
||||||
|
</div>
|
||||||
|
<div style={{ fontSize: '14px', color: '#fff', marginTop: 4 }}>
|
||||||
|
{taskPeriodText}成功率
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</Card>
|
||||||
|
|
||||||
|
<Card title="任务状态占比" className="panel-card glass-panel" size="small">
|
||||||
|
<div className="chart-wrapper">
|
||||||
|
<Pie {...taskStatusPieConfig} />
|
||||||
|
</div>
|
||||||
|
</Card>
|
||||||
|
|
||||||
|
<Card title="近7日任务趋势" className="panel-card glass-panel" size="small">
|
||||||
|
<div className="chart-wrapper">
|
||||||
|
<Line {...taskTrendConfig} />
|
||||||
|
</div>
|
||||||
|
</Card>
|
||||||
|
|
||||||
|
<Card title="异常原因分析" className="panel-card glass-panel flex-grow" size="small">
|
||||||
|
<div className="chart-wrapper">
|
||||||
|
<Rose {...roseConfig} />
|
||||||
|
</div>
|
||||||
|
</Card>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</Spin>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default Dashboard;
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -1,19 +1,18 @@
|
|||||||
import React, { useCallback, useEffect, useMemo, useState } from 'react';
|
import React, { useCallback, useEffect, useMemo, useState } from 'react';
|
||||||
import { Button, Card, Carousel, DatePicker, Empty, List, Progress, Segmented, Space, Spin, Tabs, Tag, message } from 'antd';
|
import { Spin, message } from 'antd';
|
||||||
import {
|
|
||||||
AimOutlined,
|
|
||||||
AlertOutlined,
|
|
||||||
EnvironmentOutlined,
|
|
||||||
RadarChartOutlined,
|
|
||||||
RocketOutlined,
|
|
||||||
SafetyCertificateOutlined,
|
|
||||||
} from '@ant-design/icons';
|
|
||||||
import { Column, Funnel, Heatmap, Line, Pie, Radar, RadialBar, Rose } from '@ant-design/plots';
|
|
||||||
import { history } from 'umi';
|
|
||||||
import dayjs from 'dayjs';
|
import dayjs from 'dayjs';
|
||||||
import type { AlertItem, DeviceStats, TaskStats, TrendItem } from '@/services/dashboard';
|
import type { AlertItem, DeviceStats, TaskStats, TrendItem } from '@/services/dashboard';
|
||||||
import { getDeviceStats, getMockAlerts, getTaskStats, getTrendData } from '@/services/dashboard';
|
import { getDeviceStats, getMockAlerts, getTaskStats, getTrendData } from '@/services/dashboard';
|
||||||
import { buildSmartCityModels } from './smartCity';
|
import { buildSmartCityModels } from './smartCity';
|
||||||
|
import {
|
||||||
|
CityVitalCard,
|
||||||
|
EventStreamCard,
|
||||||
|
KpiStrip,
|
||||||
|
TwinPortal,
|
||||||
|
DroneInsightCard,
|
||||||
|
DispatchCard,
|
||||||
|
EventInsightCard,
|
||||||
|
} from './components';
|
||||||
import './index.less';
|
import './index.less';
|
||||||
|
|
||||||
const Dashboard: React.FC = () => {
|
const Dashboard: React.FC = () => {
|
||||||
@@ -130,12 +129,9 @@ const Dashboard: React.FC = () => {
|
|||||||
};
|
};
|
||||||
}, [fetchData]);
|
}, [fetchData]);
|
||||||
|
|
||||||
const goTo3D = () => {
|
const smartModels = useMemo(() => {
|
||||||
// 传递来源页面,以便从map3d返回时能回到正确的大屏
|
return buildSmartCityModels({ tenantId, deviceStats, taskStats, taskTrend, alerts });
|
||||||
history.push('/map3d?from=dashboard');
|
}, [alerts, deviceStats, taskStats, taskTrend, tenantId]);
|
||||||
};
|
|
||||||
|
|
||||||
// --- 图表配置 ---
|
|
||||||
|
|
||||||
const taskTrendSeriesData = useMemo(() => {
|
const taskTrendSeriesData = useMemo(() => {
|
||||||
return taskTrend.flatMap((t) => [
|
return taskTrend.flatMap((t) => [
|
||||||
@@ -145,42 +141,6 @@ const Dashboard: React.FC = () => {
|
|||||||
]);
|
]);
|
||||||
}, [taskTrend]);
|
}, [taskTrend]);
|
||||||
|
|
||||||
const taskPeriodText = useMemo(() => {
|
|
||||||
if (taskStatType === 'day') return '当日';
|
|
||||||
if (taskStatType === 'month') return '当月';
|
|
||||||
return '当年';
|
|
||||||
}, [taskStatType]);
|
|
||||||
|
|
||||||
const datePickerFormat = useMemo(() => {
|
|
||||||
if (taskStatType === 'day') return 'YYYY-MM-DD';
|
|
||||||
if (taskStatType === 'month') return 'YYYY-MM';
|
|
||||||
return 'YYYY';
|
|
||||||
}, [taskStatType]);
|
|
||||||
|
|
||||||
const smartModels = useMemo(() => {
|
|
||||||
return buildSmartCityModels({ tenantId, deviceStats, taskStats, taskTrend, alerts });
|
|
||||||
}, [alerts, deviceStats, taskStats, taskTrend, tenantId]);
|
|
||||||
|
|
||||||
const maxEvents = useMemo(() => {
|
|
||||||
if (compactLevel === 2) return 5;
|
|
||||||
if (compactLevel === 1) return 7;
|
|
||||||
return 9;
|
|
||||||
}, [compactLevel]);
|
|
||||||
|
|
||||||
const visibleEvents = useMemo(() => {
|
|
||||||
return (smartModels.eventList || []).slice(0, maxEvents);
|
|
||||||
}, [maxEvents, smartModels.eventList]);
|
|
||||||
|
|
||||||
const regionCoverageMax = useMemo(() => {
|
|
||||||
if (compactLevel === 2) return 2;
|
|
||||||
if (compactLevel === 1) return 4;
|
|
||||||
return 6;
|
|
||||||
}, [compactLevel]);
|
|
||||||
|
|
||||||
const visibleRegionCoverage = useMemo(() => {
|
|
||||||
return (smartModels.regionCoverage || []).slice(0, regionCoverageMax);
|
|
||||||
}, [regionCoverageMax, smartModels.regionCoverage]);
|
|
||||||
|
|
||||||
const snapshotsPerPage = useMemo(() => {
|
const snapshotsPerPage = useMemo(() => {
|
||||||
if (compactLevel === 2) return 2;
|
if (compactLevel === 2) return 2;
|
||||||
if (compactLevel === 1) return 3;
|
if (compactLevel === 1) return 3;
|
||||||
@@ -193,12 +153,13 @@ const Dashboard: React.FC = () => {
|
|||||||
return 160;
|
return 160;
|
||||||
}, [compactLevel]);
|
}, [compactLevel]);
|
||||||
|
|
||||||
const radarConfig: any = useMemo(() => {
|
// 图表配置
|
||||||
return {
|
const radarConfig: any = useMemo(() => ({
|
||||||
data: smartModels.gridRadarData,
|
data: smartModels.gridRadarData,
|
||||||
xField: 'item',
|
xField: 'item',
|
||||||
yField: 'score',
|
yField: 'score',
|
||||||
seriesField: 'type',
|
seriesField: 'type',
|
||||||
|
appendPadding: [8, 10, 8, 10],
|
||||||
area: { style: { fillOpacity: 0.12 } },
|
area: { style: { fillOpacity: 0.12 } },
|
||||||
point: { size: 2, style: { fill: '#00d4ff' } },
|
point: { size: 2, style: { fill: '#00d4ff' } },
|
||||||
color: ['#00d4ff'],
|
color: ['#00d4ff'],
|
||||||
@@ -209,15 +170,14 @@ const Dashboard: React.FC = () => {
|
|||||||
yAxis: { grid: { line: { style: { stroke: 'rgba(255,255,255,0.08)' } } }, label: false },
|
yAxis: { grid: { line: { style: { stroke: 'rgba(255,255,255,0.08)' } } }, label: false },
|
||||||
legend: false,
|
legend: false,
|
||||||
autoFit: true,
|
autoFit: true,
|
||||||
};
|
}), [smartModels.gridRadarData]);
|
||||||
}, [smartModels.gridRadarData]);
|
|
||||||
|
|
||||||
const envLineConfig: any = useMemo(() => {
|
const envLineConfig: any = useMemo(() => ({
|
||||||
return {
|
|
||||||
data: smartModels.envTrendData,
|
data: smartModels.envTrendData,
|
||||||
xField: 'time',
|
xField: 'time',
|
||||||
yField: 'value',
|
yField: 'value',
|
||||||
seriesField: 'type',
|
seriesField: 'type',
|
||||||
|
appendPadding: [6, 10, 12, 8],
|
||||||
smooth: true,
|
smooth: true,
|
||||||
color: ['#00ff88', '#00d4ff'],
|
color: ['#00ff88', '#00d4ff'],
|
||||||
xAxis: { label: { style: { fill: 'rgba(255,255,255,0.62)' } }, grid: null },
|
xAxis: { label: { style: { fill: 'rgba(255,255,255,0.62)' } }, grid: null },
|
||||||
@@ -228,15 +188,14 @@ const Dashboard: React.FC = () => {
|
|||||||
legend: { position: 'top', itemName: { style: { fill: 'rgba(255,255,255,0.72)' } } },
|
legend: { position: 'top', itemName: { style: { fill: 'rgba(255,255,255,0.72)' } } },
|
||||||
tooltip: { showMarkers: true },
|
tooltip: { showMarkers: true },
|
||||||
autoFit: true,
|
autoFit: true,
|
||||||
};
|
}), [smartModels.envTrendData]);
|
||||||
}, [smartModels.envTrendData]);
|
|
||||||
|
|
||||||
const trafficHeatmapConfig: any = useMemo(() => {
|
const trafficHeatmapConfig: any = useMemo(() => ({
|
||||||
return {
|
|
||||||
data: smartModels.trafficHeatmapData,
|
data: smartModels.trafficHeatmapData,
|
||||||
xField: 'x',
|
xField: 'x',
|
||||||
yField: 'y',
|
yField: 'y',
|
||||||
colorField: 'value',
|
colorField: 'value',
|
||||||
|
appendPadding: [6, 8, 6, 8],
|
||||||
legend: { position: 'top', itemName: { style: { fill: 'rgba(255,255,255,0.72)' } } },
|
legend: { position: 'top', itemName: { style: { fill: 'rgba(255,255,255,0.72)' } } },
|
||||||
tooltip: { formatter: (d: any) => ({ name: '热度', value: `${d.value}` }) },
|
tooltip: { formatter: (d: any) => ({ name: '热度', value: `${d.value}` }) },
|
||||||
heatmapStyle: { stroke: 'rgba(255,255,255,0.08)', lineWidth: 1 },
|
heatmapStyle: { stroke: 'rgba(255,255,255,0.08)', lineWidth: 1 },
|
||||||
@@ -244,767 +203,110 @@ const Dashboard: React.FC = () => {
|
|||||||
xAxis: { label: false, grid: null, line: null },
|
xAxis: { label: false, grid: null, line: null },
|
||||||
yAxis: { label: false, grid: null, line: null },
|
yAxis: { label: false, grid: null, line: null },
|
||||||
autoFit: true,
|
autoFit: true,
|
||||||
};
|
}), [smartModels.trafficHeatmapData]);
|
||||||
}, [smartModels.trafficHeatmapData]);
|
|
||||||
|
|
||||||
const eventRadialConfig: any = useMemo(() => {
|
// 使用 CSS Grid 强制分配高度
|
||||||
return {
|
const gap = 12;
|
||||||
data: smartModels.eventTypeData,
|
|
||||||
xField: 'type',
|
|
||||||
yField: 'value',
|
|
||||||
radius: 0.88,
|
|
||||||
innerRadius: 0.25,
|
|
||||||
colorField: 'type',
|
|
||||||
color: ['#00d4ff', '#00ff88', '#ffb800', '#9d4edd', '#ff4757', '#13c2c2'],
|
|
||||||
legend: false,
|
|
||||||
label: { style: { fill: 'rgba(255,255,255,0.72)' } },
|
|
||||||
autoFit: true,
|
|
||||||
};
|
|
||||||
}, [smartModels.eventTypeData]);
|
|
||||||
|
|
||||||
const funnelConfig: any = useMemo(() => {
|
|
||||||
return {
|
|
||||||
data: smartModels.eventFunnelData,
|
|
||||||
xField: 'stage',
|
|
||||||
yField: 'value',
|
|
||||||
legend: false,
|
|
||||||
conversionTag: false,
|
|
||||||
tooltip: {
|
|
||||||
formatter: (d: any) => ({ name: d?.stage ?? d?.name ?? '阶段', value: d?.value ?? 0 }),
|
|
||||||
},
|
|
||||||
label: {
|
|
||||||
formatter: (d: any) => {
|
|
||||||
const stage = d?.stage ?? d?.name ?? d?.type ?? '阶段';
|
|
||||||
const value = d?.value ?? d?.count ?? 0;
|
|
||||||
return `${stage} ${value}`;
|
|
||||||
},
|
|
||||||
content: (d: any) => {
|
|
||||||
const stage = d?.stage ?? d?.name ?? d?.type ?? '阶段';
|
|
||||||
const value = d?.value ?? d?.count ?? 0;
|
|
||||||
return `${stage} ${value}`;
|
|
||||||
},
|
|
||||||
style: { fill: 'rgba(255,255,255,0.78)', fontSize: 12 },
|
|
||||||
},
|
|
||||||
color: ['#00d4ff', '#00ff88', '#ffb800', '#9d4edd', '#00d4ff'],
|
|
||||||
autoFit: true,
|
|
||||||
};
|
|
||||||
}, [smartModels.eventFunnelData]);
|
|
||||||
|
|
||||||
const dispatchTrendConfig: any = useMemo(() => {
|
|
||||||
return {
|
|
||||||
data: taskTrendSeriesData,
|
|
||||||
xField: 'date',
|
|
||||||
yField: 'value',
|
|
||||||
seriesField: 'type',
|
|
||||||
smooth: true,
|
|
||||||
color: ['#00d4ff', '#00ff88', '#ffb800'],
|
|
||||||
xAxis: { label: { style: { fill: 'rgba(255,255,255,0.62)' } }, grid: null },
|
|
||||||
yAxis: {
|
|
||||||
label: { style: { fill: 'rgba(255,255,255,0.62)' } },
|
|
||||||
grid: { line: { style: { stroke: 'rgba(255,255,255,0.08)' } } },
|
|
||||||
},
|
|
||||||
legend: { position: 'top', itemName: { style: { fill: 'rgba(255,255,255,0.72)' } } },
|
|
||||||
tooltip: { showMarkers: true },
|
|
||||||
autoFit: true,
|
|
||||||
};
|
|
||||||
}, [taskTrendSeriesData]);
|
|
||||||
|
|
||||||
const terminalPieConfig: any = useMemo(() => {
|
|
||||||
const data = smartModels.terminalPieData || [];
|
|
||||||
return {
|
|
||||||
data,
|
|
||||||
angleField: 'count',
|
|
||||||
colorField: 'name',
|
|
||||||
radius: 0.8,
|
|
||||||
innerRadius: 0.58,
|
|
||||||
label: {
|
|
||||||
text: (datum: any) => {
|
|
||||||
const total = data.reduce((sum, d) => sum + (d.count || 0), 0);
|
|
||||||
const count = datum?.count ?? 0;
|
|
||||||
const percent = total > 0 ? ((count / total) * 100).toFixed(0) : '0';
|
|
||||||
return `${datum?.name || ''} ${percent}%`;
|
|
||||||
},
|
|
||||||
style: { fill: 'rgba(255,255,255,0.7)' },
|
|
||||||
},
|
|
||||||
legend: false,
|
|
||||||
autoFit: true,
|
|
||||||
};
|
|
||||||
}, [smartModels.terminalPieData]);
|
|
||||||
|
|
||||||
const droneStatusPieConfig: any = useMemo(() => {
|
|
||||||
const fleet = smartModels.fleet;
|
|
||||||
const total = fleet.droneInFlight + fleet.droneStandby + fleet.droneMaintenance;
|
|
||||||
if (!total) return {};
|
|
||||||
return {
|
|
||||||
data: [
|
|
||||||
{ type: '在飞', value: fleet.droneInFlight },
|
|
||||||
{ type: '待命', value: fleet.droneStandby },
|
|
||||||
{ type: '维护', value: fleet.droneMaintenance },
|
|
||||||
],
|
|
||||||
angleField: 'value',
|
|
||||||
colorField: 'type',
|
|
||||||
radius: 0.92,
|
|
||||||
innerRadius: 0.62,
|
|
||||||
color: ['rgba(157, 78, 221, 0.95)', 'rgba(0, 212, 255, 0.9)', 'rgba(255, 184, 0, 0.92)'],
|
|
||||||
legend: false,
|
|
||||||
label: false,
|
|
||||||
statistic: {
|
|
||||||
title: false,
|
|
||||||
content: {
|
|
||||||
style: { color: 'rgba(255,255,255,0.88)', fontSize: 18, fontWeight: 700, whiteSpace: 'pre-line' },
|
|
||||||
content: `${fleet.droneOnline}/${fleet.droneTotal}\n在线`,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
autoFit: true,
|
|
||||||
};
|
|
||||||
}, [
|
|
||||||
smartModels.fleet.droneInFlight,
|
|
||||||
smartModels.fleet.droneMaintenance,
|
|
||||||
smartModels.fleet.droneOnline,
|
|
||||||
smartModels.fleet.droneStandby,
|
|
||||||
smartModels.fleet.droneTotal,
|
|
||||||
]);
|
|
||||||
|
|
||||||
const taskTypeColumnConfig: any = useMemo(() => {
|
|
||||||
return {
|
|
||||||
data: taskTypeData,
|
|
||||||
xField: 'type',
|
|
||||||
yField: 'value',
|
|
||||||
columnWidthRatio: 0.55,
|
|
||||||
color: ['#00d4ff'],
|
|
||||||
label: { style: { fill: 'rgba(255,255,255,0.85)' } },
|
|
||||||
xAxis: { label: { style: { fill: 'rgba(255,255,255,0.62)' } } },
|
|
||||||
yAxis: {
|
|
||||||
label: { style: { fill: 'rgba(255,255,255,0.62)' } },
|
|
||||||
grid: { line: { style: { stroke: 'rgba(255,255,255,0.08)' } } },
|
|
||||||
},
|
|
||||||
legend: false,
|
|
||||||
autoFit: true,
|
|
||||||
};
|
|
||||||
}, [taskTypeData]);
|
|
||||||
|
|
||||||
const annualLineConfig: any = useMemo(() => {
|
|
||||||
return {
|
|
||||||
data: annualData,
|
|
||||||
xField: 'month',
|
|
||||||
yField: 'value',
|
|
||||||
seriesField: 'type',
|
|
||||||
smooth: true,
|
|
||||||
color: ['#00d4ff', '#00ff88'],
|
|
||||||
areaStyle: { fillOpacity: 0.12 },
|
|
||||||
xAxis: { label: { style: { fill: 'rgba(255,255,255,0.62)' } } },
|
|
||||||
yAxis: {
|
|
||||||
label: { style: { fill: 'rgba(255,255,255,0.62)' } },
|
|
||||||
grid: { line: { style: { stroke: 'rgba(255,255,255,0.08)' } } },
|
|
||||||
},
|
|
||||||
legend: { position: 'top', itemName: { style: { fill: 'rgba(255,255,255,0.72)' } } },
|
|
||||||
autoFit: true,
|
|
||||||
};
|
|
||||||
}, [annualData]);
|
|
||||||
|
|
||||||
const riskRoseConfig: any = useMemo(() => {
|
|
||||||
return {
|
|
||||||
data: failureAnalysisData,
|
|
||||||
xField: 'type',
|
|
||||||
yField: 'value',
|
|
||||||
seriesField: 'type',
|
|
||||||
radius: 0.85,
|
|
||||||
innerRadius: 0.25,
|
|
||||||
colorField: 'type',
|
|
||||||
color: ['#ffb800', '#00d4ff', '#00ff88', '#9d4edd', '#ff4757', '#13c2c2'],
|
|
||||||
label: {
|
|
||||||
content: (d: any) => `${d.type}\n${d.value}`,
|
|
||||||
style: { fill: 'rgba(255,255,255,0.72)' },
|
|
||||||
},
|
|
||||||
legend: false,
|
|
||||||
autoFit: true,
|
|
||||||
};
|
|
||||||
}, [failureAnalysisData]);
|
|
||||||
|
|
||||||
const severityColor = (severity: string) => {
|
|
||||||
if (severity === 'critical') return '#ff4757';
|
|
||||||
if (severity === 'warning') return '#ffb800';
|
|
||||||
return '#00d4ff';
|
|
||||||
};
|
|
||||||
|
|
||||||
const statusTagColor = (status: string) => {
|
|
||||||
if (status === '已闭环') return '#00ff88';
|
|
||||||
if (status === '处理中') return '#9d4edd';
|
|
||||||
if (status === '已派单') return '#00d4ff';
|
|
||||||
return 'rgba(255,255,255,0.25)';
|
|
||||||
};
|
|
||||||
|
|
||||||
const regionRiskColor = (risk: string) => {
|
|
||||||
if (risk === 'critical') return '#ff4757';
|
|
||||||
if (risk === 'warning') return '#ffb800';
|
|
||||||
return '#00ff88';
|
|
||||||
};
|
|
||||||
|
|
||||||
// 运营洞察已合并进右侧“事件处置与洞察”卡片的 Tabs,避免小屏纵向堆叠过高导致裁切。
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={`dashboard-page dashboard-page--smartcity dashboard-page--compact-${compactLevel}`}>
|
<div style={{
|
||||||
<div className="dashboard-bg-animation" />
|
width: '100%',
|
||||||
|
height: '100%',
|
||||||
<Spin spinning={loading} wrapperClassName="dashboard-spin">
|
background: 'var(--bg-primary)',
|
||||||
<div className="dashboard-content">
|
overflow: 'hidden',
|
||||||
<div className="dashboard-grid">
|
padding: 12,
|
||||||
|
boxSizing: 'border-box',
|
||||||
{/* 左侧栏:城市体征 */}
|
}}>
|
||||||
<div className="grid-col left-col">
|
<Spin spinning={loading} wrapperClassName="dashboard-spin-wrapper">
|
||||||
<Card
|
<div style={{
|
||||||
title={
|
display: 'grid',
|
||||||
<span className="panel-title">
|
gridTemplateColumns: '25% 50% 25%',
|
||||||
<RadarChartOutlined /> 城市运行体征
|
gap: gap,
|
||||||
</span>
|
height: 'calc(100vh - 80px - 24px)',
|
||||||
}
|
width: '100%',
|
||||||
className="panel-card glass-panel panel-card--left-tabs"
|
}}>
|
||||||
size="small"
|
{/* 左侧栏 - CSS Grid 强制 1:1 分配 */}
|
||||||
>
|
<div style={{
|
||||||
<Tabs
|
display: 'grid',
|
||||||
size="small"
|
gridTemplateRows: '1fr 1fr',
|
||||||
className="dash-tabs"
|
gap: gap,
|
||||||
items={[
|
height: '100%',
|
||||||
{
|
minHeight: 0,
|
||||||
key: 'grid',
|
overflow: 'hidden',
|
||||||
label: '网格治理',
|
}}>
|
||||||
children: (
|
<div style={{ minHeight: 0, maxHeight: '100%', overflow: 'hidden' }}>
|
||||||
<div className="tab-pane">
|
<CityVitalCard
|
||||||
<div className="panel-subtitle">覆盖、发现、处置、复核一体化评分</div>
|
radarConfig={radarConfig}
|
||||||
<div className="chart-wrapper">
|
envLineConfig={envLineConfig}
|
||||||
<Radar {...radarConfig} />
|
trafficHeatmapConfig={trafficHeatmapConfig}
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: 'env',
|
|
||||||
label: '环境感知',
|
|
||||||
children: (
|
|
||||||
<div className="tab-pane">
|
|
||||||
<div className="panel-subtitle">空地协同采集 · 24 小时滚动</div>
|
|
||||||
<div className="chart-wrapper">
|
|
||||||
<Line {...envLineConfig} />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: 'traffic',
|
|
||||||
label: '交通热力',
|
|
||||||
children: (
|
|
||||||
<div className="tab-pane">
|
|
||||||
<div className="panel-subtitle">重点片区热度分布(网格化)</div>
|
|
||||||
<div className="chart-wrapper">
|
|
||||||
<Heatmap {...trafficHeatmapConfig} />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
),
|
|
||||||
},
|
|
||||||
]}
|
|
||||||
/>
|
|
||||||
</Card>
|
|
||||||
|
|
||||||
<Card
|
|
||||||
title={
|
|
||||||
<span className="panel-title">
|
|
||||||
<AlertOutlined /> 城市事件流
|
|
||||||
</span>
|
|
||||||
}
|
|
||||||
className="panel-card glass-panel panel-card--events"
|
|
||||||
size="small"
|
|
||||||
extra={<Tag color="cyan">实时</Tag>}
|
|
||||||
>
|
|
||||||
<div className="event-list-container">
|
|
||||||
<List
|
|
||||||
dataSource={visibleEvents}
|
|
||||||
split={false}
|
|
||||||
locale={{ emptyText: <Empty image={Empty.PRESENTED_IMAGE_SIMPLE} description="暂无事件" /> }}
|
|
||||||
renderItem={(item) => (
|
|
||||||
<List.Item className="event-item">
|
|
||||||
<div className="event-item__row">
|
|
||||||
<div className="event-item__badge" style={{ background: severityColor(item.severity) }} />
|
|
||||||
<div className="event-item__content">
|
|
||||||
<div className="event-item__head">
|
|
||||||
<span className="event-item__title">{item.title}</span>
|
|
||||||
<span className="event-item__time">{item.timeText}</span>
|
|
||||||
</div>
|
|
||||||
<div className="event-item__meta">
|
|
||||||
<span className="event-item__loc">{item.location}</span>
|
|
||||||
<Tag className="event-item__tag" color={statusTagColor(item.status)}>
|
|
||||||
{item.status}
|
|
||||||
</Tag>
|
|
||||||
<Tag className="event-item__tag" color="rgba(0,212,255,0.18)">
|
|
||||||
{item.source}
|
|
||||||
</Tag>
|
|
||||||
</div>
|
|
||||||
<div className="event-item__desc">{item.desc}</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</List.Item>
|
|
||||||
)}
|
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</Card>
|
<div style={{ minHeight: 0, maxHeight: '100%', overflow: 'hidden' }}>
|
||||||
</div>
|
<EventStreamCard events={smartModels.eventList || []} />
|
||||||
|
|
||||||
{/* 中间栏:核心监控 */}
|
|
||||||
<div className="grid-col center-col">
|
|
||||||
{/* 顶部KPI */}
|
|
||||||
<div className="kpi-strip">
|
|
||||||
{smartModels.kpis.map((kpi) => (
|
|
||||||
<div key={kpi.key} className={`kpi-tile kpi-tile--${kpi.accent || 'blue'}`}>
|
|
||||||
<div className="kpi-tile__head">
|
|
||||||
<span className="kpi-tile__label">{kpi.label}</span>
|
|
||||||
<span className="kpi-tile__dot" />
|
|
||||||
</div>
|
|
||||||
<div className="kpi-tile__value">
|
|
||||||
<span className="kpi-tile__num">{kpi.value}</span>
|
|
||||||
{kpi.unit ? <span className="kpi-tile__unit">{kpi.unit}</span> : null}
|
|
||||||
</div>
|
|
||||||
{kpi.sub ? <div className="kpi-tile__sub">{kpi.sub}</div> : null}
|
|
||||||
</div>
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* 地图/3D入口 */}
|
|
||||||
<div className="twin-portal">
|
|
||||||
<div className="twin-portal__grid" />
|
|
||||||
<div className="twin-portal__sweep" />
|
|
||||||
<div className="twin-portal__overlay">
|
|
||||||
<div className="twin-portal__top">
|
|
||||||
{compactLevel === 2 ? (
|
|
||||||
<div className="twin-portal__tags">
|
|
||||||
<Tag color="cyan">事件点位</Tag>
|
|
||||||
<Tag color="green">AI识别</Tag>
|
|
||||||
</div>
|
|
||||||
) : (
|
|
||||||
<>
|
|
||||||
<div className="twin-portal__tags">
|
|
||||||
<Tag color="cyan">事件点位</Tag>
|
|
||||||
<Tag color="geekblue">航线叠加</Tag>
|
|
||||||
<Tag color="purple">电子围栏</Tag>
|
|
||||||
<Tag color="green">AI识别</Tag>
|
|
||||||
</div>
|
|
||||||
<div className="twin-portal__chips">
|
|
||||||
<span className="chip">
|
|
||||||
<SafetyCertificateOutlined /> 安全态势
|
|
||||||
</span>
|
|
||||||
<span className="chip">
|
|
||||||
<AimOutlined /> 空域管理
|
|
||||||
</span>
|
|
||||||
<span className="chip">
|
|
||||||
<EnvironmentOutlined /> 数字孪生
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="twin-portal__center">
|
|
||||||
<div className="twin-portal__title">全域数字孪生中枢</div>
|
|
||||||
<div className="twin-portal__desc">空地协同巡检 · 城市事件识别 · 应急快速响应</div>
|
|
||||||
<Button type="primary" shape="round" size="large" onClick={goTo3D} className="twin-portal__btn">
|
|
||||||
进入 3D 监控视图
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="twin-portal__bottom">
|
|
||||||
<div className="mini-metric">
|
|
||||||
<span className="mini-metric__label">在线无人机</span>
|
|
||||||
<span className="mini-metric__value">{smartModels.fleet.droneOnline}</span>
|
|
||||||
</div>
|
|
||||||
<div className="mini-metric">
|
|
||||||
<span className="mini-metric__label">在飞架次</span>
|
|
||||||
<span className="mini-metric__value">{smartModels.fleet.droneInFlight}</span>
|
|
||||||
</div>
|
|
||||||
{compactLevel === 2 ? null : (
|
|
||||||
<>
|
|
||||||
<div className="mini-metric">
|
|
||||||
<span className="mini-metric__label">可用机库</span>
|
|
||||||
<span className="mini-metric__value">{smartModels.fleet.dockOnline}</span>
|
|
||||||
</div>
|
|
||||||
<div className="mini-metric">
|
|
||||||
<span className="mini-metric__label">合规指数</span>
|
|
||||||
<span
|
|
||||||
className={`mini-metric__value${
|
|
||||||
smartModels.airspace.complianceIndex < 85 ? ' mini-metric__value--warn' : ''
|
|
||||||
}`}
|
|
||||||
>
|
|
||||||
{smartModels.airspace.complianceIndex}
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<Card
|
|
||||||
title={
|
|
||||||
<span className="panel-title">
|
|
||||||
<AlertOutlined /> 无人机态势与AI洞察
|
|
||||||
</span>
|
|
||||||
}
|
|
||||||
className="panel-card glass-panel fill-bottom panel-card--snap"
|
|
||||||
size="small"
|
|
||||||
>
|
|
||||||
<Tabs
|
|
||||||
size="small"
|
|
||||||
className="dash-tabs"
|
|
||||||
items={[
|
|
||||||
{
|
|
||||||
key: 'snap',
|
|
||||||
label: 'AI快照',
|
|
||||||
children: (
|
|
||||||
<div className="tab-pane">
|
|
||||||
<Carousel autoplay autoplaySpeed={5500} dots className="snapshot-carousel">
|
|
||||||
{new Array(Math.max(1, Math.ceil(smartModels.aiSnapshots.length / snapshotsPerPage)))
|
|
||||||
.fill(0)
|
|
||||||
.map((_, pageIdx) => {
|
|
||||||
const start = pageIdx * snapshotsPerPage;
|
|
||||||
const page = smartModels.aiSnapshots.slice(start, start + snapshotsPerPage);
|
|
||||||
return (
|
|
||||||
<div key={`page-${pageIdx}`} className="snapshot-page">
|
|
||||||
<div className="snapshot-grid">
|
|
||||||
{page.map((s) => (
|
|
||||||
<div key={s.id} className={`snapshot-card snapshot-card--${s.severity}`}>
|
|
||||||
<div className="snapshot-card__head">
|
|
||||||
<span className="snapshot-card__tag">{s.tag}</span>
|
|
||||||
<span className="snapshot-card__time">{s.timeText}</span>
|
|
||||||
</div>
|
|
||||||
<div className="snapshot-card__title">{s.title}</div>
|
|
||||||
<div className="snapshot-card__meta">
|
|
||||||
<span className="snapshot-card__loc">{s.location}</span>
|
|
||||||
<span className="snapshot-card__conf">置信度 {s.confidence}%</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
</Carousel>
|
|
||||||
</div>
|
|
||||||
),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: 'fleet',
|
|
||||||
label: '机队态势',
|
|
||||||
children: (
|
|
||||||
<div className="tab-pane fleet-pane">
|
|
||||||
<div className="fleet-metrics">
|
|
||||||
<div className="fleet-metric">
|
|
||||||
<div className="fleet-metric__label">平均电量</div>
|
|
||||||
<div className="fleet-metric__value">{smartModels.fleet.avgBattery}%</div>
|
|
||||||
<div className="fleet-metric__sub">低电 {smartModels.fleet.lowBatteryAlerts} 起</div>
|
|
||||||
</div>
|
|
||||||
<div className="fleet-metric">
|
|
||||||
<div className="fleet-metric__label">飞行时长</div>
|
|
||||||
<div className="fleet-metric__value">{smartModels.fleet.flightHoursToday}h</div>
|
|
||||||
<div className="fleet-metric__sub">今日累计</div>
|
|
||||||
</div>
|
|
||||||
<div className="fleet-metric">
|
|
||||||
<div className="fleet-metric__label">飞行里程</div>
|
|
||||||
<div className="fleet-metric__value">{smartModels.fleet.flightMileageToday}km</div>
|
|
||||||
<div className="fleet-metric__sub">含航线复飞</div>
|
|
||||||
</div>
|
|
||||||
<div className="fleet-metric">
|
|
||||||
<div className="fleet-metric__label">可用机库</div>
|
|
||||||
<div className="fleet-metric__value">
|
|
||||||
{smartModels.fleet.dockOnline}/{smartModels.fleet.dockTotal}
|
|
||||||
</div>
|
|
||||||
<div className="fleet-metric__sub">在线/总量</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="fleet-split">
|
{/* 中间栏 - KPI固定70px + 剩余空间1:1分配 */}
|
||||||
<div className="fleet-split__left">
|
<div style={{
|
||||||
<div className="panel-subtitle">机队状态占比</div>
|
display: 'grid',
|
||||||
<div className="chart-wrapper">
|
gridTemplateRows: '70px 1fr 1fr',
|
||||||
{Object.keys(droneStatusPieConfig).length ? (
|
gap: gap,
|
||||||
<Pie {...droneStatusPieConfig} />
|
height: '100%',
|
||||||
) : (
|
minHeight: 0,
|
||||||
<Empty image={Empty.PRESENTED_IMAGE_SIMPLE} description="暂无无人机数据" />
|
overflow: 'hidden',
|
||||||
)}
|
}}>
|
||||||
|
<div style={{ minHeight: 0, maxHeight: '100%', overflow: 'hidden' }}>
|
||||||
|
<KpiStrip kpis={smartModels.kpis} />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
<div style={{ minHeight: 0, maxHeight: '100%', overflow: 'hidden' }}>
|
||||||
<div className="fleet-split__right">
|
<TwinPortal
|
||||||
<div className="panel-subtitle">重点区域覆盖</div>
|
fleet={smartModels.fleet}
|
||||||
<div className="region-list">
|
airspace={smartModels.airspace}
|
||||||
{visibleRegionCoverage.map((r) => (
|
compactLevel={compactLevel}
|
||||||
<div key={r.id} className="region-item">
|
|
||||||
<div className="region-item__head">
|
|
||||||
<span className="region-item__name">{r.name}</span>
|
|
||||||
<span className="region-item__meta">
|
|
||||||
<Tag className="region-item__tag" color={regionRiskColor(r.risk)}>
|
|
||||||
{r.risk === 'critical' ? '高风险' : r.risk === 'warning' ? '关注' : '正常'}
|
|
||||||
</Tag>
|
|
||||||
<span className="region-item__time">{r.updatedAt}</span>
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
<div className="region-item__bar">
|
|
||||||
<Progress
|
|
||||||
percent={r.coverage}
|
|
||||||
size="small"
|
|
||||||
showInfo={false}
|
|
||||||
strokeColor={regionRiskColor(r.risk)}
|
|
||||||
trailColor="rgba(255,255,255,0.08)"
|
|
||||||
/>
|
/>
|
||||||
<span className="region-item__pct">{r.coverage}%</span>
|
|
||||||
<span className="region-item__pending">待处置 {r.pending}</span>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
<div style={{ minHeight: 0, maxHeight: '100%', overflow: 'hidden' }}>
|
||||||
))}
|
<DroneInsightCard
|
||||||
</div>
|
aiSnapshots={smartModels.aiSnapshots}
|
||||||
</div>
|
fleet={smartModels.fleet}
|
||||||
</div>
|
airspace={smartModels.airspace}
|
||||||
</div>
|
regionCoverage={smartModels.regionCoverage}
|
||||||
),
|
compactLevel={compactLevel}
|
||||||
},
|
snapshotsPerPage={snapshotsPerPage}
|
||||||
{
|
airspaceGaugeSize={airspaceGaugeSize}
|
||||||
key: 'airspace',
|
|
||||||
label: '空域合规',
|
|
||||||
children: (
|
|
||||||
<div className="tab-pane airspace-pane">
|
|
||||||
<div className="airspace-top">
|
|
||||||
<div className="airspace-score">
|
|
||||||
<Progress
|
|
||||||
type="dashboard"
|
|
||||||
percent={smartModels.airspace.complianceIndex}
|
|
||||||
strokeColor={{
|
|
||||||
'0%': 'rgba(255, 71, 87, 0.95)',
|
|
||||||
'55%': 'rgba(255, 184, 0, 0.95)',
|
|
||||||
'100%': 'rgba(0, 255, 136, 0.95)',
|
|
||||||
}}
|
|
||||||
trailColor="rgba(255,255,255,0.08)"
|
|
||||||
size={airspaceGaugeSize}
|
|
||||||
/>
|
/>
|
||||||
<div className="airspace-score__meta">
|
|
||||||
<div className="airspace-score__title">合规指数</div>
|
|
||||||
<div className="airspace-score__sub">围栏/禁飞/审批综合</div>
|
|
||||||
<div className="airspace-score__sub">城市安全指数 {smartModels.airspace.safetyIndex}</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="airspace-metrics">
|
{/* 右侧栏 - CSS Grid 各50% */}
|
||||||
<div className="airspace-metric">
|
<div style={{
|
||||||
<div className="airspace-metric__val">{smartModels.airspace.geofenceTriggers}</div>
|
display: 'grid',
|
||||||
<div className="airspace-metric__lbl">围栏触发</div>
|
gridTemplateRows: '1fr 1fr',
|
||||||
</div>
|
gap: gap + 4,
|
||||||
<div className="airspace-metric">
|
height: '100%',
|
||||||
<div className="airspace-metric__val">{smartModels.airspace.noFlyWarnings}</div>
|
minHeight: 0,
|
||||||
<div className="airspace-metric__lbl">禁飞预警</div>
|
overflow: 'hidden',
|
||||||
</div>
|
}}>
|
||||||
<div className="airspace-metric">
|
<div style={{ minHeight: 0, maxHeight: '100%', overflow: 'hidden' }}>
|
||||||
<div className="airspace-metric__val">{smartModels.airspace.approvalsToday}</div>
|
<DispatchCard
|
||||||
<div className="airspace-metric__lbl">今日审批</div>
|
taskStats={taskStats}
|
||||||
</div>
|
taskTrendData={taskTrendSeriesData}
|
||||||
<div className="airspace-metric">
|
taskStatType={taskStatType}
|
||||||
<div className="airspace-metric__val">{smartModels.airspace.approvalsPassRate}%</div>
|
taskStatDate={taskStatDate}
|
||||||
<div className="airspace-metric__lbl">通过率</div>
|
onStatTypeChange={setTaskStatType}
|
||||||
</div>
|
onDateChange={setTaskStatDate}
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="airspace-notes">
|
|
||||||
<div className="airspace-note">
|
|
||||||
<span className="airspace-note__dot" />
|
|
||||||
<span className="airspace-note__text">重点区域启用“低空走廊”,优先保障应急任务快速通行。</span>
|
|
||||||
</div>
|
|
||||||
{compactLevel === 2 ? null : (
|
|
||||||
<>
|
|
||||||
<div className="airspace-note">
|
|
||||||
<span className="airspace-note__dot airspace-note__dot--warn" />
|
|
||||||
<span className="airspace-note__text">围栏触发或禁飞预警上升时,建议自动降级为“复核模式”。</span>
|
|
||||||
</div>
|
|
||||||
<div className="airspace-note">
|
|
||||||
<span className="airspace-note__dot airspace-note__dot--ok" />
|
|
||||||
<span className="airspace-note__text">审批通过率稳定后,可扩大夜航与多机协同策略的投放比例。</span>
|
|
||||||
</div>
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
),
|
|
||||||
},
|
|
||||||
]}
|
|
||||||
/>
|
/>
|
||||||
</Card>
|
|
||||||
</div>
|
</div>
|
||||||
|
<div style={{ minHeight: 0, maxHeight: '100%', overflow: 'hidden' }}>
|
||||||
{/* 右侧栏:任务与运维 */}
|
<EventInsightCard
|
||||||
<div className="grid-col right-col">
|
eventFunnelData={smartModels.eventFunnelData}
|
||||||
<Card
|
eventTypeData={smartModels.eventTypeData}
|
||||||
title={
|
terminalPieData={smartModels.terminalPieData}
|
||||||
<span className="panel-title">
|
taskTypeData={taskTypeData}
|
||||||
<RocketOutlined /> {taskPeriodText}运行调度
|
failureAnalysisData={failureAnalysisData}
|
||||||
</span>
|
annualData={annualData}
|
||||||
}
|
|
||||||
className="panel-card glass-panel panel-card--dispatch"
|
|
||||||
size="small"
|
|
||||||
extra={
|
|
||||||
<Space size={8} className="task-filter">
|
|
||||||
<Segmented
|
|
||||||
size="small"
|
|
||||||
options={[
|
|
||||||
{ label: '日', value: 'day' },
|
|
||||||
{ label: '月', value: 'month' },
|
|
||||||
{ label: '年', value: 'year' },
|
|
||||||
]}
|
|
||||||
value={taskStatType}
|
|
||||||
onChange={(v) => setTaskStatType(v as any)}
|
|
||||||
/>
|
/>
|
||||||
<DatePicker
|
|
||||||
size="small"
|
|
||||||
value={taskStatDate}
|
|
||||||
onChange={(v) => v && setTaskStatDate(v)}
|
|
||||||
picker={taskStatType === 'day' ? 'date' : taskStatType}
|
|
||||||
allowClear={false}
|
|
||||||
format={datePickerFormat}
|
|
||||||
disabledDate={(d) => !!d && d.isAfter(dayjs(), 'day')}
|
|
||||||
/>
|
|
||||||
</Space>
|
|
||||||
}
|
|
||||||
>
|
|
||||||
<div className="dispatch-grid">
|
|
||||||
<div className="dispatch-stat">
|
|
||||||
<div className="dispatch-stat__val dispatch-stat__val--pending">{taskStats?.pending || 0}</div>
|
|
||||||
<div className="dispatch-stat__lbl">待执行</div>
|
|
||||||
</div>
|
</div>
|
||||||
<div className="dispatch-stat">
|
|
||||||
<div className="dispatch-stat__val dispatch-stat__val--running">{taskStats?.running || 0}</div>
|
|
||||||
<div className="dispatch-stat__lbl">执行中</div>
|
|
||||||
</div>
|
|
||||||
<div className="dispatch-stat">
|
|
||||||
<div className="dispatch-stat__val dispatch-stat__val--done">{taskStats?.completed || 0}</div>
|
|
||||||
<div className="dispatch-stat__lbl">已完成</div>
|
|
||||||
</div>
|
|
||||||
<div className="dispatch-stat">
|
|
||||||
<div className="dispatch-stat__val dispatch-stat__val--fail">{taskStats?.failed || 0}</div>
|
|
||||||
<div className="dispatch-stat__lbl">异常</div>
|
|
||||||
</div>
|
|
||||||
<div className="dispatch-highlight">
|
|
||||||
<div className="dispatch-highlight__val">{taskStats?.successRate || 0}%</div>
|
|
||||||
<div className="dispatch-highlight__lbl">成功率</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div className="dispatch-trend">
|
|
||||||
<div className="dispatch-trend__title">近 7 日任务趋势</div>
|
|
||||||
<div className="chart-wrapper">
|
|
||||||
<Line {...dispatchTrendConfig} />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</Card>
|
|
||||||
|
|
||||||
<Card
|
|
||||||
title={
|
|
||||||
<span className="panel-title">
|
|
||||||
<EnvironmentOutlined /> 事件处置与洞察
|
|
||||||
</span>
|
|
||||||
}
|
|
||||||
className="panel-card glass-panel flex-grow panel-card--right-tabs"
|
|
||||||
size="small"
|
|
||||||
>
|
|
||||||
<Tabs
|
|
||||||
size="small"
|
|
||||||
className="dash-tabs"
|
|
||||||
items={[
|
|
||||||
{
|
|
||||||
key: 'funnel',
|
|
||||||
label: '处置闭环',
|
|
||||||
children: (
|
|
||||||
<div className="tab-pane">
|
|
||||||
<div className="chart-wrapper">
|
|
||||||
<Funnel {...funnelConfig} />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: 'types',
|
|
||||||
label: '类型分布',
|
|
||||||
children: (
|
|
||||||
<div className="tab-pane">
|
|
||||||
<div className="chart-wrapper">
|
|
||||||
<RadialBar {...eventRadialConfig} />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: 'asset',
|
|
||||||
label: '资产构成',
|
|
||||||
children: smartModels.terminalPieData?.length ? (
|
|
||||||
<div className="tab-pane">
|
|
||||||
<div className="chart-wrapper">
|
|
||||||
<Pie {...terminalPieConfig} />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
) : (
|
|
||||||
<div className="tab-pane">
|
|
||||||
<div className="empty-holder">
|
|
||||||
<Empty image={Empty.PRESENTED_IMAGE_SIMPLE} description="暂无资产数据" />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: 'capacity',
|
|
||||||
label: '作业结构',
|
|
||||||
children: taskTypeData?.length ? (
|
|
||||||
<div className="tab-pane">
|
|
||||||
<div className="chart-wrapper">
|
|
||||||
<Column {...taskTypeColumnConfig} />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
) : (
|
|
||||||
<div className="tab-pane">
|
|
||||||
<div className="empty-holder">
|
|
||||||
<Empty image={Empty.PRESENTED_IMAGE_SIMPLE} description="暂无结构数据" />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: 'risk',
|
|
||||||
label: '风险画像',
|
|
||||||
children: failureAnalysisData?.length ? (
|
|
||||||
<div className="tab-pane">
|
|
||||||
<div className="chart-wrapper">
|
|
||||||
<Rose {...riskRoseConfig} />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
) : (
|
|
||||||
<div className="tab-pane">
|
|
||||||
<div className="empty-holder">
|
|
||||||
<Empty image={Empty.PRESENTED_IMAGE_SIMPLE} description="暂无风险数据" />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: 'year',
|
|
||||||
label: '年度趋势',
|
|
||||||
children: annualData?.length ? (
|
|
||||||
<div className="tab-pane">
|
|
||||||
<div className="chart-wrapper">
|
|
||||||
<Line {...annualLineConfig} />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
) : (
|
|
||||||
<div className="tab-pane">
|
|
||||||
<div className="empty-holder">
|
|
||||||
<Empty image={Empty.PRESENTED_IMAGE_SIMPLE} description="暂无年度数据" />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
),
|
|
||||||
},
|
|
||||||
]}
|
|
||||||
/>
|
|
||||||
</Card>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</Spin>
|
</Spin>
|
||||||
|
|||||||
@@ -0,0 +1,401 @@
|
|||||||
|
import dayjs from 'dayjs';
|
||||||
|
import type { AlertItem, DeviceStats, TaskStats, TrendItem } from '@/services/dashboard';
|
||||||
|
|
||||||
|
type Severity = 'normal' | 'warning' | 'critical';
|
||||||
|
|
||||||
|
export interface SmartCityKpiItem {
|
||||||
|
key: string;
|
||||||
|
label: string;
|
||||||
|
value: number | string;
|
||||||
|
unit?: string;
|
||||||
|
accent?: 'blue' | 'green' | 'yellow' | 'red' | 'purple';
|
||||||
|
sub?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface SmartCityEventItem {
|
||||||
|
id: string;
|
||||||
|
title: string;
|
||||||
|
location: string;
|
||||||
|
source: '无人机' | '摄像头' | '机库' | '多源融合';
|
||||||
|
severity: Severity;
|
||||||
|
status: '待确认' | '已派单' | '处理中' | '已闭环';
|
||||||
|
timeText: string;
|
||||||
|
desc: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface SmartCityModels {
|
||||||
|
kpis: SmartCityKpiItem[];
|
||||||
|
fleet: {
|
||||||
|
droneTotal: number;
|
||||||
|
droneOnline: number;
|
||||||
|
droneInFlight: number;
|
||||||
|
droneStandby: number;
|
||||||
|
droneMaintenance: number;
|
||||||
|
dockTotal: number;
|
||||||
|
dockOnline: number;
|
||||||
|
cameraTotal: number;
|
||||||
|
cameraOnline: number;
|
||||||
|
lowBatteryAlerts: number;
|
||||||
|
avgBattery: number;
|
||||||
|
flightHoursToday: number;
|
||||||
|
flightMileageToday: number;
|
||||||
|
};
|
||||||
|
airspace: {
|
||||||
|
safetyIndex: number;
|
||||||
|
complianceIndex: number;
|
||||||
|
geofenceTriggers: number;
|
||||||
|
noFlyWarnings: number;
|
||||||
|
approvalsToday: number;
|
||||||
|
approvalsPassRate: number;
|
||||||
|
};
|
||||||
|
regionCoverage: Array<{
|
||||||
|
id: string;
|
||||||
|
name: string;
|
||||||
|
coverage: number;
|
||||||
|
pending: number;
|
||||||
|
risk: Severity;
|
||||||
|
updatedAt: string;
|
||||||
|
}>;
|
||||||
|
terminalPieData: { name: string; count: number }[];
|
||||||
|
onlineRate: number;
|
||||||
|
liquidRate: number;
|
||||||
|
gridRadarData: { item: string; score: number; type: '当前' }[];
|
||||||
|
envTrendData: { time: string; type: string; value: number }[];
|
||||||
|
trafficHeatmapData: { x: string; y: string; value: number }[];
|
||||||
|
eventTypeData: { type: string; value: number }[];
|
||||||
|
eventFunnelData: { stage: string; value: number }[];
|
||||||
|
eventList: SmartCityEventItem[];
|
||||||
|
aiSnapshots: Array<{
|
||||||
|
id: string;
|
||||||
|
title: string;
|
||||||
|
location: string;
|
||||||
|
tag: string;
|
||||||
|
confidence: number;
|
||||||
|
timeText: string;
|
||||||
|
severity: Severity;
|
||||||
|
}>;
|
||||||
|
}
|
||||||
|
|
||||||
|
function hashStringToSeed(text: string): number {
|
||||||
|
let hash = 2166136261;
|
||||||
|
for (let i = 0; i < text.length; i++) {
|
||||||
|
hash ^= text.charCodeAt(i);
|
||||||
|
hash = Math.imul(hash, 16777619);
|
||||||
|
}
|
||||||
|
return hash >>> 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
function createRng(seedText: string) {
|
||||||
|
let seed = hashStringToSeed(seedText) || 1;
|
||||||
|
return () => {
|
||||||
|
seed = (Math.imul(seed, 1664525) + 1013904223) >>> 0;
|
||||||
|
return seed / 4294967296;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function clampNumber(value: number, min: number, max: number) {
|
||||||
|
return Math.max(min, Math.min(max, value));
|
||||||
|
}
|
||||||
|
|
||||||
|
function pickOne<T>(rng: () => number, items: T[]): T {
|
||||||
|
return items[Math.floor(rng() * items.length)];
|
||||||
|
}
|
||||||
|
|
||||||
|
function mapAlertToEvent(alert: AlertItem): Omit<SmartCityEventItem, 'location' | 'source' | 'status'> & {
|
||||||
|
severity: Severity;
|
||||||
|
title: string;
|
||||||
|
} {
|
||||||
|
const severity: Severity =
|
||||||
|
alert.level === 'critical' ? 'critical' : alert.level === 'error' ? 'warning' : 'normal';
|
||||||
|
|
||||||
|
if (alert.type === 'device_offline') {
|
||||||
|
return {
|
||||||
|
id: alert.id,
|
||||||
|
title: '关键点位离线预警',
|
||||||
|
severity,
|
||||||
|
timeText: dayjs(alert.timestamp).format('HH:mm'),
|
||||||
|
desc: alert.message,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
if (alert.type === 'low_battery') {
|
||||||
|
return {
|
||||||
|
id: alert.id,
|
||||||
|
title: '保障能力风险提示',
|
||||||
|
severity: severity === 'normal' ? 'warning' : severity,
|
||||||
|
timeText: dayjs(alert.timestamp).format('HH:mm'),
|
||||||
|
desc: alert.message,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
if (alert.type === 'task_failed') {
|
||||||
|
return {
|
||||||
|
id: alert.id,
|
||||||
|
title: '巡检任务异常',
|
||||||
|
severity,
|
||||||
|
timeText: dayjs(alert.timestamp).format('HH:mm'),
|
||||||
|
desc: alert.message,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
id: alert.id,
|
||||||
|
title: '终端运行异常',
|
||||||
|
severity: severity === 'normal' ? 'warning' : severity,
|
||||||
|
timeText: dayjs(alert.timestamp).format('HH:mm'),
|
||||||
|
desc: alert.message,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function calcSafetyIndex(params: {
|
||||||
|
deviceStats?: DeviceStats | null;
|
||||||
|
taskStats?: TaskStats | null;
|
||||||
|
alerts?: AlertItem[];
|
||||||
|
baseSeed: string;
|
||||||
|
}) {
|
||||||
|
const rng = createRng(`${params.baseSeed}:safety`);
|
||||||
|
const onlineRate = params.deviceStats?.onlineRate ?? 0;
|
||||||
|
const successRate = params.taskStats?.successRate ?? 0;
|
||||||
|
const alerts = params.alerts || [];
|
||||||
|
|
||||||
|
const critical = alerts.filter((a) => a.level === 'critical').length;
|
||||||
|
const error = alerts.filter((a) => a.level === 'error').length;
|
||||||
|
const warning = alerts.filter((a) => a.level === 'warning').length;
|
||||||
|
|
||||||
|
const baseline = 90 + Math.round(rng() * 4);
|
||||||
|
const penalty = critical * 6 + error * 4 + warning * 2 + Math.round((100 - onlineRate) * 0.18);
|
||||||
|
const bonus = Math.round((successRate - 80) * 0.15);
|
||||||
|
|
||||||
|
return clampNumber(baseline - penalty + bonus, 60, 99);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function buildSmartCityModels(params: {
|
||||||
|
tenantId?: string;
|
||||||
|
deviceStats?: DeviceStats | null;
|
||||||
|
taskStats?: TaskStats | null;
|
||||||
|
taskTrend?: TrendItem[];
|
||||||
|
alerts?: AlertItem[];
|
||||||
|
}): SmartCityModels {
|
||||||
|
const todayKey = dayjs().format('YYYY-MM-DD');
|
||||||
|
const baseSeed = `${params.tenantId || 'default'}:${todayKey}`;
|
||||||
|
const rng = createRng(baseSeed);
|
||||||
|
|
||||||
|
const deviceStats = params.deviceStats;
|
||||||
|
const taskStats = params.taskStats;
|
||||||
|
const taskTrend = params.taskTrend || [];
|
||||||
|
const alerts = params.alerts || [];
|
||||||
|
|
||||||
|
const onlineRate = deviceStats?.onlineRate ?? 0;
|
||||||
|
const safetyIndex = calcSafetyIndex({ deviceStats, taskStats, alerts, baseSeed });
|
||||||
|
|
||||||
|
const eventCount = alerts.length + 6 + Math.floor(rng() * 6);
|
||||||
|
const avgResponse = clampNumber(8 + Math.round((1 - (taskStats?.successRate ?? 0) / 100) * 12) + Math.round(rng() * 4), 6, 28);
|
||||||
|
const closedLoopRate = clampNumber(
|
||||||
|
taskStats?.total ? Math.round(((taskStats.completed || 0) / taskStats.total) * 100) : 70 + Math.round(rng() * 18),
|
||||||
|
40,
|
||||||
|
99,
|
||||||
|
);
|
||||||
|
|
||||||
|
const byType = deviceStats?.byType || [];
|
||||||
|
const droneTotal = byType.find((d) => d.type === 'drone')?.count || 0;
|
||||||
|
const dockTotal = byType.find((d) => d.type === 'dock')?.count || 0;
|
||||||
|
const cameraTotal = byType.find((d) => d.type === 'camera')?.count || 0;
|
||||||
|
|
||||||
|
const ratio = clampNumber((onlineRate || 0) / 100, 0, 1);
|
||||||
|
const droneOnline = clampNumber(Math.round(droneTotal * ratio * (0.94 + rng() * 0.12)), 0, droneTotal);
|
||||||
|
const dockOnline = clampNumber(Math.round(dockTotal * ratio * (0.92 + rng() * 0.14)), 0, dockTotal);
|
||||||
|
const cameraOnline = clampNumber(Math.round(cameraTotal * ratio * (0.90 + rng() * 0.16)), 0, cameraTotal);
|
||||||
|
|
||||||
|
const runningTasks = taskStats?.running || 0;
|
||||||
|
const droneInFlight = clampNumber(Math.min(droneOnline, Math.max(0, runningTasks) + Math.round(rng() * 2)), 0, droneOnline);
|
||||||
|
const droneMaintenance = clampNumber(Math.round(droneTotal * (0.06 + rng() * 0.09)), 0, droneTotal);
|
||||||
|
const droneStandby = clampNumber(droneOnline - droneInFlight - Math.min(droneMaintenance, droneOnline), 0, droneOnline);
|
||||||
|
|
||||||
|
const lowBatteryAlerts = alerts.filter((a) => a.type === 'low_battery').length;
|
||||||
|
const avgBattery = clampNumber(62 + Math.round(rng() * 28) - lowBatteryAlerts * 3, 18, 98);
|
||||||
|
const flightHoursToday = clampNumber(6 + Math.round((taskStats?.total || 0) * 0.55) + Math.round(rng() * 4), 0, 78);
|
||||||
|
const flightMileageToday = clampNumber(28 + Math.round((taskStats?.total || 0) * 2.2) + Math.round(rng() * 12), 0, 420);
|
||||||
|
|
||||||
|
const critical = alerts.filter((a) => a.level === 'critical').length;
|
||||||
|
const error = alerts.filter((a) => a.level === 'error').length;
|
||||||
|
const warning = alerts.filter((a) => a.level === 'warning').length;
|
||||||
|
|
||||||
|
const complianceIndex = clampNumber(95 - critical * 6 - error * 3 - warning * 1 - Math.round((100 - onlineRate) * 0.12) + Math.round(rng() * 2), 60, 99);
|
||||||
|
const geofenceTriggers = clampNumber(Math.round(rng() * 5) + critical + Math.floor(error / 2), 0, 12);
|
||||||
|
const noFlyWarnings = clampNumber(Math.round(rng() * 3) + Math.floor(warning / 2), 0, 10);
|
||||||
|
const approvalsToday = clampNumber(18 + Math.round(rng() * 28), 0, 120);
|
||||||
|
const approvalsPassRate = clampNumber(92 - critical * 2 - error + Math.round(rng() * 4), 70, 99);
|
||||||
|
|
||||||
|
const fleet = {
|
||||||
|
droneTotal,
|
||||||
|
droneOnline,
|
||||||
|
droneInFlight,
|
||||||
|
droneStandby,
|
||||||
|
droneMaintenance,
|
||||||
|
dockTotal,
|
||||||
|
dockOnline,
|
||||||
|
cameraTotal,
|
||||||
|
cameraOnline,
|
||||||
|
lowBatteryAlerts,
|
||||||
|
avgBattery,
|
||||||
|
flightHoursToday,
|
||||||
|
flightMileageToday,
|
||||||
|
};
|
||||||
|
|
||||||
|
const airspace = {
|
||||||
|
safetyIndex,
|
||||||
|
complianceIndex,
|
||||||
|
geofenceTriggers,
|
||||||
|
noFlyWarnings,
|
||||||
|
approvalsToday,
|
||||||
|
approvalsPassRate,
|
||||||
|
};
|
||||||
|
|
||||||
|
const kpis: SmartCityKpiItem[] = [
|
||||||
|
{ key: 'air', label: '空域合规指数', value: complianceIndex, unit: '', accent: complianceIndex >= 92 ? 'green' : complianceIndex >= 82 ? 'yellow' : 'red', sub: '围栏/禁飞/链路综合' },
|
||||||
|
{ key: 'flight', label: '在飞无人机', value: droneInFlight, unit: '架', accent: 'purple', sub: `在线 ${droneOnline}/${droneTotal}` },
|
||||||
|
{ key: 'sortie', label: '今日出动任务', value: taskStats?.todayNew ?? 0, unit: '次', accent: 'blue', sub: '巡检/应急/处置' },
|
||||||
|
{ key: 'closed', label: '问题闭环率', value: closedLoopRate, unit: '%', accent: closedLoopRate >= 85 ? 'green' : 'yellow', sub: '发现→处置→复核' },
|
||||||
|
{ key: 'online', label: '终端在线率', value: onlineRate, unit: '%', accent: onlineRate >= 90 ? 'green' : onlineRate >= 75 ? 'yellow' : 'red', sub: `低电 ${lowBatteryAlerts} 起` },
|
||||||
|
];
|
||||||
|
|
||||||
|
const terminalPieData = (deviceStats?.byType || []).map((d) => ({ name: d.name, count: d.count }));
|
||||||
|
|
||||||
|
const regionCoverage = (() => {
|
||||||
|
const regions = ['政务中心片区', '滨河公园带', '高新大道走廊', '老城商圈', '西站枢纽', '南湖片区', '工业园北区', '东门立交'];
|
||||||
|
const picked = regions.slice(0, 6);
|
||||||
|
return picked.map((name, idx) => {
|
||||||
|
const coverage = clampNumber(72 + Math.round(rng() * 26) - idx * 2, 45, 99);
|
||||||
|
const pending = clampNumber(Math.round(rng() * 8) + (idx % 2 === 0 ? 1 : 0), 0, 18);
|
||||||
|
const risk: Severity = coverage >= 88 ? 'normal' : coverage >= 76 ? 'warning' : 'critical';
|
||||||
|
const updatedAt = dayjs().subtract(5 + Math.round(rng() * 55), 'minute').format('HH:mm');
|
||||||
|
return { id: `region-${idx}`, name, coverage, pending, risk, updatedAt };
|
||||||
|
});
|
||||||
|
})();
|
||||||
|
|
||||||
|
const gridRadarData = [
|
||||||
|
{ item: '巡检覆盖', score: clampNumber(70 + Math.round(rng() * 24), 55, 98), type: '当前' as const },
|
||||||
|
{ item: '问题发现', score: clampNumber(62 + Math.round(rng() * 30), 50, 98), type: '当前' as const },
|
||||||
|
{ item: '处置效率', score: clampNumber(68 + Math.round(rng() * 22), 50, 98), type: '当前' as const },
|
||||||
|
{ item: '复核通过', score: clampNumber(72 + Math.round(rng() * 18), 55, 99), type: '当前' as const },
|
||||||
|
{ item: '重点关注', score: clampNumber(58 + Math.round(rng() * 34), 45, 98), type: '当前' as const },
|
||||||
|
];
|
||||||
|
|
||||||
|
const envTrendData: { time: string; type: string; value: number }[] = [];
|
||||||
|
const startHour = dayjs().startOf('day');
|
||||||
|
const pmBase = clampNumber(22 + Math.round(rng() * 26), 15, 60);
|
||||||
|
const noiseBase = clampNumber(52 + Math.round(rng() * 10), 45, 70);
|
||||||
|
for (let i = 0; i < 24; i++) {
|
||||||
|
const time = startHour.add(i, 'hour').format('HH:00');
|
||||||
|
const wave = Math.sin((i / 24) * Math.PI * 2);
|
||||||
|
const pm = clampNumber(pmBase + wave * 10 + (rng() - 0.5) * 6, 8, 85);
|
||||||
|
const noise = clampNumber(noiseBase + Math.abs(wave) * 9 + (rng() - 0.5) * 4, 35, 85);
|
||||||
|
envTrendData.push({ time, type: 'PM2.5', value: Number(pm.toFixed(1)) });
|
||||||
|
envTrendData.push({ time, type: '噪声(dB)', value: Number(noise.toFixed(1)) });
|
||||||
|
}
|
||||||
|
|
||||||
|
const trafficHeatmapData: { x: string; y: string; value: number }[] = [];
|
||||||
|
const cols = 10;
|
||||||
|
const rows = 6;
|
||||||
|
for (let y = 0; y < rows; y++) {
|
||||||
|
for (let x = 0; x < cols; x++) {
|
||||||
|
const centerBias = 1 - Math.abs(x - (cols - 1) / 2) / cols;
|
||||||
|
const value = clampNumber(12 + centerBias * 36 + rng() * 18 + (y % 2 === 0 ? 2 : -2), 0, 100);
|
||||||
|
trafficHeatmapData.push({ x: `${x + 1}`, y: `${rows - y}`, value: Math.round(value) });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const locations = ['政务中心', '滨河公园', '高新大道', '老城商圈', '西站枢纽', '南湖片区', '工业园北区', '东门立交'];
|
||||||
|
const sources: SmartCityEventItem['source'][] = ['无人机', '摄像头', '机库', '多源融合'];
|
||||||
|
const statuses: SmartCityEventItem['status'][] = ['待确认', '已派单', '处理中', '已闭环'];
|
||||||
|
|
||||||
|
const eventListFromAlerts: SmartCityEventItem[] = alerts.slice(0, 8).map((a, idx) => {
|
||||||
|
const base = mapAlertToEvent(a);
|
||||||
|
const status = idx === 0 ? '处理中' : idx === 1 ? '待确认' : pickOne(rng, statuses);
|
||||||
|
const source = idx % 2 === 0 ? '无人机' : '机库';
|
||||||
|
return {
|
||||||
|
...base,
|
||||||
|
location: pickOne(rng, locations),
|
||||||
|
source,
|
||||||
|
status,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
const aiEventTypes = ['违停抓拍', '烟火识别', '占道经营', '河道漂浮物', '工地未戴帽', '夜间聚集'];
|
||||||
|
const aiSnapshots = new Array(10).fill(0).map((_, i) => {
|
||||||
|
const type = aiEventTypes[i % aiEventTypes.length];
|
||||||
|
const confidence = clampNumber(78 + Math.round(rng() * 20), 60, 99);
|
||||||
|
const severity: Severity = confidence >= 92 ? 'critical' : confidence >= 84 ? 'warning' : 'normal';
|
||||||
|
const timeText = dayjs().subtract(Math.round(rng() * 65), 'minute').format('HH:mm');
|
||||||
|
return {
|
||||||
|
id: `snap-${todayKey}-${i}`,
|
||||||
|
title: type,
|
||||||
|
location: pickOne(rng, locations),
|
||||||
|
tag: pickOne(rng, ['AI识别', '多源融合', '重点区域', '高频点位']),
|
||||||
|
confidence,
|
||||||
|
timeText,
|
||||||
|
severity,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
const eventListGenerated: SmartCityEventItem[] = aiSnapshots.slice(0, 6).map((s, idx) => {
|
||||||
|
const severity: Severity = s.severity;
|
||||||
|
const status = idx < 2 ? '待确认' : idx < 4 ? '已派单' : pickOne(rng, statuses);
|
||||||
|
const source = idx % 3 === 0 ? '无人机' : idx % 3 === 1 ? '摄像头' : '多源融合';
|
||||||
|
return {
|
||||||
|
id: `evt-${s.id}`,
|
||||||
|
title: s.title,
|
||||||
|
location: s.location,
|
||||||
|
source,
|
||||||
|
severity,
|
||||||
|
status,
|
||||||
|
timeText: s.timeText,
|
||||||
|
desc: `疑似${s.title}(置信度 ${s.confidence}%)`,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
const eventList = [...eventListGenerated, ...eventListFromAlerts].slice(0, 12);
|
||||||
|
|
||||||
|
const eventTypeCounts: Record<string, number> = {};
|
||||||
|
eventList.forEach((e) => {
|
||||||
|
const key = e.title;
|
||||||
|
eventTypeCounts[key] = (eventTypeCounts[key] || 0) + 1;
|
||||||
|
});
|
||||||
|
const eventTypeData = Object.entries(eventTypeCounts)
|
||||||
|
.map(([type, value]) => ({ type, value }))
|
||||||
|
.sort((a, b) => b.value - a.value)
|
||||||
|
.slice(0, 6);
|
||||||
|
|
||||||
|
const eventFunnelData = (() => {
|
||||||
|
const total = eventCount;
|
||||||
|
const confirmed = clampNumber(Math.round(total * (0.78 + rng() * 0.08)), 0, total);
|
||||||
|
const assigned = clampNumber(Math.round(confirmed * (0.75 + rng() * 0.1)), 0, confirmed);
|
||||||
|
const processing = clampNumber(Math.round(assigned * (0.72 + rng() * 0.12)), 0, assigned);
|
||||||
|
const closed = clampNumber(Math.round(processing * (0.78 + rng() * 0.12)), 0, processing);
|
||||||
|
return [
|
||||||
|
{ stage: '识别', value: total },
|
||||||
|
{ stage: '确认', value: confirmed },
|
||||||
|
{ stage: '派单', value: assigned },
|
||||||
|
{ stage: '处置', value: processing },
|
||||||
|
{ stage: '闭环', value: closed },
|
||||||
|
];
|
||||||
|
})();
|
||||||
|
|
||||||
|
const liquidRate = clampNumber((onlineRate || 0) / 100, 0, 1);
|
||||||
|
|
||||||
|
void taskTrend;
|
||||||
|
|
||||||
|
return {
|
||||||
|
kpis,
|
||||||
|
fleet,
|
||||||
|
airspace,
|
||||||
|
regionCoverage,
|
||||||
|
terminalPieData,
|
||||||
|
onlineRate,
|
||||||
|
liquidRate,
|
||||||
|
gridRadarData,
|
||||||
|
envTrendData,
|
||||||
|
trafficHeatmapData,
|
||||||
|
eventTypeData,
|
||||||
|
eventFunnelData,
|
||||||
|
eventList,
|
||||||
|
aiSnapshots,
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -0,0 +1,186 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import { Card } from 'antd';
|
||||||
|
import { BarChartOutlined } from '@ant-design/icons';
|
||||||
|
import { Area, Column } from '@ant-design/plots';
|
||||||
|
|
||||||
|
interface AnnualTrendCardProps {
|
||||||
|
annualData: any[];
|
||||||
|
taskTypeData: any[];
|
||||||
|
}
|
||||||
|
|
||||||
|
const AnnualTrendCard: React.FC<AnnualTrendCardProps> = ({ annualData, taskTypeData }) => {
|
||||||
|
const areaConfig: any = {
|
||||||
|
data: annualData,
|
||||||
|
xField: 'month',
|
||||||
|
yField: 'value',
|
||||||
|
seriesField: 'type',
|
||||||
|
color: ['#00b4d8', '#00e5a0'],
|
||||||
|
areaStyle: { fillOpacity: 0.3 },
|
||||||
|
line: {
|
||||||
|
style: { lineWidth: 2 },
|
||||||
|
},
|
||||||
|
point: {
|
||||||
|
size: 3,
|
||||||
|
shape: 'circle',
|
||||||
|
style: {
|
||||||
|
fill: '#fff',
|
||||||
|
stroke: '#00b4d8',
|
||||||
|
lineWidth: 2,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
xAxis: {
|
||||||
|
label: {
|
||||||
|
style: { fill: 'rgba(200,230,255,0.75)', fontSize: 11 },
|
||||||
|
},
|
||||||
|
line: {
|
||||||
|
style: { stroke: 'rgba(0,180,216,0.2)' },
|
||||||
|
},
|
||||||
|
tickLine: null,
|
||||||
|
},
|
||||||
|
yAxis: {
|
||||||
|
label: {
|
||||||
|
style: { fill: 'rgba(200,230,255,0.75)', fontSize: 11 },
|
||||||
|
},
|
||||||
|
grid: {
|
||||||
|
line: { style: { stroke: 'rgba(0,150,200,0.15)', lineDash: [4, 4] } },
|
||||||
|
},
|
||||||
|
line: null,
|
||||||
|
tickLine: null,
|
||||||
|
},
|
||||||
|
legend: {
|
||||||
|
position: 'top',
|
||||||
|
itemName: {
|
||||||
|
style: { fill: 'rgba(200,230,255,0.85)', fontSize: 12, fontWeight: 600 },
|
||||||
|
},
|
||||||
|
marker: {
|
||||||
|
symbol: 'circle',
|
||||||
|
style: { r: 4 },
|
||||||
|
},
|
||||||
|
itemSpacing: 16,
|
||||||
|
},
|
||||||
|
smooth: true,
|
||||||
|
animation: {
|
||||||
|
appear: {
|
||||||
|
animation: 'wave-in',
|
||||||
|
duration: 1000,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
tooltip: {
|
||||||
|
showMarkers: true,
|
||||||
|
marker: {
|
||||||
|
fill: '#00b4d8',
|
||||||
|
},
|
||||||
|
domStyles: {
|
||||||
|
'g2-tooltip': {
|
||||||
|
background: 'rgba(10, 30, 50, 0.95)',
|
||||||
|
boxShadow: '0 4px 12px rgba(0,0,0,0.3)',
|
||||||
|
border: '1px solid rgba(0,180,216,0.3)',
|
||||||
|
},
|
||||||
|
'g2-tooltip-title': {
|
||||||
|
color: 'rgba(200,230,255,0.95)',
|
||||||
|
},
|
||||||
|
'g2-tooltip-list-item': {
|
||||||
|
color: 'rgba(200,230,255,0.85)',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
autoFit: true,
|
||||||
|
};
|
||||||
|
|
||||||
|
const columnConfig: any = {
|
||||||
|
data: taskTypeData,
|
||||||
|
xField: 'type',
|
||||||
|
yField: 'value',
|
||||||
|
seriesField: 'type',
|
||||||
|
color: ({ type }: any) => {
|
||||||
|
if (type === '航线巡检') return '#00b4d8';
|
||||||
|
if (type === '定点监测') return '#00e5a0';
|
||||||
|
return '#ff9f43';
|
||||||
|
},
|
||||||
|
columnStyle: {
|
||||||
|
radius: [6, 6, 0, 0],
|
||||||
|
},
|
||||||
|
label: {
|
||||||
|
text: (datum: any) => datum?.value?.toString() || '0',
|
||||||
|
style: {
|
||||||
|
fill: '#fff',
|
||||||
|
fontSize: 12,
|
||||||
|
fontWeight: 600,
|
||||||
|
textAlign: 'center',
|
||||||
|
},
|
||||||
|
position: 'top',
|
||||||
|
offset: 8,
|
||||||
|
},
|
||||||
|
xAxis: {
|
||||||
|
label: {
|
||||||
|
style: { fill: 'rgba(200,230,255,0.75)', fontSize: 11 },
|
||||||
|
},
|
||||||
|
line: {
|
||||||
|
style: { stroke: 'rgba(0,180,216,0.2)' },
|
||||||
|
},
|
||||||
|
tickLine: null,
|
||||||
|
},
|
||||||
|
yAxis: {
|
||||||
|
label: {
|
||||||
|
style: { fill: 'rgba(200,230,255,0.75)', fontSize: 11 },
|
||||||
|
},
|
||||||
|
grid: {
|
||||||
|
line: { style: { stroke: 'rgba(0,150,200,0.15)', lineDash: [4, 4] } },
|
||||||
|
},
|
||||||
|
line: null,
|
||||||
|
tickLine: null,
|
||||||
|
},
|
||||||
|
legend: false,
|
||||||
|
animation: {
|
||||||
|
appear: {
|
||||||
|
animation: 'scale-in-y',
|
||||||
|
duration: 800,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
tooltip: {
|
||||||
|
domStyles: {
|
||||||
|
'g2-tooltip': {
|
||||||
|
background: 'rgba(10, 30, 50, 0.95)',
|
||||||
|
boxShadow: '0 4px 12px rgba(0,0,0,0.3)',
|
||||||
|
border: '1px solid rgba(0,180,216,0.3)',
|
||||||
|
},
|
||||||
|
'g2-tooltip-title': {
|
||||||
|
color: 'rgba(200,230,255,0.95)',
|
||||||
|
},
|
||||||
|
'g2-tooltip-list-item': {
|
||||||
|
color: 'rgba(200,230,255,0.85)',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
autoFit: true,
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Card
|
||||||
|
title={
|
||||||
|
<span style={{ color: 'rgba(255,255,255,0.92)', display: 'flex', alignItems: 'center', gap: 8 }}>
|
||||||
|
<BarChartOutlined style={{ color: '#00b4d8' }} /> 年度巡检任务趋势与任务类型
|
||||||
|
</span>
|
||||||
|
}
|
||||||
|
className="maritime-card"
|
||||||
|
size="small"
|
||||||
|
>
|
||||||
|
<div className="panel-split">
|
||||||
|
<div className="panel-section">
|
||||||
|
<div className="panel-subtitle">年度巡检趋势</div>
|
||||||
|
<div className="maritime-chart-wrapper">
|
||||||
|
<Area {...areaConfig} />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="panel-section">
|
||||||
|
<div className="panel-subtitle">任务类型统计</div>
|
||||||
|
<div className="maritime-chart-wrapper">
|
||||||
|
<Column {...columnConfig} />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</Card>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default AnnualTrendCard;
|
||||||
@@ -0,0 +1,116 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import { Card } from 'antd';
|
||||||
|
import { LineChartOutlined } from '@ant-design/icons';
|
||||||
|
import { Area } from '@ant-design/plots';
|
||||||
|
|
||||||
|
interface AnnualTrendChartProps {
|
||||||
|
annualData: any[];
|
||||||
|
}
|
||||||
|
|
||||||
|
const AnnualTrendChart: React.FC<AnnualTrendChartProps> = ({ annualData }) => {
|
||||||
|
const areaConfig: any = {
|
||||||
|
data: annualData,
|
||||||
|
xField: 'month',
|
||||||
|
yField: 'value',
|
||||||
|
seriesField: 'type',
|
||||||
|
color: ['#00b4d8', '#00e5a0'],
|
||||||
|
appendPadding: [20, 10, 10, 10],
|
||||||
|
areaStyle: { fillOpacity: 0.25 },
|
||||||
|
line: {
|
||||||
|
style: { lineWidth: 2 },
|
||||||
|
},
|
||||||
|
point: {
|
||||||
|
size: 2,
|
||||||
|
shape: 'circle',
|
||||||
|
style: {
|
||||||
|
fill: '#fff',
|
||||||
|
stroke: '#00b4d8',
|
||||||
|
lineWidth: 1.5,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
xAxis: {
|
||||||
|
label: {
|
||||||
|
style: { fill: 'rgba(200,230,255,0.75)', fontSize: 10 },
|
||||||
|
autoRotate: false,
|
||||||
|
autoHide: true,
|
||||||
|
},
|
||||||
|
line: {
|
||||||
|
style: { stroke: 'rgba(0,180,216,0.2)' },
|
||||||
|
},
|
||||||
|
tickLine: null,
|
||||||
|
},
|
||||||
|
yAxis: {
|
||||||
|
label: {
|
||||||
|
style: { fill: 'rgba(200,230,255,0.75)', fontSize: 10 },
|
||||||
|
},
|
||||||
|
grid: {
|
||||||
|
line: { style: { stroke: 'rgba(0,150,200,0.15)', lineDash: [4, 4] } },
|
||||||
|
},
|
||||||
|
line: null,
|
||||||
|
tickLine: null,
|
||||||
|
},
|
||||||
|
legend: {
|
||||||
|
position: 'top-left',
|
||||||
|
offsetY: -5,
|
||||||
|
itemName: {
|
||||||
|
style: { fill: 'rgba(200,230,255,0.85)', fontSize: 11, fontWeight: 600 },
|
||||||
|
},
|
||||||
|
marker: {
|
||||||
|
symbol: 'circle',
|
||||||
|
style: { r: 3 },
|
||||||
|
},
|
||||||
|
itemSpacing: 12,
|
||||||
|
},
|
||||||
|
smooth: true,
|
||||||
|
animation: {
|
||||||
|
appear: {
|
||||||
|
animation: 'wave-in',
|
||||||
|
duration: 1000,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
tooltip: {
|
||||||
|
showMarkers: true,
|
||||||
|
marker: {
|
||||||
|
fill: '#00b4d8',
|
||||||
|
},
|
||||||
|
domStyles: {
|
||||||
|
'g2-tooltip': {
|
||||||
|
background: 'rgba(10, 30, 50, 0.95)',
|
||||||
|
boxShadow: '0 4px 12px rgba(0,0,0,0.3)',
|
||||||
|
border: '1px solid rgba(0,180,216,0.3)',
|
||||||
|
},
|
||||||
|
'g2-tooltip-title': {
|
||||||
|
color: 'rgba(200,230,255,0.95)',
|
||||||
|
},
|
||||||
|
'g2-tooltip-list-item': {
|
||||||
|
color: 'rgba(200,230,255,0.85)',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
autoFit: true,
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Card
|
||||||
|
title={
|
||||||
|
<span style={{ color: 'rgba(255,255,255,0.92)', display: 'flex', alignItems: 'center', gap: 8 }}>
|
||||||
|
<LineChartOutlined style={{ color: '#00b4d8' }} /> 年度巡检任务趋势
|
||||||
|
</span>
|
||||||
|
}
|
||||||
|
className="maritime-card"
|
||||||
|
size="small"
|
||||||
|
styles={{
|
||||||
|
body: {
|
||||||
|
padding: '8px 8px 4px 8px',
|
||||||
|
overflow: 'visible',
|
||||||
|
},
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<div className="maritime-chart-wrapper">
|
||||||
|
<Area {...areaConfig} />
|
||||||
|
</div>
|
||||||
|
</Card>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default AnnualTrendChart;
|
||||||
@@ -0,0 +1,106 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import { Card } from 'antd';
|
||||||
|
import { AppstoreOutlined } from '@ant-design/icons';
|
||||||
|
import { Pie } from '@ant-design/plots';
|
||||||
|
import type { DeviceStats } from '@/services/dashboard';
|
||||||
|
|
||||||
|
interface DeviceTypeCardProps {
|
||||||
|
deviceStats: DeviceStats | null;
|
||||||
|
}
|
||||||
|
|
||||||
|
const DeviceTypeCard: React.FC<DeviceTypeCardProps> = ({ deviceStats }) => {
|
||||||
|
const usvTypeData = (deviceStats?.byType || [
|
||||||
|
{ name: '巡检型', count: 12 },
|
||||||
|
{ name: '监测型', count: 8 },
|
||||||
|
{ name: '救援型', count: 5 },
|
||||||
|
{ name: '测量型', count: 3 },
|
||||||
|
]).map(item => ({ name: item.name, count: item.count }));
|
||||||
|
|
||||||
|
const pieConfig: any = {
|
||||||
|
data: usvTypeData,
|
||||||
|
angleField: 'count',
|
||||||
|
colorField: 'name',
|
||||||
|
radius: 0.7,
|
||||||
|
innerRadius: 0.5,
|
||||||
|
color: ['#00b4d8', '#0096c7', '#00e5a0', '#48cae4'],
|
||||||
|
appendPadding: [20, 10, 5, 10],
|
||||||
|
label: {
|
||||||
|
text: (datum: any) => {
|
||||||
|
const name = datum?.name || '';
|
||||||
|
const count = datum?.count ?? 0;
|
||||||
|
const total = usvTypeData.reduce((sum, d) => sum + (d.count || 0), 0);
|
||||||
|
const percent = total > 0 ? ((count / total) * 100).toFixed(1) : 0;
|
||||||
|
return `${name}\n${percent}%`;
|
||||||
|
},
|
||||||
|
style: {
|
||||||
|
fill: 'rgba(200,230,255,0.95)',
|
||||||
|
fontSize: 10,
|
||||||
|
fontWeight: 600,
|
||||||
|
textAlign: 'center',
|
||||||
|
},
|
||||||
|
offset: 20,
|
||||||
|
},
|
||||||
|
legend: {
|
||||||
|
position: 'bottom',
|
||||||
|
offsetY: -10,
|
||||||
|
itemValue: {
|
||||||
|
style: { fill: 'rgba(200,230,255,0.75)', fontSize: 10 }
|
||||||
|
},
|
||||||
|
itemName: {
|
||||||
|
style: { fill: 'rgba(200,230,255,0.75)', fontSize: 10 }
|
||||||
|
},
|
||||||
|
itemSpacing: 6,
|
||||||
|
layout: 'horizontal',
|
||||||
|
},
|
||||||
|
statistic: {
|
||||||
|
title: {
|
||||||
|
style: { fontSize: 11, fill: 'rgba(200,230,255,0.65)' },
|
||||||
|
content: '设备总数',
|
||||||
|
},
|
||||||
|
content: {
|
||||||
|
style: { fontSize: 16, fontWeight: 'bold', fill: '#00e5a0' },
|
||||||
|
formatter: () => {
|
||||||
|
const total = usvTypeData.reduce((sum, d) => sum + (d.count || 0), 0);
|
||||||
|
return `${total}`;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
autoFit: true,
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Card
|
||||||
|
title={
|
||||||
|
<span style={{ color: 'rgba(255,255,255,0.92)', display: 'flex', alignItems: 'center', gap: 8 }}>
|
||||||
|
<AppstoreOutlined style={{ color: '#00b4d8' }} /> 设备类型分布
|
||||||
|
</span>
|
||||||
|
}
|
||||||
|
className="maritime-card"
|
||||||
|
size="small"
|
||||||
|
styles={{
|
||||||
|
body: {
|
||||||
|
padding: 0,
|
||||||
|
display: 'flex',
|
||||||
|
flexDirection: 'column',
|
||||||
|
alignItems: 'center',
|
||||||
|
justifyContent: 'flex-start',
|
||||||
|
overflow: 'visible',
|
||||||
|
height: '100%',
|
||||||
|
},
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<div className="maritime-chart-wrapper" style={{
|
||||||
|
width: '100%',
|
||||||
|
height: '100%',
|
||||||
|
display: 'flex',
|
||||||
|
alignItems: 'flex-start',
|
||||||
|
justifyContent: 'center',
|
||||||
|
paddingTop: '10px',
|
||||||
|
}}>
|
||||||
|
<Pie {...pieConfig} />
|
||||||
|
</div>
|
||||||
|
</Card>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default DeviceTypeCard;
|
||||||
@@ -0,0 +1,58 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import { Card, List, Tag } from 'antd';
|
||||||
|
import { WarningOutlined } from '@ant-design/icons';
|
||||||
|
import dayjs from 'dayjs';
|
||||||
|
import type { AlertItem } from '@/services/dashboard';
|
||||||
|
|
||||||
|
interface MaritimeAlertCardProps {
|
||||||
|
alerts: AlertItem[];
|
||||||
|
}
|
||||||
|
|
||||||
|
const getAlertColor = (level: string) => {
|
||||||
|
switch (level) {
|
||||||
|
case 'critical': return '#ff4757';
|
||||||
|
case 'error': return '#ff9f43';
|
||||||
|
case 'warning': return '#feca57';
|
||||||
|
default: return '#54a0ff';
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const MaritimeAlertCard: React.FC<MaritimeAlertCardProps> = ({ alerts }) => {
|
||||||
|
return (
|
||||||
|
<Card
|
||||||
|
title={
|
||||||
|
<span style={{ color: 'rgba(255,255,255,0.92)', display: 'flex', alignItems: 'center', gap: 8 }}>
|
||||||
|
<WarningOutlined style={{ color: '#ff9f43' }} /> 实时告警
|
||||||
|
</span>
|
||||||
|
}
|
||||||
|
extra={<Tag color="#ff9f43">LIVE</Tag>}
|
||||||
|
className="maritime-card"
|
||||||
|
size="small"
|
||||||
|
>
|
||||||
|
<div className="alert-list-container">
|
||||||
|
<List
|
||||||
|
dataSource={alerts}
|
||||||
|
split={false}
|
||||||
|
renderItem={(item) => (
|
||||||
|
<List.Item className="maritime-alert-item">
|
||||||
|
<div className="alert-row">
|
||||||
|
<div className="alert-badge">
|
||||||
|
<Tag color={getAlertColor(item.level)}>{item.level.toUpperCase().slice(0, 1)}</Tag>
|
||||||
|
</div>
|
||||||
|
<div className="alert-content">
|
||||||
|
<div className="alert-head">
|
||||||
|
<span className="alert-name">{item.deviceName || item.taskName}</span>
|
||||||
|
<span className="alert-time">{dayjs(item.timestamp).format('HH:mm')}</span>
|
||||||
|
</div>
|
||||||
|
<div className="alert-msg">{item.message}</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</List.Item>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</Card>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default MaritimeAlertCard;
|
||||||
@@ -0,0 +1,146 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import { Card, Tabs } from 'antd';
|
||||||
|
import { FundOutlined } from '@ant-design/icons';
|
||||||
|
import { Line, Pie, Rose } from '@ant-design/plots';
|
||||||
|
import type { TaskStats, TrendItem } from '@/services/dashboard';
|
||||||
|
|
||||||
|
interface MaritimeInsightCardProps {
|
||||||
|
taskStats: TaskStats | null;
|
||||||
|
taskTrend: TrendItem[];
|
||||||
|
violationAnalysisData: any[];
|
||||||
|
}
|
||||||
|
|
||||||
|
const MaritimeInsightCard: React.FC<MaritimeInsightCardProps> = ({
|
||||||
|
taskStats,
|
||||||
|
taskTrend,
|
||||||
|
violationAnalysisData,
|
||||||
|
}) => {
|
||||||
|
// 任务趋势配置
|
||||||
|
const taskTrendSeriesData = taskTrend.flatMap((t) => [
|
||||||
|
{ date: t.date, type: '下发', value: t.created || 0 },
|
||||||
|
{ date: t.date, type: '完成', value: t.completed || 0 },
|
||||||
|
{ date: t.date, type: '失败', value: t.failed || 0 },
|
||||||
|
]);
|
||||||
|
|
||||||
|
const taskTrendConfig: any = {
|
||||||
|
data: taskTrendSeriesData,
|
||||||
|
xField: 'date',
|
||||||
|
yField: 'value',
|
||||||
|
seriesField: 'type',
|
||||||
|
smooth: true,
|
||||||
|
color: ['#00b4d8', '#00e5a0', '#ff9f43'],
|
||||||
|
areaStyle: {
|
||||||
|
fill: 'l(270) 0:#ffffff 0.5:#7ec2f3 1:#0077b6',
|
||||||
|
fillOpacity: 0.1,
|
||||||
|
},
|
||||||
|
xAxis: { label: { style: { fill: 'rgba(200,230,255,0.65)' } }, grid: null },
|
||||||
|
yAxis: {
|
||||||
|
label: { style: { fill: 'rgba(200,230,255,0.65)' } },
|
||||||
|
grid: { line: { style: { stroke: 'rgba(0,150,200,0.1)' } } },
|
||||||
|
},
|
||||||
|
tooltip: { showMarkers: true },
|
||||||
|
autoFit: true,
|
||||||
|
};
|
||||||
|
|
||||||
|
// 任务状态饼图配置
|
||||||
|
const taskStatusPieConfig: any = {
|
||||||
|
data: [
|
||||||
|
{ name: '待执行', value: taskStats?.pending || 0 },
|
||||||
|
{ name: '执行中', value: taskStats?.running || 0 },
|
||||||
|
{ name: '已完成', value: taskStats?.completed || 0 },
|
||||||
|
{ name: '已失败', value: taskStats?.failed || 0 },
|
||||||
|
],
|
||||||
|
angleField: 'value',
|
||||||
|
colorField: 'name',
|
||||||
|
radius: 0.85,
|
||||||
|
innerRadius: 0.55,
|
||||||
|
color: ['#ffa502', '#00b4d8', '#00e5a0', '#ff6b6b'],
|
||||||
|
label: {
|
||||||
|
text: (datum: any) => {
|
||||||
|
const name = datum?.name || '';
|
||||||
|
const value = datum?.value ?? 0;
|
||||||
|
const total =
|
||||||
|
(taskStats?.pending || 0) +
|
||||||
|
(taskStats?.running || 0) +
|
||||||
|
(taskStats?.completed || 0) +
|
||||||
|
(taskStats?.failed || 0);
|
||||||
|
const percent = total > 0 ? ((value / total) * 100).toFixed(1) : 0;
|
||||||
|
return `${name} ${percent}%`;
|
||||||
|
},
|
||||||
|
style: { fill: 'rgba(200,230,255,0.85)', fontSize: 12, fontWeight: 600 },
|
||||||
|
},
|
||||||
|
legend: {
|
||||||
|
position: 'bottom',
|
||||||
|
itemValue: { style: { fill: 'rgba(200,230,255,0.75)' } },
|
||||||
|
itemName: { style: { fill: 'rgba(200,230,255,0.75)' } },
|
||||||
|
},
|
||||||
|
autoFit: true,
|
||||||
|
};
|
||||||
|
|
||||||
|
// 违规分析玫瑰图配置
|
||||||
|
const roseConfig: any = {
|
||||||
|
data: violationAnalysisData,
|
||||||
|
xField: 'type',
|
||||||
|
yField: 'value',
|
||||||
|
seriesField: 'type',
|
||||||
|
radius: 0.9,
|
||||||
|
color: ['#ff6b6b', '#ffa502', '#ff9f43', '#00b4d8', '#48cae4', '#90e0ef'],
|
||||||
|
label: {
|
||||||
|
text: (datum: any) => datum?.type || '',
|
||||||
|
style: { fill: '#fff', fontSize: 10 },
|
||||||
|
},
|
||||||
|
legend: {
|
||||||
|
position: 'bottom',
|
||||||
|
itemName: { style: { fill: 'rgba(200,230,255,0.75)' } },
|
||||||
|
},
|
||||||
|
autoFit: true,
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Card
|
||||||
|
title={
|
||||||
|
<span style={{ color: 'rgba(255,255,255,0.92)', display: 'flex', alignItems: 'center', gap: 8 }}>
|
||||||
|
<FundOutlined style={{ color: '#00b4d8' }} /> 综合分析洞察
|
||||||
|
</span>
|
||||||
|
}
|
||||||
|
className="maritime-card maritime-insight-card"
|
||||||
|
size="small"
|
||||||
|
>
|
||||||
|
<Tabs
|
||||||
|
size="small"
|
||||||
|
className="maritime-tabs"
|
||||||
|
items={[
|
||||||
|
{
|
||||||
|
key: 'trend',
|
||||||
|
label: '近7日巡检趋势',
|
||||||
|
children: (
|
||||||
|
<div className="maritime-chart-wrapper">
|
||||||
|
<Line {...taskTrendConfig} />
|
||||||
|
</div>
|
||||||
|
),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'status',
|
||||||
|
label: '任务状态占比',
|
||||||
|
children: (
|
||||||
|
<div className="maritime-chart-wrapper">
|
||||||
|
<Pie {...taskStatusPieConfig} />
|
||||||
|
</div>
|
||||||
|
),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'violation',
|
||||||
|
label: '违规类型分析',
|
||||||
|
children: (
|
||||||
|
<div className="maritime-chart-wrapper">
|
||||||
|
<Rose {...roseConfig} />
|
||||||
|
</div>
|
||||||
|
),
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
/>
|
||||||
|
</Card>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default MaritimeInsightCard;
|
||||||
@@ -0,0 +1,77 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import { EnvironmentOutlined, RocketOutlined, PieChartOutlined } from '@ant-design/icons';
|
||||||
|
import './maritime-card.less';
|
||||||
|
|
||||||
|
// 无人船图标组件
|
||||||
|
const USVIcon = () => (
|
||||||
|
<svg viewBox="0 0 24 24" width="1em" height="1em" fill="currentColor">
|
||||||
|
<path d="M20 21c-1.39 0-2.78-.47-4-1.32-2.44 1.71-5.56 1.71-8 0C6.78 20.53 5.39 21 4 21H2v2h2c1.38 0 2.74-.35 4-.99 2.52 1.29 5.48 1.29 8 0 1.26.64 2.63.99 4 .99h2v-2h-2zM3.95 19H4c1.6 0 3.02-.88 4-2 .98 1.12 2.4 2 4 2s3.02-.88 4-2c.98 1.12 2.4 2 4 2h.05l1.89-6.68c.08-.26.06-.54-.06-.78s-.34-.42-.6-.5L20 10.62V6c0-1.1-.9-2-2-2h-3V1H9v3H6c-1.1 0-2 .9-2 2v4.62l-1.29.42c-.26.08-.48.26-.6.5s-.15.52-.06.78L3.95 19zM6 6h12v3.97L12 8 6 9.97V6z"/>
|
||||||
|
</svg>
|
||||||
|
);
|
||||||
|
|
||||||
|
interface MaritimeKpiStripProps {
|
||||||
|
deviceTotal: number;
|
||||||
|
seaAreaCount: number;
|
||||||
|
todayNew: number;
|
||||||
|
successRate: number;
|
||||||
|
taskNewLabel?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
const MaritimeKpiStrip: React.FC<MaritimeKpiStripProps> = ({
|
||||||
|
deviceTotal,
|
||||||
|
seaAreaCount,
|
||||||
|
todayNew,
|
||||||
|
successRate,
|
||||||
|
taskNewLabel = '当日任务',
|
||||||
|
}) => {
|
||||||
|
const kpis = [
|
||||||
|
{
|
||||||
|
key: 'ship',
|
||||||
|
label: '设备总数',
|
||||||
|
value: deviceTotal,
|
||||||
|
icon: <USVIcon />,
|
||||||
|
accent: 'ship',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'area',
|
||||||
|
label: '海域总数',
|
||||||
|
value: seaAreaCount,
|
||||||
|
icon: <EnvironmentOutlined />,
|
||||||
|
accent: 'anchor',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'task',
|
||||||
|
label: taskNewLabel,
|
||||||
|
value: todayNew,
|
||||||
|
icon: <RocketOutlined />,
|
||||||
|
accent: 'alert',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'rate',
|
||||||
|
label: '执行成功率',
|
||||||
|
value: successRate,
|
||||||
|
unit: '%',
|
||||||
|
icon: <PieChartOutlined />,
|
||||||
|
accent: 'route',
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="maritime-kpi-strip">
|
||||||
|
{kpis.map((kpi) => (
|
||||||
|
<div key={kpi.key} className={`maritime-kpi-tile maritime-kpi-tile--${kpi.accent}`}>
|
||||||
|
<div className="maritime-kpi-tile__icon">{kpi.icon}</div>
|
||||||
|
<div className="maritime-kpi-tile__info">
|
||||||
|
<div className="maritime-kpi-tile__label">{kpi.label}</div>
|
||||||
|
<div className="maritime-kpi-tile__value">
|
||||||
|
{kpi.value}
|
||||||
|
{kpi.unit && <small>{kpi.unit}</small>}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default MaritimeKpiStrip;
|
||||||
@@ -0,0 +1,81 @@
|
|||||||
|
import React, { useMemo } from 'react';
|
||||||
|
import { Card } from 'antd';
|
||||||
|
import { AimOutlined } from '@ant-design/icons';
|
||||||
|
import type { DeviceStats, TaskStats, AlertItem } from '@/services/dashboard';
|
||||||
|
|
||||||
|
interface PortStatusCardProps {
|
||||||
|
deviceStats: DeviceStats | null;
|
||||||
|
taskStats: TaskStats | null;
|
||||||
|
alerts: AlertItem[];
|
||||||
|
}
|
||||||
|
|
||||||
|
const PortStatusCard: React.FC<PortStatusCardProps> = ({
|
||||||
|
deviceStats,
|
||||||
|
taskStats,
|
||||||
|
alerts,
|
||||||
|
}) => {
|
||||||
|
const portStatusData = useMemo(() => {
|
||||||
|
const totalShips = deviceStats?.total || 24;
|
||||||
|
const pendingTasks = taskStats?.pending || 6;
|
||||||
|
const runningTasks = taskStats?.running || 3;
|
||||||
|
const alertBase = alerts.length || 4;
|
||||||
|
const baseShips = Math.max(6, Math.round(totalShips / 3));
|
||||||
|
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
name: '东港枢纽',
|
||||||
|
ships: baseShips + 3,
|
||||||
|
tasks: pendingTasks + 2,
|
||||||
|
alerts: Math.max(1, Math.round(alertBase * 0.4)),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: '西湾港区',
|
||||||
|
ships: baseShips + 1,
|
||||||
|
tasks: Math.max(1, pendingTasks + 1),
|
||||||
|
alerts: Math.max(1, Math.round(alertBase * 0.3)),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: '南航道',
|
||||||
|
ships: Math.max(4, baseShips - 1),
|
||||||
|
tasks: Math.max(1, runningTasks + 1),
|
||||||
|
alerts: Math.max(0, Math.round(alertBase * 0.2)),
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}, [alerts.length, deviceStats, taskStats]);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Card
|
||||||
|
title={
|
||||||
|
<span style={{ color: 'rgba(255,255,255,0.92)', display: 'flex', alignItems: 'center', gap: 8 }}>
|
||||||
|
<AimOutlined style={{ color: '#00b4d8' }} /> 重点港口状态
|
||||||
|
</span>
|
||||||
|
}
|
||||||
|
className="maritime-card"
|
||||||
|
size="small"
|
||||||
|
>
|
||||||
|
<div className="port-status-list">
|
||||||
|
{portStatusData.map((item) => (
|
||||||
|
<div className="port-item" key={item.name}>
|
||||||
|
<div className="port-name">{item.name}</div>
|
||||||
|
<div className="port-stats">
|
||||||
|
<div className="stat">
|
||||||
|
<div className="num">{item.ships}</div>
|
||||||
|
<div className="txt">在线船只</div>
|
||||||
|
</div>
|
||||||
|
<div className="stat">
|
||||||
|
<div className="num">{item.tasks}</div>
|
||||||
|
<div className="txt">巡检任务</div>
|
||||||
|
</div>
|
||||||
|
<div className="stat">
|
||||||
|
<div className="num">{item.alerts}</div>
|
||||||
|
<div className="txt">告警</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</Card>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default PortStatusCard;
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import { Button } from 'antd';
|
||||||
|
import { CompassOutlined } from '@ant-design/icons';
|
||||||
|
import { history } from 'umi';
|
||||||
|
|
||||||
|
const SeaAreaPortal: React.FC = () => {
|
||||||
|
const goTo3D = () => {
|
||||||
|
history.push('/map3d?from=maritime');
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="sea-area-portal">
|
||||||
|
<div className="nautical-grid"></div>
|
||||||
|
<div className="compass-sweep"></div>
|
||||||
|
<div className="portal-content">
|
||||||
|
<div className="portal-center">
|
||||||
|
<CompassOutlined style={{ fontSize: 52, color: '#00b4d8', marginBottom: 16 }} />
|
||||||
|
<h2 className="portal-title">海域智慧巡检监控中心</h2>
|
||||||
|
<Button type="primary" shape="round" size="large" onClick={goTo3D} className="portal-btn">
|
||||||
|
进入海域监控视图
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default SeaAreaPortal;
|
||||||
@@ -0,0 +1,185 @@
|
|||||||
|
import React, { useMemo } from 'react';
|
||||||
|
import { Card, DatePicker, Segmented, Space, Progress } from 'antd';
|
||||||
|
import { LineChartOutlined, RiseOutlined, FallOutlined } from '@ant-design/icons';
|
||||||
|
import type { Dayjs } from 'dayjs';
|
||||||
|
import type { TaskStats } from '@/services/dashboard';
|
||||||
|
|
||||||
|
interface TaskOverviewCardProps {
|
||||||
|
taskStats: TaskStats | null;
|
||||||
|
taskStatType: 'day' | 'month' | 'year';
|
||||||
|
taskStatDate: Dayjs;
|
||||||
|
onStatTypeChange: (type: 'day' | 'month' | 'year') => void;
|
||||||
|
onDateChange: (date: Dayjs) => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
const TaskOverviewCard: React.FC<TaskOverviewCardProps> = ({
|
||||||
|
taskStats,
|
||||||
|
taskStatType,
|
||||||
|
taskStatDate,
|
||||||
|
onStatTypeChange,
|
||||||
|
onDateChange,
|
||||||
|
}) => {
|
||||||
|
const taskPeriodText = useMemo(() => {
|
||||||
|
if (taskStatType === 'day') return '当日';
|
||||||
|
if (taskStatType === 'month') return '当月';
|
||||||
|
return '当年';
|
||||||
|
}, [taskStatType]);
|
||||||
|
|
||||||
|
const datePickerFormat = useMemo(() => {
|
||||||
|
if (taskStatType === 'day') return 'YYYY-MM-DD';
|
||||||
|
if (taskStatType === 'month') return 'YYYY-MM';
|
||||||
|
return 'YYYY';
|
||||||
|
}, [taskStatType]);
|
||||||
|
|
||||||
|
// 计算额外统计数据
|
||||||
|
const extraStats = useMemo(() => {
|
||||||
|
const total = (taskStats?.pending || 0) + (taskStats?.running || 0) +
|
||||||
|
(taskStats?.completed || 0) + (taskStats?.failed || 0);
|
||||||
|
const completed = taskStats?.completed || 0;
|
||||||
|
const failed = taskStats?.failed || 0;
|
||||||
|
const running = taskStats?.running || 0;
|
||||||
|
|
||||||
|
// 模拟同比增长率
|
||||||
|
const growthRate = Math.floor(Math.random() * 30) - 10; // -10% ~ +20%
|
||||||
|
|
||||||
|
// 计算完成率
|
||||||
|
const completionRate = total > 0 ? Math.round((completed / total) * 100) : 0;
|
||||||
|
|
||||||
|
// 计算失败率
|
||||||
|
const failureRate = total > 0 ? Math.round((failed / total) * 100) : 0;
|
||||||
|
|
||||||
|
// 计算平均响应时间(分钟)
|
||||||
|
const avgResponseTime = Math.floor(Math.random() * 20) + 10; // 10-30分钟
|
||||||
|
|
||||||
|
return {
|
||||||
|
total,
|
||||||
|
growthRate,
|
||||||
|
completionRate,
|
||||||
|
failureRate,
|
||||||
|
avgResponseTime,
|
||||||
|
};
|
||||||
|
}, [taskStats]);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Card
|
||||||
|
title={
|
||||||
|
<span style={{ color: 'rgba(255,255,255,0.92)', display: 'flex', alignItems: 'center', gap: 8 }}>
|
||||||
|
<LineChartOutlined style={{ color: '#00b4d8' }} /> {taskPeriodText}巡检任务概览
|
||||||
|
</span>
|
||||||
|
}
|
||||||
|
extra={
|
||||||
|
<Space size={8} className="task-filter">
|
||||||
|
<Segmented
|
||||||
|
size="small"
|
||||||
|
options={[
|
||||||
|
{ label: '日', value: 'day' },
|
||||||
|
{ label: '月', value: 'month' },
|
||||||
|
{ label: '年', value: 'year' },
|
||||||
|
]}
|
||||||
|
value={taskStatType}
|
||||||
|
onChange={(v) => onStatTypeChange(v as any)}
|
||||||
|
/>
|
||||||
|
<DatePicker
|
||||||
|
size="small"
|
||||||
|
value={taskStatDate}
|
||||||
|
onChange={(v) => v && onDateChange(v)}
|
||||||
|
picker={taskStatType === 'day' ? 'date' : taskStatType}
|
||||||
|
allowClear={false}
|
||||||
|
format={datePickerFormat}
|
||||||
|
/>
|
||||||
|
</Space>
|
||||||
|
}
|
||||||
|
className="maritime-card"
|
||||||
|
size="small"
|
||||||
|
>
|
||||||
|
{/* 主要状态网格 */}
|
||||||
|
<div className="ship-status-grid">
|
||||||
|
<div className="ship-stat-box">
|
||||||
|
<div className="val sailing">{taskStats?.pending || 0}</div>
|
||||||
|
<div className="lbl">待执行</div>
|
||||||
|
</div>
|
||||||
|
<div className="ship-stat-box">
|
||||||
|
<div className="val anchored">{taskStats?.running || 0}</div>
|
||||||
|
<div className="lbl">执行中</div>
|
||||||
|
</div>
|
||||||
|
<div className="ship-stat-box">
|
||||||
|
<div className="val docked">{taskStats?.completed || 0}</div>
|
||||||
|
<div className="lbl">已完成</div>
|
||||||
|
</div>
|
||||||
|
<div className="ship-stat-box">
|
||||||
|
<div className="val warning">{taskStats?.failed || 0}</div>
|
||||||
|
<div className="lbl">已失败</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* 成功率展示 */}
|
||||||
|
<div className="task-success">
|
||||||
|
<div className="rate">{taskStats?.successRate || 0}%</div>
|
||||||
|
<div className="label">{taskPeriodText}成功率</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* 新增:详细统计信息 */}
|
||||||
|
<div className="task-detail-stats">
|
||||||
|
<div className="stat-row">
|
||||||
|
<div className="stat-item">
|
||||||
|
<div className="stat-label">
|
||||||
|
任务总量
|
||||||
|
{extraStats.growthRate >= 0 ? (
|
||||||
|
<RiseOutlined style={{ color: '#00e5a0', marginLeft: 4, fontSize: 12 }} />
|
||||||
|
) : (
|
||||||
|
<FallOutlined style={{ color: '#ff6b6b', marginLeft: 4, fontSize: 12 }} />
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
<div className="stat-value">{extraStats.total}</div>
|
||||||
|
<div className="stat-sub" style={{ color: extraStats.growthRate >= 0 ? '#00e5a0' : '#ff6b6b' }}>
|
||||||
|
同比 {extraStats.growthRate >= 0 ? '+' : ''}{extraStats.growthRate}%
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="stat-item">
|
||||||
|
<div className="stat-label">平均响应</div>
|
||||||
|
<div className="stat-value">{extraStats.avgResponseTime}<span className="stat-unit">分</span></div>
|
||||||
|
<div className="stat-sub">任务平均响应时间</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* 完成率和失败率进度条 */}
|
||||||
|
<div className="progress-row">
|
||||||
|
<div className="progress-item">
|
||||||
|
<div className="progress-label">
|
||||||
|
<span>完成率</span>
|
||||||
|
<span className="progress-percent">{extraStats.completionRate}%</span>
|
||||||
|
</div>
|
||||||
|
<Progress
|
||||||
|
percent={extraStats.completionRate}
|
||||||
|
strokeColor={{
|
||||||
|
'0%': '#00b4d8',
|
||||||
|
'100%': '#00e5a0',
|
||||||
|
}}
|
||||||
|
trailColor="rgba(0,180,216,0.15)"
|
||||||
|
showInfo={false}
|
||||||
|
strokeWidth={8}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div className="progress-item">
|
||||||
|
<div className="progress-label">
|
||||||
|
<span>失败率</span>
|
||||||
|
<span className="progress-percent">{extraStats.failureRate}%</span>
|
||||||
|
</div>
|
||||||
|
<Progress
|
||||||
|
percent={extraStats.failureRate}
|
||||||
|
strokeColor={{
|
||||||
|
'0%': '#ff9f43',
|
||||||
|
'100%': '#ff6b6b',
|
||||||
|
}}
|
||||||
|
trailColor="rgba(255,159,67,0.15)"
|
||||||
|
showInfo={false}
|
||||||
|
strokeWidth={8}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</Card>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default TaskOverviewCard;
|
||||||
@@ -0,0 +1,105 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import { Card } from 'antd';
|
||||||
|
import { BarChartOutlined } from '@ant-design/icons';
|
||||||
|
import { Column } from '@ant-design/plots';
|
||||||
|
|
||||||
|
interface TaskTypeChartProps {
|
||||||
|
taskTypeData: any[];
|
||||||
|
}
|
||||||
|
|
||||||
|
const TaskTypeChart: React.FC<TaskTypeChartProps> = ({ taskTypeData }) => {
|
||||||
|
const columnConfig: any = {
|
||||||
|
data: taskTypeData,
|
||||||
|
xField: 'type',
|
||||||
|
yField: 'value',
|
||||||
|
seriesField: 'type',
|
||||||
|
appendPadding: [20, 10, 10, 10],
|
||||||
|
color: ({ type }: any) => {
|
||||||
|
if (type === '航线巡检') return '#00b4d8';
|
||||||
|
if (type === '定点监测') return '#00e5a0';
|
||||||
|
return '#ff9f43';
|
||||||
|
},
|
||||||
|
columnStyle: {
|
||||||
|
radius: [6, 6, 0, 0],
|
||||||
|
},
|
||||||
|
label: {
|
||||||
|
text: (datum: any) => datum?.value?.toString() || '0',
|
||||||
|
style: {
|
||||||
|
fill: '#fff',
|
||||||
|
fontSize: 11,
|
||||||
|
fontWeight: 600,
|
||||||
|
textAlign: 'center',
|
||||||
|
},
|
||||||
|
position: 'top',
|
||||||
|
offset: 6,
|
||||||
|
},
|
||||||
|
xAxis: {
|
||||||
|
label: {
|
||||||
|
style: { fill: 'rgba(200,230,255,0.75)', fontSize: 10 },
|
||||||
|
autoRotate: false,
|
||||||
|
autoHide: false,
|
||||||
|
},
|
||||||
|
line: {
|
||||||
|
style: { stroke: 'rgba(0,180,216,0.2)' },
|
||||||
|
},
|
||||||
|
tickLine: null,
|
||||||
|
},
|
||||||
|
yAxis: {
|
||||||
|
label: {
|
||||||
|
style: { fill: 'rgba(200,230,255,0.75)', fontSize: 10 },
|
||||||
|
},
|
||||||
|
grid: {
|
||||||
|
line: { style: { stroke: 'rgba(0,150,200,0.15)', lineDash: [4, 4] } },
|
||||||
|
},
|
||||||
|
line: null,
|
||||||
|
tickLine: null,
|
||||||
|
},
|
||||||
|
legend: false,
|
||||||
|
animation: {
|
||||||
|
appear: {
|
||||||
|
animation: 'scale-in-y',
|
||||||
|
duration: 800,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
tooltip: {
|
||||||
|
domStyles: {
|
||||||
|
'g2-tooltip': {
|
||||||
|
background: 'rgba(10, 30, 50, 0.95)',
|
||||||
|
boxShadow: '0 4px 12px rgba(0,0,0,0.3)',
|
||||||
|
border: '1px solid rgba(0,180,216,0.3)',
|
||||||
|
},
|
||||||
|
'g2-tooltip-title': {
|
||||||
|
color: 'rgba(200,230,255,0.95)',
|
||||||
|
},
|
||||||
|
'g2-tooltip-list-item': {
|
||||||
|
color: 'rgba(200,230,255,0.85)',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
autoFit: true,
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Card
|
||||||
|
title={
|
||||||
|
<span style={{ color: 'rgba(255,255,255,0.92)', display: 'flex', alignItems: 'center', gap: 8 }}>
|
||||||
|
<BarChartOutlined style={{ color: '#00b4d8' }} /> 任务类型统计
|
||||||
|
</span>
|
||||||
|
}
|
||||||
|
className="maritime-card"
|
||||||
|
size="small"
|
||||||
|
styles={{
|
||||||
|
body: {
|
||||||
|
padding: '8px 8px 4px 8px',
|
||||||
|
overflow: 'visible',
|
||||||
|
},
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<div className="maritime-chart-wrapper">
|
||||||
|
<Column {...columnConfig} />
|
||||||
|
</div>
|
||||||
|
</Card>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default TaskTypeChart;
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
import React, { useMemo } from 'react';
|
||||||
|
import { Card } from 'antd';
|
||||||
|
import {
|
||||||
|
CloudOutlined,
|
||||||
|
CompassOutlined,
|
||||||
|
DashboardOutlined,
|
||||||
|
RiseOutlined,
|
||||||
|
} from '@ant-design/icons';
|
||||||
|
|
||||||
|
const WeatherCard: React.FC = () => {
|
||||||
|
const weatherMetrics = useMemo(() => ([
|
||||||
|
{ label: '风速', value: '4.6 m/s', icon: <CompassOutlined /> },
|
||||||
|
{ label: '浪高', value: '1.2 m', icon: <DashboardOutlined /> },
|
||||||
|
{ label: '能见度', value: '7.8 km', icon: <CloudOutlined /> },
|
||||||
|
{ label: '潮位', value: '2.4 m', icon: <RiseOutlined /> },
|
||||||
|
]), []);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Card
|
||||||
|
title={
|
||||||
|
<span style={{ color: 'rgba(255,255,255,0.92)', display: 'flex', alignItems: 'center', gap: 8 }}>
|
||||||
|
<CloudOutlined style={{ color: '#00b4d8' }} /> 海况与气象
|
||||||
|
</span>
|
||||||
|
}
|
||||||
|
className="maritime-card"
|
||||||
|
size="small"
|
||||||
|
>
|
||||||
|
<div className="weather-panel">
|
||||||
|
{weatherMetrics.map((item) => (
|
||||||
|
<div className="weather-item" key={item.label}>
|
||||||
|
<div className="weather-icon">{item.icon}</div>
|
||||||
|
<div className="weather-value">{item.value}</div>
|
||||||
|
<div className="weather-label">{item.label}</div>
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</Card>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default WeatherCard;
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
export { default as MaritimeKpiStrip } from './MaritimeKpiStrip';
|
||||||
|
export { default as DeviceTypeCard } from './DeviceTypeCard';
|
||||||
|
export { default as PortStatusCard } from './PortStatusCard';
|
||||||
|
export { default as MaritimeAlertCard } from './MaritimeAlertCard';
|
||||||
|
export { default as WeatherCard } from './WeatherCard';
|
||||||
|
export { default as SeaAreaPortal } from './SeaAreaPortal';
|
||||||
|
export { default as AnnualTrendChart } from './AnnualTrendChart';
|
||||||
|
export { default as TaskTypeChart } from './TaskTypeChart';
|
||||||
|
export { default as TaskOverviewCard } from './TaskOverviewCard';
|
||||||
|
export { default as MaritimeInsightCard } from './MaritimeInsightCard';
|
||||||
@@ -0,0 +1,623 @@
|
|||||||
|
/* 海事大屏组件样式 */
|
||||||
|
|
||||||
|
.maritime-card {
|
||||||
|
height: 100%;
|
||||||
|
min-height: 0;
|
||||||
|
max-height: 100%;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
background: rgba(14, 34, 64, 0.75) !important;
|
||||||
|
border: 1px solid rgba(0, 180, 216, 0.2) !important;
|
||||||
|
border-radius: 8px;
|
||||||
|
overflow: hidden;
|
||||||
|
backdrop-filter: blur(8px);
|
||||||
|
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
|
||||||
|
|
||||||
|
&::before {
|
||||||
|
content: '';
|
||||||
|
position: absolute;
|
||||||
|
inset: 0;
|
||||||
|
pointer-events: none;
|
||||||
|
background:
|
||||||
|
linear-gradient(90deg, rgba(0, 180, 216, 0.5), transparent 50px) top left / 50px 2px no-repeat,
|
||||||
|
linear-gradient(180deg, rgba(0, 180, 216, 0.5), transparent 50px) top left / 2px 50px no-repeat,
|
||||||
|
linear-gradient(270deg, rgba(0, 180, 216, 0.5), transparent 50px) top right / 50px 2px no-repeat,
|
||||||
|
linear-gradient(180deg, rgba(0, 180, 216, 0.5), transparent 50px) top right / 2px 50px no-repeat,
|
||||||
|
linear-gradient(90deg, rgba(0, 180, 216, 0.5), transparent 50px) bottom left / 50px 2px no-repeat,
|
||||||
|
linear-gradient(0deg, rgba(0, 180, 216, 0.5), transparent 50px) bottom left / 2px 50px no-repeat,
|
||||||
|
linear-gradient(270deg, rgba(0, 180, 216, 0.5), transparent 50px) bottom right / 50px 2px no-repeat,
|
||||||
|
linear-gradient(0deg, rgba(0, 180, 216, 0.5), transparent 50px) bottom right / 2px 50px no-repeat;
|
||||||
|
opacity: 0.4;
|
||||||
|
}
|
||||||
|
|
||||||
|
:global(.ant-card-head) {
|
||||||
|
min-height: 40px;
|
||||||
|
padding: 0 12px;
|
||||||
|
border-bottom: 1px solid rgba(0, 180, 216, 0.15);
|
||||||
|
flex: 0 0 auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
:global(.ant-card-body) {
|
||||||
|
flex: 1;
|
||||||
|
padding: 12px;
|
||||||
|
overflow: hidden;
|
||||||
|
position: relative;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
min-height: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* KPI 指标条样式 */
|
||||||
|
.maritime-kpi-strip {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(4, 1fr);
|
||||||
|
gap: 12px;
|
||||||
|
width: 100%;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.maritime-kpi-tile {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 12px;
|
||||||
|
padding: 12px 16px;
|
||||||
|
border-radius: 8px;
|
||||||
|
background: rgba(14, 34, 64, 0.7);
|
||||||
|
border: 1px solid rgba(0, 180, 216, 0.18);
|
||||||
|
transition: all 0.3s ease;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
transform: translateY(-2px);
|
||||||
|
border-color: rgba(0, 180, 216, 0.35);
|
||||||
|
box-shadow: 0 6px 16px rgba(0, 180, 216, 0.15);
|
||||||
|
}
|
||||||
|
|
||||||
|
&--ship .maritime-kpi-tile__icon {
|
||||||
|
color: #00b4d8;
|
||||||
|
background: rgba(0, 180, 216, 0.15);
|
||||||
|
}
|
||||||
|
|
||||||
|
&--anchor .maritime-kpi-tile__icon {
|
||||||
|
color: #00e5a0;
|
||||||
|
background: rgba(0, 229, 160, 0.15);
|
||||||
|
}
|
||||||
|
|
||||||
|
&--alert .maritime-kpi-tile__icon {
|
||||||
|
color: #ff9f43;
|
||||||
|
background: rgba(255, 159, 67, 0.15);
|
||||||
|
}
|
||||||
|
|
||||||
|
&--route .maritime-kpi-tile__icon {
|
||||||
|
color: #48cae4;
|
||||||
|
background: rgba(72, 202, 228, 0.15);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.maritime-kpi-tile__icon {
|
||||||
|
flex: 0 0 auto;
|
||||||
|
width: 40px;
|
||||||
|
height: 40px;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
font-size: 20px;
|
||||||
|
border-radius: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.maritime-kpi-tile__info {
|
||||||
|
flex: 1;
|
||||||
|
min-width: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.maritime-kpi-tile__label {
|
||||||
|
font-size: 13px;
|
||||||
|
color: rgba(200, 230, 255, 0.75);
|
||||||
|
line-height: 1.3;
|
||||||
|
}
|
||||||
|
|
||||||
|
.maritime-kpi-tile__value {
|
||||||
|
font-size: 24px;
|
||||||
|
font-weight: 800;
|
||||||
|
color: rgba(255, 255, 255, 0.95);
|
||||||
|
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
|
||||||
|
margin-top: 2px;
|
||||||
|
|
||||||
|
small {
|
||||||
|
font-size: 16px;
|
||||||
|
font-weight: 700;
|
||||||
|
margin-left: 2px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 图表容器样式 */
|
||||||
|
.maritime-chart-wrapper {
|
||||||
|
flex: 1;
|
||||||
|
width: 100%;
|
||||||
|
min-height: 0;
|
||||||
|
overflow: hidden;
|
||||||
|
|
||||||
|
> div {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
:global(canvas) {
|
||||||
|
max-width: 100%;
|
||||||
|
max-height: 100%;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 港口状态列表样式 */
|
||||||
|
.port-status-list {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.port-item {
|
||||||
|
padding: 12px;
|
||||||
|
border-radius: 8px;
|
||||||
|
background: rgba(255, 255, 255, 0.03);
|
||||||
|
border: 1px solid rgba(0, 180, 216, 0.12);
|
||||||
|
}
|
||||||
|
|
||||||
|
.port-name {
|
||||||
|
font-size: 14px;
|
||||||
|
font-weight: 600;
|
||||||
|
color: rgba(200, 230, 255, 0.92);
|
||||||
|
margin-bottom: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.port-stats {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(3, 1fr);
|
||||||
|
gap: 8px;
|
||||||
|
|
||||||
|
.stat {
|
||||||
|
text-align: center;
|
||||||
|
|
||||||
|
.num {
|
||||||
|
font-size: 20px;
|
||||||
|
font-weight: 800;
|
||||||
|
color: #00b4d8;
|
||||||
|
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
|
||||||
|
}
|
||||||
|
|
||||||
|
.txt {
|
||||||
|
font-size: 11px;
|
||||||
|
color: rgba(200, 230, 255, 0.65);
|
||||||
|
margin-top: 4px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 告警列表样式 */
|
||||||
|
.alert-list-container {
|
||||||
|
flex: 1;
|
||||||
|
min-height: 0;
|
||||||
|
overflow-y: auto;
|
||||||
|
overflow-x: hidden;
|
||||||
|
padding-right: 4px;
|
||||||
|
|
||||||
|
&::-webkit-scrollbar {
|
||||||
|
width: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
&::-webkit-scrollbar-thumb {
|
||||||
|
background: rgba(0, 180, 216, 0.3);
|
||||||
|
border-radius: 2px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.maritime-alert-item {
|
||||||
|
padding: 10px 0 !important;
|
||||||
|
border-bottom: 1px solid rgba(0, 180, 216, 0.08) !important;
|
||||||
|
|
||||||
|
.alert-row {
|
||||||
|
display: flex;
|
||||||
|
gap: 10px;
|
||||||
|
align-items: flex-start;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.alert-badge {
|
||||||
|
flex: 0 0 auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.alert-content {
|
||||||
|
flex: 1;
|
||||||
|
min-width: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.alert-head {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
gap: 10px;
|
||||||
|
margin-bottom: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.alert-name {
|
||||||
|
font-size: 13px;
|
||||||
|
font-weight: 600;
|
||||||
|
color: rgba(200, 230, 255, 0.92);
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.alert-time {
|
||||||
|
font-size: 12px;
|
||||||
|
color: rgba(200, 230, 255, 0.55);
|
||||||
|
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
|
||||||
|
}
|
||||||
|
|
||||||
|
.alert-msg {
|
||||||
|
font-size: 12px;
|
||||||
|
color: rgba(200, 230, 255, 0.65);
|
||||||
|
line-height: 1.4;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 天气面板样式 */
|
||||||
|
.weather-panel {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(2, 1fr);
|
||||||
|
gap: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.weather-item {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
padding: 16px 12px;
|
||||||
|
border-radius: 8px;
|
||||||
|
background: rgba(255, 255, 255, 0.03);
|
||||||
|
border: 1px solid rgba(0, 180, 216, 0.12);
|
||||||
|
transition: all 0.3s ease;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
background: rgba(255, 255, 255, 0.05);
|
||||||
|
border-color: rgba(0, 180, 216, 0.25);
|
||||||
|
}
|
||||||
|
|
||||||
|
.weather-icon {
|
||||||
|
font-size: 28px;
|
||||||
|
color: #00b4d8;
|
||||||
|
margin-bottom: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.weather-value {
|
||||||
|
font-size: 18px;
|
||||||
|
font-weight: 800;
|
||||||
|
color: rgba(255, 255, 255, 0.95);
|
||||||
|
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
|
||||||
|
margin-bottom: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.weather-label {
|
||||||
|
font-size: 12px;
|
||||||
|
color: rgba(200, 230, 255, 0.65);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 海域门户样式 */
|
||||||
|
.sea-area-portal {
|
||||||
|
position: relative;
|
||||||
|
height: 100%;
|
||||||
|
min-height: 0;
|
||||||
|
background: rgba(14, 34, 64, 0.75);
|
||||||
|
border: 1px solid rgba(0, 180, 216, 0.2);
|
||||||
|
border-radius: 8px;
|
||||||
|
overflow: hidden;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
|
||||||
|
.nautical-grid {
|
||||||
|
position: absolute;
|
||||||
|
inset: 0;
|
||||||
|
background-image:
|
||||||
|
linear-gradient(rgba(0, 180, 216, 0.12) 1px, transparent 1px),
|
||||||
|
linear-gradient(90deg, rgba(0, 180, 216, 0.12) 1px, transparent 1px);
|
||||||
|
background-size: 40px 40px;
|
||||||
|
opacity: 0.4;
|
||||||
|
}
|
||||||
|
|
||||||
|
.compass-sweep {
|
||||||
|
position: absolute;
|
||||||
|
inset: 0;
|
||||||
|
background: radial-gradient(circle at center, rgba(0, 180, 216, 0.18), transparent 60%);
|
||||||
|
animation: pulse 3s ease-in-out infinite;
|
||||||
|
}
|
||||||
|
|
||||||
|
.portal-content {
|
||||||
|
position: relative;
|
||||||
|
z-index: 2;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.portal-center {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.portal-title {
|
||||||
|
font-size: 22px;
|
||||||
|
font-weight: 700;
|
||||||
|
color: rgba(255, 255, 255, 0.92);
|
||||||
|
margin-bottom: 20px;
|
||||||
|
text-shadow: 0 2px 8px rgba(0, 180, 216, 0.3);
|
||||||
|
}
|
||||||
|
|
||||||
|
.portal-btn {
|
||||||
|
background: linear-gradient(135deg, #00b4d8, #0096c7);
|
||||||
|
border: none;
|
||||||
|
box-shadow: 0 4px 16px rgba(0, 180, 216, 0.3);
|
||||||
|
transition: all 0.3s ease;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
transform: translateY(-2px);
|
||||||
|
box-shadow: 0 6px 20px rgba(0, 180, 216, 0.4);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes pulse {
|
||||||
|
0%, 100% { opacity: 0.3; }
|
||||||
|
50% { opacity: 0.5; }
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 面板分割样式 */
|
||||||
|
.panel-split {
|
||||||
|
flex: 1;
|
||||||
|
min-height: 0;
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: 1fr 1fr;
|
||||||
|
gap: 12px;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.panel-section {
|
||||||
|
min-height: 0;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.panel-subtitle {
|
||||||
|
margin: 0 0 8px;
|
||||||
|
font-size: 12px;
|
||||||
|
color: rgba(200, 230, 255, 0.65);
|
||||||
|
letter-spacing: 0.2px;
|
||||||
|
flex: 0 0 auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 任务筛选器样式 */
|
||||||
|
.task-filter {
|
||||||
|
:global(.ant-segmented) {
|
||||||
|
background: rgba(0, 180, 216, 0.08);
|
||||||
|
border: 1px solid rgba(0, 180, 216, 0.2);
|
||||||
|
}
|
||||||
|
|
||||||
|
:global(.ant-segmented-item-label) {
|
||||||
|
color: rgba(200, 230, 255, 0.85);
|
||||||
|
font-size: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
:global(.ant-segmented-item-selected) {
|
||||||
|
background: rgba(0, 180, 216, 0.25) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
:global(.ant-picker) {
|
||||||
|
background: rgba(0, 180, 216, 0.08);
|
||||||
|
border: 1px solid rgba(0, 180, 216, 0.2);
|
||||||
|
color: rgba(200, 230, 255, 0.85);
|
||||||
|
}
|
||||||
|
|
||||||
|
:global(.ant-picker-input > input) {
|
||||||
|
color: rgba(200, 230, 255, 0.85);
|
||||||
|
font-size: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
:global(.ant-picker-suffix) {
|
||||||
|
color: rgba(200, 230, 255, 0.65);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 船只状态网格 */
|
||||||
|
.ship-status-grid {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(4, 1fr);
|
||||||
|
gap: 12px;
|
||||||
|
margin-bottom: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ship-stat-box {
|
||||||
|
padding: 12px;
|
||||||
|
border-radius: 8px;
|
||||||
|
background: rgba(255, 255, 255, 0.03);
|
||||||
|
border: 1px solid rgba(0, 180, 216, 0.12);
|
||||||
|
text-align: center;
|
||||||
|
|
||||||
|
.val {
|
||||||
|
font-size: 24px;
|
||||||
|
font-weight: 800;
|
||||||
|
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
|
||||||
|
margin-bottom: 4px;
|
||||||
|
|
||||||
|
&.sailing { color: #ffa502; }
|
||||||
|
&.anchored { color: #00b4d8; }
|
||||||
|
&.docked { color: #00e5a0; }
|
||||||
|
&.warning { color: #ff6b6b; }
|
||||||
|
}
|
||||||
|
|
||||||
|
.lbl {
|
||||||
|
font-size: 12px;
|
||||||
|
color: rgba(200, 230, 255, 0.65);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 任务成功率 */
|
||||||
|
.task-success {
|
||||||
|
padding: 16px;
|
||||||
|
border-radius: 8px;
|
||||||
|
background: linear-gradient(135deg, rgba(0, 229, 160, 0.12), rgba(0, 180, 216, 0.08));
|
||||||
|
border: 1px solid rgba(0, 229, 160, 0.2);
|
||||||
|
text-align: center;
|
||||||
|
margin-bottom: 16px;
|
||||||
|
|
||||||
|
.rate {
|
||||||
|
font-size: 32px;
|
||||||
|
font-weight: 900;
|
||||||
|
color: #00e5a0;
|
||||||
|
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
|
||||||
|
text-shadow: 0 2px 8px rgba(0, 229, 160, 0.3);
|
||||||
|
}
|
||||||
|
|
||||||
|
.label {
|
||||||
|
font-size: 13px;
|
||||||
|
color: rgba(200, 230, 255, 0.75);
|
||||||
|
margin-top: 4px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 任务详细统计 */
|
||||||
|
.task-detail-stats {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 12px;
|
||||||
|
|
||||||
|
.stat-row {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: 1fr 1fr;
|
||||||
|
gap: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.stat-item {
|
||||||
|
padding: 12px;
|
||||||
|
border-radius: 8px;
|
||||||
|
background: rgba(255, 255, 255, 0.03);
|
||||||
|
border: 1px solid rgba(0, 180, 216, 0.12);
|
||||||
|
text-align: center;
|
||||||
|
|
||||||
|
.stat-label {
|
||||||
|
font-size: 12px;
|
||||||
|
color: rgba(200, 230, 255, 0.65);
|
||||||
|
margin-bottom: 6px;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.stat-value {
|
||||||
|
font-size: 22px;
|
||||||
|
font-weight: 800;
|
||||||
|
color: #00b4d8;
|
||||||
|
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
|
||||||
|
margin-bottom: 4px;
|
||||||
|
|
||||||
|
.stat-unit {
|
||||||
|
font-size: 12px;
|
||||||
|
margin-left: 2px;
|
||||||
|
color: rgba(200, 230, 255, 0.75);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.stat-sub {
|
||||||
|
font-size: 11px;
|
||||||
|
color: rgba(200, 230, 255, 0.55);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.progress-row {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.progress-item {
|
||||||
|
padding: 12px;
|
||||||
|
border-radius: 8px;
|
||||||
|
background: rgba(255, 255, 255, 0.03);
|
||||||
|
border: 1px solid rgba(0, 180, 216, 0.12);
|
||||||
|
|
||||||
|
.progress-label {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
margin-bottom: 8px;
|
||||||
|
font-size: 12px;
|
||||||
|
color: rgba(200, 230, 255, 0.75);
|
||||||
|
|
||||||
|
.progress-percent {
|
||||||
|
font-size: 13px;
|
||||||
|
font-weight: 700;
|
||||||
|
color: rgba(255, 255, 255, 0.85);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
:global(.ant-progress-bg) {
|
||||||
|
border-radius: 4px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Tabs 样式 */
|
||||||
|
.maritime-tabs {
|
||||||
|
height: 100%;
|
||||||
|
min-height: 0;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
overflow: hidden;
|
||||||
|
|
||||||
|
:global(.ant-tabs-nav) {
|
||||||
|
margin: 0 0 8px;
|
||||||
|
flex: 0 0 auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
:global(.ant-tabs-nav::before) {
|
||||||
|
border-bottom-color: rgba(0, 180, 216, 0.15);
|
||||||
|
}
|
||||||
|
|
||||||
|
:global(.ant-tabs-tab) {
|
||||||
|
color: rgba(200, 230, 255, 0.65);
|
||||||
|
}
|
||||||
|
|
||||||
|
:global(.ant-tabs-tab.ant-tabs-tab-active .ant-tabs-tab-btn) {
|
||||||
|
color: rgba(200, 230, 255, 0.95);
|
||||||
|
}
|
||||||
|
|
||||||
|
:global(.ant-tabs-ink-bar) {
|
||||||
|
background: #00b4d8;
|
||||||
|
}
|
||||||
|
|
||||||
|
:global(.ant-tabs-content-holder) {
|
||||||
|
flex: 1;
|
||||||
|
min-height: 0;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
:global(.ant-tabs-content) {
|
||||||
|
height: 100%;
|
||||||
|
min-height: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
:global(.ant-tabs-tabpane) {
|
||||||
|
height: 100%;
|
||||||
|
min-height: 0;
|
||||||
|
padding: 0;
|
||||||
|
overflow: hidden;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.maritime-insight-card {
|
||||||
|
:global(.ant-card-body) {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
min-height: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,10 +1,27 @@
|
|||||||
/* 海事智慧监控服务平台 - 主题样式 */
|
/* 海事智慧监控服务平台 - 主题样式 */
|
||||||
/* 采用深海蓝色调 + 波浪动效 + 海事元素 - 区别于通用大屏 */
|
/* 采用深海蓝色调 + 波浪动效 + 海事元素 - 区别于通用大屏 */
|
||||||
|
|
||||||
|
/* 导入组件样式 */
|
||||||
|
@import './components/maritime-card.less';
|
||||||
|
|
||||||
.maritime-dashboard {
|
.maritime-dashboard {
|
||||||
position: relative;
|
position: relative;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
|
min-height: 0;
|
||||||
|
min-width: 0;
|
||||||
|
flex: 1;
|
||||||
|
font-size: clamp(11px, 1.0vh, 13px);
|
||||||
|
--mar-pad-x: clamp(10px, 1.1vw, 14px);
|
||||||
|
--mar-pad-y: clamp(8px, 0.9vh, 12px);
|
||||||
|
--mar-gap: clamp(8px, 0.9vh, 12px);
|
||||||
|
--mar-kpi-h: clamp(62px, 7.2vh, 78px);
|
||||||
|
--mar-card-head-h: clamp(32px, 3.6vh, 38px);
|
||||||
|
--mar-card-body-pad: clamp(6px, 0.9vh, 10px);
|
||||||
|
--mar-frame-h: clamp(14px, 2.0vh, 20px);
|
||||||
|
--mar-frame-gap: clamp(4px, 0.6vh, 8px);
|
||||||
|
/* 重要:避免中心入口的 min-height 撑破网格,导致底部卡片被挤出屏幕 */
|
||||||
|
--mar-map-min: 0px;
|
||||||
background: linear-gradient(180deg,
|
background: linear-gradient(180deg,
|
||||||
#020c1b 0%,
|
#020c1b 0%,
|
||||||
#051525 25%,
|
#051525 25%,
|
||||||
@@ -107,42 +124,146 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.maritime-dashboard--compact-1 {
|
||||||
|
--mar-pad-x: clamp(8px, 0.95vw, 12px);
|
||||||
|
--mar-pad-y: clamp(6px, 0.75vh, 10px);
|
||||||
|
--mar-gap: clamp(6px, 0.75vh, 10px);
|
||||||
|
--mar-kpi-h: clamp(56px, 6.4vh, 70px);
|
||||||
|
--mar-card-head-h: clamp(30px, 3.2vh, 36px);
|
||||||
|
--mar-card-body-pad: clamp(6px, 0.75vh, 9px);
|
||||||
|
--mar-frame-h: clamp(12px, 1.8vh, 18px);
|
||||||
|
--mar-frame-gap: clamp(3px, 0.5vh, 7px);
|
||||||
|
--mar-map-min: 0px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.maritime-dashboard--compact-2 {
|
||||||
|
--mar-pad-x: clamp(6px, 0.85vw, 10px);
|
||||||
|
--mar-pad-y: clamp(4px, 0.65vh, 8px);
|
||||||
|
--mar-gap: clamp(5px, 0.65vh, 8px);
|
||||||
|
--mar-kpi-h: clamp(52px, 6vh, 64px);
|
||||||
|
--mar-card-head-h: clamp(28px, 3.0vh, 34px);
|
||||||
|
--mar-card-body-pad: clamp(5px, 0.65vh, 8px);
|
||||||
|
--mar-frame-h: clamp(10px, 1.6vh, 16px);
|
||||||
|
--mar-frame-gap: clamp(3px, 0.45vh, 6px);
|
||||||
|
--mar-map-min: 0px;
|
||||||
|
}
|
||||||
|
|
||||||
/* 主内容区域 */
|
/* 主内容区域 */
|
||||||
.maritime-spin {
|
.maritime-spin {
|
||||||
height: 100%;
|
height: 100%;
|
||||||
|
min-height: 0;
|
||||||
|
display: block;
|
||||||
|
flex: 1;
|
||||||
|
width: 100%;
|
||||||
:global(.ant-spin-container) {
|
:global(.ant-spin-container) {
|
||||||
height: 100%;
|
height: 100%;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
min-height: 0;
|
||||||
|
width: 100%;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.maritime-content {
|
.maritime-content {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
padding: 16px 18px;
|
padding: var(--mar-pad-y) var(--mar-pad-x);
|
||||||
|
/* 参考智慧城市:底部装饰条保留但尽量少占内容区高度 */
|
||||||
|
padding-bottom: calc(var(--mar-pad-y) + var(--mar-frame-h));
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
position: relative;
|
position: relative;
|
||||||
z-index: 1;
|
z-index: 1;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
|
min-height: 0;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
width: 100%;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
|
||||||
|
.maritime-bottom-frame {
|
||||||
|
position: absolute;
|
||||||
|
left: clamp(12px, 1.6vw, 26px);
|
||||||
|
right: clamp(12px, 1.6vw, 26px);
|
||||||
|
bottom: clamp(6px, 0.8vh, 12px);
|
||||||
|
height: var(--mar-frame-h);
|
||||||
|
border-radius: 12px;
|
||||||
|
z-index: 2;
|
||||||
|
pointer-events: none;
|
||||||
|
background:
|
||||||
|
linear-gradient(
|
||||||
|
90deg,
|
||||||
|
rgba(0, 120, 180, 0.08),
|
||||||
|
rgba(0, 180, 230, 0.7) 34%,
|
||||||
|
rgba(0, 229, 160, 0.45) 50%,
|
||||||
|
rgba(0, 180, 230, 0.7) 66%,
|
||||||
|
rgba(0, 120, 180, 0.08)
|
||||||
|
) bottom/100% 2px no-repeat,
|
||||||
|
linear-gradient(90deg, rgba(0, 220, 255, 0.85), transparent 90px) bottom left/90px 2px no-repeat,
|
||||||
|
linear-gradient(270deg, rgba(0, 220, 255, 0.85), transparent 90px) bottom right/90px 2px no-repeat,
|
||||||
|
linear-gradient(180deg, rgba(0, 180, 230, 0.6), transparent 80%) bottom left/2px 100% no-repeat,
|
||||||
|
linear-gradient(180deg, rgba(0, 180, 230, 0.6), transparent 80%) bottom right/2px 100% no-repeat;
|
||||||
|
box-shadow: 0 -6px 18px rgba(0, 120, 180, 0.3);
|
||||||
|
|
||||||
|
&::before {
|
||||||
|
content: '';
|
||||||
|
position: absolute;
|
||||||
|
left: 50%;
|
||||||
|
bottom: 6px;
|
||||||
|
width: clamp(120px, 18vw, 220px);
|
||||||
|
height: 6px;
|
||||||
|
transform: translateX(-50%);
|
||||||
|
border-radius: 999px;
|
||||||
|
background: linear-gradient(90deg, transparent, rgba(0, 220, 255, 0.85), transparent);
|
||||||
|
box-shadow: 0 0 12px rgba(0, 180, 230, 0.4);
|
||||||
|
opacity: 0.85;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.maritime-grid {
|
.maritime-grid {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: 25% 50% 25%;
|
grid-template-columns: minmax(0, 1fr) minmax(0, 2fr) minmax(0, 1fr);
|
||||||
grid-template-rows: 100%;
|
grid-template-rows: minmax(0, 1fr);
|
||||||
gap: 14px;
|
gap: var(--mar-gap);
|
||||||
|
/* 只用 flex 约束高度,避免百分比高度在某些容器链路下变成不确定值 */
|
||||||
|
flex: 1;
|
||||||
|
width: 100%;
|
||||||
|
min-height: 0;
|
||||||
|
min-width: 0;
|
||||||
|
justify-items: stretch;
|
||||||
|
align-items: stretch;
|
||||||
|
}
|
||||||
|
|
||||||
|
.maritime-dashboard .grid-col {
|
||||||
|
display: grid;
|
||||||
|
gap: var(--mar-gap);
|
||||||
height: 100%;
|
height: 100%;
|
||||||
|
overflow: hidden;
|
||||||
|
min-height: 0;
|
||||||
|
min-width: 0;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.grid-col {
|
.maritime-dashboard .grid-col > * {
|
||||||
display: flex;
|
min-height: 0;
|
||||||
flex-direction: column;
|
max-height: 100%;
|
||||||
gap: 14px;
|
|
||||||
height: 100%;
|
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.maritime-dashboard .grid-col.left-col {
|
||||||
|
/* 4张卡片:上两张偏“静态概览”稍矮,告警为主要信息流更高,海况为补充更矮 */
|
||||||
|
grid-template-rows: minmax(0, 0.9fr) minmax(0, 0.85fr) minmax(0, 1.35fr) minmax(0, 0.55fr);
|
||||||
|
}
|
||||||
|
|
||||||
|
.maritime-dashboard .grid-col.right-col {
|
||||||
|
/* 4张卡片:概览较高,其余三张均衡 */
|
||||||
|
grid-template-rows: minmax(0, 1.15fr) minmax(0, 0.95fr) minmax(0, 1fr) minmax(0, 0.9fr);
|
||||||
|
}
|
||||||
|
|
||||||
|
.maritime-dashboard .grid-col.center-col {
|
||||||
|
/* 参考智慧城市:固定 KPI + 其余区域按比例分配,避免底部卡片被挤出屏幕 */
|
||||||
|
grid-template-rows: var(--mar-kpi-h) minmax(0, 1.35fr) minmax(0, 0.85fr);
|
||||||
|
}
|
||||||
|
|
||||||
/* 海事风格玻璃面板 */
|
/* 海事风格玻璃面板 */
|
||||||
.panel-card {
|
.panel-card {
|
||||||
background: transparent !important;
|
background: transparent !important;
|
||||||
@@ -180,22 +301,22 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
:global(.ant-card-head) {
|
:global(.ant-card-head) {
|
||||||
min-height: 42px;
|
min-height: var(--mar-card-head-h);
|
||||||
padding: 0 14px;
|
padding: 0 12px;
|
||||||
border-bottom: 1px solid rgba(0, 180, 230, 0.15);
|
border-bottom: 1px solid rgba(0, 180, 230, 0.15);
|
||||||
background: linear-gradient(90deg, rgba(0, 100, 150, 0.2), transparent);
|
background: linear-gradient(90deg, rgba(0, 100, 150, 0.2), transparent);
|
||||||
|
|
||||||
.ant-card-head-title {
|
.ant-card-head-title {
|
||||||
font-size: 15px;
|
font-size: 13px;
|
||||||
color: #e0f7ff;
|
color: #e0f7ff;
|
||||||
padding: 10px 0;
|
padding: 8px 0;
|
||||||
letter-spacing: 1px;
|
letter-spacing: 1px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
:global(.ant-card-body) {
|
:global(.ant-card-body) {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
padding: 12px;
|
padding: var(--mar-card-body-pad);
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
position: relative;
|
position: relative;
|
||||||
display: flex;
|
display: flex;
|
||||||
@@ -203,6 +324,49 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.panel-block {
|
||||||
|
height: 100%;
|
||||||
|
min-height: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.panel-split {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||||
|
gap: var(--mar-gap);
|
||||||
|
height: 100%;
|
||||||
|
min-height: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.panel-split--ratio {
|
||||||
|
grid-template-columns: minmax(0, 1.2fr) minmax(0, 0.8fr);
|
||||||
|
}
|
||||||
|
|
||||||
|
.panel-stack {
|
||||||
|
display: grid;
|
||||||
|
grid-template-rows: repeat(2, minmax(0, 1fr));
|
||||||
|
gap: var(--mar-gap);
|
||||||
|
height: 100%;
|
||||||
|
min-height: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.panel-stack--alert {
|
||||||
|
grid-template-rows: minmax(0, 1.3fr) minmax(0, 0.7fr);
|
||||||
|
}
|
||||||
|
|
||||||
|
.panel-section {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
min-height: 0;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.panel-subtitle {
|
||||||
|
font-size: 12px;
|
||||||
|
color: rgba(200, 230, 255, 0.7);
|
||||||
|
letter-spacing: 1px;
|
||||||
|
margin-bottom: 6px;
|
||||||
|
}
|
||||||
|
|
||||||
.chart-wrapper {
|
.chart-wrapper {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
@@ -222,8 +386,8 @@
|
|||||||
.kpi-row {
|
.kpi-row {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: repeat(4, 1fr);
|
grid-template-columns: repeat(4, 1fr);
|
||||||
gap: 12px;
|
gap: var(--mar-gap);
|
||||||
height: 85px;
|
height: var(--mar-kpi-h);
|
||||||
}
|
}
|
||||||
|
|
||||||
.kpi-card {
|
.kpi-card {
|
||||||
@@ -232,7 +396,7 @@
|
|||||||
border-radius: 8px;
|
border-radius: 8px;
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
padding: 0 16px;
|
padding: 0 12px;
|
||||||
position: relative;
|
position: relative;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
|
|
||||||
@@ -248,10 +412,10 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.kpi-icon {
|
.kpi-icon {
|
||||||
font-size: 26px;
|
font-size: 22px;
|
||||||
margin-right: 14px;
|
margin-right: 10px;
|
||||||
width: 46px;
|
width: 40px;
|
||||||
height: 46px;
|
height: 40px;
|
||||||
border-radius: 50%;
|
border-radius: 50%;
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
@@ -267,7 +431,7 @@
|
|||||||
.kpi-info {
|
.kpi-info {
|
||||||
.label { font-size: 12px; color: rgba(200, 230, 255, 0.7); }
|
.label { font-size: 12px; color: rgba(200, 230, 255, 0.7); }
|
||||||
.value {
|
.value {
|
||||||
font-size: 26px;
|
font-size: 22px;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
color: #fff;
|
color: #fff;
|
||||||
font-family: 'Segoe UI', sans-serif;
|
font-family: 'Segoe UI', sans-serif;
|
||||||
@@ -281,6 +445,8 @@
|
|||||||
/* 中央海图监控区域 */
|
/* 中央海图监控区域 */
|
||||||
.map-portal-wrapper {
|
.map-portal-wrapper {
|
||||||
flex: 2;
|
flex: 2;
|
||||||
|
min-height: var(--mar-map-min);
|
||||||
|
height: 100%;
|
||||||
position: relative;
|
position: relative;
|
||||||
background: linear-gradient(180deg, rgba(0, 40, 80, 0.5) 0%, rgba(0, 60, 100, 0.3) 100%);
|
background: linear-gradient(180deg, rgba(0, 40, 80, 0.5) 0%, rgba(0, 60, 100, 0.3) 100%);
|
||||||
border: 1px solid rgba(0, 180, 230, 0.35);
|
border: 1px solid rgba(0, 180, 230, 0.35);
|
||||||
@@ -353,8 +519,8 @@
|
|||||||
|
|
||||||
.portal-center {
|
.portal-center {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
width: 320px;
|
width: clamp(240px, 16vw, 300px);
|
||||||
height: 320px;
|
height: clamp(240px, 16vw, 300px);
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
@@ -385,16 +551,16 @@
|
|||||||
|
|
||||||
.portal-title {
|
.portal-title {
|
||||||
color: #e0f7ff;
|
color: #e0f7ff;
|
||||||
margin-bottom: 20px;
|
margin-bottom: 14px;
|
||||||
font-size: 20px;
|
font-size: 18px;
|
||||||
letter-spacing: 3px;
|
letter-spacing: 3px;
|
||||||
text-shadow: 0 0 15px rgba(0, 200, 255, 0.5);
|
text-shadow: 0 0 15px rgba(0, 200, 255, 0.5);
|
||||||
}
|
}
|
||||||
|
|
||||||
.portal-btn {
|
.portal-btn {
|
||||||
height: 46px;
|
height: 42px;
|
||||||
padding: 0 36px;
|
padding: 0 30px;
|
||||||
font-size: 15px;
|
font-size: 14px;
|
||||||
background: linear-gradient(135deg, #0096c7 0%, #0077b6 100%);
|
background: linear-gradient(135deg, #0096c7 0%, #0077b6 100%);
|
||||||
border: none;
|
border: none;
|
||||||
box-shadow: 0 4px 20px rgba(0, 150, 200, 0.4);
|
box-shadow: 0 4px 20px rgba(0, 150, 200, 0.4);
|
||||||
@@ -412,6 +578,8 @@
|
|||||||
|
|
||||||
/* 告警列表 - 海事风格 */
|
/* 告警列表 - 海事风格 */
|
||||||
.alert-list-container {
|
.alert-list-container {
|
||||||
|
flex: 1;
|
||||||
|
min-height: 0;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
|
|
||||||
@@ -487,11 +655,31 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.task-success {
|
||||||
|
margin-top: 16px;
|
||||||
|
text-align: center;
|
||||||
|
|
||||||
|
.rate {
|
||||||
|
font-size: 32px;
|
||||||
|
font-weight: bold;
|
||||||
|
color: #00e5a0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.label {
|
||||||
|
font-size: 14px;
|
||||||
|
color: #e0f7ff;
|
||||||
|
margin-top: 4px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* 气象信息面板 */
|
/* 气象信息面板 */
|
||||||
.weather-panel {
|
.weather-panel {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
gap: 12px;
|
gap: 12px;
|
||||||
|
flex: 1;
|
||||||
|
min-height: 0;
|
||||||
|
align-content: flex-start;
|
||||||
|
|
||||||
.weather-item {
|
.weather-item {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
@@ -524,6 +712,13 @@
|
|||||||
|
|
||||||
/* 港口状态 */
|
/* 港口状态 */
|
||||||
.port-status-list {
|
.port-status-list {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 8px;
|
||||||
|
flex: 1;
|
||||||
|
min-height: 0;
|
||||||
|
overflow-y: auto;
|
||||||
|
|
||||||
.port-item {
|
.port-item {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
@@ -531,7 +726,7 @@
|
|||||||
padding: 10px 12px;
|
padding: 10px 12px;
|
||||||
background: rgba(0, 80, 120, 0.25);
|
background: rgba(0, 80, 120, 0.25);
|
||||||
border-radius: 6px;
|
border-radius: 6px;
|
||||||
margin-bottom: 8px;
|
margin-bottom: 0;
|
||||||
border-left: 3px solid #00b4d8;
|
border-left: 3px solid #00b4d8;
|
||||||
|
|
||||||
.port-name {
|
.port-name {
|
||||||
@@ -635,9 +830,19 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* 响应式布局 */
|
/* 响应式布局 */
|
||||||
@media (max-width: 1400px) {
|
@media (max-width: 1680px) {
|
||||||
.maritime-grid {
|
.maritime-grid {
|
||||||
grid-template-columns: 28% 44% 28%;
|
grid-template-columns: minmax(0, 1.1fr) minmax(0, 1.8fr) minmax(0, 1.1fr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@media (max-width: 1440px) {
|
||||||
|
.maritime-grid {
|
||||||
|
grid-template-columns: minmax(0, 1.2fr) minmax(0, 1.6fr) minmax(0, 1.2fr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -657,7 +862,10 @@
|
|||||||
grid-template-rows: auto;
|
grid-template-rows: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
.grid-col {
|
.maritime-dashboard .grid-col {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: var(--mar-gap);
|
||||||
height: auto;
|
height: auto;
|
||||||
min-height: 400px;
|
min-height: 400px;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,34 +1,22 @@
|
|||||||
import React, { useState, useEffect, useCallback, useMemo } from 'react';
|
import React, { useState, useEffect, useCallback, useMemo } from 'react';
|
||||||
import { Card, Button, List, Tag, Spin, message, DatePicker, Segmented, Space } from 'antd';
|
import { Spin, message } from 'antd';
|
||||||
import {
|
|
||||||
WarningOutlined,
|
|
||||||
RocketOutlined,
|
|
||||||
CompassOutlined,
|
|
||||||
PieChartOutlined,
|
|
||||||
EnvironmentOutlined,
|
|
||||||
} from '@ant-design/icons';
|
|
||||||
import { Line, Pie, Column, Area, Rose } from '@ant-design/plots';
|
|
||||||
import { history } from 'umi';
|
|
||||||
import dayjs from 'dayjs';
|
import dayjs from 'dayjs';
|
||||||
|
import type { AlertItem, DeviceStats, TaskStats, TrendItem } from '@/services/dashboard';
|
||||||
|
import { getDeviceStats, getTaskStats, getTrendData } from '@/services/dashboard';
|
||||||
import {
|
import {
|
||||||
getDeviceStats,
|
MaritimeKpiStrip,
|
||||||
getTaskStats,
|
DeviceTypeCard,
|
||||||
getTrendData,
|
PortStatusCard,
|
||||||
getMockAlerts,
|
MaritimeAlertCard,
|
||||||
DeviceStats,
|
WeatherCard,
|
||||||
TaskStats,
|
SeaAreaPortal,
|
||||||
TrendItem,
|
AnnualTrendChart,
|
||||||
AlertItem,
|
TaskTypeChart,
|
||||||
} from '@/services/dashboard';
|
TaskOverviewCard,
|
||||||
|
MaritimeInsightCard,
|
||||||
|
} from './components';
|
||||||
import './index.less';
|
import './index.less';
|
||||||
|
|
||||||
// 无人船图标组件
|
|
||||||
const USVIcon = () => (
|
|
||||||
<svg viewBox="0 0 24 24" width="1em" height="1em" fill="currentColor">
|
|
||||||
<path d="M20 21c-1.39 0-2.78-.47-4-1.32-2.44 1.71-5.56 1.71-8 0C6.78 20.53 5.39 21 4 21H2v2h2c1.38 0 2.74-.35 4-.99 2.52 1.29 5.48 1.29 8 0 1.26.64 2.63.99 4 .99h2v-2h-2zM3.95 19H4c1.6 0 3.02-.88 4-2 .98 1.12 2.4 2 4 2s3.02-.88 4-2c.98 1.12 2.4 2 4 2h.05l1.89-6.68c.08-.26.06-.54-.06-.78s-.34-.42-.6-.5L20 10.62V6c0-1.1-.9-2-2-2h-3V1H9v3H6c-1.1 0-2 .9-2 2v4.62l-1.29.42c-.26.08-.48.26-.6.5s-.15.52-.06.78L3.95 19zM6 6h12v3.97L12 8 6 9.97V6z"/>
|
|
||||||
</svg>
|
|
||||||
);
|
|
||||||
|
|
||||||
const MaritimeDashboard: React.FC = () => {
|
const MaritimeDashboard: React.FC = () => {
|
||||||
const [loading, setLoading] = useState(true);
|
const [loading, setLoading] = useState(true);
|
||||||
const [deviceStats, setDeviceStats] = useState<DeviceStats | null>(null);
|
const [deviceStats, setDeviceStats] = useState<DeviceStats | null>(null);
|
||||||
@@ -43,6 +31,18 @@ const MaritimeDashboard: React.FC = () => {
|
|||||||
const [tenantId, setTenantId] = useState<string | undefined>();
|
const [tenantId, setTenantId] = useState<string | undefined>();
|
||||||
const [includeChildren, setIncludeChildren] = useState<boolean>(true);
|
const [includeChildren, setIncludeChildren] = useState<boolean>(true);
|
||||||
|
|
||||||
|
// 海事专用告警数据
|
||||||
|
const getMaritimeAlerts = useCallback((): AlertItem[] => {
|
||||||
|
return [
|
||||||
|
{ id: '1', type: 'device_fault', level: 'critical', deviceName: '巡检船-01', message: '检测到船只超速航行,航速28节', timestamp: new Date(Date.now() - 120000).toISOString() },
|
||||||
|
{ id: '2', type: 'device_offline', level: 'error', deviceName: '巡检船-03', message: '设备信号丢失超过10分钟', timestamp: new Date(Date.now() - 300000).toISOString() },
|
||||||
|
{ id: '3', type: 'task_failed', level: 'warning', taskName: '巡检任务#1024', message: '发现违规锚泊船只1艘', timestamp: new Date(Date.now() - 600000).toISOString() },
|
||||||
|
{ id: '4', type: 'low_battery', level: 'warning', deviceName: '巡检船-02', message: '电池电量低于20%', timestamp: new Date(Date.now() - 900000).toISOString() },
|
||||||
|
{ id: '5', type: 'task_failed', level: 'warning', taskName: '巡检任务#1023', message: '巡检完成,未发现违规', timestamp: new Date(Date.now() - 1200000).toISOString() },
|
||||||
|
];
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
// 初始化模拟数据
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
// 模拟年度数据
|
// 模拟年度数据
|
||||||
const mockAnnual: any[] = [];
|
const mockAnnual: any[] = [];
|
||||||
@@ -78,6 +78,7 @@ const MaritimeDashboard: React.FC = () => {
|
|||||||
]);
|
]);
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
// 监听租户变化
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const handler = (e: any) => {
|
const handler = (e: any) => {
|
||||||
const nextTenantId = e?.detail?.tenantId as string | undefined;
|
const nextTenantId = e?.detail?.tenantId as string | undefined;
|
||||||
@@ -89,6 +90,7 @@ const MaritimeDashboard: React.FC = () => {
|
|||||||
return () => window.removeEventListener('tenant-change', handler as any);
|
return () => window.removeEventListener('tenant-change', handler as any);
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
// 获取数据
|
||||||
const fetchData = useCallback(async () => {
|
const fetchData = useCallback(async () => {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
try {
|
try {
|
||||||
@@ -110,7 +112,6 @@ const MaritimeDashboard: React.FC = () => {
|
|||||||
setDeviceStats(deviceRes);
|
setDeviceStats(deviceRes);
|
||||||
setTaskStats(taskRes);
|
setTaskStats(taskRes);
|
||||||
setTaskTrend(trendRes.taskTrend);
|
setTaskTrend(trendRes.taskTrend);
|
||||||
// 模拟海事告警数据
|
|
||||||
setAlerts(getMaritimeAlerts());
|
setAlerts(getMaritimeAlerts());
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('获取数据失败:', error);
|
console.error('获取数据失败:', error);
|
||||||
@@ -118,418 +119,141 @@ const MaritimeDashboard: React.FC = () => {
|
|||||||
} finally {
|
} finally {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
}
|
}
|
||||||
}, [includeChildren, taskStatDate, taskStatType, tenantId]);
|
}, [getMaritimeAlerts, includeChildren, taskStatDate, taskStatType, tenantId]);
|
||||||
|
|
||||||
// 海事专用告警数据
|
|
||||||
const getMaritimeAlerts = (): AlertItem[] => {
|
|
||||||
return [
|
|
||||||
{ id: '1', type: 'device_fault', level: 'critical', deviceName: '巡检船-01', message: '检测到船只超速航行,航速28节', timestamp: new Date(Date.now() - 120000).toISOString() },
|
|
||||||
{ id: '2', type: 'device_offline', level: 'error', deviceName: '巡检船-03', message: '设备信号丢失超过10分钟', timestamp: new Date(Date.now() - 300000).toISOString() },
|
|
||||||
{ id: '3', type: 'task_failed', level: 'warning', taskName: '巡检任务#1024', message: '发现违规锚泊船只1艘', timestamp: new Date(Date.now() - 600000).toISOString() },
|
|
||||||
{ id: '4', type: 'low_battery', level: 'warning', deviceName: '巡检船-02', message: '电池电量低于20%', timestamp: new Date(Date.now() - 900000).toISOString() },
|
|
||||||
{ id: '5', type: 'task_failed', level: 'warning', taskName: '巡检任务#1023', message: '巡检完成,未发现违规', timestamp: new Date(Date.now() - 1200000).toISOString() },
|
|
||||||
];
|
|
||||||
};
|
|
||||||
|
|
||||||
|
// 初始化和定时刷新数据
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!tenantId) return;
|
|
||||||
fetchData();
|
fetchData();
|
||||||
}, [fetchData]);
|
|
||||||
|
|
||||||
// 定时刷新
|
|
||||||
useEffect(() => {
|
|
||||||
const dataTimer = setInterval(fetchData, 30000);
|
const dataTimer = setInterval(fetchData, 30000);
|
||||||
return () => {
|
return () => {
|
||||||
clearInterval(dataTimer);
|
clearInterval(dataTimer);
|
||||||
};
|
};
|
||||||
}, [fetchData]);
|
}, [fetchData]);
|
||||||
|
|
||||||
const goTo3D = () => {
|
|
||||||
// 传递来源页面,以便从map3d返回时能回到正确的大屏
|
|
||||||
history.push('/map3d?from=maritime');
|
|
||||||
};
|
|
||||||
|
|
||||||
// --- 图表配置 ---
|
|
||||||
|
|
||||||
const taskTrendSeriesData = useMemo(() => {
|
|
||||||
return taskTrend.flatMap((t) => [
|
|
||||||
{ date: t.date, type: '下发', value: t.created || 0 },
|
|
||||||
{ date: t.date, type: '完成', value: t.completed || 0 },
|
|
||||||
{ date: t.date, type: '失败', value: t.failed || 0 },
|
|
||||||
]);
|
|
||||||
}, [taskTrend]);
|
|
||||||
|
|
||||||
// 近7日任务完成数趋势数据
|
|
||||||
const taskCompleteTrendData = useMemo(() => {
|
|
||||||
return taskTrend.map((t) => ({
|
|
||||||
date: t.date,
|
|
||||||
value: t.completed || 0,
|
|
||||||
}));
|
|
||||||
}, [taskTrend]);
|
|
||||||
|
|
||||||
const taskTrendConfig: any = {
|
|
||||||
data: taskTrendSeriesData,
|
|
||||||
xField: 'date',
|
|
||||||
yField: 'value',
|
|
||||||
seriesField: 'type',
|
|
||||||
smooth: true,
|
|
||||||
color: ['#00b4d8', '#00e5a0', '#ff9f43'],
|
|
||||||
areaStyle: {
|
|
||||||
fill: 'l(270) 0:#ffffff 0.5:#7ec2f3 1:#0077b6',
|
|
||||||
fillOpacity: 0.1,
|
|
||||||
},
|
|
||||||
xAxis: { label: { style: { fill: 'rgba(200,230,255,0.65)' } }, grid: null },
|
|
||||||
yAxis: { label: { style: { fill: 'rgba(200,230,255,0.65)' } }, grid: { line: { style: { stroke: 'rgba(0,150,200,0.1)' } } } },
|
|
||||||
tooltip: { showMarkers: true },
|
|
||||||
height: 180,
|
|
||||||
};
|
|
||||||
|
|
||||||
// 设备类型分布 - 模拟数据
|
|
||||||
const usvTypeData: { name: string; count: number }[] = useMemo(() => {
|
|
||||||
return (deviceStats?.byType || [
|
|
||||||
{ name: '巡检型', count: 12 },
|
|
||||||
{ name: '监测型', count: 8 },
|
|
||||||
{ name: '救援型', count: 5 },
|
|
||||||
{ name: '测量型', count: 3 },
|
|
||||||
]).map(item => ({ name: item.name, count: item.count }));
|
|
||||||
}, [deviceStats]);
|
|
||||||
|
|
||||||
const pieConfig: any = {
|
|
||||||
data: usvTypeData,
|
|
||||||
angleField: 'count',
|
|
||||||
colorField: 'name',
|
|
||||||
radius: 0.7,
|
|
||||||
innerRadius: 0.5,
|
|
||||||
color: ['#00b4d8', '#0096c7', '#00e5a0', '#48cae4'],
|
|
||||||
label: {
|
|
||||||
text: (datum: any) => {
|
|
||||||
const name = datum?.name || '';
|
|
||||||
const count = datum?.count ?? 0;
|
|
||||||
const data = usvTypeData as { name: string; count: number }[];
|
|
||||||
const total = data.reduce((sum, d) => sum + (d.count || 0), 0);
|
|
||||||
const percent = total > 0 ? ((count / total) * 100).toFixed(1) : 0;
|
|
||||||
return `${name} ${percent}%`;
|
|
||||||
},
|
|
||||||
style: { fill: 'rgba(200,230,255,0.65)' },
|
|
||||||
},
|
|
||||||
legend: { position: 'bottom', itemValue: { style: { fill: 'rgba(200,230,255,0.65)' } }, itemName: { style: { fill: 'rgba(200,230,255,0.65)' } } },
|
|
||||||
height: 200,
|
|
||||||
};
|
|
||||||
|
|
||||||
const columnConfig: any = {
|
|
||||||
data: taskTypeData,
|
|
||||||
xField: 'type',
|
|
||||||
yField: 'value',
|
|
||||||
seriesField: 'type',
|
|
||||||
color: ({ type }: any) => {
|
|
||||||
if (type === '航线巡检') return '#00b4d8';
|
|
||||||
if (type === '定点监测') return '#00e5a0';
|
|
||||||
return '#ff9f43';
|
|
||||||
},
|
|
||||||
label: {
|
|
||||||
text: (datum: any) => datum?.value?.toString() || '0',
|
|
||||||
style: { fill: '#fff' },
|
|
||||||
},
|
|
||||||
xAxis: { label: { style: { fill: 'rgba(200,230,255,0.65)' } } },
|
|
||||||
yAxis: { label: { style: { fill: 'rgba(200,230,255,0.65)' } }, grid: { line: { style: { stroke: 'rgba(0,150,200,0.1)' } } } },
|
|
||||||
legend: false,
|
|
||||||
height: 180,
|
|
||||||
};
|
|
||||||
|
|
||||||
const taskCompleteTrendConfig: any = {
|
|
||||||
data: taskCompleteTrendData,
|
|
||||||
xField: 'date',
|
|
||||||
yField: 'value',
|
|
||||||
smooth: true,
|
|
||||||
color: '#00e5a0',
|
|
||||||
areaStyle: { fillOpacity: 0.2 },
|
|
||||||
xAxis: { label: { style: { fill: 'rgba(200,230,255,0.65)' } }, grid: null },
|
|
||||||
yAxis: {
|
|
||||||
label: { style: { fill: 'rgba(200,230,255,0.65)' } },
|
|
||||||
grid: { line: { style: { stroke: 'rgba(0,150,200,0.08)' } } },
|
|
||||||
},
|
|
||||||
tooltip: { showMarkers: true },
|
|
||||||
height: 160,
|
|
||||||
};
|
|
||||||
|
|
||||||
const areaConfig: any = {
|
|
||||||
data: annualData,
|
|
||||||
xField: 'month',
|
|
||||||
yField: 'value',
|
|
||||||
seriesField: 'type',
|
|
||||||
color: ['#00b4d8', '#00e5a0'],
|
|
||||||
areaStyle: { fillOpacity: 0.25 },
|
|
||||||
xAxis: { label: { style: { fill: 'rgba(200,230,255,0.65)' } } },
|
|
||||||
yAxis: { label: { style: { fill: 'rgba(200,230,255,0.65)' } }, grid: { line: { style: { stroke: 'rgba(0,150,200,0.1)' } } } },
|
|
||||||
legend: { position: 'top-right', itemName: { style: { fill: 'rgba(200,230,255,0.8)' } } },
|
|
||||||
smooth: true,
|
|
||||||
height: 220,
|
|
||||||
};
|
|
||||||
|
|
||||||
const roseConfig: any = {
|
|
||||||
data: violationAnalysisData,
|
|
||||||
xField: 'type',
|
|
||||||
yField: 'value',
|
|
||||||
seriesField: 'type',
|
|
||||||
radius: 0.9,
|
|
||||||
color: ['#ff6b6b', '#ffa502', '#ff9f43', '#00b4d8', '#48cae4', '#90e0ef'],
|
|
||||||
label: {
|
|
||||||
text: (datum: any) => datum?.type || '',
|
|
||||||
style: { fill: '#fff', fontSize: 10 },
|
|
||||||
},
|
|
||||||
legend: { position: 'bottom', itemName: { style: { fill: 'rgba(200,230,255,0.65)' } } },
|
|
||||||
height: 200,
|
|
||||||
};
|
|
||||||
|
|
||||||
const taskStatusPieConfig: any = {
|
|
||||||
data: [
|
|
||||||
{ name: '待执行', value: taskStats?.pending || 0 },
|
|
||||||
{ name: '执行中', value: taskStats?.running || 0 },
|
|
||||||
{ name: '已完成', value: taskStats?.completed || 0 },
|
|
||||||
{ name: '已失败', value: taskStats?.failed || 0 },
|
|
||||||
],
|
|
||||||
angleField: 'value',
|
|
||||||
colorField: 'name',
|
|
||||||
radius: 0.85,
|
|
||||||
innerRadius: 0.55,
|
|
||||||
color: ['#ffa502', '#00b4d8', '#00e5a0', '#ff6b6b'],
|
|
||||||
label: {
|
|
||||||
text: (datum: any) => {
|
|
||||||
const name = datum?.name || '';
|
|
||||||
const value = datum?.value ?? 0;
|
|
||||||
const total = (taskStats?.pending || 0) + (taskStats?.running || 0) + (taskStats?.completed || 0) + (taskStats?.failed || 0);
|
|
||||||
const percent = total > 0 ? ((value / total) * 100).toFixed(1) : 0;
|
|
||||||
return `${name} ${percent}%`;
|
|
||||||
},
|
|
||||||
style: { fill: 'rgba(200,230,255,0.65)' },
|
|
||||||
},
|
|
||||||
legend: { position: 'bottom', itemValue: { style: { fill: 'rgba(200,230,255,0.65)' } }, itemName: { style: { fill: 'rgba(200,230,255,0.65)' } } },
|
|
||||||
height: 190,
|
|
||||||
};
|
|
||||||
|
|
||||||
const getAlertColor = (level: string) => {
|
|
||||||
switch (level) {
|
|
||||||
case 'critical': return '#ff4757';
|
|
||||||
case 'error': return '#ff9f43';
|
|
||||||
case 'warning': return '#feca57';
|
|
||||||
default: return '#54a0ff';
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const taskPeriodText = useMemo(() => {
|
|
||||||
if (taskStatType === 'day') return '当日';
|
|
||||||
if (taskStatType === 'month') return '当月';
|
|
||||||
return '当年';
|
|
||||||
}, [taskStatType]);
|
|
||||||
|
|
||||||
const taskNewLabel = useMemo(() => {
|
const taskNewLabel = useMemo(() => {
|
||||||
if (taskStatType === 'day') return '当日任务';
|
if (taskStatType === 'day') return '当日任务';
|
||||||
if (taskStatType === 'month') return '当月任务';
|
if (taskStatType === 'month') return '当月任务';
|
||||||
return '当年任务';
|
return '当年任务';
|
||||||
}, [taskStatType]);
|
}, [taskStatType]);
|
||||||
|
|
||||||
const datePickerFormat = useMemo(() => {
|
// 使用 CSS Grid 强制分配高度(类似智慧城市首页)
|
||||||
if (taskStatType === 'day') return 'YYYY-MM-DD';
|
const gap = 12;
|
||||||
if (taskStatType === 'month') return 'YYYY-MM';
|
|
||||||
return 'YYYY';
|
|
||||||
}, [taskStatType]);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="maritime-dashboard">
|
<div style={{
|
||||||
|
width: '100%',
|
||||||
|
height: '100%',
|
||||||
|
background: 'var(--bg-primary)',
|
||||||
|
overflow: 'hidden',
|
||||||
|
padding: 12,
|
||||||
|
boxSizing: 'border-box',
|
||||||
|
}}>
|
||||||
|
{/* 保留海事背景装饰 */}
|
||||||
<div className="wave-bg-animation"></div>
|
<div className="wave-bg-animation"></div>
|
||||||
<div className="wave-layer"></div>
|
<div className="wave-layer"></div>
|
||||||
<div className="wave-layer-2"></div>
|
<div className="wave-layer-2"></div>
|
||||||
<div className="wave-layer-3"></div>
|
<div className="wave-layer-3"></div>
|
||||||
|
<div className="maritime-bottom-frame" aria-hidden="true" />
|
||||||
|
|
||||||
<Spin spinning={loading} wrapperClassName="maritime-spin">
|
<Spin spinning={loading} wrapperClassName="maritime-spin">
|
||||||
<div className="maritime-content">
|
<div style={{
|
||||||
<div className="maritime-grid">
|
display: 'grid',
|
||||||
|
gridTemplateColumns: '25% 50% 25%',
|
||||||
{/* 左侧栏:设备态势 */}
|
gap: gap,
|
||||||
<div className="grid-col left-col">
|
height: 'calc(100vh - 80px - 24px)',
|
||||||
<Card title="设备类型分布" className="panel-card ocean-glass" size="small">
|
width: '100%',
|
||||||
<div className="chart-wrapper">
|
}}>
|
||||||
<Pie {...pieConfig} />
|
{/* 左侧栏 - CSS Grid 四个卡片分配,设备类型分布给更多空间 */}
|
||||||
|
<div style={{
|
||||||
|
display: 'grid',
|
||||||
|
gridTemplateRows: '1.2fr 1fr 1.1fr 0.7fr',
|
||||||
|
gap: gap,
|
||||||
|
height: '100%',
|
||||||
|
minHeight: 0,
|
||||||
|
overflow: 'hidden',
|
||||||
|
}}>
|
||||||
|
<div style={{ minHeight: 0, maxHeight: '100%', overflow: 'hidden' }}>
|
||||||
|
<DeviceTypeCard deviceStats={deviceStats} />
|
||||||
</div>
|
</div>
|
||||||
</Card>
|
<div style={{ minHeight: 0, maxHeight: '100%', overflow: 'hidden' }}>
|
||||||
|
<PortStatusCard
|
||||||
<Card title="任务类型统计" className="panel-card ocean-glass" size="small">
|
deviceStats={deviceStats}
|
||||||
<div className="chart-wrapper">
|
taskStats={taskStats}
|
||||||
<Column {...columnConfig} />
|
alerts={alerts}
|
||||||
</div>
|
|
||||||
</Card>
|
|
||||||
|
|
||||||
<Card title="近7日任务完成趋势" className="panel-card ocean-glass" size="small">
|
|
||||||
<div className="chart-wrapper">
|
|
||||||
<Area {...taskCompleteTrendConfig} />
|
|
||||||
</div>
|
|
||||||
</Card>
|
|
||||||
|
|
||||||
<Card
|
|
||||||
title={<span><WarningOutlined className="icon-warning" /> 实时告警</span>}
|
|
||||||
className="panel-card ocean-glass flex-grow"
|
|
||||||
size="small"
|
|
||||||
extra={<Tag color="#ff9f43">LIVE</Tag>}
|
|
||||||
>
|
|
||||||
<div className="alert-list-container">
|
|
||||||
<List
|
|
||||||
dataSource={alerts}
|
|
||||||
split={false}
|
|
||||||
renderItem={(item) => (
|
|
||||||
<List.Item className="alert-item">
|
|
||||||
<div className="alert-row">
|
|
||||||
<div className="alert-badge">
|
|
||||||
<Tag color={getAlertColor(item.level)}>{item.level.toUpperCase().slice(0, 1)}</Tag>
|
|
||||||
</div>
|
|
||||||
<div className="alert-content">
|
|
||||||
<div className="alert-head">
|
|
||||||
<span className="alert-name">{item.deviceName || item.taskName}</span>
|
|
||||||
<span className="alert-time">{dayjs(item.timestamp).format('HH:mm')}</span>
|
|
||||||
</div>
|
|
||||||
<div className="alert-msg">{item.message}</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</List.Item>
|
|
||||||
)}
|
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</Card>
|
<div style={{ minHeight: 0, maxHeight: '100%', overflow: 'hidden' }}>
|
||||||
</div>
|
<MaritimeAlertCard alerts={alerts} />
|
||||||
|
|
||||||
{/* 中间栏:核心监控 */}
|
|
||||||
<div className="grid-col center-col">
|
|
||||||
{/* 顶部KPI */}
|
|
||||||
<div className="kpi-row">
|
|
||||||
<div className="kpi-card">
|
|
||||||
<div className="kpi-icon ship"><USVIcon /></div>
|
|
||||||
<div className="kpi-info">
|
|
||||||
<div className="label">设备总数</div>
|
|
||||||
<div className="value">{deviceStats?.total || 0}</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div className="kpi-card">
|
|
||||||
<div className="kpi-icon anchor"><EnvironmentOutlined /></div>
|
|
||||||
<div className="kpi-info">
|
|
||||||
<div className="label">海域总数</div>
|
|
||||||
<div className="value">{deviceStats?.tourismCount || 0}</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div className="kpi-card">
|
|
||||||
<div className="kpi-icon alert"><RocketOutlined /></div>
|
|
||||||
<div className="kpi-info">
|
|
||||||
<div className="label">{taskNewLabel}</div>
|
|
||||||
<div className="value">{taskStats?.todayNew || 0}</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div className="kpi-card">
|
|
||||||
<div className="kpi-icon route"><PieChartOutlined /></div>
|
|
||||||
<div className="kpi-info">
|
|
||||||
<div className="label">执行成功率</div>
|
|
||||||
<div className="value">{taskStats?.successRate || 0}<small>%</small></div>
|
|
||||||
</div>
|
</div>
|
||||||
|
<div style={{ minHeight: 0, maxHeight: '100%', overflow: 'hidden' }}>
|
||||||
|
<WeatherCard />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* 海域监控入口 */}
|
{/* 中间栏 - KPI固定70px + 海域门户 + 年度趋势和任务类型左右并排 */}
|
||||||
<div className="map-portal-wrapper">
|
<div style={{
|
||||||
<div className="nautical-grid"></div>
|
display: 'grid',
|
||||||
<div className="compass-sweep"></div>
|
gridTemplateRows: '70px 1fr 1fr',
|
||||||
<div className="map-content">
|
gap: gap,
|
||||||
<div className="portal-center">
|
height: '100%',
|
||||||
<CompassOutlined style={{ fontSize: 52, color: '#00b4d8', marginBottom: 16 }} />
|
minHeight: 0,
|
||||||
<h2 className="portal-title">海域智慧巡检监控中心</h2>
|
overflow: 'hidden',
|
||||||
<Button type="primary" shape="round" size="large" onClick={goTo3D} className="portal-btn">
|
}}>
|
||||||
进入海域监控视图
|
<div style={{ minHeight: 0, maxHeight: '100%', overflow: 'hidden' }}>
|
||||||
</Button>
|
<MaritimeKpiStrip
|
||||||
</div>
|
deviceTotal={deviceStats?.total || 0}
|
||||||
</div>
|
seaAreaCount={deviceStats?.tourismCount || 0}
|
||||||
</div>
|
todayNew={taskStats?.todayNew || 0}
|
||||||
|
successRate={taskStats?.successRate || 0}
|
||||||
{/* 年度巡检任务趋势 */}
|
taskNewLabel={taskNewLabel}
|
||||||
<Card title="年度巡检任务趋势分析" className="panel-card ocean-glass fill-bottom" size="small">
|
|
||||||
<div className="chart-wrapper">
|
|
||||||
<Area {...areaConfig} />
|
|
||||||
</div>
|
|
||||||
</Card>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* 右侧栏:任务与运维 */}
|
|
||||||
<div className="grid-col right-col">
|
|
||||||
<Card
|
|
||||||
title={`${taskPeriodText}巡检任务`}
|
|
||||||
className="panel-card ocean-glass"
|
|
||||||
size="small"
|
|
||||||
extra={
|
|
||||||
<Space size={8} className="task-filter">
|
|
||||||
<Segmented
|
|
||||||
size="small"
|
|
||||||
options={[
|
|
||||||
{ label: '日', value: 'day' },
|
|
||||||
{ label: '月', value: 'month' },
|
|
||||||
{ label: '年', value: 'year' },
|
|
||||||
]}
|
|
||||||
value={taskStatType}
|
|
||||||
onChange={(v) => setTaskStatType(v as any)}
|
|
||||||
/>
|
/>
|
||||||
<DatePicker
|
</div>
|
||||||
size="small"
|
<div style={{ minHeight: 0, maxHeight: '100%', overflow: 'hidden' }}>
|
||||||
value={taskStatDate}
|
<SeaAreaPortal />
|
||||||
onChange={(v) => v && setTaskStatDate(v)}
|
</div>
|
||||||
picker={taskStatType === 'day' ? 'date' : taskStatType}
|
{/* 年度趋势和任务类型左右并排 */}
|
||||||
allowClear={false}
|
<div style={{
|
||||||
format={datePickerFormat}
|
display: 'grid',
|
||||||
disabledDate={(d) => !!d && d.isAfter(dayjs(), 'day')}
|
gridTemplateColumns: '1fr 1fr',
|
||||||
|
gap: gap,
|
||||||
|
minHeight: 0,
|
||||||
|
maxHeight: '100%',
|
||||||
|
overflow: 'hidden',
|
||||||
|
}}>
|
||||||
|
<div style={{ minHeight: 0, maxHeight: '100%', overflow: 'hidden' }}>
|
||||||
|
<AnnualTrendChart annualData={annualData} />
|
||||||
|
</div>
|
||||||
|
<div style={{ minHeight: 0, maxHeight: '100%', overflow: 'hidden' }}>
|
||||||
|
<TaskTypeChart taskTypeData={taskTypeData} />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* 右侧栏 - CSS Grid 各50% */}
|
||||||
|
<div style={{
|
||||||
|
display: 'grid',
|
||||||
|
gridTemplateRows: '1fr 1fr',
|
||||||
|
gap: gap,
|
||||||
|
height: '100%',
|
||||||
|
minHeight: 0,
|
||||||
|
overflow: 'hidden',
|
||||||
|
}}>
|
||||||
|
<div style={{ minHeight: 0, maxHeight: '100%', overflow: 'hidden' }}>
|
||||||
|
<TaskOverviewCard
|
||||||
|
taskStats={taskStats}
|
||||||
|
taskStatType={taskStatType}
|
||||||
|
taskStatDate={taskStatDate}
|
||||||
|
onStatTypeChange={setTaskStatType}
|
||||||
|
onDateChange={setTaskStatDate}
|
||||||
/>
|
/>
|
||||||
</Space>
|
|
||||||
}
|
|
||||||
>
|
|
||||||
<div className="ship-status-grid">
|
|
||||||
<div className="ship-stat-box">
|
|
||||||
<div className="val sailing">{taskStats?.pending || 0}</div>
|
|
||||||
<div className="lbl">待执行</div>
|
|
||||||
</div>
|
</div>
|
||||||
<div className="ship-stat-box">
|
<div style={{ minHeight: 0, maxHeight: '100%', overflow: 'hidden' }}>
|
||||||
<div className="val anchored">{taskStats?.running || 0}</div>
|
<MaritimeInsightCard
|
||||||
<div className="lbl">执行中</div>
|
taskStats={taskStats}
|
||||||
|
taskTrend={taskTrend}
|
||||||
|
violationAnalysisData={violationAnalysisData}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div className="ship-stat-box">
|
|
||||||
<div className="val docked">{taskStats?.completed || 0}</div>
|
|
||||||
<div className="lbl">已完成</div>
|
|
||||||
</div>
|
|
||||||
<div className="ship-stat-box">
|
|
||||||
<div className="val warning">{taskStats?.failed || 0}</div>
|
|
||||||
<div className="lbl">已失败</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div style={{ marginTop: 16, textAlign: 'center' }}>
|
|
||||||
<div style={{ fontSize: '32px', fontWeight: 'bold', color: '#00e5a0' }}>
|
|
||||||
{taskStats?.successRate || 0}%
|
|
||||||
</div>
|
|
||||||
<div style={{ fontSize: '14px', color: '#e0f7ff', marginTop: 4 }}>
|
|
||||||
{taskPeriodText}成功率
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</Card>
|
|
||||||
|
|
||||||
<Card title="任务状态占比" className="panel-card ocean-glass" size="small">
|
|
||||||
<div className="chart-wrapper">
|
|
||||||
<Pie {...taskStatusPieConfig} />
|
|
||||||
</div>
|
|
||||||
</Card>
|
|
||||||
|
|
||||||
<Card title="近7日巡检趋势" className="panel-card ocean-glass" size="small">
|
|
||||||
<div className="chart-wrapper">
|
|
||||||
<Line {...taskTrendConfig} />
|
|
||||||
</div>
|
|
||||||
</Card>
|
|
||||||
|
|
||||||
<Card title="违规类型分析" className="panel-card ocean-glass flex-grow" size="small">
|
|
||||||
<div className="chart-wrapper">
|
|
||||||
<Rose {...roseConfig} />
|
|
||||||
</div>
|
|
||||||
</Card>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</Spin>
|
</Spin>
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
test
|
|
||||||
Reference in New Issue
Block a user