From d7255297f088d08a05f9644f6b61c78684e405da Mon Sep 17 00:00:00 2001 From: wangfq Date: Thu, 28 May 2026 12:00:59 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=87=AA=E5=8A=A8=E5=8C=96=E5=BC=80?= =?UTF-8?q?=E5=A7=8B=E5=89=8D=E6=B8=85=E9=99=A4=E6=97=A7=E9=80=8F=E4=BC=A0?= =?UTF-8?q?=E8=AE=B0=E5=BD=95=EF=BC=8C=E9=87=8D=E7=BD=AE=E6=89=80=E6=9C=89?= =?UTF-8?q?=E8=AE=A1=E6=95=B0=E5=92=8C=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- edc-web/app/__pycache__/config.cpython-311.pyc | Bin 993 -> 1040 bytes edc-web/app/models.py | 11 +++++++++++ edc-web/app/routes/test_op.py | 4 +++- edc-web/app/static/js/test_op.js | 9 +++++++-- 4 files changed, 21 insertions(+), 3 deletions(-) diff --git a/edc-web/app/__pycache__/config.cpython-311.pyc b/edc-web/app/__pycache__/config.cpython-311.pyc index caade3155b06235e2cbe6d1f63d2e494480be931..d635b3c709cdacf11d11cf60ec4bc644050e22ff 100644 GIT binary patch delta 139 zcmaFJK7oUGIWI340}y;#A)eK_k@ps(JX1>gEg@GI=Xl@9;6R`F0LS3qaQ`5eTWp3# z#wMm_lbM+2>R9M!zAd(m!uY##HVFel#~{w>Zhh8>z1b` r=}%t3R3ja7QPAj$pizU@4N8F?q4XR477yC`UKMbMxQV@grF&r7vzmM1YH!hxFTvXIgNQ005Fyw%K!iX diff --git a/edc-web/app/models.py b/edc-web/app/models.py index 62c5eb9..cd008a4 100644 --- a/edc-web/app/models.py +++ b/edc-web/app/models.py @@ -108,6 +108,17 @@ def get_serialnet_records(dnt_id: int, limit: int = 50) -> list[dict]: conn.close() +def clear_serialnet_records(dnt_id: int): + """清除指定设备的所有透传记录""" + conn = get_conn() + try: + with conn.cursor() as cur: + cur.execute("DELETE FROM tb_serialnet WHERE dnt_id=%s", (dnt_id,)) + conn.commit() + finally: + conn.close() + + # ─── tb_state_tst ────────────────────────────────────────────────── def get_latest_test_state(dnt_id: int) -> dict | None: diff --git a/edc-web/app/routes/test_op.py b/edc-web/app/routes/test_op.py index 911cfbf..91a29f2 100644 --- a/edc-web/app/routes/test_op.py +++ b/edc-web/app/routes/test_op.py @@ -8,6 +8,7 @@ from app.models import ( get_serialnet_stats, get_latest_test_state, get_automation_averages, + clear_serialnet_records, ) bp = Blueprint("test_op", __name__) @@ -54,7 +55,8 @@ def api_automation_start(): dnt_id = data.get("dnt_id") count = int(data.get("count", 1)) - # 插入第一条 0xB0 指令 + # 清除旧记录,然后插入第一条 0xB0 + clear_serialnet_records(dnt_id) record_id = insert_serialnet(dnt_id, COMMANDS["B0"]) return jsonify({ "ok": True, diff --git a/edc-web/app/static/js/test_op.js b/edc-web/app/static/js/test_op.js index 6da7a7c..6590701 100644 --- a/edc-web/app/static/js/test_op.js +++ b/edc-web/app/static/js/test_op.js @@ -48,9 +48,14 @@ async function startAuto() { autoFailed = 0; autoRemaining = count; - // 清空平均值显示 + // 清空显示 resetAverages(); - updateUI(); + document.getElementById("latest-result").innerHTML = '

等待测试...

'; + document.getElementById("progress-bar").style.width = "0%"; + document.getElementById("progress-text").textContent = "0/" + count + " (0 失败)"; + document.getElementById("stat-done").textContent = "0"; + document.getElementById("stat-failed").textContent = "0"; + document.getElementById("stat-remaining").textContent = count; const btn = document.getElementById("btn-auto"); btn.textContent = "结束";