|
|
@ -443,4 +443,72 @@ public class SysSalesShippingInformServiceImpl implements ISysSalesShippingInfor |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* 导出出货单2模板 |
|
|
|
* */ |
|
|
|
@Override |
|
|
|
public void exportShippingOrderTwo(String outOrderCode, HttpServletResponse response) { |
|
|
|
String fileName = "销售出货单2.xlsx"; |
|
|
|
FileDownloadUtils fileDownloadUtils = new FileDownloadUtils(); |
|
|
|
|
|
|
|
try { |
|
|
|
String fileAbsolutePath = fileDownloadUtils.getFileAbsolutePath(fileName); |
|
|
|
|
|
|
|
SysSalesShippingInform salesShippingInform = sysSalesShippingInformMapper.selectSysSalesShippingInformByCode(outOrderCode); |
|
|
|
|
|
|
|
List<SysSalesShippingInformDetail> salesShippingInformDetails = shippingInformDetailMapper.selectSysSalesShippingInformDetailByCode(outOrderCode); |
|
|
|
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); |
|
|
|
String deliverTime = dateFormat.format(salesShippingInform.getDeliverTime()); |
|
|
|
String realFileName = salesShippingInform.getSalesOrderCode() +"-"+ fileName.substring(0, fileName.lastIndexOf("."))+ ".xlsx"; |
|
|
|
// 设置响应头,指定文件名和文件类型
|
|
|
|
response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(realFileName, "UTF-8")); |
|
|
|
response.setContentType("application/octet-stream"); |
|
|
|
|
|
|
|
|
|
|
|
AtomicInteger index = new AtomicInteger(1); |
|
|
|
|
|
|
|
//处理物料数据
|
|
|
|
List<ExportSalesShippingInformDto> exportSalesShippingInformDtos = new ArrayList<>(); |
|
|
|
|
|
|
|
for (SysSalesShippingInformDetail salesShippingInformDetail : salesShippingInformDetails) { |
|
|
|
ExportSalesShippingInformDto exportSalesShippingInformDto = new ExportSalesShippingInformDto(); |
|
|
|
exportSalesShippingInformDto.setIndex(index.getAndIncrement()); |
|
|
|
exportSalesShippingInformDto.setMaterialName(salesShippingInformDetail.getMaterialName()); |
|
|
|
exportSalesShippingInformDto.setMaterialNo(salesShippingInformDetail.getMaterialNo()); |
|
|
|
exportSalesShippingInformDto.setMaterialDescribe(salesShippingInformDetail.getMaterialDescribe()); |
|
|
|
exportSalesShippingInformDto.setMaterialUnit(salesShippingInformDetail.getMaterialUnit()); |
|
|
|
exportSalesShippingInformDto.setMakeNum(salesShippingInformDetail.getMakeNum()); |
|
|
|
exportSalesShippingInformDto.setSalesOrderNumber(salesShippingInform.getSalesOrderNumber()); |
|
|
|
exportSalesShippingInformDto.setRemark(salesShippingInform.getRemark()); |
|
|
|
exportSalesShippingInformDtos.add(exportSalesShippingInformDto); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//totalMakeNum
|
|
|
|
String totalMakeNum = String.valueOf(salesShippingInformDetails.stream().mapToInt(SysSalesShippingInformDetail::getMakeNum).sum()); |
|
|
|
|
|
|
|
|
|
|
|
ExcelWriter workBook = EasyExcel.write(response.getOutputStream()).withTemplate(fileAbsolutePath).build(); |
|
|
|
|
|
|
|
WriteSheet sheet = EasyExcel.writerSheet().build(); |
|
|
|
|
|
|
|
FillConfig fillConfig = FillConfig.builder().forceNewRow(true).build(); |
|
|
|
|
|
|
|
HashMap<String, Object> map = MapUtils.newHashMap(); |
|
|
|
map.put("customerId",salesShippingInform.getCustomerId()); |
|
|
|
map.put("deliverTime",deliverTime); |
|
|
|
map.put("businessMembers",salesShippingInform.getBusinessMembers()); |
|
|
|
map.put("totalMakeNum",totalMakeNum); |
|
|
|
|
|
|
|
// 写入数据
|
|
|
|
workBook.fill(map, sheet); |
|
|
|
workBook.fill(exportSalesShippingInformDtos, fillConfig, sheet); |
|
|
|
workBook.finish(); |
|
|
|
|
|
|
|
} catch (IOException e) { |
|
|
|
throw new RuntimeException("文件处理失败",e); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|