1.新增通过point_id获取测点信息接口
This commit is contained in:
@@ -21,7 +21,7 @@ class ConstructionMonitorUtils:
|
||||
"桥位施工桥梁,制梁前": 30,
|
||||
"桥位施工桥梁,上部结构施工中": 1,
|
||||
"架桥机(运梁车)通过": 7,
|
||||
"桥梁主体工程完工后,第1至3个月": 7,
|
||||
"桥梁主体工程完工后,第1至3个月": 7, # 模拟包含英文逗号的原始数据
|
||||
"桥梁主体工程完工后,第4至6个月": 14,
|
||||
"桥梁主体工程完工后,6个月以后": 30,
|
||||
"轨道铺设期间,前": 30,
|
||||
@@ -43,18 +43,31 @@ class ConstructionMonitorUtils:
|
||||
"轨道板(道床)铺设后,第2至3个月": 30,
|
||||
"轨道板(道床)铺设后,3个月以后": 90
|
||||
}
|
||||
# 构建中英文括号兼容映射表
|
||||
# 构建中英文括号+逗号兼容映射表
|
||||
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():
|
||||
# 1. 保留原始key
|
||||
compatible_map[original_key] = period
|
||||
# 生成中文括号版key并添加到映射表
|
||||
|
||||
# 2. 生成中文括号版key(原逻辑)
|
||||
chinese_bracket_key = original_key.replace("(", "(").replace(")", ")")
|
||||
if chinese_bracket_key != original_key:
|
||||
compatible_map[chinese_bracket_key] = period
|
||||
|
||||
# 3. 生成英文逗号转中文逗号版key(新增逻辑)
|
||||
chinese_comma_key = original_key.replace(",", ",")
|
||||
if chinese_comma_key != original_key:
|
||||
compatible_map[chinese_comma_key] = period
|
||||
|
||||
# 4. 生成中文括号+中文逗号混合版key(双重兼容)
|
||||
mixed_key = chinese_bracket_key.replace(",", ",")
|
||||
if mixed_key != original_key and mixed_key not in compatible_map:
|
||||
compatible_map[mixed_key] = period
|
||||
|
||||
return compatible_map
|
||||
|
||||
def get_due_data(self, input_data: List[List[Dict]], start: int = 0, end: int = 1, current_date: datetime = None) -> Dict[str, List[Dict]]:
|
||||
@@ -64,9 +77,7 @@ class ConstructionMonitorUtils:
|
||||
|
||||
calc_date = current_date.date() if current_date else datetime.now().date()
|
||||
|
||||
# ------------------------------
|
||||
# 原有核心逻辑(完全不变)
|
||||
# ------------------------------
|
||||
for point_idx, point_data in enumerate(input_data):
|
||||
if not point_data:
|
||||
continue
|
||||
@@ -138,22 +149,17 @@ class ConstructionMonitorUtils:
|
||||
item_copy["remaining"] = due_days
|
||||
result["data"].append(item_copy)
|
||||
|
||||
# ------------------------------
|
||||
# 新增步骤:data中相同NYID保留剩余天数最少的记录
|
||||
# ------------------------------
|
||||
if result["data"]:
|
||||
# 用字典临时存储:key=NYID,value=该NYID下剩余天数最少的记录
|
||||
nyid_min_remaining = {}
|
||||
for record in result["data"]:
|
||||
nyid = record.get("NYID") # 假设NYID字段名是"NYID",若实际不同需调整
|
||||
nyid = record.get("NYID")
|
||||
if not nyid:
|
||||
continue # 无NYID的记录直接保留(或按需求处理)
|
||||
continue
|
||||
|
||||
# 若该NYID未存储,或当前记录剩余天数更少,则更新
|
||||
if nyid not in nyid_min_remaining or record["remaining"] < nyid_min_remaining[nyid]["remaining"]:
|
||||
nyid_min_remaining[nyid] = record
|
||||
|
||||
# 将字典 values 转换为列表,作为去重后的data
|
||||
result["data"] = list(nyid_min_remaining.values())
|
||||
|
||||
return result
|
||||
Reference in New Issue
Block a user