提交 99ac3782 authored 作者: zhouzhigang's avatar zhouzhigang

经销商订单导出

上级 568257bc
......@@ -787,10 +787,12 @@ public class FgOrderServiceImpl extends BaseModelServiceImpl<Order,Integer> impl
@Override
public String exportSupplierPage(QueryExportExcelOrderInfoForm form, HttpServletRequest request, HttpServletResponse response) throws Exception{
List<OrderInfoVo> list = orderInfoMapper.queryOrderInfoList(form);//获取订单详情以及订单详情和班级的关系
List<OrderInfoVo> collect = list.stream().filter(e -> e.getClassId() != null).collect(Collectors.toList());
collect.forEach(this::fmtOrderInfoVo);//构建表头
list.forEach(this::fmtOrderInfoVo);//构建表头
this.excelExport(list, request, response);//导出excel
this.excelExport(collect, request, response);//导出excel
return null;
}
......@@ -805,7 +807,7 @@ public class FgOrderServiceImpl extends BaseModelServiceImpl<Order,Integer> impl
return vo;
}).distinct().collect(Collectors.toList());//班级名称列表作为excel中sheet0导出
Map<String,List<OrderInfoVo>> map = list.stream().filter(e -> e.getClassId() != null).collect(Collectors.groupingBy(OrderInfoVo::getClassName));//以班级名称进行分组,将对应班级下的教材以sheet导出,班级名称作为sheet名称
Map<String,List<OrderInfoVo>> map = list.stream().collect(Collectors.groupingBy(OrderInfoVo::getClassName));//以班级名称进行分组,将对应班级下的教材以sheet导出,班级名称作为sheet名称
......@@ -840,89 +842,93 @@ public class FgOrderServiceImpl extends BaseModelServiceImpl<Order,Integer> impl
cell1.setCellValue(classNameList.get(i).getClassName());
}
for(Map.Entry<String, List<OrderInfoVo>> entry : map.entrySet()){
HSSFSheet sheet = wb.createSheet(entry.getKey());//sheet1,2,3......
//表头
HSSFRow row1 = sheet.createRow(0);
HSSFCell cell = row1.createCell(0);
cell.setCellStyle(style);
//表第一行固定内容
int startRow = 0;
List<String> titleValue = Lists.newArrayList("客户", "课程", "教材", "ISBN", "出版社", "价格", "数量", "折扣");//列名
HSSFRow titleRow1 = sheet.createRow(startRow);
for (int i = 0; i < 8; i++) {
HSSFCell titleCell = titleRow1.createCell(i);
titleCell.setCellStyle(style);
titleCell.setCellValue(titleValue.get(i));
}
List<OrderInfoVo> voList = entry.getValue();
List<ExportOrderInfoVo> infoList = BeanUtils.copyList(voList, ExportOrderInfoVo.class);
for (int i = 0; i < infoList.size(); i++) {
ExportOrderInfoVo orderInfo = infoList.get(i);
startRow++;
HSSFRow row = sheet.createRow(startRow);
if(StringUtils.isNotBlank(orderInfo.getSchoolName())) {
HSSFCell cell0 = row.createCell(0);
cell0.setCellStyle(style);
cell0.setCellValue(orderInfo.getSchoolName());
if(map.isEmpty()){
return;
}else{
for(Map.Entry<String, List<OrderInfoVo>> entry : map.entrySet()){
HSSFSheet sheet = wb.createSheet(entry.getKey());//sheet1,2,3......
//表头
HSSFRow row1 = sheet.createRow(0);
HSSFCell cell = row1.createCell(0);
cell.setCellStyle(style);
//表第一行固定内容
int startRow = 0;
List<String> titleValue = Lists.newArrayList("客户", "课程", "教材", "ISBN", "出版社", "价格", "数量", "折扣");//列名
HSSFRow titleRow1 = sheet.createRow(startRow);
for (int i = 0; i < 8; i++) {
HSSFCell titleCell = titleRow1.createCell(i);
titleCell.setCellStyle(style);
titleCell.setCellValue(titleValue.get(i));
}
if(StringUtils.isNotBlank(orderInfo.getLessonName())) {
HSSFCell cell1 = row.createCell(1);
cell1.setCellStyle(style);
cell1.setCellValue(orderInfo.getLessonName());
}
if(StringUtils.isNotBlank(orderInfo.getBookName())) {
Cell cell2 = row.createCell(2);
cell2.setCellStyle(style);
cell2.setCellValue(orderInfo.getBookName());
}
if(StringUtils.isNotBlank(orderInfo.getIsbn())) {
Cell cell3 = row.createCell(3);
cell3.setCellStyle(style);
cell3.setCellValue(orderInfo.getIsbn());
}
if(StringUtils.isNotBlank(orderInfo.getPublisher())) {
Cell cell4 = row.createCell(4);
cell4.setCellStyle(style);
cell4.setCellValue(orderInfo.getPublisher());
}
if(orderInfo.getPrice() != null) {
Cell cell5 = row.createCell(5);
cell5.setCellStyle(style);
cell5.setCellValue(orderInfo.getPrice().toString());
}
if(StringUtils.isNotBlank(orderInfo.getNum().toString())) {
Cell cell6 = row.createCell(6);
cell6.setCellStyle(style);
cell6.setCellValue(orderInfo.getNum().toString());
}
if(StringUtils.isNotBlank(orderInfo.getDiscount().toString())) {
Cell cell7 = row.createCell(7);
cell7.setCellStyle(style);
cell7.setCellValue(orderInfo.getDiscount().toString());
}
}
List<OrderInfoVo> voList = entry.getValue();
List<ExportOrderInfoVo> infoList = BeanUtils.copyList(voList, ExportOrderInfoVo.class);
for (int i = 0; i < infoList.size(); i++) {
ExportOrderInfoVo orderInfo = infoList.get(i);
startRow++;
HSSFRow row = sheet.createRow(startRow);
if(StringUtils.isNotBlank(orderInfo.getSchoolName())) {
HSSFCell cell0 = row.createCell(0);
cell0.setCellStyle(style);
cell0.setCellValue(orderInfo.getSchoolName());
}
if(StringUtils.isNotBlank(orderInfo.getLessonName())) {
HSSFCell cell1 = row.createCell(1);
cell1.setCellStyle(style);
cell1.setCellValue(orderInfo.getLessonName());
}
if(StringUtils.isNotBlank(orderInfo.getBookName())) {
Cell cell2 = row.createCell(2);
cell2.setCellStyle(style);
cell2.setCellValue(orderInfo.getBookName());
}
if(StringUtils.isNotBlank(orderInfo.getIsbn())) {
Cell cell3 = row.createCell(3);
cell3.setCellStyle(style);
cell3.setCellValue(orderInfo.getIsbn());
}
if(StringUtils.isNotBlank(orderInfo.getPublisher())) {
Cell cell4 = row.createCell(4);
cell4.setCellStyle(style);
cell4.setCellValue(orderInfo.getPublisher());
}
if(orderInfo.getPrice() != null) {
Cell cell5 = row.createCell(5);
cell5.setCellStyle(style);
cell5.setCellValue(orderInfo.getPrice().toString());
}
if(StringUtils.isNotBlank(orderInfo.getNum().toString())) {
Cell cell6 = row.createCell(6);
cell6.setCellStyle(style);
cell6.setCellValue(orderInfo.getNum().toString());
}
if(StringUtils.isNotBlank(orderInfo.getDiscount().toString())) {
Cell cell7 = row.createCell(7);
cell7.setCellStyle(style);
cell7.setCellValue(orderInfo.getDiscount().toString());
}
}
}
}
//excel中sheet0加超链接
HSSFCellStyle hlink_style = wb.createCellStyle();
Font hlink_font = wb.createFont();
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论