feat: 新增检验数据查询接口,优化主窗口防抖机制及数据处理逻辑

This commit is contained in:
zhu-mengmeng 2025-07-22 18:34:18 +08:00
parent 95ba01e152
commit 268a1cc16b
3 changed files with 464 additions and 230 deletions

View File

@ -1138,4 +1138,55 @@ class InspectionDAO:
return True
except Exception as e:
logging.error(f"删除包装记录失败: {str(e)}")
return False
return False
def get_inspection_data_by_config(self, order_id, gc_note, tray_id, position, config_id):
"""根据工程号、托盘号、位置和配置ID查询检验数据
Args:
order_id: 订单号
gc_note: 工程号
tray_id: 托盘号
position: 位置序号
config_id: 配置ID
Returns:
dict: 检验数据记录如果不存在则返回None
"""
try:
# 使用SQLUtils获取数据库连接
sql = """
SELECT id, order_id, gc_note, position, config_id, value, status, remark, tray_id, create_time, update_time
FROM wsbz_inspection_data
WHERE order_id = ? AND gc_note = ? AND tray_id = ? AND position = ? AND config_id = ?
ORDER BY update_time DESC
LIMIT 1
"""
with SQLUtils('sqlite', database='db/jtDB.db') as db:
# 执行查询
db.cursor.execute(sql, (order_id, gc_note, tray_id, position, config_id))
# 获取结果
row = db.cursor.fetchone()
# 如果有结果,转换为字典
if row:
return {
'id': row[0],
'order_id': row[1],
'gc_note': row[2],
'position': row[3],
'config_id': row[4],
'value': row[5],
'status': row[6],
'remark': row[7],
'tray_id': row[8],
'create_time': row[9],
'update_time': row[10]
}
else:
return None
except Exception as e:
logging.error(f"查询检验数据失败: {str(e)}")
return None

View File

@ -48,7 +48,7 @@ class ModbusMonitor(QObject):
register_error = Signal(int, str)
monitor_status_changed = Signal(bool, str)
def __init__(self, polling_interval=1.0, max_errors=3, retry_interval=5.0):
def __init__(self, polling_interval=0.5, max_errors=3, retry_interval=5.0):
"""
初始化Modbus监控器

File diff suppressed because it is too large Load Diff