forked from github/dataease
feat: 定时报告发送至飞书群聊
This commit is contained in:
parent
a0be293ca9
commit
5cc0262f97
@ -215,6 +215,13 @@ public class EmailTaskHandler extends TaskHandler implements Job {
|
||||
files = viewExportExcel.export(panelId, viewIdList, proxy, justExportView, taskInstance.getTaskId().toString());
|
||||
}
|
||||
|
||||
List<String> groupList = null;
|
||||
if (StringUtils.isNotBlank(emailTemplateDTO.getGroups())) {
|
||||
String groups = emailTemplateDTO.getGroups();
|
||||
groupList = Arrays.stream(groups.split(",")).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
byte[] bytes = null;
|
||||
List<String> channels = null;
|
||||
String recisetting = emailTemplateDTO.getRecisetting();
|
||||
if (StringUtils.isBlank(recisetting)) {
|
||||
@ -233,10 +240,10 @@ public class EmailTaskHandler extends TaskHandler implements Job {
|
||||
try {
|
||||
Integer panelFormat = emailTemplateDTO.getPanelFormat();
|
||||
if (ObjectUtils.isEmpty(panelFormat) || panelFormat == 0) {
|
||||
byte[] bytes = emailXpackService.printData(url, token, xpackPixelEntity);
|
||||
bytes = emailXpackService.printData(url, token, xpackPixelEntity);
|
||||
emailService.sendWithImageAndFiles(recipients, emailTemplateDTO.getTitle(), contentStr, bytes, files);
|
||||
} else {
|
||||
byte[] bytes = emailXpackService.printPdf(url, token, xpackPixelEntity, false, true);
|
||||
bytes = emailXpackService.printPdf(url, token, xpackPixelEntity, false, true);
|
||||
emailService.sendPdfWithFiles(recipients, emailTemplateDTO.getTitle(), contentStr, bytes, files);
|
||||
}
|
||||
|
||||
@ -260,7 +267,7 @@ public class EmailTaskHandler extends TaskHandler implements Job {
|
||||
|
||||
if (CollectionUtils.isNotEmpty(wecomUsers)) {
|
||||
WecomXpackService wecomXpackService = SpringContextUtil.getBean(WecomXpackService.class);
|
||||
byte[] bytes = emailXpackService.printData(url, token, xpackPixelEntity);
|
||||
bytes = emailXpackService.printData(url, token, xpackPixelEntity);
|
||||
WecomMsgResult wecomMsgResult = wecomXpackService.pushOaMsg(wecomUsers, emailTemplateDTO.getTitle(), contentStr, bytes, files);
|
||||
if (wecomMsgResult.getErrcode() != 0) {
|
||||
errorMsgs.add("wecom: " + wecomMsgResult.getErrmsg());
|
||||
@ -285,7 +292,7 @@ public class EmailTaskHandler extends TaskHandler implements Job {
|
||||
|
||||
if (CollectionUtils.isNotEmpty(dingTalkUsers)) {
|
||||
DingtalkXpackService dingtalkXpackService = SpringContextUtil.getBean(DingtalkXpackService.class);
|
||||
byte[] bytes = emailXpackService.printData(url, token, xpackPixelEntity);
|
||||
bytes = emailXpackService.printData(url, token, xpackPixelEntity);
|
||||
DingtalkMsgResult dingtalkMsgResult = dingtalkXpackService.pushOaMsg(dingTalkUsers, emailTemplateDTO.getTitle(), contentStr, bytes, files);
|
||||
if (dingtalkMsgResult.getErrcode() != 0) {
|
||||
errorMsgs.add("dingtalk: " + dingtalkMsgResult.getErrmsg());
|
||||
@ -310,7 +317,7 @@ public class EmailTaskHandler extends TaskHandler implements Job {
|
||||
|
||||
if (CollectionUtils.isNotEmpty(larkUsers)) {
|
||||
LarkXpackService larkXpackService = SpringContextUtil.getBean(LarkXpackService.class);
|
||||
byte[] bytes = emailXpackService.printData(url, token, xpackPixelEntity);
|
||||
bytes = emailXpackService.printData(url, token, xpackPixelEntity);
|
||||
LarkMsgResult larkMsgResult = larkXpackService.pushOaMsg(larkUsers, emailTemplateDTO.getTitle(), contentStr, bytes, files);
|
||||
if (larkMsgResult.getCode() != 0) {
|
||||
errorMsgs.add("lark: " + larkMsgResult.getMsg());
|
||||
@ -335,7 +342,7 @@ public class EmailTaskHandler extends TaskHandler implements Job {
|
||||
|
||||
if (CollectionUtils.isNotEmpty(larksuiteUsers)) {
|
||||
LarksuiteXpackService larksuiteXpackService = SpringContextUtil.getBean(LarksuiteXpackService.class);
|
||||
byte[] bytes = emailXpackService.printData(url, token, xpackPixelEntity);
|
||||
bytes = emailXpackService.printData(url, token, xpackPixelEntity);
|
||||
LarksuiteMsgResult larksuiteMsgResult = larksuiteXpackService.pushOaMsg(larksuiteUsers, emailTemplateDTO.getTitle(), contentStr, bytes, files);
|
||||
if (larksuiteMsgResult.getCode() != 0) {
|
||||
errorMsgs.add("larksuite: " + larksuiteMsgResult.getMsg());
|
||||
@ -348,6 +355,20 @@ public class EmailTaskHandler extends TaskHandler implements Job {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (SpringContextUtil.getBean(AuthUserService.class).supportLark() && CollectionUtils.isNotEmpty(groupList)) {
|
||||
LarkXpackService larkXpackService = SpringContextUtil.getBean(LarkXpackService.class);
|
||||
if (ObjectUtils.isEmpty(bytes)) {
|
||||
bytes = emailXpackService.printData(url, token, xpackPixelEntity);
|
||||
}
|
||||
List<LarkMsgResult> larkMsgResultList = larkXpackService.pushChatOaMsg(groupList, emailTemplateDTO.getTitle(), contentStr, bytes, files);
|
||||
larkMsgResultList.forEach(larkMsgResult -> {
|
||||
if (larkMsgResult.getCode() != 0) {
|
||||
LogUtil.error(larkMsgResult.getMsg());
|
||||
errorMsgs.add("lark: " + larkMsgResult.getMsg());
|
||||
}
|
||||
});
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(errorMsgs)) {
|
||||
String msg = errorMsgs.stream().collect(Collectors.joining(" \n "));
|
||||
Exception exception = new RuntimeException(msg);
|
||||
|
@ -14,9 +14,9 @@ import io.dataease.exception.DataEaseException;
|
||||
import io.dataease.i18n.Translator;
|
||||
import io.dataease.plugins.common.base.domain.SysUserAssist;
|
||||
import io.dataease.plugins.common.util.SpringContextUtil;
|
||||
|
||||
import io.dataease.plugins.xpack.display.dto.response.SysSettingDto;
|
||||
import io.dataease.plugins.xpack.lark.dto.entity.LarkAppUserEntity;
|
||||
import io.dataease.plugins.xpack.lark.dto.entity.LarkGroupResult;
|
||||
import io.dataease.plugins.xpack.lark.dto.entity.LarkQrResult;
|
||||
import io.dataease.plugins.xpack.lark.dto.entity.LarkUserInfo;
|
||||
import io.dataease.plugins.xpack.lark.dto.response.LarkAppUserResult;
|
||||
@ -240,4 +240,12 @@ public class XLarkServer {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ResponseBody
|
||||
@GetMapping("/group")
|
||||
public LarkGroupResult group() {
|
||||
LarkXpackService larkXpackService = SpringContextUtil.getBean(LarkXpackService.class);
|
||||
return larkXpackService.getGroup();
|
||||
}
|
||||
}
|
||||
|
@ -2775,7 +2775,8 @@ export default {
|
||||
range_view: 'Displayed data',
|
||||
range_all: 'All data',
|
||||
execute_now: 'Execute now',
|
||||
fire_now_success: 'Task executing'
|
||||
fire_now_success: 'Task executing',
|
||||
larkgroups: 'Lark group'
|
||||
},
|
||||
dynamic_time: {
|
||||
set_default: 'Set Default',
|
||||
|
@ -2767,7 +2767,8 @@ export default {
|
||||
range_view: '展示數據',
|
||||
range_all: '全部數據',
|
||||
execute_now: '立即執行',
|
||||
fire_now_success: '任務發起成功'
|
||||
fire_now_success: '任務發起成功',
|
||||
larkgroups: '飛書群'
|
||||
},
|
||||
dynamic_time: {
|
||||
set_default: '設置默認值',
|
||||
|
@ -2768,7 +2768,8 @@ export default {
|
||||
range_view: '展示数据',
|
||||
range_all: '全部数据',
|
||||
execute_now: '立即执行',
|
||||
fire_now_success: '任务发起成功'
|
||||
fire_now_success: '任务发起成功',
|
||||
larkgroups: '飞书群'
|
||||
},
|
||||
dynamic_time: {
|
||||
set_default: '设置默认值',
|
||||
|
@ -32,4 +32,6 @@ public class XpackEmailTaskRequest extends XpackTaskCreateRequest {
|
||||
private String conditions;
|
||||
|
||||
private String viewDataRange = "view";
|
||||
|
||||
private String groups;
|
||||
}
|
||||
|
@ -35,4 +35,6 @@ public class XpackEmailTemplateDTO implements Serializable {
|
||||
|
||||
private Boolean status;
|
||||
|
||||
private String groups;
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,16 @@
|
||||
package io.dataease.plugins.xpack.lark.dto.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class LarkGroupData implements Serializable {
|
||||
|
||||
private boolean has_more;
|
||||
|
||||
private String page_token;
|
||||
|
||||
private List<LarkGroupItem> items;
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
package io.dataease.plugins.xpack.lark.dto.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
public class LarkGroupHttpResult extends LarkBaseResult implements Serializable {
|
||||
|
||||
private LarkGroupData data;
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
package io.dataease.plugins.xpack.lark.dto.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
public class LarkGroupItem implements Serializable {
|
||||
|
||||
private String chat_id;
|
||||
|
||||
private String name;
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
package io.dataease.plugins.xpack.lark.dto.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class LarkGroupResult implements Serializable {
|
||||
|
||||
private boolean valid;
|
||||
|
||||
private List<LarkGroupItem> groupList;
|
||||
}
|
@ -2,13 +2,13 @@ package io.dataease.plugins.xpack.lark.service;
|
||||
|
||||
import io.dataease.plugins.common.service.PluginComponentService;
|
||||
import io.dataease.plugins.xpack.display.dto.response.SysSettingDto;
|
||||
import io.dataease.plugins.xpack.lark.dto.entity.LarkGroupResult;
|
||||
import io.dataease.plugins.xpack.lark.dto.entity.LarkMsgResult;
|
||||
import io.dataease.plugins.xpack.lark.dto.entity.LarkQrResult;
|
||||
import io.dataease.plugins.xpack.lark.dto.entity.LarkUserInfo;
|
||||
import io.dataease.plugins.xpack.lark.dto.response.LarkAppUserResult;
|
||||
import io.dataease.plugins.xpack.lark.dto.response.LarkInfo;
|
||||
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
@ -33,4 +33,8 @@ public abstract class LarkXpackService extends PluginComponentService {
|
||||
public abstract LarkMsgResult pushMsg(List<String> userIds, String message);
|
||||
|
||||
public abstract LarkMsgResult pushOaMsg(List<String> userIds, String title, String content, byte[] bytes, List<File> files);
|
||||
|
||||
public abstract List<LarkMsgResult> pushChatOaMsg(List<String> groupList, String title, String content, byte[] bytes, List<File> files);
|
||||
|
||||
public abstract LarkGroupResult getGroup();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user