云
17 小时以前 fec1341c1cb8e11cfbe3fa7dfabe447edb72b630
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/wm/productsales/MesWmProductSalesController.java
@@ -8,14 +8,14 @@
import cn.iocoder.yudao.framework.common.util.collection.MapUtils;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
import cn.iocoder.yudao.module.crm.api.customer.CrmCustomerApi;
import cn.iocoder.yudao.module.crm.api.customer.dto.CrmCustomerRespDTO;
import cn.iocoder.yudao.module.mes.controller.admin.wm.productsales.vo.MesWmProductSalesPageReqVO;
import cn.iocoder.yudao.module.mes.controller.admin.wm.productsales.vo.MesWmProductSalesRespVO;
import cn.iocoder.yudao.module.mes.controller.admin.wm.productsales.vo.MesWmProductSalesSaveReqVO;
import cn.iocoder.yudao.module.mes.controller.admin.wm.productsales.vo.MesWmProductSalesShippingReqVO;
import cn.iocoder.yudao.module.mes.dal.dataobject.md.client.MesMdClientDO;
import cn.iocoder.yudao.module.mes.dal.dataobject.wm.productsales.MesWmProductSalesDO;
import cn.iocoder.yudao.module.mes.dal.dataobject.wm.salesnotice.MesWmSalesNoticeDO;
import cn.iocoder.yudao.module.mes.service.md.client.MesMdClientService;
import cn.iocoder.yudao.module.mes.service.wm.productsales.MesWmProductSalesService;
import cn.iocoder.yudao.module.mes.service.wm.salesnotice.MesWmSalesNoticeService;
import io.swagger.v3.oas.annotations.Operation;
@@ -44,7 +44,7 @@
    @Resource
    private MesWmProductSalesService productSalesService;
    @Resource
    private MesMdClientService clientService;
    private CrmCustomerApi crmCustomerApi;
    @Resource
    private MesWmSalesNoticeService salesNoticeService;
@@ -75,7 +75,6 @@
    @GetMapping("/get")
    @Operation(summary = "获得销售出库单")
    @Parameter(name = "id", description = "编号", required = true, example = "1024")
    @PreAuthorize("@ss.hasPermission('mes:wm-product-sales:query')")
    public CommonResult<MesWmProductSalesRespVO> getProductSales(@RequestParam("id") Long id) {
        MesWmProductSalesDO sales = productSalesService.getProductSales(id);
        if (sales == null) {
@@ -86,7 +85,6 @@
    @GetMapping("/page")
    @Operation(summary = "获得销售出库单分页")
    @PreAuthorize("@ss.hasPermission('mes:wm-product-sales:query')")
    public CommonResult<PageResult<MesWmProductSalesRespVO>> getProductSalesPage(
            @Valid MesWmProductSalesPageReqVO pageReqVO) {
        PageResult<MesWmProductSalesDO> pageResult = productSalesService.getProductSalesPage(pageReqVO);
@@ -117,7 +115,6 @@
    @GetMapping("/check-quantity")
    @Operation(summary = "校验销售出库单数量")
    @Parameter(name = "id", description = "编号", required = true)
    @PreAuthorize("@ss.hasPermission('mes:wm-product-sales:query')")
    public CommonResult<Boolean> checkProductSalesQuantity(@RequestParam("id") Long id) {
        return success(productSalesService.checkProductSalesQuantity(id));
    }
@@ -164,17 +161,17 @@
            return Collections.emptyList();
        }
        // 1. 获得关联数据
        Map<Long, MesMdClientDO> clientMap = clientService.getClientMap(
        Map<Long, CrmCustomerRespDTO> customerMap = crmCustomerApi.getCustomerMap(
                convertSet(list, MesWmProductSalesDO::getClientId));
        Map<Long, MesWmSalesNoticeDO> noticeMap = salesNoticeService.getSalesNoticeMap(
                convertSet(list, MesWmProductSalesDO::getNoticeId));
        // 2. 构建结果
        return BeanUtils.toBean(list, MesWmProductSalesRespVO.class, vo -> {
            MapUtils.findAndThen(clientMap, vo.getClientId(), client ->
                    vo.setClientName(client.getName()).setClientCode(client.getCode()));
            MapUtils.findAndThen(customerMap, vo.getClientId(), customer ->
                    vo.setClientName(customer.getName()));
            MapUtils.findAndThen(noticeMap, vo.getNoticeId(),
                    notice -> vo.setNoticeCode(notice.getCode()));
        });
    }
}
}