|
|
@ -20,13 +20,14 @@ public class MyExcelUtil extends ExcelUtil { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static <T> void export(HttpServletResponse response, List<DistributionStockupPackageListDetailExcel> stockupList) { |
|
|
|
public static <T> void export(HttpServletResponse response, List<DistributionStockupPackageListDetailExcel> stockupList,String fileName) { |
|
|
|
try { |
|
|
|
try { |
|
|
|
response.setContentType("application/vnd.ms-excel"); |
|
|
|
response.setContentType("application/vnd.ms-excel"); |
|
|
|
response.setCharacterEncoding(Charsets.UTF_8.name()); |
|
|
|
fileName = URLEncoder.encode(fileName, Charsets.UTF_8.name()); |
|
|
|
response.setHeader("Content-disposition", "attachment;filename=" + "备货清单列表" + ".xlsx"); |
|
|
|
response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".xlsx"); |
|
|
|
response.setHeader("content-Type", "application/vnd.ms-excel"); |
|
|
|
response.setHeader("content-Type", "application/vnd.ms-excel"); |
|
|
|
ExcelWriter excelWriter = EasyExcel.write(response.getOutputStream()).build(); |
|
|
|
response.setCharacterEncoding("UTF-8"); |
|
|
|
|
|
|
|
ExcelWriter excelWriter = EasyExcel.write(response.getOutputStream(),DistributionStockupPackageListDetailExcel.class).build(); |
|
|
|
//将清单进行分组,首先区分是否是库存品,其次进行区分订制品和零担
|
|
|
|
//将清单进行分组,首先区分是否是库存品,其次进行区分订制品和零担
|
|
|
|
Map<Integer, List<DistributionStockupPackageListDetailExcel>> isInventoryMap = stockupList.stream().collect(Collectors.groupingBy(DistributionStockupPackageListDetailExcel::getIsInventory)); |
|
|
|
Map<Integer, List<DistributionStockupPackageListDetailExcel>> isInventoryMap = stockupList.stream().collect(Collectors.groupingBy(DistributionStockupPackageListDetailExcel::getIsInventory)); |
|
|
|
isInventoryMap.forEach((k,v)->{ |
|
|
|
isInventoryMap.forEach((k,v)->{ |
|
|
@ -34,21 +35,23 @@ public class MyExcelUtil extends ExcelUtil { |
|
|
|
//进行是否零担的区分
|
|
|
|
//进行是否零担的区分
|
|
|
|
Map<String, List<DistributionStockupPackageListDetailExcel>> isZeroMap = v.stream().collect(Collectors.groupingBy(DistributionStockupPackageListDetailExcel::getIsZero)); |
|
|
|
Map<String, List<DistributionStockupPackageListDetailExcel>> isZeroMap = v.stream().collect(Collectors.groupingBy(DistributionStockupPackageListDetailExcel::getIsZero)); |
|
|
|
isZeroMap.forEach((m,n)->{ |
|
|
|
isZeroMap.forEach((m,n)->{ |
|
|
|
if (m.equals(0)){ |
|
|
|
if (m.equals("0")){ |
|
|
|
//订制品
|
|
|
|
//订制品
|
|
|
|
WriteSheet writeSheet = EasyExcel.writerSheet("订制品备货清单").head(DistributionStockupPackageListDetailExcel.class).build(); |
|
|
|
WriteSheet writeSheet = EasyExcel.writerSheet(1,"订制品备货清单").head(DistributionStockupPackageListDetailExcel.class).build(); |
|
|
|
|
|
|
|
excelWriter.write(n, writeSheet); |
|
|
|
}else { |
|
|
|
}else { |
|
|
|
//零担
|
|
|
|
//零担
|
|
|
|
WriteSheet writeSheet = EasyExcel.writerSheet("零担备货清单").head(DistributionStockupPackageListDetailExcel.class).build(); |
|
|
|
WriteSheet writeSheet = EasyExcel.writerSheet(2,"零担备货清单").head(DistributionStockupPackageListDetailExcel.class).build(); |
|
|
|
|
|
|
|
excelWriter.write(n, writeSheet); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
}else { |
|
|
|
}else { |
|
|
|
//库存品
|
|
|
|
//库存品
|
|
|
|
|
|
|
|
WriteSheet writeSheet = EasyExcel.writerSheet(3,"库存品备货清单").head(DistributionStockupPackageListDetailExcel.class).build(); |
|
|
|
|
|
|
|
excelWriter.write(v, writeSheet); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
excelWriter.finish(); |
|
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
} catch (Exception e) { |
|
|
|
|
|
|
|
|
|
|
|
throw new RuntimeException("请稍后再试...."); |
|
|
|
throw new RuntimeException("请稍后再试...."); |
|
|
|