|
@ -22,6 +22,7 @@ import com.ruoyi.common.utils.StringUtils; |
|
|
import com.ruoyi.common.utils.file.FileDownloadUtils; |
|
|
import com.ruoyi.common.utils.file.FileDownloadUtils; |
|
|
import com.ruoyi.system.domain.*; |
|
|
import com.ruoyi.system.domain.*; |
|
|
import com.ruoyi.system.dto.ExportShippingInformOrderDto; |
|
|
import com.ruoyi.system.dto.ExportShippingInformOrderDto; |
|
|
|
|
|
import com.ruoyi.system.dto.ExportShippingInvoiceDto; |
|
|
import com.ruoyi.system.dto.ExportShippingOrderDto; |
|
|
import com.ruoyi.system.dto.ExportShippingOrderDto; |
|
|
import com.ruoyi.system.dto.ExportShippingPackingDto; |
|
|
import com.ruoyi.system.dto.ExportShippingPackingDto; |
|
|
import com.ruoyi.system.mapper.*; |
|
|
import com.ruoyi.system.mapper.*; |
|
@ -666,6 +667,88 @@ public class SysSalesShippingInformServiceImpl implements ISysSalesShippingInfor |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 导出出货单发票1模板 |
|
|
|
|
|
* */ |
|
|
|
|
|
@Override |
|
|
|
|
|
public void exportShippingInvoiceOne(String outOrderCode, HttpServletResponse response) { |
|
|
|
|
|
String fileName = "销售出货发票1.xlsx"; |
|
|
|
|
|
FileDownloadUtils fileDownloadUtils = new FileDownloadUtils(); |
|
|
|
|
|
try { |
|
|
|
|
|
String fileRelativePath = fileDownloadUtils.getFileRelativePath(fileName); |
|
|
|
|
|
if (StringUtils.isEmpty(outOrderCode)){ |
|
|
|
|
|
log.warn("出货单号为空,请检查:{}", outOrderCode); |
|
|
|
|
|
throw new RuntimeException("出货单号为空,请检查"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
String realFileName = outOrderCode + "-" + fileName.substring(0, fileName.lastIndexOf(".")) + ".xlsx"; |
|
|
|
|
|
|
|
|
|
|
|
//设置响应头,指定文件和文件类型
|
|
|
|
|
|
response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(realFileName, "UTF-8")); |
|
|
|
|
|
response.setContentType("application/octet-stream"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SysSalesShippingInform sysSalesShippingInform = sysSalesShippingInformMapper.selectSysSalesShippingInformByCode(outOrderCode); |
|
|
|
|
|
String salesOrderCode = sysSalesShippingInform.getSalesOrderCode(); |
|
|
|
|
|
SysMakeOrder sysMakeOrder = sysMakeOrderMapper.selectMakeOrderBySaleNo(salesOrderCode); |
|
|
|
|
|
|
|
|
|
|
|
List<SysSalesOrderChild> sysSalesOrderChildren = salesOrderChildMapper.selectOrderChildListBySalesOrderCode(salesOrderCode); |
|
|
|
|
|
|
|
|
|
|
|
String makeNo = sysMakeOrder.getMakeNo(); |
|
|
|
|
|
if (!StringUtils.isEmpty(makeNo)){ |
|
|
|
|
|
List<AfterSalesShippingDevice> afterSalesShippingDevices = salesShippingDeviceMapper.selectShippingDeviceByMakeNo(makeNo); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Map<String, Object> map = new HashMap<>(); |
|
|
|
|
|
map.put("customerContact",sysSalesShippingInform.getCustomerContact()); |
|
|
|
|
|
map.put("customerContactAddress",sysSalesShippingInform.getCustomerContactAddress()); |
|
|
|
|
|
map.put("customerContactBillto",sysSalesShippingInform.getCustomerContactBillto()); |
|
|
|
|
|
map.put("contactAddressBillto",sysSalesShippingInform.getContactAddressBillto()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ArrayList<ExportShippingInvoiceDto> exportShippingInvoiceDtos = new ArrayList<>(); |
|
|
|
|
|
|
|
|
|
|
|
AtomicInteger index = new AtomicInteger(1); |
|
|
|
|
|
|
|
|
|
|
|
for (SysSalesOrderChild sysSalesOrderChild : sysSalesOrderChildren) { |
|
|
|
|
|
ExportShippingInvoiceDto exportShippingInvoiceDto = new ExportShippingInvoiceDto(); |
|
|
|
|
|
exportShippingInvoiceDto.setIndex(index.getAndIncrement()); |
|
|
|
|
|
exportShippingInvoiceDto.setMaterialName(sysSalesOrderChild.getMaterialName()); |
|
|
|
|
|
exportShippingInvoiceDto.setMaterialNum(1); |
|
|
|
|
|
|
|
|
|
|
|
if (sysSalesOrderChild.getMaterialUsd() != null) { |
|
|
|
|
|
exportShippingInvoiceDto.setMaterialUsd(new BigDecimal(sysSalesOrderChild.getMaterialUsd())); |
|
|
|
|
|
} else { |
|
|
|
|
|
// 如果 materialUsd 为 null,可以设置为默认值或者保持不变
|
|
|
|
|
|
exportShippingInvoiceDto.setMaterialUsd(BigDecimal.ZERO); // 示例: 设置为0
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (sysSalesOrderChild.getMaterialUsdSum() != null) { |
|
|
|
|
|
exportShippingInvoiceDto.setMaterialUsdSum(new BigDecimal(sysSalesOrderChild.getMaterialUsdSum())); |
|
|
|
|
|
} else { |
|
|
|
|
|
// 如果 materialUsdSum 为 null,可以设置为默认值或者保持不变
|
|
|
|
|
|
exportShippingInvoiceDto.setMaterialUsdSum(BigDecimal.ZERO); // 示例: 设置为0
|
|
|
|
|
|
} |
|
|
|
|
|
exportShippingInvoiceDto.setMakeNo(makeNo); |
|
|
|
|
|
// to do 缺少物料型号
|
|
|
|
|
|
exportShippingInvoiceDtos.add(exportShippingInvoiceDto); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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(exportShippingInvoiceDtos, fillConfig, sheet); |
|
|
|
|
|
workBook.finish(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} catch (IOException e) { |
|
|
|
|
|
throw new RuntimeException("文件处理失败",e); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 导出出货通知单模板 |
|
|
* 导出出货通知单模板 |
|
|
* */ |
|
|
* */ |
|
|