-- 删除证书表
DROP TABLE IF EXISTS certificate;

-- 重新创建证书表
CREATE TABLE IF NOT EXISTS certificate
(
    id                INTEGER PRIMARY KEY AUTOINCREMENT,
    status            INTEGER       DEFAULT 0,
    company           TEXT,
    db_type           TEXT,
    db_drive          TEXT,
    db_ip             TEXT,
    db_port           TEXT,
    db_name           TEXT,
    db_passwd         TEXT,
    db_is_conn        INTEGER       DEFAULT 0,
    target_ip         TEXT,
    target_userdn     TEXT,
    target_passwd     TEXT,
    cert_url          TEXT,
    cert_num          INTEGER,
    import_cert_file1 TEXT,
    import_cert_file2 TEXT,
    create_time       TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP,
    update_time       TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP
);

-- 删除数据终端表
DROP TABLE IF EXISTS data_terminal;

-- 重新创建数据终端表
CREATE TABLE IF NOT EXISTS data_terminal
(
    id          INTEGER PRIMARY KEY AUTOINCREMENT,
    name        TEXT,
    type        TEXT,
    number      TEXT,
    producer_id INTEGER,
    manager_num TEXT,
    physics_num TEXT,
    status      INTEGER       DEFAULT 0,
    create_time TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP,
    update_time TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP
);

-- 删除设备表
DROP TABLE IF EXISTS device;

-- 重新创建设备表
CREATE TABLE IF NOT EXISTS device
(
    id          INTEGER PRIMARY KEY,
    device_id   TEXT,
    name        TEXT,
    type        INTEGER,
    producer_id INTEGER,
    status      TEXT,
    add_time    TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP,
    create_time TEXT          DEFAULT CURRENT_TIMESTAMP,
    update_time TEXT          DEFAULT CURRENT_TIMESTAMP
);

-- 删除设备发放表
DROP TABLE IF EXISTS device_distribution;

-- 重新创建设备发放表
CREATE TABLE IF NOT EXISTS device_distribution
(
    id          INTEGER PRIMARY KEY AUTOINCREMENT,
    type        TEXT,
    status      INTEGER       DEFAULT 0,
    number      TEXT,
    basis       TEXT,
    user_name   TEXT,
    phone       TEXT,
    send_node   TEXT,
    begin_time  TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP,
    end_time    TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP,
    create_time TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP,
    update_time TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP
);

-- 删除设备类型表
DROP TABLE IF EXISTS device_type;

-- 重新创建设备类型表
CREATE TABLE IF NOT EXISTS device_type
(
    id               INTEGER PRIMARY KEY,
    name             TEXT,
    type_number      TEXT,
    pattern          TEXT,
    secret_level     TEXT,
    management_level TEXT,
    create_time      TEXT DEFAULT CURRENT_TIMESTAMP,
    update_time      TEXT DEFAULT CURRENT_TIMESTAMP
);

-- 删除一期产品类型表
DROP TABLE IF EXISTS device_type_producer;

-- 重新创建一期产品类型表
CREATE TABLE IF NOT EXISTS device_type_producer
(
    id          INTEGER PRIMARY KEY,
    type_id     INTEGER,
    producer_id INTEGER,
    create_time TEXT DEFAULT CURRENT_TIMESTAMP,
    update_time TEXT DEFAULT CURRENT_TIMESTAMP
);

-- 删除一期资源表
DROP TABLE IF EXISTS resource;

-- 重新创建一期资源表
CREATE TABLE IF NOT EXISTS resource
(
    id           INTEGER PRIMARY KEY AUTOINCREMENT,
    status       INTEGER,
    db_user      VARCHAR(255),
    db_passwd    VARCHAR(255),
    db_server_ip VARCHAR(255),
    type         INTEGER,
    data_name    VARCHAR(255),
    node_name    VARCHAR(255),
    device_no    VARCHAR(255),
    support_unit VARCHAR(255),
    manager_node VARCHAR(255),
    file1        VARCHAR(255),
    file2        VARCHAR(255),
    file3        VARCHAR(255),
    file4        VARCHAR(255),
    create_time  TEXT DEFAULT CURRENT_TIMESTAMP,
    update_time  TEXT DEFAULT CURRENT_TIMESTAMP
);

-- 删除一期密钥表
DROP TABLE IF EXISTS secret_key;

-- 重新创建一期密钥表
CREATE TABLE IF NOT EXISTS secret_key
(
    id          INTEGER PRIMARY KEY AUTOINCREMENT,
    type        VARCHAR(255),
    length      INTEGER,
    count       INTEGER,
    algorithm   VARCHAR(255),
    create_time TEXT DEFAULT CURRENT_TIMESTAMP,
    update_time TEXT DEFAULT CURRENT_TIMESTAMP
);

