|
|
@@ -1,7 +1,9 @@
|
|
|
import settings
|
|
|
+from settings import sendSocketMessage
|
|
|
from .detail_func import *
|
|
|
import json
|
|
|
from .base import *
|
|
|
+
|
|
|
# from .match_and_cutout_mode_control.base_deal_image_v2 import BaseDealImage
|
|
|
# from module.view_control.MineQWidget import DialogShow, WorkerOneThread
|
|
|
import threading
|
|
|
@@ -13,13 +15,16 @@ from PIL import Image
|
|
|
from io import BytesIO
|
|
|
import os, re
|
|
|
from functools import partial
|
|
|
+
|
|
|
# from multiprocessing import Process, Queue
|
|
|
import pickle
|
|
|
-from .base_deal import BaseDealImage
|
|
|
+from .base_deal import BaseDealImage
|
|
|
from middleware import UnicornException
|
|
|
from settings import recordDataPoint
|
|
|
+import asyncio
|
|
|
+
|
|
|
|
|
|
-class RunMain():
|
|
|
+class RunMain:
|
|
|
# run_end_sign = Signal(dict)
|
|
|
# show_dialog_sign = Signal(dict)
|
|
|
# show_progress_detail_sign = Signal(str)
|
|
|
@@ -67,7 +72,9 @@ class RunMain():
|
|
|
goods_art_nos = config_data["goods_art_nos"]
|
|
|
logo_path = config_data["logo_path"]
|
|
|
cutout_mode = config_data["cutout_mode"] # 是否精细化抠图,默认为普通抠图
|
|
|
- special_goods_art_no_folder_line = config_data["special_goods_art_no_folder_line"]
|
|
|
+ special_goods_art_no_folder_line = config_data[
|
|
|
+ "special_goods_art_no_folder_line"
|
|
|
+ ]
|
|
|
# 自动处理红蜻蜓货号,进行重命名
|
|
|
# if settings.PROJECT == "红蜻蜓":
|
|
|
# # 规整红蜻蜓货号图
|
|
|
@@ -86,20 +93,34 @@ class RunMain():
|
|
|
is_filter = False
|
|
|
specified_goods_art_no_folder = special_goods_art_no_folder_line
|
|
|
specified_goods_art_no_folder = specified_goods_art_no_folder.strip()
|
|
|
- specified_goods_art_no_folder = specified_goods_art_no_folder.replace(",", ",")
|
|
|
- specified_goods_art_no_folder_list = specified_goods_art_no_folder.split(",")
|
|
|
- specified_goods_art_no_folder_list = [x for x in specified_goods_art_no_folder_list if x]
|
|
|
+ specified_goods_art_no_folder = specified_goods_art_no_folder.replace(
|
|
|
+ ",", ","
|
|
|
+ )
|
|
|
+ specified_goods_art_no_folder_list = specified_goods_art_no_folder.split(
|
|
|
+ ","
|
|
|
+ )
|
|
|
+ specified_goods_art_no_folder_list = [
|
|
|
+ x for x in specified_goods_art_no_folder_list if x
|
|
|
+ ]
|
|
|
if not specified_goods_art_no_folder_list:
|
|
|
- return_data["message"] += '请手动输入文件夹名称(多选),或关闭指定文件夹模式\n'
|
|
|
+ return_data[
|
|
|
+ "message"
|
|
|
+ ] += "请手动输入文件夹名称(多选),或关闭指定文件夹模式\n"
|
|
|
else:
|
|
|
for i in all_goods_art_no_folder_data:
|
|
|
if i["folder_path"] in specified_goods_art_no_folder_list:
|
|
|
i["label"] = "待处理"
|
|
|
# 哪些数据不合规
|
|
|
- all_folder_name_list = [x["folder_name"] for x in all_goods_art_no_folder_data]
|
|
|
+ all_folder_name_list = [
|
|
|
+ x["folder_name"] for x in all_goods_art_no_folder_data
|
|
|
+ ]
|
|
|
for goods_art_no_folder_name in specified_goods_art_no_folder_list:
|
|
|
if goods_art_no_folder_name not in all_folder_name_list:
|
|
|
- return_data["message"] += '文件夹:{},在您选的目录下不存在\n'.format(goods_art_no_folder_name)
|
|
|
+ return_data[
|
|
|
+ "message"
|
|
|
+ ] += "文件夹:{},在您选的目录下不存在\n".format(
|
|
|
+ goods_art_no_folder_name
|
|
|
+ )
|
|
|
f = False
|
|
|
|
|
|
if not f:
|
|
|
@@ -110,7 +131,9 @@ class RunMain():
|
|
|
# 清空指定文件夹的已抠图文件
|
|
|
if is_do_other:
|
|
|
for folder_data in all_goods_art_no_folder_data:
|
|
|
- goods_art_no_folder_path = "{}/原始图_已抠图".format(folder_data["folder_path"])
|
|
|
+ goods_art_no_folder_path = "{}/原始图_已抠图".format(
|
|
|
+ folder_data["folder_path"]
|
|
|
+ )
|
|
|
if os.path.exists(goods_art_no_folder_path):
|
|
|
remove_all_file(goods_art_no_folder_path)
|
|
|
|
|
|
@@ -120,13 +143,13 @@ class RunMain():
|
|
|
res = BaseDealImage(token=self.token).getImageOrder(
|
|
|
image_order=image_order, resize_image_view=resize_image_view
|
|
|
)
|
|
|
- if res['code'] != 0:
|
|
|
- return_data["message"] += "{}\n".format(res['msg'])
|
|
|
+ if res["code"] != 0:
|
|
|
+ return_data["message"] += "{}\n".format(res["msg"])
|
|
|
# raise UnicornException(return_data["message"])
|
|
|
return return_data
|
|
|
else:
|
|
|
# 图片命名顺序
|
|
|
- image_order_list = res['imageOrderList']
|
|
|
+ image_order_list = res["imageOrderList"]
|
|
|
print("图片命名顺序", image_order_list, all_goods_art_no_folder_data)
|
|
|
for goods_art_no_folder_data in all_goods_art_no_folder_data:
|
|
|
if goods_art_no_folder_data["label"] != "待处理":
|
|
|
@@ -145,12 +168,15 @@ class RunMain():
|
|
|
goods_art_no_folder_data["label"] = "不处理"
|
|
|
|
|
|
# ================检查每个货号文件夹图片数量是否符合要求
|
|
|
- all_goods_art_no_folder_data, message = BaseDealImage(token=self.token).check_folders_image_amount(all_goods_art_no_folder_data,
|
|
|
- image_order_list)
|
|
|
+ all_goods_art_no_folder_data, message = BaseDealImage(
|
|
|
+ token=self.token
|
|
|
+ ).check_folders_image_amount(all_goods_art_no_folder_data, image_order_list)
|
|
|
if message:
|
|
|
return_data["message"] += "{}\n".format(message)
|
|
|
return_data["code"] = 0
|
|
|
- return_data["data"]["all_goods_art_no_folder_data"] = all_goods_art_no_folder_data
|
|
|
+ return_data["data"][
|
|
|
+ "all_goods_art_no_folder_data"
|
|
|
+ ] = all_goods_art_no_folder_data
|
|
|
return_data["data"]["image_dir"] = image_dir
|
|
|
return_data["data"]["resize_image_view"] = resize_image_view
|
|
|
return_data["data"]["cutout_mode"] = cutout_mode
|
|
|
@@ -180,12 +206,16 @@ class RunMain():
|
|
|
|
|
|
do_next = False
|
|
|
text = ""
|
|
|
- all_goods_art_no_folder_data = return_data["data"]["all_goods_art_no_folder_data"]
|
|
|
+ all_goods_art_no_folder_data = return_data["data"][
|
|
|
+ "all_goods_art_no_folder_data"
|
|
|
+ ]
|
|
|
button_1, button_2, button_3 = None, None, None
|
|
|
text += return_data["message"]
|
|
|
# 存在错误文件夹
|
|
|
error_folder = [x for x in all_goods_art_no_folder_data if x["label"] == "错误"]
|
|
|
- todo_folder = [x for x in all_goods_art_no_folder_data if x["label"] == "待处理"]
|
|
|
+ todo_folder = [
|
|
|
+ x for x in all_goods_art_no_folder_data if x["label"] == "待处理"
|
|
|
+ ]
|
|
|
if error_folder:
|
|
|
button_2 = "移除错误文件"
|
|
|
if error_folder and todo_folder:
|
|
|
@@ -194,7 +224,9 @@ class RunMain():
|
|
|
if not error_folder and todo_folder:
|
|
|
button_1 = "继续"
|
|
|
# do_next = True
|
|
|
- text += "\n==================\n错误数据:{}个,校验无误数据:{}个".format(len(error_folder), len(todo_folder))
|
|
|
+ text += "\n==================\n错误数据:{}个,校验无误数据:{}个".format(
|
|
|
+ len(error_folder), len(todo_folder)
|
|
|
+ )
|
|
|
self.show_progress_detail(text)
|
|
|
if button_1 is None and button_2 is None and button_3 is None:
|
|
|
pass
|
|
|
@@ -223,16 +255,22 @@ class RunMain():
|
|
|
# print(my_dialog.flag_name)
|
|
|
|
|
|
if "移除" in self.dialog_result:
|
|
|
- for error_folder_data in [x for x in all_goods_art_no_folder_data if x["label"] == "错误"]:
|
|
|
+ for error_folder_data in [
|
|
|
+ x for x in all_goods_art_no_folder_data if x["label"] == "错误"
|
|
|
+ ]:
|
|
|
self.move_error_folders(
|
|
|
one_path=error_folder_data["folder_path"],
|
|
|
- target_folder="{}/软件-处理失败".format(config_data["image_dir"]),
|
|
|
+ target_folder="{}/软件-处理失败".format(
|
|
|
+ config_data["image_dir"]
|
|
|
+ ),
|
|
|
)
|
|
|
if "继续" in self.dialog_result:
|
|
|
do_next = True
|
|
|
|
|
|
if do_next:
|
|
|
- all_goods_art_no_folder_data = [x for x in all_goods_art_no_folder_data if x["label"] == "待处理"]
|
|
|
+ all_goods_art_no_folder_data = [
|
|
|
+ x for x in all_goods_art_no_folder_data if x["label"] == "待处理"
|
|
|
+ ]
|
|
|
print("===============all_goods_art_no_folder_data===============")
|
|
|
print(all_goods_art_no_folder_data)
|
|
|
|
|
|
@@ -251,26 +289,32 @@ class RunMain():
|
|
|
print("已结束抠图处理")
|
|
|
return True
|
|
|
|
|
|
- async def do_run_cutout_image(self,
|
|
|
- all_goods_art_no_folder_data,
|
|
|
- callback_func,
|
|
|
- image_order_list,
|
|
|
- cutout_mode,
|
|
|
- resize_image_view,
|
|
|
- windows,
|
|
|
- logo_path,
|
|
|
- config_data):
|
|
|
+ async def do_run_cutout_image(
|
|
|
+ self,
|
|
|
+ all_goods_art_no_folder_data,
|
|
|
+ callback_func,
|
|
|
+ image_order_list,
|
|
|
+ cutout_mode,
|
|
|
+ resize_image_view,
|
|
|
+ windows,
|
|
|
+ logo_path,
|
|
|
+ config_data,
|
|
|
+ ):
|
|
|
print("BaseDealImage().run_main========>>>>")
|
|
|
deal = BaseDealImage(token=self.token)
|
|
|
- await deal.run_main(all_goods_art_no_folder_data=all_goods_art_no_folder_data,
|
|
|
- callback_func=callback_func,
|
|
|
- image_order_list=image_order_list,
|
|
|
- cutout_mode=cutout_mode,
|
|
|
- resize_image_view=resize_image_view,
|
|
|
- windows=windows,
|
|
|
- logo_path=logo_path,
|
|
|
- )
|
|
|
- goods_arts = [goods_art_no_folder_data["folder_name"] for goods_art_no_folder_data in all_goods_art_no_folder_data]
|
|
|
+ await deal.run_main(
|
|
|
+ all_goods_art_no_folder_data=all_goods_art_no_folder_data,
|
|
|
+ callback_func=callback_func,
|
|
|
+ image_order_list=image_order_list,
|
|
|
+ cutout_mode=cutout_mode,
|
|
|
+ resize_image_view=resize_image_view,
|
|
|
+ windows=windows,
|
|
|
+ logo_path=logo_path,
|
|
|
+ )
|
|
|
+ goods_arts = [
|
|
|
+ goods_art_no_folder_data["folder_name"]
|
|
|
+ for goods_art_no_folder_data in all_goods_art_no_folder_data
|
|
|
+ ]
|
|
|
recordDataPoint(
|
|
|
token=self.token,
|
|
|
uuid=self.uuid,
|
|
|
@@ -280,28 +324,33 @@ class RunMain():
|
|
|
callback_func("已结束抠图处理")
|
|
|
return True
|
|
|
|
|
|
- def do_run_cutout_image1111(self, all_goods_art_no_folder_data,
|
|
|
- callback_func,
|
|
|
- image_order_list,
|
|
|
- cutout_mode,
|
|
|
- resize_image_view,
|
|
|
- windows,
|
|
|
- logo_path,
|
|
|
- config_data):
|
|
|
+ def do_run_cutout_image1111(
|
|
|
+ self,
|
|
|
+ all_goods_art_no_folder_data,
|
|
|
+ callback_func,
|
|
|
+ image_order_list,
|
|
|
+ cutout_mode,
|
|
|
+ resize_image_view,
|
|
|
+ windows,
|
|
|
+ logo_path,
|
|
|
+ config_data,
|
|
|
+ ):
|
|
|
|
|
|
max_workers = 1
|
|
|
with concurrent.futures.ThreadPoolExecutor(max_workers=max_workers) as executor:
|
|
|
futures = []
|
|
|
- futures.append(executor.submit(
|
|
|
- BaseDealImage().run_main,
|
|
|
- all_goods_art_no_folder_data=all_goods_art_no_folder_data,
|
|
|
- callback_func=callback_func,
|
|
|
- image_order_list=image_order_list,
|
|
|
- cutout_mode=cutout_mode,
|
|
|
- resize_image_view=resize_image_view,
|
|
|
- windows=windows,
|
|
|
- logo_path=logo_path,
|
|
|
- ))
|
|
|
+ futures.append(
|
|
|
+ executor.submit(
|
|
|
+ BaseDealImage().run_main,
|
|
|
+ all_goods_art_no_folder_data=all_goods_art_no_folder_data,
|
|
|
+ callback_func=callback_func,
|
|
|
+ image_order_list=image_order_list,
|
|
|
+ cutout_mode=cutout_mode,
|
|
|
+ resize_image_view=resize_image_view,
|
|
|
+ windows=windows,
|
|
|
+ logo_path=logo_path,
|
|
|
+ )
|
|
|
+ )
|
|
|
|
|
|
# 使用 wait 方法等待所有任务完成
|
|
|
done, not_done = concurrent.futures.wait(futures, timeout=60)
|
|
|
@@ -461,7 +510,7 @@ class RunMain():
|
|
|
{
|
|
|
"goods_art_no": one_folder,
|
|
|
"success": False,
|
|
|
- "info":f"文件夹:{one_folder} 找不到对应数据",
|
|
|
+ "info": f"文件夹:{one_folder} 找不到对应数据",
|
|
|
}
|
|
|
)
|
|
|
|
|
|
@@ -470,7 +519,7 @@ class RunMain():
|
|
|
_text = json.dumps(goods_no_dict)
|
|
|
print(goods_no_dict)
|
|
|
create_folder("qt_test")
|
|
|
- with open("qt_test/goods_no_dict.txt", 'w', encoding='utf-8') as file:
|
|
|
+ with open("qt_test/goods_no_dict.txt", "w", encoding="utf-8") as file:
|
|
|
file.write(_text)
|
|
|
print("===============goods_no_dict==================")
|
|
|
|
|
|
@@ -510,9 +559,7 @@ class RunMain():
|
|
|
error_folder_list.append(
|
|
|
{
|
|
|
"folder_name": _folder_name,
|
|
|
- "folder_path": "{}\{}".format(
|
|
|
- image_dir, _folder_name
|
|
|
- ),
|
|
|
+ "folder_path": "{}\{}".format(image_dir, _folder_name),
|
|
|
}
|
|
|
)
|
|
|
return_data["message"] += "文件夹:{};{}\n".format(
|
|
|
@@ -544,12 +591,19 @@ class RunMain():
|
|
|
# }}
|
|
|
|
|
|
if is_use_excel:
|
|
|
- excel_temp_goods_no_data = self.data_mode_generate_detail.get_basic_template_information(
|
|
|
- _goods_no_dict=goods_no_dict, excel_path=excel_path)
|
|
|
+ excel_temp_goods_no_data = (
|
|
|
+ self.data_mode_generate_detail.get_basic_template_information(
|
|
|
+ _goods_no_dict=goods_no_dict, excel_path=excel_path
|
|
|
+ )
|
|
|
+ )
|
|
|
else:
|
|
|
excel_temp_goods_no_data = {}
|
|
|
|
|
|
- print("731===================excel_temp_goods_no_data,is_use_excel:{}".format(is_use_excel))
|
|
|
+ print(
|
|
|
+ "731===================excel_temp_goods_no_data,is_use_excel:{}".format(
|
|
|
+ is_use_excel
|
|
|
+ )
|
|
|
+ )
|
|
|
print(json.dumps(excel_temp_goods_no_data))
|
|
|
|
|
|
# ===========数据组装,统计每个款需要生成哪些模板==============
|
|
|
@@ -641,7 +695,7 @@ class RunMain():
|
|
|
check_path(target_folder)
|
|
|
move_folders(path_list=[one_path], target_folder=target_folder)
|
|
|
|
|
|
- def check_for_detail_first_call_back(self, data):
|
|
|
+ async def check_for_detail_first_call_back(self, data):
|
|
|
# 首次数据校验的信息返回
|
|
|
# self.show_message(text="22222222222222222222222")
|
|
|
# QMessageBox.critical(self, "警告", "1111111", QMessageBox.Ok)
|
|
|
@@ -652,7 +706,6 @@ class RunMain():
|
|
|
print(data)
|
|
|
if code != 0:
|
|
|
raise UnicornException(config_data["success_handler"])
|
|
|
-
|
|
|
do_next = False
|
|
|
if data["message"]:
|
|
|
button_1, button_2, button_3 = None, None, None
|
|
|
@@ -681,12 +734,13 @@ class RunMain():
|
|
|
else:
|
|
|
print("runmain 642----------------")
|
|
|
# todo 弹框修改处理等
|
|
|
- _dialog_dict = {"text": text,
|
|
|
- "button_1": button_1,
|
|
|
- "button_2": button_2,
|
|
|
- "button_3": button_3,
|
|
|
- "windows": self,
|
|
|
- }
|
|
|
+ _dialog_dict = {
|
|
|
+ "text": text,
|
|
|
+ "button_1": button_1,
|
|
|
+ "button_2": button_2,
|
|
|
+ "button_3": button_3,
|
|
|
+ "windows": self,
|
|
|
+ }
|
|
|
# self.show_dialog_sign.emit(_dialog_dict)
|
|
|
# # 等待事件被设置
|
|
|
# self.event.wait()
|
|
|
@@ -721,17 +775,20 @@ class RunMain():
|
|
|
"assigned_page_dict": data["data"]["assigned_page_dict"],
|
|
|
"excel_temp_goods_no_data": data["data"]["excel_temp_goods_no_data"],
|
|
|
# 表格数据可能存在多模板,数据结构为一个款号下的多个模板的数据列表
|
|
|
- "finally_goods_no_need_temps": data["data"]["finally_goods_no_need_temps"], # 每个款号需要生成的模板数据
|
|
|
+ "finally_goods_no_need_temps": data["data"][
|
|
|
+ "finally_goods_no_need_temps"
|
|
|
+ ], # 每个款号需要生成的模板数据
|
|
|
}
|
|
|
# todo work
|
|
|
- new_func = partial(self.detail_run_by_thread,
|
|
|
- config_data=kwargs["config_data"],
|
|
|
- _goods_no_dict=kwargs["_goods_no_dict"],
|
|
|
- temp_name=kwargs["temp_name"],
|
|
|
- temp_name_list=kwargs["temp_name_list"],
|
|
|
- assigned_page_dict=kwargs["assigned_page_dict"],
|
|
|
- excel_temp_goods_no_data=kwargs["excel_temp_goods_no_data"],
|
|
|
- finally_goods_no_need_temps=kwargs["finally_goods_no_need_temps"])
|
|
|
+ new_func = await self.detail_run_by_thread(
|
|
|
+ config_data=kwargs["config_data"],
|
|
|
+ _goods_no_dict=kwargs["_goods_no_dict"],
|
|
|
+ temp_name=kwargs["temp_name"],
|
|
|
+ temp_name_list=kwargs["temp_name_list"],
|
|
|
+ assigned_page_dict=kwargs["assigned_page_dict"],
|
|
|
+ excel_temp_goods_no_data=kwargs["excel_temp_goods_no_data"],
|
|
|
+ finally_goods_no_need_temps=kwargs["finally_goods_no_need_temps"],
|
|
|
+ )
|
|
|
# self._w_3 = WorkerOneThread(func=new_func, name="_w_3")
|
|
|
# self._w_3.start()
|
|
|
return new_func
|
|
|
@@ -741,9 +798,16 @@ class RunMain():
|
|
|
# self.run_end_sign.emit(config_data)
|
|
|
return config_data
|
|
|
|
|
|
- def detail_run_by_thread(self, config_data, _goods_no_dict, temp_name, temp_name_list, assigned_page_dict,
|
|
|
- excel_temp_goods_no_data,
|
|
|
- finally_goods_no_need_temps):
|
|
|
+ async def detail_run_by_thread(
|
|
|
+ self,
|
|
|
+ config_data,
|
|
|
+ _goods_no_dict,
|
|
|
+ temp_name,
|
|
|
+ temp_name_list,
|
|
|
+ assigned_page_dict,
|
|
|
+ excel_temp_goods_no_data,
|
|
|
+ finally_goods_no_need_temps,
|
|
|
+ ):
|
|
|
"""
|
|
|
excel_temp_goods_no_data: {}, # 表格数据可能存在多模板,数据结构为一个款号下的多个模板的数据列表
|
|
|
finally_goods_no_need_temps: {}, # 每个款号需要生成的模板数据
|
|
|
@@ -782,42 +846,52 @@ class RunMain():
|
|
|
if goods_no in excel_temp_goods_no_data:
|
|
|
if _temp_name in excel_temp_goods_no_data[goods_no]:
|
|
|
# 将表格中的特定的模板的行,替换到goods_no的data中,因为不同的模板有数据特殊性
|
|
|
- for _key, _key_value in excel_temp_goods_no_data[goods_no][_temp_name].items():
|
|
|
+ for _key, _key_value in excel_temp_goods_no_data[
|
|
|
+ goods_no
|
|
|
+ ][_temp_name].items():
|
|
|
if _key in temp_info_data:
|
|
|
temp_info_data[_key] = _key_value
|
|
|
print("goods_no:{},_temp_name:{}".format(goods_no, _temp_name))
|
|
|
out_put_dir_resp = "{}/详情模板{}/{}".format(
|
|
|
- out_put_dir, _temp_name, goods_no
|
|
|
- )
|
|
|
- all_detail_path_list.append("{}/详情模板{}/{}".format(out_put_dir, _temp_name, goods_no))
|
|
|
+ out_put_dir, _temp_name, goods_no
|
|
|
+ )
|
|
|
+ # await sendSocketMessage(
|
|
|
+ # code=0,
|
|
|
+ # msg="开始处理详情",
|
|
|
+ # data={"goods_no": goods_no, "temp_name": _temp_name},
|
|
|
+ # msg_type="detail_progress"
|
|
|
+ # )
|
|
|
+ all_detail_path_list.append(
|
|
|
+ "{}/详情模板{}/{}".format(out_put_dir, _temp_name, goods_no)
|
|
|
+ )
|
|
|
# continue
|
|
|
- self.detail_deal_one_data(
|
|
|
- goods_no=goods_no,
|
|
|
- value=temp_info_data,
|
|
|
- out_put_dir=out_put_dir,
|
|
|
- temp_name=_temp_name,
|
|
|
- assigned_page_list=assigned_page_list,
|
|
|
- temp_class=config_data["temp_class"],
|
|
|
- target_error_folder=config_data["target_error_folder"],
|
|
|
- image_dir=config_data["image_dir"],
|
|
|
- )
|
|
|
+ await self.detail_deal_one_data(
|
|
|
+ goods_no=goods_no,
|
|
|
+ value=temp_info_data,
|
|
|
+ out_put_dir=out_put_dir,
|
|
|
+ temp_name=_temp_name,
|
|
|
+ assigned_page_list=assigned_page_list,
|
|
|
+ temp_class=config_data["temp_class"],
|
|
|
+ target_error_folder=config_data["target_error_folder"],
|
|
|
+ image_dir=config_data["image_dir"],
|
|
|
+ )
|
|
|
config_data["success_handler"].append(
|
|
|
- {"goods_art_no": goods_no, "success": True, "info": "处理成功"}
|
|
|
- )
|
|
|
+ {"goods_art_no": goods_no, "success": True, "info": "处理成功"}
|
|
|
+ )
|
|
|
recordDataPoint(
|
|
|
token=self.token,
|
|
|
uuid=self.uuid,
|
|
|
page="详情图生成成功",
|
|
|
- data={"goods_art_no": goods_no,"temp_name": _temp_name},
|
|
|
+ data={"goods_art_no": goods_no, "temp_name": _temp_name},
|
|
|
)
|
|
|
except BaseException as e:
|
|
|
self.show_progress_detail(
|
|
|
- {
|
|
|
- "goods_art_no": goods_no,
|
|
|
- "success": False,
|
|
|
- "info": "款:{}生成详情异常:{}".format(goods_no, e),
|
|
|
- }
|
|
|
- )
|
|
|
+ {
|
|
|
+ "goods_art_no": goods_no,
|
|
|
+ "success": False,
|
|
|
+ "info": "款:{}生成详情异常:{}".format(goods_no, e),
|
|
|
+ }
|
|
|
+ )
|
|
|
print(e)
|
|
|
# raise UnicornException("款:{}生成详情异常:{}".format(goods_no, e))
|
|
|
config_data["success_handler"].append(
|
|
|
@@ -831,14 +905,20 @@ class RunMain():
|
|
|
token=self.token,
|
|
|
uuid=self.uuid,
|
|
|
page="详情图生成失败",
|
|
|
- data={"goods_art_no": goods_no, "temp_name": _temp_name,"message": str(e)},
|
|
|
+ data={
|
|
|
+ "goods_art_no": goods_no,
|
|
|
+ "temp_name": _temp_name,
|
|
|
+ "message": str(e),
|
|
|
+ },
|
|
|
)
|
|
|
|
|
|
# ==============完成处理==============
|
|
|
self.set_state(state_value=2)
|
|
|
if self.total_num:
|
|
|
if self.fail_num:
|
|
|
- self.show_progress_detail("处理完成,-----处理失败数据:{}个款".format(self.fail_num))
|
|
|
+ self.show_progress_detail(
|
|
|
+ "处理完成,-----处理失败数据:{}个款".format(self.fail_num)
|
|
|
+ )
|
|
|
else:
|
|
|
self.show_progress_detail("处理完成")
|
|
|
else:
|
|
|
@@ -853,9 +933,16 @@ class RunMain():
|
|
|
|
|
|
return config_data
|
|
|
|
|
|
- def detail_run_by_thread11111(self, config_data, _goods_no_dict, temp_name, temp_name_list, assigned_page_dict,
|
|
|
- excel_temp_goods_no_data,
|
|
|
- finally_goods_no_need_temps):
|
|
|
+ def detail_run_by_thread11111(
|
|
|
+ self,
|
|
|
+ config_data,
|
|
|
+ _goods_no_dict,
|
|
|
+ temp_name,
|
|
|
+ temp_name_list,
|
|
|
+ assigned_page_dict,
|
|
|
+ excel_temp_goods_no_data,
|
|
|
+ finally_goods_no_need_temps,
|
|
|
+ ):
|
|
|
"""
|
|
|
excel_temp_goods_no_data: {}, # 表格数据可能存在多模板,数据结构为一个款号下的多个模板的数据列表
|
|
|
finally_goods_no_need_temps: {}, # 每个款号需要生成的模板数据
|
|
|
@@ -902,22 +989,28 @@ class RunMain():
|
|
|
if _temp_name in excel_temp_goods_no_data[goods_no]:
|
|
|
# 将表格中的特定的模板的行,替换到goods_no的data中,因为不同的模板有数据特殊性
|
|
|
print("xxxxxx====>", excel_temp_goods_no_data[goods_no])
|
|
|
- for _key, _key_value in excel_temp_goods_no_data[goods_no][_temp_name].items():
|
|
|
+ for _key, _key_value in excel_temp_goods_no_data[
|
|
|
+ goods_no
|
|
|
+ ][_temp_name].items():
|
|
|
if _key in temp_info_data:
|
|
|
temp_info_data[_key] = _key_value
|
|
|
|
|
|
print("temp_info_data11111111111111111111111")
|
|
|
print("goods_no:{},_temp_name:{}".format(goods_no, _temp_name))
|
|
|
- all_detail_path_list.append("{}/{}/".format(out_put_dir, _temp_name, goods_no))
|
|
|
+ all_detail_path_list.append(
|
|
|
+ "{}/{}/".format(out_put_dir, _temp_name, goods_no)
|
|
|
+ )
|
|
|
# continue
|
|
|
- futures.append(executor.submit(
|
|
|
- self.detail_deal_one_data,
|
|
|
- goods_no=goods_no,
|
|
|
- value=temp_info_data,
|
|
|
- out_put_dir=out_put_dir,
|
|
|
- temp_name=_temp_name,
|
|
|
- assigned_page_list=assigned_page_list,
|
|
|
- ))
|
|
|
+ futures.append(
|
|
|
+ executor.submit(
|
|
|
+ self.detail_deal_one_data,
|
|
|
+ goods_no=goods_no,
|
|
|
+ value=temp_info_data,
|
|
|
+ out_put_dir=out_put_dir,
|
|
|
+ temp_name=_temp_name,
|
|
|
+ assigned_page_list=assigned_page_list,
|
|
|
+ )
|
|
|
+ )
|
|
|
|
|
|
# for goods_no, value in _goods_no_dict.items():
|
|
|
# _temp_name = temp_name
|
|
|
@@ -969,7 +1062,7 @@ class RunMain():
|
|
|
print("text=====>", text)
|
|
|
return text
|
|
|
|
|
|
- def detail_deal_one_data(
|
|
|
+ async def detail_deal_one_data(
|
|
|
self,
|
|
|
goods_no,
|
|
|
value,
|
|
|
@@ -983,7 +1076,7 @@ class RunMain():
|
|
|
# if self.windows.state == 99:
|
|
|
# self.show_progress_detail("用户主动取消:{}".format(goods_no))
|
|
|
# return
|
|
|
-
|
|
|
+ await asyncio.sleep(0.01)
|
|
|
self.show_progress_detail("正在生成:{},模板:{}".format(goods_no, temp_name))
|
|
|
is_deal_success = False
|
|
|
print("=================deal_one_data=====================")
|
|
|
@@ -992,29 +1085,39 @@ class RunMain():
|
|
|
print("value:", value)
|
|
|
print("temp_class:", temp_class)
|
|
|
if settings.IS_TEST:
|
|
|
- temp_class[temp_name](goods_no, value,
|
|
|
- out_put_dir=out_put_dir,
|
|
|
- windows=self.windows,
|
|
|
- assigned_page_list=assigned_page_list)
|
|
|
+ temp_class[temp_name](
|
|
|
+ goods_no,
|
|
|
+ value,
|
|
|
+ out_put_dir=out_put_dir,
|
|
|
+ windows=self.windows,
|
|
|
+ assigned_page_list=assigned_page_list,
|
|
|
+ )
|
|
|
is_deal_success = True
|
|
|
else:
|
|
|
try:
|
|
|
# # 处理图片详情图生成
|
|
|
- temp_class[temp_name](goods_no, value,
|
|
|
- out_put_dir=out_put_dir,
|
|
|
- windows=self.windows,
|
|
|
- assigned_page_list=assigned_page_list)
|
|
|
+ temp_class[temp_name](
|
|
|
+ goods_no,
|
|
|
+ value,
|
|
|
+ out_put_dir=out_put_dir,
|
|
|
+ windows=self.windows,
|
|
|
+ assigned_page_list=assigned_page_list,
|
|
|
+ )
|
|
|
is_deal_success = True
|
|
|
except BaseException as e:
|
|
|
self.show_progress_detail("{}处理失败".format(goods_no))
|
|
|
error_text = "{}".format(e)
|
|
|
if "Unable to allocate" in error_text:
|
|
|
error_text = "电脑内存不足,生成失败"
|
|
|
- print(f"发生错误的文件: {e.__traceback__.tb_frame.f_globals['__file__']}")
|
|
|
+ print(
|
|
|
+ f"发生错误的文件: {e.__traceback__.tb_frame.f_globals['__file__']}"
|
|
|
+ )
|
|
|
print(f"发生错误的行号: {e.__traceback__.tb_lineno}")
|
|
|
# self.show_progress_detail("失败原因:{}".format(error_text))
|
|
|
self.fail_num += 1
|
|
|
- raise UnicornException("{}处理失败,失败原因:{}".format(goods_no,error_text))
|
|
|
+ raise UnicornException(
|
|
|
+ "{}处理失败,失败原因:{}".format(goods_no, error_text)
|
|
|
+ )
|
|
|
|
|
|
self.n += 1
|
|
|
|
|
|
@@ -1034,7 +1137,7 @@ class RunMain():
|
|
|
)
|
|
|
pass
|
|
|
# 更新进度
|
|
|
- print("更新进度============>",self.n, self.total_num)
|
|
|
+ print("更新进度============>", self.n, self.total_num)
|
|
|
# self.windows.progress_sign.emit(
|
|
|
# {
|
|
|
# "type": "详情图生成",
|
|
|
@@ -1044,7 +1147,7 @@ class RunMain():
|
|
|
|
|
|
def check_serializable(self, obj): # 检查某个对象其中的属性哪些不能被序列化
|
|
|
for attr_name in dir(obj):
|
|
|
- if not attr_name.startswith('__'):
|
|
|
+ if not attr_name.startswith("__"):
|
|
|
try:
|
|
|
attr_value = getattr(obj, attr_name)
|
|
|
serialized = pickle.dumps(attr_value)
|