|
@ -1,5 +1,9 @@ |
|
|
package com.ruoyi.system.service.impl; |
|
|
package com.ruoyi.system.service.impl; |
|
|
|
|
|
|
|
|
|
|
|
import com.alibaba.excel.EasyExcel; |
|
|
|
|
|
import com.alibaba.excel.ExcelWriter; |
|
|
|
|
|
import com.alibaba.excel.write.metadata.WriteSheet; |
|
|
|
|
|
import com.alibaba.excel.write.metadata.fill.FillConfig; |
|
|
import com.github.pagehelper.Page; |
|
|
import com.github.pagehelper.Page; |
|
|
import com.github.pagehelper.PageHelper; |
|
|
import com.github.pagehelper.PageHelper; |
|
|
import com.ruoyi.common.core.domain.entity.SysUser; |
|
|
import com.ruoyi.common.core.domain.entity.SysUser; |
|
@ -12,6 +16,7 @@ import com.ruoyi.common.service.ICommonService; |
|
|
import com.ruoyi.common.utils.DateUtils; |
|
|
import com.ruoyi.common.utils.DateUtils; |
|
|
import com.ruoyi.common.utils.ShiroUtils; |
|
|
import com.ruoyi.common.utils.ShiroUtils; |
|
|
import com.ruoyi.common.utils.StringUtils; |
|
|
import com.ruoyi.common.utils.StringUtils; |
|
|
|
|
|
import com.ruoyi.common.utils.file.FileDownloadUtils; |
|
|
import com.ruoyi.process.general.service.IProcessService; |
|
|
import com.ruoyi.process.general.service.IProcessService; |
|
|
import com.ruoyi.process.todoitem.mapper.BizTodoItemMapper; |
|
|
import com.ruoyi.process.todoitem.mapper.BizTodoItemMapper; |
|
|
import com.ruoyi.system.domain.*; |
|
|
import com.ruoyi.system.domain.*; |
|
@ -33,8 +38,12 @@ import org.springframework.stereotype.Service; |
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
import org.springframework.util.CollectionUtils; |
|
|
import org.springframework.util.CollectionUtils; |
|
|
|
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
|
|
|
import java.io.IOException; |
|
|
import java.math.BigDecimal; |
|
|
import java.math.BigDecimal; |
|
|
|
|
|
import java.net.URLEncoder; |
|
|
import java.util.*; |
|
|
import java.util.*; |
|
|
|
|
|
import java.util.concurrent.atomic.AtomicInteger; |
|
|
import java.util.stream.Collectors; |
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
@ -92,8 +101,7 @@ public class SysSalesOrderServiceImpl implements ISysSalesOrderService |
|
|
private ISysUserService sysUserService; |
|
|
private ISysUserService sysUserService; |
|
|
|
|
|
|
|
|
private final static String RMB = "1"; //RMB
|
|
|
private final static String RMB = "1"; //RMB
|
|
|
|
|
|
|
|
|
private final static String USD = "2"; //美元
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 查询销售订单 |
|
|
* 查询销售订单 |
|
@ -558,4 +566,141 @@ public class SysSalesOrderServiceImpl implements ISysSalesOrderService |
|
|
vo.setMaterialTaxMoney(tax); |
|
|
vo.setMaterialTaxMoney(tax); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 导出销售订单模板数据 |
|
|
|
|
|
*/ |
|
|
|
|
|
@Override |
|
|
|
|
|
public void exportSalesOrder(ExportSalesOrderVo exportSalesOrderVo, HttpServletResponse response) { |
|
|
|
|
|
String salesOrderCode = exportSalesOrderVo.getSalesOrderCode(); |
|
|
|
|
|
Long salesOrderId = exportSalesOrderVo.getSalesOrderId(); |
|
|
|
|
|
|
|
|
|
|
|
String fileName = "销售订单.xlsx"; |
|
|
|
|
|
try { |
|
|
|
|
|
FileDownloadUtils fileDownloadUtils = new FileDownloadUtils(); |
|
|
|
|
|
String fileRelativePath = fileDownloadUtils.getFileRelativePath(fileName); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String realFileName = salesOrderCode +"-" +fileRelativePath.substring(0,fileName.lastIndexOf(".")) + ".xlsx"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 设置响应头,指定文件名和文件类型
|
|
|
|
|
|
response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(realFileName, "UTF-8")); |
|
|
|
|
|
response.setContentType("application/octet-stream"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SysSalesOrderVo sysSalesOrderVo = sysSalesOrderMapper.selectSysSalesOrderById(salesOrderId); |
|
|
|
|
|
if (sysSalesOrderVo == null){ |
|
|
|
|
|
throw new RuntimeException("销售订单为空"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
HashMap<String, Object> map = new HashMap<>(); |
|
|
|
|
|
|
|
|
|
|
|
map.put("salesOrderType", exportSalesOrderVo.getSalesOrderType()); |
|
|
|
|
|
map.put("enterpriseCode", exportSalesOrderVo.getEnterpriseCode()); |
|
|
|
|
|
map.put("salesOrderNumber", exportSalesOrderVo.getSalesOrderNumber()); |
|
|
|
|
|
map.put("paymentTerms", exportSalesOrderVo.getPaymentTerms()); |
|
|
|
|
|
map.put("tradeClause", exportSalesOrderVo.getTradeClause()); |
|
|
|
|
|
map.put("invoice", sysSalesOrderVo.getInvoice()); |
|
|
|
|
|
map.put("commonCurrency", sysSalesOrderVo.getCommonCurrency()); |
|
|
|
|
|
map.put("taxMoneySum", exportSalesOrderVo.getTaxMoneySum()); |
|
|
|
|
|
map.put("noTaxMoneySum", exportSalesOrderVo.getNoTaxMoneySum()); |
|
|
|
|
|
map.put("warrantyDate", exportSalesOrderVo.getWarrantyDate()); |
|
|
|
|
|
map.put("remark", exportSalesOrderVo.getRemark()); |
|
|
|
|
|
|
|
|
|
|
|
List<ExportSalesOrderChildVo> exportSalesOrderChildVoList = exportSalesOrderVo.getExportSalesOrderChildVoList(); |
|
|
|
|
|
|
|
|
|
|
|
ExcelWriter workBook = EasyExcel.write(response.getOutputStream()).withTemplate(fileRelativePath).build(); |
|
|
|
|
|
WriteSheet sheet = EasyExcel.writerSheet().build(); |
|
|
|
|
|
FillConfig fillConfig = FillConfig.builder().forceNewRow(true).build(); |
|
|
|
|
|
workBook.fill(map, sheet); |
|
|
|
|
|
workBook.fill(exportSalesOrderChildVoList, fillConfig, sheet); |
|
|
|
|
|
workBook.finish(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}catch (IOException | RuntimeException e){ |
|
|
|
|
|
throw new RuntimeException("文件处理失败",e); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public void exportSalesOrderByCode(String salesOrderCode, HttpServletResponse response) { |
|
|
|
|
|
|
|
|
|
|
|
String fileName = "销售订单.xlsx"; |
|
|
|
|
|
try { |
|
|
|
|
|
FileDownloadUtils fileDownloadUtils = new FileDownloadUtils(); |
|
|
|
|
|
String fileRelativePath = fileDownloadUtils.getFileRelativePath(fileName); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String realFileName = salesOrderCode +"-" +fileName.substring(0,fileName.lastIndexOf(".")) + ".xlsx"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 设置响应头,指定文件名和文件类型
|
|
|
|
|
|
response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(realFileName, "UTF-8")); |
|
|
|
|
|
response.setContentType("application/octet-stream"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SysSalesOrderVo sysSalesOrderVo = sysSalesOrderMapper.selectSysSalesOrderBySalesOrderCode(salesOrderCode); |
|
|
|
|
|
if (sysSalesOrderVo == null){ |
|
|
|
|
|
throw new RuntimeException("销售订单为空"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
ExportSalesOrderVo exportSalesOrderVo = selectExportSalesOrderById(sysSalesOrderVo.getSalesOrderId()); |
|
|
|
|
|
|
|
|
|
|
|
List<ExportSalesOrderChildVo> exportSalesOrderChildVoList = showExportSalesOrderChildListByICode(salesOrderCode); |
|
|
|
|
|
|
|
|
|
|
|
AtomicInteger index = new AtomicInteger(1); |
|
|
|
|
|
exportSalesOrderChildVoList.forEach(exportSalesOrderChildVo -> { |
|
|
|
|
|
exportSalesOrderChildVo.setIndex(index.getAndIncrement()); |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
String invoice = sysSalesOrderVo.getInvoice(); |
|
|
|
|
|
|
|
|
|
|
|
if ("1".equals(invoice)){ |
|
|
|
|
|
invoice = "是"; |
|
|
|
|
|
}else { |
|
|
|
|
|
invoice = "否"; |
|
|
|
|
|
} |
|
|
|
|
|
String commonCurrency = sysSalesOrderVo.getCommonCurrency(); |
|
|
|
|
|
if (RMB.equals(commonCurrency)){ |
|
|
|
|
|
commonCurrency = "人民币"; |
|
|
|
|
|
}else { |
|
|
|
|
|
commonCurrency = "美元"; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
HashMap<String, Object> map = new HashMap<>(); |
|
|
|
|
|
|
|
|
|
|
|
map.put("salesOrderType", exportSalesOrderVo.getSalesOrderType()); |
|
|
|
|
|
map.put("enterpriseCode", exportSalesOrderVo.getEnterpriseCode()); |
|
|
|
|
|
map.put("salesOrderNumber", exportSalesOrderVo.getSalesOrderNumber()); |
|
|
|
|
|
map.put("paymentTerms", exportSalesOrderVo.getPaymentTerms()); |
|
|
|
|
|
map.put("tradeClause", exportSalesOrderVo.getTradeClause()); |
|
|
|
|
|
map.put("invoice",invoice ); |
|
|
|
|
|
map.put("commonCurrency", commonCurrency); |
|
|
|
|
|
map.put("taxMoneySum", exportSalesOrderVo.getTaxMoneySum()); |
|
|
|
|
|
map.put("noTaxMoneySum", exportSalesOrderVo.getNoTaxMoneySum()); |
|
|
|
|
|
map.put("warrantyDate", exportSalesOrderVo.getWarrantyDate()); |
|
|
|
|
|
map.put("remark", exportSalesOrderVo.getRemark()); |
|
|
|
|
|
|
|
|
|
|
|
ExcelWriter workBook = EasyExcel.write(response.getOutputStream()).withTemplate(fileRelativePath).build(); |
|
|
|
|
|
WriteSheet sheet = EasyExcel.writerSheet().build(); |
|
|
|
|
|
FillConfig fillConfig = FillConfig.builder().forceNewRow(true).build(); |
|
|
|
|
|
workBook.fill(map, sheet); |
|
|
|
|
|
workBook.fill(exportSalesOrderChildVoList, fillConfig, sheet); |
|
|
|
|
|
workBook.finish(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}catch (IOException | RuntimeException e){ |
|
|
|
|
|
throw new RuntimeException("文件处理失败",e); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|