create table ent_data
(
    商业公司名称       varchar(255) null,
    商业公司地址       varchar(255) null,
    商业公司规模       varchar(255) null,
    三合一社会信用代码 varchar(255) null,
    GSP证书编号        varchar(255) null,
    公司注册地         varchar(255) null,
    注册资本           varchar(255) null,
    法人代表           varchar(255) null,
    服务药企           varchar(255) null,
    公司简介           varchar(255) null,
    经营优势           varchar(255) null,
    备注               varchar(255) null,
    f13                varchar(255) null,
    f14                varchar(255) null
)
    row_format = DYNAMIC;

create table ent_his
(
    医院名称 varchar(255) null,
    医院地址 varchar(255) null,
    医院规模 varchar(255) null,
    医院性质 varchar(255) null,
    联系总机 varchar(255) null,
    公共邮箱 varchar(255) null,
    医院简介 varchar(255) null,
    备注     varchar(255) null
)
    row_format = DYNAMIC;

create table hnqz_sequence
(
    id           bigint auto_increment
        primary key,
    value        bigint      not null,
    name         varchar(32) not null,
    gmt_create   datetime    not null,
    gmt_modified datetime    not null,
    constraint uk_name
        unique (name)
);

create table huiqiyun_input_record
(
    id           int auto_increment comment '主键id'
        primary key,
    req_msg_id   varchar(64)                        null comment '报文流水号',
    req_body     text                               null comment '请求body',
    decrypt_body text                               null comment '解密后的body',
    create_time  datetime default CURRENT_TIMESTAMP null comment '创建时间'
)
    comment '汇企云回调异步通知记录';

create table lingcaiai_input_record
(
    id           int auto_increment comment '主键id'
        primary key,
    verify       varchar(128)                        not null comment '签名',
    channel      varchar(32)                         not null comment '通知类型',
    req_body     text                                not null comment '请求body内容',
    batch_no     varchar(32)                         null comment '项目单号',
    account_no   varchar(32)                         null comment '账号单号',
    order_status int                                 null comment '订单状态',
    create_time  timestamp default CURRENT_TIMESTAMP not null comment '创建时间'
)
    comment '浪潮(灵才接好活)结算回调请求记录';

create table medical_equipment
(
    id            int auto_increment comment '医疗器械'
        primary key,
    name          varchar(64)      null comment '器械名称',
    manufacturer  varchar(64)      null comment '生产厂家',
    drug_ent_id   int              null comment '所属企业id',
    drug_ent_name varchar(64)      null comment '所属企业名称',
    specification varchar(64)      null comment '规格',
    measure_unit  varchar(64)      null comment '计量单位组名称',
    level         varchar(20)      null comment '等级',
    remark        varchar(64)      null comment '备注',
    del_flag      char default '0' null comment '删除标记,1:已删除,0:正常',
    create_time   datetime         null comment '创建时间',
    create_user   int              null comment '创建人',
    update_time   datetime         null comment '更新时间',
    update_user   int              null comment '更新人'
)
    comment '医疗器械';

create table monitoring_indicator
(
    id                 int(20) auto_increment
        primary key,
    alarm_amount       decimal(18) default 0 not null comment '报警金额',
    limit_amount       decimal(18) default 0 not null comment '限制金额',
    yaoyi_limit_amount decimal(18)           not null comment '平台限额',
    subject_location   varchar(64)           null comment '税源地'
)
    comment '风险监控' row_format = DYNAMIC;

create table olading_input_record
(
    id             int auto_increment comment '主键id'
        primary key,
    request_id     varchar(32)                         null comment '请求流水号',
    interface_name varchar(32)                         not null comment '请求接口名称',
    req_body       text                                not null comment '请求body内容',
    public_key     varchar(2048)                       null comment '请求公钥',
    private_key    varchar(2048)                       null comment '请求时私钥',
    create_time    timestamp default CURRENT_TIMESTAMP not null comment '创建时间'
)
    comment '自由职家请求记录';

create table party_a_encrypted_input_record
(
    id              int(20) auto_increment
        primary key,
    dept_id         int(20)                             not null comment '主体id',
    ser_public_key  varchar(2048)                       not null comment '请求时服务器公钥',
    ser_private_key varchar(2048)                       not null comment '请求时服务器私钥',
    cli_public_key  varchar(2048)                       not null comment '请求时客户端公钥',
    cli_private_key varchar(2048)                       not null comment '请求时客户端私钥',
    signature       varchar(32)                         not null comment '请求时签名字符串',
    original_text   longtext                            not null comment '加密后的信息',
    password        varchar(2048)                       not null comment '密码',
    create_time     timestamp default CURRENT_TIMESTAMP not null comment '创建时间'
)
    comment '甲方请求加密信息记录' row_format = DYNAMIC;

create table party_b_encrypted_output_record
(
    id              int(20) auto_increment
        primary key,
    dept_id         int(20)                             not null comment '主体id',
    ser_public_key  varchar(2048)                       not null comment '请求时服务器公钥',
    ser_private_key varchar(2048)                       not null comment '请求时服务器私钥',
    cli_public_key  varchar(2048)                       not null comment '请求时客户端公钥',
    cli_private_key varchar(2048)                       not null comment '请求时客户端私钥',
    signature       varchar(32)                         not null comment '请求时签名字符串',
    original_text   longtext                            not null comment '加密后的信息',
    password        varchar(2048)                       not null comment '密码',
    input_id        int(20)                             not null comment '请求id',
    create_time     timestamp default CURRENT_TIMESTAMP not null comment '创建时间'
)
    comment '乙方响应加密信息记录' row_format = DYNAMIC;

create table qifu_input_record
(
    id           int auto_increment comment '主键id'
        primary key,
    req_type     varchar(20)                        not null comment '请求业务类型',
    req_id       varchar(64)                        null comment '请求序号',
    req_body     text                               null comment '请求body',
    decrypt_body text                               null comment '解密后的body',
    create_time  datetime default CURRENT_TIMESTAMP null comment '创建时间'
)
    comment '福建企赋回调异步通知记录';

create table qrtz_calendars
(
    sched_name    varchar(120) charset utf8 not null,
    calendar_name varchar(200) charset utf8 not null,
    calendar      blob                      not null,
    primary key (sched_name, calendar_name)
)
    row_format = DYNAMIC;

create table qrtz_fired_triggers
(
    sched_name        varchar(120) charset utf8 not null,
    entry_id          varchar(95) charset utf8  not null,
    trigger_name      varchar(200) charset utf8 not null,
    trigger_group     varchar(200) charset utf8 not null,
    instance_name     varchar(200) charset utf8 not null,
    fired_time        bigint(13)                not null,
    sched_time        bigint(13)                not null,
    priority          int                       not null,
    state             varchar(16) charset utf8  not null,
    job_name          varchar(200) charset utf8 null,
    job_group         varchar(200) charset utf8 null,
    is_nonconcurrent  varchar(1) charset utf8   null,
    requests_recovery varchar(1) charset utf8   null,
    primary key (sched_name, entry_id)
)
    row_format = DYNAMIC;

create table qrtz_job_details
(
    sched_name        varchar(120) charset utf8 not null,
    job_name          varchar(200) charset utf8 not null,
    job_group         varchar(200) charset utf8 not null,
    description       varchar(250) charset utf8 null,
    job_class_name    varchar(250) charset utf8 not null,
    is_durable        varchar(1) charset utf8   not null,
    is_nonconcurrent  varchar(1) charset utf8   not null,
    is_update_data    varchar(1) charset utf8   not null,
    requests_recovery varchar(1) charset utf8   not null,
    job_data          blob                      null,
    primary key (sched_name, job_name, job_group)
)
    row_format = DYNAMIC;

create table qrtz_locks
(
    sched_name varchar(120) charset utf8 not null,
    lock_name  varchar(40) charset utf8  not null,
    primary key (sched_name, lock_name)
)
    row_format = DYNAMIC;

create table qrtz_paused_trigger_grps
(
    sched_name    varchar(120) charset utf8 not null,
    trigger_group varchar(200) charset utf8 not null,
    primary key (sched_name, trigger_group)
)
    row_format = DYNAMIC;

create table qrtz_scheduler_state
(
    sched_name        varchar(120) charset utf8 not null,
    instance_name     varchar(200) charset utf8 not null,
    last_checkin_time bigint(13)                not null,
    checkin_interval  bigint(13)                not null,
    primary key (sched_name, instance_name)
)
    row_format = DYNAMIC;

create table qrtz_triggers
(
    sched_name     varchar(120) charset utf8 not null,
    trigger_name   varchar(200) charset utf8 not null,
    trigger_group  varchar(200) charset utf8 not null,
    job_name       varchar(200) charset utf8 not null,
    job_group      varchar(200) charset utf8 not null,
    description    varchar(250) charset utf8 null,
    next_fire_time bigint(13)                null,
    prev_fire_time bigint(13)                null,
    priority       int                       null,
    trigger_state  varchar(16) charset utf8  not null,
    trigger_type   varchar(8) charset utf8   not null,
    start_time     bigint(13)                not null,
    end_time       bigint(13)                null,
    calendar_name  varchar(200) charset utf8 null,
    misfire_instr  smallint(2)               null,
    job_data       blob                      null,
    primary key (sched_name, trigger_name, trigger_group),
    constraint qrtz_triggers_ibfk_1
        foreign key (sched_name, job_name, job_group) references qrtz_job_details (sched_name, job_name, job_group)
)
    row_format = DYNAMIC;

create table qrtz_blob_triggers
(
    sched_name    varchar(120) charset utf8 not null,
    trigger_name  varchar(200) charset utf8 not null,
    trigger_group varchar(200) charset utf8 not null,
    blob_data     blob                      null,
    primary key (sched_name, trigger_name, trigger_group),
    constraint qrtz_blob_triggers_ibfk_1
        foreign key (sched_name, trigger_name, trigger_group) references qrtz_triggers (sched_name, trigger_name, trigger_group)
)
    row_format = DYNAMIC;

create table qrtz_cron_triggers
(
    sched_name      varchar(120) charset utf8 not null,
    trigger_name    varchar(200) charset utf8 not null,
    trigger_group   varchar(200) charset utf8 not null,
    cron_expression varchar(200) charset utf8 not null,
    time_zone_id    varchar(80) charset utf8  null,
    primary key (sched_name, trigger_name, trigger_group),
    constraint qrtz_cron_triggers_ibfk_1
        foreign key (sched_name, trigger_name, trigger_group) references qrtz_triggers (sched_name, trigger_name, trigger_group)
)
    row_format = DYNAMIC;

create table qrtz_simple_triggers
(
    sched_name      varchar(120) charset utf8 not null,
    trigger_name    varchar(200) charset utf8 not null,
    trigger_group   varchar(200) charset utf8 not null,
    repeat_count    bigint(7)                 not null,
    repeat_interval bigint(12)                not null,
    times_triggered bigint(10)                not null,
    primary key (sched_name, trigger_name, trigger_group),
    constraint qrtz_simple_triggers_ibfk_1
        foreign key (sched_name, trigger_name, trigger_group) references qrtz_triggers (sched_name, trigger_name, trigger_group)
)
    row_format = DYNAMIC;

create table qrtz_simprop_triggers
(
    sched_name    varchar(120) charset utf8 not null,
    trigger_name  varchar(200) charset utf8 not null,
    trigger_group varchar(200) charset utf8 not null,
    str_prop_1    varchar(512) charset utf8 null,
    str_prop_2    varchar(512) charset utf8 null,
    str_prop_3    varchar(512) charset utf8 null,
    int_prop_1    int                       null,
    int_prop_2    int                       null,
    long_prop_1   bigint                    null,
    long_prop_2   bigint                    null,
    dec_prop_1    decimal(13, 4)            null,
    dec_prop_2    decimal(13, 4)            null,
    bool_prop_1   varchar(1) charset utf8   null,
    bool_prop_2   varchar(1) charset utf8   null,
    primary key (sched_name, trigger_name, trigger_group),
    constraint qrtz_simprop_triggers_ibfk_1
        foreign key (sched_name, trigger_name, trigger_group) references qrtz_triggers (sched_name, trigger_name, trigger_group)
)
    row_format = DYNAMIC;

create index sched_name
    on qrtz_triggers (sched_name, job_name, job_group);

create table re_album_drug
(
    album_id int not null comment '产品相册ID',
    drug_id  int not null comment '药品ID',
    constraint re_album_drug_index
        unique (album_id, drug_id)
)
    row_format = DYNAMIC;

create table re_dept_drug
(
    drug_id int null,
    dept_id int null
)
    charset = utf8
    row_format = DYNAMIC;

create table report_handler_dept_relation
(
    id            int auto_increment comment '主键id'
        primary key,
    report_type   varchar(20)   null comment '报告类型',
    detp_id       int           null comment '企业id',
    handler_class varchar(64)   null comment '处理类',
    create_time   datetime      null comment '创建时间',
    create_user   int           null comment '创建人',
    update_time   datetime      null comment '更新时间',
    update_user   int           null comment '更新人',
    template      varchar(1024) null comment '模板文件名称'
)
    comment '导出报告处理类和企业关系表';

create table single_ent_settle_same_amount_for_members_in_current_month
(
    record_id               int unsigned auto_increment comment 'id'
        primary key,
    note_id                 int unsigned                       null comment '积分包计算记录id',
    realname                varchar(32)                        null comment '用户名称',
    username                varchar(11)                        null comment '用户名',
    id_number               varchar(18)                        null comment '身份证',
    dept_id                 int                                null comment '结算企业id',
    dept_name               varchar(64)                        null comment '结算企业名称',
    settle_amount           decimal(20, 2)                     null comment '结算金额',
    sub_to_gig_time         datetime                           null comment '结算时间',
    settle_state            varchar(16)                        null comment '结算企业名称',
    sub_type_name           varchar(16)                        null comment '结算渠道名称',
    package_name            varchar(64)                        null comment '积分包名称',
    settle_note_create_time datetime                           null comment '结算记录创建时间',
    period int unsigned null comment '统计周期',
    member_count            int unsigned                       null comment '风控人数',
    uuid                    varchar(64)                        not null comment 'uuid',
    create_time             datetime default CURRENT_TIMESTAMP null comment '创建时间'
)
    comment '单人连续多月结算相同金额';

create index idx_uuid
    on single_ent_settle_same_amount_for_members_in_current_month (uuid);

create table single_member_settle_amount_overrun_in_several_months
(
    record_id               int unsigned auto_increment comment 'id'
        primary key,
    note_id                 int unsigned                       null comment '积分包计算记录id',
    realname                varchar(32)                        null comment '用户名称',
    username                varchar(11)                        null comment '用户名',
    dept_id                 int                                null comment '结算企业id',
    dept_name               varchar(64)                        null comment '结算企业名称',
    settle_amount           decimal(20, 2)                     null comment '结算金额',
    sub_to_gig_time         datetime                           null comment '结算时间',
    settle_state            varchar(16)                        null comment '结算企业名称',
    sub_type_name           varchar(16)                        null comment '结算渠道名称',
    package_name            varchar(64)                        null comment '积分包名称',
    settle_note_create_time datetime                           null comment '结算记录创建时间',
    period int unsigned null comment '统计周期',
    platform_limit          decimal                            null comment '结算限制',
    uuid                    varchar(64)                        not null comment 'uuid',
    create_time             datetime default CURRENT_TIMESTAMP null comment '创建时间'
)
    comment '单人连续多月结算额超标';

create index idx_uuid
    on single_member_settle_amount_overrun_in_several_months (uuid);

create table single_member_settle_same_amount_in_several_months
(
    record_id               int unsigned auto_increment comment 'id'
        primary key,
    note_id                 int unsigned                       null comment '积分包计算记录id',
    realname                varchar(32)                        null comment '用户名称',
    username                varchar(11)                        null comment '用户名',
    id_number               varchar(18)                        null comment '身份证',
    dept_id                 int                                null comment '结算企业id',
    dept_name               varchar(64)                        null comment '结算企业名称',
    settle_amount           decimal(20, 2)                     null comment '结算金额',
    sub_to_gig_time         datetime                           null comment '结算时间',
    settle_state            varchar(16)                        null comment '结算企业名称',
    sub_type_name           varchar(16)                        null comment '结算渠道名称',
    package_name            varchar(64)                        null comment '积分包名称',
    settle_note_create_time datetime                           null comment '结算记录创建时间',
    period int unsigned null comment '统计周期',
    uuid                    varchar(64)                        not null comment 'uuid',
    create_time             datetime default CURRENT_TIMESTAMP null comment '创建时间'
)
    comment '单人连续多月结算相同金额';

create index idx_uuid
    on single_member_settle_same_amount_in_several_months (uuid);

create table single_member_without_such_task_types_in_several_months
(
    record_id            int unsigned auto_increment comment 'id'
        primary key,
    user_id              int unsigned                       null comment '用户id',
    package_id           int unsigned                       null comment '积分包id',
    package_name         varchar(32)                        null comment '积分包名称',
    status               varchar(11)                        null comment '积分包状态',
    realname             varchar(32)                        null comment '用户名称',
    username             varchar(11)                        null comment '用户名',
    dept_id              int                                null comment '结算企业id',
    dept_name            varchar(64)                        null comment '结算企业名称',
    period int unsigned null comment '统计周期',
    type_list            varchar(255)                       null comment '风控任务类型',
    package_create_time  datetime                           null comment '积分包创建时间',
    package_pick_up_time datetime                           null comment '积分包领取时间',
    first_task_time      datetime                           null comment '首个任务时间',
    uuid                 varchar(64)                        not null comment 'uuid',
    create_time          datetime default CURRENT_TIMESTAMP null comment '创建时间'
)
    comment '单人连续多月结算相同金额';

create index idx_uuid
    on single_member_without_such_task_types_in_several_months (uuid);

create table sys_cert_result_record
(
    id           int(20) auto_increment
        primary key,
    user_id      int(20)                             not null comment '用户id',
    dept_id      int(20)                             not null comment '归属体id',
    subject_type int(1)                              not null comment '归属类型：0-> 人力家，1-> 税邦云',
    method       varchar(25)                         not null comment '请求方法',
    code         varchar(5)                          null comment '状态码',
    status       varchar(5)                          null comment '结果码',
    message      varchar(256)                        not null comment '结果信息',
    create_time  timestamp default CURRENT_TIMESTAMP not null on update CURRENT_TIMESTAMP comment '创建时间'
)
    comment '认证结果记录表' row_format = DYNAMIC;

create table sys_csm_user_relation
(
    user_id   int not null comment 'csm用户id',
    parent_id int not null comment '父级用户id',
    primary key (user_id, parent_id)
)
    comment 'csm用户关系表';

create table sys_dept
(
    dept_id                      int(20) auto_increment
        primary key,
    name                         varchar(50)                        not null,
    sort                         int      default 0                 not null comment '排序',
    create_time                  datetime default CURRENT_TIMESTAMP null comment '创建时间',
    update_time                  datetime                           null on update CURRENT_TIMESTAMP comment '修改时间',
    del_flag                     char     default '0'               null,
    parent_id                    int                                null,
    tenant_id                    int                                null,
    dept_code                    varchar(50)                        null,
    level                        int(2)                             null comment '级别',
    level1_name                  varchar(50)                        null comment '药企名称',
    level1_id                    int                                null comment '药企ID',
    level2_name                  varchar(50)                        null comment '一级代理商名称',
    level2_id                    int                                null comment '一级代理商ID',
    level3_name                  varchar(50)                        null comment '二级代理商名称',
    level3_id                    int                                null comment '二级代理商ID',
    app_id                       varchar(32)                        null,
    app_secret                   varchar(255)                       null,
    rsa_public_key               varchar(256)                       null,
    query_url                    varchar(255)                       null,
    subject_name                 varchar(128)                       null comment '结算主体',
    subject_type                 varchar(1024)                      null,
    tax_code                     varchar(50)                        null comment '税号',
    dept_permissions             varchar(255)                       null comment '部门专用权限限制（字符串逗号分隔:0.导出）',
    gmv1_rate                    int                                null comment 'gmv1收益率（万分之）',
    gmv2_rate                    int                                null comment 'gmv2收益率（万分之）',
    renlijia_service_charge_rate int                                null comment '人力家服务费（万分之）',
    issue_date                   date                               null comment '服务起始时间',
    expiry_date                  date                               null comment '服务截止时间',
    financial_review_type        char(10)                           null comment '财务复核方式',
    emails                       varchar(1024)                      null comment '邮箱(多个逗号分隔)',
    constraint sys_dept_dept_code_uindex
        unique (dept_code)
)
    comment '部门管理' row_format = DYNAMIC;

create table sys_dept_0517
(
    dept_id        int(20) auto_increment
        primary key,
    name           varchar(50)                        not null,
    sort           int      default 0                 not null comment '排序',
    create_time    datetime default CURRENT_TIMESTAMP null comment '创建时间',
    update_time    datetime                           null on update CURRENT_TIMESTAMP comment '修改时间',
    del_flag       char     default '0'               null,
    parent_id      int                                null,
    tenant_id      int                                null,
    dept_code      varchar(50)                        null,
    level          int(2)                             null comment '级别',
    level1_name    varchar(50)                        null comment '药企名称',
    level1_id      int                                null comment '药企ID',
    level2_name    varchar(50)                        null comment '一级代理商名称',
    level2_id      int                                null comment '一级代理商ID',
    level3_name    varchar(50)                        null comment '二级代理商名称',
    level3_id      int                                null comment '二级代理商ID',
    app_id         varchar(32)                        null,
    app_secret     varchar(255)                       null,
    rsa_public_key varchar(256)                       null,
    query_url      varchar(255)                       null,
    subject_name   varchar(128)                       null comment '结算主体',
    subject_type   varchar(2)                         null comment '认证方式0-人力家 1-税邦云'
)
    comment '部门管理' row_format = DYNAMIC;

create table sys_dept_csm
(
    rec_id       int(20) auto_increment comment 'id'
        primary key,
    dept_id      int(20)                            not null comment '企业id',
    wl_qrcode_id varchar(32)                        not null comment '绑定的智能码 id',
    corp_id      varchar(32)                        not null comment '企业id',
    csm_name     varchar(32)                        not null comment '客户成功姓名',
    user_id      int                                null comment '用户id',
    create_time  datetime default CURRENT_TIMESTAMP not null comment '创建时间',
    update_time  datetime default CURRENT_TIMESTAMP not null on update CURRENT_TIMESTAMP comment '修改时间'
)
    comment '企业csm表';

create index idx_dept_id
    on sys_dept_csm (dept_id);

create table sys_dept_encryptor
(
    id              int(20) auto_increment
        primary key,
    dept_id         int(20)                             not null comment '主体id',
    ser_public_key  varchar(2048)                       not null comment '服务器公钥',
    ser_private_key varchar(2048)                       not null comment '服务器私钥',
    cli_public_key  varchar(2048)                       null comment '客户端公钥',
    cli_private_key varchar(2048)                       null comment '客户端私钥',
    signature       varchar(32)                         not null comment '签名字符串',
    create_time     timestamp default CURRENT_TIMESTAMP not null comment '创建时间',
    update_time     timestamp default CURRENT_TIMESTAMP not null comment '更新时间'
)
    comment '主体加密器' row_format = DYNAMIC;

create table sys_dept_invoice
(
    id                      int auto_increment comment '主键id'
        primary key,
    dept_id                 int                                      null comment '组织机构ID',
    invoice_amount          decimal(10, 2) default 0.00              not null comment '开票金额（元）',
    relation_package_score  int            default 0                 not null comment '关联积分值',
    relation_package_number int            default 0                 not null comment '关联积分包个数',
    approval_status         varchar(10)    default 'PENDING'         not null comment '审核状态',
    approval_time           datetime                                 null comment '审核时间',
    invoice_type            char(10)                                 not null comment '发票类型',
    address                 varchar(64)                              null comment '邮寄地址',
    addressee_name          varchar(32)                              null comment '收件人姓名',
    addressee_phone         varchar(20)                              null comment '收件人手机号',
    del_flag                varchar(10)    default '0'               not null comment '是否删除',
    create_time             datetime       default CURRENT_TIMESTAMP null comment '创建时间',
    create_user             int                                      null comment '创建人',
    update_time             datetime                                 null comment '更新时间',
    update_user             int                                      null comment '更新人'
)
    comment '企业开票表';

create index sys_dept_invoice_dept_id_index
    on sys_dept_invoice (dept_id);

create table sys_dept_invoice_relation
(
    id             int auto_increment comment '主键id'
        primary key,
    invoice_id     int                                   null comment '企业开票表ID',
    dept_id        int                                   not null comment '发包企业id',
    package_id     int                                   not null comment '积分包id',
    invoice_status varchar(10) default 'PENDING'         not null comment '开票状态',
    invoice_time   datetime                              null comment '开票时间',
    del_flag       varchar(10) default '0'               not null comment '是否删除',
    create_time    datetime    default CURRENT_TIMESTAMP null comment '创建/申请时间',
    create_user    int                                   null comment '创建人',
    update_time    datetime                              null comment '更新时间',
    update_user    int                                   null comment '更新人',
    constraint sys_dept_invoice_relation_invoice_id_package_id_uindex
        unique (invoice_id, package_id)
)
    comment '企业开票关联表';

create table sys_dept_recharge
(
    id              int auto_increment comment '主键id'
        primary key,
    dept_id         int                                      null comment '组织机构ID',
    score           int            default 0                 not null comment '积分余额',
    balance         decimal(10, 2) default 0.00              not null comment '余额（元）(已废弃)',
    permissions     varchar(64)                              null comment '权限,多个逗号分隔',
    service_charge  decimal(5, 2)  default 0.00              not null comment '服务费率',
    overdraw_amount decimal(10, 2) default 0.00              not null comment '可透支金额(已废弃)',
    overdraw_score  int            default 0                 not null comment '可透支积分',
    del_flag        varchar(10)    default '0'               not null comment '是否删除',
    create_time     datetime       default CURRENT_TIMESTAMP null comment '创建时间',
    create_user     int                                      null comment '创建人',
    update_time     datetime                                 null comment '更新时间',
    update_user     int                                      null comment '更新人',
    version         int            default 0                 null,
    constraint sys_dept_recharge_dept_id_uindex
        unique (dept_id)
)
    comment '积分充值表';

create table sys_dept_recharge_record
(
    id               int auto_increment comment '主键id'
        primary key,
    recharge_id      int                                      null comment '积分充值表ID',
    dept_id          int                                      null comment '组织机构ID',
    relation_dept_id int                                      null comment '关联组织机构ID（关联操作对象）',
    change_score     int                                      not null comment '充值积分',
    change_amount    decimal(10, 2) default 0.00              not null comment '充值金额（元）(已废弃)',
    type             char(25)                                 not null comment '操作类型',
    current_score    int                                      not null comment '充值后积分余额',
    current_balance  decimal(10, 2) default 0.00              not null comment '充值后积分余额（元）(已废弃)',
    package_id       int                                      null comment '积分包id',
    package_type     varchar(32)                              null comment '积分包类型',
    del_flag         varchar(10)    default '0'               not null comment '是否删除',
    create_time      datetime       default CURRENT_TIMESTAMP null comment '创建时间',
    create_user      int                                      null comment '创建人'
)
    comment '积分充值/使用记录表';

create index sys_dept_recharge_record_dept_id_index
    on sys_dept_recharge_record (dept_id);

create table sys_dept_relation
(
    ancestor   int not null comment '祖先节点',
    descendant int not null comment '后代节点'
)
    comment '部门关系表' row_format = DYNAMIC;

create index idx1
    on sys_dept_relation (ancestor);

create index idx2
    on sys_dept_relation (descendant);

create table sys_dept_sub
(
    sub_id                   int auto_increment
        primary key,
    dept_id                  int(20)                    not null,
    subject_type             varchar(2)    default '0'  not null comment '认证方式0-人力家 1-税邦云',
    subject_channel          int           default 0    not null comment '结算通道',
    subject_location         varchar(64)                null comment '税源地',
    app_id                   varchar(255)  default '0'  null,
    app_secret               varchar(2048)              null,
    rsa_public_key           varchar(2048)              null,
    query_url                varchar(255)               null,
    subject_name             varchar(128)               null comment '结算主体',
    limit_amount             decimal(18, 2)             null,
    enable_flag              varchar(2)    default '0'  null,
    subject_user_type        varchar(2)                 null comment '税邦云用户类型id',
    subject_invoice_category varchar(25)                null comment '税邦云用户类型对应的发票类目',
    path_no                  varchar(128)               null comment '汇企云批次付款渠道编号',
    update_time              datetime                   null comment '更新时间',
    service_charge           decimal(4, 2) default 0.00 not null,
    cert_enable              tinyint       default 1    null comment '认证是否启用：1：启用，0：停用',
    settle_enable            tinyint       default 1    null comment '结算是否启用：1：启用，0：停用',
    eid_enable               tinyint       default 1    null comment 'E证通认证是否启用：1-启用，0-停用'
)
    comment '部门结算主体管理' row_format = DYNAMIC;

create table sys_dict
(
    id          int(64) auto_increment comment '编号'
        primary key,
    type        varchar(100)                       null,
    description varchar(100)                       null,
    create_time datetime default CURRENT_TIMESTAMP not null comment '创建时间',
    update_time datetime default CURRENT_TIMESTAMP not null comment '更新时间',
    remarks     varchar(255)                       null,
    `system`    char     default '0'               null,
    del_flag    char     default '0'               null,
    tenant_id   int      default 0                 not null comment '所属租户'
)
    comment '字典表' row_format = DYNAMIC;

create index sys_dict_del_flag
    on sys_dict (del_flag);

create table sys_dict_item
(
    id          int(64) auto_increment comment '编号'
        primary key,
    dict_id     int                                not null,
    value       varchar(100)                       null,
    label       varchar(100)                       null,
    type        varchar(100)                       null,
    description varchar(512)                       null,
    sort        int(10)  default 0                 not null comment '排序（升序）',
    create_time datetime default CURRENT_TIMESTAMP not null comment '创建时间',
    update_time datetime default CURRENT_TIMESTAMP not null on update CURRENT_TIMESTAMP comment '更新时间',
    remarks     varchar(255)                       null,
    del_flag    char     default '0'               null,
    tenant_id   int      default 0                 not null comment '所属租户'
)
    comment '字典项' row_format = DYNAMIC;

create index sys_dict_del_flag
    on sys_dict_item (del_flag);

create index sys_dict_label
    on sys_dict_item (label);

create index sys_dict_value
    on sys_dict_item (value);

create table sys_dict_item_copy
(
    id          int(64) auto_increment comment '编号'
        primary key,
    dict_id     int                                not null,
    value       varchar(100)                       null,
    label       varchar(100)                       null,
    type        varchar(100)                       null,
    description varchar(100)                       null,
    sort        int(10)  default 0                 not null comment '排序（升序）',
    create_time datetime default CURRENT_TIMESTAMP not null comment '创建时间',
    update_time datetime default CURRENT_TIMESTAMP not null on update CURRENT_TIMESTAMP comment '更新时间',
    remarks     varchar(255)                       null,
    del_flag    char     default '0'               null,
    tenant_id   int      default 0                 not null comment '所属租户'
)
    comment '字典项' row_format = DYNAMIC;

create index sys_dict_del_flag
    on sys_dict_item_copy (del_flag);

create index sys_dict_label
    on sys_dict_item_copy (label);

create index sys_dict_value
    on sys_dict_item_copy (value);

