feat: 完成 issue #13 树脂模板封装(固化已交付化工AI平台)

This commit is contained in:
2026-08-04 22:20:28 +08:00
parent 8b8fa54024
commit 33c2586dd7
6 changed files with 291 additions and 0 deletions
+57
View File
@@ -0,0 +1,57 @@
# iAOP-Template-Resin(吸附树脂行业模板)
对应 EPIC #13「树脂模板封装(并行,固化已交付项目)」:
将**已终验的化工新材料AI平台(吸附树脂)**固化为 iAOP-Template-Resin,
验证内核复制能力;与 Template-Ti(`templates/ti-cl4/`)并行,由 bot_pm 协调。
## 行业背景(来自 docs/项目对比与通用产品可行性分析.md)
- 吸附树脂:ASC / ASD / HPR / ACD 系列,间歇/配方驱动(树脂合成、交联度、交换容量);
- 已终验交付(M1–M9,2026-05-30),覆盖 802/803/804 多车间 + 污水/纯水/能源;
- 数据源:和利时 DCS + 威盛 DCS + 西门子 S7-1200 PLC + 称重/能源 + 人工录入;
- AI 能力:质量预测 / 工艺优化 / 配方推荐 / 异常检测 + R&D AI + LLM 网关 + RAG。
## 模板资产
```
templates/resin/
├── point-dict/
│ └── point_dict.resin.csv 树脂点位字典(对齐内核 CSV schema:9 列)
├── rag-kb/
│ └── kb.resin.template.yaml 树脂 RAG 知识库配置(工艺规范/SOP/国标)
├── dashboard/
│ └── cockpit.resin.yaml 树脂驾驶舱布局(PRD 5.5 schema)
├── version.yaml 模板版本清单(打包发布用,子任务 #85)
├── _sanity_check.py 资产离线校验
└── README.md
```
## 资产说明
| 资产 | 对应子任务 | 说明 |
| --- | --- | --- |
| `point_dict.resin.csv` | #82 抽取树脂点位字典 | 反应釜/交联釜温度压力液位、搅拌转速、引发剂滴加速率、原料(苯乙烯/二乙烯苯)流量、称重/能源/蒸汽点位,协议覆盖 opcua/s7/weighing/energy/manual |
| `kb.resin.template.yaml` | #83 树脂 RAG 知识库导出 | 吸附树脂合成工艺规范、异常处置 SOP、GB/T 离子交换树脂标准(5475/8144/8330) |
| `cockpit.resin.yaml` | #84 树脂驾驶舱布局提取 | 四状态工艺视图(合成→交联→洗涤→干燥)、温度/转速趋势、交换容量/交联度/批产率/单吨能耗 KPI、告警面板、NL 查询入口 |
| `version.yaml` | #85 树脂模板打包与版本发布 | 模板元信息 + 资产清单 + 基线(已交付化工AI平台) |
## 使用方式(验证内核复制能力)
模板资产全部**配置驱动**:换行业只替换 `templates/<行业>/` 下的资产,
内核(`core/`)零改动——
1. **采集层**:把 `point_dict.resin.csv` 交给边缘网关(`core/edge-gateway`)
按点位字典加载,校验设备/测点完整性后启动只读采集;
2. **知识层**:把 `kb.resin.template.yaml` + 树脂文档集交给领域 RAG
(`core/rag-kb`),换行业只改模板资产;
3. **呈现层**:把 `cockpit.resin.yaml` 交给配置化驾驶舱(PRD 5.5),
切换行业模板后驾驶舱按布局自动重排,无需改前端代码;
4. **打包发布**:按 `version.yaml` 的 assets 清单收集模板,独立 semver。
## 校验
```bash
python _sanity_check.py
```
校验:点位 CSV 表头与内核 schema 对齐、YAML 资产可解析、
version.yaml 资产清单完整、驾驶舱 widget 类型合法。
+88
View File
@@ -0,0 +1,88 @@
# -*- coding: utf-8 -*-
"""iAOP-Template-Resin 模板资产 sanity 检查(无构建环境下的离线基本验证)。
检查项:
1. 点位字典 CSV:表头与内核 `core/edge-gateway/config/point_dict.example.csv`
对齐(9 列),且非空、无空行;
2. 所有 YAML 资产(RAG 配置 / 驾驶舱布局 / 版本清单)可被 yaml 解析;
3. version.yaml 声明的 assets 清单文件全部存在;
4. 驾驶舱布局 widget 类型在 PRD 5.5 schema 允许集合内。
用法:python _sanity_check.py
"""
import csv
import os
import sys
import yaml # noqa: E402
HERE = os.path.dirname(os.path.abspath(__file__))
# 对齐 core/edge-gateway/config/point_dict.example.csv 表头
EXPECTED_COLUMNS = [
"device_id", "point_id", "name", "unit", "dataType",
"sampleRate", "qualityCode", "opcNode", "protocol",
]
# PRD 5.5 iAOP-cockpit-layout-v1 允许的 widget 类型
ALLOWED_WIDGETS = {
"process_view", "trend", "kpi_card", "alarm_panel", "nl_query",
}
def main() -> int:
failures: list[str] = []
# 1) 点位字典 CSV
csv_path = os.path.join(HERE, "point-dict", "point_dict.resin.csv")
with open(csv_path, "r", encoding="utf-8") as fh:
rows = list(csv.reader(fh))
if not rows:
failures.append("point_dict.resin.csv 为空")
else:
header = [c.strip() for c in rows[0]]
if header != EXPECTED_COLUMNS:
failures.append(
f"CSV 表头与内核 schema 不一致:{header} != {EXPECTED_COLUMNS}")
if len(rows) < 2:
failures.append("CSV 缺少数据行")
for i, row in enumerate(rows[1:], 2):
if len(row) != len(EXPECTED_COLUMNS):
failures.append(f"CSV 第 {i} 行列数异常:{len(row)}")
# 2) YAML 资产可解析
for rel in ("rag-kb/kb.resin.template.yaml",
"dashboard/cockpit.resin.yaml",
"version.yaml"):
path = os.path.join(HERE, rel)
with open(path, "r", encoding="utf-8") as fh:
yaml.safe_load(fh)
# 3) version.yaml assets 清单存在
with open(os.path.join(HERE, "version.yaml"), "r", encoding="utf-8") as fh:
version = yaml.safe_load(fh)
for rel in version.get("assets", []):
if not os.path.isfile(os.path.join(HERE, rel)):
failures.append(f"version.yaml 声明资产缺失:{rel}")
# 4) 驾驶舱布局 widget 类型合法
with open(os.path.join(HERE, "dashboard", "cockpit.resin.yaml"),
"r", encoding="utf-8") as fh:
cockpit = yaml.safe_load(fh)
if cockpit.get("$schema") != "iAOP-cockpit-layout-v1":
failures.append("驾驶舱布局缺少/错误 $schema")
for w in cockpit.get("widgets", []):
if w.get("type") not in ALLOWED_WIDGETS:
failures.append(f"非法 widget 类型:{w.get('type')}")
if failures:
print("FAIL")
for f in failures:
print(" -", f)
return 1
print(f"OK: 点位 {len(rows) - 1} 条,YAML/清单/widget 校验通过")
return 0
if __name__ == "__main__":
sys.exit(main())
@@ -0,0 +1,76 @@
# -*- coding: utf-8 -*-
# 树脂驾驶舱布局资产(iAOP-Template-Resin,EPIC #13)。
#
# 对齐 PRD 5.5「⑤ 配置化驾驶舱」布局 JSON Schema(iAOP-cockpit-layout-v1):
# 切换行业模板后,驾驶舱按本布局自动重排,无需改前端代码。
# widget 类型:process_view(工艺流程视图)/ trend(实时趋势)/ kpi_card(KPI卡片)/
# alarm_panel(告警面板)/ nl_query(NL查询入口)。
$schema: iAOP-cockpit-layout-v1
title: 吸附树脂车间驾驶舱
theme: dark
widgets:
- type: process_view
src: resin_four_state.svg
x: 0
y: 0
w: 12
h: 4
description: 四状态工艺流程(合成 → 交联 → 洗涤 → 干燥)
- type: trend
bind: R-801.TEMP
x: 0
y: 4
w: 6
h: 2
description: 反应釜温度实时趋势
- type: trend
bind: R-801.AGIT
x: 6
y: 4
w: 6
h: 2
description: 搅拌转速实时趋势
- type: kpi_card
metric: resin_exchange_capacity
label: 交换容量
x: 0
y: 6
w: 3
h: 2
description: 当批平均交换容量(mmol/g)
- type: kpi_card
metric: resin_crosslink_degree
label: 交联度
x: 3
y: 6
w: 3
h: 2
description: 当批平均交联度(%)
- type: kpi_card
metric: batch_yield
label: 批产率
x: 6
y: 6
w: 3
h: 2
description: 当批产率(%)
- type: kpi_card
metric: energy_per_ton
label: 单吨能耗
x: 9
y: 6
w: 3
h: 2
description: 单吨树脂综合能耗(kWh/t)
- type: alarm_panel
x: 0
y: 8
w: 9
h: 3
description: 告警面板(温度/交联度/质量预测异常)
- type: nl_query
x: 9
y: 8
w: 3
h: 3
description: 自然语言查询入口(配方/质量/能耗问答)
@@ -0,0 +1,22 @@
device_id,point_id,name,unit,dataType,sampleRate,qualityCode,opcNode,protocol
R-801,R-801.TEMP,反应釜温度,℃,float,1000,true,ns=2;s=R801.Temp,opcua
R-801,R-801.PRES,反应釜压力,kPa,float,1000,true,ns=2;s=R801.Pres,opcua
R-801,R-801.LEVEL,釜内液位,%,float,1000,true,ns=2;s=R801.Level,opcua
R-801,R-801.AGIT,搅拌转速,rpm,float,1000,true,ns=2;s=R801.Agit,opcua
R-801,R-801.FLOW,进料流量,m3/h,float,1000,true,ns=2;s=R801.Flow,opcua
R-801,R-801.DOSAGE,引发剂滴加速率,L/min,float,1000,true,ns=2;s=R801.Dosage,opcua
R-802,R-802.TEMP,交联釜温度,℃,float,1000,true,ns=2;s=R802.Temp,opcua
R-802,R-802.PRES,交联釜压力,kPa,float,1000,true,ns=2;s=R802.Pres,opcua
R-802,R-802.LEVEL,交联釜液位,%,float,1000,true,ns=2;s=R802.Level,opcua
X-801,X-801.CROSS,交联度,%,float,60000,true,holding:40021,manual
X-801,X-801.EXC,交换容量,mmol/g,float,60000,true,holding:40022,manual
ST-01,ST-01.FLOW,苯乙烯流量,m3/h,float,1000,true,ns=2;s=ST.Flow,opcua
ST-01,ST-01.TANK,苯乙烯储罐液位,%,float,1000,true,ns=2;s=ST.Tank,opcua
DVB-01,DVB-01.FLOW,二乙烯苯流量,m3/h,float,1000,true,ns=2;s=DVB.Flow,opcua
W-01,W-01.WT,称重给料值,kg,float,1000,true,holding:40001,weighing
E-01,E-01.PWR,车间电功率,kW,float,1000,true,holding:40010,energy
E-01,E-01.KWH,车间累计电耗,kWh,float,1000,true,holding:40012,energy
ST-02,ST-02.STEAM,蒸汽流量,t/h,float,1000,true,ns=2;s=ST2.Steam,opcua
S7-01,S7-01.PUMP_A,洗涤泵A频率,Hz,float,1000,true,DB100.0.0,s7
S7-01,S7-01.PUMP_B,洗涤泵B频率,Hz,float,1000,true,DB100.4.0,s7
S7-01,S7-01.DRYER,干燥机出口温度,℃,float,1000,true,DB100.8.0,s7
1 device_id point_id name unit dataType sampleRate qualityCode opcNode protocol
2 R-801 R-801.TEMP 反应釜温度 ℃ float 1000 true ns=2;s=R801.Temp opcua
3 R-801 R-801.PRES 反应釜压力 kPa float 1000 true ns=2;s=R801.Pres opcua
4 R-801 R-801.LEVEL 釜内液位 % float 1000 true ns=2;s=R801.Level opcua
5 R-801 R-801.AGIT 搅拌转速 rpm float 1000 true ns=2;s=R801.Agit opcua
6 R-801 R-801.FLOW 进料流量 m3/h float 1000 true ns=2;s=R801.Flow opcua
7 R-801 R-801.DOSAGE 引发剂滴加速率 L/min float 1000 true ns=2;s=R801.Dosage opcua
8 R-802 R-802.TEMP 交联釜温度 ℃ float 1000 true ns=2;s=R802.Temp opcua
9 R-802 R-802.PRES 交联釜压力 kPa float 1000 true ns=2;s=R802.Pres opcua
10 R-802 R-802.LEVEL 交联釜液位 % float 1000 true ns=2;s=R802.Level opcua
11 X-801 X-801.CROSS 交联度 % float 60000 true holding:40021 manual
12 X-801 X-801.EXC 交换容量 mmol/g float 60000 true holding:40022 manual
13 ST-01 ST-01.FLOW 苯乙烯流量 m3/h float 1000 true ns=2;s=ST.Flow opcua
14 ST-01 ST-01.TANK 苯乙烯储罐液位 % float 1000 true ns=2;s=ST.Tank opcua
15 DVB-01 DVB-01.FLOW 二乙烯苯流量 m3/h float 1000 true ns=2;s=DVB.Flow opcua
16 W-01 W-01.WT 称重给料值 kg float 1000 true holding:40001 weighing
17 E-01 E-01.PWR 车间电功率 kW float 1000 true holding:40010 energy
18 E-01 E-01.KWH 车间累计电耗 kWh float 1000 true holding:40012 energy
19 ST-02 ST-02.STEAM 蒸汽流量 t/h float 1000 true ns=2;s=ST2.Steam opcua
20 S7-01 S7-01.PUMP_A 洗涤泵A频率 Hz float 1000 true DB100.0.0 s7
21 S7-01 S7-01.PUMP_B 洗涤泵B频率 Hz float 1000 true DB100.4.0 s7
22 S7-01 S7-01.DRYER 干燥机出口温度 ℃ float 1000 true DB100.8.0 s7
@@ -0,0 +1,27 @@
# -*- coding: utf-8 -*-
# 模板 RAG 库资产:resin(吸附树脂 / 离子交换树脂,iAOP-Template-Resin)。
#
# 说明(固化自已交付化工新材料AI平台,EPIC #13):
# - 知识源分类固定三类(PRD 7.3 领域RAG知识库一期范围):
# - process 工艺规范(树脂合成工艺规范、生产操作手册);
# - sop 标准作业程序 / 异常处置 SOP;
# - standard 国标 / 行业标准 / 文献(离子交换树脂相关 GB/T)。
# - 换行业只改本文件 + 对应文档集,内核零改动;
# - 与 core/rag-kb/config/kb.template.yaml(ti-cl4 示例)同构。
template: resin
version: 1.0.0
sources:
- kind: process
documents:
- 吸附树脂合成工艺规范
- 离子交换树脂生产操作手册
- kind: sop
documents:
- 树脂合成异常处置SOP
- 交联度超标处置流程
- 交接班报告生成规范
- kind: standard
documents:
- GB/T 5475 离子交换树脂取样方法
- GB/T 8144 阳离子交换树脂交换容量测定方法
- GB/T 8330 离子交换树脂湿真密度测定方法
+21
View File
@@ -0,0 +1,21 @@
# -*- coding: utf-8 -*-
# iAOP-Template-Resin 模板版本清单(EPIC #13 固化,子任务 #85 打包发布)。
#
# 说明:
# - baseline:固化来源 = 已终验化工新材料AI平台(吸附树脂,M1–M9,2026-05-30);
# - assets:本模板包含的资产文件清单(打包发布时按此清单收集);
# - 版本策略:模板独立 semver,内核(core/)升级不改变模板版本语义。
template: resin
kind: iAOP-Template
industry: 吸附树脂(离子交换树脂 / 吸附分离材料,ASC/ASD/HPR/ACD 系列)
baseline: 化工新材料AI平台(已终验交付,M1–M9,2026-05-30,76 任务)
parallel_with: ti-cl4 # 与 Template-Ti 并行,由 bot_pm 协调
status: 固化中
version: 0.1.0
assets:
- point-dict/point_dict.resin.csv
- rag-kb/kb.resin.template.yaml
- dashboard/cockpit.resin.yaml
notes:
- 点位字典取自已交付平台采集层(和利时DCS/威盛DCS/西门子S7-1200/称重/能源/人工录入)
- 驾驶舱布局对齐 PRD 5.5 iAOP-cockpit-layout-v1 schema