版本:v1.0 | 日期:2026-09-09 | 后端模块:yudao-module-bi(决策支持)
详细设计见 decision_module_redesign.md
/bi/decision-overview)/bi/purchase-sales)/bi/warehouse)/bi/production-equipment)/bi/quality)/bi/energy,新增)/bi/sales-customer,新增)本次为新增接口,不改动既有接口签名。
| 方法 | 路径 | 说明 |
|---|---|---|
| GET | /bi/decision/kpi/trend/{kpiCode} |
指定 KPI 的历史快照序列(折线图数据源) |
请求参数(Query):
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| kpiCode | String | 是 | KPI 编码(见下方 KPI 清单) |
| beginTime | String | 否 | 开始时间 yyyy-MM-dd HH:mm:ss,默认近 30 天 |
| endTime | String | 否 | 结束时间,默认当前 |
| periodType | String | 否 | 统计周期 hour/day/week/month,默认 hour |
响应字段:
{
"code": 0,
"data": {
"kpiCode": "device_operation_rate",
"kpiName": "开机率",
"category": "device_operation",
"unit": "%",
"periodType": "hour",
"points": [
{"time": "2026-09-09T02:00:00", "value": 100.0000},
{"time": "2026-09-09T03:00:00", "value": 100.0000}
]
}
}
快照由定时任务每小时聚合写入,KPI 定义后需等待下一整点聚合出数;无快照时
points为空数组。
| 方法 | 路径 | 说明 |
|---|---|---|
| GET | /bi/decision/kpi/compare/{kpiCode} |
当前快照值较上一周期的变化率及近 24 期统计 |
响应字段:
| 字段 | 类型 | 说明 |
|---|---|---|
| currentValue / currentTime | Decimal / String | 最近一期快照值与时间 |
| previousValue / previousTime | Decimal / String | 上一期快照值 |
| changeRate | Decimal | 环比变化率(%),上期不存在或为 0 时为 null |
| avgValue / maxValue / minValue | Decimal | 近 24 期均值/最大/最小 |
| periodCount | int | 实际快照条数 |
| 方法 | 路径 | 说明 |
|---|---|---|
| POST | /bi/decision/forecast/generate |
生成预测,新增 model 参数 |
新增 Query 参数:
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| forecastCode | String | 是 | 预测编码(沿用) |
| model | String | 否 | 模型:SMA/WMA/LR/SEASONAL/YOY,缺省 SMA |
| window | int | 否 | 移动平均窗口,默认 12 |
| period | int | 否 | 季节周期,默认 7 |
| 方法 | 路径 | 说明 |
|---|---|---|
| POST | /bi/decision/forecast/generate-from-kpi |
用 KPI 快照历史按模型滚动预测未来 N 期 |
请求参数(Query):
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| kpiCode | String | 是 | 用哪个 KPI 的历史快照预测 |
| model | String | 否 | SMA/WMA/LR/SEASONAL/YOY,缺省 SMA |
| window | int | 否 | 默认 12 |
| period | int | 否 | 默认 7 |
| periods | int | 否 | 预测期数,默认 30,上限 90 |
| intervalMinutes | int | 否 | 预测点间隔分钟,默认 360 |
响应: 生成的预测记录数(int)
注意: 历史快照不足时返回 BI_FORECAST_NO_HISTORY 错误码(code 非 0),前端需提示"暂无历史数据,无法预测"。
POST /bi/dashboard/{dashboardCode}/data — 大屏数据(沿用既有 bi_dashboard_frontend.md 联调约定)GET /bi/decision/forecast/list、POST /bi/decision/forecast/history、POST /bi/decision/forecast/generate-work-order、GET /bi/decision/alert/page 等| 域 | KPI 编码 | 名称 | 单位 |
|---|---|---|---|
| energy | energy_telemetry_devices | 遥测在采设备数 | 台 |
| energy | energy_telemetry_points | 在采测点总数 | 个 |
| energy | energy_anomaly_rate | 遥测异常率 | % |
| energy | energy_power_load | 实时功率负荷 | kW |
| energy | energy_power_consumption | 周期用电量 | kWh |
| device_operation | device_total / device_running | 设备总数 / 运行设备数 | 台 |
| device_operation | device_operation_rate | 开机率 | % |
| device_operation | device_avg_efficiency | 平均生产效率 | 件/时 |
| device_operation | device_need_repair | 待维修工单数 | 单 |
| production | prod_work_order_total / prod_work_order_finish | 工单总数 / 累计产量 | 单 / 件 |
| production | prod_plan_achieve_rate / prod_feedback_qualified | 计划达成率 / 报工合格率 | % |
| production | prod_daily_output | 今日产量 | 件 |
| quality | quality_iqc_pass_rate / quality_ipqc_pass_rate / quality_oqc_pass_rate | 来料/过程/出货合格率 | % |
| quality | quality_ncr_count | 不合格品报告数 | 单 |
| procurement | pur_request_amount / pur_order_amount / pur_order_pending_in | 采购申请/订单金额、待入库量 | 元 / 件 |
| procurement | stock_amount_value / stock_low_alert | 库存货值 / 低库存物料数 | 元 / 个 |
| procurement | cost_payment_amount | 应付款近30天 | 元 |
| sales | sale_order_amount / crm_contract_amount / crm_receivable_amount | 销售订单/合同/回款金额 | 元 |
| sales | crm_customer_count / srm_avg_score | 客户数 / 供应商评分 | 个 / 分 |
| safety | safety_andon_count / safety_andon_unhandled | 安灯报警数 / 未处置数 | 次 / 个 |
| dashboardCode | 名称 | 数据带入 / 刷新 |
|---|---|---|
| decision_overview | 决策总览 | number/gauge 卡片 5 分钟刷新,趋势折线 10 分钟刷新 |
| energy | 能耗监控 | 实时卡片 5 分钟刷新;无功率/电量测点时"功率负荷"显示 0 |
| sales_customer | 营销客户 | 指标卡片 10 分钟刷新 |
大屏统一走
POST /bi/dashboard/{code}/data,position用 12 列栅格({x,y,w,h}),图表类型 number/gauge/line/bar 渲染约定与既有bi_dashboard_frontend.md一致。
| 场景 | 规则 |
|---|---|
| KPI 首次配置 | 快照从下一个整点开始聚合,趋势接口暂空 |
| 业务表无数据 | KPI 返回 0 或空,不视为异常;设备/遥测当前即有真实数据 |
| 能耗无功率测点 | 功率负荷/用电量返回 0,属正常占位;补充功率类测点后自动出值 |
| 预测无历史 | 返回 BI_FORECAST_NO_HISTORY,前端提示无历史数据 |
| 预警去重 | 同一 KPI 已有未处理预警时不重复生成,人工处理后恢复 |
bi_alert_record。bi:decision:kpi:query/update、bi:decision:alert:query/confirm/handle,新接口不新增权限,无需改菜单。