-- 删除操作日志表
DROP TABLE IF EXISTS sys_log;

-- 重新创建操作日志表
CREATE TABLE IF NOT EXISTS sys_log
(
    id          INTEGER PRIMARY KEY AUTOINCREMENT,
    operation   VARCHAR(255),
    method      VARCHAR(255),
    params      VARCHAR(255),
    time        INTEGER,
    ip          VARCHAR(255),
    module_name VARCHAR(255),
    method_path VARCHAR(255),
    class_path  VARCHAR(255),
    http_type   VARCHAR(255),
    result      VARCHAR(255),
    create_time TEXT DEFAULT CURRENT_TIMESTAMP,
    update_time TEXT DEFAULT CURRENT_TIMESTAMP
);

-- 删除设备初装表
DROP TABLE IF EXISTS device_init;

-- 重新创建设备初装表
CREATE TABLE IF NOT EXISTS device_init
(
    id                   INTEGER PRIMARY KEY AUTOINCREMENT,
    secret               VARCHAR(255),
    algorithm            VARCHAR(255),
    self_inspection_code VARCHAR(255),
    device_name          VARCHAR(255),
    init_number          VARCHAR(255),
    version_number       VARCHAR(255),
    local_num            VARCHAR(255),
    firmware_version     VARCHAR(255),
    device_status        VARCHAR(255),
    file_name            VARCHAR(255),
    data_installed       VARCHAR(255),
    create_time          TEXT DEFAULT CURRENT_TIMESTAMP,
    update_time          TEXT DEFAULT CURRENT_TIMESTAMP
);

-- 删除参数设置表
DROP TABLE IF EXISTS parameter_set;

-- 重新创建参数设置表
CREATE TABLE IF NOT EXISTS parameter_set
(
    id          INTEGER PRIMARY KEY AUTOINCREMENT,
    ip_address  VARCHAR(255),
    create_time TEXT DEFAULT CURRENT_TIMESTAMP,
    update_time TEXT DEFAULT CURRENT_TIMESTAMP
);

-- 删除密码机初装表
DROP TABLE IF EXISTS secret_init;

-- 重新创建密码机初装表
CREATE TABLE IF NOT EXISTS secret_init
(
    id                 INTEGER PRIMARY KEY AUTOINCREMENT,
    password_init      VARCHAR(255),
    algorithm_param    VARCHAR(255),
    param_code         VARCHAR(255),
    file_name          VARCHAR(255),
    secret_data_status VARCHAR(255),
    secret_rain        VARCHAR(255),
    secret_kill        VARCHAR(255),
    mmj_kill           VARCHAR(255),
    create_time        TEXT DEFAULT CURRENT_TIMESTAMP,
    update_time        TEXT DEFAULT CURRENT_TIMESTAMP
);

-- 删除秘钥体格式列表表
DROP TABLE IF EXISTS secret_format;

-- 重新创建秘钥体格式列表表
CREATE TABLE IF NOT EXISTS secret_format
(
    id               INTEGER PRIMARY KEY AUTOINCREMENT,
    product_name     VARCHAR(255),
    carrier_name     VARCHAR(255),
    carrier_number   VARCHAR(255),
    manager_filename VARCHAR(255),
    system_name      VARCHAR(255),
    shstem_id        VARCHAR(255),
    publisher        VARCHAR(255),
    publisher_type   VARCHAR(255),
    current_status   VARCHAR(255),
    carrier_type     VARCHAR(255),
    create_time      TEXT DEFAULT CURRENT_TIMESTAMP,
    update_time      TEXT DEFAULT CURRENT_TIMESTAMP
);

-- 删除秘钥体申请列表表
DROP TABLE IF EXISTS secret_ask;

-- 重新创建秘钥体申请列表表
CREATE TABLE IF NOT EXISTS secret_ask
(
    id             INTEGER PRIMARY KEY AUTOINCREMENT,
    apply_new_old  VARCHAR(255),
    ask_type       VARCHAR(255),
    product_name   VARCHAR(255),
    product_num    VARCHAR(255),
    apply_num      VARCHAR(255),
    apply_time     DATETIME,
    apply_result   VARCHAR(255),
    carrier_model  VARCHAR(255),
    current_status VARCHAR(255),
    carrier_type   VARCHAR(255),
    create_time    TEXT DEFAULT CURRENT_TIMESTAMP,
    update_time    TEXT DEFAULT CURRENT_TIMESTAMP
);

