|
...
|
...
|
@@ -11,7 +11,10 @@ namespace App\Console\Commands\Project; |
|
|
|
|
|
|
|
use App\Models\Domain\DomainInfo;
|
|
|
|
use App\Models\Project\Project;
|
|
|
|
use App\Models\WebSetting\WebSettingSeo;
|
|
|
|
use App\Services\ProjectServer;
|
|
|
|
use Illuminate\Console\Command;
|
|
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
|
|
|
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
|
|
|
|
|
|
...
|
...
|
@@ -31,15 +34,35 @@ class DownloadProject extends Command |
|
|
|
*/
|
|
|
|
protected $description = '导出项目数据';
|
|
|
|
|
|
|
|
// public function handle(){
|
|
|
|
// $projectModel = new Project();
|
|
|
|
// $data = $projectModel->formatQuery(['channel'=>['like','%"channel_id": "57"%'],'delete_status'=>0])->with(['deploy_optimize'])->get()->toArray();
|
|
|
|
// if(!empty($data)){
|
|
|
|
// $result = $this->exportData($data);
|
|
|
|
// }
|
|
|
|
// echo date('Y-m-d H:i:s') . ' ' . json_encode($result) . PHP_EOL;
|
|
|
|
// return $result;
|
|
|
|
//
|
|
|
|
// }
|
|
|
|
|
|
|
|
public function handle(){
|
|
|
|
$data = [];
|
|
|
|
$projectModel = new Project();
|
|
|
|
$data = $projectModel->formatQuery(['channel'=>['like','%"channel_id": "57"%'],'delete_status'=>0])->with(['deploy_optimize'])->get()->toArray();
|
|
|
|
if(!empty($data)){
|
|
|
|
$result = $this->exportData($data);
|
|
|
|
$projectList = $projectModel->list(['delete_status'=>0,'type'=>['in',[2,3]]],'id',['id','status','type','title','remain_day']);
|
|
|
|
foreach ($projectList as $v){
|
|
|
|
ProjectServer::useProject($v['id']);
|
|
|
|
$seoModel = new WebSettingSeo();
|
|
|
|
$seoInfo = $seoModel->read(['project_id'=>$v['id']]);
|
|
|
|
if($seoInfo === false){
|
|
|
|
$data[] = $v;
|
|
|
|
}else{
|
|
|
|
if(empty($seoInfo['single_page_suffix'])){
|
|
|
|
$data[] = $v;
|
|
|
|
}
|
|
|
|
echo date('Y-m-d H:i:s') . ' ' . json_encode($result) . PHP_EOL;
|
|
|
|
return $result;
|
|
|
|
|
|
|
|
}
|
|
|
|
DB::disconnect('custom_mysql');
|
|
|
|
}
|
|
|
|
return $this->exportData($data);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function exportData($data){
|
|
...
|
...
|
@@ -79,6 +102,7 @@ class DownloadProject extends Command |
|
|
|
$filePath = public_path('upload/excel/'.$filename);
|
|
|
|
// 导出 Excel 文件
|
|
|
|
$writer->save($filePath);
|
|
|
|
echo date('Y-m-d H:i:s') . 'file_link:'.url('upload/excel/'.$filename) . PHP_EOL;
|
|
|
|
// 返回导出文件的响应
|
|
|
|
return ['file_link'=>url('upload/excel/'.$filename)];
|
|
|
|
}
|
...
|
...
|
|