今天的任务开始加难度了~~
各位小伙伴还能接收嘛
现在就让我们开始吧~~
首先查看接口文档,确定需求,清除接口位置,以及请求和相应的参数
接口名:/report/getVulnerabilityMap
请求方式:GET
参数列表:
传入参数:
/report/getVulnerabilityMap/2021-03-08/2022-04-08
beginCreateTime 开始时间
endCreateTime 结束时间
返回值:
{
"msg":"操作成功",
"code":200,
"data":{
"cluesNums":752, 线索数量
"effectiveCluesNums":506, 有效线索数
"businessNums":268, 商机数量
"contractNums":111 合同数量
}
}
只需要找到对应的接口,按照返回值类型来开发就可以了,以下奉上代码~~
实体类:
@Data
public class VulnerabilityMapVo {
private Integer cluesNums; //线索数
private Integer effectiveCluesNums; //有效线索数
private Integer businessNums; //商机数
private Integer contractNums ; //合同数
}
controller层:
/**
* 线索转化率漏斗图
* @param beginCreateTime 开始时间
* @param endCreateTime 结束时间
* @return
*/
//http://localhost/dev-api/report/getVulnerabilityMap/2022-09-27/2022-10-04
@GetMapping("/getVulnerabilityMap/{beginCreateTime}/{endCreateTime}")
public AjaxResult getVulnerabilityMap(@PathVariable String beginCreateTime, @PathVariable String endCreateTime){
return AjaxResult.success(reportService.getVulnerabilityMap(beginCreateTime,endCreateTime));
}
service层
VulnerabilityMapVo getVulnerabilityMap(String beginCreateTime, String endCreateTime);
实现层:
/**
* 线索转化率漏斗图
* @param beginCreateTime
* @param endCreateTime
* @return
*/
@Override
public VulnerabilityMapVo getVulnerabilityMap(String beginCreateTime, String endCreateTime) {
VulnerabilityMapVo mapVo = new VulnerabilityMapVo();
//线索总数
int cluesNums = clueMapper.getCluesNums(beginCreateTime,endCreateTime);
System.err.println("线索总数" + cluesNums);
//有效线索数
int effectiveCluesNums = clueMapper.getEffectiveCluesNums(beginCreateTime,endCreateTime);
System.err.println("有效线索数" + effectiveCluesNums);
//商机数量
int businessNums = businessMapper.getBusinessNums(beginCreateTime,endCreateTime);
System.err.println("商机数量" + businessNums);
//合同数量
int contractNums = contractMapper.getContractNums(beginCreateTime,endCreateTime);
System.err.println("合同数量" + contractNums);
mapVo.setCluesNums(cluesNums);
mapVo.setEffectiveCluesNums(effectiveCluesNums);
mapVo.setBusinessNums(businessNums);
mapVo.setContractNums(contractNums);
return mapVo;
}
线索总数mapper:
/**
* 漏斗图--线索总数
* @return
*/
int getCluesNums(@Param("beginCreateTime") String beginCreateTime,@Param("endCreateTime") String endCreateTime);
线索总数mapper.xml
有效线索mapper:
/**
* 有效线索数
* @return
*/
int getEffectiveCluesNums(@Param("beginCreateTime") String beginCreateTime,@Param("endCreateTime") String endCreateTime);
有效线索mapper.xml:
对应的状态1、2、3、7,定义在clue实体类最下方的常量
商机总数量mapper:
/**
* 商机数量
* @param beginCreateTime
* @param endCreateTime
* @return
*/
int getBusinessNums(@Param("beginCreateTime") String beginCreateTime, @Param("endCreateTime") String endCreateTime);
商机总数量mapper.xml
合同总数量mapper:
/**
* 合同数量
* @param beginCreateTime
* @param endCreateTime
* @return
*/
int getContractNums(@Param("beginCreateTime") String beginCreateTime,@Param("endCreateTime") String endCreateTime);
合同总数量mapper.xml
同样的,首先还是查看接口文档,看对应的接口以及请求和相应参数
接口名/index/businessChangeStatistics
请求方式Get
参数列表
传入参数:
/index/businessChangeStatistics?beginCreateTime=2021-02-02&endCreateTime=2022-02-17
beginCreateTime 开始时间
endCreateTime 结束时间
返回值:
{
"msg":"操作成功",
"code":200,
"data":[
{
"create_by":"zhangkai", 用户名称
"deptName":"商机部", 部门名称
"num":100, 转化数量
"radio":31.65 转化率
},
{
"create_by":"admin",
"deptName":"研发部门",
"num":9,
"radio":2.85
},
{
"create_by":"shangji",
"deptName":"新人创建演示用部门",
"num":1,
"radio":0.32
},
{
"create_by":"shangji1",
"deptName":"销售部门",
"num":1,
"radio":0.32
}
]
}
相应数据实体类:
@Data
public class BusinessChangeVO {
private String createBy; //用户名称
private String deptName; //部门名称
private Long num; //转化数量
private BigDecimal radio; //转化率
}
controller层:
//商机转换龙虎榜
// http://localhost/dev-api/index/businessChangeStatistics
// ?beginCreateTime=2022-09-05&endCreateTime=2022-10-05&deptId=100
@GetMapping("/businessChangeStatistics")
public AjaxResult businessChangeStatistics(@Param("beginCreateTime") String beginCreateTime,
@Param("endCreateTime") String endCreateTime,
@Param("deptId") Integer deptId){
List list = reportService.businessChangeStatistics(beginCreateTime,endCreateTime,deptId);
return AjaxResult.success(list);
}
service层:
List businessChangeStatistics(String beginCreateTime, String endCreateTime, Integer deptId);
实现层:
* 商机龙虎榜
* @param beginCreateTime
* @param endCreateTime
* @param deptId
* @return
*/
@Override
public List businessChangeStatistics(String beginCreateTime, String endCreateTime, Integer deptId) {
//获取总的商机数量
int all = businessMapper.getAll(beginCreateTime,endCreateTime);
System.err.println("商机all:" + all);
//获取转换商机数据
List volist = contractMapper.getVOlist(beginCreateTime,endCreateTime);
System.err.println(volist);
//计算转化百分比
List collect = volist.stream().map(vo -> {
vo.setRadio(getRadio(all, vo.getNum()));
return vo;
}).collect(Collectors.toList());
return collect;
}
原代码提供了一个静态方法,用来计算百分比:
/**
* ************看我看我***********
* 用我能少走很多路
* 我是用来机选百分比的方法
*
* @param all
* @param num
* @return
*/
private BigDecimal getRadio(Integer all, Long num) {
if (all.intValue() == 0) {
return new BigDecimal(0);
}
BigDecimal numBigDecimal = new BigDecimal(num);
BigDecimal allBigDecimal = new BigDecimal(all);
BigDecimal divide = numBigDecimal.divide(allBigDecimal, 4, BigDecimal.ROUND_HALF_UP);
return divide.multiply(new BigDecimal(100));
}
对应的mapper方法:
/**
* 获取商机总数量
* @param beginCreateTime
* @param endCreateTime
* @return
*/
int getAll(@Param("beginCreateTime") String beginCreateTime, @Param("endCreateTime") String endCreateTime);
businessMapper:
/**
* 获取商机转化数据
* @param beginCreateTime
* @param endCreateTime
* @return
*/
List getVOlist(@Param("beginCreateTime") String beginCreateTime, @Param("endCreateTime") String endCreateTime);
线索转化龙虎榜实现基本上同上,直接上代码
接口文档信息如下:
接口名/index/salesStatistic
请求方式Get
参数列表
传入参数:
/index/salesStatistic?beginCreateTime=2021-02-02&endCreateTime=2022-02-17
beginCreateTime 开始时间
endCreateTime 结束时间
返回值:
{
"msg":"操作成功",
"code":200,
"data":[
{
"create_by":"admin", 用户名称
"deptName":"研发部门", 部门名称
"num":70, 转化条数
"radio":9.32 转化率
},
{
"create_by":"xiansuo",
"deptName":"新人创建演示用部门",
"num":22,
"radio":2.93
},
{
"create_by":"zhuoyihang",
"deptName":"市场部",
"num":20,
"radio":2.66
},
{
"create_by":"jack",
"deptName":"市场部",
"num":20,
"radio":2.66
},
{
"create_by":"liuxingyu",
"deptName":"市场部",
"num":20,
"radio":2.66
},
{
"create_by":"zhangxiaoyan",
"deptName":"市场部",
"num":20,
"radio":2.66
},
{
"create_by":"zhangzhang",
"deptName":"市场部",
"num":20,
"radio":2.66
},
{
"create_by":"zhangyifan",
"deptName":"市场部",
"num":20,
"radio":2.66
},
{
"create_by":"zhanger",
"deptName":"市场部",
"num":20,
"radio":2.66
},
{
"create_by":"zhangguan",
"deptName":"市场部",
"num":20,
"radio":2.66
}
]
}
实体类:
返回数据一样,所以可以和上面公用一个实体类
controller:
//线索转换龙虎榜
//http://localhost/dev-api/index/salesStatistic
// ?beginCreateTime=2022-09-05&endCreateTime=2022-10-05&deptId=100
@GetMapping("/salesStatistic")
public AjaxResult salesStatistic(@Param("beginCreateTime") String beginCreateTime,
@Param("endCreateTime") String endCreateTime,
@Param("deptId") Integer deptId){
List list = reportService.salesStatistic(beginCreateTime,endCreateTime,deptId);
return AjaxResult.success(list);
}
service层:
List salesStatistic(String beginCreateTime, String endCreateTime, Integer deptId);
实现层:
/**
* 线索龙虎榜
* @param beginCreateTime
* @param endCreateTime
* @param deptId
* @return
*/
@Override
public List salesStatistic(String beginCreateTime, String endCreateTime, Integer deptId) {
//获取总的线索数量
int all = clueMapper.getCluesNums(beginCreateTime,endCreateTime);
System.err.println("线索all:" + all);
//获取转换线索数据
List volist = businessMapper.getVOlist(beginCreateTime,endCreateTime);
System.err.println(volist);
List collect = volist.stream().map(vo -> {
vo.setRadio(getRadio(all, vo.getNum()));
return vo;
}).collect(Collectors.toList());
return collect;
}
clueMapper层:
/**
* 漏斗图--线索总数
* @return
*/
int getCluesNums(@Param("beginCreateTime") String beginCreateTime,@Param("endCreateTime") String endCreateTime);
businessMapper:
/**
* 获取商机转化数据
* @param beginCreateTime
* @param endCreateTime
* @return
*/
List getVOlist(@Param("beginCreateTime") String beginCreateTime, @Param("endCreateTime") String endCreateTime);
以上则是今天的开胃菜环节了,接下来正式进入任务环节~~
开始干吧~~
首先查看接口文档
接口名 /index/getTodoInfo
请求方式 get请求
参数列表
传入参数:
/index/getTodoInfo?beginCreateTime=2021-05-05&endCreateTime=2023-05-05
beginCreateTime 开始时间
endCreateTime 结束时间
返回值:
{
"msg":"操作成功",
"code":200,
"data":{
"tofollowedCluesNum":0, //待跟进线索数目
"tofollowedBusinessNum":0,//待跟进商机数目
"toallocatedCluesNum":1,//待分配线索数目
"toallocatedBusinessNum":0 //待分配商机数目
}
}
controller层:
/**
* 首页--待办数据统计接口
* @param beginCreateTime
* @param endCreateTime
* @return
*/
// http://localhost/dev-api/index/getTodoInfo?beginCreateTime=2022-09-04&endCreateTime=2022-10-04
@GetMapping("/getTodoInfo")
public AjaxResult getTodoInfo(@RequestParam("beginCreateTime") String beginCreateTime,
@RequestParam("endCreateTime") String endCreateTime){
return AjaxResult.success(reportService.getTodoInfo(beginCreateTime,endCreateTime));
}
service层:
/**
* 待办事宜
* @param beginCreateTime
* @param endCreateTime
* @return
*/
IndexTodoInfoVO getTodoInfo(String beginCreateTime, String endCreateTime);
实体类:
/**
* 首页--今日待办--返回前端VO类
*/
@Data
public class IndexTodoInfoVO {
private Integer tofollowedCluesNum=0; //待跟进线索数目
private Integer tofollowedBusinessNum=0; //待跟进商机数目
private Integer toallocatedCluesNum=0; //待分配线索数目
private Integer toallocatedBusinessNum=0; //待分配商机数目
}
实现层:
/**
* 首页--待办数据统计接口
* @param beginCreateTime 开始时间
* @param endCreateTime 结束时间
* @return
*/
@Override
public IndexTodoInfoVO getTodoInfo(String beginCreateTime, String endCreateTime) {
//1)构建一个空的结果集对象
IndexTodoInfoVO result = new IndexTodoInfoVO();
//2 封装结果集属性
// 2.1 由于查询需要用到用户名 调用工具类获取用户名
String username = SecurityUtils.getUsername();
try {
//3 封装结果集对象
result.setTofollowedCluesNum(reportMpper.getTofollowedCluesNum(beginCreateTime, endCreateTime, username));
result.setTofollowedBusinessNum(reportMpper.getTofollowedBusinessNum(beginCreateTime, endCreateTime, username));
result.setToallocatedCluesNum(reportMpper.getToallocatedCluesNum(beginCreateTime, endCreateTime, username));
result.setToallocatedBusinessNum(reportMpper.getToallocatedBusinessNum(beginCreateTime, endCreateTime, username));
} catch (Exception e) {
e.printStackTrace();
return null;
}
//4 返回结果集对象
return result;
}
mapper:
/**=========================================待办========================================*/
/**
* 待跟进线索数目
* @param beginCreateTime
* @param endCreateTime
* @param username
* @return
*/
Integer getTofollowedCluesNum(@Param("startTime") String beginCreateTime,
@Param("endTime") String endCreateTime,
@Param("username") String username);
/**
* 待跟进商机数目
* @param beginCreateTime
* @param endCreateTime
* @param username
* @return
*/
Integer getTofollowedBusinessNum(@Param("startTime") String beginCreateTime,
@Param("endTime") String endCreateTime,
@Param("username") String username);
/**
* 待分配线索数目
* @param beginCreateTime
* @param endCreateTime
* @param username
* @return
*/
Integer getToallocatedCluesNum(@Param("startTime") String beginCreateTime,
@Param("endTime") String endCreateTime,
@Param("username") String username);
/**
* 待分配商机数目
* @param beginCreateTime
* @param endCreateTime
* @param username
* @return
*/
Integer getToallocatedBusinessNum(@Param("startTime") String beginCreateTime,
@Param("endTime") String endCreateTime,
@Param("username") String username);
mapper.xml
首先查看接口文档
接口名/report/subjectStatistics
请求方式 get请求
参数列表
传入参数:
/report/subjectStatistics/2020-03-11/2022-04-14
beginCreateTime 开始时间
endCreateTime 结束时间
返回值:
{
"msg":"操作成功",
"code":200,
"data":[
{
"subject":"Java", 学科
"num":108 合同数量
},
{
"subject":"产品经理",
"num":1
},
{
"subject":"前端",
"num":2
},
{
"subject":"大数据",
"num":1
}
]
}
controller:
/**
* 学科客户分布饼图
* @return
*/
@GetMapping("/subjectStatistics/{beginCreateTime}/{endCreateTime}")
public AjaxResult subjectStatistics(@PathVariable String beginCreateTime, @PathVariable String endCreateTime){
return AjaxResult.success(reportService.subjectStatistics(beginCreateTime,endCreateTime));
}
servic层:
/**
* 学科分布饼图
* @param beginCreateTime
* @param endCreateTime
* @return
*/
List subjectStatistics(String beginCreateTime, String endCreateTime);
实体类:
@Data
public class PieVO {
//学科名称
private String subject;
//学科数量
private Integer num;
}
实现层:
/**
* 学科饼图统计
* @param beginCreateTime
* @param endCreateTime
* @return
*/
@Override
public List subjectStatistics(String beginCreateTime, String endCreateTime) {
//查学科集合
List projects = contractMapper.selectProject();
System.err.println(projects);
return projects;
}
mapper:
public List selectProject();
老规矩,查看接口文档,这个和原代码写的新增商机数量折线图类似,直接cv过来改一下就好了!!!
接口名 /report/cluesStatistics
请求方式 get请求
参数列表
传入参数:
/report/cluesStatistics/2022-03-06/2022-03-13 beginCreateTime 开始时间
endCreateTime 结束时间
返回值:
{
"xAxis":[
"2021-03-11",
"2021-03-12",
"2021-03-13",
"2021-03-14",
"2021-03-15"
],
"series":[
{
"name":"新增线索数量",
"data":[
0,
0,
0,
0,
0
]
},
{
"name":"线索总数量",
"data":[
0,
0,
0,
0,
0
]
}
]
}
controller:
/**
* 线索统计
* @param beginCreateTime
* @param endCreateTime
* @return
*/
@GetMapping("/cluesStatistics/{beginCreateTime}/{endCreateTime}")
public LineChartVO cluesStatistics(@PathVariable String beginCreateTime, @PathVariable String endCreateTime){
return reportService.cluesStatistics(beginCreateTime,endCreateTime);
}
service:
/**
* 线索统计
* @param beginCreateTime
* @param endCreateTime
* @return
*/
public LineChartVO cluesStatistics(String beginCreateTime, String endCreateTime);
实体类:
/**
* 折线图
*/
public class LineChartVO {
private List xAxis = new ArrayList<>();
private List series = new ArrayList<>();
public List getxAxis() {
return xAxis;
}
public void setxAxis(List xAxis) {
this.xAxis = xAxis;
}
public List getSeries() {
return series;
}
public void setSeries(List series) {
this.series = series;
}
}
实现层:
/**
* 线索统计
*
* @param beginCreateTime
* @param endCreateTime
* @return
*/
@Override
public LineChartVO cluesStatistics(String beginCreateTime, String endCreateTime) {
LineChartVO lineChartVo = new LineChartVO();
try {
//获取范围时间集合
List timeList = findDates(beginCreateTime, endCreateTime);
lineChartVo.setxAxis(timeList);
List series = new ArrayList<>();
List
此处原代码提供了一个方法,用来获取两个时间段的时间范围,并返回一个集合,直接那俩用就好了
/**
* *************看我看我**************
* 传入两个时间范围,返回这两个时间范围内的所有时间,并保存在一个集合中
*
* @param beginTime
* @param endTime
* @return
* @throws ParseException
*/
public static List findDates(String beginTime, String endTime)
throws ParseException {
List allDate = new ArrayList();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Date dBegin = sdf.parse(beginTime);
Date dEnd = sdf.parse(endTime);
allDate.add(sdf.format(dBegin));
Calendar calBegin = Calendar.getInstance();
// 使用给定的 Date 设置此 Calendar 的时间
calBegin.setTime(dBegin);
Calendar calEnd = Calendar.getInstance();
// 使用给定的 Date 设置此 Calendar 的时间
calEnd.setTime(dEnd);
// 测试此日期是否在指定日期之后
while (dEnd.after(calBegin.getTime())) {
// 根据日历的规则,为给定的日历字段添加或减去指定的时间量
calBegin.add(Calendar.DAY_OF_MONTH, 1);
allDate.add(sdf.format(calBegin.getTime()));
}
System.out.println("时间==" + allDate);
return allDate;
}
以上就是第三天的大概内容了,由不懂得可以私信呀~