-- 删除秘钥体导入表
DROP TABLE IF EXISTS secret_import;

-- 重新创建秘钥体导入表
CREATE TABLE IF NOT EXISTS secret_import
(
    id             INTEGER PRIMARY KEY AUTOINCREMENT,
    product_name   VARCHAR(255),
    product_num    VARCHAR(255),
    carrier_type   VARCHAR(255),
    apply_num      VARCHAR(255),
    apply_model    VARCHAR(255),
    number         INTEGER,
    source         VARCHAR(255),
    current_status VARCHAR(255),
    is_clean       INTEGER,
    import_time    DATETIME,
    key_type       VARCHAR(255),
    create_time    TEXT DEFAULT CURRENT_TIMESTAMP,
    update_time    TEXT DEFAULT CURRENT_TIMESTAMP
);

-- 删除秘钥体接收单表
DROP TABLE IF EXISTS secret_body_acceptance;

-- 重新创建秘钥体接收单表
CREATE TABLE IF NOT EXISTS secret_body_acceptance
(
    id              INTEGER PRIMARY KEY AUTOINCREMENT,
    product_name    VARCHAR(255),
    product_num     VARCHAR(255),
    source          VARCHAR(255),
    operator        VARCHAR(255),
    import_time     DATETIME,
    is_interface    VARCHAR(255),
    send_unit       VARCHAR(255),
    password_type   VARCHAR(255),
    number_carriers VARCHAR(255),
    code_carriers   VARCHAR(255),
    apply_model     VARCHAR(255),
    number          INTEGER,
    notes           VARCHAR(255),
    create_time     TEXT DEFAULT CURRENT_TIMESTAMP,
    update_time     TEXT DEFAULT CURRENT_TIMESTAMP
);

-- 删除上下级配发列表表
DROP TABLE IF EXISTS secret_issue_subordinate;

-- 重新创建上下级配发列表表
CREATE TABLE IF NOT EXISTS secret_issue_subordinate
(
    id                       INTEGER PRIMARY KEY AUTOINCREMENT,
    issue_type               VARCHAR(255),
    product_name             VARCHAR(255),
    product_num              VARCHAR(255),
    carrier_type             VARCHAR(255),
    apply_model              VARCHAR(255),
    dist_manager_name        VARCHAR(255),
    dist_manager_identifer   VARCHAR(255),
    issue_num                INTEGER,
    issue_status             VARCHAR(255),
    del_notes                VARCHAR(255),
    sub_operate_time         DATETIME,
    apply_manager_sys_name   VARCHAR(255),
    apply_manager_model_name VARCHAR(255),
    quantity                 VARCHAR(255),
    quantity_time            DATETIME,
    dist_code                VARCHAR(255),
    apply_code               VARCHAR(255),
    create_time              TEXT DEFAULT CURRENT_TIMESTAMP,
    update_time              TEXT DEFAULT CURRENT_TIMESTAMP
);


-- 删除向邮箱配发表
DROP TABLE IF EXISTS secret_issue_mailbox;

-- 重新创建向邮箱配发表
CREATE TABLE IF NOT EXISTS secret_issue_mailbox
(
    id                       INTEGER PRIMARY KEY AUTOINCREMENT,
    key_dist_platform_name   VARCHAR(255),
    key_dist_platform_entity VARCHAR(255),
    product_name             VARCHAR(255),
    product_code             VARCHAR(255),
    apply_type               VARCHAR(255),
    apply_model              VARCHAR(255),
    total                    INTEGER,
    download_num             INTEGER,
    empower                  VARCHAR(255),
    priority                 VARCHAR(255),
    over_time                DATETIME,
    notification_flag        VARCHAR(255),
    delete_flag              VARCHAR(255),
    create_time              TEXT DEFAULT CURRENT_TIMESTAMP,
    update_time              TEXT DEFAULT CURRENT_TIMESTAMP
);

-- 删除向专用密码管理系统配发表
DROP TABLE IF EXISTS secret_issue_private;

-- 重新创建向专用密码管理系统配发表
CREATE TABLE IF NOT EXISTS secret_issue_private
(
    id                     INTEGER PRIMARY KEY AUTOINCREMENT,
    duty_name              VARCHAR(255),
    duty_area_identify     VARCHAR(255),
    affiliated_network     VARCHAR(255),
    ip_address             VARCHAR(255),
    product_name           VARCHAR(255),
    product_code           VARCHAR(255),
    issue_manager_sys_name VARCHAR(255),
    operate_time           VARCHAR(255),
    sync_status            VARCHAR(255),
    create_time            TEXT DEFAULT CURRENT_TIMESTAMP,
    update_time            TEXT DEFAULT CURRENT_TIMESTAMP
);

