$ErrorActionPreference = "SilentlyContinue"
# Check if his controllers exist in fs-company jar
$jarPath = "d:\ylrz\ylrz_saas_his_scrm\fs-company\target\fs-company.jar"
$tempDir = "$env:TEMP\jar_check2"
if (Test-Path $tempDir) { Remove-Item $tempDir -Recurse -Force }
New-Item -ItemType Directory -Path $tempDir -Force | Out-Null

# Use Expand-Archive for jar (it's a zip)
Copy-Item $jarPath "$tempDir\check.jar" -Force
Set-Location $tempDir

# List all his controller classes in the jar
Add-Type -AssemblyName System.IO.Compression.FileSystem
$zip = [System.IO.Compression.ZipFile]::OpenRead("$tempDir\check.jar")
$hisEntries = $zip.Entries | Where-Object { $_.FullName -match "his/controller/Fs.*Controller\.class" }
Write-Output "=== HIS Controller classes in fs-company.jar ==="
Write-Output "Total: $($hisEntries.Count)"
foreach ($e in $hisEntries) {
    Write-Output $e.FullName
}

# Also check course, crm, live controllers
Write-Output ""
Write-Output "=== COURSE Controller classes ==="
$courseEntries = $zip.Entries | Where-Object { $_.FullName -match "course/controller/.*Controller\.class" }
Write-Output "Total: $($courseEntries.Count)"
foreach ($e in $courseEntries) {
    Write-Output $e.FullName
}

Write-Output ""
Write-Output "=== CRM Controller classes ==="
$crmEntries = $zip.Entries | Where-Object { $_.FullName -match "crm/controller/.*Controller\.class" }
Write-Output "Total: $($crmEntries.Count)"
foreach ($e in $crmEntries) {
    Write-Output $e.FullName
}

Write-Output ""
Write-Output "=== LIVE Controller classes ==="
$liveEntries = $zip.Entries | Where-Object { $_.FullName -match "live/controller/.*Controller\.class" }
Write-Output "Total: $($liveEntries.Count)"
foreach ($e in $liveEntries) {
    Write-Output $e.FullName
}

Write-Output ""
Write-Output "=== FASTGPT Controller classes ==="
$fastEntries = $zip.Entries | Where-Object { $_.FullName -match "fastGpt/.*Controller\.class" -or $_.FullName -match "fastgpt/.*Controller\.class" }
Write-Output "Total: $($fastEntries.Count)"
foreach ($e in $fastEntries) {
    Write-Output $e.FullName
}

Write-Output ""
Write-Output "=== QW Controller classes (from fs-admin-saas) ==="
$qwEntries = $zip.Entries | Where-Object { $_.FullName -match "qw/controller/.*Controller\.class" }
Write-Output "Total: $($qwEntries.Count)"
foreach ($e in $qwEntries) {
    Write-Output $e.FullName
}

$zip.Dispose()
Write-Output "Done"
