|
|
@@ -16,7 +16,7 @@ from functools import partial
|
|
|
# from multiprocessing import Process, Queue
|
|
|
import pickle
|
|
|
from .base_deal import BaseDealImage
|
|
|
-
|
|
|
+from middleware import UnicornException
|
|
|
|
|
|
class RunMain():
|
|
|
# run_end_sign = Signal(dict)
|
|
|
@@ -71,7 +71,6 @@ class RunMain():
|
|
|
# # 规整红蜻蜓货号图
|
|
|
# all_goods_art_no_folder_data = get_all_goods_art_no_folder(path=image_dir)
|
|
|
# BaseDealImage().rename_folder_for_hqt(all_goods_art_no_folder_data=all_goods_art_no_folder_data)
|
|
|
-
|
|
|
# 重新获取文件夹信息
|
|
|
all_goods_art_no_folder_data = get_all_goods_art_no_folder(path=image_dir)
|
|
|
|
|
|
@@ -100,6 +99,7 @@ class RunMain():
|
|
|
f = False
|
|
|
|
|
|
if not f:
|
|
|
+ # raise UnicornException(return_data["message"])
|
|
|
self.set_state(state_value=2)
|
|
|
return
|
|
|
|
|
|
@@ -118,6 +118,7 @@ class RunMain():
|
|
|
)
|
|
|
if res['code'] != 0:
|
|
|
return_data["message"] += "{}\n".format(res['msg'])
|
|
|
+ # raise UnicornException(return_data["message"])
|
|
|
return return_data
|
|
|
else:
|
|
|
# 图片命名顺序
|
|
|
@@ -165,15 +166,13 @@ class RunMain():
|
|
|
code = return_data["code"]
|
|
|
config_data = return_data["data"]["config_data"]
|
|
|
config_data["sign_text"] = ""
|
|
|
- # if code != 0:
|
|
|
- # # self.windows.show_message(return_data["message"])
|
|
|
- # # self.show_progress_detail(return_data["message"])
|
|
|
- # _dialog_dict = {"text": return_data["message"],
|
|
|
- # "windows": self,
|
|
|
- # }
|
|
|
- # self.show_dialog_sign.emit(_dialog_dict)
|
|
|
- # self.event.wait()
|
|
|
- # return
|
|
|
+ if code != 0:
|
|
|
+ # self.windows.show_message(return_data["message"])
|
|
|
+ # self.show_progress_detail(return_data["message"])
|
|
|
+ # _dialog_dict = {"text": return_data["message"],
|
|
|
+ # "windows": self,
|
|
|
+ # }
|
|
|
+ raise UnicornException(return_data["message"])
|
|
|
|
|
|
do_next = False
|
|
|
text = ""
|
|
|
@@ -364,12 +363,15 @@ class RunMain():
|
|
|
is_use_excel = config_data["is_use_excel"]
|
|
|
excel_path = config_data["excel_path"]
|
|
|
temp_class = config_data["temp_class"]
|
|
|
+ goods_art_no = config_data["goods_art_no"]
|
|
|
is_check_color_is_all = config_data["is_check_color_is_all"]
|
|
|
detail_is_pass = config_data["detail_is_pass"]
|
|
|
|
|
|
error_folder_list = []
|
|
|
# 遍历货号获取所有货号--可能为编号
|
|
|
- folder_name_list = get_all_dir_info(image_dir=image_dir)
|
|
|
+ folder_name_list = get_all_dir_info(
|
|
|
+ image_dir=image_dir, goods_art_no=goods_art_no
|
|
|
+ )
|
|
|
if not folder_name_list:
|
|
|
return_data["message"] += "不存在任何货号/编号文件夹\n"
|
|
|
print("不存在任何货号/编号文件夹")
|
|
|
@@ -417,7 +419,6 @@ class RunMain():
|
|
|
"""
|
|
|
# 获取所有文件夹基础数据内容 检查不满足要求的文件不满足要求移动到错误文件夹
|
|
|
need_view_list = temp_class[temp_name].need_view
|
|
|
- print("*********need_view_list************", need_view_list)
|
|
|
_all_dir_info_data = get_all_dir_info_and_pic_info(
|
|
|
image_dir, folder_name_list, need_view_list
|
|
|
)
|
|
|
@@ -586,6 +587,8 @@ class RunMain():
|
|
|
_goods_no_dict[goods_no] = value # 需要生成的数据
|
|
|
finally_goods_no_need_temps[goods_no].append(__temp_name)
|
|
|
else:
|
|
|
+ # output/2025-04-03/软件-详情图生成/huilima-2/AQN141132
|
|
|
+ return_data["data"]["config_data"]["out_put_dir"] = _path
|
|
|
if detail_is_pass:
|
|
|
return_data["message"] += "\n款号:{},模板:{} 已存在".format(goods_no, __temp_name)
|
|
|
else:
|
|
|
@@ -644,21 +647,7 @@ class RunMain():
|
|
|
print("635 check_for_detail_first_call_back")
|
|
|
print(data)
|
|
|
if code != 0:
|
|
|
- # self.windows.show_message(data["message"])
|
|
|
- # my_dialog = DialogShow(self.windows.windows, text=data["message"])
|
|
|
- # ret = my_dialog.exec()
|
|
|
- self.show_progress_detail(text=data["message"])
|
|
|
- _dialog_dict = {"text": data["message"],
|
|
|
- "windows": self,
|
|
|
- }
|
|
|
- # self.show_dialog_sign.emit(_dialog_dict)
|
|
|
- # self.event.wait()
|
|
|
- print("_dialog_dict", _dialog_dict)
|
|
|
-
|
|
|
- # self.windows.set_state(2)
|
|
|
- config_data["sign_text"] = "已结束详情处理"
|
|
|
- # self.run_end_sign.emit(config_data)
|
|
|
- print("config_data==>", config_data)
|
|
|
+ raise UnicornException(data["message"])
|
|
|
return False
|
|
|
|
|
|
do_next = False
|
|
|
@@ -747,8 +736,7 @@ class RunMain():
|
|
|
else:
|
|
|
config_data["sign_text"] = "已结束详情处理"
|
|
|
# self.run_end_sign.emit(config_data)
|
|
|
- print("config_data===>2", config_data)
|
|
|
- return True
|
|
|
+ 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,
|
|
|
@@ -776,39 +764,41 @@ class RunMain():
|
|
|
|
|
|
all_detail_path_list = []
|
|
|
for goods_no, temp_name_list in finally_goods_no_need_temps.items():
|
|
|
- # try:
|
|
|
- for _temp_name in temp_name_list:
|
|
|
- # if _temp_name != "xiaosushuoxie-4":
|
|
|
- # continue
|
|
|
- assigned_page_list = []
|
|
|
- if _temp_name in assigned_page_dict:
|
|
|
- assigned_page_list = assigned_page_dict[_temp_name]
|
|
|
- # 如果为使用表格,则获取表格中的数据作为款号的基础数据
|
|
|
- temp_info_data = copy.copy(_goods_no_dict[goods_no])
|
|
|
- if is_use_excel:
|
|
|
- # 将表格中的数据进行替换
|
|
|
- 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():
|
|
|
- if _key in temp_info_data:
|
|
|
- temp_info_data[_key] = _key_value
|
|
|
- print("temp_info_data2222222222222222222222")
|
|
|
- print("goods_no:{},_temp_name:{}".format(goods_no, _temp_name))
|
|
|
- all_detail_path_list.append("{}/{}/".format(out_put_dir, _temp_name, goods_no))
|
|
|
- # continue
|
|
|
- self.detail_deal_one_data(
|
|
|
+ try:
|
|
|
+ for _temp_name in temp_name_list:
|
|
|
+ # if _temp_name != "xiaosushuoxie-4":
|
|
|
+ # continue
|
|
|
+ assigned_page_list = []
|
|
|
+ if _temp_name in assigned_page_dict:
|
|
|
+ assigned_page_list = assigned_page_dict[_temp_name]
|
|
|
+ # 如果为使用表格,则获取表格中的数据作为款号的基础数据
|
|
|
+ temp_info_data = copy.copy(_goods_no_dict[goods_no])
|
|
|
+ if is_use_excel:
|
|
|
+ # 将表格中的数据进行替换
|
|
|
+ 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():
|
|
|
+ if _key in temp_info_data:
|
|
|
+ temp_info_data[_key] = _key_value
|
|
|
+ print("goods_no:{},_temp_name:{}".format(goods_no, _temp_name))
|
|
|
+ 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"],
|
|
|
)
|
|
|
- # except BaseException as e:
|
|
|
- # self.show_progress_detail(
|
|
|
- # "款:{}生成详情异常:{}".format(goods_no, e))
|
|
|
- # print(e)
|
|
|
+ except BaseException as e:
|
|
|
+ self.show_progress_detail(
|
|
|
+ "款:{}生成详情异常:{}".format(goods_no, e))
|
|
|
+ print(e)
|
|
|
+ raise UnicornException("款:{}生成详情异常:{}".format(goods_no, e))
|
|
|
|
|
|
# ==============完成处理==============
|
|
|
self.set_state(state_value=2)
|
|
|
@@ -822,8 +812,9 @@ class RunMain():
|
|
|
|
|
|
config_data["sign_text"] = "已结束详情处理"
|
|
|
config_data["all_detail_path_list"] = all_detail_path_list
|
|
|
+ config_data["out_put_dir"] = out_put_dir
|
|
|
# 打开文件夹
|
|
|
- os.startfile(out_put_dir)
|
|
|
+ # os.startfile(out_put_dir)
|
|
|
|
|
|
return config_data
|
|
|
|
|
|
@@ -943,7 +934,15 @@ class RunMain():
|
|
|
return text
|
|
|
|
|
|
def detail_deal_one_data(
|
|
|
- self, goods_no, value, out_put_dir, temp_name, assigned_page_list, temp_class
|
|
|
+ self,
|
|
|
+ goods_no,
|
|
|
+ value,
|
|
|
+ out_put_dir,
|
|
|
+ temp_name,
|
|
|
+ assigned_page_list,
|
|
|
+ temp_class,
|
|
|
+ target_error_folder,
|
|
|
+ image_dir,
|
|
|
):
|
|
|
# if self.windows.state == 99:
|
|
|
# self.show_progress_detail("用户主动取消:{}".format(goods_no))
|
|
|
@@ -990,10 +989,10 @@ class RunMain():
|
|
|
# 将相关的文件夹统一移动至错误文件夹
|
|
|
move_folders(
|
|
|
path_list=[
|
|
|
- "{}/{}".format(self.windows.image_dir, x)
|
|
|
+ "{}/{}".format(image_dir, x)
|
|
|
for x in [x["文件夹名称"] for x in goods_art_no_list]
|
|
|
],
|
|
|
- target_folder=self.windows.target_error_folder,
|
|
|
+ target_folder=target_error_folder,
|
|
|
)
|
|
|
pass
|
|
|
# 更新进度
|