提交 39050090 编写于 作者: Hello 码上秃's avatar Hello 码上秃

功能开发__统计分析__线索统计__新增线索数量折线图

上级 03b019df
......@@ -29,4 +29,13 @@ huike-framework/src/main/java/com/huike/framework/interceptor/RepeatSubmitInterc
huike-common/src/main/java/com/huike/common/annotation/RepeatSubmit.java
ID工具包:
huike-common/src/main/java/com/huike/common/utils/uuid
\ No newline at end of file
huike-common/src/main/java/com/huike/common/utils/uuid
妙用Optional(134行)
huike-report/src/main/java/com/huike/report/service/impl/ReportServiceImpl.java
传入两个时间范围,返回这两个时间范围内的所有时间,并保存在一个集合中(334行)
huike-report/src/main/java/com/huike/report/service/impl/ReportServiceImpl.java
关于时间和数字的SQL写法(116行)
huike-report/src/main/resources/mapper/report/ReportMapper.xml
\ No newline at end of file
......@@ -49,6 +49,17 @@ public class ReportController extends BaseController {
return AjaxResult.success(reportService.subjectStatistics(beginCreateTime, endCreateTime));
}
/**
* 新增线索数量折线图
* @param beginCreateTime
* @param endCreateTime
* @return
*/
@GetMapping("/cluesStatistics/{beginCreateTime}/{endCreateTime}")
public LineChartVO cluesStatistics(@PathVariable String beginCreateTime, @PathVariable String endCreateTime) {
return reportService.cluesStatistics(beginCreateTime, endCreateTime);
}
/**
* 销售统计
* @param beginCreateTime
......
......@@ -102,4 +102,6 @@ public interface TbContractMapper {
public List<Map<String,Object>> contractStatisticsByUser(IndexStatisticsVo query);
List<Map<String, Object>> subjectStatistics(@Param("beginCreateTime") String beginCreateTime, @Param("endCreateTime") String endCreateTime);
List<Map<String, Object>> clueStatistics(@Param("beginCreateTime") String beginCreateTime, @Param("endCreateTime") String endCreateTime);
}
......@@ -276,9 +276,22 @@
tb_contract tc
LEFT join tb_course tb on tc.course_id = tb.id
WHERE
DATE_FORMAT( tc.create_time, '%Y-%m-%d' ) BETWEEN DATE_FORMAT( #{beginCreateTime}, '%Y-%m-%d' ) AND DATE_FORMAT( #{endCreateTime}, '%Y-%m-%d' )
<if test="beginCreateTime != null and beginCreateTime != ''
and endCreateTime != null and endCreateTime != ''">
DATE_FORMAT( tc.create_time, '%Y-%m-%d' ) BETWEEN DATE_FORMAT( #{beginCreateTime}, '%Y-%m-%d' ) AND DATE_FORMAT( #{endCreateTime}, '%Y-%m-%d' )
</if>
GROUP BY
tb.name
</select>
<select id="clueStatistics" resultType="java.util.Map">
SELECT
count( 1 ) AS num, DATE_FORMAT( create_time, '%Y-%m-%d' ) dd
FROM
tb_clue
where
date_format( create_time, '%y-%m-%d' ) BETWEEN date_format(#{beginCreateTime},'%y-%m-%d') AND date_format(#{endCreateTime},'%y-%m-%d')
GROUP BY dd
</select>
</mapper>
\ No newline at end of file
......@@ -3,9 +3,7 @@ package com.huike.report.service;
import java.util.List;
import java.util.Map;
import com.huike.common.core.page.TableDataInfo;
import com.huike.report.domain.vo.*;
import org.apache.ibatis.annotations.Param;
import com.huike.clues.domain.TbActivity;
import com.huike.clues.domain.TbClue;
......@@ -30,6 +28,13 @@ public interface IReportService {
*/
List<Map<String, Object>> subjectStatistics(String beginCreateTime, String endCreateTime);
/**
* 新增线索数量折线图
* @param beginCreateTime
* @param endCreateTime
* @return
*/
LineChartVO cluesStatistics(String beginCreateTime, String endCreateTime);
/**
* 客户统计报表
......
......@@ -108,6 +108,48 @@ public class ReportServiceImpl implements IReportService {
return contractMapper.subjectStatistics(beginCreateTime, endCreateTime);
}
/**
* 新增线索数量折线图
* @param beginCreateTime
* @param endCreateTime
* @return
*/
@Override
public LineChartVO cluesStatistics(String beginCreateTime, String endCreateTime) {
LineChartVO lineChartVo = new LineChartVO();
try {
LineSeriesVO lineSeriesDTONewClue = new LineSeriesVO();
lineSeriesDTONewClue.setName("新增线索数量");
LineSeriesVO lineSeriesDTOTotalClue = new LineSeriesVO();
lineSeriesDTOTotalClue.setName("线索总数量");
List<String> timeList = findDates(beginCreateTime, endCreateTime); // 传入两个时间范围,返回这两个时间范围内的所有时间
lineChartVo.setxAxis(timeList);
List<LineSeriesVO> series = new ArrayList<>();
List<Map<String, Object>> statistics = contractMapper.clueStatistics(beginCreateTime, endCreateTime);
int sum = 0;
for (String dayByDay : timeList) {
Optional optional = statistics.stream().filter(item -> item.get("dd").equals(dayByDay)).findFirst();
if (optional.isPresent()) {
Map<String, Object> cuurentData = (Map<String, Object>) optional.get();
lineSeriesDTONewClue.getData().add(cuurentData.get("num"));
sum += Integer.parseInt(cuurentData.get("num").toString());
} else {
lineSeriesDTONewClue.getData().add(0);
}
lineSeriesDTOTotalClue.getData().add(sum);
}
series.add(lineSeriesDTONewClue);
series.add(lineSeriesDTOTotalClue);
lineChartVo.setSeries(series);
} catch (ParseException e) {
}
return lineChartVo;
}
@Override
public LineChartVO salesStatistics(String beginCreateTime, String endCreateTime) {
LineChartVO lineChartVo =new LineChartVO();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册