feat(1c): ingest company registry workbook

This commit is contained in:
igor04091968
2026-05-22 11:14:31 +03:00
parent 5c4966f1ff
commit 2e682ec0c3
15 changed files with 290 additions and 3 deletions
@@ -560,6 +560,7 @@ function New-ActivityWatchDeploymentConfig {
[string]$File1CTargetHost,
[string]$File1CTargetUser = 'igor',
[string]$File1CRemoteRoot = '/opt/activitywatch/clickhouse-1c/landing',
[string]$File1CRegistryWorkbookPath = 'E:\USER1\СПИСОК ПРЕДПРИЯТИЙ И ИХ РАСПРЕДЕЛЕНИЕ.xlsx',
[switch]$IntegrationTestEnabled
)
@@ -645,6 +646,7 @@ function New-ActivityWatchDeploymentConfig {
targetHost = $File1CTargetHost
targetUser = $File1CTargetUser
remoteRoot = $File1CRemoteRoot
registryWorkbookPath = $File1CRegistryWorkbookPath
}
}
sessionEvents = [pscustomobject]@{
+2
View File
@@ -49,6 +49,7 @@ param(
[string]$File1CAutoUploadTaskName = 'ActivityWatch File1C Upload',
[string]$File1CTargetHost,
[string]$File1CTargetUser = 'igor',
[string]$File1CRegistryWorkbookPath = 'E:\USER1\СПИСОК ПРЕДПРИЯТИЙ И ИХ РАСПРЕДЕЛЕНИЕ.xlsx',
[switch]$IntegrationTestEnabled
)
@@ -157,6 +158,7 @@ $config = New-ActivityWatchDeploymentConfig `
-File1CAutoUploadTaskName $File1CAutoUploadTaskName `
-File1CTargetHost $File1CTargetHost `
-File1CTargetUser $File1CTargetUser `
-File1CRegistryWorkbookPath $File1CRegistryWorkbookPath `
-LaunchScriptPath $launchScriptPath `
-RecoveryScriptPath $recoveryScriptPath `
-UserTasks $taskDefinitions `
+2
View File
@@ -50,6 +50,7 @@ param(
[string]$File1CAutoUploadTaskName = 'ActivityWatch File1C Upload',
[string]$File1CTargetHost,
[string]$File1CTargetUser = 'igor',
[string]$File1CRegistryWorkbookPath = 'E:\USER1\СПИСОК ПРЕДПРИЯТИЙ И ИХ РАСПРЕДЕЛЕНИЕ.xlsx',
[switch]$SkipHardening,
[switch]$ValidateAfterDeploy,
[switch]$IntegrationTestEnabled
@@ -118,6 +119,7 @@ if (-not (Test-Path -LiteralPath $deployScript)) {
-File1CAutoUploadTaskName $File1CAutoUploadTaskName `
-File1CTargetHost $File1CTargetHost `
-File1CTargetUser $File1CTargetUser `
-File1CRegistryWorkbookPath $File1CRegistryWorkbookPath `
-IntegrationTestEnabled:$IntegrationTestEnabled
if (-not $SkipHardening) {
+23 -1
View File
@@ -4,7 +4,8 @@ param(
[string]$AnalyticsHost = '',
[string]$AnalyticsUser = 'igor',
[string]$RemoteRoot = '/opt/activitywatch/clickhouse-1c/landing',
[string]$RemoteKeyPath = 'C:\ProgramData\AWatch-rus\ssh\awops_ed25519'
[string]$RemoteKeyPath = 'C:\ProgramData\AWatch-rus\ssh\awops_ed25519',
[string]$RegistryWorkbookPath = ''
)
Set-StrictMode -Version Latest
@@ -263,6 +264,16 @@ if ($config.PSObject.Properties.Name -contains 'analytics' -and
-not [string]::IsNullOrWhiteSpace([string]$config.analytics.file1cAutomation.remoteRoot)) {
$RemoteRoot = [string]$config.analytics.file1cAutomation.remoteRoot
}
if ([string]::IsNullOrWhiteSpace($RegistryWorkbookPath) -and
$config.PSObject.Properties.Name -contains 'analytics' -and
$config.analytics.PSObject.Properties.Name -contains 'file1cAutomation' -and
$config.analytics.file1cAutomation.PSObject.Properties.Name -contains 'registryWorkbookPath' -and
-not [string]::IsNullOrWhiteSpace([string]$config.analytics.file1cAutomation.registryWorkbookPath)) {
$RegistryWorkbookPath = [string]$config.analytics.file1cAutomation.registryWorkbookPath
}
if ([string]::IsNullOrWhiteSpace($RegistryWorkbookPath)) {
$RegistryWorkbookPath = 'E:\USER1\СПИСОК ПРЕДПРИЯТИЙ И ИХ РАСПРЕДЕЛЕНИЕ.xlsx'
}
$infobases = @(Get-1CFileInfobases)
$nowUtc = (Get-Date).ToUniversalTime().ToString('yyyy-MM-ddTHH:mm:ssZ')
@@ -459,6 +470,7 @@ $files = @{
reglog = Join-Path $outRoot "reglog-$stamp.jsonl"
audit = Join-Path $outRoot "audit-$stamp.jsonl"
host = Join-Path $outRoot "host-$stamp.jsonl"
registry = Join-Path $outRoot "company-registry-$stamp.xlsx"
}
$documentRows = @($documents | ForEach-Object { $_ })
@@ -473,6 +485,11 @@ Write-JsonLines -Path ([string]$files['reglog']) -Rows $reglogRows
Write-JsonLines -Path ([string]$files['audit']) -Rows $auditRows
Write-JsonLines -Path ([string]$files['host']) -Rows $hostRowsNormalized
$registryUploaded = $false
if (Test-Path -LiteralPath $RegistryWorkbookPath) {
Copy-Item -LiteralPath $RegistryWorkbookPath -Destination ([string]$files['registry']) -Force
}
$effectiveKeyPath = New-TemporarySshKeyCopy -SourceKeyPath $RemoteKeyPath
try {
@@ -480,6 +497,10 @@ try {
foreach ($dataset in 'documents', 'companies', 'reglog', 'audit', 'host') {
Invoke-SshUploadWithRetry -KeyPath $effectiveKeyPath -SourcePath ([string]$files[$dataset]) -Destination "$AnalyticsUser@$AnalyticsHost`:$RemoteRoot/$dataset/"
}
if (Test-Path -LiteralPath ([string]$files['registry'])) {
Invoke-SshUploadWithRetry -KeyPath $effectiveKeyPath -SourcePath ([string]$files['registry']) -Destination "$AnalyticsUser@$AnalyticsHost`:$RemoteRoot/registry/"
$registryUploaded = $true
}
Save-ExporterState -Path $ExporterStatePath -State $nextExporterState
Write-RunLog "upload complete analyticsHost=$AnalyticsHost remoteRoot=$RemoteRoot"
}
@@ -501,5 +522,6 @@ Write-RunLog 'file1c exporter done'
reglog = $reglog.Count
audit = $audit.Count
host = $hostRows.Count
registry = if ($registryUploaded) { 1 } else { 0 }
}
} | ConvertTo-Json -Depth 8