yeg
6 天以前 a04222c873e5e55f48c8d33b5c0bc46fa524ac8d
scripts/j22-collector.ps1
@@ -50,6 +50,13 @@
    [int]$ConnectTimeoutSec = 10,
    [int]$CommandTimeoutSec = 15,
    [int]$HttpTimeoutSec = 30,
    # 通道号偏移:把厂商自己软件里显示的通道号报给后端,让界面与登记能跟厂商软件对上。
    # 现场核对过:甲方软件按 01–30 编号,而它库里的表名 Ws<N>_IV_0 比它小 1。
    # 依据是四组记录互证(软件里的通道号 ↔ 它的库名 ↔ 我们的表名):
    #   02 ↔ DB_20260921_165803 ↔ Ws1 ;03 ↔ DB_20260927_172118 ↔ Ws2
    #   25 ↔ DB_20260927_155145 ↔ Ws24 ;28 ↔ DB_20261002_174234 ↔ Ws27
    # 它只是展示名(不参与通道身份),所以若现场发现哪个通道对不上,改这个值即可,不用改代码、不影响数据。
    [int]$ChannelNoOffset = 1,
    # 下面两个留空即在正文里解析成"脚本同目录";不要写成 param 默认值:
    # Windows PowerShell 的参数默认值不在脚本作用域里求值,$PSScriptRoot 在那里是空的(现场实测踩到)。
    [string]$StateFile,
@@ -216,7 +223,10 @@
function Send-Topology($channels) {
    if ($channels.Count -eq 0) { return $true }
    $rows = @()
    foreach ($channel in $channels) { $rows += [pscustomobject]@{ channel = $channel } }
    foreach ($channel in $channels) {
        # channel 是身份(表名里的号);channelNo 是厂商软件里显示的号,只用于界面显示与登记
        $rows += [pscustomobject]@{ channel = $channel; channelNo = ($channel + $ChannelNoOffset) }
    }
    $payload = [pscustomobject]@{ kind = 'TOPOLOGY'; rows = $rows } | ConvertTo-Json -Depth 4 -Compress
    return Send-Payload $payload
}