From f12aeb4bddd4d04ef40608a7ccece2f1285c06cc Mon Sep 17 00:00:00 2001 From: fit2cloud-chenyw Date: Mon, 20 Dec 2021 17:19:28 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20chrome-driver=E6=88=AA=E5=9B=BE=E5=88=86?= =?UTF-8?q?=E8=BE=A8=E7=8E=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../strategy/impl/EmailTaskHandler.java | 26 +++++++++---------- .../plugins/server/XEmailTaskServer.java | 17 +++++++----- 2 files changed, 22 insertions(+), 21 deletions(-) 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 775d4da38b..83172c2235 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,6 +1,5 @@ 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; @@ -26,11 +25,9 @@ import org.springframework.stereotype.Service; import javax.annotation.Resource; - @Service public class EmailTaskHandler extends TaskHandler implements Job { - private static final Integer RUNING = 0; private static final Integer SUCCESS = 1; private static final Integer ERROR = -1; @@ -38,7 +35,6 @@ public class EmailTaskHandler extends TaskHandler implements Job { @Resource private AuthUserServiceImpl authUserServiceImpl; - @Override protected JobDataMap jobDataMap(GlobalTaskEntity taskEntity) { JobDataMap jobDataMap = new JobDataMap(); @@ -54,7 +50,8 @@ public class EmailTaskHandler extends TaskHandler implements Job { @Override public void execute(JobExecutionContext context) throws JobExecutionException { // 插件没有加载 空转 - if (!CommonBeanFactory.getBean(AuthUserService.class).pluginLoaded()) return; + if (!CommonBeanFactory.getBean(AuthUserService.class).pluginLoaded()) + return; JobDataMap jobDataMap = context.getJobDetail().getJobDataMap(); GlobalTaskEntity taskEntity = (GlobalTaskEntity) jobDataMap.get("taskEntity"); @@ -74,7 +71,6 @@ public class EmailTaskHandler extends TaskHandler implements Job { } - public EmailTaskHandler proxy() { return CommonBeanFactory.getBean(EmailTaskHandler.class); } @@ -106,12 +102,13 @@ public class EmailTaskHandler extends TaskHandler implements Job { emailXpackService.saveInstance(taskInstance); } - @Async - public void sendReport(GlobalTaskInstance taskInstance, XpackEmailTemplateDTO emailTemplateDTO, SysUserEntity user) { + public void sendReport(GlobalTaskInstance taskInstance, XpackEmailTemplateDTO emailTemplateDTO, + SysUserEntity user) { EmailXpackService emailXpackService = SpringContextUtil.getBean(EmailXpackService.class); try { - byte[] bytes = emailXpackService.printData(panelUrl(emailTemplateDTO.getPanelId()), tokenByUser(user), buildPixel(emailTemplateDTO)); + byte[] bytes = emailXpackService.printData(panelUrl(emailTemplateDTO.getPanelId()), tokenByUser(user), + buildPixel(emailTemplateDTO)); // 下面继续执行发送邮件的 String recipients = emailTemplateDTO.getRecipients(); byte[] content = emailTemplateDTO.getContent(); @@ -131,12 +128,14 @@ public class EmailTaskHandler extends TaskHandler implements Job { private XpackPixelEntity buildPixel(XpackEmailTemplateDTO emailTemplateDTO) { XpackPixelEntity pixelEntity = new XpackPixelEntity(); String pixelStr = emailTemplateDTO.getPixel(); - if (StringUtils.isBlank(pixelStr)) return null; + if (StringUtils.isBlank(pixelStr)) + return null; String[] arr = pixelStr.split("\\*"); - if (arr.length != 2) return null; + if (arr.length != 2) + return null; try { - int x = Integer.parseInt(arr[0]); - int y = Integer.parseInt(arr[1]); + int x = Integer.parseInt(arr[0].trim()); + int y = Integer.parseInt(arr[1].trim()); pixelEntity.setX(String.valueOf(x)); pixelEntity.setY(String.valueOf(y)); return pixelEntity; @@ -145,7 +144,6 @@ public class EmailTaskHandler extends TaskHandler implements Job { } } - private String tokenByUser(SysUserEntity user) { TokenInfo tokenInfo = TokenInfo.builder().userId(user.getUserId()).username(user.getUsername()).build(); String token = JWTUtils.sign(tokenInfo, user.getPassword()); 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 ea5110e449..82462243e4 100644 --- a/backend/src/main/java/io/dataease/plugins/server/XEmailTaskServer.java +++ b/backend/src/main/java/io/dataease/plugins/server/XEmailTaskServer.java @@ -1,6 +1,5 @@ package io.dataease.plugins.server; - import com.github.pagehelper.Page; import com.github.pagehelper.PageHelper; import io.dataease.commons.exception.DEException; @@ -34,7 +33,8 @@ public class XEmailTaskServer { private ScheduleService scheduleService; @PostMapping("/queryTasks/{goPage}/{pageSize}") - public Pager> queryTask(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody XpackGridRequest request) { + public Pager> queryTask(@PathVariable int goPage, @PathVariable int pageSize, + @RequestBody XpackGridRequest request) { EmailXpackService emailXpackService = SpringContextUtil.getBean(EmailXpackService.class); Page page = PageHelper.startPage(goPage, pageSize, true); List tasks = emailXpackService.taskGrid(request); @@ -115,7 +115,8 @@ public class XEmailTaskServer { } @PostMapping("/queryInstancies/{goPage}/{pageSize}") - public Pager> instancesGrid(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody XpackGridRequest request) { + public Pager> instancesGrid(@PathVariable int goPage, @PathVariable int pageSize, + @RequestBody XpackGridRequest request) { EmailXpackService emailXpackService = SpringContextUtil.getBean(EmailXpackService.class); Page page = PageHelper.startPage(goPage, pageSize, true); List instances = emailXpackService.taskInstanceGrid(request); @@ -132,13 +133,15 @@ public class XEmailTaskServer { private XpackPixelEntity buildPixel(String pixel) { - if (StringUtils.isBlank(pixel)) return null; + if (StringUtils.isBlank(pixel)) + return null; String[] arr = pixel.split("\\*"); - if (arr.length != 2) return null; + if (arr.length != 2) + return null; try { XpackPixelEntity result = new XpackPixelEntity(); - int x = Integer.parseInt(arr[0]); - int y = Integer.parseInt(arr[1]); + int x = Integer.parseInt(arr[0].trim()); + int y = Integer.parseInt(arr[1].trim()); result.setX(String.valueOf(x)); result.setY(String.valueOf(y)); return result;