Commit 73c459f360c0e15841b1ce52442e8af30a258790

Authored by puhui999
1 parent eaa8e4be

完善更进

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 {
13 13 String CRM_AUDIT_STATUS = "crm_audit_status"; // CRM 审批状态
14 14 String CRM_PRODUCT_UNIT = "crm_product_unit"; // CRM 产品单位
15 15 String CRM_PRODUCT_STATUS = "crm_product_status"; // CRM 产品状态
  16 + String CRM_FOLLOW_UP_TYPE = "crm_follow_up_type"; // 跟进方式
16 17  
17 18 }
... ...
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/followup/CrmFollowUpRecordController.java
1 1 package cn.iocoder.yudao.module.crm.controller.admin.followup;
2 2  
3 3 import cn.iocoder.yudao.framework.common.pojo.CommonResult;
4   -import cn.iocoder.yudao.framework.common.pojo.PageParam;
5 4 import cn.iocoder.yudao.framework.common.pojo.PageResult;
  5 +import cn.iocoder.yudao.framework.common.util.collection.MapUtils;
6 6 import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
7   -import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
8   -import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
9 7 import cn.iocoder.yudao.module.crm.controller.admin.followup.vo.CrmFollowUpRecordPageReqVO;
10 8 import cn.iocoder.yudao.module.crm.controller.admin.followup.vo.CrmFollowUpRecordRespVO;
11 9 import cn.iocoder.yudao.module.crm.controller.admin.followup.vo.CrmFollowUpRecordSaveReqVO;
  10 +import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO;
  11 +import cn.iocoder.yudao.module.crm.dal.dataobject.contact.CrmContactDO;
12 12 import cn.iocoder.yudao.module.crm.dal.dataobject.followup.CrmFollowUpRecordDO;
  13 +import cn.iocoder.yudao.module.crm.service.business.CrmBusinessService;
  14 +import cn.iocoder.yudao.module.crm.service.contact.CrmContactService;
13 15 import cn.iocoder.yudao.module.crm.service.followup.CrmFollowUpRecordService;
14 16 import io.swagger.v3.oas.annotations.Operation;
15 17 import io.swagger.v3.oas.annotations.Parameter;
16 18 import io.swagger.v3.oas.annotations.tags.Tag;
17 19 import jakarta.annotation.Resource;
18   -import jakarta.servlet.http.HttpServletResponse;
19 20 import jakarta.validation.Valid;
20 21 import org.springframework.security.access.prepost.PreAuthorize;
21 22 import org.springframework.validation.annotation.Validated;
22 23 import org.springframework.web.bind.annotation.*;
23 24  
24   -import java.io.IOException;
  25 +import java.util.ArrayList;
25 26 import java.util.List;
  27 +import java.util.Map;
  28 +import java.util.Set;
26 29  
27 30 import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
28   -import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT;
  31 +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap;
  32 +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSetByFlatMap;
