增加图片处理操作
This commit is contained in:
parent
614c277dae
commit
44a797c59b
|
@ -12,7 +12,8 @@ from tools.content_tools import (
|
||||||
|
|
||||||
from tools.get_pictures import (
|
from tools.get_pictures import (
|
||||||
make_Thumbnail,resize_and_reduce_quality,
|
make_Thumbnail,resize_and_reduce_quality,
|
||||||
get_picture_nums,find_image,collect_defect_data
|
get_picture_nums,find_image,collect_defect_data,
|
||||||
|
process_picture_data
|
||||||
)
|
)
|
||||||
|
|
||||||
from tools.Get_Json import (get_project_info,get_jizu_info,
|
from tools.Get_Json import (get_project_info,get_jizu_info,
|
||||||
|
@ -179,7 +180,11 @@ async def generate_report(base_info, baogao_info):
|
||||||
temperature = shigong_data['temperature'] #温度
|
temperature = shigong_data['temperature'] #温度
|
||||||
wind_speed = shigong_data['windSpeed'] #风速
|
wind_speed = shigong_data['windSpeed'] #风速
|
||||||
weather = get_weather(shigong_data["weatherCode"]) #天气
|
weather = get_weather(shigong_data["weatherCode"]) #天气
|
||||||
|
#拉取图片数据
|
||||||
picture_data = get_picture(turbine_id)
|
picture_data = get_picture(turbine_id)
|
||||||
|
#获取缺陷图列表和典型图列表
|
||||||
|
defect_pictures, typical_pictures = process_picture_data(picture_data, image_source_to_find)
|
||||||
|
#处理图片数据
|
||||||
|
|
||||||
|
|
||||||
date_year_month = get_year_month(baogao_date)
|
date_year_month = get_year_month(baogao_date)
|
||||||
|
|
|
@ -53,21 +53,20 @@ def get_part_list(turbineId : str) -> dict:
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def get_picture(turbineId : str):
|
def get_picture(turbineId : str) -> list[dict]:
|
||||||
"""获取对应机组所有图片
|
"""获取对应机组所有图片
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
turbineId (str): 机组ID
|
turbineId (str): 机组ID
|
||||||
Return:
|
Return:
|
||||||
list: 包含所有图片信息的列表(按部件分list)
|
list: 包含所有图片信息的列表(按部件分list)
|
||||||
[
|
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"imageId": "字符串",
|
"imageId": "图片id",
|
||||||
"imageName": "字符串",
|
"imageName": "图片名",
|
||||||
"imagePath": "字符串",
|
"imagePath": "图片路径",
|
||||||
"partId": "字符串",
|
"partId": "部件id",
|
||||||
"partName": "字符串",
|
"partName": "部件名",
|
||||||
"imageResolution": "字符串",
|
"imageResolution": "字符串",
|
||||||
"focalDistance": "字符串/None",
|
"focalDistance": "字符串/None",
|
||||||
"shootingTime": "字符串/None",
|
"shootingTime": "字符串/None",
|
||||||
|
@ -88,13 +87,6 @@ def get_picture(turbineId : str):
|
||||||
"gps": "字符串/None"
|
"gps": "字符串/None"
|
||||||
},
|
},
|
||||||
...
|
...
|
||||||
],
|
|
||||||
[
|
|
||||||
{
|
|
||||||
// 相同结构的字典对象
|
|
||||||
},
|
|
||||||
...
|
|
||||||
]
|
|
||||||
]
|
]
|
||||||
"""
|
"""
|
||||||
picturerul = DTURL + GETPICTURELIST
|
picturerul = DTURL + GETPICTURELIST
|
||||||
|
@ -104,6 +96,15 @@ def get_picture(turbineId : str):
|
||||||
params = {
|
params = {
|
||||||
"partId" : part_id,
|
"partId" : part_id,
|
||||||
}
|
}
|
||||||
result.append(get_data(picturerul, params = params))
|
for images in get_data(picturerul, params = params):
|
||||||
|
result.append(images)
|
||||||
|
print(f"图片数据获取成功:{result}")
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
def find_defect_record(defect_pictures : list[dict]):
|
||||||
|
"""查找缺陷图片的缺陷记录
|
||||||
|
|
||||||
|
Args:
|
||||||
|
defect_pictures (list[dict]): 缺陷图列表
|
||||||
|
"""
|
||||||
|
|
Binary file not shown.
Binary file not shown.
|
@ -232,3 +232,26 @@ def create_thumbnail(file_path: str, size: tuple) -> Image:
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"图片处理有问题:{e}")
|
print(f"图片处理有问题:{e}")
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
def process_picture_data(picture_data : list[dict],
|
||||||
|
image_source_to_find : list[str],
|
||||||
|
quexian_type : str,
|
||||||
|
dianxing_type : str) -> tuple[list[str], list[str]]:
|
||||||
|
"""处理从数据库获取的图片数据
|
||||||
|
|
||||||
|
Args:
|
||||||
|
picture_data (list[dict]): 图片数据
|
||||||
|
image_source_to_find (list[str]): 要查找的图片来源枚举(外内防雷)
|
||||||
|
quexian_type (str): 缺陷类型枚举值
|
||||||
|
dianxing_type (str): 典型类型枚举值
|
||||||
|
Returns:
|
||||||
|
tuple(
|
||||||
|
defct_pictures, 缺陷图列表
|
||||||
|
dianxing_pictures 典型图列表
|
||||||
|
)
|
||||||
|
"""
|
||||||
|
#过滤目标来源的图片数据
|
||||||
|
picture_data = [pic for pic in picture_data if pic['imageSource'] in image_source_to_find]
|
||||||
|
#分别择出缺陷图和典型图
|
||||||
|
return [pic for pic in picture_data if pic['imageType'] == quexian_type], [pic for pic in picture_data if pic['imageType'] == dianxing_type]
|
||||||
|
|
Loading…
Reference in New Issue