OaSdk.java 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455
  1. package com.usoftchina.dingtalk.sdk;
  2. import com.aliyun.dingtalktodo_1_0.models.*;
  3. import com.aliyun.teaopenapi.models.Config;
  4. import com.aliyun.teautil.models.RuntimeOptions;
  5. import com.dingtalk.api.DefaultDingTalkClient;
  6. import com.dingtalk.api.DingTalkClient;
  7. import com.dingtalk.api.request.*;
  8. import com.dingtalk.api.response.*;
  9. import com.taobao.api.internal.util.StringUtils;
  10. import com.usoftchina.dingtalk.sdk.config.DingTalkProperties;
  11. import com.usoftchina.dingtalk.sdk.util.DateUtils;
  12. import org.springframework.util.CollectionUtils;
  13. import java.util.ArrayList;
  14. import java.util.List;
  15. /**
  16. * oa
  17. * 签到、考勤
  18. *
  19. * @author yingp
  20. * @date 2020/2/19
  21. */
  22. public class OaSdk extends BaseSdk {
  23. public OaSdk(DingTalkProperties properties) {
  24. super(properties);
  25. }
  26. /**
  27. * 获取部门用户签到记录
  28. * 企业使用此接口可获取部门人员的签到记录,进行统计分析,也可以基于高德地图(http://lbs.amap.com/)API接口开发人员分布图和热力图。
  29. * <p>
  30. * 注意:目前最多获取1000人以内的签到数据,如果所传部门ID及其子部门下的user超过1000,会报错。
  31. * </p>
  32. *
  33. * @param agentCode
  34. * @param departmentId
  35. * @param startTime 起始时间。Unix时间戳,如:1520956800000
  36. * @param endTime 结束时间。Unix时间戳,如:1520956800000。开始时间和结束时间的间隔不能大于45天
  37. * @return
  38. */
  39. public List<OapiCheckinRecordResponse.Data> getCheckinData(String agentCode, long departmentId, long startTime, long endTime) {
  40. List<OapiCheckinRecordResponse.Data> dataList = new ArrayList<>();
  41. long size = 100;
  42. int i = 0;
  43. while (true) {
  44. List<OapiCheckinRecordResponse.Data> tempList = getCheckinData(agentCode, departmentId, startTime, endTime, i++, size);
  45. if (null != tempList) {
  46. dataList.addAll(tempList);
  47. if (tempList.size() < size) {
  48. break;
  49. }
  50. } else {
  51. break;
  52. }
  53. }
  54. return dataList;
  55. }
  56. /**
  57. * 分页获取部门用户签到记录
  58. * 企业使用此接口可获取部门人员的签到记录,进行统计分析,也可以基于高德地图(http://lbs.amap.com/)API接口开发人员分布图和热力图。
  59. * <p>
  60. * 注意:目前最多获取1000人以内的签到数据,如果所传部门ID及其子部门下的user超过1000,会报错。
  61. * </p>
  62. *
  63. * @param agentCode
  64. * @param departmentId
  65. * @param startTime
  66. * @param endTime
  67. * @param offset 支持分页查询,与size 参数同时设置时才生效,此参数代表偏移量,从0、1、2...依次递增
  68. * @param size 支持分页查询,与offset 参数同时设置时才生效,此参数代表分页大小,最大100
  69. * @return
  70. */
  71. public List<OapiCheckinRecordResponse.Data> getCheckinData(String agentCode, long departmentId, long startTime, long endTime, long offset, long size) {
  72. DingTalkClient client = new DefaultDingTalkClient(getProperties().getApi() + "/checkin/record");
  73. OapiCheckinRecordRequest req = new OapiCheckinRecordRequest();
  74. req.setDepartmentId(String.valueOf(departmentId));
  75. req.setStartTime(startTime);
  76. req.setEndTime(endTime);
  77. req.setOffset(offset);
  78. req.setOrder("asc");
  79. req.setSize(size);
  80. req.setHttpMethod("GET");
  81. OapiCheckinRecordResponse resp = cached(() -> client.execute(req, getAccessToken(agentCode)));
  82. assertOK(resp);
  83. return resp.getData();
  84. }
  85. /**
  86. * 获取用户签到记录
  87. * 企业使用此接口可获取指定人员的签到记录,进行统计分析,也可以基于高德地图(http://lbs.amap.com)API接口开发人员分布图和热力图。
  88. *
  89. * @param agentCode
  90. * @param userIdList
  91. * @param startTime 起始时间。Unix时间戳,如:1520956800000
  92. * @param endTime 结束时间。Unix时间戳,如:1520956800000。如果是取1个人的数据,时间范围最大到10天,如果是取多个人的数据,时间范围最大1天。
  93. * @return
  94. */
  95. public List<OapiCheckinRecordGetResponse.CheckinRecordVo> getCheckinData(String agentCode, List<String> userIdList, long startTime, long endTime) {
  96. List<OapiCheckinRecordGetResponse.CheckinRecordVo> dataList = new ArrayList<>();
  97. long size = 100;
  98. int i = 0;
  99. while (true) {
  100. List<OapiCheckinRecordGetResponse.CheckinRecordVo> tempList = getCheckinData(agentCode, userIdList, startTime, endTime, i++, size);
  101. if (null != tempList) {
  102. dataList.addAll(tempList);
  103. if (tempList.size() < size) {
  104. break;
  105. }
  106. } else {
  107. break;
  108. }
  109. }
  110. return dataList;
  111. }
  112. /**
  113. * 分页获取用户签到记录
  114. * 企业使用此接口可获取指定人员的签到记录,进行统计分析,也可以基于高德地图(http://lbs.amap.com)API接口开发人员分布图和热力图。
  115. *
  116. * @param agentCode
  117. * @param userIdList
  118. * @param startTime
  119. * @param endTime
  120. * @param cursor 分页查询的游标,最开始可以传0,然后以1、2依次递增
  121. * @param size 分页查询的每页大小,最大100
  122. * @return
  123. */
  124. public List<OapiCheckinRecordGetResponse.CheckinRecordVo> getCheckinData(String agentCode, List<String> userIdList, long startTime, long endTime, long cursor, long size) {
  125. DingTalkClient client = new DefaultDingTalkClient(getProperties().getApi() + "/topapi/checkin/record/get");
  126. OapiCheckinRecordGetRequest req = new OapiCheckinRecordGetRequest();
  127. req.setStartTime(startTime);
  128. req.setEndTime(endTime);
  129. req.setSize(size);
  130. req.setCursor(cursor);
  131. req.setUseridList(String.join(",", userIdList));
  132. OapiCheckinRecordGetResponse resp = cached(() -> client.execute(req, getAccessToken(agentCode)));
  133. assertOK(resp);
  134. return resp.getResult().getPageList();
  135. }
  136. /**
  137. * 获取打卡详情
  138. * 该接口用于返回企业内员工的实际打卡记录。比如,企业给一个员工设定的排班是上午9点和下午6点各打一次卡,但是员工在这期间打了多次,该接口会把所有的打卡记录都返回。
  139. * <p>
  140. * 如果只要获取打卡结果数据,不需要详情数据,可使用获取打卡结果接口。
  141. * </p>
  142. *
  143. * @param agentCode
  144. * @param userIdList 企业内的员工id列表,最多不能超过50个
  145. * @param startTime 查询考勤打卡记录的起始工作日。格式为“yyyy-MM-dd hh:mm:ss”。
  146. * @param endTime 查询考勤打卡记录的结束工作日。格式为“yyyy-MM-dd hh:mm:ss”。注意,起始与结束工作日最多相隔7天
  147. */
  148. public List<OapiAttendanceListRecordResponse.Recordresult> getAttendanceRecordList(String agentCode, List<String> userIdList, long startTime, long endTime) {
  149. DingTalkClient client = new DefaultDingTalkClient(getProperties().getApi() + "/attendance/listRecord");
  150. OapiAttendanceListRecordRequest req = new OapiAttendanceListRecordRequest();
  151. req.setCheckDateFrom(DateUtils.formatDateTime(startTime));
  152. req.setCheckDateTo(DateUtils.formatDateTime(endTime));
  153. req.setUserIds(userIdList);
  154. OapiAttendanceListRecordResponse resp = cached(() -> client.execute(req, getAccessToken(agentCode)));
  155. assertOK(resp);
  156. return resp.getRecordresult();
  157. }
  158. /**
  159. * 获取打卡结果
  160. * 该接口用于返回企业内员工的实际打卡结果。比如,企业给一个员工设定的排班是上午9点和下午6点各打一次卡,即使员工在这期间打了多次,该接口也只会返回两条记录,包括上午的打卡结果和下午的打卡结果。
  161. * <p>
  162. * 如果要获取打卡详细数据,比如打卡位置,可使用获取打卡详情接口。
  163. * </p>
  164. *
  165. * @param agentCode
  166. * @param userIdList
  167. * @param startTime 查询考勤打卡记录的起始工作日。格式为“yyyy-MM-dd HH:mm:ss”,HH:mm:ss可以使用00:00:00,将返回此日期从0点到24点的结果
  168. * @param endTime 查询考勤打卡记录的结束工作日。格式为“yyyy-MM-dd HH:mm:ss”,HH:mm:ss可以使用00:00:00,将返回此日期从0点到24点的结果。注意,起始与结束工作日最多相隔7天
  169. * @param offset 表示获取考勤数据的起始点,第一次传0,如果还有多余数据,下次获取传的offset值为之前的offset+limit,0、1、2...依次递增
  170. * @param limit 表示获取考勤数据的条数,最大不能超过50条
  171. * @return
  172. */
  173. public List<OapiAttendanceListResponse.Recordresult> getAttendanceList(String agentCode, List<String> userIdList, long startTime, long endTime, long offset, long limit) {
  174. DingTalkClient client = new DefaultDingTalkClient(getProperties().getApi() + "/attendance/list");
  175. OapiAttendanceListRequest req = new OapiAttendanceListRequest();
  176. req.setWorkDateFrom(DateUtils.formatDateTime(startTime));
  177. req.setWorkDateTo(DateUtils.formatDateTime(endTime));
  178. req.setUserIdList(userIdList);
  179. req.setOffset(offset);
  180. req.setLimit(limit);
  181. OapiAttendanceListResponse resp = cached(() -> client.execute(req, getAccessToken(agentCode)));
  182. assertOK(resp);
  183. return resp.getRecordresult();
  184. }
  185. /**
  186. * 获取打卡结果
  187. * 该接口用于返回企业内员工的实际打卡结果。比如,企业给一个员工设定的排班是上午9点和下午6点各打一次卡,即使员工在这期间打了多次,该接口也只会返回两条记录,包括上午的打卡结果和下午的打卡结果。
  188. * <p>
  189. * 如果要获取打卡详细数据,比如打卡位置,可使用获取打卡详情接口。
  190. * </p>
  191. *
  192. * @param agentCode
  193. * @param userIdList
  194. * @param startTime 查询考勤打卡记录的起始工作日。格式为“yyyy-MM-dd HH:mm:ss”,HH:mm:ss可以使用00:00:00,将返回此日期从0点到24点的结果
  195. * @param endTime 查询考勤打卡记录的结束工作日。格式为“yyyy-MM-dd HH:mm:ss”,HH:mm:ss可以使用00:00:00,将返回此日期从0点到24点的结果。注意,起始与结束工作日最多相隔7天
  196. * @return
  197. */
  198. public List<OapiAttendanceListResponse.Recordresult> getAttendanceList(String agentCode, List<String> userIdList, long startTime, long endTime) {
  199. List<OapiAttendanceListResponse.Recordresult> dataList = new ArrayList<>();
  200. long size = 100;
  201. int i = 0;
  202. while (true) {
  203. List<OapiAttendanceListResponse.Recordresult> tempList = getAttendanceList(agentCode, userIdList, startTime, endTime, i++ * size, size);
  204. if (null != tempList) {
  205. dataList.addAll(tempList);
  206. if (tempList.size() < size) {
  207. break;
  208. }
  209. } else {
  210. break;
  211. }
  212. }
  213. return dataList;
  214. }
  215. //离职、补卡、请假、出差、加班
  216. /**
  217. * 获取出差单列表
  218. * 该接口用于返回企业内员工的出差申请单。
  219. *
  220. * @param agentCode
  221. * @param startTime 查询起始工作日。格式为“yyyy-MM-dd HH:mm:ss”,HH:mm:ss可以使用00:00:00,将返回此日期从0点到24点的结果
  222. * @param endTime 查询结束工作日。格式为“yyyy-MM-dd HH:mm:ss”,HH:mm:ss可以使用00:00:00,将返回此日期从0点到24点的结果。注意,起始与结束工作日最多相隔7天
  223. * @param offset 表示获取考勤数据的起始点,第一次传1,如果还有多余数据,下次获取传的offset值为之前的offset+limit 1、2...依次递增
  224. * @param size 表示获取考勤数据的条数,最大不能超过50条
  225. * @return
  226. */
  227. public List<OapiAlitripBtripApplySearchResponse.OpenApplyRs> getAlitripList(String agentCode, String startTime, String endTime, long offset, long size) {
  228. DingTalkClient client = new DefaultDingTalkClient(getProperties().getApi() + "/topapi/alitrip/btrip/apply/search");
  229. OapiAlitripBtripApplySearchRequest req = new OapiAlitripBtripApplySearchRequest();
  230. OapiAlitripBtripApplySearchRequest.OpenSearchRq rq = new OapiAlitripBtripApplySearchRequest.OpenSearchRq();
  231. rq.setCorpid(getProperties().getCorpId());
  232. rq.setStartTime(StringUtils.parseDateTime(startTime));
  233. rq.setEndTime(StringUtils.parseDateTime(endTime));
  234. rq.setPage(offset);
  235. rq.setPageSize(size);
  236. req.setRq(rq);
  237. OapiAlitripBtripApplySearchResponse resp = cached(() -> client.execute(req, getAccessToken(agentCode)));
  238. assertOK(resp);
  239. return resp.getModule();
  240. }
  241. public List<OapiAlitripBtripApplySearchResponse.OpenApplyRs> getAllAlitrip(String agentCode, String startTime, String endTime){
  242. List<OapiAlitripBtripApplySearchResponse.OpenApplyRs> dataList = new ArrayList<>();
  243. long i=1,size=50;
  244. while (true) {
  245. List<OapiAlitripBtripApplySearchResponse.OpenApplyRs> alitripList = getAlitripList(agentCode, startTime, endTime, i++, size);
  246. if (null != alitripList) {
  247. dataList.addAll(alitripList);
  248. if (alitripList.size() < size) {
  249. break;
  250. }
  251. } else {
  252. break;
  253. }
  254. }
  255. return dataList;
  256. }
  257. /**
  258. * 员工离职列表
  259. * @param agentCode
  260. * @param offset
  261. * @param size
  262. */
  263. public OapiSmartworkHrmEmployeeQuerydimissionResponse.Paginator getEmpLeaveRecords(String agentCode, long offset, long size){
  264. DingTalkClient client = new DefaultDingTalkClient(getProperties().getApi() + "/topapi/smartwork/hrm/employee/querydimission");
  265. OapiSmartworkHrmEmployeeQuerydimissionRequest req = new OapiSmartworkHrmEmployeeQuerydimissionRequest();
  266. req.setOffset(offset);
  267. req.setSize(size);
  268. OapiSmartworkHrmEmployeeQuerydimissionResponse resp= cached(() -> client.execute(req, getAccessToken(agentCode)));
  269. assertOK(resp);
  270. return resp.getResult();
  271. }
  272. /**
  273. * 员工离职列表
  274. * @param agentCode
  275. */
  276. public List<OapiSmartworkHrmEmployeeListdimissionResponse.EmpDimissionInfoVo> getAllEmpLeaveRecords(String agentCode){
  277. List<OapiSmartworkHrmEmployeeListdimissionResponse.EmpDimissionInfoVo> list = new ArrayList<>();
  278. long i=1,size=50;
  279. while (true) {
  280. OapiSmartworkHrmEmployeeQuerydimissionResponse.Paginator empLeaveRecords = getEmpLeaveRecords(agentCode, i++, size);
  281. if (null != empLeaveRecords) {
  282. Long nextCursor = empLeaveRecords.getNextCursor()==null?0:empLeaveRecords.getNextCursor();
  283. list.addAll(getEmpLeave(agentCode, empLeaveRecords.getDataList()));
  284. if (nextCursor<=0) {
  285. break;
  286. }
  287. } else {
  288. break;
  289. }
  290. }
  291. return list;
  292. }
  293. /**
  294. * 员工离职信息
  295. *
  296. * @param agentCode
  297. * @param userIdList
  298. */
  299. public List<OapiSmartworkHrmEmployeeListdimissionResponse.EmpDimissionInfoVo> getEmpLeave(String agentCode, List<String> userIdList){
  300. DingTalkClient client = new DefaultDingTalkClient(getProperties().getApi() + "/topapi/smartwork/hrm/employee/listdimission");
  301. OapiSmartworkHrmEmployeeListdimissionRequest req = new OapiSmartworkHrmEmployeeListdimissionRequest();
  302. req.setUseridList(String.join(",", userIdList));
  303. OapiSmartworkHrmEmployeeListdimissionResponse resp= cached(() -> client.execute(req, getAccessToken(agentCode)));
  304. assertOK(resp);
  305. return resp.getResult();
  306. }
  307. /**
  308. * 员工请假列表
  309. * @param agentCode
  310. * @param offset
  311. * @param size
  312. */
  313. public List<OapiAttendanceGetleavestatusResponse.LeaveStatusVO> getLeaves(String agentCode,List<String> userIdList, long startTime, long endTime, long offset, long size){
  314. DingTalkClient client = new DefaultDingTalkClient(getProperties().getApi() + "/topapi/attendance/getleavestatus");
  315. OapiAttendanceGetleavestatusRequest req = new OapiAttendanceGetleavestatusRequest();
  316. req.setUseridList(String.join(",", userIdList));
  317. req.setStartTime(startTime);
  318. req.setEndTime(endTime);
  319. req.setOffset(offset);
  320. req.setSize(size);
  321. OapiAttendanceGetleavestatusResponse resp= cached(() -> client.execute(req, getAccessToken(agentCode)));
  322. assertOK(resp);
  323. OapiAttendanceGetleavestatusResponse.LeaveStatusListVO leaveStatusListVO = resp.getResult();
  324. if (leaveStatusListVO!=null){
  325. return leaveStatusListVO.getLeaveStatus();
  326. }
  327. return null;
  328. }
  329. public List<OapiAttendanceGetleavestatusResponse.LeaveStatusVO> getAllLeaves(String agentCode, List<String> userIdList, long startTime, long endTime){
  330. List<OapiAttendanceGetleavestatusResponse.LeaveStatusVO> dataList = new ArrayList<>();
  331. long i=1,size=20;
  332. while (true) {
  333. List<OapiAttendanceGetleavestatusResponse.LeaveStatusVO> leaves = getLeaves(agentCode, userIdList, startTime, endTime, i++, size);
  334. if (!CollectionUtils.isEmpty(leaves)) {
  335. dataList.addAll(leaves);
  336. if (leaves.size() < size) {
  337. break;
  338. }
  339. } else {
  340. break;
  341. }
  342. }
  343. return dataList;
  344. }
  345. /**
  346. * 使用 Token 初始化账号Client
  347. * @return Client
  348. * @throws Exception
  349. */
  350. public com.aliyun.dingtalktodo_1_0.Client initClient() throws Exception {
  351. Config config = new Config();
  352. config.protocol = "https";
  353. config.regionId = "central";
  354. return new com.aliyun.dingtalktodo_1_0.Client(config);
  355. }
  356. public void createTodo(String agentCode,String unionId,String creatorId,String appUrl,String pcUrl,String title,String description,int priority,String dingNotify,Boolean isOnlyShow) throws Exception {
  357. com.aliyun.dingtalktodo_1_0.Client client = initClient();
  358. CreateTodoTaskHeaders createTodoTaskHeaders = new CreateTodoTaskHeaders();
  359. createTodoTaskHeaders.xAcsDingtalkAccessToken = getAccessToken(agentCode);
  360. CreateTodoTaskRequest.CreateTodoTaskRequestNotifyConfigs notifyConfigs = new CreateTodoTaskRequest.CreateTodoTaskRequestNotifyConfigs()
  361. .setDingNotify(dingNotify);
  362. CreateTodoTaskRequest.CreateTodoTaskRequestDetailUrl detailUrl = new CreateTodoTaskRequest.CreateTodoTaskRequestDetailUrl()
  363. .setAppUrl(appUrl)
  364. .setPcUrl(pcUrl);
  365. CreateTodoTaskRequest createTodoTaskRequest = new CreateTodoTaskRequest()
  366. .setSubject(title)
  367. .setCreatorId(creatorId)
  368. .setDescription(description)
  369. .setDueTime(DateUtils.nowDateEnd().getTime())
  370. .setExecutorIds(java.util.Arrays.asList(
  371. unionId
  372. ))
  373. .setParticipantIds(java.util.Arrays.asList(
  374. unionId
  375. ))
  376. .setDetailUrl(detailUrl)
  377. .setIsOnlyShowExecutor(isOnlyShow)
  378. .setPriority(priority)
  379. .setNotifyConfigs(notifyConfigs);
  380. client.createTodoTaskWithOptions(unionId, createTodoTaskRequest, createTodoTaskHeaders, new RuntimeOptions());
  381. }
  382. public void updateTodo(String agentCode,String creatorId,String unionId,String taskId,String title,String description) throws Exception {
  383. com.aliyun.dingtalktodo_1_0.Client client = initClient();
  384. UpdateTodoTaskHeaders updateTodoTaskHeaders = new UpdateTodoTaskHeaders();
  385. updateTodoTaskHeaders.xAcsDingtalkAccessToken =getAccessToken(agentCode);
  386. UpdateTodoTaskRequest updateTodoTaskRequest = new UpdateTodoTaskRequest()
  387. .setOperatorId(creatorId)
  388. .setSubject(title)
  389. .setDescription(description)
  390. .setDueTime(DateUtils.nowDateTime().getTime())
  391. .setDone(true)
  392. .setExecutorIds(java.util.Arrays.asList(
  393. unionId
  394. ))
  395. .setParticipantIds(java.util.Arrays.asList(
  396. unionId
  397. ));
  398. client.updateTodoTaskWithOptions(unionId, taskId, updateTodoTaskRequest, updateTodoTaskHeaders, new RuntimeOptions());
  399. }
  400. public QueryOrgTodoTasksResponse getTodo(String agentCode,String unionId,String nextToken,Boolean isDone) throws Exception {
  401. com.aliyun.dingtalktodo_1_0.Client client = initClient();
  402. QueryOrgTodoTasksHeaders queryOrgTodoTasksHeaders = new QueryOrgTodoTasksHeaders();
  403. queryOrgTodoTasksHeaders.xAcsDingtalkAccessToken = getAccessToken(agentCode);
  404. QueryOrgTodoTasksRequest queryOrgTodoTasksRequest = new QueryOrgTodoTasksRequest()
  405. .setNextToken(nextToken)
  406. .setIsDone(isDone);
  407. return client.queryOrgTodoTasksWithOptions(unionId, queryOrgTodoTasksRequest, queryOrgTodoTasksHeaders, new RuntimeOptions());
  408. }
  409. public List<QueryOrgTodoTasksResponseBody.QueryOrgTodoTasksResponseBodyTodoCards> getAllTodo(String agentCode,String unionId,String nextToken,Boolean isDone) throws Exception {
  410. Boolean b=true;
  411. List<QueryOrgTodoTasksResponseBody.QueryOrgTodoTasksResponseBodyTodoCards> todos = new ArrayList<>();
  412. while (b){
  413. QueryOrgTodoTasksResponse todo = getTodo(agentCode, unionId, nextToken, isDone);
  414. QueryOrgTodoTasksResponseBody body = todo.getBody();
  415. todos.addAll(body.getTodoCards());
  416. String token = body.getNextToken();
  417. if (token!=null&&!"".equals(token)){
  418. nextToken=token;
  419. }else {
  420. b=false;
  421. }
  422. }
  423. return todos;
  424. }
  425. public void deleteTodo(String agentCode,String unionId,String taskId) throws Exception {
  426. com.aliyun.dingtalktodo_1_0.Client client = initClient();
  427. DeleteTodoTaskHeaders deleteTodoTaskHeaders = new DeleteTodoTaskHeaders();
  428. deleteTodoTaskHeaders.xAcsDingtalkAccessToken = getAccessToken(agentCode);
  429. DeleteTodoTaskRequest deleteTodoTaskRequest = new DeleteTodoTaskRequest()
  430. .setOperatorId(unionId);
  431. client.deleteTodoTaskWithOptions(unionId, taskId, deleteTodoTaskRequest, deleteTodoTaskHeaders, new RuntimeOptions());
  432. }
  433. }