fix(项目报告): 定时任务发送的报告图像内容国际化优化
定时任务发送的报告图像内容根据创建用户所选择的语言而进行国际化优化
This commit is contained in:
parent
6cdc67b339
commit
75c6378c6c
|
@ -250,7 +250,7 @@ public class ReportStatisticsService {
|
|||
return reportStatisticsMapper.selectByExample(example);
|
||||
}
|
||||
|
||||
public String getImageContentById(ReportStatisticsWithBLOBs reportRecordId) {
|
||||
public String getImageContentById(ReportStatisticsWithBLOBs reportRecordId, String language) {
|
||||
ChromeUtils chromeUtils = ChromeUtils.getInstance();
|
||||
HeadlessRequest headlessRequest = new HeadlessRequest();
|
||||
BaseSystemConfigDTO baseInfo = CommonBeanFactory.getBean(SystemParameterService.class).getBaseInfo();
|
||||
|
@ -264,7 +264,7 @@ public class ReportStatisticsService {
|
|||
platformUrl += "/echartPic?shareId=" + reportRecordId.getId();
|
||||
headlessRequest.setUrl(platformUrl);
|
||||
headlessRequest.setRemoteDriverUrl(remoteDriverUrl);
|
||||
String imageData = chromeUtils.getImageInfo(headlessRequest);
|
||||
String imageData = chromeUtils.getImageInfo(headlessRequest, language);
|
||||
return imageData;
|
||||
}
|
||||
|
||||
|
|
|
@ -10,6 +10,8 @@ import org.openqa.selenium.chrome.ChromeOptions;
|
|||
import org.openqa.selenium.remote.RemoteWebDriver;
|
||||
|
||||
import java.net.URL;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class ChromeUtils {
|
||||
private static ChromeUtils chromeUtils = new ChromeUtils();
|
||||
|
@ -21,24 +23,26 @@ public class ChromeUtils {
|
|||
return chromeUtils;
|
||||
}
|
||||
|
||||
private synchronized WebDriver genWebDriver(HeadlessRequest headlessRequest) {
|
||||
private synchronized WebDriver genWebDriver(HeadlessRequest headlessRequest, String language) {
|
||||
if (headlessRequest.isEmpty()) {
|
||||
LogUtil.error("Headless request is null! " + JSON.toJSONString(headlessRequest));
|
||||
return null;
|
||||
}
|
||||
//初始化一个chrome浏览器实例driver
|
||||
ChromeOptions options = new ChromeOptions();
|
||||
options.addArguments("headless");
|
||||
options.addArguments("no-sandbox");
|
||||
options.addArguments("disable-gpu");
|
||||
options.addArguments("disable-features=NetworkService");
|
||||
options.addArguments("ignore-certificate-errors");
|
||||
options.addArguments("silent-launch");
|
||||
options.addArguments("disable-application-cache");
|
||||
options.addArguments("disable-web-security");
|
||||
options.addArguments("no-proxy-server");
|
||||
options.addArguments("disable-dev-shm-usage");
|
||||
options.addArguments("lang=zh_CN.UTF-8");
|
||||
|
||||
if (StringUtils.isEmpty(language)) {
|
||||
language = "zh-cn";
|
||||
}
|
||||
if (StringUtils.equalsAnyIgnoreCase(language, "zh-cn")) {
|
||||
Map<String, Object> optionMap = new HashMap<>();
|
||||
optionMap.put("intl.accept_languages", "zh-CN,en,en_US");
|
||||
options.setExperimentalOption("prefs", optionMap);
|
||||
} else if (StringUtils.equalsAnyIgnoreCase(language, "zh_tw")) {
|
||||
Map<String, Object> optionMap = new HashMap<>();
|
||||
optionMap.put("intl.accept_languages", "zh-TW,en,en_US");
|
||||
options.setExperimentalOption("prefs", optionMap);
|
||||
}
|
||||
|
||||
WebDriver driver = null;
|
||||
try {
|
||||
|
@ -55,8 +59,8 @@ public class ChromeUtils {
|
|||
return driver;
|
||||
}
|
||||
|
||||
public synchronized String getImageInfo(HeadlessRequest request) {
|
||||
WebDriver driver = this.genWebDriver(request);
|
||||
public synchronized String getImageInfo(HeadlessRequest request, String langurage) {
|
||||
WebDriver driver = this.genWebDriver(request, langurage);
|
||||
String files = null;
|
||||
if (driver != null) {
|
||||
try {
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit a618ef0fb1ae45790e0c7de9805c8ff17c9df5be
|
||||
Subproject commit fcc6073110adde4f6a67833046a7346721602fd0
|
Loading…
Reference in New Issue