create table sys_ent_rel
(
    rel_id      int(20) auto_increment comment 'id'
        primary key,
    ent_id      int(20)                            not null comment '企业id',
    e_type      varchar(8)                         not null comment '租户类型',
    pro_line    varchar(8)                         not null comment '产品线',
    e_level     varchar(8)                         not null comment '租户层级',
    parent_id   int(20)                            not null comment '父级id',
    root_id     int(20)                            not null comment '顶层id',
    create_time datetime default CURRENT_TIMESTAMP not null comment '创建时间',
    update_time datetime default CURRENT_TIMESTAMP not null on update CURRENT_TIMESTAMP comment '修改时间'
)
    comment '企业层级关系表';

create index idx_level
    on sys_ent_rel (e_level);

create index idx_pid
    on sys_ent_rel (parent_id);

create index idx_pro_line
    on sys_ent_rel (pro_line);

create index idx_rid
    on sys_ent_rel (root_id);

create index idx_type
    on sys_ent_rel (e_type);

create table sys_file
(
    id          bigint(32) auto_increment comment '编号'
        primary key,
    file_name   varchar(1500)                      null,
    bucket_name varchar(200)                       null,
    original    varchar(1500)                      null,
    type        varchar(50)                        null,
    file_size   bigint(50)                         null comment '文件大小',
    create_user varchar(32)                        null,
    create_time datetime default CURRENT_TIMESTAMP null comment '上传时间',
    update_user varchar(32)                        null,
    update_time datetime default CURRENT_TIMESTAMP null on update CURRENT_TIMESTAMP comment '更新时间',
    del_flag    char     default '0'               null,
    tenant_id   int                                null comment '所属租户'
)
    comment '文件管理表' row_format = DYNAMIC;

create table sys_job
(
    job_id              int auto_increment comment '任务id',
    job_name            varchar(64)                            not null comment '任务名称',
    job_group           varchar(64)                            not null comment '任务组名',
    job_order           char         default '1'               null comment '组内执行顺利，值越大执行优先级越高，最大值9，最小值1',
    job_type            char         default '1'               not null comment '1、java类;2、spring bean名称;3、rest调用;4、jar调用;9其他',
    execute_path        varchar(500)                           null comment 'job_type=3时，rest调用地址，仅支持rest get协议,需要增加String返回值，0成功，1失败;job_type=4时，jar路径;其它值为空',
    class_name          varchar(500)                           null comment 'job_type=1时，类完整路径;job_type=2时，spring bean名称;其它值为空',
    method_name         varchar(500)                           null comment '任务方法',
    method_params_value varchar(2000)                          null comment '参数值',
    cron_expression     varchar(255)                           null comment 'cron执行表达式',
    misfire_policy      varchar(20)  default '3'               null comment '错失执行策略（1错失周期立即执行 2错失周期执行一次 3下周期执行）',
    job_tenant_type     char         default '1'               null comment '1、多租户任务;2、非多租户任务',
    job_status          char         default '0'               null comment '状态（1、未发布;2、运行中;3、暂停;4、删除;）',
    job_execute_status  char         default '0'               null comment '状态（0正常 1异常）',
    create_by           varchar(64)                            null comment '创建者',
    create_time         datetime     default CURRENT_TIMESTAMP not null comment '创建时间',
    update_by           varchar(64)  default ''                null comment '更新者',
    update_time         datetime     default CURRENT_TIMESTAMP not null comment '更新时间',
    start_time          timestamp                              null comment '初次执行时间',
    previous_time       timestamp                              null comment '上次执行时间',
    next_time           timestamp                              null comment '下次执行时间',
    tenant_id           int          default 1                 null comment '租户',
    remark              varchar(500) default ''                null comment '备注信息',
    primary key (job_id, job_name, job_group)
)
    comment '定时任务调度表' row_format = DYNAMIC;

create table sys_job_log
(
    job_log_id          int auto_increment comment '任务日志ID'
        primary key,
    job_id              int                                                  not null comment '任务id',
    job_name            varchar(64) charset utf8                             null comment '任务名称',
    job_group           varchar(64) charset utf8                             null comment '任务组名',
    job_order           char charset utf8                                    null comment '组内执行顺利，值越大执行优先级越高，最大值9，最小值1',
    job_type            char charset utf8          default '1'               not null comment '1、java类;2、spring bean名称;3、rest调用;4、jar调用;9其他',
    execute_path        varchar(500) charset utf8                            null comment 'job_type=3时，rest调用地址，仅支持post协议;job_type=4时，jar路径;其它值为空',
    class_name          varchar(500) charset utf8                            null comment 'job_type=1时，类完整路径;job_type=2时，spring bean名称;其它值为空',
    method_name         varchar(500) charset utf8                            null comment '任务方法',
    method_params_value varchar(2000) charset utf8                           null comment '参数值',
    cron_expression     varchar(255) charset utf8                            null comment 'cron执行表达式',
    job_message         varchar(500) charset utf8                            null comment '日志信息',
    job_log_status      char charset utf8          default '0'               null comment '执行状态（0正常 1失败）',
    execute_time        varchar(30) charset utf8                             null comment '执行时间',
    exception_info      varchar(2000) charset utf8 default ''                null comment '异常信息',
    create_time         datetime                   default CURRENT_TIMESTAMP not null comment '创建时间',
    tenant_id           int                        default 1                 not null comment '租户id',
    uuid                varchar(64)                                          null comment 'uuid'
)
    comment '定时任务执行日志表' row_format = DYNAMIC;

create table sys_log
(
    id          bigint(64) auto_increment comment '编号'
        primary key,
    type        char     default '0'               null,
    title       varchar(255)                       null,
    service_id  varchar(32)                        null,
    create_by   varchar(255)                       null,
    create_time datetime default CURRENT_TIMESTAMP null comment '创建时间',
    update_time datetime                           null on update CURRENT_TIMESTAMP comment '更新时间',
    remote_addr varchar(255)                       null,
    user_agent  varchar(1000)                      null,
    request_uri varchar(255)                       null,
    method      varchar(10)                        null,
    params      text                               null,
    resp        text                               null comment '响应信息',
    time        mediumtext charset utf8            null comment '执行时间',
    del_flag    char     default '0'               null,
    exception   text                               null,
    tenant_id   int      default 0                 null comment '所属租户'
)
    comment '日志表' row_format = DYNAMIC;

create index sys_log_create_by
    on sys_log (create_by(191));

create index sys_log_create_date
    on sys_log (create_time);

create index sys_log_request_uri
    on sys_log (request_uri(191));

create index sys_log_type
    on sys_log (type);

create table sys_menu
(
    menu_id     int auto_increment comment '菜单ID'
        primary key,
    name        varchar(32)                        null,
    permission  varchar(32)                        null,
    path        varchar(128)                       null,
    parent_id   int                                null comment '父菜单ID',
    icon        varchar(32)                        null,
    sort        int      default 1                 null comment '排序值',
    keep_alive  char     default '0'               null,
    type        char     default '0'               null,
    create_time datetime default CURRENT_TIMESTAMP null comment '创建时间',
    update_time datetime                           null comment '更新时间',
    del_flag    char     default '0'               null,
    tenant_id   int(11) unsigned                   null comment '租户ID'
)
    comment '菜单权限表' row_format = DYNAMIC;

create table sys_oauth_client_details
(
    id                      int auto_increment comment 'ID'
        primary key,
    client_id               varchar(32)      not null,
    resource_ids            varchar(256)     null,
    client_secret           varchar(256)     null,
    scope                   varchar(256)     null,
    authorized_grant_types  varchar(256)     null,
    web_server_redirect_uri varchar(256)     null,
    authorities             varchar(256)     null,
    access_token_validity   int              null,
    refresh_token_validity  int              null,
    additional_information  varchar(4096)    null,
    autoapprove             varchar(256)     null,
    del_flag                char default '0' null,
    tenant_id               int  default 0   not null comment '所属租户'
)
    comment '终端信息表' row_format = DYNAMIC;

create table sys_plat
(
    id        int          not null
        primary key,
    phone     varchar(255) null comment '手机号',
    idcard    varchar(255) null comment '身份证号',
    temp1     varchar(255) null comment '备用字段1',
    temp2     varchar(255) null comment '备用字段2',
    temp3     varchar(255) null comment '备用字段3',
    temp4     varchar(255) null comment '备用字段4',
    备用字段5 varchar(255) null comment '备用字段5'
)
    comment '平台用户信息' row_format = DYNAMIC;

create table sys_portal_conf
(
    conf_id       bigint auto_increment comment '主键'
        primary key,
    spec_path     varchar(32)                        not null comment '专属路径',
    portal_logo   varchar(255)                       not null comment 'logo',
    portal_icon   varchar(255)                       not null comment 'icon',
    portal_title  varchar(32)                        not null comment 'title',
    portal_name   varchar(16)                        not null comment '名称',
    bg_img        varchar(255)                       null comment '背景图',
    theme_color   json                               null comment '主题色',
    icp_no        varchar(128)                       not null comment 'icp备案',
    pc_no         varchar(128)                       not null comment 'pc备案号',
    created_by    varchar(64)                        not null comment '创建人',
    modified_by   varchar(64)                        not null comment '修改人',
    created_time  datetime default CURRENT_TIMESTAMP not null comment '创建时间',
    modified_time datetime default CURRENT_TIMESTAMP not null on update CURRENT_TIMESTAMP comment '修改时间'
)
    comment '门户配置信息' collate = utf8_bin;

create index sys_portal_conf_spec_path_index
    on sys_portal_conf (spec_path);

create table sys_public_param
(
    public_id     bigint auto_increment comment '编号'
        primary key,
    public_name   varchar(128)                       null comment '名称',
    public_key    varchar(128)                       null comment '键',
    public_value  varchar(128)                       null comment '值',
    status        char     default '0'               null comment '状态（0：正常，9：冻结）',
    validate_code varchar(64)                        null,
    create_time   datetime default CURRENT_TIMESTAMP not null comment '创建时间',
    update_time   datetime                           null on update CURRENT_TIMESTAMP comment '修改时间',
    public_type   char     default '0'               null,
    `system`      char     default '0'               null,
    del_flag      char     default '0'               null,
    tenant_id     int                                null comment '租户ID'
)
    comment '公共参数配置表' row_format = DYNAMIC;

create table sys_role
(
    role_id     int auto_increment
        primary key,
    role_name   varchar(64)                        null,
    role_code   varchar(64)                        null,
    role_desc   varchar(255)                       null,
    ds_type     char     default '2'               null,
    ds_scope    varchar(255)                       null,
    create_time datetime default CURRENT_TIMESTAMP not null,
    update_time datetime                           null,
    del_flag    char     default '0'               null,
    tenant_id   int                                null
)
    comment '系统角色表' row_format = DYNAMIC;

create index role_idx1_role_code
    on sys_role (role_code);

create table sys_role_menu
(
    role_id int not null comment '角色ID',
    menu_id int not null comment '菜单ID',
    primary key (role_id, menu_id)
)
    comment '角色菜单表' row_format = DYNAMIC;

create table sys_route_conf
(
    id          int auto_increment comment '主键'
        primary key,
    route_name  varchar(30)                        null,
    route_id    varchar(30)                        null,
    predicates  json                               null comment '断言',
    filters     json                               null comment '过滤器',
    uri         varchar(50)                        null,
    `order`     int(2)   default 0                 null comment '排序',
    create_time datetime default CURRENT_TIMESTAMP null comment '创建时间',
    update_time datetime                           null on update CURRENT_TIMESTAMP comment '修改时间',
    del_flag    char     default '0'               null
)
    comment '路由配置表' row_format = DYNAMIC;

create table sys_social_details
(
    id           int auto_increment comment '主鍵'
        primary key,
    type         varchar(16)                        null,
    remark       varchar(64)                        null,
    app_id       varchar(64)                        null,
    app_secret   varchar(64)                        null,
    random_key   varchar(16)                        null comment '随机key（16位）',
    redirect_url varchar(128)                       null,
    create_time  datetime default CURRENT_TIMESTAMP null comment '创建时间',
    update_time  datetime default CURRENT_TIMESTAMP null on update CURRENT_TIMESTAMP comment '更新时间',
    del_flag     char     default '0'               null,
    tenant_id    int      default 0                 not null comment '所属租户'
)
    comment '系统社交登录账号表' row_format = DYNAMIC;

create table sys_social_details_copy
(
    id           int auto_increment comment '主鍵'
        primary key,
    type         varchar(16)                        null,
    remark       varchar(64)                        null,
    app_id       varchar(64)                        null,
    app_secret   varchar(64)                        null,
    redirect_url varchar(128)                       null,
    create_time  datetime default CURRENT_TIMESTAMP null comment '创建时间',
    update_time  datetime default CURRENT_TIMESTAMP null on update CURRENT_TIMESTAMP comment '更新时间',
    del_flag     char     default '0'               null,
    tenant_id    int      default 0                 not null comment '所属租户'
)
    comment '系统社交登录账号表' row_format = DYNAMIC;

create table sys_social_details_copy1
(
    id           int auto_increment comment '主鍵'
        primary key,
    type         varchar(16)                        null,
    remark       varchar(64)                        null,
    app_id       varchar(64)                        null,
    app_secret   varchar(64)                        null,
    random_key   varchar(16)                        null comment '随机key（16位）',
    redirect_url varchar(128)                       null,
    create_time  datetime default CURRENT_TIMESTAMP null comment '创建时间',
    update_time  datetime default CURRENT_TIMESTAMP null on update CURRENT_TIMESTAMP comment '更新时间',
    del_flag     char     default '0'               null,
    tenant_id    int      default 0                 not null comment '所属租户'
)
    comment '系统社交登录账号表' row_format = DYNAMIC;

create table sys_tenant
(
    id          int auto_increment comment '租户id'
        primary key,
    name        varchar(255)                       null,
    code        varchar(64)                        null,
    start_time  datetime                           null comment '开始时间',
    end_time    datetime                           null comment '结束时间',
    status      char     default '0'               null,
    del_flag    char     default '0'               null,
    create_time datetime default CURRENT_TIMESTAMP not null comment '创建',
    update_time datetime default CURRENT_TIMESTAMP not null on update CURRENT_TIMESTAMP comment '更新时间'
)
    comment '租户表' row_format = DYNAMIC;

create table sys_user
(
    user_id                        int auto_increment comment '主键ID'
        primary key,
    username                       varchar(64)                          null,
    password                       varchar(255)                         null,
    salt                           varchar(255)                         null,
    phone                          varchar(20)                          null,
    avatar                         varchar(1024)                        null,
    dept_id                        int                                  null comment '部门ID',
    create_time                    datetime   default CURRENT_TIMESTAMP null comment '创建时间',
    update_time                    datetime                             null on update CURRENT_TIMESTAMP comment '修改时间',
    lock_flag                      char       default '0'               null,
    del_flag                       char       default '0'               null,
    wx_openid                      varchar(32)                          null comment '微信登录openId',
    mini_openid                    varchar(32)                          null comment '小程序openId',
    qq_openid                      varchar(32)                          null comment 'QQ openId',
    gitee_login                    varchar(100)                         null comment '码云 标识',
    osc_id                         varchar(100)                         null comment '开源中国 标识',
    tenant_id                      int        default 0                 not null comment '所属租户',
    realname                       varchar(30)                          null comment '用户姓名',
    province                       varchar(20)                          null comment '省',
    city                           varchar(20)                          null comment '市',
    area                           varchar(20)                          null comment '区',
    address                        varchar(255)                         null comment '地址',
    temp1                          varchar(255)                         null comment '备用字段1',
    temp2                          varchar(2000)                        null comment '备用字段2',
    temp3                          varchar(255)                         null comment '备用字段3',
    temp4                          varchar(255)                         null comment '备用字段4',
    temp5                          varchar(255)                         null comment '备用字段5',
    plat_id                        varchar(50)                          null comment '平台ID',
    drug_ent_id                    varchar(11)                          null comment '药企ID',
    w1                             varchar(255)                         null,
    id_card_number                 varchar(32)                          null comment '身份证',
    user_sign                      varchar(255)                         null comment '签名',
    cert_status                    int(2)                               null comment '认证状态',
    cert_remark                    varchar(255)                         null comment '认证结果描述',
    province_code                  varchar(11)                          null comment '省份编码',
    city_code                      varchar(11)                          null comment '城市编码',
    user_type                      varchar(2) default '0'               null comment '认证方式0-人力家 1-税邦云',
    bank_card_number               varchar(19)                          null comment '银行卡号',
    rlj_cert_status                int(2)                               null comment '人力家认证状态',
    tax_helper_agreement_signature int(1)     default 0                 null comment '税邦云协议签署记录 0 未签署 1 已签署',
    bank_phone                     varchar(11)                          null comment '银行预留手机号',
    bank_name                      varchar(32)                          null comment '开户行',
    sign_agreement                 varchar(1024)                        null comment '小程序签署协议信息',
    age_reminder                   tinyint    default 1                 null comment '年龄超60周岁提醒',
    re_signed_agreement            int        default 1                 null comment '是否已补签协议',
    gender                         char(5)                              null comment '性别，1男，2女',
    degree                         char(2)                              null comment '学历',
    qualification_record_number    varchar(64)                          null comment '医药代表资质备案号',
    qualifications_url             varchar(256)                         null comment '资质证书url'
)
    comment '用户表' row_format = DYNAMIC;

create index user_idx1_username
    on sys_user (username);

create index user_qq_openid
    on sys_user (qq_openid);

create index user_wx_openid
    on sys_user (wx_openid);

create table sys_user_0226
(
    user_id        int auto_increment comment '主键ID'
        primary key,
    username       varchar(64)                        null,
    password       varchar(255)                       null,
    salt           varchar(255)                       null,
    phone          varchar(20)                        null,
    avatar         varchar(255)                       null,
    dept_id        int                                null comment '部门ID',
    create_time    datetime default CURRENT_TIMESTAMP null comment '创建时间',
    update_time    datetime                           null on update CURRENT_TIMESTAMP comment '修改时间',
    lock_flag      char     default '0'               null,
    del_flag       char     default '0'               null,
    wx_openid      varchar(32)                        null comment '微信登录openId',
    mini_openid    varchar(32)                        null comment '小程序openId',
    qq_openid      varchar(32)                        null comment 'QQ openId',
    gitee_login    varchar(100)                       null comment '码云 标识',
    osc_id         varchar(100)                       null comment '开源中国 标识',
    tenant_id      int      default 0                 not null comment '所属租户',
    realname       varchar(30)                        null comment '用户姓名',
    province       varchar(20)                        null comment '省',
    city           varchar(20)                        null comment '市',
    area           varchar(20)                        null comment '区',
    address        varchar(255)                       null comment '地址',
    temp1          varchar(255)                       null comment '备用字段1',
    temp2          varchar(2000)                      null comment '备用字段2',
    temp3          varchar(255)                       null comment '备用字段3',
    temp4          varchar(255)                       null comment '备用字段4',
    temp5          varchar(255)                       null comment '备用字段5',
    plat_id        varchar(50)                        null comment '平台ID',
    drug_ent_id    varchar(11)                        null comment '药企ID',
    w1             varchar(255)                       null,
    id_card_number varchar(32)                        null comment '身份证',
    user_sign      varchar(255)                       null comment '签名',
    cert_status    int(2)                             null comment '认证状态',
    cert_remark    varchar(255)                       null comment '认证结果描述',
    province_code  varchar(11)                        null comment '省份编码',
    city_code      varchar(11)                        null comment '城市编码'
)
    comment '用户表' row_format = DYNAMIC;

create index user_idx1_username
    on sys_user_0226 (username);

create index user_qq_openid
    on sys_user_0226 (qq_openid);

create index user_wx_openid
    on sys_user_0226 (wx_openid);

create table sys_user_0517
(
    user_id          int auto_increment comment '主键ID'
        primary key,
    username         varchar(64)                          null,
    password         varchar(255)                         null,
    salt             varchar(255)                         null,
    phone            varchar(20)                          null,
    avatar           varchar(255)                         null,
    dept_id          int                                  null comment '部门ID',
    create_time      datetime   default CURRENT_TIMESTAMP null comment '创建时间',
    update_time      datetime                             null on update CURRENT_TIMESTAMP comment '修改时间',
    lock_flag        char       default '0'               null,
    del_flag         char       default '0'               null,
    wx_openid        varchar(32)                          null comment '微信登录openId',
    mini_openid      varchar(32)                          null comment '小程序openId',
    qq_openid        varchar(32)                          null comment 'QQ openId',
    gitee_login      varchar(100)                         null comment '码云 标识',
    osc_id           varchar(100)                         null comment '开源中国 标识',
    tenant_id        int        default 0                 not null comment '所属租户',
    realname         varchar(30)                          null comment '用户姓名',
    province         varchar(20)                          null comment '省',
    city             varchar(20)                          null comment '市',
    area             varchar(20)                          null comment '区',
    address          varchar(255)                         null comment '地址',
    temp1            varchar(255)                         null comment '备用字段1',
    temp2            varchar(2000)                        null comment '备用字段2',
    temp3            varchar(255)                         null comment '备用字段3',
    temp4            varchar(255)                         null comment '备用字段4',
    temp5            varchar(255)                         null comment '备用字段5',
    plat_id          varchar(50)                          null comment '平台ID',
    drug_ent_id      varchar(11)                          null comment '药企ID',
    w1               varchar(255)                         null,
    id_card_number   varchar(32)                          null comment '身份证',
    user_sign        varchar(255)                         null comment '签名',
    cert_status      int(2)                               null comment '认证状态',
    cert_remark      varchar(255)                         null comment '认证结果描述',
    province_code    varchar(11)                          null comment '省份编码',
    city_code        varchar(11)                          null comment '城市编码',
    user_type        varchar(2) default '0'               null comment '认证方式0-人力家 1-税邦云',
    bank_card_number varchar(19)                          null comment '银行卡号'
)
    comment '用户表' row_format = DYNAMIC;

create index user_idx1_username
    on sys_user_0517 (username);

create index user_qq_openid
    on sys_user_0517 (qq_openid);

create index user_wx_openid
    on sys_user_0517 (wx_openid);

create table sys_user_ext_record
(
    id                   int auto_increment comment '主键id'
        primary key,
    user_id              int              not null comment '用户id',
    dept_id              int              not null comment '部门id',
    real_name            varchar(30)      null comment '用户姓名',
    phone                varchar(20)      null comment '手机号',
    id_card_number       varchar(32)      null comment '身份证号',
    bank_card_number     varchar(19)      null comment '银行卡号',
    bank_phone           varchar(11)      null comment '银行预留手机号',
    id_card_front_url    varchar(255)     null comment '身份证照片-正面',
    id_card_back_url     varchar(255)     null comment '身份证照片-反面',
    id_card_front_base64 longtext         null comment '身份证照片-正面base64',
    id_card_back_base64  longtext         null comment '身份证照片-反面base64',
    best_frame_url       varchar(255)     null comment '最佳帧照片url',
    best_frame_base64    longtext         null comment '最佳帧照片base64',
    etoken               varchar(40)      null comment 'etoken',
    remark               varchar(255)     null comment '备注',
    del_flag             char default '0' null comment '删除标记',
    create_time          datetime         null comment '创建时间',
    create_user          int              null comment '创建人',
    update_time          datetime         null comment '更新时间',
    update_user          int              null comment '更新人'
)
    comment '用户认证相关的扩展信息';

create index sys_user_ext_record_user_id_index
    on sys_user_ext_record (user_id);

create table sys_user_record
(
    id          int auto_increment comment '主键id'
        primary key,
    user_id     varchar(64)                        null comment '用户id',
    type        varchar(64)                        null comment '记录类型',
    msg         varchar(1024)                      null comment '记录信息',
    del_flag    char(64) default '0'               not null comment '删除标记位',
    create_user varchar(64)                        null comment '创建人',
    create_time datetime default CURRENT_TIMESTAMP null comment '创建时间',
    update_user varchar(64)                        null comment '更新人',
    update_time datetime                           null on update CURRENT_TIMESTAMP comment '更新时间时间'
)
    comment '用户回访记录表';

create table sys_user_role
(
    user_id int not null comment '用户ID',
    role_id int not null comment '角色ID',
    primary key (user_id, role_id)
)
    comment '用户角色表' row_format = DYNAMIC;

create table sys_user_sub
(
    id                int auto_increment comment '主键ID'
        primary key,
    user_id           int              not null comment '用户ID',
    dept_id           int              null comment '部门id',
    gig_type          int(2)           not null comment '零工平台类型（订单支付方式类型:0-人力家 1-税邦云 2-自由职家 3-易联数科）',
    gig_channel       int    default 0 null comment '渠道',
    subject_location  varchar(64)      null comment '税源地',
    callback_status   int(1) default 0 null comment '回调状态',
    cert_status       int    default 0 not null comment '认证状态',
    cert_remark       longtext         null comment '认证结果描述',
    fail_reason       varchar(255)     null comment '认证失败原因',
    user_type         varchar(2)       null comment '人员类型',
    bank_card_number  varchar(19)      null comment '银行卡号',
    bank_phone        varchar(11)      null comment '银行预留手机号',
    bank_name         varchar(64)      null comment '开户行',
    id_card_front_url varchar(255)     null comment '身份证照片-正面',
    id_card_back_url  varchar(255)     null comment '身份证照片-反面',
    cert_video1_url   varchar(255)     null comment '认证视频1',
    cert_video2_url   varchar(255)     null comment '认证视频1',
    agreement_url     varchar(255)     null comment '协议',
    request_id        varchar(255)     null comment '请求流水号',
    create_time       datetime         null comment '创建时间',
    create_user       int              null comment '创建人',
    update_time       datetime         null comment '更新时间',
    update_user       int              null comment '更新人',
    callback_time     datetime         null comment '回调时间'
)
    comment '用户签约认证主体信息表';

create table sys_wx_reply_message
(
    id          int auto_increment comment '主鍵'
        primary key,
    keyword     varchar(255)                         not null comment '关键字',
    type        tinyint(1)                           not null comment '消息类型（0：文字，1：图片，2：视频，3：图文消息）',
    create_time datetime   default CURRENT_TIMESTAMP not null comment '创建时间',
    update_time datetime                             not null comment '更新时间',
    enable_flag tinyint(1) default 0                 not null comment '是否生效（0：未生效，1：生效）'
)
    comment '微信自动回复消息表' row_format = DYNAMIC;

create table sys_wx_reply_message_media
(
    id           int auto_increment comment '主键'
        primary key,
    media_type   tinyint(1)                         not null comment '素材类型（1：文字，2：图片，3：视频）',
    title        varchar(255)                       null comment '视频的标题',
    introduction varchar(255)                       null comment '视频的描述',
    content      varchar(1024)                      null comment '内容',
    name         varchar(255)                       null comment '文件名称',
    url          varchar(512)                       null comment 'url地址',
    wx_media_id  varchar(128)                       null comment '微信素材id',
    sort         int(2)                             not null comment '排序',
    create_time  datetime default CURRENT_TIMESTAMP not null comment '创建时间',
    update_time  datetime                           not null comment '更新时间'
)
    comment '微信自动回复消息素材表' row_format = DYNAMIC;

create table sys_wx_reply_message_relation
(
    id               int auto_increment
        primary key,
    message_id       int not null comment '微信消息id',
    message_media_id int not null comment '微信消息素材id'
)
    comment '微信消息和素材关联表' row_format = DYNAMIC;

create table upms_sequence
(
    id           bigint auto_increment
        primary key,
    value        bigint      not null,
    name         varchar(32) not null,
    gmt_create   datetime    not null,
    gmt_modified datetime    not null,
    constraint uk_name
        unique (name)
);

create table user_agreement_signature_record
(
    id          int auto_increment comment 'id'
        primary key,
    user_id     int                                not null comment '用户id',
    target      int(1)                             not null comment '协议方',
    agreement   mediumtext                         null comment '协议文本',
    sign_time   datetime                           not null comment '签署时间',
    create_time datetime default CURRENT_TIMESTAMP not null comment '创建时间',
    sign_img    longtext                           null comment '手签图片'
)
    comment '用户协议签名';

create table wm_ad_record
(
    record_id    bigint unsigned auto_increment comment 'id'
        primary key,
    user_id      int                                not null comment '用户id',
    ad_url       varchar(255)                       not null comment '跳转地址',
    created_time datetime default CURRENT_TIMESTAMP null comment '创建时间'
)
    comment '部门管理';

create table wm_af_customer
(
    id               int auto_increment comment '主键id'
        primary key,
    dept_id          int                          null comment '部门id',
    customer_number  varchar(20) charset utf8mb4  not null comment '客户id',
    customer_name    varchar(50) charset utf8mb4  not null comment '客户名称',
    customer_type    varchar(20)                  not null comment '客户类别(0-药企、1-CSO、2-CRO、3-其他)',
    customer_manager varchar(50) charset utf8mb4  not null comment '客户经理',
    channel_name     varchar(50) charset utf8mb4  null comment '渠道名称',
    sign_date        datetime                     null comment '签订日期',
    expiration_date  datetime                     null comment '有效期截止',
    customer_status  varchar(20)                  null comment '客户状态:(0-客户备案、1-合同立项、2-签约 、3-上线)',
    remark           varchar(128) charset utf8mb4 null comment '说明',
    contract_file    varchar(512) charset utf8mb4 null comment '合同附件',
    contract_name    varchar(50) charset utf8mb4  null comment '合同名称',
    create_time      datetime                     null comment '创建时间',
    create_user      int                          null comment '创建人',
    update_time      datetime                     null comment '更新时间',
    update_user      int                          null comment '更新人'
)
    comment '档案-客户管理' charset = utf8
                            row_format = DYNAMIC;

create table wm_contract
(
    id              bigint(11) auto_increment comment '编号'
        primary key,
    customer_id     int                          null comment '客户主键id',
    tenant_id       int                          null comment '租户id',
    serial_no       varchar(255)                 null comment '合同编号',
    title           varchar(255) charset utf8    null comment '合同名称',
    party_a         varchar(255) charset utf8    null comment '签约甲方',
    party_b         varchar(255) charset utf8    null comment '签约乙方',
    sign_time       datetime                     null comment '签约时间',
    expiration_time datetime                     null comment '有效截止时间',
    filing_time     datetime                     null comment '归档时间',
    state           varchar(255) charset utf8    null comment '说明',
    pic_url         varchar(255) charset utf8mb4 null comment '合同图片地址',
    mgr             varchar(50) charset utf8mb4  null comment '客户经理名称',
    remark          varchar(255) charset utf8    null comment '备注',
    create_user     int                          null comment '创建人',
    create_time     datetime                     null comment '创建时间',
    update_user     int                          null comment '修改人',
    update_time     datetime                     null comment '修改时间'
)
    comment '档案-合同管理' charset = latin1
                            row_format = DYNAMIC;

create table wm_contract0609
(
    id              bigint(11) auto_increment comment '编号'
        primary key,
    contract_number varchar(255)                 null comment '合同编号',
    contract_name   varchar(255) charset utf8    null comment '合同名称',
    sign_jia        varchar(255) charset utf8    null comment '签约甲方',
    sign_yi         varchar(255) charset utf8    null comment '签约乙方',
    sign_time       datetime                     null comment '签约时间',
    filing_time     datetime                     null comment '归档时间',
    state           varchar(255) charset utf8    null comment '说明',
    annex_contract  varchar(500) charset utf8mb4 null comment '合同附件',
    remark          varchar(255) charset utf8    null comment '备注',
    create_time     datetime                     null comment '创建时间',
    update_user     varchar(128) charset utf8    null comment '修改人',
    update_time     datetime                     null comment '修改时间',
    dept_id         varchar(11) charset utf8mb4  null comment '组织机构ID'
)
    comment '档案-合同管理' charset = latin1
                            row_format = DYNAMIC;

