From 62b994c3eaa3e80ac3323541fa01f3d9a9ec4df2 Mon Sep 17 00:00:00 2001 From: vine_liutk <961510893@qq.com> Date: Thu, 1 Feb 2024 21:34:25 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84=E4=BA=BA=E5=8F=A3=E8=BF=81?= =?UTF-8?q?=E7=A7=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Admin/Controllers/BuildingController.php | 4 - .../2024_01_29_110440_create_people_table.php | 33 ++-- database/seeders/KeywordSeeder.php | 2 +- database/seeders/MigrationSeeder.php | 9 +- database/seeders/migrations/PersonSeeder.php | 149 ++++++++++++++++++ 5 files changed, 176 insertions(+), 21 deletions(-) create mode 100644 database/seeders/migrations/PersonSeeder.php diff --git a/app/Admin/Controllers/BuildingController.php b/app/Admin/Controllers/BuildingController.php index 74ac961..6d6e083 100644 --- a/app/Admin/Controllers/BuildingController.php +++ b/app/Admin/Controllers/BuildingController.php @@ -19,10 +19,6 @@ class BuildingController extends AdminController public function list(): Page { $crud = $this->baseCRUD() - //去掉分页-start - ->loadDataOnce(true) - ->footerToolbar([]) - //去掉分页-end ->headerToolbar([ $this->createButton(true), amis('reload')->align('right'), diff --git a/database/migrations/2024_01_29_110440_create_people_table.php b/database/migrations/2024_01_29_110440_create_people_table.php index ec196c1..c953225 100644 --- a/database/migrations/2024_01_29_110440_create_people_table.php +++ b/database/migrations/2024_01_29_110440_create_people_table.php @@ -14,22 +14,27 @@ return new class extends Migration Schema::create('persons', function (Blueprint $table) { $table->id(); $table->string('name')->comment('姓名'); - $table->string('use_name')->nullable()->comment('曾用名'); + + $table->string('avatar')->nullable()->comment('头像'); + $table->string('used_name')->nullable()->comment('曾用名'); $table->string('idcard', 50)->unique()->nullable()->comment('身份证号码'); $table->unsignedBigInteger('gender')->nullable()->comment('性别:0未知,1男,2女'); - $table->dateTime('birthday')->nullable()->comment('生日'); - $table->unsignedBigInteger('origin_province_id')->default(0)->comment('籍贯-省'); - $table->unsignedBigInteger('origin_city_id')->default(0)->comment('籍贯-市'); - $table->unsignedBigInteger('origin_area_id')->default(0)->comment('籍贯-区'); + $table->date('birthday')->nullable()->comment('生日'); + + $table->string('origin_city_code')->nullable()->comment('户籍地区代码'); + $table->unsignedBigInteger('origin_province_id')->nullable()->comment('籍贯-省'); + $table->unsignedBigInteger('origin_city_id')->nullable()->comment('籍贯-市'); + $table->unsignedBigInteger('origin_area_id')->nullable()->comment('籍贯-区'); + $table->string('origin_complete_address')->nullable()->comment('籍贯地址'); $table->string('card_city_code')->nullable()->comment('户籍地区代码'); - $table->unsignedBigInteger('card_province_id')->default(0)->comment('户籍-省'); - $table->unsignedBigInteger('card_city_id')->default(0)->comment('户籍-市'); - $table->unsignedBigInteger('card_area_id')->default(0)->comment('户籍-区'); + $table->unsignedBigInteger('card_province_id')->nullable()->comment('户籍-省'); + $table->unsignedBigInteger('card_city_id')->nullable()->comment('户籍-市'); + $table->unsignedBigInteger('card_area_id')->nullable()->comment('户籍-区'); $table->string('card_address')->nullable()->comment('户籍-街道详细地址'); $table->string('card_complete_address')->nullable()->comment('户籍-完整地址'); - $table->unsignedBigInteger('housing_estate')->default(0)->comment('小区'); - $table->unsignedBigInteger('building')->default(0)->comment('楼栋'); + $table->unsignedBigInteger('housing_estate')->nullable()->comment('小区'); + $table->unsignedBigInteger('building')->nullable()->comment('楼栋'); $table->string('house_number')->nullable()->comment('门牌号'); $table->string('house_complete_address')->nullable()->comment('小区完整地址'); $table->string('real_address')->nullable()->comment('实际居住地址'); @@ -38,25 +43,29 @@ return new class extends Migration $table->unsignedBigInteger('political_face')->nullable()->comment('政治面貌'); $table->unsignedBigInteger('educational_level')->nullable()->comment('文化程度'); $table->unsignedBigInteger('marry_state')->nullable()->comment('婚姻状况'); + $table->unsignedBigInteger('job_cate')->nullable()->comment('工种'); $table->string('job')->nullable()->comment('职业'); $table->string('health')->nullable()->comment('身体状况'); $table->string('phone')->nullable()->comment('联系方式'); $table->string('remark')->nullable()->comment('备注'); - $table->string('type')->nullable()->comment('类型'); + $table->unsignedTinyInteger('type')->nullable()->comment('类型11-出生人口,12-迁入人口(11、12统称户籍人口),2-流动人口,3-留守人口,4-境外人口'); $table->unsignedTinyInteger('has_benefit')->default(0)->comment('是否享受福利'); $table->unsignedBigInteger('organized_body')->nullable()->comment('社别'); $table->string('t_ids')->nullable()->comment('标签'); + $table->unsignedBigInteger('domicile')->nullable()->comment('户籍类型'); $table->string('domicile_code')->nullable()->comment('户籍编号'); $table->unsignedTinyInteger('is_master')->default(0)->comment('是否户主'); - $table->string('master_connect')->default('')->comment('户主关系'); + $table->string('master_connect')->nullable()->default('')->comment('户主关系'); $table->unsignedTinyInteger('is_voter')->default(0)->comment('是否参加选民投票'); $table->string('wx_openid')->nullable()->comment('微信openId'); $table->string('baidu_face_id')->nullable()->comment('百度人脸ID'); + $table->unsignedTinyInteger('state')->nullable()->comment('状态'); + $table->timestamps(); }); } diff --git a/database/seeders/KeywordSeeder.php b/database/seeders/KeywordSeeder.php index bccefb0..bbcac25 100644 --- a/database/seeders/KeywordSeeder.php +++ b/database/seeders/KeywordSeeder.php @@ -17,7 +17,7 @@ class KeywordSeeder extends Seeder { Keyword::truncate(); $list = [ - ['key' => 'article_category', 'name' => '文章分类', 'list' => []], + // ['key' => 'article_category', 'name' => '文章分类', 'list' => []], //标签value填写色号,指定标签颜色 ['key' => 'article_tag', 'name' => '文章标签', 'list' => []], ['key' => 'banner_address', 'name' => '广告位置', 'list' => []], diff --git a/database/seeders/MigrationSeeder.php b/database/seeders/MigrationSeeder.php index 2b12c64..fd6d35a 100644 --- a/database/seeders/MigrationSeeder.php +++ b/database/seeders/MigrationSeeder.php @@ -3,7 +3,7 @@ namespace Database\Seeders; use Illuminate\Database\Seeder; -use Database\Seeders\Migrations\{ArticleCategorySeeder, KeywordSeeder, BuildingSeeder}; +use Database\Seeders\Migrations\{ArticleCategorySeeder, KeywordSeeder, BuildingSeeder,PersonSeeder}; class MigrationSeeder extends Seeder { @@ -15,9 +15,10 @@ class MigrationSeeder extends Seeder public function run() { $this->call([ - ArticleCategorySeeder::class, - KeywordSeeder::class, - BuildingSeeder::class, + // ArticleCategorySeeder::class, + // KeywordSeeder::class, + // BuildingSeeder::class, + PersonSeeder::class, ]); } } diff --git a/database/seeders/migrations/PersonSeeder.php b/database/seeders/migrations/PersonSeeder.php new file mode 100644 index 0000000..6d7eb66 --- /dev/null +++ b/database/seeders/migrations/PersonSeeder.php @@ -0,0 +1,149 @@ +truncate(); + + DB::connection('djc_mysql')->table('t_person')->orderBy('id', 'ASC')->chunk(100, function($persons){ + + // $newPersons = []; + if($persons->count() > 0){ + $typeArr = [ + 5=>'刑满释放人员', + 6=>'社区矫正人员', + 7=>'肇事肇祸等严重精神障碍患者', + 8=>'吸毒人员', + 9=>'重点青少年', + 10=>'上访信访人员', + 11=>'艾滋病危险人员', + 13=>'残疾人', + 14=>'低保五保', + 15=>'失独家庭', + 16=>'失业农民', + 17=>'其他困难人员', + 18=>'困难家庭', + 20=>'党员']; + foreach($persons as $person){ + if($person->valid){//有效的记录 + if(!empty($person->idcard) && DB::table('persons')->where('idcard', $person->idcard)->exists()){ + DB::table('persons')->where('idcard', $person->idcard)->delete(); + } + $_person = [ + 'id' => $person->id, + 'name'=> $person->useName, + 'used_name' => $person->usedName ?: null, + 'idcard' => $person->idcard ?: null, + 'gender' => $person->gender == '男' ? 1:($person->gender == '女' ? 2:0), + 'birthday' => (!empty(strtotime($person->birth)) && ($person->birth == date('Y-m-d', strtotime($person->birth)))) ? $person->birth:null, + + 'origin_province_id'=> null, + 'origin_city_id' => null, + 'origin_complete_address' => $person->nativePlace, + 'card_complete_address' => $person->birthAddr, + + 'housing_estate' => null, + 'building' => null, + 'house_number' => null, + 'house_complete_address' => null, + 'real_address' => null, + + 'nation' => Keyword::where('parent_key', 'nation')->where('oid', $person->folkId)->value('id'), + 'political_face' => Keyword::where('parent_key', 'political_face')->where('oid', $person->politicsId)->value('id'), + 'educational_level' => Keyword::where('parent_key', 'educational_level')->where('oid', $person->educationId)->value('id'), + 'marry_state' => Keyword::where('parent_key', 'marry_state')->where('name', $person->marryStatus)->value('id'), + 'job_cate' => Keyword::where('parent_key', 'job_cate')->where('name', $person->workType)->value('id'), + 'job' => $person->career, + 'health'=> $person->health, + 'phone' => $person->phone, + 'remark'=> $person->remark, + + 'type'=>$person->type, + 'has_benefit' => $person->benefit == '是' ? 1:0, + 'organized_body' => Keyword::where('parent_key', 'organized_body')->where('oid', $person->societyId)->value('id'), + + 'domicile'=> Keyword::where('parent_key', 'domicile')->where('oid', $person->houseHoldTypeId)->value('id'), + 'domicile_code' => $person->houseHoldNumber, + 'is_master' => $person->houseHoldMasterRelative == '户主' ? 1:0, + 'master_connect' => $person->houseHoldMasterRelative ?: null, + + 'is_voter' => $person->voter == '是' ? 1:0, + + 'wx_openid' => $person->openid ?: null, + 'baidu_face_id' => $person->baiduUserId ?: null, + + 'state' => $person->status, + + 't_ids' => null, + + 'created_at' => now(), + 'updated_at' => now(), + ]; + //处理人物标签 + if(!empty($person->type1)){ + $_tIds = []; + $_typeIds = explode(',',$person->type1); + foreach($typeArr as $k => $typeName){ + if(in_array($k, $_typeIds)){ + $_tIds[] = Keyword::where('parent_key', 'person_tag')->where('name', $typeName)->value('id'); + } + } + if($_tIds){ + $_person['t_ids'] = implode(',', $_tIds); + } + } + + //处理籍贯地址选中问题-todo;如果是重庆市-巴南区,重庆市-九龙坡,重庆-巴县,重庆市-綦江区 + if(Str::startsWith($person->nativePlace, '重庆市') || Str::startsWith($person->nativePlace, '重庆')){ + $_person['origin_province_id'] = 2221; + $_person['origin_city_id'] = 2222; + } + + //处理户籍地址选中问题*-doto; + + //处理居住地址 + if($person->courtId){ + $houseCompleteAddress = ''; + $housingEstate = Keyword::where('parent_key', 'housing_estate')->where('oid', $person->courtId)->first(); + $building = Keyword::where('parent_key', 'like', '$housing_estate%')->where('oid', $person->buildingId ?:0)->first(); + if($housingEstate){ + $_person['housing_estate'] = $housingEstate->id; + $houseCompleteAddress .= $housingEstate->name; + } + if($building){ + $_person['building'] = $building->id; + $houseCompleteAddress .= $building->name; + } + $_person['house_number'] = $person->door; + $houseCompleteAddress .= ' '.$person->door; + if($houseCompleteAddress){ + $_person['house_complete_address'] = $houseCompleteAddress; + } + $_person['real_address'] = $person->addr2; + } + + // $newPersons[] = $_person; + DB::table('persons')->insert($_person); + } + } + } + // if(count($newPersons) > 0){ + // DB::table('persons')->insert($newPersons); + // } + }); + } +} \ No newline at end of file