generated from liutk/owl-admin-base
完善人口迁移
parent
e5296c5fc5
commit
62b994c3ea
|
|
@ -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'),
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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' => []],
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,149 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Seeders\Migrations;
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Str;
|
||||
use Throwable;
|
||||
use App\Models\Keyword;
|
||||
|
||||
class PersonSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
DB::table('persons')->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);
|
||||
// }
|
||||
});
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue