Skip to content

v0.8.1

Choose a tag to compare

@github-actions github-actions released this 11 Nov 03:04
· 44 commits to master since this release

[0.8.1] - 2026-11-11

新增

  • Kafka 推送通道:新增 kafka 类型,基于纯 Go 的 franz-go 实现,支持多个 seed broker、SASL/PLAIN、TLS、acks(all/leader/none,非 all 自动关闭幂等写入)、自动建 topic 开关与断网缓存/补发。复用消息类通道的全部载荷格式(native-json / group-json / mapping-json / script)、采集组订阅、载荷预览与测试发送;record key 固定为设备编码(缺失回落设备 ID),同一设备落在同一分区,workers 默认 1 保证按序发送。新增迁移 035_add_kafka_push_channel_form.sql。
  • 开放接口报警明细:新增报警历史分页 GET /openApi/alarm/pageAlarm、当前活跃离线报警 GET /openApi/alarm/listActive(不分页)与越限记录分页 GET /openApi/alarm/pageThresholdRecord,与既有的可靠性 / 异常聚合报表互补,回答「具体是哪几条」(开放接口文档 v1.7,4.9–4.11)。
  • 开放接口订阅设备与点位同步:新增 GET /openApi/subscription/devicePoint/sync,按 deviceId 游标分批返回订阅报文维护的设备 / 点位元信息(mqtt_subscription_device_point),形态与 4.5 设备同步一致,供外部系统全量遍历(开放接口文档 v1.8,4.12)。
  • 开放接口物模型批量 upsert:新增 POST /openApi/thingModel/batchUpsert,外部系统可按 code / identifier 自然键批量创建或更新物模型与其属性(没有则创建,有则更新)。每个模型一个事务、跨模型部分成功,逐条返回 created/updated/failed 与错误码;请求中未出现的属性不删除,已被点位绑定的属性改变 kind/accessMode 仍被拒绝(41018)(开放接口文档 v1.9,4.13)。
  • 开放接口物模型批量删除:新增 POST /openApi/thingModel/batchDelete(按 code 批量删模型,连带其属性)与 POST /openApi/thingModelProperty/batchDelete(按 modelCode + identifier 批量删属性),逐条返回 deleted/failed 与错误码,跨条部分成功;沿用单条删除的绑定保护(模型被设备绑定或其属性被点位绑定返回 41005,属性被点位绑定返回 41006),已不存在时分别返回 41002 / 41004(开放接口文档 v1.10,4.14–4.15)。
  • 按协议生成完整设备导入模板:GET /device/importTemplate 支持 protocolId。指定协议时,模板在基础列(名称/协议/描述/编码/物模型/状态)之外追加该协议 form_json 的全部连接参数列,标题按当前语言解析、必填项带标记、下拉项带 Excel 数据验证;连接参数会按字段类型写入 protocol_json(input→字符串、inputNumber→数字、select→选项原始类型)。含参数列的模板要求整表同一协议,混协议或模板与协议表单不一致时整表拒绝。示例行移到第二张工作表,直接导入未修改的模板不会产生示例设备。按协议模板导入时还会根据 host/port/unitId/dstNode 生成扫描身份签名(scan_identity),让导入设备参与扫描判重;通用模板与串口协议仍留空。手工新建与修改设备连接配置时也会按配置生成/重算扫描身份(修改配置此前是直接清空),只有认不出 host 时才写空串。
  • 设备导入的「编码」改为必填:模板必须包含编码列,逐行留空、格式非法或重复只让该行失败,不再按名称自动生成。旧的三列模板(无编码列)不再支持,四列及以上(含编码)的旧模板仍可导入。
  • 设备导入支持物模型与启停状态:模板新增「物模型」(名称或标识,必须存在且启用)与「状态」(启用/禁用,默认启用)两列。
  • 导入模板表头标注优化:必填列统一在列名末尾加 *,表头按必填(深蓝底 + 红色下边框)/选填(浅蓝底)分色,示例表底部附一行图例。导入仍按列名与 [fieldKey] 识别,不受配色影响。
  • 设备列表展示在线状态:设备对象列表的「状态」列改为「在线状态」,按「禁用 / 未接入 / 在线 / 离线」四态展示,并带悬停说明。后端 DeviceVO 新增 collected 字段,区分「启用但尚未进入采集调度」与真正的在线/离线,口径与首页设备总览一致。
  • 扫描结果导出为设备导入模板:POST /deviceScan/exportTemplate 把勾选的扫描结果按该协议的设备导入模板导出(.xlsx)。文件与 GET /device/importTemplate?protocolId= 同构,表头下方直接填好名称、编码、描述与 protocolJson 里的连接参数;在 Excel 里改完编码/名称后,走设备导入即可落库。扫描页「添加为设备」弹窗新增「导出 Excel」按钮。

修复

  • 被推送通道订阅的采集组拒绝删除:删除采集组前检查各推送通道的 config_json.groupIds,仍被任一通道(含停用通道)订阅时返回新错误码 40050,避免删除后通道配置里留下永远匹配不到任何批次的组 ID。设备删除(单条与批量)会级联删掉名下采集组,因此名下任一组被订阅时同样整批拒绝并返回 40065;批量删除不做部分成功。先从通道配置中移除该组即可恢复删除。
  • 设备/点位被触发规则引用时拒绝删除:删除设备(单条与批量)前检查事件触发规则的动作设备、动作点位与条件点位引用;删除点位(单条与批量)前检查动作点位与条件点位引用。有引用时分别返回新错误码 40063 / 40064 并整批不删,避免删除后规则持续报 condition address ... not found、且再也无法触发。先修改或删除相关规则即可恢复删除。

