feat: add dynamic printer configuration manager

Co-authored-by: aider (openai/DeepSeek-V3.2-Thinking) <aider@aider.chat>
This commit is contained in:
dxc
2026-02-11 14:14:59 +08:00
parent 5f3ceef3fd
commit c6fd0aca90
3 changed files with 72 additions and 8 deletions

View File

@ -1,11 +1,13 @@
import socket
import datetime
from .print_config import PrintConfigManager
class NetworkPrintService:
def __init__(self, ip='192.168.9.250', port=9100):
self.ip = ip
self.port = port
def __init__(self, ip=None, port=None):
config = PrintConfigManager.get_config('network_printer')
self.ip = ip if ip is not None else config['ip']
self.port = port if port is not None else config['port']
def _send_to_printer(self, content):
"""
@ -37,4 +39,4 @@ class NetworkPrintService:
def print_stocktake_report(self, data):
# 同样处理
return self._send_to_printer(f"盘点报告: 应盘{data.get('total')}, 实盘{data.get('scanned')}")
return self._send_to_printer(f"盘点报告: 应盘{data.get('total')}, 实盘{data.get('scanned')}")