|
|
@@ -385,6 +385,11 @@ def parse_electromagnetic_detection_record(markdown_content: str) -> Electromagn
|
|
|
monitor_at_idx = i
|
|
|
logger.debug(f"[电磁检测] 识别到时间列: 索引{i}, 值={cell}")
|
|
|
continue
|
|
|
+ # 仅时间格式(HH:MM 或 HH:MM:SS),避免把小数如 11.13 当时间
|
|
|
+ if re.match(r'^\d{1,2}:\d{2}(:\d{2})?$', cell) and monitor_at_idx == -1:
|
|
|
+ monitor_at_idx = i
|
|
|
+ logger.debug(f"[电磁检测] 识别到时间列(仅时间): 索引{i}, 值={cell}")
|
|
|
+ continue
|
|
|
|
|
|
# 检查是否是高度列(包含"m"单位,且不是时间格式)
|
|
|
if "m" in cell and not re.search(r'\d{4}[.\-]\d{1,2}[.\-]\d{1,2}', cell):
|
|
|
@@ -412,10 +417,16 @@ def parse_electromagnetic_detection_record(markdown_content: str) -> Electromagn
|
|
|
logger.debug(f"[电磁检测] 使用默认高度列位置: 索引2")
|
|
|
|
|
|
if monitor_at_idx == -1:
|
|
|
- # 尝试默认位置:第3列(索引3)
|
|
|
- if len(row) > 3 and row[3]:
|
|
|
- time_value = row[3].strip()
|
|
|
- if time_value:
|
|
|
+ # 时间列通常在线高列之后;若线高已识别,优先尝试 线高+1 列为时间(避免与线高列重合导致线高与检测时间重复、测量值1错位)
|
|
|
+ if height_idx >= 0 and height_idx + 1 < len(row):
|
|
|
+ time_value = (row[height_idx + 1] or "").strip()
|
|
|
+ if time_value and re.match(r'^\d{1,2}:\d{2}(:\d{2})?$', time_value):
|
|
|
+ monitor_at_idx = height_idx + 1
|
|
|
+ logger.debug(f"[电磁检测] 使用默认时间列位置: 索引{monitor_at_idx}(线高列+1)")
|
|
|
+ if monitor_at_idx == -1 and len(row) > 3 and row[3]:
|
|
|
+ time_value = (row[3] or "").strip()
|
|
|
+ # 不能与线高列重合(否则线高与检测时间会重复,且测量值1错位)
|
|
|
+ if time_value and height_idx != 3:
|
|
|
monitor_at_idx = 3
|
|
|
logger.debug(f"[电磁检测] 使用默认时间列位置: 索引3")
|
|
|
|