123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118 |
- <?php
- namespace App\Console\Commands;
- use App\Imports\chatOrder;
- use App\Imports\Docter\DocterInfo;
- use App\Imports\Docter\DocterOrganizationInfo;
- use App\Imports\Docter\OrganizationInfo;
- use App\Imports\Docter\OrganizationOffice;
- use App\Models\Organization;
- use Illuminate\Console\Command;
- use Maatwebsite\Excel\Facades\Excel;
- class ImportDocter extends Command
- {
- /**
- * The name and signature of the console command.
- *
- * @var string
- */
- protected $signature = 'import:importDocter {type} {filepath}';
- /**
- * 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()
- {
- $type = $this->argument('type');
- $file_path = $this->argument('filepath');
- //路径相对于项目根目录即 /public
- if(empty($type) || empty($file_path)){
- dd('请输入完整参数');
- }
- //医生信息导入
- if($type == 'docter'){
- $this->makeDocter($file_path);
- }
- if($type == 'organization'){
- $this->makeOrganization($file_path);
- }
- // if($type == 'docter_organization'){
- // $this->makeDocterOrganization($file_path);
- // }
- if($type == 'organization_office'){
- $this->makeOrganizationOffice($file_path);
- }
- }
- /*
- * 导入医生要分为3个步骤
- * 1.先导入机构模块
- * 2.先导入医生模块
- * 3.再导入医生机构模块
- * */
- //医生模块
- public function makeDocter($file_path)
- {
- $this->imports($file_path);
- }
- public function imports($filePath)
- {
- $filePath = './public/import/' . $filePath . '.xlsx';
- Excel::import(new DocterInfo(), $filePath);
- }
- // //医生机构模块
- // public function makeDocterOrganization($file_path)
- // {
- // $this->importsDocterOrganization($file_path);
- // }
- // public function importsDocterOrganization($filePath)
- // {
- // $filePath = './public/import/' . $filePath . '.xlsx';
- //
- // Excel::import(new DocterOrganizationInfo(), $filePath);
- // }
- //机构模块
- public function makeOrganization($file_path)
- {
- $this->importsOrganization($file_path);
- }
- public function importsOrganization($filePath)
- {
- $filePath = './public/import/' . $filePath . '.xlsx';
- Excel::import(new OrganizationInfo(), $filePath);
- }
- //机构科室模块
- public function makeOrganizationOffice($file_path)
- {
- $this->importsOrganizationOffice($file_path);
- }
- public function importsOrganizationOffice($filePath)
- {
- $filePath = './public/import/' . $filePath . '.xls';
- Excel::import(new OrganizationOffice(), $filePath);
- }
- }
|