forked from github/dataease
Merge pull request #3086 from dataease/pr@dev@perf_report_msg_channel
perf(系统管理-定时报告): 优化企业微信、钉钉消息渠道
This commit is contained in:
commit
96fec55cf4
@ -115,7 +115,7 @@ public class SystemParameterController {
|
||||
return GlobalFileUtil.down(fileId, fileName);
|
||||
}
|
||||
|
||||
@GetMapping("/showpicture/{fileId}")
|
||||
@GetMapping(value = "/showpicture/{fileId}", produces = {MediaType.IMAGE_JPEG_VALUE, MediaType.IMAGE_PNG_VALUE})
|
||||
public ResponseEntity<byte[]> showPicture(@PathVariable("fileId") String fileId) throws Exception {
|
||||
|
||||
return GlobalFileUtil.showPicture(fileId);
|
||||
|
@ -5,6 +5,7 @@ import io.dataease.auth.entity.TokenInfo;
|
||||
import io.dataease.auth.service.AuthUserService;
|
||||
import io.dataease.auth.service.impl.AuthUserServiceImpl;
|
||||
import io.dataease.auth.util.JWTUtils;
|
||||
import io.dataease.commons.exception.DEException;
|
||||
import io.dataease.dto.PermissionProxy;
|
||||
import io.dataease.ext.ExtTaskMapper;
|
||||
import io.dataease.commons.utils.CommonBeanFactory;
|
||||
@ -16,10 +17,16 @@ import io.dataease.job.sechedule.strategy.TaskHandler;
|
||||
import io.dataease.plugins.common.entity.GlobalTaskEntity;
|
||||
import io.dataease.plugins.common.entity.GlobalTaskInstance;
|
||||
import io.dataease.plugins.config.SpringContextUtil;
|
||||
import io.dataease.plugins.xpack.dingtalk.dto.entity.DingtalkMsgResult;
|
||||
import io.dataease.plugins.xpack.dingtalk.service.DingtalkXpackService;
|
||||
import io.dataease.plugins.xpack.email.dto.request.XpackEmailTaskRequest;
|
||||
import io.dataease.plugins.xpack.email.dto.request.XpackPixelEntity;
|
||||
import io.dataease.plugins.xpack.email.dto.response.XpackEmailTemplateDTO;
|
||||
import io.dataease.plugins.xpack.email.service.EmailXpackService;
|
||||
import io.dataease.plugins.xpack.lark.dto.entity.LarkMsgResult;
|
||||
import io.dataease.plugins.xpack.lark.service.LarkXpackService;
|
||||
import io.dataease.plugins.xpack.wecom.dto.entity.WecomMsgResult;
|
||||
import io.dataease.plugins.xpack.wecom.service.WecomXpackService;
|
||||
import io.dataease.service.chart.ViewExportExcel;
|
||||
import io.dataease.service.system.EmailService;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
@ -30,6 +37,7 @@ import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
@ -177,8 +185,53 @@ public class EmailTaskHandler extends TaskHandler implements Job {
|
||||
files = viewExportExcel.export(panelId, viewIdList, proxy);
|
||||
}
|
||||
|
||||
emailService.sendWithImageAndFiles(recipients, emailTemplateDTO.getTitle(), contentStr, bytes, files);
|
||||
List<String> channels = null;
|
||||
String recisetting = emailTemplateDTO.getRecisetting();
|
||||
if (StringUtils.isBlank(recisetting)) {
|
||||
channels = new ArrayList<>();
|
||||
channels.add("email");
|
||||
} else {
|
||||
channels = Arrays.stream(recisetting.split(",")).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
List<String> reciLists = Arrays.stream(recipients.split(",")).collect(Collectors.toList());
|
||||
for (int i = 0; i < channels.size(); i++) {
|
||||
String channel = channels.get(i);
|
||||
switch (channel) {
|
||||
case "email" :
|
||||
emailService.sendWithImageAndFiles(recipients, emailTemplateDTO.getTitle(), contentStr, bytes, files);
|
||||
break;
|
||||
case "wecom" :
|
||||
if (SpringContextUtil.getBean(AuthUserService.class).supportWecom()) {
|
||||
WecomXpackService wecomXpackService = SpringContextUtil.getBean(WecomXpackService.class);
|
||||
WecomMsgResult wecomMsgResult = wecomXpackService.pushOaMsg(reciLists, emailTemplateDTO.getTitle(), contentStr, bytes, files);
|
||||
if (wecomMsgResult.getErrcode() != 0) {
|
||||
DEException.throwException(wecomMsgResult.getErrmsg());
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "dingtalk" :
|
||||
if (SpringContextUtil.getBean(AuthUserService.class).supportDingtalk()) {
|
||||
DingtalkXpackService dingtalkXpackService = SpringContextUtil.getBean(DingtalkXpackService.class);
|
||||
DingtalkMsgResult dingtalkMsgResult = dingtalkXpackService.pushOaMsg(reciLists, emailTemplateDTO.getTitle(), contentStr, bytes, files);
|
||||
if (dingtalkMsgResult.getErrcode() != 0) {
|
||||
DEException.throwException(dingtalkMsgResult.getErrmsg());
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "lark" :
|
||||
if (SpringContextUtil.getBean(AuthUserService.class).supportLark()) {
|
||||
LarkXpackService larkXpackService = SpringContextUtil.getBean(LarkXpackService.class);
|
||||
LarkMsgResult larkMsgResult = larkXpackService.pushOaMsg(reciLists, emailTemplateDTO.getTitle(), contentStr, bytes, files);
|
||||
if (larkMsgResult.getCode() != 0) {
|
||||
DEException.throwException(larkMsgResult.getMsg());
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
success(taskInstance);
|
||||
} catch (Exception e) {
|
||||
error(taskInstance, e);
|
||||
@ -186,6 +239,7 @@ public class EmailTaskHandler extends TaskHandler implements Job {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private XpackPixelEntity buildPixel(XpackEmailTemplateDTO emailTemplateDTO) {
|
||||
XpackPixelEntity pixelEntity = new XpackPixelEntity();
|
||||
String pixelStr = emailTemplateDTO.getPixel();
|
||||
|
Loading…
Reference in New Issue
Block a user