From 23fab39fddc350b82231c5eb27298a719aef72b5 Mon Sep 17 00:00:00 2001
From: xyc <jc_xiong@hotmail.com>
Date: 星期三, 07 十月 2026 09:13:31 +0800
Subject: [PATCH] docs(交接): 补充 10-07 上午国省道调整更正与新会话接手说明

---
 pack-deploy.ps1 |  111 ++++++++++++++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 100 insertions(+), 11 deletions(-)

diff --git a/pack-deploy.ps1 b/pack-deploy.ps1
index 1e31977..68074de 100644
--- a/pack-deploy.ps1
+++ b/pack-deploy.ps1
@@ -3,13 +3,18 @@
   鐢ㄦ硶锛�
     powershell -NoProfile -ExecutionPolicy Bypass -File pack-deploy.ps1
     powershell -NoProfile -ExecutionPolicy Bypass -File pack-deploy.ps1 -OutRoot "E:\璇曢獙" -SkipFrontend
+    powershell -NoProfile -ExecutionPolicy Bypass -File pack-deploy.ps1 -NoFrontendDist -SkipServiceWrapper
+      鈥斺�� 鍗曠鍙e彂甯冿細涓嶇敓鎴愮嫭绔嬬殑 frontend\dist 鐩綍锛堜粛鏋勫缓骞跺悓姝� backend\web锛屽崟绔彛蹇呴渶锛夛紱
+         鏈嶅姟鍣ㄥ凡瑁呮湇鍔℃椂閰嶅悎 -SkipServiceWrapper 鍘绘帀绾� 17 MB 鐨� WinSW锛屽彲鏄捐憲鍑忓皬鍖呬綋绉��
 
   鍋氫簲浠朵簨锛�
     1) 鐢� deploy-templates\jar-application.yml锛堝叏鍗犱綅绗︼級涓存椂鏇挎崲婧愮爜 application.yml锛�
        鎵ц mvn clean package锛涙棤璁烘垚璐ラ兘杩樺師寮�鍙戞満鐪熷疄閰嶇疆
     2) 瑙e帇 jar 妫�鏌ュ唴缃� application.yml锛氬繀椤诲叏鏄崰浣嶇锛堢姝� sk- 瀵嗛挜 / 鏄庢枃鍙d护锛夛紝涓嶅悎鏍肩洿鎺ヤ腑姝�
     3) npm run build 閲嶅缓鍓嶇 dist锛堝彲 -SkipFrontend锛�
-    4) 缁勮瀹屾暣閮ㄧ讲鍖咃細backend(jar + application.yml + 鍚姩鑴氭湰 + docs + web) / frontend/dist / db / README
+    4) 缁勮瀹屾暣閮ㄧ讲鍖咃細backend(jar + application.yml + 鍚姩鑴氭湰 + 鏈嶅姟鍖呰鍣� + docs + web) / frontend/dist(鍙�夛紝-NoFrontendDist 涓嶆墦) / db / README
+       Windows 鏈嶅姟鍖呰鍣� WinSW锛氫紭鍏堢敤 deploy-templates\tools\winsw.exe 缂撳瓨锛堟牎楠� SHA-256锛夛紝
+       缂哄け鏃惰嚜鍔ㄤ笅杞� v2.12.0 x64 鍒拌缂撳瓨鐩綍锛涢殢鍖呰緭鍑轰负 backend\trafficAudit.exe
     5) 瀵圭粍瑁呭悗鐨勬暣鍖呭啀鎵竴閬嶆槑鏂囧瘑閽�
 
   淇鑳屾櫙锛�2026-10-03锛夛細2026-10-02 鎵嬪伐浜у嚭鐨勫寘缂� application.yml / docs / db / 鍚姩鑴氭湰锛�
