|
@@ -108,17 +108,28 @@ def fromExcelHandler(params: HandlerDetail):
|
|
|
obj = None
|
|
obj = None
|
|
|
run_main = RunMain(obj, token)
|
|
run_main = RunMain(obj, token)
|
|
|
temp_class = {}
|
|
temp_class = {}
|
|
|
|
|
+ # 可用模板列表-需要导包
|
|
|
temp_name_list = []
|
|
temp_name_list = []
|
|
|
for tempItem in params.temp_list:
|
|
for tempItem in params.temp_list:
|
|
|
temp_class[tempItem.template_id] = tempItem.template_local_classes
|
|
temp_class[tempItem.template_id] = tempItem.template_local_classes
|
|
|
temp_name_list.append(tempItem.template_id)
|
|
temp_name_list.append(tempItem.template_id)
|
|
|
|
|
+ # 抠图时用到的货号列表,与生成详情图有所区别
|
|
|
goods_art_no_arrays = []
|
|
goods_art_no_arrays = []
|
|
|
|
|
+ # # 详情图生成需要对同款商品进行分组,保证详情图可以生成多个色
|
|
|
|
|
+ goods_art_no_group_arrays = []
|
|
|
for _, goods_row in excel_df.iterrows():
|
|
for _, goods_row in excel_df.iterrows():
|
|
|
goods_art_no = str(goods_row["商品货号"])
|
|
goods_art_no = str(goods_row["商品货号"])
|
|
|
goods_art_no_arrays.append(goods_art_no)
|
|
goods_art_no_arrays.append(goods_art_no)
|
|
|
|
|
+ goods_no = str(goods_row["款号"])
|
|
|
|
|
+ a001_df = goods_art_dirs.get_group(goods_no)
|
|
|
|
|
+ goods_art_groups = a001_df["商品货号"].tolist()
|
|
|
|
|
+ if goods_art_groups in goods_art_no_group_arrays:
|
|
|
|
|
+ continue
|
|
|
|
|
+ goods_art_no_group_arrays.append(goods_art_groups)
|
|
|
limit_path = "output/{}".format(
|
|
limit_path = "output/{}".format(
|
|
|
time.strftime("%Y-%m-%d", time.localtime(time.time()))
|
|
time.strftime("%Y-%m-%d", time.localtime(time.time()))
|
|
|
)
|
|
)
|
|
|
|
|
+ # 该数组表示是否需要后面的移动文件夹操作,减少重复抠图,提升抠图时间和速度
|
|
|
move_folder_array = check_move_goods_art_no_folder(
|
|
move_folder_array = check_move_goods_art_no_folder(
|
|
|
"output", goods_art_no_arrays, limit_path
|
|
"output", goods_art_no_arrays, limit_path
|
|
|
)
|
|
)
|
|
@@ -126,10 +137,6 @@ def fromExcelHandler(params: HandlerDetail):
|
|
|
goods_art_no_image_dir = str(row["文件夹名称"])
|
|
goods_art_no_image_dir = str(row["文件夹名称"])
|
|
|
goods_art_no = str(row["商品货号"])
|
|
goods_art_no = str(row["商品货号"])
|
|
|
print("货号数据", goods_art_no)
|
|
print("货号数据", goods_art_no)
|
|
|
- goods_no = str(row["款号"])
|
|
|
|
|
- a001_df = goods_art_dirs.get_group(goods_no)
|
|
|
|
|
- goods_art_nos = a001_df["商品货号"].tolist()
|
|
|
|
|
- print("goods_art_nos", goods_art_nos)
|
|
|
|
|
if not goods_art_no:
|
|
if not goods_art_no:
|
|
|
raise UnicornException("货号不能为空")
|
|
raise UnicornException("货号不能为空")
|
|
|
session = SqlQuery()
|
|
session = SqlQuery()
|
|
@@ -139,7 +146,9 @@ def fromExcelHandler(params: HandlerDetail):
|
|
|
raise UnicornException("没有可用货号数据")
|
|
raise UnicornException("没有可用货号数据")
|
|
|
# 货号目录不存在再去进行移动和创建操作
|
|
# 货号目录不存在再去进行移动和创建操作
|
|
|
if move_folder_array.get(goods_art_no) == None:
|
|
if move_folder_array.get(goods_art_no) == None:
|
|
|
- image_dir = "{}/data/{}".format(os.getcwd(), goods_no).replace("\\", "/")
|
|
|
|
|
|
|
+ image_dir = "{}/data/{}".format(os.getcwd(), goods_art_no).replace(
|
|
|
|
|
+ "\\", "/"
|
|
|
|
|
+ )
|
|
|
check_path(image_dir)
|
|
check_path(image_dir)
|
|
|
for itemImg in images:
|
|
for itemImg in images:
|
|
|
if itemImg.image_path == "" or itemImg.image_path == None:
|
|
if itemImg.image_path == "" or itemImg.image_path == None:
|
|
@@ -163,44 +172,46 @@ def fromExcelHandler(params: HandlerDetail):
|
|
|
raise UnicornException(path)
|
|
raise UnicornException(path)
|
|
|
shutil.rmtree(image_dir)
|
|
shutil.rmtree(image_dir)
|
|
|
# path = os.path.dirname(path)
|
|
# path = os.path.dirname(path)
|
|
|
|
|
+
|
|
|
|
|
+ config_data = {
|
|
|
|
|
+ "image_dir": limit_path, # 这个目录作为本次生成的图片目录非常重要 例:./output/当前日期
|
|
|
|
|
+ "image_order": params.template_image_order,
|
|
|
|
|
+ "goods_art_no": goods_art_no,
|
|
|
|
|
+ "goods_art_nos": goods_art_no_arrays,
|
|
|
|
|
+ "is_check_number": False,
|
|
|
|
|
+ "resize_image_view": "后跟",
|
|
|
|
|
+ "cutout_mode": settings.CUTOUT_MODE,
|
|
|
|
|
+ "logo_path": params.logo_path,
|
|
|
|
|
+ "special_goods_art_no_folder_line": "",
|
|
|
|
|
+ "is_use_excel": (False if params.excel_path == "" else True), # 是否使用excel
|
|
|
|
|
+ "excel_path": params.excel_path, # excel路径
|
|
|
|
|
+ "is_check_color_is_all": False,
|
|
|
|
|
+ "cutout_is_pass": True,
|
|
|
|
|
+ "assigned_page_dict": {},
|
|
|
|
|
+ "detail_is_pass": True,
|
|
|
|
|
+ "upload_is_pass": False,
|
|
|
|
|
+ "upload_is_enable": False,
|
|
|
|
|
+ "is_filter": False,
|
|
|
|
|
+ "temp_class": temp_class,
|
|
|
|
|
+ "temp_name": params.temp_name,
|
|
|
|
|
+ "temp_name_list": temp_name_list,
|
|
|
|
|
+ "target_error_folder": f"{limit_path}/软件-生成详情错误",
|
|
|
|
|
+ "success_handler": [],
|
|
|
|
|
+ }
|
|
|
|
|
+ # 动态导入类
|
|
|
|
|
+ temp_class_dict = {}
|
|
|
|
|
+ for key, class_path in config_data["temp_class"].items():
|
|
|
|
|
+ module_path, class_name = class_path.rsplit(".", 1)
|
|
|
|
|
+ module = importlib.import_module(module_path)
|
|
|
|
|
+ cls = getattr(module, class_name)
|
|
|
|
|
+ temp_class_dict[key] = cls
|
|
|
|
|
+
|
|
|
|
|
+ config_data["temp_class"] = temp_class_dict
|
|
|
|
|
+ # 此处对抠图进行批量处理,保证所有的图片在生成详情图之前已经完成抠图,以保证详情图生成的效率
|
|
|
|
|
+ return_data = run_main.check_before_cutout(config_data)
|
|
|
|
|
+ cutout_res = run_main.check_for_cutout_image_first_call_back(return_data)
|
|
|
|
|
+ check_for_detail_first_res = None
|
|
|
try:
|
|
try:
|
|
|
- config_data = {
|
|
|
|
|
- "image_dir": limit_path, # 这个目录作为本次生成的图片目录非常重要 例:./output/当前日期
|
|
|
|
|
- "image_order": params.template_image_order,
|
|
|
|
|
- "goods_art_no": goods_art_no,
|
|
|
|
|
- "goods_art_nos": goods_art_no_arrays,
|
|
|
|
|
- "is_check_number": False,
|
|
|
|
|
- "resize_image_view": "后跟",
|
|
|
|
|
- "cutout_mode": settings.CUTOUT_MODE,
|
|
|
|
|
- "logo_path": params.logo_path,
|
|
|
|
|
- "special_goods_art_no_folder_line": "",
|
|
|
|
|
- "is_use_excel": (False if params.excel_path == "" else True), # 是否使用excel
|
|
|
|
|
- "excel_path": params.excel_path, # excel路径
|
|
|
|
|
- "is_check_color_is_all": False,
|
|
|
|
|
- "cutout_is_pass": True,
|
|
|
|
|
- "assigned_page_dict": {},
|
|
|
|
|
- "detail_is_pass": True,
|
|
|
|
|
- "upload_is_pass": False,
|
|
|
|
|
- "upload_is_enable": False,
|
|
|
|
|
- "is_filter": False,
|
|
|
|
|
- "temp_class": temp_class,
|
|
|
|
|
- "temp_name": params.temp_name,
|
|
|
|
|
- "temp_name_list": temp_name_list,
|
|
|
|
|
- "target_error_folder": f"{limit_path}/软件-生成详情错误",
|
|
|
|
|
- }
|
|
|
|
|
- # 动态导入类
|
|
|
|
|
- temp_class_dict = {}
|
|
|
|
|
- for key, class_path in config_data["temp_class"].items():
|
|
|
|
|
- module_path, class_name = class_path.rsplit(".", 1)
|
|
|
|
|
- module = importlib.import_module(module_path)
|
|
|
|
|
- cls = getattr(module, class_name)
|
|
|
|
|
- temp_class_dict[key] = cls
|
|
|
|
|
-
|
|
|
|
|
- config_data["temp_class"] = temp_class_dict
|
|
|
|
|
- # 此处对抠图进行批量处理,保证所有的图片在生成详情图之前已经完成抠图,以保证详情图生成的效率
|
|
|
|
|
- return_data = run_main.check_before_cutout(config_data)
|
|
|
|
|
- cutout_res = run_main.check_for_cutout_image_first_call_back(return_data)
|
|
|
|
|
- check_for_detail_first_res = None
|
|
|
|
|
if cutout_res:
|
|
if cutout_res:
|
|
|
return_data_check_before_detail = run_main.check_before_detail(config_data)
|
|
return_data_check_before_detail = run_main.check_before_detail(config_data)
|
|
|
check_for_detail_first_res = run_main.check_for_detail_first_call_back(
|
|
check_for_detail_first_res = run_main.check_for_detail_first_call_back(
|
|
@@ -213,7 +224,6 @@ def fromExcelHandler(params: HandlerDetail):
|
|
|
except:
|
|
except:
|
|
|
config_data = result
|
|
config_data = result
|
|
|
if config_data["sign_text"] == "已结束详情处理":
|
|
if config_data["sign_text"] == "已结束详情处理":
|
|
|
- # at_pic = AutoDealPics()
|
|
|
|
|
print("config_data", config_data)
|
|
print("config_data", config_data)
|
|
|
if config_data["upload_is_enable"]:
|
|
if config_data["upload_is_enable"]:
|
|
|
to_deal_dir = "{}/软件-详情图生成".format(config_data["image_dir"])
|
|
to_deal_dir = "{}/软件-详情图生成".format(config_data["image_dir"])
|
|
@@ -228,18 +238,26 @@ def fromExcelHandler(params: HandlerDetail):
|
|
|
)
|
|
)
|
|
|
upload_pic.run()
|
|
upload_pic.run()
|
|
|
out_put_dir = config_data["out_put_dir"]
|
|
out_put_dir = config_data["out_put_dir"]
|
|
|
- out_put_dir_path = "{}/{}".format(os.getcwd(), out_put_dir).replace("\\", "/")
|
|
|
|
|
- handler_result_folder = os.path.dirname(out_put_dir_path)
|
|
|
|
|
- handler_result.append(
|
|
|
|
|
- {"goods_art_no": goods_art_no, "success": True, "info": "处理成功"}
|
|
|
|
|
|
|
+ out_put_dir_path = "{}/{}".format(os.getcwd(), out_put_dir).replace(
|
|
|
|
|
+ "\\", "/"
|
|
|
)
|
|
)
|
|
|
|
|
+ handler_result_folder = os.path.dirname(out_put_dir_path)
|
|
|
|
|
+ if len(config_data["success_handler"])==0:
|
|
|
|
|
+ for good_art in goods_art_no_arrays:
|
|
|
|
|
+ handler_result.append(
|
|
|
|
|
+ {"goods_art_no": good_art, "success": False, "info": "处理失败"}
|
|
|
|
|
+ )
|
|
|
|
|
+ else:
|
|
|
|
|
+ handler_result = config_data["success_handler"]
|
|
|
else:
|
|
else:
|
|
|
- handler_result.append(
|
|
|
|
|
- {"goods_art_no": goods_art_no, "success": False, "info": "处理失败"}
|
|
|
|
|
- )
|
|
|
|
|
|
|
+ for good_art in goods_art_no_arrays:
|
|
|
|
|
+ handler_result.append(
|
|
|
|
|
+ {"goods_art_no": good_art, "success": False, "info": "处理失败"}
|
|
|
|
|
+ )
|
|
|
except Exception as e:
|
|
except Exception as e:
|
|
|
- handler_result.append(
|
|
|
|
|
- {"goods_art_no": goods_art_no, "success": False, "info": str(e)}
|
|
|
|
|
|
|
+ for good_art in goods_art_no_arrays:
|
|
|
|
|
+ handler_result.append(
|
|
|
|
|
+ {"goods_art_no": good_art, "success": False, "info": str(e)}
|
|
|
)
|
|
)
|
|
|
handler_result_folder = "/".join(handler_result_folder.split("/")[:-1])
|
|
handler_result_folder = "/".join(handler_result_folder.split("/")[:-1])
|
|
|
return {
|
|
return {
|
|
@@ -266,38 +284,41 @@ async def handle_detail(request: Request, params: HandlerDetail):
|
|
|
obj = None
|
|
obj = None
|
|
|
token = "Bearer " + params.token
|
|
token = "Bearer " + params.token
|
|
|
run_main = RunMain(obj, token)
|
|
run_main = RunMain(obj, token)
|
|
|
- goods_art_no_array = params.goods_art_no
|
|
|
|
|
|
|
+ goods_art_no_arrays = params.goods_art_no
|
|
|
is_only_cutout = params.is_only_cutout
|
|
is_only_cutout = params.is_only_cutout
|
|
|
handler_result = []
|
|
handler_result = []
|
|
|
handler_result_folder = ""
|
|
handler_result_folder = ""
|
|
|
if params.excel_path != "" and params.excel_path != None:
|
|
if params.excel_path != "" and params.excel_path != None:
|
|
|
return fromExcelHandler(params)
|
|
return fromExcelHandler(params)
|
|
|
- goods_art_list = run_main.data_mode_generate_detail.get_goods_art_no_info(
|
|
|
|
|
- goods_art_list=goods_art_no_array
|
|
|
|
|
- )
|
|
|
|
|
- goods_art_nos = []
|
|
|
|
|
- # for goods_no_values in goods_art_list_dict.values():
|
|
|
|
|
- # if goods_art_no in goods_no_values:
|
|
|
|
|
- # goods_art_nos = goods_no_values
|
|
|
|
|
- # break
|
|
|
|
|
- goods_art_list_dict = group_by_style_number(goods_art_list)
|
|
|
|
|
|
|
+ # goods_art_list = run_main.data_mode_generate_detail.get_goods_art_no_info(
|
|
|
|
|
+ # goods_art_list=goods_art_no_arrays
|
|
|
|
|
+ # )
|
|
|
|
|
+ # goods_art_nos = []
|
|
|
|
|
+ # goods_art_list_dict = group_by_style_number(goods_art_list)
|
|
|
path = ""
|
|
path = ""
|
|
|
- for goods_art_no in goods_art_no_array:
|
|
|
|
|
- try:
|
|
|
|
|
- if not goods_art_no:
|
|
|
|
|
- raise UnicornException("货号不能为空")
|
|
|
|
|
- session = SqlQuery()
|
|
|
|
|
- pr = CRUD(PhotoRecord)
|
|
|
|
|
- images = pr.read_all(session, conditions={"goods_art_no": goods_art_no})
|
|
|
|
|
- if not images:
|
|
|
|
|
- raise UnicornException("没有可用货号数据")
|
|
|
|
|
- if is_only_cutout != 1:
|
|
|
|
|
- detail_counts = len(params.template_image_order.split(","))
|
|
|
|
|
- image_counts = len(images)
|
|
|
|
|
- if image_counts < detail_counts:
|
|
|
|
|
- raise UnicornException(
|
|
|
|
|
- f"货号:[{goods_art_no}],实际照片数量:{image_counts}张,小于详情图要求数量:{detail_counts}张"
|
|
|
|
|
- )
|
|
|
|
|
|
|
+ limit_path = "output/{}".format(
|
|
|
|
|
+ time.strftime("%Y-%m-%d", time.localtime(time.time()))
|
|
|
|
|
+ )
|
|
|
|
|
+ # 该数组表示是否需要后面的移动文件夹操作,减少重复抠图,提升抠图时间和速度
|
|
|
|
|
+ move_folder_array = check_move_goods_art_no_folder(
|
|
|
|
|
+ "output", goods_art_no_arrays, limit_path
|
|
|
|
|
+ )
|
|
|
|
|
+ for goods_art_no in goods_art_no_arrays:
|
|
|
|
|
+ if not goods_art_no:
|
|
|
|
|
+ raise UnicornException("货号不能为空")
|
|
|
|
|
+ session = SqlQuery()
|
|
|
|
|
+ pr = CRUD(PhotoRecord)
|
|
|
|
|
+ images = pr.read_all(session, conditions={"goods_art_no": goods_art_no})
|
|
|
|
|
+ if not images:
|
|
|
|
|
+ raise UnicornException("没有可用货号数据")
|
|
|
|
|
+ if is_only_cutout != 1:
|
|
|
|
|
+ detail_counts = len(params.template_image_order.split(","))
|
|
|
|
|
+ image_counts = len(images)
|
|
|
|
|
+ if image_counts < detail_counts:
|
|
|
|
|
+ raise UnicornException(
|
|
|
|
|
+ f"货号:[{goods_art_no}],实际照片数量:{image_counts}张,小于详情图要求数量:{detail_counts}张"
|
|
|
|
|
+ )
|
|
|
|
|
+ if move_folder_array.get(goods_art_no) == None:
|
|
|
image_dir = "{}/data/".format(os.getcwd()).replace("\\", "/")
|
|
image_dir = "{}/data/".format(os.getcwd()).replace("\\", "/")
|
|
|
check_path(image_dir)
|
|
check_path(image_dir)
|
|
|
for itemImg in images:
|
|
for itemImg in images:
|
|
@@ -318,71 +339,65 @@ async def handle_detail(request: Request, params: HandlerDetail):
|
|
|
)
|
|
)
|
|
|
if not resFlag:
|
|
if not resFlag:
|
|
|
raise UnicornException(path)
|
|
raise UnicornException(path)
|
|
|
- temp_class = {}
|
|
|
|
|
- temp_name_list = []
|
|
|
|
|
- for tempItem in params.temp_list:
|
|
|
|
|
- temp_class[tempItem.template_id] = tempItem.template_local_classes
|
|
|
|
|
- temp_name_list.append(tempItem.template_id)
|
|
|
|
|
- config_data = {
|
|
|
|
|
- "image_dir": path,
|
|
|
|
|
- "image_order": (
|
|
|
|
|
- "俯视,侧视,后跟,鞋底,内里"
|
|
|
|
|
- if params.template_image_order == None
|
|
|
|
|
- or params.template_image_order == ""
|
|
|
|
|
- else params.template_image_order
|
|
|
|
|
- ),
|
|
|
|
|
- "goods_art_no": goods_art_no,
|
|
|
|
|
- "goods_art_nos": (
|
|
|
|
|
- goods_art_nos if len(goods_art_nos) > 0 else [goods_art_no]
|
|
|
|
|
- ),
|
|
|
|
|
- "is_check_number": False,
|
|
|
|
|
- "resize_image_view": "后跟",
|
|
|
|
|
- "cutout_mode": settings.CUTOUT_MODE,
|
|
|
|
|
- "logo_path": params.logo_path,
|
|
|
|
|
- "special_goods_art_no_folder_line": "",
|
|
|
|
|
- "is_use_excel": (
|
|
|
|
|
- False if params.excel_path == "" else True
|
|
|
|
|
- ), # 是否使用excel
|
|
|
|
|
- "excel_path": params.excel_path, # excel路径
|
|
|
|
|
- "is_check_color_is_all": False,
|
|
|
|
|
- "cutout_is_pass": True,
|
|
|
|
|
- "assigned_page_dict": {},
|
|
|
|
|
- "detail_is_pass": True,
|
|
|
|
|
- "upload_is_pass": False,
|
|
|
|
|
- "upload_is_enable": True,
|
|
|
|
|
- "is_filter": False,
|
|
|
|
|
- "temp_class": temp_class,
|
|
|
|
|
- "temp_name": params.temp_name,
|
|
|
|
|
- "temp_name_list": temp_name_list,
|
|
|
|
|
- "target_error_folder": f"{path}/软件-生成详情错误",
|
|
|
|
|
- }
|
|
|
|
|
- print("image_dir=====>>>>>", config_data["image_dir"])
|
|
|
|
|
- # 动态导入类
|
|
|
|
|
- temp_class_dict = {}
|
|
|
|
|
- for key, class_path in config_data["temp_class"].items():
|
|
|
|
|
- module_path, class_name = class_path.rsplit(".", 1)
|
|
|
|
|
- module = importlib.import_module(module_path)
|
|
|
|
|
- cls = getattr(module, class_name)
|
|
|
|
|
- temp_class_dict[key] = cls
|
|
|
|
|
-
|
|
|
|
|
- config_data["temp_class"] = temp_class_dict
|
|
|
|
|
- return_data = run_main.check_before_cutout(config_data)
|
|
|
|
|
- cutout_res = run_main.check_for_cutout_image_first_call_back(return_data)
|
|
|
|
|
- check_for_detail_first_res = None
|
|
|
|
|
- if cutout_res == True:
|
|
|
|
|
- out_put_dir = return_data["data"]["image_dir"] + "/" + goods_art_no
|
|
|
|
|
- out_put_dir_path = "{}/{}".format(os.getcwd(), out_put_dir).replace(
|
|
|
|
|
- "\\", "/"
|
|
|
|
|
- )
|
|
|
|
|
- # print("out_put_dir_path", out_put_dir_path)
|
|
|
|
|
- handler_result_folder = os.path.dirname(out_put_dir_path)
|
|
|
|
|
- handler_result.append(
|
|
|
|
|
- {"goods_art_no": goods_art_no, "success": True, "info": "处理成功"}
|
|
|
|
|
- )
|
|
|
|
|
- # print("检测到需要裁剪图片,开始裁剪图片", return_data)
|
|
|
|
|
- except Exception as e:
|
|
|
|
|
|
|
+ # try:
|
|
|
|
|
+ temp_class = {}
|
|
|
|
|
+ temp_name_list = []
|
|
|
|
|
+ for tempItem in params.temp_list:
|
|
|
|
|
+ temp_class[tempItem.template_id] = tempItem.template_local_classes
|
|
|
|
|
+ temp_name_list.append(tempItem.template_id)
|
|
|
|
|
+ config_data = {
|
|
|
|
|
+ "image_dir": limit_path,
|
|
|
|
|
+ "image_order": (
|
|
|
|
|
+ "俯视,侧视,后跟,鞋底,内里"
|
|
|
|
|
+ if params.template_image_order == None
|
|
|
|
|
+ or params.template_image_order == ""
|
|
|
|
|
+ else params.template_image_order
|
|
|
|
|
+ ),
|
|
|
|
|
+ "goods_art_no": "",
|
|
|
|
|
+ "goods_art_nos": goods_art_no_arrays,
|
|
|
|
|
+ "is_check_number": False,
|
|
|
|
|
+ "resize_image_view": "后跟",
|
|
|
|
|
+ "cutout_mode": settings.CUTOUT_MODE,
|
|
|
|
|
+ "logo_path": params.logo_path,
|
|
|
|
|
+ "special_goods_art_no_folder_line": "",
|
|
|
|
|
+ "is_use_excel": False, # 是否使用excel
|
|
|
|
|
+ "excel_path": "", # excel路径
|
|
|
|
|
+ "is_check_color_is_all": False,
|
|
|
|
|
+ "cutout_is_pass": True,
|
|
|
|
|
+ "assigned_page_dict": {},
|
|
|
|
|
+ "detail_is_pass": True,
|
|
|
|
|
+ "upload_is_pass": False,
|
|
|
|
|
+ "upload_is_enable": settings.IS_UPLOAD_HLM, # 是否上传到惠利玛商品库,通过config.ini得is_upload开启
|
|
|
|
|
+ "is_filter": False,
|
|
|
|
|
+ "temp_class": temp_class,
|
|
|
|
|
+ "temp_name": params.temp_name,
|
|
|
|
|
+ "temp_name_list": temp_name_list,
|
|
|
|
|
+ "target_error_folder": f"{limit_path}/软件-生成详情错误",
|
|
|
|
|
+ "success_handler": [],
|
|
|
|
|
+ }
|
|
|
|
|
+ print("image_dir=====>>>>>", config_data["image_dir"])
|
|
|
|
|
+ # 动态导入类
|
|
|
|
|
+ temp_class_dict = {}
|
|
|
|
|
+ for key, class_path in config_data["temp_class"].items():
|
|
|
|
|
+ module_path, class_name = class_path.rsplit(".", 1)
|
|
|
|
|
+ module = importlib.import_module(module_path)
|
|
|
|
|
+ cls = getattr(module, class_name)
|
|
|
|
|
+ temp_class_dict[key] = cls
|
|
|
|
|
+
|
|
|
|
|
+ config_data["temp_class"] = temp_class_dict
|
|
|
|
|
+ return_data = run_main.check_before_cutout(config_data)
|
|
|
|
|
+ cutout_res = run_main.check_for_cutout_image_first_call_back(return_data)
|
|
|
|
|
+ check_for_detail_first_res = None
|
|
|
|
|
+ if cutout_res == True:
|
|
|
|
|
+ sys_path = format(os.getcwd()).replace("\\", "/")
|
|
|
|
|
+ handler_result_folder = f"{sys_path}/{limit_path}"
|
|
|
|
|
+ for goods_art_item in goods_art_no_arrays:
|
|
|
handler_result.append(
|
|
handler_result.append(
|
|
|
- {"goods_art_no": goods_art_no, "success": False, "info": str(e)}
|
|
|
|
|
|
|
+ {
|
|
|
|
|
+ "goods_art_no": goods_art_item,
|
|
|
|
|
+ "success": True,
|
|
|
|
|
+ "info": "处理成功",
|
|
|
|
|
+ }
|
|
|
)
|
|
)
|
|
|
if is_only_cutout == 1:
|
|
if is_only_cutout == 1:
|
|
|
return {
|
|
return {
|
|
@@ -392,90 +407,53 @@ async def handle_detail(request: Request, params: HandlerDetail):
|
|
|
}
|
|
}
|
|
|
handler_result = []
|
|
handler_result = []
|
|
|
try:
|
|
try:
|
|
|
- for goods_art_no_arr in goods_art_list_dict.values():
|
|
|
|
|
- temp_class = {}
|
|
|
|
|
- temp_name_list = []
|
|
|
|
|
- for tempItem in params.temp_list:
|
|
|
|
|
- temp_class[tempItem.template_id] = tempItem.template_local_classes
|
|
|
|
|
- temp_name_list.append(tempItem.template_id)
|
|
|
|
|
- config_data = {
|
|
|
|
|
- "image_dir": path,
|
|
|
|
|
- "image_order": (
|
|
|
|
|
- "俯视,侧视,后跟,鞋底,内里"
|
|
|
|
|
- if params.template_image_order is None
|
|
|
|
|
- or params.template_image_order == ""
|
|
|
|
|
- else params.template_image_order
|
|
|
|
|
- ),
|
|
|
|
|
- "goods_art_no": "",
|
|
|
|
|
- "goods_art_nos": goods_art_no_arr,
|
|
|
|
|
- "is_check_number": False,
|
|
|
|
|
- "resize_image_view": "后跟",
|
|
|
|
|
- "cutout_mode": settings.CUTOUT_MODE,
|
|
|
|
|
- "logo_path": params.logo_path,
|
|
|
|
|
- "special_goods_art_no_folder_line": "",
|
|
|
|
|
- "is_use_excel": (
|
|
|
|
|
- False if params.excel_path == "" else True
|
|
|
|
|
- ), # 是否使用excel
|
|
|
|
|
- "excel_path": params.excel_path, # excel路径
|
|
|
|
|
- "is_check_color_is_all": False,
|
|
|
|
|
- "cutout_is_pass": True,
|
|
|
|
|
- "assigned_page_dict": {},
|
|
|
|
|
- "detail_is_pass": True,
|
|
|
|
|
- "upload_is_pass": False,
|
|
|
|
|
- "upload_is_enable": True,
|
|
|
|
|
- "is_filter": False,
|
|
|
|
|
- "temp_class": temp_class,
|
|
|
|
|
- "temp_name": params.temp_name,
|
|
|
|
|
- "temp_name_list": temp_name_list,
|
|
|
|
|
- "target_error_folder": f"{path}/软件-生成详情错误",
|
|
|
|
|
- }
|
|
|
|
|
- # 动态导入类
|
|
|
|
|
- temp_class_dict = {}
|
|
|
|
|
- for key, class_path in config_data["temp_class"].items():
|
|
|
|
|
- module_path, class_name = class_path.rsplit(".", 1)
|
|
|
|
|
- module = importlib.import_module(module_path)
|
|
|
|
|
- cls = getattr(module, class_name)
|
|
|
|
|
- temp_class_dict[key] = cls
|
|
|
|
|
-
|
|
|
|
|
- config_data["temp_class"] = temp_class_dict
|
|
|
|
|
- return_data_check_before_detail = run_main.check_before_detail(config_data)
|
|
|
|
|
- check_for_detail_first_res = run_main.check_for_detail_first_call_back(
|
|
|
|
|
- return_data_check_before_detail
|
|
|
|
|
- )
|
|
|
|
|
- if isinstance(check_for_detail_first_res, partial):
|
|
|
|
|
- result = check_for_detail_first_res()
|
|
|
|
|
- try:
|
|
|
|
|
- config_data = result["config_data"]
|
|
|
|
|
- except:
|
|
|
|
|
- config_data = result
|
|
|
|
|
- if config_data["sign_text"] == "已结束详情处理":
|
|
|
|
|
- # at_pic = AutoDealPics()
|
|
|
|
|
- print("config_data", config_data)
|
|
|
|
|
- if config_data["upload_is_enable"]:
|
|
|
|
|
- to_deal_dir = "{}/软件-详情图生成".format(config_data["image_dir"])
|
|
|
|
|
- check_path(to_deal_dir)
|
|
|
|
|
- print("to_deal_dir", to_deal_dir)
|
|
|
|
|
- if os.path.exists(to_deal_dir):
|
|
|
|
|
- upload_pic = UploadPic(
|
|
|
|
|
- windows=None,
|
|
|
|
|
- to_deal_dir=to_deal_dir,
|
|
|
|
|
- config_data=config_data,
|
|
|
|
|
- token=token,
|
|
|
|
|
- )
|
|
|
|
|
- upload_pic.run()
|
|
|
|
|
- out_put_dir = config_data["out_put_dir"]
|
|
|
|
|
|
|
+ return_data_check_before_detail = run_main.check_before_detail(config_data)
|
|
|
|
|
+ check_for_detail_first_res = run_main.check_for_detail_first_call_back(
|
|
|
|
|
+ return_data_check_before_detail
|
|
|
|
|
+ )
|
|
|
|
|
+ if isinstance(check_for_detail_first_res, partial):
|
|
|
|
|
+ result = check_for_detail_first_res()
|
|
|
|
|
+ try:
|
|
|
|
|
+ config_data = result["config_data"]
|
|
|
|
|
+ except:
|
|
|
|
|
+ config_data = result
|
|
|
|
|
+ if config_data["sign_text"] == "已结束详情处理":
|
|
|
|
|
+ # at_pic = AutoDealPics()
|
|
|
|
|
+ print("config_data", config_data)
|
|
|
|
|
+ # if config_data["upload_is_enable"]:
|
|
|
|
|
+ # to_deal_dir = "{}/软件-详情图生成".format(config_data["image_dir"])
|
|
|
|
|
+ # check_path(to_deal_dir)
|
|
|
|
|
+ # print("to_deal_dir", to_deal_dir)
|
|
|
|
|
+ # if os.path.exists(to_deal_dir):
|
|
|
|
|
+ # upload_pic = UploadPic(
|
|
|
|
|
+ # windows=None,
|
|
|
|
|
+ # to_deal_dir=to_deal_dir,
|
|
|
|
|
+ # config_data=config_data,
|
|
|
|
|
+ # token=token,
|
|
|
|
|
+ # )
|
|
|
|
|
+ # upload_pic.run()
|
|
|
|
|
+ out_put_dir = config_data.get("out_put_dir")
|
|
|
|
|
+ if out_put_dir:
|
|
|
out_put_dir_path = "{}/{}".format(os.getcwd(), out_put_dir).replace(
|
|
out_put_dir_path = "{}/{}".format(os.getcwd(), out_put_dir).replace(
|
|
|
"\\", "/"
|
|
"\\", "/"
|
|
|
)
|
|
)
|
|
|
handler_result_folder = os.path.dirname(out_put_dir_path)
|
|
handler_result_folder = os.path.dirname(out_put_dir_path)
|
|
|
- handler_result.append(
|
|
|
|
|
- {"goods_art_no": "", "success": True, "info": "处理成功"}
|
|
|
|
|
- )
|
|
|
|
|
else:
|
|
else:
|
|
|
- handler_result.append(
|
|
|
|
|
- {"goods_art_no": "", "success": False, "info": "处理失败"}
|
|
|
|
|
- )
|
|
|
|
|
|
|
+ handler_result_folder = ""
|
|
|
|
|
+ if len(config_data["success_handler"]) == 0:
|
|
|
|
|
+ for good_art in goods_art_no_arrays:
|
|
|
|
|
+ handler_result.append(
|
|
|
|
|
+ {"goods_art_no": good_art, "success": False, "info": "处理失败"}
|
|
|
|
|
+ )
|
|
|
|
|
+ else:
|
|
|
|
|
+ handler_result = config_data["success_handler"]
|
|
|
|
|
+ else:
|
|
|
|
|
+ handler_result.append(
|
|
|
|
|
+ {"goods_art_no": "", "success": False, "info": "处理失败"}
|
|
|
|
|
+ )
|
|
|
except Exception as e:
|
|
except Exception as e:
|
|
|
|
|
+ print(e.__traceback__.tb_frame.f_globals["__file__"]) # 发生异常所在的文件
|
|
|
|
|
+ print(e.__traceback__.tb_lineno) # 发生异常所在的行数
|
|
|
handler_result.append({"goods_art_no": "", "success": False, "info": str(e)})
|
|
handler_result.append({"goods_art_no": "", "success": False, "info": str(e)})
|
|
|
return {
|
|
return {
|
|
|
"code": 0,
|
|
"code": 0,
|