123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130 |
- <?php
- namespace App\Console\Commands\Transfer;
- use App\Models\MemberInfo;
- use App\Models\MembersLog;
- use App\Models\MembersPoint;
- use App\Models\PersonalServiceStick;
- use App\Models\PersonalServiceStickLog;
- use App\Models\PersonalServiceTag;
- use App\Models\PersonalServiceTagLog;
- use App\Models\PersonFavorite;
- use App\Models\PersonFocusCompany;
- use App\Models\PersonJobsSubscribe;
- use App\Models\Resume;
- use App\Models\ResumeCredent;
- use App\Models\ResumeEducation;
- use App\Models\ResumeLanguage;
- use App\Models\ResumeTrain;
- use App\Models\ResumeWork;
- use App\Models\SubsiteResume;
- use App\Models\Thirdlogin;
- use App\Models\ViewJob;
- use App\Transfer\CompanyStatistics;
- use App\Transfer\Member;
- use App\Transfer\MemberBind;
- use App\Transfer\MemberLog;
- use App\Transfer\Msg;
- use App\Transfer\PersonalFavorite;
- use App\Transfer\PersonalFocusCompany;
- use App\Transfer\PersonalJobsApply;
- use App\Transfer\PersonalJobsSubscribe;
- use App\Transfer\PersonalStickLog;
- use App\Transfer\PersonalTagLog;
- use App\Transfer\ResumeImg;
- use App\Transfer\ViewJobs;
- use App\Transfer\ViewResume;
- use Illuminate\Console\Command;
- use Illuminate\Support\Facades\DB;
- class TransferTestApply extends Command
- {
- /**
- * The name and signature of the console command.
- *
- * @var string
- */
- protected $signature = 'aix:transfer-member-apply';
- /**
- * The console command description.
- *
- * @var string
- */
- protected $description = '转移旧系统个人数据';
- /**
- * Create a new command instance.
- *
- * @return void
- */
- public function __construct()
- {
- parent::__construct();
- }
- /**
- * Execute the console command.
- *
- * @return mixed
- */
- public function handle()
- {
- $this->info('清除企业统计数据表companyStatistics');
- DB::table('company_statistics')->delete();
- //转移company_statistics数据
- $this->info("开始转移数据...");
- $total = CompanyStatistics::get()->count();
- $bar=$this->output->createProgressBar($total);
- CompanyStatistics::with('companyProfile')->orderBy('id', 'asc')->chunk(3000, function ($companyStatistics) use ($bar) {
- $statistics_arr = [];
- $this->handleStatistics($companyStatistics, $statistics_arr);
- if ($statistics_arr) {
- \App\Models\CompanyStatistics::insert($statistics_arr);
- }
- $bar->advance(3000);
- });
- $bar->finish();
- $this->line(" 完成!");
- $this->info("转移company_statistics数据成功.");
- }
- public function handleStatistics($companyStatistics, &$statistics_arr)
- {
- $statisticsData = [];
- foreach ($companyStatistics as $key => $val) {
- if ($val->companyProfile) {
- $statisticsData['id'] = $val->id;
- if ($val->comid) {
- $statisticsData['company_id'] = $val->companyProfile->uid;
- } else {
- $statisticsData['company_id'] = $val->comid;
- };
- $statisticsData['uid'] = $val->uid;
- if ($val->uid) {
- if ($val->companys) {
- $statisticsData['utype'] = 1;
- } else {
- $statisticsData['utype'] = 2;
- }
- } else {
- $statisticsData['utype'] = 0;
- }
- $statisticsData['job_id'] = $val->jobid;
- $statisticsData['source'] = $val->source;
- $statisticsData['apply'] = $val->apply;
- $statisticsData['created_at'] = date('Y-m-d H:i:s', $val->addtime);
- $statisticsData['updated_at'] = date('Y-m-d H:i:s', $val->addtime);
- $statistics_arr[] = $statisticsData;
- }
- }
- }
- }
|