forked from github/dataease
Merge pull request #1477 from dataease/pr@dev@fix_chrome_driver_pixel
fix: chrome-driver截图分辨率
This commit is contained in:
commit
9dfee5adf8
@ -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());
|
||||
|
@ -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<List<XpackTaskGridDTO>> queryTask(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody XpackGridRequest request) {
|
||||
public Pager<List<XpackTaskGridDTO>> queryTask(@PathVariable int goPage, @PathVariable int pageSize,
|
||||
@RequestBody XpackGridRequest request) {
|
||||
EmailXpackService emailXpackService = SpringContextUtil.getBean(EmailXpackService.class);
|
||||
Page<Object> page = PageHelper.startPage(goPage, pageSize, true);
|
||||
List<XpackTaskGridDTO> tasks = emailXpackService.taskGrid(request);
|
||||
@ -115,7 +115,8 @@ public class XEmailTaskServer {
|
||||
}
|
||||
|
||||
@PostMapping("/queryInstancies/{goPage}/{pageSize}")
|
||||
public Pager<List<XpackTaskInstanceDTO>> instancesGrid(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody XpackGridRequest request) {
|
||||
public Pager<List<XpackTaskInstanceDTO>> instancesGrid(@PathVariable int goPage, @PathVariable int pageSize,
|
||||
@RequestBody XpackGridRequest request) {
|
||||
EmailXpackService emailXpackService = SpringContextUtil.getBean(EmailXpackService.class);
|
||||
Page<Object> page = PageHelper.startPage(goPage, pageSize, true);
|
||||
List<XpackTaskInstanceDTO> 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;
|
||||
|
Loading…
Reference in New Issue
Block a user