同时支持sanic web和本地main方法运行
This commit is contained in:
parent
e128908d67
commit
bdb654da09
@ -8,7 +8,12 @@ from openpyxl.styles import Font, Alignment
|
||||
from openpyxl.utils import get_column_letter
|
||||
import glob
|
||||
from datetime import datetime
|
||||
from .smb_tool import *
|
||||
try:
|
||||
# 相对导入
|
||||
from . import smb_tool
|
||||
except ImportError:
|
||||
# 直接运行时回退到绝对导入
|
||||
import smb_tool
|
||||
|
||||
# ---------------- 常量 ----------------
|
||||
CELL_WIDTH = 0.1 # 每格宽 (米)
|
||||
@ -535,6 +540,7 @@ def process_dir(road_dict,pile_dict,dir="output",cell_area=CELL_AREA,grid_width=
|
||||
|
||||
min_pile, max_pile = get_min_max_pile(summary_data)
|
||||
print(f"{road_code}-DR-{min_pile:0.3f}-{max_pile:0.3f}-detail-{current_time}.txt")
|
||||
os.makedirs(f"{dir}/DR", exist_ok=True)
|
||||
out_file = os.path.join(f"{dir}/DR",f"{road_code}-DR-{min_pile:0.3f}-{max_pile:0.3f}-detail-{current_time}.txt")
|
||||
header = generate_header(road_type)
|
||||
with open(out_file,'w',encoding='utf-8') as f:
|
||||
@ -568,8 +574,8 @@ def process_dir(road_dict,pile_dict,dir="output",cell_area=CELL_AREA,grid_width=
|
||||
|
||||
for road_type, group in group_by_road_type.items():
|
||||
min_pile, max_pile = get_min_max_pile(group)
|
||||
print(f"DR/{road_code}-DR-{min_pile:0.3f}-{max_pile:0.3f}-{current_time}.txt")
|
||||
out_file = os.path.join(dir,f"{road_code}-DR-{min_pile:0.3f}-{max_pile:0.3f}-{current_time}.txt")
|
||||
print(f"{road_code}-DR-{min_pile:0.3f}-{max_pile:0.3f}-{current_time}.txt")
|
||||
out_file = os.path.join(f"{dir}/DR",f"{road_code}-DR-{min_pile:0.3f}-{max_pile:0.3f}-{current_time}.txt")
|
||||
header = generate_header(road_type)
|
||||
|
||||
group_list = []
|
||||
@ -658,6 +664,7 @@ def process_dir(road_dict,pile_dict,dir="output",cell_area=CELL_AREA,grid_width=
|
||||
|
||||
# 病害明细列表.xlsx
|
||||
print("输出:病害明细列表.xlsx")
|
||||
os.makedirs(f"{dir}/excel", exist_ok=True)
|
||||
headers = ['序号','路线编码','方向','桩号','路面类型','病害名称','程度','长度(m)',' 宽度(m)',' 面积(㎡)',' 横向位置','备注']
|
||||
data_list = []
|
||||
if summary_data:
|
||||
@ -675,7 +682,7 @@ def process_dir(road_dict,pile_dict,dir="output",cell_area=CELL_AREA,grid_width=
|
||||
data_list.append(excel_data)
|
||||
|
||||
all_data = [headers] + data_list
|
||||
write_to_excel_pandas(all_data, img_file_path + '/excel/病害明细列表.xlsx')
|
||||
smb_tool.write_to_excel_pandas(all_data, img_file_path + '/excel/病害明细列表.xlsx')
|
||||
|
||||
# 综合明细表.xlsx
|
||||
print("输出:综合明细表.xlsx")
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user