@@ -20,16 +25,24 @@
 param(
   [string]$OutRoot = '',
   [switch]$SkipFrontend,
-  [switch]$SkipBackend      # 澶嶇敤宸插瓨鍦ㄧ殑 jar锛堜笉閲嶇紪璇戙�佷笉鍔ㄦ簮鐮侀厤缃級锛屼粎鐢ㄤ簬琛ュ叏/閲嶇粍鍙戝竷鍖�
+  [switch]$NoFrontendDist,  # 鍗曠鍙e彂甯冿細涓嶆墦鐙珛鐨� frontend\dist 鐩綍锛屼絾浠嶆瀯寤�/鍚屾 backend\web锛堝崟绔彛蹇呴渶锛�
+  [switch]$SkipBackend,     # 澶嶇敤宸插瓨鍦ㄧ殑 jar锛堜笉閲嶇紪璇戙�佷笉鍔ㄦ簮鐮侀厤缃級锛屼粎鐢ㄤ簬琛ュ叏/閲嶇粍鍙戝竷鍖�
+  [switch]$SkipServiceWrapper   # 涓嶆妸 WinSW 鏈嶅姟鍖呰鍣ㄦ墦杩涘寘锛堝嵆涓嶆彁渚涒�滄敞鍐屾垚 Windows 鏈嶅姟鈥濈殑寮�鏈鸿嚜鍚級
 )
 
 $ErrorActionPreference = 'Stop'
 $root = Split-Path -Parent $MyInvocation.MyCommand.Path
+$pomPath = Join-Path $root 'traffic-audit-server\pom.xml'
+if (-not (Test-Path $pomPath)) { throw "Missing Maven project: $pomPath" }
+[xml]$pom = Get-Content -LiteralPath $pomPath -Raw -Encoding UTF8
+$productVersion = [string]$pom.project.version
+if (-not $productVersion) { throw 'Missing <version> in traffic-audit-server\pom.xml' }
+if ($productVersion -match '(?i)-SNAPSHOT$') { throw "Release builds must not use a SNAPSHOT version: $productVersion" }
 if (-not $OutRoot) { $OutRoot = Join-Path $root 'deploy' }      # 榛樿杈撳嚭鍒颁粨搴� deploy\锛堝凡 gitignore锛�
 $tplDir    = Join-Path $root 'deploy-templates'                  # 鎵撳寘妯℃澘浠讹紙宸插叆搴擄級
 $tplJarCfg = Join-Path $tplDir 'jar-application.yml'             # 杩� jar 鐨勫崰浣嶇閰嶇疆
 $srcCfg    = Join-Path $root 'traffic-audit-server\src\main\resources\application.yml'
-$jarRel    = 'traffic-audit-server\target\traffic-audit-server-1.0.0-SNAPSHOT.jar'
+$jarRel    = 'traffic-audit-server\target\traffic-audit-server.jar'
 $jar       = Join-Path $root $jarRel
 $webDist   = Join-Path $root 'traffic-audit-web\dist'
 
@@ -79,6 +92,18 @@
   $sr = New-Object System.IO.StreamReader($entry.Open())
   $text = $sr.ReadToEnd()
   $sr.Close()
+
+  $versionEntry = $zip.Entries | Where-Object { $_.FullName -eq 'BOOT-INF/classes/app-version.properties' }
+  if (-not $versionEntry) { throw 'jar 鍐呯己灏� BOOT-INF/classes/app-version.properties' }
+  $vr = New-Object System.IO.StreamReader($versionEntry.Open())
+  $versionText = $vr.ReadToEnd()
+  $vr.Close()
+
+  $manifestEntry = $zip.Entries | Where-Object { $_.FullName -eq 'META-INF/MANIFEST.MF' }
+  if (-not $manifestEntry) { throw 'jar 鍐呯己灏� META-INF/MANIFEST.MF' }
+  $mr = New-Object System.IO.StreamReader($manifestEntry.Open())
+  $manifestText = $mr.ReadToEnd()
+  $mr.Close()
 } finally { $zip.Dispose() }
 
 function Get-SecretHits([string]$ymlText) {
@@ -102,7 +127,21 @@
 }
 Write-Host '      閫氳繃锛歫ar 鍐呯疆閰嶇疆鍏ㄩ儴涓哄崰浣嶇锛屾棤鏄庢枃瀵嗛挜/鍙d护銆�'
 
