抓取生产工单,抓取发料异常
This commit is contained in:
@@ -489,11 +489,34 @@ def sync_abnormal_report():
|
||||
try:
|
||||
import auto_fetch_abnormal_report
|
||||
page = auto_fetch_abnormal_report.get_page(port=9222)
|
||||
success = auto_fetch_abnormal_report.navigate_to_report(page)
|
||||
if success:
|
||||
auto_fetch_abnormal_report.fetch_report_data(page)
|
||||
|
||||
# 自动重试机制
|
||||
while True:
|
||||
try:
|
||||
success = auto_fetch_abnormal_report.navigate_to_report(page)
|
||||
if success:
|
||||
result = auto_fetch_abnormal_report.fetch_report_data(page)
|
||||
# 如果返回 False,说明被踢回首页或发生中断,需要重试
|
||||
if result is False:
|
||||
print("♻️ 检测到页面被系统踢回首页或中断,正在为您自动重新导航并恢复抓取...")
|
||||
import time
|
||||
time.sleep(3)
|
||||
continue
|
||||
else:
|
||||
break
|
||||
else:
|
||||
print("❌ 导航进入报表失败,尝试重新导航...")
|
||||
import time
|
||||
time.sleep(3)
|
||||
continue
|
||||
except Exception as inner_e:
|
||||
print(f"⚠️ 抓取循环中发生异常: {inner_e},尝试重新恢复...")
|
||||
import time
|
||||
time.sleep(3)
|
||||
continue
|
||||
|
||||
except Exception as e:
|
||||
print(f"手动发料异常报表抓取失败: {e}")
|
||||
print(f"❌ 手动发料异常报表抓取严重失败: {e}")
|
||||
finally:
|
||||
release_browser()
|
||||
|
||||
@@ -1207,15 +1230,17 @@ if __name__ == '__main__':
|
||||
|
||||
# 启动前开启一个线程去拉起浏览器
|
||||
threading.Thread(target=open_browser, args=(port,), daemon=True).start()
|
||||
print(f"🚀 前端展示后端服务已启动!请在浏览器访问: http://127.0.0.1:{port}")
|
||||
print("🚀 前端展示后端服务已启动!")
|
||||
print(f"👉 本机访问地址: http://127.0.0.1:{port}")
|
||||
print(f"👉 局域网访问地址: http://192.168.7.198:{port} (允许手机/其他电脑访问)")
|
||||
else:
|
||||
# 如果是热加载的主控进程,随便给个默认端口(反正它不干活),并且不打开浏览器
|
||||
port = 5050
|
||||
|
||||
# 更改为动态端口,避开被占用的端口。修改 host 为 127.0.0.1 避免 Windows 权限拦截
|
||||
# 更改为动态端口,避开被占用的端口。修改 host 为 0.0.0.0 允许局域网访问
|
||||
app.run(
|
||||
debug=not is_frozen,
|
||||
host='127.0.0.1',
|
||||
host='0.0.0.0',
|
||||
port=port,
|
||||
threaded=True,
|
||||
use_reloader=False # 彻底关闭 Flask 内置的热加载,避免双进程互相影响
|
||||
|
||||
Reference in New Issue
Block a user