| | |
| | | return contractVO; |
| | | } |
| | | |
| | | @GetMapping("/download-document") |
| | | @Operation(summary = "按购销合同模板下载合同 Word 文件") |
| | | @PreAuthorize("@ss.hasPermission('crm:contract:query')") |
| | | public void downloadDocument(@RequestParam("id") Long id, HttpServletResponse response) throws IOException { |
| | | // getContract 包含合同数据权限校验;沿用详情页的产品、单位和客户信息。 |
| | | CrmContractRespVO contract = buildContractDetail(contractService.getContract(id)); |
| | | Assert.notNull(contract, "合同不存在"); |
| | | byte[] content = cn.iocoder.yudao.module.crm.service.contract.CrmContractDocumentRenderer.render(contract); |
| | | String filename = "购销合同-" + contract.getNo() + ".docx"; |
| | | response.setContentType("application/vnd.openxmlformats-officedocument.wordprocessingml.document"); |
| | | response.setHeader("Cache-Control", "no-store"); |
| | | response.setHeader("Content-Disposition", "attachment; filename*=UTF-8''" + java.net.URLEncoder.encode(filename, java.nio.charset.StandardCharsets.UTF_8).replace("+", "%20")); |
| | | response.setContentLength(content.length); |
| | | response.getOutputStream().write(content); |
| | | } |
| | | |
| | | @GetMapping("/page") |
| | | @Operation(summary = "获得合同分页") |
| | | @PreAuthorize("@ss.hasPermission('crm:contract:query')") |
| | |
| | | @ApiAccessLog(operateType = EXPORT) |
| | | public void exportContractExcel(@Valid CrmContractPageReqVO exportReqVO, |
| | | HttpServletResponse response) throws IOException { |
| | | exportReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); // 不分页,导出全部符合条件的合同 |
| | | PageResult<CrmContractDO> pageResult = contractService.getContractPage(exportReqVO, getLoginUserId()); |
| | | // 拼接客户、商机、签约人、回款金额等关联信息 |
| | | List<CrmContractRespVO> list = buildContractDetailList(pageResult.getList()); |