| | |
| | | import cn.iocoder.yudao.module.crm.controller.admin.quotation.vo.CrmSaleQuotationSaveReqVO; |
| | | import cn.iocoder.yudao.module.crm.dal.dataobject.quotation.CrmSaleQuotationDO; |
| | | import cn.iocoder.yudao.module.crm.dal.dataobject.quotation.CrmSaleQuotationProductDO; |
| | | import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; |
| | | import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerService; |
| | | import cn.iocoder.yudao.module.crm.service.quotation.CrmSaleQuotationService; |
| | | import cn.iocoder.yudao.module.mdm.api.item.MdmItemApi; |
| | | import cn.iocoder.yudao.module.mdm.api.item.dto.MdmItemRespDTO; |
| | |
| | | private MdmItemApi mdmItemApi; |
| | | @Resource |
| | | private MdmUnitMeasureApi mdmUnitMeasureApi; |
| | | @Resource |
| | | private CrmCustomerService customerService; |
| | | |
| | | @PostMapping("/create") |
| | | @Operation(summary = "创建销售报价单") |
| | |
| | | ExcelUtils.write(response, "销售报价单.xls", "数据", CrmSaleQuotationRespVO.class, list); |
| | | } |
| | | |
| | | @PutMapping("/submit") |
| | | @Operation(summary = "提交销售报价审批") |
| | | @PreAuthorize("@ss.hasPermission('crm:sale-quotation:submit')") |
| | | public CommonResult<Boolean> submitSaleQuotation(@RequestParam("id") Long id, |
| | | @RequestParam("processDefinitionKey") String processDefinitionKey) { |
| | | saleQuotationService.submitSaleQuotation(id, processDefinitionKey, getLoginUserId()); |
| | | return success(true); |
| | | } |
| | | |
| | | @GetMapping("/approve-process-list") |
| | | @Operation(summary = "获取销售报价审批流程列表") |
| | | @PreAuthorize("@ss.hasPermission('crm:sale-quotation:query')") |
| | | public CommonResult<List<Map<String, Object>>> getSaleQuotationApproveProcessList() { |
| | | return success(saleQuotationService.getSaleQuotationApproveProcessDefinitionList()); |
| | | } |
| | | |
| | | @PostMapping("/convert-contract") |
| | | @Operation(summary = "转为合同") |
| | | @Parameter(name = "id", description = "报价单编号", required = true) |
| | |
| | | MapUtils.findAndThen(unitMap, item.getItemUnitId(), unit -> item.setItemUnitName(unit.getName())); |
| | | })); |
| | | } |
| | | // 2. 填充关联信息 |
| | | // 2. 填充客户名称 |
| | | if (saleQuotation.getCustomerId() != null) { |
| | | CrmCustomerDO customer = customerService.getCustomer(saleQuotation.getCustomerId()); |
| | | if (customer != null) { |
| | | respVO.setCustomerName(customer.getName()); |
| | | } |
| | | } |
| | | // 3. 填充关联信息 |
| | | fillSaleQuotationRelatedFields(respVO); |
| | | return respVO; |
| | | } |
| | |
| | | Map<Long, List<CrmSaleQuotationProductDO>> productMap = convertMultiMap(productList, CrmSaleQuotationProductDO::getQuotationId); |
| | | // 1.2 物料信息 |
| | | Map<Long, MdmItemRespDTO> itemMap = mdmItemApi.getItemMap(convertSet(productList, CrmSaleQuotationProductDO::getItemId)); |
| | | // 1.3 用户信息 |
| | | // 1.3 客户信息 |
| | | Map<Long, CrmCustomerDO> customerMap = customerService.getCustomerMap( |
| | | convertSet(pageResult.getList(), CrmSaleQuotationDO::getCustomerId)); |
| | | // 1.4 用户信息 |
| | | Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap( |
| | | convertSet(pageResult.getList(), CrmSaleQuotationDO::getOwnerUserId)); |
| | | // 1.4 部门信息 |
| | | // 1.5 部门信息 |
| | | Map<Long, DeptRespDTO> deptMap = deptApi.getDeptMap( |
| | | convertSet(pageResult.getList(), CrmSaleQuotationDO::getOwnerUserId)); |
| | | |
| | |
| | | vo.setItems(BeanUtils.toBean(productMap.get(vo.getId()), CrmSaleQuotationRespVO.Item.class, |
| | | item -> MapUtils.findAndThen(itemMap, item.getItemId(), mdmItem -> item.setItemCode(mdmItem.getCode()) |
| | | .setItemName(mdmItem.getName()).setItemBarCode(mdmItem.getBarCode())))); |
| | | MapUtils.findAndThen(customerMap, vo.getCustomerId(), customer -> vo.setCustomerName(customer.getName())); |
| | | MapUtils.findAndThen(userMap, vo.getOwnerUserId(), user -> vo.setOwnerUserName(user.getNickname())); |
| | | MapUtils.findAndThen(deptMap, vo.getOwnerUserId(), dept -> vo.setOwnerUserDeptName(dept.getName())); |
| | | }); |