create table wm_da_agent
(
    id                 int auto_increment
        primary key,
    gsmc               varchar(50)                        not null comment '公司名称',
    yyzz               varchar(5000)                      null comment '营业执照',
    sbjnzm             varchar(5000)                      null comment '社保缴纳证明',
    frsfzzm_zm         varchar(500)                       null comment '法人身份证证明-正面',
    frsfzzm_bm         varchar(500)                       null comment '法人身份证证明-背面',
    frsfzzm_sc         varchar(500)                       null comment '法人身份证证明-手持',
    is_examine         char                               null comment '是否审核',
    zj_type            varchar(20)                        null comment '证件类型',
    zj_number          varchar(50)                        null comment '证件号码',
    ext_drug_ent       varchar(255)                       null comment '扩展可选药企',
    dept_id            varchar(11)                        null comment '组织机构ID',
    del_flag           char     default '0'               not null comment '是否删除',
    enable_flag        char     default '0'               not null comment '是否禁用',
    tenant_id          int      default 1                 not null comment '所属租户',
    create_time        datetime default CURRENT_TIMESTAMP null on update CURRENT_TIMESTAMP comment '创建时间',
    create_user        int                                null comment '创建人',
    update_time        datetime                           null comment '更新时间',
    update_user        varchar(200)                       null comment '更新人',
    drug_ent_id        varchar(20)                        null comment '所属药企',
    temp1              varchar(255)                       null,
    temp2              varchar(255)                       null,
    js_account         varchar(32)                        null comment '结算账号 ',
    management         varchar(2)                         null comment '管理模式',
    pgqx               varchar(11)                        null comment '派工权限',
    qylx               varchar(11)                        null comment '企业类型',
    subject_type       varchar(1024)                      null,
    agent_type         char(2)                            not null,
    mah_settle_dept_id int                                null comment 'MAH结算-药企deptId'
)
    comment '档案-代理商' row_format = DYNAMIC;

create table wm_da_agent_0517
(
    id           int auto_increment
        primary key,
    gsmc         varchar(50)                        not null comment '公司名称',
    yyzz         varchar(500)                       null comment '营业执照',
    sbjnzm       varchar(500)                       null comment '社保缴纳证明',
    frsfzzm_zm   varchar(500)                       null comment '法人身份证证明-正面',
    frsfzzm_bm   varchar(500)                       null comment '法人身份证证明-背面',
    frsfzzm_sc   varchar(500)                       null comment '法人身份证证明-手持',
    is_examine   char                               null comment '是否审核',
    zj_type      varchar(20)                        null comment '证件类型',
    zj_number    varchar(50)                        null comment '证件号码',
    ext_drug_ent varchar(255)                       null comment '扩展可选药企',
    dept_id      varchar(11)                        null comment '组织机构ID',
    del_flag     char     default '0'               not null comment '是否删除',
    enable_flag  char     default '0'               not null comment '是否禁用',
    tenant_id    int      default 1                 not null comment '所属租户',
    create_time  datetime default CURRENT_TIMESTAMP null on update CURRENT_TIMESTAMP comment '创建时间',
    create_user  int                                null comment '创建人',
    update_time  datetime                           null comment '更新时间',
    update_user  varchar(200)                       null comment '更新人',
    drug_ent_id  varchar(20)                        null comment '所属药企',
    temp1        varchar(255)                       null,
    temp2        varchar(255)                       null,
    js_account   varchar(32)                        null comment '结算账号 ',
    management   varchar(2)                         null comment '管理模式',
    pgqx         varchar(11)                        null comment '派工权限',
    qylx         varchar(11)                        null comment '企业类型',
    subject_type varchar(50)                        null
)
    comment '档案-代理商' row_format = DYNAMIC;

create table wm_da_dis_excel
(
    商业公司名称       varchar(255) null,
    商业公司地址       varchar(255) null,
    f3                 varchar(255) null,
    三合一社会信用代码 varchar(255) null,
    GSP证书编号        varchar(255) null,
    公司注册地         varchar(255) null,
    注册资本           varchar(255) null,
    法人代表           varchar(255) null
)
    row_format = DYNAMIC;

create table wm_da_distribution
(
    id                          int auto_increment
        primary key,
    gsmc                        varchar(50)            not null comment '商业公司名称',
    province                    longtext               null comment '省',
    city                        longtext               null comment '市',
    area                        longtext               null comment '区',
    address                     varchar(255)           not null comment '地址',
    longitude                   varchar(255)           null comment '经度',
    latitude                    varchar(255)           null comment '纬度',
    gsgm                        varchar(50)            null comment '公司规模',
    shyshxydm                   varchar(20)            not null comment '三合一社会信用代码',
    gszcd                       varchar(255)           not null comment '公司注册地',
    zczb                        varchar(20)            null comment '注册资本',
    gspzsbh                     varchar(20)            null comment 'GSP证书编号',
    frdb                        varchar(20)            not null comment '法人代表',
    zjl                         varchar(20)            null comment '总经理',
    cjbmfzrxm                   varchar(20)            null comment '采购部门负责人姓名',
    cjbmfzrlxfs                 varchar(20)            null comment '采购部门负责人联系方式',
    cgbmdjrxm                   varchar(20)            null comment '采购部门对接人姓名',
    cgbmdjrlxfs                 varchar(20)            null comment '采购部门对接人联系方式',
    xsbmfzrxm                   varchar(20)            null comment '销售部门负责人姓名',
    xsbmfzrlxfs                 varchar(20)            null comment '销售部门负责人联系方式',
    xsbmdjrxm                   varchar(20)            null comment '销售部门对接人姓名',
    xsbmdjrlxfs                 varchar(20)            null comment '销售部门对接人联系方式',
    gsjj                        varchar(2048)          null comment '公司简介',
    jyys                        varchar(500)           null comment '经营优势',
    dept_id                     varchar(11)            null comment '组织机构ID',
    del_flag                    varchar(1) default '0' not null comment '是否删除',
    enable_flag                 varchar(1) default '0' not null comment '是否禁用',
    tenant_id                   int        default 1   not null comment '所属租户',
    create_time                 datetime               null on update CURRENT_TIMESTAMP comment '创建时间',
    create_user                 int                    null comment '创建人',
    update_time                 datetime               null comment '更新时间',
    update_user                 int                    null comment '更新人',
    sygsdz                      varchar(255)           null comment '商业公司地址',
    medicine_traceability       varchar(1)             not null comment '药品信息化追溯体系（0-扫码入库，1-其他）',
    medicine_traceability_other varchar(255)           null comment '药品信息化追溯体系-其他（追溯体系介绍）'
)
    comment '档案-配送公司' row_format = DYNAMIC;

create table wm_da_drug_ent
(
    id           int auto_increment
        primary key,
    entname      varchar(50)      null comment '企业名称',
    entcode      varchar(50)      null comment '组织机构代码',
    temp1        varchar(50)      null,
    temp2        varchar(50)      null,
    temp3        varchar(50)      null,
    temp4        varchar(50)      null,
    dept_id      int              null comment '组织机构ID',
    del_flag     int(1) default 0 not null comment '是否删除',
    enable_flag  int(1) default 0 not null comment '是否禁用',
    tenant_id    int    default 1 not null comment '所属租户',
    create_time  datetime         null on update CURRENT_TIMESTAMP comment '创建时间',
    create_user  int              null comment '创建人',
    update_time  datetime         null comment '更新时间',
    update_user  int              null comment '更新人',
    pgqx         varchar(2)       null comment '派工权限',
    management   varchar(2)       null comment '管理模式',
    subject_type varchar(1024)    null,
    constraint code
        unique (entcode)
)
    comment '档案-药企' row_format = DYNAMIC;

create table wm_da_drug_ent_drugtable
(
    id            int auto_increment
        primary key,
    drugname      varchar(50)      null comment '药品名称',
    drugname_ty   varchar(255)     null comment '通用药品你名称',
    drug_ent_id   char(11)         null comment '企业ID',
    is_yb         char             null comment '是否医保',
    dose_id       char(11)         null comment '剂型ID',
    guige_id      char(11)         null comment '规格ID',
    remark        varchar(255)     null comment '备注',
    dept_id       int              null comment '组织机构ID',
    del_flag      int(1) default 0 not null comment '是否删除',
    enable_flag   int(1) default 0 not null comment '是否禁用',
    tenant_id     int    default 1 not null comment '所属租户',
    create_time   datetime         null on update CURRENT_TIMESTAMP comment '创建时间',
    create_user   int              null comment '创建人',
    update_time   datetime         null comment '更新时间',
    update_user   int              null comment '更新人',
    drug_ent_name varchar(255)     null comment '所属药企名称',
    drug_ent_num  int              null comment '分配统计',
    ssxkcyy       varchar(64)      null comment '上市许可持有人',
    yyfz          varchar(128)     null comment '原验/仿制',
    dose_name     varchar(128)     null comment '剂型名称',
    guige_name    varchar(128)     null comment '规格名称',
    detail        text             null comment '详情信息(暂手动维护,用于报告)'
)
    comment '档案-药企药品' row_format = DYNAMIC;

create index 剂型
    on wm_da_drug_ent_drugtable (dose_id);

create index 药企外键
    on wm_da_drug_ent_drugtable (drug_ent_id);

create index 规格
    on wm_da_drug_ent_drugtable (guige_id);

create table wm_da_hospital
(
    id          int auto_increment
        primary key,
    yymc        varchar(100)           not null comment '医院名称',
    province    varchar(20)            null comment '省',
    city        varchar(20)            null comment '市',
    area        varchar(20)            null comment '区',
    address     varchar(255)           null comment '地址',
    longitude   varchar(255)           null comment '经度',
    latitude    varchar(255)           null comment '纬度',
    yygm        varchar(20)            null comment '医院规模',
    yyxz        varchar(255)           null comment '医院性质',
    lxzj        varchar(50)            null comment '联系总机',
    ggyx        varchar(50)            null comment '公共邮箱',
    yzxm        varchar(50)            null comment '院长姓名',
    yzlxfs      varchar(20)            null comment '院长联系方式',
    fyzxm       varchar(20)            null comment '副院长姓名',
    fyzlxfs     varchar(20)            null comment '副院长联系方式',
    ywcczxm     varchar(20)            null comment '医务处处长姓名',
    ywcczlxfs   varchar(20)            null comment '医务处处长联系方式',
    jwcczxm     varchar(20)            null comment '教务处处长姓名',
    jwcczlxfs   varchar(20)            null comment '教务处处长联系方式',
    yjkzrxm     varchar(20)            null comment '药剂科主任姓名',
    yjkzrlsfs   varchar(20)            null comment '药剂科主任联系方式',
    ybczs       varchar(10)            null comment '院病床总数（张）',
    zlghsy      varchar(255)           null comment '主流供货商业',
    pspzsfry    char                   null comment '普什品种是否入院',
    pspzpssy    varchar(50)            null comment '普什品种配送商业',
    dept_id     varchar(11)            null comment '组织机构ID',
    website     varchar(1024)          null comment '医院官网',
    del_flag    varchar(1) default '0' not null comment '是否删除',
    enable_flag varchar(1) default '0' not null comment '是否禁用',
    tenant_id   int        default 1   not null comment '所属租户',
    create_time datetime               null on update CURRENT_TIMESTAMP comment '创建时间',
    create_user int                    null comment '创建人',
    update_time datetime               null comment '更新时间',
    update_user int                    null comment '更新人',
    ybczs_bak   int(10)                null comment '备份床位数字段历史数据'
)
    comment '档案-医院' row_format = DYNAMIC;

create table wm_da_pharmacy
(
    id            int auto_increment
        primary key,
    pharmacy_name varchar(255)                  null comment '药店名称',
    province      longtext                      null comment '省',
    city          varchar(20)                   null comment '市',
    area          varchar(20)                   null comment '区',
    address       varchar(255)                  null comment '地址',
    longitude     varchar(255)                  null comment '经度',
    latitude      varchar(255)                  null comment '纬度',
    dept_id       varchar(11)                   null comment '组织机构ID',
    del_flag      varchar(1) default '0'        not null comment '是否删除',
    enable_flag   varchar(1) default '0'        not null comment '是否禁用',
    tenant_id     int        default 1          not null comment '所属租户',
    create_time   datetime                      null on update CURRENT_TIMESTAMP comment '创建时间',
    create_user   int                           null comment '创建人',
    update_time   datetime                      null comment '更新时间',
    update_user   int                           null comment '更新人',
    pharmacy_type char(10)   default 'ORDINARY' null comment '药店类型'
)
    comment '药店档案' row_format = DYNAMIC;

create table wm_da_project
(
    id              int(50) auto_increment comment '主键id'
        primary key,
    project_id      bigint                                  null comment '项目id',
    project_name    varchar(50) charset utf8mb4             null comment '项目名称',
    partya          varchar(30) charset utf8mb4             null comment '项目甲方',
    partyb          varchar(30) charset utf8mb4             null comment '项目乙方',
    sign_data       datetime                                null comment '签订日期',
    expiration_date datetime                                null comment '有效期截止',
    project_status  int(1)                                  null comment '项目状态 2进行中 1已完成',
    customer_care   varchar(30) charset utf8mb4             null comment '客户维护',
    remark          varchar(50) charset utf8mb4  default '' null comment '说明',
    contract_file   varchar(500) charset utf8mb4 default '' null comment '合同附件',
    contract_name   varchar(30) charset utf8mb4             null comment '合同名称',
    create_time     datetime                                null comment '创建时间',
    create_user     int                                     null comment '创建人',
    update_time     datetime                                null comment '更新时间',
    update_user     int                                     null comment '更新人',
    export1         varchar(30) charset utf8mb4             null comment '备用1',
    export2         varchar(30) charset utf8mb4             null comment '备用2',
    export3         varchar(30) charset utf8mb4             null comment '备用3'
)
    comment '档案-项目管理' charset = utf8
                            row_format = DYNAMIC;

create table wm_da_track
(
    id                   int auto_increment comment '主键id'
        primary key,
    trace_principal_name varchar(50) charset utf8mb4            null comment '跟踪主体名称',
    trace_object_name    varchar(50) charset utf8mb4            null comment '跟踪客体名称',
    status               int(1)                                 null comment '状态 0进行中 1已完成',
    create_time          datetime                               null comment '创建时间',
    create_user          int                                    null comment '创建人',
    update_time          datetime                               null comment '更新时间',
    update_user          int                                    null comment '更新人',
    project_id           bigint                                 null comment '项目id',
    export1              varchar(30) charset utf8mb4 default '' null comment '备用1',
    export2              varchar(30) charset utf8mb4 default '' null comment '备用2',
    export3              varchar(30) charset utf8mb4 default '' null comment '备用3'
)
    comment '档案-跟踪信息' charset = utf8
                            row_format = DYNAMIC;

create table wm_da_zb
(
    地区     varchar(255) null,
    医院编码 varchar(255) null,
    医院名称 varchar(255) null,
    医院地址 varchar(255) null,
    邮编     varchar(255) null,
    电话     varchar(255) null,
    院长     varchar(255) null,
    床位数   varchar(255) null,
    日门诊量 varchar(255) null,
    等级     varchar(255) null,
    专科     varchar(255) null,
    设备     varchar(255) null,
    网址     varchar(255) null,
    邮箱     varchar(255) null,
    f15      varchar(255) null,
    f16      varchar(255) null,
    id       int auto_increment
        primary key
)
    row_format = DYNAMIC;

create table wm_dept_budget
(
    id           int auto_increment
        primary key,
    dept_id      int          null comment '所属机构',
    belong_date  varchar(20)  null comment '预算月份',
    declare_dept varchar(255) null comment '申报机构',
    budget_type  varchar(2)   null comment '预算类型',
    budget       int(20)      null comment '预算值',
    create_time  datetime     null comment '创建时间'
)
    comment '预算管理' row_format = DYNAMIC;

create table wm_dept_gmv
(
    id                           int auto_increment comment '主键id'
        primary key,
    dept_id                      int                                not null comment '部门ID',
    year                         char(4)                            not null comment '年份',
    month                        char(4)                            not null comment '月份',
    gmv1                         bigint                             not null comment '按积分值统计的GMV（单位：积分）',
    gmv1_rate                    int                                not null comment 'gmv1收益率（万分之）',
    gmv2                         bigint                             not null comment '按结算额统计的GMV（单位：分）',
    gmv2_rate                    int                                not null comment 'gmv2收益率（万分之）',
    renlijia_service_charge_rate int                                null comment '人力家服务费（万分之）',
    income                       bigint                             not null comment '要易收益（单位：分）',
    update_time                  datetime default CURRENT_TIMESTAMP not null comment '修改时间'
)
    comment 'GMV数据统计主表' row_format = DYNAMIC;

create table wm_dept_gmv_record
(
    id                           int auto_increment comment 'id'
        primary key,
    gmv_id                       int                                not null comment 'GMV数据统计主表id',
    statistics_day               char(2)                            not null comment '统计日(1-31)',
    gmv1                         bigint                             not null comment '按积分值统计的GMV（单位：积分）',
    gmv1_rate                    int                                not null comment 'gmv1收益率（万分之）',
    gmv2                         bigint                             not null comment '按结算额统计的GMV（单位：分）',
    gmv2_rate                    int                                not null comment 'gmv2收益率（万分之）',
    renlijia_service_charge_rate int                                null comment '人力家服务费（万分之）',
    income                       bigint                             not null comment '要易收益（单位：分）',
    update_time                  datetime default CURRENT_TIMESTAMP not null comment '修改时间'
)
    comment 'GMV数据统计每日记录表' row_format = DYNAMIC;

create table wm_dept_regulations
(
    id          int auto_increment comment 'id'
        primary key,
    dept_id     int                                null comment '部门id',
    file_name   varchar(50)                        not null comment '文件名称',
    file_url    varchar(1024)                      not null comment '文件地址',
    sort        int      default 0                 not null comment '排序',
    del_flag    char     default '0'               not null comment '删除标记:0(未删除)，1(已删除)',
    enable_flag char     default '0'               not null comment '是否禁用:0(启用)，1(禁用)',
    create_time datetime default CURRENT_TIMESTAMP null comment '创建时间',
    update_time datetime                           null on update CURRENT_TIMESTAMP comment '修改时间',
    constraint wm_dept_regulations_dept_id_uindex
        unique (dept_id, file_name)
)
    comment '企业规章制度';

create table wm_dept_task_type_config
(
    id             int auto_increment
        primary key,
    dept_id        int      not null comment '组织机构ID',
    task_type_json text     null comment '任务类型配置',
    create_time    datetime null on update CURRENT_TIMESTAMP comment '创建时间',
    create_user    int      null comment '创建人',
    update_time    datetime null comment '更新时间',
    update_user    int      null comment '更新人'
)
    comment '部门任务类型配置';

create table wm_dept_task_type_template
(
    id           int auto_increment
        primary key,
    dept_id      int         not null comment '组织机构ID',
    task_type_id int         null comment '任务类型id',
    template     varchar(64) null comment '模板',
    detail       json        null comment '规则详情',
    create_time  datetime    null comment '创建时间',
    create_user  int         null comment '创建人',
    update_time  datetime    null comment '更新时间',
    update_user  int         null comment '更新人'
)
    comment '部门任务类型模板';

create table wm_ent_rate
(
    id               int auto_increment,
    dept_id          int         not null,
    end_type         varchar(32) not null,
    subject_location varchar(32) not null comment '结算渠道',
    type             int         not null comment '结算手续费包含；0不包含、1包含',
    rate             double      null comment '结算渠道的服务费率',
    constraint wm_ent_rate_id_uindex
        unique (id)
)
    comment '企业服务费率';

create table wm_ent_relation
(
    id             int auto_increment
        primary key,
    dept_id_parent int         not null comment '当前企业的父级企业',
    dept_id        int         null comment '当前企业',
    dept_name      varchar(32) null comment '冗余字段，用于matebase检索企业名称',
    constraint wm_end_relation_id_uindex
        unique (id)
)
    comment '企业关联关系（仅限单层，暂不支持递归父级）';

create table wm_ent_type
(
    id       int auto_increment,
    dept_id  int         not null comment '关联企业id，详见sys_dept.dept_id'
        primary key,
    end_type varchar(32) not null comment '企业所属类型；CSO、HCP',
    constraint wm_end_type_id_uindex
        unique (id)
)
    comment '企业类型';

create table wm_feedback
(
    id          int auto_increment
        primary key,
    yj_userid   char(11)         null comment '反馈意见用户ID',
    yg_content  longtext         null comment '反馈意见内容',
    dept_id     int              null comment '组织机构ID',
    del_flag    int(1) default 0 not null comment '是否删除',
    enable_flag int(1) default 0 not null comment '是否禁用',
    tenant_id   int    default 1 not null comment '所属租户',
    create_time datetime         null on update CURRENT_TIMESTAMP comment '创建时间',
    create_user int              null comment '创建人',
    update_time datetime         null comment '更新时间',
    update_user int              null comment '更新人'
)
    comment '意见反馈' row_format = DYNAMIC;

create index 反馈人ID
    on wm_feedback (yj_userid);

create table wm_import_user
(
    id                    int auto_increment
        primary key,
    score_id              varchar(50)      not null comment '积分包ID',
    import_name           varchar(20)      null comment '姓名',
    import_phone          varchar(20)      null comment '手机号',
    import_id_card_number varchar(18)      null comment '身份证号',
    user_sign             varchar(255)     null comment '签名',
    cert_status           int(2)           null comment '认证状态',
    cert_remark           varchar(255)     null comment '认证结果描述',
    create_time           datetime         null comment '创建时间',
    create_user           int              null comment '创建人',
    del_flag              char default '0' not null comment '是否删除',
    real_flag             char default '0' not null comment '是否禁用'
)
    comment '导入任务成员表' row_format = DYNAMIC;

create table wm_payoff
(
    id              int auto_increment comment '主键id'
        primary key,
    score_name      varchar(50) charset utf8mb4 null comment '积分包名称',
    id_number       varchar(20) charset utf8mb4 null comment '身份证号',
    settle_status   int(2)                      null comment '结算状态',
    cause_failure   varchar(50) charset utf8mb4 null comment '失败原因',
    cert_status     int(2)                      null comment '实名认证状态',
    submitted_value varchar(50) charset utf8mb4 null comment '已提交积分值',
    settle_amount   decimal(30, 2)              null comment '实际结算金额',
    discount        decimal(11, 4)              null comment '折扣',
    score_id        varchar(50) charset utf8mb4 null comment '关联积分包id',
    settle_people   varchar(20) charset utf8mb4 null comment '结算人',
    settle_time     datetime                    null comment '结算时间',
    statement_no    varchar(64) charset utf8mb4 null comment '结算单号',
    export1         varchar(20) charset utf8mb4 null comment '备用1',
    export2         varchar(20) charset utf8mb4 null comment '备用2',
    export3         varchar(20) charset utf8mb4 null comment '备用3'
)
    comment '结算表' charset = utf8
                     row_format = DYNAMIC;

create table wm_pkg_quiz_rel
(
    rel_id       int auto_increment comment 'Id'
        primary key,
    pkg_id       int                                    not null comment '积分包ID',
    quiz_id      int                                    null comment '试卷id',
    quiz_title   varchar(64)                            not null comment '标题',
    item_qty     int unsigned                           not null comment '试卷项数量',
    total_mark   int unsigned default 0                 not null comment '总分',
    passing_mark int unsigned default 0                 not null comment '及格分',
    quiz_items   json                                   null comment '试卷项',
    avail        tinyint(1)   default 1                 not null comment '可视化',
    create_time  datetime     default CURRENT_TIMESTAMP not null comment '创建时间'
)
    comment '积分包试卷表';

create table wm_project
(
    id             int auto_increment comment '主键id'
        primary key,
    dept_id        int          not null comment '部门id',
    project_number varchar(50)  not null comment '项目编号',
    project_name   varchar(50)  not null comment '项目名称',
    delegate       varchar(50)  not null comment '委托方',
    sign_time      datetime     not null comment '项目签约时间',
    remark         varchar(128) null comment '备注',
    create_time    datetime     null comment '创建时间',
    create_user    int          null comment '创建人',
    update_time    datetime     null comment '更新时间',
    update_user    int          null comment '更新人',
    constraint dept_id_project_number_unique
        unique (dept_id, project_number)
)
    comment '项目管理' row_format = DYNAMIC;

create table wm_project_evidence
(
    id          int auto_increment comment '主键id'
        primary key,
    project_id  int          not null comment '项目id',
    filename    varchar(64)  not null comment '文件名称',
    url         varchar(512) not null comment '静态证据url',
    type        varchar(10)  not null comment '文件类型',
    create_time datetime     null comment '创建时间',
    create_user int          null comment '创建人'
)
    comment '项目管理-静态证据子表' row_format = DYNAMIC;

create table wm_question
(
    qst_id      int auto_increment comment 'Id'
        primary key,
    serial_num  varchar(64)                        not null comment '序列号',
    label       varchar(64)                        not null comment '标题',
    options     json                               null comment '选项',
    answer      varchar(255)                       null comment '答案',
    ent_id      int unsigned                       not null comment '企业信息',
    create_by   varchar(64)                        not null comment '创建人',
    update_by   varchar(64)                        not null comment '修改人',
    create_time datetime default CURRENT_TIMESTAMP not null comment '创建时间',
    update_time datetime default CURRENT_TIMESTAMP not null on update CURRENT_TIMESTAMP comment '更新时间',
    constraint uk_sn
        unique (serial_num)
)
    comment '试题表';

create index idx_eid
    on wm_question (ent_id);

create table wm_quiz
(
    quiz_id      int auto_increment comment 'Id'
        primary key,
    serial_num   varchar(64)                        not null comment '序列号',
    quiz_title   varchar(64)                        not null comment '标题',
    introduction varchar(255)                       null comment '简介',
    source_type  varchar(8)                         not null comment '问卷来源类型',
    quiz_state   varchar(8)                         not null comment '问卷状态',
    ent_id       int unsigned                       not null comment '企业信息',
    quiz_expand  json                               null comment '试卷统计',
    create_by    varchar(64)                        not null comment '创建人',
    update_by    varchar(64)                        not null comment '修改人',
    create_time  datetime default CURRENT_TIMESTAMP not null comment '创建时间',
    update_time  datetime default CURRENT_TIMESTAMP not null on update CURRENT_TIMESTAMP comment '更新时间',
    constraint uk_sn
        unique (serial_num)
)
    comment '试卷表';

create index idx_eid
    on wm_quiz (ent_id);

create index idx_st
    on wm_quiz (source_type);

create index idx_state
    on wm_quiz (quiz_state);

create table wm_quiz_item
(
    item_id      int auto_increment comment 'Id'
        primary key,
    quiz_sn      varchar(64)                        not null comment '试卷序号',
    label        varchar(1024)                      not null comment '标题',
    quiz_options json                               null comment '选项',
    answer       varchar(255)                       null comment '答案',
    widget       bigint                             not null comment '排序权重',
    mark         int      default 0                 not null comment '分数',
    create_by    varchar(64)                        not null comment '创建人',
    update_by    varchar(64)                        not null comment '修改人',
    create_time  datetime default CURRENT_TIMESTAMP not null comment '创建时间',
    update_time  datetime default CURRENT_TIMESTAMP not null on update CURRENT_TIMESTAMP comment '更新时间'
)
    comment '试卷项表';

create index idx_quiz_sn
    on wm_quiz_item (quiz_sn);

create table wm_relation
(
    up_id       int                                not null,
    down_id     int                                not null,
    create_time datetime default CURRENT_TIMESTAMP null comment '创建时间',
    constraint wm_relation_pk
        unique (up_id, down_id)
)
    comment '企业关系表' row_format = DYNAMIC;

create table wm_report
(
    id                int auto_increment comment '主键id'
        primary key,
    report_no         varchar(64)                 not null comment '报告单号',
    drug_ent_id       int                         null comment '结算企业ID',
    score_id          int                         not null comment '积分包ID',
    apply_drug_ent_id int                         null comment '申请结算企业ID',
    package_score     varchar(11)                 null comment '积分包值',
    task_number       varchar(11)                 null comment '任务数量',
    total_score       varchar(11)                 null comment '合计分值',
    report_status     varchar(2)                  null comment '报告状态',
    create_people     varchar(50)                 null comment '创建人',
    create_time       datetime                    null comment '创建时间',
    approval_people   varchar(20)                 null comment '审核人',
    approval_time     datetime                    null comment '审核时间',
    update_people     varchar(20)                 null comment '更新人',
    update_time       datetime                    null comment '更新时间',
    del_flag          varchar(2) default '0'      not null comment '是否删除',
    export1           varchar(20) charset utf8mb4 null comment '备用1',
    export2           varchar(20) charset utf8mb4 null comment '备用2',
    export3           varchar(20) charset utf8mb4 null comment '备用3'
)
    comment '报告审核表' charset = utf8
                         row_format = DYNAMIC;

create index wm_report_score_id_index
    on wm_report (score_id);

create table wm_report_export_record
(
    record_id     int auto_increment comment '主键id'
        primary key,
    report_no     varchar(64)  not null comment '报告单号',
    report_title  varchar(128) not null comment '报告名称',
    dept_id       int          null comment '结算企业ID',
    export_status varchar(2)   null comment '报告状态',
    oss_url       varchar(255) null comment '报告地址',
    created_by    varchar(50)  null comment '创建人',
    created_time  datetime     null comment '创建时间',
    finish_time   datetime     null comment '完成时间'
)
    comment '报告审核表' charset = utf8;

