diff --git a/backend/pom.xml b/backend/pom.xml
index d7f33a9a94..cf9bf9be59 100644
--- a/backend/pom.xml
+++ b/backend/pom.xml
@@ -5,7 +5,7 @@
dataease-server
io.dataease
- 1.4.0
+ 1.5.0
4.0.0
diff --git a/backend/src/main/java/io/dataease/job/sechedule/strategy/impl/EmailTaskHandler.java b/backend/src/main/java/io/dataease/job/sechedule/strategy/impl/EmailTaskHandler.java
index 18afcb9b75..97ee372f35 100644
--- a/backend/src/main/java/io/dataease/job/sechedule/strategy/impl/EmailTaskHandler.java
+++ b/backend/src/main/java/io/dataease/job/sechedule/strategy/impl/EmailTaskHandler.java
@@ -1,18 +1,27 @@
package io.dataease.job.sechedule.strategy.impl;
+import io.dataease.auth.entity.SysUserEntity;
+import io.dataease.auth.entity.TokenInfo;
import io.dataease.auth.service.AuthUserService;
+import io.dataease.auth.util.JWTUtils;
+import io.dataease.commons.utils.CodingUtil;
import io.dataease.commons.utils.CommonBeanFactory;
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.email.dto.response.XpackEmailTemplateDTO;
import io.dataease.plugins.xpack.email.service.EmailXpackService;
import org.quartz.*;
+import org.springframework.core.env.Environment;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+
@Service
public class EmailTaskHandler extends TaskHandler implements Job {
@@ -21,12 +30,19 @@ public class EmailTaskHandler extends TaskHandler implements Job {
private static final Integer RUNING = 0;
+ private AuthUserService authUserService;
@Override
protected JobDataMap jobDataMap(GlobalTaskEntity taskEntity) {
JobDataMap jobDataMap = new JobDataMap();
jobDataMap.put("taskEntity", taskEntity);
+ EmailXpackService emailXpackService = SpringContextUtil.getBean(EmailXpackService.class);
+ XpackEmailTemplateDTO emailTemplateDTO = emailXpackService.emailTemplate(taskEntity.getTaskId());
+ jobDataMap.put("emailTemplate", emailTemplateDTO);
+
+ SysUserEntity creator = CommonBeanFactory.getBean(AuthUserService.class).getUserById(taskEntity.getCreator());
+ jobDataMap.put("creator", creator);
return jobDataMap;
}
@@ -41,7 +57,15 @@ public class EmailTaskHandler extends TaskHandler implements Job {
GlobalTaskInstance taskInstance = buildInstance(taskEntity);
Long instanceId = saveInstance(taskInstance);
taskInstance.setInstanceId(instanceId);
- proxy().printImage(taskEntity, taskInstance);
+
+
+ XpackEmailTemplateDTO emailTemplate = (XpackEmailTemplateDTO) jobDataMap.get("emailTemplate");
+
+
+ SysUserEntity creator = (SysUserEntity) jobDataMap.get("creator");
+
+ proxy().sendReport(taskEntity, taskInstance, emailTemplate, creator);
+
}
@@ -62,13 +86,37 @@ public class EmailTaskHandler extends TaskHandler implements Job {
return taskInstance;
}
- @Async
- public void printImage(GlobalTaskEntity taskEntity, GlobalTaskInstance taskInstance) {
- EmailXpackService emailXpackService = SpringContextUtil.getBean(EmailXpackService.class);
- emailXpackService.executeJob(taskEntity, taskInstance);
+
+ @Async
+ public void sendReport(GlobalTaskEntity taskEntity, GlobalTaskInstance taskInstance, XpackEmailTemplateDTO emailTemplateDTO, SysUserEntity user) {
+ EmailXpackService emailXpackService = SpringContextUtil.getBean(EmailXpackService.class);
+ String fileId = emailXpackService.print(panelUrl(emailTemplateDTO.getPanelId()), tokenByUser(user));
+ // 下面继续执行发送邮件的略记
+ String recipients = emailTemplateDTO.getRecipients();
+ byte[] content = emailTemplateDTO.getContent();
}
+ private String tokenByUser(SysUserEntity user) {
+ TokenInfo tokenInfo = TokenInfo.builder().userId(user.getUserId()).username(user.getUsername()).build();
+ String token = JWTUtils.sign(tokenInfo, user.getPassword());
+ return token;
+ }
+
+ private String panelUrl(String panelId) {
+ InetAddress ip = null;
+ try {
+ ip = InetAddress.getLocalHost();
+ } catch (UnknownHostException e) {
+ e.printStackTrace();
+ }
+ Environment environment = SpringContextUtil.getBean(Environment.class);
+ Integer port = environment.getProperty("server.port", Integer.class);
+ String url = "http://" + ip + ":"+port + "/#/preview/" + panelId;
+
+ return url;
+ }
+
}
diff --git a/backend/src/main/java/io/dataease/plugins/server/XEmailTaskServer.java b/backend/src/main/java/io/dataease/plugins/server/XEmailTaskServer.java
index 00e944f01f..96f9e660ea 100644
--- a/backend/src/main/java/io/dataease/plugins/server/XEmailTaskServer.java
+++ b/backend/src/main/java/io/dataease/plugins/server/XEmailTaskServer.java
@@ -3,6 +3,7 @@ package io.dataease.plugins.server;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
+import io.dataease.commons.utils.AuthUtils;
import io.dataease.commons.utils.BeanUtils;
import io.dataease.commons.utils.PageUtils;
import io.dataease.commons.utils.Pager;
@@ -42,6 +43,7 @@ public class XEmailTaskServer {
public void save(@RequestBody XpackEmailCreate param) throws Exception{
XpackEmailTaskRequest request = param.fillContent();
EmailXpackService emailXpackService = SpringContextUtil.getBean(EmailXpackService.class);
+ request.setCreator(AuthUtils.getUser().getUserId());
emailXpackService.save(request);
GlobalTaskEntity globalTask = BeanUtils.copyBean(new GlobalTaskEntity(), request);
scheduleService.addSchedule(globalTask);
diff --git a/frontend/pom.xml b/frontend/pom.xml
index a0d56dfe10..623e59b2c8 100644
--- a/frontend/pom.xml
+++ b/frontend/pom.xml
@@ -6,7 +6,7 @@
dataease-server
io.dataease
- 1.4.0
+ 1.5.0
4.0.0
diff --git a/pom.xml b/pom.xml
index 8ae328d1e5..adb32f27a7 100644
--- a/pom.xml
+++ b/pom.xml
@@ -4,7 +4,7 @@
4.0.0
io.dataease
dataease-server
- 1.4.0
+ 1.5.0
pom