DROP TABLE IF EXISTS `mp_server_windows_dispute`;
CREATE TABLE IF NOT EXISTS `mp_server_windows_dispute` (
  `id` bigint NOT NULL COMMENT '主键',
  `sw_id` bigint DEFAULT NULL COMMENT '窗口id,即账号id',
  `dispute_id` bigint DEFAULT NULL COMMENT '纠纷字典id',
  `status` int DEFAULT 1 COMMENT '状态 0:禁用, 1:启用',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='服务窗口-纠纷关联表';

DROP TABLE IF EXISTS `mp_appeal`;
CREATE TABLE IF NOT EXISTS `mp_appeal` (
  `id` bigint NOT NULL COMMENT '主键',
  `street_id` bigint DEFAULT NULL COMMENT '所属街道字典id',
  `dispute_id` bigint DEFAULT NULL COMMENT '纠纷字典id',
  `dispute_name` varchar(32) DEFAULT NULL COMMENT '纠纷名称',
  `dispute_level` int DEFAULT null COMMENT '纠纷等级(事件等级), 0:简单, 1:一般, 2:重大, 3:疑难',
  `first_reg_time` datetime COMMENT '首次登记时间',
  `finish_time` datetime COMMENT '办结时间',
  `problem_desc` varchar(512) DEFAULT null COMMENT '反应问题',
  `skip_grant` int DEFAULT 0 COMMENT '是否越级上报, 0:否, 1:是',
  `status` int DEFAULT 1 COMMENT '诉求状态(办理状态)0:待处理, 1:正在处理, 2:达成协议, 3:调解成功',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='诉求表';

DROP TABLE IF EXISTS `mp_appeal_reg`;
CREATE TABLE IF NOT EXISTS `mp_appeal_reg` (
  `id` bigint NOT NULL COMMENT '主键',
  `appeal_id` bigint DEFAULT NULL COMMENT '诉求id',
  `person_num` int(4) DEFAULT NULL COMMENT '来访人数',
  `dispose_dept` varchar(512) DEFAULT null COMMENT '何单位处理过-单位id',
  `dispose_dept_name` varchar(64) DEFAULT null COMMENT '何单位处理过-单位名称',
  `protocol` varchar(512) DEFAULT null COMMENT '基层协议',
  `opinion` varchar(512) DEFAULT null COMMENT '基层处理意见',
  `review_opinion` varchar(512) DEFAULT null COMMENT '部门复查意见',
  `legal_paper` varchar(512) DEFAULT null COMMENT '法律文书',
  `reg_time` datetime COMMENT '登记时间(来访时间)',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='诉求登记表';

DROP TABLE IF EXISTS `mp_appeal_mediation`;
CREATE TABLE IF NOT EXISTS `mp_appeal_mediation` (
  `id` bigint NOT NULL COMMENT '主键',
  `appeal_id` bigint DEFAULT NULL COMMENT '诉求id',
  `appeal_reg_id` bigint DEFAULT NULL COMMENT '诉求登记Id',
  `talking_time` datetime DEFAULT NULL COMMENT '接谈时间',
  `talking_his` varchar(1024) DEFAULT NULL COMMENT '接谈记录',
  `attitude` varchar(512) DEFAULT NULL COMMENT '上访人意见和态度',
  `talking_advice` varchar(512) DEFAULT NULL COMMENT '接谈意见',
  `duty_dept_ids` varchar(512) DEFAULT NULL COMMENT '责任单位id列表, 以逗号分割',
  `copy_dept_ids` varchar(512) DEFAULT NULL COMMENT '抄送单位id列表, 以逗号分割',
  `feedback_deadline` datetime DEFAULT NULL COMMENT '反馈时限',
  `finish_deadline` datetime DEFAULT NULL COMMENT '办结时限',
  `remark` varchar(512) DEFAULT NULL COMMENT '备注',
  `submit_time` datetime DEFAULT NULL COMMENT '提交时间',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='诉求调解表';

DROP TABLE IF EXISTS `mp_appeal_visitor`;
CREATE TABLE IF NOT EXISTS `mp_appeal_visitor` (
  `id` bigint NOT NULL COMMENT '主键',
  `appeal_id` bigint DEFAULT NULL COMMENT '诉求id',
  `appeal_reg_id` bigint DEFAULT NULL COMMENT '诉求登记Id',
  `username` varchar(128) DEFAULT NULL COMMENT '姓名',
  `gender` varchar(8) DEFAULT NULL COMMENT '性别',
  `age` int(4) DEFAULT NULL COMMENT '年龄',
  `cardno` varchar(32) DEFAULT NULL COMMENT '身份证号',
  `address` varchar(128) DEFAULT NULL COMMENT '住址',
  `address_now` varchar(128) DEFAULT NULL COMMENT '现住址',
  `phone` varchar(16) DEFAULT NULL COMMENT '联系电话',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='诉求调解表';

DROP TABLE IF EXISTS `mp_appeal_mediation_file`;
CREATE TABLE IF NOT EXISTS `mp_appeal_mediation_file` (
  `id` bigint NOT NULL COMMENT '主键',
  `appeal_id` bigint DEFAULT NULL COMMENT '诉求id',
  `appeal_reg_id` bigint DEFAULT NULL COMMENT '诉求登记Id',
  `mediation_id` bigint DEFAULT NULL COMMENT '调解记录id',
  `file_addr` varchar(128) DEFAULT NULL COMMENT '文件地址',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='调解附件表';
