任务目录:
任务一:添加线索跟进记录
任务二:查询线索跟进记录列表
任务三:添加商机跟进记录
任务四:查询商机跟进记录列表
任务一:新增线索跟进记录
实体类:
@Data
public class TableDataInfo implements Serializable{private static final long serialVersionUID = 1L;/** 总记录数 */private long total;/** 列表数据 */private List<?> rows;/** 消息状态码 */private int code;/** 消息内容 */private String msg;private Map<String,Object> params;/*** 表格数据对象*/public TableDataInfo(){}/*** 分页* * @param list 列表数据* @param total 总记录数*/public TableDataInfo(List<?> list, int total){this.rows = list;this.total = total;}
Controller层
/*** 新增线索跟进记录*/@PreAuthorize("@ss.hasPermi('clues:record:add')")@Log(title = "线索跟进记录", businessType = BusinessType.INSERT)@PostMappingpublic AjaxResult add(@RequestBody ClueTrackRecordVo tbClueTrackRecord) {tbClueTrackRecordService.addTrack(tbClueTrackRecord);return AjaxResult.success("操作成功!");}
Service层:
void addTrack(ClueTrackRecordVo tbClueTrackRecord);
实现层:
public void addTrack(ClueTrackRecordVo tbClueTrackRecord) {/*分析:线索跟进涉及到两张表的操作,一部分是客户基本信息(已经存在,所以用修改操作),一部分是跟进信息(不存在,所以用新增操作)*///1.因为修改操作的参数要求TbClue,所以将ClueTrackRecordVo拷贝到TbClue中TbClue tbClue = new TbClue();BeanUtils.copyProperties(tbClueTrackRecord,tbClue);tbClue.setId(tbClueTrackRecord.getClueId());//TbClue表中线索为id,ClueTrackRecordVo表中线索为clueIdtbClueMapper.updateTbClue(tbClue);//2.在跟进表中新增String username = SecurityUtils.getUsername();tbClueTrackRecordMapper.addTrackRecord(tbClueTrackRecord,username);}
Mapper层:
void addTrackRecord(@Param("tbClueTrackRecord") ClueTrackRecordVo tbClueTrackRecord, @Param("username") String username);
Mapper.xml
<insert id="addTrackRecord">INSERT INTO tb_clue_track_record(clue_id, create_by, subject, record, level, create_time, next_time) VALUES (#{tbClueTrackRecord.clueId},#{username},#{tbClueTrackRecord.subject},#{tbClueTrackRecord.record},#{tbClueTrackRecord.level},NOW(),#{tbClueTrackRecord.nextTime})</insert>
任务二:查询线索跟进记录列表
效果图:
实体类:
/*** 表格分页数据对象* * */
@Date
public class TableDataInfo implements Serializable{private static final long serialVersionUID = 1L;/** 总记录数 */private long total;/** 列表数据 */private List<?> rows;/** 消息状态码 */private int code;/** 消息内容 */private String msg;private Map<String,Object> params;
Controller层:
/*** 查询线索跟进记录列表*/@PreAuthorize("@ss.hasPermi('clues:record:list')")@GetMapping("/list")public TableDataInfo list(@RequestParam("clueId")Long clueId) {List<TbClueTrackRecord> list=tbClueTrackRecordService.getRecords(clueId);//返回需要一个list集合类型的TbClueTrackRecordreturn getDataTable(list);//getDataTable类型是TableDataInfo,用于返回分页集合}
Service层:
List<TbClueTrackRecord> getRecords(Long clueId);
实现层:
@Overridepublic List<TbClueTrackRecord> getRecords(Long clueId) {return tbClueTrackRecordMapper.selectTrack(clueId);}
Mapper层:
List<TbClueTrackRecord> selectTrack(Long clueId);
Mapper.xml:
<select id="selectTrack" resultType="com.huike.clues.domain.TbClueTrackRecord">SELECT id, clue_id, create_by, subject, record, level, create_time, type, next_timeFROM tb_clue_track_recordWHERE clue_id=#{clueId}ORDER BY create_time DESC</select>
任务三:新增商机跟进记录
实体类:
@Date
public class BusinessTrackVo {private Long businessId;/** 客户姓名 */private String name;/** 手机号 */private String phone;/** 渠道 */private Long channelId;/** 活动id */private Long activityId;/** 省 */@Excel(name = "省")private String provinces;/** 区 */@Excel(name = "区")private String city;/** 男或者女 */private String sex;/** 年龄 */private Integer age;/** 微信 */private String weixin;/** qq */private String qq;/** 意向等级 */private String level;/** 意向学科 */private String subject;/** 课程 */private Long courseId;/** 职业 */private String occupation;/** 学历 */private String education;/** 在职情况 */private String job;/** 薪资 */private String salary;/** 专业 */private String major;/** 希望薪资 */private String expectedSalary;/** 学习原因 */private String reasons;/** 职业计划 */private String plan;/** 计划时间 */@JsonFormat(pattern = "yyyy-MM-dd")@Excel(name = "计划时间", width = 30, dateFormat = "yyyy-MM-dd")private Date planTime;/** 其他意向 */@Excel(name = "其他意向")private String otherIntention;@JsonFormat(pattern = "yyyy-MM-dd HH:mm")private Date nextTime;//沟通备注private String remark;//沟通重点private String keyItems;/** 沟通纪要 */private String record;/** 跟进状态 */private String trackStatus;
Controller层:
/*** 新增商机跟进记录*/@PreAuthorize("@ss.hasPermi('business:record:add')")@Log(title = "商机跟进记录", businessType = BusinessType.INSERT)@PostMappingpublic AjaxResult add(@RequestBody BusinessTrackVo businessTrackVo){tbBusinessTrackRecordService.addBusinessTrack(businessTrackVo);return AjaxResult.success("操作成功!");}
Service层:
void addBusinessTrack(BusinessTrackVo businessTrackVo);
实现层:
@Overridepublic void addBusinessTrack(BusinessTrackVo businessTrackVo) {TbBusiness tbBusiness = new TbBusiness();BeanUtils.copyProperties(businessTrackVo, tbBusiness);tbBusiness.setId(businessTrackVo.getBusinessId());tbBusinessMapper.updateTbBusiness(tbBusiness);String username = SecurityUtils.getUsername();tbBusinessTrackRecordMapper.addBusinessTrack(businessTrackVo, username);}
Mapper层:
void addBusinessTrack(@Param("businessTrackVo") BusinessTrackVo businessTrackVo,@Param("username") String username);
Mapper.xml:
<insert id="addBusinessTrack">INSERT INTO tb_business_track_recordVALUES (null,#{businessTrackVo.businessId},#{username},#{businessTrackVo.keyItems},#{businessTrackVo.record},NOW(),#{businessTrackVo.trackStatus},#{businessTrackVo.nextTime})</insert>
任务四:查询商机跟进记录列表
效果图:
实体类:
@Date
public class TbBusinessTrackRecord extends BaseEntity
{private static final long serialVersionUID = 1L;/** 任务id */private Long id;/** 线索id */@Excel(name = "线索id")private Long businessId;@Excel(name = "跟进人")private String createBy;/** 沟通重点 */@Excel(name = "沟通重点")private String keyItems;private List<String> keys =new ArrayList<>();/** 沟通纪要 */@Excel(name = "沟通纪要")private String record;/** 跟进状态 */@Excel(name = "跟进状态")private String trackStatus;@JsonFormat(pattern = "yyyy-MM-dd HH:mm")private Date nextTime;
Controller层:
/*** 查询商机跟进记录列表*/@PreAuthorize("@ss.hasPermi('business:record:list')")@GetMapping("/list")public AjaxResult list(@RequestParam("businessId")Long id){List<TbBusinessTrackRecord> tbBusinessTrackRecordList = tbBusinessTrackRecordService.selectBusinessTrack(id);return AjaxResult.success(tbBusinessTrackRecordList);}
Service层:
List<TbBusinessTrackRecord> selectBusinessTrack(Long id);
实现层:
@Overridepublic List<TbBusinessTrackRecord> selectBusinessTrack(Long id) {//思考:因为tbBusinessTrackRecordMapper获取的对象集合不包括返回需要的keys字段,所以遍历对象,将对象的KeyItems值查询对应的keys//1.获取TbBusinessTrackRecord集合List<TbBusinessTrackRecord> tbBusinessTrackRecordList = tbBusinessTrackRecordMapper.selectBusinessTrack(id);//2.遍历集合for (TbBusinessTrackRecord tbBusinessTrackRecord : tbBusinessTrackRecordList) {//2.将tbBusinessTrackRecord对象中的keyItems取出String[] split = tbBusinessTrackRecord.getKeyItems().split(",");//3.将tbBusinessTrackRecord对象中的keys取出List<String> keys = tbBusinessTrackRecord.getKeys();//3.将split赋值给tbBusinessTrackRecord中的keysfor (String s : split) {String key = sysDictDataService.selectDictLabel("communication_point", s);//通过sysDictDataService获取type(communication_point)和value(2,4,5)对应的label(价格,师资....)keys.add(key);}}return tbBusinessTrackRecordList;
}
Mapper层:
List<TbBusinessTrackRecord> selectBusinessTrack(Long id);
Mapper.xml:
<sql id="Base_Column_List">create_time,business_id,key_items,track_status,next_time,record,create_by</sql><select id="selectBusinessTrack" resultType="com.huike.business.domain.TbBusinessTrackRecord">SELECT <include refid="Base_Column_List"/>FROM tb_business_track_recordWHERE business_id=#{businessId}ORDER BY create_time DESC</select>