增加http接口禁止代理
This commit is contained in:
parent
eb86c4c0f9
commit
09c7702eb7
Binary file not shown.
@ -72,9 +72,9 @@ TF_API_TOKEN = os.getenv("TF_API_TOKEN", "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.e
|
||||
TF_WEB_POST = os.getenv("TF_WEB_POST", "false").lower() == "true" # 是否过账,从环境变量读取
|
||||
sync_disabled_label = "sync_disabled" # 是否限制接口调用的变量名
|
||||
# 外部接口叫料模板id
|
||||
CM_ID = "571985c1-cfa5-4186-8acd-6e3868a5e08c"
|
||||
CM_ID = os.getenv("CM_ID", "571985c1-cfa5-4186-8acd-6e3868a5e08c")
|
||||
# 送货模板id
|
||||
DG_ID = "e22cacb4-a580-45ba-949e-356f57fa1a43"
|
||||
DG_ID = os.getenv("DG_ID", "e22cacb4-a580-45ba-949e-356f57fa1a43")
|
||||
def get_tf_api_config() -> Dict[str, Any]:
|
||||
"""获取天风系统API配置"""
|
||||
return {
|
||||
|
8088
logs/app.log
8088
logs/app.log
File diff suppressed because it is too large
Load Diff
6709
logs/app.log.2025-10-13
Normal file
6709
logs/app.log.2025-10-13
Normal file
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -13334,7 +13334,6 @@ imported by:
|
||||
• <a href="#services.calldevice_service">services.calldevice_service</a>
|
||||
• <a href="#services.execution.handlers.task">services.execution.handlers.task</a>
|
||||
• <a href="#services.sync_service">services.sync_service</a>
|
||||
• <a href="#services.task_edit_service">services.task_edit_service</a>
|
||||
• <a href="#utils.alert_sync">utils.alert_sync</a>
|
||||
|
||||
</div>
|
||||
@ -22647,6 +22646,7 @@ imports:
|
||||
• <a href="#importlib">importlib</a>
|
||||
• <a href="#importlib._bootstrap">importlib._bootstrap</a>
|
||||
• <a href="#importlib._bootstrap_external">importlib._bootstrap_external</a>
|
||||
• <a href="#importlib.machinery">importlib.machinery</a>
|
||||
• <a href="#sys">sys</a>
|
||||
• <a href="#warnings">warnings</a>
|
||||
|
||||
@ -22817,6 +22817,7 @@ imported by:
|
||||
• <a href="#cffi._imp_emulation">cffi._imp_emulation</a>
|
||||
• <a href="#cffi.verifier">cffi.verifier</a>
|
||||
• <a href="#ctypes.util">ctypes.util</a>
|
||||
• <a href="#importlib">importlib</a>
|
||||
• <a href="#importlib.abc">importlib.abc</a>
|
||||
• <a href="#inspect">inspect</a>
|
||||
• <a href="#packaging.tags">packaging.tags</a>
|
||||
@ -51101,8 +51102,7 @@ imported by:
|
||||
<a target="code" href="///D:/jsw_code/project/VWED_phase1/VWED_server/services/task_edit_service.py" type="text/plain"><tt>services.task_edit_service</tt></a>
|
||||
<span class="moduletype">SourceModule</span> <div class="import">
|
||||
imports:
|
||||
<a href="#config.tf_api_config">config.tf_api_config</a>
|
||||
• <a href="#data.enum.task_def_enum">data.enum.task_def_enum</a>
|
||||
<a href="#data.enum.task_def_enum">data.enum.task_def_enum</a>
|
||||
• <a href="#data.enum.task_record_enum">data.enum.task_record_enum</a>
|
||||
• <a href="#data.models">data.models</a>
|
||||
• <a href="#data.models.operate_point_layer">data.models.operate_point_layer</a>
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
packaging/dist/VWED_Task_System.exe
vendored
BIN
packaging/dist/VWED_Task_System.exe
vendored
Binary file not shown.
BIN
packaging/dist/VWED_Task_System_Debug.exe
vendored
BIN
packaging/dist/VWED_Task_System_Debug.exe
vendored
Binary file not shown.
@ -1,7 +1,7 @@
|
||||
2025-10-13 15:27:26,675 - services.enhanced_scheduler.task_scheduler - INFO - 加载任务调度器配置: 工作线程数=100-150, 队列数=3, 任务超时=3600秒
|
||||
2025-10-13 15:27:26,675 - services.enhanced_scheduler.priority_queue_manager - INFO - 初始化优先级队列管理器: 队列数=3, 阈值百分比=[0.1, 0.3, 1.0], 工作线程比例=[0.6, 0.3, 0.1]
|
||||
2025-10-13 15:27:26,675 - services.enhanced_scheduler.worker_manager - INFO - 初始化工作线程管理器: min=100, max=150, 心跳间隔=1200秒, 自动扩缩容间隔=120秒
|
||||
2025-10-13 15:27:26,676 - services.enhanced_scheduler.task_persistence - INFO - 初始化任务持久化管理器: 间隔=300秒, 目录=D:\jsw_code\project\VWED_phase1\VWED_server\data\task_backups, 最大备份数=5
|
||||
2025-10-13 15:27:26,676 - services.enhanced_scheduler.periodic_task_manager - INFO - 初始化定时任务管理器: 检查间隔=5秒
|
||||
2025-10-13 15:27:26,676 - services.enhanced_scheduler.task_scheduler - INFO - 增强版任务调度器初始化完成
|
||||
2025-10-13 15:27:26,736 - utils.component_manager - INFO - 已加载 8 个组件分类,共 52 个组件类型
|
||||
2025-10-16 10:17:04,877 - services.enhanced_scheduler.task_scheduler - INFO - 加载任务调度器配置: 工作线程数=100-150, 队列数=3, 任务超时=3600秒
|
||||
2025-10-16 10:17:04,878 - services.enhanced_scheduler.priority_queue_manager - INFO - 初始化优先级队列管理器: 队列数=3, 阈值百分比=[0.1, 0.3, 1.0], 工作线程比例=[0.6, 0.3, 0.1]
|
||||
2025-10-16 10:17:04,878 - services.enhanced_scheduler.worker_manager - INFO - 初始化工作线程管理器: min=100, max=150, 心跳间隔=1200秒, 自动扩缩容间隔=120秒
|
||||
2025-10-16 10:17:04,878 - services.enhanced_scheduler.task_persistence - INFO - 初始化任务持久化管理器: 间隔=300秒, 目录=D:\jsw_code\project\VWED_phase1\VWED_server\data\task_backups, 最大备份数=5
|
||||
2025-10-16 10:17:04,879 - services.enhanced_scheduler.periodic_task_manager - INFO - 初始化定时任务管理器: 检查间隔=5秒
|
||||
2025-10-16 10:17:04,879 - services.enhanced_scheduler.task_scheduler - INFO - 增强版任务调度器初始化完成
|
||||
2025-10-16 10:17:04,962 - utils.component_manager - INFO - 已加载 8 个组件分类,共 52 个组件类型
|
||||
|
Binary file not shown.
Binary file not shown.
BIN
services/__pycache__/calldevice_service.cpython-313.pyc
Normal file
BIN
services/__pycache__/calldevice_service.cpython-313.pyc
Normal file
Binary file not shown.
Binary file not shown.
BIN
services/__pycache__/sync_service.cpython-313.pyc
Normal file
BIN
services/__pycache__/sync_service.cpython-313.pyc
Normal file
Binary file not shown.
Binary file not shown.
BIN
services/__pycache__/task_edit_service.cpython-313.pyc
Normal file
BIN
services/__pycache__/task_edit_service.cpython-313.pyc
Normal file
Binary file not shown.
@ -1941,7 +1941,9 @@ class CallDeviceService:
|
||||
}
|
||||
|
||||
try:
|
||||
response = requests.post(url, json=reset_request, headers=headers)
|
||||
# 禁用代理,确保直接连接到目标地址
|
||||
proxies = {'http': None, 'https': None}
|
||||
response = requests.post(url, json=reset_request, headers=headers, proxies=proxies)
|
||||
response_text = response.text
|
||||
logger.info(f"复位按钮状态响应: {response_text}")
|
||||
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -103,7 +103,8 @@ class HttpGetBlockHandler(BlockHandler):
|
||||
|
||||
while attempt < max_attempts:
|
||||
try:
|
||||
async with aiohttp.ClientSession() as session:
|
||||
# 禁用代理环境变量,避免被Squid等代理拦截
|
||||
async with aiohttp.ClientSession(trust_env=False) as session:
|
||||
async with session.get(url, headers=headers) as response:
|
||||
# 读取响应内容
|
||||
response_text = await response.text()
|
||||
@ -257,7 +258,8 @@ class HttpPostBlockHandler(BlockHandler):
|
||||
|
||||
while attempt < max_attempts:
|
||||
try:
|
||||
async with aiohttp.ClientSession() as session:
|
||||
# 禁用代理环境变量,避免被Squid等代理拦截
|
||||
async with aiohttp.ClientSession(trust_env=False) as session:
|
||||
async with session.post(url, json=data, headers=headers) as response:
|
||||
# 读取响应内容
|
||||
response_text = await response.text()
|
||||
|
@ -62,7 +62,8 @@ async def call_robot_api(api_name: str, params: Dict[str, Any]) -> Dict[str, Any
|
||||
logger.debug(f"调用外部API {api_name} - {method} {url}, 参数: {params}")
|
||||
|
||||
try:
|
||||
async with aiohttp.ClientSession() as session:
|
||||
# 禁用代理环境变量,避免被Squid等代理拦截
|
||||
async with aiohttp.ClientSession(trust_env=False) as session:
|
||||
# 根据HTTP方法选择相应的请求方式
|
||||
if method == "GET":
|
||||
# 对于GET请求,将params转换为URL参数
|
||||
|
@ -24,6 +24,8 @@ from config.tf_api_config import get_tf_api_config
|
||||
# 获取配置
|
||||
tf_config = get_tf_api_config()
|
||||
|
||||
# 注意: 在aiohttp 3.x版本中,trust_env参数应该传递给ClientSession而不是TCPConnector
|
||||
|
||||
# 接口配置
|
||||
class TFApiConfig:
|
||||
"""系统任务API配置"""
|
||||
@ -144,7 +146,8 @@ async def create_task(task_record_id: str, task_name: str, is_periodic: bool, pr
|
||||
logger.debug(f"创建任务请求参数: {request_data.model_dump_json()}")
|
||||
# 优化超时配置,分别设置连接超时和总超时
|
||||
timeout = aiohttp.ClientTimeout(total=TFApiConfig.TIMEOUT, connect=5)
|
||||
async with aiohttp.ClientSession(timeout=timeout) as session:
|
||||
# 禁用代理环境变量,避免被Squid等代理拦截
|
||||
async with aiohttp.ClientSession(timeout=timeout, trust_env=False) as session:
|
||||
async with session.post(
|
||||
url,
|
||||
json=request_data.model_dump(),
|
||||
@ -205,9 +208,9 @@ async def create_choose_amr_task(task_id: str, key_station_name: str, amr_name:
|
||||
|
||||
try:
|
||||
logger.info(f"正在创建选择AMR任务: {task_id}, 站点: {key_station_name}")
|
||||
|
||||
|
||||
timeout = aiohttp.ClientTimeout(total=TFApiConfig.TIMEOUT, connect=5)
|
||||
async with aiohttp.ClientSession(timeout=timeout) as session:
|
||||
async with aiohttp.ClientSession(timeout=timeout, trust_env=False) as session:
|
||||
async with session.post(
|
||||
url,
|
||||
json=request_data.model_dump(),
|
||||
@ -264,9 +267,9 @@ async def add_action(task_id: str, station_name: str, action: str, token: str =
|
||||
|
||||
try:
|
||||
logger.info(f"正在为任务添加动作: {task_id}, 站点: {station_name}, 动作: {action}")
|
||||
|
||||
|
||||
timeout = aiohttp.ClientTimeout(total=TFApiConfig.TIMEOUT, connect=5)
|
||||
async with aiohttp.ClientSession(timeout=timeout) as session:
|
||||
async with aiohttp.ClientSession(timeout=timeout, trust_env=False) as session:
|
||||
async with session.post(
|
||||
url,
|
||||
json=request_data.model_dump(),
|
||||
@ -312,9 +315,9 @@ async def closure_task(task_id: str, token: str = None) -> Optional[ApiResponse]
|
||||
|
||||
try:
|
||||
logger.info(f"正在封口任务: {task_id}")
|
||||
|
||||
|
||||
timeout = aiohttp.ClientTimeout(total=TFApiConfig.TIMEOUT, connect=5)
|
||||
async with aiohttp.ClientSession(timeout=timeout) as session:
|
||||
async with aiohttp.ClientSession(timeout=timeout, trust_env=False) as session:
|
||||
async with session.put(
|
||||
url,
|
||||
headers=headers
|
||||
@ -357,9 +360,9 @@ async def get_task_block_detail(task_block_id: str, token: str = None) -> Option
|
||||
|
||||
try:
|
||||
logger.info(f"正在获取任务块详情: {task_block_id}")
|
||||
|
||||
|
||||
timeout = aiohttp.ClientTimeout(total=TFApiConfig.TIMEOUT, connect=5)
|
||||
async with aiohttp.ClientSession(timeout=timeout) as session:
|
||||
async with aiohttp.ClientSession(timeout=timeout, trust_env=False) as session:
|
||||
async with session.get(
|
||||
url,
|
||||
headers=headers
|
||||
@ -406,9 +409,9 @@ async def get_task_block_action_detail(task_block_id: str, token: str = None) ->
|
||||
|
||||
try:
|
||||
logger.info(f"正在获取任务块动作详情: {task_block_id}")
|
||||
|
||||
|
||||
timeout = aiohttp.ClientTimeout(total=TFApiConfig.TIMEOUT, connect=5)
|
||||
async with aiohttp.ClientSession(timeout=timeout) as session:
|
||||
async with aiohttp.ClientSession(timeout=timeout, trust_env=False) as session:
|
||||
async with session.get(
|
||||
url,
|
||||
headers=headers
|
||||
@ -587,9 +590,9 @@ async def set_task_in_progress(task_id: str, token: str = None) -> Optional[ApiR
|
||||
|
||||
try:
|
||||
logger.info(f"正在设置系统任务状态为执行中: {task_id}")
|
||||
|
||||
|
||||
timeout = aiohttp.ClientTimeout(total=TFApiConfig.TIMEOUT, connect=5)
|
||||
async with aiohttp.ClientSession(timeout=timeout) as session:
|
||||
async with aiohttp.ClientSession(timeout=timeout, trust_env=False) as session:
|
||||
async with session.put(
|
||||
url,
|
||||
headers=headers
|
||||
@ -634,7 +637,7 @@ async def set_task_completed(task_id: str, token: str = None) -> Optional[ApiRes
|
||||
try:
|
||||
logger.info(f"正在设置系统任务状态为已完成: {task_id}")
|
||||
timeout = aiohttp.ClientTimeout(total=TFApiConfig.TIMEOUT, connect=5)
|
||||
async with aiohttp.ClientSession(timeout=timeout) as session:
|
||||
async with aiohttp.ClientSession(timeout=timeout, trust_env=False) as session:
|
||||
async with session.put(
|
||||
url,
|
||||
headers=headers
|
||||
@ -677,9 +680,9 @@ async def set_task_terminated(task_id: str, token: str = None) -> Optional[ApiRe
|
||||
|
||||
try:
|
||||
logger.info(f"正在设置系统任务状态为已终止: {task_id}")
|
||||
|
||||
|
||||
timeout = aiohttp.ClientTimeout(total=TFApiConfig.TIMEOUT, connect=5)
|
||||
async with aiohttp.ClientSession(timeout=timeout) as session:
|
||||
async with aiohttp.ClientSession(timeout=timeout, trust_env=False) as session:
|
||||
async with session.put(
|
||||
url,
|
||||
headers=headers
|
||||
@ -721,9 +724,9 @@ async def set_task_failed(task_id: str, token: str = None) -> Optional[ApiRespon
|
||||
headers["x-tenant-id"] = "1000"
|
||||
try:
|
||||
logger.info(f"正在设置任务状态为已失败: {task_id}")
|
||||
|
||||
|
||||
timeout = aiohttp.ClientTimeout(total=TFApiConfig.TIMEOUT, connect=5)
|
||||
async with aiohttp.ClientSession(timeout=timeout) as session:
|
||||
async with aiohttp.ClientSession(timeout=timeout, trust_env=False) as session:
|
||||
async with session.put(
|
||||
url,
|
||||
headers=headers
|
||||
@ -771,9 +774,9 @@ async def set_task_description(task_id: str, description: str, token: str = None
|
||||
|
||||
try:
|
||||
logger.info(f"正在设置VWED任务描述: {task_id}, 描述: {description}")
|
||||
|
||||
|
||||
timeout = aiohttp.ClientTimeout(total=TFApiConfig.TIMEOUT, connect=5)
|
||||
async with aiohttp.ClientSession(timeout=timeout) as session:
|
||||
async with aiohttp.ClientSession(timeout=timeout, trust_env=False) as session:
|
||||
async with session.put(
|
||||
url,
|
||||
json=request_data,
|
||||
@ -820,9 +823,9 @@ async def get_amr_info(token: str = None) -> Optional[Dict[str, Any]]:
|
||||
|
||||
try:
|
||||
logger.info("正在获取AMR信息")
|
||||
|
||||
|
||||
timeout = aiohttp.ClientTimeout(total=TFApiConfig.TIMEOUT, connect=5)
|
||||
async with aiohttp.ClientSession(timeout=timeout) as session:
|
||||
async with aiohttp.ClientSession(timeout=timeout, trust_env=False) as session:
|
||||
async with session.get(
|
||||
url,
|
||||
headers=headers
|
||||
@ -889,9 +892,9 @@ async def get_login_token(username: str = "vwed", password: str = "vwed_123456")
|
||||
try:
|
||||
logger.info(f"正在获取登录token,用户: {username}")
|
||||
logger.debug(f"登录请求参数: {request_data.model_dump_json()}")
|
||||
|
||||
|
||||
timeout = aiohttp.ClientTimeout(total=TFApiConfig.TIMEOUT, connect=5)
|
||||
async with aiohttp.ClientSession(timeout=timeout) as session:
|
||||
async with aiohttp.ClientSession(timeout=timeout, trust_env=False) as session:
|
||||
async with session.post(
|
||||
url,
|
||||
json=request_data.model_dump(),
|
||||
@ -1005,12 +1008,19 @@ def get_login_token_sync(username: str = "vwed", password: str = "vwed_123456")
|
||||
try:
|
||||
logger.info(f"正在获取登录token,用户: {username}")
|
||||
logger.debug(f"登录请求参数: {request_data.model_dump_json()}")
|
||||
|
||||
|
||||
# 禁用代理,确保直接连接到目标地址
|
||||
proxies = {
|
||||
'http': None,
|
||||
'https': None
|
||||
}
|
||||
|
||||
response = requests.post(
|
||||
url,
|
||||
json=request_data.model_dump(),
|
||||
headers=headers,
|
||||
timeout=TFApiConfig.TIMEOUT
|
||||
timeout=TFApiConfig.TIMEOUT,
|
||||
proxies=proxies
|
||||
)
|
||||
|
||||
# 尝试解析JSON
|
||||
|
@ -615,17 +615,18 @@ class TaskEditService:
|
||||
# 导入内置函数管理模块
|
||||
from utils.built_in_functions import get_function_list
|
||||
from data.models.operate_point_layer import OperatePointLayer
|
||||
from services.sync_service import get_amr_info
|
||||
from config.tf_api_config import TF_API_TOKEN
|
||||
|
||||
from services.sync_service import get_amr_info, refresh_token_if_needed
|
||||
|
||||
# 获取所有内置函数
|
||||
built_in_functions = get_function_list()
|
||||
|
||||
|
||||
# 获取AMR信息
|
||||
robot_values = []
|
||||
robot_group_values = []
|
||||
try:
|
||||
amr_response = await get_amr_info(TF_API_TOKEN)
|
||||
# 获取或刷新token
|
||||
token = await refresh_token_if_needed()
|
||||
amr_response = await get_amr_info(token)
|
||||
if amr_response and amr_response.get("success", False):
|
||||
amr_list = amr_response.get("result", [])
|
||||
# 处理机器人数据
|
||||
|
Binary file not shown.
BIN
utils/__pycache__/alert_sync.cpython-313.pyc
Normal file
BIN
utils/__pycache__/alert_sync.cpython-313.pyc
Normal file
Binary file not shown.
Binary file not shown.
@ -207,13 +207,19 @@ class AlertSyncService:
|
||||
for attempt in range(self.retry_count):
|
||||
try:
|
||||
print("------------------====>>>", alert_data,"<<<<=================")
|
||||
# 禁用代理,确保直接连接到目标地址
|
||||
proxies = {
|
||||
'http': None,
|
||||
'https': None
|
||||
}
|
||||
response = requests.post(
|
||||
self.sync_url,
|
||||
json=alert_data,
|
||||
timeout=self.timeout,
|
||||
headers={'Content-Type': 'application/json',
|
||||
'x-access-token': token
|
||||
}
|
||||
},
|
||||
proxies=proxies
|
||||
)
|
||||
if response.status_code == 200:
|
||||
result = response.json()
|
||||
|
Loading…
x
Reference in New Issue
Block a user