create table wm_score_package
(
    id                         int auto_increment
        primary key,
    task_rule_id               varchar(11)                 null comment '规则ID',
    drug_ent_id                varchar(11)                 null,
    score_id                   varchar(50)                 null,
    score_name                 varchar(255)                null comment '积分包名称',
    score                      varchar(11)                 null,
    agent_type_id              varchar(1)                  null,
    level1_id                  varchar(11)                 null comment '一级代理商',
    level2_id                  varchar(11)                 null comment '二级代理商',
    zb_id                      varchar(11)                 null comment '众包ID',
    xxdb_id                    varchar(11)                 null comment '销售代表ID',
    typeid                     varchar(11)                 null comment '分配对象类型',
    package_status             varchar(11)                 null comment '积分包状态',
    package_finish_status      varchar(2)                  null comment '积分包完成状态',
    package_audit_status       varchar(2)                  null comment '积分包审核状态',
    send_package_dept_id       varchar(11)                 null comment '发包方ID',
    dept_id                    varchar(11)                 null comment '组织机构ID',
    del_flag                   char           default '0'  not null comment '是否删除',
    enable_flag                char           default '0'  not null comment '是否禁用',
    tenant_id                  int            default 1    not null comment '所属租户',
    create_time                datetime                    null comment '创建时间',
    create_user                int                         null comment '创建人',
    update_time                datetime                    null comment '更新时间',
    update_user                int                         null comment '更新人',
    ytj                        int                         null,
    ysh                        int                         null,
    dsh                        int                         null,
    ytjtt                      int                         null,
    ywctt                      int                         null,
    yshtt                      int                         null,
    receive_date               datetime                    null comment '领取时间',
    is_conduct                 varchar(1)                  null comment '是否进行中',
    drugs_ids                  varchar(255)                null,
    statement_no               varchar(64)                 null comment '结算单号',
    settle_status              int(2)                      null comment '结算状态',
    remark                     varchar(255)                null comment '结算结果描述',
    invoice_category           varchar(50)                 null comment '发票类目',
    settle_amount              decimal(30, 2)              null comment '实际结算金额',
    discount                   decimal(11, 4)              null comment '折扣',
    package_finish_time        datetime                    null comment '完成时间',
    relation_score_id          varchar(11)                 null comment '关联积分包id',
    package_type1              varchar(11)                 null comment '积分包任务类型1',
    package_type2              varchar(11)                 null comment '积分包任务类型2',
    user_num                   int                         null comment '需求人数',
    task_num                   int                         null comment '任务个数',
    package_user_scope         varchar(11)                 null comment '接单对象范围',
    kfpjf                      int(30)                     null comment '可分配积分',
    belong_date                varchar(20)                 null comment '所属月份',
    allocation_date            datetime                    null comment '分配日期',
    pay_rate                   decimal(20, 2)              null comment '已支付百分比',
    finish_rate                decimal(20, 2)              null comment '已完成百分比',
    pay_score                  varchar(11)                 null comment '已支付积分值',
    end_label_date             varchar(64)                 null comment '查询结束日期',
    score_package_name         varchar(255)                null comment '积分包名称',
    related_service            varchar(11)                 null comment '关联服务企业',
    package_is_conduct         varchar(1)                  null comment '积分包是否进行中',
    description                varchar(255)                null comment '描述',
    user_score                 varchar(11)                 null comment '个人预计包值',
    enable_type                char           default '0'  null comment '终止方式',
    is_receive                 varchar(1)                  null comment '是否允许接单',
    rule_id                    varchar(50)                 null comment '规则id',
    accept_sug                 varchar(20)    default ''   null comment '接包对象',
    task_add_flag              varchar(1)     default '1'  null comment '是否可以新增任务1-可以  0-不可以',
    settle_flag                char           default '0'  null comment '结算状态',
    score_package_status       varchar(11)                 null comment '积分包状态',
    old_package                char(2)        default '0'  null comment '是否为旧数据',
    settlement_date            datetime                    null comment '结算时间',
    source_type                char           default '0'  null comment '数据来源类型（0：手动上传，1：系统对接）',
    project_num                varchar(50)                 null comment '项目编号',
    drug_producer              varchar(512)                null comment '关联药品生产厂商名称',
    p2p_amount                 decimal(11, 2)              null,
    p2p_time                   datetime                    null comment '公对公提交时间',
    oms_order_sn               varchar(64)                 null comment '订单号',
    sub_type                   varchar(2)                  null comment '结算渠道',
    sub_location               varchar(64)                 null comment '税源地',
    p2p_service_amount         decimal(11, 2) default 0.00 null comment '公对公服务费',
    pkg_sn                     varchar(32)                 null comment '积分包编号',
    mah_settle_dept_id         int                         null comment 'MAH结算-药企deptId',
    mah_settle_step            char(8)                     null comment 'MAH结算-步进状态(BUSINESS-业务, FINANCE-财务)',
    mah_settle_time            datetime                    null comment 'mah结算时间',
    ent_task_limit             decimal(5, 2)  default 0.00 null comment '企业任务上限(单位%)',
    drugtable                  varchar(255)                null comment '推广药品id',
    invoice_number             varchar(64)                 null comment '发票号码',
    invoice_file               json                        null comment '发票文件',
    audit_management_fee_rates decimal(5, 2)  default 0.00 not null comment '审核管理费比例',
    end_time                   date                        null comment '截止日期'
)
    comment '积分包' row_format = DYNAMIC;

create index wm_score_package_accept_sug_index
    on wm_score_package (accept_sug);

create index wm_score_package_mah_settle_dept_id_index
    on wm_score_package (mah_settle_dept_id);

create index wm_score_package_relation_score_id_index
    on wm_score_package (relation_score_id);

create index wm_score_package_send_dept_id_index
    on wm_score_package (send_package_dept_id);

create index 一级代理商1
    on wm_score_package (level1_id);

create index 二级代理商2
    on wm_score_package (level2_id);

create index 代理商
    on wm_score_package (agent_type_id);

create index 代理商类型
    on wm_score_package (drug_ent_id);

create index 众包
    on wm_score_package (zb_id);

create table wm_score_package_0226
(
    id                    int auto_increment
        primary key,
    task_rule_id          varchar(11)             null comment '规则ID',
    drug_ent_id           varchar(11)             null,
    score_id              varchar(50)             null,
    score_name            varchar(255)            null comment '积分包名称',
    score                 varchar(11)             null,
    agent_type_id         varchar(1)              null,
    level1_id             varchar(11)             null comment '一级代理商',
    level2_id             varchar(11)             null comment '二级代理商',
    zb_id                 varchar(11)             null comment '众包ID',
    xxdb_id               varchar(11)             null comment '销售代表ID',
    typeid                varchar(11)             null comment '分配对象类型',
    package_status        varchar(11)             null comment '积分包状态',
    package_finish_status varchar(2)              null comment '积分包完成状态',
    package_audit_status  varchar(2)              null comment '积分包审核状态',
    send_package_dept_id  varchar(11)             null comment '发包方ID',
    dept_id               varchar(11)             null comment '组织机构ID',
    del_flag              char        default '0' not null comment '是否删除',
    enable_flag           char        default '0' not null comment '是否禁用',
    tenant_id             int         default 1   not null comment '所属租户',
    create_time           datetime                null comment '创建时间',
    create_user           int                     null comment '创建人',
    update_time           datetime                null comment '更新时间',
    update_user           int                     null comment '更新人',
    ytj                   int                     null,
    ysh                   int                     null,
    dsh                   int                     null,
    ytjtt                 int                     null,
    ywctt                 int                     null,
    yshtt                 int                     null,
    receive_date          datetime                null comment '领取时间',
    is_conduct            varchar(1)              null comment '是否进行中',
    drugs_ids             varchar(255)            null,
    statement_no          varchar(64)             null comment '结算单号',
    settle_status         int(2)                  null comment '结算状态',
    remark                varchar(255)            null comment '结算结果描述',
    invoice_category      varchar(50)             null comment '发票类目',
    settle_amount         decimal(30, 2)          null comment '实际结算金额',
    discount              decimal(11, 4)          null comment '折扣',
    package_finish_time   datetime                null comment '完成时间',
    relation_score_id     varchar(11)             null comment '关联积分包id',
    package_type1         varchar(11)             null comment '积分包任务类型1',
    package_type2         varchar(11)             null comment '积分包任务类型2',
    user_num              int                     null comment '需求人数',
    task_num              int                     null comment '任务个数',
    package_user_scope    varchar(11)             null comment '接单对象范围',
    kfpjf                 int(30)                 null comment '可分配积分',
    belong_date           varchar(20)             null comment '所属月份',
    allocation_date       datetime                null comment '分配日期',
    pay_rate              decimal(20, 2)          null comment '已支付百分比',
    finish_rate           decimal(20, 2)          null comment '已完成百分比',
    pay_score             varchar(11)             null comment '已支付积分值',
    end_label_date        varchar(64)             null comment '查询结束日期',
    score_package_name    varchar(255)            null comment '积分包名称',
    related_service       varchar(11)             null comment '关联服务企业',
    package_is_conduct    varchar(1)              null comment '积分包是否进行中',
    description           varchar(255)            null comment '描述',
    user_score            varchar(11)             null comment '个人预计包值',
    enable_type           char        default '0' null comment '终止方式',
    is_receive            varchar(1)              null comment '是否允许接单',
    rule_id               varchar(50)             null comment '规则id',
    accept_sug            varchar(20) default ''  null comment '接包对象',
    task_add_flag         varchar(1)  default '1' null comment '是否可以新增任务1-可以  0-不可以',
    settle_flag           char        default '0' null comment '结算状态',
    score_package_status  varchar(11)             null comment '积分包状态',
    old_package           char(2)     default '0' null comment '是否为旧数据'
)
    comment '积分包' row_format = DYNAMIC;

create index 一级代理商1
    on wm_score_package_0226 (level1_id);

create index 二级代理商2
    on wm_score_package_0226 (level2_id);

create index 代理商
    on wm_score_package_0226 (agent_type_id);

create index 代理商类型
    on wm_score_package_0226 (drug_ent_id);

create index 众包
    on wm_score_package_0226 (zb_id);

create table wm_score_package_0517
(
    id                    int auto_increment
        primary key,
    task_rule_id          varchar(11)             null comment '规则ID',
    drug_ent_id           varchar(11)             null,
    score_id              varchar(50)             null,
    score_name            varchar(255)            null comment '积分包名称',
    score                 varchar(11)             null,
    agent_type_id         varchar(1)              null,
    level1_id             varchar(11)             null comment '一级代理商',
    level2_id             varchar(11)             null comment '二级代理商',
    zb_id                 varchar(11)             null comment '众包ID',
    xxdb_id               varchar(11)             null comment '销售代表ID',
    typeid                varchar(11)             null comment '分配对象类型',
    package_status        varchar(11)             null comment '积分包状态',
    package_finish_status varchar(2)              null comment '积分包完成状态',
    package_audit_status  varchar(2)              null comment '积分包审核状态',
    send_package_dept_id  varchar(11)             null comment '发包方ID',
    dept_id               varchar(11)             null comment '组织机构ID',
    del_flag              char        default '0' not null comment '是否删除',
    enable_flag           char        default '0' not null comment '是否禁用',
    tenant_id             int         default 1   not null comment '所属租户',
    create_time           datetime                null comment '创建时间',
    create_user           int                     null comment '创建人',
    update_time           datetime                null comment '更新时间',
    update_user           int                     null comment '更新人',
    ytj                   int                     null,
    ysh                   int                     null,
    dsh                   int                     null,
    ytjtt                 int                     null,
    ywctt                 int                     null,
    yshtt                 int                     null,
    receive_date          datetime                null comment '领取时间',
    is_conduct            varchar(1)              null comment '是否进行中',
    drugs_ids             varchar(255)            null,
    statement_no          varchar(64)             null comment '结算单号',
    settle_status         int(2)                  null comment '结算状态',
    remark                varchar(255)            null comment '结算结果描述',
    invoice_category      varchar(50)             null comment '发票类目',
    settle_amount         decimal(30, 2)          null comment '实际结算金额',
    discount              decimal(11, 4)          null comment '折扣',
    package_finish_time   datetime                null comment '完成时间',
    relation_score_id     varchar(11)             null comment '关联积分包id',
    package_type1         varchar(11)             null comment '积分包任务类型1',
    package_type2         varchar(11)             null comment '积分包任务类型2',
    user_num              int                     null comment '需求人数',
    task_num              int                     null comment '任务个数',
    package_user_scope    varchar(11)             null comment '接单对象范围',
    kfpjf                 int(30)                 null comment '可分配积分',
    belong_date           varchar(20)             null comment '所属月份',
    allocation_date       datetime                null comment '分配日期',
    pay_rate              decimal(20, 2)          null comment '已支付百分比',
    finish_rate           decimal(20, 2)          null comment '已完成百分比',
    pay_score             varchar(11)             null comment '已支付积分值',
    end_label_date        varchar(64)             null comment '查询结束日期',
    score_package_name    varchar(255)            null comment '积分包名称',
    related_service       varchar(11)             null comment '关联服务企业',
    package_is_conduct    varchar(1)              null comment '积分包是否进行中',
    description           varchar(255)            null comment '描述',
    user_score            varchar(11)             null comment '个人预计包值',
    enable_type           char        default '0' null comment '终止方式',
    is_receive            varchar(1)              null comment '是否允许接单',
    rule_id               varchar(50)             null comment '规则id',
    accept_sug            varchar(20) default ''  null comment '接包对象',
    task_add_flag         varchar(1)  default '1' null comment '是否可以新增任务1-可以  0-不可以',
    settle_flag           char        default '0' null comment '结算状态',
    score_package_status  varchar(11)             null comment '积分包状态',
    old_package           char(2)     default '0' null comment '是否为旧数据',
    settlement_date       datetime                null comment '结算时间'
)
    comment '积分包' row_format = DYNAMIC;

create index 一级代理商1
    on wm_score_package_0517 (level1_id);

create index 二级代理商2
    on wm_score_package_0517 (level2_id);

create index 代理商
    on wm_score_package_0517 (agent_type_id);

create index 代理商类型
    on wm_score_package_0517 (drug_ent_id);

create index 众包
    on wm_score_package_0517 (zb_id);

create table wm_score_package_settle_note
(
    id                 int auto_increment
        primary key,
    package_status_id  varchar(20)      null,
    package_id         varchar(20)      null,
    settle_amount      decimal(10, 2)   null,
    user_id            varchar(20)      null,
    invoice_type       int(20)          null,
    settle_no          varchar(128)     null,
    discount           decimal(10, 2)   null,
    settle_note_status int(2) default 0 null,
    remark             text             null,
    notify_time        datetime         null,
    task_id            varchar(20)      null comment '任务ID',
    category_name      varchar(128)     null comment '开票类型名称',
    create_time        datetime         null comment '创建时间',
    sub_time           datetime         null comment '提交时间',
    update_time        datetime         null comment '更新时间',
    stream_id          varchar(50)      null comment '税邦云流水号',
    id_card_number     varchar(20)      null comment '身份证号',
    sub_to_gig_time    datetime         null comment '提交到零工平台时间',
    sub_type           varchar(2)       null comment '结算类型',
    subject_location   varchar(64)      null comment '税源地',
    third_task_id      varchar(20)      null comment '第三方任务id',
    finish_task_flag   int    default 0 null comment '是否完成完单操作',
    actual_amount      decimal(18, 2)   null,
    settle_dept_id     int              null comment '实际结算企业id',
    settle_dept_sub_id int              null comment '实际结算企业subId',
    review_status      char(20)         null comment '财务复核状态',
    review_time        datetime         null comment '复核时间',
    review_user        int              null comment '复核人'
)
    charset = utf8
    row_format = DYNAMIC;

create table wm_score_package_settle_note_0510
(
    id                 int auto_increment
        primary key,
    package_status_id  varchar(20)                         null,
    package_id         varchar(20)                         null,
    settle_amount      decimal(10, 2)                      null,
    user_id            varchar(20)                         null,
    invoice_type       int(20)                             null,
    settle_no          varchar(128)                        null,
    discount           decimal(10, 2)                      null,
    settle_note_status int(2)    default 0                 null,
    remark             varchar(256)                        null,
    notify_time        timestamp default CURRENT_TIMESTAMP null on update CURRENT_TIMESTAMP
)
    charset = utf8
    row_format = DYNAMIC;

create table wm_score_package_settle_note_0517
(
    id                 int auto_increment
        primary key,
    package_status_id  varchar(20)                         null,
    package_id         varchar(20)                         null,
    settle_amount      decimal(10, 2)                      null,
    user_id            varchar(20)                         null,
    invoice_type       int(20)                             null,
    settle_no          varchar(128)                        null,
    discount           decimal(10, 2)                      null,
    settle_note_status int(2)    default 0                 null,
    remark             varchar(256)                        null,
    notify_time        timestamp default CURRENT_TIMESTAMP null on update CURRENT_TIMESTAMP
)
    charset = utf8
    row_format = DYNAMIC;

create table wm_score_package_settle_note_111
(
    id                 int auto_increment
        primary key,
    package_status_id  varchar(20)      null,
    package_id         varchar(20)      null,
    settle_amount      decimal(10, 2)   null,
    user_id            varchar(20)      null,
    invoice_type       int(20)          null,
    settle_no          varchar(128)     null,
    discount           decimal(10, 2)   null,
    settle_note_status int(2) default 0 null,
    remark             varchar(256)     null,
    notify_time        timestamp        null,
    task_id            varchar(20)      null comment '任务ID',
    category_name      varchar(128)     null comment '开票类型名称',
    create_time        datetime         null comment '创建时间',
    sub_time           datetime         null comment '提交时间',
    update_time        datetime         null comment '更新时间',
    stream_id          varchar(50)      null comment '税邦云流水号',
    id_card_number     varchar(20)      null comment '身份证号',
    sub_type           varchar(2)       null comment '结算类型'
)
    charset = utf8
    row_format = DYNAMIC;

create table wm_score_package_settle_note_20220113
(
    id                 int            null,
    package_status_id  varchar(20)    null,
    package_id         varchar(20)    null,
    settle_amount      decimal(10, 2) null,
    user_id            varchar(20)    null,
    invoice_type       int            null,
    settle_no          varchar(128)   null,
    discount           decimal(10, 2) null,
    settle_note_status int            null,
    remark             varchar(256)   null,
    notify_time        datetime       null,
    task_id            varchar(20)    null,
    category_name      varchar(128)   null,
    create_time        datetime       null,
    sub_time           datetime       null,
    update_time        datetime       null,
    stream_id          varchar(50)    null,
    id_card_number     varchar(20)    null,
    sub_type           varchar(2)     null,
    sub_to_gig_time    datetime       null
)
    comment '税邦云回调数据异常，数据回滚前备份';

create table wm_score_package_status
(
    id            int auto_increment
        primary key,
    user_id       varchar(11)            null comment '用户id',
    package_id    varchar(11)            null comment '积分包id',
    status        varchar(11)            null comment '审核状态：1.审核中，2.审核通过，3.审核不通过',
    dept_id       varchar(11)            null comment '组织机构ID',
    del_flag      char       default '0' not null comment '是否删除',
    enable_flag   char       default '0' not null comment '是否禁用',
    tenant_id     int        default 1   not null comment '所属租户',
    create_time   datetime               null comment '创建时间',
    create_user   int                    null comment '创建人',
    update_time   datetime               null comment '更新时间',
    update_user   int                    null comment '更新人',
    user_score    varchar(11)            null comment '个人预计包值',
    enable_type   char       default '0' null comment '终止方式',
    task_num      int                    null comment '个人包任务个数',
    task_add_flag varchar(1) default '1' null comment '是否可以新增任务1-可以  0-不可以',
    quiz_res      json                   null comment '测评结果'
)
    comment '积分包状态' row_format = DYNAMIC;

create table wm_score_package_status_0226
(
    id            int auto_increment
        primary key,
    user_id       varchar(11)            null,
    package_id    varchar(11)            null,
    status        varchar(11)            null,
    dept_id       varchar(11)            null comment '组织机构ID',
    del_flag      char       default '0' not null comment '是否删除',
    enable_flag   char       default '0' not null comment '是否禁用',
    tenant_id     int        default 1   not null comment '所属租户',
    create_time   datetime               null comment '创建时间',
    create_user   int                    null comment '创建人',
    update_time   datetime               null comment '更新时间',
    update_user   int                    null comment '更新人',
    user_score    varchar(11)            null comment '个人预计包值',
    enable_type   char       default '0' null comment '终止方式',
    task_num      int                    null comment '个人包任务个数',
    task_add_flag varchar(1) default '1' null comment '是否可以新增任务1-可以  0-不可以'
)
    comment '积分包状态' row_format = DYNAMIC;

create table wm_score_package_task_ref
(
    id              int              not null
        primary key,
    task_id         varchar(11)      null comment '任务ID',
    task_package_id varchar(11)      null comment '任务所属积分包ID',
    user_id         varchar(11)      null comment '医药代表ID',
    status          varchar(11)      null comment '任务状态',
    dept_id         varchar(11)      null comment '组织机构ID',
    del_flag        char default '0' not null comment '是否删除',
    enable_flag     char default '0' not null comment '是否禁用',
    tenant_id       int  default 1   not null comment '所属租户',
    create_time     datetime         null on update CURRENT_TIMESTAMP comment '创建时间',
    create_user     int              null comment '创建人',
    update_time     datetime         null comment '更新时间',
    update_user     int              null comment '更新人'
)
    comment '任务-积分包关联' row_format = DYNAMIC;

create index package1
    on wm_score_package_task_ref (task_package_id);

create index rw1
    on wm_score_package_task_ref (task_id);

create index user11
    on wm_score_package_task_ref (user_id);

create table wm_score_task_type
(
    id           bigint auto_increment comment '主键id'
        primary key,
    score_id     varchar(20) charset utf8mb4  null comment '关联积分包id',
    task_type_id varchar(11) charset utf8mb4  null comment '有效任务类型id',
    type         varchar(255) charset utf8mb4 null comment '积分包类型，1:定额，2定量'
)
    comment '积分包任务类型表' charset = utf8
                               row_format = DYNAMIC;

create table wm_settle_account_receive
(
    id             int auto_increment
        primary key,
    account_name   varchar(255)                       null,
    account_no     varchar(255)                       null,
    op_type        varchar(255)                       null,
    amount         varchar(255)                       null,
    bank_serial_no varchar(255)                       null,
    explore1       varchar(255)                       null,
    explore2       varchar(255)                       null,
    explore3       varchar(255)                       null,
    update_time    datetime default CURRENT_TIMESTAMP not null on update CURRENT_TIMESTAMP comment '更新时间'
)
    charset = utf8
    row_format = DYNAMIC;

create table wm_task
(
    id                             int auto_increment
        primary key,
    task_number                    varchar(32)             null comment '任务编号',
    task_rule_id                   varchar(11)             null comment '积分规则',
    score                          int(5)                  null comment '积分值',
    score_package_drug_id          varchar(11)             null comment '任务提交到的积分包ID',
    score_package_level1_id        varchar(11)             null comment '任务提交到一级经销商的集分宝id',
    score_package_id               varchar(11)             null comment '积分包',
    task_type_id                   varchar(11)             null comment '任务类型ID',
    lookinto_date                  datetime                null comment '调研时间',
    province                       varchar(20)             null comment '省',
    city                           varchar(20)             null comment '市',
    area                           varchar(20)             null comment '区',
    address                        varchar(255)            null comment '地址',
    lookinto_type_id               varchar(11)             null comment '调研类型ID',
    task_content_id                varchar(11)             null comment '任务内容ID',
    task_status                    char(2)                 null comment '任务状态',
    task_user_id                   varchar(11)             null comment '任务用户ID',
    task_user_type                 varchar(11)             null comment '用户类型ID',
    drug_ent_id                    varchar(11)             null comment '服务药企',
    dept_id                        varchar(11)             null comment '组织机构ID',
    del_flag                       char        default '0' not null comment '是否删除',
    enable_flag                    char        default '0' not null comment '是否禁用',
    tenant_id                      int         default 1   not null comment '所属租户',
    create_time                    datetime                null comment '创建时间',
    create_user                    int                     null comment '创建人',
    update_time                    datetime                null comment '更新时间',
    update_user                    int                     null comment '更新人',
    submit_status                  varchar(2)              null comment '提交状态',
    share_img_url                  varchar(255)            null comment '分享图片地址',
    plat_audit_status              char(2)     default '0' null comment '平台审核状态',
    ext_ids                        varchar(255)            null comment '备用字段',
    task_info_img                  varchar(255)            null comment '任务详情图片',
    compare_result                 varchar(2)              null comment '对比结果',
    approval_opinion               varchar(2)              null comment '审批意见',
    approval_info                  varchar(500)            null comment '审批说明',
    real_flag                      char(2)     default '0' null comment '是否真实',
    report_one_id                  int                     null comment '任务提交到一级cso的报告ID',
    report_one_approval_status     varchar(32) default '0' null comment '任务提交到一级cso的报告审核状态',
    report_one_approval_opinion    varchar(2)              null comment '任务提交到一级cso的报告审批意见',
    report_one_approval_info       varchar(1024)           null comment '任务提交到一级cso的报告审批说明',
    report_second_id               int                     null comment '任务提交到二级cso的报告ID',
    report_second_approval_status  varchar(32) default '0' null comment '任务提交到二级cso的报告审核状态',
    report_second_approval_opinion varchar(2)              null comment '任务提交到二级cso的报告审批意见',
    report_second_approval_info    varchar(1024)           null comment '任务提交到二级cso的报告审批说明',
    report_drug_id                 int                     null comment '任务提交到药企的报告ID',
    report_drug_approval_status    varchar(32) default '0' null comment '任务提交到药企的报告审核状态',
    report_drug_approval_opinion   varchar(2)              null comment '任务提交到药企的报告审批意见',
    report_drug_approval_info      varchar(1024)           null comment '任务提交到药企的报告审批说明',
    task_status_info               varchar(500)            null comment 'cso审核审核意见',
    task_from                      varchar(2)  default '1' null comment '来源',
    task_settle_status             int                     null comment '任务结算状态',
    review_task_count              int         default 0   not null comment '复审次数记录',
    dept_review_task_count         int         default 0   not null comment '企业复审次数记录',
    approval_user_id               int                     null comment '审核人userId',
    approval_time                  datetime                null comment '审核时间',
    dept_approval_user_id          int                     null comment '企业审核人userId',
    dept_approval_time             datetime                null comment '企业审核时间',
    remote_ip                      varchar(255)            null comment '远端ip',
    ip2region                      varchar(255)            null comment '地址'
)
    comment '任务表' row_format = DYNAMIC;

create index sp_ts_rf_index
    on wm_task (score_package_id, real_flag, task_status);

create index wm_task_report_drug_id_index
    on wm_task (report_drug_id);

create index wm_task_report_one_id_index
    on wm_task (report_one_id);

create index wm_task_report_second_id_index
    on wm_task (report_second_id);

create index wm_task_score_package_id_index
    on wm_task (score_package_id);

create index wm_task_user_id_index
    on wm_task (task_user_id);

create index 任务内容
    on wm_task (task_content_id);

create index 任务类型task
    on wm_task (task_type_id);

create index 调研类型
    on wm_task (lookinto_type_id);

create table wm_task_0514
(
    id                             int auto_increment
        primary key,
    task_rule_id                   varchar(11)             null comment '积分规则',
    score                          int(5)                  null comment '积分值',
    score_package_drug_id          varchar(11)             null comment '任务提交到的积分包ID',
    score_package_level1_id        varchar(11)             null comment '任务提交到一级经销商的集分宝id',
    score_package_id               varchar(11)             null comment '积分包',
    task_type_id                   varchar(11)             null comment '任务类型ID',
    lookinto_date                  datetime                null comment '调研时间',
    province                       varchar(20)             null comment '省',
    city                           varchar(20)             null comment '市',
    area                           varchar(20)             null comment '区',
    address                        varchar(255)            null comment '地址',
    lookinto_type_id               varchar(11)             null comment '调研类型ID',
    task_content_id                varchar(11)             null comment '任务内容ID',
    task_status                    char(2)                 null comment '任务状态',
    task_user_id                   varchar(11)             null comment '任务用户ID',
    task_user_type                 varchar(11)             null comment '用户类型ID',
    drug_ent_id                    varchar(11)             null comment '服务药企',
    dept_id                        varchar(11)             null comment '组织机构ID',
    del_flag                       char        default '0' not null comment '是否删除',
    enable_flag                    char        default '0' not null comment '是否禁用',
    tenant_id                      int         default 1   not null comment '所属租户',
    create_time                    datetime                null comment '创建时间',
    create_user                    int                     null comment '创建人',
    update_time                    datetime                null comment '更新时间',
    update_user                    int                     null comment '更新人',
    submit_status                  varchar(2)              null comment '提交状态',
    share_img_url                  varchar(255)            null comment '分享图片地址',
    plat_audit_status              char(2)     default '0' null comment '平台审核状态',
    ext_ids                        varchar(255)            null comment '备用字段',
    task_info_img                  varchar(255)            null comment '任务详情图片',
    compare_result                 varchar(2)              null comment '对比结果',
    approval_opinion               varchar(2)              null comment '审批意见',
    approval_info                  varchar(500)            null comment '审批说明',
    real_flag                      char(2)     default '0' null comment '是否真实',
    report_one_id                  int                     null comment '任务提交到一级cso的报告ID',
    report_one_approval_status     varchar(32) default '0' null comment '任务提交到一级cso的报告审核状态',
    report_one_approval_opinion    varchar(2)              null comment '任务提交到一级cso的报告审批意见',
    report_one_approval_info       varchar(50)             null comment '任务提交到一级cso的报告审批说明',
    report_second_id               int                     null comment '任务提交到二级cso的报告ID',
    report_second_approval_status  varchar(32) default '0' null comment '任务提交到二级cso的报告审核状态',
    report_second_approval_opinion varchar(2)              null comment '任务提交到二级cso的报告审批意见',
    report_second_approval_info    varchar(50)             null comment '任务提交到二级cso的报告审批说明',
    report_drug_id                 int                     null comment '任务提交到药企的报告ID',
    report_drug_approval_status    varchar(32) default '0' null comment '任务提交到药企的报告审核状态',
    report_drug_approval_opinion   varchar(2)              null comment '任务提交到药企的报告审批意见',
    report_drug_approval_info      varchar(50)             null comment '任务提交到药企的报告审批说明',
    task_status_info               varchar(500)            null comment 'cso审核审核意见',
    task_from                      varchar(2)  default '1' null comment '来源'
)
    comment '任务表' row_format = DYNAMIC;

create index 任务内容
    on wm_task_0514 (task_content_id);

create index 任务类型task
    on wm_task_0514 (task_type_id);

create index 调研类型
    on wm_task_0514 (lookinto_type_id);

create table wm_task_0518
(
    id                             int auto_increment
        primary key,
    task_rule_id                   varchar(11)             null comment '积分规则',
    score                          int(5)                  null comment '积分值',
    score_package_drug_id          varchar(11)             null comment '任务提交到的积分包ID',
    score_package_level1_id        varchar(11)             null comment '任务提交到一级经销商的集分宝id',
    score_package_id               varchar(11)             null comment '积分包',
    task_type_id                   varchar(11)             null comment '任务类型ID',
    lookinto_date                  datetime                null comment '调研时间',
    province                       varchar(20)             null comment '省',
    city                           varchar(20)             null comment '市',
    area                           varchar(20)             null comment '区',
    address                        varchar(255)            null comment '地址',
    lookinto_type_id               varchar(11)             null comment '调研类型ID',
    task_content_id                varchar(11)             null comment '任务内容ID',
    task_status                    char(2)                 null comment '任务状态',
    task_user_id                   varchar(11)             null comment '任务用户ID',
    task_user_type                 varchar(11)             null comment '用户类型ID',
    drug_ent_id                    varchar(11)             null comment '服务药企',
    dept_id                        varchar(11)             null comment '组织机构ID',
    del_flag                       char        default '0' not null comment '是否删除',
    enable_flag                    char        default '0' not null comment '是否禁用',
    tenant_id                      int         default 1   not null comment '所属租户',
    create_time                    datetime                null comment '创建时间',
    create_user                    int                     null comment '创建人',
    update_time                    datetime                null comment '更新时间',
    update_user                    int                     null comment '更新人',
    submit_status                  varchar(2)              null comment '提交状态',
    share_img_url                  varchar(255)            null comment '分享图片地址',
    plat_audit_status              char(2)     default '0' null comment '平台审核状态',
    ext_ids                        varchar(255)            null comment '备用字段',
    task_info_img                  varchar(255)            null comment '任务详情图片',
    compare_result                 varchar(2)              null comment '对比结果',
    approval_opinion               varchar(2)              null comment '审批意见',
    approval_info                  varchar(500)            null comment '审批说明',
    real_flag                      char(2)     default '0' null comment '是否真实',
    report_one_id                  int                     null comment '任务提交到一级cso的报告ID',
    report_one_approval_status     varchar(32) default '0' null comment '任务提交到一级cso的报告审核状态',
    report_one_approval_opinion    varchar(2)              null comment '任务提交到一级cso的报告审批意见',
    report_one_approval_info       varchar(50)             null comment '任务提交到一级cso的报告审批说明',
    report_second_id               int                     null comment '任务提交到二级cso的报告ID',
    report_second_approval_status  varchar(32) default '0' null comment '任务提交到二级cso的报告审核状态',
    report_second_approval_opinion varchar(2)              null comment '任务提交到二级cso的报告审批意见',
    report_second_approval_info    varchar(50)             null comment '任务提交到二级cso的报告审批说明',
    report_drug_id                 int                     null comment '任务提交到药企的报告ID',
    report_drug_approval_status    varchar(32) default '0' null comment '任务提交到药企的报告审核状态',
    report_drug_approval_opinion   varchar(2)              null comment '任务提交到药企的报告审批意见',
    report_drug_approval_info      varchar(50)             null comment '任务提交到药企的报告审批说明',
    task_status_info               varchar(500)            null comment 'cso审核审核意见',
    task_from                      varchar(2)  default '1' null comment '来源'
)
    comment '任务表' row_format = DYNAMIC;

