|
|
@@ -8,6 +8,7 @@ from serial.tools import list_ports
|
|
|
from model import PhotoRecord
|
|
|
import settings
|
|
|
|
|
|
+
|
|
|
from utils.hlm_http_request import forward_request
|
|
|
from utils.utils_func import check_path
|
|
|
from sockets.socket_client import socket_manager
|
|
|
@@ -21,6 +22,12 @@ from service.run_main import RunMain
|
|
|
import importlib
|
|
|
from service.auto_deal_pics.upload_pic import UploadPic
|
|
|
# from service.AutoDealPics import AutoDealPics
|
|
|
+# for plugin in settings.plugins:
|
|
|
+# module_path, class_name = plugin.rsplit(".", 1)
|
|
|
+# print("module_path", module_path, class_name)
|
|
|
+# module = importlib.import_module(module_path)
|
|
|
+# getattr(module, class_name)
|
|
|
+
|
|
|
|
|
|
@app.get("/")
|
|
|
async def index():
|
|
|
@@ -131,11 +138,13 @@ async def handle_detail(request: Request, params: HandlerDetail):
|
|
|
images = pr.read_all(session, conditions={"goods_art_no": goods_art_no})
|
|
|
if not images:
|
|
|
raise UnicornException("没有可用货号数据")
|
|
|
- image_dir = "{}/data/".format(os.getcwd())
|
|
|
+ image_dir = "{}/data/".format(os.getcwd()).replace("\\", "/")
|
|
|
+ check_path(image_dir)
|
|
|
for itemImg in images:
|
|
|
- if not os.path.exists(image_dir + "/" + os.path.basename(itemImg.image_path)):
|
|
|
+ if not os.path.exists(
|
|
|
+ image_dir + "/" + os.path.basename(itemImg.image_path)
|
|
|
+ ):
|
|
|
shutil.copy(itemImg.image_path, image_dir)
|
|
|
- check_path(image_dir)
|
|
|
dealImage = DealImage(image_dir)
|
|
|
resFlag, path = dealImage.dealMoveImage(
|
|
|
image_dir=image_dir, callback_func=None, goods_art_no=goods_art_no
|
|
|
@@ -148,28 +157,28 @@ async def handle_detail(request: Request, params: HandlerDetail):
|
|
|
temp_class[tempItem.template_id] = tempItem.template_local_classes
|
|
|
temp_name_list.append(tempItem.template_id)
|
|
|
config_data = {
|
|
|
- "image_dir": path,
|
|
|
- "image_order": params.template_image_order,
|
|
|
- "goods_art_no": goods_art_no,
|
|
|
- "is_check_number": False,
|
|
|
- "resize_image_view": "后跟",
|
|
|
- "cutout_mode": "0",
|
|
|
- "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"{path}/软件-生成详情错误",
|
|
|
- }
|
|
|
+ "image_dir": path,
|
|
|
+ "image_order": params.template_image_order,
|
|
|
+ "goods_art_no": goods_art_no,
|
|
|
+ "is_check_number": False,
|
|
|
+ "resize_image_view": "后跟",
|
|
|
+ "cutout_mode": "0",
|
|
|
+ "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"{path}/软件-生成详情错误",
|
|
|
+ }
|
|
|
# 动态导入类
|
|
|
temp_class_dict = {}
|
|
|
for key, class_path in config_data["temp_class"].items():
|
|
|
@@ -187,8 +196,8 @@ async def handle_detail(request: Request, params: HandlerDetail):
|
|
|
if cutout_res == True:
|
|
|
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
|
|
|
- )
|
|
|
+ return_data_check_before_detail
|
|
|
+ )
|
|
|
if isinstance(check_for_detail_first_res, partial):
|
|
|
result = check_for_detail_first_res()
|
|
|
try:
|
|
|
@@ -204,26 +213,22 @@ async def handle_detail(request: Request, params: HandlerDetail):
|
|
|
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,
|
|
|
- )
|
|
|
+ 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"]
|
|
|
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": "处理成功"}
|
|
|
- )
|
|
|
+ {"goods_art_no": goods_art_no, "success": True, "info": "处理成功"}
|
|
|
+ )
|
|
|
else:
|
|
|
- # return {
|
|
|
- # "code": 1,
|
|
|
- # "msg": "处理失败,请联系管理员",
|
|
|
- # "data": None}
|
|
|
handler_result.append(
|
|
|
- {"goods_art_no": goods_art_no, "success": False, "info": "处理失败"}
|
|
|
- )
|
|
|
+ {"goods_art_no": goods_art_no, "success": False, "info": "处理失败"}
|
|
|
+ )
|
|
|
except Exception as e:
|
|
|
handler_result.append(
|
|
|
{"goods_art_no": goods_art_no, "success": False, "info": str(e)}
|