Add HTTP print API for packing list and sign-off receipt
- core/printing.py: SumatraPDF silent print backend (dry_run, timeout, error capture) - core/print_document.py: orchestrate generate() + print, per-report paper size, printer fallback - core/print_api.py: FastAPI POST /api/print + GET /api/health, HTTPBearer auth, English Swagger at /api/docs - serve.py: uvicorn entrypoint - config: printers/print/api sections in settings.yaml + core/settings.py - requirements.txt: add fastapi, uvicorn - .gitignore: ignore logs/
This commit is contained in:
@@ -48,11 +48,37 @@ class ReportConfig(BaseModel):
|
||||
debug_border: bool = False
|
||||
|
||||
|
||||
class PrintersConfig(BaseModel):
|
||||
"""打印机配置(MVP:单一默认打印机)"""
|
||||
|
||||
default: str
|
||||
|
||||
|
||||
class PrintConfig(BaseModel):
|
||||
"""打印后端配置"""
|
||||
|
||||
backend: str = "sumatrapdf"
|
||||
sumatrapdf_path: str = "C:/Program Files/SumatraPDF/SumatraPDF.exe"
|
||||
default_settings: str = "paper=A4,orientation=portrait,color=bw"
|
||||
settings_by_report: dict[str, str] = {}
|
||||
|
||||
|
||||
class ApiConfig(BaseModel):
|
||||
"""HTTP 打印服务配置"""
|
||||
|
||||
host: str = "0.0.0.0"
|
||||
port: int = 8000
|
||||
token: str = ""
|
||||
|
||||
|
||||
class Settings(BaseModel):
|
||||
"""应用配置"""
|
||||
|
||||
database: DatabaseConfig
|
||||
report: ReportConfig = ReportConfig()
|
||||
printers: PrintersConfig
|
||||
print: PrintConfig = PrintConfig()
|
||||
api: ApiConfig = ApiConfig()
|
||||
|
||||
@property
|
||||
def database_url(self) -> URL:
|
||||
|
||||
Reference in New Issue
Block a user