29 33  
30 34  
31 35 @Tag(name = "管理后台 - 跟进记录")
... ... @@ -36,6 +40,10 @@ public class CrmFollowUpRecordController {
36 40  
37 41 @Resource
38 42 private CrmFollowUpRecordService crmFollowUpRecordService;
  43 + @Resource
  44 + private CrmContactService contactService;
  45 + @Resource
  46 + private CrmBusinessService businessService;
39 47  
40 48 @PostMapping("/create")
41 49 @Operation(summary = "创建跟进记录")
... ... @@ -75,20 +83,32 @@ public class CrmFollowUpRecordController {
75 83 @PreAuthorize("@ss.hasPermission('crm:follow-up-record:query')")
76 84 public CommonResult<PageResult<CrmFollowUpRecordRespVO>> getFollowUpRecordPage(@Valid CrmFollowUpRecordPageReqVO pageReqVO) {
77 85 PageResult<CrmFollowUpRecordDO> pageResult = crmFollowUpRecordService.getFollowUpRecordPage(pageReqVO);
78   - return success(BeanUtils.toBean(pageResult, CrmFollowUpRecordRespVO.class));
  86 + Set<Long> contactIds = convertSetByFlatMap(pageResult.getList(), item -> item.getContactIds().stream());
  87 + Set<Long> businessIds = convertSetByFlatMap(pageResult.getList(), item -> item.getBusinessIds().stream());
  88 + Map<Long, CrmContactDO> contactMap = convertMap(contactService.getContactList(contactIds), CrmContactDO::getId);
  89 + Map<Long, CrmBusinessDO> businessMap = convertMap(businessService.getBusinessList(businessIds), CrmBusinessDO::getId);
  90 + PageResult<CrmFollowUpRecordRespVO> result = BeanUtils.toBean(pageResult, CrmFollowUpRecordRespVO.class);
  91 + result.getList().forEach(item -> {
  92 + setContactNames(item, contactMap);
  93 + setBusinessNames(item, businessMap);
  94 + });
  95 + return success(result);
  96 + }
  97 +
  98 + private static void setContactNames(CrmFollowUpRecordRespVO vo, Map<Long, CrmContactDO> contactMap) {
  99 + List<String> names = new ArrayList<>();
  100 + vo.getContactIds().forEach(id -> {
  101 + MapUtils.findAndThen(contactMap, id, contactDO -> names.add(contactDO.getName()));
  102 + });
  103 + vo.setContactNames(names);
79 104 }
80 105  
81   - @GetMapping("/export-excel")
82   - @Operation(summary = "导出跟进记录 Excel")
83   - @PreAuthorize("@ss.hasPermission('crm:follow-up-record:export')")
84   - @OperateLog(type = EXPORT)
85   - public void exportFollowUpRecordExcel(@Valid CrmFollowUpRecordPageReqVO pageReqVO,
86   - HttpServletResponse response) throws IOException {
87   - pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
88   - List<CrmFollowUpRecordDO> list = crmFollowUpRecordService.getFollowUpRecordPage(pageReqVO).getList();
89   - // 导出 Excel
90   - ExcelUtils.write(response, "跟进记录.xls", "数据", CrmFollowUpRecordRespVO.class,
91   - BeanUtils.toBean(list, CrmFollowUpRecordRespVO.class));
  106 + private static void setBusinessNames(CrmFollowUpRecordRespVO vo, Map<Long, CrmBusinessDO> businessMap) {
  107 + List<String> names = new ArrayList<>();
  108 + vo.getContactIds().forEach(id -> {
  109 + MapUtils.findAndThen(businessMap, id, businessDO -> names.add(businessDO.getName()));
  110 + });
  111 + vo.setBusinessNames(names);
92 112 }
93 113  
94 114 }
95 115 \ No newline at end of file
... ...
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;
5 5 import lombok.Data;
6 6 import lombok.EqualsAndHashCode;
7 7 import lombok.ToString;
8   -import org.springframework.format.annotation.DateTimeFormat;
9   -
10   -import java.time.LocalDateTime;
11   -
12   -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
13 8  
14 9 @Schema(description = "管理后台 - 跟进记录分页 Request VO")
15 10 @Data
... ... @@ -23,15 +18,4 @@ public class CrmFollowUpRecordPageReqVO extends PageParam {
23 18 @Schema(description = "数据编号", example = "5564")
24 19 private Long bizId;
25 20  
26   - @Schema(description = "跟进类型", example = "2")
27   - private Integer type;
28   -
29   - @Schema(description = "下次联系时间")
30   - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
31   - private LocalDateTime[] nextTime;
32   -
33   - @Schema(description = "创建时间")
34   - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
35   - private LocalDateTime[] createTime;
36   -
37 21 }
38 22 \ No newline at end of file
... ...
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/followup/vo/CrmFollowUpRecordRespVO.java
1 1 package cn.iocoder.yudao.module.crm.controller.admin.followup.vo;
2 2  
3 3 import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
4   -import cn.iocoder.yudao.framework.excel.core.convert.DictConvert;
5 4 import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
6   -import com.alibaba.excel.annotation.ExcelProperty;
7 5 import io.swagger.v3.oas.annotations.media.Schema;
8 6 import lombok.Data;
9 7  
10 8 import java.time.LocalDateTime;
  9 +import java.util.List;
  10 +
  11 +import static cn.iocoder.yudao.module.crm.enums.DictTypeConstants.CRM_FOLLOW_UP_TYPE;
11 12  
12 13 @Schema(description = "管理后台 - 跟进记录 Response VO")
13 14 @Data
... ... @@ -15,40 +16,35 @@ import java.time.LocalDateTime;
15 16 public class CrmFollowUpRecordRespVO {
16 17  
17 18 @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "28800")
18   - @ExcelProperty("编号")
19 19 private Long id;
20 20  
21 21 @Schema(description = "数据类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
22   - @ExcelProperty("数据类型")
23 22 private Integer bizType;
24 23  
25 24 @Schema(description = "数据编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "5564")
26   - @ExcelProperty("数据编号")
27 25 private Long bizId;
28 26  
29 27 @Schema(description = "跟进类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
30   - @ExcelProperty(value = "跟进类型", converter = DictConvert.class)
31   - @DictFormat("crm_follow_up_type") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中
  28 + @DictFormat(CRM_FOLLOW_UP_TYPE)
32 29 private Integer type;
33 30  
34 31 @Schema(description = "跟进内容", requiredMode = Schema.RequiredMode.REQUIRED)
35   - @ExcelProperty("跟进内容")
36 32 private String content;
37 33  
38 34 @Schema(description = "下次联系时间", requiredMode = Schema.RequiredMode.REQUIRED)
39   - @ExcelProperty("下次联系时间")
40 35 private LocalDateTime nextTime;
41 36  
42 37 @Schema(description = "关联的商机编号数组")
43   - @ExcelProperty("关联的商机编号数组")
44   - private String businessIds;
  38 + private List<Long> businessIds;
  39 + @Schema(description = "关联的商机名称数组")
  40 + private List<String> businessNames;
45 41  
46 42 @Schema(description = "关联的联系人编号数组")
47   - @ExcelProperty("关联的联系人编号数组")
48   - private String contactIds;
  43 + private List<Long> contactIds;
  44 + @Schema(description = "关联的联系人名称数组")
  45 + private List<String> contactNames;
49 46  
50 47 @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
51   - @ExcelProperty("创建时间")
52 48 private LocalDateTime createTime;
53 49  
54 50 }
55 51 \ No newline at end of file
... ...
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;
6 6 import lombok.Data;
7 7  
8 8 import java.time.LocalDateTime;
  9 +import java.util.List;
9 10  
10 11 @Schema(description = "管理后台 - 跟进记录新增/修改 Request VO")
11 12 @Data
... ... @@ -35,9 +36,9 @@ public class CrmFollowUpRecordSaveReqVO {
35 36 private LocalDateTime nextTime;
36 37  
37 38 @Schema(description = "关联的商机编号数组")
38   - private String businessIds;
  39 + private List<Long> businessIds;
39 40  
40 41 @Schema(description = "关联的联系人编号数组")
41   - private String contactIds;
  42 + private List<Long> contactIds;
42 43  
43 44 }
44 45 \ No newline at end of file
... ...
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;
4 4 import cn.iocoder.yudao.framework.mybatis.core.type.LongListTypeHandler;
5 5 import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO;
6 6 import cn.iocoder.yudao.module.crm.dal.dataobject.contact.CrmContactDO;
  7 +import cn.iocoder.yudao.module.crm.enums.DictTypeConstants;
7 8 import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum;
8 9 import com.baomidou.mybatisplus.annotation.KeySequence;
9 10 import com.baomidou.mybatisplus.annotation.TableField;
... ... @@ -53,9 +54,8 @@ public class CrmFollowUpRecordDO extends BaseDO {
53 54 private Long bizId;
54 55  
55 56 /**
56   - * 跟进类型
  57 + * 跟进类型,关联字典{@link DictTypeConstants#CRM_FOLLOW_UP_TYPE}
57 58 *
58   - * TODO @puhui999:可以搞个数据字典,打电话、发短信、上门拜访、微信、邮箱、QQ
59 59 */
60 60 private Integer type;
61 61 /**
... ...
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&lt;CrmFollowUpRecordDO
19 19 return selectPage(reqVO, new LambdaQueryWrapperX<CrmFollowUpRecordDO>()
20 20 .eqIfPresent(CrmFollowUpRecordDO::getBizType, reqVO.getBizType())
21 21 .eqIfPresent(CrmFollowUpRecordDO::getBizId, reqVO.getBizId())
22   - .eqIfPresent(CrmFollowUpRecordDO::getType, reqVO.getType())
23   - .betweenIfPresent(CrmFollowUpRecordDO::getNextTime, reqVO.getNextTime())
24   - .betweenIfPresent(CrmFollowUpRecordDO::getCreateTime, reqVO.getCreateTime())
25 22 .orderByDesc(CrmFollowUpRecordDO::getId));
26 23 }
27 24  
... ...
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessService.java
... ... @@ -60,6 +60,14 @@ public interface CrmBusinessService {
60 60 List<CrmBusinessDO> getBusinessList(Collection<Long> ids, Long userId);
61 61  
62 62 /**
  63 + * 获得商机列表
  64 + *
  65 + * @param ids 编号
  66 + * @return 商机列表
  67 + */
  68 + List<CrmBusinessDO> getBusinessList(Collection<Long> ids);
  69 +
  70 + /**
63 71 * 获得商机分页
64 72 *
65 73 * 数据权限:基于 {@link CrmBusinessDO}
... ...
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessServiceImpl.java
... ... @@ -156,6 +156,11 @@ public class CrmBusinessServiceImpl implements CrmBusinessService {
156 156 }
157 157  
158 158 @Override
  159 + public List<CrmBusinessDO> getBusinessList(Collection<Long> ids) {
  160 + return businessMapper.selectBatchIds(ids);
  161 + }
  162 +
  163 + @Override
159 164 public PageResult<CrmBusinessDO> getBusinessPage(CrmBusinessPageReqVO pageReqVO, Long userId) {
160 165 return businessMapper.selectPage(pageReqVO, userId);
161 166 }
... ...
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/CrmContactService.java
... ... @@ -77,6 +77,14 @@ public interface CrmContactService {
77 77 /**
78 78 * 获得联系人列表
79 79 *
  80 + * @param ids 编号
  81 + * @return 联系人列表
  82 + */
  83 + List<CrmContactDO> getContactList(Collection<Long> ids);
  84 +
  85 + /**
  86 + * 获得联系人列表
  87 + *
80 88 * @return 联系人列表
81 89 */
82 90 List<CrmContactDO> getContactList();
... ...
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/CrmContactServiceImpl.java
... ... @@ -208,6 +208,11 @@ public class CrmContactServiceImpl implements CrmContactService {
208 208 }
209 209  
210 210 @Override
  211 + public List<CrmContactDO> getContactList(Collection<Long> ids) {
  212 + return contactMapper.selectBatchIds(ids);
  213 + }
  214 +
  215 + @Override
211 216 public List<CrmContactDO> getContactList() {
212 217 return contactMapper.selectList();
213 218 }
... ...