| | |
| | | import cn.iocoder.yudao.module.crm.service.business.CrmBusinessService; |
| | | import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerService; |
| | | import cn.iocoder.yudao.module.crm.enums.quotation.CrmSaleQuotationStatusEnum; |
| | | import cn.iocoder.yudao.module.crm.service.quotation.CrmSaleQuotationDocumentRenderer; |
| | | import cn.iocoder.yudao.module.crm.service.quotation.CrmSaleQuotationExcelRenderer; |
| | | import cn.iocoder.yudao.module.crm.service.contact.CrmContactService; |
| | | import cn.iocoder.yudao.module.crm.service.quotation.CrmSaleQuotationService; |
| | | import cn.iocoder.yudao.module.system.service.companyconfig.SystemCompanyConfigService; |
| | | import cn.iocoder.yudao.module.mdm.api.item.MdmItemApi; |
| | |
| | | private MdmUnitMeasureApi mdmUnitMeasureApi; |
| | | @Resource |
| | | private CrmCustomerService customerService; |
| | | @Resource |
| | | private CrmContactService contactService; |
| | | @Resource |
| | | private CrmBusinessService businessService; |
| | | @Resource |
| | |
| | | ExcelUtils.write(response, "销售报价单.xls", "数据", CrmSaleQuotationRespVO.class, list); |
| | | } |
| | | |
| | | @GetMapping("/export-word") |
| | | @Operation(summary = "导出销售报价单 Word(带电子章)") |
| | | @GetMapping({"/export-word", "/export-quotation-excel"}) |
| | | @Operation(summary = "导出销售报价单 Excel(带电子章)") |
| | | @Parameter(name = "id", description = "报价单编号", required = true) |
| | | @PreAuthorize("@ss.hasPermission('crm:sale-quotation:export')") |
| | | @ApiAccessLog(operateType = EXPORT) |
| | |
| | | saleQuotationService.getSaleQuotationProductListByQuotationId(id)); |
| | | var companyConfig = companyConfigService.getCompanyConfig(); |
| | | String companyName = companyConfig != null ? companyConfig.getCompanyName() : null; |
| | | byte[] content = CrmSaleQuotationDocumentRenderer.render(respVO, companyName); |
| | | var customer = saleQuotation.getCustomerId() == null ? null : customerService.getCustomer(saleQuotation.getCustomerId()); |
| | | var contact = saleQuotation.getContactId() == null ? null : contactService.getContact(saleQuotation.getContactId()); |
| | | String phone = contact == null ? null : (contact.getMobile() != null && !contact.getMobile().isBlank() |
| | | ? contact.getMobile() : contact.getTelephone()); |
| | | byte[] content = CrmSaleQuotationExcelRenderer.render(respVO, companyName, |
| | | customer == null ? null : customer.getDetailAddress(), contact == null ? null : contact.getName(), phone); |
| | | |
| | | String filename = "报价单-" + saleQuotation.getNo() |
| | | + (respVO.getCustomerName() != null ? "-" + respVO.getCustomerName() : "") + ".docx"; |
| | | + (respVO.getCustomerName() != null ? "-" + respVO.getCustomerName() : "") + ".xlsx"; |
| | | String encoded = URLEncoder.encode(filename, StandardCharsets.UTF_8).replace("+", "%20"); |
| | | response.setContentType("application/vnd.openxmlformats-officedocument.wordprocessingml.document"); |
| | | response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); |
| | | response.setHeader("Content-Disposition", "attachment;filename*=UTF-8''" + encoded); |
| | | response.getOutputStream().write(content); |
| | | } |