diff --git a/fam-core/src/fam_core/db_layer.py b/fam-core/src/fam_core/db_layer.py index af00032..a19671c 100644 --- a/fam-core/src/fam_core/db_layer.py +++ b/fam-core/src/fam_core/db_layer.py @@ -176,8 +176,28 @@ def get_video_url_exists(video_path: str) -> bool: # ============================================================ def _dt_or_none(value): - """datetime 字段归一化: 空串/None → NULL(MariaDB 严格模式拒绝 '' 插入 DATETIME 列)""" - return value if value else None + """datetime 字段归一化(MariaDB 严格模式兼容) + + - 空串/None/'None'/'null' → NULL + - ISO 8601(2026-08-20T01:06:44Z / 2026-08-20T01:06:44.123+00:00)→ '2026-08-20 01:06:44' + - 已为标准格式则原样返回 + """ + if value is None: + return None + s = str(value).strip() + if s in ('', 'None', 'null', 'NaN'): + return None + # 归一化 ISO 8601 -> 'YYYY-MM-DD HH:MM:SS' + s2 = s.replace('T', ' ').replace('Z', '').replace('z', '') + if '+' in s2[10:]: + s2 = s2[:s2.index('+')] + if '.' in s2: + s2 = s2[:s2.index('.')] + try: + dt = datetime.strptime(s2, '%Y-%m-%d %H:%M:%S') + return dt.strftime('%Y-%m-%d %H:%M:%S') + except Exception: + return None def insert_event(task_id: int, event_start_time: str, event_end_time: str, diff --git a/fam-edge/config/config.yaml b/fam-edge/config/config.yaml index c7cc96f..848892d 100644 --- a/fam-edge/config/config.yaml +++ b/fam-edge/config/config.yaml @@ -72,6 +72,6 @@ models: model_name: "qwen2.5:7b" base_url: "http://localhost:11434" timeout: 300 - num_predict: 1024 + num_predict: 512 circuit_breaker: enabled: false