create index 任务内容
    on wm_task_0518 (task_content_id);

create index 任务类型task
    on wm_task_0518 (task_type_id);

create index 调研类型
    on wm_task_0518 (lookinto_type_id);

create table wm_task_content
(
    id     int auto_increment
        primary key,
    temp1  varchar(1000) null comment '字段1',
    temp2  varchar(1000) null comment '字段2',
    temp3  varchar(1000) null comment '字段3',
    temp4  varchar(1000) null comment '字段4',
    temp5  varchar(1000) null,
    temp6  varchar(1000) null,
    temp7  varchar(1000) null,
    temp8  varchar(1000) null,
    temp9  varchar(1000) null,
    temp10 longtext      null,
    temp11 varchar(255)  null,
    temp12 longtext      null,
    temp13 varchar(255)  null,
    temp14 varchar(255)  null,
    temp15 varchar(255)  null,
    temp16 varchar(255)  null,
    temp17 varchar(255)  null,
    temp18 varchar(255)  null,
    temp19 varchar(255)  null,
    temp20 longtext      null,
    temp21 varchar(2000) null,
    temp22 varchar(255)  null,
    temp23 varchar(255)  null,
    temp24 varchar(255)  null,
    temp25 varchar(255)  null,
    temp26 varchar(255)  null,
    temp28 text          null,
    temp29 text          null,
    temp30 varchar(255)  null,
    temp31 varchar(255)  null comment 'temp31',
    temp32 varchar(255)  null comment 'temp32'
)
    comment '任务内容表' row_format = DYNAMIC;

create table wm_task_content_config
(
    id                 int auto_increment
        primary key,
    base_type_id       char(10)                           null comment '任务大类',
    task_type_id       char(10)                           null comment '任务ID',
    task_filed_key     varchar(255)                       null comment '字段1',
    task_filed_value   varchar(255)                       null comment '字段2',
    seq                int                                null comment '顺序',
    task_filed_type    char(20)                           null comment '字段类型',
    task_filed_minsize int                                null comment '最大长度',
    task_filed_maxsize int                                null comment '最小长度',
    task_filed_alert   varchar(255)                       null comment '弹框提示',
    dict_url           varchar(255)                       null comment '字典值请求URL',
    dict_group_name    varchar(255)                       null comment '字典值分组名称',
    is_mustfill        char                               null comment '是否必填',
    dept_id            int                                null comment '组织机构ID',
    del_flag           char     default '0'               not null comment '是否删除',
    enable_flag        char     default '0'               not null comment '是否禁用',
    tenant_id          int      default 1                 not null comment '所属租户',
    create_time        datetime default CURRENT_TIMESTAMP null comment '创建时间',
    create_user        int                                null comment '创建人',
    update_time        datetime default CURRENT_TIMESTAMP null comment '更新时间',
    update_user        int                                null comment '更新人'
)
    comment '任务内容字段配置' row_format = DYNAMIC;

create index 任务5
    on wm_task_content_config (task_type_id);

create table wm_task_download_job
(
    id               int auto_increment
        primary key,
    agent_id         varchar(10) not null,
    task_type_id     varchar(10) not null,
    download_user_id varchar(10) null
)
    row_format = DYNAMIC;

create table wm_task_info_config_ref
(
    id                    int         not null
        primary key,
    task_table_name       varchar(50) null comment '任务表名称',
    task_table_filed_name varchar(50) not null comment '任务表字段名称',
    config_filed_name     varchar(50) null comment '配置字段名称',
    task_type_id          int         null comment '任务类型ID'
)
    row_format = DYNAMIC;

create table wm_task_rule
(
    id           int auto_increment
        primary key,
    drugent_id   char(10)               null comment '药企ID',
    rule_type_id char(2)                null comment '规则类型，1药企 2一级代理商',
    rule_month   varchar(255)           null comment '规则月份',
    level1_id    varchar(11)            null comment '一级代理商ID',
    level2_id    varchar(11)            null comment '二级代理商ID',
    dept_id      varchar(11)            null comment '组织机构ID',
    del_flag     varchar(1) default '0' not null comment '是否删除',
    enable_flag  varchar(1) default '0' not null comment '是否禁用',
    tenant_id    int        default 1   not null comment '所属租户',
    create_time  datetime               null on update CURRENT_TIMESTAMP comment '创建时间',
    create_user  int                    null comment '创建人',
    update_time  datetime               null comment '更新时间',
    update_user  int                    null comment '更新人'
)
    comment '任务积分规则' row_format = DYNAMIC;

create table wm_task_settle_note
(
    id                 int auto_increment
        primary key,
    package_id         varchar(20)             null,
    package_status_id  varchar(20)             null,
    task_id            varchar(20)             null,
    settle_amount      decimal(10, 2)          null,
    user_id            varchar(20)             null,
    invoice_type       int(20)                 null,
    settle_no          varchar(128)            null,
    discount           decimal(10, 2)          null,
    settle_note_status int(2)       default 0  null,
    remark             varchar(256)            null,
    category_name      varchar(255)            null,
    create_time        datetime                null,
    sub_time           datetime                null,
    notify_time        datetime                null,
    update_time        datetime                null,
    stream_id          varchar(255) default '' null
)
    charset = utf8
    row_format = DYNAMIC;

create table wm_task_sub_percent_rule
(
    rule_id     int(20) auto_increment comment '规则ID'
        primary key,
    dept_id     int(20)                            not null comment '企业id',
    sub_cate    varchar(50)                        not null comment '次级分类',
    batch_id    varchar(32)                        null comment '批量保存编号',
    sub_rule    json                               null comment '规则',
    opt_flag    varchar(32)                        not null comment '操作标记',
    create_time datetime default CURRENT_TIMESTAMP not null comment '创建时间',
    update_time datetime default CURRENT_TIMESTAMP not null on update CURRENT_TIMESTAMP comment '修改时间'
)
    comment '任务提交百分比限制规则表';

create index idx_dept_id
    on wm_task_sub_percent_rule (dept_id);

create index idx_sub_cate
    on wm_task_sub_percent_rule (sub_cate);

create table wm_task_sub_rule
(
    rule_id     int(20) auto_increment comment '规则ID'
        primary key,
    dept_id     int(20)                            not null comment '企业id',
    sub_cate    varchar(32)                        not null comment '次级分类',
    sub_rule    json                               null comment '规则',
    opt_flag    varchar(32)                        not null comment '操作标记',
    create_time datetime default CURRENT_TIMESTAMP not null comment '创建时间',
    update_time datetime default CURRENT_TIMESTAMP not null on update CURRENT_TIMESTAMP comment '修改时间'
)
    comment '任务提交规则表';

create index idx_dept_id
    on wm_task_sub_rule (dept_id);

create index idx_sub_cate
    on wm_task_sub_rule (sub_cate);

create table wm_task_type
(
    id                 int(11) unsigned auto_increment
        primary key,
    task_type_name     varchar(50)             null comment '任务类型名称',
    task_type_level    char                    null comment '任务类型级别',
    task_score_start   int(5)                  null comment '积分范围开始',
    task_score_end     int(5)                  null comment '积分范围结束',
    score              int(10)                 null comment '完成后可获得分',
    task_ent_id        varchar(11)             null comment '积分分配代理商',
    durgent_id         char(11)                null comment '药企ID',
    level1_id          char(11)                null comment '一级代理商ID',
    dept_id            int                     null comment '组织机构ID',
    del_flag           int(1)      default 0   not null comment '是否删除',
    enable_flag        char        default '0' not null comment '是否禁用',
    tenant_id          int         default 1   not null comment '所属租户',
    create_time        datetime                null on update CURRENT_TIMESTAMP comment '创建时间',
    create_user        int                     null comment '创建人',
    update_time        datetime                null comment '更新时间',
    update_user        int                     null comment '更新人',
    status             int(1)      default 0   null comment '积分规则状态',
    base_id            varchar(11)             null comment '父类ID',
    real_flag          char                    null,
    rule_id            varchar(64) default ''  null,
    parent_id          varchar(11)             null comment '父级ID',
    task_receiver_type char        default '1' null comment '承接对象(1-个人,2-企业)',
    task_remark        text                    null comment '任务备注'
)
    comment '任务类型打分表' row_format = DYNAMIC;

create table wm_task_type_0422
(
    id               int(11) unsigned auto_increment
        primary key,
    task_type_name   varchar(50)             null comment '任务类型名称',
    task_type_level  char                    null comment '任务类型级别',
    task_score_start int(5)                  null comment '积分范围开始',
    task_score_end   int(5)                  null comment '积分范围结束',
    score            int(10)                 null comment '完成后可获得分',
    task_ent_id      varchar(11)             null comment '积分分配代理商',
    durgent_id       char(11)                null comment '药企ID',
    level1_id        char(11)                null comment '一级代理商ID',
    dept_id          int                     null comment '组织机构ID',
    del_flag         int(1)      default 0   not null comment '是否删除',
    enable_flag      char        default '0' not null comment '是否禁用',
    tenant_id        int         default 1   not null comment '所属租户',
    create_time      datetime                null on update CURRENT_TIMESTAMP comment '创建时间',
    create_user      int                     null comment '创建人',
    update_time      datetime                null comment '更新时间',
    update_user      int                     null comment '更新人',
    status           int(1)      default 0   null comment '积分规则状态',
    base_id          varchar(11)             null comment '父类ID',
    real_flag        char                    null,
    rule_id          varchar(64) default ''  null,
    parent_id        varchar(11)             null comment '父级ID'
)
    comment '任务类型打分表' row_format = DYNAMIC;

create table wm_task_type_ent_ref
(
    id          int auto_increment
        primary key,
    agent_id    varchar(11)                        null comment '代理商ID',
    drugent_id  varchar(11)                        null comment '药企ID',
    dept_id     int                                null comment '组织机构ID',
    del_flag    char     default '0'               not null comment '是否删除',
    enable_flag char     default '0'               not null comment '是否禁用',
    tenant_id   int      default 1                 not null comment '所属租户',
    create_time datetime default CURRENT_TIMESTAMP null on update CURRENT_TIMESTAMP comment '创建时间',
    create_user int                                null comment '创建人',
    update_time datetime                           null comment '更新时间',
    update_user int                                null comment '更新人'
)
    comment '药企给代理商设定积分规则' row_format = DYNAMIC;

create table wm_task_type_score_ref
(
    id              int              not null
        primary key,
    task_rule_id    int              null comment '积分规则ID',
    task_type_score varchar(255)     null comment '任务类型打分',
    task_type_id    int              null comment '任务类型ID',
    typeid          int(1)           null comment '1.平台给一级代理商打分
2.一级代理商给二级代理商打分',
    level1_id       int(10)          null comment '一级代理商ID',
    level2_id       int(10)          null comment '二级代理商ID',
    drugent_id      int(10)          null comment '药企ID',
    month_str       varchar(255)     null comment '积分规则所属月份',
    dept_id         int              null comment '组织机构ID',
    del_flag        int(1) default 0 not null comment '是否删除',
    enable_flag     int(1) default 0 not null comment '是否禁用',
    tenant_id       int    default 1 not null comment '所属租户',
    create_time     datetime         null on update CURRENT_TIMESTAMP comment '创建时间',
    create_user     int              null comment '创建人',
    update_time     datetime         null comment '更新时间',
    update_user     int              null comment '更新人'
)
    comment '任务类型打分' row_format = DYNAMIC;

create index taskrule11
    on wm_task_type_score_ref (task_rule_id);

create index tasktype112
    on wm_task_type_score_ref (task_type_id);

create table wm_task_type_sub_cate
(
    ttsc_id     int(20) auto_increment comment '规则ID'
        primary key,
    type_id     int(20)                            not null comment '企业id',
    type_name   varchar(32)                        not null comment '任务名称',
    sub_cate    varchar(32)                        not null comment '次级分类',
    create_time datetime default CURRENT_TIMESTAMP not null comment '创建时间',
    update_time datetime default CURRENT_TIMESTAMP not null on update CURRENT_TIMESTAMP comment '修改时间'
)
    comment '任务提交规则表';

create index idx_dept_id
    on wm_task_type_sub_cate (type_id);

create index idx_sub_cate
    on wm_task_type_sub_cate (sub_cate);

create table wm_task_type_sub_cate2
(
    dtt_id      int(20) auto_increment comment '主键ID'
        primary key,
    type_id     int(20)                            not null comment '企业id',
    type_name   varchar(32)                        not null comment '任务名称',
    sub_cate    varchar(50)                        not null comment '次级分类',
    parent_id   varchar(10)                        null comment '对应wm_task_type的parent_id',
    create_time datetime default CURRENT_TIMESTAMP not null comment '创建时间',
    update_time datetime default CURRENT_TIMESTAMP not null on update CURRENT_TIMESTAMP comment '修改时间'
)
    comment '任务类型二级分类表';

create index idx_dept_id
    on wm_task_type_sub_cate2 (type_id);

create index idx_sub_cate
    on wm_task_type_sub_cate2 (sub_cate);

create table wm_task_ware
(
    ware_id       bigint unsigned auto_increment comment 'id'
        primary key,
    ware_sn       varchar(64)                               not null comment '库存序号',
    task_id       varchar(18)                               not null comment '任务id',
    ava_count     bigint unsigned default 1                 not null comment '可用库存数',
    locked_count  bigint unsigned default 0                 not null comment '已锁定数量',
    order_sn      bigint                                    null comment '锁定订单',
    created_time  datetime        default CURRENT_TIMESTAMP not null comment '创建时间',
    modified_time datetime                                  not null on update CURRENT_TIMESTAMP comment '修改时间',
    constraint uk_record_id
        unique (task_id)
)
    comment '任务库存表';

create table wm_team
(
    id          int auto_increment
        primary key,
    dept_id     int                                not null comment '组织机构ID',
    name        varchar(50)                        not null comment '团队名称',
    leader      varchar(128)                       null comment '团队负责人',
    member      varchar(2048)                      null comment '团队成员',
    enable_flag char     default '0'               not null comment '是否禁用（0-企业，1-禁用）',
    del_flag    char     default '0'               not null comment '是否删除（0-正常，1-已删除）',
    create_time datetime default CURRENT_TIMESTAMP not null comment '创建时间',
    create_user int                                null comment '创建人',
    update_time datetime                           null comment '更新时间',
    update_user int                                null comment '更新人'
)
    comment '团队管理';

create table wm_user_plat_quiz_res
(
    res_id      int auto_increment comment 'Id'
        primary key,
    user_id     int                                not null comment '用户ID',
    quiz_id     int                                null comment '试卷id',
    quiz_res    json                               null comment '测试结果',
    res_expiry  date                               not null comment '测评有效期',
    create_time datetime default CURRENT_TIMESTAMP not null comment '创建时间'
)
    comment '用户测评的评判结果';

create index idx_qid
    on wm_user_plat_quiz_res (quiz_id);

create index idx_uid
    on wm_user_plat_quiz_res (user_id);

create table wm_user_sign
(
    id            int auto_increment
        primary key,
    sign_userid   varchar(11)  null comment '签到人',
    sign_ent_id   varchar(11)  null comment '签到企业ID',
    sign_date     datetime     null comment '签到日期',
    score         int          null comment '得分',
    longitude     varchar(255) not null comment '经度',
    latitude      varchar(255) not null comment '纬度',
    sign_ent_name varchar(255) null comment '签单企业名称',
    sign_ent_type varchar(11)  null comment '签到企业类型',
    task_type_id  varchar(11)  null comment '任务类型id'
)
    comment '用户签到表' row_format = DYNAMIC;

create table wm_user_sign_detail
(
    id            int auto_increment
        primary key,
    sign_id       int                          not null comment '签到表id',
    drug          text                         not null comment '推广药品',
    purpose       varchar(20)                  not null comment '拜访目的',
    result        char                         not null comment '拜访结果',
    remark        varchar(255)                 null comment '备注',
    department    varchar(64)                  null comment '拜访科室',
    visitor       varchar(64)                  null comment '拜访人员',
    detail        json                         null comment '详情数据',
    template_type char(10) default 'TEMPLATE1' null comment '所属模板类型'
)
    comment '用户签到详情';

create table wm_wk_album
(
    id          int auto_increment
        primary key,
    xcmc        varchar(255)     not null comment '相册名称',
    scfm        varchar(255)     not null comment '封面',
    glyp        varchar(255)     null comment '关联药品',
    wb          longtext         not null comment '文本',
    dept_id     int              null comment '组织机构ID',
    del_flag    int(1) default 0 not null comment '是否删除',
    enable_flag int(1) default 0 not null comment '是否禁用',
    tenant_id   int    default 1 not null comment '所属租户',
    create_time datetime         null on update CURRENT_TIMESTAMP comment '创建时间',
    create_user int              null comment '创建人',
    update_time datetime         null comment '更新时间',
    update_user int              null comment '更新人',
    forward_num int    default 0 null comment '转发数',
    temp1       varchar(255)     null comment '关联药品汉字',
    score       varchar(255)     null comment '前端显示分数使用'
)
    comment '文库-相册' row_format = DYNAMIC;

create table wm_wk_article
(
    id          int auto_increment
        primary key,
    title       varchar(500)     not null comment '文章标题',
    author      varchar(255)     not null comment '作者',
    fm          varchar(255)     null comment '封面',
    content     longtext         not null comment '文章内容',
    source      varchar(255)     null comment '文章来源',
    description varchar(1000)    null comment '描述',
    dept_id     int              null comment '组织机构ID',
    del_flag    int(1) default 0 not null comment '是否删除',
    enable_flag int(1) default 0 not null comment '是否禁用',
    tenant_id   int    default 1 not null comment '所属租户',
    create_time datetime         null comment '创建时间',
    create_user int              null comment '创建人',
    update_time datetime         null comment '更新时间',
    update_user int              null comment '更新人',
    forward_num int              null comment '转发数',
    channel_id  varchar(50)      null comment '抓取文章栏目ID',
    article_id  varchar(50)      null comment '抓取文章ID',
    score       varchar(255)     null,
    read_num    int    default 0 null comment '阅读数',
    new_flag    int(1) default 0 null comment '新标签',
    hot_flag    int(1) default 0 null comment '热门标签',
    area        varchar(128)     null comment '区域',
    source_ent  varchar(255)     null comment '文章来源(来源企业)'
)
    comment '文库-文章' row_format = DYNAMIC;

create table wm_wk_article0507
(
    id          int    default 0 not null,
    title       varchar(500)     not null comment '文章标题',
    author      varchar(255)     not null comment '作者',
    fm          varchar(255)     null comment '封面',
    content     longtext         not null comment '文章内容',
    source      varchar(255)     null comment '文章来源',
    description varchar(1000)    null comment '描述',
    dept_id     int              null comment '组织机构ID',
    del_flag    int(1) default 0 not null comment '是否删除',
    enable_flag int(1) default 0 not null comment '是否禁用',
    tenant_id   int    default 1 not null comment '所属租户',
    create_time datetime         null comment '创建时间',
    create_user int              null comment '创建人',
    update_time datetime         null comment '更新时间',
    update_user int              null comment '更新人',
    forward_num int              null comment '转发数',
    channel_id  varchar(50)      null comment '抓取文章栏目ID',
    article_id  varchar(50)      null comment '抓取文章ID',
    score       varchar(255)     null,
    read_num    int    default 0 null comment '阅读数',
    new_flag    int(1) default 0 null comment '新标签',
    hot_flag    int(1) default 0 null comment '热门标签',
    area        varchar(128)     null comment '区域'
)
    row_format = DYNAMIC;

create table wm_wk_article_20210225
(
    id          int auto_increment
        primary key,
    title       varchar(500)     not null comment '文章标题',
    author      varchar(255)     not null comment '作者',
    fm          varchar(255)     null comment '封面',
    content     longtext         not null comment '文章内容',
    source      varchar(255)     null comment '文章来源',
    description varchar(1000)    null comment '描述',
    dept_id     int              null comment '组织机构ID',
    del_flag    int(1) default 0 not null comment '是否删除',
    enable_flag int(1) default 0 not null comment '是否禁用',
    tenant_id   int    default 1 not null comment '所属租户',
    create_time datetime         null comment '创建时间',
    create_user int              null comment '创建人',
    update_time datetime         null comment '更新时间',
    update_user int              null comment '更新人',
    forward_num int              null comment '转发数',
    channel_id  varchar(50)      null comment '抓取文章栏目ID',
    article_id  varchar(50)      null comment '抓取文章ID',
    score       varchar(255)     null,
    read_num    int    default 0 null comment '阅读数',
    new_flag    int(1) default 0 null comment '新标签',
    hot_flag    int(1) default 0 null comment '热门标签',
    area        varchar(128)     null comment '区域'
)
    comment '文库-文章' row_format = DYNAMIC;

create table wm_wk_article_20210225001
(
    id          int auto_increment
        primary key,
    title       varchar(500)     not null comment '文章标题',
    author      varchar(255)     not null comment '作者',
    fm          varchar(255)     null comment '封面',
    content     longtext         not null comment '文章内容',
    source      varchar(255)     null comment '文章来源',
    description varchar(1000)    null comment '描述',
    dept_id     int              null comment '组织机构ID',
    del_flag    int(1) default 0 not null comment '是否删除',
    enable_flag int(1) default 0 not null comment '是否禁用',
    tenant_id   int    default 1 not null comment '所属租户',
    create_time datetime         null comment '创建时间',
    create_user int              null comment '创建人',
    update_time datetime         null comment '更新时间',
    update_user int              null comment '更新人',
    forward_num int              null comment '转发数',
    channel_id  varchar(50)      null comment '抓取文章栏目ID',
    article_id  varchar(50)      null comment '抓取文章ID',
    score       varchar(255)     null,
    read_num    int    default 0 null comment '阅读数',
    new_flag    int(1) default 0 null comment '新标签',
    hot_flag    int(1) default 0 null comment '热门标签',
    area        varchar(128)     null comment '区域'
)
    comment '文库-文章' row_format = DYNAMIC;

create table wm_wk_article_55798
(
    id          int    default 0 not null,
    title       varchar(500)     not null comment '文章标题',
    author      varchar(255)     not null comment '作者',
    fm          varchar(255)     null comment '封面',
    content     longtext         not null comment '文章内容',
    source      varchar(255)     null comment '文章来源',
    description varchar(1000)    null comment '描述',
    dept_id     int              null comment '组织机构ID',
    del_flag    int(1) default 0 not null comment '是否删除',
    enable_flag int(1) default 0 not null comment '是否禁用',
    tenant_id   int    default 1 not null comment '所属租户',
    create_time datetime         null comment '创建时间',
    create_user int              null comment '创建人',
    update_time datetime         null comment '更新时间',
    update_user int              null comment '更新人',
    forward_num int              null comment '转发数',
    channel_id  varchar(50)      null comment '抓取文章栏目ID',
    article_id  varchar(50)      null comment '抓取文章ID',
    score       varchar(255)     null,
    read_num    int    default 0 null comment '阅读数',
    new_flag    int(1) default 0 null comment '新标签',
    hot_flag    int(1) default 0 null comment '热门标签',
    area        varchar(128)     null comment '区域'
)
    row_format = DYNAMIC;

create table wm_wk_article_config
(
    id          int auto_increment
        primary key,
    type        char(2)                            null,
    source      varchar(11)                        null,
    total       int                                null,
    create_time datetime default CURRENT_TIMESTAMP null
)
    comment '文章抓取配置' row_format = DYNAMIC;

create table wm_wk_article_share
(
    id           int auto_increment
        primary key,
    share_type   varchar(11)  null comment '分享类型',
    arctile_id   varchar(200) null comment '文章ID',
    share_userid varchar(11)  null comment '分享用户ID',
    open_user    varchar(255) null comment '打开文章用户',
    create_time  datetime     null comment '打开时间',
    temp1        varchar(255) null comment '备用字段1',
    temp2        varchar(255) null comment '备用字段2',
    temp3        varchar(255) null comment '备用字段3'
)
    comment '文章分享' row_format = DYNAMIC;

create table xinbada_input_record
(
    id                 int auto_increment comment '主键id'
        primary key,
    signature          varchar(128)                            not null comment '签名',
    action_name        varchar(32)                             not null comment '通知类型',
    req_body           text                                    not null comment '请求body内容',
    order_uuid         varchar(64)                             null comment '订单编号唯一',
    order_status       int                                     null comment '订单状态',
    order_no           varchar(32)                             null,
    customer_user_uuid varchar(64)                             null,
    server_user_uuid   varchar(64)                             null,
    public_key         varchar(2048)                           null comment '请求公钥',
    private_key        varchar(2048)                           null comment '请求时私钥',
    create_time        timestamp   default CURRENT_TIMESTAMP   not null comment '创建时间',
    gig_type           varchar(32) default 'ZHENG_QI_ZHI_XING' null comment '零工平台类型'
)
    comment '正启之星请求记录';

create table xinshiyi_input_record
(
    id           int auto_increment comment '主键id'
        primary key,
    req_id       varchar(64)                        null comment '请求序号',
    batch_id     varchar(64)                        null comment '批次号',
    msg_method   char(20)                           null comment '消息接口名称',
    order_status int                                null comment '订单状态',
    req_body     text                               null comment '请求body',
    create_time  datetime default CURRENT_TIMESTAMP null comment '创建时间'
)
    comment '薪事易回调异步通知记录';

create table xxl_job_group
(
    id           int auto_increment
        primary key,
    app_name     varchar(64)       not null comment '执行器AppName',
    title        varchar(12)       not null comment '执行器名称',
    `order`      int     default 0 not null comment '排序',
    address_type tinyint default 0 not null comment '执行器地址类型：0=自动注册、1=手动录入',
    address_list varchar(512)      null comment '执行器地址列表，多地址逗号分隔'
)
    row_format = DYNAMIC;

create table xxl_job_info
(
    id                        int auto_increment
        primary key,
    job_group                 int                  not null comment '执行器主键ID',
    job_cron                  varchar(128)         not null comment '任务执行CRON',
    job_desc                  varchar(255)         not null,
    add_time                  datetime             null,
    update_time               datetime             null,
    author                    varchar(64)          null comment '作者',
    alarm_email               varchar(255)         null comment '报警邮件',
    executor_route_strategy   varchar(50)          null comment '执行器路由策略',
    executor_handler          varchar(255)         null comment '执行器任务handler',
    executor_param            varchar(512)         null comment '执行器任务参数',
    executor_block_strategy   varchar(50)          null comment '阻塞处理策略',
    executor_timeout          int        default 0 not null comment '任务执行超时时间，单位秒',
    executor_fail_retry_count int        default 0 not null comment '失败重试次数',
    glue_type                 varchar(50)          not null comment 'GLUE类型',
    glue_source               mediumtext           null comment 'GLUE源代码',
    glue_remark               varchar(128)         null comment 'GLUE备注',
    glue_updatetime           datetime             null comment 'GLUE更新时间',
    child_jobid               varchar(255)         null comment '子任务ID，多个逗号分隔',
    trigger_status            tinyint    default 0 not null comment '调度状态：0-停止，1-运行',
    trigger_last_time         bigint(13) default 0 not null comment '上次调度时间',
    trigger_next_time         bigint(13) default 0 not null comment '下次调度时间'
)
    row_format = DYNAMIC;

create table xxl_job_lock
(
    lock_name varchar(50) not null comment '锁名称'
        primary key
)
    row_format = DYNAMIC;

create table xxl_job_log
(
    id                        bigint auto_increment
        primary key,
    job_group                 int               not null comment '执行器主键ID',
    job_id                    int               not null comment '任务，主键ID',
    executor_address          varchar(255)      null comment '执行器地址，本次执行的地址',
    executor_handler          varchar(255)      null comment '执行器任务handler',
    executor_param            varchar(512)      null comment '执行器任务参数',
    executor_sharding_param   varchar(20)       null comment '执行器任务分片参数，格式如 1/2',
    executor_fail_retry_count int     default 0 not null comment '失败重试次数',
    trigger_time              datetime          null comment '调度-时间',
    trigger_code              int               not null comment '调度-结果',
    trigger_msg               text              null comment '调度-日志',
    handle_time               datetime          null comment '执行-时间',
    handle_code               int               not null comment '执行-状态',
    handle_msg                text              null comment '执行-日志',
    alarm_status              tinyint default 0 not null comment '告警状态：0-默认、1-无需告警、2-告警成功、3-告警失败'
)
    row_format = DYNAMIC;

create index I_handle_code
    on xxl_job_log (handle_code);

create index I_trigger_time
    on xxl_job_log (trigger_time);

create table xxl_job_log_report
(
    id            int auto_increment
        primary key,
    trigger_day   datetime      null comment '调度-时间',
    running_count int default 0 not null comment '运行中-日志数量',
    suc_count     int default 0 not null comment '执行成功-日志数量',
    fail_count    int default 0 not null comment '执行失败-日志数量',
    constraint i_trigger_day
        unique (trigger_day)
)
    row_format = DYNAMIC;

create table xxl_job_logglue
(
    id          int auto_increment
        primary key,
    job_id      int          not null comment '任务，主键ID',
    glue_type   varchar(50)  null comment 'GLUE类型',
    glue_source mediumtext   null comment 'GLUE源代码',
    glue_remark varchar(128) not null comment 'GLUE备注',
    add_time    datetime     null,
    update_time datetime     null
)
    row_format = DYNAMIC;

create table xxl_job_registry
(
    id             int auto_increment
        primary key,
    registry_group varchar(50)  not null,
    registry_key   varchar(255) not null,
    registry_value varchar(255) not null,
    update_time    datetime     null
)
    row_format = DYNAMIC;

create index i_g_k_v
    on xxl_job_registry (registry_group, registry_key(191), registry_value(191));

create table xxl_job_user
(
    id         int auto_increment
        primary key,
    username   varchar(50)  not null comment '账号',
    password   varchar(50)  not null comment '密码',
    role       tinyint      not null comment '角色：0-普通用户、1-管理员',
    permission varchar(255) null comment '权限：执行器ID列表，多个逗号分割',
    constraint i_username
        unique (username)
)
    row_format = DYNAMIC;

create table zhongyiyun_input_record
(
    id           int auto_increment comment '主键id'
        primary key,
    req_type     varchar(20)                        not null comment '请求业务类型',
    req_id       varchar(64)                        null comment '请求序号',
    req_body     text                               null comment '请求body',
    decrypt_body text                               null comment '解密后的body',
    create_time  datetime default CURRENT_TIMESTAMP null comment '创建时间'
)
    comment '众蚁云回调异步通知记录';

