|  |  |  | 
|---|
|  |  |  | * api 地址 https://open.dingtalk.com/document/orgapp/asynchronous-sending-of-enterprise-session-messages | 
|---|
|  |  |  | * @throws ApiException | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public void workInfoOANotice(Long agentId,String userIds,OapiMessageCorpconversationAsyncsendV2Request.Msg msg)throws ApiException { | 
|---|
|  |  |  | DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/topapi/message/corpconversation/asyncsend_v2"); | 
|---|
|  |  |  | OapiMessageCorpconversationAsyncsendV2Request request = new OapiMessageCorpconversationAsyncsendV2Request(); | 
|---|
|  |  |  | request.setAgentId(agentId); | 
|---|
|  |  |  | request.setUseridList(userIds); | 
|---|
|  |  |  | request.setToAllUser(false); | 
|---|
|  |  |  | public Boolean workInfoOANotice(Long agentId,String userIds,OapiMessageCorpconversationAsyncsendV2Request.Msg msg){ | 
|---|
|  |  |  | try{ | 
|---|
|  |  |  | DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/topapi/message/corpconversation/asyncsend_v2"); | 
|---|
|  |  |  | OapiMessageCorpconversationAsyncsendV2Request request = new OapiMessageCorpconversationAsyncsendV2Request(); | 
|---|
|  |  |  | request.setAgentId(agentId); | 
|---|
|  |  |  | request.setUseridList(userIds); | 
|---|
|  |  |  | request.setToAllUser(false); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | request.setMsg(msg); | 
|---|
|  |  |  | OapiMessageCorpconversationAsyncsendV2Response rsp = client.execute(request, "60c2df248ca93d4eafb4a04a2330d3d3");//getToken()); | 
|---|
|  |  |  | if(rsp.getErrcode().equals(Constants.DD_ERR_CODE)){ | 
|---|
|  |  |  | request.setMsg(msg); | 
|---|
|  |  |  | OapiMessageCorpconversationAsyncsendV2Response rsp = client.execute(request, "60c2df248ca93d4eafb4a04a2330d3d3");//getToken()); | 
|---|
|  |  |  | if(rsp.getErrcode().equals(Constants.DD_ERR_CODE)){ | 
|---|
|  |  |  | return true; | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),rsp.getMessage()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }catch (ApiException apiException){ | 
|---|
|  |  |  |  | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),rsp.getMessage()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return false; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | * unionIdList 待办通知人员集合 | 
|---|
|  |  |  | * @throws Exception | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public String toDoNotice(String title,List<String> unionIdList,List<CreateTodoTaskRequest.CreateTodoTaskRequestContentFieldList> fieldList) throws Exception { | 
|---|
|  |  |  | com.aliyun.dingtalktodo_1_0.Client client = DingTalk.createV1Client(); | 
|---|
|  |  |  | CreateTodoTaskHeaders createTodoTaskHeaders = new CreateTodoTaskHeaders(); | 
|---|
|  |  |  | createTodoTaskHeaders.xAcsDingtalkAccessToken = "43cf8213909f34ef81e7447905b822fb";//getToken(); | 
|---|
|  |  |  | //待办截止前的提醒 | 
|---|
|  |  |  | CreateTodoTaskRequest.CreateTodoTaskRequestRemindNotifyConfigs remindNotifyConfigs = new CreateTodoTaskRequest.CreateTodoTaskRequestRemindNotifyConfigs() | 
|---|
|  |  |  | .setDingNotify("1") | 
|---|
|  |  |  | .setSendTodoApn("true"); | 
|---|
|  |  |  | //待办通知配置 | 
|---|
|  |  |  | CreateTodoTaskRequest.CreateTodoTaskRequestNotifyConfigs notifyConfigs = new CreateTodoTaskRequest.CreateTodoTaskRequestNotifyConfigs() | 
|---|
|  |  |  | .setDingNotify("1") | 
|---|
|  |  |  | .setSendTodoApn("true") | 
|---|
|  |  |  | .setSendAssistantChat("true"); | 
|---|
|  |  |  | //按钮事件 | 
|---|
|  |  |  | CreateTodoTaskRequest.CreateTodoTaskRequestActionListParam actionList0Param = new CreateTodoTaskRequest.CreateTodoTaskRequestActionListParam() | 
|---|
|  |  |  | .setBody(""); | 
|---|
|  |  |  | CreateTodoTaskRequest.CreateTodoTaskRequestActionList actionList0 = new CreateTodoTaskRequest.CreateTodoTaskRequestActionList() | 
|---|
|  |  |  | .setTitle("去处理") | 
|---|
|  |  |  | .setActionType(2) | 
|---|
|  |  |  | .setParam(actionList0Param) | 
|---|
|  |  |  | .setUrl("https://www.baidu.com") //TODO 详情地址 | 
|---|
|  |  |  | .setActionKey("ak-1-1"); | 
|---|
|  |  |  | //详情页url跳转地址 | 
|---|
|  |  |  | CreateTodoTaskRequest.CreateTodoTaskRequestDetailUrl detailUrl = new CreateTodoTaskRequest.CreateTodoTaskRequestDetailUrl() | 
|---|
|  |  |  | .setAppUrl("https://www.baidu.com") | 
|---|
|  |  |  | .setPcUrl("https://www.baidu.com"); | 
|---|
|  |  |  | CreateTodoTaskRequest createTodoTaskRequest = new CreateTodoTaskRequest() | 
|---|
|  |  |  | .setSubject(title) | 
|---|
|  |  |  | .setCreatorId(unionIdList.get(Constants.ZERO)) | 
|---|
|  |  |  | .setDescription(title) | 
|---|
|  |  |  | .setExecutorIds(unionIdList) | 
|---|
|  |  |  | .setDetailUrl(detailUrl) | 
|---|
|  |  |  | .setContentFieldList(fieldList) | 
|---|
|  |  |  | .setIsOnlyShowExecutor(true) | 
|---|
|  |  |  | .setPriority(20) | 
|---|
|  |  |  | .setNotifyConfigs(notifyConfigs) | 
|---|
|  |  |  | .setActionList(java.util.Arrays.asList(actionList0)) | 
|---|
|  |  |  | .setTodoType("TODO") | 
|---|
|  |  |  | .setRemindNotifyConfigs(remindNotifyConfigs); | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | CreateTodoTaskResponse response = client.createTodoTaskWithOptions(unionIdList.get(Constants.ZERO), createTodoTaskRequest, createTodoTaskHeaders, new com.aliyun.teautil.models.RuntimeOptions()); | 
|---|
|  |  |  | log.error("待办通知发送成功,发送内容:{}"+JSONObject.toJSONString(response)); | 
|---|
|  |  |  | return response.getBody().getId(); | 
|---|
|  |  |  | } catch (TeaException err) { | 
|---|
|  |  |  | if (!com.aliyun.teautil.Common.empty(err.code) && !com.aliyun.teautil.Common.empty(err.message)) { | 
|---|
|  |  |  | log.error("待办通知发送失败,失败原因:{}"+err.message); | 
|---|
|  |  |  | public String toDoNotice(String title,List<String> unionIdList,List<CreateTodoTaskRequest.CreateTodoTaskRequestContentFieldList> fieldList,String url) { | 
|---|
|  |  |  | try{ | 
|---|
|  |  |  | com.aliyun.dingtalktodo_1_0.Client client = DingTalk.createV1Client(); | 
|---|
|  |  |  | CreateTodoTaskHeaders createTodoTaskHeaders = new CreateTodoTaskHeaders(); | 
|---|
|  |  |  | createTodoTaskHeaders.xAcsDingtalkAccessToken = getToken(); | 
|---|
|  |  |  | //待办截止前的提醒 | 
|---|
|  |  |  | CreateTodoTaskRequest.CreateTodoTaskRequestRemindNotifyConfigs remindNotifyConfigs = new CreateTodoTaskRequest.CreateTodoTaskRequestRemindNotifyConfigs() | 
|---|
|  |  |  | .setDingNotify("1") | 
|---|
|  |  |  | .setSendTodoApn("true"); | 
|---|
|  |  |  | //待办通知配置 | 
|---|
|  |  |  | CreateTodoTaskRequest.CreateTodoTaskRequestNotifyConfigs notifyConfigs = new CreateTodoTaskRequest.CreateTodoTaskRequestNotifyConfigs() | 
|---|
|  |  |  | .setDingNotify("1") | 
|---|
|  |  |  | .setSendTodoApn("true") | 
|---|
|  |  |  | .setSendAssistantChat("true"); | 
|---|
|  |  |  | //按钮事件 | 
|---|
|  |  |  | CreateTodoTaskRequest.CreateTodoTaskRequestActionListParam actionList0Param = new CreateTodoTaskRequest.CreateTodoTaskRequestActionListParam() | 
|---|
|  |  |  | .setBody(""); | 
|---|
|  |  |  | CreateTodoTaskRequest.CreateTodoTaskRequestActionList actionList0 = new CreateTodoTaskRequest.CreateTodoTaskRequestActionList() | 
|---|
|  |  |  | .setTitle("去处理") | 
|---|
|  |  |  | .setActionType(2) | 
|---|
|  |  |  | .setParam(actionList0Param) | 
|---|
|  |  |  | .setUrl("https://www.baidu.com") //TODO 详情地址 | 
|---|
|  |  |  | .setActionKey("ak-1-1"); | 
|---|
|  |  |  | //详情页url跳转地址 | 
|---|
|  |  |  | CreateTodoTaskRequest.CreateTodoTaskRequestDetailUrl detailUrl = new CreateTodoTaskRequest.CreateTodoTaskRequestDetailUrl() | 
|---|
|  |  |  | .setAppUrl("https://www.baidu.com") | 
|---|
|  |  |  | .setPcUrl("https://www.baidu.com"); | 
|---|
|  |  |  | CreateTodoTaskRequest createTodoTaskRequest = new CreateTodoTaskRequest() | 
|---|
|  |  |  | .setSubject(title) | 
|---|
|  |  |  | .setCreatorId(unionIdList.get(Constants.ZERO)) | 
|---|
|  |  |  | .setDescription(title) | 
|---|
|  |  |  | .setExecutorIds(unionIdList) | 
|---|
|  |  |  | .setDetailUrl(detailUrl) | 
|---|
|  |  |  | .setContentFieldList(fieldList) | 
|---|
|  |  |  | .setIsOnlyShowExecutor(true) | 
|---|
|  |  |  | .setPriority(20) | 
|---|
|  |  |  | .setNotifyConfigs(notifyConfigs) | 
|---|
|  |  |  | .setActionList(java.util.Arrays.asList(actionList0)) | 
|---|
|  |  |  | .setTodoType("TODO") | 
|---|
|  |  |  | .setRemindNotifyConfigs(remindNotifyConfigs); | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | CreateTodoTaskResponse response = client.createTodoTaskWithOptions(unionIdList.get(Constants.ZERO), createTodoTaskRequest, createTodoTaskHeaders, new com.aliyun.teautil.models.RuntimeOptions()); | 
|---|
|  |  |  | log.error("待办通知发送成功,发送内容:{}"+JSONObject.toJSONString(response)); | 
|---|
|  |  |  | return response.getBody().getId(); | 
|---|
|  |  |  | } catch (TeaException err) { | 
|---|
|  |  |  | if (!com.aliyun.teautil.Common.empty(err.code) && !com.aliyun.teautil.Common.empty(err.message)) { | 
|---|
|  |  |  | log.error("待办通知发送失败,失败原因:{}"+err.message); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } catch (Exception _err) { | 
|---|
|  |  |  | TeaException err = new TeaException(_err.getMessage(), _err); | 
|---|
|  |  |  | if (!com.aliyun.teautil.Common.empty(err.code) && !com.aliyun.teautil.Common.empty(err.message)) { | 
|---|
|  |  |  | // err 中含有 code 和 message 属性,可帮助开发定位问题 | 
|---|
|  |  |  | log.error("待办通知发送失败,失败原因:{}"+err.message); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } catch (Exception _err) { | 
|---|
|  |  |  | TeaException err = new TeaException(_err.getMessage(), _err); | 
|---|
|  |  |  | if (!com.aliyun.teautil.Common.empty(err.code) && !com.aliyun.teautil.Common.empty(err.message)) { | 
|---|
|  |  |  | // err 中含有 code 和 message 属性,可帮助开发定位问题 | 
|---|
|  |  |  | log.error("待办通知发送失败,失败原因:{}"+err.message); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return null; | 
|---|
|  |  |  | }catch (Exception e){ | 
|---|
|  |  |  | throw  new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"钉钉待办任务通知发送失败"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return null; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 处理全部人的待办信息 | 
|---|
|  |  |  | * 处理全部人的待办信息 (流程审批完成、本级审批完成 使用) | 
|---|
|  |  |  | * @param unionId | 
|---|
|  |  |  | * @param taskId | 
|---|
|  |  |  | * api地址 https://open.dingtalk.com/document/orgapp/updates-dingtalk-to-do-tasks | 
|---|
|  |  |  | * @throws Exception | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public void updToDoNoticeInfoStatus(String unionId,String taskId) throws Exception { | 
|---|
|  |  |  | com.aliyun.dingtalktodo_1_0.Client client = DingTalk.createV1Client(); | 
|---|
|  |  |  | UpdateTodoTaskHeaders updateTodoTaskHeaders = new UpdateTodoTaskHeaders(); | 
|---|
|  |  |  | updateTodoTaskHeaders.xAcsDingtalkAccessToken = "43cf8213909f34ef81e7447905b822fb";//getToken(); | 
|---|
|  |  |  | UpdateTodoTaskRequest updateTodoTaskRequest = new UpdateTodoTaskRequest() | 
|---|
|  |  |  | .setOperatorId(unionId) | 
|---|
|  |  |  | .setDone(true); | 
|---|
|  |  |  | public void updToDoNoticeInfoStatus(String unionId,String taskId){ | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | com.aliyun.dingtalktodo_1_0.Client client = DingTalk.createV1Client(); | 
|---|
|  |  |  | UpdateTodoTaskHeaders updateTodoTaskHeaders = new UpdateTodoTaskHeaders(); | 
|---|
|  |  |  | updateTodoTaskHeaders.xAcsDingtalkAccessToken = getToken(); | 
|---|
|  |  |  | UpdateTodoTaskRequest updateTodoTaskRequest = new UpdateTodoTaskRequest() | 
|---|
|  |  |  | .setOperatorId(unionId) | 
|---|
|  |  |  | .setDone(true); | 
|---|
|  |  |  | UpdateTodoTaskResponse response = client.updateTodoTaskWithOptions(unionId, taskId, updateTodoTaskRequest, updateTodoTaskHeaders, new RuntimeOptions()); | 
|---|
|  |  |  | log.error("待办通知发送成功,发送内容:{}"+JSONObject.toJSONString(response)); | 
|---|
|  |  |  | } catch (TeaException err) { | 
|---|
|  |  |  | 
|---|
|  |  |  | // err 中含有 code 和 message 属性,可帮助开发定位问题 | 
|---|
|  |  |  | log.error("待办通知发送失败,失败原因:{}"+err.message); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } catch (Exception _err) { | 
|---|
|  |  |  | TeaException err = new TeaException(_err.getMessage(), _err); | 
|---|
|  |  |  | if (!com.aliyun.teautil.Common.empty(err.code) && !com.aliyun.teautil.Common.empty(err.message)) { | 
|---|
|  |  |  | 
|---|
|  |  |  | * api 地址 https://open.dingtalk.com/document/orgapp/update-dingtalk-to-do-status | 
|---|
|  |  |  | * @throws Exception | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public void updUserToDoNoticeInfoStatus(String unionId,String taskId,String dealUnionId) throws Exception { | 
|---|
|  |  |  | com.aliyun.dingtalktodo_1_0.Client client = DingTalk.createV1Client(); | 
|---|
|  |  |  | UpdateTodoTaskExecutorStatusHeaders updateTodoTaskExecutorStatusHeaders = new UpdateTodoTaskExecutorStatusHeaders(); | 
|---|
|  |  |  | updateTodoTaskExecutorStatusHeaders.xAcsDingtalkAccessToken = "43cf8213909f34ef81e7447905b822fb";//getToken(); | 
|---|
|  |  |  | UpdateTodoTaskExecutorStatusRequest.UpdateTodoTaskExecutorStatusRequestExecutorStatusList executorStatusList0 = new UpdateTodoTaskExecutorStatusRequest.UpdateTodoTaskExecutorStatusRequestExecutorStatusList() | 
|---|
|  |  |  | .setId(dealUnionId) | 
|---|
|  |  |  | .setIsDone(true); | 
|---|
|  |  |  | UpdateTodoTaskExecutorStatusRequest updateTodoTaskExecutorStatusRequest = new UpdateTodoTaskExecutorStatusRequest() | 
|---|
|  |  |  | .setExecutorStatusList(java.util.Arrays.asList( | 
|---|
|  |  |  | executorStatusList0 | 
|---|
|  |  |  | )); | 
|---|
|  |  |  | public void updUserToDoNoticeInfoStatus(String unionId,String taskId,String dealUnionId){ | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | com.aliyun.dingtalktodo_1_0.Client client = DingTalk.createV1Client(); | 
|---|
|  |  |  | UpdateTodoTaskExecutorStatusHeaders updateTodoTaskExecutorStatusHeaders = new UpdateTodoTaskExecutorStatusHeaders(); | 
|---|
|  |  |  | updateTodoTaskExecutorStatusHeaders.xAcsDingtalkAccessToken = getToken(); | 
|---|
|  |  |  | UpdateTodoTaskExecutorStatusRequest.UpdateTodoTaskExecutorStatusRequestExecutorStatusList executorStatusList0 = new UpdateTodoTaskExecutorStatusRequest.UpdateTodoTaskExecutorStatusRequestExecutorStatusList() | 
|---|
|  |  |  | .setId(dealUnionId) | 
|---|
|  |  |  | .setIsDone(true); | 
|---|
|  |  |  | UpdateTodoTaskExecutorStatusRequest updateTodoTaskExecutorStatusRequest = new UpdateTodoTaskExecutorStatusRequest() | 
|---|
|  |  |  | .setExecutorStatusList(java.util.Arrays.asList( | 
|---|
|  |  |  | executorStatusList0 | 
|---|
|  |  |  | )); | 
|---|
|  |  |  | UpdateTodoTaskExecutorStatusResponse response = client.updateTodoTaskExecutorStatusWithOptions(unionId, taskId, updateTodoTaskExecutorStatusRequest, updateTodoTaskExecutorStatusHeaders, new RuntimeOptions()); | 
|---|
|  |  |  | log.error("待办通知发送成功,发送内容:{}"+JSONObject.toJSONString(response)); | 
|---|
|  |  |  | } catch (TeaException err) { | 
|---|
|  |  |  | 
|---|
|  |  |  | carUseBook.setType(Constants.ZERO); | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | dingTalk.workInfoOANotice(4015267031L,"1568490244651036",dingTalk.getCarUseNoticeMsg(carUseBook,"用车申请")); | 
|---|
|  |  |  | //        dingTalk.workInfoOANotice(4015267031L,"1568490244651036",dingTalk.getCarUseNoticeMsg(carUseBook,"用车申请")); | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //        dingTalk.toDoNotice("小豆丁提交的公务车用车",java.util.Arrays.asList("iPsP86axviPHiSP4nm5YgQNCQiEiE","XiPYJKRAv9eCoO4UPM20HQQiEiE","eWbHiSp3uRtrMtiiOX5LXamgiEiE") ,dingTalk.getToDoCarUseBookFiledInfo(carUseBook)); | 
|---|
|  |  |  | dingTalk.toDoNotice("小豆丁提交的公务车用车",java.util.Arrays.asList("iPsP86axviPHiSP4nm5YgQNCQiEiE","XiPYJKRAv9eCoO4UPM20HQQiEiE","eWbHiSp3uRtrMtiiOX5LXamgiEiE") ,dingTalk.getToDoCarUseBookFiledInfo(carUseBook),""); | 
|---|
|  |  |  | // | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //        dingTalk.updUserToDoNoticeInfoStatus("iPsP86axviPHiSP4nm5YgQNCQiEiE", | 
|---|