diff --git a/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/DictTypeConstants.java b/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/DictTypeConstants.java index 76a4d872c..13c202550 100644 --- a/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/DictTypeConstants.java +++ b/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/DictTypeConstants.java @@ -13,5 +13,6 @@ public interface DictTypeConstants { String CRM_AUDIT_STATUS = "crm_audit_status"; // CRM 审批状态 String CRM_PRODUCT_UNIT = "crm_product_unit"; // CRM 产品单位 String CRM_PRODUCT_STATUS = "crm_product_status"; // CRM 产品状态 + String CRM_FOLLOW_UP_TYPE = "crm_follow_up_type"; // 跟进方式 } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/followup/CrmFollowUpRecordController.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/followup/CrmFollowUpRecordController.java index 93c02542a..c46bfefcb 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/followup/CrmFollowUpRecordController.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/followup/CrmFollowUpRecordController.java @@ -1,31 +1,35 @@ package cn.iocoder.yudao.module.crm.controller.admin.followup; import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageParam; import cn.iocoder.yudao.framework.common.pojo.PageResult; +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.framework.operatelog.core.annotations.OperateLog; import cn.iocoder.yudao.module.crm.controller.admin.followup.vo.CrmFollowUpRecordPageReqVO; import cn.iocoder.yudao.module.crm.controller.admin.followup.vo.CrmFollowUpRecordRespVO; import cn.iocoder.yudao.module.crm.controller.admin.followup.vo.CrmFollowUpRecordSaveReqVO; +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.followup.CrmFollowUpRecordDO; +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.followup.CrmFollowUpRecordService; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.annotation.Resource; -import jakarta.servlet.http.HttpServletResponse; import jakarta.validation.Valid; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; -import java.io.IOException; +import java.util.ArrayList; import java.util.List; +import java.util.Map; +import java.util.Set; import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT; +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSetByFlatMap; @Tag(name = "管理后台 - 跟进记录") @@ -36,6 +40,10 @@ public class CrmFollowUpRecordController { @Resource private CrmFollowUpRecordService crmFollowUpRecordService; + @Resource + private CrmContactService contactService; + @Resource + private CrmBusinessService businessService; @PostMapping("/create") @Operation(summary = "创建跟进记录") @@ -75,20 +83,32 @@ public class CrmFollowUpRecordController { @PreAuthorize("@ss.hasPermission('crm:follow-up-record:query')") public CommonResult> getFollowUpRecordPage(@Valid CrmFollowUpRecordPageReqVO pageReqVO) { PageResult pageResult = crmFollowUpRecordService.getFollowUpRecordPage(pageReqVO); - return success(BeanUtils.toBean(pageResult, CrmFollowUpRecordRespVO.class)); + Set contactIds = convertSetByFlatMap(pageResult.getList(), item -> item.getContactIds().stream()); + Set businessIds = convertSetByFlatMap(pageResult.getList(), item -> item.getBusinessIds().stream()); + Map contactMap = convertMap(contactService.getContactList(contactIds), CrmContactDO::getId); + Map businessMap = convertMap(businessService.getBusinessList(businessIds), CrmBusinessDO::getId); + PageResult result = BeanUtils.toBean(pageResult, CrmFollowUpRecordRespVO.class); + result.getList().forEach(item -> { + setContactNames(item, contactMap); + setBusinessNames(item, businessMap); + }); + return success(result); } - @GetMapping("/export-excel") - @Operation(summary = "导出跟进记录 Excel") - @PreAuthorize("@ss.hasPermission('crm:follow-up-record:export')") - @OperateLog(type = EXPORT) - public void exportFollowUpRecordExcel(@Valid CrmFollowUpRecordPageReqVO pageReqVO, - HttpServletResponse response) throws IOException { - pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); - List list = crmFollowUpRecordService.getFollowUpRecordPage(pageReqVO).getList(); - // 导出 Excel - ExcelUtils.write(response, "跟进记录.xls", "数据", CrmFollowUpRecordRespVO.class, - BeanUtils.toBean(list, CrmFollowUpRecordRespVO.class)); + private static void setContactNames(CrmFollowUpRecordRespVO vo, Map contactMap) { + List names = new ArrayList<>(); + vo.getContactIds().forEach(id -> { + MapUtils.findAndThen(contactMap, id, contactDO -> names.add(contactDO.getName())); + }); + vo.setContactNames(names); + } + + private static void setBusinessNames(CrmFollowUpRecordRespVO vo, Map businessMap) { + List names = new ArrayList<>(); + vo.getContactIds().forEach(id -> { + MapUtils.findAndThen(businessMap, id, businessDO -> names.add(businessDO.getName())); + }); + vo.setBusinessNames(names); } } \ No newline at end of file diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/followup/vo/CrmFollowUpRecordPageReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/followup/vo/CrmFollowUpRecordPageReqVO.java index 04d63b85e..78c28a08f 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/followup/vo/CrmFollowUpRecordPageReqVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/followup/vo/CrmFollowUpRecordPageReqVO.java @@ -5,11 +5,6 @@ import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.ToString; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; @Schema(description = "管理后台 - 跟进记录分页 Request VO") @Data @@ -23,15 +18,4 @@ public class CrmFollowUpRecordPageReqVO extends PageParam { @Schema(description = "数据编号", example = "5564") private Long bizId; - @Schema(description = "跟进类型", example = "2") - private Integer type; - - @Schema(description = "下次联系时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] nextTime; - - @Schema(description = "创建时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] createTime; - } \ No newline at end of file diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/followup/vo/CrmFollowUpRecordRespVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/followup/vo/CrmFollowUpRecordRespVO.java index c8f0a0453..8d4b145b6 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/followup/vo/CrmFollowUpRecordRespVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/followup/vo/CrmFollowUpRecordRespVO.java @@ -1,13 +1,14 @@ package cn.iocoder.yudao.module.crm.controller.admin.followup.vo; import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; -import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; -import com.alibaba.excel.annotation.ExcelProperty; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; import java.time.LocalDateTime; +import java.util.List; + +import static cn.iocoder.yudao.module.crm.enums.DictTypeConstants.CRM_FOLLOW_UP_TYPE; @Schema(description = "管理后台 - 跟进记录 Response VO") @Data @@ -15,40 +16,35 @@ import java.time.LocalDateTime; public class CrmFollowUpRecordRespVO { @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "28800") - @ExcelProperty("编号") private Long id; @Schema(description = "数据类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - @ExcelProperty("数据类型") private Integer bizType; @Schema(description = "数据编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "5564") - @ExcelProperty("数据编号") private Long bizId; @Schema(description = "跟进类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - @ExcelProperty(value = "跟进类型", converter = DictConvert.class) - @DictFormat("crm_follow_up_type") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中 + @DictFormat(CRM_FOLLOW_UP_TYPE) private Integer type; @Schema(description = "跟进内容", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("跟进内容") private String content; @Schema(description = "下次联系时间", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("下次联系时间") private LocalDateTime nextTime; @Schema(description = "关联的商机编号数组") - @ExcelProperty("关联的商机编号数组") - private String businessIds; + private List businessIds; + @Schema(description = "关联的商机名称数组") + private List businessNames; @Schema(description = "关联的联系人编号数组") - @ExcelProperty("关联的联系人编号数组") - private String contactIds; + private List contactIds; + @Schema(description = "关联的联系人名称数组") + private List contactNames; @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("创建时间") private LocalDateTime createTime; } \ No newline at end of file diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/followup/vo/CrmFollowUpRecordSaveReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/followup/vo/CrmFollowUpRecordSaveReqVO.java index b78844278..b6d0e13c7 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/followup/vo/CrmFollowUpRecordSaveReqVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/followup/vo/CrmFollowUpRecordSaveReqVO.java @@ -6,6 +6,7 @@ import jakarta.validation.constraints.NotNull; import lombok.Data; import java.time.LocalDateTime; +import java.util.List; @Schema(description = "管理后台 - 跟进记录新增/修改 Request VO") @Data @@ -35,9 +36,9 @@ public class CrmFollowUpRecordSaveReqVO { private LocalDateTime nextTime; @Schema(description = "关联的商机编号数组") - private String businessIds; + private List businessIds; @Schema(description = "关联的联系人编号数组") - private String contactIds; + private List contactIds; } \ No newline at end of file diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/followup/CrmFollowUpRecordDO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/followup/CrmFollowUpRecordDO.java index 600983205..25378e137 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/followup/CrmFollowUpRecordDO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/followup/CrmFollowUpRecordDO.java @@ -4,6 +4,7 @@ import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; import cn.iocoder.yudao.framework.mybatis.core.type.LongListTypeHandler; 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.enums.DictTypeConstants; import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum; import com.baomidou.mybatisplus.annotation.KeySequence; import com.baomidou.mybatisplus.annotation.TableField; @@ -53,9 +54,8 @@ public class CrmFollowUpRecordDO extends BaseDO { private Long bizId; /** - * 跟进类型 + * 跟进类型,关联字典{@link DictTypeConstants#CRM_FOLLOW_UP_TYPE} * - * TODO @puhui999:可以搞个数据字典,打电话、发短信、上门拜访、微信、邮箱、QQ */ private Integer type; /** diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/followup/CrmFollowUpRecordMapper.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/followup/CrmFollowUpRecordMapper.java index b45e5332c..a9b1dc315 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/followup/CrmFollowUpRecordMapper.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/followup/CrmFollowUpRecordMapper.java @@ -19,9 +19,6 @@ public interface CrmFollowUpRecordMapper extends BaseMapperX() .eqIfPresent(CrmFollowUpRecordDO::getBizType, reqVO.getBizType()) .eqIfPresent(CrmFollowUpRecordDO::getBizId, reqVO.getBizId()) - .eqIfPresent(CrmFollowUpRecordDO::getType, reqVO.getType()) - .betweenIfPresent(CrmFollowUpRecordDO::getNextTime, reqVO.getNextTime()) - .betweenIfPresent(CrmFollowUpRecordDO::getCreateTime, reqVO.getCreateTime()) .orderByDesc(CrmFollowUpRecordDO::getId)); } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessService.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessService.java index c2b132648..e67442502 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessService.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessService.java @@ -59,6 +59,14 @@ public interface CrmBusinessService { */ List getBusinessList(Collection ids, Long userId); + /** + * 获得商机列表 + * + * @param ids 编号 + * @return 商机列表 + */ + List getBusinessList(Collection ids); + /** * 获得商机分页 * diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessServiceImpl.java index 03a14ceb6..6db11943a 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessServiceImpl.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessServiceImpl.java @@ -155,6 +155,11 @@ public class CrmBusinessServiceImpl implements CrmBusinessService { return businessMapper.selectBatchIds(ids, userId); } + @Override + public List getBusinessList(Collection ids) { + return businessMapper.selectBatchIds(ids); + } + @Override public PageResult getBusinessPage(CrmBusinessPageReqVO pageReqVO, Long userId) { return businessMapper.selectPage(pageReqVO, userId); diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/CrmContactService.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/CrmContactService.java index 5235dae4f..36e0b1898 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/CrmContactService.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/CrmContactService.java @@ -74,6 +74,14 @@ public interface CrmContactService { */ List getContactList(Collection ids, Long userId); + /** + * 获得联系人列表 + * + * @param ids 编号 + * @return 联系人列表 + */ + List getContactList(Collection ids); + /** * 获得联系人列表 * diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/CrmContactServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/CrmContactServiceImpl.java index 5bab0aa28..e99fd88ab 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/CrmContactServiceImpl.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/CrmContactServiceImpl.java @@ -207,6 +207,11 @@ public class CrmContactServiceImpl implements CrmContactService { return contactMapper.selectBatchIds(ids, userId); } + @Override + public List getContactList(Collection ids) { + return contactMapper.selectBatchIds(ids); + } + @Override public List getContactList() { return contactMapper.selectList();