处理字典数据同步

main
vine_liutk 2024-01-31 19:22:15 +08:00
parent 3e354ad31f
commit e5296c5fc5
17 changed files with 3663 additions and 11 deletions

View File

@ -15,6 +15,13 @@ DB_DATABASE=laravel
DB_USERNAME=root
DB_PASSWORD=
DJC_DB_CONNECTION=mysql
DJC_DB_HOST=127.0.0.1
DJC_DB_PORT=3306
DJC_DB_DATABASE=laravel
DJC_DB_USERNAME=root
DJC_DB_PASSWORD=
BROADCAST_DRIVER=log
CACHE_DRIVER=file
FILESYSTEM_DISK=public

View File

@ -40,10 +40,10 @@ class KeywordController extends AdminController
$columnsArr [] = TableColumn::make()->name('value')->label('值');
}
$crud = $this->baseCRUD()
//去掉分页-start
->loadDataOnce(true)
// //去掉分页-start
->loadDataOnce(false)
->footerToolbar([])
//去掉分页-end
// //去掉分页-end
->headerToolbar([
$this->createButton(true),
amis('reload')->align('right'),

View File

@ -13,7 +13,7 @@ class Keyword extends Model
use HasFactory;
use Filterable;
protected $fillable = ['name', 'key', 'value', 'parent_id', 'parent_key', 'path', 'sort', 'lv'];
protected $fillable = ['name', 'key', 'value', 'parent_id', 'parent_key', 'path', 'sort', 'lv', 'oid'];
protected function serializeDate(\DateTimeInterface $date)
{

View File

@ -0,0 +1,11 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Person extends Model
{
use HasFactory;
}

View File

@ -63,6 +63,26 @@ return [
]) : [],
],
'djc_mysql' => [
'driver' => 'mysql',
'url' => env('DJC_DATABASE_URL'),
'host' => env('DJC_DB_HOST', '127.0.0.1'),
'port' => env('DJC_DB_PORT', '3306'),
'database' => env('DJC_DB_DATABASE', 'forge'),
'username' => env('DJC_DB_USERNAME', 'forge'),
'password' => env('DJC_DB_PASSWORD', ''),
'unix_socket' => env('DJC_DB_SOCKET', ''),
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_unicode_ci',
'prefix' => '',
'prefix_indexes' => true,
'strict' => true,
'engine' => null,
'options' => extension_loaded('pdo_mysql') ? array_filter([
PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
]) : [],
],
'pgsql' => [
'driver' => 'pgsql',
'url' => env('DATABASE_URL'),

View File

@ -0,0 +1,29 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
$zoneFile = database_path('sql/zone.sql');
DB::unprepared(file_get_contents($zoneFile));
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('zones');
}
};

View File