create table zhongzhi_input_record
(
    id          int auto_increment comment '主键id'
        primary key,
    req_type    varchar(20)                        not null comment '请求业务类型',
    order_no    varchar(64)                        null comment '三方订单号',
    req_body    text                               null comment '请求body',
    create_time datetime default CURRENT_TIMESTAMP null comment '创建时间'
)
    comment '中智回调异步通知记录';

create definer = root@`%` view view_wm_socre_package_total as
select `ccc`.`id`                    AS `id`,
       `ccc`.`invoice_category`      AS `invoice_category`,
       `ccc`.`settle_status`         AS `settle_status`,
       `ccc`.`settle_amount`         AS `settle_amount`,
       `ccc`.`discount`              AS `discount`,
       `ccc`.`task_rule_id`          AS `task_rule_id`,
       `ccc`.`drug_ent_id`           AS `drug_ent_id`,
       `ccc`.`score_id`              AS `score_id`,
       `ccc`.`score_name`            AS `score_name`,
       `ccc`.`score`                 AS `score`,
       `ccc`.`agent_type_id`         AS `agent_type_id`,
       `ccc`.`level1_id`             AS `level1_id`,
       `ccc`.`level2_id`             AS `level2_id`,
       `ccc`.`zb_id`                 AS `zb_id`,
       `ccc`.`xxdb_id`               AS `xxdb_id`,
       `ccc`.`typeid`                AS `typeid`,
       `ccc`.`package_status`        AS `package_status`,
       `ccc`.`package_finish_status` AS `package_finish_status`,
       `ccc`.`package_audit_status`  AS `package_audit_status`,
       `ccc`.`send_package_dept_id`  AS `send_package_dept_id`,
       `ccc`.`dept_id`               AS `dept_id`,
       `ccc`.`del_flag`              AS `del_flag`,
       `ccc`.`enable_flag`           AS `enable_flag`,
       `ccc`.`tenant_id`             AS `tenant_id`,
       `ccc`.`create_time`           AS `create_time`,
       `ccc`.`create_user`           AS `create_user`,
       `ccc`.`update_time`           AS `update_time`,
       `ccc`.`update_user`           AS `update_user`,
       `ccc`.`receive_date`          AS `receive_date`,
       `ccc`.`ytj`                   AS `ytj`,
       `ccc`.`ysh`                   AS `ysh`,
       `ccc`.`dsh`                   AS `dsh`,
       `ccc`.`t_type`                AS `t_type`
from (select `hnqzx`.`wm_score_package`.`id`                    AS `id`,
             `hnqzx`.`wm_score_package`.`invoice_category`      AS `invoice_category`,
             `hnqzx`.`wm_score_package`.`settle_status`         AS `settle_status`,
             `hnqzx`.`wm_score_package`.`settle_amount`         AS `settle_amount`,
             `hnqzx`.`wm_score_package`.`discount`              AS `discount`,
             `hnqzx`.`wm_score_package`.`task_rule_id`          AS `task_rule_id`,
             `hnqzx`.`wm_score_package`.`drug_ent_id`           AS `drug_ent_id`,
             `hnqzx`.`wm_score_package`.`score_id`              AS `score_id`,
             `hnqzx`.`wm_score_package`.`score_name`            AS `score_name`,
             `hnqzx`.`wm_score_package`.`score`                 AS `score`,
             `hnqzx`.`wm_score_package`.`agent_type_id`         AS `agent_type_id`,
             `hnqzx`.`wm_score_package`.`level1_id`             AS `level1_id`,
             `hnqzx`.`wm_score_package`.`level2_id`             AS `level2_id`,
             `hnqzx`.`wm_score_package`.`zb_id`                 AS `zb_id`,
             `hnqzx`.`wm_score_package`.`xxdb_id`               AS `xxdb_id`,
             `hnqzx`.`wm_score_package`.`typeid`                AS `typeid`,
             `hnqzx`.`wm_score_package`.`package_status`        AS `package_status`,
             `hnqzx`.`wm_score_package`.`package_finish_status` AS `package_finish_status`,
             `hnqzx`.`wm_score_package`.`package_audit_status`  AS `package_audit_status`,
             `hnqzx`.`wm_score_package`.`send_package_dept_id`  AS `send_package_dept_id`,
             `hnqzx`.`wm_score_package`.`dept_id`               AS `dept_id`,
             `hnqzx`.`wm_score_package`.`del_flag`              AS `del_flag`,
             `hnqzx`.`wm_score_package`.`enable_flag`           AS `enable_flag`,
             `hnqzx`.`wm_score_package`.`tenant_id`             AS `tenant_id`,
             `hnqzx`.`wm_score_package`.`create_time`           AS `create_time`,
             `hnqzx`.`wm_score_package`.`create_user`           AS `create_user`,
             `hnqzx`.`wm_score_package`.`update_time`           AS `update_time`,
             `hnqzx`.`wm_score_package`.`update_user`           AS `update_user`,
             `hnqzx`.`wm_score_package`.`receive_date`          AS `receive_date`,
             `hnqzx`.`wm_score_package`.`is_conduct`            AS `is_conduct`,
             `bb`.`ytj`                                         AS `ytj`,
             `bb`.`ysh`                                         AS `ysh`,
             `bb`.`dsh`                                         AS `dsh`,
             1                                                  AS `t_type`
      from (`hnqzx`.`wm_score_package` left join (select `hnqzx`.`wm_task`.`score_package_id`  AS `score_package_id`,
                                                         sum(if((`hnqzx`.`wm_task`.`task_status` > 0),
                                                                `hnqzx`.`wm_task`.`score`, 0)) AS `ytj`,
                                                         sum(if((`hnqzx`.`wm_task`.`task_status` = 3),
                                                                `hnqzx`.`wm_task`.`score`, 0)) AS `ysh`,
                                                         sum(if((`hnqzx`.`wm_task`.`task_status` = 2),
                                                                `hnqzx`.`wm_task`.`score`, 0)) AS `dsh`
                                                  from `hnqzx`.`wm_task`
                                                  where ((`hnqzx`.`wm_task`.`score_package_id` is not null) and
                                                         (`hnqzx`.`wm_task`.`real_flag` = '0'))
                                                  group by `hnqzx`.`wm_task`.`score_package_id`) `bb`
            on ((`hnqzx`.`wm_score_package`.`id` = `bb`.`score_package_id`)))
      where ((`hnqzx`.`wm_score_package`.`del_flag` = '0') and (`hnqzx`.`wm_score_package`.`enable_flag` = '0') and
             (`hnqzx`.`wm_score_package`.`agent_type_id` = 2) and (`hnqzx`.`wm_score_package`.`typeid` in (3, 4)))
      union
      select `hnqzx`.`wm_score_package`.`id`                    AS `id`,
             `hnqzx`.`wm_score_package`.`invoice_category`      AS `invoice_category`,
             `hnqzx`.`wm_score_package`.`settle_status`         AS `settle_status`,
             `hnqzx`.`wm_score_package`.`settle_amount`         AS `settle_amount`,
             `hnqzx`.`wm_score_package`.`discount`              AS `discount`,
             `hnqzx`.`wm_score_package`.`task_rule_id`          AS `task_rule_id`,
             `hnqzx`.`wm_score_package`.`drug_ent_id`           AS `drug_ent_id`,
             `hnqzx`.`wm_score_package`.`score_id`              AS `score_id`,
             `hnqzx`.`wm_score_package`.`score_name`            AS `score_name`,
             `hnqzx`.`wm_score_package`.`score`                 AS `score`,
             `hnqzx`.`wm_score_package`.`agent_type_id`         AS `agent_type_id`,
             `hnqzx`.`wm_score_package`.`level1_id`             AS `level1_id`,
             `hnqzx`.`wm_score_package`.`level2_id`             AS `level2_id`,
             `hnqzx`.`wm_score_package`.`zb_id`                 AS `zb_id`,
             `hnqzx`.`wm_score_package`.`xxdb_id`               AS `xxdb_id`,
             `hnqzx`.`wm_score_package`.`typeid`                AS `typeid`,
             `hnqzx`.`wm_score_package`.`package_status`        AS `package_status`,
             `hnqzx`.`wm_score_package`.`package_finish_status` AS `package_finish_status`,
             `hnqzx`.`wm_score_package`.`package_audit_status`  AS `package_audit_status`,
             `hnqzx`.`wm_score_package`.`send_package_dept_id`  AS `send_package_dept_id`,
             `hnqzx`.`wm_score_package`.`dept_id`               AS `dept_id`,
             `hnqzx`.`wm_score_package`.`del_flag`              AS `del_flag`,
             `hnqzx`.`wm_score_package`.`enable_flag`           AS `enable_flag`,
             `hnqzx`.`wm_score_package`.`tenant_id`             AS `tenant_id`,
             `hnqzx`.`wm_score_package`.`create_time`           AS `create_time`,
             `hnqzx`.`wm_score_package`.`create_user`           AS `create_user`,
             `hnqzx`.`wm_score_package`.`update_time`           AS `update_time`,
             `hnqzx`.`wm_score_package`.`update_user`           AS `update_user`,
             `hnqzx`.`wm_score_package`.`receive_date`          AS `receive_date`,
             `hnqzx`.`wm_score_package`.`is_conduct`            AS `is_conduct`,
             `bb`.`ytj`                                         AS `ytj`,
             `bb`.`ysh`                                         AS `ysh`,
             `bb`.`dsh`                                         AS `dsh`,
             2                                                  AS `t_type`
      from (`hnqzx`.`wm_score_package` left join (select `hnqzx`.`wm_task`.`score_package_level1_id` AS `score_package_id`,
                                                         sum(if((`hnqzx`.`wm_task`.`task_status` > 0),
                                                                `hnqzx`.`wm_task`.`score`, 0))       AS `ytj`,
                                                         sum(if((`hnqzx`.`wm_task`.`task_status` = 3),
                                                                `hnqzx`.`wm_task`.`score`, 0))       AS `ysh`,
                                                         sum(if((`hnqzx`.`wm_task`.`task_status` = 2),
                                                                `hnqzx`.`wm_task`.`score`, 0))       AS `dsh`
                                                  from `hnqzx`.`wm_task`
                                                  where ((`hnqzx`.`wm_task`.`score_package_id` is not null) and
                                                         (`hnqzx`.`wm_task`.`real_flag` = '0'))
                                                  group by `hnqzx`.`wm_task`.`score_package_level1_id`) `bb`
            on ((`hnqzx`.`wm_score_package`.`id` = `bb`.`score_package_id`)))
      where ((`hnqzx`.`wm_score_package`.`del_flag` = '0') and (`hnqzx`.`wm_score_package`.`enable_flag` = '0') and
             (`hnqzx`.`wm_score_package`.`agent_type_id` = 2) and (`hnqzx`.`wm_score_package`.`typeid` = 2))
      union
      select `hnqzx`.`wm_score_package`.`id`                    AS `id`,
             `hnqzx`.`wm_score_package`.`invoice_category`      AS `invoice_category`,
             `hnqzx`.`wm_score_package`.`settle_status`         AS `settle_status`,
             `hnqzx`.`wm_score_package`.`settle_amount`         AS `settle_amount`,
             `hnqzx`.`wm_score_package`.`discount`              AS `discount`,
             `hnqzx`.`wm_score_package`.`task_rule_id`          AS `task_rule_id`,
             `hnqzx`.`wm_score_package`.`drug_ent_id`           AS `drug_ent_id`,
             `hnqzx`.`wm_score_package`.`score_id`              AS `score_id`,
             `hnqzx`.`wm_score_package`.`score_name`            AS `score_name`,
             `hnqzx`.`wm_score_package`.`score`                 AS `score`,
             `hnqzx`.`wm_score_package`.`agent_type_id`         AS `agent_type_id`,
             `hnqzx`.`wm_score_package`.`level1_id`             AS `level1_id`,
             `hnqzx`.`wm_score_package`.`level2_id`             AS `level2_id`,
             `hnqzx`.`wm_score_package`.`zb_id`                 AS `zb_id`,
             `hnqzx`.`wm_score_package`.`xxdb_id`               AS `xxdb_id`,
             `hnqzx`.`wm_score_package`.`typeid`                AS `typeid`,
             `hnqzx`.`wm_score_package`.`package_status`        AS `package_status`,
             `hnqzx`.`wm_score_package`.`package_finish_status` AS `package_finish_status`,
             `hnqzx`.`wm_score_package`.`package_audit_status`  AS `package_audit_status`,
             `hnqzx`.`wm_score_package`.`send_package_dept_id`  AS `send_package_dept_id`,
             `hnqzx`.`wm_score_package`.`dept_id`               AS `dept_id`,
             `hnqzx`.`wm_score_package`.`del_flag`              AS `del_flag`,
             `hnqzx`.`wm_score_package`.`enable_flag`           AS `enable_flag`,
             `hnqzx`.`wm_score_package`.`tenant_id`             AS `tenant_id`,
             `hnqzx`.`wm_score_package`.`create_time`           AS `create_time`,
             `hnqzx`.`wm_score_package`.`create_user`           AS `create_user`,
             `hnqzx`.`wm_score_package`.`update_time`           AS `update_time`,
             `hnqzx`.`wm_score_package`.`update_user`           AS `update_user`,
             `hnqzx`.`wm_score_package`.`receive_date`          AS `receive_date`,
             `hnqzx`.`wm_score_package`.`is_conduct`            AS `is_conduct`,
             `bb`.`ytj`                                         AS `ytj`,
             `bb`.`ysh`                                         AS `ysh`,
             `bb`.`dsh`                                         AS `dsh`,
             3                                                  AS `t_type`
      from (`hnqzx`.`wm_score_package` left join (select `hnqzx`.`wm_task`.`score_package_drug_id` AS `score_package_id`,
                                                         sum(if((`hnqzx`.`wm_task`.`task_status` > 0),
                                                                `hnqzx`.`wm_task`.`score`, 0))     AS `ytj`,
                                                         sum(if((`hnqzx`.`wm_task`.`task_status` = 3),
                                                                `hnqzx`.`wm_task`.`score`, 0))     AS `ysh`,
                                                         sum(if((`hnqzx`.`wm_task`.`task_status` = 2),
                                                                `hnqzx`.`wm_task`.`score`, 0))     AS `dsh`
                                                  from `hnqzx`.`wm_task`
                                                  where ((`hnqzx`.`wm_task`.`score_package_id` is not null) and
                                                         (`hnqzx`.`wm_task`.`real_flag` = '0'))
                                                  group by `hnqzx`.`wm_task`.`score_package_drug_id`) `bb`
            on ((`hnqzx`.`wm_score_package`.`id` = `bb`.`score_package_id`)))
      where ((`hnqzx`.`wm_score_package`.`del_flag` = '0') and (`hnqzx`.`wm_score_package`.`enable_flag` = '0') and
             (`hnqzx`.`wm_score_package`.`agent_type_id` = 1))) `ccc`
order by `ccc`.`agent_type_id`, `ccc`.`create_time` desc;

create definer = root@`%` view view_wm_socre_package_total_20210115 as
select `ccc`.`id`                    AS `id`,
       `ccc`.`invoice_category`      AS `invoice_category`,
       `ccc`.`settle_status`         AS `settle_status`,
       `ccc`.`settle_amount`         AS `settle_amount`,
       `ccc`.`discount`              AS `discount`,
       `ccc`.`task_rule_id`          AS `task_rule_id`,
       `ccc`.`drug_ent_id`           AS `drug_ent_id`,
       `ccc`.`score_id`              AS `score_id`,
       `ccc`.`score_name`            AS `score_name`,
       `ccc`.`score`                 AS `score`,
       `ccc`.`agent_type_id`         AS `agent_type_id`,
       `ccc`.`level1_id`             AS `level1_id`,
       `ccc`.`level2_id`             AS `level2_id`,
       `ccc`.`zb_id`                 AS `zb_id`,
       `ccc`.`xxdb_id`               AS `xxdb_id`,
       `ccc`.`typeid`                AS `typeid`,
       `ccc`.`package_status`        AS `package_status`,
       `ccc`.`package_finish_status` AS `package_finish_status`,
       `ccc`.`package_audit_status`  AS `package_audit_status`,
       `ccc`.`send_package_dept_id`  AS `send_package_dept_id`,
       `ccc`.`dept_id`               AS `dept_id`,
       `ccc`.`del_flag`              AS `del_flag`,
       `ccc`.`enable_flag`           AS `enable_flag`,
       `ccc`.`tenant_id`             AS `tenant_id`,
       `ccc`.`create_time`           AS `create_time`,
       `ccc`.`create_user`           AS `create_user`,
       `ccc`.`update_time`           AS `update_time`,
       `ccc`.`update_user`           AS `update_user`,
       `ccc`.`receive_date`          AS `receive_date`,
       `ccc`.`ytj`                   AS `ytj`,
       `ccc`.`ysh`                   AS `ysh`,
       `ccc`.`dsh`                   AS `dsh`,
       `ccc`.`t_type`                AS `t_type`
from (select `hnqzx`.`wm_score_package`.`id`                    AS `id`,
             `hnqzx`.`wm_score_package`.`invoice_category`      AS `invoice_category`,
             `hnqzx`.`wm_score_package`.`settle_status`         AS `settle_status`,
             `hnqzx`.`wm_score_package`.`settle_amount`         AS `settle_amount`,
             `hnqzx`.`wm_score_package`.`discount`              AS `discount`,
             `hnqzx`.`wm_score_package`.`task_rule_id`          AS `task_rule_id`,
             `hnqzx`.`wm_score_package`.`drug_ent_id`           AS `drug_ent_id`,
             `hnqzx`.`wm_score_package`.`score_id`              AS `score_id`,
             `hnqzx`.`wm_score_package`.`score_name`            AS `score_name`,
             `hnqzx`.`wm_score_package`.`score`                 AS `score`,
             `hnqzx`.`wm_score_package`.`agent_type_id`         AS `agent_type_id`,
             `hnqzx`.`wm_score_package`.`level1_id`             AS `level1_id`,
             `hnqzx`.`wm_score_package`.`level2_id`             AS `level2_id`,
             `hnqzx`.`wm_score_package`.`zb_id`                 AS `zb_id`,
             `hnqzx`.`wm_score_package`.`xxdb_id`               AS `xxdb_id`,
             `hnqzx`.`wm_score_package`.`typeid`                AS `typeid`,
             `hnqzx`.`wm_score_package`.`package_status`        AS `package_status`,
             `hnqzx`.`wm_score_package`.`package_finish_status` AS `package_finish_status`,
             `hnqzx`.`wm_score_package`.`package_audit_status`  AS `package_audit_status`,
             `hnqzx`.`wm_score_package`.`send_package_dept_id`  AS `send_package_dept_id`,
             `hnqzx`.`wm_score_package`.`dept_id`               AS `dept_id`,
             `hnqzx`.`wm_score_package`.`del_flag`              AS `del_flag`,
             `hnqzx`.`wm_score_package`.`enable_flag`           AS `enable_flag`,
             `hnqzx`.`wm_score_package`.`tenant_id`             AS `tenant_id`,
             `hnqzx`.`wm_score_package`.`create_time`           AS `create_time`,
             `hnqzx`.`wm_score_package`.`create_user`           AS `create_user`,
             `hnqzx`.`wm_score_package`.`update_time`           AS `update_time`,
             `hnqzx`.`wm_score_package`.`update_user`           AS `update_user`,
             `hnqzx`.`wm_score_package`.`receive_date`          AS `receive_date`,
             `hnqzx`.`wm_score_package`.`is_conduct`            AS `is_conduct`,
             `bb`.`ytj`                                         AS `ytj`,
             `bb`.`ysh`                                         AS `ysh`,
             `bb`.`dsh`                                         AS `dsh`,
             1                                                  AS `t_type`
      from (`hnqzx`.`wm_score_package` left join (select `hnqzx`.`wm_task`.`score_package_id`  AS `score_package_id`,
                                                         sum(if((`hnqzx`.`wm_task`.`task_status` > 0),
                                                                `hnqzx`.`wm_task`.`score`, 0)) AS `ytj`,
                                                         sum(if((`hnqzx`.`wm_task`.`task_status` = 3),
                                                                `hnqzx`.`wm_task`.`score`, 0)) AS `ysh`,
                                                         sum(if((`hnqzx`.`wm_task`.`task_status` = 2),
                                                                `hnqzx`.`wm_task`.`score`, 0)) AS `dsh`
                                                  from `hnqzx`.`wm_task`
                                                  where (`hnqzx`.`wm_task`.`score_package_id` is not null)
                                                  group by `hnqzx`.`wm_task`.`score_package_id`) `bb`
            on ((`hnqzx`.`wm_score_package`.`id` = `bb`.`score_package_id`)))
      where ((`hnqzx`.`wm_score_package`.`del_flag` = '0') and (`hnqzx`.`wm_score_package`.`enable_flag` = '0') and
             (`hnqzx`.`wm_score_package`.`agent_type_id` = 2) and (`hnqzx`.`wm_score_package`.`typeid` in (3, 4)))
      union
      select `hnqzx`.`wm_score_package`.`id`                    AS `id`,
             `hnqzx`.`wm_score_package`.`invoice_category`      AS `invoice_category`,
             `hnqzx`.`wm_score_package`.`settle_status`         AS `settle_status`,
             `hnqzx`.`wm_score_package`.`settle_amount`         AS `settle_amount`,
             `hnqzx`.`wm_score_package`.`discount`              AS `discount`,
             `hnqzx`.`wm_score_package`.`task_rule_id`          AS `task_rule_id`,
             `hnqzx`.`wm_score_package`.`drug_ent_id`           AS `drug_ent_id`,
             `hnqzx`.`wm_score_package`.`score_id`              AS `score_id`,
             `hnqzx`.`wm_score_package`.`score_name`            AS `score_name`,
             `hnqzx`.`wm_score_package`.`score`                 AS `score`,
             `hnqzx`.`wm_score_package`.`agent_type_id`         AS `agent_type_id`,
             `hnqzx`.`wm_score_package`.`level1_id`             AS `level1_id`,
             `hnqzx`.`wm_score_package`.`level2_id`             AS `level2_id`,
             `hnqzx`.`wm_score_package`.`zb_id`                 AS `zb_id`,
             `hnqzx`.`wm_score_package`.`xxdb_id`               AS `xxdb_id`,
             `hnqzx`.`wm_score_package`.`typeid`                AS `typeid`,
             `hnqzx`.`wm_score_package`.`package_status`        AS `package_status`,
             `hnqzx`.`wm_score_package`.`package_finish_status` AS `package_finish_status`,
             `hnqzx`.`wm_score_package`.`package_audit_status`  AS `package_audit_status`,
             `hnqzx`.`wm_score_package`.`send_package_dept_id`  AS `send_package_dept_id`,
             `hnqzx`.`wm_score_package`.`dept_id`               AS `dept_id`,
             `hnqzx`.`wm_score_package`.`del_flag`              AS `del_flag`,
             `hnqzx`.`wm_score_package`.`enable_flag`           AS `enable_flag`,
             `hnqzx`.`wm_score_package`.`tenant_id`             AS `tenant_id`,
             `hnqzx`.`wm_score_package`.`create_time`           AS `create_time`,
             `hnqzx`.`wm_score_package`.`create_user`           AS `create_user`,
             `hnqzx`.`wm_score_package`.`update_time`           AS `update_time`,
             `hnqzx`.`wm_score_package`.`update_user`           AS `update_user`,
             `hnqzx`.`wm_score_package`.`receive_date`          AS `receive_date`,
             `hnqzx`.`wm_score_package`.`is_conduct`            AS `is_conduct`,
             `bb`.`ytj`                                         AS `ytj`,
             `bb`.`ysh`                                         AS `ysh`,
             `bb`.`dsh`                                         AS `dsh`,
             2                                                  AS `t_type`
      from (`hnqzx`.`wm_score_package` left join (select `hnqzx`.`wm_task`.`score_package_level1_id` AS `score_package_id`,
                                                         sum(if((`hnqzx`.`wm_task`.`task_status` > 0),
                                                                `hnqzx`.`wm_task`.`score`, 0))       AS `ytj`,
                                                         sum(if((`hnqzx`.`wm_task`.`task_status` = 3),
                                                                `hnqzx`.`wm_task`.`score`, 0))       AS `ysh`,
                                                         sum(if((`hnqzx`.`wm_task`.`task_status` = 2),
                                                                `hnqzx`.`wm_task`.`score`, 0))       AS `dsh`
                                                  from `hnqzx`.`wm_task`
                                                  where (`hnqzx`.`wm_task`.`score_package_id` is not null)
                                                  group by `hnqzx`.`wm_task`.`score_package_level1_id`) `bb`
            on ((`hnqzx`.`wm_score_package`.`id` = `bb`.`score_package_id`)))
      where ((`hnqzx`.`wm_score_package`.`del_flag` = '0') and (`hnqzx`.`wm_score_package`.`enable_flag` = '0') and
             (`hnqzx`.`wm_score_package`.`agent_type_id` = 2) and (`hnqzx`.`wm_score_package`.`typeid` = 2))
      union
      select `hnqzx`.`wm_score_package`.`id`                    AS `id`,
             `hnqzx`.`wm_score_package`.`invoice_category`      AS `invoice_category`,
             `hnqzx`.`wm_score_package`.`settle_status`         AS `settle_status`,
             `hnqzx`.`wm_score_package`.`settle_amount`         AS `settle_amount`,
             `hnqzx`.`wm_score_package`.`discount`              AS `discount`,
             `hnqzx`.`wm_score_package`.`task_rule_id`          AS `task_rule_id`,
             `hnqzx`.`wm_score_package`.`drug_ent_id`           AS `drug_ent_id`,
             `hnqzx`.`wm_score_package`.`score_id`              AS `score_id`,
             `hnqzx`.`wm_score_package`.`score_name`            AS `score_name`,
             `hnqzx`.`wm_score_package`.`score`                 AS `score`,
             `hnqzx`.`wm_score_package`.`agent_type_id`         AS `agent_type_id`,
             `hnqzx`.`wm_score_package`.`level1_id`             AS `level1_id`,
             `hnqzx`.`wm_score_package`.`level2_id`             AS `level2_id`,
             `hnqzx`.`wm_score_package`.`zb_id`                 AS `zb_id`,
             `hnqzx`.`wm_score_package`.`xxdb_id`               AS `xxdb_id`,
             `hnqzx`.`wm_score_package`.`typeid`                AS `typeid`,
             `hnqzx`.`wm_score_package`.`package_status`        AS `package_status`,
             `hnqzx`.`wm_score_package`.`package_finish_status` AS `package_finish_status`,
             `hnqzx`.`wm_score_package`.`package_audit_status`  AS `package_audit_status`,
             `hnqzx`.`wm_score_package`.`send_package_dept_id`  AS `send_package_dept_id`,
             `hnqzx`.`wm_score_package`.`dept_id`               AS `dept_id`,
             `hnqzx`.`wm_score_package`.`del_flag`              AS `del_flag`,
             `hnqzx`.`wm_score_package`.`enable_flag`           AS `enable_flag`,
             `hnqzx`.`wm_score_package`.`tenant_id`             AS `tenant_id`,
             `hnqzx`.`wm_score_package`.`create_time`           AS `create_time`,
             `hnqzx`.`wm_score_package`.`create_user`           AS `create_user`,
             `hnqzx`.`wm_score_package`.`update_time`           AS `update_time`,
             `hnqzx`.`wm_score_package`.`update_user`           AS `update_user`,
             `hnqzx`.`wm_score_package`.`receive_date`          AS `receive_date`,
             `hnqzx`.`wm_score_package`.`is_conduct`            AS `is_conduct`,
             `bb`.`ytj`                                         AS `ytj`,
             `bb`.`ysh`                                         AS `ysh`,
             `bb`.`dsh`                                         AS `dsh`,
             3                                                  AS `t_type`
      from (`hnqzx`.`wm_score_package` left join (select `hnqzx`.`wm_task`.`score_package_drug_id` AS `score_package_id`,
                                                         sum(if((`hnqzx`.`wm_task`.`task_status` > 0),
                                                                `hnqzx`.`wm_task`.`score`, 0))     AS `ytj`,
                                                         sum(if((`hnqzx`.`wm_task`.`task_status` = 3),
                                                                `hnqzx`.`wm_task`.`score`, 0))     AS `ysh`,
                                                         sum(if((`hnqzx`.`wm_task`.`task_status` = 2),
                                                                `hnqzx`.`wm_task`.`score`, 0))     AS `dsh`
                                                  from `hnqzx`.`wm_task`
                                                  where (`hnqzx`.`wm_task`.`score_package_id` is not null)
                                                  group by `hnqzx`.`wm_task`.`score_package_drug_id`) `bb`
            on ((`hnqzx`.`wm_score_package`.`id` = `bb`.`score_package_id`)))
      where ((`hnqzx`.`wm_score_package`.`del_flag` = '0') and (`hnqzx`.`wm_score_package`.`enable_flag` = '0') and
             (`hnqzx`.`wm_score_package`.`agent_type_id` = 1))) `ccc`
order by `ccc`.`agent_type_id`, `ccc`.`create_time` desc;

create definer = root@`%` view wm_zb_count as
select distinct `ccc`.`package_id`              AS `package_id`,
                `ccc`.`score_name`              AS `score_name`,
                `ccc`.`score_id`                AS `score_id`,
                `ccc`.`package_score`           AS `package_score`,
                `ccc`.`send_package_dept_id`    AS `send_package_dept_id`,
                `ccc`.`pcreate_time`            AS `pcreate_time`,
                `ccc`.`realname`                AS `realname`,
                `ccc`.`idcard`                  AS `idcard`,
                `ccc`.`phone`                   AS `phone`,
                `ccc`.`dept_name`               AS `dept_name`,
                `ccc`.`user_id`                 AS `user_id`,
                `ccc`.`task_type_name`          AS `task_type_name`,
                `ccc`.`base_id`                 AS `base_id`,
                `ccc`.`id`                      AS `id`,
                `ccc`.`task_rule_id`            AS `task_rule_id`,
                `ccc`.`score`                   AS `score`,
                `ccc`.`score_package_drug_id`   AS `score_package_drug_id`,
                `ccc`.`score_package_level1_id` AS `score_package_level1_id`,
                `ccc`.`score_package_id`        AS `score_package_id`,
                `ccc`.`task_type_id`            AS `task_type_id`,
                `ccc`.`lookinto_date`           AS `lookinto_date`,
                `ccc`.`province`                AS `province`,
                `ccc`.`city`                    AS `city`,
                `ccc`.`area`                    AS `area`,
                `ccc`.`address`                 AS `address`,
                `ccc`.`lookinto_type_id`        AS `lookinto_type_id`,
                `ccc`.`task_content_id`         AS `task_content_id`,
                `ccc`.`task_status`             AS `task_status`,
                `ccc`.`task_user_id`            AS `task_user_id`,
                `ccc`.`task_user_type`          AS `task_user_type`,
                `ccc`.`drug_ent_id`             AS `drug_ent_id`,
                `ccc`.`dept_id`                 AS `dept_id`,
                `ccc`.`del_flag`                AS `del_flag`,
                `ccc`.`enable_flag`             AS `enable_flag`,
                `ccc`.`tenant_id`               AS `tenant_id`,
                `ccc`.`lookinto_date`           AS `create_time`,
                `ccc`.`create_user`             AS `create_user`,
                `ccc`.`update_time`             AS `update_time`,
                `ccc`.`update_user`             AS `update_user`,
                `ccc`.`submit_status`           AS `submit_status`,
                `ccc`.`share_img_url`           AS `share_img_url`,
                `ccc`.`plat_audit_status`       AS `plat_audit_status`,
                `ccc`.`ext_ids`                 AS `ext_ids`,
                `ccc`.`task_info_img`           AS `task_info_img`,
                `ccc`.`t_type`                  AS `t_type`
