调整条件
This commit is contained in:
parent
1947f5dcda
commit
736ba63f42
@ -105,7 +105,7 @@ class DatabaseManager:
|
|||||||
return False, f"认证失败: {str(e)}"
|
return False, f"认证失败: {str(e)}"
|
||||||
|
|
||||||
@log_timing
|
@log_timing
|
||||||
def get_latest_sample_data(self):
|
def get_latest_sample_data(self, data_source=None):
|
||||||
"""
|
"""
|
||||||
Retrieves the most recently measured sample data, flattened.
|
Retrieves the most recently measured sample data, flattened.
|
||||||
Returns a dictionary where keys are element names and values are concentrations.
|
Returns a dictionary where keys are element names and values are concentrations.
|
||||||
@ -121,12 +121,10 @@ class DatabaseManager:
|
|||||||
query = f"""
|
query = f"""
|
||||||
SELECT *
|
SELECT *
|
||||||
FROM {self.schema}.element_analysis_data
|
FROM {self.schema}.element_analysis_data
|
||||||
WHERE measure_datetime = (
|
WHERE data_source = %s
|
||||||
SELECT MAX(measure_datetime) FROM {self.schema}.element_analysis_data
|
|
||||||
)
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
cur.execute(query)
|
cur.execute(query, (data_source,))
|
||||||
rows = cur.fetchall()
|
rows = cur.fetchall()
|
||||||
cur.close()
|
cur.close()
|
||||||
conn.close()
|
conn.close()
|
||||||
|
|||||||
@ -226,8 +226,9 @@ class BaseInspectionPage(QDialog):
|
|||||||
self.show_info("数据库错误", f"插入失败: {db_msg}\n(请检查数据库连接)")
|
self.show_info("数据库错误", f"插入失败: {db_msg}\n(请检查数据库连接)")
|
||||||
return
|
return
|
||||||
|
|
||||||
|
data_source = parsed_data[0].get('data_source') if parsed_data else None
|
||||||
with log_timing_context("DB读取最新样本数据", "base_page"):
|
with log_timing_context("DB读取最新样本数据", "base_page"):
|
||||||
latest_data = db.get_latest_sample_data()
|
latest_data = db.get_latest_sample_data(data_source)
|
||||||
if latest_data:
|
if latest_data:
|
||||||
self.update_ui_with_data(latest_data)
|
self.update_ui_with_data(latest_data)
|
||||||
self.show_info("同步成功", f"已同步 {len(parsed_data)} 条元素数据。\n源文件: {target_xml_name}")
|
self.show_info("同步成功", f"已同步 {len(parsed_data)} 条元素数据。\n源文件: {target_xml_name}")
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user