| | |
| | | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| | | import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; |
| | | import cn.iocoder.yudao.module.crm.controller.admin.quotation.vo.CrmSaleQuotationPageReqVO; |
| | | import cn.iocoder.yudao.module.crm.controller.admin.quotation.vo.CrmSaleQuotationImportExcelVO; |
| | | import cn.iocoder.yudao.module.crm.service.quotation.CrmSaleQuotationImportService; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | import cn.iocoder.yudao.module.crm.controller.admin.quotation.vo.CrmSaleQuotationRespVO; |
| | | import cn.iocoder.yudao.module.crm.controller.admin.quotation.vo.CrmSaleQuotationSaveReqVO; |
| | | import cn.iocoder.yudao.module.crm.dal.dataobject.quotation.CrmSaleQuotationDO; |
| | |
| | | @Resource |
| | | private StorageAttachmentApi storageAttachmentApi; |
| | | |
| | | @Resource |
| | | private CrmSaleQuotationImportService quotationImportService; |
| | | |
| | | @GetMapping("/get-import-template") |
| | | @Operation(summary = "下载销售报价导入模板") |
| | | @PreAuthorize("@ss.hasPermission('crm:sale-quotation:create')") |
| | | public void importTemplate(HttpServletResponse response) throws IOException { |
| | | ExcelUtils.write(response, "销售报价导入模板.xls", "报价明细", CrmSaleQuotationImportExcelVO.class, java.util.Collections.emptyList()); |
| | | } |
| | | |
| | | @PostMapping("/import") |
| | | @Operation(summary = "导入销售报价(仅新增)") |
| | | @PreAuthorize("@ss.hasPermission('crm:sale-quotation:create')") |
| | | public CommonResult<Map<String, Object>> importQuotation(@RequestParam("file") MultipartFile file, |
| | | @RequestParam(value = "updateSupport", defaultValue = "false") boolean updateSupport) throws Exception { |
| | | if (updateSupport) throw new IllegalArgumentException("报价导入仅支持新增,请关闭覆盖选项"); |
| | | return success(quotationImportService.importRows(ExcelUtils.read(file, CrmSaleQuotationImportExcelVO.class), getLoginUserId())); |
| | | } |
| | | @PostMapping("/create") |
| | | @Operation(summary = "创建销售报价单") |
| | | @PreAuthorize("@ss.hasPermission('crm:sale-quotation:create')") |
| | |
| | | |
| | | @DeleteMapping("/delete") |
| | | @Operation(summary = "删除销售报价单") |
| | | @Parameter(name = "ids", description = "编号数组", required = true) |
| | | @Parameter(name = "id", description = "单个编号", required = false) |
| | | @Parameter(name = "ids", description = "编号数组", required = false) |
| | | @PreAuthorize("@ss.hasPermission('crm:sale-quotation:delete')") |
| | | public CommonResult<Boolean> deleteSaleQuotation(@RequestParam("ids") List<Long> ids) { |
| | | saleQuotationService.deleteSaleQuotation(ids); |
| | | public CommonResult<Boolean> deleteSaleQuotation( |
| | | @RequestParam(value = "id", required = false) Long id, |
| | | @RequestParam(value = "ids", required = false) List<Long> ids) { |
| | | // 支持单个id或多个ids |
| | | List<Long> deleteIds = new java.util.ArrayList<>(); |
| | | if (id != null) { |
| | | deleteIds.add(id); |
| | | } |
| | | if (ids != null && !ids.isEmpty()) { |
| | | deleteIds.addAll(ids); |
| | | } |
| | | if (deleteIds.isEmpty()) { |
| | | throw new IllegalArgumentException("请求参数缺失:id 或 ids"); |
| | | } |
| | | saleQuotationService.deleteSaleQuotation(deleteIds); |
| | | return success(true); |
| | | } |
| | | |
| | | @GetMapping("/get") |
| | | @Operation(summary = "获得销售报价单") |
| | | @Parameter(name = "id", description = "编号", required = true, example = "1024") |
| | | @PreAuthorize("@ss.hasPermission('crm:sale-quotation:query')") |
| | | public CommonResult<CrmSaleQuotationRespVO> getSaleQuotation(@RequestParam("id") Long id) { |
| | | CrmSaleQuotationDO saleQuotation = saleQuotationService.getSaleQuotation(id); |
| | | if (saleQuotation == null) { |
| | |
| | | |
| | | @GetMapping("/page") |
| | | @Operation(summary = "获得销售报价单分页") |
| | | @PreAuthorize("@ss.hasPermission('crm:sale-quotation:query')") |
| | | public CommonResult<PageResult<CrmSaleQuotationRespVO>> getSaleQuotationPage(@Valid CrmSaleQuotationPageReqVO pageReqVO) { |
| | | PageResult<CrmSaleQuotationDO> pageResult = saleQuotationService.getSaleQuotationPage(pageReqVO, getLoginUserId()); |
| | | return success(buildSaleQuotationRespVOPageResult(pageResult)); |
| | |
| | | |
| | | @GetMapping("/page-by-customer") |
| | | @Operation(summary = "获得销售报价单分页(基于客户)") |
| | | @PreAuthorize("@ss.hasPermission('crm:sale-quotation:query')") |
| | | public CommonResult<PageResult<CrmSaleQuotationRespVO>> getSaleQuotationPageByCustomerId(@Valid CrmSaleQuotationPageReqVO pageReqVO) { |
| | | PageResult<CrmSaleQuotationDO> pageResult = saleQuotationService.getSaleQuotationPageByCustomerId(pageReqVO); |
| | | return success(buildSaleQuotationRespVOPageResult(pageResult)); |
| | |
| | | |
| | | @GetMapping("/page-by-business") |
| | | @Operation(summary = "获得销售报价单分页(基于商机)") |
| | | @PreAuthorize("@ss.hasPermission('crm:sale-quotation:query')") |
| | | public CommonResult<PageResult<CrmSaleQuotationRespVO>> getSaleQuotationPageByBusinessId(@Valid CrmSaleQuotationPageReqVO pageReqVO) { |
| | | PageResult<CrmSaleQuotationDO> pageResult = saleQuotationService.getSaleQuotationPageByBusinessId(pageReqVO); |
| | | return success(buildSaleQuotationRespVOPageResult(pageResult)); |