|
@@ -134,10 +134,19 @@ async def forwardRequest(request: HlmForwardRequest):
|
|
|
|
|
|
|
|
|
|
|
|
|
async def fromExcelHandler(params: HandlerDetail):
|
|
async def fromExcelHandler(params: HandlerDetail):
|
|
|
|
|
+ obj = None
|
|
|
excel_path = params.excel_path
|
|
excel_path = params.excel_path
|
|
|
token = "Bearer " + params.token
|
|
token = "Bearer " + params.token
|
|
|
uuid = params.uuid
|
|
uuid = params.uuid
|
|
|
|
|
+ aigc_clazz = AIGCDataRequest(token)
|
|
|
|
|
+ run_main = RunMain(obj, token, uuid)
|
|
|
|
|
+ onlineData = OnlineDataRequest(token)
|
|
|
excel_df = pd.read_excel(excel_path, sheet_name=0, header=0)
|
|
excel_df = pd.read_excel(excel_path, sheet_name=0, header=0)
|
|
|
|
|
+ online_stores = params.online_stores # 上传第三方的店铺名称数组
|
|
|
|
|
+ is_product_scene = params.is_product_scene # 上传第三方的店铺名称数组
|
|
|
|
|
+ is_upper_footer = params.is_upper_footer # 上传第三方的店铺名称数组
|
|
|
|
|
+ upper_footer_params = params.upper_footer_params # 上传第三方的店铺名称数组
|
|
|
|
|
+ product_scene_prompt = params.product_scene_prompt # 上传第三方的店铺名称数组
|
|
|
handler_result = []
|
|
handler_result = []
|
|
|
handler_result_folder = ""
|
|
handler_result_folder = ""
|
|
|
if "文件夹名称" not in excel_df.columns:
|
|
if "文件夹名称" not in excel_df.columns:
|
|
@@ -147,14 +156,6 @@ async def fromExcelHandler(params: HandlerDetail):
|
|
|
if "款号" not in excel_df.columns:
|
|
if "款号" not in excel_df.columns:
|
|
|
raise UnicornException("缺失 [款号] 列")
|
|
raise UnicornException("缺失 [款号] 列")
|
|
|
goods_art_dirs = excel_df.groupby(excel_df["款号"])
|
|
goods_art_dirs = excel_df.groupby(excel_df["款号"])
|
|
|
- obj = None
|
|
|
|
|
- run_main = RunMain(obj, token, uuid)
|
|
|
|
|
- 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)
|
|
|
|
|
# 抠图时用到的货号列表,与生成详情图有所区别
|
|
# 抠图时用到的货号列表,与生成详情图有所区别
|
|
|
goods_art_no_arrays = []
|
|
goods_art_no_arrays = []
|
|
|
# # 详情图生成需要对同款商品进行分组,保证详情图可以生成多个色
|
|
# # 详情图生成需要对同款商品进行分组,保证详情图可以生成多个色
|
|
@@ -175,43 +176,74 @@ async def fromExcelHandler(params: HandlerDetail):
|
|
|
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
|
|
|
)
|
|
)
|
|
|
- for index, row in excel_df.iterrows():
|
|
|
|
|
- goods_art_no_image_dir = str(row["文件夹名称"])
|
|
|
|
|
- goods_art_no = str(row["商品货号"])
|
|
|
|
|
- print("货号数据", goods_art_no)
|
|
|
|
|
- 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(
|
|
|
|
|
- f"商品货号【{goods_art_no}】在商品档案资料中不存在,请检查货号是否正确"
|
|
|
|
|
- )
|
|
|
|
|
- # 货号目录不存在再去进行移动和创建操作
|
|
|
|
|
- if move_folder_array.get(goods_art_no) == None:
|
|
|
|
|
- image_dir = "{}/data/".format(os.getcwd()).replace("\\", "/")
|
|
|
|
|
- check_path(image_dir)
|
|
|
|
|
- for idx, itemImg in enumerate(images):
|
|
|
|
|
- if itemImg.image_path == "" or itemImg.image_path == None:
|
|
|
|
|
- raise UnicornException(
|
|
|
|
|
- f"货号【{goods_art_no}】存在没有拍摄完成的图片,请重拍或删除后重试"
|
|
|
|
|
- )
|
|
|
|
|
- new_file_name = str(itemImg.goods_art_no) + "_" + str(idx) + ".jpg"
|
|
|
|
|
- if not os.path.exists(
|
|
|
|
|
- image_dir + "/" + os.path.basename(new_file_name)
|
|
|
|
|
- ):
|
|
|
|
|
- shutil.copy(itemImg.image_path, image_dir + new_file_name)
|
|
|
|
|
- dealImage = DealImage(image_dir)
|
|
|
|
|
- resFlag, path = dealImage.dealMoveImage(
|
|
|
|
|
- image_dir=image_dir,
|
|
|
|
|
- callback_func=None,
|
|
|
|
|
- goods_art_no=goods_art_no_image_dir,
|
|
|
|
|
- )
|
|
|
|
|
- if not resFlag:
|
|
|
|
|
- raise UnicornException(path)
|
|
|
|
|
- shutil.rmtree(image_dir)
|
|
|
|
|
- # path = os.path.dirname(path)
|
|
|
|
|
|
|
+ try:
|
|
|
|
|
+ for index, row in excel_df.iterrows():
|
|
|
|
|
+ goods_art_no_image_dir = str(row["文件夹名称"])
|
|
|
|
|
+ goods_art_no = str(row["商品货号"])
|
|
|
|
|
+ print("货号数据", goods_art_no)
|
|
|
|
|
+ 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(
|
|
|
|
|
+ f"商品货号【{goods_art_no}】在商品档案资料中不存在,请检查货号是否正确"
|
|
|
|
|
+ )
|
|
|
|
|
+ # 货号目录不存在再去进行移动和创建操作
|
|
|
|
|
+ if move_folder_array.get(goods_art_no) == None:
|
|
|
|
|
+ image_dir = "{}/data/".format(os.getcwd()).replace("\\", "/")
|
|
|
|
|
+ check_path(image_dir)
|
|
|
|
|
+ for idx, itemImg in enumerate(images):
|
|
|
|
|
+ if itemImg.image_path == "" or itemImg.image_path == None:
|
|
|
|
|
+ raise UnicornException(
|
|
|
|
|
+ f"货号【{goods_art_no}】存在没有拍摄完成的图片,请重拍或删除后重试"
|
|
|
|
|
+ )
|
|
|
|
|
+ new_file_name = str(itemImg.goods_art_no) + "_" + str(idx) + ".jpg"
|
|
|
|
|
+ if not os.path.exists(
|
|
|
|
|
+ image_dir + "/" + os.path.basename(new_file_name)
|
|
|
|
|
+ ):
|
|
|
|
|
+ shutil.copy(itemImg.image_path, image_dir + new_file_name)
|
|
|
|
|
+ dealImage = DealImage(image_dir)
|
|
|
|
|
+ resFlag, path = dealImage.dealMoveImage(
|
|
|
|
|
+ image_dir=image_dir,
|
|
|
|
|
+ callback_func=None,
|
|
|
|
|
+ goods_art_no=goods_art_no_image_dir,
|
|
|
|
|
+ )
|
|
|
|
|
+ if not resFlag:
|
|
|
|
|
+ raise UnicornException(path)
|
|
|
|
|
+ shutil.rmtree(image_dir)
|
|
|
|
|
+ # path = os.path.dirname(path)
|
|
|
|
|
+ except UnicornException as e:
|
|
|
|
|
+ handler_result_folder = ""
|
|
|
|
|
+ handler_result.append(
|
|
|
|
|
+ {"goods_art_no": "", "success": False, "info": str(e.msg)}
|
|
|
|
|
+ )
|
|
|
|
|
+ print(f"UnicornException 生成错误信息:{e}")
|
|
|
|
|
+ await sendAsyncMessage(
|
|
|
|
|
+ msg="处理结束",
|
|
|
|
|
+ data={"output_folder": handler_result_folder, "list": handler_result},
|
|
|
|
|
+ status="处理结束",
|
|
|
|
|
+ msg_type="detail_result_progress",
|
|
|
|
|
+ )
|
|
|
|
|
+ return True
|
|
|
|
|
+ except Exception as e:
|
|
|
|
|
+ print(f"详情图生成错误信息:{e}")
|
|
|
|
|
+ handler_result_folder = ""
|
|
|
|
|
+ handler_result.append({"goods_art_no": "", "success": False, "info": str(e)})
|
|
|
|
|
+ await sendAsyncMessage(
|
|
|
|
|
+ msg="处理结束",
|
|
|
|
|
+ data={"output_folder": handler_result_folder, "list": handler_result},
|
|
|
|
|
+ status="处理结束",
|
|
|
|
|
+ msg_type="detail_result_progress",
|
|
|
|
|
+ )
|
|
|
|
|
+ return True
|
|
|
|
|
+ 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)
|
|
|
cutOutMode = (
|
|
cutOutMode = (
|
|
|
"0"
|
|
"0"
|
|
|
if settings.getSysConfigs("other_configs", "cutout_mode", "普通抠图")
|
|
if settings.getSysConfigs("other_configs", "cutout_mode", "普通抠图")
|
|
@@ -261,12 +293,168 @@ async def fromExcelHandler(params: HandlerDetail):
|
|
|
return_data = run_main.check_before_cutout(config_data)
|
|
return_data = run_main.check_before_cutout(config_data)
|
|
|
cutout_res = run_main.check_for_cutout_image_first_call_back(return_data)
|
|
cutout_res = run_main.check_for_cutout_image_first_call_back(return_data)
|
|
|
check_for_detail_first_res = None
|
|
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(
|
|
|
|
|
+ {
|
|
|
|
|
+ "goods_art_no": goods_art_item,
|
|
|
|
|
+ "success": True,
|
|
|
|
|
+ "info": "处理成功",
|
|
|
|
|
+ }
|
|
|
|
|
+ )
|
|
|
try:
|
|
try:
|
|
|
- if cutout_res:
|
|
|
|
|
- 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 is_product_scene == 1:
|
|
|
|
|
+ if product_scene_prompt == "" or product_scene_prompt == None:
|
|
|
|
|
+ raise UnicornException("请填写场景描述")
|
|
|
|
|
+ if is_upper_footer == 1:
|
|
|
|
|
+ if upper_footer_params == {} or upper_footer_params == None:
|
|
|
|
|
+ raise UnicornException("请选择模特")
|
|
|
|
|
+ man_id = upper_footer_params.get("man_id")
|
|
|
|
|
+ if not man_id:
|
|
|
|
|
+ raise UnicornException("请选择男模特")
|
|
|
|
|
+ women_id = upper_footer_params.get("women_id")
|
|
|
|
|
+ if not women_id:
|
|
|
|
|
+ raise UnicornException("请选择女模特")
|
|
|
|
|
+ return_data_check_before_detail = run_main.check_before_detail(config_data)
|
|
|
|
|
+ print("报错前返回的结果数据", return_data_check_before_detail)
|
|
|
|
|
+ if is_product_scene == 1:
|
|
|
|
|
+ goods_dict = parserGoodsDict2Aigc(return_data_check_before_detail)
|
|
|
|
|
+ new_goods_dict = {}
|
|
|
|
|
+ await sendAsyncMessage(
|
|
|
|
|
+ msg="开始处理场景图",
|
|
|
|
|
+ goods_arts=[goods_art_no for goods_art_no in goods_dict.keys()],
|
|
|
|
|
+ status="开始处理",
|
|
|
|
|
+ msg_type="scene_progress",
|
|
|
|
|
+ )
|
|
|
|
|
+ for goods_art_no in goods_dict.keys():
|
|
|
|
|
+ print("处理场景图", goods_art_no)
|
|
|
|
|
+ goods_art_dict_info = goods_dict[goods_art_no]
|
|
|
|
|
+ first_goods_art_no_info = goods_art_dict_info.get("货号资料", [])[0]
|
|
|
|
|
+ first_pics = first_goods_art_no_info.get("pics")
|
|
|
|
|
+ ceshi_image_path = first_pics.get("侧视-抠图")
|
|
|
|
|
+ save_root_path = ceshi_image_path.split("阴影图处理")[0]
|
|
|
|
|
+ save_image_path = f"{save_root_path}场景图.jpg"
|
|
|
|
|
+ if os.path.isfile(save_image_path):
|
|
|
|
|
+ goods_art_dict_info["场景图"] = save_image_path
|
|
|
|
|
+ new_goods_dict[goods_art_no] = goods_art_dict_info
|
|
|
|
|
+ continue
|
|
|
|
|
+ aigc_clazz.center_paste_image(ceshi_image_path, save_image_path)
|
|
|
|
|
+ try:
|
|
|
|
|
+ image_path = aigc_clazz.generateProductScene(
|
|
|
|
|
+ save_image_path, product_scene_prompt, save_image_path
|
|
|
|
|
+ )
|
|
|
|
|
+ # image_path = aigc_clazz.generateProductSceneQW(
|
|
|
|
|
+ # save_image_path, product_scene_prompt, save_image_path
|
|
|
|
|
+ # )
|
|
|
|
|
+ goods_art_dict_info["场景图"] = image_path
|
|
|
|
|
+ new_goods_dict[goods_art_no] = goods_art_dict_info
|
|
|
|
|
+ handler_result.append(
|
|
|
|
|
+ {
|
|
|
|
|
+ "goods_art_no": goods_art_no,
|
|
|
|
|
+ "success": True,
|
|
|
|
|
+ "info": "场景图处理成功",
|
|
|
|
|
+ }
|
|
|
|
|
+ )
|
|
|
|
|
+ await sendAsyncMessage(
|
|
|
|
|
+ msg="场景图处理完成",
|
|
|
|
|
+ goods_arts=[goods_art_no],
|
|
|
|
|
+ status="场景图处理完成",
|
|
|
|
|
+ msg_type="scene_progress",
|
|
|
|
|
+ )
|
|
|
|
|
+ except Exception as e:
|
|
|
|
|
+ os.remove(save_image_path)
|
|
|
|
|
+ handler_result.append(
|
|
|
|
|
+ {
|
|
|
|
|
+ "goods_art_no": goods_art_no,
|
|
|
|
|
+ "success": False,
|
|
|
|
|
+ "info": f"场景图处理失败:{e}",
|
|
|
|
|
+ }
|
|
|
|
|
+ )
|
|
|
|
|
+ await sendAsyncMessage(
|
|
|
|
|
+ msg="场景图处理失败",
|
|
|
|
|
+ goods_arts=[goods_art_no],
|
|
|
|
|
+ status="场景图处理失败",
|
|
|
|
|
+ msg_type="scene_progress",
|
|
|
|
|
+ )
|
|
|
|
|
+ if new_goods_dict is not None or new_goods_dict != {}:
|
|
|
|
|
+ return_data_check_before_detail["data"][
|
|
|
|
|
+ "goods_no_dict"
|
|
|
|
|
+ ] = new_goods_dict
|
|
|
|
|
+ if is_upper_footer == 1:
|
|
|
|
|
+ goods_dict = parserGoodsDict2Aigc(return_data_check_before_detail)
|
|
|
|
|
+ new_goods_dict = {}
|
|
|
|
|
+ await sendAsyncMessage(
|
|
|
|
|
+ msg="开始处理模特图",
|
|
|
|
|
+ goods_arts=list(goods_dict.keys()),
|
|
|
|
|
+ status="开始处理模特图",
|
|
|
|
|
+ msg_type="upper_footer_progress",
|
|
|
)
|
|
)
|
|
|
|
|
+ for goods_art_no in goods_dict.keys():
|
|
|
|
|
+ goods_art_dict_info = goods_dict[goods_art_no]
|
|
|
|
|
+ first_goods_art_no_info = goods_art_dict_info.get("货号资料", [])[0]
|
|
|
|
|
+ first_pics = first_goods_art_no_info.get("pics")
|
|
|
|
|
+ gender = goods_art_dict_info.get("性别")
|
|
|
|
|
+ model_id = man_id if "男" in gender else women_id
|
|
|
|
|
+ ceshi_image_path = first_pics.get("侧视-抠图")
|
|
|
|
|
+ save_root_path = ceshi_image_path.split("阴影图处理")[0]
|
|
|
|
|
+ save_image_path = f"{save_root_path}模特图.jpg"
|
|
|
|
|
+ if os.path.isfile(save_image_path):
|
|
|
|
|
+ goods_art_dict_info["模特图"] = save_image_path
|
|
|
|
|
+ new_goods_dict[goods_art_no] = goods_art_dict_info
|
|
|
|
|
+ continue
|
|
|
|
|
+ shutil.copy(ceshi_image_path, save_image_path)
|
|
|
|
|
+ try:
|
|
|
|
|
+ image_path = aigc_clazz.generateUpperShoes(
|
|
|
|
|
+ save_image_path, model_id, save_image_path
|
|
|
|
|
+ )
|
|
|
|
|
+ # image_path = aigc_clazz.generateModelShoesQW(
|
|
|
|
|
+ # save_image_path, model_id, save_image_path
|
|
|
|
|
+ # )
|
|
|
|
|
+ goods_art_dict_info["模特图"] = image_path
|
|
|
|
|
+ new_goods_dict[goods_art_no] = goods_art_dict_info
|
|
|
|
|
+ handler_result.append(
|
|
|
|
|
+ {
|
|
|
|
|
+ "goods_art_no": goods_art_no,
|
|
|
|
|
+ "success": True,
|
|
|
|
|
+ "info": "模特图处理成功",
|
|
|
|
|
+ }
|
|
|
|
|
+ )
|
|
|
|
|
+ await sendAsyncMessage(
|
|
|
|
|
+ msg="模特图处理成功",
|
|
|
|
|
+ goods_arts=[goods_art_no],
|
|
|
|
|
+ status="模特图处理成功",
|
|
|
|
|
+ msg_type="upper_footer_progress",
|
|
|
|
|
+ )
|
|
|
|
|
+ except Exception as e:
|
|
|
|
|
+ os.remove(save_image_path)
|
|
|
|
|
+ handler_result.append(
|
|
|
|
|
+ {
|
|
|
|
|
+ "goods_art_no": goods_art_no,
|
|
|
|
|
+ "success": False,
|
|
|
|
|
+ "info": f"模特图处理失败:{e}",
|
|
|
|
|
+ }
|
|
|
|
|
+ )
|
|
|
|
|
+ await sendAsyncMessage(
|
|
|
|
|
+ msg="模特图处理失败",
|
|
|
|
|
+ goods_arts=[goods_art_no],
|
|
|
|
|
+ status="模特图处理失败",
|
|
|
|
|
+ msg_type="upper_footer_progress",
|
|
|
|
|
+ )
|
|
|
|
|
+ if new_goods_dict is not None or new_goods_dict != {}:
|
|
|
|
|
+ return_data_check_before_detail["data"][
|
|
|
|
|
+ "goods_no_dict"
|
|
|
|
|
+ ] = new_goods_dict
|
|
|
|
|
+ await sendAsyncMessage(
|
|
|
|
|
+ msg="开始处理详情页",
|
|
|
|
|
+ goods_arts=[],
|
|
|
|
|
+ status="开始处理详情页",
|
|
|
|
|
+ msg_type="detail_progress",
|
|
|
|
|
+ )
|
|
|
|
|
+ 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):
|
|
if isinstance(check_for_detail_first_res, partial):
|
|
|
result = check_for_detail_first_res()
|
|
result = check_for_detail_first_res()
|
|
|
try:
|
|
try:
|
|
@@ -274,19 +462,25 @@ async def fromExcelHandler(params: HandlerDetail):
|
|
|
except:
|
|
except:
|
|
|
config_data = result
|
|
config_data = result
|
|
|
if config_data["sign_text"] == "已结束详情处理":
|
|
if config_data["sign_text"] == "已结束详情处理":
|
|
|
|
|
+ await sendAsyncMessage(
|
|
|
|
|
+ msg="详情页处理结束",
|
|
|
|
|
+ goods_arts=[],
|
|
|
|
|
+ status="详情页处理结束",
|
|
|
|
|
+ msg_type="detail_progress",
|
|
|
|
|
+ )
|
|
|
print("config_data", config_data)
|
|
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()
|
|
|
|
|
|
|
+ # 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")
|
|
out_put_dir = config_data.get("out_put_dir")
|
|
|
if out_put_dir == None:
|
|
if out_put_dir == None:
|
|
|
handler_result_folder = ""
|
|
handler_result_folder = ""
|
|
@@ -317,12 +511,50 @@ async def fromExcelHandler(params: HandlerDetail):
|
|
|
}
|
|
}
|
|
|
)
|
|
)
|
|
|
else:
|
|
else:
|
|
|
|
|
+ if len(online_stores) > 0:
|
|
|
|
|
+ result_goods_no_dict = return_data_check_before_detail["data"][
|
|
|
|
|
+ "goods_no_dict"
|
|
|
|
|
+ ]
|
|
|
|
|
+ for goods_idx, goods_no_dict in enumerate(
|
|
|
|
|
+ result_goods_no_dict.keys()
|
|
|
|
|
+ ):
|
|
|
|
|
+ all_detail_path_list = config_data["all_detail_path_list"]
|
|
|
|
|
+ for detail_path in all_detail_path_list:
|
|
|
|
|
+ if goods_no_dict in detail_path:
|
|
|
|
|
+ detail_path_replace = detail_path.replace("\\", "/")
|
|
|
|
|
+ result_goods_no_dict[goods_no_dict][
|
|
|
|
|
+ "detail_path"
|
|
|
|
|
+ ] = f"{detail_path_replace}/详情页.jpg"
|
|
|
|
|
+ await sendAsyncMessage(
|
|
|
|
|
+ msg="开始上传商品数据",
|
|
|
|
|
+ goods_arts=[],
|
|
|
|
|
+ status="开始上传商品数据",
|
|
|
|
|
+ msg_type="upload_goods_progress",
|
|
|
|
|
+ )
|
|
|
|
|
+ try:
|
|
|
|
|
+ onlineData.uploadGoods2ThirdParty(
|
|
|
|
|
+ result_goods_no_dict, online_stores=online_stores
|
|
|
|
|
+ )
|
|
|
|
|
+ except Exception as e:
|
|
|
|
|
+ print(f"上传任务出现错误:{e}")
|
|
|
|
|
+ await sendAsyncMessage(
|
|
|
|
|
+ msg="商品上传第三方成功",
|
|
|
|
|
+ goods_arts=[],
|
|
|
|
|
+ status="商品上传第三方成功",
|
|
|
|
|
+ msg_type="upload_goods_progress",
|
|
|
|
|
+ )
|
|
|
handler_result = config_data["success_handler"]
|
|
handler_result = config_data["success_handler"]
|
|
|
else:
|
|
else:
|
|
|
for good_art in goods_art_no_arrays:
|
|
for good_art in goods_art_no_arrays:
|
|
|
handler_result.append(
|
|
handler_result.append(
|
|
|
{"goods_art_no": good_art, "success": False, "info": "处理失败"}
|
|
{"goods_art_no": good_art, "success": False, "info": "处理失败"}
|
|
|
)
|
|
)
|
|
|
|
|
+ except UnicornException as e:
|
|
|
|
|
+ handler_result_folder = ""
|
|
|
|
|
+ handler_result.append(
|
|
|
|
|
+ {"goods_art_no": "", "success": False, "info": str(e.msg)}
|
|
|
|
|
+ )
|
|
|
|
|
+ print(f"UnicornException 生成错误信息:{e}")
|
|
|
except Exception as e:
|
|
except Exception as e:
|
|
|
for good_art in goods_art_no_arrays:
|
|
for good_art in goods_art_no_arrays:
|
|
|
handler_result.append(
|
|
handler_result.append(
|
|
@@ -629,12 +861,12 @@ async def process_handle_detail(request: Request, params: HandlerDetail):
|
|
|
continue
|
|
continue
|
|
|
aigc_clazz.center_paste_image(ceshi_image_path, save_image_path)
|
|
aigc_clazz.center_paste_image(ceshi_image_path, save_image_path)
|
|
|
try:
|
|
try:
|
|
|
- # image_path = aigc_clazz.generateProductScene(
|
|
|
|
|
- # save_image_path, product_scene_prompt, save_image_path
|
|
|
|
|
- # )
|
|
|
|
|
- image_path = aigc_clazz.generateProductSceneQW(
|
|
|
|
|
|
|
+ image_path = aigc_clazz.generateProductScene(
|
|
|
save_image_path, product_scene_prompt, save_image_path
|
|
save_image_path, product_scene_prompt, save_image_path
|
|
|
)
|
|
)
|
|
|
|
|
+ # image_path = aigc_clazz.generateProductSceneQW(
|
|
|
|
|
+ # save_image_path, product_scene_prompt, save_image_path
|
|
|
|
|
+ # )
|
|
|
goods_art_dict_info["场景图"] = image_path
|
|
goods_art_dict_info["场景图"] = image_path
|
|
|
new_goods_dict[goods_art_no] = goods_art_dict_info
|
|
new_goods_dict[goods_art_no] = goods_art_dict_info
|
|
|
handler_result.append(
|
|
handler_result.append(
|
|
@@ -693,12 +925,12 @@ async def process_handle_detail(request: Request, params: HandlerDetail):
|
|
|
continue
|
|
continue
|
|
|
shutil.copy(ceshi_image_path, save_image_path)
|
|
shutil.copy(ceshi_image_path, save_image_path)
|
|
|
try:
|
|
try:
|
|
|
- # image_path = aigc_clazz.generateUpperShoes(
|
|
|
|
|
- # save_image_path, model_id, save_image_path
|
|
|
|
|
- # )
|
|
|
|
|
- image_path = aigc_clazz.generateModelShoesQW(
|
|
|
|
|
|
|
+ image_path = aigc_clazz.generateUpperShoes(
|
|
|
save_image_path, model_id, save_image_path
|
|
save_image_path, model_id, save_image_path
|
|
|
)
|
|
)
|
|
|
|
|
+ # image_path = aigc_clazz.generateModelShoesQW(
|
|
|
|
|
+ # save_image_path, model_id, save_image_path
|
|
|
|
|
+ # )
|
|
|
goods_art_dict_info["模特图"] = image_path
|
|
goods_art_dict_info["模特图"] = image_path
|
|
|
new_goods_dict[goods_art_no] = goods_art_dict_info
|
|
new_goods_dict[goods_art_no] = goods_art_dict_info
|
|
|
handler_result.append(
|
|
handler_result.append(
|