123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102 |
- <?php
- namespace App\Console\Commands\Transfer;
- use App\Transfer\Company;
- use Illuminate\Console\Command;
- class TransferOther extends Command
- {
-
- protected $signature = 'aix:transfer-other';
-
- protected $description = '转移旧系统企业数据';
-
- public function __construct()
- {
- parent::__construct();
- }
-
- public function handle()
- {
- $this->info("清除企业数据表:companys");
-
- $this->info("清除企业数据表:companyImg");
-
-
- $this->info("开始转移数据...");
- $total = Company::where(['utype' => 1])->count();
- $bar=$this->output->createProgressBar($total);
- Company::where(['utype' => 1])->orderBy('uid', 'asc')->chunk(500, function ($companys) use ($bar) {
- $company_array=[];
- $company_job_array=[];
- $company_img_array=[];
-
- foreach ($companys as $company) {
-
- $this->handleCompany($company, $company_array);
-
- $this->handleCompanyJob($company->jobs, $company_job_array);
-
-
- }
-
- $bar->advance(500);
- });
- $bar->finish();
- $this->line(" 完成!");
- $this->info("转移企业数据成功.");
- }
- public function handleCompany($company, &$result_array)
- {
- $data['id']=$company->uid;
- $data['id']="xx";
- $data['id']="xx";
- $data['id']="xx";
- $data['id']="xx";
- $result_array[]= $data;
- }
- public function handleCompanyJob($jobs, &$result_array)
- {
- foreach ($jobs as $job) {
- $data['id']=$job->uid;
- $data['id']="xx";
- $data['id']="xx";
- $data['id']="xx";
- $data['id']="xx";
- $result_array[]= $data;
- }
- }
- }
|