DROP TABLE IF EXISTS `risk_alarm`;
CREATE TABLE `risk_alarm` (
	`id` BIGINT(32) NOT NULL AUTO_INCREMENT COMMENT 'ID，唯一编号',
	`sid` VARCHAR(64) NOT NULL COMMENT 'sid',
	`createTime` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '记录创建时间',
	`remarks` varchar(255) DEFAULT NULL COMMENT '备注信息',
	
	`customerSid` varchar(64) DEFAULT NULL COMMENT '客户Sid',
	`customerName` varchar(100) DEFAULT NULL COMMENT '客户名称',
	
	`positionCode` int(11) DEFAULT NULL COMMENT '风险处于位置1.主体2.供应商3.仓库4.门店',
	`positionSid` varchar(64) DEFAULT NULL COMMENT '风险处于位置Sid',
	`positionName` varchar(100) DEFAULT NULL COMMENT '风险处于位置名称',
	
	`triggerTime` DATETIME NULL DEFAULT NULL COMMENT '风险触发时间',
	
	`treatmentStatus` INT(11) NOT NULL DEFAULT '0' COMMENT '风险处理状态：0=待处理，1=处理中，2=已办结',
	`treatmentTime` DATETIME NULL DEFAULT NULL COMMENT '风险处理时间',
	`treatmentContent` varchar(500) DEFAULT NULL COMMENT '风险处理内容',
	
  `eliminationStatus` int(11) DEFAULT '0' COMMENT '风险消除程度0.未消除1.已消除',
	`eliminationTime` DATETIME NULL DEFAULT NULL COMMENT '风险消除时间',
	`eliminationContent` varchar(500) DEFAULT NULL COMMENT '风险消除内容',
	
	`indicatorSid` varchar(64) DEFAULT NULL COMMENT '风险指标Sid',
	`indicatorCode` varchar(100) DEFAULT NULL COMMENT '风险指标代码',
	`indicatorName` varchar(100) DEFAULT NULL COMMENT '风险指标名称',
	
	`levelSid` varchar(64) DEFAULT NULL COMMENT '风险等级(程度)Sid',
	`levelCode` varchar(100) DEFAULT NULL COMMENT '风险等级(程度)代码',
	`levelName` varchar(100) DEFAULT NULL COMMENT '风险等级(程度)名称',
	
	`typeSid` varchar(64) DEFAULT NULL COMMENT '风险类别Sid',
	`typeCode` varchar(100) DEFAULT NULL COMMENT '风险类别代码',
	`typeName` varchar(100) DEFAULT NULL COMMENT '风险类别名称',
	PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB COMMENT='风险警报记录' ;

DROP TABLE IF EXISTS `risk_alarm_treatment`;
CREATE TABLE `risk_alarm_treatment` (
	`id` BIGINT(32) NOT NULL AUTO_INCREMENT COMMENT 'ID，唯一编号',
	`createTime` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '记录创建时间',
	`remarks` VARCHAR(100) DEFAULT NULL COMMENT '备注说明',
	
	`riskAlarmSid` VARCHAR(100) DEFAULT NULL COMMENT '风险警报记录SID',
	
	`treatmentStatus` INT(11) NOT NULL DEFAULT '0' COMMENT '风险处理状态：0=待处理，1=处理中，2=已办结',
	`treatmentTime` DATETIME NULL DEFAULT NULL COMMENT '风险处理时间',
	`treatmentContent` varchar(500) DEFAULT NULL COMMENT '风险处理内容',
	
	`userSid` VARCHAR(100) DEFAULT NULL COMMENT '处理人Sid',
	`userName` VARCHAR(100) DEFAULT NULL COMMENT '处理人姓名',
	`userPhone` VARCHAR(100) DEFAULT NULL COMMENT '处理人电话',
	
	PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB  COMMENT='风险警报-处理记录';

DROP TABLE IF EXISTS `risk_indicators`;
CREATE TABLE `risk_indicators` (
	`id` BIGINT(32) NOT NULL AUTO_INCREMENT COMMENT 'ID，唯一编号',
	`sid` VARCHAR(64) NOT NULL COMMENT 'sid',
	`createTime` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '记录创建时间',
	`remarks` varchar(255) DEFAULT NULL COMMENT '备注信息',
	
	`reportTarget` int(11) DEFAULT NULL COMMENT '报送单位：1.监管公司2.贷款支行3.总行',
	
	`code` varchar(100) DEFAULT NULL COMMENT '代码',
	`name` varchar(100) DEFAULT NULL COMMENT '名称',
	`content` varchar(500) DEFAULT NULL COMMENT '指标说明',
	
	`levelSid` varchar(64) DEFAULT NULL COMMENT '风险等级(程度)Sid',
	`levelCode` varchar(100) DEFAULT NULL COMMENT '风险等级(程度)代码',
	`levelName` varchar(100) DEFAULT NULL COMMENT '风险等级(程度)名称',
	
	`typeSid` varchar(64) DEFAULT NULL COMMENT '风险类别Sid',
	`typeCode` varchar(100) DEFAULT NULL COMMENT '风险类别代码',
	`typeName` varchar(100) DEFAULT NULL COMMENT '风险类别名称',
	
	PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB COMMENT='风险指标' ;

DROP TABLE IF EXISTS `risk_level`;
CREATE TABLE `risk_level` (
	`id` BIGINT(32) NOT NULL AUTO_INCREMENT COMMENT 'ID，唯一编号',
	`sid` VARCHAR(64) NOT NULL COMMENT 'sid',
	`createTime` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '记录创建时间',
	`remarks` varchar(255) DEFAULT NULL COMMENT '备注信息',
	
	`reportTarget` int(11) DEFAULT NULL COMMENT '报送单位：1.监管公司2.贷款支行3.总行',
	
	`code` varchar(100) DEFAULT NULL COMMENT '代码',
	`name` varchar(100) DEFAULT NULL COMMENT '名称',
	`handlingMethod` varchar(500) DEFAULT NULL COMMENT '处理方式',
	
	PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB COMMENT='风险等级' ;

DROP TABLE IF EXISTS `risk_type`;
CREATE TABLE `risk_type` (
	`id` BIGINT(32) NOT NULL AUTO_INCREMENT COMMENT 'ID，唯一编号',
	`sid` VARCHAR(64) NOT NULL COMMENT 'sid',
	`createTime` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '记录创建时间',
	`remarks` varchar(255) DEFAULT NULL COMMENT '备注信息',
	
	`code` varchar(100) DEFAULT NULL COMMENT '代码',
	`name` varchar(100) DEFAULT NULL COMMENT '名称',
	`content` varchar(500) DEFAULT NULL COMMENT '分类说明',
	
	`hierarchy` int(11) DEFAULT '1' COMMENT '层级',
	`parentSid` varchar(64) DEFAULT NULL COMMENT '父类Sid',
	`parentName` varchar(64) DEFAULT NULL COMMENT '父类Sid',
	
	PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB COMMENT='风险类别';

DROP TABLE IF EXISTS `risk_blacklist`;
CREATE TABLE `risk_blacklist` (
	`id` BIGINT(32) NOT NULL AUTO_INCREMENT COMMENT 'ID，唯一编号',
	`sid` VARCHAR(64) NOT NULL COMMENT 'sid',
	`createTime` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '记录创建时间',
	`remarks` varchar(255) DEFAULT NULL COMMENT '备注信息',
	
	`objectSid` varchar(64) DEFAULT NULL COMMENT '风险对象Sid',
	`objectType` int(11) DEFAULT NULL COMMENT '风险对象类型1.供应商2.仓库3.门店',
	PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB COMMENT='风险黑名单';



DROP TABLE IF EXISTS `business_risk_data`;
CREATE TABLE `business_risk_data`  (
  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'id',
  `sid` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT 'sid',
  `lockVersion` int(11) NULL DEFAULT 0 COMMENT '版本锁',
  `createTime` timestamp(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0) COMMENT '创建时间',
  `modifyTime` timestamp(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0) COMMENT '修改时间',
  `isEnable` int(11) NULL DEFAULT 1 COMMENT '是否可用：1可用，0不可用',
  `state` int(11) NULL DEFAULT 1 COMMENT '状态',
  `isDelete` int(11) NULL DEFAULT 0 COMMENT '是否删除：0未删除，1已删除',
  `remarks` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '备注',
  `createBySid` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '创建人sid',
  `updateBySid` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '修改人sid',
  `addReason` varchar(300) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '列入经营异常名录原因',
  `addDate` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '列入日期',
  `romoveReason` varchar(256) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '移出经营异常名录原因（保留字段）',
  `removeDate` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '移出日期（保留字段)',
  `decisionOffice` varchar(128) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '作出决定机关',
  `removeDecisionOffice` varchar(128) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '移出决定机关（保留字段）',
  `buSid` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '企业时间Sid',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 6 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '任务执行数据表' ROW_FORMAT = Dynamic;

SET FOREIGN_KEY_CHECKS = 1;

DROP TABLE IF EXISTS `business_risk_date`;
CREATE TABLE `business_risk_date`  (
  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'id',
  `sid` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT 'sid',
  `lockVersion` int(11) NULL DEFAULT 0 COMMENT '版本锁',
  `createTime` timestamp(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0) COMMENT '创建时间',
  `modifyTime` timestamp(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0) COMMENT '修改时间',
  `isEnable` int(11) NULL DEFAULT 1 COMMENT '是否可用：1可用，0不可用',
  `state` int(11) NULL DEFAULT 1 COMMENT '状态',
  `isDelete` int(11) NULL DEFAULT 0 COMMENT '是否删除：0未删除，1已删除',
  `remarks` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '备注',
  `createBySid` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '创建人sid',
  `updateBySid` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '修改人sid',
  `executionTime` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '执行时间',
  `businessName` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '企业名称',
  `OrderNumber` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '订单编号',
  `verifyResult` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '风险编码 0代表无1代表有',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 10 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '任务执行时间表' ROW_FORMAT = Dynamic;

SET FOREIGN_KEY_CHECKS = 1;

DROP TABLE IF EXISTS `enterprise_information`;
CREATE TABLE `enterprise_information`  (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `sid` varchar(255) CHARACTER SET utf8 COLLATE utf8_croatian_ci NOT NULL COMMENT 'ids',
  `enterpriseName` varchar(255) CHARACTER SET utf8 COLLATE utf8_croatian_ci NULL DEFAULT NULL COMMENT '企业名称',
  `enterpriseAbbreviation` varchar(255) CHARACTER SET utf8 COLLATE utf8_croatian_ci NULL DEFAULT NULL COMMENT '企业简称',
  `bankAccount` varchar(255) CHARACTER SET utf8 COLLATE utf8_croatian_ci NULL DEFAULT NULL COMMENT '银行账户',
  `accountNumber` varchar(255) CHARACTER SET utf8 COLLATE utf8_croatian_ci NULL DEFAULT NULL COMMENT '账号',
  `openingBankName` varchar(255) CHARACTER SET utf8 COLLATE utf8_croatian_ci NULL DEFAULT NULL COMMENT '开户行',
  `juridicalPerson` varchar(255) CHARACTER SET utf8 COLLATE utf8_croatian_ci NULL DEFAULT NULL COMMENT '法人',
  `businessLicenseNumber` varchar(255) CHARACTER SET utf8 COLLATE utf8_croatian_ci NULL DEFAULT NULL COMMENT '营业执照号',
  `address` varchar(255) CHARACTER SET utf8 COLLATE utf8_croatian_ci NULL DEFAULT NULL COMMENT '地址',
  `province` varchar(255) CHARACTER SET utf8 COLLATE utf8_croatian_ci NULL DEFAULT NULL COMMENT '省',
  `city` varchar(255) CHARACTER SET utf8 COLLATE utf8_croatian_ci NULL DEFAULT NULL COMMENT '市',
  `county` varchar(255) CHARACTER SET utf8 COLLATE utf8_croatian_ci NULL DEFAULT NULL COMMENT '区',
  `contacts` varchar(255) CHARACTER SET utf8 COLLATE utf8_croatian_ci NULL DEFAULT NULL COMMENT '联系人',
  `telephone` varchar(255) CHARACTER SET utf8 COLLATE utf8_croatian_ci NULL DEFAULT NULL COMMENT '电话',
  `lockVersion` int(11) NULL DEFAULT 0 COMMENT '版本锁',
  `createTime` timestamp(0) NULL DEFAULT CURRENT_TIMESTAMP(0) COMMENT '创建时间',
  `modifyTime` timestamp(0) NULL DEFAULT CURRENT_TIMESTAMP(0) COMMENT '修改时间',
  `isEnable` int(11) NULL DEFAULT 1 COMMENT '是否可用：1可用，0不可用',
  `state` int(11) NULL DEFAULT 1 COMMENT '状态',
  `isDelete` int(11) NULL DEFAULT 0 COMMENT '是否删除：0未删除，1已删除',
  `remarks` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '备注',
  `createBySid` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '创建人sid',
  `updateBySid` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '修改人sid',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 14 CHARACTER SET = utf8 COLLATE = utf8_croatian_ci COMMENT = '企业信息' ROW_FORMAT = DYNAMIC;

SET FOREIGN_KEY_CHECKS = 1;


DROP TABLE IF EXISTS `push_information`;
CREATE TABLE `push_information`  (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `sid` varchar(255) CHARACTER SET utf8 COLLATE utf8_croatian_ci NOT NULL COMMENT 'sid',
  `lockVersion` int(11) NULL DEFAULT 0 COMMENT '版本锁',
  `createTime` timestamp(0) NULL DEFAULT CURRENT_TIMESTAMP(0) COMMENT '创建时间',
  `modifyTime` timestamp(0) NULL DEFAULT CURRENT_TIMESTAMP(0) COMMENT '修改时间',
  `isEnable` int(11) NULL DEFAULT 1 COMMENT '是否可用：1可用，0不可用',
  `state` int(11) NULL DEFAULT 1 COMMENT '状态',
  `isDelete` int(11) NULL DEFAULT 0 COMMENT '是否删除：0未删除，1已删除',
  `remarks` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '备注',
  `createBySid` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '创建人sid',
  `updateBySid` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '修改人sid',
  `enterpriseName` varchar(255) CHARACTER SET utf8 COLLATE utf8_croatian_ci NULL DEFAULT NULL COMMENT '企业名称',
  `contacts` varchar(255) CHARACTER SET utf8 COLLATE utf8_croatian_ci NULL DEFAULT NULL COMMENT '联系人',
  `telephone` varchar(255) CHARACTER SET utf8 COLLATE utf8_croatian_ci NULL DEFAULT NULL COMMENT '电话',
  `openId` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '微信公众号唯一标识',
  `bankAccount` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '银行账号',
  `openingBankName` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '开户行',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 12 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '推送人员表' ROW_FORMAT = Dynamic;

SET FOREIGN_KEY_CHECKS = 1;

DROP TABLE IF EXISTS `risk_index`;
CREATE TABLE `risk_index`  (
  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'id',
  `sid` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT 'sid',
  `createTime` timestamp(0) NULL DEFAULT CURRENT_TIMESTAMP(0) COMMENT '记录创建时间',
  `remarks` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '备注信息',
  `code` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '代码',
  `name` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '名称',
  `content` varchar(500) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '指标说明',
  `levelSid` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '风险等级(程度)Sid',
  `levelCode` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '风险等级(程度)代码',
  `levelName` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '风险等级(程度)名称',
  `typeSid` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '风险类别Sid',
  `typeCode` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '风险类别代码',
  `typeName` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '风险类别名称',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 3 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '监控指标' ROW_FORMAT = Dynamic;

SET FOREIGN_KEY_CHECKS = 1;