feat: 管理后台UI全面优化 + TCP指令发送修复

- 指令页面:三个设备选择器合并为顶部统一选择器,在线/离线分组显示
- 仪表盘:8卡片压缩为6紧凑卡片,新增刷新按钮和更新时间戳
- 仪表盘:最近告警添加"查看全部"跳转链接
- 考勤页面:定位方式显示GPS/WiFi/LBS文字标签替代纯图标
- 告警页面:alarm_source中文化(单围栏/多围栏/基站/WiFi)
- 告警页面:确认操作改为DOM单行更新,无需刷新整个表格
- 数据日志:默认选中"位置"类型
- 全部表格:全选复选框tooltip改为"全选当前页"
- TCP修复:移除发送前硬性在线检查,改为尝试发送+失败提示
- TCP修复:检测僵死连接(writer.is_closing)并自动清理

via [HAPI](https://hapi.run)

Co-Authored-By: HAPI <noreply@hapi.run>
This commit is contained in:
2026-03-31 05:01:04 +00:00
parent 61c300bad8
commit b970b78136
3 changed files with 162 additions and 133 deletions

View File

@@ -103,12 +103,6 @@ async def _send_to_device(
executor : async callable
The actual send function, e.g. tcp_command_service.send_command(...)
"""
if not tcp_command_service.is_device_online(device.imei):
raise HTTPException(
status_code=400,
detail=f"Device {device.imei} is not online / 设备 {device.imei} 不在线",
)
command_log = await command_service.create_command(
db,
device_id=device.id,
@@ -117,7 +111,7 @@ async def _send_to_device(
)
try:
await executor()
result = await executor()
except Exception as e:
logging.getLogger(__name__).error("Command send failed: %s", e)
command_log.status = "failed"
@@ -128,6 +122,15 @@ async def _send_to_device(
detail=fail_msg,
)
if result is False:
command_log.status = "failed"
await db.flush()
await db.refresh(command_log)
raise HTTPException(
status_code=400,
detail=f"Device {device.imei} TCP not connected / 设备 {device.imei} TCP未连接请等待设备重连",
)
command_log.status = "sent"
command_log.sent_at = now_cst()
await db.flush()