feat: 波动测试模式前端适配 — tb_state_tst扩展+0xB4存库+页面更新

- edc_server/models.py: tb_state_tst DDL增加test_mode/data_source + B4字段
  + ALTER TABLE自动迁移 + insert_test_result扩展 + insert_wave_data
- edc_server/handlers.py: 0xB2处理传test_mode、0xB4处理调用insert_wave_data存库
- edc-web/models.py: 新增get_latest_wave_data/get_wave_records + test_mode筛选
- edc-web/routes: test_op返回wave数据、test_data支持test_mode筛选
- 前端: test_op页面增加波动数据显示区+测试模式列
  test_data页面增加test_mode下拉筛选+B4字段列+CSV导出适配
This commit is contained in:
wangfq
2026-06-03 14:14:52 +08:00
parent cf0b308e22
commit a69d7ab1d0
8 changed files with 368 additions and 8 deletions
+47 -4
View File
@@ -151,8 +151,11 @@ def get_latest_test_state(dnt_id: int) -> dict | None:
def get_test_data(page: int = 1, per_page: int = 20,
serial: str = "", date_from: str = "",
date_to: str = "") -> tuple[list[dict], int]:
"""分页查询测试数据(JOIN dnt_info),返回 (records, total)"""
date_to: str = "", test_mode: str = "") -> tuple[list[dict], int]:
"""分页查询测试数据(JOIN dnt_info),返回 (records, total)
test_mode: ''=全部, '0'=灵敏度, '1'=波动
"""
conn = get_conn()
try:
with conn.cursor() as cur:
@@ -167,6 +170,9 @@ def get_test_data(page: int = 1, per_page: int = 20,
if date_to:
where.append("t.create_time <= %s")
params.append(date_to + " 23:59:59")
if test_mode:
where.append("t.test_mode = %s")
params.append(int(test_mode))
where_clause = " AND ".join(where) if where else "1=1"
@@ -195,8 +201,11 @@ def get_test_data(page: int = 1, per_page: int = 20,
def get_all_test_data_for_export(serial: str = "", date_from: str = "",
date_to: str = "") -> list[dict]:
"""导出全部数据"""
date_to: str = "", test_mode: str = "") -> list[dict]:
"""导出全部数据
test_mode: ''=全部, '0'=灵敏度, '1'=波动
"""
conn = get_conn()
try:
with conn.cursor() as cur:
@@ -211,6 +220,9 @@ def get_all_test_data_for_export(serial: str = "", date_from: str = "",
if date_to:
where.append("t.create_time <= %s")
params.append(date_to + " 23:59:59")
if test_mode:
where.append("t.test_mode = %s")
params.append(int(test_mode))
where_clause = " AND ".join(where) if where else "1=1"
cur.execute(
@@ -285,6 +297,37 @@ def get_automation_records(dnt_id: int, since: str) -> list[dict]:
conn.close()
def get_latest_wave_data(dnt_id: int) -> dict | None:
"""获取设备最新一条 B4 波动测试数据"""
conn = get_conn()
try:
with conn.cursor() as cur:
cur.execute(
"SELECT * FROM tb_state_tst WHERE dnt_id=%s AND data_source='B4' "
"ORDER BY id DESC LIMIT 1",
(dnt_id,),
)
return cur.fetchone()
finally:
conn.close()
def get_wave_records(dnt_id: int, since: str) -> list[dict]:
"""获取本轮 B4 波动测试明细"""
conn = get_conn()
try:
with conn.cursor() as cur:
cur.execute(
"SELECT * FROM tb_state_tst "
"WHERE dnt_id=%s AND data_source='B4' AND create_time >= %s "
"ORDER BY id ASC",
(dnt_id, since),
)
return cur.fetchall()
finally:
conn.close()
# ─── 用户管理 ──────────────────────────────────────────────────────
def get_user_by_username(username: str) -> dict | None: