1.修改冬休逻辑

2.修改沉降数据接口,多加一个aname字段
This commit is contained in:
whm
2025-11-26 06:25:49 +08:00
parent 354beb769e
commit 3f4a22ce67
3 changed files with 51 additions and 14 deletions

View File

@@ -2,8 +2,11 @@ from datetime import datetime
from typing import List, Dict
import warnings
import copy
# 注意:根据实际项目路径调整导入,若本地测试可注释掉
from ..core.logging_config import get_logger
logger = get_logger(__name__)
class ConstructionMonitorUtils:
def __init__(self):
# 原始工况周期映射表(保持不变)
@@ -33,7 +36,7 @@ class ConstructionMonitorUtils:
"轨道铺设完成后12个月以后": 180,
"填筑或堆载,一般情况": 1,
"填筑或堆载,沉降量突变情况": 1,
"填筑或堆载,两次填筑间隔时间较长情况": 3,
"填筑或堆载,两次填筑间隔时间较长情况": 3, # 该工况原周期为3天
"堆载预压或路基填筑完成第1至3个月": 7,
"堆载预压或路基填筑完成第4至6个月": 14,
"堆载预压或路基填筑完成6个月以后": 30,
@@ -44,8 +47,7 @@ class ConstructionMonitorUtils:
"轨道板(道床)铺设后第2至3个月": 30,
"轨道板(道床)铺设后3个月以后": 90,
"架桥机(运梁车) 首次通过后": 7,
"架桥机(运梁车) 首次通过前":1,
"架桥机(运梁车) 首次通过前": 1,
}
# 构建中英文括号+逗号兼容映射表
self.compatible_periods = self._build_compatible_brackets_map()
@@ -103,6 +105,8 @@ class ConstructionMonitorUtils:
continue
base_condition = None
# 新增:标记是否为冬休回溯到合法工况的场景
is_winter_break = False # 初始化冬休标识
if latest_condition != "冬休":
if latest_condition not in self.compatible_periods:
result["error_data"].append(latest_item)
@@ -124,6 +128,7 @@ class ConstructionMonitorUtils:
base_condition = None
break
base_condition = history_condition
is_winter_break = True # 触发:冬休且回溯到合法历史工况
break
item_copy = copy.deepcopy(latest_item)
@@ -147,16 +152,29 @@ class ConstructionMonitorUtils:
result["winter"].append(item_copy)
continue
period = self.compatible_periods[base_condition]
# 核心修改:冬休回溯场景下调整测量间隔(基准周期)
original_period = self.compatible_periods[base_condition]
if is_winter_break:
# 规则1原周期为3天则改为7天规则2其他周期直接翻倍
if original_period == 3:
adjusted_period = 7
else:
adjusted_period = original_period * 2
else:
# 非冬休场景,使用原始周期
adjusted_period = original_period
# 基于调整后的周期计算剩余天数
days_passed = (calc_date - create_date).days
due_days = period - days_passed
due_days = adjusted_period - days_passed
if due_days < 0:
item_copy["remaining"] = 0 - int(abs(due_days))
result["error_data"].append(item_copy)
warn_msg = (
f"【超期警报】测点{point_idx} 最新工况'{latest_condition}'{create_date}"
f"已超期{abs(due_days)}天!基准工况:{base_condition}周期{period}"
f"已超期{abs(due_days)}天!基准工况:{base_condition}"
f"原始周期{original_period}{',冬休调整后周期'+str(adjusted_period)+'' if is_winter_break else ''}"
)
logger.warning(warn_msg)
warnings.warn(warn_msg, UserWarning)