完善更进

This commit is contained in:
puhui999 2024-01-14 00:22:17 +08:00
parent eaa8e4be96
commit 73c459f360
11 changed files with 80 additions and 55 deletions

View File

@ -13,5 +13,6 @@ public interface DictTypeConstants {
String CRM_AUDIT_STATUS = "crm_audit_status"; // CRM 审批状态 String CRM_AUDIT_STATUS = "crm_audit_status"; // CRM 审批状态
String CRM_PRODUCT_UNIT = "crm_product_unit"; // CRM 产品单位 String CRM_PRODUCT_UNIT = "crm_product_unit"; // CRM 产品单位
String CRM_PRODUCT_STATUS = "crm_product_status"; // CRM 产品状态 String CRM_PRODUCT_STATUS = "crm_product_status"; // CRM 产品状态
String CRM_FOLLOW_UP_TYPE = "crm_follow_up_type"; // 跟进方式
} }

View File

@ -1,31 +1,35 @@
package cn.iocoder.yudao.module.crm.controller.admin.followup; package cn.iocoder.yudao.module.crm.controller.admin.followup;
import cn.iocoder.yudao.framework.common.pojo.CommonResult; 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.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.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.CrmFollowUpRecordPageReqVO;
import cn.iocoder.yudao.module.crm.controller.admin.followup.vo.CrmFollowUpRecordRespVO; 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.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.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 cn.iocoder.yudao.module.crm.service.followup.CrmFollowUpRecordService;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.Valid; import jakarta.validation.Valid;
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.util.ArrayList;
import java.util.List; 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.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 = "管理后台 - 跟进记录") @Tag(name = "管理后台 - 跟进记录")
@ -36,6 +40,10 @@ public class CrmFollowUpRecordController {
@Resource @Resource
private CrmFollowUpRecordService crmFollowUpRecordService; private CrmFollowUpRecordService crmFollowUpRecordService;
@Resource
private CrmContactService contactService;
@Resource
private CrmBusinessService businessService;
@PostMapping("/create") @PostMapping("/create")
@Operation(summary = "创建跟进记录") @Operation(summary = "创建跟进记录")
@ -75,20 +83,32 @@ public class CrmFollowUpRecordController {
@PreAuthorize("@ss.hasPermission('crm:follow-up-record:query')") @PreAuthorize("@ss.hasPermission('crm:follow-up-record:query')")
public CommonResult<PageResult<CrmFollowUpRecordRespVO>> getFollowUpRecordPage(@Valid CrmFollowUpRecordPageReqVO pageReqVO) { public CommonResult<PageResult<CrmFollowUpRecordRespVO>> getFollowUpRecordPage(@Valid CrmFollowUpRecordPageReqVO pageReqVO) {
PageResult<CrmFollowUpRecordDO> pageResult = crmFollowUpRecordService.getFollowUpRecordPage(pageReqVO); PageResult<CrmFollowUpRecordDO> pageResult = crmFollowUpRecordService.getFollowUpRecordPage(pageReqVO);
return success(BeanUtils.toBean(pageResult, CrmFollowUpRecordRespVO.class)); Set<Long> contactIds = convertSetByFlatMap(pageResult.getList(), item -> item.getContactIds().stream());
Set<Long> businessIds = convertSetByFlatMap(pageResult.getList(), item -> item.getBusinessIds().stream());
Map<Long, CrmContactDO> contactMap = convertMap(contactService.getContactList(contactIds), CrmContactDO::getId);
Map<Long, CrmBusinessDO> businessMap = convertMap(businessService.getBusinessList(businessIds), CrmBusinessDO::getId);
PageResult<CrmFollowUpRecordRespVO> result = BeanUtils.toBean(pageResult, CrmFollowUpRecordRespVO.class);
result.getList().forEach(item -> {
setContactNames(item, contactMap);
setBusinessNames(item, businessMap);
});
return success(result);
} }
@GetMapping("/export-excel") private static void setContactNames(CrmFollowUpRecordRespVO vo, Map<Long, CrmContactDO> contactMap) {
@Operation(summary = "导出跟进记录 Excel") List<String> names = new ArrayList<>();
@PreAuthorize("@ss.hasPermission('crm:follow-up-record:export')") vo.getContactIds().forEach(id -> {
@OperateLog(type = EXPORT) MapUtils.findAndThen(contactMap, id, contactDO -> names.add(contactDO.getName()));
public void exportFollowUpRecordExcel(@Valid CrmFollowUpRecordPageReqVO pageReqVO, });
HttpServletResponse response) throws IOException { vo.setContactNames(names);
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); }
List<CrmFollowUpRecordDO> list = crmFollowUpRecordService.getFollowUpRecordPage(pageReqVO).getList();
// 导出 Excel private static void setBusinessNames(CrmFollowUpRecordRespVO vo, Map<Long, CrmBusinessDO> businessMap) {
ExcelUtils.write(response, "跟进记录.xls", "数据", CrmFollowUpRecordRespVO.class, List<String> names = new ArrayList<>();
BeanUtils.toBean(list, CrmFollowUpRecordRespVO.class)); vo.getContactIds().forEach(id -> {
MapUtils.findAndThen(businessMap, id, businessDO -> names.add(businessDO.getName()));
});
vo.setBusinessNames(names);
} }
} }

