mirror of
				https://gitee.com/hhyykk/ipms-sjy.git
				synced 2025-11-01 02:38:43 +08:00 
			
		
		
		
	完善更进
This commit is contained in:
		| @@ -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<PageResult<CrmFollowUpRecordRespVO>> getFollowUpRecordPage(@Valid CrmFollowUpRecordPageReqVO 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") | ||||
|     @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<CrmFollowUpRecordDO> list = crmFollowUpRecordService.getFollowUpRecordPage(pageReqVO).getList(); | ||||
|         // 导出 Excel | ||||
|         ExcelUtils.write(response, "跟进记录.xls", "数据", CrmFollowUpRecordRespVO.class, | ||||
|                 BeanUtils.toBean(list, CrmFollowUpRecordRespVO.class)); | ||||
|     private static void setContactNames(CrmFollowUpRecordRespVO vo, Map<Long, CrmContactDO> contactMap) { | ||||
|         List<String> 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<Long, CrmBusinessDO> businessMap) { | ||||
|         List<String> names = new ArrayList<>(); | ||||
|         vo.getContactIds().forEach(id -> { | ||||
|             MapUtils.findAndThen(businessMap, id, businessDO -> names.add(businessDO.getName())); | ||||
|         }); | ||||
|         vo.setBusinessNames(names); | ||||
|     } | ||||
|  | ||||
| } | ||||
| @@ -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; | ||||
|  | ||||
| } | ||||
| @@ -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<Long> businessIds; | ||||
|     @Schema(description = "关联的商机名称数组") | ||||
|     private List<String> businessNames; | ||||
|  | ||||
|     @Schema(description = "关联的联系人编号数组") | ||||
|     @ExcelProperty("关联的联系人编号数组") | ||||
|     private String contactIds; | ||||
|     private List<Long> contactIds; | ||||
|     @Schema(description = "关联的联系人名称数组") | ||||
|     private List<String> contactNames; | ||||
|  | ||||
|     @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) | ||||
|     @ExcelProperty("创建时间") | ||||
|     private LocalDateTime createTime; | ||||
|  | ||||
| } | ||||
| @@ -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<Long> businessIds; | ||||
|  | ||||
|     @Schema(description = "关联的联系人编号数组") | ||||
|     private String contactIds; | ||||
|     private List<Long> contactIds; | ||||
|  | ||||
| } | ||||
| @@ -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; | ||||
|     /** | ||||
|   | ||||
| @@ -19,9 +19,6 @@ public interface CrmFollowUpRecordMapper extends BaseMapperX<CrmFollowUpRecordDO | ||||
|         return selectPage(reqVO, new LambdaQueryWrapperX<CrmFollowUpRecordDO>() | ||||
|                 .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)); | ||||
|     } | ||||
|  | ||||
|   | ||||
| @@ -59,6 +59,14 @@ public interface CrmBusinessService { | ||||
|      */ | ||||
|     List<CrmBusinessDO> getBusinessList(Collection<Long> ids, Long userId); | ||||
|  | ||||
|     /** | ||||
|      * 获得商机列表 | ||||
|      * | ||||
|      * @param ids 编号 | ||||
|      * @return 商机列表 | ||||
|      */ | ||||
|     List<CrmBusinessDO> getBusinessList(Collection<Long> ids); | ||||
|  | ||||
|     /** | ||||
|      * 获得商机分页 | ||||
|      * | ||||
|   | ||||
| @@ -155,6 +155,11 @@ public class CrmBusinessServiceImpl implements CrmBusinessService { | ||||
|         return businessMapper.selectBatchIds(ids, userId); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public List<CrmBusinessDO> getBusinessList(Collection<Long> ids) { | ||||
|         return businessMapper.selectBatchIds(ids); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public PageResult<CrmBusinessDO> getBusinessPage(CrmBusinessPageReqVO pageReqVO, Long userId) { | ||||
|         return businessMapper.selectPage(pageReqVO, userId); | ||||
|   | ||||
| @@ -74,6 +74,14 @@ public interface CrmContactService { | ||||
|      */ | ||||
|     List<CrmContactDO> getContactList(Collection<Long> ids, Long userId); | ||||
|  | ||||
|     /** | ||||
|      * 获得联系人列表 | ||||
|      * | ||||
|      * @param ids 编号 | ||||
|      * @return 联系人列表 | ||||
|      */ | ||||
|     List<CrmContactDO> getContactList(Collection<Long> ids); | ||||
|  | ||||
|     /** | ||||
|      * 获得联系人列表 | ||||
|      * | ||||
|   | ||||
| @@ -207,6 +207,11 @@ public class CrmContactServiceImpl implements CrmContactService { | ||||
|         return contactMapper.selectBatchIds(ids, userId); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public List<CrmContactDO> getContactList(Collection<Long> ids) { | ||||
|         return contactMapper.selectBatchIds(ids); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public List<CrmContactDO> getContactList() { | ||||
|         return contactMapper.selectList(); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 puhui999
					puhui999