This commit is contained in:
lhx
2025-11-29 16:25:40 +08:00
4 changed files with 76 additions and 48 deletions

View File

@@ -35,7 +35,7 @@ async def get_point_ids_by_linecode(
checkpoint_service = CheckpointService()
try:
point_ids = checkpoint_service.get_point_ids_by_linecode(db, request.linecode)
point_ids,point_id_dict = checkpoint_service.get_point_ids_by_linecode(db, request.linecode)
return {
"code": 0,
@@ -43,6 +43,7 @@ async def get_point_ids_by_linecode(
"data": {
"linecode": request.linecode,
"point_ids": point_ids,
"point_id_dict": point_id_dict,
"count": len(point_ids)
}
}

View File

@@ -254,10 +254,14 @@ class CheckpointService(BaseService[Checkpoint]):
print(nyid_list)
# 2. 根据NYID列表查询沉降数据表获取所有point_id去重
point_id_query = db.query(SettlementData.point_id).filter(
point_id_query = db.query(
SettlementData.point_id
).filter(
SettlementData.NYID.in_(nyid_list)
).distinct()
point_id_list = [result.point_id for result in point_id_query.all() if result.point_id]
point_id_list = [f'{result.point_id}' for result in point_id_query.all() if result.point_id]
# -{db.query(Checkpoint.aname).filter(Checkpoint.point_id == result.point_id).first().aname}
point_id_dict = {item :db.query(Checkpoint.aname).filter(Checkpoint.point_id == item).first().aname for item in point_id_list}
return point_id_list
return point_id_list,point_id_dict

View File

@@ -11,68 +11,89 @@ class ConstructionMonitorUtils:
def __init__(self):
# 原始工况周期映射表(保持不变)
self.base_periods = {
"仰拱(底板)施工完成后第1个月": 7,
"仰拱(底板)施工完成后第2至3个月": 14,
"仰拱(底板)施工完成后3个月以后": 30,
"无砟轨道铺设后第1至3个月": 30,
"无砟轨道铺设后4至12个月": 90,
"无砟轨道铺设后12个月以后": 180,
"仰拱(底板)施工完成后,第1个月": 7,
"仰拱(底板)施工完成后,第2至3个月": 14,
"仰拱(底板)施工完成后,3个月以后": 30,
"无砟轨道铺设后,第1至3个月": 30,
"无砟轨道铺设后,4至12个月": 90,
"无砟轨道铺设后,12个月以后": 180,
"墩台施工到一定高度": 30,
"墩台混凝土施工": 30,
"预制梁桥架梁前": 30,
"预制梁桥预制梁架设前": 1,
"预制梁桥预制梁架设后": 7,
"桥位施工桥梁制梁前": 30,
"桥位施工桥梁上部结构施工中": 1,
"预制梁桥,架梁前": 30,
"预制梁桥,预制梁架设前": 1,
"预制梁桥,预制梁架设后": 7,
"桥位施工桥梁,制梁前": 30,
"桥位施工桥梁,上部结构施工中": 1,
"架桥机(运梁车)通过": 7,
"桥梁主体工程完工后,第1至3个月": 7, # 包含英文逗号的原始数据
"桥梁主体工程完工后第4至6个月": 14,
"桥梁主体工程完工后6个月以后": 30,
"轨道铺设期间": 30,
"轨道铺设期间": 14,
"轨道铺设完成后第1个月": 14,
"轨道铺设完成后2至3个月": 30,
"轨道铺设完成后4至12个月": 90,
"轨道铺设完成后12个月以后": 180,
"填筑或堆载一般情况": 1,
"填筑或堆载沉降量突变情况": 1,
"填筑或堆载两次填筑间隔时间较长情况": 3, # 该工况原周期为3天
"堆载预压或路基填筑完成第1至3个月": 7,
"堆载预压或路基填筑完成第4至6个月": 14,
"堆载预压或路基填筑完成6个月以后": 30,
"桥梁主体工程完工后,第4至6个月": 14,
"桥梁主体工程完工后,6个月以后": 30,
"轨道铺设期间,": 30,
"轨道铺设期间,": 14,
"轨道铺设完成后,第1个月": 14,
"轨道铺设完成后,2至3个月": 30,
"轨道铺设完成后,4至12个月": 90,
"轨道铺设完成后,12个月以后": 180,
"填筑或堆载,一般情况": 1,
"填筑或堆载,沉降量突变情况": 1,
"填筑或堆载,两次填筑间隔时间较长情况": 3, # 该工况原周期为3天
"堆载预压或路基填筑完成,第1至3个月": 7,
"堆载预压或路基填筑完成,第4至6个月": 14,
"堆载预压或路基填筑完成,6个月以后": 30,
"架桥机(运梁车)首次通过前": 1,
"架桥机(运梁车)首次通过后前3天": 1,
"架桥机(运梁车)首次通过后,前3天": 1,
"架桥机(运梁车)首次通过后": 7,
"轨道板(道床)铺设后第1个月": 14,
"轨道板(道床)铺设后第2至3个月": 30,
"轨道板(道床)铺设后3个月以后": 90,
"架桥机(运梁车) 首次通过后": 7,
"架桥机(运梁车) 首次通过前": 1,
"轨道板(道床)铺设后,第1个月": 14,
"轨道板(道床)铺设后,第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
# ========== 第一步处理原始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
# 2. 生成中文括号版key
# ========== 第二步:生成中文括号变体(含空格/无空格) ==========
# 带空格的中文括号key
chinese_bracket_key = original_key.replace("(", "").replace(")", "")
if chinese_bracket_key != original_key:
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
# 3. 生成英文逗号转中文逗号版key
# ========== 第三步:生成中文逗号变体(含空格/无空格) ==========
# 带空格的中文逗号key
chinese_comma_key = original_key.replace(",", "")
if chinese_comma_key != original_key:
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
# 4. 生成中文括号+中文逗号混合版key
# ========== 第四步:生成中文括号+逗号混合变体(含空格/无空格) ==========
# 带空格的混合变体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

View File

@@ -241,6 +241,7 @@ def scheduled_get_max_nyid_by_point_id(start: int = 0,end: int = 0):
# 2. 计算到期数据
monitor = ConstructionMonitorUtils()
daily_data = monitor.get_due_data(result,start=start,end=end)
print(daily_data)
# time.sleep(10000)
data = daily_data['data']
error_data = daily_data['error_data']
@@ -256,7 +257,6 @@ def scheduled_get_max_nyid_by_point_id(start: int = 0,end: int = 0):
print(max_num)
# 提取冬休数据的point_id列表
new_list = [int(w['point_id']) for w in winters]
print(new_list)
# 获取更多历史记录
nyid_list = daily_service.get_nyid_by_point_id(db, new_list, max_num)
w_list = monitor.get_due_data(nyid_list,start=start,end=end)
@@ -298,7 +298,7 @@ def scheduled_get_max_nyid_by_point_id(start: int = 0,end: int = 0):
d['account_data'] = account_response.__dict__ if account_response else None
else:
d['account_data'] = None
print(f"一共有{len(data)}条数据{data}")
print(f"一共有{len(data)}条数据")
# 6. 构造DailyData数据并批量创建
# daily_create_data1 = set()
daily_create_data = []
@@ -320,6 +320,8 @@ def scheduled_get_max_nyid_by_point_id(start: int = 0,end: int = 0):
daily_create_data.append(tem)
# 批量创建记录
if daily_create_data:
# with open('data.json', 'w', encoding='utf-8') as f:
# json.dump(daily_create_data, f, ensure_ascii=False, indent=4)
created_records = daily_service.batch_create_by_account_nyid(db, daily_create_data)
logger.info(f"定时任务完成:成功创建{len(created_records)}条DailyData记录共处理{len(data)}个point_id数据")
else: