|
|
@@ -49,13 +49,6 @@ async def index():
|
|
|
return {"message": "Hello World"}
|
|
|
|
|
|
|
|
|
-@app.get("/send_test")
|
|
|
-async def index():
|
|
|
- data = {"data1": 1, "data2": 2, "data3": 3, "data4": 4}
|
|
|
- await socket_manager.send_message(msg="测试", data=data)
|
|
|
- return {"message": "Hello World"}
|
|
|
-
|
|
|
-
|
|
|
@app.get("/scan_serials", description="扫描可用的设备端口")
|
|
|
async def scanSerials():
|
|
|
"""扫描串口"""
|
|
|
@@ -64,44 +57,6 @@ async def scanSerials():
|
|
|
return {"message": "Hello World"}
|
|
|
|
|
|
|
|
|
-@app.get("/test_conndevice")
|
|
|
-def test_conndevice():
|
|
|
- device_control = DeviceControl()
|
|
|
- p_list = []
|
|
|
- temp_ports_dict = {}
|
|
|
- # while 1:
|
|
|
- time.sleep(1)
|
|
|
- ports_dict = device_control.scan_serial_port()
|
|
|
- temp_ports_dict = ports_dict
|
|
|
-
|
|
|
- if not ports_dict:
|
|
|
- # 全部清空 移除所有串口
|
|
|
- if p_list:
|
|
|
- _p = p_list.pop()
|
|
|
- device_control.remove_port(_p)
|
|
|
- # continue
|
|
|
-
|
|
|
- if ports_dict:
|
|
|
- # print(plist)
|
|
|
- for index, _i in enumerate(p_list):
|
|
|
- if _i not in ports_dict:
|
|
|
- _p = p_list.pop(index)
|
|
|
- device_control.remove_port(_p)
|
|
|
-
|
|
|
- for _port_name, _port_value in ports_dict.items():
|
|
|
- if _port_name not in p_list:
|
|
|
- try:
|
|
|
- p_list.append(_port_name)
|
|
|
- device_control.add_port_by_linkage(_port_name)
|
|
|
- except BaseException as e:
|
|
|
- print(e.__traceback__.tb_frame.f_globals["__file__"]) # 发生异常所在的文件
|
|
|
- print(e.__traceback__.tb_lineno) # 发生异常所在的行数
|
|
|
- print("串口不存在{} {}".format(_port_name, e))
|
|
|
-
|
|
|
- # threading.Thread(target=self.add_port, args=(_port_name, _port_value)).start()
|
|
|
- # self.add_port(_p)
|
|
|
-
|
|
|
-
|
|
|
@app.api_route("/forward_request", methods=["GET", "POST"], description="代理转发hlm项目得请求")
|
|
|
async def forwardRequest(request: HlmForwardRequest):
|
|
|
"""
|
|
|
@@ -264,6 +219,7 @@ def fromExcelHandler(params: HandlerDetail):
|
|
|
@app.post("/handle_detail")
|
|
|
async def handle_detail(request: Request, params: HandlerDetail):
|
|
|
goods_art_no_array = params.goods_art_no
|
|
|
+ is_only_cutout = params.is_only_cutout
|
|
|
handler_result = []
|
|
|
handler_result_folder = ""
|
|
|
if params.excel_path != "" and params.excel_path != None:
|
|
|
@@ -337,6 +293,18 @@ async def handle_detail(request: Request, params: HandlerDetail):
|
|
|
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 is_only_cutout == 1 and 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 = out_put_dir_path
|
|
|
+ handler_result.append(
|
|
|
+ {"goods_art_no": goods_art_no, "success": True, "info": "处理成功"}
|
|
|
+ )
|
|
|
+ # print("检测到需要裁剪图片,开始裁剪图片", return_data)
|
|
|
+ continue
|
|
|
if cutout_res == True:
|
|
|
return_data_check_before_detail = run_main.check_before_detail(config_data)
|
|
|
print(
|