create table hrsa_sub_table
(
    id bigint primary key ,
    create_time datetime,
    update_time datetime,
    creator bigint,
    delete_type int default 0,
    tenant_key nvarchar(10),
    sub_table_name nvarchar(100) not null,
    dimension nvarchar(20) not null,
    start_month nvarchar(10),
    end_month nvarchar(10),
    pay_org_string nvarchar(500),
    pay_agency_string nvarchar(500),
    sub_company_string nvarchar(500),
    depart_string nvarchar(500),
    grade_string nvarchar(500),
    position_string nvarchar(500),
    status_string nvarchar(500),
    employee_type nvarchar(500),
    employee_string nvarchar(500),
    payment_type_string nvarchar(100)
)
GO

create table hrsa_sub_table_item
(
    id bigint primary key ,
    create_time datetime,
    update_time datetime,
    creator bigint,
    delete_type int default 0,
    tenant_key nvarchar(10),
    table_id bigint not null,
    item_name nvarchar(50) not null,
    item_value nvarchar(500) not null,
    index_value int not null,
    total_rule nvarchar(500),
    count_rule nvarchar(500),
    unit_type int default 2
)
GO

alter table hrsa_sub_table add table_type int
GO

alter table hrsa_sub_table add constraint df_table_type_7b1e7561 default 0 for table_type
GO

create table hrsa_salary_stats_dim
(
    id bigint primary key ,
    create_time datetime,
    update_time datetime,
    creator bigint,
    delete_type int default 0,
    tenant_key nvarchar(10),
    dim_name nvarchar(100),
    dim_type nvarchar(20),
    remark nvarchar(500),
    setting nvarchar(2000),
    is_default int,
    dim_code nvarchar(50)
)
GO

create table hrsa_salary_stats_report
(
    id bigint primary key ,
    create_time datetime,
    update_time datetime,
    creator bigint,
    delete_type int default 0,
    tenant_key nvarchar(10),
    report_name nvarchar(100),
    dimension nvarchar(1000),
    tax_agent_setting nvarchar(1000),
    income_category_setting nvarchar(20),
    sub_company_setting nvarchar(1000),
    depart_setting nvarchar(1000),
    grade_setting nvarchar(1000),
    position_setting nvarchar(1000),
    status_setting nvarchar(1000),
    employee_setting nvarchar(1000),
    hiredate_setting varchar(1000),
    leavedate_setting varchar(1000),
    salary_start_month datetime,
    salary_end_month datetime
)
GO

create table hrsa_salary_statistics_item
(
    id bigint primary key ,
    create_time datetime,
    update_time datetime,
    creator bigint,
    delete_type int default 0,
    tenant_key nvarchar(10),
    item_name nvarchar(50),
    item_value nvarchar(1000),
    count_rule nvarchar(500),
    sum_rule nvarchar(500),
    avg_rule nvarchar(500),
    max_rule nvarchar(500),
    min_rule nvarchar(500),
    median_rule nvarchar(500),
    index_value int,
    unit_type int,
    stat_report_id bigint
)
GO

create table hrsa_charts_setting
(
    id bigint primary key ,
    create_time datetime,
    update_time datetime,
    creator bigint,
    delete_type int default 0,
    tenant_key nvarchar(10),
    table_id bigint not null,
    charts_type int not null,
    item_values nvarchar(500),
    item_col_value nvarchar(50) not null,
    dimension_range int not null,
    item_sort_value nvarchar(500),
    item_col_sort_value nvarchar(50),
    sort_type int,
    sort_num int
)
GO

create table hrsa_salary_echarts_setting
(
    id bigint primary key ,
    create_time datetime,
    update_time datetime,
    creator bigint,
    delete_type int default 0,
    tenant_key nvarchar(10),
    report_id bigint not null,
    charts_type int not null,
    item_values nvarchar(500),
    item_col_value nvarchar(50) not null,
    dimension_range int not null,
    item_sort_value nvarchar(500),
    item_col_sort_value nvarchar(50),
    sort_type int,
    sort_num int
)
GO

alter table hrsa_salary_stats_dim alter column dim_type nvarchar(30)
GO

alter table hrsa_salary_stats_report alter column income_category_setting nvarchar(1000)
GO

create table hrsa_statreportlogs_detail
(
    id bigint primary key ,
    create_time datetime,
    update_time datetime,
    creator bigint,
    delete_type int default 0,
    tenant_key nvarchar(10),
    uuid nvarchar(36) not null,
    mainid nvarchar(36) not null,
    dataid nvarchar(50) not null,
    belongdataid nvarchar(50) not null,
    tablename nvarchar(200) not null,
    tablenamelabelid nvarchar(50) default '-1' not null,
    tablenamedesc nvarchar(50) not null,
    fieldname nvarchar(200) not null,
    fieldnamelabelid nvarchar(50) default '-1' not null,
    newvalue nvarchar(max) not null,
    oldvalue nvarchar(max) not null,
    newrealvalue nvarchar(max) not null,
    oldrealvalue nvarchar(max) not null,
    fielddesc nvarchar(200) not null,
    showorder int not null,
    isdetail int default 0 not null
)
GO

create table hrsa_statreportlogs
(
    id bigint primary key ,
    create_time datetime,
    update_time datetime,
    creator bigint,
    delete_type int default 0,
    tenant_key nvarchar(10),
    uuid nvarchar(36) not null,
    log_date datetime not null,
    device nvarchar(500) not null,
    log_operator bigint not null,
    operatorname nvarchar(100),
    targetid bigint default '-1' not null,
    targetname nvarchar(max) not null,
    modulename nvarchar(100) not null,
    functionname nvarchar(100) not null,
    interfacename nvarchar(100) not null,
    requesturl nvarchar(200) not null,
    requesturi nvarchar(200) not null,
    operatetype nvarchar(50) not null,
    operatetypename nvarchar(100) not null,
    operatedesc nvarchar(3000) not null,
    params nvarchar(max) not null,
    belongmainid nvarchar(36) not null,
    clientip nvarchar(50) not null,
    groupid nvarchar(50) not null,
    groupnamelabel nvarchar(1000) not null,
    redoservice nvarchar(200) not null,
    redocontext nvarchar(max) not null,
    cancelservice nvarchar(200) not null,
    cancelcontext nvarchar(max) not null,
    totalruntime bigint default '0' not null,
    mainruntime bigint default '0' not null,
    log_result nvarchar(100) not null,
    fromterminal nvarchar(100) not null,
    resultdesc nvarchar(max) not null,
    old_content nvarchar(3000) not null,
    link_type nvarchar(20) not null,
    link_id bigint default '0' not null,
    old_link_id bigint default '0' not null
)
GO

alter table hrsa_salary_stats_report add remark nvarchar(100)
GO

alter table hrsa_salary_stats_report add second_dimension nvarchar(100)
GO

alter table hrsa_salary_stats_report add sort_index nvarchar(100)
GO

alter table hrsa_salary_stats_report add sort_type nvarchar(100)
GO

alter table hrsa_salary_stats_dim add label_id int
GO