-- 删除密钥体配发三联单1表
DROP TABLE IF EXISTS secret_issue_three_one;

-- 重新创建密钥体配发三联单1表
CREATE TABLE IF NOT EXISTS secret_issue_three_one
(
    id                     INTEGER PRIMARY KEY AUTOINCREMENT,
    duty_name              VARCHAR(255),
    duty_area_identify     VARCHAR(255),
    affiliated_network     VARCHAR(255),
    ip_address             VARCHAR(255),
    product_name           VARCHAR(255),
    product_code           VARCHAR(255),
    issue_manager_sys_name VARCHAR(255),
    create_time            TEXT DEFAULT CURRENT_TIMESTAMP,
    update_time            TEXT DEFAULT CURRENT_TIMESTAMP
);

-- 删除密钥体配发三联单2表
DROP TABLE IF EXISTS secret_issue_three_two;

-- 重新创建密钥体配发三联单2表
CREATE TABLE IF NOT EXISTS secret_issue_three_two
(
    id                 INTEGER PRIMARY KEY AUTOINCREMENT,
    duty_name          VARCHAR(255),
    duty_area_identify VARCHAR(255),
    affiliated_network VARCHAR(255),
    ip_address         VARCHAR(255),
    product_name       VARCHAR(255),
    product_code       VARCHAR(255),
    notes              VARCHAR(255),
    create_time        TEXT DEFAULT CURRENT_TIMESTAMP,
    update_time        TEXT DEFAULT CURRENT_TIMESTAMP
);

-- 删除明文载体包封表
DROP TABLE IF EXISTS clear_text_key_body;

-- 重新创建明文载体包封表
CREATE TABLE IF NOT EXISTS clear_text_key_body
(
    id               INTEGER PRIMARY KEY AUTOINCREMENT,
    product_name     VARCHAR(255),
    product_code     VARCHAR(255),
    carrier_code     VARCHAR(255),
    carrier_type     VARCHAR(255),
    carrier_model    VARCHAR(255),
    file_path        VARCHAR(255),
    carrier_position VARCHAR(255),
    create_time      TEXT DEFAULT CURRENT_TIMESTAMP,
    update_time      TEXT DEFAULT CURRENT_TIMESTAMP
);

-- 删除秘文载体包封表
DROP TABLE IF EXISTS encrypted_key_body;

-- 重新创建秘文载体包封表
CREATE TABLE IF NOT EXISTS encrypted_key_body
(
    id                  INTEGER PRIMARY KEY AUTOINCREMENT,
    carrier_type        VARCHAR(255),
    carrier_model       VARCHAR(255),
    file_path           VARCHAR(255),
    product_name        VARCHAR(255),
    product_code        VARCHAR(255),
    originator_identify VARCHAR(255),
    receiver_identify   VARCHAR(255),
    create_time         TEXT DEFAULT CURRENT_TIMESTAMP,
    update_time         TEXT DEFAULT CURRENT_TIMESTAMP
);


-- 管理系统管理盘数据维护
DROP TABLE IF EXISTS manage_sys_disk_data_maintenance;

CREATE TABLE IF NOT EXISTS manage_sys_disk_data_maintenance
(
    id                     INTEGER PRIMARY KEY AUTOINCREMENT,
    management_disk_number VARCHAR(255),
    carrier_model          VARCHAR(255),
    file_path              VARCHAR(255),
    product_name           TEXT,
    product_code           VARCHAR(255),
    create_time            TEXT DEFAULT CURRENT_TIMESTAMP,
    update_time            TEXT DEFAULT CURRENT_TIMESTAMP
);

-- 统型完善普密设备密钥互通关系配置
DROP TABLE IF EXISTS relation_setting;

CREATE TABLE IF NOT EXISTS relation_setting
(
    id               INTEGER PRIMARY KEY AUTOINCREMENT,
    device_name      VARCHAR(255),
    manager_model_id VARCHAR(255),
    device_model     VARCHAR(255),
    type             INTEGER,
    create_time      TEXT DEFAULT CURRENT_TIMESTAMP,
    update_time      TEXT DEFAULT CURRENT_TIMESTAMP
);

-- 管理密钥装配
DROP TABLE IF EXISTS manager_secret_setting;

