1.创建待办任务模块
This commit is contained in:
parent
1c0816dcc6
commit
c734272842
@ -1,3 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# This file is auto-generated, don't edit it. Thanks.
|
||||
import json
|
||||
import pprint
|
||||
from copy import deepcopy
|
||||
@ -5,8 +7,14 @@ from copy import deepcopy
|
||||
import pymongo
|
||||
import redis
|
||||
import requests
|
||||
|
||||
from alibabacloud_dingtalk.todo_1_0.client import Client as dingtalktodo_1_0Client
|
||||
from alibabacloud_tea_openapi import models as open_api_models
|
||||
from alibabacloud_dingtalk.todo_1_0 import models as dingtalktodo__1__0_models
|
||||
from alibabacloud_tea_util import models as util_models
|
||||
from alibabacloud_tea_util.client import Client as UtilClient
|
||||
from alibabacloud_tea_openapi import models as open_api_models
|
||||
from core.config import Settings, Debug
|
||||
from utils import get_msec
|
||||
|
||||
Settings = Settings()
|
||||
Mongo = Debug()
|
||||
@ -25,8 +33,12 @@ def get_token():
|
||||
获取钉钉token
|
||||
:return:
|
||||
"""
|
||||
corpid = 'dingd10b2fc689700431'
|
||||
corpsecret = 'eL2gsI4Hgqx__FC8T5Bjmue_zQoyG5sm-SJqEDdS4NmKPTzFLQ2G93CX24VP2_n3'
|
||||
#最外部应用的配置
|
||||
# corpid = 'dingd10b2fc689700431'
|
||||
# corpsecret = 'eL2gsI4Hgqx__FC8T5Bjmue_zQoyG5sm-SJqEDdS4NmKPTzFLQ2G93CX24VP2_n3'
|
||||
# 具体应用的配置
|
||||
corpid = 'dinghujiejktl8lytdfo'
|
||||
corpsecret = 'T5wXtmBZ0JD4ciWs1SP8ZWgRjnLiNFp4KJ0nRJpW_y621aPfu4qz631eCsapkFCh'
|
||||
url = f"https://oapi.dingtalk.com/gettoken"
|
||||
# 请求头
|
||||
headers = {'Content-type': 'text/html;charset=utf-8', 'Access-Control-Allow-Origin': '*'}
|
||||
@ -280,7 +292,67 @@ def get_alluid_list():
|
||||
redisuid = redisdb.get('user_id_list')
|
||||
user = redisuid.decode()
|
||||
return json.loads(user)
|
||||
class Sample:
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
@staticmethod
|
||||
def create_client() -> dingtalktodo_1_0Client:
|
||||
"""
|
||||
使用 Token 初始化账号Client
|
||||
@return: Client
|
||||
@throws Exception
|
||||
"""
|
||||
config = open_api_models.Config()
|
||||
config.protocol = 'https'
|
||||
config.region_id = 'central'
|
||||
return dingtalktodo_1_0Client(config)
|
||||
|
||||
@staticmethod
|
||||
def create_task(
|
||||
subject: str, creator_id: str, description: str, executor_ids: list
|
||||
) -> None:
|
||||
"""
|
||||
创建钉钉待办
|
||||
:param subject: 待办标题
|
||||
:param creator_id: 创建者
|
||||
:param description: 待办内容
|
||||
:param executor_ids: 执行者
|
||||
:return:
|
||||
"""
|
||||
client = Sample.create_client()
|
||||
create_todo_task_headers = dingtalktodo__1__0_models.CreateTodoTaskHeaders()
|
||||
create_todo_task_headers.x_acs_dingtalk_access_token = get_redistoken()
|
||||
notify_configs = dingtalktodo__1__0_models.CreateTodoTaskRequestNotifyConfigs(
|
||||
ding_notify='1'
|
||||
)
|
||||
# detail_url = dingtalktodo__1__0_models.CreateTodoTaskRequestDetailUrl(
|
||||
# app_url='https://www.dingtalk.com',
|
||||
# pc_url='https://www.dingtalk.com'
|
||||
# )
|
||||
create_todo_task_request = dingtalktodo__1__0_models.CreateTodoTaskRequest(
|
||||
# source_id='isv_dingtalkTodo1', #业务id
|
||||
subject=subject, # 待办标题
|
||||
creator_id=creator_id, # 创建者unionid
|
||||
description=description, # 最大长度 4096
|
||||
due_time=get_msec(), # 完成待办的截止日期 毫秒
|
||||
executor_ids=executor_ids, # 执行者的unionid
|
||||
# participant_ids=[
|
||||
# '6IiSFiSMFoRLWvXgl1Xc82XgiEiE'
|
||||
# ], #参与者
|
||||
# detail_url=detail_url,#详情页跳转地址
|
||||
is_only_show_executor=True,
|
||||
priority=20, # 优先级,普通
|
||||
notify_configs=notify_configs # 待办通知配置
|
||||
)
|
||||
client.create_todo_task_with_options(creator_id, create_todo_task_request,
|
||||
create_todo_task_headers, util_models.RuntimeOptions())
|
||||
# try:
|
||||
# client.create_todo_task_with_options('PUoiinWIpa2yH2ymhiiGiP6g', create_todo_task_request,
|
||||
# create_todo_task_headers, util_models.RuntimeOptions())
|
||||
# except Exception as err:
|
||||
# if not UtilClient.empty(err.code) and not UtilClient.empty(err.message):
|
||||
# return err.message
|
||||
|
||||
if __name__ == '__main__':
|
||||
import time
|
||||
|
@ -376,7 +376,14 @@ def png2pdf(dir_path, filename):
|
||||
doc.save(res_path)
|
||||
return res_path, new_filename
|
||||
|
||||
|
||||
def get_msec():
|
||||
"""
|
||||
获取当前日期的毫秒级时间
|
||||
:return:
|
||||
"""
|
||||
today = datetime.date.today().strftime('%Y-%m-%d 23:59:59')
|
||||
t = int(time.mktime(time.strptime(today, "%Y-%m-%d %H:%M:%S")))
|
||||
return int(round(t * 1000))
|
||||
if __name__ == '__main__':
|
||||
pass
|
||||
# fn=r'C:\Users\Administrator\Desktop\面试简历1\智联招聘_张双琪_Web开发工程师_中文.doc'
|
||||
|
Loading…
Reference in New Issue
Block a user