Sfoglia il codice sorgente

修改准考证为绝对路径

sandm 2 giorni fa
parent
commit
70c21f9049
1 ha cambiato i file con 9 aggiunte e 9 eliminazioni
  1. 9 9
      app/Jobs/TicketJob.php

+ 9 - 9
app/Jobs/TicketJob.php

@@ -545,11 +545,11 @@ class TicketJob implements ShouldQueue
     }
 
     protected function fetch($data, $template, $type, $recruit = null){
-        $templateProcessor = new TemplateProcessor(base_path() . "/storage/app/public/" . $template);
+        $templateProcessor = new TemplateProcessor("/data/www/wwwroot/jucai/storage/app/public/" . $template);
         foreach ($data as $k => $v){
             if($k == 'avatar'){
-                if(file_exists(base_path() . '/public/' . $v)){
-                    $templateProcessor->setImageValue('avatar',['path' => base_path() . '/public/' . $v, 'width' => 200, 'height' => 150]);
+                if(file_exists('/data/www/wwwroot/jucai/public/' . $v)){
+                    $templateProcessor->setImageValue('avatar',['path' => '/data/www/wwwroot/jucai/public/' . $v, 'width' => 200, 'height' => 150]);
                 }else{
                     $templateProcessor->setImageValue('avatar',['path' => 'https://www.jucai.gov.cn/' . $v, 'width' => 200, 'height' => 150]);
                 }
@@ -566,7 +566,7 @@ class TicketJob implements ShouldQueue
             $date = date("Y-m-d",time());
         }
 
-        if(!is_dir(base_path() . "/storage/app/public/recruit/ticket/word/{$date}/{$name}/{$type}")){
+        if(!is_dir("/data/www/wwwroot/jucai/storage/app/public/recruit/ticket/word/{$date}/{$name}/{$type}")){
             Storage::makeDirectory("public/recruit/ticket/word/{$date}/{$name}/{$type}");
         }
 //        if(!is_dir(base_path() . "/storage/app/public/recruit/ticket/pdf/{$date}/{$name}/{$type}" )){
@@ -574,7 +574,7 @@ class TicketJob implements ShouldQueue
 //        }
 
         $filename = sha1($date . '_' . $data['realname'] . '_' . $data['card'] . '_' . $data['post']);
-        $word_url = base_path() . "/storage/app/public/recruit/ticket/word/{$date}/{$name}/{$type}/" . $filename . '.docx';
+        $word_url = "/data/www/wwwroot/jucai/storage/app/public/recruit/ticket/word/{$date}/{$name}/{$type}/" . $filename . '.docx';
         $templateProcessor->saveAs($word_url);//另存为
 //        $pdf_url = base_path() . "/storage/app/public/recruit/ticket/pdf/{$date}/{$name}/{$type}";
 //        shell_exec('export DISPLAY=:0.0');
@@ -591,7 +591,7 @@ class TicketJob implements ShouldQueue
             $date = date("Y-m-d",time());
         }
         $filename = $date . '_' . $data['realname'] . '_' . $data['card'] . '_' . $data['post'];
-        if(file_exists(base_path() . "/storage/app/public/recruit/ticket/word/{$date}/{$name}/{$type}/" . $filename . '.docx')){
+        if(file_exists("/data/www/wwwroot/jucai/storage/app/public/recruit/ticket/word/{$date}/{$name}/{$type}/" . $filename . '.docx')){
             echo $filename . "跳过\r\n";
             return true;
         }else{
@@ -608,11 +608,11 @@ class TicketJob implements ShouldQueue
             $name = uniqid();
             $date = date("Y-m-d",time());
         }
-        if(!is_dir(base_path() . "/storage/app/public/recruit/ticket/pdf/{$date}/{$name}/{$type}" )){
+        if(!is_dir("/data/www/wwwroot/jucai/storage/app/public/recruit/ticket/pdf/{$date}/{$name}/{$type}" )){
             Storage::makeDirectory("public/recruit/ticket/pdf/{$date}/{$name}/{$type}");
         }
-        $word_url = base_path() . "/storage/app/public/recruit/ticket/word/{$date}/{$name}/{$type}/*.docx";
-        $pdf_url = base_path() . "/storage/app/public/recruit/ticket/pdf/{$date}/{$name}/{$type}";
+        $word_url = "/data/www/wwwroot/jucai/storage/app/public/recruit/ticket/word/{$date}/{$name}/{$type}/*.docx";
+        $pdf_url = "/data/www/wwwroot/jucai/storage/app/public/recruit/ticket/pdf/{$date}/{$name}/{$type}";
         shell_exec('export DISPLAY=:0.0 && export HOME=/data/wwwroot &&libreoffice --headless --convert-to pdf:writer_pdf_Export ' . $word_url . ' --outdir ' . $pdf_url);
     }
 }