CREATE TABLE IF NOT EXISTS manager_secret_setting
(
    id                 INTEGER PRIMARY KEY AUTOINCREMENT,
    device_name        VARCHAR(255),
    manager_model_id   VARCHAR(255),
    device_model       VARCHAR(255),
    product_name       VARCHAR(255),
    product_code       VARCHAR(255),
    usage_reserve_area INTEGER,
    dist_type          VARCHAR(255),
    install_method     VARCHAR(255),
    start_date         VARCHAR(255),
    set_number         VARCHAR(255),
    carrier_type       VARCHAR(255),
    enter_date         DATETIME,
    management_flag    VARCHAR(255),
    assembly_situation VARCHAR(255),
    create_time        TEXT DEFAULT CURRENT_TIMESTAMP,
    update_time        TEXT DEFAULT CURRENT_TIMESTAMP
);

-- 用户密钥装配
DROP TABLE IF EXISTS user_relation_setting;

CREATE TABLE IF NOT EXISTS user_relation_setting
(
    id                 INTEGER PRIMARY KEY AUTOINCREMENT,
    device_name        VARCHAR(255),
    manager_model_id   VARCHAR(255),
    device_model       VARCHAR(255),
    product_name       VARCHAR(255),
    product_code       VARCHAR(255),
    usage_reserve_area INTEGER,
    dist_type          VARCHAR(255),
    install_method     VARCHAR(255),
    start_date         VARCHAR(255),
    set_number         VARCHAR(255),
    carrier_type       VARCHAR(255),
    enter_date         DATETIME,
    management_flag    VARCHAR(255),
    assembly_situation VARCHAR(255),
    create_time        TEXT DEFAULT CURRENT_TIMESTAMP,
    update_time        TEXT DEFAULT CURRENT_TIMESTAMP
);

-- 专用密钥装配
DROP TABLE IF EXISTS special_setting;

CREATE TABLE IF NOT EXISTS special_setting
(
    id                  INTEGER PRIMARY KEY AUTOINCREMENT,
    device_name         VARCHAR(255),
    manager_model_id    VARCHAR(255),
    device_model        VARCHAR(255),
    product_name        VARCHAR(255),
    product_code        VARCHAR(255),
    usage_reserve_area  INTEGER,
    dist_type           VARCHAR(255),
    install_method      VARCHAR(255),
    start_date          VARCHAR(255),
    set_number          VARCHAR(255),
    carrier_type        VARCHAR(255),
    enter_date          DATETIME,
    management_flag     VARCHAR(255),
    assembly_situation  VARCHAR(255),
    is_donwload_mailbox VARCHAR(255),
    create_time         TEXT DEFAULT CURRENT_TIMESTAMP,
    update_time         TEXT DEFAULT CURRENT_TIMESTAMP
);

-- 密钥配发三联单
DROP TABLE IF EXISTS order_distribution;

CREATE TABLE IF NOT EXISTS order_distribution
(
    id                 INTEGER PRIMARY KEY AUTOINCREMENT,
    device_name        VARCHAR(255),
    manager_model_id   VARCHAR(255),
    device_model       VARCHAR(255),
    file_type          VARCHAR(255),
    product_code       VARCHAR(255),
    usage_reserve_area INTEGER,
    dist_type          VARCHAR(255),
    create_time        TEXT DEFAULT CURRENT_TIMESTAMP,
    update_time        TEXT DEFAULT CURRENT_TIMESTAMP
);

-- 设备管理-执勤区配置-核心区信息
DROP TABLE IF EXISTS core_area_info;

CREATE TABLE IF NOT EXISTS core_area_info
(
    id                INTEGER PRIMARY KEY AUTOINCREMENT,
    unit_info         VARCHAR(255),
    manager_entity_id VARCHAR(64),
    ip                VARCHAR(64),
    unit_tel          VARCHAR(32),
    rank              INTEGER DEFAULT 1,
    create_time       TEXT    DEFAULT CURRENT_TIMESTAMP,
    update_time       TEXT    DEFAULT CURRENT_TIMESTAMP
);

-- 设备管理-执勤区配置-执勤区信息
DROP TABLE IF EXISTS duty_area_info;

CREATE TABLE IF NOT EXISTS duty_area_info
(
    id                   INTEGER PRIMARY KEY AUTOINCREMENT,
    duty_area_name       VARCHAR(128),
    isolator_external_ip VARCHAR(64),
    home_network         VARCHAR(64),
    external_server_ip   VARCHAR(64),
    isolator_intranet_ip VARCHAR(64),
    default_conn         VARCHAR(32),
    gateway_id           VARCHAR(32),
    create_time          TEXT    DEFAULT CURRENT_TIMESTAMP,
    update_time          TEXT    DEFAULT CURRENT_TIMESTAMP,
    del_flag             INTEGER DEFAULT 0
);