View File

@ -5,11 +5,6 @@ import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import lombok.ToString; 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") @Schema(description = "管理后台 - 跟进记录分页 Request VO")
@Data @Data
@ -23,15 +18,4 @@ public class CrmFollowUpRecordPageReqVO extends PageParam {
@Schema(description = "数据编号", example = "5564") @Schema(description = "数据编号", example = "5564")
private Long bizId; 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;
} }

View File

@ -1,13 +1,14 @@
package cn.iocoder.yudao.module.crm.controller.admin.followup.vo; 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.annotations.DictFormat;
import cn.iocoder.yudao.framework.excel.core.convert.DictConvert;
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.ExcelProperty;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data; import lombok.Data;
import java.time.LocalDateTime; 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") @Schema(description = "管理后台 - 跟进记录 Response VO")
@Data @Data
@ -15,40 +16,35 @@ import java.time.LocalDateTime;
public class CrmFollowUpRecordRespVO { public class CrmFollowUpRecordRespVO {
@Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "28800") @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "28800")
@ExcelProperty("编号")
private Long id; private Long id;
@Schema(description = "数据类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") @Schema(description = "数据类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
@ExcelProperty("数据类型")
private Integer bizType; private Integer bizType;
@Schema(description = "数据编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "5564") @Schema(description = "数据编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "5564")
@ExcelProperty("数据编号")
private Long bizId; private Long bizId;
@Schema(description = "跟进类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") @Schema(description = "跟进类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
@ExcelProperty(value = "跟进类型", converter = DictConvert.class) @DictFormat(CRM_FOLLOW_UP_TYPE)
@DictFormat("crm_follow_up_type") // TODO 代码优化建议设置到对应的 DictTypeConstants 枚举类中
private Integer type; private Integer type;
@Schema(description = "跟进内容", requiredMode = Schema.RequiredMode.REQUIRED) @Schema(description = "跟进内容", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("跟进内容")
private String content; private String content;
@Schema(description = "下次联系时间", requiredMode = Schema.RequiredMode.REQUIRED) @Schema(description = "下次联系时间", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("下次联系时间")
private LocalDateTime nextTime; private LocalDateTime nextTime;
@Schema(description = "关联的商机编号数组") @Schema(description = "关联的商机编号数组")
@ExcelProperty("关联的商机编号数组") private List<Long> businessIds;
private String businessIds; @Schema(description = "关联的商机名称数组")
private List<String> businessNames;
@Schema(description = "关联的联系人编号数组") @Schema(description = "关联的联系人编号数组")
@ExcelProperty("关联的联系人编号数组") private List<Long> contactIds;
private String contactIds; @Schema(description = "关联的联系人名称数组")
private List<String> contactNames;
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("创建时间")
private LocalDateTime createTime; private LocalDateTime createTime;
} }

View File

@ -6,6 +6,7 @@ import jakarta.validation.constraints.NotNull;
import lombok.Data; import lombok.Data;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.List;
@Schema(description = "管理后台 - 跟进记录新增/修改 Request VO") @Schema(description = "管理后台 - 跟进记录新增/修改 Request VO")
@Data @Data
@ -35,9 +36,9 @@ public class CrmFollowUpRecordSaveReqVO {
private LocalDateTime nextTime; private LocalDateTime nextTime;
@Schema(description = "关联的商机编号数组") @Schema(description = "关联的商机编号数组")
private String businessIds; private List<Long> businessIds;
@Schema(description = "关联的联系人编号数组") @Schema(description = "关联的联系人编号数组")
private String contactIds; private List<Long> contactIds;
} }

View File

@ -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.framework.mybatis.core.type.LongListTypeHandler;
import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO; 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.contact.CrmContactDO;
import cn.iocoder.yudao.module.crm.enums.DictTypeConstants;
import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum; import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum;
import com.baomidou.mybatisplus.annotation.KeySequence; import com.baomidou.mybatisplus.annotation.KeySequence;
import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableField;
@ -53,9 +54,8 @@ public class CrmFollowUpRecordDO extends BaseDO {
private Long bizId; private Long bizId;
/** /**
* 跟进类型 * 跟进类型,关联字典{@link DictTypeConstants#CRM_FOLLOW_UP_TYPE}
* *
* TODO @puhui999可以搞个数据字典打电话发短信上门拜访微信邮箱QQ
*/ */
private Integer type; private Integer type;
/** /**

View File

@ -19,9 +19,6 @@ public interface CrmFollowUpRecordMapper extends BaseMapperX<CrmFollowUpRecordDO
return selectPage(reqVO, new LambdaQueryWrapperX<CrmFollowUpRecordDO>() return selectPage(reqVO, new LambdaQueryWrapperX<CrmFollowUpRecordDO>()
.eqIfPresent(CrmFollowUpRecordDO::getBizType, reqVO.getBizType()) .eqIfPresent(CrmFollowUpRecordDO::getBizType, reqVO.getBizType())
.eqIfPresent(CrmFollowUpRecordDO::getBizId, reqVO.getBizId()) .eqIfPresent(CrmFollowUpRecordDO::getBizId, reqVO.getBizId())
.eqIfPresent(CrmFollowUpRecordDO::getType, reqVO.getType())
.betweenIfPresent(CrmFollowUpRecordDO::getNextTime, reqVO.getNextTime())
.betweenIfPresent(CrmFollowUpRecordDO::getCreateTime, reqVO.getCreateTime())
.orderByDesc(CrmFollowUpRecordDO::getId)); .orderByDesc(CrmFollowUpRecordDO::getId));
} }

View File

@ -59,6 +59,14 @@ public interface CrmBusinessService {
*/ */
List<CrmBusinessDO> getBusinessList(Collection<Long> ids, Long userId); List<CrmBusinessDO> getBusinessList(Collection<Long> ids, Long userId);
/**
* 获得商机列表
*
* @param ids 编号
* @return 商机列表
*/
List<CrmBusinessDO> getBusinessList(Collection<Long> ids);
/** /**
* 获得商机分页 * 获得商机分页
* *

View File

@ -155,6 +155,11 @@ public class CrmBusinessServiceImpl implements CrmBusinessService {
return businessMapper.selectBatchIds(ids, userId); return businessMapper.selectBatchIds(ids, userId);
} }
@Override
public List<CrmBusinessDO> getBusinessList(Collection<Long> ids) {
return businessMapper.selectBatchIds(ids);
}
@Override @Override
public PageResult<CrmBusinessDO> getBusinessPage(CrmBusinessPageReqVO pageReqVO, Long userId) { public PageResult<CrmBusinessDO> getBusinessPage(CrmBusinessPageReqVO pageReqVO, Long userId) {
return businessMapper.selectPage(pageReqVO, userId); return businessMapper.selectPage(pageReqVO, userId);

View File

@ -74,6 +74,14 @@ public interface CrmContactService {
*/ */
List<CrmContactDO> getContactList(Collection<Long> ids, Long userId); List<CrmContactDO> getContactList(Collection<Long> ids, Long userId);
/**
* 获得联系人列表
*
* @param ids 编号
* @return 联系人列表
*/
List<CrmContactDO> getContactList(Collection<Long> ids);
/** /**
* 获得联系人列表 * 获得联系人列表
* *

View File

@ -207,6 +207,11 @@ public class CrmContactServiceImpl implements CrmContactService {
return contactMapper.selectBatchIds(ids, userId); return contactMapper.selectBatchIds(ids, userId);
} }
@Override
public List<CrmContactDO> getContactList(Collection<Long> ids) {
return contactMapper.selectBatchIds(ids);
}
@Override @Override
public List<CrmContactDO> getContactList() { public List<CrmContactDO> getContactList() {
return contactMapper.selectList(); return contactMapper.selectList();