PayrollManagementSystem/scripts/tplus/prepare_sql2008r2_vm.ps1
liuwenxin 108bf87225 feat(核算)!: 添加 T+ 正式核算与采集托管
补齐源快照、资料预演、正式导入及工资核算的依赖链路。
新增版本化输入、逐段 FIFO、生成锁和结构化当月调整,
并提供默认关闭的周期采集、有限重试及 Windows 托管。

原始客户资料、私有配置及首页改动不纳入本次提交。

BREAKING CHANGE: 升级前需应用新增迁移,并通过
PAYROLL_MAKER_USER_ID 绑定实际工资制作人,否则业务只读。
旧单批次核算默认关闭;历史兼容需显式启用
PAYROLL_ALLOW_LEGACY_CALCULATION。生产启用和真实金额待验收。
2026-11-02 09:42:53 +08:00

38 lines
1.8 KiB
PowerShell
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

[CmdletBinding()]
param(
[string]$VmName = "tplus-sql2008r2-test",
[string]$Root = "E:\work\app\tplus-vm",
[string]$WindowsIso = ""
)
Set-StrictMode -Version Latest
$ErrorActionPreference = "Stop"
$rootPath = [IO.Path]::GetFullPath($Root)
if (-not $rootPath.StartsWith("E:\work\app\", [StringComparison]::OrdinalIgnoreCase)) {
throw "虚拟机目录必须位于 E:\work\app 下。"
}
if ($WindowsIso -and -not (Test-Path -LiteralPath $WindowsIso -PathType Leaf)) {
throw "Windows 安装介质不存在。"
}
if (Get-VM -Name $VmName -ErrorAction SilentlyContinue) {
throw "同名虚拟机已存在,拒绝覆盖。"
}
if ((Get-PSDrive E).Free -lt 40GB) { throw "E 盘剩余不足 40GB,暂不创建测试环境。" }
New-Item -ItemType Directory -Path $rootPath -Force | Out-Null
$disk = Join-Path $rootPath "sqlserver2008r2.vhdx"
if (Test-Path -LiteralPath $disk) { throw "测试磁盘已存在,拒绝覆盖。" }
New-VHD -Path $disk -SizeBytes 64GB -Dynamic | Out-Null
$vm = New-VM -Name $VmName -Generation 1 -MemoryStartupBytes 4GB `
-VHDPath $disk -Path $rootPath
Set-VM -VM $vm -ProcessorCount 2 -AutomaticStartAction Nothing `
-AutomaticStopAction ShutDown -CheckpointType Disabled `
-SnapshotFileLocation $rootPath -SmartPagingFilePath $rootPath
# 来宾系统尚未安装,先断开网卡,不改 Docker/WSL 的交换机。
Get-VMNetworkAdapter -VM $vm | Disconnect-VMNetworkAdapter
if ($WindowsIso) {
Add-VMDvdDrive -VM $vm -Path $WindowsIso | Out-Null
}
Get-VM -Name $VmName | Select-Object Name, State, Generation, Path
Get-VMHardDiskDrive -VMName $VmName | Select-Object Path
Write-Host "仅创建了未启动的虚拟机和动态磁盘,未安装 Windows 或 SQL Server。"
Write-Host "需授权 Windows x64 和 SQL Server 2008 R2 安装介质,不能用 Express 承载此大账套。"