Added

  • Kafka push channel: adds the kafka type backed by the pure-Go franz-go client, supporting multiple seed brokers, SASL/PLAIN, TLS, acks (all/leader/none, with idempotent writes disabled for non-all), an auto-create-topic switch and the shared offline spool/replay. It reuses every message format (native-json / group-json / mapping-json / script), group subscriptions, payload preview and test send; the record key is the device code (falling back to the device ID) so one device stays on one partition, and workers defaults to 1 for ordered sends. Adds migration 035_add_kafka_push_channel_form.sql.
  • OpenAPI alarm details: adds alarm-history paging GET /openApi/alarm/pageAlarm, currently-active offline alarms GET /openApi/alarm/listActive (unpaginated) and threshold-record paging GET /openApi/alarm/pageThresholdRecord, complementing the existing reliability / abnormality aggregates with "which alarms exactly" detail queries (OpenAPI docs v1.7, 4.9–4.11).
  • OpenAPI subscription device/point sync: adds GET /openApi/subscription/devicePoint/sync, returning device/point metadata maintained from subscription messages (mqtt_subscription_device_point) in device-level cursor batches, mirroring 4.5 for full external traversal (OpenAPI docs v1.8, 4.12).
  • OpenAPI thing-model batch upsert: adds POST /openApi/thingModel/batchUpsert, letting external systems create or update thing models and their properties in batches by the code / identifier natural keys (create if absent, update if present). Each model is one transaction with partial success across models; every entry reports created/updated/failed plus an error code. Properties absent from the request are never deleted, and changing kind/accessMode on a property bound to a point is still rejected (41018) (OpenAPI docs v1.9, 4.13).
  • OpenAPI thing-model batch delete: adds POST /openApi/thingModel/batchDelete (delete models by code, including their properties) and POST /openApi/thingModelProperty/batchDelete (delete properties by modelCode + identifier). Each entry reports deleted/failed plus an error code, with partial success across entries. The single-delete binding guards are reused (a model bound to a device or whose properties are bound to points returns 41005; a bound property returns 41006), and missing entries return 41002 / 41004 (OpenAPI docs v1.10, 4.14–4.15).
  • Protocol-aware complete device import template: GET /device/importTemplate accepts protocolId. For a selected protocol the template adds every connection-parameter column from that protocol's form_json to the base columns (name / protocol / description / code / thing model / status), localizes titles, marks required fields and adds Excel data validation for options; imported values are written into protocol_json with their proper types (input → string, inputNumber → number, select → the option's original type). Templates with parameter columns require a single protocol for the whole file; mixed protocols or a stale template are rejected wholesale. The sample row moves to a second worksheet so importing an untouched template creates no sample device. Protocol-template imports also derive the scan identity (scan_identity) from host/port/unitId/dstNode, so imported devices participate in scan duplicate detection; universal templates and serial protocols stay empty. Manual creation and connection-config edits now generate/recompute the scan identity from the config (edits previously cleared it), writing an empty value only when no host can be derived.
  • Device import code column is now required: the template must contain a code column; empty, invalid or duplicate codes fail only that row, and codes are no longer generated from names. The legacy three-column template (without a code column) is no longer supported; legacy four-or-more-column templates that include a code column still import.
  • Thing model and enabled status in device import: two new columns — "thing model" (name or code, must exist and be enabled) and "status" (enabled/disabled, default enabled).
  • Clearer required/optional header annotations: required columns now end with *, and header cells are color-coded (required: deep blue with a red bottom border; optional: light blue). The example sheet ends with a legend. Import still matches columns by header name and [fieldKey], so the styling does not affect parsing.
  • Online status in the device list: the device object list's status column now shows a four-state "online status" — disabled / not collected / online / offline — with a hover explanation. DeviceVO gains a collected field so "enabled but not in the collection schedule" is distinguishable from genuinely online/offline, using the same semantics as the dashboard overview.
  • Export scan results as a device import template: POST /deviceScan/exportTemplate exports the selected scan results using the protocol's device import template (.xlsx). The file matches GET /device/importTemplate?protocolId= exactly, with names, codes, descriptions and connection parameters from protocolJson prefilled below the header; edit the codes/names in Excel and import them from the device object page. The scan add dialog gains an "Export to Excel" button.

Fixed

  • Collector groups subscribed by push channels can no longer be deleted: deleting a collector group now checks every push channel's config_json.groupIds; if any channel (including disabled ones) still subscribes to it, deletion is rejected with the new error code 40050, so channel configs no longer retain group IDs that can never match a batch. Since deleting a device cascades to its collector groups, single and batch device deletion are rejected wholesale with 40065 when any group of the device is subscribed; batch deletion never partially succeeds. Remove the group from the channel configuration first.
  • Devices and points referenced by trigger rules can no longer be deleted: single and batch device deletion check event-trigger rules for references through the action device, action points and condition points; single and batch point deletion check action and condition points. A referenced device or point returns the new error code 40063 / 40064 and the whole batch is left untouched, so deleting them no longer leaves rules logging condition address ... not found and unable to fire. Modify or delete the referencing rule first to proceed.