mirror of
				https://gitee.com/hhyykk/ipms-sjy.git
				synced 2025-10-31 10:18:42 +08:00 
			
		
		
		
	CRM-CONTRACT: 完善合同编辑回显
This commit is contained in:
		| @@ -166,10 +166,10 @@ public class CrmBusinessController { | |||||||
|         return CrmBusinessConvert.INSTANCE.convertPage(pageResult, customerList, statusTypeList, statusList); |         return CrmBusinessConvert.INSTANCE.convertPage(pageResult, customerList, statusTypeList, statusList); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @PutMapping("/transfer") |     @PutMapping("/transfer-business") | ||||||
|     @Operation(summary = "商机转移") |     @Operation(summary = "商机转移") | ||||||
|     @PreAuthorize("@ss.hasPermission('crm:business:update')") |     @PreAuthorize("@ss.hasPermission('crm:business:update')") | ||||||
|     public CommonResult<Boolean> transfer(@Valid @RequestBody CrmBusinessTransferReqVO reqVO) { |     public CommonResult<Boolean> transferBusiness(@Valid @RequestBody CrmBusinessTransferReqVO reqVO) { | ||||||
|         businessService.transferBusiness(reqVO, getLoginUserId()); |         businessService.transferBusiness(reqVO, getLoginUserId()); | ||||||
|         return success(true); |         return success(true); | ||||||
|     } |     } | ||||||
|   | |||||||
| @@ -88,10 +88,10 @@ public class CrmClueController { | |||||||
|         ExcelUtils.write(response, "线索.xls", "数据", CrmClueRespVO.class, datas); |         ExcelUtils.write(response, "线索.xls", "数据", CrmClueRespVO.class, datas); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @PutMapping("/transfer") |     @PutMapping("/transfer-clue") | ||||||
|     @Operation(summary = "线索转移") |     @Operation(summary = "线索转移") | ||||||
|     @PreAuthorize("@ss.hasPermission('crm:clue:update')") |     @PreAuthorize("@ss.hasPermission('crm:clue:update')") | ||||||
|     public CommonResult<Boolean> transfer(@Valid @RequestBody CrmClueTransferReqVO reqVO) { |     public CommonResult<Boolean> transferClue(@Valid @RequestBody CrmClueTransferReqVO reqVO) { | ||||||
|         clueService.transferClue(reqVO, getLoginUserId()); |         clueService.transferClue(reqVO, getLoginUserId()); | ||||||
|         return success(true); |         return success(true); | ||||||
|     } |     } | ||||||
|   | |||||||
| @@ -102,7 +102,7 @@ public class CrmContactController { | |||||||
|         List<CrmCustomerDO> customerList = customerService.getCustomerList( |         List<CrmCustomerDO> customerList = customerService.getCustomerList( | ||||||
|                 Collections.singletonList(contact.getCustomerId())); |                 Collections.singletonList(contact.getCustomerId())); | ||||||
|         // 3. 直属上级 |         // 3. 直属上级 | ||||||
|         List<CrmContactDO> parentContactList = contactService.getContactList( |         List<CrmContactDO> parentContactList = contactService.getContactListByIds( | ||||||
|                 Collections.singletonList(contact.getParentId()), getLoginUserId()); |                 Collections.singletonList(contact.getParentId()), getLoginUserId()); | ||||||
|         return success(CrmContactConvert.INSTANCE.convert(contact, userMap, customerList, parentContactList)); |         return success(CrmContactConvert.INSTANCE.convert(contact, userMap, customerList, parentContactList)); | ||||||
|     } |     } | ||||||
| @@ -112,7 +112,7 @@ public class CrmContactController { | |||||||
|     @Parameter(name = "ids", description = "编号", required = true, example = "[1024]") |     @Parameter(name = "ids", description = "编号", required = true, example = "[1024]") | ||||||
|     @PreAuthorize("@ss.hasPermission('crm:contact:query')") |     @PreAuthorize("@ss.hasPermission('crm:contact:query')") | ||||||
|     public CommonResult<List<CrmContactRespVO>> getContactListByIds(@RequestParam("ids") List<Long> ids) { |     public CommonResult<List<CrmContactRespVO>> getContactListByIds(@RequestParam("ids") List<Long> ids) { | ||||||
|         return success(BeanUtils.toBean(contactService.getContactList(ids, getLoginUserId()), CrmContactRespVO.class)); |         return success(BeanUtils.toBean(contactService.getContactListByIds(ids, getLoginUserId()), CrmContactRespVO.class)); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @GetMapping("/simple-all-list") |     @GetMapping("/simple-all-list") | ||||||
| @@ -170,15 +170,15 @@ public class CrmContactController { | |||||||
|         Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(convertListByFlatMap(contactList, |         Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(convertListByFlatMap(contactList, | ||||||
|                 contact -> Stream.of(NumberUtils.parseLong(contact.getCreator()), contact.getOwnerUserId()))); |                 contact -> Stream.of(NumberUtils.parseLong(contact.getCreator()), contact.getOwnerUserId()))); | ||||||
|         // 3. 直属上级 |         // 3. 直属上级 | ||||||
|         List<CrmContactDO> parentContactList = contactService.getContactList( |         List<CrmContactDO> parentContactList = contactService.getContactListByIds( | ||||||
|                 convertSet(contactList, CrmContactDO::getParentId), getLoginUserId()); |                 convertSet(contactList, CrmContactDO::getParentId), getLoginUserId()); | ||||||
|         return CrmContactConvert.INSTANCE.convertPage(pageResult, userMap, crmCustomerDOList, parentContactList); |         return CrmContactConvert.INSTANCE.convertPage(pageResult, userMap, crmCustomerDOList, parentContactList); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @PutMapping("/transfer") |     @PutMapping("/transfer-contact") | ||||||
|     @Operation(summary = "联系人转移") |     @Operation(summary = "联系人转移") | ||||||
|     @PreAuthorize("@ss.hasPermission('crm:contact:update')") |     @PreAuthorize("@ss.hasPermission('crm:contact:update')") | ||||||
|     public CommonResult<Boolean> transfer(@Valid @RequestBody CrmContactTransferReqVO reqVO) { |     public CommonResult<Boolean> transferContact(@Valid @RequestBody CrmContactTransferReqVO reqVO) { | ||||||
|         contactService.transferContact(reqVO, getLoginUserId()); |         contactService.transferContact(reqVO, getLoginUserId()); | ||||||
|         return success(true); |         return success(true); | ||||||
|     } |     } | ||||||
|   | |||||||
| @@ -10,11 +10,15 @@ import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; | |||||||
| import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; | import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; | ||||||
| import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.*; | import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.*; | ||||||
| import cn.iocoder.yudao.module.crm.convert.contract.CrmContractConvert; | import cn.iocoder.yudao.module.crm.convert.contract.CrmContractConvert; | ||||||
|  | import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO; | ||||||
| import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessProductDO; | import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessProductDO; | ||||||
|  | import cn.iocoder.yudao.module.crm.dal.dataobject.contact.CrmContactDO; | ||||||
| import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractDO; | import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractDO; | ||||||
| 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.dal.dataobject.product.CrmProductDO; | import cn.iocoder.yudao.module.crm.dal.dataobject.product.CrmProductDO; | ||||||
| import cn.iocoder.yudao.module.crm.service.business.CrmBusinessProductService; | import cn.iocoder.yudao.module.crm.service.business.CrmBusinessProductService; | ||||||
|  | import cn.iocoder.yudao.module.crm.service.business.CrmBusinessService; | ||||||
|  | import cn.iocoder.yudao.module.crm.service.contact.CrmContactService; | ||||||
| import cn.iocoder.yudao.module.crm.service.contract.CrmContractService; | import cn.iocoder.yudao.module.crm.service.contract.CrmContractService; | ||||||
| import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerService; | import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerService; | ||||||
| import cn.iocoder.yudao.module.crm.service.product.CrmProductService; | import cn.iocoder.yudao.module.crm.service.product.CrmProductService; | ||||||
| @@ -26,11 +30,13 @@ import io.swagger.v3.oas.annotations.tags.Tag; | |||||||
| import jakarta.annotation.Resource; | import jakarta.annotation.Resource; | ||||||
| import jakarta.servlet.http.HttpServletResponse; | import jakarta.servlet.http.HttpServletResponse; | ||||||
| import jakarta.validation.Valid; | import jakarta.validation.Valid; | ||||||
|  | import org.springframework.context.annotation.Lazy; | ||||||
| import org.springframework.security.access.prepost.PreAuthorize; | import org.springframework.security.access.prepost.PreAuthorize; | ||||||
| import org.springframework.validation.annotation.Validated; | import org.springframework.validation.annotation.Validated; | ||||||
| import org.springframework.web.bind.annotation.*; | import org.springframework.web.bind.annotation.*; | ||||||
|  |  | ||||||
| import java.io.IOException; | import java.io.IOException; | ||||||
|  | import java.util.Collections; | ||||||
| import java.util.List; | import java.util.List; | ||||||
| import java.util.Map; | import java.util.Map; | ||||||
| import java.util.stream.Stream; | import java.util.stream.Stream; | ||||||
| @@ -52,6 +58,11 @@ public class CrmContractController { | |||||||
|     @Resource |     @Resource | ||||||
|     private CrmCustomerService customerService; |     private CrmCustomerService customerService; | ||||||
|     @Resource |     @Resource | ||||||
|  |     private CrmContactService contactService; | ||||||
|  |     @Resource | ||||||
|  |     private CrmBusinessService businessService; | ||||||
|  |     @Resource | ||||||
|  |     @Lazy | ||||||
|     private CrmBusinessProductService businessProductService; |     private CrmBusinessProductService businessProductService; | ||||||
|     @Resource |     @Resource | ||||||
|     private CrmProductService productService; |     private CrmProductService productService; | ||||||
| @@ -89,7 +100,8 @@ public class CrmContractController { | |||||||
|     @PreAuthorize("@ss.hasPermission('crm:contract:query')") |     @PreAuthorize("@ss.hasPermission('crm:contract:query')") | ||||||
|     public CommonResult<CrmContractRespVO> getContract(@RequestParam("id") Long id) { |     public CommonResult<CrmContractRespVO> getContract(@RequestParam("id") Long id) { | ||||||
|         CrmContractDO contract = contractService.getContract(id); |         CrmContractDO contract = contractService.getContract(id); | ||||||
|         CrmContractRespVO respVO = BeanUtils.toBean(contract, CrmContractRespVO.class); |         List<CrmContractRespVO> respVOList = buildContractDetail(Collections.singletonList(contract)); | ||||||
|  |         CrmContractRespVO respVO = respVOList.getFirst(); | ||||||
|         List<CrmBusinessProductDO> businessProductList = businessProductService.getBusinessProductListByContractId(id); |         List<CrmBusinessProductDO> businessProductList = businessProductService.getBusinessProductListByContractId(id); | ||||||
|         Map<Long, CrmBusinessProductDO> businessProductMap = convertMap(businessProductList, CrmBusinessProductDO::getProductId); |         Map<Long, CrmBusinessProductDO> businessProductMap = convertMap(businessProductList, CrmBusinessProductDO::getProductId); | ||||||
|         List<CrmProductDO> productList = productService.getProductListByIds(convertSet(businessProductList, CrmBusinessProductDO::getProductId)); |         List<CrmProductDO> productList = productService.getProductListByIds(convertSet(businessProductList, CrmBusinessProductDO::getProductId)); | ||||||
| @@ -108,15 +120,15 @@ public class CrmContractController { | |||||||
|     @PreAuthorize("@ss.hasPermission('crm:contract:query')") |     @PreAuthorize("@ss.hasPermission('crm:contract:query')") | ||||||
|     public CommonResult<PageResult<CrmContractRespVO>> getContractPage(@Valid CrmContractPageReqVO pageVO) { |     public CommonResult<PageResult<CrmContractRespVO>> getContractPage(@Valid CrmContractPageReqVO pageVO) { | ||||||
|         PageResult<CrmContractDO> pageResult = contractService.getContractPage(pageVO, getLoginUserId()); |         PageResult<CrmContractDO> pageResult = contractService.getContractPage(pageVO, getLoginUserId()); | ||||||
|         return success(buildContractDetailPage(pageResult)); |         return success(BeanUtils.toBean(pageResult, CrmContractRespVO.class).setList(buildContractDetail(pageResult.getList()))); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @GetMapping("/page-by-customer") |     @GetMapping("/page-by-customer") | ||||||
|     @Operation(summary = "获得联系人分页,基于指定客户") |     @Operation(summary = "获得合同分页,基于指定客户") | ||||||
|     public CommonResult<PageResult<CrmContractRespVO>> getContractPageByCustomer(@Valid CrmContractPageReqVO pageVO) { |     public CommonResult<PageResult<CrmContractRespVO>> getContractPageByCustomer(@Valid CrmContractPageReqVO pageVO) { | ||||||
|         Assert.notNull(pageVO.getCustomerId(), "客户编号不能为空"); |         Assert.notNull(pageVO.getCustomerId(), "客户编号不能为空"); | ||||||
|         PageResult<CrmContractDO> pageResult = contractService.getContractPageByCustomerId(pageVO); |         PageResult<CrmContractDO> pageResult = contractService.getContractPageByCustomerId(pageVO); | ||||||
|         return success(buildContractDetailPage(pageResult)); |         return success(BeanUtils.toBean(pageResult, CrmContractRespVO.class).setList(buildContractDetail(pageResult.getList()))); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @GetMapping("/export-excel") |     @GetMapping("/export-excel") | ||||||
| @@ -132,23 +144,28 @@ public class CrmContractController { | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
|      * 构建详细的合同分页结果 |      * 构建详细的合同结果 | ||||||
|      * |      * | ||||||
|      * @param pageResult 简单的合同分页结果 |      * @param contractList 原始合同信息 | ||||||
|      * @return 详细的合同分页结果 |      * @return 细的合同结果 | ||||||
|      */ |      */ | ||||||
|     private PageResult<CrmContractRespVO> buildContractDetailPage(PageResult<CrmContractDO> pageResult) { |     private List<CrmContractRespVO> buildContractDetail(List<CrmContractDO> contractList) { | ||||||
|         List<CrmContractDO> contactList = pageResult.getList(); |         if (CollUtil.isEmpty(contractList)) { | ||||||
|         if (CollUtil.isEmpty(contactList)) { |             return Collections.emptyList(); | ||||||
|             return PageResult.empty(pageResult.getTotal()); |  | ||||||
|         } |         } | ||||||
|         // 1. 获取客户列表 |         // 1. 获取客户列表 | ||||||
|         List<CrmCustomerDO> customerList = customerService.getCustomerList( |         List<CrmCustomerDO> customerList = customerService.getCustomerList( | ||||||
|                 convertSet(contactList, CrmContractDO::getCustomerId)); |                 convertSet(contractList, CrmContractDO::getCustomerId)); | ||||||
|         // 2. 获取创建人、负责人列表 |         // 2. 获取创建人、负责人列表 | ||||||
|         Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(convertListByFlatMap(contactList, |         Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(convertListByFlatMap(contractList, | ||||||
|                 contact -> Stream.of(NumberUtils.parseLong(contact.getCreator()), contact.getOwnerUserId()))); |                 contact -> Stream.of(NumberUtils.parseLong(contact.getCreator()), contact.getOwnerUserId()))); | ||||||
|         return CrmContractConvert.INSTANCE.convertPage(pageResult, userMap, customerList); |         // 3. 获取联系人 | ||||||
|  |         Map<Long, CrmContactDO> contactMap = convertMap(contactService.getContactListByIds(convertSet(contractList, | ||||||
|  |                 CrmContractDO::getContactId)), CrmContactDO::getId); | ||||||
|  |         // 4. 获取商机 | ||||||
|  |         Map<Long, CrmBusinessDO> businessMap = convertMap(businessService.getBusinessList(convertSet(contractList, | ||||||
|  |                 CrmContractDO::getBusinessId)), CrmBusinessDO::getId); | ||||||
|  |         return CrmContractConvert.INSTANCE.convertList(contractList, userMap, customerList, contactMap, businessMap); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @PutMapping("/transfer-contract") |     @PutMapping("/transfer-contract") | ||||||
|   | |||||||
| @@ -29,10 +29,16 @@ public class CrmContractRespVO { | |||||||
|     @Schema(description = "客户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "18336") |     @Schema(description = "客户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "18336") | ||||||
|     @ExcelProperty("客户编号") |     @ExcelProperty("客户编号") | ||||||
|     private Long customerId; |     private Long customerId; | ||||||
|  |     @Schema(description = "客户名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "18336") | ||||||
|  |     @ExcelProperty("客户名称") | ||||||
|  |     private String customerName; | ||||||
|  |  | ||||||
|     @Schema(description = "商机编号", example = "10864") |     @Schema(description = "商机编号", example = "10864") | ||||||
|     @ExcelProperty("商机编号") |     @ExcelProperty("商机编号") | ||||||
|     private Long businessId; |     private Long businessId; | ||||||
|  |     @Schema(description = "商机名称", example = "10864") | ||||||
|  |     @ExcelProperty("商机名称") | ||||||
|  |     private String businessName; | ||||||
|  |  | ||||||
|     @Schema(description = "工作流编号", example = "1043") |     @Schema(description = "工作流编号", example = "1043") | ||||||
|     @ExcelProperty("工作流编号") |     @ExcelProperty("工作流编号") | ||||||
| @@ -77,10 +83,16 @@ public class CrmContractRespVO { | |||||||
|     @Schema(description = "联系人编号", example = "18546") |     @Schema(description = "联系人编号", example = "18546") | ||||||
|     @ExcelProperty("联系人编号") |     @ExcelProperty("联系人编号") | ||||||
|     private Long contactId; |     private Long contactId; | ||||||
|  |     @Schema(description = "联系人编号", example = "18546") | ||||||
|  |     @ExcelProperty("联系人编号") | ||||||
|  |     private String contactName; | ||||||
|  |  | ||||||
|     @Schema(description = "公司签约人", example = "14036") |     @Schema(description = "公司签约人", example = "14036") | ||||||
|     @ExcelProperty("公司签约人") |     @ExcelProperty("公司签约人") | ||||||
|     private Long signUserId; |     private Long signUserId; | ||||||
|  |     @Schema(description = "公司签约人", example = "14036") | ||||||
|  |     @ExcelProperty("公司签约人") | ||||||
|  |     private String signUserName; | ||||||
|  |  | ||||||
|     @Schema(description = "最后跟进时间") |     @Schema(description = "最后跟进时间") | ||||||
|     @ExcelProperty("最后跟进时间") |     @ExcelProperty("最后跟进时间") | ||||||
| @@ -104,10 +116,6 @@ public class CrmContractRespVO { | |||||||
|     @ExcelProperty("创建人名字") |     @ExcelProperty("创建人名字") | ||||||
|     private String creatorName; |     private String creatorName; | ||||||
|  |  | ||||||
|     @Schema(description = "客户名字", example = "test") |  | ||||||
|     @ExcelProperty("客户名字") |  | ||||||
|     private String customerName; |  | ||||||
|  |  | ||||||
|     @Schema(description = "负责人", example = "test") |     @Schema(description = "负责人", example = "test") | ||||||
|     @ExcelProperty("负责人") |     @ExcelProperty("负责人") | ||||||
|     private String ownerUserName; |     private String ownerUserName; | ||||||
|   | |||||||
| @@ -232,10 +232,10 @@ public class CrmCustomerController { | |||||||
|         return success(customerService.importCustomerList(list, updateSupport, getLoginUserId())); |         return success(customerService.importCustomerList(list, updateSupport, getLoginUserId())); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @PutMapping("/transfer") |     @PutMapping("/transfer-customer") | ||||||
|     @Operation(summary = "转移客户") |     @Operation(summary = "转移客户") | ||||||
|     @PreAuthorize("@ss.hasPermission('crm:customer:update')") |     @PreAuthorize("@ss.hasPermission('crm:customer:update')") | ||||||
|     public CommonResult<Boolean> transfer(@Valid @RequestBody CrmCustomerTransferReqVO reqVO) { |     public CommonResult<Boolean> transferCustomer(@Valid @RequestBody CrmCustomerTransferReqVO reqVO) { | ||||||
|         customerService.transferCustomer(reqVO, getLoginUserId()); |         customerService.transferCustomer(reqVO, getLoginUserId()); | ||||||
|         return success(true); |         return success(true); | ||||||
|     } |     } | ||||||
|   | |||||||
| @@ -75,7 +75,7 @@ public class CrmFollowUpRecordController { | |||||||
|     public CommonResult<PageResult<CrmFollowUpRecordRespVO>> getFollowUpRecordPage(@Valid CrmFollowUpRecordPageReqVO pageReqVO) { |     public CommonResult<PageResult<CrmFollowUpRecordRespVO>> getFollowUpRecordPage(@Valid CrmFollowUpRecordPageReqVO pageReqVO) { | ||||||
|         PageResult<CrmFollowUpRecordDO> pageResult = followUpRecordService.getFollowUpRecordPage(pageReqVO); |         PageResult<CrmFollowUpRecordDO> pageResult = followUpRecordService.getFollowUpRecordPage(pageReqVO); | ||||||
|         /// 拼接数据 |         /// 拼接数据 | ||||||
|         Map<Long, CrmContactDO> contactMap = convertMap(contactService.getContactList( |         Map<Long, CrmContactDO> contactMap = convertMap(contactService.getContactListByIds( | ||||||
|                 convertSetByFlatMap(pageResult.getList(), item -> item.getContactIds().stream())), CrmContactDO::getId); |                 convertSetByFlatMap(pageResult.getList(), item -> item.getContactIds().stream())), CrmContactDO::getId); | ||||||
|         Map<Long, CrmBusinessDO> businessMap = convertMap(businessService.getBusinessList( |         Map<Long, CrmBusinessDO> businessMap = convertMap(businessService.getBusinessList( | ||||||
|                 convertSetByFlatMap(pageResult.getList(), item -> item.getBusinessIds().stream())), CrmBusinessDO::getId); |                 convertSetByFlatMap(pageResult.getList(), item -> item.getBusinessIds().stream())), CrmBusinessDO::getId); | ||||||
|   | |||||||
| @@ -1,9 +1,10 @@ | |||||||
| package cn.iocoder.yudao.module.crm.convert.contract; | package cn.iocoder.yudao.module.crm.convert.contract; | ||||||
|  |  | ||||||
| import cn.iocoder.yudao.framework.common.pojo.PageResult; |  | ||||||
| import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | ||||||
| import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractRespVO; | import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractRespVO; | ||||||
| import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractTransferReqVO; | import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractTransferReqVO; | ||||||
|  | import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO; | ||||||
|  | import cn.iocoder.yudao.module.crm.dal.dataobject.contact.CrmContactDO; | ||||||
| import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractDO; | import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractDO; | ||||||
| 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.CrmPermissionTransferReqBO; | import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionTransferReqBO; | ||||||
| @@ -31,17 +32,21 @@ public interface CrmContractConvert { | |||||||
|     @Mapping(target = "bizId", source = "reqVO.id") |     @Mapping(target = "bizId", source = "reqVO.id") | ||||||
|     CrmPermissionTransferReqBO convert(CrmContractTransferReqVO reqVO, Long userId); |     CrmPermissionTransferReqBO convert(CrmContractTransferReqVO reqVO, Long userId); | ||||||
|  |  | ||||||
|     default PageResult<CrmContractRespVO> convertPage(PageResult<CrmContractDO> pageResult, Map<Long, AdminUserRespDTO> userMap, |     default List<CrmContractRespVO> convertList(List<CrmContractDO> contractList, Map<Long, AdminUserRespDTO> userMap, | ||||||
|                                                       List<CrmCustomerDO> customerList) { |                                                 List<CrmCustomerDO> customerList, Map<Long, CrmContactDO> contactMap, | ||||||
|         PageResult<CrmContractRespVO> voPageResult = BeanUtils.toBean(pageResult, CrmContractRespVO.class); |                                                 Map<Long, CrmBusinessDO> businessMap) { | ||||||
|  |         List<CrmContractRespVO> respVOList = BeanUtils.toBean(contractList, CrmContractRespVO.class); | ||||||
|         // 拼接关联字段 |         // 拼接关联字段 | ||||||
|         Map<Long, CrmCustomerDO> customerMap = convertMap(customerList, CrmCustomerDO::getId); |         Map<Long, CrmCustomerDO> customerMap = convertMap(customerList, CrmCustomerDO::getId); | ||||||
|         voPageResult.getList().forEach(contract -> { |         respVOList.forEach(contract -> { | ||||||
|             findAndThen(userMap, contract.getOwnerUserId(), user -> contract.setOwnerUserName(user.getNickname())); |             findAndThen(userMap, contract.getOwnerUserId(), user -> contract.setOwnerUserName(user.getNickname())); | ||||||
|             findAndThen(userMap, Long.parseLong(contract.getCreator()), user -> contract.setCreatorName(user.getNickname())); |             findAndThen(userMap, Long.parseLong(contract.getCreator()), user -> contract.setCreatorName(user.getNickname())); | ||||||
|  |             findAndThen(userMap, contract.getSignUserId(), user -> contract.setSignUserName(user.getNickname())); | ||||||
|             findAndThen(customerMap, contract.getCustomerId(), customer -> contract.setCustomerName(customer.getName())); |             findAndThen(customerMap, contract.getCustomerId(), customer -> contract.setCustomerName(customer.getName())); | ||||||
|  |             findAndThen(contactMap, contract.getContactId(), contact -> contract.setContactName(contact.getName())); | ||||||
|  |             findAndThen(businessMap, contract.getBusinessId(), business -> contract.setBusinessName(business.getName())); | ||||||
|         }); |         }); | ||||||
|         return voPageResult; |         return respVOList; | ||||||
|     } |     } | ||||||
|  |  | ||||||
| } | } | ||||||
|   | |||||||
| @@ -80,7 +80,7 @@ public interface CrmContactService { | |||||||
|      * @param userId 用户编号 |      * @param userId 用户编号 | ||||||
|      * @return 联系人列表 |      * @return 联系人列表 | ||||||
|      */ |      */ | ||||||
|     List<CrmContactDO> getContactList(Collection<Long> ids, Long userId); |     List<CrmContactDO> getContactListByIds(Collection<Long> ids, Long userId); | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
|      * 获得联系人列表 |      * 获得联系人列表 | ||||||
| @@ -88,7 +88,7 @@ public interface CrmContactService { | |||||||
|      * @param ids 编号 |      * @param ids 编号 | ||||||
|      * @return 联系人列表 |      * @return 联系人列表 | ||||||
|      */ |      */ | ||||||
|     List<CrmContactDO> getContactList(Collection<Long> ids); |     List<CrmContactDO> getContactListByIds(Collection<Long> ids); | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
|      * 获得联系人列表 |      * 获得联系人列表 | ||||||
|   | |||||||
| @@ -210,7 +210,7 @@ public class CrmContactServiceImpl implements CrmContactService { | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public List<CrmContactDO> getContactList(Collection<Long> ids, Long userId) { |     public List<CrmContactDO> getContactListByIds(Collection<Long> ids, Long userId) { | ||||||
|         if (CollUtil.isEmpty(ids)) { |         if (CollUtil.isEmpty(ids)) { | ||||||
|             return ListUtil.empty(); |             return ListUtil.empty(); | ||||||
|         } |         } | ||||||
| @@ -218,7 +218,7 @@ public class CrmContactServiceImpl implements CrmContactService { | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public List<CrmContactDO> getContactList(Collection<Long> ids) { |     public List<CrmContactDO> getContactListByIds(Collection<Long> ids) { | ||||||
|         if (CollUtil.isEmpty(ids)) { |         if (CollUtil.isEmpty(ids)) { | ||||||
|             return ListUtil.empty(); |             return ListUtil.empty(); | ||||||
|         } |         } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 puhui999
					puhui999