修改--同步机器人信息脚本增加错误处理

This commit is contained in:
haotian 2025-06-23 10:37:17 +08:00
parent cfe4e5ac1a
commit b6dff25c44
2 changed files with 12 additions and 7 deletions

View File

@ -160,11 +160,14 @@ class RobotSyncService:
robot_info.updateTime = datetime.now()
# 更新字段
for key, value in robot_data.items():
if hasattr(robot_info, key):
setattr(robot_info, key, value)
await db.flush()
try:
for key, value in robot_data.items():
if hasattr(robot_info, key):
setattr(robot_info, key, value)
await db.flush()
except:
print("更新robot_info失败")
async def _update_group_robot_relation(self, db: AsyncSession, robot_id: str, grouping_id: str):
"""更新分组和机器人的关系"""

View File

@ -336,10 +336,12 @@ class Kangda:
response = response.json()
# 返回租户名下的任务列表
# 返回租户名下的任务列表, 204==>未安排值班==>data为空字符串
if response.get("code") == 204:
return None
return response.get("data").get("dutyList")
# print(response)
except requests.exceptions.RequestException as e:
print("查询分组出错:", e)