from (select `hnqzx`.`wm_score_package`.`id`                   AS `package_id`,
             `hnqzx`.`wm_score_package`.`score_name`           AS `score_name`,
             `hnqzx`.`wm_score_package`.`score`                AS `package_score`,
             `hnqzx`.`wm_score_package`.`send_package_dept_id` AS `send_package_dept_id`,
             `hnqzx`.`wm_score_package`.`score_id`             AS `score_id`,
             `hnqzx`.`wm_score_package`.`create_time`          AS `pcreate_time`,
             `hnqzx`.`sys_user`.`realname`                     AS `realname`,
             `hnqzx`.`sys_user`.`id_card_number`               AS `idcard`,
             `hnqzx`.`sys_user`.`phone`                        AS `phone`,
             `hnqzx`.`sys_dept`.`name`                         AS `dept_name`,
             `hnqzx`.`sys_user`.`user_id`                      AS `user_id`,
             `hnqzx`.`wm_task_type`.`task_type_name`           AS `task_type_name`,
             `hnqzx`.`wm_task_type`.`base_id`                  AS `base_id`,
             `hnqzx`.`wm_task`.`id`                            AS `id`,
             `hnqzx`.`wm_task`.`task_rule_id`                  AS `task_rule_id`,
             `hnqzx`.`wm_task`.`score`                         AS `score`,
             `hnqzx`.`wm_task`.`score_package_drug_id`         AS `score_package_drug_id`,
             `hnqzx`.`wm_task`.`score_package_level1_id`       AS `score_package_level1_id`,
             `hnqzx`.`wm_task`.`score_package_id`              AS `score_package_id`,
             `hnqzx`.`wm_task`.`task_type_id`                  AS `task_type_id`,
             `hnqzx`.`wm_task`.`lookinto_date`                 AS `lookinto_date`,
             `hnqzx`.`wm_task`.`province`                      AS `province`,
             `hnqzx`.`wm_task`.`city`                          AS `city`,
             `hnqzx`.`wm_task`.`area`                          AS `area`,
             `hnqzx`.`wm_task`.`address`                       AS `address`,
             `hnqzx`.`wm_task`.`lookinto_type_id`              AS `lookinto_type_id`,
             `hnqzx`.`wm_task`.`task_content_id`               AS `task_content_id`,
             `hnqzx`.`wm_task`.`task_status`                   AS `task_status`,
             `hnqzx`.`wm_task`.`task_user_id`                  AS `task_user_id`,
             `hnqzx`.`wm_task`.`task_user_type`                AS `task_user_type`,
             `hnqzx`.`wm_task`.`drug_ent_id`                   AS `drug_ent_id`,
             `hnqzx`.`wm_task`.`dept_id`                       AS `dept_id`,
             `hnqzx`.`wm_task`.`del_flag`                      AS `del_flag`,
             `hnqzx`.`wm_task`.`enable_flag`                   AS `enable_flag`,
             `hnqzx`.`wm_task`.`tenant_id`                     AS `tenant_id`,
             `hnqzx`.`wm_task`.`lookinto_date`                 AS `create_time`,
             `hnqzx`.`wm_task`.`create_user`                   AS `create_user`,
             `hnqzx`.`wm_task`.`update_time`                   AS `update_time`,
             `hnqzx`.`wm_task`.`update_user`                   AS `update_user`,
             `hnqzx`.`wm_task`.`submit_status`                 AS `submit_status`,
             `hnqzx`.`wm_task`.`share_img_url`                 AS `share_img_url`,
             `hnqzx`.`wm_task`.`plat_audit_status`             AS `plat_audit_status`,
             `hnqzx`.`wm_task`.`real_flag`                     AS `real_flag`,
             `hnqzx`.`wm_task`.`ext_ids`                       AS `ext_ids`,
             `hnqzx`.`wm_task`.`task_info_img`                 AS `task_info_img`,
             1                                                 AS `t_type`
      from ((((`hnqzx`.`wm_task` left join `hnqzx`.`wm_score_package` on ((`hnqzx`.`wm_task`.`score_package_id` =
                                                                           `hnqzx`.`wm_score_package`.`id`))) join `hnqzx`.`wm_task_type`) join `hnqzx`.`sys_user`) join `hnqzx`.`sys_dept`)
      where ((`hnqzx`.`wm_task_type`.`id` = `hnqzx`.`wm_task`.`task_type_id`) and
             (`hnqzx`.`sys_user`.`user_id` = `hnqzx`.`wm_task`.`task_user_id`) and
             (`hnqzx`.`sys_user`.`dept_id` = `hnqzx`.`sys_dept`.`dept_id`))
      union
      select `hnqzx`.`wm_task`.`score_package_drug_id`         AS `package_id`,
             `hnqzx`.`wm_score_package`.`score_name`           AS `score_name`,
             `hnqzx`.`wm_score_package`.`score`                AS `package_score`,
             `hnqzx`.`wm_score_package`.`send_package_dept_id` AS `send_package_dept_id`,
             `hnqzx`.`wm_score_package`.`score_id`             AS `score_id`,
             `hnqzx`.`wm_score_package`.`create_time`          AS `pcreate_time`,
             `hnqzx`.`sys_user`.`realname`                     AS `realname`,
             `hnqzx`.`sys_user`.`id_card_number`               AS `idcard`,
             `hnqzx`.`sys_user`.`phone`                        AS `phone`,
             `hnqzx`.`sys_dept`.`name`                         AS `dept_name`,
             `hnqzx`.`sys_user`.`user_id`                      AS `user_id`,
             `hnqzx`.`wm_task_type`.`task_type_name`           AS `task_type_name`,
             `hnqzx`.`wm_task_type`.`base_id`                  AS `base_id`,
             `hnqzx`.`wm_task`.`id`                            AS `id`,
             `hnqzx`.`wm_task`.`task_rule_id`                  AS `task_rule_id`,
             `hnqzx`.`wm_task`.`score`                         AS `score`,
             `hnqzx`.`wm_task`.`score_package_drug_id`         AS `score_package_drug_id`,
             `hnqzx`.`wm_task`.`score_package_level1_id`       AS `score_package_level1_id`,
             `hnqzx`.`wm_task`.`score_package_id`              AS `score_package_id`,
             `hnqzx`.`wm_task`.`task_type_id`                  AS `task_type_id`,
             `hnqzx`.`wm_task`.`lookinto_date`                 AS `lookinto_date`,
             `hnqzx`.`wm_task`.`province`                      AS `province`,
             `hnqzx`.`wm_task`.`city`                          AS `city`,
             `hnqzx`.`wm_task`.`area`                          AS `area`,
             `hnqzx`.`wm_task`.`address`                       AS `address`,
             `hnqzx`.`wm_task`.`lookinto_type_id`              AS `lookinto_type_id`,
             `hnqzx`.`wm_task`.`task_content_id`               AS `task_content_id`,
             `hnqzx`.`wm_task`.`task_status`                   AS `task_status`,
             `hnqzx`.`wm_task`.`task_user_id`                  AS `task_user_id`,
             `hnqzx`.`wm_task`.`task_user_type`                AS `task_user_type`,
             `hnqzx`.`wm_task`.`drug_ent_id`                   AS `drug_ent_id`,
             `hnqzx`.`wm_task`.`dept_id`                       AS `dept_id`,
             `hnqzx`.`wm_task`.`del_flag`                      AS `del_flag`,
             `hnqzx`.`wm_task`.`enable_flag`                   AS `enable_flag`,
             `hnqzx`.`wm_task`.`tenant_id`                     AS `tenant_id`,
             `hnqzx`.`wm_task`.`lookinto_date`                 AS `create_time`,
             `hnqzx`.`wm_task`.`create_user`                   AS `create_user`,
             `hnqzx`.`wm_task`.`update_time`                   AS `update_time`,
             `hnqzx`.`wm_task`.`update_user`                   AS `update_user`,
             `hnqzx`.`wm_task`.`submit_status`                 AS `submit_status`,
             `hnqzx`.`wm_task`.`share_img_url`                 AS `share_img_url`,
             `hnqzx`.`wm_task`.`plat_audit_status`             AS `plat_audit_status`,
             `hnqzx`.`wm_task`.`real_flag`                     AS `real_flag`,
             `hnqzx`.`wm_task`.`ext_ids`                       AS `ext_ids`,
             `hnqzx`.`wm_task`.`task_info_img`                 AS `task_info_img`,
             2                                                 AS `t_type`
      from ((((`hnqzx`.`wm_task` left join `hnqzx`.`wm_score_package` on ((`hnqzx`.`wm_task`.`score_package_drug_id` =
                                                                           `hnqzx`.`wm_score_package`.`id`))) join `hnqzx`.`wm_task_type`) join `hnqzx`.`sys_user`) join `hnqzx`.`sys_dept`)
      where ((`hnqzx`.`wm_task_type`.`id` = `hnqzx`.`wm_task`.`task_type_id`) and
             (`hnqzx`.`sys_user`.`user_id` = `hnqzx`.`wm_task`.`task_user_id`) and
             (`hnqzx`.`sys_user`.`dept_id` = `hnqzx`.`sys_dept`.`dept_id`))
      union
      select `hnqzx`.`wm_task`.`score_package_level1_id`       AS `package_id`,
             `hnqzx`.`wm_score_package`.`score_name`           AS `score_name`,
             `hnqzx`.`wm_score_package`.`score`                AS `package_score`,
             `hnqzx`.`wm_score_package`.`send_package_dept_id` AS `send_package_dept_id`,
             `hnqzx`.`wm_score_package`.`score_id`             AS `score_id`,
             `hnqzx`.`wm_score_package`.`create_time`          AS `pcreate_time`,
             `hnqzx`.`sys_user`.`realname`                     AS `realname`,
             `hnqzx`.`sys_user`.`id_card_number`               AS `idcard`,
             `hnqzx`.`sys_user`.`phone`                        AS `phone`,
             `hnqzx`.`sys_dept`.`name`                         AS `dept_name`,
             `hnqzx`.`sys_user`.`user_id`                      AS `user_id`,
             `hnqzx`.`wm_task_type`.`task_type_name`           AS `task_type_name`,
             `hnqzx`.`wm_task_type`.`base_id`                  AS `base_id`,
             `hnqzx`.`wm_task`.`id`                            AS `id`,
             `hnqzx`.`wm_task`.`task_rule_id`                  AS `task_rule_id`,
             `hnqzx`.`wm_task`.`score`                         AS `score`,
             `hnqzx`.`wm_task`.`score_package_drug_id`         AS `score_package_drug_id`,
             `hnqzx`.`wm_task`.`score_package_level1_id`       AS `score_package_level1_id`,
             `hnqzx`.`wm_task`.`score_package_id`              AS `score_package_id`,
             `hnqzx`.`wm_task`.`task_type_id`                  AS `task_type_id`,
             `hnqzx`.`wm_task`.`lookinto_date`                 AS `lookinto_date`,
             `hnqzx`.`wm_task`.`province`                      AS `province`,
             `hnqzx`.`wm_task`.`city`                          AS `city`,
             `hnqzx`.`wm_task`.`area`                          AS `area`,
             `hnqzx`.`wm_task`.`address`                       AS `address`,
             `hnqzx`.`wm_task`.`lookinto_type_id`              AS `lookinto_type_id`,
             `hnqzx`.`wm_task`.`task_content_id`               AS `task_content_id`,
             `hnqzx`.`wm_task`.`task_status`                   AS `task_status`,
             `hnqzx`.`wm_task`.`task_user_id`                  AS `task_user_id`,
             `hnqzx`.`wm_task`.`task_user_type`                AS `task_user_type`,
             `hnqzx`.`wm_task`.`drug_ent_id`                   AS `drug_ent_id`,
             `hnqzx`.`wm_task`.`dept_id`                       AS `dept_id`,
             `hnqzx`.`wm_task`.`del_flag`                      AS `del_flag`,
             `hnqzx`.`wm_task`.`enable_flag`                   AS `enable_flag`,
             `hnqzx`.`wm_task`.`tenant_id`                     AS `tenant_id`,
             `hnqzx`.`wm_task`.`lookinto_date`                 AS `create_time`,
             `hnqzx`.`wm_task`.`create_user`                   AS `create_user`,
             `hnqzx`.`wm_task`.`update_time`                   AS `update_time`,
             `hnqzx`.`wm_task`.`update_user`                   AS `update_user`,
             `hnqzx`.`wm_task`.`submit_status`                 AS `submit_status`,
             `hnqzx`.`wm_task`.`share_img_url`                 AS `share_img_url`,
             `hnqzx`.`wm_task`.`plat_audit_status`             AS `plat_audit_status`,
             `hnqzx`.`wm_task`.`real_flag`                     AS `real_flag`,
             `hnqzx`.`wm_task`.`ext_ids`                       AS `ext_ids`,
             `hnqzx`.`wm_task`.`task_info_img`                 AS `task_info_img`,
             3                                                 AS `t_type`
      from ((((`hnqzx`.`wm_task` left join `hnqzx`.`wm_score_package` on ((`hnqzx`.`wm_task`.`score_package_level1_id` =
                                                                           `hnqzx`.`wm_score_package`.`id`))) join `hnqzx`.`wm_task_type`) join `hnqzx`.`sys_user`) join `hnqzx`.`sys_dept`)
      where ((`hnqzx`.`wm_task_type`.`id` = `hnqzx`.`wm_task`.`task_type_id`) and
             (`hnqzx`.`sys_user`.`user_id` = `hnqzx`.`wm_task`.`task_user_id`) and
             (`hnqzx`.`sys_user`.`dept_id` = `hnqzx`.`sys_dept`.`dept_id`))) `ccc`
where ((`ccc`.`package_id` is not null) and (`ccc`.`task_status` = 3) and (`ccc`.`enable_flag` = 0) and
       (`ccc`.`del_flag` = 0) and (`ccc`.`real_flag` = '0'))
order by `ccc`.`task_rule_id`, `ccc`.`task_user_id`, `ccc`.`lookinto_date`;

create definer = root@`%` view wm_zb_count_20210115 as
select distinct `ccc`.`package_id`              AS `package_id`,
                `ccc`.`score_name`              AS `score_name`,
                `ccc`.`score_id`                AS `score_id`,
                `ccc`.`package_score`           AS `package_score`,
                `ccc`.`send_package_dept_id`    AS `send_package_dept_id`,
                `ccc`.`pcreate_time`            AS `pcreate_time`,
                `ccc`.`realname`                AS `realname`,
                `ccc`.`idcard`                  AS `idcard`,
                `ccc`.`phone`                   AS `phone`,
                `ccc`.`dept_name`               AS `dept_name`,
                `ccc`.`user_id`                 AS `user_id`,
                `ccc`.`task_type_name`          AS `task_type_name`,
                `ccc`.`base_id`                 AS `base_id`,
                `ccc`.`id`                      AS `id`,
                `ccc`.`task_rule_id`            AS `task_rule_id`,
                `ccc`.`score`                   AS `score`,
                `ccc`.`score_package_drug_id`   AS `score_package_drug_id`,
                `ccc`.`score_package_level1_id` AS `score_package_level1_id`,
                `ccc`.`score_package_id`        AS `score_package_id`,
                `ccc`.`task_type_id`            AS `task_type_id`,
                `ccc`.`lookinto_date`           AS `lookinto_date`,
                `ccc`.`province`                AS `province`,
                `ccc`.`city`                    AS `city`,
                `ccc`.`area`                    AS `area`,
                `ccc`.`address`                 AS `address`,
                `ccc`.`lookinto_type_id`        AS `lookinto_type_id`,
                `ccc`.`task_content_id`         AS `task_content_id`,
                `ccc`.`task_status`             AS `task_status`,
                `ccc`.`task_user_id`            AS `task_user_id`,
                `ccc`.`task_user_type`          AS `task_user_type`,
                `ccc`.`drug_ent_id`             AS `drug_ent_id`,
                `ccc`.`dept_id`                 AS `dept_id`,
                `ccc`.`del_flag`                AS `del_flag`,
                `ccc`.`enable_flag`             AS `enable_flag`,
                `ccc`.`tenant_id`               AS `tenant_id`,
                `ccc`.`lookinto_date`           AS `create_time`,
                `ccc`.`create_user`             AS `create_user`,
                `ccc`.`update_time`             AS `update_time`,
                `ccc`.`update_user`             AS `update_user`,
                `ccc`.`submit_status`           AS `submit_status`,
                `ccc`.`share_img_url`           AS `share_img_url`,
                `ccc`.`plat_audit_status`       AS `plat_audit_status`,
                `ccc`.`ext_ids`                 AS `ext_ids`,
                `ccc`.`task_info_img`           AS `task_info_img`,
                `ccc`.`t_type`                  AS `t_type`
from (select `hnqzx`.`wm_score_package`.`id`                   AS `package_id`,
             `hnqzx`.`wm_score_package`.`score_name`           AS `score_name`,
             `hnqzx`.`wm_score_package`.`score`                AS `package_score`,
             `hnqzx`.`wm_score_package`.`send_package_dept_id` AS `send_package_dept_id`,
             `hnqzx`.`wm_score_package`.`score_id`             AS `score_id`,
             `hnqzx`.`wm_score_package`.`create_time`          AS `pcreate_time`,
             `hnqzx`.`sys_user`.`realname`                     AS `realname`,
             `hnqzx`.`sys_user`.`temp1`                        AS `idcard`,
             `hnqzx`.`sys_user`.`phone`                        AS `phone`,
             `hnqzx`.`sys_dept`.`name`                         AS `dept_name`,
             `hnqzx`.`sys_user`.`user_id`                      AS `user_id`,
             `hnqzx`.`wm_task_type`.`task_type_name`           AS `task_type_name`,
             `hnqzx`.`wm_task_type`.`base_id`                  AS `base_id`,
             `hnqzx`.`wm_task`.`id`                            AS `id`,
             `hnqzx`.`wm_task`.`task_rule_id`                  AS `task_rule_id`,
             `hnqzx`.`wm_task`.`score`                         AS `score`,
             `hnqzx`.`wm_task`.`score_package_drug_id`         AS `score_package_drug_id`,
             `hnqzx`.`wm_task`.`score_package_level1_id`       AS `score_package_level1_id`,
             `hnqzx`.`wm_task`.`score_package_id`              AS `score_package_id`,
             `hnqzx`.`wm_task`.`task_type_id`                  AS `task_type_id`,
             `hnqzx`.`wm_task`.`lookinto_date`                 AS `lookinto_date`,
             `hnqzx`.`wm_task`.`province`                      AS `province`,
             `hnqzx`.`wm_task`.`city`                          AS `city`,
             `hnqzx`.`wm_task`.`area`                          AS `area`,
             `hnqzx`.`wm_task`.`address`                       AS `address`,
             `hnqzx`.`wm_task`.`lookinto_type_id`              AS `lookinto_type_id`,
             `hnqzx`.`wm_task`.`task_content_id`               AS `task_content_id`,
             `hnqzx`.`wm_task`.`task_status`                   AS `task_status`,
             `hnqzx`.`wm_task`.`task_user_id`                  AS `task_user_id`,
             `hnqzx`.`wm_task`.`task_user_type`                AS `task_user_type`,
             `hnqzx`.`wm_task`.`drug_ent_id`                   AS `drug_ent_id`,
             `hnqzx`.`wm_task`.`dept_id`                       AS `dept_id`,
             `hnqzx`.`wm_task`.`del_flag`                      AS `del_flag`,
             `hnqzx`.`wm_task`.`enable_flag`                   AS `enable_flag`,
             `hnqzx`.`wm_task`.`tenant_id`                     AS `tenant_id`,
             `hnqzx`.`wm_task`.`lookinto_date`                 AS `create_time`,
             `hnqzx`.`wm_task`.`create_user`                   AS `create_user`,
             `hnqzx`.`wm_task`.`update_time`                   AS `update_time`,
             `hnqzx`.`wm_task`.`update_user`                   AS `update_user`,
             `hnqzx`.`wm_task`.`submit_status`                 AS `submit_status`,
             `hnqzx`.`wm_task`.`share_img_url`                 AS `share_img_url`,
             `hnqzx`.`wm_task`.`plat_audit_status`             AS `plat_audit_status`,
             `hnqzx`.`wm_task`.`ext_ids`                       AS `ext_ids`,
             `hnqzx`.`wm_task`.`task_info_img`                 AS `task_info_img`,
             1                                                 AS `t_type`
      from ((((`hnqzx`.`wm_task` left join `hnqzx`.`wm_score_package` on ((`hnqzx`.`wm_task`.`score_package_id` =
                                                                           `hnqzx`.`wm_score_package`.`id`))) join `hnqzx`.`wm_task_type`) join `hnqzx`.`sys_user`) join `hnqzx`.`sys_dept`)
      where ((`hnqzx`.`wm_task_type`.`id` = `hnqzx`.`wm_task`.`task_type_id`) and
             (`hnqzx`.`sys_user`.`user_id` = `hnqzx`.`wm_task`.`task_user_id`) and
             (`hnqzx`.`sys_user`.`dept_id` = `hnqzx`.`sys_dept`.`dept_id`))
      union
      select `hnqzx`.`wm_task`.`score_package_drug_id`         AS `package_id`,
             `hnqzx`.`wm_score_package`.`score_name`           AS `score_name`,
             `hnqzx`.`wm_score_package`.`score`                AS `package_score`,
             `hnqzx`.`wm_score_package`.`send_package_dept_id` AS `send_package_dept_id`,
             `hnqzx`.`wm_score_package`.`score_id`             AS `score_id`,
             `hnqzx`.`wm_score_package`.`create_time`          AS `pcreate_time`,
             `hnqzx`.`sys_user`.`realname`                     AS `realname`,
             `hnqzx`.`sys_user`.`temp1`                        AS `idcard`,
             `hnqzx`.`sys_user`.`phone`                        AS `phone`,
             `hnqzx`.`sys_dept`.`name`                         AS `dept_name`,
             `hnqzx`.`sys_user`.`user_id`                      AS `user_id`,
             `hnqzx`.`wm_task_type`.`task_type_name`           AS `task_type_name`,
             `hnqzx`.`wm_task_type`.`base_id`                  AS `base_id`,
             `hnqzx`.`wm_task`.`id`                            AS `id`,
             `hnqzx`.`wm_task`.`task_rule_id`                  AS `task_rule_id`,
             `hnqzx`.`wm_task`.`score`                         AS `score`,
             `hnqzx`.`wm_task`.`score_package_drug_id`         AS `score_package_drug_id`,
             `hnqzx`.`wm_task`.`score_package_level1_id`       AS `score_package_level1_id`,
             `hnqzx`.`wm_task`.`score_package_id`              AS `score_package_id`,
             `hnqzx`.`wm_task`.`task_type_id`                  AS `task_type_id`,
             `hnqzx`.`wm_task`.`lookinto_date`                 AS `lookinto_date`,
             `hnqzx`.`wm_task`.`province`                      AS `province`,
             `hnqzx`.`wm_task`.`city`                          AS `city`,
             `hnqzx`.`wm_task`.`area`                          AS `area`,
             `hnqzx`.`wm_task`.`address`                       AS `address`,
             `hnqzx`.`wm_task`.`lookinto_type_id`              AS `lookinto_type_id`,
             `hnqzx`.`wm_task`.`task_content_id`               AS `task_content_id`,
             `hnqzx`.`wm_task`.`task_status`                   AS `task_status`,
             `hnqzx`.`wm_task`.`task_user_id`                  AS `task_user_id`,
             `hnqzx`.`wm_task`.`task_user_type`                AS `task_user_type`,
             `hnqzx`.`wm_task`.`drug_ent_id`                   AS `drug_ent_id`,
             `hnqzx`.`wm_task`.`dept_id`                       AS `dept_id`,
             `hnqzx`.`wm_task`.`del_flag`                      AS `del_flag`,
             `hnqzx`.`wm_task`.`enable_flag`                   AS `enable_flag`,
             `hnqzx`.`wm_task`.`tenant_id`                     AS `tenant_id`,
             `hnqzx`.`wm_task`.`lookinto_date`                 AS `create_time`,
             `hnqzx`.`wm_task`.`create_user`                   AS `create_user`,
             `hnqzx`.`wm_task`.`update_time`                   AS `update_time`,
             `hnqzx`.`wm_task`.`update_user`                   AS `update_user`,
             `hnqzx`.`wm_task`.`submit_status`                 AS `submit_status`,
             `hnqzx`.`wm_task`.`share_img_url`                 AS `share_img_url`,
             `hnqzx`.`wm_task`.`plat_audit_status`             AS `plat_audit_status`,
             `hnqzx`.`wm_task`.`ext_ids`                       AS `ext_ids`,
             `hnqzx`.`wm_task`.`task_info_img`                 AS `task_info_img`,
             2                                                 AS `t_type`
      from ((((`hnqzx`.`wm_task` left join `hnqzx`.`wm_score_package` on ((`hnqzx`.`wm_task`.`score_package_drug_id` =
                                                                           `hnqzx`.`wm_score_package`.`id`))) join `hnqzx`.`wm_task_type`) join `hnqzx`.`sys_user`) join `hnqzx`.`sys_dept`)
      where ((`hnqzx`.`wm_task_type`.`id` = `hnqzx`.`wm_task`.`task_type_id`) and
             (`hnqzx`.`sys_user`.`user_id` = `hnqzx`.`wm_task`.`task_user_id`) and
             (`hnqzx`.`sys_user`.`dept_id` = `hnqzx`.`sys_dept`.`dept_id`))
      union
      select `hnqzx`.`wm_task`.`score_package_level1_id`       AS `package_id`,
             `hnqzx`.`wm_score_package`.`score_name`           AS `score_name`,
             `hnqzx`.`wm_score_package`.`score`                AS `package_score`,
             `hnqzx`.`wm_score_package`.`send_package_dept_id` AS `send_package_dept_id`,
             `hnqzx`.`wm_score_package`.`score_id`             AS `score_id`,
             `hnqzx`.`wm_score_package`.`create_time`          AS `pcreate_time`,
             `hnqzx`.`sys_user`.`realname`                     AS `realname`,
             `hnqzx`.`sys_user`.`temp1`                        AS `idcard`,
             `hnqzx`.`sys_user`.`phone`                        AS `phone`,
             `hnqzx`.`sys_dept`.`name`                         AS `dept_name`,
             `hnqzx`.`sys_user`.`user_id`                      AS `user_id`,
             `hnqzx`.`wm_task_type`.`task_type_name`           AS `task_type_name`,
             `hnqzx`.`wm_task_type`.`base_id`                  AS `base_id`,
             `hnqzx`.`wm_task`.`id`                            AS `id`,
             `hnqzx`.`wm_task`.`task_rule_id`                  AS `task_rule_id`,
             `hnqzx`.`wm_task`.`score`                         AS `score`,
             `hnqzx`.`wm_task`.`score_package_drug_id`         AS `score_package_drug_id`,
             `hnqzx`.`wm_task`.`score_package_level1_id`       AS `score_package_level1_id`,
             `hnqzx`.`wm_task`.`score_package_id`              AS `score_package_id`,
             `hnqzx`.`wm_task`.`task_type_id`                  AS `task_type_id`,
             `hnqzx`.`wm_task`.`lookinto_date`                 AS `lookinto_date`,
             `hnqzx`.`wm_task`.`province`                      AS `province`,
             `hnqzx`.`wm_task`.`city`                          AS `city`,
             `hnqzx`.`wm_task`.`area`                          AS `area`,
             `hnqzx`.`wm_task`.`address`                       AS `address`,
             `hnqzx`.`wm_task`.`lookinto_type_id`              AS `lookinto_type_id`,
             `hnqzx`.`wm_task`.`task_content_id`               AS `task_content_id`,
             `hnqzx`.`wm_task`.`task_status`                   AS `task_status`,
             `hnqzx`.`wm_task`.`task_user_id`                  AS `task_user_id`,
             `hnqzx`.`wm_task`.`task_user_type`                AS `task_user_type`,
             `hnqzx`.`wm_task`.`drug_ent_id`                   AS `drug_ent_id`,
             `hnqzx`.`wm_task`.`dept_id`                       AS `dept_id`,
             `hnqzx`.`wm_task`.`del_flag`                      AS `del_flag`,
             `hnqzx`.`wm_task`.`enable_flag`                   AS `enable_flag`,
             `hnqzx`.`wm_task`.`tenant_id`                     AS `tenant_id`,
             `hnqzx`.`wm_task`.`lookinto_date`                 AS `create_time`,
             `hnqzx`.`wm_task`.`create_user`                   AS `create_user`,
             `hnqzx`.`wm_task`.`update_time`                   AS `update_time`,
             `hnqzx`.`wm_task`.`update_user`                   AS `update_user`,
             `hnqzx`.`wm_task`.`submit_status`                 AS `submit_status`,
             `hnqzx`.`wm_task`.`share_img_url`                 AS `share_img_url`,
             `hnqzx`.`wm_task`.`plat_audit_status`             AS `plat_audit_status`,
             `hnqzx`.`wm_task`.`ext_ids`                       AS `ext_ids`,
             `hnqzx`.`wm_task`.`task_info_img`                 AS `task_info_img`,
             3                                                 AS `t_type`
      from ((((`hnqzx`.`wm_task` left join `hnqzx`.`wm_score_package` on ((`hnqzx`.`wm_task`.`score_package_level1_id` =
                                                                           `hnqzx`.`wm_score_package`.`id`))) join `hnqzx`.`wm_task_type`) join `hnqzx`.`sys_user`) join `hnqzx`.`sys_dept`)
      where ((`hnqzx`.`wm_task_type`.`id` = `hnqzx`.`wm_task`.`task_type_id`) and
             (`hnqzx`.`sys_user`.`user_id` = `hnqzx`.`wm_task`.`task_user_id`) and
             (`hnqzx`.`sys_user`.`dept_id` = `hnqzx`.`sys_dept`.`dept_id`))) `ccc`
where ((`ccc`.`package_id` is not null) and (`ccc`.`task_status` = 3) and (`ccc`.`enable_flag` = 0) and
       (`ccc`.`del_flag` = 0))
order by `ccc`.`task_rule_id`, `ccc`.`task_user_id`, `ccc`.`lookinto_date`;

