|
@@ -16,7 +16,7 @@ import time, shutil, os
|
|
|
from sqlalchemy import and_, asc, desc
|
|
from sqlalchemy import and_, asc, desc
|
|
|
from functools import partial
|
|
from functools import partial
|
|
|
from service.deal_image import DealImage
|
|
from service.deal_image import DealImage
|
|
|
-from databases import DeviceConfig, SysConfigs, SqlQuery, CRUD, select,DeviceConfigTabs
|
|
|
|
|
|
|
+from databases import DeviceConfig, SysConfigs, SqlQuery, CRUD, select, DeviceConfigTabs
|
|
|
from service.run_main import RunMain
|
|
from service.run_main import RunMain
|
|
|
import importlib
|
|
import importlib
|
|
|
from service.auto_deal_pics.upload_pic import UploadPic
|
|
from service.auto_deal_pics.upload_pic import UploadPic
|
|
@@ -25,6 +25,7 @@ import hashlib
|
|
|
import win32api, win32gui, win32con
|
|
import win32api, win32gui, win32con
|
|
|
from win32gui import EnumWindows, GetWindowText
|
|
from win32gui import EnumWindows, GetWindowText
|
|
|
|
|
|
|
|
|
|
+
|
|
|
# from service.AutoDealPics import AutoDealPics
|
|
# from service.AutoDealPics import AutoDealPics
|
|
|
# for plugin in settings.plugins:
|
|
# for plugin in settings.plugins:
|
|
|
# module_path, class_name = plugin.rsplit(".", 1)
|
|
# module_path, class_name = plugin.rsplit(".", 1)
|
|
@@ -57,7 +58,9 @@ async def scanSerials():
|
|
|
return {"message": "Hello World"}
|
|
return {"message": "Hello World"}
|
|
|
|
|
|
|
|
|
|
|
|
|
-@app.api_route("/forward_request", methods=["GET", "POST"], description="代理转发hlm项目得请求")
|
|
|
|
|
|
|
+@app.api_route(
|
|
|
|
|
+ "/forward_request", methods=["GET", "POST"], description="代理转发hlm项目得请求"
|
|
|
|
|
+)
|
|
|
async def forwardRequest(request: HlmForwardRequest):
|
|
async def forwardRequest(request: HlmForwardRequest):
|
|
|
"""
|
|
"""
|
|
|
转发HTTP请求到目标URL
|
|
转发HTTP请求到目标URL
|
|
@@ -78,7 +81,9 @@ async def forwardRequest(request: HlmForwardRequest):
|
|
|
if not target_url:
|
|
if not target_url:
|
|
|
raise UnicornException("目标url地址不能为空")
|
|
raise UnicornException("目标url地址不能为空")
|
|
|
# 调用 hlm_http_request 中的 forward_request 函数
|
|
# 调用 hlm_http_request 中的 forward_request 函数
|
|
|
- response = forward_request(target_url, params=params, method=method, headers=headers)
|
|
|
|
|
|
|
+ response = forward_request(
|
|
|
|
|
+ target_url, params=params, method=method, headers=headers
|
|
|
|
|
+ )
|
|
|
return response
|
|
return response
|
|
|
except requests.RequestException as e:
|
|
except requests.RequestException as e:
|
|
|
raise UnicornException(e)
|
|
raise UnicornException(e)
|
|
@@ -125,10 +130,10 @@ def fromExcelHandler(params: HandlerDetail):
|
|
|
f"货号【{goods_art_no}】存在没有拍摄完成的图片,请重拍或删除后重试"
|
|
f"货号【{goods_art_no}】存在没有拍摄完成的图片,请重拍或删除后重试"
|
|
|
)
|
|
)
|
|
|
new_file_name = (
|
|
new_file_name = (
|
|
|
- str(itemImg.goods_art_no) + "_" + str(itemImg.id) + ".jpg"
|
|
|
|
|
|
|
+ str(itemImg.goods_art_no) + "_" + str(itemImg.id) + ".jpg"
|
|
|
)
|
|
)
|
|
|
if not os.path.exists(
|
|
if not os.path.exists(
|
|
|
- image_dir + "/" + os.path.basename(new_file_name)
|
|
|
|
|
|
|
+ image_dir + "/" + os.path.basename(new_file_name)
|
|
|
):
|
|
):
|
|
|
shutil.copy(itemImg.image_path, image_dir + "/" + new_file_name)
|
|
shutil.copy(itemImg.image_path, image_dir + "/" + new_file_name)
|
|
|
dealImage = DealImage(image_dir)
|
|
dealImage = DealImage(image_dir)
|
|
@@ -184,8 +189,10 @@ 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:
|
|
|
|
|
- return_data_check_before_detail = run_main.check_before_detail(config_data)
|
|
|
|
|
|
|
+ if cutout_res:
|
|
|
|
|
+ return_data_check_before_detail = run_main.check_before_detail(
|
|
|
|
|
+ config_data
|
|
|
|
|
+ )
|
|
|
print(
|
|
print(
|
|
|
"return_data_check_before_detail======> 测试 ==>",
|
|
"return_data_check_before_detail======> 测试 ==>",
|
|
|
return_data_check_before_detail,
|
|
return_data_check_before_detail,
|
|
@@ -215,13 +222,21 @@ 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("\\", "/")
|
|
|
|
|
|
|
+ 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": goods_art_no, "success": True, "info": "处理成功"})
|
|
|
|
|
|
|
+ handler_result.append(
|
|
|
|
|
+ {"goods_art_no": goods_art_no, "success": True, "info": "处理成功"}
|
|
|
|
|
+ )
|
|
|
else:
|
|
else:
|
|
|
- handler_result.append({"goods_art_no": goods_art_no, "success": False, "info": "处理失败"})
|
|
|
|
|
|
|
+ handler_result.append(
|
|
|
|
|
+ {"goods_art_no": goods_art_no, "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)})
|
|
|
|
|
|
|
+ handler_result.append(
|
|
|
|
|
+ {"goods_art_no": goods_art_no, "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 {
|
|
|
"code": 0,
|
|
"code": 0,
|
|
@@ -230,19 +245,43 @@ def fromExcelHandler(params: HandlerDetail):
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+def group_by_style_number(data):
|
|
|
|
|
+ result = {}
|
|
|
|
|
+ for goods_id, info in data.items():
|
|
|
|
|
+ style_number = info["款号"]
|
|
|
|
|
+
|
|
|
|
|
+ if style_number not in result:
|
|
|
|
|
+ result[style_number] = []
|
|
|
|
|
+ result[style_number].append(goods_id)
|
|
|
|
|
+
|
|
|
|
|
+ return result
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
@app.post("/handle_detail")
|
|
@app.post("/handle_detail")
|
|
|
async def handle_detail(request: Request, params: HandlerDetail):
|
|
async def handle_detail(request: Request, params: HandlerDetail):
|
|
|
|
|
+ obj = None
|
|
|
|
|
+ token = "Bearer " + params.token
|
|
|
|
|
+ run_main = RunMain(obj, token)
|
|
|
goods_art_no_array = params.goods_art_no
|
|
goods_art_no_array = 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)
|
|
|
|
|
+ path = ""
|
|
|
for goods_art_no in goods_art_no_array:
|
|
for goods_art_no in goods_art_no_array:
|
|
|
try:
|
|
try:
|
|
|
if not goods_art_no:
|
|
if not goods_art_no:
|
|
|
raise UnicornException("货号不能为空")
|
|
raise UnicornException("货号不能为空")
|
|
|
- token = "Bearer " + params.token
|
|
|
|
|
session = SqlQuery()
|
|
session = SqlQuery()
|
|
|
pr = CRUD(PhotoRecord)
|
|
pr = CRUD(PhotoRecord)
|
|
|
images = pr.read_all(session, conditions={"goods_art_no": goods_art_no})
|
|
images = pr.read_all(session, conditions={"goods_art_no": goods_art_no})
|
|
@@ -253,8 +292,8 @@ async def handle_detail(request: Request, params: HandlerDetail):
|
|
|
image_counts = len(images)
|
|
image_counts = len(images)
|
|
|
if image_counts < detail_counts:
|
|
if image_counts < detail_counts:
|
|
|
raise UnicornException(
|
|
raise UnicornException(
|
|
|
- f"货号:[{goods_art_no}],实际照片数量:{image_counts}张,小于详情图要求数量:{detail_counts}张"
|
|
|
|
|
- )
|
|
|
|
|
|
|
+ f"货号:[{goods_art_no}],实际照片数量:{image_counts}张,小于详情图要求数量:{detail_counts}张"
|
|
|
|
|
+ )
|
|
|
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:
|
|
@@ -263,16 +302,16 @@ async def handle_detail(request: Request, params: HandlerDetail):
|
|
|
f"货号【{goods_art_no}】存在没有拍摄完成的图片,请重拍或删除后重试"
|
|
f"货号【{goods_art_no}】存在没有拍摄完成的图片,请重拍或删除后重试"
|
|
|
)
|
|
)
|
|
|
new_file_name = (
|
|
new_file_name = (
|
|
|
- str(itemImg.goods_art_no) + "_" + str(itemImg.id) + ".jpg"
|
|
|
|
|
|
|
+ str(itemImg.goods_art_no) + "_" + str(itemImg.id) + ".jpg"
|
|
|
)
|
|
)
|
|
|
if not os.path.exists(
|
|
if not os.path.exists(
|
|
|
- image_dir + "/" + os.path.basename(new_file_name)
|
|
|
|
|
|
|
+ image_dir + "/" + os.path.basename(new_file_name)
|
|
|
):
|
|
):
|
|
|
shutil.copy(itemImg.image_path, image_dir + "/" + new_file_name)
|
|
shutil.copy(itemImg.image_path, image_dir + "/" + new_file_name)
|
|
|
dealImage = DealImage(image_dir)
|
|
dealImage = DealImage(image_dir)
|
|
|
resFlag, path = dealImage.dealMoveImage(
|
|
resFlag, path = dealImage.dealMoveImage(
|
|
|
- image_dir=image_dir, callback_func=None, goods_art_no=goods_art_no
|
|
|
|
|
- )
|
|
|
|
|
|
|
+ image_dir=image_dir, callback_func=None, goods_art_no=goods_art_no
|
|
|
|
|
+ )
|
|
|
if not resFlag:
|
|
if not resFlag:
|
|
|
raise UnicornException(path)
|
|
raise UnicornException(path)
|
|
|
temp_class = {}
|
|
temp_class = {}
|
|
@@ -285,11 +324,13 @@ async def handle_detail(request: Request, params: HandlerDetail):
|
|
|
"image_order": (
|
|
"image_order": (
|
|
|
"俯视,侧视,后跟,鞋底,内里"
|
|
"俯视,侧视,后跟,鞋底,内里"
|
|
|
if params.template_image_order == None
|
|
if params.template_image_order == None
|
|
|
- or params.template_image_order == ""
|
|
|
|
|
|
|
+ or params.template_image_order == ""
|
|
|
else params.template_image_order
|
|
else params.template_image_order
|
|
|
),
|
|
),
|
|
|
"goods_art_no": goods_art_no,
|
|
"goods_art_no": goods_art_no,
|
|
|
- "goods_art_nos": [goods_art_no],
|
|
|
|
|
|
|
+ "goods_art_nos": (
|
|
|
|
|
+ goods_art_nos if len(goods_art_nos) > 0 else [goods_art_no]
|
|
|
|
|
+ ),
|
|
|
"is_check_number": False,
|
|
"is_check_number": False,
|
|
|
"resize_image_view": "后跟",
|
|
"resize_image_view": "后跟",
|
|
|
"cutout_mode": settings.CUTOUT_MODE,
|
|
"cutout_mode": settings.CUTOUT_MODE,
|
|
@@ -303,7 +344,7 @@ async def handle_detail(request: Request, params: HandlerDetail):
|
|
|
"cutout_is_pass": True,
|
|
"cutout_is_pass": True,
|
|
|
"assigned_page_dict": {},
|
|
"assigned_page_dict": {},
|
|
|
"detail_is_pass": True,
|
|
"detail_is_pass": True,
|
|
|
- "upload_is_pass": True,
|
|
|
|
|
|
|
+ "upload_is_pass": False,
|
|
|
"upload_is_enable": True,
|
|
"upload_is_enable": True,
|
|
|
"is_filter": False,
|
|
"is_filter": False,
|
|
|
"temp_class": temp_class,
|
|
"temp_class": temp_class,
|
|
@@ -321,12 +362,10 @@ async def handle_detail(request: Request, params: HandlerDetail):
|
|
|
temp_class_dict[key] = cls
|
|
temp_class_dict[key] = cls
|
|
|
|
|
|
|
|
config_data["temp_class"] = temp_class_dict
|
|
config_data["temp_class"] = temp_class_dict
|
|
|
- obj = None
|
|
|
|
|
- run_main = RunMain(obj, token)
|
|
|
|
|
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 is_only_cutout == 1 and cutout_res == True:
|
|
|
|
|
|
|
+ if cutout_res == True:
|
|
|
out_put_dir = return_data["data"]["image_dir"] + "/" + goods_art_no
|
|
out_put_dir = return_data["data"]["image_dir"] + "/" + goods_art_no
|
|
|
out_put_dir_path = "{}/{}".format(os.getcwd(), out_put_dir).replace(
|
|
out_put_dir_path = "{}/{}".format(os.getcwd(), out_put_dir).replace(
|
|
|
"\\", "/"
|
|
"\\", "/"
|
|
@@ -334,19 +373,73 @@ async def handle_detail(request: Request, params: HandlerDetail):
|
|
|
# print("out_put_dir_path", out_put_dir_path)
|
|
# print("out_put_dir_path", out_put_dir_path)
|
|
|
handler_result_folder = os.path.dirname(out_put_dir_path)
|
|
handler_result_folder = os.path.dirname(out_put_dir_path)
|
|
|
handler_result.append(
|
|
handler_result.append(
|
|
|
- {"goods_art_no": goods_art_no, "success": True, "info": "处理成功"}
|
|
|
|
|
- )
|
|
|
|
|
|
|
+ {"goods_art_no": goods_art_no, "success": True, "info": "处理成功"}
|
|
|
|
|
+ )
|
|
|
# print("检测到需要裁剪图片,开始裁剪图片", return_data)
|
|
# print("检测到需要裁剪图片,开始裁剪图片", return_data)
|
|
|
- continue
|
|
|
|
|
- if cutout_res == True:
|
|
|
|
|
- return_data_check_before_detail = run_main.check_before_detail(config_data)
|
|
|
|
|
- print(
|
|
|
|
|
- "return_data_check_before_detail======> 测试 ==>",
|
|
|
|
|
- return_data_check_before_detail,
|
|
|
|
|
- )
|
|
|
|
|
- check_for_detail_first_res = run_main.check_for_detail_first_call_back(
|
|
|
|
|
- return_data_check_before_detail
|
|
|
|
|
- )
|
|
|
|
|
|
|
+ except Exception as e:
|
|
|
|
|
+ handler_result.append(
|
|
|
|
|
+ {"goods_art_no": goods_art_no, "success": False, "info": str(e)}
|
|
|
|
|
+ )
|
|
|
|
|
+ if is_only_cutout == 1:
|
|
|
|
|
+ return {
|
|
|
|
|
+ "code": 0,
|
|
|
|
|
+ "msg": "",
|
|
|
|
|
+ "data": {"output_folder": handler_result_folder, "list": handler_result},
|
|
|
|
|
+ }
|
|
|
|
|
+ handler_result = []
|
|
|
|
|
+ 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):
|
|
if isinstance(check_for_detail_first_res, partial):
|
|
|
result = check_for_detail_first_res()
|
|
result = check_for_detail_first_res()
|
|
|
try:
|
|
try:
|
|
@@ -362,20 +455,28 @@ async def handle_detail(request: Request, params: HandlerDetail):
|
|
|
print("to_deal_dir", to_deal_dir)
|
|
print("to_deal_dir", to_deal_dir)
|
|
|
if os.path.exists(to_deal_dir):
|
|
if os.path.exists(to_deal_dir):
|
|
|
upload_pic = UploadPic(
|
|
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()
|
|
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("\\", "/")
|
|
|
|
|
|
|
+ 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": goods_art_no, "success": True, "info": "处理成功"})
|
|
|
|
|
|
|
+ handler_result.append(
|
|
|
|
|
+ {"goods_art_no": "", "success": True, "info": "处理成功"}
|
|
|
|
|
+ )
|
|
|
else:
|
|
else:
|
|
|
- handler_result.append({"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)})
|
|
|
|
|
|
|
+ handler_result.append(
|
|
|
|
|
+ {"goods_art_no": "", "success": False, "info": "处理失败"}
|
|
|
|
|
+ )
|
|
|
|
|
+ except Exception as e:
|
|
|
|
|
+ handler_result.append(
|
|
|
|
|
+ {"goods_art_no": "", "success": False, "info": str(e)}
|
|
|
|
|
+ )
|
|
|
return {
|
|
return {
|
|
|
"code": 0,
|
|
"code": 0,
|
|
|
"msg": "",
|
|
"msg": "",
|
|
@@ -384,11 +485,12 @@ async def handle_detail(request: Request, params: HandlerDetail):
|
|
|
|
|
|
|
|
|
|
|
|
|
@app.get("/get_device_tabs", description="获取可执行程序命令列表")
|
|
@app.get("/get_device_tabs", description="获取可执行程序命令列表")
|
|
|
-def get_device_tabs(type:int):
|
|
|
|
|
|
|
+def get_device_tabs(type: int):
|
|
|
session = SqlQuery()
|
|
session = SqlQuery()
|
|
|
statement = (
|
|
statement = (
|
|
|
select(DeviceConfigTabs)
|
|
select(DeviceConfigTabs)
|
|
|
- .where(DeviceConfigTabs.mode_type == type).order_by(asc("id"))
|
|
|
|
|
|
|
+ .where(DeviceConfigTabs.mode_type == type)
|
|
|
|
|
+ .order_by(asc("id"))
|
|
|
)
|
|
)
|
|
|
result = session.exec(statement).all()
|
|
result = session.exec(statement).all()
|
|
|
session.close()
|
|
session.close()
|
|
@@ -461,9 +563,7 @@ def device_config_detail_query():
|
|
|
session, conditions={"tab_id": left_config, "action_name": "侧视"}
|
|
session, conditions={"tab_id": left_config, "action_name": "侧视"}
|
|
|
)
|
|
)
|
|
|
if model == None:
|
|
if model == None:
|
|
|
- model = configModel.read(
|
|
|
|
|
- session, conditions={"tab_id": left_config}
|
|
|
|
|
- )
|
|
|
|
|
|
|
+ model = configModel.read(session, conditions={"tab_id": left_config})
|
|
|
return {"code": 0, "msg": "", "data": model}
|
|
return {"code": 0, "msg": "", "data": model}
|
|
|
|
|
|
|
|
|
|
|
|
@@ -527,7 +627,6 @@ def reset_config(params: ModelGetDeviceConfig):
|
|
|
|
|
|
|
|
@app.get("/get_photo_records", description="获取拍照记录")
|
|
@app.get("/get_photo_records", description="获取拍照记录")
|
|
|
def get_photo_records(page: int = 1, size: int = 5):
|
|
def get_photo_records(page: int = 1, size: int = 5):
|
|
|
-
|
|
|
|
|
session = SqlQuery()
|
|
session = SqlQuery()
|
|
|
photos = CRUD(PhotoRecord)
|
|
photos = CRUD(PhotoRecord)
|
|
|
print("准备查询拍摄记录", datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"))
|
|
print("准备查询拍摄记录", datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"))
|
|
@@ -580,9 +679,12 @@ def get_photo_records(page: int = 1, size: int = 5):
|
|
|
|
|
|
|
|
@app.get("/get_last_photo_record", description="获取最后一条拍照记录")
|
|
@app.get("/get_last_photo_record", description="获取最后一条拍照记录")
|
|
|
def get_last_photo_record():
|
|
def get_last_photo_record():
|
|
|
-
|
|
|
|
|
session = SqlQuery()
|
|
session = SqlQuery()
|
|
|
- statement = select(PhotoRecord).where(PhotoRecord.image_path != None).order_by(desc("photo_create_time"))
|
|
|
|
|
|
|
+ statement = (
|
|
|
|
|
+ select(PhotoRecord)
|
|
|
|
|
+ .where(PhotoRecord.image_path != None)
|
|
|
|
|
+ .order_by(desc("photo_create_time"))
|
|
|
|
|
+ )
|
|
|
result = session.exec(statement).first()
|
|
result = session.exec(statement).first()
|
|
|
session.close()
|
|
session.close()
|
|
|
return {
|
|
return {
|
|
@@ -609,7 +711,6 @@ def get_photo_records(goods_art_no: str = None):
|
|
|
|
|
|
|
|
@app.post("/delect_goods_arts", description="通过货号删除记录")
|
|
@app.post("/delect_goods_arts", description="通过货号删除记录")
|
|
|
def delect_goods_arts(params: PhotoRecordDelete):
|
|
def delect_goods_arts(params: PhotoRecordDelete):
|
|
|
-
|
|
|
|
|
session = SqlQuery()
|
|
session = SqlQuery()
|
|
|
photos = CRUD(PhotoRecord)
|
|
photos = CRUD(PhotoRecord)
|
|
|
for item in params.goods_art_nos:
|
|
for item in params.goods_art_nos:
|
|
@@ -665,7 +766,9 @@ def save_sys_configs(params: SysConfigParams):
|
|
|
return {"code": 1, "msg": "配置不存在", "data": None}
|
|
return {"code": 1, "msg": "配置不存在", "data": None}
|
|
|
# 走编辑逻辑
|
|
# 走编辑逻辑
|
|
|
kwargs = params.__dict__
|
|
kwargs = params.__dict__
|
|
|
- save_device_config = sysConfig.updateConditions(session, conditions={"key": params.key}, **kwargs)
|
|
|
|
|
|
|
+ save_device_config = sysConfig.updateConditions(
|
|
|
|
|
+ session, conditions={"key": params.key}, **kwargs
|
|
|
|
|
+ )
|
|
|
return {"code": 0, "msg": "操作成功", "data": save_device_config}
|
|
return {"code": 0, "msg": "操作成功", "data": save_device_config}
|
|
|
|
|
|
|
|
|
|
|
|
@@ -736,6 +839,7 @@ def add_logo(params: LogoParams):
|
|
|
"data": {"logo": logo_path_info},
|
|
"data": {"logo": logo_path_info},
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+
|
|
|
@app.post("/delete_logo", description="删除logo")
|
|
@app.post("/delete_logo", description="删除logo")
|
|
|
def delete_logo(params: LogoParamsupdate):
|
|
def delete_logo(params: LogoParamsupdate):
|
|
|
logo_path = params.path
|
|
logo_path = params.path
|
|
@@ -754,13 +858,15 @@ def delete_logo(params: LogoParamsupdate):
|
|
|
@app.post("/close_other_window", description="关闭窗口")
|
|
@app.post("/close_other_window", description="关闭窗口")
|
|
|
def close_other_window():
|
|
def close_other_window():
|
|
|
hwnd_list = []
|
|
hwnd_list = []
|
|
|
|
|
+
|
|
|
def callback(hwnd, _):
|
|
def callback(hwnd, _):
|
|
|
title = GetWindowText(hwnd)
|
|
title = GetWindowText(hwnd)
|
|
|
if title == "digiCamControl by Duka Istvan":
|
|
if title == "digiCamControl by Duka Istvan":
|
|
|
hwnd_list.append(hwnd)
|
|
hwnd_list.append(hwnd)
|
|
|
|
|
+
|
|
|
EnumWindows(callback, None)
|
|
EnumWindows(callback, None)
|
|
|
if hwnd_list:
|
|
if hwnd_list:
|
|
|
hwnd = hwnd_list[0]
|
|
hwnd = hwnd_list[0]
|
|
|
win32gui.PostMessage(hwnd, win32con.WM_CLOSE, 0, 0)
|
|
win32gui.PostMessage(hwnd, win32con.WM_CLOSE, 0, 0)
|
|
|
- return {"code": 0, "msg": "关闭成功", "data": {"status":True}}
|
|
|
|
|
|
|
+ return {"code": 0, "msg": "关闭成功", "data": {"status": True}}
|
|
|
return {"code": 0, "msg": "关闭失败", "data": {"status": False}}
|
|
return {"code": 0, "msg": "关闭失败", "data": {"status": False}}
|