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

create table hrsa_sub_table_item
(
    id number primary key ,
    create_time date,
    update_time date,
    creator number,
    delete_type int default 0,
    tenant_key varchar2(10),
    table_id number not null,
    item_name varchar2(50) not null,
    item_value varchar2(500) not null,
    index_value int not null,
    total_rule varchar2(500),
    count_rule varchar2(500),
    unit_type int default 2
)
/

alter table hrsa_sub_table add table_type int
/

alter table hrsa_sub_table modify table_type default 0
/

create table hrsa_salary_stats_dim
(
    id number primary key ,
    create_time date,
    update_time date,
    creator number,
    delete_type int default 0,
    tenant_key varchar2(10),
    dim_name varchar2(100),
    dim_type varchar2(20),
    remark varchar2(500),
    setting varchar2(2000),
    is_default int,
    dim_code varchar2(50)
)
/

create table hrsa_salary_stats_report
(
    id number primary key ,
    create_time date,
    update_time date,
    creator number,
    delete_type int default 0,
    tenant_key varchar2(10),
    report_name varchar2(100),
    dimension varchar2(1000),
    tax_agent_setting varchar2(1000),
    income_category_setting varchar2(20),
    sub_company_setting varchar2(1000),
    depart_setting varchar2(1000),
    grade_setting varchar2(1000),
    position_setting varchar2(1000),
    status_setting varchar2(1000),
    employee_setting varchar2(1000),
    hiredate_setting varchar2(1000),
    leavedate_setting varchar2(1000),
    salary_start_month date,
    salary_end_month date
)
/

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

create table hrsa_charts_setting
(
    id number primary key ,
    create_time date,
    update_time date,
    creator number,
    delete_type int default 0,
    tenant_key varchar2(10),
    table_id number not null,
    charts_type int not null,
    item_values varchar2(500),
    item_col_value varchar2(50) not null,
    dimension_range int not null,
    item_sort_value varchar2(500),
    item_col_sort_value varchar2(50),
    sort_type int,
    sort_num int
)
/

create table hrsa_salary_echarts_setting
(
    id number primary key ,
    create_time date,
    update_time date,
    creator number,
    delete_type int default 0,
    tenant_key varchar2(10),
    report_id number not null,
    charts_type int not null,
    item_values varchar2(500),
    item_col_value varchar2(50) not null,
    dimension_range int not null,
    item_sort_value varchar2(500),
    item_col_sort_value varchar2(50),
    sort_type int,
    sort_num int
)
/

alter table hrsa_salary_stats_dim modify dim_type varchar2(30)
/

alter table hrsa_salary_stats_report modify income_category_setting varchar2(1000)
/


alter table hrsa_salary_stats_report add remark varchar2(100)
/

alter table hrsa_salary_stats_report add second_dimension varchar2(100)
/

alter table hrsa_salary_stats_report add sort_index varchar2(100)
/

alter table hrsa_salary_stats_report add sort_type varchar2(100)
/

alter table hrsa_salary_stats_dim add label_id int
/