增加图片处理操作
This commit is contained in:
parent
614c277dae
commit
44a797c59b
|
@ -12,7 +12,8 @@ from tools.content_tools import (
|
|||
|
||||
from tools.get_pictures import (
|
||||
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,
|
||||
|
@ -179,7 +180,11 @@ async def generate_report(base_info, baogao_info):
|
|||
temperature = shigong_data['temperature'] #温度
|
||||
wind_speed = shigong_data['windSpeed'] #风速
|
||||
weather = get_weather(shigong_data["weatherCode"]) #天气
|
||||
#拉取图片数据
|
||||
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)
|
||||
|
|
|
@ -53,7 +53,7 @@ def get_part_list(turbineId : str) -> dict:
|
|||
|
||||
|
||||
|
||||
def get_picture(turbineId : str):
|
||||
def get_picture(turbineId : str) -> list[dict]:
|
||||
"""获取对应机组所有图片
|
||||
|
||||
Args:
|
||||
|
@ -61,40 +61,32 @@ def get_picture(turbineId : str):
|
|||
Return:
|
||||
list: 包含所有图片信息的列表(按部件分list)
|
||||
[
|
||||
[
|
||||
{
|
||||
"imageId": "字符串",
|
||||
"imageName": "字符串",
|
||||
"imagePath": "字符串",
|
||||
"partId": "字符串",
|
||||
"partName": "字符串",
|
||||
"imageResolution": "字符串",
|
||||
"focalDistance": "字符串/None",
|
||||
"shootingTime": "字符串/None",
|
||||
"cameraManufacturer": "字符串/None",
|
||||
"cameraModel": "字符串/None",
|
||||
"weather": "字符串/None",
|
||||
"weatherLabel": "字符串/None",
|
||||
"humidness": "数值/None",
|
||||
"temperature": "字符串/None",
|
||||
"windLevel": "数值/None",
|
||||
"shootingMethod": "字符串/None",
|
||||
"shootingMethodLabel": "字符串/None",
|
||||
"shootingDistance": "数值/None",
|
||||
"collectorName": "字符串/None",
|
||||
"imageType": "None",
|
||||
"imageTypeLabel": "None",
|
||||
"audioList": "None",
|
||||
"gps": "字符串/None"
|
||||
},
|
||||
...
|
||||
],
|
||||
[
|
||||
{
|
||||
// 相同结构的字典对象
|
||||
},
|
||||
...
|
||||
]
|
||||
{
|
||||
"imageId": "图片id",
|
||||
"imageName": "图片名",
|
||||
"imagePath": "图片路径",
|
||||
"partId": "部件id",
|
||||
"partName": "部件名",
|
||||
"imageResolution": "字符串",
|
||||
"focalDistance": "字符串/None",
|
||||
"shootingTime": "字符串/None",
|
||||
"cameraManufacturer": "字符串/None",
|
||||
"cameraModel": "字符串/None",
|
||||
"weather": "字符串/None",
|
||||
"weatherLabel": "字符串/None",
|
||||
"humidness": "数值/None",
|
||||
"temperature": "字符串/None",
|
||||
"windLevel": "数值/None",
|
||||
"shootingMethod": "字符串/None",
|
||||
"shootingMethodLabel": "字符串/None",
|
||||
"shootingDistance": "数值/None",
|
||||
"collectorName": "字符串/None",
|
||||
"imageType": "None",
|
||||
"imageTypeLabel": "None",
|
||||
"audioList": "None",
|
||||
"gps": "字符串/None"
|
||||
},
|
||||
...
|
||||
]
|
||||
"""
|
||||
picturerul = DTURL + GETPICTURELIST
|
||||
|
@ -104,6 +96,15 @@ def get_picture(turbineId : str):
|
|||
params = {
|
||||
"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
|
||||
|
||||
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:
|
||||
print(f"图片处理有问题:{e}")
|
||||
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