feat(shipping-notice): 新增临时库存管理功能,支持创建会话、获取分析结果及字段映射建议
This commit is contained in:
1 parent
46eb63f5bb
commit
e9bdd81f1a
320 files changed
+28361
-10487
No files matched your search
@@ -3,10 +3,14 @@
|
||||
为货代库存 RPA Worker 写入 Windows 用户级永久环境变量(含共享 scope 与心跳)。
|
||||
|
||||
.DESCRIPTION
|
||||
test/prod 部署时必须配置 FREIGHT_RPA_SHARED_SCOPE_ID,与 Ubuntu 后端
|
||||
test/prod 部署时必须配置 SHIPPING_NOTICE_RPA_SHARED_SCOPE_ID,与 Ubuntu 后端
|
||||
SHIPPING_NOTICE_RPA_SHARED_SCOPE_ID 一致,否则 Worker 不会写哨兵文件,
|
||||
后端就绪检查将报 shared_sentinel_missing。
|
||||
|
||||
RPA Profile 凭据解密还要求 Windows Worker 与对应环境后端使用同一个
|
||||
SHIPPING_NOTICE_RPA_CREDENTIAL_KEY。脚本通过 SecureString 交互读取该密钥,
|
||||
不接收明文命令行参数,也不会在控制台显示密钥。
|
||||
|
||||
用法(以管理员或 RPA 专用账号登录后执行一次):
|
||||
.\scripts\rpa\set_rpa_worker_env.ps1 -Environment test -ApiBase "http://192.168.1.20:8890" -ToolApiKey "<密钥>"
|
||||
.\scripts\rpa\set_rpa_worker_env.ps1 -Environment prod -ApiBase "http://生产地址:端口" -ToolApiKey "<密钥>"
|
||||
@@ -25,6 +29,8 @@ param(
|
||||
[Parameter(Mandatory = $true)]
|
||||
[string]$ToolApiKey,
|
||||
|
||||
[SecureString]$CredentialKey,
|
||||
|
||||
[string]$DsvUsername = "",
|
||||
[string]$DsvPassword = "",
|
||||
[string]$CraneUsername = "",
|
||||
@@ -33,6 +39,33 @@ param(
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
|
||||
function ConvertTo-PlainText {
|
||||
param([Parameter(Mandatory = $true)][SecureString]$Value)
|
||||
$pointer = [Runtime.InteropServices.Marshal]::SecureStringToBSTR($Value)
|
||||
try {
|
||||
return [Runtime.InteropServices.Marshal]::PtrToStringBSTR($pointer)
|
||||
} finally {
|
||||
[Runtime.InteropServices.Marshal]::ZeroFreeBSTR($pointer)
|
||||
}
|
||||
}
|
||||
|
||||
if (-not $CredentialKey) {
|
||||
$CredentialKey = Read-Host `
|
||||
"请输入与 $Environment 后端一致的 SHIPPING_NOTICE_RPA_CREDENTIAL_KEY" `
|
||||
-AsSecureString
|
||||
}
|
||||
$CredentialKeyPlainText = ConvertTo-PlainText -Value $CredentialKey
|
||||
try {
|
||||
$credentialKeyBytes = [Convert]::FromBase64String(
|
||||
$CredentialKeyPlainText.Replace('-', '+').Replace('_', '/')
|
||||
)
|
||||
} catch {
|
||||
throw "SHIPPING_NOTICE_RPA_CREDENTIAL_KEY 必须是有效的 Fernet URL-safe Base64 密钥"
|
||||
}
|
||||
if ($credentialKeyBytes.Length -ne 32) {
|
||||
throw "SHIPPING_NOTICE_RPA_CREDENTIAL_KEY 解码后必须为 32 字节"
|
||||
}
|
||||
|
||||
if ($Environment -eq "test") {
|
||||
$Root = "C:\HxopsRpaTest"
|
||||
$ScopeId = "hxops-rpa-test-data"
|
||||
@@ -45,37 +78,39 @@ $DataRoot = Join-Path $Root "data"
|
||||
$Vars = [ordered]@{
|
||||
"HXOPS_API_BASE" = $ApiBase
|
||||
"SHIPPING_NOTICE_TOOL_API_KEY" = $ToolApiKey
|
||||
"FREIGHT_RPA_ENVIRONMENT" = $Environment
|
||||
"FREIGHT_RPA_SHARED_SCOPE_ID" = $ScopeId
|
||||
"FREIGHT_RPA_HEARTBEAT_SECONDS" = "20"
|
||||
"FREIGHT_RPA_MOCK" = "false"
|
||||
"FREIGHT_RPA_HEADLESS" = "false"
|
||||
"FREIGHT_RPA_BROWSER_CHANNEL" = "msedge"
|
||||
"FREIGHT_RPA_POLL_SECONDS" = "3"
|
||||
"FREIGHT_RPA_INVENTORY_TRIGGER_DIR" = Join-Path $DataRoot "inventory_triggers"
|
||||
"FREIGHT_INVENTORY_DROP_DIR" = Join-Path $DataRoot "inventory_drop"
|
||||
"FREIGHT_RPA_UPLOAD_TRIGGER_DIR" = Join-Path $DataRoot "upload_triggers"
|
||||
"FREIGHT_UPLOAD_QUEUE_DIR" = Join-Path $DataRoot "upload_queue"
|
||||
"FREIGHT_RPA_BROWSER_PROFILE_DIR" = Join-Path $DataRoot "browser_profile"
|
||||
"FREIGHT_RPA_LOG_FILE" = Join-Path $DataRoot "logs\worker.log"
|
||||
"FREIGHT_RPA_LOG_MAX_BYTES" = "10485760"
|
||||
"FREIGHT_RPA_LOG_BACKUP_COUNT" = "5"
|
||||
"SHIPPING_NOTICE_RPA_CREDENTIAL_KEY" = $CredentialKeyPlainText
|
||||
"SHIPPING_NOTICE_RPA_WORKER_ENVIRONMENT" = $Environment
|
||||
"SHIPPING_NOTICE_RPA_SHARED_SCOPE_ID" = $ScopeId
|
||||
"SHIPPING_NOTICE_RPA_WORKER_HEARTBEAT_SECONDS" = "20"
|
||||
"SHIPPING_NOTICE_RPA_WORKER_MOCK" = "false"
|
||||
"SHIPPING_NOTICE_RPA_WORKER_HEADLESS" = "false"
|
||||
"SHIPPING_NOTICE_RPA_WORKER_BROWSER_CHANNEL" = "msedge"
|
||||
"SHIPPING_NOTICE_RPA_WORKER_POLL_SECONDS" = "3"
|
||||
"SHIPPING_NOTICE_RPA_SHARED_INVENTORY_TRIGGER_DIR" = Join-Path $DataRoot "inventory_triggers"
|
||||
"SHIPPING_NOTICE_RPA_SHARED_INVENTORY_DROP_DIR" = Join-Path $DataRoot "inventory_drop"
|
||||
"SHIPPING_NOTICE_RPA_SHARED_UPLOAD_TRIGGER_DIR" = Join-Path $DataRoot "upload_triggers"
|
||||
"SHIPPING_NOTICE_RPA_SHARED_UPLOAD_QUEUE_DIR" = Join-Path $DataRoot "upload_queue"
|
||||
"SHIPPING_NOTICE_RPA_WORKER_BROWSER_PROFILE_DIR" = Join-Path $DataRoot "browser_profile"
|
||||
"SHIPPING_NOTICE_RPA_WORKER_LOG_FILE" = Join-Path $DataRoot "logs\worker.log"
|
||||
"SHIPPING_NOTICE_RPA_WORKER_LOG_MAX_BYTES" = "10485760"
|
||||
"SHIPPING_NOTICE_RPA_WORKER_LOG_BACKUP_COUNT" = "5"
|
||||
}
|
||||
|
||||
if ($DsvUsername) { $Vars["FREIGHT_RPA_DSV_USERNAME"] = $DsvUsername }
|
||||
if ($DsvPassword) { $Vars["FREIGHT_RPA_DSV_PASSWORD"] = $DsvPassword }
|
||||
if ($CraneUsername) { $Vars["FREIGHT_RPA_CRANE_USERNAME"] = $CraneUsername }
|
||||
if ($CranePassword) { $Vars["FREIGHT_RPA_CRANE_PASSWORD"] = $CranePassword }
|
||||
if ($DsvUsername) { $Vars["SHIPPING_NOTICE_RPA_WORKER_DSV_USERNAME"] = $DsvUsername }
|
||||
if ($DsvPassword) { $Vars["SHIPPING_NOTICE_RPA_WORKER_DSV_PASSWORD"] = $DsvPassword }
|
||||
if ($CraneUsername) { $Vars["SHIPPING_NOTICE_RPA_WORKER_CRANE_USERNAME"] = $CraneUsername }
|
||||
if ($CranePassword) { $Vars["SHIPPING_NOTICE_RPA_WORKER_CRANE_PASSWORD"] = $CranePassword }
|
||||
|
||||
$SensitiveKeys = @(
|
||||
"SHIPPING_NOTICE_TOOL_API_KEY",
|
||||
"FREIGHT_RPA_DSV_PASSWORD",
|
||||
"FREIGHT_RPA_CRANE_PASSWORD"
|
||||
"SHIPPING_NOTICE_RPA_CREDENTIAL_KEY",
|
||||
"SHIPPING_NOTICE_RPA_WORKER_DSV_PASSWORD",
|
||||
"SHIPPING_NOTICE_RPA_WORKER_CRANE_PASSWORD"
|
||||
)
|
||||
|
||||
$UsernameKeys = @(
|
||||
"FREIGHT_RPA_DSV_USERNAME",
|
||||
"FREIGHT_RPA_CRANE_USERNAME"
|
||||
"SHIPPING_NOTICE_RPA_WORKER_DSV_USERNAME",
|
||||
"SHIPPING_NOTICE_RPA_WORKER_CRANE_USERNAME"
|
||||
)
|
||||
|
||||
function Get-MaskedUsername {
|
||||
@@ -114,10 +149,11 @@ foreach ($entry in $Vars.GetEnumerator()) {
|
||||
$display = Get-DisplayValue -Key $entry.Key -Value ([string]$entry.Value)
|
||||
Write-Host ("[ok] {0}={1}" -f $entry.Key, $display)
|
||||
}
|
||||
$CredentialKeyPlainText = $null
|
||||
|
||||
Write-Host ""
|
||||
Write-Host "Environment=$Environment scope_id=$ScopeId root=$Root"
|
||||
Write-Host "请关闭并重新打开 PowerShell,然后验证:"
|
||||
Write-Host " echo `$env:FREIGHT_RPA_SHARED_SCOPE_ID"
|
||||
Write-Host " echo `$env:SHIPPING_NOTICE_RPA_SHARED_SCOPE_ID"
|
||||
Write-Host " cd $Root"
|
||||
Write-Host " python scripts\rpa\freight_rpa_worker.py"
|
||||
Reference in new issue
Block a user