--  豁免事项跟进sql
CREATE TABLE `exemption_matters`
(
    `id`                     bigint(20) unsigned NOT NULL AUTO_INCREMENT,
    `payment_apply_id` bigint(20) unsigned DEFAULT '0' COMMENT '付款申请ID',
    `exemption_status`       varchar(32) DEFAULT NULL COMMENT '豁免状态 0 处理中 1 已完成 2 已逾期',
    `user_create`            varchar(50)        DEFAULT '' COMMENT '创建人',
    `user_modified`          varchar(50)        DEFAULT '' COMMENT '修改人',
    `gmt_create`             timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
    `gmt_modified`           timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
    PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB COMMENT='豁免事项跟进和付款关系表';

CREATE TABLE `exemption_matters_approval`
(
    `id`                   bigint(20) unsigned NOT NULL AUTO_INCREMENT,
    `exemption_matters_id` bigint(20) unsigned DEFAULT '0' COMMENT '豁免事项跟进和付款关系表Id',
    `approval_conclusion`  varchar(50)        DEFAULT '' COMMENT '通过pass/退回back',
    `approval_comments`    varchar(3000)      DEFAULT '' COMMENT '审批意见',
    `user_create`          varchar(32)        DEFAULT '' COMMENT '创建人',
    `user_modified`        varchar(32)        DEFAULT '' COMMENT '修改人',
    `gmt_create`           timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
    `gmt_modified`         timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
    PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB COMMENT='--豁免事项跟进审核表';

CREATE TABLE `exemption_matters_history`
(
    `id`                     bigint(20) unsigned NOT NULL AUTO_INCREMENT,
    `payment_apply_id` bigint(20) unsigned DEFAULT '0' COMMENT '付款申请ID',
    `statusId`               tinyint(3) DEFAULT NULL COMMENT '状态 0 处理中 1 已完成 2 已逾期',
    `user_create`            varchar(50)        DEFAULT '' COMMENT '创建人',
    `user_modified`          varchar(50)        DEFAULT '' COMMENT '修改人',
    `gmt_create`             timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
    `gmt_modified`           timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
    PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB COMMENT='豁免事项跟进和付款关系历史表';

CREATE TABLE `exemption_matters_ref`
(
    `id`                   bigint(20) unsigned NOT NULL AUTO_INCREMENT,
    `exemption_matters_id` bigint(20) unsigned DEFAULT '0' COMMENT '豁免事项跟进和付款关系表Id',
    `payment_condition_id` bigint(20) unsigned DEFAULT '0' COMMENT '付款条件ID',
    `file_id`              bigint(20) unsigned DEFAULT '0' COMMENT '附件ID',
    PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB COMMENT='豁免事项跟进附件';

CREATE TABLE `exemption_matters_ref_history`
(
    `id`                   bigint(20) unsigned NOT NULL AUTO_INCREMENT,
    `exemption_matters_id` bigint(20) unsigned DEFAULT '0' COMMENT '豁免事项跟进和付款关系表Id',
    `payment_condition_id` bigint(20) unsigned DEFAULT '0' COMMENT '付款条件ID',
    `file_id`              bigint(20) unsigned DEFAULT '0' COMMENT '附件ID',
    PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB COMMENT='付款条件豁免事项跟进附件历史';

INSERT INTO `t_permission`( `type`, `cname`, `ename`, `gradation`, `moduleName`) VALUES ( 'menu', '豁免跟进管理', 'ExemptionFollow', 8, NULL);
INSERT INTO `t_permission`( `parentId`, `type`, `cname`, `ename`, `gradation`, `moduleName`, `url`, `icon`) VALUES ( (SELECT t.id FROM t_permission t WHERE t.ename = 'ExemptionFollow'), 'menu', '查看', 'viewExemptionMatters', 1, '豁免跟进管理', NULL, NULL);
INSERT INTO `t_permission`(`parentId`, `type`, `cname`, `ename`, `gradation`, `moduleName`, `url`, `icon`) VALUES ((SELECT t.id FROM t_permission t WHERE t.ename = 'ExemptionFollow'), 'menu', '数据可见-查看全员', 'viewAllExemptionMatters', 0, '豁免跟进管理', NULL, NULL);
INSERT INTO `t_permission`(`parentId`, `type`, `cname`, `ename`, `gradation`, `moduleName`, `url`, `icon`) VALUES ((SELECT t.id FROM t_permission t WHERE t.ename = 'ExemptionFollow'), 'menu', '下载', 'downloadExemptionMatters', 2, '豁免跟进管理', NULL, NULL);

INSERT INTO `t_dictionary`(`name`, `parentId`, `code`, `value`, `gradation`) VALUES ('豁免跟进', 252, 'ExemptionMatters', NULL, 21);