@ -0,0 +1,71 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('persons', function (Blueprint $table) {
$table->id();
$table->string('name')->comment('姓名');
$table->string('use_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->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->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->string('house_number')->nullable()->comment('门牌号');
$table->string('house_complete_address')->nullable()->comment('小区完整地址');
$table->string('real_address')->nullable()->comment('实际居住地址');
$table->unsignedBigInteger('nation')->nullable()->comment('民族');
$table->unsignedBigInteger('political_face')->nullable()->comment('政治面貌');
$table->unsignedBigInteger('educational_level')->nullable()->comment('文化程度');
$table->unsignedBigInteger('marry_state')->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('has_benefit')->default(0)->comment('是否享受福利');
$table->unsignedBigInteger('organized_body')->nullable()->comment('社别');
$table->string('t_ids')->nullable()->comment('标签');
$table->string('domicile_code')->nullable()->comment('户籍编号');
$table->unsignedTinyInteger('is_master')->default(0)->comment('是否户主');
$table->string('master_connect')->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->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('persons');
}
};

View File

@ -0,0 +1,30 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('keywords', function (Blueprint $table) {
//
$table->unsignedBigInteger('oid')->nullable()->comment('老ID主键');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('keywords', function (Blueprint $table) {
//
$table->dropColumn('oid');
});
}
};

View File

@ -30,8 +30,18 @@ class AdminMenuSeeder extends Seeder
['title' => 'keywords', 'icon' => 'ph:codesandbox-logo-light', 'url' => '/system/keywords', 'order'=>6],//字典管理
],
],
['title' => 'djc_wind', 'icon' => 'tabler:brand-databricks', 'url' => '/djc', 'order'=>2,//道角枫云
'children' => [
['title'=>'base_person_data', 'icon'=>'carbon:data-center','url'=>'/base_person_data', 'order'=>1, 'children' => [
['title'=>'real_person_data', 'icon'=>'material-symbols:frame-person-outline-rounded','url'=>'/real_person_data', 'order'=>0, 'children' => [
['title'=>'persons', 'icon'=>'material-symbols:switch-account-outline','url'=>'/persons', 'order'=>0],
['title'=>'person_changes', 'icon'=>'material-symbols:user-attributes-outline','url'=>'/person_changes', 'order'=>1],
]],
]],
]
],
['title' => 'web_content', 'icon' => 'ph:codesandbox-logo-light', 'url' => '/web_content', 'order'=>2,//网站管理
['title' => 'web_content', 'icon' => 'iconoir:internet', 'url' => '/web_content', 'order'=>3,//网站管理
'children' => [
['title'=>'ads', 'icon'=>'lets-icons:img-box','url'=>'/ads', 'order'=>0],
['title'=>'friend_links', 'icon'=>'mdi:link-variant','url'=>'/friend_links', 'order'=>1],
@ -39,7 +49,7 @@ class AdminMenuSeeder extends Seeder
['title'=>'articles', 'icon'=>'ic:outline-article','url'=>'/articles', 'order'=>3],
]
],
['title' => 'data_content', 'icon' => 'ph:codesandbox-logo-light', 'url' => '/data_content', 'order'=>3, //数据管理
['title' => 'data_content', 'icon' => 'ph:codesandbox-logo-light', 'url' => '/data_content', 'order'=>4, //数据管理
'children' =>[
//财务报表类型,档案类型,部门管理,地区类型,社别管理,小区管理,楼栋管理,户籍类型,民族管理,政治面貌,文化程度,机构管理,口头纠纷类型,卫生检查类型,图书类型,企业地区管理,收支情况类型,福利类型,工种管理
['title' => 'financial_cate', 'icon' => 'tabler:zoom-money', 'url' => '/financial_cate?parent_name=financial_cate&has_owner=0', 'order'=>0],//财务报表类型

View File

@ -12,7 +12,10 @@ class DatabaseSeeder extends Seeder
*/
public function run(): void
{
//初始化迁移
$this->call(AdminMenuSeeder::class);
$this->call(KeywordSeeder::class);
//执行老数据迁移-todo;
}
}

View File

@ -21,7 +21,19 @@ class KeywordSeeder extends Seeder
//标签value填写色号指定标签颜色
['key' => 'article_tag', 'name' => '文章标签', 'list' => []],
['key' => 'banner_address', 'name' => '广告位置', 'list' => []],
['key' => 'institution_type', 'name' => '组织属性', 'list' => []],
['key' => 'institution_type', 'name' => '组织属性', 'list' => [
'网络化结构组织','道角村综治中心','群防群治组织','党组织','村组织'
]],
['key' => 'marry_state', 'name' => '婚姻状况', 'list' => [
'未婚','已婚','离异','再婚','复婚','丧偶'
]],
['key' => 'military_service_status', 'name' => '兵役情况', 'list' => [
'未服兵役','现役军人','退役军人'
]],
['key' => 'person_tag', 'name' => '人口标签', 'list' => [
'刑满释放人员', '社区矫正人员', '肇事肇祸等严重精神障碍患者', '吸毒人员', '重点青少年','上访信访人员', '艾滋病危险人员','残疾人','低保五保','失独家庭','失业农民','其他困难人员','困难家庭','党员'
]],
//菜单
['key' => 'financial_cate', 'name' => '财务报表类型', 'list' => []],
['key' => 'file_cate', 'name' => '档案类型', 'list' => []],

View File

@ -0,0 +1,23 @@
<?php
namespace Database\Seeders;
use Illuminate\Database\Seeder;
use Database\Seeders\Migrations\{ArticleCategorySeeder, KeywordSeeder, BuildingSeeder};
class MigrationSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
$this->call([
ArticleCategorySeeder::class,
KeywordSeeder::class,
BuildingSeeder::class,
]);
}
}

View File

@ -1,8 +1,7 @@
<?php
namespace Database\Seeders;
namespace Database\Seeders\Migrations;
use Slowlyo\OwlAdmin\Models\AdminMenu;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Str;
@ -17,11 +16,12 @@ class ArticleCategorySeeder extends Seeder
*/
public function run()
{
$oldCates = DB::table('t_article_type')->get()->sortBy('pid');
//老文章分类表
$oldCates = DB::connection('djc_mysql')->table('t_article_type')->get()->sortBy('pid');
$newCategories = [];
foreach($oldCates as $cate){
if(empty($cate->name)){
if(empty($cate->name) || empty($dict->valid)){
continue;
}
$_category = [

View File

@ -0,0 +1,62 @@
<?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 BuildingSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
$oldDicts = DB::connection('djc_mysql')->table('t_data_dict')->where('dictKey', 'building')->get();
$newKeywords = [];
$buildings = [];
foreach($oldDicts as $dict){
if(empty($dict->dictKey) || empty($dict->valid)){
continue;
}
$_keyword = null;
$_parent = Keyword::where('oid', $dict->parentId)->first();
if($_parent){
$_keyword = [
'key' => $_parent->key.$dict->id,
'name' => $dict->txt,
'sort' => $dict->sorted,
'parent_id' => $_parent->id,
'parent_key'=> $_parent->key,
'lv' => $_parent->lv+1,
'path' => $_parent->path.$_parent->id.'-',
'oid' => $dict->id,
'created_at'=>now(),
'updated_at'=>now()
];
}
if($_keyword){
$newKeywords[$dict->id] = $_keyword;
}
}
if(count($newKeywords) > 0){
try {
DB::begintransaction();
DB::table('keywords')->insert($newKeywords);
DB::commit();
} catch (Throwable $th) {
DB::rollBack();
report($th);
}
}
}
}

View File

@ -0,0 +1,112 @@
<?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 KeywordSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
$oldDicts = DB::connection('djc_mysql')->table('t_data_dict')->get();
$newKeywords = [];
$parentList = Keyword::whereIn('key', ['financial_cate', 'file_cate', 'department', 'area_cate', 'organized_body', 'housing_estate', 'domicile', 'nation', 'political_face','educational_level','oral_disputes','sanitary_inspection', 'book_cate', 'business_area','money_cate', 'welfare_cate', 'job_cate'])->get();
$buildings = [];
foreach($oldDicts as $dict){
if(empty($dict->dictKey) || empty($dict->valid)){
continue;
}
$_parent = $_keyword = null;
switch($dict->dictKey){
case 'financeReportType'://财务报表类型
$_parent = $parentList->where('key', 'financial_cate')->first();
break;
case 'profileType'://档案类型
$_parent = $parentList->where('key', 'file_cate')->first();
break;
case 'addrType'://企业地区管理
$_parent = $parentList->where('key', 'business_area')->first();
break;
case 'bookType'://图书类型
$_parent = $parentList->where('key', 'book_cate')->first();
break;
case 'court'://小区管理
$_parent = $parentList->where('key', 'housing_estate')->first();
break;
case 'workType'://工种管理
$_parent = $parentList->where('key', 'job_cate')->first();
break;
case 'welfType'://福利类型
$_parent = $parentList->where('key', 'welfare_cate')->first();
break;
case 'society'://社别
$_parent = $parentList->where('key', 'organized_body')->first();
break;
case 'regionType'://地区类型
$_parent = $parentList->where('key', 'area_cate')->first();
break;
case 'politics'://政治面貌
$_parent = $parentList->where('key', 'political_face')->first();
break;
case 'payType'://收支类型
$_parent = $parentList->where('key', 'money_cate')->first();
break;
case 'hygieneType'://卫生检查类型
$_parent = $parentList->where('key', 'sanitary_inspection')->first();
break;
case 'houseHold'://户籍管理
$_parent = $parentList->where('key', 'domicile')->first();
break;
case 'folk'://民族管理
$_parent = $parentList->where('key', 'nation')->first();
break;
case 'eduction'://文化程度
$_parent = $parentList->where('key', 'educational_level')->first();
break;
case 'disputeType'://口头纠纷类型
$_parent = $parentList->where('key', 'oral_disputes')->first();
break;
}
if($_parent){
$_keyword = [
'key' => $_parent->key.$dict->id,
'name' => $dict->txt,
'sort' => $dict->sorted,
'parent_id' => $_parent->id,
'parent_key'=> $_parent->key,
'lv' => $_parent->lv+1,
'path' => $_parent->path.$_parent->id.'-',
'oid' => $dict->id,
'created_at'=>now(),
'updated_at'=>now()
];
}
if($_keyword){
$newKeywords[$dict->id] = $_keyword;
}
}
if(count($newKeywords) > 0){
try {
DB::begintransaction();
DB::table('keywords')->insert($newKeywords);
DB::commit();
} catch (Throwable $th) {
DB::rollBack();
report($th);
}
}
}
}

3257
database/sql/zone.sql 100644

File diff suppressed because it is too large Load Diff

View File

@ -35,4 +35,9 @@ return [
'job_cate' => '工种管理',
'friend_links' => '友情链接',
'article_categories'=> '文章分类',
'djc_wind' => '道角枫云',
'base_person_data' => '基础信息数据',
'real_person_data' => '实有人口管理',
'persons' => '户籍人口',
'person_changes' => '户籍变动'
];