1.适配新的工况信息

This commit is contained in:
whm
2026-02-06 18:16:44 +08:00
parent f7e77093df
commit fdf07e0dab
2 changed files with 145 additions and 83 deletions

View File

@@ -3,15 +3,31 @@ from typing import List, Dict
import warnings
import copy
# 注意:根据实际项目路径调整导入,若本地测试可注释掉
from ..core.logging_config import get_logger
# from ..core.logging_config import get_logger
import json
# 本地测试时的logger替代可根据实际情况删除
class MockLogger:
def warning(self, msg):
print(f"[WARNING] {msg}")
def info(self, msg):
print(f"[INFO] {msg}")
def get_logger(name):
return MockLogger()
logger = get_logger(__name__)
class ConstructionMonitorUtils:
def __init__(self):
# 原始工况周期映射表(保持不变)
# 原始工况周期映射表(保持不变重复key会自动保留后面的
self.base_periods = {
"路基或预压土填筑,连续填筑":1,
"路基或预压土填筑,两次填筑间隔时间较长":7,
"预压土或路基填筑完成第1~3个月":7,
"预压土或路基填筑完成第4~6个月":14,
"仰拱底板施工完成后第1个月": 7,
"预压土或路基填筑完成6个月以后":30,
"仰拱底板施工完成后第2至3个月": 14,
"仰拱底板施工完成后3个月以后": 30,
"仰拱(底板)施工完成后第1个月": 7, # 原:仰拱(底板)施工完成后,第1个月
@@ -50,56 +66,43 @@ class ConstructionMonitorUtils:
"架桥机(运梁车) 首次通过后": 7, # 原:架桥机(运梁车)首次通过后(仅加空格)
"轨道板(道床)铺设后第1个月": 14, # 原:轨道板(道床)铺设后,第1个月
"轨道板(道床)铺设后第2至3个月": 30, # 原:轨道板(道床)铺设后,第2至3个月
"轨道板(道床)铺设后3个月以后": 90 # 未出现在待处理集,保留原始格式
"轨道板(道床)铺设后3个月以后": 90,
"架桥机(运梁车)首次通过前": 1,
"架桥机(运梁车)首次通过后前3天": 1,
"架桥机(运梁车)首次通过后": 7,
"轨道板铺设前": 14,
"轨道板(道床)铺设后第1至3个月": 14,
"轨道板(道床)铺设后第4至6个月": 30,
"轨道板(道床)铺设后6个月以后": 90,
"站场填方路基段填筑完成至静态验收": 14,
"桥墩(台)地面处拆模后": 30,
"敦身混凝土施工": 30,
"预制梁桥,架梁前": 30,
"预制梁桥,预制梁架设前": 1,
"预制梁桥预制梁架设后": 7,
"现浇梁,浇筑前": 30,
"现浇梁上部结构施工中": 1,
"架桥机(运梁车)通过": 2,
"桥梁主体工程完工后第1至3个月": 7,
"桥梁主体工程完工后第4至6个月": 14,
"侨梁主体工程完工后6个月以后": 30,
"轨道铺设,前": 30,
"轨道铺设,后": 14,
"轨道铺设完成后第1个月": 14,
"轨道铺设完成后2至3个月": 30,
"轨道铺设完成后4至12个月": 90,
"轨道铺设完成后12个月以后": 180,
"仰拱(底板)施工完成后第1个月": 7,
"仰拱(底板)施工完成后第2至3个月": 14,
"仰拱(底板)施工完成后3个月以后": 30,
"轨道板铺设前": 14,
"无砟轨道铺设后第1至3个月": 30,
"无砟轨道铺设后4至12个月": 90,
"无砟轨道铺设后12个月以后": 180,
"特殊地段隧道施工完成后至静态验收": 14
}
# 构建中英文括号+逗号兼容映射表
self.compatible_periods = self._build_compatible_brackets_map()
def _build_compatible_brackets_map(self) -> Dict[str, int]:
"""构建支持中英文括号、中英文逗号,且忽略所有空格的兼容映射表"""
compatible_map = {}
for original_key, period in self.base_periods.items():
# ========== 第一步处理原始key的空格和符号生成基础变体 ==========
# 1. 清洗空格:去除首尾+全角空格+合并连续空格+最终删除所有空格
key_no_space = original_key.strip().replace(" ", " ").replace(" ", " ").replace(" ", "")
# 2. 原始key未清洗空格
compatible_map[original_key] = period
# 3. 无空格的原始符号key
if key_no_space not in compatible_map:
compatible_map[key_no_space] = period
# ========== 第二步:生成中文括号变体(含空格/无空格) ==========
# 带空格的中文括号key
chinese_bracket_key = original_key.replace("(", "").replace(")", "")
if chinese_bracket_key != original_key and chinese_bracket_key not in compatible_map:
compatible_map[chinese_bracket_key] = period
# 无空格的中文括号key
chinese_bracket_no_space = key_no_space.replace("(", "").replace(")", "")
if chinese_bracket_no_space not in compatible_map:
compatible_map[chinese_bracket_no_space] = period
# ========== 第三步:生成中文逗号变体(含空格/无空格) ==========
# 带空格的中文逗号key
chinese_comma_key = original_key.replace(",", "")
if chinese_comma_key != original_key and chinese_comma_key not in compatible_map:
compatible_map[chinese_comma_key] = period
# 无空格的中文逗号key
chinese_comma_no_space = key_no_space.replace(",", "")
if chinese_comma_no_space not in compatible_map:
compatible_map[chinese_comma_no_space] = period
# ========== 第四步:生成中文括号+逗号混合变体(含空格/无空格) ==========
# 带空格的混合变体key
mixed_key = chinese_bracket_key.replace(",", "")
if mixed_key != original_key and mixed_key not in compatible_map:
compatible_map[mixed_key] = period
# 无空格的混合变体key
mixed_no_space = chinese_bracket_no_space.replace(",", "")
if mixed_no_space not in compatible_map:
compatible_map[mixed_no_space] = period
return compatible_map
# 移除兼容映射表直接使用原始base_periods字典特性重复key自动保留后面的
self.compatible_periods = self.base_periods
def get_due_data(self, input_data: List[List[Dict]], start: int = 0, end: int = 0, current_date: datetime = None) -> Dict[str, List[Dict]]:
result = {"winter": [], "data": [], "error_data": []}