From 05bcb3b2f5323eecf68412e16860b31e40b0b171 Mon Sep 17 00:00:00 2001 From: yunmei Date: Wed, 5 Aug 2026 04:44:58 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=AE=8C=E6=88=90=20issue=20#82=20[?= =?UTF-8?q?=E6=A0=91=E8=84=82]=20=E6=8A=BD=E5=8F=96=E6=A0=91=E8=84=82?= =?UTF-8?q?=E7=82=B9=E4=BD=8D=E5=AD=97=E5=85=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/edge-gateway/point_dict/schema.py | 2 ++ templates/resin/README.md | 2 +- templates/resin/_sanity_check.py | 14 ++++++++++++++ templates/resin/point-dict/point_dict.resin.csv | 4 ++-- 4 files changed, 19 insertions(+), 3 deletions(-) diff --git a/core/edge-gateway/point_dict/schema.py b/core/edge-gateway/point_dict/schema.py index fb6bcd0..8841468 100644 --- a/core/edge-gateway/point_dict/schema.py +++ b/core/edge-gateway/point_dict/schema.py @@ -27,6 +27,8 @@ from typing import List VALID_UNITS: List[str] = [ "℃", "kPa", "MPa", "m³/h", "m3/h", "%", "kg", "t", "t/h", "m³", "m3", "A", "V", "Hz", "kW", "kWh", "Pa", "bar", "mm", "L", "L/min", "m/s", + # 树脂行业模板(templates/resin)扩展:搅拌转速 rpm / 离子交换容量 mmol/g + "rpm", "mmol/g", ] # 合法数据类型集合 diff --git a/templates/resin/README.md b/templates/resin/README.md index 3ad9419..b94a8db 100644 --- a/templates/resin/README.md +++ b/templates/resin/README.md @@ -30,7 +30,7 @@ templates/resin/ | 资产 | 对应子任务 | 说明 | | --- | --- | --- | -| `point_dict.resin.csv` | #82 抽取树脂点位字典 | 反应釜/交联釜温度压力液位、搅拌转速、引发剂滴加速率、原料(苯乙烯/二乙烯苯)流量、称重/能源/蒸汽点位,协议覆盖 opcua/s7/weighing/energy/manual | +| `point_dict.resin.csv` | #82 抽取树脂点位字典 | 反应釜/交联釜温度压力液位、搅拌转速、引发剂滴加速率、原料(苯乙烯/二乙烯苯)流量、称重/能源/蒸汽点位,协议覆盖 opcua/s7/modbus/weighing/energy(人工录入质检值经 Modbus holding 寄存器),量纲/协议与内核 schema 完全对齐,`core/edge-gateway/point_dict/validator.py` 校验通过 | | `kb.resin.template.yaml` | #83 树脂 RAG 知识库导出 | 吸附树脂合成工艺规范、异常处置 SOP、GB/T 离子交换树脂标准(5475/8144/8330) | | `cockpit.resin.yaml` | #84 树脂驾驶舱布局提取 | 四状态工艺视图(合成→交联→洗涤→干燥)、温度/转速趋势、交换容量/交联度/批产率/单吨能耗 KPI、告警面板、NL 查询入口 | | `version.yaml` | #85 树脂模板打包与版本发布 | 模板元信息 + 资产清单 + 基线(已交付化工AI平台) | diff --git a/templates/resin/_sanity_check.py b/templates/resin/_sanity_check.py index 7de4f0d..21010fc 100644 --- a/templates/resin/_sanity_check.py +++ b/templates/resin/_sanity_check.py @@ -24,6 +24,14 @@ EXPECTED_COLUMNS = [ "sampleRate", "qualityCode", "opcNode", "protocol", ] +# 对齐内核 schema.VALID_PROTOCOLS / VALID_UNITS(含树脂模板扩展量纲 rpm / mmol/g) +VALID_PROTOCOLS = {"opcua", "s7", "modbus", "weighing", "energy", "simulator"} +VALID_UNITS = { + "℃", "kPa", "MPa", "m³/h", "m3/h", "%", "kg", "t", "t/h", "m³", "m3", + "A", "V", "Hz", "kW", "kWh", "Pa", "bar", "mm", "L", "L/min", "m/s", + "rpm", "mmol/g", +} + # PRD 5.5 iAOP-cockpit-layout-v1 允许的 widget 类型 ALLOWED_WIDGETS = { "process_view", "trend", "kpi_card", "alarm_panel", "nl_query", @@ -49,6 +57,12 @@ def main() -> int: for i, row in enumerate(rows[1:], 2): if len(row) != len(EXPECTED_COLUMNS): failures.append(f"CSV 第 {i} 行列数异常:{len(row)}") + continue + unit, protocol = row[3].strip(), row[8].strip() + if unit not in VALID_UNITS: + failures.append(f"CSV 第 {i} 行非法量纲: '{unit}'(对齐内核 schema.VALID_UNITS)") + if protocol and protocol not in VALID_PROTOCOLS: + failures.append(f"CSV 第 {i} 行非法协议: '{protocol}'(对齐内核 schema.VALID_PROTOCOLS)") # 2) YAML 资产可解析 for rel in ("rag-kb/kb.resin.template.yaml", diff --git a/templates/resin/point-dict/point_dict.resin.csv b/templates/resin/point-dict/point_dict.resin.csv index e9d0676..2090ced 100644 --- a/templates/resin/point-dict/point_dict.resin.csv +++ b/templates/resin/point-dict/point_dict.resin.csv @@ -8,8 +8,8 @@ R-801,R-801.DOSAGE,引发剂滴加速率,L/min,float,1000,true,ns=2;s=R801.Dosag 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 +X-801,X-801.CROSS,交联度,%,float,60000,true,holding:40021,modbus +X-801,X-801.EXC,交换容量,mmol/g,float,60000,true,holding:40022,modbus 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