This commit is contained in:
1 parent
57e98728eb
commit
f6202d551e
13 files changed
+386
-41
No files matched your search
+45
-23
@@ -10,25 +10,6 @@ from app.utils.utils import *
|
||||
from app.utils.yd_utils import get_token, get_activity_info
|
||||
|
||||
|
||||
@shared_task(ignore_result=False)
|
||||
def add(a: int, b: int) -> int:
|
||||
return a + b
|
||||
|
||||
|
||||
@shared_task()
|
||||
def block() -> None:
|
||||
time.sleep(5)
|
||||
|
||||
|
||||
@shared_task(bind=True, ignore_result=False)
|
||||
def process(self: Task, total: int) -> object:
|
||||
for i in range(total):
|
||||
self.update_state(state="PROGRESS", meta={"current": i + 1, "total": total})
|
||||
time.sleep(1)
|
||||
|
||||
return {"current": total, "total": total}
|
||||
|
||||
|
||||
@shared_task(include_result=False)
|
||||
def process_message_callback(
|
||||
app_id, app_secret, bitable_token, table_id, cache_dir, data
|
||||
@@ -93,11 +74,52 @@ def process_message_callback(
|
||||
|
||||
@shared_task()
|
||||
def sync_xbot_activity_info():
|
||||
app_id = os.environ["APP_ID"]
|
||||
app_secret = os.environ["APP_SECRET"]
|
||||
|
||||
bitable_token = os.environ["OFFICE_XBOT_BITABLE_TOKEN"]
|
||||
table_id = os.environ["OFFICE_XBOT_TABLE_ID"]
|
||||
view_id = os.environ["OFFICE_XBOT_VIEW_ID"]
|
||||
|
||||
xbot_username = os.environ["XBOT_USERNAME"]
|
||||
xbot_password = os.environ["XBOT_PASSWORD"]
|
||||
|
||||
client = lark.Client.builder().app_id(app_id).app_secret(app_secret).build()
|
||||
|
||||
token = get_token(xbot_username, xbot_password)
|
||||
office_activity_uuids: list = get_activity_info(token)
|
||||
|
||||
handle_list = []
|
||||
|
||||
# 同步应用数据
|
||||
# office_app_uuids = get_office_app_uuids()
|
||||
|
||||
# print(f"office_activity_uuids count: {len(office_app_uuids)}")
|
||||
|
||||
# 同步指令数据
|
||||
office_activity_uuids = get_activity_info(token)
|
||||
print(f"office_activity_uuids count: {len(office_activity_uuids)}")
|
||||
|
||||
for item in office_activity_uuids:
|
||||
uuid = item.get("uuid")
|
||||
package_viewName = item.get("packageViewName")
|
||||
print(uuid, package_viewName)
|
||||
robot_uuid = item.get("robotUuid")
|
||||
package_view_name = item.get("packageViewName")
|
||||
print("=====================================")
|
||||
print(f"同步信息: {robot_uuid}, {package_view_name}")
|
||||
record_id = get_filtered_record_by_uuid(
|
||||
client, bitable_token, table_id, view_id, "UUID", robot_uuid
|
||||
)
|
||||
if record_id:
|
||||
print(f"{robot_uuid}已同步多维表格中")
|
||||
update_record(
|
||||
client, bitable_token, table_id, record_id, {"名称": package_view_name}
|
||||
)
|
||||
else:
|
||||
handle_list.append(robot_uuid)
|
||||
print(f"{robot_uuid}: {package_view_name} 未同步多维表格中")
|
||||
add_record(
|
||||
client,
|
||||
bitable_token,
|
||||
table_id,
|
||||
{"UUID": robot_uuid, "名称": package_view_name, "分类": "官方指令"},
|
||||
)
|
||||
print(f"新增的数量: {len(handle_list)}")
|
||||
print("新增的uuid: ", handle_list)
|
||||
Reference in new issue
Block a user