feat(wms/coil): 新增钢卷物料个性化导出功能
1. 后端新增导出列元数据接口 `/exportColumns`,返回字段名与中文列名的映射。 2. 后端新增个性化导出接口 `/exportCustom`,支持通过 `columns` 参数指定导出的字段集合,利用增强的 `ExcelUtil.exportExcel` 方法实现按需导出。 3. 前端钢卷接收报表页面新增自定义导出弹窗,支持按列分组展示、搜索、全选/反选/清空列,并调用新接口实现仅导出选中列的数据。 4. 在导出VO中补充“班组”字段的Excel映射注解。
This commit is contained in:
@@ -29,6 +29,7 @@ import java.io.UnsupportedEncodingException;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Excel相关处理
|
||||
@@ -149,6 +150,33 @@ public class ExcelUtil {
|
||||
builder.doWrite(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出excel(仅导出指定列)
|
||||
*
|
||||
* @param list 导出数据集合
|
||||
* @param sheetName 工作表的名称
|
||||
* @param clazz 实体类
|
||||
* @param includeColumnFieldNames 需要导出的字段名集合(Java字段名,非Excel列名)
|
||||
* @param response 响应体
|
||||
*/
|
||||
public static <T> void exportExcel(List<T> list, String sheetName, Class<T> clazz,
|
||||
Set<String> includeColumnFieldNames,
|
||||
HttpServletResponse response) {
|
||||
try {
|
||||
resetResponse(sheetName, response);
|
||||
ServletOutputStream os = response.getOutputStream();
|
||||
EasyExcel.write(os, clazz)
|
||||
.autoCloseStream(false)
|
||||
.registerWriteHandler(new LongestMatchColumnWidthStyleStrategy())
|
||||
.registerConverter(new ExcelBigNumberConvert())
|
||||
.includeColumnFieldNames(includeColumnFieldNames)
|
||||
.sheet(sheetName)
|
||||
.doWrite(list);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException("导出Excel异常");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 单表多数据模板导出 模板格式为 {.属性}
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user