use of com.topcom.cms.data.domain.WeChat in project topcom-cloud by 545314690.
the class WarningJob method sendWechat.
/**
* 发送微信
* @param page
* @param subject
* @param wangningLogId
*/
private void sendWechat(Page page, CustomSubject subject, Long wangningLogId) {
WarningTask warningTask = subject.getWarning();
logger.info("开始推送Wechat消息:" + subject.getName());
List<Contact> contacts = warningTask.getContacts();
Set<String> wechatSet = contacts.stream().filter(contact -> Contact.Type.WECHAT.equals(contact.getType())).map(contact -> contact.getAccount()).collect(Collectors.toSet());
WechatSendRequest wechatSendRequest = new WechatSendRequest();
JSONObject data = getData(page.getContent());
User user = userManager.findById(subject.getUserId());
// userName
setData(data, "name", user.getFullName() == null ? user.getUsername() : user.getFullName());
setData(data, "subjectName", subject.getName());
setData(data, "num", page.getTotalElements());
wechatSendRequest.setData(data);
wechatSendRequest.setTemplate_id(TEMPLATE_ID);
wechatSendRequest.setUrl(warningEmailSetting.getLogUrl());
if (wechatSet.size() > 0) {
for (String s : wechatSet) {
wechatSendRequest.setTouser(s);
wechatUtil.sendTemplate(JSONObject.fromObject(wechatSendRequest));
}
warningTask.setLastWarningDate(new Date());
warningManager.save(warningTask);
}
}
Aggregations