-- 设备管理-执勤区配置-数据同步信息
DROP TABLE IF EXISTS data_sync_info;

CREATE TABLE IF NOT EXISTS data_sync_info
(
    id             INTEGER PRIMARY KEY AUTOINCREMENT,
    duty_area_name VARCHAR(128),
    home_network   VARCHAR(64),
    ip             VARCHAR(64),
    result         VARCHAR(64),
    type           INTEGER DEFAULT 1,
    create_time    TEXT    DEFAULT CURRENT_TIMESTAMP,
    update_time    TEXT    DEFAULT CURRENT_TIMESTAMP
);

-- 设备管理-远程维护-下级管理系统信息
DROP TABLE IF EXISTS uphold_sub_system;

CREATE TABLE IF NOT EXISTS uphold_sub_system
(
    id                INTEGER PRIMARY KEY AUTOINCREMENT,
    unit_name         VARCHAR(128),
    manager_entity_id VARCHAR(64),
    ip                VARCHAR(64),
    version_info      VARCHAR(64),
    select_time       TEXT DEFAULT CURRENT_TIMESTAMP,
    select_status     VARCHAR(32),
    create_time       TEXT DEFAULT CURRENT_TIMESTAMP,
    update_time       TEXT DEFAULT CURRENT_TIMESTAMP
);


-- 设备管理-报号维护-管理系统列表
DROP TABLE IF EXISTS uphold_manager_system;

CREATE TABLE IF NOT EXISTS uphold_manager_system
(
    id                INTEGER PRIMARY KEY AUTOINCREMENT,
    sys_name          VARCHAR(128),
    manager_entity_id VARCHAR(64),
    receive_number    VARCHAR(64),
    sent_number       VARCHAR(64),
    create_time       TEXT    DEFAULT CURRENT_TIMESTAMP,
    update_time       TEXT    DEFAULT CURRENT_TIMESTAMP,
    del_flag          INTEGER DEFAULT 0
);

-- 算法管理_算法信息维护
DROP TABLE IF EXISTS uphold_algorithm_info;

CREATE TABLE IF NOT EXISTS uphold_algorithm_info
(
    id                         INTEGER PRIMARY KEY AUTOINCREMENT,
    algorithm_name             VARCHAR(64),
    algorithm_short_name       VARCHAR(64),
    algorithm_number           VARCHAR(64),
    pwd_type                   VARCHAR(8),
    algorithm_usage            VARCHAR(64),
    algorithm_style            VARCHAR(64),
    algorithm_model_short_name VARCHAR(64),
    args_short_name            VARCHAR(64),
    info_size                  VARCHAR(32),
    work_model                 VARCHAR(64),
    pwd_size                   INTEGER,
    use_flag                   INTEGER DEFAULT 0,
    create_time                TEXT    DEFAULT CURRENT_TIMESTAMP,
    update_time                TEXT    DEFAULT CURRENT_TIMESTAMP,
    del_flag                   INTEGER DEFAULT 0
);

-- 算法管理_参数信息维护
DROP TABLE IF EXISTS uphold_args_info;

CREATE TABLE IF NOT EXISTS uphold_args_info
(
    id               INTEGER PRIMARY KEY AUTOINCREMENT,
    args_cn_name     VARCHAR(64),
    algorithm_id     INTEGER NOT NULL,
    args_short_name  VARCHAR(64),
    model_short_name VARCHAR(64),
    device_type      VARCHAR(64),
    args_type        VARCHAR(64),
    args_style       VARCHAR(64),
    create_time      TEXT    DEFAULT CURRENT_TIMESTAMP,
    update_time      TEXT    DEFAULT CURRENT_TIMESTAMP,
    del_flag         INTEGER DEFAULT 0
);

-- 算法管理_算法配发
DROP TABLE IF EXISTS algorithm_distribute;

CREATE TABLE IF NOT EXISTS algorithm_distribute
(
    id                INTEGER PRIMARY KEY AUTOINCREMENT,
    algorithm_id      INTEGER NOT NULL,
    status            VARCHAR(64),
    distribute_result VARCHAR(64),
    distribute_type   INTEGER,
    target_system     VARCHAR(64),
    create_time       TEXT    DEFAULT CURRENT_TIMESTAMP,
    update_time       TEXT    DEFAULT CURRENT_TIMESTAMP,
    del_flag          INTEGER DEFAULT 0
);

-- 算法管理_算法参数配发
DROP TABLE IF EXISTS algorithm_args_distribute;

