feat(edc-web): 线圈参数/模拟车辆参数管理 + 工装关联 + 测试环境显示
新增功能: - 线圈参数管理页 (/coil-info): 增删改查,日志记录 - 模拟车辆管理页 (/simulate-car): 增删改查,日志记录 - 工装配置页新增线圈/模拟车辆选择区,保存时关联到 tb_fixture_param - 测试信息查询页新增「测试环境」列,显示当前线圈和模拟车辆信息 - edc_server 写入测试数据时自动从 fixture 获取线圈/车辆关联 数据库: - 新增 tb_coil_info、tb_simulate_car 表 - tb_fixture_param 增加 coil_id/simulate_car_id 字段 - tb_state_tst 增加 coil_id/simulate_car_id 字段 后端: - models.py 新增线圈/模拟车辆 CRUD - get_fixture_param 改为 LEFT JOIN 返回线圈/车辆详情 - upsert_fixture_param 支持 coil_id/simulate_car_id - 测试数据查询 LEFT JOIN 线圈/车辆信息
This commit is contained in:
@@ -14,6 +14,16 @@ from app.models import (
|
||||
delete_vehicle_base_test,
|
||||
get_serialnet_by_id,
|
||||
insert_log,
|
||||
get_coil_info_list,
|
||||
get_coil_info_by_id,
|
||||
create_coil_info,
|
||||
update_coil_info,
|
||||
delete_coil_info,
|
||||
get_simulate_car_list,
|
||||
get_simulate_car_by_id,
|
||||
create_simulate_car,
|
||||
update_simulate_car,
|
||||
delete_simulate_car,
|
||||
)
|
||||
|
||||
bp = Blueprint("fixture", __name__)
|
||||
@@ -275,3 +285,181 @@ def api_delete_vehicle_base_test(test_id):
|
||||
return jsonify({"ok": True})
|
||||
except Exception as e:
|
||||
return jsonify({"ok": False, "error": str(e)}), 500
|
||||
|
||||
|
||||
# ─── 线圈参数页面 ──────────────────────────────────────────────────
|
||||
|
||||
@bp.route("/coil-info")
|
||||
@login_required
|
||||
def coil_info_page():
|
||||
"""线圈参数管理页面"""
|
||||
return render_template("coil_info.html")
|
||||
|
||||
|
||||
@bp.route("/api/coil-info")
|
||||
@login_required
|
||||
def api_list_coil_info():
|
||||
"""列出线圈参数"""
|
||||
search = request.args.get("search", "")
|
||||
items = get_coil_info_list(search)
|
||||
return jsonify(items)
|
||||
|
||||
|
||||
@bp.route("/api/coil-info/<int:coil_id>")
|
||||
@login_required
|
||||
def api_get_coil_info(coil_id):
|
||||
"""获取单个线圈参数"""
|
||||
item = get_coil_info_by_id(coil_id)
|
||||
if not item:
|
||||
return jsonify({"error": "不存在"}), 404
|
||||
return jsonify(item)
|
||||
|
||||
|
||||
@bp.route("/api/coil-info", methods=["POST"])
|
||||
@login_required
|
||||
def api_create_coil_info():
|
||||
"""创建线圈参数"""
|
||||
data = request.get_json()
|
||||
if not data:
|
||||
return jsonify({"ok": False, "error": "数据为空"}), 400
|
||||
try:
|
||||
coil_id = create_coil_info(**data)
|
||||
insert_log(
|
||||
current_user.id, current_user.username, "create",
|
||||
target="coil_info",
|
||||
detail=f"创建线圈: {data.get('coil_num','')} {data.get('name','')}",
|
||||
result="ok", ip=request.remote_addr or "",
|
||||
)
|
||||
return jsonify({"ok": True, "id": coil_id})
|
||||
except Exception as e:
|
||||
return jsonify({"ok": False, "error": str(e)}), 500
|
||||
|
||||
|
||||
@bp.route("/api/coil-info/<int:coil_id>", methods=["PUT"])
|
||||
@login_required
|
||||
def api_update_coil_info(coil_id):
|
||||
"""更新线圈参数"""
|
||||
data = request.get_json()
|
||||
if not data:
|
||||
return jsonify({"ok": False, "error": "数据为空"}), 400
|
||||
try:
|
||||
update_coil_info(coil_id, **data)
|
||||
insert_log(
|
||||
current_user.id, current_user.username, "update",
|
||||
target="coil_info",
|
||||
detail=f"更新线圈 id={coil_id}: {data.get('coil_num','')} {data.get('name','')}",
|
||||
result="ok", ip=request.remote_addr or "",
|
||||
)
|
||||
return jsonify({"ok": True})
|
||||
except Exception as e:
|
||||
return jsonify({"ok": False, "error": str(e)}), 500
|
||||
|
||||
|
||||
@bp.route("/api/coil-info/<int:coil_id>", methods=["DELETE"])
|
||||
@login_required
|
||||
def api_delete_coil_info(coil_id):
|
||||
"""删除线圈参数"""
|
||||
try:
|
||||
item = get_coil_info_by_id(coil_id)
|
||||
detail = f"删除线圈 id={coil_id}"
|
||||
if item:
|
||||
detail += f": {item.get('coil_num','')} {item.get('name','')}"
|
||||
delete_coil_info(coil_id)
|
||||
insert_log(
|
||||
current_user.id, current_user.username, "delete",
|
||||
target="coil_info",
|
||||
detail=detail,
|
||||
result="ok", ip=request.remote_addr or "",
|
||||
)
|
||||
return jsonify({"ok": True})
|
||||
except Exception as e:
|
||||
return jsonify({"ok": False, "error": str(e)}), 500
|
||||
|
||||
|
||||
# ─── 模拟车辆参数页面 ──────────────────────────────────────────────
|
||||
|
||||
@bp.route("/simulate-car")
|
||||
@login_required
|
||||
def simulate_car_page():
|
||||
"""模拟车辆参数管理页面"""
|
||||
return render_template("simulate_car.html")
|
||||
|
||||
|
||||
@bp.route("/api/simulate-car")
|
||||
@login_required
|
||||
def api_list_simulate_car():
|
||||
"""列出模拟车辆参数"""
|
||||
search = request.args.get("search", "")
|
||||
items = get_simulate_car_list(search)
|
||||
return jsonify(items)
|
||||
|
||||
|
||||
@bp.route("/api/simulate-car/<int:car_id>")
|
||||
@login_required
|
||||
def api_get_simulate_car(car_id):
|
||||
"""获取单个模拟车辆参数"""
|
||||
item = get_simulate_car_by_id(car_id)
|
||||
if not item:
|
||||
return jsonify({"error": "不存在"}), 404
|
||||
return jsonify(item)
|
||||
|
||||
|
||||
@bp.route("/api/simulate-car", methods=["POST"])
|
||||
@login_required
|
||||
def api_create_simulate_car():
|
||||
"""创建模拟车辆参数"""
|
||||
data = request.get_json()
|
||||
if not data:
|
||||
return jsonify({"ok": False, "error": "数据为空"}), 400
|
||||
try:
|
||||
car_id = create_simulate_car(**data)
|
||||
insert_log(
|
||||
current_user.id, current_user.username, "create",
|
||||
target="simulate_car",
|
||||
detail=f"创建模拟车辆: {data.get('simulate_num','')} {data.get('name','')}",
|
||||
result="ok", ip=request.remote_addr or "",
|
||||
)
|
||||
return jsonify({"ok": True, "id": car_id})
|
||||
except Exception as e:
|
||||
return jsonify({"ok": False, "error": str(e)}), 500
|
||||
|
||||
|
||||
@bp.route("/api/simulate-car/<int:car_id>", methods=["PUT"])
|
||||
@login_required
|
||||
def api_update_simulate_car(car_id):
|
||||
"""更新模拟车辆参数"""
|
||||
data = request.get_json()
|
||||
if not data:
|
||||
return jsonify({"ok": False, "error": "数据为空"}), 400
|
||||
try:
|
||||
update_simulate_car(car_id, **data)
|
||||
insert_log(
|
||||
current_user.id, current_user.username, "update",
|
||||
target="simulate_car",
|
||||
detail=f"更新模拟车辆 id={car_id}: {data.get('simulate_num','')} {data.get('name','')}",
|
||||
result="ok", ip=request.remote_addr or "",
|
||||
)
|
||||
return jsonify({"ok": True})
|
||||
except Exception as e:
|
||||
return jsonify({"ok": False, "error": str(e)}), 500
|
||||
|
||||
|
||||
@bp.route("/api/simulate-car/<int:car_id>", methods=["DELETE"])
|
||||
@login_required
|
||||
def api_delete_simulate_car(car_id):
|
||||
"""删除模拟车辆参数"""
|
||||
try:
|
||||
item = get_simulate_car_by_id(car_id)
|
||||
detail = f"删除模拟车辆 id={car_id}"
|
||||
if item:
|
||||
detail += f": {item.get('simulate_num','')} {item.get('name','')}"
|
||||
delete_simulate_car(car_id)
|
||||
insert_log(
|
||||
current_user.id, current_user.username, "delete",
|
||||
target="simulate_car",
|
||||
detail=detail,
|
||||
result="ok", ip=request.remote_addr or "",
|
||||
)
|
||||
return jsonify({"ok": True})
|
||||
except Exception as e:
|
||||
return jsonify({"ok": False, "error": str(e)}), 500
|
||||
|
||||
Reference in New Issue
Block a user