初始提交:5G 基站退服时长智能分析与故障闭环管控系统
Flask + SQLite 后端,免构建 React + ECharts 前端,含合成样例数据。 测试参考数据(FOR-TEST-ONLY)与运行时数据库不入库。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
commit
011972b129
39 files changed
+29010
No files matched your search
+20
@@ -0,0 +1,20 @@
|
|||||||
|
# Python
|
||||||
|
__pycache__/
|
||||||
|
*.py[cod]
|
||||||
|
.venv/
|
||||||
|
venv/
|
||||||
|
.idea/
|
||||||
|
.vscode/
|
||||||
|
|
||||||
|
# 运行时生成的数据库(首次启动自动创建,删除即重置)
|
||||||
|
data/outage.db
|
||||||
|
data/*.db-journal
|
||||||
|
|
||||||
|
# 测试用参考数据:含真实网管导出、Access 库与 .exe,体积大且可能涉及运营商数据,不入库
|
||||||
|
FOR-TEST-ONLY/
|
||||||
|
|
||||||
|
# 系统文件
|
||||||
|
Thumbs.db
|
||||||
|
desktop.ini
|
||||||
|
.DS_Store
|
||||||
|
~$*
|
||||||
@@ -0,0 +1,123 @@
|
|||||||
|
# 5G 基站退服时长智能分析与故障闭环管控系统
|
||||||
|
|
||||||
|
Python + Flask + SQLite 后端,React 19 + [Liquid Glass UI](https://tsdsj.github.io/liquid-glass-react/)(`@ttqtt/liquid-glass-react`)+ ECharts 前端。
|
||||||
|
|
||||||
|
## 用 PyCharm 运行
|
||||||
|
|
||||||
|
1. PyCharm → `File > Open`,选择 `Local-sever` 文件夹。
|
||||||
|
2. 配置解释器(Python 3.9+),在 Terminal 中安装依赖:
|
||||||
|
```bash
|
||||||
|
pip install -r requirements.txt
|
||||||
|
```
|
||||||
|
3. 右键 `app.py` → `Run 'app'`,浏览器打开 <http://127.0.0.1:5000>。
|
||||||
|
|
||||||
|
前端免构建:`static/js/` 下就是浏览器直接运行的源码,**运行和修改都不需要 Node.js**,改完刷新浏览器即可。
|
||||||
|
|
||||||
|
首次启动会自动创建 `data/outage.db`,并生成样例数据(约 1 秒)。删除该文件即可重置数据库。
|
||||||
|
|
||||||
|
| 账号 | 密码 | 角色 |
|
||||||
|
|---|---|---|
|
||||||
|
| admin | admin123 | 管理员:全部功能(含用户管理,系统不开放自助注册) |
|
||||||
|
| user | user123 | 普通用户:查询、统计、看板、导出,以及更新闭环进度 |
|
||||||
|
|
||||||
|
## 文件结构
|
||||||
|
|
||||||
|
```
|
||||||
|
Local-sever/
|
||||||
|
├── app.py Flask 路由:认证与权限、增删改查、导入、统计、导出、日志、用户;托管前端页面
|
||||||
|
├── core.py 核心算法:建库入库、两级根因关联、时长与考核指标
|
||||||
|
├── importer.py 数据导入:读取 Excel/CSV、自动识别文件类型、逐行校验(见下方“支持导入的文件”)
|
||||||
|
├── data_gen.py 第 18 题数据生成器(Data-Generated-Core-Py/data.py 的改进版,字段口径一致)
|
||||||
|
├── publish_online.py 同步到 ../Online-sever(1Panel 线上版)
|
||||||
|
├── data/ sites.csv / data_outage.csv / data_alarm.csv 种子数据,outage.db 自动生成
|
||||||
|
├── static/ 前端(全部可直接阅读和修改)
|
||||||
|
│ ├── index.html 页面入口,importmap 把 'vendor' / 'echarts' 指向 vendor/ 下的文件
|
||||||
|
│ ├── app.css 全部样式(Apple 系统色与背景、布局、响应式)
|
||||||
|
│ ├── js/
|
||||||
|
│ │ ├── main.js 入口:GlassProvider(跟随系统深浅色)+ ToastProvider;含 html`` 写法说明
|
||||||
|
│ │ ├── App.js 外壳:登录判断、分组侧边栏(窄屏为抽屉)、顶栏全局筛选、页面切换(#/页面id)
|
||||||
|
│ │ ├── Login.js 登录页
|
||||||
|
│ │ ├── api.js api() 请求、useFetch() 页面取数、download() 导出、useApp() 全局上下文
|
||||||
|
│ │ ├── format.js 数字格式、Apple 系统色、根因颜色
|
||||||
|
│ │ ├── components/ ui(卡片/指标/标签/下拉)、DataTable(表格+分页)、FormDialog、EChart、icons
|
||||||
|
│ │ └── pages/ index.js 页面注册表 + 10 个业务页面,一页一个文件
|
||||||
|
│ └── vendor/ 第三方库(React、液态玻璃组件库、htm、ECharts),压缩文件,不要手改
|
||||||
|
├── tools/vendor-build/ 只在升级第三方库时使用,见下文
|
||||||
|
└── _legacy_frontend/ 最早的原生 JS 前端,仅供对照,可删除
|
||||||
|
```
|
||||||
|
|
||||||
|
## 修改前端
|
||||||
|
|
||||||
|
前端是 React,但**不需要编译**:组件用 `html\`...\`` 模板([htm](https://github.com/developit/htm))书写,浏览器直接运行。和 JSX 的区别只有三点:
|
||||||
|
|
||||||
|
```js
|
||||||
|
// JSX: <Section title="标题" span={6}><EChart option={opt}/></Section>
|
||||||
|
// htm:
|
||||||
|
html`<${Section} title="标题" span=${6}><${EChart} option=${opt}/></${Section}>`
|
||||||
|
```
|
||||||
|
|
||||||
|
1. 组件名写成 `<${Section}>`,结束标签写成 `</${Section}>`;
|
||||||
|
2. 变量和表达式写成 `${...}`;
|
||||||
|
3. 嵌套模板也用 `html\`...\``;一个模板有多个并列根元素时用 `<${Fragment}>…</${Fragment}>` 包起来。
|
||||||
|
|
||||||
|
### 新增一个页面
|
||||||
|
|
||||||
|
1. 在 `static/js/pages/` 新建 `Xxx.js`,默认导出组件;用 `useApp()` 取全局筛选,`useFetch(url, 参数)` 请求数据。
|
||||||
|
2. 在 `pages/index.js` 中加一行注册(选择所属分组);需要图标时在 `components/icons.js` 加一条路径。
|
||||||
|
3. 刷新浏览器。
|
||||||
|
|
||||||
|
### 升级第三方库(很少需要)
|
||||||
|
|
||||||
|
`static/vendor/` 由 `tools/vendor-build/` 一次性生成。只有升级 React、组件库或 ECharts,或需要新的 React API / 新的图表类型时才需要 Node.js 20.19+:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cd tools/vendor-build
|
||||||
|
npm install
|
||||||
|
npm run build # 重新生成 ../../static/vendor/
|
||||||
|
```
|
||||||
|
|
||||||
|
## 前端设计说明
|
||||||
|
|
||||||
|
- **Apple 风格**:背景 #f5f5f7(深色 #000),卡片纯白(深色 #1c1c1e),颜色全部取自 Apple 系统色(systemBlue #007aff 等),字体优先 SF / 苹方。
|
||||||
|
- **分层**:玻璃材质只用于侧边栏、顶栏、弹窗、提示等浮动操作层;指标、图表、表格放在不透明卡片上(层级清晰,也避免大面积 `backdrop-filter` 的性能开销)。
|
||||||
|
- **窄屏**:侧边栏收进抽屉,顶栏只有菜单、标题、筛选三个控件,筛选项点开才显示,首屏直接看到数据。
|
||||||
|
- **性能**:页面按需懒加载;ECharts 只注册 4 种图表并在登录后才加载;图表配置内容不变时不重绘;后端明细缓存到数据变化为止。
|
||||||
|
- **无障碍**:跟随系统深浅色、减少动效;状态标签除颜色外始终带文字。
|
||||||
|
|
||||||
|
## 数据说明(对齐 _数据集总索引.md 第 18 题)
|
||||||
|
|
||||||
|
索引中推荐的 HuggingFace 数据集(COOPER、TelecomTS)在本机网络下无法访问,而且国内退服台账没有公开数据集。因此按索引的建议,用 `data.py` 的第 18 题口径生成合成数据,并在以下几处做了改进:
|
||||||
|
|
||||||
|
- **字段完全一致**:`record_id, ne_id, cell_id, district, vendor, start_time, end_time, duration_min, cause_category, cause_detail, ticket_id, closed`,按索引要求新增原因码 `cause_code`(参照《中兴 5G NR 基站日常故障处理指导手册》章节编码)。告警流字段与 data.py 的 `gen_alarm` 一致。
|
||||||
|
- **站点库**:data.py 原版每条记录随机生成站号,无法按站点汇聚统计。改进版生成固定站点库,覆盖南宁 7 个城区、5 类场景(商圈 / 高校 / 交通枢纽 / 城中村 / 工业园区)和 3 类站型(宏站 / 室分 / 分布式皮基站)。
|
||||||
|
- **退服与告警联动**:每次退服都会产生“小区退服”告警和对应的根因告警,约 65% 带有 `parent_alarm_id` 衍生关系;另外混入背景告警和时间窗内的干扰告警,用于检验算法。
|
||||||
|
- **贴近现网的分布**:沿用 data.py 的长尾时长分段;约 12% 为问题站点(重复退服);夏季停电高发;割接集中在凌晨窗口;约 1.5% 的上报时长存在人工计算错误,用于验证系统重算时长的功能。
|
||||||
|
- 论文中请注明数据为“合成数据”。
|
||||||
|
|
||||||
|
重新生成数据:`python data_gen.py --rows 6000`,然后删除 `data/outage.db` 并重启。
|
||||||
|
|
||||||
|
## 支持导入的文件(「数据导入校验」页,上传后自动识别)
|
||||||
|
|
||||||
|
| 类型 | 文件 | 入库方式 |
|
||||||
|
|---|---|---|
|
||||||
|
| 退服流水 | 系统模板(页面可下载)或 `data_outage.csv` 口径,支持中文表头 | 校验后追加,按起止时间重算时长,并对新记录做根因分析 |
|
||||||
|
| 告警流 | `data_alarm.csv` 口径(含 `alarm_code` 列) | 告警编号相同则覆盖,入库后对全部流水重新关联 |
|
||||||
|
| 网管告警 | `Reference-data/参数及告警检查工具/新建当前告警浏览结果*.csv`(华为网管导出,GBK 编码,表头前的说明行自动跳过) | 同上;按告警名称关键字归入根因类别(如 SCTP/X2/用户面承载→传输中断,射频单元/BBU/单板→设备硬件,驻波→天馈,交流掉电/直流→电源,小区不可用/退服→小区退服);没有 eNodeB ID 的网管系统告警列为问题行 |
|
||||||
|
| 站点工参 | `Reference-data/电信5G工参.xlsx`、`移动5G工参.xlsx` | 按基站汇总小区;按站名关键字推断场景(学院→高校、客运/东站→交通枢纽、产业园→工业园区、广场/营业厅→商圈,其余→城中村);已有基站只更新基础信息,保留页面上设置过的场景 |
|
||||||
|
|
||||||
|
`Reference-data` 中其余文件与本课题的退服分析无关,未做导入支持:KPI 日通报(地市级 GSM/TD/LTE 汇总)、质差小区分析(接入/掉话类)、MML 命令与参数查询结果、Access 数据库、故障处理手册 PDF(已用于处置建议的原因码编码)。
|
||||||
|
|
||||||
|
注意:参考目录里的网管告警来自其他地市的 LTE 网络,基站编号与站点库对不上,导入后会留档但不参与根因判定(预览时显示“匹配站点库”条数)。导入工参会增加站点总数,退服率的分母随之变大。
|
||||||
|
|
||||||
|
## 核心算法(core.py)
|
||||||
|
|
||||||
|
- **退服时长**:一律按“恢复时间 − 开始时间”重算;上报时长保存为 `reported_min`,两者相差超过 1 分钟即标记为“时长差错”。
|
||||||
|
- **退服率** = 总退服时长 ÷(站点数 × 统计时长);**网络可用率** = 1 − 退服率。
|
||||||
|
- **超长退服站点**:月均超长退服 ≥ 1 次(单次时长 ≥ 场景阈值)。**高频重复站点**:月均退服次数 ≥ 场景次数阈值。两个阈值都可在页面上配置。
|
||||||
|
- **根因判定分两级**:
|
||||||
|
1. 衍生关系:“小区退服”告警带有 `parent_alarm_id` 时,直接取父告警的类别。
|
||||||
|
2. 时间窗:回溯退服前未清除的同站告警,按优先级判定:割接施工(30 分钟)→ 电源故障(300 分钟)→ 机房环境(180 分钟)→ 传输中断(15 分钟)→ 天馈故障(30 分钟)→ 设备硬件(15 分钟)。
|
||||||
|
|
||||||
|
准确率按“上报原因大类 × 判定根因”交叉矩阵计算,样例数据约 98%。
|
||||||
|
- **断站分级**:重要 / 主要 / 次要,对应不同的处置响应时限。
|
||||||
|
- **影响评估**:受影响用户 = 小区数 × 单小区在线用户 × 忙闲时系数;业务损失 = 小区话务 × 退服时长。
|
||||||
@@ -0,0 +1,661 @@
|
|||||||
|
"""5G 基站退服时长智能分析与故障闭环管控系统 —— Flask 入口。运行:python app.py 后访问 http://127.0.0.1:5000
|
||||||
|
|
||||||
|
前端为免构建的 React 单页应用(static/index.html + static/js/),由本文件直接托管,改完刷新浏览器即生效。
|
||||||
|
本文件只负责:登录与权限、接收请求参数、调用 core.py / importer.py、把结果转成 JSON 或 Excel。
|
||||||
|
|
||||||
|
接口分组(与下方代码顺序一致):
|
||||||
|
页面与认证 / /login /logout /healthz
|
||||||
|
看板与统计 /api/meta /api/dashboard /api/stats /api/confusion /api/sites/rank
|
||||||
|
退服流水 /api/outages(查询、新增、修改、删除、批量) /api/analyze
|
||||||
|
数据导入 /api/import/preview /api/import/confirm /api/template
|
||||||
|
站点与场景 /api/sites /api/scenes
|
||||||
|
导出与系统 /api/export/<报表> /api/logs /api/users
|
||||||
|
"""
|
||||||
|
import io
|
||||||
|
import os
|
||||||
|
import time
|
||||||
|
import uuid
|
||||||
|
from datetime import datetime
|
||||||
|
from functools import wraps
|
||||||
|
|
||||||
|
import pandas as pd
|
||||||
|
from flask import Flask, jsonify, redirect, request, send_file, send_from_directory, session
|
||||||
|
from werkzeug.security import check_password_hash, generate_password_hash
|
||||||
|
|
||||||
|
import core
|
||||||
|
import importer
|
||||||
|
from core import execute, log, query
|
||||||
|
|
||||||
|
STATIC = os.path.join(core.BASE, 'static')
|
||||||
|
|
||||||
|
app = Flask(__name__)
|
||||||
|
app.secret_key = os.environ.get('SECRET_KEY', 'outage-5g-nanning')
|
||||||
|
app.config['MAX_CONTENT_LENGTH'] = 32 * 1024 * 1024 # 上传文件最大 32 MB
|
||||||
|
app.config['SESSION_COOKIE_SECURE'] = os.environ.get('COOKIE_SECURE') == '1' # 线上启用 HTTPS 后设为 1
|
||||||
|
|
||||||
|
# 导入预览缓存:token -> (类型, 合格数据)。预览和确认是两次请求,中间的数据暂存在进程内存里,
|
||||||
|
# 所以线上 gunicorn 只能开 1 个进程(见 Online-sever/gunicorn.conf.py)。
|
||||||
|
PENDING = {}
|
||||||
|
|
||||||
|
# 可用作筛选条件的查询参数
|
||||||
|
FILTER_KEYS = ['scene', 'region', 'site_type', 'vendor', 'root_cause', 'status', 'site', 'cause_category', 'month',
|
||||||
|
'date_from', 'date_to']
|
||||||
|
|
||||||
|
|
||||||
|
# ================================================================ 权限检查
|
||||||
|
# 二十多个接口都要做同样的登录 / 管理员检查,用装饰器写一次,接口函数上标注即可一眼看出权限要求。
|
||||||
|
def login_required(fn):
|
||||||
|
@wraps(fn)
|
||||||
|
def wrapper(*args, **kwargs):
|
||||||
|
if 'user' not in session:
|
||||||
|
if request.path.startswith('/api'):
|
||||||
|
return jsonify(error='未登录'), 401
|
||||||
|
return redirect('/login')
|
||||||
|
return fn(*args, **kwargs)
|
||||||
|
return wrapper
|
||||||
|
|
||||||
|
|
||||||
|
def admin_required(fn):
|
||||||
|
@wraps(fn)
|
||||||
|
@login_required
|
||||||
|
def wrapper(*args, **kwargs):
|
||||||
|
if session.get('role') != 'admin':
|
||||||
|
return jsonify(error='权限不足,仅管理员可操作'), 403
|
||||||
|
return fn(*args, **kwargs)
|
||||||
|
return wrapper
|
||||||
|
|
||||||
|
|
||||||
|
def current_filters():
|
||||||
|
"""从查询参数中取出非空的筛选条件。"""
|
||||||
|
filters = {}
|
||||||
|
for key in FILTER_KEYS:
|
||||||
|
value = request.args.get(key, '').strip()
|
||||||
|
if value:
|
||||||
|
filters[key] = value
|
||||||
|
return filters
|
||||||
|
|
||||||
|
|
||||||
|
def to_records(df, columns):
|
||||||
|
"""DataFrame 转成前端用的字典列表,空值转为空字符串。"""
|
||||||
|
return df[columns].fillna('').to_dict('records')
|
||||||
|
|
||||||
|
|
||||||
|
@app.errorhandler(Exception)
|
||||||
|
def on_error(e):
|
||||||
|
"""所有未处理的异常都以 JSON 返回错误信息,前端统一弹出提示。"""
|
||||||
|
code = getattr(e, 'code', 500)
|
||||||
|
if not isinstance(code, int):
|
||||||
|
code = 500
|
||||||
|
message = getattr(e, 'description', None) or str(e)
|
||||||
|
return jsonify(error=message), code
|
||||||
|
|
||||||
|
|
||||||
|
# ================================================================ 页面与认证
|
||||||
|
def single_page():
|
||||||
|
"""登录页与主界面是同一个页面,前端根据 /api/meta 是否返回 401 决定显示哪个。"""
|
||||||
|
return send_from_directory(STATIC, 'index.html')
|
||||||
|
|
||||||
|
|
||||||
|
@app.route('/')
|
||||||
|
def index():
|
||||||
|
return single_page()
|
||||||
|
|
||||||
|
|
||||||
|
@app.route('/healthz')
|
||||||
|
def healthz():
|
||||||
|
"""健康检查:数据库可访问即返回 ok,供面板 / Docker 监控使用(无需登录)。"""
|
||||||
|
query('SELECT 1')
|
||||||
|
return jsonify(ok=True)
|
||||||
|
|
||||||
|
|
||||||
|
@app.route('/login', methods=['GET'])
|
||||||
|
def login_page():
|
||||||
|
return single_page()
|
||||||
|
|
||||||
|
|
||||||
|
@app.route('/login', methods=['POST'])
|
||||||
|
def login():
|
||||||
|
data = request.get_json()
|
||||||
|
users = query('SELECT * FROM users WHERE username=?', (data.get('username'),))
|
||||||
|
if not users or not check_password_hash(users[0]['password'], data.get('password', '')):
|
||||||
|
return jsonify(error='用户名或密码错误'), 400
|
||||||
|
user = users[0]
|
||||||
|
session.update(user=user['username'], role=user['role'])
|
||||||
|
log(user['username'], '登录')
|
||||||
|
return jsonify(ok=True)
|
||||||
|
|
||||||
|
|
||||||
|
@app.route('/logout')
|
||||||
|
def logout():
|
||||||
|
if 'user' in session:
|
||||||
|
log(session['user'], '注销')
|
||||||
|
session.clear()
|
||||||
|
return redirect('/login')
|
||||||
|
|
||||||
|
|
||||||
|
# ================================================================ 看板与统计
|
||||||
|
@app.route('/api/meta')
|
||||||
|
@login_required
|
||||||
|
def meta():
|
||||||
|
"""下拉选项、当前用户与数据概况。前端启动时请求一次。"""
|
||||||
|
months = [row['m'] for row in query('SELECT DISTINCT substr(start_time,1,7) AS m FROM outages ORDER BY m')]
|
||||||
|
regions = [row['d'] for row in query('SELECT DISTINCT district AS d FROM sites ORDER BY d')]
|
||||||
|
vendors = [row['v'] for row in query('SELECT DISTINCT vendor AS v FROM sites ORDER BY v')]
|
||||||
|
overview = query("SELECT (SELECT COUNT(*) FROM sites) AS sites, COUNT(*) AS records, "
|
||||||
|
"SUM(status <> '已闭环') AS open FROM outages")[0] # 侧边栏底部的数据概况
|
||||||
|
return jsonify(scenes=core.SCENES, site_types=core.SITE_TYPES, causes=core.CAUSES, months=months,
|
||||||
|
regions=regions, vendors=vendors, status=['待处理', '处理中', '已闭环'],
|
||||||
|
role=session['role'], user=session['user'], overview=overview)
|
||||||
|
|
||||||
|
|
||||||
|
@app.route('/api/dashboard')
|
||||||
|
@login_required
|
||||||
|
def dashboard():
|
||||||
|
started = time.time()
|
||||||
|
filters = current_filters()
|
||||||
|
df = core.frame(filters)
|
||||||
|
stats = core.site_stats(df)
|
||||||
|
|
||||||
|
# 月度趋势:次数与时长(小时)
|
||||||
|
trend = df.groupby('month').agg(n=('id', 'size'), h=('duration_min', 'sum')).reset_index()
|
||||||
|
trend['h'] = (trend['h'] / 60).round(1)
|
||||||
|
|
||||||
|
# 场景 × 月份 热力图:[场景, 月份, 小时]
|
||||||
|
heat = df.groupby(['scene', 'month'])['duration_min'].sum().div(60).round(1).reset_index()
|
||||||
|
|
||||||
|
# 根因占比:[根因, 次数]
|
||||||
|
pie = df['root_cause'].fillna('未分析').value_counts().reset_index().values.tolist()
|
||||||
|
|
||||||
|
# 0-23 点各时段退服次数
|
||||||
|
hours = df['start'].dt.hour.value_counts().sort_index().reindex(range(24), fill_value=0).tolist()
|
||||||
|
|
||||||
|
# 分场景对标:每个场景单独核算一遍考核指标
|
||||||
|
bench = []
|
||||||
|
for scene in core.SCENES:
|
||||||
|
scene_sites = core.site_count({**filters, 'scene': scene})
|
||||||
|
if scene_sites == 0:
|
||||||
|
continue
|
||||||
|
scene_kpi = core.kpis(df[df['scene'] == scene], scene_sites)
|
||||||
|
bench.append(dict(scene=scene, **scene_kpi))
|
||||||
|
|
||||||
|
return jsonify(
|
||||||
|
kpi=core.kpis(df, core.site_count(filters)),
|
||||||
|
elapsed=round(time.time() - started, 3),
|
||||||
|
rank=to_records(stats.head(15), ['site_name', 'scene', 'total_min', 'count']),
|
||||||
|
trend=trend.to_dict('records'),
|
||||||
|
pie=pie,
|
||||||
|
heat=heat.values.tolist(),
|
||||||
|
months=sorted(df['month'].unique().tolist()),
|
||||||
|
bench=bench,
|
||||||
|
levels=df['level'].value_counts().to_dict(),
|
||||||
|
status=df['status'].value_counts().to_dict(),
|
||||||
|
hours=hours,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
STAT_DIMENSIONS = ['scene', 'region', 'site_type', 'vendor', 'month', 'root_cause', 'cause_category', 'cause_code',
|
||||||
|
'site_name', 'level']
|
||||||
|
|
||||||
|
|
||||||
|
@app.route('/api/stats')
|
||||||
|
@login_required
|
||||||
|
def stats():
|
||||||
|
"""按指定维度分组统计退服次数、时长、超长占比、影响用户等。"""
|
||||||
|
dimension = request.args.get('dim', 'scene')
|
||||||
|
if dimension not in STAT_DIMENSIONS:
|
||||||
|
return jsonify(error='不支持的维度'), 400
|
||||||
|
|
||||||
|
df = core.frame(current_filters())
|
||||||
|
grouped = df.groupby(dimension).agg(
|
||||||
|
count=('id', 'size'), total_min=('duration_min', 'sum'), avg_min=('duration_min', 'mean'),
|
||||||
|
max_min=('duration_min', 'max'), long_count=('is_long', 'sum'), users=('affected_users', 'sum'),
|
||||||
|
loss_gb=('loss_gb', 'sum'), sites=('site_name', 'nunique'),
|
||||||
|
).reset_index()
|
||||||
|
grouped['long_ratio'] = (grouped['long_count'] / grouped['count'] * 100).round(2)
|
||||||
|
grouped = grouped.round({'total_min': 1, 'avg_min': 1, 'loss_gb': 1})
|
||||||
|
|
||||||
|
sort = request.args.get('sort', 'total_min')
|
||||||
|
if sort not in grouped.columns:
|
||||||
|
sort = 'total_min'
|
||||||
|
grouped = grouped.sort_values(sort, ascending=request.args.get('asc') == '1')
|
||||||
|
|
||||||
|
log(session['user'], '统计查询', f'维度={dimension} 条件={current_filters()}')
|
||||||
|
return jsonify(rows=grouped.rename(columns={dimension: 'key'}).to_dict('records'))
|
||||||
|
|
||||||
|
|
||||||
|
@app.route('/api/confusion')
|
||||||
|
@login_required
|
||||||
|
def confusion():
|
||||||
|
"""上报原因 × 系统判定根因 交叉表,对角线为判定一致,用于检验根因判定准确率。"""
|
||||||
|
df = core.frame(current_filters())
|
||||||
|
df = df[df['cause_category'].isin(core.CAUSES)]
|
||||||
|
matrix = pd.crosstab(df['cause_category'], df['root_cause'])
|
||||||
|
matrix = matrix.reindex(index=core.CAUSES, columns=core.CAUSES, fill_value=0)
|
||||||
|
return jsonify(causes=core.CAUSES, matrix=matrix.values.tolist())
|
||||||
|
|
||||||
|
|
||||||
|
@app.route('/api/sites/rank')
|
||||||
|
@login_required
|
||||||
|
def site_rank():
|
||||||
|
"""超长退服站点(kind=long)/ 高频重复站点(kind=repeat)清单,附处置建议。"""
|
||||||
|
stats = core.site_stats(core.frame(current_filters()))
|
||||||
|
kind = request.args.get('kind', 'long')
|
||||||
|
if kind == 'long':
|
||||||
|
stats = stats[stats['long']]
|
||||||
|
elif kind == 'repeat':
|
||||||
|
stats = stats[stats['repeat']]
|
||||||
|
stats = stats.copy()
|
||||||
|
stats['advice'] = [core.advice(cause, '重要') for cause in stats['top_cause']]
|
||||||
|
columns = ['ne_id', 'site_name', 'region', 'scene', 'site_type', 'count', 'total_min', 'avg_min', 'max_min',
|
||||||
|
'long_count', 'long_min', 'freq_count', 'top_cause', 'advice']
|
||||||
|
return jsonify(rows=to_records(stats, columns))
|
||||||
|
|
||||||
|
|
||||||
|
# ================================================================ 退服流水管理
|
||||||
|
OUTAGE_LIST_COLUMNS = ['id', 'record_id', 'ne_id', 'cell_id', 'site_name', 'scene', 'site_type', 'region', 'vendor',
|
||||||
|
'start_time', 'end_time', 'duration_min', 'reported_min', 'dur_diff', 'cause_category',
|
||||||
|
'cause_detail', 'cause_code', 'ticket_id', 'root_cause', 'evidence', 'level', 'status',
|
||||||
|
'handler', 'remark', 'affected_users', 'loss_gb', 'advice']
|
||||||
|
|
||||||
|
# 新增 / 管理员修改时写入的字段,顺序与 outage_values() 返回值一致
|
||||||
|
OUTAGE_EDIT_FIELDS = ['record_id', 'ne_id', 'cell_id', 'start_time', 'end_time', 'duration_min', 'cause_category',
|
||||||
|
'cause_detail', 'ticket_id', 'status', 'handler', 'remark']
|
||||||
|
|
||||||
|
|
||||||
|
@app.route('/api/outages')
|
||||||
|
@login_required
|
||||||
|
def outages():
|
||||||
|
"""退服流水分页查询。除通用筛选外,long=1 只看超长,diff=1 只看上报时长差错。"""
|
||||||
|
filters = current_filters()
|
||||||
|
df = core.frame(filters)
|
||||||
|
if request.args.get('long') == '1':
|
||||||
|
df = df[df['is_long']]
|
||||||
|
if request.args.get('diff') == '1':
|
||||||
|
df = df[df['dur_diff']]
|
||||||
|
|
||||||
|
sort = request.args.get('sort', 'start_time')
|
||||||
|
if sort not in df.columns:
|
||||||
|
sort = 'start_time'
|
||||||
|
df = df.sort_values(sort, ascending=request.args.get('asc') == '1')
|
||||||
|
|
||||||
|
page = int(request.args.get('page', 1))
|
||||||
|
size = int(request.args.get('size', 20))
|
||||||
|
rows = df.iloc[(page - 1) * size: page * size].copy()
|
||||||
|
rows['advice'] = [core.advice(cause, level) for cause, level in zip(rows['root_cause'], rows['level'])]
|
||||||
|
|
||||||
|
if filters:
|
||||||
|
log(session['user'], '查询退服流水', str(filters))
|
||||||
|
return jsonify(total=len(df), rows=to_records(rows, OUTAGE_LIST_COLUMNS))
|
||||||
|
|
||||||
|
|
||||||
|
def outage_values(data):
|
||||||
|
"""校验新增 / 修改的表单,返回按 OUTAGE_EDIT_FIELDS 顺序排列的值。退服时长按起止时间计算。"""
|
||||||
|
start = pd.to_datetime(data['start_time'])
|
||||||
|
end = pd.to_datetime(data['end_time'])
|
||||||
|
if end < start:
|
||||||
|
raise ValueError('恢复时间早于开始时间')
|
||||||
|
if not query('SELECT 1 FROM sites WHERE ne_id=?', (data['ne_id'],)):
|
||||||
|
raise ValueError('基站不在站点库中')
|
||||||
|
|
||||||
|
values = {
|
||||||
|
'record_id': data.get('record_id', ''),
|
||||||
|
'ne_id': data['ne_id'],
|
||||||
|
'cell_id': data.get('cell_id', ''),
|
||||||
|
'start_time': start.strftime(core.TIME_FMT),
|
||||||
|
'end_time': end.strftime(core.TIME_FMT),
|
||||||
|
'duration_min': round((end - start).total_seconds() / 60, 1),
|
||||||
|
'cause_category': data.get('cause_category') or None,
|
||||||
|
'cause_detail': data.get('cause_detail', ''),
|
||||||
|
'ticket_id': data.get('ticket_id', ''),
|
||||||
|
'status': data.get('status') or '待处理',
|
||||||
|
'handler': data.get('handler', ''),
|
||||||
|
'remark': data.get('remark', ''),
|
||||||
|
}
|
||||||
|
return tuple(values[field] for field in OUTAGE_EDIT_FIELDS)
|
||||||
|
|
||||||
|
|
||||||
|
@app.route('/api/outages', methods=['POST'])
|
||||||
|
@admin_required
|
||||||
|
def outage_add():
|
||||||
|
columns = ','.join(OUTAGE_EDIT_FIELDS)
|
||||||
|
placeholders = ','.join('?' * len(OUTAGE_EDIT_FIELDS))
|
||||||
|
new_id = execute(f'INSERT INTO outages({columns}) VALUES({placeholders})', outage_values(request.get_json()))
|
||||||
|
core.analyze_all([new_id])
|
||||||
|
log(session['user'], '新增退服记录', f'id={new_id}')
|
||||||
|
return jsonify(ok=True, id=new_id)
|
||||||
|
|
||||||
|
|
||||||
|
@app.route('/api/outages/<int:outage_id>', methods=['PUT'])
|
||||||
|
@login_required
|
||||||
|
def outage_update(outage_id):
|
||||||
|
"""
|
||||||
|
两种修改:
|
||||||
|
闭环处理:普通用户(或请求中没有 ne_id 时)只更新状态、处理人、处理说明;
|
||||||
|
完整修改:管理员修改全部字段,并重新做根因分析。
|
||||||
|
"""
|
||||||
|
data = request.get_json()
|
||||||
|
is_admin = session['role'] == 'admin'
|
||||||
|
|
||||||
|
if not is_admin or 'ne_id' not in data:
|
||||||
|
execute('UPDATE outages SET status=?, handler=?, remark=? WHERE id=?',
|
||||||
|
(data.get('status'), data.get('handler', ''), data.get('remark', ''), outage_id))
|
||||||
|
log(session['user'], '更新闭环进度', f"id={outage_id} -> {data.get('status')}")
|
||||||
|
return jsonify(ok=True)
|
||||||
|
|
||||||
|
assignments = ','.join(f'{field}=?' for field in OUTAGE_EDIT_FIELDS)
|
||||||
|
execute(f'UPDATE outages SET {assignments} WHERE id=?', outage_values(data) + (outage_id,))
|
||||||
|
core.analyze_all([outage_id])
|
||||||
|
log(session['user'], '修改退服记录', f'id={outage_id}')
|
||||||
|
return jsonify(ok=True)
|
||||||
|
|
||||||
|
|
||||||
|
@app.route('/api/outages/<int:outage_id>', methods=['DELETE'])
|
||||||
|
@login_required
|
||||||
|
def outage_delete(outage_id):
|
||||||
|
if session['role'] != 'admin':
|
||||||
|
return jsonify(error='权限不足,仅管理员可删除'), 403
|
||||||
|
execute('DELETE FROM outages WHERE id=?', (outage_id,))
|
||||||
|
log(session['user'], '删除退服记录', f'id={outage_id}')
|
||||||
|
return jsonify(ok=True)
|
||||||
|
|
||||||
|
|
||||||
|
@app.route('/api/outages/batch', methods=['POST'])
|
||||||
|
@admin_required
|
||||||
|
def outage_batch():
|
||||||
|
"""批量删除(action=delete)或批量修改闭环状态(其他 action)。"""
|
||||||
|
data = request.get_json()
|
||||||
|
ids = [int(i) for i in data.get('ids', [])]
|
||||||
|
if not ids:
|
||||||
|
return jsonify(error='未选择记录'), 400
|
||||||
|
|
||||||
|
placeholders = ','.join('?' * len(ids))
|
||||||
|
if data.get('action') == 'delete':
|
||||||
|
execute(f'DELETE FROM outages WHERE id IN ({placeholders})', ids)
|
||||||
|
else:
|
||||||
|
execute(f'UPDATE outages SET status=? WHERE id IN ({placeholders})', [data.get('status', '已闭环')] + ids)
|
||||||
|
log(session['user'], '批量维护', f"{data.get('action')} {len(ids)} 条")
|
||||||
|
return jsonify(ok=True, n=len(ids))
|
||||||
|
|
||||||
|
|
||||||
|
@app.route('/api/analyze', methods=['POST'])
|
||||||
|
@admin_required
|
||||||
|
def reanalyze():
|
||||||
|
"""对全部退服流水重新做根因分析(修改阈值或导入告警后使用)。"""
|
||||||
|
started = time.time()
|
||||||
|
count = core.analyze_all()
|
||||||
|
accuracy = core.kpis(core.frame())['acc']
|
||||||
|
log(session['user'], '全量根因分析', f'{count} 条')
|
||||||
|
return jsonify(n=count, elapsed=round(time.time() - started, 3), acc=accuracy)
|
||||||
|
|
||||||
|
|
||||||
|
# ================================================================ 数据导入
|
||||||
|
PREVIEW_ROWS = 50 # 预览时返回给前端的合格数据条数(工参为按基站汇总后的站点)
|
||||||
|
|
||||||
|
|
||||||
|
@app.route('/api/import/preview', methods=['POST'])
|
||||||
|
@admin_required
|
||||||
|
def import_preview():
|
||||||
|
"""
|
||||||
|
上传文件 → 自动识别类型并逐行校验 → 返回统计、问题行与前 50 条合格数据,合格数据暂存等待确认。
|
||||||
|
支持的文件类型见 importer.py。
|
||||||
|
"""
|
||||||
|
started = time.time()
|
||||||
|
upload = request.files['file']
|
||||||
|
df = importer.read_upload(upload.read(), upload.filename)
|
||||||
|
kind, label, good, errors = importer.validate(df)
|
||||||
|
|
||||||
|
token = uuid.uuid4().hex
|
||||||
|
PENDING[token] = (kind, good)
|
||||||
|
|
||||||
|
result = dict(token=token, kind=kind, label=label, total=len(df), ok=len(good), bad=len(errors),
|
||||||
|
errors=errors[:500], diff=0)
|
||||||
|
|
||||||
|
if kind == 'outage':
|
||||||
|
# 上报时长与系统按起止时间重算的时长相差超过 1 分钟的条数
|
||||||
|
reported = pd.to_numeric(good['reported_min'], errors='coerce')
|
||||||
|
result['diff'] = int(((reported - good['duration_min'].astype(float)).abs() > 1).sum())
|
||||||
|
if kind == 'alarm':
|
||||||
|
# 告警的基站在站点库中能找到的条数:找不到的告警可以入库,但不会参与本系统站点的根因分析
|
||||||
|
known_sites = {row['ne_id'] for row in query('SELECT ne_id FROM sites')}
|
||||||
|
result['matched'] = int(good['ne_id'].isin(known_sites).sum())
|
||||||
|
if kind == 'site':
|
||||||
|
result['added'] = int((good['action'] == '新增').sum())
|
||||||
|
result['updated'] = int((good['action'] == '更新').sum())
|
||||||
|
|
||||||
|
# 先把空值换成空字符串再转文本:JSON 里不能出现 NaN,否则浏览器无法解析
|
||||||
|
preview = good.head(PREVIEW_ROWS).fillna('').astype(str).replace({'None': '', 'nan': ''})
|
||||||
|
result['preview'] = preview.to_dict('records')
|
||||||
|
result['elapsed'] = round(time.time() - started, 3)
|
||||||
|
|
||||||
|
log(session['user'], '导入预览', f'{upload.filename}({label})共{len(df)}行,合格{len(good)},问题{len(errors)}')
|
||||||
|
return jsonify(result)
|
||||||
|
|
||||||
|
|
||||||
|
@app.route('/api/import/confirm', methods=['POST'])
|
||||||
|
@admin_required
|
||||||
|
def import_confirm():
|
||||||
|
"""把预览时暂存的合格数据入库。告警入库后对全部流水重新关联;流水入库后只分析新记录。"""
|
||||||
|
started = time.time()
|
||||||
|
token = request.get_json().get('token')
|
||||||
|
kind, good = PENDING.pop(token, (None, None))
|
||||||
|
if good is None or good.empty:
|
||||||
|
return jsonify(error='预览已失效或无合格数据'), 400
|
||||||
|
|
||||||
|
result = dict(kind=kind)
|
||||||
|
if kind == 'alarm':
|
||||||
|
count = core.save_alarms(good)
|
||||||
|
core.analyze_all()
|
||||||
|
description = f'告警 {count} 条'
|
||||||
|
elif kind == 'site':
|
||||||
|
added, updated = core.save_sites(good)
|
||||||
|
count = added + updated
|
||||||
|
result['added'] = added
|
||||||
|
result['updated'] = updated
|
||||||
|
description = f'站点 新增{added} 更新{updated}'
|
||||||
|
else:
|
||||||
|
new_ids = core.save_outages(good)
|
||||||
|
core.analyze_all(new_ids)
|
||||||
|
count = len(new_ids)
|
||||||
|
description = f'退服流水 {count} 条'
|
||||||
|
|
||||||
|
log(session['user'], '导入入库', description)
|
||||||
|
result['n'] = count
|
||||||
|
result['elapsed'] = round(time.time() - started, 3)
|
||||||
|
return jsonify(result)
|
||||||
|
|
||||||
|
|
||||||
|
@app.route('/api/template')
|
||||||
|
@login_required
|
||||||
|
def template():
|
||||||
|
"""退服流水导入模板:故意包含几行错误数据,用于演示校验功能。"""
|
||||||
|
ne = [row['ne_id'] for row in query('SELECT ne_id FROM sites LIMIT 6')]
|
||||||
|
rows = [
|
||||||
|
['TF9000001', ne[0], '2026-10-02 08:10:00', '2026-10-02 09:40:00', 90, '电源故障', '市电停电', 'PW01', '是'],
|
||||||
|
['TF9000002', ne[1], '2026-10-03 14:00:00', '2026-10-03 14:35:00', 35, '传输中断', '光模块损坏', 'TR02', '是'],
|
||||||
|
['TF9000003', ne[2], '2026-10-04 22:00:00', '2026-10-04 21:00:00', 60, '设备硬件', '单板复位', 'HW04', '否'], # 恢复早于开始
|
||||||
|
['TF9000004', '', '2026-10-05 10:00:00', '2026-10-05 11:00:00', 60, '', '', '', '否'], # 缺站号
|
||||||
|
['TF9000005', ne[3], '2026/10/06 7:30', '错误时间', '', '', '', '', '否'], # 时间格式错
|
||||||
|
['TF9000006', ne[1], '2026-10-03 14:00:00', '2026-10-03 14:35:00', 35, '传输中断', '光模块损坏', 'TR02', '是'], # 与第 2 行重复
|
||||||
|
['TF9000007', 'gNodeB-00000', '2026-10-07 10:00:00', '2026-10-07 10:20:00', 20, '其他', '原因待查', 'OT01', '否'], # 站号不存在
|
||||||
|
['TF9000008', ne[4], '2026-10-07 23:15:00', '2026-10-08 06:00:00', 45, '割接施工', '计划割接', 'OP01', '否'], # 上报时长错误
|
||||||
|
]
|
||||||
|
columns = ['record_id', 'ne_id', 'start_time', 'end_time', 'duration_min', 'cause_category', 'cause_detail',
|
||||||
|
'cause_code', 'closed']
|
||||||
|
return excel_response({'退服流水': pd.DataFrame(rows, columns=columns)}, '退服流水导入模板.xlsx')
|
||||||
|
|
||||||
|
|
||||||
|
# ================================================================ 站点与场景
|
||||||
|
@app.route('/api/sites')
|
||||||
|
@login_required
|
||||||
|
def sites():
|
||||||
|
return jsonify(rows=query('SELECT * FROM sites ORDER BY scene, district, site_name'),
|
||||||
|
scenes=query('SELECT * FROM scenes'))
|
||||||
|
|
||||||
|
|
||||||
|
@app.route('/api/sites/<site_id>', methods=['PUT'])
|
||||||
|
@admin_required
|
||||||
|
def site_edit(site_id):
|
||||||
|
data = request.get_json()
|
||||||
|
execute('UPDATE sites SET scene=?, site_type=?, district=? WHERE ne_id=?',
|
||||||
|
(data['scene'], data['site_type'], data['district'], site_id))
|
||||||
|
log(session['user'], '修改站点', f"{site_id} -> {data['scene']}/{data['site_type']}")
|
||||||
|
return jsonify(ok=True)
|
||||||
|
|
||||||
|
|
||||||
|
@app.route('/api/scenes/<scene>', methods=['PUT'])
|
||||||
|
@admin_required
|
||||||
|
def scene_edit(scene):
|
||||||
|
data = request.get_json()
|
||||||
|
execute('UPDATE scenes SET long_min=?, freq_count=?, users_per_cell=?, gb_per_cell_h=? WHERE scene=?',
|
||||||
|
(int(data['long_min']), int(data['freq_count']), int(data['users_per_cell']),
|
||||||
|
float(data['gb_per_cell_h']), scene))
|
||||||
|
log(session['user'], '修改场景阈值', f'{scene}: {data}')
|
||||||
|
return jsonify(ok=True)
|
||||||
|
|
||||||
|
|
||||||
|
# ================================================================ 报表导出
|
||||||
|
# 导出 Excel 时的中文列名
|
||||||
|
EXPORT_COLUMN_NAMES = {
|
||||||
|
'ne_id': '基站编号', 'site_name': '基站名称', 'region': '片区', 'vendor': '厂家', 'cell_id': '小区', 'scene': '场景',
|
||||||
|
'site_type': '站型', 'count': '退服次数', 'total_min': '累计退服时长(分)', 'avg_min': '平均退服时长(分)',
|
||||||
|
'max_min': '最长单次(分)', 'long_count': '超长次数', 'users': '受影响用户', 'top_cause': '主要根因',
|
||||||
|
'long_min': '超长阈值(分)', 'freq_count': '次数阈值(次/月)', 'start_time': '开始时间', 'end_time': '恢复时间',
|
||||||
|
'duration_min': '系统计算时长(分)', 'reported_min': '上报时长(分)', 'cause_category': '上报原因大类',
|
||||||
|
'cause_detail': '原因细项', 'cause_code': '原因码', 'ticket_id': '工单号', 'root_cause': '系统判定根因',
|
||||||
|
'evidence': '关联告警', 'level': '断站分级', 'status': '闭环状态', 'advice': '处置建议', 'record_id': '流水号',
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def excel_response(sheets, filename):
|
||||||
|
"""把 {工作表名: DataFrame} 写成 Excel 并作为下载返回。列宽按内容长度自动调整(10~60)。"""
|
||||||
|
buffer = io.BytesIO()
|
||||||
|
with pd.ExcelWriter(buffer, engine='openpyxl') as writer:
|
||||||
|
for sheet_name, df in sheets.items():
|
||||||
|
df.to_excel(writer, sheet_name=sheet_name, index=False)
|
||||||
|
worksheet = writer.sheets[sheet_name]
|
||||||
|
for column_cells in worksheet.columns:
|
||||||
|
longest = 10
|
||||||
|
for cell in column_cells[:200]: # 只看前 200 行,避免大表导出变慢
|
||||||
|
longest = max(longest, len(str(cell.value or '')) * 1.6)
|
||||||
|
worksheet.column_dimensions[column_cells[0].column_letter].width = min(60, longest)
|
||||||
|
buffer.seek(0)
|
||||||
|
return send_file(buffer, as_attachment=True, download_name=filename)
|
||||||
|
|
||||||
|
|
||||||
|
@app.route('/api/export/<kind>')
|
||||||
|
@login_required
|
||||||
|
def export(kind):
|
||||||
|
"""三类报表:stats 退服统计表、long 超长退服站点清单、advice 根因处置建议清单。"""
|
||||||
|
df = core.frame(current_filters())
|
||||||
|
stats = core.site_stats(df)
|
||||||
|
stamp = datetime.now().strftime('%Y%m%d%H%M')
|
||||||
|
|
||||||
|
if kind == 'stats':
|
||||||
|
k = core.kpis(df)
|
||||||
|
kpi_rows = [
|
||||||
|
['退服次数', k['count']], ['累计退服时长(小时)', k['total_h']], ['平均退服时长(分钟)', k['avg_min']],
|
||||||
|
['退服率(%)', k['outage_rate']], ['网络可用率(%)', k['availability']], ['超长退服占比(%)', k['long_ratio']],
|
||||||
|
['重复退服率(%)', k['repeat_rate']], ['受影响用户数', k['users']], ['业务损失(GB)', k['loss_gb']],
|
||||||
|
['根因判定准确率(%)', k['acc']], ['闭环率(%)', k['closed']], ['上报时长差错(条)', k['dur_fix']],
|
||||||
|
]
|
||||||
|
site_columns = ['ne_id', 'site_name', 'region', 'scene', 'site_type', 'count', 'total_min', 'avg_min',
|
||||||
|
'max_min', 'long_count', 'users', 'top_cause']
|
||||||
|
sheets = {
|
||||||
|
'考核指标': pd.DataFrame(kpi_rows, columns=['指标', '数值']),
|
||||||
|
'站点退服统计': stats[site_columns].rename(columns=EXPORT_COLUMN_NAMES),
|
||||||
|
}
|
||||||
|
title = '退服统计表'
|
||||||
|
|
||||||
|
elif kind == 'long':
|
||||||
|
stats = stats[stats['long'] | stats['repeat']].copy()
|
||||||
|
site_kinds = []
|
||||||
|
for is_long, is_repeat in zip(stats['long'], stats['repeat']):
|
||||||
|
if is_long and is_repeat:
|
||||||
|
site_kinds.append('超长+高频')
|
||||||
|
elif is_long:
|
||||||
|
site_kinds.append('超长退服')
|
||||||
|
else:
|
||||||
|
site_kinds.append('高频重复')
|
||||||
|
stats['类型'] = site_kinds
|
||||||
|
stats['advice'] = [core.advice(cause, '重要') for cause in stats['top_cause']]
|
||||||
|
columns = ['ne_id', 'site_name', 'region', 'scene', 'site_type', '类型', 'count', 'total_min', 'avg_min',
|
||||||
|
'long_min', 'freq_count', 'top_cause', 'advice']
|
||||||
|
sheets = {'超长与高频站点': stats[columns].rename(columns=EXPORT_COLUMN_NAMES)}
|
||||||
|
title = '超长退服站点清单'
|
||||||
|
|
||||||
|
elif kind == 'advice':
|
||||||
|
long_outages = df[df['is_long']].copy()
|
||||||
|
long_outages['advice'] = [core.advice(cause, level)
|
||||||
|
for cause, level in zip(long_outages['root_cause'], long_outages['level'])]
|
||||||
|
long_outages = long_outages.sort_values('duration_min', ascending=False)
|
||||||
|
columns = ['record_id', 'ne_id', 'site_name', 'scene', 'start_time', 'end_time', 'duration_min',
|
||||||
|
'cause_category', 'cause_code', 'root_cause', 'evidence', 'level', 'status', 'ticket_id', 'advice']
|
||||||
|
sheets = {'根因处置建议': long_outages[columns].rename(columns=EXPORT_COLUMN_NAMES)}
|
||||||
|
title = '根因处置建议清单'
|
||||||
|
|
||||||
|
else:
|
||||||
|
return jsonify(error='未知报表'), 400
|
||||||
|
|
||||||
|
log(session['user'], '导出报表', title)
|
||||||
|
return excel_response(sheets, f'{title}_{stamp}.xlsx')
|
||||||
|
|
||||||
|
|
||||||
|
# ================================================================ 日志与用户
|
||||||
|
@app.route('/api/logs')
|
||||||
|
@admin_required
|
||||||
|
def logs():
|
||||||
|
return jsonify(rows=query('SELECT * FROM logs ORDER BY id DESC LIMIT 500'))
|
||||||
|
|
||||||
|
|
||||||
|
@app.route('/api/users', methods=['GET'])
|
||||||
|
@admin_required
|
||||||
|
def users_list():
|
||||||
|
return jsonify(rows=query('SELECT id, username, role, created_at FROM users'))
|
||||||
|
|
||||||
|
|
||||||
|
@app.route('/api/users', methods=['POST'])
|
||||||
|
@admin_required
|
||||||
|
def user_add():
|
||||||
|
data = request.get_json()
|
||||||
|
if query('SELECT 1 FROM users WHERE username=?', (data['username'],)):
|
||||||
|
return jsonify(error='用户名已存在'), 400
|
||||||
|
execute('INSERT INTO users(username,password,role,created_at) VALUES(?,?,?,?)',
|
||||||
|
(data['username'], generate_password_hash(data['password']), data.get('role', 'user'),
|
||||||
|
datetime.now().strftime(core.TIME_FMT)))
|
||||||
|
log(session['user'], '新增用户', data['username'])
|
||||||
|
return users_list()
|
||||||
|
|
||||||
|
|
||||||
|
@app.route('/api/users/<int:user_id>', methods=['PUT'])
|
||||||
|
@admin_required
|
||||||
|
def user_update(user_id):
|
||||||
|
"""重置密码或修改角色(请求里带哪个字段就改哪个)。密码以 PBKDF2-SHA256 加盐哈希保存。"""
|
||||||
|
users = query('SELECT username FROM users WHERE id=?', (user_id,))
|
||||||
|
if not users:
|
||||||
|
return jsonify(error='用户不存在'), 404
|
||||||
|
data = request.get_json()
|
||||||
|
if data.get('password'):
|
||||||
|
execute('UPDATE users SET password=? WHERE id=?', (generate_password_hash(data['password']), user_id))
|
||||||
|
if data.get('role'):
|
||||||
|
execute('UPDATE users SET role=? WHERE id=?', (data['role'], user_id))
|
||||||
|
log(session['user'], '修改用户', users[0]['username'])
|
||||||
|
return jsonify(ok=True)
|
||||||
|
|
||||||
|
|
||||||
|
@app.route('/api/users/<int:user_id>', methods=['DELETE'])
|
||||||
|
@admin_required
|
||||||
|
def user_delete(user_id):
|
||||||
|
users = query('SELECT username FROM users WHERE id=?', (user_id,))
|
||||||
|
if not users:
|
||||||
|
return jsonify(error='用户不存在'), 404
|
||||||
|
if users[0]['username'] == session['user']:
|
||||||
|
return jsonify(error='不能删除当前登录账号'), 400
|
||||||
|
execute('DELETE FROM users WHERE id=?', (user_id,))
|
||||||
|
log(session['user'], '删除用户', users[0]['username'])
|
||||||
|
return jsonify(ok=True)
|
||||||
|
|
||||||
|
|
||||||
|
core.init_db()
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
app.run(debug=True, port=int(os.environ.get('PORT', 5000)))
|
||||||
@@ -0,0 +1,455 @@
|
|||||||
|
"""核心层:数据库、入库、根因关联分析、考核指标核算。字段口径与 data_gen.py(data.py 第 18 题)一致。
|
||||||
|
|
||||||
|
从上到下依次是:
|
||||||
|
1. 配置常量(场景、根因、时间窗规则、处置建议)
|
||||||
|
2. 数据库基础操作与明细缓存
|
||||||
|
3. 建库与首次导入样例数据
|
||||||
|
4. 入库(退服流水、告警、站点)
|
||||||
|
5. 根因关联分析
|
||||||
|
6. 指标核算(明细、站点统计、考核指标)
|
||||||
|
文件导入的读取与校验在 importer.py。
|
||||||
|
"""
|
||||||
|
import os
|
||||||
|
import sqlite3
|
||||||
|
from contextlib import contextmanager
|
||||||
|
from datetime import datetime
|
||||||
|
|
||||||
|
import numpy as np
|
||||||
|
import pandas as pd
|
||||||
|
from werkzeug.security import generate_password_hash
|
||||||
|
|
||||||
|
# ================================================================ 1. 配置常量
|
||||||
|
BASE = os.path.dirname(os.path.abspath(__file__))
|
||||||
|
DATA = os.path.join(BASE, 'data')
|
||||||
|
DB_PATH = os.environ.get('OUTAGE_DB', os.path.join(DATA, 'outage.db')) # 线上部署可指向持久化目录
|
||||||
|
TIME_FMT = '%Y-%m-%d %H:%M:%S'
|
||||||
|
|
||||||
|
SCENES = ['商圈', '高校', '交通枢纽', '城中村', '工业园区']
|
||||||
|
SITE_TYPES = ['宏站', '室分', '分布式皮基站']
|
||||||
|
CAUSES = ['传输中断', '电源故障', '设备硬件', '天馈故障', '机房环境', '割接施工', '其他']
|
||||||
|
KEY_SCENES = ['商圈', '高校', '交通枢纽'] # 高话务关键场景,断站分级时从严
|
||||||
|
|
||||||
|
# 场景默认阈值:超长退服时长(分钟)、高频退服次数(次/月)、单小区平均在线用户、单小区每小时话务(GB)
|
||||||
|
SCENE_DEFAULT = {
|
||||||
|
'商圈': (120, 4, 320, 18),
|
||||||
|
'高校': (120, 4, 420, 22),
|
||||||
|
'交通枢纽': (90, 3, 380, 20),
|
||||||
|
'城中村': (240, 6, 160, 9),
|
||||||
|
'工业园区': (180, 5, 120, 7),
|
||||||
|
}
|
||||||
|
|
||||||
|
# 时间窗规则:(告警类别, 判定根因, 告警最多早于退服多少分钟),按优先级从高到低排列。
|
||||||
|
# 割接操作最先排除;停电有蓄电池后备、机房高温有过热保护延时,所以窗口放宽;
|
||||||
|
# 停电往往同时引起传输告警,因为电源优先级更高,这种情况归为电源故障。
|
||||||
|
RULES = [
|
||||||
|
('割接施工', '割接施工', 30),
|
||||||
|
('电源故障', '电源故障', 300),
|
||||||
|
('机房环境', '机房环境', 180),
|
||||||
|
('传输中断', '传输中断', 15),
|
||||||
|
('天馈故障', '天馈故障', 30),
|
||||||
|
('设备硬件', '设备硬件', 15),
|
||||||
|
]
|
||||||
|
|
||||||
|
ADVICE = {
|
||||||
|
'电源故障': ['核查市电及开关电源状态,必要时调度油机发电', '检测蓄电池组容量,老化电池纳入更换计划', '评估加装智能电表与远程动环监控'],
|
||||||
|
'传输中断': ['联系传输专业排查光缆/光模块,定位断点', '核查 SCTP 偶联与 NG 链路配置', '重要站点规划传输双路由保护'],
|
||||||
|
'设备硬件': ['远程复位 BBU/AAU,观察告警是否清除', '安排备件上站更换故障单板或射频单元', '同批次设备开展隐患排查'],
|
||||||
|
'天馈故障': ['测试驻波比,排查馈线接头与防水', '检查天线是否被遮挡或破坏', '雨季前开展天馈防水专项整治'],
|
||||||
|
'机房环境': ['上站检修空调,临时加装排风', '排查漏水点并做好设备防护', '接入动环温湿度与水浸监控'],
|
||||||
|
'割接施工': ['核实割接/闭塞是否已报备并在窗口内', '督促割接完成后及时解闭塞并验证业务', '施工前联系光缆路由交底,防止误碰'],
|
||||||
|
'其他': ['调取网管日志与现场照片综合研判', '派单现场复核,联系业主确认是否断电', '持续观察,重复发生升级处理'],
|
||||||
|
}
|
||||||
|
LEVEL_TIP = {'重要': '一级(2小时内响应,优先闭环)', '主要': '二级(4小时内响应)', '次要': '三级(24小时内处理)'}
|
||||||
|
|
||||||
|
|
||||||
|
# ================================================================ 2. 数据库基础操作
|
||||||
|
@contextmanager
|
||||||
|
def db():
|
||||||
|
"""
|
||||||
|
打开数据库连接,用法:with db() as conn: ...
|
||||||
|
正常结束时提交、出错时回滚,最后一定关闭连接。sqlite3 自带的 with 只负责提交/回滚,不会关闭连接,
|
||||||
|
所以这里统一包一层,全文件都通过它访问数据库。
|
||||||
|
"""
|
||||||
|
conn = sqlite3.connect(DB_PATH)
|
||||||
|
conn.row_factory = sqlite3.Row
|
||||||
|
try:
|
||||||
|
with conn:
|
||||||
|
yield conn
|
||||||
|
finally:
|
||||||
|
conn.close()
|
||||||
|
|
||||||
|
|
||||||
|
def query(sql, args=()):
|
||||||
|
"""执行查询,返回字典列表。"""
|
||||||
|
with db() as conn:
|
||||||
|
rows = conn.execute(sql, args).fetchall()
|
||||||
|
return [dict(row) for row in rows]
|
||||||
|
|
||||||
|
|
||||||
|
def execute(sql, args=(), changes_data=True):
|
||||||
|
"""执行一条写语句,返回新行 id。changes_data=True 表示改动了业务数据,需要清空明细缓存。"""
|
||||||
|
with db() as conn:
|
||||||
|
new_id = conn.execute(sql, args).lastrowid
|
||||||
|
if changes_data:
|
||||||
|
data_changed()
|
||||||
|
return new_id
|
||||||
|
|
||||||
|
|
||||||
|
def log(user, action, detail=''):
|
||||||
|
"""记录操作日志。日志不影响统计结果,所以不清空明细缓存。"""
|
||||||
|
now = datetime.now().strftime(TIME_FMT)
|
||||||
|
execute('INSERT INTO logs(username, action, detail, ts) VALUES(?,?,?,?)', (user, action, detail, now),
|
||||||
|
changes_data=False)
|
||||||
|
|
||||||
|
|
||||||
|
# 明细缓存:未筛选的退服明细(含派生字段)计算一次后保存在内存里,各接口在它上面做筛选;
|
||||||
|
# 任何写入业务数据的操作都要调用 data_changed(),下次访问时重新计算。
|
||||||
|
_frame_cache = None
|
||||||
|
|
||||||
|
|
||||||
|
def data_changed():
|
||||||
|
global _frame_cache
|
||||||
|
_frame_cache = None
|
||||||
|
|
||||||
|
|
||||||
|
# ================================================================ 3. 建库与样例数据
|
||||||
|
SCHEMA = """
|
||||||
|
CREATE TABLE IF NOT EXISTS users(id INTEGER PRIMARY KEY, username TEXT UNIQUE, password TEXT,
|
||||||
|
role TEXT DEFAULT 'user', created_at TEXT);
|
||||||
|
CREATE TABLE IF NOT EXISTS scenes(scene TEXT PRIMARY KEY, long_min INTEGER, freq_count INTEGER,
|
||||||
|
users_per_cell INTEGER, gb_per_cell_h REAL);
|
||||||
|
CREATE TABLE IF NOT EXISTS sites(ne_id TEXT PRIMARY KEY, site_name TEXT, district TEXT, scene TEXT,
|
||||||
|
site_type TEXT, vendor TEXT, cells INTEGER, lng REAL, lat REAL);
|
||||||
|
CREATE TABLE IF NOT EXISTS outages(id INTEGER PRIMARY KEY, record_id TEXT, ne_id TEXT, cell_id TEXT,
|
||||||
|
start_time TEXT, end_time TEXT, duration_min REAL, reported_min REAL, cause_category TEXT, cause_detail TEXT,
|
||||||
|
cause_code TEXT, ticket_id TEXT, root_cause TEXT, evidence TEXT, status TEXT DEFAULT '待处理',
|
||||||
|
handler TEXT, remark TEXT);
|
||||||
|
CREATE INDEX IF NOT EXISTS ix_out_ne ON outages(ne_id, start_time);
|
||||||
|
CREATE TABLE IF NOT EXISTS alarms(alarm_id TEXT PRIMARY KEY, ne_id TEXT, alarm_code TEXT, alarm_name TEXT,
|
||||||
|
alarm_level TEXT, category TEXT, start_time TEXT, clear_time TEXT, duration_s INTEGER, cleared TEXT,
|
||||||
|
parent_alarm_id TEXT);
|
||||||
|
CREATE INDEX IF NOT EXISTS ix_alarm_ne ON alarms(ne_id, start_time);
|
||||||
|
CREATE TABLE IF NOT EXISTS logs(id INTEGER PRIMARY KEY, username TEXT, action TEXT, detail TEXT, ts TEXT);
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
def init_db():
|
||||||
|
"""启动时调用:建表;数据库文件是第一次创建时,再写入默认账号、场景阈值,并导入 data/ 下的样例数据。"""
|
||||||
|
is_first_run = not os.path.exists(DB_PATH)
|
||||||
|
os.makedirs(os.path.dirname(DB_PATH), exist_ok=True)
|
||||||
|
with db() as conn:
|
||||||
|
conn.executescript(SCHEMA)
|
||||||
|
if not is_first_run:
|
||||||
|
return
|
||||||
|
|
||||||
|
now = datetime.now().strftime(TIME_FMT)
|
||||||
|
with db() as conn:
|
||||||
|
conn.execute('INSERT INTO users(username,password,role,created_at) VALUES(?,?,?,?)',
|
||||||
|
('admin', generate_password_hash('admin123'), 'admin', now))
|
||||||
|
conn.execute('INSERT INTO users(username,password,role,created_at) VALUES(?,?,?,?)',
|
||||||
|
('user', generate_password_hash('user123'), 'user', now))
|
||||||
|
for scene, (long_min, freq_count, users_per_cell, gb_per_cell_h) in SCENE_DEFAULT.items():
|
||||||
|
conn.execute('INSERT INTO scenes VALUES(?,?,?,?,?)', (scene, long_min, freq_count, users_per_cell, gb_per_cell_h))
|
||||||
|
|
||||||
|
# 样例数据缺失时现场生成(约 1 秒)
|
||||||
|
if not os.path.exists(os.path.join(DATA, 'data_outage.csv')):
|
||||||
|
import data_gen
|
||||||
|
data_gen.generate(out=DATA)
|
||||||
|
|
||||||
|
sites = pd.read_csv(os.path.join(DATA, 'sites.csv'), encoding='utf-8-sig', dtype=str)
|
||||||
|
alarms = pd.read_csv(os.path.join(DATA, 'data_alarm.csv'), encoding='utf-8-sig', dtype=str)
|
||||||
|
outages = pd.read_csv(os.path.join(DATA, 'data_outage.csv'), encoding='utf-8-sig', dtype=str)
|
||||||
|
|
||||||
|
with db() as conn:
|
||||||
|
sites.to_sql('sites', conn, if_exists='append', index=False)
|
||||||
|
save_alarms(alarms)
|
||||||
|
|
||||||
|
# 样例退服流水与用户上传的文件走同一套校验(时长重算、上报时长核对)。
|
||||||
|
# importer 依赖本模块,所以在函数内导入,避免两个模块互相导入时出错。
|
||||||
|
import importer
|
||||||
|
good_outages, _ = importer.validate_outages(outages)
|
||||||
|
save_outages(good_outages)
|
||||||
|
analyze_all()
|
||||||
|
|
||||||
|
|
||||||
|
# ================================================================ 4. 入库
|
||||||
|
def save_outages(good):
|
||||||
|
"""合格退服流水入库,返回新记录的 id 列表(用于随后只对新记录做根因分析)。"""
|
||||||
|
with db() as conn:
|
||||||
|
last_id = conn.execute('SELECT COALESCE(MAX(id), 0) FROM outages').fetchone()[0]
|
||||||
|
good.to_sql('outages', conn, if_exists='append', index=False)
|
||||||
|
data_changed()
|
||||||
|
new_rows = query('SELECT id FROM outages WHERE id > ?', (last_id,))
|
||||||
|
return [row['id'] for row in new_rows]
|
||||||
|
|
||||||
|
|
||||||
|
def save_alarms(df):
|
||||||
|
"""告警入库。告警编号相同的覆盖旧记录(重复导入同一份网管导出不会产生重复告警)。"""
|
||||||
|
with db() as conn:
|
||||||
|
df.to_sql('alarms_tmp', conn, if_exists='replace', index=False)
|
||||||
|
conn.execute('INSERT OR REPLACE INTO alarms SELECT * FROM alarms_tmp')
|
||||||
|
conn.execute('DROP TABLE alarms_tmp')
|
||||||
|
data_changed()
|
||||||
|
return len(df)
|
||||||
|
|
||||||
|
|
||||||
|
def save_sites(df):
|
||||||
|
"""
|
||||||
|
工参站点入库,返回 (新增数, 更新数)。
|
||||||
|
已存在的基站只更新名称、片区、站型、厂家、小区数、经纬度,保留管理员在页面上设置过的场景标签。
|
||||||
|
"""
|
||||||
|
added = 0
|
||||||
|
updated = 0
|
||||||
|
with db() as conn:
|
||||||
|
for site in df.to_dict('records'):
|
||||||
|
values = (site['ne_id'], site['site_name'], site['district'], site['scene'], site['site_type'],
|
||||||
|
site['vendor'], site['cells'], site['lng'], site['lat'])
|
||||||
|
conn.execute('INSERT INTO sites(ne_id, site_name, district, scene, site_type, vendor, cells, lng, lat) '
|
||||||
|
'VALUES(?,?,?,?,?,?,?,?,?) '
|
||||||
|
'ON CONFLICT(ne_id) DO UPDATE SET site_name=excluded.site_name, district=excluded.district, '
|
||||||
|
'site_type=excluded.site_type, vendor=excluded.vendor, cells=excluded.cells, '
|
||||||
|
'lng=excluded.lng, lat=excluded.lat', values)
|
||||||
|
if site['action'] == '新增':
|
||||||
|
added += 1
|
||||||
|
else:
|
||||||
|
updated += 1
|
||||||
|
data_changed()
|
||||||
|
return added, updated
|
||||||
|
|
||||||
|
|
||||||
|
# ================================================================ 5. 根因关联分析
|
||||||
|
def analyze(outages):
|
||||||
|
"""
|
||||||
|
两级根因判定。outages 需含 id, ne_id, start_time 三列,返回 [(根因, 证据, id), ...]。
|
||||||
|
第一级 衍生关系:同站、同一时刻的“小区退服”告警如果带 parent_alarm_id,直接取父告警的类别
|
||||||
|
(网管已经给出因果链,最可靠);
|
||||||
|
第二级 时间窗: 否则回溯同站在退服前仍未清除的告警,按 RULES 的优先级取第一个命中的类别;
|
||||||
|
都没有命中判为“其他”。
|
||||||
|
"""
|
||||||
|
if outages.empty:
|
||||||
|
return []
|
||||||
|
|
||||||
|
# 只取涉及到的基站的告警,避免全表读取
|
||||||
|
ne_ids = tuple(outages['ne_id'].dropna().unique())
|
||||||
|
placeholders = ','.join('?' * len(ne_ids))
|
||||||
|
with db() as conn:
|
||||||
|
alarms = pd.read_sql(f'SELECT alarm_id, ne_id, alarm_name, category, start_time, clear_time, parent_alarm_id '
|
||||||
|
f'FROM alarms WHERE ne_id IN ({placeholders})', conn, params=ne_ids,
|
||||||
|
parse_dates=['start_time', 'clear_time'])
|
||||||
|
alarms = alarms.rename(columns={'start_time': 'alarm_time'})
|
||||||
|
|
||||||
|
outages = outages[['id', 'ne_id', 'start_time']].copy()
|
||||||
|
outages['start_time'] = pd.to_datetime(outages['start_time'])
|
||||||
|
|
||||||
|
results = {} # 退服 id -> (根因, 证据)
|
||||||
|
|
||||||
|
# ---- 第一级:衍生关系。找到带父告警的“小区退服”告警,再查出父告警的类别
|
||||||
|
child_alarms = alarms[(alarms['category'] == '小区退服') & alarms['parent_alarm_id'].fillna('').ne('')]
|
||||||
|
child_alarms = child_alarms[['ne_id', 'alarm_time', 'parent_alarm_id']].rename(columns={'alarm_time': 'start_time'})
|
||||||
|
parent_alarms = alarms.drop(columns=['ne_id', 'parent_alarm_id'])
|
||||||
|
child_with_parent = child_alarms.merge(parent_alarms, left_on='parent_alarm_id', right_on='alarm_id')
|
||||||
|
matched = outages.merge(child_with_parent, on=['ne_id', 'start_time']).drop_duplicates('id')
|
||||||
|
for row in matched.itertuples():
|
||||||
|
if row.category in CAUSES:
|
||||||
|
evidence = f'衍生关系:{row.alarm_name}@{row.alarm_time:%m-%d %H:%M}'
|
||||||
|
results[row.id] = (row.category, evidence)
|
||||||
|
|
||||||
|
# ---- 第二级:时间窗。把剩余退服与同站的根因类告警两两配对,逐条规则打标
|
||||||
|
remaining = outages[~outages['id'].isin(results)]
|
||||||
|
pairs = remaining.merge(alarms[alarms['category'] != '小区退服'], on='ne_id')
|
||||||
|
minutes_before = (pairs['start_time'] - pairs['alarm_time']).dt.total_seconds() / 60
|
||||||
|
# 告警在退服时仍未清除(允许 1 分钟误差)才可能是原因
|
||||||
|
still_active = pairs['clear_time'].isna() | (pairs['clear_time'] >= pairs['start_time'] - pd.Timedelta(minutes=1))
|
||||||
|
|
||||||
|
pairs['rank'] = 99 # 命中规则的序号,越小优先级越高;99 表示没有命中
|
||||||
|
for rank, (category, _, window) in enumerate(RULES):
|
||||||
|
hit = ((pairs['category'] == category) & (minutes_before <= window) & (minutes_before >= -5)
|
||||||
|
& still_active & (pairs['rank'] > rank))
|
||||||
|
pairs.loc[hit, 'rank'] = rank
|
||||||
|
|
||||||
|
# 每条退服取优先级最高、时间最早的一条告警作为根因
|
||||||
|
best = pairs[pairs['rank'] < 99].sort_values(['id', 'rank', 'alarm_time']).drop_duplicates('id')
|
||||||
|
for row in best.itertuples():
|
||||||
|
evidence = f'时间窗:{row.alarm_name}@{row.alarm_time:%m-%d %H:%M}'
|
||||||
|
results[row.id] = (RULES[row.rank][1], evidence)
|
||||||
|
|
||||||
|
output = []
|
||||||
|
for outage_id in outages['id']:
|
||||||
|
cause, evidence = results.get(outage_id, ('其他', '时间窗内无关联告警'))
|
||||||
|
output.append((cause, evidence, int(outage_id)))
|
||||||
|
return output
|
||||||
|
|
||||||
|
|
||||||
|
def analyze_all(ids=None):
|
||||||
|
"""对指定 id(不传则全部)的退服流水重新做根因分析并写回数据库,返回分析条数。"""
|
||||||
|
sql = 'SELECT id, ne_id, start_time FROM outages'
|
||||||
|
if ids:
|
||||||
|
sql += ' WHERE id IN (' + ','.join(str(i) for i in ids) + ')'
|
||||||
|
with db() as conn:
|
||||||
|
outages = pd.read_sql(sql, conn)
|
||||||
|
|
||||||
|
results = analyze(outages)
|
||||||
|
with db() as conn:
|
||||||
|
conn.executemany('UPDATE outages SET root_cause=?, evidence=? WHERE id=?', results)
|
||||||
|
data_changed()
|
||||||
|
return len(results)
|
||||||
|
|
||||||
|
|
||||||
|
# ================================================================ 6. 指标核算
|
||||||
|
def full_frame():
|
||||||
|
"""
|
||||||
|
全部退服流水 + 站点信息 + 场景阈值,并计算派生字段:
|
||||||
|
is_long 是否超长、dur_diff 上报时长差错、affected_users 受影响用户、loss_gb 业务损失、level 断站分级。
|
||||||
|
结果缓存到数据变化为止(见 data_changed)。
|
||||||
|
"""
|
||||||
|
global _frame_cache
|
||||||
|
if _frame_cache is not None:
|
||||||
|
return _frame_cache
|
||||||
|
|
||||||
|
with db() as conn:
|
||||||
|
df = pd.read_sql('SELECT o.*, s.site_name, s.district AS region, s.scene, s.site_type, s.vendor, s.cells, '
|
||||||
|
'c.long_min, c.freq_count, c.users_per_cell, c.gb_per_cell_h FROM outages o '
|
||||||
|
'LEFT JOIN sites s ON o.ne_id = s.ne_id LEFT JOIN scenes c ON s.scene = c.scene', conn)
|
||||||
|
|
||||||
|
df['site_name'] = df['site_name'].fillna(df['ne_id']) # 站点库里没有的站,用站号代替站名
|
||||||
|
df['start'] = pd.to_datetime(df['start_time'])
|
||||||
|
df['month'] = df['start_time'].str[:7]
|
||||||
|
|
||||||
|
long_min = df['long_min'].fillna(120)
|
||||||
|
df['is_long'] = df['duration_min'] >= long_min
|
||||||
|
df['dur_diff'] = (df['reported_min'] - df['duration_min']).abs() > 1 # 人工上报时长与系统计算相差超过 1 分钟
|
||||||
|
|
||||||
|
# 影响评估:受影响用户 = 小区数 × 单小区在线用户 × 忙闲时系数;业务损失 = 小区数 × 单小区话务 × 系数 × 时长
|
||||||
|
busy_factor = np.where(df['start'].dt.hour.between(9, 22), 1.0, 0.35) # 9-22 点为忙时
|
||||||
|
cells = df['cells'].fillna(3).astype(float)
|
||||||
|
df['affected_users'] = (cells * df['users_per_cell'].fillna(200) * busy_factor).round().astype(int)
|
||||||
|
df['loss_gb'] = (cells * df['gb_per_cell_h'].fillna(10) * busy_factor * df['duration_min'] / 60).round(2)
|
||||||
|
|
||||||
|
# 断站分级(按整列一次计算,比逐行判断快几十倍):
|
||||||
|
# 重要:超长,且是关键场景或时长超过阈值 2 倍
|
||||||
|
# 主要:超长;或关键场景下退服 ≥ 30 分钟
|
||||||
|
# 次要:其余
|
||||||
|
key_scene = df['scene'].isin(KEY_SCENES)
|
||||||
|
is_important = df['is_long'] & (key_scene | (df['duration_min'] >= 2 * long_min))
|
||||||
|
is_major = df['is_long'] | (key_scene & (df['duration_min'] >= 30))
|
||||||
|
df['level'] = np.select([is_important, is_major], ['重要', '主要'], default='次要')
|
||||||
|
|
||||||
|
_frame_cache = df
|
||||||
|
return df
|
||||||
|
|
||||||
|
|
||||||
|
def frame(filters=None):
|
||||||
|
"""按筛选条件(字典)取退服明细。返回独立副本,调用方可以随意修改而不影响缓存。"""
|
||||||
|
filters = filters or {}
|
||||||
|
df = full_frame()
|
||||||
|
|
||||||
|
for column in ('scene', 'region', 'site_type', 'vendor', 'root_cause', 'status', 'cause_category'):
|
||||||
|
if filters.get(column):
|
||||||
|
df = df[df[column] == filters[column]]
|
||||||
|
|
||||||
|
keyword = filters.get('site')
|
||||||
|
if keyword:
|
||||||
|
name_hit = df['site_name'].str.contains(keyword, regex=False)
|
||||||
|
id_hit = df['ne_id'].str.contains(keyword, regex=False)
|
||||||
|
df = df[name_hit | id_hit]
|
||||||
|
|
||||||
|
if filters.get('month'):
|
||||||
|
df = df[df['month'] == filters['month']]
|
||||||
|
if filters.get('date_from'):
|
||||||
|
df = df[df['start_time'] >= filters['date_from']]
|
||||||
|
if filters.get('date_to'):
|
||||||
|
df = df[df['start_time'] <= filters['date_to'] + ' 23:59:59']
|
||||||
|
return df.copy()
|
||||||
|
|
||||||
|
|
||||||
|
def site_count(filters=None):
|
||||||
|
"""满足站点类筛选条件(场景、片区、站型、厂家)的站点数,用作退服率的分母。"""
|
||||||
|
filters = filters or {}
|
||||||
|
column_of = {'scene': 'scene', 'region': 'district', 'site_type': 'site_type', 'vendor': 'vendor'}
|
||||||
|
conditions = []
|
||||||
|
args = []
|
||||||
|
for key, column in column_of.items():
|
||||||
|
if filters.get(key):
|
||||||
|
conditions.append(f'{column} = ?')
|
||||||
|
args.append(filters[key])
|
||||||
|
|
||||||
|
sql = 'SELECT COUNT(*) AS n FROM sites'
|
||||||
|
if conditions:
|
||||||
|
sql += ' WHERE ' + ' AND '.join(conditions)
|
||||||
|
return query(sql, args)[0]['n']
|
||||||
|
|
||||||
|
|
||||||
|
def kpis(df, n_sites=None):
|
||||||
|
"""
|
||||||
|
运维考核指标。
|
||||||
|
退服率 = 总退服时长 ÷(站点数 × 统计时长);网络可用率 = 1 − 退服率
|
||||||
|
根因判定准确率 = 上报原因与系统判定一致的比例(只统计上报原因已填写的记录)
|
||||||
|
"""
|
||||||
|
if not n_sites:
|
||||||
|
n_sites = site_count()
|
||||||
|
if df.empty:
|
||||||
|
return dict(count=0, total_h=0, avg_min=0, outage_rate=0, availability=100, long_ratio=0, repeat_rate=0,
|
||||||
|
users=0, loss_gb=0, sites=n_sites, acc=0, dur_fix=0, closed=0)
|
||||||
|
|
||||||
|
total_minutes = df['duration_min'].sum()
|
||||||
|
period_minutes = max((df['start'].max() - df['start'].min()).total_seconds() / 60, 1)
|
||||||
|
outage_rate = total_minutes / (n_sites * period_minutes) * 100
|
||||||
|
|
||||||
|
stats = site_stats(df)
|
||||||
|
|
||||||
|
known = df[df['cause_category'].isin(CAUSES) & df['root_cause'].notna()]
|
||||||
|
if len(known):
|
||||||
|
accuracy = round((known['cause_category'] == known['root_cause']).mean() * 100, 2)
|
||||||
|
else:
|
||||||
|
accuracy = 0
|
||||||
|
|
||||||
|
return dict(
|
||||||
|
count=len(df),
|
||||||
|
total_h=round(total_minutes / 60, 1),
|
||||||
|
avg_min=round(df['duration_min'].mean(), 1),
|
||||||
|
outage_rate=round(outage_rate, 4),
|
||||||
|
availability=round(100 - outage_rate, 4),
|
||||||
|
long_ratio=round(df['is_long'].mean() * 100, 2),
|
||||||
|
repeat_rate=round(stats['repeat'].mean() * 100, 2),
|
||||||
|
users=int(df['affected_users'].sum()),
|
||||||
|
loss_gb=round(df['loss_gb'].sum(), 1),
|
||||||
|
sites=n_sites,
|
||||||
|
acc=accuracy,
|
||||||
|
dur_fix=int(df['dur_diff'].sum()),
|
||||||
|
closed=round((df['status'] == '已闭环').mean() * 100, 2),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def site_stats(df):
|
||||||
|
"""
|
||||||
|
站点维度统计,按累计退服时长从大到小排序。
|
||||||
|
超长退服站点 long:月均超长退服 ≥ 1 次
|
||||||
|
高频重复站点 repeat:月均退服次数 ≥ 场景次数阈值
|
||||||
|
"""
|
||||||
|
if df.empty:
|
||||||
|
return pd.DataFrame(columns=['site_name', 'count', 'total_min', 'long', 'repeat'])
|
||||||
|
|
||||||
|
stats = df.groupby(['ne_id', 'site_name', 'region', 'scene', 'site_type'], dropna=False).agg(
|
||||||
|
count=('id', 'size'), total_min=('duration_min', 'sum'), avg_min=('duration_min', 'mean'),
|
||||||
|
max_min=('duration_min', 'max'), long_count=('is_long', 'sum'), users=('affected_users', 'sum'),
|
||||||
|
long_min=('long_min', 'first'), freq_count=('freq_count', 'first'),
|
||||||
|
).reset_index()
|
||||||
|
|
||||||
|
# 主要根因:每站出现次数最多的根因;次数相同时取名称排序靠前的(与 pandas 的 mode 结果一致)
|
||||||
|
cause_counts = df.groupby(['ne_id', 'root_cause']).size().rename('n').reset_index()
|
||||||
|
cause_counts = cause_counts.sort_values(['ne_id', 'n', 'root_cause'], ascending=[True, False, True])
|
||||||
|
top_cause = cause_counts.drop_duplicates('ne_id').set_index('ne_id')['root_cause']
|
||||||
|
stats['top_cause'] = stats['ne_id'].map(top_cause).fillna('')
|
||||||
|
|
||||||
|
months = max(df['month'].nunique(), 1)
|
||||||
|
stats['long'] = stats['long_count'] / months >= 1
|
||||||
|
stats['repeat'] = stats['count'] / months >= stats['freq_count'].fillna(4)
|
||||||
|
stats['total_min'] = stats['total_min'].round(1)
|
||||||
|
stats['avg_min'] = stats['avg_min'].round(1)
|
||||||
|
return stats.sort_values('total_min', ascending=False)
|
||||||
|
|
||||||
|
|
||||||
|
def advice(cause, level):
|
||||||
|
"""处置建议文本:响应时限(按断站分级)+ 该根因的三条处置措施。"""
|
||||||
|
measures = ADVICE.get(cause or '其他', ADVICE['其他'])
|
||||||
|
return f"【{LEVEL_TIP.get(level, '')}】" + ';'.join(measures)
|
||||||
+18936
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
+186
@@ -0,0 +1,186 @@
|
|||||||
|
ne_id,site_name,district,scene,site_type,vendor,cells,lng,lat
|
||||||
|
gNodeB-44155,青秀万象城-室分01,青秀区,商圈,室分,厂家A,6,108.410848,22.823974
|
||||||
|
gNodeB-18366,青秀万象城-皮站02,青秀区,商圈,分布式皮基站,厂家A,6,108.409408,22.824675
|
||||||
|
gNodeB-84155,青秀万象城-皮站03,青秀区,商圈,分布式皮基站,厂家A,2,108.410036,22.829578
|
||||||
|
gNodeB-90653,青秀万象城-皮站04,青秀区,商圈,分布式皮基站,厂家A,6,108.415614,22.825259
|
||||||
|
gNodeB-42942,青秀万象城-室分05,青秀区,商圈,室分,厂家A,4,108.405226,22.831949
|
||||||
|
gNodeB-74810,青秀万象城-室分06,青秀区,商圈,室分,厂家A,1,108.410569,22.826243
|
||||||
|
gNodeB-54185,青秀航洋国际-宏站01,青秀区,商圈,宏站,厂家B,3,108.378711,22.829434
|
||||||
|
gNodeB-23073,青秀航洋国际-宏站02,青秀区,商圈,宏站,厂家B,3,108.376298,22.838061
|
||||||
|
gNodeB-70545,青秀航洋国际-室分03,青秀区,商圈,室分,厂家B,6,108.370506,22.83047
|
||||||
|
gNodeB-15969,青秀航洋国际-宏站04,青秀区,商圈,宏站,厂家B,3,108.373833,22.828763
|
||||||
|
gNodeB-66085,青秀航洋国际-宏站05,青秀区,商圈,宏站,厂家B,3,108.373684,22.837445
|
||||||
|
gNodeB-29316,青秀航洋国际-皮站06,青秀区,商圈,分布式皮基站,厂家B,4,108.375984,22.835153
|
||||||
|
gNodeB-59007,青秀东盟商务区-皮站01,青秀区,商圈,分布式皮基站,厂家B,1,108.383373,22.7899
|
||||||
|
gNodeB-11152,青秀东盟商务区-皮站02,青秀区,商圈,分布式皮基站,厂家B,6,108.384918,22.794776
|
||||||
|
gNodeB-62225,青秀东盟商务区-室分03,青秀区,商圈,室分,厂家B,2,108.390349,22.788282
|
||||||
|
gNodeB-31851,青秀东盟商务区-宏站04,青秀区,商圈,宏站,厂家B,3,108.38456,22.787621
|
||||||
|
gNodeB-14413,青秀东盟商务区-皮站05,青秀区,商圈,分布式皮基站,厂家B,6,108.384132,22.790708
|
||||||
|
gNodeB-78185,青秀东盟商务区-宏站06,青秀区,商圈,宏站,厂家B,3,108.386987,22.791594
|
||||||
|
gNodeB-49647,兴宁朝阳广场-宏站01,兴宁区,商圈,宏站,厂家A,3,108.401744,22.868533
|
||||||
|
gNodeB-58331,兴宁朝阳广场-室分02,兴宁区,商圈,室分,厂家A,6,108.403183,22.875081
|
||||||
|
gNodeB-54367,兴宁朝阳广场-皮站03,兴宁区,商圈,分布式皮基站,厂家A,6,108.391601,22.870677
|
||||||
|
gNodeB-49282,兴宁朝阳广场-室分04,兴宁区,商圈,室分,厂家A,1,108.393125,22.872733
|
||||||
|
gNodeB-20254,兴宁朝阳广场-室分05,兴宁区,商圈,室分,厂家A,4,108.394708,22.87396
|
||||||
|
gNodeB-28449,兴宁朝阳广场-皮站06,兴宁区,商圈,分布式皮基站,厂家A,1,108.391705,22.865717
|
||||||
|
gNodeB-76464,兴宁三街两巷-宏站01,兴宁区,商圈,宏站,厂家C,3,108.350686,22.837855
|
||||||
|
gNodeB-96115,兴宁三街两巷-室分02,兴宁区,商圈,室分,厂家C,4,108.350623,22.837892
|
||||||
|
gNodeB-12607,兴宁三街两巷-宏站03,兴宁区,商圈,宏站,厂家C,3,108.355271,22.835528
|
||||||
|
gNodeB-62791,兴宁三街两巷-室分04,兴宁区,商圈,室分,厂家C,2,108.355108,22.835928
|
||||||
|
gNodeB-39823,兴宁三街两巷-皮站05,兴宁区,商圈,分布式皮基站,厂家C,2,108.348046,22.838435
|
||||||
|
gNodeB-93713,兴宁三街两巷-宏站06,兴宁区,商圈,宏站,厂家C,3,108.344717,22.835942
|
||||||
|
gNodeB-77288,江南沙井万达-宏站01,江南区,商圈,宏站,厂家B,3,108.302632,22.781843
|
||||||
|
gNodeB-84687,江南沙井万达-宏站02,江南区,商圈,宏站,厂家B,3,108.300552,22.782599
|
||||||
|
gNodeB-98791,江南沙井万达-室分03,江南区,商圈,室分,厂家B,2,108.307029,22.781805
|
||||||
|
gNodeB-96997,江南沙井万达-宏站04,江南区,商圈,宏站,厂家B,3,108.299266,22.783835
|
||||||
|
gNodeB-70407,江南沙井万达-室分05,江南区,商圈,室分,厂家B,2,108.30072,22.783449
|
||||||
|
gNodeB-38627,江南沙井万达-皮站06,江南区,商圈,分布式皮基站,厂家B,1,108.304257,22.781289
|
||||||
|
gNodeB-75089,西乡塘西大商圈-宏站01,西乡塘区,商圈,宏站,厂家C,3,108.331948,22.812949
|
||||||
|
gNodeB-82200,西乡塘西大商圈-宏站02,西乡塘区,商圈,宏站,厂家C,3,108.332237,22.814374
|
||||||
|
gNodeB-87165,西乡塘西大商圈-宏站03,西乡塘区,商圈,宏站,厂家C,3,108.328829,22.820628
|
||||||
|
gNodeB-89128,西乡塘西大商圈-宏站04,西乡塘区,商圈,宏站,厂家C,3,108.327461,22.81741
|
||||||
|
gNodeB-80893,西乡塘西大商圈-室分05,西乡塘区,商圈,室分,厂家C,4,108.329279,22.813983
|
||||||
|
gNodeB-87611,西乡塘西大商圈-室分06,西乡塘区,商圈,室分,厂家C,2,108.332814,22.819473
|
||||||
|
gNodeB-71133,良庆五象万达-皮站01,良庆区,商圈,分布式皮基站,厂家C,6,108.41461,22.760461
|
||||||
|
gNodeB-32022,良庆五象万达-室分02,良庆区,商圈,室分,厂家C,6,108.414842,22.764066
|
||||||
|
gNodeB-61305,良庆五象万达-宏站03,良庆区,商圈,宏站,厂家C,3,108.410671,22.761886
|
||||||
|
gNodeB-48417,良庆五象万达-室分04,良庆区,商圈,室分,厂家C,1,108.410635,22.758907
|
||||||
|
gNodeB-13317,良庆五象万达-室分05,良庆区,商圈,室分,厂家C,6,108.411663,22.761246
|
||||||
|
gNodeB-20547,良庆五象万达-室分06,良庆区,商圈,室分,厂家C,1,108.407245,22.766092
|
||||||
|
gNodeB-80877,西乡塘广西大学-宏站01,西乡塘区,高校,宏站,厂家A,3,108.290483,22.835316
|
||||||
|
gNodeB-12641,西乡塘广西大学-皮站02,西乡塘区,高校,分布式皮基站,厂家A,1,108.279949,22.832094
|
||||||
|
gNodeB-98078,西乡塘广西大学-宏站03,西乡塘区,高校,宏站,厂家A,3,108.288911,22.826849
|
||||||
|
gNodeB-59466,西乡塘广西大学-室分04,西乡塘区,高校,室分,厂家A,2,108.289943,22.833188
|
||||||
|
gNodeB-52040,西乡塘广西大学-宏站05,西乡塘区,高校,宏站,厂家A,3,108.290548,22.833641
|
||||||
|
gNodeB-83811,西乡塘广西大学-宏站06,西乡塘区,高校,宏站,厂家A,3,108.283487,22.827352
|
||||||
|
gNodeB-16657,西乡塘广西民族大学-宏站01,西乡塘区,高校,宏站,厂家B,3,108.306497,22.851535
|
||||||
|
gNodeB-47091,西乡塘广西民族大学-宏站02,西乡塘区,高校,宏站,厂家B,3,108.296637,22.849463
|
||||||
|
gNodeB-18301,西乡塘广西民族大学-宏站03,西乡塘区,高校,宏站,厂家B,3,108.295084,22.854536
|
||||||
|
gNodeB-73273,西乡塘广西民族大学-室分04,西乡塘区,高校,室分,厂家B,2,108.301582,22.855841
|
||||||
|
gNodeB-59829,西乡塘广西民族大学-室分05,西乡塘区,高校,室分,厂家B,2,108.298405,22.848783
|
||||||
|
gNodeB-32171,西乡塘广西民族大学-宏站06,西乡塘区,高校,宏站,厂家B,3,108.306161,22.855432
|
||||||
|
gNodeB-92464,青秀广西医科大学-皮站01,青秀区,高校,分布式皮基站,厂家C,2,108.360691,22.83391
|
||||||
|
gNodeB-59543,青秀广西医科大学-室分02,青秀区,高校,室分,厂家C,1,108.363705,22.834596
|
||||||
|
gNodeB-69673,青秀广西医科大学-宏站03,青秀区,高校,宏站,厂家C,3,108.359872,22.835012
|
||||||
|
gNodeB-81277,青秀广西医科大学-室分04,青秀区,高校,室分,厂家C,6,108.364975,22.837178
|
||||||
|
gNodeB-37638,青秀广西医科大学-宏站05,青秀区,高校,宏站,厂家C,3,108.367119,22.839559
|
||||||
|
gNodeB-36137,青秀广西医科大学-室分06,青秀区,高校,室分,厂家C,4,108.364453,22.839938
|
||||||
|
gNodeB-15799,西乡塘南宁师范大学-皮站01,西乡塘区,高校,分布式皮基站,厂家A,1,108.311167,22.814345
|
||||||
|
gNodeB-15948,西乡塘南宁师范大学-室分02,西乡塘区,高校,室分,厂家A,2,108.309624,22.818693
|
||||||
|
gNodeB-46455,西乡塘南宁师范大学-室分03,西乡塘区,高校,室分,厂家A,4,108.311819,22.816711
|
||||||
|
gNodeB-17311,西乡塘南宁师范大学-室分04,西乡塘区,高校,室分,厂家A,6,108.310642,22.819171
|
||||||
|
gNodeB-88660,西乡塘南宁师范大学-室分05,西乡塘区,高校,室分,厂家A,1,108.317148,22.813893
|
||||||
|
gNodeB-18904,西乡塘南宁师范大学-宏站06,西乡塘区,高校,宏站,厂家A,3,108.316265,22.821106
|
||||||
|
gNodeB-65771,邕宁南宁学院-室分01,邕宁区,高校,室分,厂家B,4,108.476018,22.765737
|
||||||
|
gNodeB-30680,邕宁南宁学院-室分02,邕宁区,高校,室分,厂家B,4,108.48078,22.762903
|
||||||
|
gNodeB-94891,邕宁南宁学院-室分03,邕宁区,高校,室分,厂家B,6,108.476262,22.762751
|
||||||
|
gNodeB-69620,邕宁南宁学院-室分04,邕宁区,高校,室分,厂家B,6,108.475093,22.767735
|
||||||
|
gNodeB-60854,邕宁南宁学院-室分05,邕宁区,高校,室分,厂家B,4,108.482903,22.767621
|
||||||
|
gNodeB-24431,邕宁南宁学院-宏站06,邕宁区,高校,宏站,厂家B,3,108.478681,22.769025
|
||||||
|
gNodeB-17805,武鸣武鸣大学城-宏站01,武鸣区,高校,宏站,厂家B,3,108.292176,23.142877
|
||||||
|
gNodeB-67766,武鸣武鸣大学城-皮站02,武鸣区,高校,分布式皮基站,厂家B,2,108.286839,23.141706
|
||||||
|
gNodeB-97715,武鸣武鸣大学城-皮站03,武鸣区,高校,分布式皮基站,厂家B,4,108.289506,23.145378
|
||||||
|
gNodeB-65466,武鸣武鸣大学城-宏站04,武鸣区,高校,宏站,厂家B,3,108.290079,23.14065
|
||||||
|
gNodeB-79348,武鸣武鸣大学城-宏站05,武鸣区,高校,宏站,厂家B,3,108.29359,23.139189
|
||||||
|
gNodeB-33646,武鸣武鸣大学城-皮站06,武鸣区,高校,分布式皮基站,厂家B,2,108.286783,23.142818
|
||||||
|
gNodeB-59494,青秀南宁东站-皮站01,青秀区,交通枢纽,分布式皮基站,厂家A,4,108.364146,22.809888
|
||||||
|
gNodeB-93642,青秀南宁东站-室分02,青秀区,交通枢纽,室分,厂家A,6,108.359453,22.807253
|
||||||
|
gNodeB-23234,青秀南宁东站-宏站03,青秀区,交通枢纽,宏站,厂家A,3,108.364485,22.809154
|
||||||
|
gNodeB-92231,青秀南宁东站-皮站04,青秀区,交通枢纽,分布式皮基站,厂家A,1,108.362401,22.810573
|
||||||
|
gNodeB-63174,青秀南宁东站-宏站05,青秀区,交通枢纽,宏站,厂家A,3,108.366609,22.805118
|
||||||
|
gNodeB-23584,青秀南宁东站-宏站06,青秀区,交通枢纽,宏站,厂家A,3,108.367499,22.804662
|
||||||
|
gNodeB-65616,西乡塘南宁火车站-皮站01,西乡塘区,交通枢纽,分布式皮基站,厂家B,6,108.301467,22.831584
|
||||||
|
gNodeB-77580,西乡塘南宁火车站-室分02,西乡塘区,交通枢纽,室分,厂家B,6,108.30861,22.832811
|
||||||
|
gNodeB-76164,西乡塘南宁火车站-室分03,西乡塘区,交通枢纽,室分,厂家B,4,108.305228,22.829483
|
||||||
|
gNodeB-24657,西乡塘南宁火车站-室分04,西乡塘区,交通枢纽,室分,厂家B,6,108.303102,22.828794
|
||||||
|
gNodeB-28273,西乡塘南宁火车站-宏站05,西乡塘区,交通枢纽,宏站,厂家B,3,108.308732,22.833989
|
||||||
|
gNodeB-47203,西乡塘南宁火车站-皮站06,西乡塘区,交通枢纽,分布式皮基站,厂家B,1,108.30309,22.831337
|
||||||
|
gNodeB-41327,江南吴圩国际机场-宏站01,江南区,交通枢纽,宏站,厂家A,3,108.293675,22.79716
|
||||||
|
gNodeB-32721,江南吴圩国际机场-宏站02,江南区,交通枢纽,宏站,厂家A,3,108.297075,22.794045
|
||||||
|
gNodeB-81221,江南吴圩国际机场-宏站03,江南区,交通枢纽,宏站,厂家A,3,108.294283,22.791246
|
||||||
|
gNodeB-27507,江南吴圩国际机场-皮站04,江南区,交通枢纽,分布式皮基站,厂家A,2,108.299158,22.797503
|
||||||
|
gNodeB-86609,江南吴圩国际机场-皮站05,江南区,交通枢纽,分布式皮基站,厂家A,6,108.296548,22.79033
|
||||||
|
gNodeB-17785,江南吴圩国际机场-宏站06,江南区,交通枢纽,宏站,厂家A,3,108.289049,22.793266
|
||||||
|
gNodeB-79693,江南江南客运站-宏站01,江南区,交通枢纽,宏站,厂家C,3,108.287228,22.777837
|
||||||
|
gNodeB-43971,江南江南客运站-室分02,江南区,交通枢纽,室分,厂家C,6,108.282658,22.778758
|
||||||
|
gNodeB-68667,江南江南客运站-宏站03,江南区,交通枢纽,宏站,厂家C,3,108.281646,22.775948
|
||||||
|
gNodeB-60959,江南江南客运站-室分04,江南区,交通枢纽,室分,厂家C,2,108.278693,22.775232
|
||||||
|
gNodeB-34952,江南江南客运站-皮站05,江南区,交通枢纽,分布式皮基站,厂家C,2,108.280659,22.777455
|
||||||
|
gNodeB-38481,江南江南客运站-室分06,江南区,交通枢纽,室分,厂家C,4,108.277067,22.776338
|
||||||
|
gNodeB-43602,青秀埌东客运站-室分01,青秀区,交通枢纽,室分,厂家B,1,108.358842,22.825241
|
||||||
|
gNodeB-38730,青秀埌东客运站-室分02,青秀区,交通枢纽,室分,厂家B,4,108.358128,22.823618
|
||||||
|
gNodeB-81197,青秀埌东客运站-皮站03,青秀区,交通枢纽,分布式皮基站,厂家B,2,108.361934,22.830783
|
||||||
|
gNodeB-57294,青秀埌东客运站-室分04,青秀区,交通枢纽,室分,厂家B,2,108.358708,22.830665
|
||||||
|
gNodeB-19244,青秀埌东客运站-宏站05,青秀区,交通枢纽,宏站,厂家B,3,108.364662,22.832098
|
||||||
|
gNodeB-15797,青秀埌东客运站-宏站06,青秀区,交通枢纽,宏站,厂家B,3,108.363937,22.829927
|
||||||
|
gNodeB-22147,西乡塘安吉客运站-宏站01,西乡塘区,交通枢纽,宏站,厂家C,3,108.332736,22.80983
|
||||||
|
gNodeB-31928,西乡塘安吉客运站-皮站02,西乡塘区,交通枢纽,分布式皮基站,厂家C,1,108.336062,22.813715
|
||||||
|
gNodeB-57693,西乡塘安吉客运站-室分03,西乡塘区,交通枢纽,室分,厂家C,4,108.327558,22.811399
|
||||||
|
gNodeB-26188,西乡塘安吉客运站-皮站04,西乡塘区,交通枢纽,分布式皮基站,厂家C,4,108.334747,22.814243
|
||||||
|
gNodeB-48276,西乡塘安吉客运站-宏站05,西乡塘区,交通枢纽,宏站,厂家C,3,108.33537,22.814093
|
||||||
|
gNodeB-42277,西乡塘安吉客运站-室分06,西乡塘区,交通枢纽,室分,厂家C,6,108.332526,22.813992
|
||||||
|
gNodeB-12074,江南沙井村-室分01,江南区,城中村,室分,厂家A,1,108.268215,22.769434
|
||||||
|
gNodeB-46264,江南沙井村-宏站02,江南区,城中村,宏站,厂家A,3,108.264642,22.772647
|
||||||
|
gNodeB-39706,江南沙井村-宏站03,江南区,城中村,宏站,厂家A,3,108.265462,22.774369
|
||||||
|
gNodeB-96385,江南沙井村-宏站04,江南区,城中村,宏站,厂家A,3,108.272032,22.778704
|
||||||
|
gNodeB-77468,江南沙井村-宏站05,江南区,城中村,宏站,厂家A,3,108.273942,22.772539
|
||||||
|
gNodeB-61046,西乡塘秀厢村-宏站01,西乡塘区,城中村,宏站,厂家B,3,108.324205,22.813987
|
||||||
|
gNodeB-57580,西乡塘秀厢村-宏站02,西乡塘区,城中村,宏站,厂家B,3,108.326471,22.807369
|
||||||
|
gNodeB-59690,西乡塘秀厢村-宏站03,西乡塘区,城中村,宏站,厂家B,3,108.32748,22.809082
|
||||||
|
gNodeB-95734,西乡塘秀厢村-宏站04,西乡塘区,城中村,宏站,厂家B,3,108.318962,22.806991
|
||||||
|
gNodeB-10571,西乡塘秀厢村-宏站05,西乡塘区,城中村,宏站,厂家B,3,108.32851,22.810851
|
||||||
|
gNodeB-71314,西乡塘石埠-宏站01,西乡塘区,城中村,宏站,厂家B,3,108.316459,22.861925
|
||||||
|
gNodeB-29827,西乡塘石埠-宏站02,西乡塘区,城中村,宏站,厂家B,3,108.315927,22.856098
|
||||||
|
gNodeB-42374,西乡塘石埠-宏站03,西乡塘区,城中村,宏站,厂家B,3,108.309681,22.854398
|
||||||
|
gNodeB-89707,西乡塘石埠-宏站04,西乡塘区,城中村,宏站,厂家B,3,108.309218,22.861294
|
||||||
|
gNodeB-21353,西乡塘石埠-宏站05,西乡塘区,城中村,宏站,厂家B,3,108.31252,22.858164
|
||||||
|
gNodeB-67869,兴宁三塘-宏站01,兴宁区,城中村,宏站,厂家A,3,108.361275,22.879129
|
||||||
|
gNodeB-81811,兴宁三塘-宏站02,兴宁区,城中村,宏站,厂家A,3,108.362864,22.87701
|
||||||
|
gNodeB-47264,兴宁三塘-宏站03,兴宁区,城中村,宏站,厂家A,3,108.362329,22.87193
|
||||||
|
gNodeB-11969,兴宁三塘-宏站04,兴宁区,城中村,宏站,厂家A,3,108.360972,22.873772
|
||||||
|
gNodeB-99722,兴宁三塘-宏站05,兴宁区,城中村,宏站,厂家A,3,108.364975,22.874966
|
||||||
|
gNodeB-26175,良庆大沙田-宏站01,良庆区,城中村,宏站,厂家C,3,108.36864,22.730658
|
||||||
|
gNodeB-76744,良庆大沙田-宏站02,良庆区,城中村,宏站,厂家C,3,108.366373,22.729006
|
||||||
|
gNodeB-48767,良庆大沙田-宏站03,良庆区,城中村,宏站,厂家C,3,108.363126,22.732649
|
||||||
|
gNodeB-79195,良庆大沙田-宏站04,良庆区,城中村,宏站,厂家C,3,108.367701,22.732657
|
||||||
|
gNodeB-39224,良庆大沙田-宏站05,良庆区,城中村,宏站,厂家C,3,108.365096,22.730442
|
||||||
|
gNodeB-62049,邕宁蒲庙-宏站01,邕宁区,城中村,宏站,厂家B,3,108.496859,22.758585
|
||||||
|
gNodeB-22093,邕宁蒲庙-宏站02,邕宁区,城中村,宏站,厂家B,3,108.499163,22.758882
|
||||||
|
gNodeB-84060,邕宁蒲庙-宏站03,邕宁区,城中村,宏站,厂家B,3,108.492383,22.760795
|
||||||
|
gNodeB-90576,邕宁蒲庙-宏站04,邕宁区,城中村,宏站,厂家B,3,108.494803,22.759126
|
||||||
|
gNodeB-43369,邕宁蒲庙-宏站05,邕宁区,城中村,宏站,厂家B,3,108.497016,22.751948
|
||||||
|
gNodeB-88777,武鸣城厢-宏站01,武鸣区,城中村,宏站,厂家A,3,108.243755,23.165412
|
||||||
|
gNodeB-57991,武鸣城厢-宏站02,武鸣区,城中村,宏站,厂家A,3,108.241447,23.169172
|
||||||
|
gNodeB-14773,武鸣城厢-宏站03,武鸣区,城中村,宏站,厂家A,3,108.242153,23.164484
|
||||||
|
gNodeB-78253,武鸣城厢-宏站04,武鸣区,城中村,宏站,厂家A,3,108.242587,23.173204
|
||||||
|
gNodeB-66299,武鸣城厢-宏站05,武鸣区,城中村,宏站,厂家A,3,108.243158,23.170387
|
||||||
|
gNodeB-78661,青秀长塘-宏站01,青秀区,城中村,宏站,厂家B,3,108.372575,22.805397
|
||||||
|
gNodeB-65618,青秀长塘-宏站02,青秀区,城中村,宏站,厂家B,3,108.375939,22.805923
|
||||||
|
gNodeB-20334,青秀长塘-宏站03,青秀区,城中村,宏站,厂家B,3,108.365665,22.809011
|
||||||
|
gNodeB-61987,青秀长塘-宏站04,青秀区,城中村,宏站,厂家B,3,108.375409,22.811091
|
||||||
|
gNodeB-79707,青秀长塘-宏站05,青秀区,城中村,宏站,厂家B,3,108.369121,22.810103
|
||||||
|
gNodeB-40732,西乡塘高新区-宏站01,西乡塘区,工业园区,宏站,厂家B,3,108.297469,22.820547
|
||||||
|
gNodeB-18441,西乡塘高新区-宏站02,西乡塘区,工业园区,宏站,厂家B,3,108.297983,22.814854
|
||||||
|
gNodeB-15374,西乡塘高新区-宏站03,西乡塘区,工业园区,宏站,厂家B,3,108.289857,22.814524
|
||||||
|
gNodeB-43937,西乡塘高新区-宏站04,西乡塘区,工业园区,宏站,厂家B,3,108.296339,22.820346
|
||||||
|
gNodeB-17078,西乡塘高新区-宏站05,西乡塘区,工业园区,宏站,厂家B,3,108.293727,22.814211
|
||||||
|
gNodeB-86694,江南经开区-宏站01,江南区,工业园区,宏站,厂家B,3,108.301631,22.800126
|
||||||
|
gNodeB-97285,江南经开区-宏站02,江南区,工业园区,宏站,厂家B,3,108.304788,22.801173
|
||||||
|
gNodeB-69681,江南经开区-宏站03,江南区,工业园区,宏站,厂家B,3,108.297857,22.801791
|
||||||
|
gNodeB-14151,江南经开区-宏站04,江南区,工业园区,宏站,厂家B,3,108.303415,22.808434
|
||||||
|
gNodeB-13403,江南经开区-室分05,江南区,工业园区,室分,厂家B,4,108.304138,22.805962
|
||||||
|
gNodeB-94441,武鸣东盟经开区-宏站01,武鸣区,工业园区,宏站,厂家A,3,108.28193,23.170667
|
||||||
|
gNodeB-30853,武鸣东盟经开区-宏站02,武鸣区,工业园区,宏站,厂家A,3,108.273395,23.174276
|
||||||
|
gNodeB-81266,武鸣东盟经开区-宏站03,武鸣区,工业园区,宏站,厂家A,3,108.277334,23.174016
|
||||||
|
gNodeB-59913,武鸣东盟经开区-室分04,武鸣区,工业园区,室分,厂家A,1,108.278392,23.168697
|
||||||
|
gNodeB-19556,武鸣东盟经开区-宏站05,武鸣区,工业园区,宏站,厂家A,3,108.271703,23.165866
|
||||||
|
gNodeB-17283,邕宁新兴产业园-宏站01,邕宁区,工业园区,宏站,厂家A,3,108.497134,22.75274
|
||||||
|
gNodeB-55039,邕宁新兴产业园-室分02,邕宁区,工业园区,室分,厂家A,6,108.494631,22.752366
|
||||||
|
gNodeB-68638,邕宁新兴产业园-宏站03,邕宁区,工业园区,宏站,厂家A,3,108.49589,22.75082
|
||||||
|
gNodeB-75324,邕宁新兴产业园-宏站04,邕宁区,工业园区,宏站,厂家A,3,108.496026,22.755425
|
||||||
|
gNodeB-68196,邕宁新兴产业园-室分05,邕宁区,工业园区,室分,厂家A,4,108.492959,22.752205
|
||||||
|
gNodeB-54568,良庆五象产业园-宏站01,良庆区,工业园区,宏站,厂家C,3,108.366355,22.757479
|
||||||
|
gNodeB-43433,良庆五象产业园-宏站02,良庆区,工业园区,宏站,厂家C,3,108.365669,22.753636
|
||||||
|
gNodeB-43093,良庆五象产业园-室分03,良庆区,工业园区,室分,厂家C,6,108.364324,22.755635
|
||||||
|
gNodeB-30703,良庆五象产业园-宏站04,良庆区,工业园区,宏站,厂家C,3,108.360767,22.757079
|
||||||
|
gNodeB-84197,良庆五象产业园-宏站05,良庆区,工业园区,宏站,厂家C,3,108.360836,22.762173
|
||||||
|
+279
@@ -0,0 +1,279 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
"""
|
||||||
|
第 18 题 · 基站退服数据生成器(Data-Generated-Core-Py/data.py 的改进版)
|
||||||
|
================================================================
|
||||||
|
字段口径与 data.py 完全一致:
|
||||||
|
data_outage.csv 退服记录 record_id, ne_id, cell_id, district, vendor, start_time, end_time,
|
||||||
|
duration_min, cause_category, cause_detail, cause_code, ticket_id, closed
|
||||||
|
data_alarm.csv 告警流 alarm_id, ne_id, alarm_code, alarm_name, alarm_level, category,
|
||||||
|
start_time, clear_time, duration_s, cleared, parent_alarm_id
|
||||||
|
sites.csv 站点库 ne_id, site_name, district, scene, site_type, vendor, cells, lng, lat
|
||||||
|
相对 data.py 的改进(对齐 _数据集总索引.md 第 18 题要求:站号、起止时间、原因码、厂家、片区):
|
||||||
|
1. 新增站点库:南宁 7 个城区 × 5 类通信场景 × 3 类站型,站号固定,退服可按站点汇聚;
|
||||||
|
2. 新增原因码 cause_code,编码体系参照《中兴 5G NR 基站日常故障处理指导手册》章节;
|
||||||
|
3. 退服与告警联动生成:每次退服产生“小区退服”告警及对应根因告警(含衍生关系 parent_alarm_id),
|
||||||
|
另混入背景告警与时间窗内的干扰告警,用于检验根因关联算法;
|
||||||
|
4. 约 1.5% 的上报时长存在人工计算错误,用于检验系统自动计算与核对;
|
||||||
|
5. 分布贴近现网:长尾时长(沿用 data.py 分段)、问题站点重复退服、夏季雷雨停电高发、割接集中在凌晨。
|
||||||
|
数据为合成数据,论文中须注明。仅依赖标准库,可单独运行:python data_gen.py --rows 6000
|
||||||
|
|
||||||
|
注意:固定随机种子保证每次生成的数据完全相同。修改代码时不要调整随机数的调用顺序,否则数据会变化。
|
||||||
|
"""
|
||||||
|
import argparse
|
||||||
|
import csv
|
||||||
|
import datetime
|
||||||
|
import os
|
||||||
|
import random
|
||||||
|
|
||||||
|
DISTRICTS = { # 片区 -> 中心经纬度
|
||||||
|
'青秀区': (108.385, 22.816), '兴宁区': (108.368, 22.853), '江南区': (108.273, 22.781),
|
||||||
|
'西乡塘区': (108.306, 22.836), '良庆区': (108.393, 22.752), '邕宁区': (108.487, 22.758), '武鸣区': (108.275, 23.159),
|
||||||
|
}
|
||||||
|
VENDORS = ['厂家A', '厂家B', '厂家C']
|
||||||
|
# 场景 -> [(片区, 地标)] 地标名用于生成站名,均为南宁城区真实地名
|
||||||
|
LANDMARKS = {
|
||||||
|
'商圈': [('青秀区', '万象城'), ('青秀区', '航洋国际'), ('青秀区', '东盟商务区'), ('兴宁区', '朝阳广场'),
|
||||||
|
('兴宁区', '三街两巷'), ('江南区', '沙井万达'), ('西乡塘区', '西大商圈'), ('良庆区', '五象万达')],
|
||||||
|
'高校': [('西乡塘区', '广西大学'), ('西乡塘区', '广西民族大学'), ('青秀区', '广西医科大学'),
|
||||||
|
('西乡塘区', '南宁师范大学'), ('邕宁区', '南宁学院'), ('武鸣区', '武鸣大学城')],
|
||||||
|
'交通枢纽': [('青秀区', '南宁东站'), ('西乡塘区', '南宁火车站'), ('江南区', '吴圩国际机场'),
|
||||||
|
('江南区', '江南客运站'), ('青秀区', '埌东客运站'), ('西乡塘区', '安吉客运站')],
|
||||||
|
'城中村': [('江南区', '沙井村'), ('西乡塘区', '秀厢村'), ('西乡塘区', '石埠'), ('兴宁区', '三塘'),
|
||||||
|
('良庆区', '大沙田'), ('邕宁区', '蒲庙'), ('武鸣区', '城厢'), ('青秀区', '长塘')],
|
||||||
|
'工业园区': [('西乡塘区', '高新区'), ('江南区', '经开区'), ('武鸣区', '东盟经开区'),
|
||||||
|
('邕宁区', '新兴产业园'), ('良庆区', '五象产业园')],
|
||||||
|
}
|
||||||
|
# 场景 -> (每个地标站点数, 站型权重[宏站, 室分, 分布式皮基站], 退服倾向系数)
|
||||||
|
SCENE_CFG = {
|
||||||
|
'商圈': (6, [3, 4, 3], 0.9), '高校': (6, [5, 3, 2], 0.8), '交通枢纽': (6, [4, 4, 2], 0.7),
|
||||||
|
'城中村': (5, [9, 1, 0], 1.6), '工业园区': (5, [8, 2, 0], 1.2),
|
||||||
|
}
|
||||||
|
TYPE_CODE = {'宏站': '宏站', '室分': '室分', '分布式皮基站': '皮站'} # 站型 -> 站名中的简写
|
||||||
|
|
||||||
|
# 原因大类 / 细项 / 原因码(参照中兴手册章节)—— 大类与细项沿用 data.py
|
||||||
|
CAUSES = {
|
||||||
|
'传输中断': [('光缆被挖断', 'TR01'), ('光模块损坏', 'TR02'), ('传输误码超限', 'TR03'), ('上游设备掉电', 'TR04')],
|
||||||
|
'电源故障': [('市电停电', 'PW01'), ('蓄电池失效', 'PW02'), ('开关电源模块故障', 'PW03')],
|
||||||
|
'设备硬件': [('BBU 主控板故障', 'HW01'), ('RRU 功放故障', 'HW02'), ('GPS 失锁', 'HW03'), ('单板复位', 'HW04')],
|
||||||
|
'天馈故障': [('驻波比超标', 'AN01'), ('馈线进水', 'AN02'), ('天线被破坏', 'AN03')],
|
||||||
|
'机房环境': [('空调故障', 'EN01'), ('机房高温', 'EN02'), ('漏水', 'EN03')],
|
||||||
|
'割接施工': [('计划割接', 'OP01'), ('施工误碰光缆', 'OP02'), ('设备搬迁', 'OP03')],
|
||||||
|
'其他': [('原因待查', 'OT01'), ('业主断电', 'OT02')],
|
||||||
|
}
|
||||||
|
# 各场景原因大类权重,顺序同 CAUSES(城中村停电多、园区施工多、室分为主场景机房/业主问题多)
|
||||||
|
CAUSE_W = {
|
||||||
|
'商圈': [22, 20, 18, 6, 12, 10, 12], '高校': [24, 24, 20, 8, 8, 10, 6], '交通枢纽': [26, 18, 24, 8, 8, 12, 4],
|
||||||
|
'城中村': [22, 38, 14, 10, 6, 4, 6], '工业园区': [30, 20, 14, 8, 6, 18, 4],
|
||||||
|
}
|
||||||
|
# 告警库:沿用 data.py ALARM_LIB,补充 ALM-113~116 以覆盖割接、主控板、开关电源、漏水
|
||||||
|
ALARM_LIB = {
|
||||||
|
'小区退服': ('ALM-101', '小区退服', '严重'),
|
||||||
|
'传输中断': [('ALM-102', 'BBU 链路断', '严重'), ('ALM-103', '光模块收发异常', '重要'), ('ALM-110', '传输误码超限', '次要')],
|
||||||
|
'电源故障': [('ALM-105', '市电停电', '严重'), ('ALM-106', '蓄电池欠压', '重要'), ('ALM-115', '开关电源模块故障', '重要')],
|
||||||
|
'设备硬件': [('ALM-114', 'BBU 主控板故障', '严重'), ('ALM-111', 'PRRU 离线', '重要'), ('ALM-108', 'GPS 失锁', '次要'),
|
||||||
|
('ALM-112', '时钟不同步', '次要')],
|
||||||
|
'天馈故障': [('ALM-104', 'RRU 驻波比过高', '重要'), ('ALM-109', 'VSWR 告警', '重要')],
|
||||||
|
'机房环境': [('ALM-107', '机房温度过高', '重要'), ('ALM-116', '机房水浸告警', '重要')],
|
||||||
|
'割接施工': [('ALM-113', '网元人工闭塞/复位', '次要')],
|
||||||
|
}
|
||||||
|
# 根因告警相对退服开始的提前量(分钟):停电有蓄电池后备、高温有过热保护延时;未列出的类别为 (0, 8)
|
||||||
|
LEAD = {'电源故障': (20, 240), '机房环境': (15, 150), '割接施工': (0, 20), '天馈故障': (0, 25)}
|
||||||
|
T0 = datetime.datetime(2026, 1, 1)
|
||||||
|
DAYS = 273 # 2026-01-01 ~ 2026-09-30
|
||||||
|
MONTH_W = [0.8, 0.75, 0.9, 1.0, 1.15, 1.35, 1.45, 1.4, 1.1] # 各月退服权重:夏季雷雨、高温停电高发
|
||||||
|
FMT = '%Y-%m-%d %H:%M:%S'
|
||||||
|
|
||||||
|
OUTAGE_HEAD = ['record_id', 'ne_id', 'cell_id', 'district', 'vendor', 'start_time', 'end_time', 'duration_min',
|
||||||
|
'cause_category', 'cause_detail', 'cause_code', 'ticket_id', 'closed']
|
||||||
|
ALARM_HEAD = ['alarm_id', 'ne_id', 'alarm_code', 'alarm_name', 'alarm_level', 'category', 'start_time',
|
||||||
|
'clear_time', 'duration_s', 'cleared', 'parent_alarm_id']
|
||||||
|
SITE_HEAD = ['ne_id', 'site_name', 'district', 'scene', 'site_type', 'vendor', 'cells', 'lng', 'lat']
|
||||||
|
|
||||||
|
|
||||||
|
def gen_sites(rng):
|
||||||
|
"""生成站点库:每个地标周围若干站点,同一地标同一厂家组网。"""
|
||||||
|
sites = []
|
||||||
|
used_ids = set()
|
||||||
|
for scene, marks in LANDMARKS.items():
|
||||||
|
per_mark, type_weights, _ = SCENE_CFG[scene]
|
||||||
|
for district, mark in marks:
|
||||||
|
center_lng, center_lat = DISTRICTS[district]
|
||||||
|
# 地标位置在片区中心附近随机偏移
|
||||||
|
mark_lng = center_lng + rng.uniform(-.03, .03)
|
||||||
|
mark_lat = center_lat + rng.uniform(-.025, .025)
|
||||||
|
vendor = rng.choice(VENDORS)
|
||||||
|
for k in range(per_mark):
|
||||||
|
site_type = rng.choices(list(TYPE_CODE), type_weights)[0]
|
||||||
|
|
||||||
|
number = rng.randint(10000, 99999)
|
||||||
|
while number in used_ids:
|
||||||
|
number = rng.randint(10000, 99999)
|
||||||
|
used_ids.add(number)
|
||||||
|
|
||||||
|
if site_type == '宏站':
|
||||||
|
cells = 3
|
||||||
|
else:
|
||||||
|
cells = rng.choice([1, 2, 4, 6])
|
||||||
|
lng = round(mark_lng + rng.uniform(-.006, .006), 6)
|
||||||
|
lat = round(mark_lat + rng.uniform(-.005, .005), 6)
|
||||||
|
|
||||||
|
sites.append({
|
||||||
|
'ne_id': 'gNodeB-%05d' % number,
|
||||||
|
'site_name': '%s%s-%s%02d' % (district[:-1], mark, TYPE_CODE[site_type], k + 1),
|
||||||
|
'district': district, 'scene': scene, 'site_type': site_type, 'vendor': vendor,
|
||||||
|
'cells': cells, 'lng': lng, 'lat': lat,
|
||||||
|
})
|
||||||
|
return sites
|
||||||
|
|
||||||
|
|
||||||
|
def gen_duration(rng, category):
|
||||||
|
"""退服时长(分钟),沿用 data.py 的长尾分段:多数短退服,少数超长。割接受窗口限制偏短,停电、机房类偏长。"""
|
||||||
|
factor = {'割接施工': .88, '电源故障': 1.08, '机房环境': 1.05}.get(category, 1)
|
||||||
|
r = rng.random() * factor
|
||||||
|
if r < 0.62:
|
||||||
|
return rng.randint(5, 60)
|
||||||
|
if r < 0.88:
|
||||||
|
return rng.randint(61, 360)
|
||||||
|
if r < 0.97:
|
||||||
|
return rng.randint(361, 1440)
|
||||||
|
return rng.randint(1441, 7200)
|
||||||
|
|
||||||
|
|
||||||
|
def gen_start(rng, category):
|
||||||
|
"""退服开始时间:按月份权重抽日期;割接集中在凌晨,停电/机房一半发生在午后。"""
|
||||||
|
while True:
|
||||||
|
day = rng.randrange(DAYS)
|
||||||
|
month = (T0 + datetime.timedelta(days=day)).month
|
||||||
|
if rng.random() < MONTH_W[month - 1] / max(MONTH_W):
|
||||||
|
break
|
||||||
|
if category == '割接施工':
|
||||||
|
minute = rng.randint(0, 6 * 60) # 夜间维护窗口 00:00-06:00
|
||||||
|
elif category in ('电源故障', '机房环境') and rng.random() < .5:
|
||||||
|
minute = rng.randint(12 * 60, 20 * 60) # 午后雷雨、高温
|
||||||
|
else:
|
||||||
|
minute = rng.randint(0, 24 * 60 - 1)
|
||||||
|
return T0 + datetime.timedelta(days=day, minutes=minute)
|
||||||
|
|
||||||
|
|
||||||
|
def add_alarm(rng, alarms, ne_id, category, start, end, parent=''):
|
||||||
|
"""生成一条告警追加到 alarms 列表,返回告警编号。end 为 None 表示未清除。"""
|
||||||
|
if category == '小区退服':
|
||||||
|
code, name, level = ALARM_LIB['小区退服']
|
||||||
|
else:
|
||||||
|
code, name, level = rng.choice(ALARM_LIB[category])
|
||||||
|
alarm_id = 'ALM%08d' % (len(alarms) + 1)
|
||||||
|
|
||||||
|
if end:
|
||||||
|
clear_time = end.strftime(FMT)
|
||||||
|
duration = int((end - start).total_seconds())
|
||||||
|
cleared = '是'
|
||||||
|
else:
|
||||||
|
clear_time = ''
|
||||||
|
duration = 0
|
||||||
|
cleared = '否'
|
||||||
|
|
||||||
|
alarms.append({'alarm_id': alarm_id, 'ne_id': ne_id, 'alarm_code': code, 'alarm_name': name, 'alarm_level': level,
|
||||||
|
'category': category, 'start_time': start.strftime(FMT), 'clear_time': clear_time,
|
||||||
|
'duration_s': duration, 'cleared': cleared, 'parent_alarm_id': parent})
|
||||||
|
return alarm_id
|
||||||
|
|
||||||
|
|
||||||
|
def generate(n=6000, seed=2026, out='.'):
|
||||||
|
rng = random.Random(seed + 18)
|
||||||
|
sites = gen_sites(rng)
|
||||||
|
|
||||||
|
# 站点退服倾向 = 场景系数 × 站点系数;约 12% 的站点是问题站点,系数明显更高(会被判为高频重复站点)
|
||||||
|
weights = []
|
||||||
|
for site in sites:
|
||||||
|
if rng.random() < .12:
|
||||||
|
site_factor = rng.uniform(4, 8)
|
||||||
|
else:
|
||||||
|
site_factor = rng.uniform(.5, 1.5)
|
||||||
|
weights.append(SCENE_CFG[site['scene']][2] * site_factor)
|
||||||
|
|
||||||
|
categories = list(CAUSES)
|
||||||
|
outages = []
|
||||||
|
alarms = []
|
||||||
|
|
||||||
|
for i in range(n):
|
||||||
|
site = sites[rng.choices(range(len(sites)), weights)[0]]
|
||||||
|
ne_id = site['ne_id']
|
||||||
|
category = rng.choices(categories, CAUSE_W[site['scene']])[0]
|
||||||
|
detail, code = rng.choice(CAUSES[category])
|
||||||
|
start = gen_start(rng, category)
|
||||||
|
duration = gen_duration(rng, category)
|
||||||
|
end = start + datetime.timedelta(minutes=duration)
|
||||||
|
|
||||||
|
# 约 1.5% 的流水为人工计算错误:跨天时漏算整天,或按整点取整后再差半小时
|
||||||
|
reported = duration
|
||||||
|
if rng.random() < .015:
|
||||||
|
if duration > 1440:
|
||||||
|
reported = duration % 1440
|
||||||
|
else:
|
||||||
|
reported = max(5, round(duration / 60) * 60 + rng.choice([-30, 30]))
|
||||||
|
|
||||||
|
cell_id = '460-11-%s-%02d' % (ne_id[-5:], rng.randint(1, site['cells']))
|
||||||
|
# 最近 10 天的退服大多还没闭环,更早的 93% 已闭环
|
||||||
|
is_recent = (T0 + datetime.timedelta(days=DAYS) - start).days < 10
|
||||||
|
if is_recent:
|
||||||
|
closed = rng.choice(['否', '否', '是'])
|
||||||
|
else:
|
||||||
|
closed = rng.choices(['是', '否'], [93, 7])[0]
|
||||||
|
|
||||||
|
outages.append({
|
||||||
|
'record_id': 'TF%07d' % (3000001 + i), 'ne_id': ne_id, 'cell_id': cell_id,
|
||||||
|
'district': site['district'], 'vendor': site['vendor'], 'start_time': start.strftime(FMT),
|
||||||
|
'end_time': end.strftime(FMT), 'duration_min': reported, 'cause_category': category,
|
||||||
|
'cause_detail': detail, 'cause_code': code, 'ticket_id': 'GD%06d' % (200001 + i), 'closed': closed,
|
||||||
|
})
|
||||||
|
|
||||||
|
# 联动告警:根因告警先于退服发生 -> 小区退服告警(约 65% 记录了父告警 parent_alarm_id)
|
||||||
|
root_alarm = ''
|
||||||
|
if category in ALARM_LIB:
|
||||||
|
lead_min, lead_max = LEAD.get(category, (0, 8))
|
||||||
|
alarm_start = start - datetime.timedelta(minutes=rng.randint(lead_min, lead_max))
|
||||||
|
root_alarm = add_alarm(rng, alarms, ne_id, category, alarm_start, end)
|
||||||
|
if category == '电源故障' and rng.random() < .6: # 停电导致传输设备掉电,衍生传输告警
|
||||||
|
add_alarm(rng, alarms, ne_id, '传输中断', start, end, root_alarm)
|
||||||
|
|
||||||
|
if rng.random() < .65:
|
||||||
|
parent = root_alarm
|
||||||
|
else:
|
||||||
|
parent = ''
|
||||||
|
add_alarm(rng, alarms, ne_id, '小区退服', start, end, parent)
|
||||||
|
|
||||||
|
# 约 7% 的退服前出现一条无关的干扰告警,检验算法能否按优先级排除
|
||||||
|
if rng.random() < .07:
|
||||||
|
noise_category = rng.choice(['传输中断', '设备硬件', '天馈故障', '机房环境'])
|
||||||
|
noise_start = start - datetime.timedelta(minutes=rng.randint(0, 12))
|
||||||
|
noise_end = noise_start + datetime.timedelta(minutes=rng.randint(2, 30))
|
||||||
|
add_alarm(rng, alarms, ne_id, noise_category, noise_start, noise_end)
|
||||||
|
|
||||||
|
# 背景告警:与退服无关的日常闪断告警
|
||||||
|
for _ in range(n):
|
||||||
|
site = rng.choice(sites)
|
||||||
|
category = rng.choice(['传输中断', '设备硬件', '天馈故障', '机房环境', '电源故障'])
|
||||||
|
alarm_start = T0 + datetime.timedelta(minutes=rng.randint(0, DAYS * 1440))
|
||||||
|
alarm_end = alarm_start + datetime.timedelta(minutes=rng.choice([1, 3, 8, 20, 45]))
|
||||||
|
add_alarm(rng, alarms, site['ne_id'], category, alarm_start, alarm_end)
|
||||||
|
|
||||||
|
alarms.sort(key=lambda alarm: alarm['start_time'])
|
||||||
|
|
||||||
|
os.makedirs(out, exist_ok=True)
|
||||||
|
outputs = [('sites.csv', sites, SITE_HEAD), ('data_outage.csv', outages, OUTAGE_HEAD), ('data_alarm.csv', alarms, ALARM_HEAD)]
|
||||||
|
for filename, rows, header in outputs:
|
||||||
|
with open(os.path.join(out, filename), 'w', newline='', encoding='utf-8-sig') as f:
|
||||||
|
writer = csv.DictWriter(f, fieldnames=header)
|
||||||
|
writer.writeheader()
|
||||||
|
writer.writerows(rows)
|
||||||
|
return len(sites), len(outages), len(alarms)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
parser = argparse.ArgumentParser(description='第18题基站退服数据生成器')
|
||||||
|
parser.add_argument('--rows', type=int, default=6000, help='退服记录条数,默认 6000')
|
||||||
|
parser.add_argument('--seed', type=int, default=2026)
|
||||||
|
parser.add_argument('--out', default=os.path.join(os.path.dirname(os.path.abspath(__file__)), 'data'))
|
||||||
|
args = parser.parse_args()
|
||||||
|
n_sites, n_outages, n_alarms = generate(args.rows, args.seed, args.out)
|
||||||
|
print('站点 %d 个,退服记录 %d 条,告警 %d 条 -> %s' % (n_sites, n_outages, n_alarms, args.out))
|
||||||
+426
@@ -0,0 +1,426 @@
|
|||||||
|
"""数据导入:读取上传文件 → 识别文件类型 → 逐行校验,返回合格数据与问题行,入库由 core.py 完成。
|
||||||
|
|
||||||
|
支持四种文件(上传时自动识别,不需要用户选择):
|
||||||
|
outage 退服流水(本系统模板 / data_outage.csv 口径,支持中文表头)
|
||||||
|
alarm 告警流(data_alarm.csv 口径,含 alarm_code 列)
|
||||||
|
nms_alarm 华为网管「当前告警浏览」导出 CSV(Reference-data/参数及告警检查工具)
|
||||||
|
site 5G 工参表,电信 / 移动两种格式(Reference-data/电信5G工参.xlsx、移动5G工参.xlsx)
|
||||||
|
|
||||||
|
每个 validate_xxx 函数都返回 (合格数据 DataFrame, 问题行列表),问题行格式为
|
||||||
|
{'row': 文件中的行号, 'key': 编号, 'start_time': 时间(没有则为空), 'reason': 不合格原因}。
|
||||||
|
"""
|
||||||
|
import io
|
||||||
|
|
||||||
|
import pandas as pd
|
||||||
|
|
||||||
|
from core import CAUSES, TIME_FMT, query
|
||||||
|
|
||||||
|
# 用来在文件前几行里找“表头行”的关键字:网管导出的文件在表头前有几行说明文字
|
||||||
|
HEADER_KEYWORDS = ['ne_id', 'alarm_id', 'start_time', '基站编号', '流水号', '告警ID', 'gNodeBID', 'ENBID']
|
||||||
|
|
||||||
|
|
||||||
|
# ================================================================ 1. 读取上传文件
|
||||||
|
def read_upload(raw, filename):
|
||||||
|
"""把上传文件读成 DataFrame,所有列按文本读取(避免基站编号被读成小数),自动跳过表头前的说明行。"""
|
||||||
|
name = filename.lower()
|
||||||
|
if name.endswith('.csv'):
|
||||||
|
return read_csv_text(decode(raw))
|
||||||
|
if name.endswith(('.xlsx', '.xls')):
|
||||||
|
return read_excel(raw)
|
||||||
|
raise ValueError('仅支持 Excel / CSV 文件')
|
||||||
|
|
||||||
|
|
||||||
|
def decode(raw):
|
||||||
|
"""网管导出的 CSV 多为 GBK 编码,本系统模板为 UTF-8,两种都尝试。"""
|
||||||
|
try:
|
||||||
|
return raw.decode('utf-8-sig')
|
||||||
|
except UnicodeDecodeError:
|
||||||
|
return raw.decode('gbk', errors='replace')
|
||||||
|
|
||||||
|
|
||||||
|
def read_csv_text(text):
|
||||||
|
# 网管导出文件开头有“保存时间、用户名、筛选条件”等说明,其中还有跨行的引号内容,
|
||||||
|
# 所以不能按行数跳过,而是找到表头所在行,从那一行的位置截取文本再交给 pandas。
|
||||||
|
lines = text.splitlines(keepends=True)
|
||||||
|
header_line = 0
|
||||||
|
for i, line in enumerate(lines[:50]):
|
||||||
|
if any(word in line for word in HEADER_KEYWORDS):
|
||||||
|
header_line = i
|
||||||
|
break
|
||||||
|
body = ''.join(lines[header_line:])
|
||||||
|
return pd.read_csv(io.StringIO(body), dtype=str)
|
||||||
|
|
||||||
|
|
||||||
|
def read_excel(raw):
|
||||||
|
# 先不指定表头读一遍前几十行,找到表头行,再按该行作为表头正式读取(只读第一个工作表)
|
||||||
|
preview = pd.read_excel(io.BytesIO(raw), header=None, nrows=50, dtype=str)
|
||||||
|
header_row = 0
|
||||||
|
for i in range(len(preview)):
|
||||||
|
cells = [str(v) for v in preview.iloc[i].tolist()]
|
||||||
|
if any(word in cell for cell in cells for word in HEADER_KEYWORDS):
|
||||||
|
header_row = i
|
||||||
|
break
|
||||||
|
df = pd.read_excel(io.BytesIO(raw), header=header_row, dtype=str)
|
||||||
|
df.columns = [str(c).strip() for c in df.columns]
|
||||||
|
return df
|
||||||
|
|
||||||
|
|
||||||
|
# ================================================================ 2. 识别类型并校验
|
||||||
|
def validate(df):
|
||||||
|
"""识别文件类型并调用对应的校验函数,返回 (类型, 类型说明, 合格数据, 问题行)。"""
|
||||||
|
df = df.reset_index(drop=True)
|
||||||
|
df.columns = [str(c).strip() for c in df.columns]
|
||||||
|
columns = set(df.columns)
|
||||||
|
|
||||||
|
if '告警ID' in columns and '首次发生时间(NT)' in columns:
|
||||||
|
good, errors = validate_nms_alarms(df)
|
||||||
|
return 'alarm', '告警流(华为网管导出)', good, errors
|
||||||
|
if 'alarm_code' in columns or '告警名称' in columns:
|
||||||
|
good, errors = validate_alarms(df)
|
||||||
|
return 'alarm', '告警流', good, errors
|
||||||
|
if 'gNodeBID' in columns:
|
||||||
|
good, errors = validate_sites(df, SITE_COLUMNS_TELECOM)
|
||||||
|
return 'site', '站点工参(电信格式)', good, errors
|
||||||
|
if 'ENBID' in columns:
|
||||||
|
good, errors = validate_sites(df, SITE_COLUMNS_MOBILE)
|
||||||
|
return 'site', '站点工参(移动格式)', good, errors
|
||||||
|
|
||||||
|
good, errors = validate_outages(df)
|
||||||
|
return 'outage', '退服流水', good, errors
|
||||||
|
|
||||||
|
|
||||||
|
def clean_text(series):
|
||||||
|
"""
|
||||||
|
统一成去掉首尾空格的文本,空值、'nan'、'None'、'-' 都变成空字符串。
|
||||||
|
注意要先 fillna 再 astype(str):pandas 3 起 astype(str) 会保留空值,不再变成字符串 'nan'。
|
||||||
|
"""
|
||||||
|
return series.fillna('').astype(str).str.strip().replace({'nan': '', 'None': '', '-': ''})
|
||||||
|
|
||||||
|
|
||||||
|
def parse_time(series):
|
||||||
|
"""把一列文本解析成时间;空值、'-'、格式错误都变成 NaT。网管时间为“月/日/年”格式,pandas 默认按月在前解析。"""
|
||||||
|
return pd.to_datetime(clean_text(series), errors='coerce', format='mixed')
|
||||||
|
|
||||||
|
|
||||||
|
def rename_columns(df, aliases):
|
||||||
|
"""按别名表把中文 / 其他写法的表头改成系统字段名。aliases: {字段名: [别名, ...]}"""
|
||||||
|
mapping = {}
|
||||||
|
for field, names in aliases.items():
|
||||||
|
for column in df.columns:
|
||||||
|
if column == field or column in names:
|
||||||
|
mapping[column] = field
|
||||||
|
return df.rename(columns=mapping)
|
||||||
|
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------- 2.1 退服流水
|
||||||
|
OUTAGE_ALIASES = {
|
||||||
|
'record_id': ['流水号'], 'ne_id': ['基站编号', '站号'], 'site_name': ['基站名称', '站点名称'],
|
||||||
|
'cell_id': ['小区', '小区编号'], 'start_time': ['退服开始时间', '开始时间'],
|
||||||
|
'end_time': ['退服恢复时间', '恢复时间', '结束时间'], 'duration_min': ['退服时长', '退服时长(分钟)'],
|
||||||
|
'cause_category': ['原因大类', '退服原因'], 'cause_detail': ['原因细项'], 'cause_code': ['原因码'],
|
||||||
|
'ticket_id': ['工单号'], 'closed': ['是否闭环'],
|
||||||
|
}
|
||||||
|
OUTAGE_SAVE_COLUMNS = ['record_id', 'ne_id', 'cell_id', 'start_time', 'end_time', 'duration_min', 'reported_min',
|
||||||
|
'cause_category', 'cause_detail', 'cause_code', 'ticket_id', 'status']
|
||||||
|
|
||||||
|
|
||||||
|
def validate_outages(df):
|
||||||
|
"""
|
||||||
|
退服流水校验:必填字段、站号是否在站点库、时间格式、恢复早于开始、超过 30 天、文件内及库内重复。
|
||||||
|
退服时长一律按“恢复时间 − 开始时间”重算;文件里人工上报的时长保存为 reported_min,供核对差错。
|
||||||
|
"""
|
||||||
|
df = rename_columns(df, OUTAGE_ALIASES)
|
||||||
|
|
||||||
|
# 文件只给了站名没给站号时,按站点库把站名换成站号
|
||||||
|
if 'ne_id' not in df.columns and 'site_name' in df.columns:
|
||||||
|
name_to_ne = {}
|
||||||
|
for site in query('SELECT ne_id, site_name FROM sites'):
|
||||||
|
name_to_ne[site['site_name']] = site['ne_id']
|
||||||
|
df['ne_id'] = df['site_name'].map(name_to_ne).fillna(df['site_name'])
|
||||||
|
|
||||||
|
missing = []
|
||||||
|
for field in ('ne_id', 'start_time', 'end_time'):
|
||||||
|
if field not in df.columns:
|
||||||
|
missing.append(OUTAGE_ALIASES[field][0])
|
||||||
|
if missing:
|
||||||
|
raise ValueError('缺少必填字段:' + '、'.join(missing))
|
||||||
|
|
||||||
|
for field in OUTAGE_ALIASES:
|
||||||
|
if field not in df.columns:
|
||||||
|
df[field] = None
|
||||||
|
|
||||||
|
df['ne_id'] = clean_text(df['ne_id'])
|
||||||
|
start_text = clean_text(df['start_time']) # 问题行里原样显示用户填写的开始时间
|
||||||
|
start = parse_time(df['start_time'])
|
||||||
|
end = parse_time(df['end_time'])
|
||||||
|
|
||||||
|
known_sites = {row['ne_id'] for row in query('SELECT ne_id FROM sites')}
|
||||||
|
existing = {(row['ne_id'], row['start_time']) for row in query('SELECT ne_id, start_time FROM outages')}
|
||||||
|
seen_in_file = set()
|
||||||
|
|
||||||
|
errors = []
|
||||||
|
good_rows = []
|
||||||
|
for i in range(len(df)):
|
||||||
|
ne_id = df.at[i, 'ne_id']
|
||||||
|
reasons = []
|
||||||
|
if not ne_id:
|
||||||
|
reasons.append('基站编号缺失')
|
||||||
|
elif ne_id not in known_sites:
|
||||||
|
reasons.append('基站不在站点库中')
|
||||||
|
if pd.isna(start[i]):
|
||||||
|
reasons.append('开始时间缺失或格式错误')
|
||||||
|
if pd.isna(end[i]):
|
||||||
|
reasons.append('恢复时间缺失或格式错误')
|
||||||
|
|
||||||
|
# 以下检查依赖时间有效,前面已有问题就不再继续判断
|
||||||
|
if not reasons:
|
||||||
|
key = (ne_id, start[i].strftime(TIME_FMT))
|
||||||
|
if end[i] < start[i]:
|
||||||
|
reasons.append('恢复时间早于开始时间')
|
||||||
|
elif (end[i] - start[i]).days > 30:
|
||||||
|
reasons.append('退服时长超过30天,疑似录入错误')
|
||||||
|
elif key in seen_in_file or key in existing:
|
||||||
|
reasons.append('重复记录(同站同开始时间)')
|
||||||
|
seen_in_file.add(key)
|
||||||
|
|
||||||
|
if reasons:
|
||||||
|
errors.append({'row': i + 2, 'key': ne_id, 'start_time': start_text[i], 'reason': ';'.join(reasons)})
|
||||||
|
else:
|
||||||
|
good_rows.append(i)
|
||||||
|
|
||||||
|
good = df.loc[good_rows].copy()
|
||||||
|
good_start = start.loc[good_rows]
|
||||||
|
good_end = end.loc[good_rows]
|
||||||
|
good['start_time'] = good_start.dt.strftime(TIME_FMT)
|
||||||
|
good['end_time'] = good_end.dt.strftime(TIME_FMT)
|
||||||
|
good['reported_min'] = pd.to_numeric(good['duration_min'], errors='coerce').astype(float)
|
||||||
|
good['duration_min'] = ((good_end - good_start).dt.total_seconds() / 60).round(1)
|
||||||
|
good['status'] = good['closed'].map({'是': '已闭环', '否': '待处理'}).fillna('待处理')
|
||||||
|
# 原因大类只接受系统定义的 7 类,其他写法视为未填写
|
||||||
|
good['cause_category'] = good['cause_category'].where(good['cause_category'].isin(CAUSES), None)
|
||||||
|
|
||||||
|
good = good[OUTAGE_SAVE_COLUMNS]
|
||||||
|
good = good.astype(object).where(good.notna(), None) # NaN 换成 None,入库后是 NULL
|
||||||
|
return good, errors
|
||||||
|
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------- 2.2 告警流(本系统口径)
|
||||||
|
ALARM_SAVE_COLUMNS = ['alarm_id', 'ne_id', 'alarm_code', 'alarm_name', 'alarm_level', 'category', 'start_time',
|
||||||
|
'clear_time', 'duration_s', 'cleared', 'parent_alarm_id']
|
||||||
|
|
||||||
|
|
||||||
|
def validate_alarms(df):
|
||||||
|
missing = []
|
||||||
|
for field in ('alarm_id', 'ne_id', 'category', 'start_time'):
|
||||||
|
if field not in df.columns:
|
||||||
|
missing.append(field)
|
||||||
|
if missing:
|
||||||
|
raise ValueError('告警文件缺少字段:' + '、'.join(missing))
|
||||||
|
|
||||||
|
for field in ALARM_SAVE_COLUMNS:
|
||||||
|
if field not in df.columns:
|
||||||
|
df[field] = None
|
||||||
|
|
||||||
|
start = parse_time(df['start_time'])
|
||||||
|
bad = df['ne_id'].isna() | start.isna() | df['alarm_id'].isna() | df['alarm_id'].duplicated()
|
||||||
|
|
||||||
|
alarm_id_text = clean_text(df['alarm_id'])
|
||||||
|
start_text = clean_text(df['start_time'])
|
||||||
|
errors = []
|
||||||
|
for i in df.index[bad]:
|
||||||
|
errors.append({'row': i + 2, 'key': alarm_id_text[i], 'start_time': start_text[i],
|
||||||
|
'reason': '告警编号缺失/重复、基站编号缺失或时间格式错误'})
|
||||||
|
|
||||||
|
good = df.loc[~bad, ALARM_SAVE_COLUMNS].copy()
|
||||||
|
good['start_time'] = start[~bad].dt.strftime(TIME_FMT)
|
||||||
|
return good, errors
|
||||||
|
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------- 2.3 华为网管告警导出
|
||||||
|
# 按告警名称关键字归入系统的告警类别。顺序很重要:先判断更具体的类别,
|
||||||
|
# 例如“射频单元驻波告警”应归天馈而不是设备硬件,“射频单元交流掉电告警”应归电源。
|
||||||
|
# “小区退服”是退服现象本身,根因分析时用来匹配退服时刻;其余类别对应根因。
|
||||||
|
NMS_CATEGORY_KEYWORDS = [
|
||||||
|
('小区退服', ['退服', '小区不可用']),
|
||||||
|
('割接施工', ['闭塞', '人工']),
|
||||||
|
('电源故障', ['掉电', '电源', '直流', '交流', '市电', '电池', '欠压', '停电']),
|
||||||
|
('机房环境', ['温度', '水浸', '烟雾', '空调', '湿度', '门禁']),
|
||||||
|
('天馈故障', ['驻波', 'VSWR', '天馈', '天线设备']),
|
||||||
|
('设备硬件', ['射频单元', 'RRU', 'RHUB', 'BBU', 'IR', 'CPRI', '单板', '硬件', '心跳', 'CANBUS',
|
||||||
|
'时钟', '星卡', 'GPS', '主控', '基带']),
|
||||||
|
('传输中断', ['SCTP', 'X2', 'S1', '用户面', '传输', '光口', '光模块', '光接口', 'E1/T1', 'IMA',
|
||||||
|
'SAAL', 'Path', '链路', '连接中断', '断链']),
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
def classify_nms_alarm(name):
|
||||||
|
for category, keywords in NMS_CATEGORY_KEYWORDS:
|
||||||
|
for word in keywords:
|
||||||
|
if word in name:
|
||||||
|
return category
|
||||||
|
return '其他'
|
||||||
|
|
||||||
|
|
||||||
|
def validate_nms_alarms(df):
|
||||||
|
"""
|
||||||
|
华为网管告警导出 → 系统告警表。字段对应:日志流水号→告警编号,eNodeB ID→基站编号,告警ID→告警码,
|
||||||
|
首次发生时间→开始时间,清除时间→清除时间;告警类别由告警名称按关键字归类。
|
||||||
|
没有 eNodeB ID 的是网管系统自身的告警(如账号、License),与基站退服无关,列为问题行不入库。
|
||||||
|
"""
|
||||||
|
# 网管导出文件末尾有一行“总计 N 条”,不是告警数据,直接去掉
|
||||||
|
first_column = df.columns[0]
|
||||||
|
is_total_row = df[first_column].astype(str).str.startswith('总计')
|
||||||
|
df = df[~is_total_row].reset_index(drop=True)
|
||||||
|
|
||||||
|
ne_id = clean_text(df['eNodeB ID'])
|
||||||
|
serial = clean_text(df['日志流水号'])
|
||||||
|
name = clean_text(df['名称'])
|
||||||
|
start_text = clean_text(df['首次发生时间(NT)'])
|
||||||
|
start = parse_time(df['首次发生时间(NT)'])
|
||||||
|
clear = parse_time(df['清除时间(NT)'])
|
||||||
|
|
||||||
|
errors = []
|
||||||
|
good_rows = []
|
||||||
|
for i in range(len(df)):
|
||||||
|
reasons = []
|
||||||
|
if not serial[i]:
|
||||||
|
reasons.append('日志流水号缺失')
|
||||||
|
if not ne_id[i]:
|
||||||
|
reasons.append('无 eNodeB ID(网管系统告警,与基站无关)')
|
||||||
|
if pd.isna(start[i]):
|
||||||
|
reasons.append('首次发生时间缺失或格式错误')
|
||||||
|
if reasons:
|
||||||
|
errors.append({'row': i + 2, 'key': name[i], 'start_time': start_text[i], 'reason': ';'.join(reasons)})
|
||||||
|
else:
|
||||||
|
good_rows.append(i)
|
||||||
|
|
||||||
|
good = pd.DataFrame({
|
||||||
|
'alarm_id': 'NMS-' + serial.loc[good_rows], # 加前缀,避免与本系统告警编号冲突
|
||||||
|
'ne_id': ne_id.loc[good_rows],
|
||||||
|
'alarm_code': clean_text(df['告警ID']).loc[good_rows],
|
||||||
|
'alarm_name': name.loc[good_rows],
|
||||||
|
'alarm_level': clean_text(df['级别']).loc[good_rows],
|
||||||
|
'category': name.loc[good_rows].map(classify_nms_alarm),
|
||||||
|
'start_time': start.loc[good_rows].dt.strftime(TIME_FMT),
|
||||||
|
'clear_time': clear.loc[good_rows].dt.strftime(TIME_FMT),
|
||||||
|
'duration_s': (clear.loc[good_rows] - start.loc[good_rows]).dt.total_seconds(),
|
||||||
|
'parent_alarm_id': None, # 网管导出只标注了“衍生告警”,没有给出父告警编号
|
||||||
|
})
|
||||||
|
good['cleared'] = good['clear_time'].notna().map({True: '是', False: '否'})
|
||||||
|
good = good[ALARM_SAVE_COLUMNS]
|
||||||
|
good = good.astype(object).where(good.notna(), None)
|
||||||
|
return good, errors
|
||||||
|
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------- 2.4 5G 工参表 → 站点库
|
||||||
|
# 工参表一行是一个小区,同一基站有多行;入库时按基站汇总,小区数 = 行数。
|
||||||
|
SITE_COLUMNS_TELECOM = {
|
||||||
|
'ne_id': 'gNodeBID', 'site_name': 'gNodeBName', 'district': '区域', 'vendor': None,
|
||||||
|
'site_type': '站点类型', 'lng': '经度Longitude', 'lat': '纬度Latitude',
|
||||||
|
}
|
||||||
|
SITE_COLUMNS_MOBILE = {
|
||||||
|
'ne_id': 'ENBID', 'site_name': '现网基站名称', 'district': None, 'vendor': '厂商',
|
||||||
|
'site_type': '覆盖类型(室分、宏站)', 'lng': '经度', 'lat': '纬度',
|
||||||
|
}
|
||||||
|
NANNING_DISTRICTS = ['青秀区', '兴宁区', '江南区', '西乡塘区', '良庆区', '邕宁区', '武鸣区']
|
||||||
|
|
||||||
|
# 按站名关键字推断通信场景,按顺序取第一个命中;都不命中归为“城中村”(城郊居民区),可在页面上调整。
|
||||||
|
# 这里的场景名必须是 core.SCENES 中定义的 5 类之一。
|
||||||
|
SCENE_KEYWORDS = [
|
||||||
|
('高校', ['大学', '学院', '学校', '校区', '中学', '职校', '师范']),
|
||||||
|
('交通枢纽', ['火车站', '高铁', '东站', '客运', '机场', '地铁', '汽车站', '收费站', '枢纽', '码头']),
|
||||||
|
('工业园区', ['工业', '产业园', '园区', '厂', '物流', '开发区', '经开']),
|
||||||
|
('商圈', ['广场', '商场', '万达', '万象', '购物', '酒店', '大厦', '商务', '市场', '营业厅', '步行街', '中心']),
|
||||||
|
]
|
||||||
|
DEFAULT_SCENE = '城中村'
|
||||||
|
|
||||||
|
|
||||||
|
def guess_scene(site_name):
|
||||||
|
for scene, keywords in SCENE_KEYWORDS:
|
||||||
|
for word in keywords:
|
||||||
|
if word in site_name:
|
||||||
|
return scene
|
||||||
|
return DEFAULT_SCENE
|
||||||
|
|
||||||
|
|
||||||
|
def guess_site_type(text):
|
||||||
|
"""工参里的站型写法不统一(室分 / 宏站 / 微站 / 皮站 …),统一成系统的三类。"""
|
||||||
|
if '室' in text:
|
||||||
|
return '室分'
|
||||||
|
if '皮' in text or '微' in text or '分布式' in text:
|
||||||
|
return '分布式皮基站'
|
||||||
|
return '宏站'
|
||||||
|
|
||||||
|
|
||||||
|
def guess_district(site_name):
|
||||||
|
for district in NANNING_DISTRICTS:
|
||||||
|
if district in site_name:
|
||||||
|
return district
|
||||||
|
return '其他'
|
||||||
|
|
||||||
|
|
||||||
|
def column_or_empty(df, column):
|
||||||
|
"""取一列并清洗;工参格式里没有这一列时返回同长度的空文本列。"""
|
||||||
|
if column is None or column not in df.columns:
|
||||||
|
return pd.Series([''] * len(df), index=df.index)
|
||||||
|
return clean_text(df[column])
|
||||||
|
|
||||||
|
|
||||||
|
def validate_sites(df, columns):
|
||||||
|
"""
|
||||||
|
工参表校验并按基站汇总。基站编号缺失或经纬度不在中国范围内的小区行列为问题行;
|
||||||
|
库中已存在的基站标为“更新”(入库时保留管理员设置过的场景标签),其余为“新增”。
|
||||||
|
"""
|
||||||
|
cells = pd.DataFrame({
|
||||||
|
'ne_id': column_or_empty(df, columns['ne_id']),
|
||||||
|
'site_name': column_or_empty(df, columns['site_name']),
|
||||||
|
'district': column_or_empty(df, columns['district']),
|
||||||
|
'vendor': column_or_empty(df, columns['vendor']),
|
||||||
|
'site_type': column_or_empty(df, columns['site_type']),
|
||||||
|
'lng': pd.to_numeric(column_or_empty(df, columns['lng']), errors='coerce'),
|
||||||
|
'lat': pd.to_numeric(column_or_empty(df, columns['lat']), errors='coerce'),
|
||||||
|
})
|
||||||
|
|
||||||
|
errors = []
|
||||||
|
good_rows = []
|
||||||
|
for i in range(len(cells)):
|
||||||
|
reasons = []
|
||||||
|
if not cells.at[i, 'ne_id']:
|
||||||
|
reasons.append('基站编号缺失')
|
||||||
|
lng = cells.at[i, 'lng']
|
||||||
|
lat = cells.at[i, 'lat']
|
||||||
|
if pd.isna(lng) or pd.isna(lat) or not (73 <= lng <= 136) or not (3 <= lat <= 54):
|
||||||
|
reasons.append('经纬度缺失或不在中国范围内')
|
||||||
|
if reasons:
|
||||||
|
errors.append({'row': i + 2, 'key': cells.at[i, 'ne_id'] or cells.at[i, 'site_name'], 'start_time': '',
|
||||||
|
'reason': ';'.join(reasons)})
|
||||||
|
else:
|
||||||
|
good_rows.append(i)
|
||||||
|
cells = cells.loc[good_rows]
|
||||||
|
|
||||||
|
existing = {row['ne_id'] for row in query('SELECT ne_id FROM sites')}
|
||||||
|
sites = []
|
||||||
|
for ne_id, group in cells.groupby('ne_id', sort=False):
|
||||||
|
first = group.iloc[0]
|
||||||
|
site_name = first['site_name'] or ne_id
|
||||||
|
district = first['district'] or guess_district(site_name)
|
||||||
|
if ne_id in existing:
|
||||||
|
action = '更新'
|
||||||
|
else:
|
||||||
|
action = '新增'
|
||||||
|
sites.append({
|
||||||
|
'ne_id': ne_id,
|
||||||
|
'site_name': site_name,
|
||||||
|
'district': district,
|
||||||
|
'scene': guess_scene(site_name),
|
||||||
|
'site_type': guess_site_type(first['site_type']),
|
||||||
|
'vendor': first['vendor'] or '未知',
|
||||||
|
'cells': len(group),
|
||||||
|
'lng': round(float(first['lng']), 6),
|
||||||
|
'lat': round(float(first['lat']), 6),
|
||||||
|
'action': action,
|
||||||
|
})
|
||||||
|
|
||||||
|
good = pd.DataFrame(sites, columns=['ne_id', 'site_name', 'district', 'scene', 'site_type', 'vendor',
|
||||||
|
'cells', 'lng', 'lat', 'action'])
|
||||||
|
return good, errors
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
Flask>=2.3
|
||||||
|
pandas>=2.0
|
||||||
|
openpyxl>=3.1
|
||||||
+244
@@ -0,0 +1,244 @@
|
|||||||
|
/*
|
||||||
|
* 应用样式(Apple 风格)。
|
||||||
|
* - 颜色取自 Apple 人机界面指南的系统色;背景为 apple.com 的 #f5f5f7 / 深色 #000。
|
||||||
|
* - 外框(导航、按钮、文字)保持中性灰阶,systemBlue 只用来标记选中项、主操作和图表里最需要关注的那一项。
|
||||||
|
* - 间距统一取 4 的倍数;字重只用 400 / 500,数字和标题偶尔用 600。
|
||||||
|
* - 玻璃只用于侧边栏、顶栏、弹窗、提示;内容卡片保持不透明(层级清晰,也更省 GPU)。
|
||||||
|
* - 组件库控件(按钮、下拉、输入框)沿用库自带样式,这里只写布局和业务小组件。
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* ---------- 颜色与基础 ---------- */
|
||||||
|
:root {
|
||||||
|
--bg: #f5f5f7;
|
||||||
|
--card: #ffffff;
|
||||||
|
--label: #1d1d1f;
|
||||||
|
--secondary: #6e6e73;
|
||||||
|
--tertiary: #86868b;
|
||||||
|
--separator: rgba(0, 0, 0, .08);
|
||||||
|
--fill: rgba(118, 118, 128, .12);
|
||||||
|
--blue: #007aff; --green: #34c759; --orange: #ff9500; --red: #ff3b30; --yellow: #ffcc00;
|
||||||
|
--gap: 16px;
|
||||||
|
--side-w: 248px;
|
||||||
|
--radius: 18px;
|
||||||
|
}
|
||||||
|
@media (prefers-color-scheme: dark) {
|
||||||
|
:root {
|
||||||
|
--bg: #000000;
|
||||||
|
--card: #1c1c1e;
|
||||||
|
--label: #f5f5f7;
|
||||||
|
--secondary: #98989d;
|
||||||
|
--tertiary: #6e6e73;
|
||||||
|
--separator: rgba(255, 255, 255, .1);
|
||||||
|
--fill: rgba(118, 118, 128, .24);
|
||||||
|
--blue: #0a84ff; --green: #30d158; --orange: #ff9f0a; --red: #ff453a; --yellow: #ffd60a;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
* { box-sizing: border-box; }
|
||||||
|
html, body { margin: 0; }
|
||||||
|
body {
|
||||||
|
min-height: 100dvh;
|
||||||
|
background: var(--bg);
|
||||||
|
color: var(--label);
|
||||||
|
font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
|
||||||
|
font-size: 14px;
|
||||||
|
-webkit-font-smoothing: antialiased;
|
||||||
|
}
|
||||||
|
h1, h3, h4 { margin: 0; }
|
||||||
|
/* 只有大标题收紧字距;小字收紧会更难读 */
|
||||||
|
h1, h3 { letter-spacing: -.01em; }
|
||||||
|
a { color: var(--blue); }
|
||||||
|
|
||||||
|
/* 通用小工具 */
|
||||||
|
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
|
||||||
|
.row.nowrap { flex-wrap: nowrap; }
|
||||||
|
.grow { flex: 1; }
|
||||||
|
.hint { color: var(--secondary); font-size: 12px; }
|
||||||
|
.small { font-size: 12px; }
|
||||||
|
.text-red { color: var(--red); }
|
||||||
|
.toolbar { margin-bottom: 16px; }
|
||||||
|
.gap-bottom { margin-bottom: 16px; }
|
||||||
|
.sub-title { margin: 20px 0 8px; font-size: 13px; color: var(--secondary); font-weight: 500; }
|
||||||
|
.center-screen { min-height: 100dvh; display: grid; place-items: center; padding: 16px; color: var(--secondary); }
|
||||||
|
|
||||||
|
/* 标志细节:未闭环圆点。只出现在“未闭环数量”和“待处理 / 处理中”状态上,表示这件事还没处理完 */
|
||||||
|
.dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: currentColor;
|
||||||
|
margin-right: 4px; vertical-align: middle; }
|
||||||
|
|
||||||
|
/* ---------- 外壳:侧边栏 + 主区 ---------- */
|
||||||
|
.shell {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: var(--side-w) minmax(0, 1fr);
|
||||||
|
gap: var(--gap);
|
||||||
|
padding: var(--gap);
|
||||||
|
min-height: 100dvh;
|
||||||
|
}
|
||||||
|
.main { min-width: 0; display: flex; flex-direction: column; gap: var(--gap); }
|
||||||
|
|
||||||
|
/* 侧边栏:撑满视口高度,导航在中间滚动,数据概况与用户固定在底部 */
|
||||||
|
.side { top: var(--gap); }
|
||||||
|
.side .lg-sidebar-surface { height: calc(100dvh - 2 * var(--gap)); }
|
||||||
|
.side .lg-sidebar-body { flex: 1; }
|
||||||
|
.brand { display: flex; align-items: center; gap: 12px; padding: 4px 8px 8px; }
|
||||||
|
.brand b, .brand small, .userbox b, .userbox small { display: block; }
|
||||||
|
.brand b { font-size: 15px; font-weight: 600; }
|
||||||
|
.brand small, .userbox small { color: var(--secondary); font-size: 12px; margin-top: 2px; }
|
||||||
|
/* 系统图标(static/icon.svg):圆角和颜色都画在图里,不再额外加彩色发光 */
|
||||||
|
.logo { width: 36px; height: 36px; flex: none; }
|
||||||
|
.logo.lg { width: 72px; height: 72px; filter: drop-shadow(0 4px 12px rgba(0, 0, 0, .12)); }
|
||||||
|
|
||||||
|
/* 分组标题离自己的条目近(8px),离上一组远(16px),一眼能看出分组 */
|
||||||
|
.nav-group { display: flex; flex-direction: column; gap: 2px; margin-bottom: 16px; }
|
||||||
|
.nav-title { padding: 0 10px 8px; font-size: 12px; font-weight: 500; color: var(--tertiary); }
|
||||||
|
.nav-item {
|
||||||
|
display: flex; align-items: center; gap: 10px;
|
||||||
|
min-height: 36px; padding: 0 10px; border-radius: 10px;
|
||||||
|
color: var(--label); text-decoration: none; font-size: 14px;
|
||||||
|
transition: background-color .15s;
|
||||||
|
}
|
||||||
|
.nav-item svg { color: var(--secondary); flex: none; }
|
||||||
|
.nav-item:hover { background: color-mix(in srgb, var(--fill) 60%, transparent); }
|
||||||
|
/* 选中项:灰色底面 + 细描边,只有图标用强调色,不再整块蓝底 */
|
||||||
|
.nav-item[aria-current="page"] { background: var(--fill); box-shadow: inset 0 0 0 1px var(--separator); font-weight: 500; }
|
||||||
|
.nav-item[aria-current="page"] svg { color: var(--blue); }
|
||||||
|
.nav-item:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
|
||||||
|
|
||||||
|
.side-footer { display: flex; flex-direction: column; gap: 12px; }
|
||||||
|
.overview {
|
||||||
|
display: grid; grid-template-columns: repeat(3, 1fr); margin: 0;
|
||||||
|
padding: 12px 4px; border-radius: 12px; background: var(--fill); text-align: center;
|
||||||
|
}
|
||||||
|
.overview dt { font-size: 11px; color: var(--secondary); }
|
||||||
|
.overview dt .dot { background: var(--orange); }
|
||||||
|
.overview dd { margin: 4px 0 0; font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; }
|
||||||
|
.userbox { display: flex; align-items: center; gap: 12px; padding: 0 4px; }
|
||||||
|
.avatar {
|
||||||
|
width: 32px; height: 32px; border-radius: 50%; flex: none; display: grid; place-items: center;
|
||||||
|
background: var(--fill); color: var(--secondary); font-weight: 500;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 顶栏(玻璃) */
|
||||||
|
.topbar { position: sticky; top: var(--gap); z-index: 5; }
|
||||||
|
.topbar, .topbar > .lg-content { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
|
||||||
|
.topbar { padding: 12px 16px; }
|
||||||
|
.topbar-title { font-size: 22px; font-weight: 600; margin-right: auto; white-space: nowrap; }
|
||||||
|
.filters { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; min-width: 0; }
|
||||||
|
.filters .lg-field { width: 152px; }
|
||||||
|
.only-narrow, .scrim { display: none; }
|
||||||
|
|
||||||
|
/* ---------- 内容 ---------- */
|
||||||
|
.grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: var(--gap); }
|
||||||
|
.section { grid-column: span 12; min-width: 0; background: var(--card); border-radius: var(--radius); }
|
||||||
|
.span-4 { grid-column: span 4; } .span-5 { grid-column: span 5; } .span-6 { grid-column: span 6; }
|
||||||
|
.span-7 { grid-column: span 7; } .span-8 { grid-column: span 8; }
|
||||||
|
.section-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; min-height: 32px; margin-bottom: 16px; }
|
||||||
|
.section-head h3 { font-size: 17px; font-weight: 600; }
|
||||||
|
.report-desc { margin: 0 0 16px; min-height: 3em; line-height: 1.6; }
|
||||||
|
|
||||||
|
/* 指标:同一张卡片内的网格,用细分隔线区分 */
|
||||||
|
/* 每项左侧一条分隔线,向左偏移 1px 后由 overflow 裁掉每行第一项的线 */
|
||||||
|
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); row-gap: 12px; overflow: hidden; }
|
||||||
|
.kpi { margin-left: -1px; border-left: 1px solid var(--separator); padding: 4px 16px; min-width: 0; }
|
||||||
|
.kpi-title { font-size: 12px; color: var(--secondary); }
|
||||||
|
.kpi-value { margin-top: 4px; font-size: 26px; font-weight: 600; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
|
||||||
|
.kpi-value small { margin-left: 4px; font-size: 13px; font-weight: 400; letter-spacing: 0; color: var(--secondary); }
|
||||||
|
.kpi-sub { margin-top: 4px; font-size: 11px; color: var(--tertiary); }
|
||||||
|
|
||||||
|
/* 表格 */
|
||||||
|
.table-wrap { overflow: auto; border-radius: 12px; border: 1px solid var(--separator); }
|
||||||
|
table { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
|
||||||
|
th, td { padding: 8px 12px; text-align: left; white-space: nowrap; border-bottom: 1px solid var(--separator); }
|
||||||
|
th { position: sticky; top: 0; z-index: 1; background: var(--card); color: var(--secondary); font-size: 12px; font-weight: 500; }
|
||||||
|
tbody tr:hover td { background: color-mix(in srgb, var(--fill) 50%, transparent); }
|
||||||
|
tbody tr:last-child td { border-bottom: 0; }
|
||||||
|
td.wrap { white-space: normal; min-width: 260px; line-height: 1.55; }
|
||||||
|
td.empty { text-align: center; color: var(--tertiary); padding: 32px; }
|
||||||
|
th.check, td.check { width: 40px; padding-right: 0; }
|
||||||
|
.th-sort { all: unset; cursor: pointer; display: inline-flex; gap: 4px; align-items: center; }
|
||||||
|
.th-sort span { opacity: .4; font-size: 11px; }
|
||||||
|
.th-sort:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; border-radius: 4px; }
|
||||||
|
th[aria-sort] .th-sort { color: var(--blue); }
|
||||||
|
th[aria-sort] .th-sort span { opacity: 1; }
|
||||||
|
.pager { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px; margin-top: 12px;
|
||||||
|
color: var(--secondary); font-size: 13px; }
|
||||||
|
|
||||||
|
/* 标签、根因、提示 */
|
||||||
|
.tag { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 500;
|
||||||
|
background: var(--fill); color: var(--secondary); }
|
||||||
|
.tag[data-tone="red"] { background: color-mix(in srgb, var(--red) 14%, transparent); color: var(--red); }
|
||||||
|
.tag[data-tone="orange"] { background: color-mix(in srgb, var(--orange) 16%, transparent); color: var(--orange); }
|
||||||
|
.tag[data-tone="green"] { background: color-mix(in srgb, var(--green) 16%, transparent); color: var(--green); }
|
||||||
|
.tag[data-tone="blue"] { background: color-mix(in srgb, var(--blue) 14%, transparent); color: var(--blue); }
|
||||||
|
.tag[data-tone="yellow"] { background: color-mix(in srgb, var(--yellow) 22%, transparent); color: color-mix(in srgb, var(--yellow) 55%, var(--label)); }
|
||||||
|
.cause { display: inline-flex; align-items: center; gap: 8px; }
|
||||||
|
.cause i { width: 8px; height: 8px; border-radius: 50%; flex: none; }
|
||||||
|
.note { padding: 12px 16px; border-radius: 12px; line-height: 1.75; font-size: 13px; color: var(--secondary);
|
||||||
|
background: var(--fill); }
|
||||||
|
.note b { color: var(--label); font-weight: 500; }
|
||||||
|
.note.full { grid-column: 1 / -1; }
|
||||||
|
.chips { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 16px 0; }
|
||||||
|
.chip { padding: 8px 12px; border-radius: 12px; background: var(--fill); font-weight: 500; font-variant-numeric: tabular-nums; }
|
||||||
|
.chip span { margin-right: 6px; font-size: 12px; font-weight: 400; color: var(--secondary); }
|
||||||
|
.chip[data-tone="green"] { color: var(--green); }
|
||||||
|
.chip[data-tone="red"] { color: var(--red); }
|
||||||
|
.chip[data-tone="orange"] { color: var(--orange); }
|
||||||
|
|
||||||
|
/* 导入拖拽区:中性虚线框,悬停 / 拖入时才出现浅灰底 */
|
||||||
|
.drop { display: block; padding: 32px; text-align: center; cursor: pointer; border-radius: 12px; color: var(--secondary);
|
||||||
|
border: 1.5px dashed color-mix(in srgb, var(--label) 20%, transparent); transition: background-color .15s, border-color .15s; }
|
||||||
|
.drop:hover, .drop[data-over] { background: color-mix(in srgb, var(--fill) 60%, transparent); border-color: var(--blue); }
|
||||||
|
.drop b { color: var(--label); font-weight: 500; }
|
||||||
|
.drop-icon { display: flex; justify-content: center; margin-bottom: 8px; color: var(--secondary); }
|
||||||
|
.drop p { margin: 8px auto 0; max-width: 820px; font-size: 13px; line-height: 1.7; }
|
||||||
|
|
||||||
|
/* 弹窗表单:外框玻璃,表单放在不透明面板上保证可读性 */
|
||||||
|
.form-dialog { width: min(600px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); }
|
||||||
|
.form-dialog form { padding: 16px; border-radius: 14px; background: var(--card); }
|
||||||
|
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; }
|
||||||
|
.form-grid > .full { grid-column: 1 / -1; }
|
||||||
|
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }
|
||||||
|
|
||||||
|
/* 加载与登录 */
|
||||||
|
.loading { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 48px; color: var(--secondary); }
|
||||||
|
.loading span { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--fill); border-top-color: var(--secondary);
|
||||||
|
animation: spin .8s linear infinite; }
|
||||||
|
@keyframes spin { to { transform: rotate(360deg); } }
|
||||||
|
.login-card, .login-card > .lg-content { display: grid; justify-items: center; gap: 12px; text-align: center; }
|
||||||
|
.login-card { width: min(400px, 100%); padding: 40px 32px; }
|
||||||
|
.login-card h1 { font-size: 24px; font-weight: 600; color: var(--label); }
|
||||||
|
.login-card p { margin: 0; }
|
||||||
|
.login-form { display: grid; gap: 12px; width: 100%; margin: 8px 0 4px; text-align: start; }
|
||||||
|
|
||||||
|
/* ---------- 响应式(按窗口宽度) ---------- */
|
||||||
|
@media (max-width: 1280px) {
|
||||||
|
.span-4, .span-5, .span-6, .span-7, .span-8 { grid-column: span 12; }
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 窄屏:侧边栏变成抽屉,顶栏只保留标题 + 菜单 + 筛选按钮,筛选项点开才显示 */
|
||||||
|
@media (max-width: 900px) {
|
||||||
|
:root { --gap: 12px; }
|
||||||
|
.shell { grid-template-columns: minmax(0, 1fr); padding-top: 0; }
|
||||||
|
.shell .side {
|
||||||
|
position: fixed; z-index: 30; top: var(--gap); bottom: var(--gap); left: var(--gap);
|
||||||
|
width: min(280px, 82vw); transform: translateX(calc(-100% - 24px)); transition: transform .25s ease;
|
||||||
|
}
|
||||||
|
.side .lg-sidebar-surface { height: 100%; }
|
||||||
|
.shell[data-menu="open"] .side { transform: none; }
|
||||||
|
.shell[data-menu="open"] .scrim { display: block; position: fixed; inset: 0; z-index: 25; background: rgba(0, 0, 0, .3); }
|
||||||
|
|
||||||
|
.topbar { top: 0; margin: 0 calc(-1 * var(--gap)); padding: 8px 12px; border-radius: 0 0 18px 18px; }
|
||||||
|
.topbar-title { font-size: 17px; font-weight: 600; margin: 0 auto; }
|
||||||
|
.only-narrow { display: inline-flex; }
|
||||||
|
.filters { display: none; width: 100%; }
|
||||||
|
.topbar[data-filters="open"] .filters { display: flex; }
|
||||||
|
.filters .lg-field { width: calc(50% - 4px); }
|
||||||
|
|
||||||
|
.section { padding: 16px !important; }
|
||||||
|
.kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
|
||||||
|
.kpi-value { font-size: 22px; }
|
||||||
|
.form-grid { grid-template-columns: minmax(0, 1fr); }
|
||||||
|
}
|
||||||
|
@media (prefers-reduced-motion: reduce) {
|
||||||
|
.loading span { animation: none; }
|
||||||
|
.shell .side { transition: none; }
|
||||||
|
}
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 14 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 1.8 KiB |
@@ -0,0 +1,30 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024">
|
||||||
|
<!-- 5G 基站退服分析系统图标:Apple 风格圆角方块 + 系统色渐变(systemTeal → systemBlue → systemIndigo)+ 白色基站信号图形 -->
|
||||||
|
<defs>
|
||||||
|
<linearGradient id="bg" x1="0" y1="0" x2="1" y2="1">
|
||||||
|
<stop offset="0" stop-color="#5ac8fa"/>
|
||||||
|
<stop offset="0.55" stop-color="#007aff"/>
|
||||||
|
<stop offset="1" stop-color="#5856d6"/>
|
||||||
|
</linearGradient>
|
||||||
|
<!-- 顶部柔和高光,呼应界面的玻璃质感 -->
|
||||||
|
<radialGradient id="shine" cx="0.3" cy="0" r="0.9">
|
||||||
|
<stop offset="0" stop-color="#fff" stop-opacity="0.35"/>
|
||||||
|
<stop offset="0.6" stop-color="#fff" stop-opacity="0"/>
|
||||||
|
</radialGradient>
|
||||||
|
</defs>
|
||||||
|
|
||||||
|
<rect width="1024" height="1024" rx="230" fill="url(#bg)"/>
|
||||||
|
<rect width="1024" height="1024" rx="230" fill="url(#shine)"/>
|
||||||
|
|
||||||
|
<g fill="none" stroke="#fff" stroke-width="56" stroke-linecap="round" stroke-linejoin="round">
|
||||||
|
<!-- 信号波:内外两层 -->
|
||||||
|
<path d="M405 310 A140 140 0 0 0 405 490 M619 310 A140 140 0 0 1 619 490"/>
|
||||||
|
<path d="M321 239 A250 250 0 0 0 321 561 M703 239 A250 250 0 0 1 703 561" opacity="0.6"/>
|
||||||
|
<!-- 铁塔:两条塔腿 -->
|
||||||
|
<path d="M512 470 L412 790 M512 470 L612 790"/>
|
||||||
|
</g>
|
||||||
|
<!-- 铁塔桁架:交叉斜撑(比横撑更像铁塔,也避免看成字母 A) -->
|
||||||
|
<path d="M471 600 L596 740 M553 600 L428 740" fill="none" stroke="#fff" stroke-width="36" stroke-linecap="round"/>
|
||||||
|
<!-- 天线 -->
|
||||||
|
<circle cx="512" cy="400" r="50" fill="#fff"/>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 1.5 KiB |
@@ -0,0 +1,27 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<html lang="zh-CN">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
|
||||||
|
<meta name="color-scheme" content="light dark">
|
||||||
|
<title>5G 基站退服时长智能分析与故障闭环管控系统</title>
|
||||||
|
<!-- 图标:标签页(SVG,旧浏览器用 PNG)、iOS 主屏幕 -->
|
||||||
|
<link rel="icon" href="/static/icon.svg" type="image/svg+xml">
|
||||||
|
<link rel="icon" href="/static/favicon-32.png" sizes="32x32" type="image/png">
|
||||||
|
<link rel="apple-touch-icon" href="/static/apple-touch-icon.png">
|
||||||
|
<meta name="apple-mobile-web-app-title" content="基站退服">
|
||||||
|
<meta name="theme-color" content="#f5f5f7" media="(prefers-color-scheme: light)">
|
||||||
|
<meta name="theme-color" content="#000000" media="(prefers-color-scheme: dark)">
|
||||||
|
<link rel="stylesheet" href="/static/vendor/vendor.css">
|
||||||
|
<link rel="stylesheet" href="/static/app.css">
|
||||||
|
<!-- 模块别名:页面代码中 import ... from 'vendor' / 'echarts' 即指向下面的文件 -->
|
||||||
|
<script type="importmap">
|
||||||
|
{"imports": {"vendor": "/static/vendor/vendor.js", "echarts": "/static/vendor/echarts.js"}}
|
||||||
|
</script>
|
||||||
|
<link rel="modulepreload" href="/static/vendor/vendor.js">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div id="root"></div>
|
||||||
|
<script type="module" src="/static/js/main.js"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -0,0 +1,155 @@
|
|||||||
|
import {
|
||||||
|
GlassButton, GlassIconButton, GlassSurface, html, Sidebar, Suspense, TextField, useEffect, useMemo, useState,
|
||||||
|
} from 'vendor';
|
||||||
|
import {api, AppContext} from './api.js';
|
||||||
|
import {num, ROLE_NAME} from './format.js';
|
||||||
|
import {Icon} from './components/icons.js';
|
||||||
|
import {Loading, Select} from './components/ui.js';
|
||||||
|
import {Login} from './Login.js';
|
||||||
|
import {GROUPS, PAGES} from './pages/index.js';
|
||||||
|
|
||||||
|
/** 根组件:请求 /api/meta,未登录(401)时显示登录页 */
|
||||||
|
export function Root() {
|
||||||
|
const [meta, setMeta] = useState(null);
|
||||||
|
const [status, setStatus] = useState('loading'); // loading | login | ready | error
|
||||||
|
|
||||||
|
const load = async () => {
|
||||||
|
try {
|
||||||
|
setMeta(await api('/api/meta'));
|
||||||
|
setStatus('ready');
|
||||||
|
} catch (err) {
|
||||||
|
if (err.status === 401) {
|
||||||
|
setStatus('login');
|
||||||
|
} else {
|
||||||
|
setStatus('error');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
useEffect(() => { load(); }, []);
|
||||||
|
|
||||||
|
// 导入站点等操作后刷新下拉选项和侧边栏的数据概况;只更新数据,不重新挂载页面
|
||||||
|
const refreshMeta = async () => {
|
||||||
|
setMeta(await api('/api/meta'));
|
||||||
|
};
|
||||||
|
|
||||||
|
if (status === 'loading') return html`<div className="center-screen"><${Loading}/></div>`;
|
||||||
|
if (status === 'login') return html`<${Login} onLogin=${load}/>`;
|
||||||
|
if (status === 'error') return html`<div className="center-screen">服务器连接失败,请刷新重试</div>`;
|
||||||
|
return html`<${Shell} meta=${meta} refreshMeta=${refreshMeta}/>`;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 当前页面 id 保存在地址栏 hash 中(#/outages),刷新后停留在当前页
|
||||||
|
const pageFromHash = () => location.hash.replace('#/', '') || 'dashboard';
|
||||||
|
|
||||||
|
function Shell({meta, refreshMeta}) {
|
||||||
|
const isAdmin = meta.role === 'admin';
|
||||||
|
const pages = PAGES.filter(p => isAdmin || !p.admin);
|
||||||
|
const [pageId, setPageId] = useState(pageFromHash);
|
||||||
|
const [filters, setFilters] = useState({});
|
||||||
|
const [menuOpen, setMenuOpen] = useState(false); // 仅窄屏:侧边栏抽屉
|
||||||
|
const page = pages.find(p => p.id === pageId) || pages[0];
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const onHash = () => { setPageId(pageFromHash()); setMenuOpen(false); };
|
||||||
|
addEventListener('hashchange', onHash);
|
||||||
|
return () => removeEventListener('hashchange', onHash);
|
||||||
|
}, []);
|
||||||
|
useEffect(() => { document.title = `${page.title} · 5G 基站退服分析`; }, [page]);
|
||||||
|
|
||||||
|
const ctx = useMemo(() => ({meta, isAdmin, filters, refreshMeta}), [meta, isAdmin, filters]);
|
||||||
|
const Page = page.component;
|
||||||
|
|
||||||
|
const navGroup = group => html`
|
||||||
|
<nav key=${group} className="nav-group" aria-label=${group}>
|
||||||
|
<div className="nav-title">${group}</div>
|
||||||
|
${pages.filter(p => p.group === group).map(p => html`
|
||||||
|
<a key=${p.id} href=${`#/${p.id}`} className="nav-item" aria-current=${p.id === page.id ? 'page' : undefined}>
|
||||||
|
<${Icon} name=${p.icon}/>${p.title}
|
||||||
|
</a>`)}
|
||||||
|
</nav>`;
|
||||||
|
|
||||||
|
return html`
|
||||||
|
<${AppContext.Provider} value=${ctx}>
|
||||||
|
<div className="shell" data-menu=${menuOpen ? 'open' : undefined}>
|
||||||
|
<${Sidebar} aria-label="主导航" className="side" header=${html`<${Brand}/>`} footer=${html`<${SideFooter} meta=${meta}/>`}>
|
||||||
|
${GROUPS.map(navGroup)}
|
||||||
|
</${Sidebar}>
|
||||||
|
<div className="scrim" onClick=${() => setMenuOpen(false)}></div>
|
||||||
|
<main className="main">
|
||||||
|
<${TopBar} title=${page.title} meta=${meta} filters=${filters} onFilters=${setFilters} onMenu=${() => setMenuOpen(true)}/>
|
||||||
|
<${Suspense} fallback=${html`<${Loading}/>`}>
|
||||||
|
<${Page} key=${page.id}/>
|
||||||
|
</${Suspense}>
|
||||||
|
</main>
|
||||||
|
</div>
|
||||||
|
</${AppContext.Provider}>`;
|
||||||
|
}
|
||||||
|
|
||||||
|
const Brand = () => html`
|
||||||
|
<div className="brand">
|
||||||
|
<img className="logo" src="/static/icon.svg" alt=""/>
|
||||||
|
<div>
|
||||||
|
<b>5G 基站退服</b>
|
||||||
|
<small>智能分析 · 闭环管控</small>
|
||||||
|
</div>
|
||||||
|
</div>`;
|
||||||
|
|
||||||
|
/** 侧边栏底部:数据概况 + 当前用户 */
|
||||||
|
const SideFooter = ({meta}) => html`
|
||||||
|
<div className="side-footer">
|
||||||
|
<dl className="overview">
|
||||||
|
<div><dt>站点</dt><dd>${num(meta.overview.sites)}</dd></div>
|
||||||
|
<div><dt>退服流水</dt><dd>${num(meta.overview.records)}</dd></div>
|
||||||
|
<div><dt><i className="dot" aria-hidden="true"></i>未闭环</dt><dd>${num(meta.overview.open)}</dd></div>
|
||||||
|
</dl>
|
||||||
|
<div className="userbox">
|
||||||
|
<div className="avatar" aria-hidden="true">${meta.user.slice(0, 1).toUpperCase()}</div>
|
||||||
|
<div className="grow">
|
||||||
|
<b>${meta.user}</b>
|
||||||
|
<small>${ROLE_NAME[meta.role]}</small>
|
||||||
|
</div>
|
||||||
|
<${GlassButton} variant="plain" controlSize="small" icon=${html`<${Icon} name="logout" size=${16}/>`}
|
||||||
|
onClick=${() => { location.href = '/logout'; }}>注销</${GlassButton}>
|
||||||
|
</div>
|
||||||
|
</div>`;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 顶栏(玻璃浮层):页面标题 + 全局筛选。
|
||||||
|
* 窄屏下筛选项折叠到“筛选”按钮后面,避免玻璃面板占满首屏。
|
||||||
|
*/
|
||||||
|
function TopBar({title, meta, filters, onFilters, onMenu}) {
|
||||||
|
const [open, setOpen] = useState(false);
|
||||||
|
const active = Object.values(filters).filter(Boolean).length; // 已生效的筛选条件个数
|
||||||
|
|
||||||
|
// 修改一个筛选条件,其余条件保持不变
|
||||||
|
const setFilter = (key, value) => {
|
||||||
|
onFilters(old => ({...old, [key]: value}));
|
||||||
|
};
|
||||||
|
|
||||||
|
return html`
|
||||||
|
<${GlassSurface} className="topbar" radius=${22} data-filters=${open ? 'open' : undefined}>
|
||||||
|
<${GlassIconButton} className="only-narrow" aria-label="打开导航" icon=${html`<${Icon} name="menu"/>`} onClick=${onMenu}/>
|
||||||
|
<h1 className="topbar-title">${title}</h1>
|
||||||
|
<${GlassButton} className="only-narrow" controlSize="small" icon=${html`<${Icon} name="filter" size=${16}/>`}
|
||||||
|
onClick=${() => setOpen(o => !o)} aria-expanded=${open}>
|
||||||
|
筛选${active ? ` · ${active}` : ''}
|
||||||
|
</${GlassButton}>
|
||||||
|
<div className="filters">
|
||||||
|
<${Select} label="场景" all="全部场景" options=${meta.scenes} value=${filters.scene}
|
||||||
|
onChange=${value => setFilter('scene', value)}/>
|
||||||
|
<${Select} label="片区" all="全部片区" options=${meta.regions} value=${filters.region}
|
||||||
|
onChange=${value => setFilter('region', value)}/>
|
||||||
|
<${Select} label="厂家" all="全部厂家" options=${meta.vendors} value=${filters.vendor}
|
||||||
|
onChange=${value => setFilter('vendor', value)}/>
|
||||||
|
<${Select} label="站型" all="全部站型" options=${meta.site_types} value=${filters.site_type}
|
||||||
|
onChange=${value => setFilter('site_type', value)}/>
|
||||||
|
<${Select} label="月份" all="全部月份" options=${meta.months} value=${filters.month}
|
||||||
|
onChange=${value => setFilter('month', value)}/>
|
||||||
|
<${TextField} type="date" label="开始日期" labelHidden controlSize="small" value=${filters.date_from || ''}
|
||||||
|
onChange=${e => setFilter('date_from', e.target.value)}/>
|
||||||
|
<${TextField} type="date" label="结束日期" labelHidden controlSize="small" value=${filters.date_to || ''}
|
||||||
|
onChange=${e => setFilter('date_to', e.target.value)}/>
|
||||||
|
<${GlassButton} controlSize="small" variant="plain" disabled=${!active} onClick=${() => onFilters({})}>重置</${GlassButton}>
|
||||||
|
</div>
|
||||||
|
</${GlassSurface}>`;
|
||||||
|
}
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
import {GlassButton, GlassSurface, html, TextField, useState} from 'vendor';
|
||||||
|
import {api} from './api.js';
|
||||||
|
|
||||||
|
/** 登录页。系统不开放自助注册,账号由管理员在「用户管理」中分配。 */
|
||||||
|
export function Login({onLogin}) {
|
||||||
|
const [error, setError] = useState('');
|
||||||
|
const [busy, setBusy] = useState(false);
|
||||||
|
|
||||||
|
const submit = async e => {
|
||||||
|
e.preventDefault();
|
||||||
|
setBusy(true);
|
||||||
|
setError('');
|
||||||
|
try {
|
||||||
|
await api('/login', {json: Object.fromEntries(new FormData(e.currentTarget))});
|
||||||
|
history.replaceState(null, '', '/');
|
||||||
|
onLogin();
|
||||||
|
} catch (err) {
|
||||||
|
setError(err.message);
|
||||||
|
setBusy(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return html`
|
||||||
|
<div className="center-screen">
|
||||||
|
<${GlassSurface} size="large" radius=${28} className="login-card">
|
||||||
|
<img className="logo lg" src="/static/icon.svg" alt=""/>
|
||||||
|
<h1>5G 基站退服智能分析</h1>
|
||||||
|
<p className="hint">故障闭环管控系统 · 南宁城区</p>
|
||||||
|
<form onSubmit=${submit} className="login-form">
|
||||||
|
<${TextField} name="username" label="用户名" autoComplete="username" required controlSize="large" autoFocus/>
|
||||||
|
<${TextField} name="password" label="密码" type="password" autoComplete="current-password" required
|
||||||
|
controlSize="large" error=${error || undefined}/>
|
||||||
|
<${GlassButton} type="submit" variant="glassProminent" controlSize="large" loading=${busy}>登录</${GlassButton}>
|
||||||
|
</form>
|
||||||
|
<p className="hint small">默认账号 admin / admin123(管理员)· user / user123(普通用户)</p>
|
||||||
|
</${GlassSurface}>
|
||||||
|
</div>`;
|
||||||
|
}
|
||||||
@@ -0,0 +1,64 @@
|
|||||||
|
/* 与 Flask /api 通信。所有请求都经过 api(),页面取数用 useFetch()。 */
|
||||||
|
import {createContext, useContext, useEffect, useState, useToast} from 'vendor';
|
||||||
|
|
||||||
|
/** 对象 -> 查询串,自动丢弃空值。qs({a: 1, b: ''}) === 'a=1' */
|
||||||
|
export function qs(params = {}) {
|
||||||
|
const pairs = Object.entries(params).filter(([, v]) => v !== '' && v != null && v !== false);
|
||||||
|
return new URLSearchParams(pairs).toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发送请求并返回 JSON;失败时抛出 Error(err.status 为 HTTP 状态码)。
|
||||||
|
* api('/api/meta')
|
||||||
|
* api('/api/outages', {json: {...}}) // POST JSON
|
||||||
|
* api('/api/outages/1', {method: 'PUT', json: {}})
|
||||||
|
* api('/api/import/preview', {body: formData}) // 上传文件
|
||||||
|
*/
|
||||||
|
export async function api(url, {json, method, body} = {}) {
|
||||||
|
const init = {method: method || (json || body ? 'POST' : 'GET'), body};
|
||||||
|
if (json) {
|
||||||
|
init.headers = {'Content-Type': 'application/json'};
|
||||||
|
init.body = JSON.stringify(json);
|
||||||
|
}
|
||||||
|
const res = await fetch(url, init);
|
||||||
|
const data = await res.json().catch(() => ({error: '服务器响应异常'}));
|
||||||
|
if (!res.ok || data.error) throw Object.assign(new Error(data.error || '请求失败'), {status: res.status});
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 页面取数:url 或参数变化时自动重新请求,出错时弹出提示。
|
||||||
|
* const {data, reload} = useFetch('/api/dashboard', filters);
|
||||||
|
* data 在首次加载完成前为 null;url 传 null 时不发请求。
|
||||||
|
*/
|
||||||
|
export function useFetch(url, params) {
|
||||||
|
const toast = useToast();
|
||||||
|
const [data, setData] = useState(null);
|
||||||
|
const [version, setVersion] = useState(0);
|
||||||
|
const query = qs(params);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!url) return;
|
||||||
|
let current = true; // 参数快速变化时,丢弃过期请求的结果
|
||||||
|
api(query ? `${url}?${query}` : url).then(
|
||||||
|
result => current && setData(result),
|
||||||
|
err => current && toast({message: err.message, tone: 'error'}));
|
||||||
|
return () => { current = false; };
|
||||||
|
}, [url, query, version]);
|
||||||
|
|
||||||
|
return {data, reload: () => setVersion(v => v + 1)};
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 浏览器原生下载(导出 Excel) */
|
||||||
|
export function download(url, params) {
|
||||||
|
location.href = params ? `${url}?${qs(params)}` : url;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 全局上下文,任意页面通过 const {meta, isAdmin, filters} = useApp() 读取:
|
||||||
|
* meta 下拉选项(场景、站型、根因、月份、片区、厂家、状态)、当前用户、数据概况
|
||||||
|
* isAdmin 是否管理员
|
||||||
|
* filters 顶栏全局筛选条件
|
||||||
|
*/
|
||||||
|
export const AppContext = createContext(null);
|
||||||
|
export const useApp = () => useContext(AppContext);
|
||||||
@@ -0,0 +1,80 @@
|
|||||||
|
import {GlassButton, GlassCheckbox, html} from 'vendor';
|
||||||
|
import {num} from '../format.js';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通用表格。
|
||||||
|
* columns: [{key, title, render?(value, row), sortable?, wrap?}]
|
||||||
|
* sort: {key, asc},配合 onSort(key) 实现点击表头排序
|
||||||
|
* selected / onSelect: 传入时显示勾选列(selected 为 Set<id>)
|
||||||
|
*/
|
||||||
|
export function DataTable({columns, rows, rowKey = 'id', sort, onSort, selected, onSelect, maxHeight = 560}) {
|
||||||
|
const selectable = !!onSelect;
|
||||||
|
|
||||||
|
// 表头“全选”框的状态:全部选中 / 部分选中(显示横线)/ 未选中
|
||||||
|
let headerChecked = false;
|
||||||
|
if (selectable && rows.length > 0) {
|
||||||
|
const allOn = rows.every(r => selected.has(r[rowKey]));
|
||||||
|
const someOn = rows.some(r => selected.has(r[rowKey]));
|
||||||
|
if (allOn) {
|
||||||
|
headerChecked = true;
|
||||||
|
} else if (someOn) {
|
||||||
|
headerChecked = 'mixed';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const toggleAll = on => onSelect(new Set(on ? rows.map(r => r[rowKey]) : []));
|
||||||
|
const toggleOne = (id, on) => {
|
||||||
|
const next = new Set(selected);
|
||||||
|
on ? next.add(id) : next.delete(id);
|
||||||
|
onSelect(next);
|
||||||
|
};
|
||||||
|
|
||||||
|
const header = (c, i) => html`
|
||||||
|
<th key=${c.key + i} aria-sort=${sort?.key === c.key ? (sort.asc ? 'ascending' : 'descending') : undefined}>
|
||||||
|
${c.sortable && onSort
|
||||||
|
? html`<button className="th-sort" onClick=${() => onSort(c.key)}>
|
||||||
|
${c.title}<span aria-hidden="true">${sort?.key === c.key ? (sort.asc ? '↑' : '↓') : '↕'}</span>
|
||||||
|
</button>`
|
||||||
|
: c.title}
|
||||||
|
</th>`;
|
||||||
|
|
||||||
|
const row = (r, ri) => html`
|
||||||
|
<tr key=${r[rowKey] ?? ri}>
|
||||||
|
${selectable && html`
|
||||||
|
<td className="check">
|
||||||
|
<${GlassCheckbox} aria-label="选择" checked=${selected.has(r[rowKey])} onCheckedChange=${on => toggleOne(r[rowKey], on)}/>
|
||||||
|
</td>`}
|
||||||
|
${columns.map((c, i) => html`
|
||||||
|
<td key=${c.key + i} className=${c.wrap ? 'wrap' : undefined}>${c.render ? c.render(r[c.key], r) : r[c.key]}</td>`)}
|
||||||
|
</tr>`;
|
||||||
|
|
||||||
|
return html`
|
||||||
|
<div className="table-wrap" style=${{maxHeight}}>
|
||||||
|
<table>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
${selectable && html`
|
||||||
|
<th className="check">
|
||||||
|
<${GlassCheckbox} aria-label="全选" checked=${headerChecked} onCheckedChange=${toggleAll}/>
|
||||||
|
</th>`}
|
||||||
|
${columns.map(header)}
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
${rows.length === 0 && html`<tr><td className="empty" colSpan=${columns.length + (selectable ? 1 : 0)}>暂无数据</td></tr>`}
|
||||||
|
${rows.map(row)}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>`;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 分页条 */
|
||||||
|
export function Pager({page, size, total, onPage, prefix}) {
|
||||||
|
const pages = Math.max(1, Math.ceil(total / size));
|
||||||
|
return html`
|
||||||
|
<div className="pager">
|
||||||
|
<span>${prefix ?? `共 ${num(total)} 条`} · 第 ${page}/${pages} 页</span>
|
||||||
|
<${GlassButton} variant="gray" controlSize="small" disabled=${page <= 1} onClick=${() => onPage(page - 1)}>上一页</${GlassButton}>
|
||||||
|
<${GlassButton} variant="gray" controlSize="small" disabled=${page >= pages} onClick=${() => onPage(page + 1)}>下一页</${GlassButton}>
|
||||||
|
</div>`;
|
||||||
|
}
|
||||||
@@ -0,0 +1,62 @@
|
|||||||
|
/*
|
||||||
|
* ECharts 图表组件。
|
||||||
|
* html`<${EChart} option=${{xAxis: ..., series: [...]}} height=${320}/>`
|
||||||
|
* - 坐标轴、提示框、文字颜色由下面两套 Apple 风格主题统一提供,页面里只写数据相关的配置。
|
||||||
|
* - 跟随系统深浅色:主题变化时重建图表。
|
||||||
|
* - echarts.js 只在打开带图表的页面时才下载。
|
||||||
|
*/
|
||||||
|
import echarts from 'echarts';
|
||||||
|
import {html, useEffect, useGlassPolicy, useRef} from 'vendor';
|
||||||
|
import {PALETTE} from '../format.js';
|
||||||
|
|
||||||
|
// 柱子默认用中性灰(systemGray4 / 深色 systemGray3),需要强调的那一项由页面用 accentMax() 标成蓝色
|
||||||
|
function appleTheme({label, secondary, grid, line, tooltip, bar}) {
|
||||||
|
const axis = {
|
||||||
|
axisLine: {lineStyle: {color: line}}, axisTick: {show: false},
|
||||||
|
axisLabel: {color: secondary}, splitLine: {lineStyle: {color: grid}}, nameTextStyle: {color: secondary},
|
||||||
|
};
|
||||||
|
return {
|
||||||
|
color: PALETTE,
|
||||||
|
backgroundColor: 'transparent',
|
||||||
|
textStyle: {fontFamily: 'inherit', color: secondary},
|
||||||
|
categoryAxis: axis, valueAxis: axis,
|
||||||
|
legend: {textStyle: {color: secondary}},
|
||||||
|
tooltip: {backgroundColor: tooltip, borderWidth: 0, textStyle: {color: label},
|
||||||
|
extraCssText: 'border-radius:12px;box-shadow:0 8px 24px rgba(0,0,0,.16)'},
|
||||||
|
// 柱顶数字用次要文字色、去掉描边(默认描边在深色模式下会糊成一团)
|
||||||
|
bar: {barMaxWidth: 28, itemStyle: {borderRadius: 6, color: bar},
|
||||||
|
label: {color: secondary, fontSize: 11, textBorderWidth: 0}},
|
||||||
|
pie: {label: {color: secondary, textBorderWidth: 0}},
|
||||||
|
line: {smooth: true, symbolSize: 6, lineStyle: {width: 2.5}},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
// 颜色取自 Apple 人机界面指南的系统色(label / secondaryLabel / separator / systemGray)
|
||||||
|
echarts.registerTheme('light', appleTheme({label: '#1d1d1f', secondary: '#6e6e73', grid: 'rgba(0,0,0,.06)',
|
||||||
|
line: '#d2d2d7', tooltip: 'rgba(255,255,255,.96)', bar: '#c7c7cc'}));
|
||||||
|
echarts.registerTheme('dark', appleTheme({label: '#f5f5f7', secondary: '#98989d', grid: 'rgba(255,255,255,.08)',
|
||||||
|
line: '#424245', tooltip: 'rgba(44,44,46,.96)', bar: '#48484a'}));
|
||||||
|
|
||||||
|
const GRID = {left: 12, right: 18, top: 30, bottom: 10, containLabel: true};
|
||||||
|
|
||||||
|
export function EChart({option, height = 320}) {
|
||||||
|
const box = useRef(null);
|
||||||
|
const chart = useRef(null);
|
||||||
|
const {resolvedTheme, reduceMotion} = useGlassPolicy();
|
||||||
|
|
||||||
|
// 创建 / 主题切换时重建;容器尺寸变化时自适应
|
||||||
|
useEffect(() => {
|
||||||
|
chart.current = echarts.init(box.current, resolvedTheme);
|
||||||
|
const ro = new ResizeObserver(() => chart.current.resize());
|
||||||
|
ro.observe(box.current);
|
||||||
|
return () => { ro.disconnect(); chart.current.dispose(); };
|
||||||
|
}, [resolvedTheme]);
|
||||||
|
|
||||||
|
// 页面每次渲染都会传入新的 option 对象;内容没变时跳过重绘(例如打开弹窗不会让图表重播动画)
|
||||||
|
const key = JSON.stringify(option);
|
||||||
|
useEffect(() => {
|
||||||
|
chart.current.setOption({animation: !reduceMotion, grid: GRID, ...option}, true);
|
||||||
|
}, [key, resolvedTheme, reduceMotion]);
|
||||||
|
|
||||||
|
return html`<div ref=${box} style=${{height}}></div>`;
|
||||||
|
}
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
import {GlassButton, GlassDialog, html, useState} from 'vendor';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 表单弹窗:提交时把表单内所有带 name 的字段收集成对象,交给 onSubmit(data)。
|
||||||
|
* onSubmit 抛出异常(校验失败、接口报错)时弹窗保持打开,成功则自动关闭。
|
||||||
|
*/
|
||||||
|
export function FormDialog({onClose, title, description = '', submitText = '保存', onSubmit, children}) {
|
||||||
|
const [busy, setBusy] = useState(false);
|
||||||
|
|
||||||
|
const submit = async e => {
|
||||||
|
e.preventDefault();
|
||||||
|
const data = Object.fromEntries([...new FormData(e.currentTarget)].map(([k, v]) => [k, String(v).trim()]));
|
||||||
|
setBusy(true);
|
||||||
|
try {
|
||||||
|
await onSubmit(data);
|
||||||
|
onClose();
|
||||||
|
} catch {
|
||||||
|
// 错误已由 onSubmit 提示,弹窗保持打开
|
||||||
|
} finally {
|
||||||
|
setBusy(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return html`
|
||||||
|
<${GlassDialog} open onOpenChange=${o => !o && onClose()} title=${title} description=${description} className="form-dialog">
|
||||||
|
<form onSubmit=${submit}>
|
||||||
|
<div className="form-grid">${children}</div>
|
||||||
|
<div className="dialog-actions">
|
||||||
|
<${GlassButton} type="button" variant="gray" onClick=${onClose}>取消</${GlassButton}>
|
||||||
|
<${GlassButton} type="submit" variant="glassProminent" loading=${busy}>${submitText}</${GlassButton}>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</${GlassDialog}>`;
|
||||||
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
/* 导航图标:20px 线性图标,颜色跟随文字(currentColor)。新增图标时在 PATHS 中加一项。 */
|
||||||
|
import {html} from 'vendor';
|
||||||
|
|
||||||
|
const PATHS = {
|
||||||
|
dashboard: 'M3 3h6v8H3zM11 3h6v5h-6zM11 10h6v7h-6zM3 13h6v4H3z',
|
||||||
|
outages: 'M4 4h12M4 8h12M4 12h8M4 16h6M15 13v4M13 15h4',
|
||||||
|
import: 'M10 3v10M6 9l4 4 4-4M4 15v2h12v-2',
|
||||||
|
sites: 'M10 17V9M6 6a5.5 5.5 0 0 1 8 0M3.5 3.5a9 9 0 0 1 13 0M8 17h4',
|
||||||
|
rank: 'M4 16V10M8 16V6M12 16v-4M16 16V4',
|
||||||
|
rootcause: 'M9 3a6 6 0 1 0 0 12A6 6 0 0 0 9 3zM13.5 13.5 17 17M9 6v3l2 2',
|
||||||
|
impact: 'M3 15l4-5 3 3 4-6 3 3M3 17h14',
|
||||||
|
stats: 'M10 3v7h7A7 7 0 1 1 10 3zM12.5 1.5v6h6a6 6 0 0 0-6-6z',
|
||||||
|
reports: 'M5 2h7l4 4v12H5zM12 2v4h4M8 11h6M8 14h4',
|
||||||
|
users: 'M7 9a3 3 0 1 0 0-6 3 3 0 0 0 0 6zM2 17a5 5 0 0 1 10 0M13 4a3 3 0 0 1 0 5M15 12a5 5 0 0 1 3 5',
|
||||||
|
logout: 'M8 4H4v12h4M12 6l4 4-4 4M16 10H8',
|
||||||
|
menu: 'M3 5h14M3 10h14M3 15h14',
|
||||||
|
filter: 'M3 5h14M6 10h8M9 15h2',
|
||||||
|
};
|
||||||
|
|
||||||
|
export function Icon({name, size = 20}) {
|
||||||
|
return html`
|
||||||
|
<svg width=${size} height=${size} viewBox="0 0 20 20" fill="none" stroke="currentColor" strokeWidth="1.6"
|
||||||
|
strokeLinecap="round" strokeLinejoin="round" aria-hidden="true">
|
||||||
|
<path d=${PATHS[name]}/>
|
||||||
|
</svg>`;
|
||||||
|
}
|
||||||
@@ -0,0 +1,66 @@
|
|||||||
|
/* 内容层组件。只放有实际逻辑的组件;纯布局直接写 className(.grid / .row / .grow / .note / .chips,见 app.css)。 */
|
||||||
|
import {Card, Fragment, html, Picker, useState} from 'vendor';
|
||||||
|
import {CAUSE_COLOR, LEVEL_TONE, STATUS_TONE} from '../format.js';
|
||||||
|
|
||||||
|
/** 内容卡片:不透明,可带标题栏。span 为 12 栅格中占的列数 */
|
||||||
|
export function Section({title, hint, extra, span = 12, children}) {
|
||||||
|
return html`
|
||||||
|
<${Card} radius=${18} padding=${20} className=${`section span-${span}`}>
|
||||||
|
${(title || extra) && html`
|
||||||
|
<header className="section-head">
|
||||||
|
<h3>${title}</h3>
|
||||||
|
${hint && html`<span className="hint">${hint}</span>`}
|
||||||
|
<span className="grow"></span>
|
||||||
|
${extra}
|
||||||
|
</header>`}
|
||||||
|
${children}
|
||||||
|
</${Card}>`;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 指标卡 */
|
||||||
|
export function Kpi({title, value, unit, sub}) {
|
||||||
|
return html`
|
||||||
|
<div className="kpi">
|
||||||
|
<div className="kpi-title">${title}</div>
|
||||||
|
<div className="kpi-value">${value}<small>${unit}</small></div>
|
||||||
|
${sub && html`<div className="kpi-sub">${sub}</div>`}
|
||||||
|
</div>`;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 彩色文字标签(颜色之外始终带文字,不单靠颜色传达状态) */
|
||||||
|
export const LevelTag = ({value}) => value && html`<span className="tag" data-tone=${LEVEL_TONE[value]}>${value}</span>`;
|
||||||
|
|
||||||
|
/** 闭环状态标签:未闭环(待处理 / 处理中)前面加一个圆点,和侧边栏“未闭环”数量的圆点是同一个记号 */
|
||||||
|
export function StatusTag({value}) {
|
||||||
|
if (!value) return null;
|
||||||
|
let dot = null;
|
||||||
|
if (value !== '已闭环') {
|
||||||
|
dot = html`<i className="dot" aria-hidden="true"></i>`;
|
||||||
|
}
|
||||||
|
return html`<span className="tag" data-tone=${STATUS_TONE[value]}>${dot}${value}</span>`;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 根因:色点 + 名称 */
|
||||||
|
export const Cause = ({value}) => value && html`
|
||||||
|
<span className="cause"><i style=${{background: CAUSE_COLOR[value] || '#8e8e93'}}></i>${value}</span>`;
|
||||||
|
|
||||||
|
export const Loading = () => html`<div className="loading"><span></span>加载中…</div>`;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 下拉选择(组件库 Picker)。options 可以是字符串数组或 {value, label} 数组。
|
||||||
|
* - 传 onChange:受控用法,用于筛选条件。
|
||||||
|
* - 传 name:表单用法,value 为初始值;Picker 本身不参与表单提交,所以用隐藏 input 带上选中值。
|
||||||
|
* - 传 all:最前面加一个值为 '' 的“全部”选项。
|
||||||
|
*/
|
||||||
|
export function Select({label, options, all, value, onChange, name, showLabel = false}) {
|
||||||
|
const items = options.map(o => (typeof o === 'string' ? {value: o, label: o} : o));
|
||||||
|
if (all) items.unshift({value: '', label: all});
|
||||||
|
const [own, setOwn] = useState(value ?? items[0]?.value ?? '');
|
||||||
|
const current = onChange ? value ?? '' : own;
|
||||||
|
return html`
|
||||||
|
<${Fragment}>
|
||||||
|
<${Picker} label=${label} labelHidden=${!showLabel} options=${items} presentation="menu"
|
||||||
|
value=${current} onValueChange=${onChange || setOwn}/>
|
||||||
|
${name && html`<input type="hidden" name=${name} value=${current}/>`}
|
||||||
|
</${Fragment}>`;
|
||||||
|
}
|
||||||
@@ -0,0 +1,60 @@
|
|||||||
|
/* 显示格式与颜色常量。颜色全部取自 Apple 系统色(浅色模式值),同一实体在所有图表中颜色固定。 */
|
||||||
|
|
||||||
|
export const num = v => (v == null || v === '' ? '' : Number(v).toLocaleString('zh-CN'));
|
||||||
|
|
||||||
|
/** 站名精简:去掉运营商前缀、行政区与 BBU 后缀,便于图表标签展示 */
|
||||||
|
export const shortSite = n =>
|
||||||
|
String(n).replace(/^[A-Z]+/, '').replace(/^南宁(市)?(邕宁区)?/, '').replace(/[-_]?BBU.*$/i, '').slice(0, 14) || n;
|
||||||
|
|
||||||
|
/** 固定小数位,让同一屏的百分比位数一致(例如 97.0712 → 97.07,90.6 → 90.60) */
|
||||||
|
export function fixed(value, digits = 2) {
|
||||||
|
if (value == null || value === '') {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
return Number(value).toFixed(digits);
|
||||||
|
}
|
||||||
|
|
||||||
|
export const BLUE = '#007aff';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 柱状图数据:只把最大值标成强调色,其余柱子用主题里的中性灰。
|
||||||
|
* 这样每张图只有一个视觉焦点,读者一眼看到“最需要关注的是哪一项”。
|
||||||
|
*/
|
||||||
|
export function accentMax(values) {
|
||||||
|
const max = Math.max(...values);
|
||||||
|
const data = [];
|
||||||
|
for (const value of values) {
|
||||||
|
if (value === max && max > 0) {
|
||||||
|
data.push({value, itemStyle: {color: BLUE}});
|
||||||
|
} else {
|
||||||
|
data.push(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 热力图格子里的数字颜色:深色格子用白字,浅色格子用深色字(格子颜色深浅模式下相同,所以不跟随主题) */
|
||||||
|
export function heatLabelColor(value, max) {
|
||||||
|
if (value > max * 0.6) {
|
||||||
|
return '#ffffff';
|
||||||
|
}
|
||||||
|
return '#1d1d1f';
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 图表系列色板:systemBlue / Orange / Green / Purple / Pink / Teal / Indigo / Red */
|
||||||
|
export const PALETTE = [BLUE, '#ff9500', '#34c759', '#af52de', '#ff2d55', '#30b0c7', '#5856d6', '#ff3b30'];
|
||||||
|
|
||||||
|
/** 根因颜色 */
|
||||||
|
export const CAUSE_COLOR = {
|
||||||
|
传输中断: BLUE, 电源故障: '#ff9500', 设备硬件: '#af52de', 天馈故障: '#34c759',
|
||||||
|
机房环境: '#ff2d55', 割接施工: '#30b0c7', 其他: '#8e8e93',
|
||||||
|
};
|
||||||
|
|
||||||
|
/** 热力图色阶:由浅到深的 systemBlue */
|
||||||
|
export const BLUE_SCALE = ['#e8f2ff', '#a9cfff', '#4da3ff', '#0062cc'];
|
||||||
|
|
||||||
|
/** 断站分级、闭环状态 -> 标签色调(见 app.css 中的 .tag[data-tone]) */
|
||||||
|
export const LEVEL_TONE = {重要: 'red', 主要: 'orange', 次要: 'gray'};
|
||||||
|
export const STATUS_TONE = {已闭环: 'green', 处理中: 'blue', 待处理: 'yellow'};
|
||||||
|
|
||||||
|
export const ROLE_NAME = {admin: '管理员', user: '普通用户'};
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
/*
|
||||||
|
* 前端入口。本项目前端免构建:static/js 下的文件由浏览器直接运行,改完刷新即可。
|
||||||
|
* 组件用 html`...` 模板书写(htm 库),和 JSX 的区别只有三点:
|
||||||
|
* 1. 组件名写成 <${Section}>,结束标签写成 </${Section}>
|
||||||
|
* 2. 变量与表达式写成 ${...},例如 title=${t}、onClick=${fn}
|
||||||
|
* 3. 嵌套模板也要用 html`...`,例如 ${ok && html`<b>成功</b>`}
|
||||||
|
* 一个 html`...` 里如果有多个并列的根元素,用 <${Fragment}>...</${Fragment}> 包起来(相当于 JSX 的 <>...</>)。
|
||||||
|
*/
|
||||||
|
import {createRoot, GlassProvider, html, StrictMode, ToastProvider} from 'vendor';
|
||||||
|
import {Root} from './App.js';
|
||||||
|
|
||||||
|
// 组件库内置文案为英文,这里替换为中文(只列出用到的项)
|
||||||
|
const STRINGS = {close: '关闭', cancel: '取消', clearSearch: '清除', noResults: '无结果', moreToolbarItems: '更多'};
|
||||||
|
|
||||||
|
createRoot(document.getElementById('root')).render(html`
|
||||||
|
<${StrictMode}>
|
||||||
|
<${GlassProvider} theme="system" strings=${STRINGS}>
|
||||||
|
<${ToastProvider} limit=${3}>
|
||||||
|
<${Root}/>
|
||||||
|
</${ToastProvider}>
|
||||||
|
</${GlassProvider}>
|
||||||
|
</${StrictMode}>
|
||||||
|
`);
|
||||||
@@ -0,0 +1,111 @@
|
|||||||
|
import {GlassSegmentedControl, html, useState} from 'vendor';
|
||||||
|
import {useApp, useFetch} from '../api.js';
|
||||||
|
import {accentMax, BLUE, BLUE_SCALE, CAUSE_COLOR, fixed, heatLabelColor, num, shortSite} from '../format.js';
|
||||||
|
import {EChart} from '../components/EChart.js';
|
||||||
|
import {Kpi, Loading, Section} from '../components/ui.js';
|
||||||
|
|
||||||
|
export default function Dashboard() {
|
||||||
|
const {filters} = useApp();
|
||||||
|
const {data} = useFetch('/api/dashboard', filters);
|
||||||
|
if (!data) return html`<${Loading}/>`;
|
||||||
|
const k = data.kpi;
|
||||||
|
|
||||||
|
// 横向条形图自下而上绘制,反转后最大值在最上
|
||||||
|
const rank = [...data.rank].reverse();
|
||||||
|
const scenes = [...new Set(data.heat.map(h => h[0]))];
|
||||||
|
const bench = data.bench.filter(x => x.count);
|
||||||
|
|
||||||
|
// 热力图:每个格子单独设置数字颜色,深色格子用白字
|
||||||
|
const heatMax = Math.max(1, ...data.heat.map(h => h[2]));
|
||||||
|
const heatCells = [];
|
||||||
|
for (const [scene, month, hours] of data.heat) {
|
||||||
|
heatCells.push({
|
||||||
|
value: [data.months.indexOf(month), scenes.indexOf(scene), hours],
|
||||||
|
label: {color: heatLabelColor(hours, heatMax)},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
const rankChart = {
|
||||||
|
tooltip: {trigger: 'axis', axisPointer: {type: 'shadow'}, formatter: ([s]) => {
|
||||||
|
const r = rank[s.dataIndex];
|
||||||
|
return `${r.site_name}<br>场景:${r.scene}<br>累计:<b>${s.value} h</b>(${r.count} 次)`;
|
||||||
|
}},
|
||||||
|
xAxis: {type: 'value'},
|
||||||
|
yAxis: {type: 'category', data: rank.map(r => shortSite(r.site_name)), axisLabel: {fontSize: 11}},
|
||||||
|
series: [{type: 'bar', barMaxWidth: 16, itemStyle: {borderRadius: [0, 6, 6, 0]},
|
||||||
|
data: accentMax(rank.map(r => +(r.total_min / 60).toFixed(1)))}],
|
||||||
|
};
|
||||||
|
const pieChart = {
|
||||||
|
tooltip: {trigger: 'item', formatter: '{b}<br>{c} 次({d}%)'},
|
||||||
|
legend: {bottom: 0, icon: 'circle', itemWidth: 8},
|
||||||
|
series: [{type: 'pie', radius: ['50%', '74%'], center: ['50%', '44%'], padAngle: 2,
|
||||||
|
itemStyle: {borderRadius: 6}, label: {formatter: '{d}%'},
|
||||||
|
data: data.pie.map(([name, value]) => ({name, value, itemStyle: {color: CAUSE_COLOR[name]}}))}],
|
||||||
|
};
|
||||||
|
const heatChart = {
|
||||||
|
tooltip: {formatter: s => `${scenes[s.value[1]]} · ${data.months[s.value[0]]}<br><b>${s.value[2]} h</b>`},
|
||||||
|
grid: {left: 12, right: 70, top: 10, bottom: 10, containLabel: true},
|
||||||
|
xAxis: {type: 'category', data: data.months},
|
||||||
|
yAxis: {type: 'category', data: scenes},
|
||||||
|
visualMap: {min: 0, max: heatMax, right: 0, top: 'middle',
|
||||||
|
itemHeight: 160, calculable: true, inRange: {color: BLUE_SCALE}},
|
||||||
|
series: [{type: 'heatmap', data: heatCells,
|
||||||
|
itemStyle: {borderColor: 'transparent', borderWidth: 2, borderRadius: 6},
|
||||||
|
label: {show: true, fontSize: 10}}],
|
||||||
|
};
|
||||||
|
const hourChart = {
|
||||||
|
tooltip: {trigger: 'axis', formatter: ([s]) => `${s.name}:00 - ${s.name}:59<br><b>${s.value} 次</b>`},
|
||||||
|
xAxis: {type: 'category', data: [...Array(24).keys()]},
|
||||||
|
yAxis: {type: 'value'},
|
||||||
|
series: [{type: 'bar', barMaxWidth: 12, data: accentMax(data.hours)}],
|
||||||
|
};
|
||||||
|
const benchChart = {
|
||||||
|
tooltip: {trigger: 'axis', formatter: ([s]) =>
|
||||||
|
`${s.name}<br>平均退服时长 <b>${s.value} min</b><br>退服率 ${bench[s.dataIndex].outage_rate}%`},
|
||||||
|
xAxis: {type: 'category', data: bench.map(x => x.scene)},
|
||||||
|
yAxis: {type: 'value'},
|
||||||
|
series: [{type: 'bar', data: accentMax(bench.map(x => x.avg_min)), label: {show: true, position: 'top'}}],
|
||||||
|
};
|
||||||
|
|
||||||
|
return html`
|
||||||
|
<div className="grid">
|
||||||
|
<${Section} title="运维考核指标" hint=${`计算耗时 ${data.elapsed}s`}>
|
||||||
|
<div className="kpis">
|
||||||
|
<${Kpi} title="退服次数" value=${num(k.count)} unit="次" sub=${`覆盖 ${k.sites} 个基站`}/>
|
||||||
|
<${Kpi} title="累计退服时长" value=${num(k.total_h)} unit="h"/>
|
||||||
|
<${Kpi} title="平均退服时长" value=${k.avg_min} unit="min"/>
|
||||||
|
<${Kpi} title="退服率" value=${fixed(k.outage_rate)} unit="%" sub="退服时长 / (站点数 × 统计时长)"/>
|
||||||
|
<${Kpi} title="网络可用率" value=${fixed(k.availability)} unit="%"/>
|
||||||
|
<${Kpi} title="超长退服占比" value=${fixed(k.long_ratio)} unit="%"/>
|
||||||
|
<${Kpi} title="重复退服率" value=${fixed(k.repeat_rate)} unit="%" sub="高频站点 / 有退服站点"/>
|
||||||
|
<${Kpi} title="受影响用户" value=${num(k.users)} unit="人次"/>
|
||||||
|
<${Kpi} title="根因判定准确率" value=${fixed(k.acc)} unit="%"/>
|
||||||
|
<${Kpi} title="闭环率" value=${fixed(k.closed)} unit="%"/>
|
||||||
|
<${Kpi} title="上报时长差错" value=${k.dur_fix} unit="条" sub="已按起止时间重算纠正"/>
|
||||||
|
</div>
|
||||||
|
</${Section}>
|
||||||
|
<${Section} span=${5} title="站点累计退服时长 Top 15" hint="单位:小时"><${EChart} height=${380} option=${rankChart}/></${Section}>
|
||||||
|
<${TrendCard} trend=${data.trend}/>
|
||||||
|
<${Section} span=${4} title="退服根因占比"><${EChart} option=${pieChart}/></${Section}>
|
||||||
|
<${Section} span=${8} title="场景 × 月份 退服时长热力图" hint="单位:小时"><${EChart} option=${heatChart}/></${Section}>
|
||||||
|
<${Section} span=${7} title="退服发生时段分布" hint="单位:次"><${EChart} option=${hourChart}/></${Section}>
|
||||||
|
<${Section} span=${5} title="分场景平均退服时长对标" hint="单位:分钟"><${EChart} option=${benchChart}/></${Section}>
|
||||||
|
</div>`;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 月度趋势:看板的主图(最宽、唯一带面积填充的图),可切换次数 / 时长 */
|
||||||
|
function TrendCard({trend}) {
|
||||||
|
const [key, setKey] = useState('n');
|
||||||
|
const switcher = html`
|
||||||
|
<${GlassSegmentedControl} aria-label="趋势指标" value=${key} onValueChange=${setKey}
|
||||||
|
items=${[{value: 'n', label: '次数'}, {value: 'h', label: '时长(h)'}]}/>`;
|
||||||
|
const option = {
|
||||||
|
tooltip: {trigger: 'axis'},
|
||||||
|
xAxis: {type: 'category', data: trend.map(t => t.month), boundaryGap: false},
|
||||||
|
yAxis: {type: 'value', name: key === 'n' ? '次' : '小时'},
|
||||||
|
series: [{type: 'line', data: trend.map(t => t[key]), color: BLUE,
|
||||||
|
areaStyle: {color: {type: 'linear', x: 0, y: 0, x2: 0, y2: 1,
|
||||||
|
colorStops: [{offset: 0, color: 'rgba(0,122,255,.22)'}, {offset: 1, color: 'rgba(0,122,255,0)'}]}}}],
|
||||||
|
};
|
||||||
|
return html`<${Section} span=${7} title="月度退服趋势" extra=${switcher}><${EChart} height=${380} option=${option}/></${Section}>`;
|
||||||
|
}
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
import {html} from 'vendor';
|
||||||
|
import {useApp, useFetch} from '../api.js';
|
||||||
|
import {accentMax, fixed, num} from '../format.js';
|
||||||
|
import {EChart} from '../components/EChart.js';
|
||||||
|
import {DataTable} from '../components/DataTable.js';
|
||||||
|
import {Kpi, Loading, Section} from '../components/ui.js';
|
||||||
|
|
||||||
|
const BENCH_COLUMNS = [
|
||||||
|
{key: 'scene', title: '场景'}, {key: 'sites', title: '站点数'}, {key: 'count', title: '退服次数'},
|
||||||
|
{key: 'total_h', title: '累计时长(h)'}, {key: 'avg_min', title: '平均时长(min)'}, {key: 'outage_rate', title: '退服率(%)'},
|
||||||
|
{key: 'availability', title: '可用率(%)'}, {key: 'long_ratio', title: '超长占比(%)'}, {key: 'repeat_rate', title: '重复退服率(%)'},
|
||||||
|
{key: 'users', title: '受影响用户', render: num}, {key: 'loss_gb', title: '业务损失(GB)', render: num},
|
||||||
|
];
|
||||||
|
|
||||||
|
/** 场景柱状图配置:最大的场景用强调色标出 */
|
||||||
|
const sceneBar = (bench, values) => ({
|
||||||
|
tooltip: {trigger: 'axis', axisPointer: {type: 'shadow'}},
|
||||||
|
xAxis: {type: 'category', data: bench.map(x => x.scene)},
|
||||||
|
yAxis: {type: 'value'},
|
||||||
|
series: [{type: 'bar', barMaxWidth: 34, label: {show: true, position: 'top'}, data: accentMax(values)}],
|
||||||
|
});
|
||||||
|
|
||||||
|
export default function Impact() {
|
||||||
|
const {filters} = useApp();
|
||||||
|
const {data} = useFetch('/api/dashboard', filters);
|
||||||
|
if (!data) return html`<${Loading}/>`;
|
||||||
|
const {kpi: k, bench} = data;
|
||||||
|
|
||||||
|
return html`
|
||||||
|
<div className="grid">
|
||||||
|
<${Section} title="影响评估">
|
||||||
|
<div className="kpis">
|
||||||
|
<${Kpi} title="受影响用户" value=${num(k.users)} unit="人次" sub="小区数 × 单小区在线用户 × 忙闲时系数"/>
|
||||||
|
<${Kpi} title="业务损失" value=${num(k.loss_gb)} unit="GB" sub="小区话务 × 退服时长"/>
|
||||||
|
<${Kpi} title="退服率" value=${fixed(k.outage_rate)} unit="%"/>
|
||||||
|
<${Kpi} title="网络可用率" value=${fixed(k.availability)} unit="%"/>
|
||||||
|
<${Kpi} title="平均退服时长" value=${k.avg_min} unit="min"/>
|
||||||
|
<${Kpi} title="超长退服占比" value=${fixed(k.long_ratio)} unit="%"/>
|
||||||
|
<${Kpi} title="重复退服率" value=${fixed(k.repeat_rate)} unit="%"/>
|
||||||
|
</div>
|
||||||
|
</${Section}>
|
||||||
|
<${Section} span=${6} title="分场景退服率" hint="单位:%">
|
||||||
|
<${EChart} option=${sceneBar(bench, bench.map(x => x.outage_rate))}/>
|
||||||
|
</${Section}>
|
||||||
|
<${Section} span=${6} title="分场景受影响用户" hint="单位:万人次">
|
||||||
|
<${EChart} option=${sceneBar(bench, bench.map(x => +(x.users / 1e4).toFixed(1)))}/>
|
||||||
|
</${Section}>
|
||||||
|
<${Section} title="通信场景运维考核指标横向对标">
|
||||||
|
<${DataTable} rowKey="scene" columns=${BENCH_COLUMNS} rows=${bench}/>
|
||||||
|
</${Section}>
|
||||||
|
</div>`;
|
||||||
|
}
|
||||||
@@ -0,0 +1,161 @@
|
|||||||
|
import {GlassButton, html, useState, useToast} from 'vendor';
|
||||||
|
import {api, download, useApp} from '../api.js';
|
||||||
|
import {DataTable} from '../components/DataTable.js';
|
||||||
|
import {Icon} from '../components/icons.js';
|
||||||
|
import {Loading, Section} from '../components/ui.js';
|
||||||
|
|
||||||
|
// 问题行表格:站点工参没有时间列
|
||||||
|
const ERROR_COLUMNS = [
|
||||||
|
{key: 'row', title: '文件行号'}, {key: 'key', title: '编号 / 名称'}, {key: 'start_time', title: '时间'},
|
||||||
|
{key: 'reason', title: '问题原因', render: v => html`<span className="text-red">${v}</span>`},
|
||||||
|
];
|
||||||
|
const SITE_ERROR_COLUMNS = [
|
||||||
|
{key: 'row', title: '文件行号'}, {key: 'key', title: '基站编号 / 名称'},
|
||||||
|
{key: 'reason', title: '问题原因', render: v => html`<span className="text-red">${v}</span>`},
|
||||||
|
];
|
||||||
|
|
||||||
|
// 合格数据预览表格,按文件类型显示不同的列
|
||||||
|
const PREVIEW_COLUMNS = {
|
||||||
|
outage: [
|
||||||
|
{key: 'record_id', title: '流水号'}, {key: 'ne_id', title: '基站编号'}, {key: 'start_time', title: '开始时间'},
|
||||||
|
{key: 'end_time', title: '恢复时间'}, {key: 'duration_min', title: '计算时长(分)'},
|
||||||
|
{key: 'reported_min', title: '上报时长(分)'}, {key: 'cause_category', title: '原因大类'}, {key: 'cause_code', title: '原因码'},
|
||||||
|
],
|
||||||
|
alarm: [
|
||||||
|
{key: 'alarm_id', title: '告警编号'}, {key: 'ne_id', title: '基站编号'}, {key: 'alarm_name', title: '告警名称'},
|
||||||
|
{key: 'alarm_level', title: '级别'}, {key: 'category', title: '归入类别'}, {key: 'start_time', title: '发生时间'},
|
||||||
|
{key: 'clear_time', title: '清除时间'}, {key: 'parent_alarm_id', title: '父告警'},
|
||||||
|
],
|
||||||
|
site: [
|
||||||
|
{key: 'action', title: '操作'}, {key: 'ne_id', title: '基站编号'}, {key: 'site_name', title: '基站名称'},
|
||||||
|
{key: 'district', title: '片区'}, {key: 'scene', title: '推断场景'}, {key: 'site_type', title: '站型'},
|
||||||
|
{key: 'vendor', title: '厂家'}, {key: 'cells', title: '小区数'}, {key: 'lng', title: '经度'}, {key: 'lat', title: '纬度'},
|
||||||
|
],
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导入分两步:上传预览(服务端识别类型并校验,不入库)→ 确认入库。
|
||||||
|
* 退服流水入库后对新记录做根因分析;告警入库后对全部流水重新关联;站点入库后刷新下拉选项。
|
||||||
|
*/
|
||||||
|
export default function Import() {
|
||||||
|
const {refreshMeta} = useApp();
|
||||||
|
const toast = useToast();
|
||||||
|
const [dragOver, setDragOver] = useState(false);
|
||||||
|
const [checking, setChecking] = useState(false);
|
||||||
|
const [saving, setSaving] = useState(false);
|
||||||
|
const [preview, setPreview] = useState(null); // 服务端校验结果
|
||||||
|
const [result, setResult] = useState(null); // 入库结果
|
||||||
|
|
||||||
|
const upload = async file => {
|
||||||
|
if (!file) return;
|
||||||
|
const body = new FormData();
|
||||||
|
body.append('file', file);
|
||||||
|
setChecking(true);
|
||||||
|
setPreview(null);
|
||||||
|
setResult(null);
|
||||||
|
try {
|
||||||
|
setPreview(await api('/api/import/preview', {body}));
|
||||||
|
} catch (e) {
|
||||||
|
toast({message: e.message, tone: 'error'});
|
||||||
|
}
|
||||||
|
setChecking(false);
|
||||||
|
};
|
||||||
|
|
||||||
|
const confirmImport = async () => {
|
||||||
|
setSaving(true);
|
||||||
|
try {
|
||||||
|
const r = await api('/api/import/confirm', {json: {token: preview.token}});
|
||||||
|
setResult({...r, label: preview.label});
|
||||||
|
setPreview(null);
|
||||||
|
toast({message: `${preview.label}入库完成`, tone: 'success'});
|
||||||
|
if (r.kind === 'site') {
|
||||||
|
await refreshMeta(); // 新站点可能带来新的片区、厂家,并改变站点总数
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
toast({message: e.message, tone: 'error'});
|
||||||
|
}
|
||||||
|
setSaving(false);
|
||||||
|
};
|
||||||
|
|
||||||
|
const templateButton = html`
|
||||||
|
<${GlassButton} variant="gray" onClick=${() => download('/api/template')}>下载退服流水模板</${GlassButton}>`;
|
||||||
|
|
||||||
|
return html`
|
||||||
|
<${Section} title="数据批量导入" extra=${templateButton}>
|
||||||
|
<label className="drop" data-over=${dragOver || undefined}
|
||||||
|
onDragOver=${e => { e.preventDefault(); setDragOver(true); }} onDragLeave=${() => setDragOver(false)}
|
||||||
|
onDrop=${e => { e.preventDefault(); setDragOver(false); upload(e.dataTransfer.files[0]); }}>
|
||||||
|
<input type="file" accept=".xlsx,.xls,.csv" hidden onChange=${e => { upload(e.target.files[0]); e.target.value = ''; }}/>
|
||||||
|
<div className="drop-icon" aria-hidden="true"><${Icon} name="import" size=${28}/></div>
|
||||||
|
<b>点击或拖拽 Excel / CSV 文件到此处,系统自动识别文件类型</b>
|
||||||
|
<p>
|
||||||
|
<b>退服流水</b>:必填 ne_id、start_time、end_time(支持中文表头),系统按起止时间重算退服时长并核对上报值。<br/>
|
||||||
|
<b>告警流</b>:本系统口径(含 alarm_code 列)或华为网管「当前告警浏览」导出 CSV,按告警名称自动归入根因类别。<br/>
|
||||||
|
<b>站点工参</b>:电信 / 移动 5G 工参表,按基站汇总小区并按站名推断通信场景,已有基站只更新不重复。
|
||||||
|
</p>
|
||||||
|
</label>
|
||||||
|
|
||||||
|
${checking && html`<${Loading}/>`}
|
||||||
|
${result && html`<${ImportResult} result=${result}/>`}
|
||||||
|
${preview && html`<${PreviewPanel} preview=${preview} saving=${saving} onConfirm=${confirmImport}/>`}
|
||||||
|
</${Section}>`;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 入库完成后的说明 */
|
||||||
|
function ImportResult({result}) {
|
||||||
|
let detail = `入库 ${result.n} 条`;
|
||||||
|
if (result.kind === 'site') {
|
||||||
|
detail = `新增站点 ${result.added} 个,更新站点 ${result.updated} 个`;
|
||||||
|
}
|
||||||
|
return html`
|
||||||
|
<div className="note">
|
||||||
|
${result.label}:${detail},耗时 ${result.elapsed}s。可到「退服流水管理」或「场景与站点分级」查看。
|
||||||
|
</div>`;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 校验结果:统计数字 + 问题行 + 合格数据预览 */
|
||||||
|
function PreviewPanel({preview, saving, onConfirm}) {
|
||||||
|
const isSite = preview.kind === 'site';
|
||||||
|
let errorColumns = ERROR_COLUMNS;
|
||||||
|
if (isSite) {
|
||||||
|
errorColumns = SITE_ERROR_COLUMNS;
|
||||||
|
}
|
||||||
|
|
||||||
|
let confirmText = `确认导入 ${preview.ok} 条合格数据`;
|
||||||
|
if (isSite) {
|
||||||
|
confirmText = `确认导入 ${preview.ok} 个站点`;
|
||||||
|
}
|
||||||
|
|
||||||
|
return html`
|
||||||
|
<div>
|
||||||
|
<div className="chips">
|
||||||
|
<div className="chip"><span>文件类型</span>${preview.label}</div>
|
||||||
|
<div className="chip"><span>文件行数</span>${preview.total}</div>
|
||||||
|
<div className="chip" data-tone="green"><span>${isSite ? '汇总站点' : '校验通过'}</span>${preview.ok}</div>
|
||||||
|
<div className="chip" data-tone="red"><span>问题行</span>${preview.bad}</div>
|
||||||
|
${preview.diff > 0 && html`<div className="chip" data-tone="orange"><span>上报时长差错(已纠正)</span>${preview.diff}</div>`}
|
||||||
|
${preview.kind === 'alarm' && html`<div className="chip"><span>匹配站点库</span>${preview.matched}</div>`}
|
||||||
|
${isSite && html`<div className="chip"><span>新增 / 更新</span>${preview.added} / ${preview.updated}</div>`}
|
||||||
|
<div className="chip"><span>校验耗时</span>${preview.elapsed}s</div>
|
||||||
|
<span className="grow"></span>
|
||||||
|
<${GlassButton} variant="glassProminent" disabled=${!preview.ok} loading=${saving} onClick=${onConfirm}>
|
||||||
|
${confirmText}
|
||||||
|
</${GlassButton}>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
${preview.kind === 'alarm' && preview.matched < preview.ok && html`
|
||||||
|
<p className="hint">
|
||||||
|
有 ${preview.ok - preview.matched} 条告警的基站不在站点库中:可以入库留档,但不会参与本系统站点的根因分析。
|
||||||
|
可先导入对应的站点工参。
|
||||||
|
</p>`}
|
||||||
|
|
||||||
|
${preview.bad > 0 && html`
|
||||||
|
<div>
|
||||||
|
<h4 className="sub-title">问题数据(不会入库,最多显示 500 条)</h4>
|
||||||
|
<${DataTable} columns=${errorColumns} rows=${preview.errors} maxHeight=${320}/>
|
||||||
|
</div>`}
|
||||||
|
|
||||||
|
<h4 className="sub-title">合格数据预览(前 50 条)</h4>
|
||||||
|
<${DataTable} columns=${PREVIEW_COLUMNS[preview.kind] || PREVIEW_COLUMNS.outage} rows=${preview.preview}/>
|
||||||
|
</div>`;
|
||||||
|
}
|
||||||
@@ -0,0 +1,156 @@
|
|||||||
|
import {Fragment, GlassButton, GlassCheckbox, html, SearchField, TextField, useState, useToast} from 'vendor';
|
||||||
|
import {api, useApp, useFetch} from '../api.js';
|
||||||
|
import {DataTable, Pager} from '../components/DataTable.js';
|
||||||
|
import {FormDialog} from '../components/FormDialog.js';
|
||||||
|
import {Cause, LevelTag, Loading, Section, Select, StatusTag} from '../components/ui.js';
|
||||||
|
|
||||||
|
const PAGE_SIZE = 20;
|
||||||
|
|
||||||
|
export default function Outages() {
|
||||||
|
const {meta, filters, isAdmin} = useApp();
|
||||||
|
const toast = useToast();
|
||||||
|
const [draft, setDraft] = useState({}); // 工具栏中正在编辑的条件
|
||||||
|
const [query, setQuery] = useState({}); // 点击“查询”后生效的条件
|
||||||
|
const [page, setPage] = useState(1);
|
||||||
|
const [sort, setSort] = useState({key: 'start_time', asc: false});
|
||||||
|
const [selected, setSelected] = useState(new Set());
|
||||||
|
const [editing, setEditing] = useState(null); // null=关闭;{}=新增;记录=编辑
|
||||||
|
|
||||||
|
const {data, reload} = useFetch('/api/outages', {
|
||||||
|
...filters, ...query, page, size: PAGE_SIZE, sort: sort.key, asc: sort.asc ? 1 : 0,
|
||||||
|
});
|
||||||
|
|
||||||
|
const setD = key => value => setDraft(d => ({...d, [key]: value}));
|
||||||
|
const search = () => { setQuery(draft); setPage(1); setSelected(new Set()); };
|
||||||
|
const onSort = key => { setSort(s => ({key, asc: s.key === key ? !s.asc : false})); setPage(1); };
|
||||||
|
|
||||||
|
const remove = async row => {
|
||||||
|
if (!confirm(`确认删除退服记录 ${row.record_id}?`)) return;
|
||||||
|
try {
|
||||||
|
await api(`/api/outages/${row.id}`, {method: 'DELETE'});
|
||||||
|
toast({message: '已删除', tone: 'success'});
|
||||||
|
reload();
|
||||||
|
} catch (e) {
|
||||||
|
toast({message: e.message, tone: 'error'});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const batch = async action => {
|
||||||
|
const ids = [...selected];
|
||||||
|
if (!ids.length) return toast({message: '请先勾选记录', tone: 'warning'});
|
||||||
|
if (action === 'delete' && !confirm(`确认删除选中的 ${ids.length} 条记录?`)) return;
|
||||||
|
try {
|
||||||
|
await api('/api/outages/batch', {json: {ids, action, status: '已闭环'}});
|
||||||
|
toast({message: action === 'delete' ? '已删除' : `已闭环 ${ids.length} 条`, tone: 'success'});
|
||||||
|
setSelected(new Set());
|
||||||
|
reload();
|
||||||
|
} catch (e) {
|
||||||
|
toast({message: e.message, tone: 'error'});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const columns = [
|
||||||
|
{key: 'record_id', title: '流水号'}, {key: 'ne_id', title: '基站编号'}, {key: 'site_name', title: '基站名称'},
|
||||||
|
{key: 'scene', title: '场景'}, {key: 'site_type', title: '站型'},
|
||||||
|
{key: 'start_time', title: '退服开始', sortable: true}, {key: 'end_time', title: '恢复时间'},
|
||||||
|
{key: 'duration_min', title: '计算时长(分)', sortable: true},
|
||||||
|
{key: 'reported_min', title: '上报时长', render: (v, r) => r.dur_diff
|
||||||
|
? html`<span className="text-red" title="与起止时间不符,已按系统计算值纠正">${v} ⚠</span>` : v},
|
||||||
|
{key: 'cause_category', title: '上报原因', render: (v, r) => v && html`<span>${v} <span className="hint">${r.cause_code}</span></span>`},
|
||||||
|
{key: 'root_cause', title: '判定根因', render: v => html`<${Cause} value=${v}/>`},
|
||||||
|
{key: 'level', title: '分级', render: v => html`<${LevelTag} value=${v}/>`},
|
||||||
|
{key: 'status', title: '状态', render: v => html`<${StatusTag} value=${v}/>`},
|
||||||
|
{key: 'affected_users', title: '影响用户', sortable: true},
|
||||||
|
{key: 'id', title: '操作', render: (_, r) => html`
|
||||||
|
<div className="row nowrap">
|
||||||
|
<${GlassButton} variant="tinted" controlSize="small" onClick=${() => setEditing(r)}>${isAdmin ? '编辑' : '处理'}</${GlassButton}>
|
||||||
|
${isAdmin && html`<${GlassButton} variant="destructive" controlSize="small" onClick=${() => remove(r)}>删除</${GlassButton}>`}
|
||||||
|
</div>`},
|
||||||
|
];
|
||||||
|
|
||||||
|
return html`
|
||||||
|
<${Section}>
|
||||||
|
<div className="row toolbar">
|
||||||
|
<${SearchField} aria-label="基站编号或名称" placeholder="基站编号 / 名称关键字" value=${draft.site || ''}
|
||||||
|
onValueChange=${setD('site')} onSubmitQuery=${search}/>
|
||||||
|
<${Select} label="上报原因" all="全部上报原因" options=${meta.causes} value=${draft.cause_category} onChange=${setD('cause_category')}/>
|
||||||
|
<${Select} label="判定根因" all="全部判定根因" options=${meta.causes} value=${draft.root_cause} onChange=${setD('root_cause')}/>
|
||||||
|
<${Select} label="闭环状态" all="全部闭环状态" options=${meta.status} value=${draft.status} onChange=${setD('status')}/>
|
||||||
|
<${GlassCheckbox} label="仅超长" checked=${!!draft.long} onCheckedChange=${v => setD('long')(v ? 1 : '')}/>
|
||||||
|
<${GlassCheckbox} label="仅时长差错" checked=${!!draft.diff} onCheckedChange=${v => setD('diff')(v ? 1 : '')}/>
|
||||||
|
<${GlassButton} variant="glassProminent" onClick=${search}>查询</${GlassButton}>
|
||||||
|
<span className="grow"></span>
|
||||||
|
${isAdmin && html`
|
||||||
|
<div className="row">
|
||||||
|
<${GlassButton} onClick=${() => setEditing({})}>新增记录</${GlassButton}>
|
||||||
|
<${GlassButton} onClick=${() => batch('status')}>批量闭环</${GlassButton}>
|
||||||
|
<${GlassButton} variant="destructive" onClick=${() => batch('delete')}>批量删除</${GlassButton}>
|
||||||
|
</div>`}
|
||||||
|
</div>
|
||||||
|
${data ? html`
|
||||||
|
<div>
|
||||||
|
<${DataTable} columns=${columns} rows=${data.rows} sort=${sort} onSort=${onSort}
|
||||||
|
selected=${isAdmin ? selected : undefined} onSelect=${isAdmin ? setSelected : undefined}/>
|
||||||
|
<${Pager} page=${page} size=${PAGE_SIZE} total=${data.total} onPage=${setPage}/>
|
||||||
|
</div>` : html`<${Loading}/>`}
|
||||||
|
${editing && html`<${OutageDialog} row=${editing} onClose=${() => setEditing(null)} onSaved=${reload}/>`}
|
||||||
|
</${Section}>`;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 新增 / 编辑 / 闭环处理弹窗。管理员可改全部字段;普通用户只能更新处理进度 */
|
||||||
|
function OutageDialog({row, onClose, onSaved}) {
|
||||||
|
const {meta, isAdmin} = useApp();
|
||||||
|
const toast = useToast();
|
||||||
|
const {data: sites} = useFetch(isAdmin ? '/api/sites' : null); // 管理员需要站点列表做输入提示
|
||||||
|
const isNew = !row.id;
|
||||||
|
const dt = v => (v || '').replace(' ', 'T').slice(0, 16); // "2026-10-01 08:00:00" -> datetime-local 格式
|
||||||
|
|
||||||
|
const save = async d => {
|
||||||
|
if (isAdmin && (!d.ne_id || !d.start_time || !d.end_time)) {
|
||||||
|
toast({message: '基站编号与起止时间必填', tone: 'error'});
|
||||||
|
throw new Error('invalid');
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
if (isNew) {
|
||||||
|
await api('/api/outages', {method: 'POST', json: d});
|
||||||
|
} else {
|
||||||
|
await api(`/api/outages/${row.id}`, {method: 'PUT', json: d});
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
toast({message: e.message, tone: 'error'});
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
toast({message: '已保存', tone: 'success'});
|
||||||
|
onSaved();
|
||||||
|
};
|
||||||
|
|
||||||
|
// 管理员才有的字段:基站、流水号、原因、起止时间
|
||||||
|
const adminFields = html`<${Fragment}>
|
||||||
|
<${TextField} className="full" name="ne_id" label="基站编号(可输入站名搜索)" list="site-list" defaultValue=${row.ne_id}/>
|
||||||
|
<datalist id="site-list">${sites?.rows?.map(s => html`<option key=${s.ne_id} value=${s.ne_id}>${s.site_name}</option>`)}</datalist>
|
||||||
|
<${TextField} name="record_id" label="流水号" defaultValue=${row.record_id}/>
|
||||||
|
<${TextField} name="ticket_id" label="工单号" defaultValue=${row.ticket_id}/>
|
||||||
|
<${Select} name="cause_category" label="上报原因大类" showLabel all="(未填写)" options=${meta.causes} value=${row.cause_category}/>
|
||||||
|
<${TextField} name="cause_detail" label="原因细项" defaultValue=${row.cause_detail}/>
|
||||||
|
<${TextField} name="start_time" label="退服开始时间" type="datetime-local" defaultValue=${dt(row.start_time)}/>
|
||||||
|
<${TextField} name="end_time" label="退服恢复时间" type="datetime-local" defaultValue=${dt(row.end_time)}/>
|
||||||
|
</${Fragment}>`;
|
||||||
|
|
||||||
|
let title = '闭环处理';
|
||||||
|
let description = `流水号 ${row.record_id} · ${row.site_name}`;
|
||||||
|
if (isNew) {
|
||||||
|
title = '新增退服记录';
|
||||||
|
description = '填写退服基本信息';
|
||||||
|
} else if (isAdmin) {
|
||||||
|
title = '编辑退服记录';
|
||||||
|
}
|
||||||
|
|
||||||
|
return html`
|
||||||
|
<${FormDialog} onClose=${onClose} onSubmit=${save} title=${title} description=${description}>
|
||||||
|
${isAdmin && adminFields}
|
||||||
|
<${Select} name="status" label="闭环状态" showLabel options=${meta.status} value=${row.status || '待处理'}/>
|
||||||
|
<${TextField} name="handler" label="处理人" defaultValue=${row.handler}/>
|
||||||
|
<${TextField} className="full" name="remark" label="处理说明" multiline rows=${2} defaultValue=${row.remark}/>
|
||||||
|
${row.advice && html`<div className="note full"><b>系统判定根因:${row.root_cause}</b>(${row.evidence})<br/>${row.advice}</div>`}
|
||||||
|
</${FormDialog}>`;
|
||||||
|
}
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
import {GlassButton, GlassSegmentedControl, html, useState} from 'vendor';
|
||||||
|
import {download, useApp, useFetch} from '../api.js';
|
||||||
|
import {DataTable} from '../components/DataTable.js';
|
||||||
|
import {Cause, Loading, Section} from '../components/ui.js';
|
||||||
|
|
||||||
|
const COLUMNS = [
|
||||||
|
{key: 'ne_id', title: '基站编号'}, {key: 'site_name', title: '基站名称'}, {key: 'scene', title: '场景'},
|
||||||
|
{key: 'site_type', title: '站型'}, {key: 'region', title: '片区'}, {key: 'count', title: '退服次数'},
|
||||||
|
{key: 'total_min', title: '累计时长(分)'}, {key: 'avg_min', title: '平均时长(分)'}, {key: 'max_min', title: '最长单次(分)'},
|
||||||
|
{key: 'long_min', title: '时长阈值'}, {key: 'freq_count', title: '次数阈值'},
|
||||||
|
{key: 'top_cause', title: '主要根因', render: v => html`<${Cause} value=${v}/>`},
|
||||||
|
{key: 'advice', title: '处置建议', wrap: true},
|
||||||
|
];
|
||||||
|
|
||||||
|
export default function Rank() {
|
||||||
|
const {filters} = useApp();
|
||||||
|
const [kind, setKind] = useState('long');
|
||||||
|
const {data} = useFetch('/api/sites/rank', {...filters, kind});
|
||||||
|
|
||||||
|
return html`
|
||||||
|
<${Section}>
|
||||||
|
<div className="row toolbar">
|
||||||
|
<${GlassSegmentedControl} aria-label="站点类型" value=${kind} onValueChange=${setKind}
|
||||||
|
items=${[{value: 'long', label: '超长退服站点'}, {value: 'repeat', label: '高频重复退服站点'}]}/>
|
||||||
|
${data && html`<span className="hint">共 ${data.rows.length} 个站点</span>`}
|
||||||
|
<span className="grow"></span>
|
||||||
|
<${GlassButton} variant="glassProminent" onClick=${() => download('/api/export/long', filters)}>导出清单</${GlassButton}>
|
||||||
|
</div>
|
||||||
|
<div className="note gap-bottom">
|
||||||
|
判定规则:<b>超长退服站点</b>=月均超长退服(单次时长 ≥ 场景超长阈值)≥ 1 次;
|
||||||
|
<b>高频重复退服站点</b>=月均退服次数 ≥ 场景次数阈值。阈值在「场景与站点分级」中配置,每个入选站点均按主要根因给出处置建议。
|
||||||
|
</div>
|
||||||
|
${data ? html`<${DataTable} rowKey="ne_id" columns=${COLUMNS} rows=${data.rows}/>` : html`<${Loading}/>`}
|
||||||
|
</${Section}>`;
|
||||||
|
}
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
import {GlassButton, html} from 'vendor';
|
||||||
|
import {download, useApp, useFetch} from '../api.js';
|
||||||
|
import {DataTable} from '../components/DataTable.js';
|
||||||
|
import {Loading, Section} from '../components/ui.js';
|
||||||
|
|
||||||
|
const REPORTS = [
|
||||||
|
{kind: 'stats', title: '退服统计表', desc: '考核指标汇总 + 站点维度累计/平均退服时长、次数、超长次数、受影响用户'},
|
||||||
|
{kind: 'long', title: '超长退服站点清单', desc: '超长与高频重复退服站点、阈值、主要根因与处置建议'},
|
||||||
|
{kind: 'advice', title: '根因处置建议清单', desc: '全部超长退服记录的判定根因、关联告警证据、分级与处置建议'},
|
||||||
|
];
|
||||||
|
const LOG_COLUMNS = [
|
||||||
|
{key: 'ts', title: '时间'}, {key: 'username', title: '用户'}, {key: 'action', title: '操作'},
|
||||||
|
{key: 'detail', title: '详情', wrap: true},
|
||||||
|
];
|
||||||
|
|
||||||
|
export default function Reports() {
|
||||||
|
const {filters, isAdmin} = useApp();
|
||||||
|
const {data: logs} = useFetch(isAdmin ? '/api/logs' : null); // 操作日志仅管理员可见
|
||||||
|
|
||||||
|
let logContent = html`<${Loading}/>`;
|
||||||
|
if (!isAdmin) {
|
||||||
|
logContent = html`<p className="hint">仅管理员可查看操作日志</p>`;
|
||||||
|
} else if (logs) {
|
||||||
|
logContent = html`<${DataTable} rows=${logs.rows} columns=${LOG_COLUMNS}/>`;
|
||||||
|
}
|
||||||
|
|
||||||
|
return html`
|
||||||
|
<div className="grid">
|
||||||
|
${REPORTS.map(r => html`
|
||||||
|
<${Section} key=${r.kind} span=${4} title=${r.title}>
|
||||||
|
<p className="hint report-desc">${r.desc}</p>
|
||||||
|
<${GlassButton} variant="tinted" onClick=${() => download(`/api/export/${r.kind}`, filters)}>导出 Excel</${GlassButton}>
|
||||||
|
</${Section}>`)}
|
||||||
|
<${Section} title="操作日志">${logContent}</${Section}>
|
||||||
|
</div>`;
|
||||||
|
}
|
||||||
@@ -0,0 +1,126 @@
|
|||||||
|
import {Fragment, GlassButton, html, useState, useToast} from 'vendor';
|
||||||
|
import {api, download, useApp, useFetch} from '../api.js';
|
||||||
|
import {BLUE_SCALE, CAUSE_COLOR, heatLabelColor, num} from '../format.js';
|
||||||
|
import {EChart} from '../components/EChart.js';
|
||||||
|
import {DataTable, Pager} from '../components/DataTable.js';
|
||||||
|
import {Cause, LevelTag, Loading, Section, Select, StatusTag} from '../components/ui.js';
|
||||||
|
|
||||||
|
const PAGE_SIZE = 15;
|
||||||
|
|
||||||
|
export default function RootCause() {
|
||||||
|
const {filters, isAdmin} = useApp();
|
||||||
|
const toast = useToast();
|
||||||
|
const {data: confusion} = useFetch('/api/confusion', filters);
|
||||||
|
const {data: stats} = useFetch('/api/stats', {...filters, dim: 'root_cause'});
|
||||||
|
const [lastRun, setLastRun] = useState(null);
|
||||||
|
const [running, setRunning] = useState(false);
|
||||||
|
|
||||||
|
const runAnalysis = async () => {
|
||||||
|
setRunning(true);
|
||||||
|
try {
|
||||||
|
const r = await api('/api/analyze', {method: 'POST'});
|
||||||
|
setLastRun(r);
|
||||||
|
toast({message: `全量分析完成:${num(r.n)} 条,耗时 ${r.elapsed}s,准确率 ${r.acc}%`, tone: 'success'});
|
||||||
|
} catch (e) {
|
||||||
|
toast({message: e.message, tone: 'error'});
|
||||||
|
}
|
||||||
|
setRunning(false);
|
||||||
|
};
|
||||||
|
|
||||||
|
if (!confusion || !stats) return html`<${Loading}/>`;
|
||||||
|
|
||||||
|
// 交叉矩阵:matrix[i][j] = 上报原因 i、系统判定 j 的条数;对角线 i === j 为判定一致
|
||||||
|
const {causes, matrix} = confusion;
|
||||||
|
const n = causes.length;
|
||||||
|
let total = 0;
|
||||||
|
let hit = 0;
|
||||||
|
let maxCount = 1;
|
||||||
|
for (const row of matrix) {
|
||||||
|
maxCount = Math.max(maxCount, ...row);
|
||||||
|
}
|
||||||
|
// 热力图数据 value = [列, 行, 条数];行号倒过来,让第一个原因显示在最上面;深色格子用白字
|
||||||
|
const cells = [];
|
||||||
|
for (let i = 0; i < n; i++) {
|
||||||
|
for (let j = 0; j < n; j++) {
|
||||||
|
const count = matrix[i][j];
|
||||||
|
total += count;
|
||||||
|
if (i === j) hit += count;
|
||||||
|
cells.push({value: [j, n - 1 - i, count], label: {color: heatLabelColor(count, maxCount)}});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const matrixChart = {
|
||||||
|
tooltip: {formatter: s => `上报:${causes[n - 1 - s.value[1]]}<br>判定:${causes[s.value[0]]}<br><b>${s.value[2]} 条</b>`},
|
||||||
|
grid: {left: 12, right: 12, top: 10, bottom: 30, containLabel: true},
|
||||||
|
xAxis: {type: 'category', data: causes, name: '判定', nameLocation: 'center', nameGap: 26},
|
||||||
|
yAxis: {type: 'category', data: [...causes].reverse()},
|
||||||
|
visualMap: {show: false, min: 0, max: maxCount, inRange: {color: BLUE_SCALE}},
|
||||||
|
series: [{type: 'heatmap', data: cells, label: {show: true},
|
||||||
|
itemStyle: {borderColor: 'transparent', borderWidth: 2, borderRadius: 6}}],
|
||||||
|
};
|
||||||
|
const causeChart = {
|
||||||
|
tooltip: {trigger: 'axis', axisPointer: {type: 'shadow'}, formatter: ([s]) => {
|
||||||
|
const r = stats.rows[s.dataIndex];
|
||||||
|
return `${r.key}<br>次数 ${r.count}<br>平均时长 <b>${r.avg_min} min</b><br>超长占比 ${r.long_ratio}%`;
|
||||||
|
}},
|
||||||
|
xAxis: {type: 'category', data: stats.rows.map(r => r.key)},
|
||||||
|
yAxis: {type: 'value'},
|
||||||
|
series: [{type: 'bar', barMaxWidth: 40, label: {show: true, position: 'top'},
|
||||||
|
data: stats.rows.map(r => ({value: r.avg_min, itemStyle: {color: CAUSE_COLOR[r.key]}}))}],
|
||||||
|
};
|
||||||
|
const runButton = isAdmin && html`
|
||||||
|
<${GlassButton} variant="glassProminent" loading=${running} onClick=${runAnalysis}>全量重新分析</${GlassButton}>`;
|
||||||
|
|
||||||
|
return html`
|
||||||
|
<div className="grid">
|
||||||
|
<${Section} span=${5} title="根因判定规则" extra=${runButton}>
|
||||||
|
<div className="note">
|
||||||
|
<b>第一级 · 告警衍生关系</b>:“小区退服”告警若带 parent_alarm_id,直接取父告警类别作为根因。<br/>
|
||||||
|
<b>第二级 · 时间窗关联</b>:回溯同站在退服前仍未清除的告警,按优先级取首个命中:<br/>
|
||||||
|
① 割接施工 30 分钟 ② 电源故障 300 分钟(考虑蓄电池后备)③ 机房环境 180 分钟(考虑过热保护延时)<br/>
|
||||||
|
④ 传输中断 15 分钟 ⑤ 天馈故障 30 分钟 ⑥ 设备硬件 15 分钟<br/>
|
||||||
|
停电衍生的传输告警因优先级归为电源故障;均未命中判为“其他”,派单现场核查。
|
||||||
|
</div>
|
||||||
|
<div className="chips">
|
||||||
|
<div className="chip"><span>参与校验</span>${num(total)} 条</div>
|
||||||
|
<div className="chip" data-tone="green"><span>判定准确率</span>${total ? (hit / total * 100).toFixed(2) : 0}%</div>
|
||||||
|
<div className="chip"><span>上次分析</span>${lastRun ? `${num(lastRun.n)} 条 / ${lastRun.elapsed}s` : '—'}</div>
|
||||||
|
</div>
|
||||||
|
</${Section}>
|
||||||
|
<${Section} span=${7} title="上报原因 × 系统判定根因 交叉矩阵" hint="对角线为判定一致"><${EChart} option=${matrixChart}/></${Section}>
|
||||||
|
<${Section} title="根因维度统计" hint="柱高为平均退服时长(分钟)"><${EChart} height=${260} option=${causeChart}/></${Section}>
|
||||||
|
<${AdviceList}/>
|
||||||
|
</div>`;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 超长退服记录 + 分级处置建议(分页) */
|
||||||
|
function AdviceList() {
|
||||||
|
const {meta, filters} = useApp();
|
||||||
|
const [cause, setCause] = useState('');
|
||||||
|
const [page, setPage] = useState(1);
|
||||||
|
const params = {...filters, long: 1, root_cause: cause};
|
||||||
|
const {data} = useFetch('/api/outages', {...params, sort: 'duration_min', page, size: PAGE_SIZE});
|
||||||
|
|
||||||
|
const tools = html`<${Fragment}>
|
||||||
|
<${Select} label="根因" all="全部根因" options=${meta.causes} value=${cause} onChange=${v => { setCause(v); setPage(1); }}/>
|
||||||
|
<${GlassButton} onClick=${() => download('/api/export/advice', params)}>导出建议清单</${GlassButton}>
|
||||||
|
</${Fragment}>`;
|
||||||
|
const columns = [
|
||||||
|
{key: 'ne_id', title: '基站编号'}, {key: 'site_name', title: '基站名称'}, {key: 'scene', title: '场景'},
|
||||||
|
{key: 'start_time', title: '退服开始'}, {key: 'duration_min', title: '时长(分)'},
|
||||||
|
{key: 'root_cause', title: '根因', render: v => html`<${Cause} value=${v}/>`}, {key: 'evidence', title: '关联告警证据'},
|
||||||
|
{key: 'level', title: '分级', render: v => html`<${LevelTag} value=${v}/>`},
|
||||||
|
{key: 'status', title: '状态', render: v => html`<${StatusTag} value=${v}/>`},
|
||||||
|
{key: 'advice', title: '处置建议', wrap: true},
|
||||||
|
];
|
||||||
|
|
||||||
|
return html`
|
||||||
|
<${Section} title="超长退服根因与分级处置建议" extra=${tools}>
|
||||||
|
${data ? html`
|
||||||
|
<div>
|
||||||
|
<${DataTable} rows=${data.rows} columns=${columns}/>
|
||||||
|
<${Pager} page=${page} size=${PAGE_SIZE} total=${data.total} onPage=${setPage}
|
||||||
|
prefix=${`超长退服 ${num(data.total)} 条,100% 已生成处置建议`}/>
|
||||||
|
</div>` : html`<${Loading}/>`}
|
||||||
|
</${Section}>`;
|
||||||
|
}
|
||||||
@@ -0,0 +1,88 @@
|
|||||||
|
import {Fragment, GlassButton, html, SearchField, TextField, useState, useToast} from 'vendor';
|
||||||
|
import {api, useApp, useFetch} from '../api.js';
|
||||||
|
import {EChart} from '../components/EChart.js';
|
||||||
|
import {DataTable} from '../components/DataTable.js';
|
||||||
|
import {FormDialog} from '../components/FormDialog.js';
|
||||||
|
import {Loading, Section, Select} from '../components/ui.js';
|
||||||
|
|
||||||
|
const SCENE_FIELDS = [
|
||||||
|
{key: 'long_min', title: '超长阈值(分钟)'}, {key: 'freq_count', title: '高频阈值(次/月)'},
|
||||||
|
{key: 'users_per_cell', title: '单小区在线用户'}, {key: 'gb_per_cell_h', title: '单小区话务(GB/h)', step: '0.1'},
|
||||||
|
];
|
||||||
|
|
||||||
|
export default function Sites() {
|
||||||
|
const {meta, isAdmin} = useApp();
|
||||||
|
const toast = useToast();
|
||||||
|
const {data, reload} = useFetch('/api/sites');
|
||||||
|
const [scene, setScene] = useState('');
|
||||||
|
const [keyword, setKeyword] = useState('');
|
||||||
|
const [editScene, setEditScene] = useState(null);
|
||||||
|
const [editSite, setEditSite] = useState(null);
|
||||||
|
|
||||||
|
if (!data) return html`<${Loading}/>`;
|
||||||
|
|
||||||
|
const sites = data.rows.filter(r =>
|
||||||
|
(!scene || r.scene === scene) && (!keyword || r.site_name.includes(keyword) || r.ne_id.includes(keyword)));
|
||||||
|
|
||||||
|
// 保存场景阈值或站点分级:成功提示并刷新,失败提示并让弹窗保持打开
|
||||||
|
const save = async (url, body, message) => {
|
||||||
|
try {
|
||||||
|
await api(url, {method: 'PUT', json: body});
|
||||||
|
} catch (e) {
|
||||||
|
toast({message: e.message, tone: 'error'});
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
toast({message, tone: 'success'});
|
||||||
|
reload();
|
||||||
|
};
|
||||||
|
const editColumn = onEdit => isAdmin
|
||||||
|
? [{key: '_edit', title: '', render: (_, r) => html`
|
||||||
|
<${GlassButton} variant="tinted" controlSize="small" onClick=${() => onEdit(r)}>编辑</${GlassButton}>`}]
|
||||||
|
: [];
|
||||||
|
|
||||||
|
const mixChart = {
|
||||||
|
tooltip: {trigger: 'axis', axisPointer: {type: 'shadow'}},
|
||||||
|
legend: {top: 0, icon: 'roundRect', itemWidth: 10},
|
||||||
|
grid: {left: 12, right: 12, top: 36, bottom: 6, containLabel: true},
|
||||||
|
xAxis: {type: 'category', data: meta.scenes},
|
||||||
|
yAxis: {type: 'value'},
|
||||||
|
series: meta.site_types.map(t => ({
|
||||||
|
type: 'bar', name: t, stack: 'sites', itemStyle: {borderRadius: 0},
|
||||||
|
data: meta.scenes.map(s => data.rows.filter(r => r.scene === s && r.site_type === t).length),
|
||||||
|
})),
|
||||||
|
};
|
||||||
|
const siteFilters = html`<${Fragment}>
|
||||||
|
<${Select} label="场景" all="全部场景" options=${meta.scenes} value=${scene} onChange=${setScene}/>
|
||||||
|
<${SearchField} aria-label="站点名称关键字" placeholder="站点名称 / 编号" value=${keyword} onValueChange=${setKeyword}/>
|
||||||
|
</${Fragment}>`;
|
||||||
|
|
||||||
|
return html`
|
||||||
|
<div className="grid">
|
||||||
|
<${Section} span=${7} title="分场景阈值配置" hint="阈值用于超长 / 高频站点判定,用户数与话务用于影响评估">
|
||||||
|
<${DataTable} rowKey="scene" rows=${data.scenes} columns=${[{key: 'scene', title: '场景'}, ...SCENE_FIELDS, ...editColumn(setEditScene)]}/>
|
||||||
|
</${Section}>
|
||||||
|
<${Section} span=${5} title="场景 × 站型 站点数量"><${EChart} option=${mixChart}/></${Section}>
|
||||||
|
<${Section} title="站点场景标签与站型分级" extra=${siteFilters}>
|
||||||
|
<${DataTable} rowKey="ne_id" rows=${sites} columns=${[
|
||||||
|
{key: 'ne_id', title: '基站编号'}, {key: 'site_name', title: '站点名称'}, {key: 'vendor', title: '厂家'},
|
||||||
|
{key: 'district', title: '片区'}, {key: 'scene', title: '场景标签'}, {key: 'site_type', title: '站型'},
|
||||||
|
{key: 'cells', title: '小区数'}, {key: 'lng', title: '经度'}, {key: 'lat', title: '纬度'},
|
||||||
|
...editColumn(setEditSite)]}/>
|
||||||
|
</${Section}>
|
||||||
|
|
||||||
|
${editScene && html`
|
||||||
|
<${FormDialog} onClose=${() => setEditScene(null)} title=${`场景阈值 · ${editScene.scene}`} description="保存后立即生效"
|
||||||
|
onSubmit=${d => save(`/api/scenes/${editScene.scene}`, d, '阈值已更新')}>
|
||||||
|
${SCENE_FIELDS.map(f => html`
|
||||||
|
<${TextField} key=${f.key} name=${f.key} label=${f.title} type="number" step=${f.step || '1'} min="0" required
|
||||||
|
defaultValue=${editScene[f.key]}/>`)}
|
||||||
|
</${FormDialog}>`}
|
||||||
|
${editSite && html`
|
||||||
|
<${FormDialog} onClose=${() => setEditSite(null)} title="编辑站点分级" description=${`${editSite.ne_id} · ${editSite.site_name}`}
|
||||||
|
onSubmit=${d => save(`/api/sites/${editSite.ne_id}`, d, '站点已更新')}>
|
||||||
|
<${Select} name="district" label="片区" showLabel options=${meta.regions} value=${editSite.district}/>
|
||||||
|
<${Select} name="scene" label="场景标签" showLabel options=${meta.scenes} value=${editSite.scene}/>
|
||||||
|
<${Select} name="site_type" label="站型" showLabel options=${meta.site_types} value=${editSite.site_type}/>
|
||||||
|
</${FormDialog}>`}
|
||||||
|
</div>`;
|
||||||
|
}
|
||||||
@@ -0,0 +1,61 @@
|
|||||||
|
import {html, useState} from 'vendor';
|
||||||
|
import {useApp, useFetch} from '../api.js';
|
||||||
|
import {accentMax, CAUSE_COLOR, num, shortSite} from '../format.js';
|
||||||
|
import {EChart} from '../components/EChart.js';
|
||||||
|
import {DataTable} from '../components/DataTable.js';
|
||||||
|
import {Loading, Section, Select} from '../components/ui.js';
|
||||||
|
|
||||||
|
const DIMS = [
|
||||||
|
{value: 'scene', label: '场景'}, {value: 'region', label: '片区'}, {value: 'site_type', label: '站型'},
|
||||||
|
{value: 'vendor', label: '厂家'}, {value: 'month', label: '月份'}, {value: 'root_cause', label: '判定根因'},
|
||||||
|
{value: 'cause_category', label: '上报原因'}, {value: 'cause_code', label: '原因码'},
|
||||||
|
{value: 'level', label: '断站分级'}, {value: 'site_name', label: '基站'},
|
||||||
|
];
|
||||||
|
const COLUMNS = [
|
||||||
|
{key: 'key', title: '维度值'}, {key: 'count', title: '退服次数', sortable: true},
|
||||||
|
{key: 'total_min', title: '累计时长(分)', sortable: true}, {key: 'avg_min', title: '平均时长(分)', sortable: true},
|
||||||
|
{key: 'max_min', title: '最长单次(分)', sortable: true}, {key: 'long_count', title: '超长次数', sortable: true},
|
||||||
|
{key: 'long_ratio', title: '超长占比(%)', sortable: true}, {key: 'sites', title: '涉及站点', sortable: true},
|
||||||
|
{key: 'users', title: '受影响用户', sortable: true, render: num}, {key: 'loss_gb', title: '业务损失(GB)', sortable: true, render: num},
|
||||||
|
];
|
||||||
|
|
||||||
|
/** 多维统计:选择维度 → 后端分组聚合;点击表头切换排序指标,图表同步显示该指标前 20 名 */
|
||||||
|
export default function Stats() {
|
||||||
|
const {filters} = useApp();
|
||||||
|
const [dim, setDim] = useState('scene');
|
||||||
|
const [sort, setSort] = useState({key: 'total_min', asc: false});
|
||||||
|
const {data} = useFetch('/api/stats', {...filters, dim, sort: sort.key, asc: sort.asc ? 1 : 0});
|
||||||
|
const onSort = key => setSort(s => ({key, asc: s.key === key ? !s.asc : false}));
|
||||||
|
|
||||||
|
const top = data ? data.rows.slice(0, 20) : [];
|
||||||
|
const metric = COLUMNS.find(c => c.key === sort.key).title;
|
||||||
|
|
||||||
|
// 按根因统计时每根柱子用各自的根因色(全站统一);其他维度只把第一名标成强调色
|
||||||
|
let barData;
|
||||||
|
if (dim === 'root_cause') {
|
||||||
|
barData = top.map(r => ({value: r[sort.key], itemStyle: {color: CAUSE_COLOR[r.key]}}));
|
||||||
|
} else {
|
||||||
|
barData = accentMax(top.map(r => r[sort.key]));
|
||||||
|
}
|
||||||
|
const chart = {
|
||||||
|
tooltip: {trigger: 'axis', axisPointer: {type: 'shadow'}},
|
||||||
|
xAxis: {type: 'category', data: top.map(r => (dim === 'site_name' ? shortSite(r.key) : r.key)),
|
||||||
|
axisLabel: {rotate: top.length > 8 ? 30 : 0}},
|
||||||
|
yAxis: {type: 'value', name: metric},
|
||||||
|
series: [{type: 'bar', name: metric, barMaxWidth: 34, data: barData}],
|
||||||
|
};
|
||||||
|
|
||||||
|
return html`
|
||||||
|
<${Section}>
|
||||||
|
<div className="row toolbar">
|
||||||
|
<${Select} label="统计维度" showLabel options=${DIMS} value=${dim} onChange=${setDim}/>
|
||||||
|
<span className="grow"></span>
|
||||||
|
<span className="hint">点击表头排序,图表同步切换指标</span>
|
||||||
|
</div>
|
||||||
|
${data ? html`
|
||||||
|
<div>
|
||||||
|
<${EChart} option=${chart}/>
|
||||||
|
<${DataTable} rowKey="key" columns=${COLUMNS} rows=${data.rows} sort=${sort} onSort=${onSort}/>
|
||||||
|
</div>` : html`<${Loading}/>`}
|
||||||
|
</${Section}>`;
|
||||||
|
}
|
||||||
@@ -0,0 +1,77 @@
|
|||||||
|
import {GlassButton, html, TextField, useState, useToast} from 'vendor';
|
||||||
|
import {api, useFetch} from '../api.js';
|
||||||
|
import {ROLE_NAME} from '../format.js';
|
||||||
|
import {DataTable} from '../components/DataTable.js';
|
||||||
|
import {FormDialog} from '../components/FormDialog.js';
|
||||||
|
import {Loading, Section, Select} from '../components/ui.js';
|
||||||
|
|
||||||
|
const ROLES = [{value: 'user', label: '普通用户'}, {value: 'admin', label: '管理员'}];
|
||||||
|
|
||||||
|
export default function Users() {
|
||||||
|
const toast = useToast();
|
||||||
|
const {data, reload} = useFetch('/api/users');
|
||||||
|
const [adding, setAdding] = useState(false);
|
||||||
|
const [resetting, setResetting] = useState(null);
|
||||||
|
|
||||||
|
/** 发送请求:成功提示并刷新列表;失败提示后继续抛出(让表单弹窗保持打开) */
|
||||||
|
const send = async (url, options, message) => {
|
||||||
|
try {
|
||||||
|
await api(url, options);
|
||||||
|
} catch (e) {
|
||||||
|
toast({message: e.message, tone: 'error'});
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
toast({message, tone: 'success'});
|
||||||
|
reload();
|
||||||
|
};
|
||||||
|
const checkPassword = password => {
|
||||||
|
if (password.length >= 6) return;
|
||||||
|
toast({message: '密码至少 6 位', tone: 'error'});
|
||||||
|
throw new Error('invalid');
|
||||||
|
};
|
||||||
|
|
||||||
|
const addUser = d => { checkPassword(d.password); return send('/api/users', {json: d}, '已新增'); };
|
||||||
|
const resetPassword = d => {
|
||||||
|
checkPassword(d.password);
|
||||||
|
return send(`/api/users/${resetting.id}`, {method: 'PUT', json: d}, '密码已重置');
|
||||||
|
};
|
||||||
|
const toggleRole = u =>
|
||||||
|
send(`/api/users/${u.id}`, {method: 'PUT', json: {role: u.role === 'admin' ? 'user' : 'admin'}}, '角色已更新').catch(() => {});
|
||||||
|
const removeUser = u => {
|
||||||
|
if (confirm(`确认删除用户「${u.username}」?`)) send(`/api/users/${u.id}`, {method: 'DELETE'}, '已删除').catch(() => {});
|
||||||
|
};
|
||||||
|
|
||||||
|
const columns = [
|
||||||
|
{key: 'id', title: 'ID'}, {key: 'username', title: '用户名'}, {key: 'role', title: '角色', render: v => ROLE_NAME[v]},
|
||||||
|
{key: 'created_at', title: '创建时间'},
|
||||||
|
{key: '_ops', title: '操作', render: (_, u) => html`
|
||||||
|
<div className="row nowrap">
|
||||||
|
<${GlassButton} variant="tinted" controlSize="small" onClick=${() => setResetting(u)}>重置密码</${GlassButton}>
|
||||||
|
<${GlassButton} variant="gray" controlSize="small" onClick=${() => toggleRole(u)}>
|
||||||
|
设为${u.role === 'admin' ? '普通用户' : '管理员'}
|
||||||
|
</${GlassButton}>
|
||||||
|
<${GlassButton} variant="destructive" controlSize="small" onClick=${() => removeUser(u)}>删除</${GlassButton}>
|
||||||
|
</div>`},
|
||||||
|
];
|
||||||
|
|
||||||
|
return html`
|
||||||
|
<${Section}>
|
||||||
|
<div className="row toolbar">
|
||||||
|
<span className="hint">密码使用 PBKDF2-SHA256 加盐哈希存储。管理员:全部功能;普通用户:查询、统计、看板、导出,以及更新闭环处理进度。</span>
|
||||||
|
<span className="grow"></span>
|
||||||
|
<${GlassButton} variant="glassProminent" onClick=${() => setAdding(true)}>新增用户</${GlassButton}>
|
||||||
|
</div>
|
||||||
|
${data ? html`<${DataTable} columns=${columns} rows=${data.rows}/>` : html`<${Loading}/>`}
|
||||||
|
|
||||||
|
${adding && html`
|
||||||
|
<${FormDialog} onClose=${() => setAdding(false)} onSubmit=${addUser} title="新增用户" description="系统不开放自助注册,由管理员分配账号">
|
||||||
|
<${TextField} name="username" label="用户名" required autoComplete="off"/>
|
||||||
|
<${TextField} name="password" label="初始密码(≥6 位)" type="password" required autoComplete="new-password"/>
|
||||||
|
<${Select} name="role" label="角色" showLabel options=${ROLES} value="user"/>
|
||||||
|
</${FormDialog}>`}
|
||||||
|
${resetting && html`
|
||||||
|
<${FormDialog} onClose=${() => setResetting(null)} onSubmit=${resetPassword} title="重置密码" description=${`用户:${resetting.username}`}>
|
||||||
|
<${TextField} className="full" name="password" label="新密码(≥6 位)" type="password" required autoComplete="new-password"/>
|
||||||
|
</${FormDialog}>`}
|
||||||
|
</${Section}>`;
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
/* 页面注册表:导航分组、顺序、标题、图标与权限都在这里维护。页面按需加载,首屏只下载当前页代码。 */
|
||||||
|
import {lazy} from 'vendor';
|
||||||
|
|
||||||
|
export const GROUPS = ['分析', '数据管理', '系统'];
|
||||||
|
|
||||||
|
export const PAGES = [
|
||||||
|
{id: 'dashboard', group: '分析', title: '可视化看板', icon: 'dashboard', component: lazy(() => import('./Dashboard.js'))},
|
||||||
|
{id: 'rootcause', group: '分析', title: '根因分析与处置', icon: 'rootcause', component: lazy(() => import('./RootCause.js'))},
|
||||||
|
{id: 'rank', group: '分析', title: '超长 / 高频站点', icon: 'rank', component: lazy(() => import('./Rank.js'))},
|
||||||
|
{id: 'impact', group: '分析', title: '影响评估与考核', icon: 'impact', component: lazy(() => import('./Impact.js'))},
|
||||||
|
{id: 'stats', group: '分析', title: '统计分析', icon: 'stats', component: lazy(() => import('./Stats.js'))},
|
||||||
|
{id: 'outages', group: '数据管理', title: '退服流水管理', icon: 'outages', component: lazy(() => import('./Outages.js'))},
|
||||||
|
{id: 'import', group: '数据管理', title: '数据导入校验', icon: 'import', admin: true, component: lazy(() => import('./Import.js'))},
|
||||||
|
{id: 'sites', group: '数据管理', title: '场景与站点分级', icon: 'sites', component: lazy(() => import('./Sites.js'))},
|
||||||
|
{id: 'reports', group: '系统', title: '报表导出与日志', icon: 'reports', component: lazy(() => import('./Reports.js'))},
|
||||||
|
{id: 'users', group: '系统', title: '用户管理', icon: 'users', admin: true, component: lazy(() => import('./Users.js'))},
|
||||||
|
];
|
||||||
Vendored
+40
@@ -0,0 +1,40 @@
|
|||||||
|
/*! *****************************************************************************
|
||||||
|
Copyright (c) Microsoft Corporation.
|
||||||
|
|
||||||
|
Permission to use, copy, modify, and/or distribute this software for any
|
||||||
|
purpose with or without fee is hereby granted.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
||||||
|
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||||
|
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||||
|
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
||||||
|
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||||
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||||
|
PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
***************************************************************************** */var Eu=function(r,t){return Eu=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,i){e.__proto__=i}||function(e,i){for(var n in i)Object.prototype.hasOwnProperty.call(i,n)&&(e[n]=i[n])},Eu(r,t)};function N(r,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");Eu(r,t);function e(){this.constructor=r}r.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}var g_=function(){function r(){this.firefox=!1,this.ie=!1,this.edge=!1,this.newEdge=!1,this.weChat=!1}return r}(),y_=function(){function r(){this.browser=new g_,this.node=!1,this.wxa=!1,this.worker=!1,this.svgSupported=!1,this.touchEventsSupported=!1,this.pointerEventsSupported=!1,this.domSupported=!1,this.transformSupported=!1,this.transform3dSupported=!1,this.hasGlobalWindow=typeof window<"u"}return r}(),Z=new y_;typeof wx=="object"&&typeof wx.getSystemInfoSync=="function"?(Z.wxa=!0,Z.touchEventsSupported=!0):typeof document>"u"&&typeof self<"u"?Z.worker=!0:typeof navigator>"u"||navigator.userAgent.indexOf("Node.js")===0?(Z.node=!0,Z.svgSupported=!0):m_(navigator.userAgent,Z);function m_(r,t){var e=t.browser,i=r.match(/Firefox\/([\d.]+)/),n=r.match(/MSIE\s([\d.]+)/)||r.match(/Trident\/.+?rv:(([\d.]+))/),a=r.match(/Edge?\/([\d.]+)/),o=/micromessenger/i.test(r);i&&(e.firefox=!0,e.version=i[1]),n&&(e.ie=!0,e.version=n[1]),a&&(e.edge=!0,e.version=a[1],e.newEdge=+a[1].split(".")[0]>18),o&&(e.weChat=!0),t.svgSupported=typeof SVGRect<"u",t.touchEventsSupported="ontouchstart"in window&&!e.ie&&!e.edge,t.pointerEventsSupported="onpointerdown"in window&&(e.edge||e.ie&&+e.version>=11),t.domSupported=typeof document<"u";var s=document.documentElement.style;t.transform3dSupported=(e.ie&&"transition"in s||e.edge||"WebKitCSSMatrix"in window&&"m11"in new WebKitCSSMatrix||"MozPerspective"in s)&&!("OTransition"in s),t.transformSupported=t.transform3dSupported||e.ie&&+e.version>=9}var Wf=12,__="sans-serif",yi=Wf+"px "+__,S_=20,w_=100,b_="007LLmW'55;N0500LLLLLLLLLL00NNNLzWW\\\\WQb\\0FWLg\\bWb\\WQ\\WrWWQ000CL5LLFLL0LL**F*gLLLL5F0LF\\FFF5.5N";function x_(r){var t={};if(typeof JSON>"u")return t;for(var e=0;e<r.length;e++){var i=String.fromCharCode(e+32),n=(r.charCodeAt(e)-S_)/w_;t[i]=n}return t}var T_=x_(b_),Oe={createCanvas:function(){return typeof document<"u"&&document.createElement("canvas")},measureText:function(){var r,t;return function(e,i){if(!r){var n=Oe.createCanvas();r=n&&n.getContext("2d")}if(r)return t!==i&&(t=r.font=i||yi),r.measureText(e);e=e||"",i=i||yi;var a=/((?:\d+)?\.?\d*)px/.exec(i),o=a&&+a[1]||Wf,s=0;if(i.indexOf("mono")>=0)s=o*e.length;else for(var l=0;l<e.length;l++){var u=T_[e[l]];s+=u==null?o:u*o}return{width:s}}}(),loadImage:function(r,t,e){var i=new Image;return i.onload=t,i.onerror=e,i.src=r,i}};function ig(r){for(var t in Oe)r[t]&&(Oe[t]=r[t])}var ng=Ke(["Function","RegExp","Date","Error","CanvasGradient","CanvasPattern","Image","Canvas"],function(r,t){return r["[object "+t+"]"]=!0,r},{}),ag=Ke(["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64"],function(r,t){return r["[object "+t+"Array]"]=!0,r},{}),ln=Object.prototype.toString,Ms=Array.prototype,C_=Ms.forEach,M_=Ms.filter,Uf=Ms.slice,D_=Ms.map,sv=(function(){}).constructor,Fa=sv?sv.prototype:null,Yf="__proto__",A_=2311;function Xf(){return A_++}function Ds(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];typeof console<"u"&&console.error.apply(console,r)}function X(r){if(r==null||typeof r!="object")return r;var t=r,e=ln.call(r);if(e==="[object Array]"){if(!Ki(r)){t=[];for(var i=0,n=r.length;i<n;i++)t[i]=X(r[i])}}else if(ag[e]){if(!Ki(r)){var a=r.constructor;if(a.from)t=a.from(r);else{t=new a(r.length);for(var i=0,n=r.length;i<n;i++)t[i]=r[i]}}}else if(!ng[e]&&!Ki(r)&&!nn(r)){t={};for(var o in r)r.hasOwnProperty(o)&&o!==Yf&&(t[o]=X(r[o]))}return t}function rt(r,t,e){if(!G(t)||!G(r))return e?X(t):r;for(var i in t)if(t.hasOwnProperty(i)&&i!==Yf){var n=r[i],a=t[i];G(a)&&G(n)&&!F(a)&&!F(n)&&!nn(a)&&!nn(n)&&!Ou(a)&&!Ou(n)&&!Ki(a)&&!Ki(n)?rt(n,a,e):(e||!(i in r))&&(r[i]=X(t[i]))}return r}function I_(r,t){for(var e=r[0],i=1,n=r.length;i<n;i++)e=rt(e,r[i],t);return e}function B(r,t){if(Object.assign)Object.assign(r,t);else for(var e in t)t.hasOwnProperty(e)&&e!==Yf&&(r[e]=t[e]);return r}function at(r,t,e){for(var i=ct(t),n=0;n<i.length;n++){var a=i[n];(e?t[a]!=null:r[a]==null)&&(r[a]=t[a])}return r}var L_=Oe.createCanvas;function ut(r,t){if(r){if(r.indexOf)return r.indexOf(t);for(var e=0,i=r.length;e<i;e++)if(r[e]===t)return e}return-1}function $f(r,t){var e=r.prototype;function i(){}i.prototype=t.prototype,r.prototype=new i;for(var n in e)e.hasOwnProperty(n)&&(r.prototype[n]=e[n]);r.prototype.constructor=r,r.superClass=t}function Se(r,t,e){if(r="prototype"in r?r.prototype:r,t="prototype"in t?t.prototype:t,Object.getOwnPropertyNames)for(var i=Object.getOwnPropertyNames(t),n=0;n<i.lengtLine truncated
|
||||||
|
`),a=n.length;if(a===1)return Pv(n[0],t,e,i);for(var o=new nt(0,0,0,0),s=0;s<n.length;s++){var l=Pv(n[s],t,e,i);s===0?o.copy(l):o.union(l)}return o}function Vn(r,t,e){return e==="right"?r-=t:e==="center"&&(r-=t/2),r}function Yi(r,t,e){return e==="middle"?r-=t/2:e==="bottom"&&(r-=t),r}function nh(r){return oe("国",r)}function Qe(r,t){return typeof r=="string"?r.lastIndexOf("%")>=0?parseFloat(r)/100*t:parseFloat(r):r}function rs(r,t,e){var i=t.position||"inside",n=t.distance!=null?t.distance:5,a=e.height,o=e.width,s=a/2,l=e.x,u=e.y,f="left",h="top";if(i instanceof Array)l+=Qe(i[0],e.width),u+=Qe(i[1],e.height),f=null,h=null;else switch(i){case"left":l-=n,u+=s,f="right",h="middle";break;case"right":l+=n+o,u+=s,h="middle";break;case"top":l+=o/2,u-=n,f="center",h="bottom";break;case"bottom":l+=o/2,u+=a+n,f="center";break;case"inside":l+=o/2,u+=s,f="center",h="middle";break;case"insideLeft":l+=n,u+=s,h="middle";break;case"insideRight":l+=o-n,u+=s,f="right",h="middle";break;case"insideTop":l+=o/2,u+=n,f="center";break;case"insideBottom":l+=o/2,u+=a-n,f="center",h="bottom";break;case"insideTopLeft":l+=n,u+=n;break;case"insideTopRight":l+=o-n,u+=n,f="right";break;case"insideBottomLeft":l+=n,u+=a-n,h="bottom";break;case"insideBottomRight":l+=o-n,u+=a-n,f="right",h="bottom";break}return r=r||{},r.x=l,r.y=u,r.align=f,r.verticalAlign=h,r}var Cl="__zr_normal__",Ml=la.concat(["ignore"]),K1=Ke(la,function(r,t){return r[t]=!0,r},{ignore:!1}),Pi={},Q1=new nt(0,0,0,0),Ls=function(){function r(t){this.id=Xf(),this.animators=[],this.currentStates=[],this.states={},this._init(t)}return r.prototype._init=function(t){this.attr(t)},r.prototype.drift=function(t,e,i){switch(this.draggable){case"horizontal":e=0;break;case"vertical":t=0;break}var n=this.transform;n||(n=this.transform=[1,0,0,1,0,0]),n[4]+=t,n[5]+=e,this.decomposeTransform(),this.markRedraw()},r.prototype.beforeUpdate=function(){},r.prototype.afterUpdate=function(){},r.prototype.update=function(){this.updateTransform(),this.__dirty&&this.updateInnerText()},r.prototype.updateInnerText=function(t){var e=this._textContent;if(e&&(!e.ignore||t)){this.textConfig||(this.textConfig={});var i=this.textConfig,n=i.local,a=e.innerTransformable,o=void 0,s=void 0,l=!1;a.parent=n?this:null;var u=!1;if(a.copyTransform(e),i.position!=null){var f=Q1;i.layoutRect?f.copy(i.layoutRect):f.copy(this.getBoundingRect()),n||f.applyTransform(this.transform),this.calculateTextPosition?this.calculateTextPosition(Pi,i,f):rs(Pi,i,f),a.x=Pi.x,a.y=Pi.y,o=Pi.align,s=Pi.verticalAlign;var h=i.origin;if(h&&i.rotation!=null){var c=void 0,v=void 0;h==="center"?(c=f.width*.5,v=f.height*.5):(c=Qe(h[0],f.width),v=Qe(h[1],f.height)),u=!0,a.originX=-a.x+c+(n?0:f.x),a.originY=-a.y+v+(n?0:f.y)}}i.rotation!=null&&(a.rotation=i.rotation);var p=i.offset;p&&(a.x+=p[0],a.y+=p[1],u||(a.originX=-p[0],a.originY=-p[1]));var g=i.inside==null?typeof i.position=="string"&&i.position.indexOf("inside")>=0:i.inside,d=this._innerTextDefaultStyle||(this._innerTextDefaultStyle={}),y=void 0,m=void 0,_=void 0;g&&this.canBeInsideText()?(y=i.insideFill,m=i.insideStroke,(y==null||y==="auto")&&(y=this.getInsideTextFill()),(m==null||m==="auto")&&(m=this.getInsideTextStroke(y),_=!0)):(y=i.outsideFill,m=i.outsideStroke,(y==null||y==="auto")&&(y=this.getOutsideFill()),(m==null||m==="auto")&&(m=this.getOutsideStroke(y),_=!0)),y=y||"#000",(y!==d.fill||m!==d.stroke||_!==d.autoStroke||o!==d.align||s!==d.verticalAlign)&&(l=!0,d.fill=y,d.stroke=m,d.autoStroke=_,d.align=o,d.verticalAlign=s,e.setDefaultTextStyle(d)),e.__dirty|=ae,l&&e.dirtyStyle(!0)}},r.prototype.canBeInsideText=function(){return!0},r.prototype.getInsideTextFill=function(){return"#fff"},r.prototype.getInsideTextStroke=function(t){return"#000"},r.prototype.getOutsideFill=function(){return this.__zr&&this.__zr.isDarkMode()?Ku:qu},r.prototype.getOutsideStroke=function(t){var e=this.__zr&&this.__zr.getBackgroundColor(),i=typeof e=="string"&&ee(e);i||(i=[255,255,255,1]);for(var n=i[3],a=this.__zr.isDarkMode(),o=0;o<3;o++)i[o]=i[o]*n+(a?0:255)*(1-n);return i[3]=1,Pe(i,"rgba")},r.prototype.traverse=function(t,e){},r.prototype.attrKV=function(t,e){t==="textConfig"?this.setTextConfig(e):t==="textContent"?this.setTextContent(e):t==="clipPath"?this.setClipPath(e):t==="extra"?(this.extra=this.extra||{},B(this.extra,e)):this[t]=e},r.prototype.hide=function(){this.ignore=!0,this.markRedraw()},r.prototype.show=function(){this.ignore=!1,this.markRedraw()},r.prototype.attr=function(t,e){if(typeof t=="string")this.attrKV(t,e);else if(G(t))for(var i=t,n=ct(i),a=0;a<n.length;a++){var o=n[a];this.attrKV(o,t[o])}return this.markRedraw(),this},r.prototype.saveCurrentToNormalState=function(t){this._innerSaveToNormal(t);for(var e=this._normalState,i=0;i<this.animators.length;i++){var n=this.animators[i],a=n.__fromStateTransition;if(!(n.getLoop()||a&&a!==Cl)){var o=n.targetName,s=o?e[o]:e;n.saveTo(s)}}},r.prototype._innerSaveToNormal=function(t){var e=this._normalState;e||(e=this._normalState={}),t.textConfi
Line truncated
|
||||||
|
* ZRender, a high performance 2d drawing library.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2013, Baidu Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* LICENSE
|
||||||
|
* https://github.com/ecomfe/zrender/blob/master/LICENSE.txt
|
||||||
|
*/var Bo={},si={};function rS(r){delete si[r]}function iS(r){if(!r)return!1;if(typeof r=="string")return sa(r,1)<Zu;if(r.colorStops){for(var t=r.colorStops,e=0,i=t.length,n=0;n<i;n++)e+=sa(t[n].color,1);return e/=i,e<Zu}return!1}var nS=function(){function r(t,e,i){var n=this;this._sleepAfterStill=10,this._stillFrameAccum=0,this._needsRefresh=!0,this._needsRefreshHover=!0,this._darkMode=!1,i=i||{},this.dom=e,this.id=t;var a=new y1,o=i.renderer||"canvas";Bo[o]||(o=ct(Bo)[0]),i.useDirtyRect=i.useDirtyRect==null?!1:i.useDirtyRect;var s=new Bo[o](e,a,i,t),l=i.ssr||s.ssrOnly;this.storage=a,this.painter=s;var u=!Z.node&&!Z.worker&&!l?new $1(s.getViewportRoot(),s.root):null,f=i.useCoarsePointer,h=f==null||f==="auto"?Z.touchEventsSupported:!!f,c=44,v;h&&(v=j(i.pointerSize,c)),this.handler=new _g(a,s,u,s.root,v),this.animation=new V1({stage:{update:l?null:function(){return n._flush(!0)}}}),l||this.animation.start()}return r.prototype.add=function(t){this._disposed||!t||(this.storage.addRoot(t),t.addSelfToZr(this),this.refresh())},r.prototype.remove=function(t){this._disposed||!t||(this.storage.delRoot(t),t.removeSelfFromZr(this),this.refresh())},r.prototype.configLayer=function(t,e){this._disposed||(this.painter.configLayer&&this.painter.configLayer(t,e),this.refresh())},r.prototype.setBackgroundColor=function(t){this._disposed||(this.painter.setBackgroundColor&&this.painter.setBackgroundColor(t),this.refresh(),this._backgroundColor=t,this._darkMode=iS(t))},r.prototype.getBackgroundColor=function(){return this._backgroundColor},r.prototype.setDarkMode=function(t){this._darkMode=t},r.prototype.isDarkMode=function(){return this._darkMode},r.prototype.refreshImmediately=function(t){this._disposed||(t||this.animation.update(!0),this._needsRefresh=!1,this.painter.refresh(),this._needsRefresh=!1)},r.prototype.refresh=function(){this._disposed||(this._needsRefresh=!0,this.animation.start())},r.prototype.flush=function(){this._disposed||this._flush(!1)},r.prototype._flush=function(t){var e,i=Xi();this._needsRefresh&&(e=!0,this.refreshImmediately(t)),this._needsRefreshHover&&(e=!0,this.refreshHoverImmediately());var n=Xi();e?(this._stillFrameAccum=0,this.trigger("rendered",{elapsedTime:n-i})):this._sleepAfterStill>0&&(this._stillFrameAccum++,this._stillFrameAccum>this._sleepAfterStill&&this.animation.stop())},r.prototype.setSleepAfterStill=function(t){this._sleepAfterStill=t},r.prototype.wakeUp=function(){this._disposed||(this.animation.start(),this._stillFrameAccum=0)},r.prototype.refreshHover=function(){this._needsRefreshHover=!0},r.prototype.refreshHoverImmediately=function(){this._disposed||(this._needsRefreshHover=!1,this.painter.refreshHover&&this.painter.getType()==="canvas"&&this.painter.refreshHover())},r.prototype.resize=function(t){this._disposed||(t=t||{},this.painter.resize(t.width,t.height),this.handler.resize())},r.prototype.clearAnimation=function(){this._disposed||this.animation.clear()},r.prototype.getWidth=function(){if(!this._disposed)return this.painter.getWidth()},r.prototype.getHeight=function(){if(!this._disposed)return this.painter.getHeight()},r.prototype.setCursorStyle=function(t){this._disposed||this.handler.setCursorStyle(t)},r.prototype.findHover=function(t,e){if(!this._disposed)return this.handler.findHover(t,e)},r.prototype.on=function(t,e,i){return this._disposed||this.handler.on(t,e,i),this},r.prototype.off=function(t,e){this._disposed||this.handler.off(t,e)},r.prototype.trigger=function(t,e){this._disposed||this.handler.trigger(t,e)},r.prototype.clear=function(){if(!this._disposed){for(var t=this.storage.getRoots(),e=0;e<t.length;e++)t[e]instanceof St&&t[e].removeSelfFromZr(this);this.storage.delAllRoots(),this.painter.clear()}},r.prototype.dispose=function(){this._disposed||(this.animation.stop(),this.clear(),this.storage.dispose(),this.painter.dispose(),this.handler.dispose(),this.animation=this.storage=this.painter=this.handler=null,this._disposed=!0,rS(this.id))},r}();function Qu(r,t){var e=new nS(Xf(),r,t);return si[e.id]=e,e}function aS(r){r.dispose()}function oS(){for(var r in si)si.hasOwnProperty(r)&&si[r].dispose();si={}}function sS(r){return si[r]}function Og(r,t){Bo[r]=t}var Ju;function lS(r){if(typeof Ju=="function")return Ju(r)}function kg(r){Ju=r}var uS="5.6.0";const fS=Object.freeze(Object.defineProperty({__proto__:null,dispose:aS,disposeAll:oS,getElementSSRData:lS,getInstance:sS,init:Qu,registerPainter:Og,registerSSRDataGetter:kg,version:uS},Symbol.toStringTag,{value:"Module"}));var Rv=1e-4,Bg=20;function hS(r){return r.replace(/^\s+|\s+$/g,"")}function Be(r,t,e,i){var n=t[0],a=t[1],o=e[0],s=e[1],l=a-n,u=s-o;if(l===0)return u===0?o:(o+s)/2;if(i)if(l>0){if(r<=n)return o;if(r>=a)return s}else{if(r>=n)return o;if(r<=a)return s}else{if(r===n)return o;if(r===a)return s}return(r-n)/l*u+o}function dt(r,t){switch(r){case"center":case"middle":r="50%";break;case"left":case"top":r="0%";break;case"right":case"bottom":r="100%";break}return H(r)?hS(r).match(/%$/)?parseFloat(r)/100*t:parseLine truncated
|
||||||
|
`);n=Qg(t,e,i,n);for(var o=0,s=a.length;o<s;o++)a[o]=Jg(a[o],n);return a.join(`
|
||||||
|
`)}function Qg(r,t,e,i){i=i||{};var n=B({},i);n.font=t,e=j(e,"..."),n.maxIterations=j(i.maxIterations,2);var a=n.minChar=j(i.minChar,0);n.cnCharWidth=oe("国",t);var o=n.ascCharWidth=oe("a",t);n.placeholder=j(i.placeholder,"");for(var s=r=Math.max(0,r-1),l=0;l<a&&s>=o;l++)s-=o;var u=oe(e,t);return u>s&&(e="",u=0),s=r-u,n.ellipsis=e,n.ellipsisWidth=u,n.contentWidth=s,n.containerWidth=r,n}function Jg(r,t){var e=t.containerWidth,i=t.font,n=t.contentWidth;if(!e)return"";var a=oe(r,i);if(a<=e)return r;for(var o=0;;o++){if(a<=n||o>=t.maxIterations){r+=t.ellipsis;break}var s=o===0?YS(r,n,t.ascCharWidth,t.cnCharWidth):a>0?Math.floor(r.length*n/a):0;r=r.substr(0,s),a=oe(r,i)}return r===""&&(r=t.placeholder),r}function YS(r,t,e,i){for(var n=0,a=0,o=r.length;a<o&&n<t;a++){var s=r.charCodeAt(a);n+=0<=s&&s<=127?e:i}return a}function XS(r,t){r!=null&&(r+="");var e=t.overflow,i=t.padding,n=t.font,a=e==="truncate",o=nh(n),s=j(t.lineHeight,o),l=!!t.backgroundColor,u=t.lineOverflow==="truncate",f=t.width,h;f!=null&&(e==="break"||e==="breakAll")?h=r?jg(r,t.font,f,e==="breakAll",0).lines:[]:h=r?r.split(`
|
||||||
|
`):[];var c=h.length*s,v=j(t.height,c);if(c>v&&u){var p=Math.floor(v/s);h=h.slice(0,p)}if(r&&a&&f!=null)for(var g=Qg(f,n,t.ellipsis,{minChar:t.truncateMinChar,placeholder:t.placeholder}),d=0;d<h.length;d++)h[d]=Jg(h[d],g);for(var y=v,m=0,d=0;d<h.length;d++)m=Math.max(oe(h[d],n),m);f==null&&(f=m);var _=m;return i&&(y+=i[0]+i[2],_+=i[1]+i[3],f+=i[1]+i[3]),l&&(_=f),{lines:h,height:v,outerWidth:_,outerHeight:y,lineHeight:s,calculatedLineHeight:o,contentWidth:m,contentHeight:c,width:f}}var $S=function(){function r(){}return r}(),Nv=function(){function r(t){this.tokens=[],t&&(this.tokens=t)}return r}(),ZS=function(){function r(){this.width=0,this.height=0,this.contentWidth=0,this.contentHeight=0,this.outerWidth=0,this.outerHeight=0,this.lines=[]}return r}();function qS(r,t){var e=new ZS;if(r!=null&&(r+=""),!r)return e;for(var i=t.width,n=t.height,a=t.overflow,o=(a==="break"||a==="breakAll")&&i!=null?{width:i,accumWidth:0,breakAll:a==="breakAll"}:null,s=Ll.lastIndex=0,l;(l=Ll.exec(r))!=null;){var u=l.index;u>s&&Pl(e,r.substring(s,u),t,o),Pl(e,l[2],t,o,l[1]),s=Ll.lastIndex}s<r.length&&Pl(e,r.substring(s,r.length),t,o);var f=[],h=0,c=0,v=t.padding,p=a==="truncate",g=t.lineOverflow==="truncate";function d(O,k,z){O.width=k,O.lineHeight=z,h+=z,c=Math.max(c,k)}t:for(var y=0;y<e.lines.length;y++){for(var m=e.lines[y],_=0,w=0,b=0;b<m.tokens.length;b++){var S=m.tokens[b],x=S.styleName&&t.rich[S.styleName]||{},T=S.textPadding=x.padding,D=T?T[1]+T[3]:0,A=S.font=x.font||t.font;S.contentHeight=nh(A);var M=j(x.height,S.contentHeight);if(S.innerHeight=M,T&&(M+=T[0]+T[2]),S.height=M,S.lineHeight=qi(x.lineHeight,t.lineHeight,M),S.align=x&&x.align||t.align,S.verticalAlign=x&&x.verticalAlign||"middle",g&&n!=null&&h+S.lineHeight>n){b>0?(m.tokens=m.tokens.slice(0,b),d(m,w,_),e.lines=e.lines.slice(0,y+1)):e.lines=e.lines.slice(0,y);break t}var I=x.width,L=I==null||I==="auto";if(typeof I=="string"&&I.charAt(I.length-1)==="%")S.percentWidth=I,f.push(S),S.contentWidth=oe(S.text,A);else{if(L){var P=x.backgroundColor,R=P&&P.image;R&&(R=US(R),Es(R)&&(S.width=Math.max(S.width,R.width*M/R.height)))}var E=p&&i!=null?i-w:null;E!=null&&E<S.width?!L||E<D?(S.text="",S.width=S.contentWidth=0):(S.text=Kg(S.text,E-D,A,t.ellipsis,{minChar:t.truncateMinChar}),S.width=S.contentWidth=oe(S.text,A)):S.contentWidth=oe(S.text,A)}S.width+=D,w+=S.width,x&&(_=Math.max(_,S.lineHeight))}d(m,w,_)}e.outerWidth=e.width=j(i,c),e.outerHeight=e.height=j(n,h),e.contentHeight=h,e.contentWidth=c,v&&(e.outerWidth+=v[1]+v[3],e.outerHeight+=v[0]+v[2]);for(var y=0;y<f.length;y++){var S=f[y],V=S.percentWidth;S.width=parseInt(V,10)/100*e.width}return e}function Pl(r,t,e,i,n){var a=t==="",o=n&&e.rich[n]||{},s=r.lines,l=o.font||e.font,u=!1,f,h;if(i){var c=o.padding,v=c?c[1]+c[3]:0;if(o.width!=null&&o.width!=="auto"){var p=Qe(o.width,i.width)+v;s.length>0&&p+i.accumWidth>i.width&&(f=t.split(`
|
||||||
|
`),u=!0),i.accumWidth=p}else{var g=jg(t,l,i.width,i.breakAll,i.accumWidth);i.accumWidth=g.accumWidth+v,h=g.linesWidths,f=g.lines}}else f=t.split(`
|
||||||
|
`);for(var d=0;d<f.length;d++){var y=f[d],m=new $S;if(m.styleName=n,m.text=y,m.isLineHolder=!y&&!a,typeof o.width=="number"?m.width=o.width:m.width=h?h[d]:oe(y,l),!d&&!u){var _=(s[s.length-1]||(s[0]=new Nv)).tokens,w=_.length;w===1&&_[0].isLineHolder?_[0]=m:(y||!w||a)&&_.push(m)}else s.push(new Nv([m]))}}function KS(r){var t=r.charCodeAt(0);return t>=32&&t<=591||t>=880&&t<=4351||t>=4608&&t<=5119||t>=7680&&t<=8303}var QS=Ke(",&?/;] ".split(""),function(r,t){return r[t]=!0,r},{});function JS(r){return KS(r)?!!QS[r]:!0}function jg(r,t,e,i,n){for(var a=[],o=[],s="",l="",u=0,f=0,h=0;h<r.length;h++){var c=r.charAt(h);if(c===`
|
||||||
|
`){l&&(s+=l,f+=u),a.push(s),o.push(f),s="",l="",u=0,f=0;continue}var v=oe(c,t),p=i?!1:!JS(c);if(a.length?f+v>e:n+f+v>e){f?(s||l)&&(p?(s||(s=l,l="",u=0,f=u),a.push(s),o.push(f-u),l+=c,u+=v,s="",f=u):(l&&(s+=l,l="",u=0),a.push(s),o.push(f),s=c,f=v)):p?(a.push(l),o.push(u),l=c,u=v):(a.push(c),o.push(v));continue}f+=v,p?(l+=c,u+=v):(l&&(s+=l,l="",u=0),s+=c)}return!a.length&&!s&&(s=r,l="",u=0),l&&(s+=l),s&&(a.push(s),o.push(f)),a.length===1&&(f+=n),{accumWidth:f,lines:a,linesWidths:o}}var rf="__zr_style_"+Math.round(Math.random()*10),ci={shadowBlur:0,shadowOffsetX:0,shadowOffsetY:0,shadowColor:"#000",opacity:1,blend:"source-over"},Os={style:{shadowBlur:!0,shadowOffsetX:!0,shadowOffsetY:!0,shadowColor:!0,opacity:!0}};ci[rf]=!0;var Fv=["z","z2","invisible"],jS=["invisible"],La=function(r){N(t,r);function t(e){return r.call(this,e)||this}return t.prototype._init=function(e){for(var i=ct(e),n=0;n<i.length;n++){var a=i[n];a==="style"?this.useStyle(e[a]):r.prototype.attrKV.call(this,a,e[a])}this.style||this.useStyle({})},t.prototype.beforeBrush=function(){},t.prototype.afterBrush=function(){},t.prototype.innerBeforeBrush=function(){},t.prototype.innerAfterBrush=function(){},t.prototype.shouldBePainted=function(e,i,n,a){var o=this.transform;if(this.ignore||this.invisible||this.style.opacity===0||this.culling&&tw(this,e,i)||o&&!o[0]&&!o[3])return!1;if(n&&this.__clipPaths){for(var s=0;s<this.__clipPaths.length;++s)if(this.__clipPaths[s].isZeroArea())return!1}if(a&&this.parent)for(var l=this.parent;l;){if(l.ignore)return!1;l=l.parent}return!0},t.prototype.contain=function(e,i){return this.rectContain(e,i)},t.prototype.traverse=function(e,i){e.call(i,this)},t.prototype.rectContain=function(e,i){var n=this.transformCoordToLocal(e,i),a=this.getBoundingRect();return a.contain(n[0],n[1])},t.prototype.getPaintRect=function(){var e=this._paintRect;if(!this._paintRect||this.__dirty){var i=this.transform,n=this.getBoundingRect(),a=this.style,o=a.shadowBlur||0,s=a.shadowOffsetX||0,l=a.shadowOffsetY||0;e=this._paintRect||(this._paintRect=new nt(0,0,0,0)),i?nt.applyTransform(e,n,i):e.copy(n),(o||s||l)&&(e.width+=o*2+Math.abs(s),e.height+=o*2+Math.abs(l),e.x=Math.min(e.x,e.x+s-o),e.y=Math.min(e.y,e.y+l-o));var u=this.dirtyRectTolerance;e.isZero()||(e.x=Math.floor(e.x-u),e.y=Math.floor(e.y-u),e.width=Math.ceil(e.width+1+u*2),e.height=Math.ceil(e.height+1+u*2))}return e},t.prototype.setPrevPaintRect=function(e){e?(this._prevPaintRect=this._prevPaintRect||new nt(0,0,0,0),this._prevPaintRect.copy(e)):this._prevPaintRect=null},t.prototype.getPrevPaintRect=function(){return this._prevPaintRect},t.prototype.animateStyle=function(e){return this.animate("style",e)},t.prototype.updateDuringAnimation=function(e){e==="style"?this.dirtyStyle():this.markRedraw()},t.prototype.attrKV=function(e,i){e!=="style"?r.prototype.attrKV.call(this,e,i):this.style?this.setStyle(i):this.useStyle(i)},t.prototype.setStyle=function(e,i){return typeof e=="string"?this.style[e]=i:B(this.style,e),this.dirtyStyle(),this},t.prototype.dirtyStyle=function(e){e||this.markRedraw(),this.__dirty|=Fn,this._rect&&(this._rect=null)},t.prototype.dirty=function(){this.dirtyStyle()},t.prototype.styleChanged=function(){return!!(this.__dirty&Fn)},t.prototype.styleUpdated=function(){this.__dirty&=~Fn},t.prototype.createStyle=function(e){return Ta(ci,e)},t.prototype.useStyle=function(e){e[rf]||(e=this.createStyle(e)),this.__inHover?this.__hoverStyle=e:this.style=e,this.dirtyStyle()},t.prototype.isStyleObject=function(e){return e[rf]},t.prototype._innerSaveToNormal=function(e){r.prototype._innerSaveToNormal.call(this,e);var i=this._normalState;e.style&&!i.style&&(i.style=this._mergeStyle(this.createStyle(),this.style)),this._savePrimaryToNormal(e,i,Fv)},t.prototype._applyStateObj=function(e,i,n,a,o,s){r.prototype._applyStateObj.call(this,e,i,n,a,o,s);var l=!(i&&a),u;if(i&&i.style?o?a?u=i.style:(u=this._mergeStyle(this.createStyle(),n.style),this._mergeStyle(u,i.style)):(u=this._mergeStyle(this.createStyle(),a?this.style:n.style),this._mergeStyle(u,i.style)):l&&(u=n.style),u)if(o){var f=this.style;if(this.style=this.createStyle(l?{}:f),l)for(var h=ct(f),c=0;c<h.length;c++){var v=h[c];v in u&&(u[v]=u[v],this.style[v]=f[v])}for(var p=ct(u),c=0;c<p.length;c++){var v=p[c];this.style[v]=this.style[v]}this._transitionState(e,{style:u},s,this.getAnimationStyleProps())}else this.useStyle(u);for(var g=this.__inHover?jS:Fv,c=0;c<g.length;c++){var v=g[c];i&&i[v]!=null?this[v]=i[v]:l&&n[v]!=null&&(this[v]=n[v])}},t.prototype._mergeStates=function(e){for(var i=r.prototype._mergeStates.call(this,e),n,a=0;a<e.length;a++){var o=e[a];o.style&&(n=n||{},this._mergeStyle(n,o.style))}return n&&(i.style=n),i},t.prototype._mergeStyle=function(e,i){return B(e,i),e},t.prototype.getAnimationStyleProps=function(){return Os},t.initDefaultProps=function(){var e=t.prototype;e.type="displayable",e.invisible=!1,e.z=0,e.z2=0,e.zlevel=0,e.culling=!1,e.cursor="pointer",e.rectHover=!1,e.incremental=!1,e._rect=null,e.dirty
Line truncated
|
||||||
|
yyyy`);var i=me(t),n=e?"getUTC":"get",a=i[n+"FullYear"](),o=i[n+"Month"]()+1,s=i[n+"Date"](),l=i[n+"Hours"](),u=i[n+"Minutes"](),f=i[n+"Seconds"](),h=i[n+"Milliseconds"]();return r=r.replace("MM",Gt(o,2)).replace("M",o).replace("yyyy",a).replace("yy",Gt(a%100+"",2)).replace("dd",Gt(s,2)).replace("d",s).replace("hh",Gt(l,2)).replace("h",l).replace("mm",Gt(u,2)).replace("m",u).replace("ss",Gt(f,2)).replace("s",f).replace("SSS",Gt(h,3)),r}function ex(r){return r&&r.charAt(0).toUpperCase()+r.substr(1)}function xi(r,t){return t=t||"transparent",H(r)?r:G(r)&&r.colorStops&&(r.colorStops[0]||{}).color||t}var Vo=C,rx=["left","right","top","bottom","width","height"],io=[["width","left","right"],["height","top","bottom"]];function Lh(r,t,e,i,n){var a=0,o=0;i==null&&(i=1/0),n==null&&(n=1/0);var s=0;t.eachChild(function(l,u){var f=l.getBoundingRect(),h=t.childAt(u+1),c=h&&h.getBoundingRect(),v,p;if(r==="horizontal"){var g=f.width+(c?-c.x+f.x:0);v=a+g,v>i||l.newline?(a=0,v=g,o+=s+e,s=f.height):s=Math.max(s,f.height)}else{var d=f.height+(c?-c.y+f.y:0);p=o+d,p>n||l.newline?(a+=s+e,o=0,p=d,s=f.width):s=Math.max(s,f.width)}l.newline||(l.x=a,l.y=o,l.markRedraw(),r==="horizontal"?a=v+e:o=p+e)})}var rn=Lh;yt(Lh,"vertical");yt(Lh,"horizontal");function Br(r,t,e){e=hn(e||0);var i=t.width,n=t.height,a=dt(r.left,i),o=dt(r.top,n),s=dt(r.right,i),l=dt(r.bottom,n),u=dt(r.width,i),f=dt(r.height,n),h=e[2]+e[0],c=e[1]+e[3],v=r.aspect;switch(isNaN(u)&&(u=i-s-c-a),isNaN(f)&&(f=n-l-h-o),v!=null&&(isNaN(u)&&isNaN(f)&&(v>i/n?u=i*.8:f=n*.8),isNaN(u)&&(u=v*f),isNaN(f)&&(f=u/v)),isNaN(a)&&(a=i-s-u-c),isNaN(o)&&(o=n-l-f-h),r.left||r.right){case"center":a=i/2-u/2-e[3];break;case"right":a=i-u-c;break}switch(r.top||r.bottom){case"middle":case"center":o=n/2-f/2-e[0];break;case"bottom":o=n-f-h;break}a=a||0,o=o||0,isNaN(u)&&(u=i-c-a-(s||0)),isNaN(f)&&(f=n-h-o-(l||0));var p=new nt(a+e[3],o+e[0],u,f);return p.margin=e,p}function ix(r,t,e,i,n,a){a=a||r,a.x=r.x,a.y=r.y;var o;if(o=r.getBoundingRect(),r.needLocalTransform()){var s=r.getLocalTransform();o=o.clone(),o.applyTransform(s)}var l=Br(at({width:o.width,height:o.height},t),e,i),u=l.x-o.x,f=l.y-o.y;return a.x+=u,a.y+=f,a===r&&r.markRedraw(),!0}function da(r){var t=r.layoutMode||r.constructor.layoutMode;return G(t)?t:t?{type:t}:null}function on(r,t,e){var i=e&&e.ignoreSize;!F(i)&&(i=[i,i]);var n=o(io[0],0),a=o(io[1],1);u(io[0],r,n),u(io[1],r,a);function o(f,h){var c={},v=0,p={},g=0,d=2;if(Vo(f,function(_){p[_]=r[_]}),Vo(f,function(_){s(t,_)&&(c[_]=p[_]=t[_]),l(c,_)&&v++,l(p,_)&&g++}),i[h])return l(t,f[1])?p[f[2]]=null:l(t,f[2])&&(p[f[1]]=null),p;if(g===d||!v)return p;if(v>=d)return c;for(var y=0;y<f.length;y++){var m=f[y];if(!s(c,m)&&s(r,m)){c[m]=r[m];break}}return c}function s(f,h){return f.hasOwnProperty(h)}function l(f,h){return f[h]!=null&&f[h]!=="auto"}function u(f,h,c){Vo(f,function(v){h[v]=c[v]})}}function Js(r){return nx({},r)}function nx(r,t){return t&&r&&Vo(rx,function(e){t.hasOwnProperty(e)&&(r[e]=t[e])}),r}var ax=Tt(),ot=function(r){N(t,r);function t(e,i,n){var a=r.call(this,e,i,n)||this;return a.uid=Xs("ec_cpt_model"),a}return t.prototype.init=function(e,i,n){this.mergeDefaultAndTheme(e,n)},t.prototype.mergeDefaultAndTheme=function(e,i){var n=da(this),a=n?Js(e):{},o=i.getTheme();rt(e,o.get(this.mainType)),rt(e,this.getDefaultOption()),n&&on(e,a,n)},t.prototype.mergeOption=function(e,i){rt(this.option,e,!0);var n=da(this);n&&on(this.option,e,n)},t.prototype.optionUpdated=function(e,i){},t.prototype.getDefaultOption=function(){var e=this.constructor;if(!kS(e))return e.defaultOption;var i=ax(this);if(!i.defaultOption){for(var n=[],a=e;a;){var o=a.prototype.defaultOption;o&&n.push(o),a=a.superClass}for(var s={},l=n.length-1;l>=0;l--)s=rt(s,n[l],!0);i.defaultOption=s}return i.defaultOption},t.prototype.getReferringComponents=function(e,i){var n=e+"Index",a=e+"Id";return Ia(this.ecModel,e,{index:this.get(n,!0),id:this.get(a,!0)},i)},t.prototype.getBoxLayoutParams=function(){var e=this;return{left:e.get("left"),top:e.get("top"),right:e.get("right"),bottom:e.get("bottom"),width:e.get("width"),height:e.get("height")}},t.prototype.getZLevelKey=function(){return""},t.prototype.setZLevel=function(e){this.option.zlevel=e},t.protoInitialize=function(){var e=t.prototype;e.type="component",e.id="",e.name="",e.mainType="",e.subType="",e.componentIndex=0}(),t}(pt);Zg(ot,pt);Rs(ot);Gb(ot);Wb(ot,ox);function ox(r){var t=[];return C(ot.getClassesByMainType(r),function(e){t=t.concat(e.dependencies||e.prototype.dependencies||[])}),t=W(t,function(e){return qe(e).main}),r!=="dataset"&&ut(t,"dataset")<=0&&t.unshift("dataset"),t}var Yy="";typeof navigator<"u"&&(Yy=navigator.platform||"");var Bi="rgba(0, 0, 0, 0.2)";const sx={darkMode:"auto",colorBy:"series",color:["#5470c6","#91cc75","#fac858","#ee6666","#73c0de","#3ba272","#fc8452","#9a60b4","#ea7ccc"],gradientColor:["#f6efa6","#d88273","#bf444c"],aria:{decal:{decals:[{color:Bi,dashArrayX:[1,0],dashArrayY:[2,5],symbolSize:1,rotation:Math.PI/6},{color:Bi,symbol:"cir
Line truncated
|
||||||
|
`,`
|
||||||
|
|
||||||
|
`,`
|
||||||
|
|
||||||
|
|
||||||
|
`];function ya(r,t){return t.type=r,t}function pf(r){return r.type==="section"}function vm(r){return pf(r)?lT:uT}function cm(r){if(pf(r)){var t=0,e=r.blocks.length,i=e>1||e>0&&!r.noHeader;return C(r.blocks,function(n){var a=cm(n);a>=t&&(t=a+ +(i&&(!a||pf(n)&&!n.noHeader)))}),t}return 0}function lT(r,t,e,i){var n=t.noHeader,a=fT(cm(t)),o=[],s=t.blocks||[];ke(!s||F(s)),s=s||[];var l=r.orderMode;if(t.sortBlocks&&l){s=s.slice();var u={valueAsc:"asc",valueDesc:"desc"};if(_i(u,l)){var f=new Xx(u[l],null);s.sort(function(p,g){return f.evaluate(p.sortParam,g.sortParam)})}else l==="seriesDesc"&&s.reverse()}C(s,function(p,g){var d=t.valueFormatter,y=vm(p)(d?B(B({},r),{valueFormatter:d}):r,p,g>0?a.html:0,i);y!=null&&o.push(y)});var h=r.renderMode==="richText"?o.join(a.richText):df(o.join(""),n?e:a.html);if(n)return h;var c=hf(t.header,"ordinal",r.useUTC),v=hm(i,r.renderMode).nameStyle;return r.renderMode==="richText"?pm(r,c,v)+a.richText+h:df('<div style="'+v+";"+fm+';">'+Qt(c)+"</div>"+h,e)}function uT(r,t,e,i){var n=r.renderMode,a=t.noName,o=t.noValue,s=!t.markerType,l=t.name,u=r.useUTC,f=t.valueFormatter||r.valueFormatter||function(w){return w=F(w)?w:[w],W(w,function(b,S){return hf(b,F(v)?v[S]:v,u)})};if(!(a&&o)){var h=s?"":r.markupStyleCreator.makeTooltipMarker(t.markerType,t.markerColor||"#333",n),c=a?"":hf(l,"ordinal",u),v=t.valueType,p=o?[]:f(t.value,t.dataIndex),g=!s||!a,d=!s&&a,y=hm(i,n),m=y.nameStyle,_=y.valueStyle;return n==="richText"?(s?"":h)+(a?"":pm(r,c,m))+(o?"":cT(r,p,g,d,_)):df((s?"":h)+(a?"":hT(c,!s,m))+(o?"":vT(p,g,d,_)),e)}}function Zc(r,t,e,i,n,a){if(r){var o=vm(r),s={useUTC:n,renderMode:e,orderMode:i,markupStyleCreator:t,valueFormatter:r.valueFormatter};return o(s,r,0,a)}}function fT(r){return{html:oT[r],richText:sT[r]}}function df(r,t){var e='<div style="clear:both"></div>',i="margin: "+t+"px 0 0";return'<div style="'+i+";"+fm+';">'+r+e+"</div>"}function hT(r,t,e){var i=t?"margin-left:2px":"";return'<span style="'+e+";"+i+'">'+Qt(r)+"</span>"}function vT(r,t,e,i){var n=e?"10px":"20px",a=t?"float:right;margin-left:"+n:"";return r=F(r)?r:[r],'<span style="'+a+";"+i+'">'+W(r,function(o){return Qt(o)}).join(" ")+"</span>"}function pm(r,t,e){return r.markupStyleCreator.wrapRichTextStyle(t,e)}function cT(r,t,e,i,n){var a=[n],o=i?10:20;return e&&a.push({padding:[0,0,0,o],align:"right"}),r.markupStyleCreator.wrapRichTextStyle(F(t)?t.join(" "):t,a)}function pT(r,t){var e=r.getData().getItemVisual(t,"style"),i=e[r.visualDrawType];return xi(i)}function dm(r,t){var e=r.get("padding");return e??(t==="richText"?[8,10]:10)}var eu=function(){function r(){this.richTextStyles={},this._nextStyleNameId=Gg()}return r.prototype._generateStyleName=function(){return"__EC_aUTo_"+this._nextStyleNameId++},r.prototype.makeTooltipMarker=function(t,e,i){var n=i==="richText"?this._generateStyleName():null,a=Uy({color:e,type:t,renderMode:i,markerId:n});return H(a)?a:(this.richTextStyles[n]=a.style,a.content)},r.prototype.wrapRichTextStyle=function(t,e){var i={};F(e)?C(e,function(a){return B(i,a)}):B(i,e);var n=this._generateStyleName();return this.richTextStyles[n]=i,"{"+n+"|"+t+"}"},r}();function dT(r){var t=r.series,e=r.dataIndex,i=r.multipleSeries,n=t.getData(),a=n.mapDimensionsAll("defaultedTooltip"),o=a.length,s=t.getRawValue(e),l=F(s),u=pT(t,e),f,h,c,v;if(o>1||l&&!o){var p=gT(s,t,e,a,u);f=p.inlineValues,h=p.inlineValueTypes,c=p.blocks,v=p.inlineValues[0]}else if(o){var g=n.getDimensionInfo(a[0]);v=f=sn(n,e,a[0]),h=g.type}else v=f=l?s[0]:s;var d=lh(t),y=d&&t.name||"",m=n.getName(e),_=i?y:m;return ya("section",{header:y,noHeader:i||!d,sortParam:v,blocks:[ya("nameValue",{markerType:"item",markerColor:u,name:_,noName:!Ae(_),value:f,valueType:h,dataIndex:e})].concat(c||[])})}function gT(r,t,e,i,n){var a=t.getData(),o=Ke(r,function(h,c,v){var p=a.getDimensionInfo(v);return h=h||p&&p.tooltip!==!1&&p.displayName!=null},!1),s=[],l=[],u=[];i.length?C(i,function(h){f(sn(a,e,h),h)}):C(r,f);function f(h,c){var v=a.getDimensionInfo(c);!v||v.otherDims.tooltip===!1||(o?u.push(ya("nameValue",{markerType:"subItem",markerColor:n,name:v.displayName,value:h,valueType:v.type})):(s.push(h),l.push(v.type)))}return{inlineValues:s,inlineValueTypes:l,blocks:u}}var gr=Tt();function oo(r,t){return r.getName(t)||r.getId(t)}var yT="__universalTransitionEnabled",$t=function(r){N(t,r);function t(){var e=r!==null&&r.apply(this,arguments)||this;return e._selectedDataIndicesMap={},e}return t.prototype.init=function(e,i,n){this.seriesIndex=this.componentIndex,this.dataTask=ea({count:_T,reset:ST}),this.dataTask.context={model:this},this.mergeDefaultAndTheme(e,n);var a=gr(this).sourceManager=new aT(this);a.prepareSource();var o=this.getInitialData(e,n);Kc(o,this),this.dataTask.context.data=o,gr(this).dataBeforeProcessed=o,qc(this),this._initSelectedMapFromData(o)},t.prototype.mergeDefaultAndTheme=function(e,i){var n=da(this),a=n?Js(e):{},o=this.subType;ot.hasClass(o)&&(o+="Series"),rt(e,i.getTheme().get(this.subType)),rt(e,this.getDefaultOption(
Line truncated
|
||||||
|
|
||||||
|
`:"<br/>",y=h.join(d);this._showOrMove(s,function(){this._updateContentNotChangedOnAxis(e,u)?this._updatePosition(s,v,o[0],o[1],this._tooltipContent,u):this._showTooltipContent(s,y,u,Math.random()+"",o[0],o[1],v,null,c)})},t.prototype._showSeriesItemTooltip=function(e,i,n){var a=this._ecModel,o=it(i),s=o.seriesIndex,l=a.getSeriesByIndex(s),u=o.dataModel||l,f=o.dataIndex,h=o.dataType,c=u.getData(h),v=this._renderMode,p=e.positionDefault,g=Bn([c.getItemModel(f),u,l&&(l.coordinateSystem||{}).model],this._tooltipModel,p?{position:p}:null),d=g.get("trigger");if(!(d!=null&&d!=="item")){var y=u.getDataParams(f,h),m=new eu;y.marker=m.makeTooltipMarker("item",xi(y.color),v);var _=Wc(u.formatTooltip(f,!1,h)),w=g.get("order"),b=g.get("valueFormatter"),S=_.frag,x=S?Zc(b?B({valueFormatter:b},S):S,m,v,w,a.get("useUTC"),g.get("textStyle")):_.text,T="item_"+u.name+"_"+f;this._showOrMove(g,function(){this._showTooltipContent(g,x,y,T,e.offsetX,e.offsetY,e.position,e.target,m)}),n({type:"showTip",dataIndexInside:f,dataIndex:c.getRawIndex(f),seriesIndex:s,from:this.uid})}},t.prototype._showComponentItemTooltip=function(e,i,n){var a=this._renderMode==="html",o=it(i),s=o.tooltipConfig,l=s.option||{},u=l.encodeHTMLContent;if(H(l)){var f=l;l={content:f,formatter:f},u=!0}u&&a&&l.content&&(l=X(l),l.content=Qt(l.content));var h=[l],c=this._ecModel.getComponent(o.componentMainType,o.componentIndex);c&&h.push(c),h.push({formatter:l.content});var v=e.positionDefault,p=Bn(h,this._tooltipModel,v?{position:v}:null),g=p.get("content"),d=Math.random()+"",y=new eu;this._showOrMove(p,function(){var m=X(p.get("formatterParams")||{});this._showTooltipContent(p,g,m,d,e.offsetX,e.offsetY,e.position,i,y)}),n({type:"showTip",from:this.uid})},t.prototype._showTooltipContent=function(e,i,n,a,o,s,l,u,f){if(this._ticket="",!(!e.get("showContent")||!e.get("show"))){var h=this._tooltipContent;h.setEnterable(e.get("enterable"));var c=e.get("formatter");l=l||e.get("position");var v=i,p=this._getNearestPoint([o,s],n,e.get("trigger"),e.get("borderColor")),g=p.color;if(c)if(H(c)){var d=e.ecModel.get("useUTC"),y=F(n)?n[0]:n,m=y&&y.axisType&&y.axisType.indexOf("time")>=0;v=c,m&&(v=ka(y.axisValue,v,d)),v=Ih(v,n,!0)}else if(q(c)){var _=J(function(w,b){w===this._ticket&&(h.setContent(b,f,e,g,l),this._updatePosition(e,l,o,s,h,n,u))},this);this._ticket=a,v=c(n,a,_)}else v=c;h.setContent(v,f,e,g,l),h.show(e,g),this._updatePosition(e,l,o,s,h,n,u)}},t.prototype._getNearestPoint=function(e,i,n,a){if(n==="axis"||F(i))return{color:a||(this._renderMode==="html"?"#fff":"none")};if(!F(i))return{color:a||i.color||i.borderColor}},t.prototype._updatePosition=function(e,i,n,a,o,s,l){var u=this._api.getWidth(),f=this._api.getHeight();i=i||e.get("position");var h=o.getSize(),c=e.get("align"),v=e.get("verticalAlign"),p=l&&l.getBoundingRect().clone();if(l&&p.applyTransform(l.transform),q(i)&&(i=i([n,a],s,o.el,p,{viewSize:[u,f],contentSize:h.slice()})),F(i))n=dt(i[0],u),a=dt(i[1],f);else if(G(i)){var g=i;g.width=h[0],g.height=h[1];var d=Br(g,{width:u,height:f});n=d.x,a=d.y,c=null,v=null}else if(H(i)&&l){var y=vL(i,p,h,e.get("borderWidth"));n=y[0],a=y[1]}else{var y=fL(n,a,o,u,f,c?null:20,v?null:20);n=y[0],a=y[1]}if(c&&(n-=Bd(c)?h[0]/2:c==="right"?h[0]:0),v&&(a-=Bd(v)?h[1]/2:v==="bottom"?h[1]:0),i_(e)){var y=hL(n,a,o,u,f);n=y[0],a=y[1]}o.moveTo(n,a)},t.prototype._updateContentNotChangedOnAxis=function(e,i){var n=this._lastDataByCoordSys,a=this._cbParamsList,o=!!n&&n.length===e.length;return o&&C(n,function(s,l){var u=s.dataByAxis||[],f=e[l]||{},h=f.dataByAxis||[];o=o&&u.length===h.length,o&&C(u,function(c,v){var p=h[v]||{},g=c.seriesDataIndices||[],d=p.seriesDataIndices||[];o=o&&c.value===p.value&&c.axisType===p.axisType&&c.axisId===p.axisId&&g.length===d.length,o&&C(g,function(y,m){var _=d[m];o=o&&y.seriesIndex===_.seriesIndex&&y.dataIndex===_.dataIndex}),a&&C(c.seriesDataIndices,function(y){var m=y.seriesIndex,_=i[m],w=a[m];_&&w&&w.data!==_.data&&(o=!1)})})}),this._lastDataByCoordSys=e,this._cbParamsList=i,!!o},t.prototype._hide=function(e){this._lastDataByCoordSys=null,e({type:"hideTip",from:this.uid})},t.prototype.dispose=function(e,i){Z.node||!i.getDom()||(yf(this,"_updatePosition"),this._tooltipContent.dispose(),Ff("itemTooltip",i))},t.type="tooltip",t}(ie);function Bn(r,t,e){var i=t.ecModel,n;e?(n=new pt(e,i,i),n=new pt(t.option,n,i)):n=t;for(var a=r.length-1;a>=0;a--){var o=r[a];o&&(o instanceof pt&&(o=o.get("tooltip",!0)),H(o)&&(o={formatter:o}),o&&(n=new pt(o,n,i)))}return n}function kd(r,t){return r.dispatchAction||J(t.dispatchAction,t)}function fL(r,t,e,i,n,a,o){var s=e.getSize(),l=s[0],u=s[1];return a!=null&&(r+l+a+2>i?r-=l+a:r+=a),o!=null&&(t+u+o>n?t-=u+o:t+=o),[r,t]}function hL(r,t,e,i,n){var a=e.getSize(),o=a[0],s=a[1];return r=Math.min(r+o,i)-o,t=Math.min(t+s,n)-s,r=Math.max(r,0),t=Math.max(t,0),[r,t]}function vL(r,t,e,i){var n=e[0],a=e[1],o=Math.ceil(Math.SQRT2*i)+8,s=0,l=0,u=t.width,f=t.height;switch(r){case"inside":s=t.x+u/2-n/2,l=t.y+f/2-a/2;break;case"top":s=t.x+u
Line truncated
|
||||||
|
`)){var d=new Mo;d.newline=!0,u.add(d);return}var y=n.getSeriesByName(g)[0];if(!f.get(g))if(y){var m=y.getData(),_=m.getVisual("legendLineStyle")||{},w=m.getVisual("legendIcon"),b=m.getVisual("style"),S=this._createItem(y,g,p,v,i,e,_,b,w,h,a);S.on("click",Gi(Vd,g,null,a,c)).on("mouseover",Gi(Hf,y.name,null,a,c)).on("mouseout",Gi(Gf,y.name,null,a,c)),n.ssr&&S.eachChild(function(x){var T=it(x);T.seriesIndex=y.seriesIndex,T.dataIndex=p,T.ssrType="legend"}),f.set(g,!0)}else n.eachRawSeries(function(x){if(!f.get(g)&&x.legendVisualProvider){var T=x.legendVisualProvider;if(!T.containName(g))return;var D=T.indexOfName(g),A=T.getItemVisual(D,"style"),M=T.getItemVisual(D,"legendIcon"),I=ee(A.fill);I&&I[3]===0&&(I[3]=.2,A=B(B({},A),{fill:Pe(I,"rgba")}));var L=this._createItem(x,g,p,v,i,e,{},A,M,h,a);L.on("click",Gi(Vd,null,g,a,c)).on("mouseover",Gi(Hf,null,g,a,c)).on("mouseout",Gi(Gf,null,g,a,c)),n.ssr&&L.eachChild(function(P){var R=it(P);R.seriesIndex=x.seriesIndex,R.dataIndex=p,R.ssrType="legend"}),f.set(g,!0)}},this)},this),o&&this._createSelector(o,i,a,s,l)},t.prototype._createSelector=function(e,i,n,a,o){var s=this.getSelectorGroup();Vf(e,function(u){var f=u.type,h=new _t({style:{x:0,y:0,align:"center",verticalAlign:"middle"},onclick:function(){n.dispatchAction({type:f==="all"?"legendAllSelect":"legendInverseSelect"})}});s.add(h);var c=i.getModel("selectorLabel"),v=i.getModel(["emphasis","selectorLabel"]);fn(h,{normal:c,emphasis:v},{defaultText:u.title}),ss(h)})},t.prototype._createItem=function(e,i,n,a,o,s,l,u,f,h,c){var v=e.visualDrawType,p=o.get("itemWidth"),g=o.get("itemHeight"),d=o.isSelected(i),y=a.get("symbolRotate"),m=a.get("symbolKeepAspect"),_=a.get("icon");f=_||f||"roundRect";var w=mL(f,a,l,u,v,d,c),b=new Mo,S=a.getModel("textStyle");if(q(e.getLegendIcon)&&(!_||_==="inherit"))b.add(e.getLegendIcon({itemWidth:p,itemHeight:g,icon:f,iconRotate:y,itemStyle:w.itemStyle,lineStyle:w.lineStyle,symbolKeepAspect:m}));else{var x=_==="inherit"&&e.getData().getVisual("symbol")?y==="inherit"?e.getData().getVisual("symbolRotate"):y:0;b.add(_L({itemWidth:p,itemHeight:g,icon:f,iconRotate:x,itemStyle:w.itemStyle,symbolKeepAspect:m}))}var T=s==="left"?p+5:-5,D=s,A=o.get("formatter"),M=i;H(A)&&A?M=A.replace("{name}",i??""):q(A)&&(M=A(i));var I=d?S.getTextColor():a.get("inactiveColor");b.add(new _t({style:Ee(S,{text:M,x:T,y:g/2,fill:I,align:D,verticalAlign:"middle"},{inheritColor:I})}));var L=new gt({shape:b.getBoundingRect(),style:{fill:"transparent"}}),P=a.getModel("tooltip");return P.get("show")&&Sh({el:L,componentModel:o,itemName:i,itemTooltipOption:P.option}),b.add(L),b.eachChild(function(R){R.silent=!0}),L.silent=!h,this.getContentGroup().add(b),ss(b),b.__legendDataIndex=n,b},t.prototype.layoutInner=function(e,i,n,a,o,s){var l=this.getContentGroup(),u=this.getSelectorGroup();rn(e.get("orient"),l,e.get("itemGap"),n.width,n.height);var f=l.getBoundingRect(),h=[-f.x,-f.y];if(u.markRedraw(),l.markRedraw(),o){rn("horizontal",u,e.get("selectorItemGap",!0));var c=u.getBoundingRect(),v=[-c.x,-c.y],p=e.get("selectorButtonGap",!0),g=e.getOrient().index,d=g===0?"width":"height",y=g===0?"height":"width",m=g===0?"y":"x";s==="end"?v[g]+=f[d]+p:h[g]+=c[d]+p,v[1-g]+=f[y]/2-c[y]/2,u.x=v[0],u.y=v[1],l.x=h[0],l.y=h[1];var _={x:0,y:0};return _[d]=f[d]+p+c[d],_[y]=Math.max(f[y],c[y]),_[m]=Math.min(0,c[m]+v[1-g]),_}else return l.x=h[0],l.y=h[1],this.group.getBoundingRect()},t.prototype.remove=function(){this.getContentGroup().removeAll(),this._isFirstRender=!0},t.type="legend.plain",t}(ie);function mL(r,t,e,i,n,a,o){function s(d,y){d.lineWidth==="auto"&&(d.lineWidth=y.lineWidth>0?2:0),Vf(d,function(m,_){d[_]==="inherit"&&(d[_]=y[_])})}var l=t.getModel("itemStyle"),u=l.getItemStyle(),f=r.lastIndexOf("empty",0)===0?"fill":"stroke",h=l.getShallow("decal");u.decal=!h||h==="inherit"?i.decal:bf(h,o),u.fill==="inherit"&&(u.fill=i[n]),u.stroke==="inherit"&&(u.stroke=i[f]),u.opacity==="inherit"&&(u.opacity=(n==="fill"?i:e).opacity),s(u,i);var c=t.getModel("lineStyle"),v=c.getLineStyle();if(s(v,e),u.fill==="auto"&&(u.fill=i.fill),u.stroke==="auto"&&(u.stroke=i.fill),v.stroke==="auto"&&(v.stroke=i.fill),!a){var p=t.get("inactiveBorderWidth"),g=u[f];u.lineWidth=p==="auto"?i.lineWidth>0&&g?2:0:u.lineWidth,u.fill=t.get("inactiveColor"),u.stroke=t.get("inactiveBorderColor"),v.stroke=c.get("inactiveColor"),v.lineWidth=c.get("inactiveWidth")}return{itemStyle:u,lineStyle:v}}function _L(r){var t=r.icon||"roundRect",e=Je(t,0,0,r.itemWidth,r.itemHeight,r.itemStyle.fill,r.symbolKeepAspect);return e.setStyle(r.itemStyle),e.rotation=(r.iconRotate||0)*Math.PI/180,e.setOrigin([r.itemWidth/2,r.itemHeight/2]),t.indexOf("empty")>-1&&(e.style.stroke=e.style.fill,e.style.fill="#fff",e.style.lineWidth=2),e}function Vd(r,t,e,i){Gf(r,t,e,i),e.dispatchAction({type:"legendToggleSelect",name:r??t}),Hf(r,t,e,i)}function l_(r){for(var t=r.getZr().storage.getDisplayList(),e,i=0,n=t.length;i<n&&!(e=t[i].states.emphasis);)i++;return e&&e.hoverLayer}function Hf(r,t,e,i){l_(e)||e.
Line truncated
|
||||||
|
`||u==="")){var f=o.isSelected(u);i.hasOwnProperty(u)?i[u]=i[u]&&f:i[u]=f}})}),r==="allSelect"||r==="inverseSelect"?{selected:i}:{name:t.name,selected:i}}function wL(r){r.registerAction("legendToggleSelect","legendselectchanged",yt(Nn,"toggleSelected")),r.registerAction("legendAllSelect","legendselectall",yt(Nn,"allSelect")),r.registerAction("legendInverseSelect","legendinverseselect",yt(Nn,"inverseSelect")),r.registerAction("legendSelect","legendselected",yt(Nn,"select")),r.registerAction("legendUnSelect","legendunselected",yt(Nn,"unSelect"))}function u_(r){r.registerComponentModel(zf),r.registerComponentView(s_),r.registerProcessor(r.PRIORITY.PROCESSOR.SERIES_FILTER,SL),r.registerSubTypeDefaulter("legend",function(){return"plain"}),wL(r)}var bL=function(r){N(t,r);function t(){var e=r!==null&&r.apply(this,arguments)||this;return e.type=t.type,e}return t.prototype.setScrollDataIndex=function(e){this.option.scrollDataIndex=e},t.prototype.init=function(e,i,n){var a=Js(e);r.prototype.init.call(this,e,i,n),Hd(this,e,a)},t.prototype.mergeOption=function(e,i){r.prototype.mergeOption.call(this,e,i),Hd(this,this.option,e)},t.type="legend.scroll",t.defaultOption=$s(zf.defaultOption,{scrollDataIndex:0,pageButtonItemGap:5,pageButtonGap:null,pageButtonPosition:"end",pageFormatter:"{current}/{total}",pageIcons:{horizontal:["M0,0L12,-10L12,10z","M0,0L-12,-10L-12,10z"],vertical:["M0,0L20,0L10,-20z","M0,0L20,0L10,20z"]},pageIconColor:"#2f4554",pageIconInactiveColor:"#aaa",pageIconSize:15,pageTextStyle:{color:"#333"},animationDurationUpdate:800}),t}(zf);function Hd(r,t,e){var i=r.getOrient(),n=[1,1];n[i.index]=0,on(t,e,{type:"box",ignoreSize:!!n})}var Gd=St,Iu=["width","height"],Lu=["x","y"],xL=function(r){N(t,r);function t(){var e=r!==null&&r.apply(this,arguments)||this;return e.type=t.type,e.newlineDisabled=!0,e._currentIndex=0,e}return t.prototype.init=function(){r.prototype.init.call(this),this.group.add(this._containerGroup=new Gd),this._containerGroup.add(this.getContentGroup()),this.group.add(this._controllerGroup=new Gd)},t.prototype.resetInner=function(){r.prototype.resetInner.call(this),this._controllerGroup.removeAll(),this._containerGroup.removeClipPath(),this._containerGroup.__rectSize=null},t.prototype.renderInner=function(e,i,n,a,o,s,l){var u=this;r.prototype.renderInner.call(this,e,i,n,a,o,s,l);var f=this._controllerGroup,h=i.get("pageIconSize",!0),c=F(h)?h:[h,h];p("pagePrev",0);var v=i.getModel("pageTextStyle");f.add(new _t({name:"pageText",style:{text:"xx/xx",fill:v.getTextColor(),font:v.getFont(),verticalAlign:"middle",align:"center"},silent:!0})),p("pageNext",1);function p(g,d){var y=g+"DataIndex",m=Ws(i.get("pageIcons",!0)[i.getOrient().name][d],{onclick:J(u._pageGo,u,y,i,a)},{x:-c[0]/2,y:-c[1]/2,width:c[0],height:c[1]});m.name=g,f.add(m)}},t.prototype.layoutInner=function(e,i,n,a,o,s){var l=this.getSelectorGroup(),u=e.getOrient().index,f=Iu[u],h=Lu[u],c=Iu[1-u],v=Lu[1-u];o&&rn("horizontal",l,e.get("selectorItemGap",!0));var p=e.get("selectorButtonGap",!0),g=l.getBoundingRect(),d=[-g.x,-g.y],y=X(n);o&&(y[f]=n[f]-g[f]-p);var m=this._layoutContentAndController(e,a,y,u,f,c,v,h);if(o){if(s==="end")d[u]+=m[f]+p;else{var _=g[f]+p;d[u]-=_,m[h]-=_}m[f]+=g[f]+p,d[1-u]+=m[v]+m[c]/2-g[c]/2,m[c]=Math.max(m[c],g[c]),m[v]=Math.min(m[v],g[v]+d[1-u]),l.x=d[0],l.y=d[1],l.markRedraw()}return m},t.prototype._layoutContentAndController=function(e,i,n,a,o,s,l,u){var f=this.getContentGroup(),h=this._containerGroup,c=this._controllerGroup;rn(e.get("orient"),f,e.get("itemGap"),a?n.width:null,a?null:n.height),rn("horizontal",c,e.get("pageButtonItemGap",!0));var v=f.getBoundingRect(),p=c.getBoundingRect(),g=this._showController=v[o]>n[o],d=[-v.x,-v.y];i||(d[a]=f[u]);var y=[0,0],m=[-p.x,-p.y],_=j(e.get("pageButtonGap",!0),e.get("itemGap",!0));if(g){var w=e.get("pageButtonPosition",!0);w==="end"?m[a]+=n[o]-p[o]:y[a]+=p[o]+_}m[1-a]+=v[s]/2-p[s]/2,f.setPosition(d),h.setPosition(y),c.setPosition(m);var b={x:0,y:0};if(b[o]=g?n[o]:v[o],b[s]=Math.max(v[s],p[s]),b[l]=Math.min(0,p[l]+m[1-a]),h.__rectSize=n[o],g){var S={x:0,y:0};S[o]=Math.max(n[o]-p[o]-_,0),S[s]=b[s],h.setClipPath(new gt({shape:S})),h.__rectSize=S[o]}else c.eachChild(function(T){T.attr({invisible:!0,silent:!0})});var x=this._getPageInfo(e);return x.pageIndex!=null&&zt(f,{x:x.contentPosition[0],y:x.contentPosition[1]},g?e:null),this._updatePageInfoView(e,x),b},t.prototype._pageGo=function(e,i,n){var a=this._getPageInfo(i)[e];a!=null&&n.dispatchAction({type:"legendScroll",scrollDataIndex:a,legendId:i.id})},t.prototype._updatePageInfoView=function(e,i){var n=this._controllerGroup;C(["pagePrev","pageNext"],function(f){var h=f+"DataIndex",c=i[h]!=null,v=n.childOfName(f);v&&(v.setStyle("fill",c?e.get("pageIconColor",!0):e.get("pageIconInactiveColor",!0)),v.cursor=c?"pointer":"default")});var a=n.childOfName("pageText"),o=e.get("pageFormatter"),s=i.pageIndex,l=s!=null?s+1:0,u=i.pageCount;a&&o&&a.setStyle("text",H(o)?o.replace("{current}",l==null?"":l+"").replace("{total}",u==nul
Line truncated
|
||||||
Vendored
+1
@@ -0,0 +1 @@
|
|||||||
|
/*! @ttqtt/liquid-glass-react 0.0.2 | MIT */@layer lg.tokens{:root{--lg-font-text: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;--lg-font-display: var(--lg-font-text);--lg-font-rounded: ui-rounded, "SF Pro Rounded", var(--lg-font-text);--lg-font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;--lg-font: var(--lg-font-text);--lg-text-scale: 1;--lg-text-largetitle-size: calc(34px * var(--lg-text-scale));--lg-text-largetitle-leading: calc(41px * var(--lg-text-scale));--lg-text-largetitle-tracking: .012em;--lg-text-title1-size: calc(28px * var(--lg-text-scale));--lg-text-title1-leading: calc(34px * var(--lg-text-scale));--lg-text-title1-tracking: .014em;--lg-text-title2-size: calc(22px * var(--lg-text-scale));--lg-text-title2-leading: calc(28px * var(--lg-text-scale));--lg-text-title2-tracking: -.012em;--lg-text-title3-size: calc(20px * var(--lg-text-scale));--lg-text-title3-leading: calc(25px * var(--lg-text-scale));--lg-text-title3-tracking: -.023em;--lg-text-headline-size: calc(17px * var(--lg-text-scale));--lg-text-headline-leading: calc(22px * var(--lg-text-scale));--lg-text-headline-tracking: -.026em;--lg-text-body-size: calc(17px * var(--lg-text-scale));--lg-text-body-leading: calc(22px * var(--lg-text-scale));--lg-text-body-tracking: -.026em;--lg-text-callout-size: calc(16px * var(--lg-text-scale));--lg-text-callout-leading: calc(21px * var(--lg-text-scale));--lg-text-callout-tracking: -.02em;--lg-text-subhead-size: calc(15px * var(--lg-text-scale));--lg-text-subhead-leading: calc(20px * var(--lg-text-scale));--lg-text-subhead-tracking: -.016em;--lg-text-footnote-size: calc(13px * var(--lg-text-scale));--lg-text-footnote-leading: calc(18px * var(--lg-text-scale));--lg-text-footnote-tracking: -.006em;--lg-text-caption1-size: calc(12px * var(--lg-text-scale));--lg-text-caption1-leading: calc(16px * var(--lg-text-scale));--lg-text-caption1-tracking: 0em;--lg-text-caption2-size: calc(11px * var(--lg-text-scale));--lg-text-caption2-leading: calc(13px * var(--lg-text-scale));--lg-text-caption2-tracking: .006em;--lg-weight-regular: 400;--lg-weight-medium: 500;--lg-weight-semibold: 600;--lg-weight-bold: 700;--lg-space-1: 4px;--lg-space-2: 8px;--lg-space-3: 12px;--lg-space-4: 16px;--lg-space-5: 20px;--lg-space-6: 24px;--lg-space-8: 32px;--lg-space-10: 40px;--lg-margin: 16px;--lg-margin-regular: 20px;--lg-hit-min: 44px;--lg-hit-width: 0px;--lg-height-compact: 36px;--lg-height-comfortable: 44px;--lg-height-small: 32px;--lg-height-large: 50px;--lg-height-extra-large: 60px;--lg-height-field-small: 36px;--lg-height-field-large: 52px;--lg-field-font: max(16px, var(--lg-text-body-size));--lg-control-font: var(--lg-text-subhead-size);--lg-field-padding-block: var(--lg-space-2);--lg-readable: 672px;--lg-sidebar-width: 260px;--lg-radius-xs: 6px;--lg-radius-s: 10px;--lg-radius-m: 14px;--lg-radius-l: 20px;--lg-radius-xl: 26px;--lg-radius-xxl: 34px;--lg-radius-capsule: 9999px;--lg-radius-sheet: 38px;--lg-radius-window: 24px;--lg-radius-container: var(--lg-radius-xl);--lg-concentric-inset: 0px;--lg-z-content: 0;--lg-z-scroll-edge: 10;--lg-z-sidebar: 15;--lg-z-tabbar: 20;--lg-z-sheet-backdrop: 30;--lg-z-sheet: 31;--lg-z-menu: 40;--lg-z-alert: 41;--lg-z-toast: 60;--lg-duration-press: 90ms;--lg-duration-release: .22s;--lg-duration-layout: .28s;--lg-duration-spring: .52s;--lg-duration-overlay: .36s;--lg-duration-exit: .22s;--lg-ease: cubic-bezier(.2,.8,.2,1);--lg-ease-out: cubic-bezier(.16,1,.3,1);--lg-spring: linear(0, .008 1.1%, .03 2.2%, .118 4.6%, .43 9.6%, .657 13.4%, .84 17.4%, .94 20.7%, 1.006 23.9%, 1.05 27.5%, 1.072 31.5%, 1.07 35.9%, 1.05 41.4%, 1.011 51.3%, .995 61.4%, .994 70.3%, 1.001 87.4%, 1);--lg-spring-soft: linear(0, .011 1.6%, .045 3.4%, .164 7%, .49 14%, .71 19.4%, .866 24.8%, .955 30.3%, 1.004 36%, 1.02 42.2%, 1.018 49.3%, 1.005 61.3%, .999 78%, 1);--lg-spring-bouncy: linear(0, .01 .9%, .043 2%, .152 4.3%, .49 9.2%, .74 12.9%, .91 16.2%, 1.05 19.8%, 1.13 23.4%, 1.16 26.4%, 1.15 29.5%, 1.11 33.6%, 1.03 40.8%, .985 47.3%, .972 53.2%, .985 63%, 1.004 75.2%, 1);--lg-press-scale: 1.06;--lg-press-scale-shared: 1.07;--lg-hover-scale: 1.015;--lg-stretch-gain: 1;--lg-focus-width: 2px;--lg-focus-offset: 2px;--lg-glass-rim-width: 1px;--lg-light-angle: 145deg;--lg-glass-contrast: 1.05;--lg-material-blur: 30px}:root[data-lg-text-size=xs]{--lg-text-scale: .824}:root[data-lg-text-size=s]{--lg-text-scale: .882}:root[data-lg-text-size=m]{--lg-text-scale: .941}:root[data-lg-text-size=l]{--lg-text-scale: 1}:root[data-lg-text-size=xl]{--lg-text-scale: 1.118}:root[data-lg-text-size=xxl]{--lg-text-scale: 1.235}:root[data-lg-text-size=xxxl]{--lg-text-scale: 1.353}:root[data-lg-text-size=ax1]{--lg-text-scale: 1.647}:root[data-lg-text-size=ax2]{--lg-text-scale: 1.941}:root[data-lg-text-size=ax3]{--lg-text-scale: 2.353}:root[data-lg-text-size=ax4]{--lg-text-scale: 2.765}:root[data-lg-text-size=ax5]{--lg-text-scale: 3.118}@media (pointer: fine) and (min-wLine truncated
|
||||||
Vendored
+50
@@ -0,0 +1,50 @@
|
|||||||
|
var cv=Object.defineProperty;var sv=(i,s,o)=>s in i?cv(i,s,{enumerable:!0,configurable:!0,writable:!0,value:o}):i[s]=o;var uu=(i,s,o)=>sv(i,typeof s!="symbol"?s+"":s,o);var Gc={exports:{}},be={};/**
|
||||||
|
* @license React
|
||||||
|
* react.production.js
|
||||||
|
*
|
||||||
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the MIT license found in the
|
||||||
|
* LICENSE file in the root directory of this source tree.
|
||||||
|
*/var Xd;function ov(){if(Xd)return be;Xd=1;var i=Symbol.for("react.transitional.element"),s=Symbol.for("react.portal"),o=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),d=Symbol.for("react.profiler"),g=Symbol.for("react.consumer"),v=Symbol.for("react.context"),b=Symbol.for("react.forward_ref"),p=Symbol.for("react.suspense"),m=Symbol.for("react.memo"),z=Symbol.for("react.lazy"),O=Symbol.iterator;function x(y){return y===null||typeof y!="object"?null:(y=O&&y[O]||y["@@iterator"],typeof y=="function"?y:null)}var w={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},j=Object.assign,S={};function C(y,B,le){this.props=y,this.context=B,this.refs=S,this.updater=le||w}C.prototype.isReactComponent={},C.prototype.setState=function(y,B){if(typeof y!="object"&&typeof y!="function"&&y!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,y,B,"setState")},C.prototype.forceUpdate=function(y){this.updater.enqueueForceUpdate(this,y,"forceUpdate")};function _(){}_.prototype=C.prototype;function k(y,B,le){this.props=y,this.context=B,this.refs=S,this.updater=le||w}var T=k.prototype=new _;T.constructor=k,j(T,C.prototype),T.isPureReactComponent=!0;var L=Array.isArray,A={H:null,A:null,T:null,S:null},M=Object.prototype.hasOwnProperty;function Q(y,B,le,$,F,P){return le=P.ref,{$$typeof:i,type:y,key:B,ref:le!==void 0?le:null,props:P}}function q(y,B){return Q(y.type,B,void 0,void 0,void 0,y.props)}function R(y){return typeof y=="object"&&y!==null&&y.$$typeof===i}function Y(y){var B={"=":"=0",":":"=2"};return"$"+y.replace(/[=:]/g,function(le){return B[le]})}var K=/\/+/g;function D(y,B){return typeof y=="object"&&y!==null&&y.key!=null?Y(""+y.key):B.toString(36)}function te(){}function W(y){switch(y.status){case"fulfilled":return y.value;case"rejected":throw y.reason;default:switch(typeof y.status=="string"?y.then(te,te):(y.status="pending",y.then(function(B){y.status==="pending"&&(y.status="fulfilled",y.value=B)},function(B){y.status==="pending"&&(y.status="rejected",y.reason=B)})),y.status){case"fulfilled":return y.value;case"rejected":throw y.reason}}throw y}function ne(y,B,le,$,F){var P=typeof y;(P==="undefined"||P==="boolean")&&(y=null);var ce=!1;if(y===null)ce=!0;else switch(P){case"bigint":case"string":case"number":ce=!0;break;case"object":switch(y.$$typeof){case i:case s:ce=!0;break;case z:return ce=y._init,ne(ce(y._payload),B,le,$,F)}}if(ce)return F=F(y),ce=$===""?"."+D(y,0):$,L(F)?(le="",ce!=null&&(le=ce.replace(K,"$&/")+"/"),ne(F,B,le,"",function(ve){return ve})):F!=null&&(R(F)&&(F=q(F,le+(F.key==null||y&&y.key===F.key?"":(""+F.key).replace(K,"$&/")+"/")+ce)),B.push(F)),1;ce=0;var se=$===""?".":$+":";if(L(y))for(var de=0;de<y.length;de++)$=y[de],P=se+D($,de),ce+=ne($,B,le,P,F);else if(de=x(y),typeof de=="function")for(y=de.call(y),de=0;!($=y.next()).done;)$=$.value,P=se+D($,de++),ce+=ne($,B,le,P,F);else if(P==="object"){if(typeof y.then=="function")return ne(W(y),B,le,$,F);throw B=String(y),Error("Objects are not valid as a React child (found: "+(B==="[object Object]"?"object with keys {"+Object.keys(y).join(", ")+"}":B)+"). If you meant to render a collection of children, use an array instead.")}return ce}function V(y,B,le){if(y==null)return y;var $=[],F=0;return ne(y,$,"","",function(P){return B.call(le,P,F++)}),$}function ie(y){if(y._status===-1){var B=y._result;B=B(),B.then(function(le){(y._status===0||y._status===-1)&&(y._status=1,y._result=le)},function(le){(y._status===0||y._status===-1)&&(y._status=2,y._result=le)}),y._status===-1&&(y._status=0,y._result=B)}if(y._status===1)return y._result.default;throw y._result}var I=typeof reportError=="function"?reportError:function(y){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var B=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof y=="object"&&y!==null&&typeof y.message=="string"?String(y.message):String(y),error:y});if(!window.dispatchEvent(B))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",y);return}console.error(y)};function J(){}return be.Children={map:V,forEach:function(y,B,le){V(y,function(){B.apply(this,arguments)},le)},count:function(y){var B=0;return V(y,function(){B++}),B},toArray:function(y){return V(y,function(B){return B})||[]},only:function(y){if(!R(y))throw Error("React.Children.only expected to receive a single React element child.");return y}},be.Component=C,be.Fragment=o,be.Profiler=d,be.PureComponent=k,be.StrictMode=r,be.Suspense=p,be.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=A,be.act=function(){throw Error("act(...) is not supported in production builds of React.")},be.cache=function(y){return function(){return y.apply(null,arguments)}},be.cloneElement=function(y,B,le){if(y==null)throw Error("The argument must be a React element, but you passed
Line truncated
|
||||||
|
`||r==="\r"?(m(),g=2):v+=r),g===3&&v==="!--"&&(g=4,p=p[0])}return m(),p}(i)),s),arguments,[])).length>1?s:s[0]}var Yc={exports:{}},iu={},Xc={exports:{}},Vc={};/**
|
||||||
|
* @license React
|
||||||
|
* scheduler.production.js
|
||||||
|
*
|
||||||
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the MIT license found in the
|
||||||
|
* LICENSE file in the root directory of this source tree.
|
||||||
|
*/var Zd;function dv(){return Zd||(Zd=1,function(i){function s(V,ie){var I=V.length;V.push(ie);e:for(;0<I;){var J=I-1>>>1,y=V[J];if(0<d(y,ie))V[J]=ie,V[I]=y,I=J;else break e}}function o(V){return V.length===0?null:V[0]}function r(V){if(V.length===0)return null;var ie=V[0],I=V.pop();if(I!==ie){V[0]=I;e:for(var J=0,y=V.length,B=y>>>1;J<B;){var le=2*(J+1)-1,$=V[le],F=le+1,P=V[F];if(0>d($,I))F<y&&0>d(P,$)?(V[J]=P,V[F]=I,J=F):(V[J]=$,V[le]=I,J=le);else if(F<y&&0>d(P,I))V[J]=P,V[F]=I,J=F;else break e}}return ie}function d(V,ie){var I=V.sortIndex-ie.sortIndex;return I!==0?I:V.id-ie.id}if(i.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var g=performance;i.unstable_now=function(){return g.now()}}else{var v=Date,b=v.now();i.unstable_now=function(){return v.now()-b}}var p=[],m=[],z=1,O=null,x=3,w=!1,j=!1,S=!1,C=typeof setTimeout=="function"?setTimeout:null,_=typeof clearTimeout=="function"?clearTimeout:null,k=typeof setImmediate<"u"?setImmediate:null;function T(V){for(var ie=o(m);ie!==null;){if(ie.callback===null)r(m);else if(ie.startTime<=V)r(m),ie.sortIndex=ie.expirationTime,s(p,ie);else break;ie=o(m)}}function L(V){if(S=!1,T(V),!j)if(o(p)!==null)j=!0,W();else{var ie=o(m);ie!==null&&ne(L,ie.startTime-V)}}var A=!1,M=-1,Q=5,q=-1;function R(){return!(i.unstable_now()-q<Q)}function Y(){if(A){var V=i.unstable_now();q=V;var ie=!0;try{e:{j=!1,S&&(S=!1,_(M),M=-1),w=!0;var I=x;try{t:{for(T(V),O=o(p);O!==null&&!(O.expirationTime>V&&R());){var J=O.callback;if(typeof J=="function"){O.callback=null,x=O.priorityLevel;var y=J(O.expirationTime<=V);if(V=i.unstable_now(),typeof y=="function"){O.callback=y,T(V),ie=!0;break t}O===o(p)&&r(p),T(V)}else r(p);O=o(p)}if(O!==null)ie=!0;else{var B=o(m);B!==null&&ne(L,B.startTime-V),ie=!1}}break e}finally{O=null,x=I,w=!1}ie=void 0}}finally{ie?K():A=!1}}}var K;if(typeof k=="function")K=function(){k(Y)};else if(typeof MessageChannel<"u"){var D=new MessageChannel,te=D.port2;D.port1.onmessage=Y,K=function(){te.postMessage(null)}}else K=function(){C(Y,0)};function W(){A||(A=!0,K())}function ne(V,ie){M=C(function(){V(i.unstable_now())},ie)}i.unstable_IdlePriority=5,i.unstable_ImmediatePriority=1,i.unstable_LowPriority=4,i.unstable_NormalPriority=3,i.unstable_Profiling=null,i.unstable_UserBlockingPriority=2,i.unstable_cancelCallback=function(V){V.callback=null},i.unstable_continueExecution=function(){j||w||(j=!0,W())},i.unstable_forceFrameRate=function(V){0>V||125<V?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):Q=0<V?Math.floor(1e3/V):5},i.unstable_getCurrentPriorityLevel=function(){return x},i.unstable_getFirstCallbackNode=function(){return o(p)},i.unstable_next=function(V){switch(x){case 1:case 2:case 3:var ie=3;break;default:ie=x}var I=x;x=ie;try{return V()}finally{x=I}},i.unstable_pauseExecution=function(){},i.unstable_requestPaint=function(){},i.unstable_runWithPriority=function(V,ie){switch(V){case 1:case 2:case 3:case 4:case 5:break;default:V=3}var I=x;x=V;try{return ie()}finally{x=I}},i.unstable_scheduleCallback=function(V,ie,I){var J=i.unstable_now();switch(typeof I=="object"&&I!==null?(I=I.delay,I=typeof I=="number"&&0<I?J+I:J):I=J,V){case 1:var y=-1;break;case 2:y=250;break;case 5:y=1073741823;break;case 4:y=1e4;break;default:y=5e3}return y=I+y,V={id:z++,callback:ie,priorityLevel:V,startTime:I,expirationTime:y,sortIndex:-1},I>J?(V.sortIndex=I,s(m,V),o(p)===null&&V===o(m)&&(S?(_(M),M=-1):S=!0,ne(L,I-J))):(V.sortIndex=y,s(p,V),j||w||(j=!0,W())),V},i.unstable_shouldYield=R,i.unstable_wrapCallback=function(V){var ie=x;return function(){var I=x;x=ie;try{return V.apply(this,arguments)}finally{x=I}}}}(Vc)),Vc}var Kd;function hv(){return Kd||(Kd=1,Xc.exports=dv()),Xc.exports}var Qc={exports:{}},mt={};/**
|
||||||
|
* @license React
|
||||||
|
* react-dom.production.js
|
||||||
|
*
|
||||||
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the MIT license found in the
|
||||||
|
* LICENSE file in the root directory of this source tree.
|
||||||
|
*/var $d;function mv(){if($d)return mt;$d=1;var i=ts();function s(p){var m="https://react.dev/errors/"+p;if(1<arguments.length){m+="?args[]="+encodeURIComponent(arguments[1]);for(var z=2;z<arguments.length;z++)m+="&args[]="+encodeURIComponent(arguments[z])}return"Minified React error #"+p+"; visit "+m+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function o(){}var r={d:{f:o,r:function(){throw Error(s(522))},D:o,C:o,L:o,m:o,X:o,S:o,M:o},p:0,findDOMNode:null},d=Symbol.for("react.portal");function g(p,m,z){var O=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:d,key:O==null?null:""+O,children:p,containerInfo:m,implementation:z}}var v=i.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function b(p,m){if(p==="font")return"";if(typeof m=="string")return m==="use-credentials"?m:""}return mt.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=r,mt.createPortal=function(p,m){var z=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!m||m.nodeType!==1&&m.nodeType!==9&&m.nodeType!==11)throw Error(s(299));return g(p,m,null,z)},mt.flushSync=function(p){var m=v.T,z=r.p;try{if(v.T=null,r.p=2,p)return p()}finally{v.T=m,r.p=z,r.d.f()}},mt.preconnect=function(p,m){typeof p=="string"&&(m?(m=m.crossOrigin,m=typeof m=="string"?m==="use-credentials"?m:"":void 0):m=null,r.d.C(p,m))},mt.prefetchDNS=function(p){typeof p=="string"&&r.d.D(p)},mt.preinit=function(p,m){if(typeof p=="string"&&m&&typeof m.as=="string"){var z=m.as,O=b(z,m.crossOrigin),x=typeof m.integrity=="string"?m.integrity:void 0,w=typeof m.fetchPriority=="string"?m.fetchPriority:void 0;z==="style"?r.d.S(p,typeof m.precedence=="string"?m.precedence:void 0,{crossOrigin:O,integrity:x,fetchPriority:w}):z==="script"&&r.d.X(p,{crossOrigin:O,integrity:x,fetchPriority:w,nonce:typeof m.nonce=="string"?m.nonce:void 0})}},mt.preinitModule=function(p,m){if(typeof p=="string")if(typeof m=="object"&&m!==null){if(m.as==null||m.as==="script"){var z=b(m.as,m.crossOrigin);r.d.M(p,{crossOrigin:z,integrity:typeof m.integrity=="string"?m.integrity:void 0,nonce:typeof m.nonce=="string"?m.nonce:void 0})}}else m==null&&r.d.M(p)},mt.preload=function(p,m){if(typeof p=="string"&&typeof m=="object"&&m!==null&&typeof m.as=="string"){var z=m.as,O=b(z,m.crossOrigin);r.d.L(p,z,{crossOrigin:O,integrity:typeof m.integrity=="string"?m.integrity:void 0,nonce:typeof m.nonce=="string"?m.nonce:void 0,type:typeof m.type=="string"?m.type:void 0,fetchPriority:typeof m.fetchPriority=="string"?m.fetchPriority:void 0,referrerPolicy:typeof m.referrerPolicy=="string"?m.referrerPolicy:void 0,imageSrcSet:typeof m.imageSrcSet=="string"?m.imageSrcSet:void 0,imageSizes:typeof m.imageSizes=="string"?m.imageSizes:void 0,media:typeof m.media=="string"?m.media:void 0})}},mt.preloadModule=function(p,m){if(typeof p=="string")if(m){var z=b(m.as,m.crossOrigin);r.d.m(p,{as:typeof m.as=="string"&&m.as!=="script"?m.as:void 0,crossOrigin:z,integrity:typeof m.integrity=="string"?m.integrity:void 0})}else r.d.m(p)},mt.requestFormReset=function(p){r.d.r(p)},mt.unstable_batchedUpdates=function(p,m){return p(m)},mt.useFormState=function(p,m,z){return v.H.useFormState(p,m,z)},mt.useFormStatus=function(){return v.H.useHostTransitionStatus()},mt.version="19.0.0",mt}var Jd;function gv(){if(Jd)return Qc.exports;Jd=1;function i(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(i)}catch(s){console.error(s)}}return i(),Qc.exports=mv(),Qc.exports}/**
|
||||||
|
* @license React
|
||||||
|
* react-dom-client.production.js
|
||||||
|
*
|
||||||
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the MIT license found in the
|
||||||
|
* LICENSE file in the root directory of this source tree.
|
||||||
|
*/var Wd;function vv(){if(Wd)return iu;Wd=1;var i=hv(),s=ts(),o=gv();function r(e){var t="https://react.dev/errors/"+e;if(1<arguments.length){t+="?args[]="+encodeURIComponent(arguments[1]);for(var l=2;l<arguments.length;l++)t+="&args[]="+encodeURIComponent(arguments[l])}return"Minified React error #"+e+"; visit "+t+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function d(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}var g=Symbol.for("react.element"),v=Symbol.for("react.transitional.element"),b=Symbol.for("react.portal"),p=Symbol.for("react.fragment"),m=Symbol.for("react.strict_mode"),z=Symbol.for("react.profiler"),O=Symbol.for("react.provider"),x=Symbol.for("react.consumer"),w=Symbol.for("react.context"),j=Symbol.for("react.forward_ref"),S=Symbol.for("react.suspense"),C=Symbol.for("react.suspense_list"),_=Symbol.for("react.memo"),k=Symbol.for("react.lazy"),T=Symbol.for("react.offscreen"),L=Symbol.for("react.memo_cache_sentinel"),A=Symbol.iterator;function M(e){return e===null||typeof e!="object"?null:(e=A&&e[A]||e["@@iterator"],typeof e=="function"?e:null)}var Q=Symbol.for("react.client.reference");function q(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===Q?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case p:return"Fragment";case b:return"Portal";case z:return"Profiler";case m:return"StrictMode";case S:return"Suspense";case C:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case w:return(e.displayName||"Context")+".Provider";case x:return(e._context.displayName||"Context")+".Consumer";case j:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case _:return t=e.displayName||null,t!==null?t:q(e.type)||"Memo";case k:t=e._payload,e=e._init;try{return q(e(t))}catch{}}return null}var R=s.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,Y=Object.assign,K,D;function te(e){if(K===void 0)try{throw Error()}catch(l){var t=l.stack.trim().match(/\n( *(at )?)/);K=t&&t[1]||"",D=-1<l.stack.indexOf(`
|
||||||
|
at`)?" (<anonymous>)":-1<l.stack.indexOf("@")?"@unknown:0:0":""}return`
|
||||||
|
`+K+e+D}var W=!1;function ne(e,t){if(!e||W)return"";W=!0;var l=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var a={DetermineComponentFrameRoot:function(){try{if(t){var re=function(){throw Error()};if(Object.defineProperty(re.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(re,[])}catch(ee){var Z=ee}Reflect.construct(e,[],re)}else{try{re.call()}catch(ee){Z=ee}e.call(re.prototype)}}else{try{throw Error()}catch(ee){Z=ee}(re=e())&&typeof re.catch=="function"&&re.catch(function(){})}}catch(ee){if(ee&&Z&&typeof ee.stack=="string")return[ee.stack,Z.stack]}return[null,null]}};a.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var n=Object.getOwnPropertyDescriptor(a.DetermineComponentFrameRoot,"name");n&&n.configurable&&Object.defineProperty(a.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var u=a.DetermineComponentFrameRoot(),c=u[0],h=u[1];if(c&&h){var E=c.split(`
|
||||||
|
`),H=h.split(`
|
||||||
|
`);for(n=a=0;a<E.length&&!E[a].includes("DetermineComponentFrameRoot");)a++;for(;n<H.length&&!H[n].includes("DetermineComponentFrameRoot");)n++;if(a===E.length||n===H.length)for(a=E.length-1,n=H.length-1;1<=a&&0<=n&&E[a]!==H[n];)n--;for(;1<=a&&0<=n;a--,n--)if(E[a]!==H[n]){if(a!==1||n!==1)do if(a--,n--,0>n||E[a]!==H[n]){var ae=`
|
||||||
|
`+E[a].replace(" at new "," at ");return e.displayName&&ae.includes("<anonymous>")&&(ae=ae.replace("<anonymous>",e.displayName)),ae}while(1<=a&&0<=n);break}}}finally{W=!1,Error.prepareStackTrace=l}return(l=e?e.displayName||e.name:"")?te(l):""}function V(e){switch(e.tag){case 26:case 27:case 5:return te(e.type);case 16:return te("Lazy");case 13:return te("Suspense");case 19:return te("SuspenseList");case 0:case 15:return e=ne(e.type,!1),e;case 11:return e=ne(e.type.render,!1),e;case 1:return e=ne(e.type,!0),e;default:return""}}function ie(e){try{var t="";do t+=V(e),e=e.return;while(e);return t}catch(l){return`
|
||||||
|
Error generating stack: `+l.message+`
|
||||||
|
`+l.stack}}function I(e){var t=e,l=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,t.flags&4098&&(l=t.return),e=t.return;while(e)}return t.tag===3?l:null}function J(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function y(e){if(I(e)!==e)throw Error(r(188))}function B(e){var t=e.alternate;if(!t){if(t=I(e),t===null)throw Error(r(188));return t!==e?null:e}for(var l=e,a=t;;){var n=l.return;if(n===null)break;var u=n.alternate;if(u===null){if(a=n.return,a!==null){l=a;continue}break}if(n.child===u.child){for(u=n.child;u;){if(u===l)return y(n),e;if(u===a)return y(n),t;u=u.sibling}throw Error(r(188))}if(l.return!==a.return)l=n,a=u;else{for(var c=!1,h=n.child;h;){if(h===l){c=!0,l=n,a=u;break}if(h===a){c=!0,a=n,l=u;break}h=h.sibling}if(!c){for(h=u.child;h;){if(h===l){c=!0,l=u,a=n;break}if(h===a){c=!0,a=u,l=n;break}h=h.sibling}if(!c)throw Error(r(189))}}if(l.alternate!==a)throw Error(r(190))}if(l.tag!==3)throw Error(r(188));return l.stateNode.current===l?e:t}function le(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=le(e),t!==null)return t;e=e.sibling}return null}var $=Array.isArray,F=o.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,P={pending:!1,data:null,method:null,action:null},ce=[],se=-1;function de(e){return{current:e}}function ve(e){0>se||(e.current=ce[se],ce[se]=null,se--)}function he(e,t){se++,ce[se]=e.current,e.current=t}var Be=de(null),He=de(null),ke=de(null),et=de(null);function Ve(e,t){switch(he(ke,t),he(He,e),he(Be,null),e=t.nodeType,e){case 9:case 11:t=(t=t.documentElement)&&(t=t.namespaceURI)?pd(t):0;break;default:if(e=e===8?t.parentNode:t,t=e.tagName,e=e.namespaceURI)e=pd(e),t=bd(e,t);else switch(t){case"svg":t=1;break;case"math":t=2;break;default:t=0}}ve(Be),he(Be,t)}function Ot(){ve(Be),ve(He),ve(ke)}function rl(e){e.memoizedState!==null&&he(et,e);var t=Be.current,l=bd(t,e.type);t!==l&&(he(He,e),he(Be,l))}function Ct(e){He.current===e&&(ve(Be),ve(He)),et.current===e&&(ve(et),eu._currentValue=P)}var xe=Object.prototype.hasOwnProperty,je=i.unstable_scheduleCallback,Oe=i.unstable_cancelCallback,pt=i.unstable_shouldYield,bt=i.unstable_requestPaint,Je=i.unstable_now,el=i.unstable_getCurrentPriorityLevel,cn=i.unstable_ImmediatePriority,sn=i.unstable_UserBlockingPriority,Ut=i.unstable_NormalPriority,cl=i.unstable_LowPriority,hu=i.unstable_IdlePriority,Ci=i.log,$t=i.unstable_setDisableYieldValue,zl=null,it=null;function Pl(e){if(it&&typeof it.onCommitFiberRoot=="function")try{it.onCommitFiberRoot(zl,e,void 0,(e.current.flags&128)===128)}catch{}}function xt(e){if(typeof Ci=="function"&&$t(e),it&&typeof it.setStrictMode=="function")try{it.setStrictMode(zl,e)}catch{}}var ft=Math.clz32?Math.clz32:_i,mu=Math.log,Ui=Math.LN2;function _i(e){return e>>>=0,e===0?32:31-(mu(e)/Ui|0)|0}var gu=128,vu=4194304;function Il(e){var t=e&42;if(t!==0)return t;switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return e&4194176;case 4194304:case 8388608:case 16777216:case 33554432:return e&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return e}}function yu(e,t){var l=e.pendingLanes;if(l===0)return 0;var a=0,n=e.suspendedLanes,u=e.pingedLanes,c=e.warmLanes;e=e.finishedLanes!==0;var h=l&134217727;return h!==0?(l=h&~n,l!==0?a=Il(l):(u&=h,u!==0?a=Il(u):e||(c=h&~c,c!==0&&(a=Il(c))))):(h=l&~n,h!==0?a=Il(h):u!==0?a=Il(u):e||(c=l&~c,c!==0&&(a=Il(c)))),a===0?0:t!==0&&t!==a&&!(t&n)&&(n=a&-a,c=t&-t,n>=c||n===32&&(c&4194176)!==0)?t:a}function on(e,t){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)===0}function Wh(e,t){switch(e){case 1:case 2:case 4:case 8:return t+250;case 16:case 32:case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function cs(){var e=gu;return gu<<=1,!(gu&4194176)&&(gu=128),e}function ss(){var e=vu;return vu<<=1,!(vu&62914560)&&(vu=4194304),e}function Hi(e){for(var t=[],l=0;31>l;l++)t.push(e);return t}function fn(e,t){e.pendingLanes|=t,t!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function Fh(e,t,l,a,n,u){var c=e.pendingLanes;e.pendingLanes=l,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=l,e.entangledLanes&=l,e.errorRecoveryDisabledLanes&=l,e.shellSuspendCounter=0;var h=e.entanglements,E=e.expirationTimes,H=e.hiddenUpdates;for(l=c&~l;0<l;){var ae=31-ft(l),re=1<<ae;h[ae
Line truncated
|
||||||
|
`).replace(Dg,"")}function yd(e,t){return t=vd(t),vd(e)===t}function fi(){}function De(e,t,l,a,n,u){switch(l){case"children":typeof a=="string"?t==="body"||t==="textarea"&&a===""||wa(e,a):(typeof a=="number"||typeof a=="bigint")&&t!=="body"&&wa(e,""+a);break;case"className":bu(e,"class",a);break;case"tabIndex":bu(e,"tabindex",a);break;case"dir":case"role":case"viewBox":case"width":case"height":bu(e,l,a);break;case"style":js(e,a,u);break;case"data":if(t!=="object"){bu(e,"data",a);break}case"src":case"href":if(a===""&&(t!=="a"||l!=="href")){e.removeAttribute(l);break}if(a==null||typeof a=="function"||typeof a=="symbol"||typeof a=="boolean"){e.removeAttribute(l);break}a=Eu(""+a),e.setAttribute(l,a);break;case"action":case"formAction":if(typeof a=="function"){e.setAttribute(l,"javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')");break}else typeof u=="function"&&(l==="formAction"?(t!=="input"&&De(e,t,"name",n.name,n,null),De(e,t,"formEncType",n.formEncType,n,null),De(e,t,"formMethod",n.formMethod,n,null),De(e,t,"formTarget",n.formTarget,n,null)):(De(e,t,"encType",n.encType,n,null),De(e,t,"method",n.method,n,null),De(e,t,"target",n.target,n,null)));if(a==null||typeof a=="symbol"||typeof a=="boolean"){e.removeAttribute(l);break}a=Eu(""+a),e.setAttribute(l,a);break;case"onClick":a!=null&&(e.onclick=fi);break;case"onScroll":a!=null&&Me("scroll",e);break;case"onScrollEnd":a!=null&&Me("scrollend",e);break;case"dangerouslySetInnerHTML":if(a!=null){if(typeof a!="object"||!("__html"in a))throw Error(r(61));if(l=a.__html,l!=null){if(n.children!=null)throw Error(r(60));e.innerHTML=l}}break;case"multiple":e.multiple=a&&typeof a!="function"&&typeof a!="symbol";break;case"muted":e.muted=a&&typeof a!="function"&&typeof a!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(a==null||typeof a=="function"||typeof a=="boolean"||typeof a=="symbol"){e.removeAttribute("xlink:href");break}l=Eu(""+a),e.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",l);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":a!=null&&typeof a!="function"&&typeof a!="symbol"?e.setAttribute(l,""+a):e.removeAttribute(l);break;case"inert":case"allowFullScreen":case"async":case"autoPlay":case"controls":case"default":case"defer":case"disabled":case"disablePictureInPicture":case"disableRemotePlayback":case"formNoValidate":case"hidden":case"loop":case"noModule":case"noValidate":case"open":case"playsInline":case"readOnly":case"required":case"reversed":case"scoped":case"seamless":case"itemScope":a&&typeof a!="function"&&typeof a!="symbol"?e.setAttribute(l,""):e.removeAttribute(l);break;case"capture":case"download":a===!0?e.setAttribute(l,""):a!==!1&&a!=null&&typeof a!="function"&&typeof a!="symbol"?e.setAttribute(l,a):e.removeAttribute(l);break;case"cols":case"rows":case"size":case"span":a!=null&&typeof a!="function"&&typeof a!="symbol"&&!isNaN(a)&&1<=a?e.setAttribute(l,a):e.removeAttribute(l);break;case"rowSpan":case"start":a==null||typeof a=="function"||typeof a=="symbol"||isNaN(a)?e.removeAttribute(l):e.setAttribute(l,a);break;case"popover":Me("beforetoggle",e),Me("toggle",e),pu(e,"popover",a);break;case"xlinkActuate":ol(e,"http://www.w3.org/1999/xlink","xlink:actuate",a);break;case"xlinkArcrole":ol(e,"http://www.w3.org/1999/xlink","xlink:arcrole",a);break;case"xlinkRole":ol(e,"http://www.w3.org/1999/xlink","xlink:role",a);break;case"xlinkShow":ol(e,"http://www.w3.org/1999/xlink","xlink:show",a);break;case"xlinkTitle":ol(e,"http://www.w3.org/1999/xlink","xlink:title",a);break;case"xlinkType":ol(e,"http://www.w3.org/1999/xlink","xlink:type",a);break;case"xmlBase":ol(e,"http://www.w3.org/XML/1998/namespace","xml:base",a);break;case"xmlLang":ol(e,"http://www.w3.org/XML/1998/namespace","xml:lang",a);break;case"xmlSpace":ol(e,"http://www.w3.org/XML/1998/namespace","xml:space",a);break;case"is":pu(e,"is",a);break;case"innerText":case"textContent":break;default:(!(2<l.length)||l[0]!=="o"&&l[0]!=="O"||l[1]!=="n"&&l[1]!=="N")&&(l=im.get(l)||l,pu(e,l,a))}}function jc(e,t,l,a,n,u){switch(l){case"style":js(e,a,u);break;case"dangerouslySetInnerHTML":if(a!=null){if(typeof a!="object"||!("__html"in a))throw Error(r(61));if(l=a.__html,l!=null){if(n.children!=null)throw Error(r(60));e.innerHTML=l}}break;case"children":typeof a=="string"?wa(e,a):(typeof a=="number"||typeof a=="bigint")&&wa(e,""+a);break;case"onScroll":a!=null&&Me("scroll",e);break;case"onScrollEnd":a!=null&&Me("scrollend",e);break;case"onClick":a!=null&&(e.onclick=fi);break;case"suppressContentEditableWarning":case"suppressHydrationWar
Line truncated
|
||||||
|
* @license React
|
||||||
|
* react-jsx-runtime.production.js
|
||||||
|
*
|
||||||
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the MIT license found in the
|
||||||
|
* LICENSE file in the root directory of this source tree.
|
||||||
|
*/var Pd;function bv(){if(Pd)return ru;Pd=1;var i=Symbol.for("react.transitional.element"),s=Symbol.for("react.fragment");function o(r,d,g){var v=null;if(g!==void 0&&(v=""+g),d.key!==void 0&&(v=""+d.key),"key"in d){g={};for(var b in d)b!=="key"&&(g[b]=d[b])}else g=d;return d=g.ref,{$$typeof:i,type:r,key:v,ref:d!==void 0?d:null,props:g}}return ru.Fragment=s,ru.jsx=o,ru.jsxs=o,ru}var Id;function xv(){return Id||(Id=1,Zc.exports=bv()),Zc.exports}var f=xv();const Sv={regular:{small:{blur:14,saturation:1.15,refraction:18,edge:16},large:{blur:40,saturation:1.3,refraction:26,edge:22}},clear:{small:{blur:1.5,saturation:1.08,refraction:32,edge:18},large:{blur:6,saturation:1.12,refraction:40,edge:24}}},Ev={compact:{controlHeight:36,radius:12,gap:6},comfortable:{controlHeight:44,radius:18,gap:8}},k0={press:90,release:220,layout:280,spring:520,overlay:360},G0={space1:4,space2:8,space3:12,space4:16,space5:20,space6:24,space8:32,space10:40,margin:16,marginRegular:20,hitMin:44,readable:672,sidebarWidth:260,controlGap:8},Y0={xs:6,s:10,m:14,l:20,xl:26,xxl:34,sheet:38,window:24},X0={largeTitle:{size:34,leading:41,tracking:.012,weight:400,emphasizedWeight:700},title1:{size:28,leading:34,tracking:.014,weight:400,emphasizedWeight:700},title2:{size:22,leading:28,tracking:-.012,weight:400,emphasizedWeight:700},title3:{size:20,leading:25,tracking:-.023,weight:400,emphasizedWeight:600},headline:{size:17,leading:22,tracking:-.026,weight:600,emphasizedWeight:600},body:{size:17,leading:22,tracking:-.026,weight:400,emphasizedWeight:600},callout:{size:16,leading:21,tracking:-.02,weight:400,emphasizedWeight:600},subhead:{size:15,leading:20,tracking:-.016,weight:400,emphasizedWeight:600},footnote:{size:13,leading:18,tracking:-.006,weight:400,emphasizedWeight:600},caption1:{size:12,leading:16,tracking:0,weight:400,emphasizedWeight:600},caption2:{size:11,leading:13,tracking:.006,weight:400,emphasizedWeight:600}},V0={xs:.824,s:.882,m:.941,l:1,xl:1.118,xxl:1.235,xxxl:1.353,ax1:1.647,ax2:1.941,ax3:2.353,ax4:2.765,ax5:3.118},Q0={content:0,scrollEdge:10,sidebar:15,tabBar:20,sheetBackdrop:30,sheet:31,menu:40,alert:41,toast:60},Nv={material:"regular",renderer:"auto",quality:"balanced",theme:"system",density:"comfortable",transparency:"system",motion:"system",contrast:"system",platform:"auto"},Mv={close:"Close",cancel:"Cancel",decrease:"Decrease",increase:"Increase",clearSearch:"Clear search",searchCommands:"Search commands",noResults:"No matching commands",back:"Back to",resizeSidebar:"Resize sidebar",sheetHeight:i=>`${i} height`,morePathLevels:"More levels",moreToolbarItems:"More",collapsePanel:i=>`Collapse ${i}`,expandPanel:i=>`Expand ${i}`,movePanel:i=>`Move ${i}`},jh=N.createContext(Mv),jv=jh.Provider;function jt(){return N.useContext(jh)}const zh={...Nv,resolvedTheme:"light",resolvedPlatform:"touch",reduceTransparency:!1,reduceMotion:!1,increaseContrast:!1,forcedColors:!1,enableSvgAuto:!1},Wc=N.createContext(zh);function Jl(i){const s=N.useMemo(()=>({subscribe(o){const r=window.matchMedia(i);return r.addEventListener("change",o),()=>r.removeEventListener("change",o)},getSnapshot:()=>typeof window<"u"&&window.matchMedia(i).matches,getServerSnapshot:()=>!1}),[i]);return N.useSyncExternalStore(s.subscribe,s.getSnapshot,s.getServerSnapshot)}function Z0({children:i,strings:s,...o}){const r=N.useContext(Wc),d=jt(),g=Jl("(prefers-color-scheme: dark)"),v=Jl("(prefers-reduced-motion: reduce)"),b=Jl("(prefers-reduced-transparency: reduce)"),p=Jl("(prefers-contrast: more)"),m=Jl("(forced-colors: active)"),z=Jl("(pointer: fine) and (min-width: 768px)"),O=Object.fromEntries(Object.entries(o).filter(([,A])=>A!==void 0)),x={...r,...O},w={...x,resolvedTheme:x.theme==="system"?g?"dark":"light":x.theme,reduceMotion:r.reduceMotion||v||x.motion!=="system",reduceTransparency:r.reduceTransparency||b||m||x.transparency!=="system",increaseContrast:r.increaseContrast||p||m||x.contrast!=="system",forcedColors:r.forcedColors||m,resolvedPlatform:x.platform==="auto"?z?"desktop":"touch":x.platform},j=r===zh,{motion:S,transparency:C,contrast:_,platform:k}=x,{resolvedTheme:T}=w;N.useEffect(()=>{if(!j||typeof document>"u")return;const A=document.documentElement,M=[["data-lg-theme",T],["data-lg-motion",S==="system"?null:S],["data-lg-transparency",C==="system"?null:C],["data-lg-contrast",_==="system"?null:_],["data-lg-platform",k==="auto"?null:k]],Q=M.map(([q])=>[q,A.getAttribute(q)]);for(const[q,R]of M)R===null?A.removeAttribute(q):A.setAttribute(q,R);return()=>{for(const[q,R]of Q)R===null?A.removeAttribute(q):A.setAttribute(q,R)}},[j,T,S,C,_,k]);const L=N.useMemo(()=>s?{...d,...s}:d,[d,s]);return f.jsx(Wc.Provider,{value:w,children:f.jsx(jv,{value:L,children:i})})}const Dt=()=>N.useContext(Wc),zv=768;function wi(){return Jl(`(min-width: ${zv}px)`)?"regular":"compact"}const ls=N.createContext("mixed"),Av=()=>N.useContext(ls);function K0({tone:i,children:s}){return f.jsx(ls.Provider,{value:i,children:s})}function $0({tone:i,children:s,ref:o,...r}){return f.jsx("div",{...r,reLine truncated
|
||||||
Reference in new issue
Block a user