notice from markdown to action card
This commit is contained in:
parent
807738bd90
commit
a4b0c5fcbc
@ -56,7 +56,7 @@ public class AppleInventorySchedule {
|
||||
@Resource
|
||||
private DingTalkMsgPushUtils dingTalkMsgPushUtils;
|
||||
|
||||
@Scheduled(cron = "0 0/30 * * * ? ")
|
||||
@Scheduled(cron = "0 0/10 * * * ? ")
|
||||
public void appleInventoryMonitor() {
|
||||
if (!Boolean.TRUE.equals(appleInventoryMonitorSwitch)) {
|
||||
log.info(">>>>>>>>>>apple inventory monitor switch closed!<<<<<<<<<<");
|
||||
@ -131,7 +131,7 @@ public class AppleInventorySchedule {
|
||||
pushContentBuilder.append("**")
|
||||
.append(availableStoreName)
|
||||
.append("** <br />"));
|
||||
dingTalkMsgPushUtils.robotMarkdownMsgPush("苹果商店监控", pushContentBuilder.toString());
|
||||
dingTalkMsgPushUtils.robotMarkdownMsgPush("苹果商店监控", null, null, pushContentBuilder.toString());
|
||||
} catch (Exception e) {
|
||||
log.error("AppleMonitor error", e);
|
||||
}
|
||||
|
||||
@ -4,7 +4,6 @@ import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.TypeReference;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.cloud.context.config.annotation.RefreshScope;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
@ -50,9 +49,6 @@ public class NoticeSchedule {
|
||||
@Resource
|
||||
private INoticeLogService noticeLogService;
|
||||
|
||||
// @Value("${dingtalk.baogutang.agentId}")
|
||||
// private String agentId;
|
||||
|
||||
private static final String EDGE_X_REQUEST_URL = "https://art-api.edge-x.cn/api/v1/art/announcements?pageNum=1&pageSize=1";
|
||||
private static final String EDGE_REQUEST_URL = "https://art-api.heishiapp.com/api/v1/art/announcements?pageNum=1&pageSize=1";
|
||||
|
||||
@ -81,8 +77,8 @@ public class NoticeSchedule {
|
||||
log.info(">>>>>>>>>>notice :{} has already pushed<<<<<<<<<<", announcementsDto.getId());
|
||||
return;
|
||||
}
|
||||
String content = "# EDGE-X-" + announcementsDto.getTitle() + "\n\n + ")\n\n> 点击下方链接查看更多详情:\n\n[查看详情](" + "https://app.edge-x.cn/#/noticeDetail?noticeId=" + announcementsDto.getId() + ")";
|
||||
dingTalkMsgPushUtils.robotMarkdownMsgPush(announcementsDto.getTitle(), content);
|
||||
String content = "# EDGE-X-" + announcementsDto.getTitle() + "\n\n + ")\n\n>";
|
||||
dingTalkMsgPushUtils.robotMarkdownMsgPush(announcementsDto.getTitle(), "查看详情", "https://app.edge-x.cn/#/noticeDetail?noticeId=" + announcementsDto.getId(), content);
|
||||
// wxMsgPushService.msgPush(Message.CONTENT_TYPE_HTML, announcementsDto.getTitle(), announcementsDto.getContent(), wxMsgPushProperties.getTopicIds());
|
||||
noticeLogService.saveNotice(NoticeTypeEnum.EDGE_X, announcementsDto.getId(), announcementsDto.getType(), announcementsDto.getTitle(), announcementsDto.getCover(), "https://app.edge-x.cn/#/noticeDetail?noticeId=" + announcementsDto.getId(), announcementsDto.getCreator(), announcementsDto.getCreatedAt());
|
||||
|
||||
@ -114,8 +110,8 @@ public class NoticeSchedule {
|
||||
log.info(">>>>>>>>>>notice :{} has already pushed<<<<<<<<<<", announcementsDto.getId());
|
||||
return;
|
||||
}
|
||||
String content = "# EDGE-" + announcementsDto.getTitle() + "\n\n + ")\n\n> 点击下方链接查看更多详情:\n\n[查看详情](" + "https://activities-h5.heishiapp.com/#/noticeDetail?noticeId=" + announcementsDto.getId() + ")";
|
||||
dingTalkMsgPushUtils.robotMarkdownMsgPush(announcementsDto.getTitle(), content);
|
||||
String content = "# EDGE-" + announcementsDto.getTitle() + "\n\n + ")\n\n>";
|
||||
dingTalkMsgPushUtils.robotMarkdownMsgPush(announcementsDto.getTitle(), "查看详情", "https://activities-h5.heishiapp.com/#/noticeDetail?noticeId=" + announcementsDto.getId(), content);
|
||||
// wxMsgPushService.msgPush(Message.CONTENT_TYPE_HTML, announcementsDto.getTitle(), announcementsDto.getContent(), wxMsgPushProperties.getTopicIds());
|
||||
noticeLogService.saveNotice(NoticeTypeEnum.EDGE, announcementsDto.getId(), announcementsDto.getType(), announcementsDto.getTitle(), announcementsDto.getCover(), "https://activities-h5.heishiapp.com/#/noticeDetail?noticeId=" + announcementsDto.getId(), announcementsDto.getCreator(), announcementsDto.getCreatedAt());
|
||||
}
|
||||
|
||||
@ -134,7 +134,7 @@ public class DingTalkMsgPushUtils {
|
||||
}
|
||||
|
||||
|
||||
public void robotMarkdownMsgPush(String title, String content) {
|
||||
public void robotMarkdownMsgPush(String title, String singleTitle, String singleUrl, String content) {
|
||||
// 计算签名
|
||||
long timestamp = System.currentTimeMillis();
|
||||
String sign = this.sign(timestamp);
|
||||
@ -142,13 +142,16 @@ public class DingTalkMsgPushUtils {
|
||||
DingTalkClient client = new DefaultDingTalkClient(url);
|
||||
OapiRobotSendRequest request = new OapiRobotSendRequest();
|
||||
OapiRobotSendRequest.At at = new OapiRobotSendRequest.At();
|
||||
at.setIsAtAll(true);
|
||||
at.setIsAtAll(false);
|
||||
request.setAt(at);
|
||||
request.setMsgtype(DingTalkMsgTypeEnum.MARKDOWN.getType());
|
||||
OapiRobotSendRequest.Markdown markdown = new OapiRobotSendRequest.Markdown();
|
||||
markdown.setTitle(title);
|
||||
markdown.setText(content);
|
||||
request.setMarkdown(markdown);
|
||||
request.setMsgtype(DingTalkMsgTypeEnum.ACTION_CARD.getType());
|
||||
OapiRobotSendRequest.Actioncard actioncard = new OapiRobotSendRequest.Actioncard();
|
||||
actioncard.setBtnOrientation("0");
|
||||
actioncard.setSingleTitle(singleTitle);
|
||||
actioncard.setSingleURL(singleUrl);
|
||||
actioncard.setText(content);
|
||||
actioncard.setTitle(title);
|
||||
request.setActionCard(actioncard);
|
||||
OapiRobotSendResponse response = null;
|
||||
try {
|
||||
response = client.execute(request);
|
||||
@ -156,7 +159,6 @@ public class DingTalkMsgPushUtils {
|
||||
log.error(">>>>>>>>>>robot msg send error:{}<<<<<<<<<<", e.getMessage(), e);
|
||||
}
|
||||
log.info(">>>>>>>>>>robot msg send request:{}, response:{}<<<<<<<<<<", JSON.toJSONString(request), JSON.toJSONString(response));
|
||||
|
||||
}
|
||||
|
||||
private String sign(Long timestamp) {
|
||||
|
||||
@ -45,7 +45,7 @@ public enum DingTalkMsgTypeEnum {
|
||||
/**
|
||||
* 卡片消息
|
||||
*/
|
||||
ACTION_CARD("action_card"),
|
||||
ACTION_CARD("actionCard"),
|
||||
|
||||
;
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user