package com.matrix.component.dingding; 
 | 
  
 | 
import com.dingtalk.api.DefaultDingTalkClient; 
 | 
import com.dingtalk.api.DingTalkClient; 
 | 
import com.dingtalk.api.request.OapiMessageCorpconversationAsyncsendV2Request; 
 | 
import com.dingtalk.api.response.OapiMessageCorpconversationAsyncsendV2Response; 
 | 
import com.matrix.core.tools.LogUtil; 
 | 
import com.taobao.api.ApiException; 
 | 
  
 | 
  
 | 
/** 
 | 
 * @author jiangyouyao 
 | 
 * @description 钉钉消息发送封装工具 
 | 
 */ 
 | 
public class MessageSendUtil { 
 | 
  
 | 
    public static void sendOAMsg(String accessToken, String userList, OapiMessageCorpconversationAsyncsendV2Request.Msg msg) { 
 | 
        DingTalkClient client = new DefaultDingTalkClient( 
 | 
                "https://oapi.dingtalk.com/topapi/message/corpconversation/asyncsend_v2"); 
 | 
        OapiMessageCorpconversationAsyncsendV2Request request = new OapiMessageCorpconversationAsyncsendV2Request(); 
 | 
        request.setUseridList(userList); 
 | 
        request.setAgentId(DDEnvConfig.AGENT_ID); 
 | 
        request.setToAllUser(false); 
 | 
        request.setMsg(msg); 
 | 
        try { 
 | 
            OapiMessageCorpconversationAsyncsendV2Response response = client.execute(request, accessToken); 
 | 
        } catch (ApiException e) { 
 | 
            LogUtil.error("钉钉消息发送失败",e); 
 | 
        } 
 | 
    } 
 | 
  
 | 
} 
 |