find_conflicts.ps1 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. # Find truly conflicting paths between fs-admin-saas @Profile("admin") controllers
  2. # and fs-company own controllers
  3. # Step 1: Get all @RequestMapping paths from fs-company's OWN source
  4. $companyPath = "d:\ylrz\ylrz_saas_his_scrm\fs-company\src\main\java\com\fs"
  5. $companyControllers = Get-ChildItem -Path $companyPath -Recurse -Filter "*Controller.java"
  6. $companyPaths = @{}
  7. foreach ($file in $companyControllers) {
  8. $content = Get-Content $file.FullName -Raw -Encoding UTF8
  9. if ($content -match '@RequestMapping\s*\(\s*(?:value\s*=\s*)?"/([^"]+)"') {
  10. $path = "/" + $Matches[1]
  11. $relPath = $file.FullName.Substring($companyPath.Length + 1)
  12. $companyPaths[$path] = $relPath
  13. }
  14. }
  15. Write-Host "fs-company own controller paths: $($companyPaths.Count)"
  16. # Step 2: Get all @RequestMapping paths from fs-admin-saas controllers that have @Profile("admin")
  17. $saasPath = "d:\ylrz\ylrz_saas_his_scrm\fs-admin-saas\src\main\java\com\fs"
  18. $saasControllers = Get-ChildItem -Path $saasPath -Recurse -Filter "*Controller.java"
  19. $adminProfilePaths = @{}
  20. $companyProfilePaths = @{}
  21. $noProfilePaths = @{}
  22. foreach ($file in $saasControllers) {
  23. $content = Get-Content $file.FullName -Raw -Encoding UTF8
  24. $path = ""
  25. if ($content -match '@RequestMapping\s*\(\s*(?:value\s*=\s*)?"/([^"]+)"') {
  26. $path = "/" + $Matches[1]
  27. }
  28. if ($path -eq "") { continue }
  29. $relPath = $file.FullName.Substring($saasPath.Length + 1)
  30. if ($content -match '@Profile\s*\(\s*"admin"\s*\)') {
  31. $adminProfilePaths[$path] = $relPath
  32. } elseif ($content -match '@Profile\s*\(\s*"company"\s*\)') {
  33. $companyProfilePaths[$path] = $relPath
  34. } else {
  35. $noProfilePaths[$path] = $relPath
  36. }
  37. }
  38. Write-Host "fs-admin-saas @Profile(admin) paths: $($adminProfilePaths.Count)"
  39. Write-Host "fs-admin-saas @Profile(company) paths: $($companyProfilePaths.Count)"
  40. Write-Host "fs-admin-saas no @Profile paths: $($noProfilePaths.Count)"
  41. # Step 3: Find conflicts - paths in @Profile("admin") that ALSO exist in fs-company own source
  42. $conflicts = @{}
  43. foreach ($path in $adminProfilePaths.Keys) {
  44. if ($companyPaths.ContainsKey($path)) {
  45. $conflicts[$path] = "admin: $($adminProfilePaths[$path]) vs company: $($companyPaths[$path])"
  46. }
  47. # Also check against @Profile("company") paths
  48. if ($companyProfilePaths.ContainsKey($path)) {
  49. $conflicts[$path] = "admin: $($adminProfilePaths[$path]) vs company-profile: $($companyProfilePaths[$path])"
  50. }
  51. }
  52. Write-Host "`n=== CONFLICTING PATHS (same path in admin + company) ==="
  53. Write-Host "Total conflicts: $($conflicts.Count)"
  54. $conflicts.GetEnumerator() | Sort-Object Name | ForEach-Object { Write-Host " $($_.Name): $($_.Value)" }
  55. # Step 4: Non-conflicting admin paths that can be safely changed to @Profile({"admin","company"})
  56. $nonConflicting = @{}
  57. foreach ($path in $adminProfilePaths.Keys) {
  58. if (-not $conflicts.ContainsKey($path)) {
  59. $nonConflicting[$path] = $adminProfilePaths[$path]
  60. }
  61. }
  62. Write-Host "`n=== NON-CONFLICTING ADMIN PATHS (can add 'company' profile) ==="
  63. Write-Host "Total: $($nonConflicting.Count)"
  64. # Group by module
  65. $ncByMod = @{}
  66. foreach ($path in $nonConflicting.Keys) {
  67. if ($path -match "^/([^/]+)") {
  68. $mod = $Matches[1]
  69. if (-not $ncByMod.ContainsKey($mod)) { $ncByMod[$mod] = @() }
  70. $ncByMod[$mod] += $path
  71. }
  72. }
  73. Write-Host "`nNon-conflicting by module:"
  74. $ncByMod.GetEnumerator() | Sort-Object { $_.Value.Count } -Descending | ForEach-Object { Write-Host " $($_.Key): $($ncByMod[$_.Key].Count)" }
  75. # Step 5: For the conflicting paths, decide which version should win
  76. Write-Host "`n=== CONFLICT RESOLUTION NEEDED ==="
  77. $conflicts.GetEnumerator() | Sort-Object Name | ForEach-Object { Write-Host " $($_.Name)" }