CREATE TABLE IF NOT EXISTS algorithm_args_distribute
(
    id                INTEGER PRIMARY KEY AUTOINCREMENT,
    args_id           INTEGER NOT NULL,
    distribute_result VARCHAR(64),
    distribute_type   INTEGER,
    target_system     VARCHAR(64),
    create_time       TEXT    DEFAULT CURRENT_TIMESTAMP,
    update_time       TEXT    DEFAULT CURRENT_TIMESTAMP,
    del_flag          INTEGER DEFAULT 0
);

-- 算法管理_算法配置
DROP TABLE IF EXISTS algorithm_config;

CREATE TABLE IF NOT EXISTS algorithm_config
(
    id                       INTEGER PRIMARY KEY AUTOINCREMENT,
    algorithm_id             INTEGER NOT NULL,
    device_id                INTEGER NOT NULL,
    cooperate_manager_number VARCHAR(64),
    create_time              TEXT    DEFAULT CURRENT_TIMESTAMP,
    update_time              TEXT    DEFAULT CURRENT_TIMESTAMP,
    del_flag                 INTEGER DEFAULT 0
);

-- 算法管理_算法参数配置
DROP TABLE IF EXISTS algorithm_args_config;

CREATE TABLE IF NOT EXISTS algorithm_args_config
(
    id                       INTEGER PRIMARY KEY AUTOINCREMENT,
    args_id                  INTEGER NOT NULL,
    device_id                INTEGER NOT NULL,
    cooperate_manager_number VARCHAR(64),
    create_time              TEXT    DEFAULT CURRENT_TIMESTAMP,
    update_time              TEXT    DEFAULT CURRENT_TIMESTAMP,
    del_flag                 INTEGER DEFAULT 0
);

-- 设备注册-设备信息
DROP TABLE IF EXISTS device_hard;

CREATE TABLE IF NOT EXISTS device_hard
(
    id               INTEGER PRIMARY KEY AUTOINCREMENT,
    level            INTEGER DEFAULT 1,
    unit_name        VARCHAR(64),
    device_name      VARCHAR(64),
    device_type      VARCHAR(64),
    version          VARCHAR(64),
    device_number    VARCHAR(64),
    device_entity_id VARCHAR(64),
    device_mark_id   VARCHAR(64),
    disk_number      VARCHAR(64),
    home_network     VARCHAR(64),
    contacts         VARCHAR(64),
    contacts_info    VARCHAR(128),
    ip               VARCHAR(64),
    telephone        VARCHAR(64),
    seat_name        VARCHAR(64),
    content          VARCHAR(512),
    photo_url        VARCHAR(64),
    conn_flag        INTEGER DEFAULT 0,
    cancel_flag      INTEGER DEFAULT 0,
    create_time      TEXT    DEFAULT CURRENT_TIMESTAMP,
    update_time      TEXT    DEFAULT CURRENT_TIMESTAMP,
    del_flag         INTEGER DEFAULT 0
);

-- 设备注册-管理系统注册（上下级共用）
DROP TABLE IF EXISTS manager_system;

CREATE TABLE IF NOT EXISTS manager_system
(
    id                   INTEGER PRIMARY KEY AUTOINCREMENT,
    level                INTEGER DEFAULT 1,
    manager_sys_type     INTEGER DEFAULT 1,
    unit_name            VARCHAR(64),
    sys_name             VARCHAR(64),
    sys_type             INTEGER DEFAULT 1,
    sys_entity_id        VARCHAR(64),
    sys_mark_id          VARCHAR(64),
    isolator_external_ip VARCHAR(64),
    isolator_intranet_ip VARCHAR(64),
    manager_area         VARCHAR(64),
    telephone            VARCHAR(64),
    pwd_server_ip        VARCHAR(64),
    contacts             VARCHAR(64),
    contacts_info        VARCHAR(128),
    seat_name            VARCHAR(64),
    disk_number          VARCHAR(64),
    content              VARCHAR(512),
    photo_url            VARCHAR(64),
    create_time          TEXT    DEFAULT CURRENT_TIMESTAMP,
    update_time          TEXT    DEFAULT CURRENT_TIMESTAMP,
    del_flag             INTEGER DEFAULT 0
);

-- 设备注册-注册信息管理-管理盘信息
DROP TABLE IF EXISTS manager_disk;

CREATE TABLE IF NOT EXISTS manager_disk
(
    id          INTEGER PRIMARY KEY AUTOINCREMENT,
    disk_number VARCHAR(64),
    status      INTEGER DEFAULT 1,
    create_time TEXT    DEFAULT CURRENT_TIMESTAMP,
    update_time TEXT    DEFAULT CURRENT_TIMESTAMP,
    del_flag    INTEGER DEFAULT 0
);

