mirror of
				https://gitee.com/hhyykk/ipms-sjy.git
				synced 2025-10-31 18:28:43 +08:00 
			
		
		
		
	style: 客户 review 修改
This commit is contained in:
		| @@ -5,6 +5,8 @@ import cn.hutool.core.util.NumberUtil; | |||||||
| import cn.hutool.core.util.ObjectUtil; | import cn.hutool.core.util.ObjectUtil; | ||||||
| import cn.iocoder.yudao.framework.common.pojo.CommonResult; | import cn.iocoder.yudao.framework.common.pojo.CommonResult; | ||||||
| import cn.iocoder.yudao.framework.common.pojo.PageResult; | import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||||||
|  | import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; | ||||||
|  | import cn.iocoder.yudao.framework.common.util.collection.MapUtils; | ||||||
| import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; | import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; | ||||||
| import cn.iocoder.yudao.framework.ip.core.utils.AreaUtils; | import cn.iocoder.yudao.framework.ip.core.utils.AreaUtils; | ||||||
| import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; | import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; | ||||||
| @@ -101,25 +103,10 @@ public class CrmCustomerController { | |||||||
|     @PreAuthorize("@ss.hasPermission('crm:customer:query')") |     @PreAuthorize("@ss.hasPermission('crm:customer:query')") | ||||||
|     public CommonResult<PageResult<CrmCustomerRespVO>> getCustomerPage(@Valid CrmCustomerPageReqVO pageVO) { |     public CommonResult<PageResult<CrmCustomerRespVO>> getCustomerPage(@Valid CrmCustomerPageReqVO pageVO) { | ||||||
|         PageResult<CrmCustomerDO> pageResult = customerService.getCustomerPage(pageVO); |         PageResult<CrmCustomerDO> pageResult = customerService.getCustomerPage(pageVO); | ||||||
|         PageResult<CrmCustomerRespVO> pageVo = CrmCustomerConvert.INSTANCE.convertPage(pageResult); |         Set<Long> userSet = CollectionUtils.convertSetByFlatMap(pageResult.getList(), i -> Stream.of(NumberUtil.parseLong(i.getCreator()), i.getOwnerUserId())); | ||||||
|         // TODO @wanwan: 可以参考 CollectionUtils.convertListByFlatMap(),目的是简洁 |  | ||||||
|         Set<Long> userSet = pageVo.getList().stream().flatMap(i -> Stream.of(NumberUtil.parseLong(i.getCreator()), i.getOwnerUserId())).collect(Collectors.toSet()); |  | ||||||
|         Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(userSet); |         Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(userSet); | ||||||
|         Map<Long, DeptRespDTO> deptMap = deptApi.getDeptMap(userMap.values().stream().map(AdminUserRespDTO::getDeptId).collect(Collectors.toSet())); |         Map<Long, DeptRespDTO> deptMap = deptApi.getDeptMap(userMap.values().stream().map(AdminUserRespDTO::getDeptId).collect(Collectors.toSet())); | ||||||
|         // TODO @wanwan:这块可以形成一个 convertPage 方法,default 实现; |         PageResult<CrmCustomerRespVO> pageVo = CrmCustomerConvert.INSTANCE.convertPage(pageResult, userMap, deptMap); | ||||||
|         pageVo.getList().forEach(customerRespVO -> { |  | ||||||
|             customerRespVO.setAreaName(AreaUtils.format(customerRespVO.getAreaId())); |  | ||||||
|             customerRespVO.setCreatorName(Optional.ofNullable(userMap.get(NumberUtil.parseLong(customerRespVO.getCreator()))).map(AdminUserRespDTO::getNickname).orElse(null)); |  | ||||||
|             // TODO @wanwan:可以使用 MapUtils.findAndThen |  | ||||||
|             AdminUserRespDTO ownerUser = userMap.get(customerRespVO.getOwnerUserId()); |  | ||||||
|             if (Objects.nonNull(ownerUser)) { |  | ||||||
|                 customerRespVO.setOwnerUserName(ownerUser.getNickname()); |  | ||||||
|                 DeptRespDTO dept = deptMap.get(ownerUser.getDeptId()); |  | ||||||
|                 if (Objects.nonNull(dept)) { |  | ||||||
|                     customerRespVO.setOwnerUserDept(dept.getName()); |  | ||||||
|                 } |  | ||||||
|             } |  | ||||||
|         }); |  | ||||||
|         return success(pageVo); |         return success(pageVo); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -1,15 +1,23 @@ | |||||||
| package cn.iocoder.yudao.module.crm.convert.customer; | package cn.iocoder.yudao.module.crm.convert.customer; | ||||||
|  |  | ||||||
|  | import cn.hutool.core.util.NumberUtil; | ||||||
| import cn.iocoder.yudao.framework.common.pojo.PageResult; | import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||||||
|  | import cn.iocoder.yudao.framework.common.util.collection.MapUtils; | ||||||
|  | import cn.iocoder.yudao.framework.ip.core.utils.AreaUtils; | ||||||
| import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.*; | import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.*; | ||||||
| import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; | import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; | ||||||
| import cn.iocoder.yudao.module.crm.service.permission.bo.CrmTransferPermissionReqBO; | import cn.iocoder.yudao.module.crm.service.permission.bo.CrmTransferPermissionReqBO; | ||||||
|  | import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO; | ||||||
|  | import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; | ||||||
| import org.mapstruct.Mapper; | import org.mapstruct.Mapper; | ||||||
| import org.mapstruct.Mapping; | import org.mapstruct.Mapping; | ||||||
| import org.mapstruct.Mappings; | import org.mapstruct.Mappings; | ||||||
| import org.mapstruct.factory.Mappers; | import org.mapstruct.factory.Mappers; | ||||||
|  |  | ||||||
| import java.util.List; | import java.util.List; | ||||||
|  | import java.util.Map; | ||||||
|  | import java.util.Objects; | ||||||
|  | import java.util.Optional; | ||||||
|  |  | ||||||
| /** | /** | ||||||
|  * 客户 Convert |  * 客户 Convert | ||||||
| @@ -29,6 +37,21 @@ public interface CrmCustomerConvert { | |||||||
|  |  | ||||||
|     PageResult<CrmCustomerRespVO> convertPage(PageResult<CrmCustomerDO> page); |     PageResult<CrmCustomerRespVO> convertPage(PageResult<CrmCustomerDO> page); | ||||||
|  |  | ||||||
|  |     default PageResult<CrmCustomerRespVO> convertPage(PageResult<CrmCustomerDO> page, Map<Long, AdminUserRespDTO> userMap, Map<Long, DeptRespDTO> deptMap) { | ||||||
|  |         PageResult<CrmCustomerRespVO> result = convertPage(page); | ||||||
|  |         result.getList().forEach(customerRespVO -> { | ||||||
|  |             customerRespVO.setAreaName(AreaUtils.format(customerRespVO.getAreaId())); | ||||||
|  |             MapUtils.findAndThen(userMap, NumberUtil.parseLong(customerRespVO.getCreator()), creator -> | ||||||
|  |                     customerRespVO.setCreatorName(creator.getNickname())); | ||||||
|  |             MapUtils.findAndThen(userMap, customerRespVO.getOwnerUserId(), ownerUser -> { | ||||||
|  |                 customerRespVO.setOwnerUserName(ownerUser.getNickname()); | ||||||
|  |                 MapUtils.findAndThen(deptMap, ownerUser.getDeptId(), dept -> | ||||||
|  |                         customerRespVO.setOwnerUserDept(dept.getName())); | ||||||
|  |             }); | ||||||
|  |         }); | ||||||
|  |         return result; | ||||||
|  |     } | ||||||
|  |  | ||||||
|     List<CrmCustomerExcelVO> convertList02(List<CrmCustomerDO> list); |     List<CrmCustomerExcelVO> convertList02(List<CrmCustomerDO> list); | ||||||
|  |  | ||||||
|     @Mappings({ |     @Mappings({ | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Wanwan
					Wanwan