From aa624335b1ac67222c42eb8b5b81e73b6b96d32d Mon Sep 17 00:00:00 2001
From: liu <2021943741@qq.com>
Date: 星期一, 17 八月 2026 15:38:36 +0800
Subject: [PATCH] 销售报价删除接口支持单个id参数

---
 yudao-module-crm/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/quotation/CrmSaleQuotationController.java |  120 ++++++++++++++++++++++++++++++++++++++++++++++-------------
 1 files changed, 93 insertions(+), 27 deletions(-)

diff --git a/yudao-module-crm/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/quotation/CrmSaleQuotationController.java b/yudao-module-crm/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/quotation/CrmSaleQuotationController.java
index e1f2713..af0912e 100644
--- a/yudao-module-crm/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/quotation/CrmSaleQuotationController.java
+++ b/yudao-module-crm/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/quotation/CrmSaleQuotationController.java
@@ -13,6 +13,10 @@
 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.business.CrmBusinessDO;
+import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO;
+import cn.iocoder.yudao.module.crm.service.business.CrmBusinessService;
+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;
@@ -20,6 +24,7 @@
 import cn.iocoder.yudao.module.mdm.api.unit.dto.MdmUnitMeasureRespDTO;
 import cn.iocoder.yudao.module.system.api.dept.DeptApi;
 import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO;
+import cn.iocoder.yudao.module.system.api.storage.StorageAttachmentApi;
 import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
 import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
 import io.swagger.v3.oas.annotations.Operation;
@@ -38,8 +43,10 @@
 
 import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
 import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
+import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList;
 import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMultiMap;
 import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
+import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap;
 import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
 
 @Tag(name = "绠$悊鍚庡彴 - CRM 閿�鍞姤浠峰崟")
@@ -59,6 +66,12 @@
     private MdmItemApi mdmItemApi;
     @Resource
     private MdmUnitMeasureApi mdmUnitMeasureApi;
+    @Resource
+    private CrmCustomerService customerService;
+    @Resource
+    private CrmBusinessService businessService;
+    @Resource
+    private StorageAttachmentApi storageAttachmentApi;
 
     @PostMapping("/create")
     @Operation(summary = "鍒涘缓閿�鍞姤浠峰崟")
@@ -77,10 +90,24 @@
 
     @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鎴栧涓猧ds
+        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);
     }
 
@@ -133,22 +160,6 @@
         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)
@@ -164,20 +175,48 @@
         // 1. 鏋勫缓鐗╂枡鏄庣粏
         if (CollUtil.isNotEmpty(productList)) {
             Map<Long, MdmItemRespDTO> itemMap = mdmItemApi.getItemMap(convertSet(productList, CrmSaleQuotationProductDO::getItemId));
-            Map<Long, MdmUnitMeasureRespDTO> unitMap = mdmUnitMeasureApi.getUnitMeasureMap(
-                    convertSet(productList, CrmSaleQuotationProductDO::getItemUnitId));
+            java.util.Set<Long> unitIds = new java.util.HashSet<>(convertSet(productList, CrmSaleQuotationProductDO::getItemUnitId));
+            itemMap.values().forEach(item -> {
+                if (item.getUnitMeasureId2() != null) {
+                    unitIds.add(item.getUnitMeasureId2());
+                }
+            });
+            Map<Long, MdmUnitMeasureRespDTO> unitMap = convertMap(
+                    mdmUnitMeasureApi.getUnitMeasureList(unitIds).getCheckedData(),
+                    MdmUnitMeasureRespDTO::getId);
             respVO.setItems(BeanUtils.toBean(productList, CrmSaleQuotationRespVO.Item.class, item -> {
                 MdmItemRespDTO mdmItem = itemMap.get(item.getItemId());
                 if (mdmItem != null) {
                     item.setItemCode(mdmItem.getCode());
                     item.setItemName(mdmItem.getName());
                     item.setItemBarCode(mdmItem.getBarCode());
+                    item.setItemSpecification(mdmItem.getSpecification());
+                    item.setItemUnitId2(mdmItem.getUnitMeasureId2());
+                    item.setItemUnitId3(mdmItem.getUnitMeasureId3());
                 }
                 MapUtils.findAndThen(unitMap, item.getItemUnitId(), unit -> item.setItemUnitName(unit.getName()));
+                MapUtils.findAndThen(unitMap, item.getItemUnitId2(), unit -> item.setItemUnitName2(unit.getName()));
+                MapUtils.findAndThen(unitMap, item.getItemUnitId3(), unit -> item.setItemUnitName3(unit.getName()));
             }));
         }