-- 设备注册-注册信息管理-管理盘文件
DROP TABLE IF EXISTS manager_disk_file;

CREATE TABLE IF NOT EXISTS manager_disk_file
(
    id          INTEGER PRIMARY KEY AUTOINCREMENT,
    disk_id     INTEGER NOT NULL,
    file_name   VARCHAR(64),
    file_size   INTEGER DEFAULT 0,
    create_time TEXT    DEFAULT CURRENT_TIMESTAMP,
    update_time TEXT    DEFAULT CURRENT_TIMESTAMP,
    del_flag    INTEGER DEFAULT 0
);

-- 设备注册-注册信息管理-设备照片维护
DROP TABLE IF EXISTS device_photo;

CREATE TABLE IF NOT EXISTS device_photo
(
    id          INTEGER PRIMARY KEY AUTOINCREMENT,
    device_type VARCHAR(64),
    photo_url   VARCHAR(64),
    create_time TEXT    DEFAULT CURRENT_TIMESTAMP,
    update_time TEXT    DEFAULT CURRENT_TIMESTAMP,
    del_flag    INTEGER DEFAULT 0
);

-- 应用系统
DROP TABLE IF EXISTS application_system;

CREATE TABLE IF NOT EXISTS application_system
(
    id          INTEGER PRIMARY KEY AUTOINCREMENT,
    system_name VARCHAR(64) UNIQUE NOT NULL,
    create_time TEXT    DEFAULT CURRENT_TIMESTAMP,
    update_time TEXT    DEFAULT CURRENT_TIMESTAMP,
    del_flag    INTEGER DEFAULT 0
);

-- 设备注册-注册信息管理-应用系统配置
DROP TABLE IF EXISTS device_sys_config;

CREATE TABLE IF NOT EXISTS device_sys_config
(
    id          INTEGER PRIMARY KEY AUTOINCREMENT,
    device_id   INTEGER NOT NULL,
    sys_id      INTEGER NOT NULL,
    create_time TEXT    DEFAULT CURRENT_TIMESTAMP,
    update_time TEXT    DEFAULT CURRENT_TIMESTAMP,
    del_flag    INTEGER DEFAULT 0
);

-- 设备注册-信息汇总-数据收集
DROP TABLE IF EXISTS data_collect;

CREATE TABLE IF NOT EXISTS data_collect
(
    id          INTEGER PRIMARY KEY AUTOINCREMENT,
    sys_name    VARCHAR(128),
    identify    VARCHAR(64),
    ip          VARCHAR(64),
    status      VARCHAR(32),
    create_time TEXT    DEFAULT CURRENT_TIMESTAMP,
    update_time TEXT    DEFAULT CURRENT_TIMESTAMP,
    del_flag    INTEGER DEFAULT 0
);

-- 设备数据
DROP TABLE IF EXISTS device_data;

CREATE TABLE IF NOT EXISTS device_data
(
    id               INTEGER PRIMARY KEY AUTOINCREMENT,
    unit_name        VARCHAR(64),
    device_name      VARCHAR(64),
    device_type      VARCHAR(64),
    device_entity_id VARCHAR(64),
    home_network     VARCHAR(64),
    create_time      TEXT    DEFAULT CURRENT_TIMESTAMP,
    update_time      TEXT    DEFAULT CURRENT_TIMESTAMP,
    del_flag         INTEGER DEFAULT 0
);

-- 设备注册-单位位置
DROP TABLE IF EXISTS unit_address;

CREATE TABLE IF NOT EXISTS unit_address
(
    id          INTEGER PRIMARY KEY AUTOINCREMENT,
    unit_name   VARCHAR(64),
    parent_id   INTEGER,
    longitude   REAL,
    latitude    REAL,
    create_time TEXT    DEFAULT CURRENT_TIMESTAMP,
    update_time TEXT    DEFAULT CURRENT_TIMESTAMP,
    del_flag    INTEGER DEFAULT 0
);



DROP TABLE IF EXISTS remote_file_config;

CREATE TABLE IF NOT EXISTS remote_file_config (
   id INTEGER PRIMARY KEY AUTOINCREMENT,
   service_list TEXT,
   net_param TEXT DEFAULT NULL,
   safe_strategy TEXT DEFAULT NULL,
   manager_strategy TEXT DEFAULT NULL,
   vpn_strategy TEXT DEFAULT NULL,
   create_time TEXT    DEFAULT CURRENT_TIMESTAMP,
   update_time TEXT    DEFAULT CURRENT_TIMESTAMP
);