style: normalize code formatting across the codebase

- Standardize quote style (single to double quotes)
- Improve code formatting consistency
- Apply formatting to utilities, GUI components, and tools
- Update imports and docstrings for consistency

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
Misaka_Company
2026-02-05 14:56:35 +08:00
parent c34a300f0b
commit 2ca53f6a55
27 changed files with 693 additions and 385 deletions

View File

@@ -3,6 +3,7 @@ SQL Server 数据库连接组件
提供数据库连接和查询接口
"""
import pyodbc
from typing import List, Dict, Any, Optional
import sys
@@ -17,12 +18,12 @@ from config.defaults import DEFAULT_APP_CONFIG
# 从默认配置获取数据库配置
SQL_SERVER_CONFIG = {
'driver': DEFAULT_APP_CONFIG.database.driver,
'server': DEFAULT_APP_CONFIG.database.server,
'database': DEFAULT_APP_CONFIG.database.database,
'username': DEFAULT_APP_CONFIG.database.username,
'password': DEFAULT_APP_CONFIG.database.password,
'TrustServerCertificate': DEFAULT_APP_CONFIG.database.trust_server_certificate,
"driver": DEFAULT_APP_CONFIG.database.driver,
"server": DEFAULT_APP_CONFIG.database.server,
"database": DEFAULT_APP_CONFIG.database.database,
"username": DEFAULT_APP_CONFIG.database.username,
"password": DEFAULT_APP_CONFIG.database.password,
"TrustServerCertificate": DEFAULT_APP_CONFIG.database.trust_server_certificate,
}
@@ -61,7 +62,9 @@ class DatabaseConnection:
try:
self.connection = pyodbc.connect(conn_str)
print(f"成功连接到数据库: {self.config['server']}/{self.config['database']}")
print(
f"成功连接到数据库: {self.config['server']}/{self.config['database']}"
)
return self.connection
except pyodbc.Error as e:
print(f"数据库连接失败: {e}")
@@ -74,7 +77,9 @@ class DatabaseConnection:
self.connection = None
print("数据库连接已关闭")
def execute_query(self, sql: str, params: Optional[tuple] = None) -> List[Dict[str, Any]]:
def execute_query(
self, sql: str, params: Optional[tuple] = None
) -> List[Dict[str, Any]]:
"""
执行查询语句并返回结果
@@ -168,7 +173,7 @@ def query_production_orders(总排号_list: List[str]) -> List[Dict[str, Any]]:
db = DatabaseConnection()
# 构建占位符字符串
placeholders = ','.join(['?' for _ in 总排号_list])
placeholders = ",".join(["?" for _ in 总排号_list])
sql = f"""
SELECT [总排号], [生产订单号], [序号], [订单号], [客户名称], [产品型号]

View File

@@ -2,6 +2,7 @@
待删除物料查询组件
从数据库查询指定负责人需要删除的物料名称
"""
from typing import List, Dict, Any
from db.connection import get_connection
@@ -25,7 +26,7 @@ def get_materials_to_delete(manager_name):
with get_connection() as conn:
results = conn.execute_query(query, (manager_name,))
# 提取物料名称并去除空值
material_names = [row['MaterialName'] for row in results if row['MaterialName']]
material_names = [row["MaterialName"] for row in results if row["MaterialName"]]
return material_names

View File

@@ -2,6 +2,7 @@
生产订单号查询组件
从 ProductionID.txt 读取总排号,查询数据库获取生产订单号
"""
from db.connection import get_connection
@@ -15,7 +16,7 @@ def read_production_ids(file_path):
Returns:
总排号列表
"""
with open(file_path, 'r', encoding='utf-8') as f:
with open(file_path, "r", encoding="utf-8") as f:
# 去除空白行和空格
production_ids = [line.strip() for line in f if line.strip()]
return production_ids
@@ -40,8 +41,8 @@ def query_production_order_numbers(production_ids):
# 分批查询
for i in range(0, len(production_ids), BATCH_SIZE):
batch = production_ids[i:i + BATCH_SIZE]
placeholders = ','.join(['?' for _ in batch])
batch = production_ids[i : i + BATCH_SIZE]
placeholders = ",".join(["?" for _ in batch])
query = f"""
SELECT [生产订单号]
@@ -52,7 +53,7 @@ def query_production_order_numbers(production_ids):
with get_connection() as conn:
results = conn.execute_query(query, tuple(batch))
# 提取生产订单号并去除空值
batch_numbers = [row['生产订单号'] for row in results if row['生产订单号']]
batch_numbers = [row["生产订单号"] for row in results if row["生产订单号"]]
all_results.extend(batch_numbers)
return all_results