|
@@ -10,6 +10,9 @@ import com.ruoyi.common.core.domain.entity.SysUser;
|
|
|
import com.ruoyi.common.utils.StringUtils;
|
|
|
import com.ruoyi.system.service.ISysDeptService;
|
|
|
import com.ruoyi.system.service.ISysUserService;
|
|
|
+import com.ruoyi.system.service.impl.SysUserServiceImpl;
|
|
|
+import org.slf4j.Logger;
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
@@ -27,6 +30,8 @@ import java.util.*;
|
|
|
public class RyTask
|
|
|
{
|
|
|
|
|
|
+ private static final Logger log = LoggerFactory.getLogger(RyTask.class);
|
|
|
+
|
|
|
@Autowired
|
|
|
private ISysDeptService iSysDeptService;
|
|
|
|
|
@@ -51,8 +56,74 @@ public class RyTask
|
|
|
|
|
|
|
|
|
private String appkey = "dingmidxbep08wynpmtx";
|
|
|
+
|
|
|
+ private Long agentId = 1658484749L;
|
|
|
private String appSecret = "9_NL7MkSkxQJwlFp9wo2VX8oSxU55hxSOG2Xv8Vk6r_OcLATjMewPNRfPCIuXWNI";
|
|
|
|
|
|
+ public void setNotice(String userids,String content,String title,String url){
|
|
|
+ if(token.equals("")||(new Date().getTime()/1000 - tokentime)>exp){
|
|
|
+ getToken();
|
|
|
+ }
|
|
|
+ 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);
|
|
|
+
|
|
|
+ OapiMessageCorpconversationAsyncsendV2Request.Msg msg = new OapiMessageCorpconversationAsyncsendV2Request.Msg();
|
|
|
+// msg.setMsgtype("text");
|
|
|
+// msg.setText(new OapiMessageCorpconversationAsyncsendV2Request.Text());
|
|
|
+// msg.getText().setContent("test123");
|
|
|
+// request.setMsg(msg);
|
|
|
+
|
|
|
+// msg.setMsgtype("image");
|
|
|
+// msg.setImage(new OapiMessageCorpconversationAsyncsendV2Request.Image());
|
|
|
+// msg.getImage().setMediaId("@lADOdvRYes0CbM0CbA");
|
|
|
+// request.setMsg(msg);
|
|
|
+//
|
|
|
+// msg.setMsgtype("file");
|
|
|
+// msg.setFile(new OapiMessageCorpconversationAsyncsendV2Request.File());
|
|
|
+// msg.getFile().setMediaId("@lADOdvRYes0CbM0CbA");
|
|
|
+// request.setMsg(msg);
|
|
|
+//
|
|
|
+// msg.setMsgtype("link");
|
|
|
+// msg.setLink(new OapiMessageCorpconversationAsyncsendV2Request.Link());
|
|
|
+// msg.getLink().setTitle("test");
|
|
|
+// msg.getLink().setText("test");
|
|
|
+// msg.getLink().setMessageUrl("test");
|
|
|
+// msg.getLink().setPicUrl("test");
|
|
|
+// request.setMsg(msg);
|
|
|
+//
|
|
|
+// msg.setMsgtype("markdown");
|
|
|
+// msg.setMarkdown(new OapiMessageCorpconversationAsyncsendV2Request.Markdown());
|
|
|
+// msg.getMarkdown().setText("##### text");
|
|
|
+// msg.getMarkdown().setTitle("### Title");
|
|
|
+// request.setMsg(msg);
|
|
|
+
|
|
|
+// msg.setOa(new OapiMessageCorpconversationAsyncsendV2Request.OA());
|
|
|
+// msg.getOa().setHead(new OapiMessageCorpconversationAsyncsendV2Request.Head());
|
|
|
+// msg.getOa().getHead().setText("head");
|
|
|
+// msg.getOa().setBody(new OapiMessageCorpconversationAsyncsendV2Request.Body());
|
|
|
+// msg.getOa().getBody().setContent("xxx");
|
|
|
+// msg.setMsgtype("oa");
|
|
|
+// request.setMsg(msg);
|
|
|
+
|
|
|
+ msg.setActionCard(new OapiMessageCorpconversationAsyncsendV2Request.ActionCard());
|
|
|
+ msg.getActionCard().setTitle(title);
|
|
|
+ msg.getActionCard().setMarkdown(content==null?"### 有新工单啦":content);
|
|
|
+ msg.getActionCard().setSingleTitle("测试测试"+new Date().getTime());
|
|
|
+ msg.getActionCard().setSingleUrl(url);
|
|
|
+ msg.setMsgtype("action_card");
|
|
|
+ request.setMsg(msg);
|
|
|
+ OapiMessageCorpconversationAsyncsendV2Response rsp = client.execute(request, token);
|
|
|
+ log.debug("发送钉钉消息");
|
|
|
+
|
|
|
+ }catch (Exception e){
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
public SysUser getUserByCode(String code){
|
|
|
if(token.equals("")||(new Date().getTime()/1000 - tokentime)>exp){
|