+$builtVersion = ''
+if ($versionText -match '(?m)^\s*version\s*=\s*(.+?)\s*$') { $builtVersion = $matches[1].Trim() }
+if ($builtVersion -ne $productVersion) {
+  throw "鐗堟湰涓嶄竴鑷达細pom.xml=$productVersion, app-version.properties=$builtVersion"
+}
+
+$manifestVersion = ''
+if ($manifestText -match '(?m)^Implementation-Version:\s*(.+?)\s*$') { $manifestVersion = $matches[1].Trim() }
+if ($manifestVersion -ne $productVersion) {
+  throw "鐗堟湰涓嶄竴鑷达細pom.xml=$productVersion, MANIFEST.MF=$manifestVersion"
+}
+Write-Host "      鐗堟湰鑷閫氳繃锛�$productVersion (pom / app-version.properties / MANIFEST.MF)"
+
 # ---------- [3/5] 鍓嶇鏋勫缓 ----------
+# 鍗曠鍙i儴缃插繀椤绘湁 backend\web锛屾墍浠ュ嵆浣� -NoFrontendDist 涔熼渶瑕� dist锛涘彧鏈� -SkipFrontend 鎵嶅鐢ㄧ幇鏈� dist銆�
 Write-Host '[3/5] 鏋勫缓鍓嶇锛坣pm run build锛屽彲 -SkipFrontend 璺宠繃锛�...'
 if (-not $SkipFrontend) {
   Push-Location (Join-Path $root 'traffic-audit-web')
@@ -117,23 +156,73 @@
 }
 if (-not (Test-Path $webDist)) { throw "鏈壘鍒板墠绔骇鐗╋細$webDist锛堝幓鎺� -SkipFrontend 閲嶆柊鏋勫缓锛�" }
 