create definer = root@`%` view wm_zb_count_copy as
select distinct `ccc`.`package_id`              AS `package_id`,
                `ccc`.`score_name`              AS `score_name`,
                `ccc`.`score_id`                AS `score_id`,
                `ccc`.`package_score`           AS `package_score`,
                `ccc`.`send_package_dept_id`    AS `send_package_dept_id`,
                `ccc`.`pcreate_time`            AS `pcreate_time`,
                `ccc`.`realname`                AS `realname`,
                `ccc`.`idcard`                  AS `idcard`,
                `ccc`.`phone`                   AS `phone`,
                `ccc`.`dept_name`               AS `dept_name`,
                `ccc`.`user_id`                 AS `user_id`,
                `ccc`.`task_type_name`          AS `task_type_name`,
                `ccc`.`base_id`                 AS `base_id`,
                `ccc`.`id`                      AS `id`,
                `ccc`.`task_rule_id`            AS `task_rule_id`,
                `ccc`.`score`                   AS `score`,
                `ccc`.`score_package_drug_id`   AS `score_package_drug_id`,
                `ccc`.`score_package_level1_id` AS `score_package_level1_id`,
                `ccc`.`score_package_id`        AS `score_package_id`,
                `ccc`.`task_type_id`            AS `task_type_id`,
                `ccc`.`lookinto_date`           AS `lookinto_date`,
                `ccc`.`province`                AS `province`,
                `ccc`.`city`                    AS `city`,
                `ccc`.`area`                    AS `area`,
                `ccc`.`address`                 AS `address`,
                `ccc`.`lookinto_type_id`        AS `lookinto_type_id`,
                `ccc`.`task_content_id`         AS `task_content_id`,
                `ccc`.`task_status`             AS `task_status`,
                `ccc`.`task_user_id`            AS `task_user_id`,
                `ccc`.`task_user_type`          AS `task_user_type`,
                `ccc`.`drug_ent_id`             AS `drug_ent_id`,
                `ccc`.`dept_id`                 AS `dept_id`,
                `ccc`.`del_flag`                AS `del_flag`,
                `ccc`.`enable_flag`             AS `enable_flag`,
                `ccc`.`tenant_id`               AS `tenant_id`,
                `ccc`.`lookinto_date`           AS `create_time`,
                `ccc`.`create_user`             AS `create_user`,
                `ccc`.`update_time`             AS `update_time`,
                `ccc`.`update_user`             AS `update_user`,
                `ccc`.`submit_status`           AS `submit_status`,
                `ccc`.`share_img_url`           AS `share_img_url`,
                `ccc`.`plat_audit_status`       AS `plat_audit_status`,
                `ccc`.`ext_ids`                 AS `ext_ids`,
                `ccc`.`task_info_img`           AS `task_info_img`,
                `ccc`.`t_type`                  AS `t_type`
from (select `hnqzx`.`wm_score_package`.`id`                   AS `package_id`,
             `hnqzx`.`wm_score_package`.`score_name`           AS `score_name`,
             `hnqzx`.`wm_score_package`.`score`                AS `package_score`,
             `hnqzx`.`wm_score_package`.`send_package_dept_id` AS `send_package_dept_id`,
             `hnqzx`.`wm_score_package`.`score_id`             AS `score_id`,
             `hnqzx`.`wm_score_package`.`create_time`          AS `pcreate_time`,
             `hnqzx`.`sys_user`.`realname`                     AS `realname`,
             `hnqzx`.`sys_user`.`temp1`                        AS `idcard`,
             `hnqzx`.`sys_user`.`phone`                        AS `phone`,
             `hnqzx`.`sys_dept`.`name`                         AS `dept_name`,
             `hnqzx`.`sys_user`.`user_id`                      AS `user_id`,
             `hnqzx`.`wm_task_type`.`task_type_name`           AS `task_type_name`,
             `hnqzx`.`wm_task_type`.`base_id`                  AS `base_id`,
             `hnqzx`.`wm_task`.`id`                            AS `id`,
             `hnqzx`.`wm_task`.`task_rule_id`                  AS `task_rule_id`,
             `hnqzx`.`wm_task`.`score`                         AS `score`,
             `hnqzx`.`wm_task`.`score_package_drug_id`         AS `score_package_drug_id`,
             `hnqzx`.`wm_task`.`score_package_level1_id`       AS `score_package_level1_id`,
             `hnqzx`.`wm_task`.`score_package_id`              AS `score_package_id`,
             `hnqzx`.`wm_task`.`task_type_id`                  AS `task_type_id`,
             `hnqzx`.`wm_task`.`lookinto_date`                 AS `lookinto_date`,
             `hnqzx`.`wm_task`.`province`                      AS `province`,
             `hnqzx`.`wm_task`.`city`                          AS `city`,
             `hnqzx`.`wm_task`.`area`                          AS `area`,
             `hnqzx`.`wm_task`.`address`                       AS `address`,
             `hnqzx`.`wm_task`.`lookinto_type_id`              AS `lookinto_type_id`,
             `hnqzx`.`wm_task`.`task_content_id`               AS `task_content_id`,
             `hnqzx`.`wm_task`.`task_status`                   AS `task_status`,
             `hnqzx`.`wm_task`.`task_user_id`                  AS `task_user_id`,
             `hnqzx`.`wm_task`.`task_user_type`                AS `task_user_type`,
             `hnqzx`.`wm_task`.`drug_ent_id`                   AS `drug_ent_id`,
             `hnqzx`.`wm_task`.`dept_id`                       AS `dept_id`,
             `hnqzx`.`wm_task`.`del_flag`                      AS `del_flag`,
             `hnqzx`.`wm_task`.`enable_flag`                   AS `enable_flag`,
             `hnqzx`.`wm_task`.`tenant_id`                     AS `tenant_id`,
             `hnqzx`.`wm_task`.`lookinto_date`                 AS `create_time`,
             `hnqzx`.`wm_task`.`create_user`                   AS `create_user`,
             `hnqzx`.`wm_task`.`update_time`                   AS `update_time`,
             `hnqzx`.`wm_task`.`update_user`                   AS `update_user`,
             `hnqzx`.`wm_task`.`submit_status`                 AS `submit_status`,
             `hnqzx`.`wm_task`.`share_img_url`                 AS `share_img_url`,
             `hnqzx`.`wm_task`.`plat_audit_status`             AS `plat_audit_status`,
             `hnqzx`.`wm_task`.`ext_ids`                       AS `ext_ids`,
             `hnqzx`.`wm_task`.`task_info_img`                 AS `task_info_img`,
             1                                                 AS `t_type`
      from ((((`hnqzx`.`wm_task` left join `hnqzx`.`wm_score_package` on ((`hnqzx`.`wm_task`.`score_package_id` =
                                                                           `hnqzx`.`wm_score_package`.`id`))) join `hnqzx`.`wm_task_type`) join `hnqzx`.`sys_user`) join `hnqzx`.`sys_dept`)
      where ((`hnqzx`.`wm_task_type`.`id` = `hnqzx`.`wm_task`.`task_type_id`) and
             (`hnqzx`.`sys_user`.`user_id` = `hnqzx`.`wm_task`.`task_user_id`) and
             (`hnqzx`.`sys_user`.`dept_id` = `hnqzx`.`sys_dept`.`dept_id`))
      union
      select `hnqzx`.`wm_task`.`score_package_drug_id`         AS `package_id`,
             `hnqzx`.`wm_score_package`.`score_name`           AS `score_name`,
             `hnqzx`.`wm_score_package`.`score`                AS `package_score`,
             `hnqzx`.`wm_score_package`.`send_package_dept_id` AS `send_package_dept_id`,
             `hnqzx`.`wm_score_package`.`score_id`             AS `score_id`,
             `hnqzx`.`wm_score_package`.`create_time`          AS `pcreate_time`,
             `hnqzx`.`sys_user`.`realname`                     AS `realname`,
             `hnqzx`.`sys_user`.`temp1`                        AS `idcard`,
             `hnqzx`.`sys_user`.`phone`                        AS `phone`,
             `hnqzx`.`sys_dept`.`name`                         AS `dept_name`,
             `hnqzx`.`sys_user`.`user_id`                      AS `user_id`,
             `hnqzx`.`wm_task_type`.`task_type_name`           AS `task_type_name`,
             `hnqzx`.`wm_task_type`.`base_id`                  AS `base_id`,
             `hnqzx`.`wm_task`.`id`                            AS `id`,
             `hnqzx`.`wm_task`.`task_rule_id`                  AS `task_rule_id`,
             `hnqzx`.`wm_task`.`score`                         AS `score`,
             `hnqzx`.`wm_task`.`score_package_drug_id`         AS `score_package_drug_id`,
             `hnqzx`.`wm_task`.`score_package_level1_id`       AS `score_package_level1_id`,
             `hnqzx`.`wm_task`.`score_package_id`              AS `score_package_id`,
             `hnqzx`.`wm_task`.`task_type_id`                  AS `task_type_id`,
             `hnqzx`.`wm_task`.`lookinto_date`                 AS `lookinto_date`,
             `hnqzx`.`wm_task`.`province`                      AS `province`,
             `hnqzx`.`wm_task`.`city`                          AS `city`,
             `hnqzx`.`wm_task`.`area`                          AS `area`,
             `hnqzx`.`wm_task`.`address`                       AS `address`,
             `hnqzx`.`wm_task`.`lookinto_type_id`              AS `lookinto_type_id`,
             `hnqzx`.`wm_task`.`task_content_id`               AS `task_content_id`,
             `hnqzx`.`wm_task`.`task_status`                   AS `task_status`,
             `hnqzx`.`wm_task`.`task_user_id`                  AS `task_user_id`,
             `hnqzx`.`wm_task`.`task_user_type`                AS `task_user_type`,
             `hnqzx`.`wm_task`.`drug_ent_id`                   AS `drug_ent_id`,
             `hnqzx`.`wm_task`.`dept_id`                       AS `dept_id`,
             `hnqzx`.`wm_task`.`del_flag`                      AS `del_flag`,
             `hnqzx`.`wm_task`.`enable_flag`                   AS `enable_flag`,
             `hnqzx`.`wm_task`.`tenant_id`                     AS `tenant_id`,
             `hnqzx`.`wm_task`.`lookinto_date`                 AS `create_time`,
             `hnqzx`.`wm_task`.`create_user`                   AS `create_user`,
             `hnqzx`.`wm_task`.`update_time`                   AS `update_time`,
             `hnqzx`.`wm_task`.`update_user`                   AS `update_user`,
             `hnqzx`.`wm_task`.`submit_status`                 AS `submit_status`,
             `hnqzx`.`wm_task`.`share_img_url`                 AS `share_img_url`,
             `hnqzx`.`wm_task`.`plat_audit_status`             AS `plat_audit_status`,
             `hnqzx`.`wm_task`.`ext_ids`                       AS `ext_ids`,
             `hnqzx`.`wm_task`.`task_info_img`                 AS `task_info_img`,
             2                                                 AS `t_type`
      from ((((`hnqzx`.`wm_task` left join `hnqzx`.`wm_score_package` on ((`hnqzx`.`wm_task`.`score_package_drug_id` =
                                                                           `hnqzx`.`wm_score_package`.`id`))) join `hnqzx`.`wm_task_type`) join `hnqzx`.`sys_user`) join `hnqzx`.`sys_dept`)
      where ((`hnqzx`.`wm_task_type`.`id` = `hnqzx`.`wm_task`.`task_type_id`) and
             (`hnqzx`.`sys_user`.`user_id` = `hnqzx`.`wm_task`.`task_user_id`) and
             (`hnqzx`.`sys_user`.`dept_id` = `hnqzx`.`sys_dept`.`dept_id`))
      union
      select `hnqzx`.`wm_task`.`score_package_level1_id`       AS `package_id`,
             `hnqzx`.`wm_score_package`.`score_name`           AS `score_name`,
             `hnqzx`.`wm_score_package`.`score`                AS `package_score`,
             `hnqzx`.`wm_score_package`.`send_package_dept_id` AS `send_package_dept_id`,
             `hnqzx`.`wm_score_package`.`score_id`             AS `score_id`,
             `hnqzx`.`wm_score_package`.`create_time`          AS `pcreate_time`,
             `hnqzx`.`sys_user`.`realname`                     AS `realname`,
             `hnqzx`.`sys_user`.`temp1`                        AS `idcard`,
             `hnqzx`.`sys_user`.`phone`                        AS `phone`,
             `hnqzx`.`sys_dept`.`name`                         AS `dept_name`,
             `hnqzx`.`sys_user`.`user_id`                      AS `user_id`,
             `hnqzx`.`wm_task_type`.`task_type_name`           AS `task_type_name`,
             `hnqzx`.`wm_task_type`.`base_id`                  AS `base_id`,
             `hnqzx`.`wm_task`.`id`                            AS `id`,
             `hnqzx`.`wm_task`.`task_rule_id`                  AS `task_rule_id`,
             `hnqzx`.`wm_task`.`score`                         AS `score`,
             `hnqzx`.`wm_task`.`score_package_drug_id`         AS `score_package_drug_id`,
             `hnqzx`.`wm_task`.`score_package_level1_id`       AS `score_package_level1_id`,
             `hnqzx`.`wm_task`.`score_package_id`              AS `score_package_id`,
             `hnqzx`.`wm_task`.`task_type_id`                  AS `task_type_id`,
             `hnqzx`.`wm_task`.`lookinto_date`                 AS `lookinto_date`,
             `hnqzx`.`wm_task`.`province`                      AS `province`,
             `hnqzx`.`wm_task`.`city`                          AS `city`,
             `hnqzx`.`wm_task`.`area`                          AS `area`,
             `hnqzx`.`wm_task`.`address`                       AS `address`,
             `hnqzx`.`wm_task`.`lookinto_type_id`              AS `lookinto_type_id`,
             `hnqzx`.`wm_task`.`task_content_id`               AS `task_content_id`,
             `hnqzx`.`wm_task`.`task_status`                   AS `task_status`,
             `hnqzx`.`wm_task`.`task_user_id`                  AS `task_user_id`,
             `hnqzx`.`wm_task`.`task_user_type`                AS `task_user_type`,
             `hnqzx`.`wm_task`.`drug_ent_id`                   AS `drug_ent_id`,
             `hnqzx`.`wm_task`.`dept_id`                       AS `dept_id`,
             `hnqzx`.`wm_task`.`del_flag`                      AS `del_flag`,
             `hnqzx`.`wm_task`.`enable_flag`                   AS `enable_flag`,
             `hnqzx`.`wm_task`.`tenant_id`                     AS `tenant_id`,
             `hnqzx`.`wm_task`.`lookinto_date`                 AS `create_time`,
             `hnqzx`.`wm_task`.`create_user`                   AS `create_user`,
             `hnqzx`.`wm_task`.`update_time`                   AS `update_time`,
             `hnqzx`.`wm_task`.`update_user`                   AS `update_user`,
             `hnqzx`.`wm_task`.`submit_status`                 AS `submit_status`,
             `hnqzx`.`wm_task`.`share_img_url`                 AS `share_img_url`,
             `hnqzx`.`wm_task`.`plat_audit_status`             AS `plat_audit_status`,
             `hnqzx`.`wm_task`.`ext_ids`                       AS `ext_ids`,
             `hnqzx`.`wm_task`.`task_info_img`                 AS `task_info_img`,
             3                                                 AS `t_type`
      from ((((`hnqzx`.`wm_task` left join `hnqzx`.`wm_score_package` on ((`hnqzx`.`wm_task`.`score_package_level1_id` =
                                                                           `hnqzx`.`wm_score_package`.`id`))) join `hnqzx`.`wm_task_type`) join `hnqzx`.`sys_user`) join `hnqzx`.`sys_dept`)
      where ((`hnqzx`.`wm_task_type`.`id` = `hnqzx`.`wm_task`.`task_type_id`) and
             (`hnqzx`.`sys_user`.`user_id` = `hnqzx`.`wm_task`.`task_user_id`) and
             (`hnqzx`.`sys_user`.`dept_id` = `hnqzx`.`sys_dept`.`dept_id`))) `ccc`
where ((`ccc`.`package_id` is not null) and (`ccc`.`task_status` = 3) and (`ccc`.`enable_flag` = 0) and
       (`ccc`.`del_flag` = 0))
order by `ccc`.`task_rule_id`, `ccc`.`task_user_id`, `ccc`.`lookinto_date`;

create definer = root@`%` view wm_zb_count_copy1 as
select distinct `ccc`.`package_id`              AS `package_id`,
                `ccc`.`score_name`              AS `score_name`,
                `ccc`.`score_id`                AS `score_id`,
                `ccc`.`package_score`           AS `package_score`,
                `ccc`.`send_package_dept_id`    AS `send_package_dept_id`,
                `ccc`.`realname`                AS `realname`,
                `ccc`.`idcard`                  AS `idcard`,
                `ccc`.`phone`                   AS `phone`,
                `ccc`.`dept_name`               AS `dept_name`,
                `ccc`.`user_id`                 AS `user_id`,
                `ccc`.`task_type_name`          AS `task_type_name`,
                `ccc`.`base_id`                 AS `base_id`,
                `ccc`.`id`                      AS `id`,
                `ccc`.`task_rule_id`            AS `task_rule_id`,
                `ccc`.`score`                   AS `score`,
                `ccc`.`score_package_drug_id`   AS `score_package_drug_id`,
                `ccc`.`score_package_level1_id` AS `score_package_level1_id`,
                `ccc`.`score_package_id`        AS `score_package_id`,
                `ccc`.`task_type_id`            AS `task_type_id`,
                `ccc`.`lookinto_date`           AS `lookinto_date`,
                `ccc`.`province`                AS `province`,
                `ccc`.`city`                    AS `city`,
                `ccc`.`area`                    AS `area`,
                `ccc`.`address`                 AS `address`,
                `ccc`.`lookinto_type_id`        AS `lookinto_type_id`,
                `ccc`.`task_content_id`         AS `task_content_id`,
                `ccc`.`task_status`             AS `task_status`,
                `ccc`.`task_user_id`            AS `task_user_id`,
                `ccc`.`task_user_type`          AS `task_user_type`,
                `ccc`.`drug_ent_id`             AS `drug_ent_id`,
                `ccc`.`dept_id`                 AS `dept_id`,
                `ccc`.`del_flag`                AS `del_flag`,
                `ccc`.`enable_flag`             AS `enable_flag`,
                `ccc`.`tenant_id`               AS `tenant_id`,
                `ccc`.`create_time`             AS `create_time`,
                `ccc`.`create_user`             AS `create_user`,
                `ccc`.`update_time`             AS `update_time`,
                `ccc`.`update_user`             AS `update_user`,
                `ccc`.`submit_status`           AS `submit_status`,
                `ccc`.`share_img_url`           AS `share_img_url`,
                `ccc`.`plat_audit_status`       AS `plat_audit_status`,
                `ccc`.`ext_ids`                 AS `ext_ids`,
                `ccc`.`task_info_img`           AS `task_info_img`,
                `ccc`.`t_type`                  AS `t_type`
from (select `hnqzx`.`wm_score_package`.`id`                   AS `package_id`,
             `hnqzx`.`wm_score_package`.`score_name`           AS `score_name`,
             `hnqzx`.`wm_score_package`.`score`                AS `package_score`,
             `hnqzx`.`wm_score_package`.`send_package_dept_id` AS `send_package_dept_id`,
             `hnqzx`.`wm_score_package`.`score_id`             AS `score_id`,
             `hnqzx`.`sys_user`.`realname`                     AS `realname`,
             `hnqzx`.`sys_user`.`temp1`                        AS `idcard`,
             `hnqzx`.`sys_user`.`phone`                        AS `phone`,
             `hnqzx`.`sys_dept`.`name`                         AS `dept_name`,
             `hnqzx`.`sys_user`.`user_id`                      AS `user_id`,
             `hnqzx`.`wm_task_type`.`task_type_name`           AS `task_type_name`,
             `hnqzx`.`wm_task_type`.`base_id`                  AS `base_id`,
             `hnqzx`.`wm_task`.`id`                            AS `id`,
             `hnqzx`.`wm_task`.`task_rule_id`                  AS `task_rule_id`,
             `hnqzx`.`wm_task`.`score`                         AS `score`,
             `hnqzx`.`wm_task`.`score_package_drug_id`         AS `score_package_drug_id`,
             `hnqzx`.`wm_task`.`score_package_level1_id`       AS `score_package_level1_id`,
             `hnqzx`.`wm_task`.`score_package_id`              AS `score_package_id`,
             `hnqzx`.`wm_task`.`task_type_id`                  AS `task_type_id`,
             `hnqzx`.`wm_task`.`lookinto_date`                 AS `lookinto_date`,
             `hnqzx`.`wm_task`.`province`                      AS `province`,
             `hnqzx`.`wm_task`.`city`                          AS `city`,
             `hnqzx`.`wm_task`.`area`                          AS `area`,
             `hnqzx`.`wm_task`.`address`                       AS `address`,
             `hnqzx`.`wm_task`.`lookinto_type_id`              AS `lookinto_type_id`,
             `hnqzx`.`wm_task`.`task_content_id`               AS `task_content_id`,
             `hnqzx`.`wm_task`.`task_status`                   AS `task_status`,
             `hnqzx`.`wm_task`.`task_user_id`                  AS `task_user_id`,
             `hnqzx`.`wm_task`.`task_user_type`                AS `task_user_type`,
             `hnqzx`.`wm_task`.`drug_ent_id`                   AS `drug_ent_id`,
             `hnqzx`.`wm_task`.`dept_id`                       AS `dept_id`,
             `hnqzx`.`wm_task`.`del_flag`                      AS `del_flag`,
             `hnqzx`.`wm_task`.`enable_flag`                   AS `enable_flag`,
             `hnqzx`.`wm_task`.`tenant_id`                     AS `tenant_id`,
             `hnqzx`.`wm_task`.`create_time`                   AS `create_time`,
             `hnqzx`.`wm_task`.`create_user`                   AS `create_user`,
             `hnqzx`.`wm_task`.`update_time`                   AS `update_time`,
             `hnqzx`.`wm_task`.`update_user`                   AS `update_user`,
             `hnqzx`.`wm_task`.`submit_status`                 AS `submit_status`,
             `hnqzx`.`wm_task`.`share_img_url`                 AS `share_img_url`,
             `hnqzx`.`wm_task`.`plat_audit_status`             AS `plat_audit_status`,
             `hnqzx`.`wm_task`.`ext_ids`                       AS `ext_ids`,
             `hnqzx`.`wm_task`.`task_info_img`                 AS `task_info_img`,
             1                                                 AS `t_type`
      from ((((`hnqzx`.`wm_task` left join `hnqzx`.`wm_score_package` on ((`hnqzx`.`wm_task`.`score_package_id` =
                                                                           `hnqzx`.`wm_score_package`.`id`))) join `hnqzx`.`wm_task_type`) join `hnqzx`.`sys_user`) join `hnqzx`.`sys_dept`)
      where ((`hnqzx`.`wm_task_type`.`id` = `hnqzx`.`wm_task`.`task_type_id`) and
             (`hnqzx`.`sys_user`.`user_id` = `hnqzx`.`wm_task`.`task_user_id`) and
             (`hnqzx`.`sys_user`.`dept_id` = `hnqzx`.`sys_dept`.`dept_id`))
      union
      select `hnqzx`.`wm_task`.`score_package_drug_id`         AS `package_id`,
             `hnqzx`.`wm_score_package`.`score_name`           AS `score_name`,
             `hnqzx`.`wm_score_package`.`score`                AS `package_score`,
             `hnqzx`.`wm_score_package`.`send_package_dept_id` AS `send_package_dept_id`,
             `hnqzx`.`wm_score_package`.`score_id`             AS `score_id`,
             `hnqzx`.`sys_user`.`realname`                     AS `realname`,
             `hnqzx`.`sys_user`.`temp1`                        AS `idcard`,
             `hnqzx`.`sys_user`.`phone`                        AS `phone`,
             `hnqzx`.`sys_dept`.`name`                         AS `dept_name`,
             `hnqzx`.`sys_user`.`user_id`                      AS `user_id`,
             `hnqzx`.`wm_task_type`.`task_type_name`           AS `task_type_name`,
             `hnqzx`.`wm_task_type`.`base_id`                  AS `base_id`,
             `hnqzx`.`wm_task`.`id`                            AS `id`,
             `hnqzx`.`wm_task`.`task_rule_id`                  AS `task_rule_id`,
             `hnqzx`.`wm_task`.`score`                         AS `score`,
             `hnqzx`.`wm_task`.`score_package_drug_id`         AS `score_package_drug_id`,
             `hnqzx`.`wm_task`.`score_package_level1_id`       AS `score_package_level1_id`,
             `hnqzx`.`wm_task`.`score_package_id`              AS `score_package_id`,
             `hnqzx`.`wm_task`.`task_type_id`                  AS `task_type_id`,
             `hnqzx`.`wm_task`.`lookinto_date`                 AS `lookinto_date`,
             `hnqzx`.`wm_task`.`province`                      AS `province`,
             `hnqzx`.`wm_task`.`city`                          AS `city`,
             `hnqzx`.`wm_task`.`area`                          AS `area`,
             `hnqzx`.`wm_task`.`address`                       AS `address`,
             `hnqzx`.`wm_task`.`lookinto_type_id`              AS `lookinto_type_id`,
             `hnqzx`.`wm_task`.`task_content_id`               AS `task_content_id`,
             `hnqzx`.`wm_task`.`task_status`                   AS `task_status`,
             `hnqzx`.`wm_task`.`task_user_id`                  AS `task_user_id`,
             `hnqzx`.`wm_task`.`task_user_type`                AS `task_user_type`,
             `hnqzx`.`wm_task`.`drug_ent_id`                   AS `drug_ent_id`,
             `hnqzx`.`wm_task`.`dept_id`                       AS `dept_id`,
             `hnqzx`.`wm_task`.`del_flag`                      AS `del_flag`,
             `hnqzx`.`wm_task`.`enable_flag`                   AS `enable_flag`,
             `hnqzx`.`wm_task`.`tenant_id`                     AS `tenant_id`,
             `hnqzx`.`wm_task`.`create_time`                   AS `create_time`,
             `hnqzx`.`wm_task`.`create_user`                   AS `create_user`,
             `hnqzx`.`wm_task`.`update_time`                   AS `update_time`,
             `hnqzx`.`wm_task`.`update_user`                   AS `update_user`,
             `hnqzx`.`wm_task`.`submit_status`                 AS `submit_status`,
             `hnqzx`.`wm_task`.`share_img_url`                 AS `share_img_url`,
             `hnqzx`.`wm_task`.`plat_audit_status`             AS `plat_audit_status`,
             `hnqzx`.`wm_task`.`ext_ids`                       AS `ext_ids`,
             `hnqzx`.`wm_task`.`task_info_img`                 AS `task_info_img`,
             2                                                 AS `t_type`
      from ((((`hnqzx`.`wm_task` left join `hnqzx`.`wm_score_package` on ((`hnqzx`.`wm_task`.`score_package_drug_id` =
                                                                           `hnqzx`.`wm_score_package`.`id`))) join `hnqzx`.`wm_task_type`) join `hnqzx`.`sys_user`) join `hnqzx`.`sys_dept`)
      where ((`hnqzx`.`wm_task_type`.`id` = `hnqzx`.`wm_task`.`task_type_id`) and
             (`hnqzx`.`sys_user`.`user_id` = `hnqzx`.`wm_task`.`task_user_id`) and
             (`hnqzx`.`sys_user`.`dept_id` = `hnqzx`.`sys_dept`.`dept_id`))
      union
      select `hnqzx`.`wm_task`.`score_package_level1_id`       AS `package_id`,
             `hnqzx`.`wm_score_package`.`score_name`           AS `score_name`,
             `hnqzx`.`wm_score_package`.`score`                AS `package_score`,
             `hnqzx`.`wm_score_package`.`send_package_dept_id` AS `send_package_dept_id`,
             `hnqzx`.`wm_score_package`.`score_id`             AS `score_id`,
             `hnqzx`.`sys_user`.`realname`                     AS `realname`,
             `hnqzx`.`sys_user`.`temp1`                        AS `idcard`,
             `hnqzx`.`sys_user`.`phone`                        AS `phone`,
             `hnqzx`.`sys_dept`.`name`                         AS `dept_name`,
             `hnqzx`.`sys_user`.`user_id`                      AS `user_id`,
             `hnqzx`.`wm_task_type`.`task_type_name`           AS `task_type_name`,
             `hnqzx`.`wm_task_type`.`base_id`                  AS `base_id`,
             `hnqzx`.`wm_task`.`id`                            AS `id`,
             `hnqzx`.`wm_task`.`task_rule_id`                  AS `task_rule_id`,
             `hnqzx`.`wm_task`.`score`                         AS `score`,
             `hnqzx`.`wm_task`.`score_package_drug_id`         AS `score_package_drug_id`,
             `hnqzx`.`wm_task`.`score_package_level1_id`       AS `score_package_level1_id`,
             `hnqzx`.`wm_task`.`score_package_id`              AS `score_package_id`,
             `hnqzx`.`wm_task`.`task_type_id`                  AS `task_type_id`,
             `hnqzx`.`wm_task`.`lookinto_date`                 AS `lookinto_date`,
             `hnqzx`.`wm_task`.`province`                      AS `province`,
             `hnqzx`.`wm_task`.`city`                          AS `city`,
             `hnqzx`.`wm_task`.`area`                          AS `area`,
             `hnqzx`.`wm_task`.`address`                       AS `address`,
             `hnqzx`.`wm_task`.`lookinto_type_id`              AS `lookinto_type_id`,
             `hnqzx`.`wm_task`.`task_content_id`               AS `task_content_id`,
             `hnqzx`.`wm_task`.`task_status`                   AS `task_status`,
             `hnqzx`.`wm_task`.`task_user_id`                  AS `task_user_id`,
             `hnqzx`.`wm_task`.`task_user_type`                AS `task_user_type`,
             `hnqzx`.`wm_task`.`drug_ent_id`                   AS `drug_ent_id`,
             `hnqzx`.`wm_task`.`dept_id`                       AS `dept_id`,
             `hnqzx`.`wm_task`.`del_flag`                      AS `del_flag`,
             `hnqzx`.`wm_task`.`enable_flag`                   AS `enable_flag`,
             `hnqzx`.`wm_task`.`tenant_id`                     AS `tenant_id`,
             `hnqzx`.`wm_task`.`create_time`                   AS `create_time`,
             `hnqzx`.`wm_task`.`create_user`                   AS `create_user`,
             `hnqzx`.`wm_task`.`update_time`                   AS `update_time`,
             `hnqzx`.`wm_task`.`update_user`                   AS `update_user`,
             `hnqzx`.`wm_task`.`submit_status`                 AS `submit_status`,
             `hnqzx`.`wm_task`.`share_img_url`                 AS `share_img_url`,
             `hnqzx`.`wm_task`.`plat_audit_status`             AS `plat_audit_status`,
             `hnqzx`.`wm_task`.`ext_ids`                       AS `ext_ids`,
             `hnqzx`.`wm_task`.`task_info_img`                 AS `task_info_img`,
             3                                                 AS `t_type`
      from ((((`hnqzx`.`wm_task` left join `hnqzx`.`wm_score_package` on ((`hnqzx`.`wm_task`.`score_package_level1_id` =
                                                                           `hnqzx`.`wm_score_package`.`id`))) join `hnqzx`.`wm_task_type`) join `hnqzx`.`sys_user`) join `hnqzx`.`sys_dept`)
      where ((`hnqzx`.`wm_task_type`.`id` = `hnqzx`.`wm_task`.`task_type_id`) and
             (`hnqzx`.`sys_user`.`user_id` = `hnqzx`.`wm_task`.`task_user_id`) and
             (`hnqzx`.`sys_user`.`dept_id` = `hnqzx`.`sys_dept`.`dept_id`))) `ccc`
where ((`ccc`.`package_id` is not null) and (`ccc`.`task_status` = 3) and (`ccc`.`enable_flag` = 0) and
       (`ccc`.`del_flag` = 0))
order by `ccc`.`create_time` desc;

