zhangheng 3 rokov pred
rodič
commit
66621b95d4

+ 3 - 0
server/src/main/java/edp/core/utils/MailUtils.java

@@ -178,6 +178,7 @@ public class MailUtils {
 
             if (!emptyAttachments) {
                 mailContent.getAttachments().forEach(attachment -> {
+                    System.out.println("attachment>>>>" + attachment);
                     try {
                         if (attachment.isImage()) {
                             messageHelper.addInline(attachment.getName(), attachment.getFile());
@@ -194,10 +195,12 @@ public class MailUtils {
             }
 
             javaMailSender.send(message);
+            System.out.println("发送邮件中.........");
             if (customLogger != null) {
                 customLogger.info("Email sending content:{}, cost:{}", mailContent.toString(), watch.elapsed(TimeUnit.MILLISECONDS));
             }
         } catch (Exception e) {
+            e.printStackTrace();
             if (customLogger != null) {
                 customLogger.error("Send mail error:{}", e.getMessage());
             }

+ 33 - 2
server/src/main/java/edp/davinci/service/screenshot/ScreenshotUtil.java

@@ -87,18 +87,22 @@ public class ScreenshotUtil {
     private FileUtils fileUtils;
 
     public void screenshot(long jobId, List<ImageContent> imageContents, Integer imageWidth) {
+        System.out.println(">>>>>>>>>>>>>>imageContents>>>>>>>>>>>>>>>>"+imageContents.size());
     	scheduleLogger.info("Start screenshot for job({})", jobId);
         try {
         	int contentsSize = imageContents.size();
             List<Future> futures = new ArrayList<>(contentsSize);
             final AtomicInteger index = new AtomicInteger(1);
             imageContents.forEach(content -> futures.add(executorService.submit(() -> {
+                System.out.println(">>>>>>>>>>>>>>content>>>>>>>>>>>>>>>>"+content.getUrl());
             	scheduleLogger.info("Cronjob({}) thread({}) for screenshot start, type:{}, id:{}, total:{}", jobId, index.get(), content.getDesc(), content.getCId(), contentsSize);
                 try {
+                    System.out.println(">>>>>>>>>>>>>>生成图片>>>>>>>>>>>>>>>>");
                     File image = doScreenshot(jobId, content.getUrl(), imageWidth);
                     content.setContent(image);
+                    System.out.println(">>>>>>>>>>>>>>设置文件>>>>>>>>>>>>>>>>");
                 } catch (Exception e) {
-                	scheduleLogger.error("Cronjob({}) thread({}) screenshot error", jobId, index.get());
+                	scheduleLogger.error("Cronjob({}) thread( {}) screenshot error", jobId, index.get());
                 	scheduleLogger.error(e.getMessage(), e);
                 } finally {
                     scheduleLogger.info("Cronjob({}) thread({}) for screenshot finish, type:{}, id:{}, total:{}", jobId, index.get(), content.getDesc(), content.getCId(), contentsSize);
@@ -124,8 +128,9 @@ public class ScreenshotUtil {
     }
 
     private File doScreenshot(long jobId, String url, Integer imageWidth) throws Exception {
+        System.out.println(">>>>>>>jobId>>>>>>>>"+ jobId);
         WebDriver driver = generateWebDriver(jobId, imageWidth);
-
+        System.out.println(">>>>>>>url>>>>>>>>"+ url);
         driver.get(url);
         scheduleLogger.info("Cronjob({}) do screenshot url={}, timeout={} start", jobId, url, timeOutSecond);
         try {
@@ -218,6 +223,15 @@ public class ScreenshotUtil {
                 scheduleLogger.error(ex.toString(), ex);
             }
         }
+
+        if(isLinux()){
+            CHROME_DRIVER_PATH += "/linux";
+        }
+        if(isWindows()){
+            CHROME_DRIVER_PATH += "/window";
+        }
+        System.out.println("CHROME_DRIVER_PATH >>>> " + CHROME_DRIVER_PATH);
+
         File file = new File(CHROME_DRIVER_PATH);
         if (!file.canExecute()) {
             if (!file.setExecutable(true)) {
@@ -242,6 +256,23 @@ public class ScreenshotUtil {
         return new ChromeDriver(options);
     }
 
+    public static void main(String[] args) {
+
+        String OS = System.getProperty("os.name").toLowerCase();
+
+        System.out.println(OS);
+
+    }
+    public static boolean isLinux(){
+        String OS = System.getProperty("os.name").toLowerCase();
+        return OS.indexOf("linux")>=0;
+    }
+
+    public static boolean isWindows(){
+        String OS = System.getProperty("os.name").toLowerCase();
+        return OS.indexOf("windows")>=0;
+    }
+
     private WebDriver generatePhantomJsDriver() throws ExecutionException {
         File file = new File(PHANTOMJS_PATH);
         if (!file.canExecute()) {

+ 6 - 6
server/src/main/resources/application.yml

@@ -17,7 +17,7 @@
 davinci:
   version: 0.3-rc
 
-DAVINCI3_HOME: app
+DAVINCI3_HOME: app/
 
 file:
   userfiles-path: ${DAVINCI3_HOME}/userfiles/
@@ -70,8 +70,8 @@ spring:
     isEnable: true
 
       ## standalone config
-    host: ${REDIS_HOST:127.0.0.1}
-    port: ${REDIS_PORT:6379}
+    host: ${REDIS_HOST:61.132.52.38}
+    port: ${REDIS_PORT:20003}
 
       ## cluster config
       #  cluster:
@@ -147,7 +147,7 @@ spring:
 server:
   protocol: http
   address: ${SERVER_ADDR:127.0.0.1}
-  port: ${SERVER_PORT:8081}
+  port: ${SERVER_PORT:8080}
 
   servlet:
     context-path: /
@@ -194,8 +194,8 @@ source:
 screenshot:
   default_browser: CHROME
   timeout_second: 600
-  chromedriver_path: $your_chromedriver_path$
-  remote_webdriver_url: $your_remote_webdriver_url$
+  chromedriver_path: C:/Users/Administrator/Downloads/
+#  remote_webdriver_url: http://localhost:4446/wd/hub
 
 data-auth-center:
   channels:

BIN
server/src/main/resources/chrome-driver/linux/chromedriver