+# ---------- WinSW锛圵indows 鏈嶅姟鍖呰鍣級鍑嗗锛氭湰鍦扮紦瀛樹紭鍏堬紝缂哄け鏃朵粠瀹樻柟鍙戝竷椤典笅杞藉苟鏍¢獙 SHA-256 ----------
+# WinSW v2.12.0 瀹樻柟浜х墿鏈仛 Authenticode 绛惧悕锛屾墍浠ヤ互鍥哄畾 SHA-256 浣滀负瀹屾暣鎬ф牎楠屻��
+$winswUrl    = 'https://github.com/winsw/winsw/releases/download/v2.12.0/WinSW-x64.exe'
+$winswSha256 = '05B82D46AD331CC16BDC00DE5C6332C1EF818DF8CEEFCD49C726553209B3A0DA'
+$winswSrc    = Join-Path $tplDir 'tools\winsw.exe'
+
+function Test-WinswCache {
+  param([string]$Path)
+  if (-not (Test-Path -LiteralPath $Path)) { return $false }
+  $hash = (Get-FileHash -LiteralPath $Path -Algorithm SHA256).Hash
+  if ($hash -ne $winswSha256) {
+    Write-Host ('      璀﹀憡锛歐inSW 缂撳瓨 SHA-256 涓嶅尮閰嶏紝灏嗛噸鏂颁笅杞斤紙鏈熸湜 {0}...锛屽疄闄� {1}...锛�' -f $winswSha256.Substring(0, 12), $hash.Substring(0, 12))
+    return $false
+  }
+  return $true
+}
+
+if ($SkipServiceWrapper) {
+  Write-Host '      宸叉寜 -SkipServiceWrapper 璺宠繃锛氬寘鍐呬笉鍚� Windows 鏈嶅姟鏂瑰紡寮�鏈鸿嚜鍚�'
+} else {
+  if (-not (Test-WinswCache $winswSrc)) {
+    New-Item -ItemType Directory -Force -Path (Split-Path -Parent $winswSrc) | Out-Null
+    Write-Host '      涓嬭浇 WinSW v2.12.0 x64 ...'
+    try {
+      [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
+      Invoke-WebRequest -Uri $winswUrl -OutFile $winswSrc -UseBasicParsing
+    } catch {
+      throw ("涓嬭浇 WinSW 澶辫触锛歿0}銆俙n璇锋墜鍔ㄤ笅杞� {1} 瀛樹负 {2} 鍚庨噸璇曪紝鎴栫敤 -SkipServiceWrapper 璺宠繃銆�" -f $_.Exception.Message, $winswUrl, $winswSrc)
+    }
+    if (-not (Test-WinswCache $winswSrc)) { throw "WinSW 鏍¢獙澶辫触锛屽凡涓鎵撳寘锛�$winswSrc" }
+  }
+  Write-Host ('      WinSW 灏辩华锛圫HA-256 宸叉牎楠岋級锛歿0:N1} MB' -f ((Get-Item -LiteralPath $winswSrc).Length / 1MB))
+}
+
 # ---------- [4/5] 缁勮瀹屾暣閮ㄧ讲鐩綍 ----------
 Write-Host '[4/5] 缁勮閮ㄧ讲鐩綍...'
 $stamp = Get-Date -Format 'yyyyMMdd'
-$dest = Join-Path $OutRoot ("traffic-audit-deploy-" + $stamp)
+$dest = Join-Path $OutRoot ("traffic-audit-deploy-" + $stamp + "-v" + $productVersion)
 $n = 2
-while (Test-Path $dest) { $dest = Join-Path $OutRoot ("traffic-audit-deploy-" + $stamp + "-" + $n); $n++ }
-New-Item -ItemType Directory -Force -Path (Join-Path $dest 'backend'), (Join-Path $dest 'frontend'), (Join-Path $dest 'db') | Out-Null
+while (Test-Path $dest) { $dest = Join-Path $OutRoot ("traffic-audit-deploy-" + $stamp + "-v" + $productVersion + "-" + $n); $n++ }
+if ($NoFrontendDist) {
+  New-Item -ItemType Directory -Force -Path (Join-Path $dest 'backend'), (Join-Path $dest 'db') | Out-Null
+} else {
+  New-Item -ItemType Directory -Force -Path (Join-Path $dest 'backend'), (Join-Path $dest 'frontend'), (Join-Path $dest 'db') | Out-Null
+}
 
 Copy-Item $jar (Join-Path $dest 'backend') -Force
 Copy-Item (Join-Path $tplDir 'backend\application.yml') (Join-Path $dest 'backend') -Force
 Copy-Item (Join-Path $tplDir 'backend\start-backend.cmd') (Join-Path $dest 'backend') -Force
 Copy-Item (Join-Path $tplDir 'backend\start-backend.sh') (Join-Path $dest 'backend') -Force
-Copy-Item $webDist (Join-Path $dest 'frontend') -Recurse -Force
-Copy-Item (Join-Path $tplDir 'frontend\nginx.conf.example') (Join-Path $dest 'frontend') -Force
+Copy-Item (Join-Path $tplDir 'backend\start-backend-service.cmd') (Join-Path $dest 'backend') -Force
+Copy-Item (Join-Path $tplDir 'backend\install-autostart.ps1') (Join-Path $dest 'backend') -Force
+if (-not $SkipServiceWrapper) {
+  # WinSW 瑕佹眰閰嶇疆鏂囦欢鍚嶄笌 exe 鍚屽悕锛歵rafficAudit.exe 璇诲悓鐩綍鐨� trafficAudit.xml
+  Copy-Item -LiteralPath $winswSrc (Join-Path $dest 'backend\trafficAudit.exe') -Force
+  Copy-Item (Join-Path $tplDir 'backend\trafficAudit.xml') (Join-Path $dest 'backend') -Force
+  Copy-Item (Join-Path $tplDir 'backend\install-service.ps1') (Join-Path $dest 'backend') -Force
+  Copy-Item (Join-Path $tplDir 'backend\install-service.cmd') (Join-Path $dest 'backend') -Force
+}
+if (-not $NoFrontendDist) {
+  Copy-Item $webDist (Join-Path $dest 'frontend') -Recurse -Force
+  Copy-Item (Join-Path $tplDir 'frontend\nginx.conf.example') (Join-Path $dest 'frontend') -Force
+}
 Copy-Item (Join-Path $tplDir 'db\*.sql') (Join-Path $dest 'db') -Force
 
-# 鍗曠鍙� 8090 妯″紡锛氬悗绔粠 jar 鍚岀骇 web\ 璇诲墠绔潤鎬佹枃浠讹紝蹇呴』鍜� dist 鍐呭涓�鑷�
+# 鍗曠鍙� 8090 妯″紡锛氬悗绔粠 jar 鍚岀骇 web\ 璇诲墠绔潤鎬佹枃浠讹紝蹇呴』鍜� dist 鍐呭涓�鑷淬��
+# 鍗曠鍙e彂甯冿紙-NoFrontendDist锛夊悓鏍峰繀椤诲悓姝ワ紝鍚﹀垯椤甸潰 404銆�
 Copy-Item $webDist (Join-Path $dest 'backend\web') -Recurse -Force
 
 # docs锛氳繍琛屾椂妯℃澘 + 鐢ㄦ埛鏂囨。锛涙帓闄ゅ紑鍙戣繃绋嬫枃妗d笌缂撳瓨/澶囦唤锛堝噺灏忎綋绉�侀伩鍏嶆妸鍐呴儴娓呭崟甯﹀嚭鍘伙級
@@ -142,11 +231,11 @@
 cmd /c "robocopy `"$root\docs`" `"$docsDest`" /E /NFL /NDL /NJH /NJS /NP /XD _cache 宸ヤ綔鏃ョ粨 鍔熻兘娴嬭瘯鎶ュ憡 闂姹囨�� /XF 鐢熸垚_*.xlsx _bak_* >nul"
 if ($LASTEXITCODE -ge 8) { throw "docs 澶嶅埗澶辫触锛坮obocopy 杩斿洖 $LASTEXITCODE锛�" }
 # db 鑴氭湰涔熸斁涓�浠藉埌 docs锛堜笌鏃у寘涓�鑷达細docs/init.sql 绛夛級
-Copy-Item (Join-Path $tplDir 'db\init.sql'), (Join-Path $tplDir 'db\sql_city_bus.sql'), (Join-Path $tplDir 'db\sql_city_taxi.sql'), (Join-Path $tplDir 'db\sql_wyc.sql'), (Join-Path $tplDir 'db\sql_holiday.sql'), (Join-Path $tplDir 'db\sql_holiday_decimal_migration.sql'), (Join-Path $tplDir 'db\sql_holiday_comparison_base_migration.sql') $docsDest -Force -ErrorAction SilentlyContinue
+Copy-Item (Join-Path $tplDir 'db\init.sql'), (Join-Path $tplDir 'db\sql_city_bus.sql'), (Join-Path $tplDir 'db\sql_city_taxi.sql'), (Join-Path $tplDir 'db\sql_wyc.sql'), (Join-Path $tplDir 'db\sql_holiday.sql'), (Join-Path $tplDir 'db\sql_holiday_decimal_migration.sql'), (Join-Path $tplDir 'db\sql_holiday_comparison_base_migration.sql'), (Join-Path $tplDir 'db\sql_holiday_previous_day_migration.sql'), (Join-Path $tplDir 'db\sql_holiday_vehicle_adjustment_migration.sql'), (Join-Path $tplDir 'db\sql_observation_station.sql') $docsDest -Force -ErrorAction SilentlyContinue
 
 # README锛氱敤妯℃澘骞舵浛鎹㈡棩鏈熷崰浣�
 $readme = Get-Content (Join-Path $tplDir 'README-閮ㄧ讲璇存槑.txt') -Raw -Encoding UTF8
-$readme = $readme.Replace('{stamp}', $stamp)
+$readme = $readme.Replace('{stamp}', $stamp).Replace('{version}', $productVersion)
 Set-Content -LiteralPath (Join-Path $dest 'README-閮ㄧ讲璇存槑.txt') -Value $readme -Encoding UTF8
 
 # ---------- [5/5] 鏁村寘鏄庢枃瀵嗛挜鎵弿 + 姹囨�� ----------

--
Gitblit v1.9.1