Files
treeandClaude Opus 5.5 0e070a64fe P1:闭环时限管控、治理成效评估、站型阈值系数与接口测试
- 闭环状态流转自动记录接单/闭环时间,状态值校验;按断站分级判定响应时限
  (及时/超时/超时未响应/未到期/无记录),新增及时响应率、平均闭环时长、超时未闭环指标与筛选
- 新增治理成效评估 /api/effect:分界日期前后指标对比与问题站点逐站改善判定
- 新增站型阈值系数(实际阈值 = 场景阈值 × 站型系数)及配置接口与页面
- 样例数据新增接单/闭环时间(独立随机数,原字段不变),导入支持并校验
- 新增 tests/test_api.py(权限、导入模板、闭环流程、站型系数、成效评估、无数据边界)
- 修复:新流水无告警匹配时根因分析报错;空筛选时超长站点清单返回 500

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-18 15:14:06 +08:00

110 lines
6.3 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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);
const [editType, setEditType] = 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} span=${5} title="站型阈值系数" hint="站点实际阈值 = 场景阈值 × 站型系数">
<${DataTable} rowKey="site_type" rows=${data.site_types} columns=${[
{key: 'site_type', title: '站型'}, {key: 'long_factor', title: '超长时长系数'},
{key: 'freq_factor', title: '高频次数系数'}, ...editColumn(setEditType)]}/>
</${Section}>
<${Section} span=${7} title="场景 × 站型 实际阈值" hint="超长阈值(分钟) / 高频阈值(次/月)">
<${DataTable} rowKey="scene" rows=${data.scenes} columns=${[
{key: 'scene', title: '场景'},
...data.site_types.map(t => ({key: t.site_type, title: t.site_type, render: (_, s) =>
`${+(s.long_min * t.long_factor).toFixed(1)} / ${+(s.freq_count * t.freq_factor).toFixed(1)}`}))]}/>
</${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}>`}
${editType && html`
<${FormDialog} onClose=${() => setEditType(null)} title=${`站型系数 · ${editType.site_type}`}
description="系数 < 1 表示从严,> 1 表示放宽;保存后立即生效"
onSubmit=${d => save(`/api/site_types/${editType.site_type}`, d, '站型系数已更新')}>
<${TextField} name="long_factor" label="超长时长系数" type="number" step="0.05" min="0.1" max="10" required
defaultValue=${editType.long_factor}/>
<${TextField} name="freq_factor" label="高频次数系数" type="number" step="0.05" min="0.1" max="10" required
defaultValue=${editType.freq_factor}/>
</${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>`;
}