-        // 2. 濉厖鍏宠仈淇℃伅
+        // 2. 濉厖瀹㈡埛鍚嶇О
+        if (saleQuotation.getCustomerId() != null) {
+            CrmCustomerDO customer = customerService.getCustomer(saleQuotation.getCustomerId());
+            if (customer != null) {
+                respVO.setCustomerName(customer.getName());
+            }
+        }
+        // 2.1 濉厖鍟嗘満鍚嶇О
+        if (saleQuotation.getBusinessId() != null) {
+            CrmBusinessDO business = businessService.getBusiness(saleQuotation.getBusinessId());
+            if (business != null) {
+                respVO.setBusinessName(business.getName());
+            }
+        }
+        // 3. 濉厖鍏宠仈淇℃伅
         fillSaleQuotationRelatedFields(respVO);
+        // 4. 濉厖闄勪欢鍒楄〃
+        respVO.setAttachmentList(storageAttachmentApi.listAttachments("crm_sale_quotation", saleQuotation.getId()));
         return respVO;
     }
 
@@ -191,20 +230,47 @@
         Map<Long, List<CrmSaleQuotationProductDO>> productMap = convertMultiMap(productList, CrmSaleQuotationProductDO::getQuotationId);
         // 1.2 鐗╂枡淇℃伅
         Map<Long, MdmItemRespDTO> itemMap = mdmItemApi.getItemMap(convertSet(productList, CrmSaleQuotationProductDO::getItemId));
-        // 1.3 鐢ㄦ埛淇℃伅
+        java.util.Set<Long> unitIds = new java.util.HashSet<>(convertSet(productList, CrmSaleQuotationProductDO::getItemUnitId));
+        itemMap.values().forEach(item -> {
+            if (item.getUnitMeasureId2() != null) {
+                unitIds.add(item.getUnitMeasureId2());
+            }
+        });
+        Map<Long, MdmUnitMeasureRespDTO> unitMap = convertMap(
+                mdmUnitMeasureApi.getUnitMeasureList(unitIds).getCheckedData(),
+                MdmUnitMeasureRespDTO::getId);
+        // 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));
+        // 1.6 鍟嗘満淇℃伅锛堣繃婊� null锛宐usinessId 涓哄彲閫夊瓧娈碉級
+        Map<Long, CrmBusinessDO> businessMap = businessService.getBusinessMap(
+                convertSet(pageResult.getList(), CrmSaleQuotationDO::getBusinessId, vo -> vo.getBusinessId() != null));
 
         // 2. 寮�濮嬫嫾鎺�
         return BeanUtils.toBean(pageResult, CrmSaleQuotationRespVO.class, vo -> {
             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()))));
+                    item -> {
+                        MapUtils.findAndThen(itemMap, item.getItemId(), mdmItem -> item
+                                .setItemCode(mdmItem.getCode())
+                                .setItemName(mdmItem.getName())
+                                .setItemBarCode(mdmItem.getBarCode())
+                                .setItemSpecification(mdmItem.getSpecification())
+                                .setItemUnitId2(mdmItem.getUnitMeasureId2())
+                                .setItemUnitId3(mdmItem.getUnitMeasureId3()));
+                        MapUtils.findAndThen(unitMap, item.getItemUnitId(), unit -> item.setItemUnitName(unit.getName()));
+                        MapUtils.findAndThen(unitMap, item.getItemUnitId2(), unit -> item.setItemUnitName2(unit.getName()));
+                        MapUtils.findAndThen(unitMap, item.getItemUnitId3(), unit -> item.setItemUnitName3(unit.getName()));
+                    }));
+            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()));
+            MapUtils.findAndThen(businessMap, vo.getBusinessId(), business -> vo.setBusinessName(business.getName()));
         });
     }
 
@@ -235,4 +301,4 @@
         }
     }
 
-}
\ No newline at end of file
+}

--
Gitblit v1.9.3