导出服务的导出方案
背景
为什么要搭建这个导出服务?
因为,目前导出在大数据量的情况下,无法实现导出功能,在HTTP的时间范围内无法直接导出。
而大数据量的导出又是业务方所需要的,所以我们搭建了这样一个服务。为什么写了导出模板?
因为想避免大家的重复工作,这样可以节省大家的时间,同时也可以避免很多不必要的缺陷,让大家可以快速开发,只需要实现查询总数+分页查询的方法,就可以完成一个导出业务。
表结构
1.dms_import_export_task
create table dms_import_export_task
(
dms_import_export_task_id bigint auto_increment comment '任务主键ID'
primary key,
task_no varchar(64) not null comment '任务编号',
task_type int not null comment '任务类型 0-导入 1-导出',
biz_type int not null comment '业务类型 1-订单导出 2-问题件导出',
request_param text null comment '导出查询条件JSON',
file_name varchar(256) null comment '文件名(展示用)',
file_type varchar(16) null comment '文件类型:xlsx,csv等',
file_path varchar(512) null comment '文件路径',
task_status int default 0 not null comment '任务状态:0-待处理,1处理中,2成功,3失败,4已取消 ',
error_type int null comment '异常类型',
error_msg text null comment '失败错误信息',
start_time datetime null comment '开始处理时间',
finish_time datetime null comment '完成时间',
notify_type int default 0 null comment '通知类型:0-不通知 1-站内信 2-邮件 3-钉钉',
notify_status int default 0 null comment '通知状态:0-未通知 1-已通知',
notify_time datetime null comment '通知时间',
remark varchar(256) default '' null comment '备注',
over_flag tinyint default 0 not null comment '完结标识 0-未完结,1-已完结',
create_user bigint not null comment '创建人',
create_time datetime default CURRENT_TIMESTAMP not null comment '创建时间',
update_user bigint null comment '更新人',
update_time datetime default CURRENT_TIMESTAMP not null on update CURRENT_TIMESTAMP comment '更新时间',
constraint uniq_task_no
unique (task_no)
)
comment '导入导出任务表';
相关类图
思路:使用策略+模板的设计模块
- IExportTaskHandleService:定义一类导出业务,以及需要实现的业务
- AbstractExportTaskHandleService:抽象模板类,将一些通用的方法和流程抽取出来
- 业务类OrderExportTaskHandleServiceImpl等:具体的业务类,实现查询总数+分页查询的方法
- CombinationExportTaskHandleService:组装策略类,将对应的业务类收集起来,根据业务类型做业务分发
流程设计
目前存在的一些问题
- 深分页问题 - 依赖子类实现的时候处理
- 通知用户 - 留有方法,暂未实现
- 权限控制 - 暂无
作者:詹明威 创建时间:2026-01-12 15:40
最后编辑:詹明威 更新时间:2026-03-03 10:08
最后编辑:詹明威 更新时间:2026-03-03 10:08