fix(系统管理-定时报告): 定时报告不带视图数据发送报错

This commit is contained in:
fit2cloud-chenyw 2022-08-02 21:53:39 +08:00
parent 850543f5c2
commit 0bc9d2de78
2 changed files with 12 additions and 5 deletions

View File

@ -168,12 +168,15 @@ public class EmailTaskHandler extends TaskHandler implements Job {
contentStr = new String(content, "UTF-8");
}
List<File> files = null;
String viewIds = emailTemplateDTO.getViewIds();
List<String> viewIdList = Arrays.asList(viewIds.split(",")).stream().map(s -> (s.trim())).collect(Collectors.toList());
PermissionProxy proxy = new PermissionProxy();
proxy.setUserId(user.getUserId());
List<File> files = viewExportExcel.export(panelId, viewIdList, proxy);
if (StringUtils.isNotBlank(viewIds)) {
List<String> viewIdList = Arrays.asList(viewIds.split(",")).stream().filter(StringUtils::isNotBlank).map(s -> (s.trim())).collect(Collectors.toList());
PermissionProxy proxy = new PermissionProxy();
proxy.setUserId(user.getUserId());
files = viewExportExcel.export(panelId, viewIdList, proxy);
}
emailService.sendWithImageAndFiles(recipients, emailTemplateDTO.getTitle(), contentStr, bytes, files);
success(taskInstance);

View File

@ -1,5 +1,6 @@
package io.dataease.service.chart;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
@ -39,6 +40,9 @@ public class ViewExportExcel {
@DePermissionProxy(paramIndex = 2)
public List<File> export(String panelId, List<String> viewIds, PermissionProxy proxy) throws Exception {
if (CollectionUtils.isEmpty(viewIds)) {
return null;
}
PanelGroupService panelGroupService = SpringContextUtil.getBean(PanelGroupService.class);
PanelGroupDTO panelDto = panelGroupService.findOne(panelId);