调整
This commit is contained in:
parent
880d3df452
commit
f0fcda1e20
@ -62,9 +62,15 @@ export default {
|
||||
this.setOptions(this.chartData)
|
||||
},
|
||||
setOptions({ data } = {}) { // , actualData
|
||||
let titleList = [];
|
||||
let dataList = [];
|
||||
data.forEach(function (rItem) {
|
||||
titleList.push(rItem.text)
|
||||
dataList.push(rItem.value)
|
||||
});
|
||||
this.chart.setOption({
|
||||
xAxis: {
|
||||
data: ['前一天', '前两天', '前三天', '前四天', '前五天', '前六天', '前七天'],
|
||||
data: titleList,
|
||||
boundaryGap: false,
|
||||
axisTick: {
|
||||
show: false
|
||||
@ -104,7 +110,7 @@ export default {
|
||||
},
|
||||
smooth: true,
|
||||
type: 'line',
|
||||
data: data,
|
||||
data: dataList,
|
||||
animationDuration: 2800,
|
||||
animationEasing: 'cubicInOut'
|
||||
},
|
||||
|
@ -34,8 +34,8 @@ public class DashboardController {
|
||||
|
||||
@ApiOperation("折线图数据")
|
||||
@GetMapping("/lineChartData")
|
||||
public ResponseEntity<List<Integer>> getLineChartData(String type) {
|
||||
List<Integer> data = dashboardService.getLineChartData(type);
|
||||
public ResponseEntity<List<DashboardDataVo>> getLineChartData(String type) {
|
||||
List<DashboardDataVo> data = dashboardService.getLineChartData(type);
|
||||
return new ResponseEntity<>(data, HttpStatus.OK);
|
||||
}
|
||||
|
||||
|
@ -24,7 +24,7 @@ public interface DashboardService {
|
||||
|
||||
Map<String, Object> getCardData();
|
||||
|
||||
List<Integer> getLineChartData(String type);
|
||||
List<DashboardDataVo> getLineChartData(String type);
|
||||
|
||||
List<DashboardDataVo> getPieChatData();
|
||||
|
||||
|
@ -39,10 +39,9 @@ public class DashboardServiceImpl implements DashboardService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Integer> getLineChartData(String type) {
|
||||
public List<DashboardDataVo> getLineChartData(String type) {
|
||||
List<DashboardDataVo> data = dashboardMapper.getLineChartData(type);
|
||||
List<Integer> values = data.stream().map(i -> Integer.parseInt(i.getValue().toString())).collect(Collectors.toList());
|
||||
return values;
|
||||
return data;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -20,40 +20,32 @@
|
||||
|
||||
<select id="getLineChartData" resultType="me.zhengjie.modules.system.domain.dto.DashboardDataVo">
|
||||
<if test="type == 'user'">
|
||||
select '前一天' text, count(1) value from sys_user where DATE(create_time) = CURDATE() - INTERVAL 1 DAY UNION ALL
|
||||
select '前两天' text, count(1) value from sys_user where DATE(create_time) = CURDATE() - INTERVAL 2 DAY UNION ALL
|
||||
select '前三天' text, count(1) value from sys_user where DATE(create_time) = CURDATE() - INTERVAL 3 DAY UNION ALL
|
||||
select '前四天' text, count(1) value from sys_user where DATE(create_time) = CURDATE() - INTERVAL 4 DAY UNION ALL
|
||||
select '前五天' text, count(1) value from sys_user where DATE(create_time) = CURDATE() - INTERVAL 5 DAY UNION ALL
|
||||
select '前六天' text, count(1) value from sys_user where DATE(create_time) = CURDATE() - INTERVAL 6 DAY UNION ALL
|
||||
select '前七天' text, count(1) value from sys_user where DATE(create_time) = CURDATE() - INTERVAL 7 DAY
|
||||
SELECT dt.date_col text, sum(if(t.create_time is null, 0, 1)) value
|
||||
FROM (
|
||||
SELECT CURDATE() - INTERVAL a.num DAY AS date_col FROM (SELECT 0 AS num UNION ALL SELECT 1 UNION ALL SELECT 2 UNION ALL SELECT 3 UNION ALL SELECT 4 UNION ALL SELECT 5 UNION ALL SELECT 6) a) dt
|
||||
LEFT JOIN sys_user t ON dt.date_col = DATE_FORMAT(t.create_time, '%Y-%m-%d')
|
||||
GROUP BY dt.date_col ORDER BY dt.date_col DESC
|
||||
</if>
|
||||
<if test="type == 'dept'">
|
||||
select '前一天' text, count(1) value from sys_dict where DATE(create_time) = CURDATE() - INTERVAL 1 DAY UNION ALL
|
||||
select '前两天' text, count(1) value from sys_dict where DATE(create_time) = CURDATE() - INTERVAL 2 DAY UNION ALL
|
||||
select '前三天' text, count(1) value from sys_dict where DATE(create_time) = CURDATE() - INTERVAL 3 DAY UNION ALL
|
||||
select '前四天' text, count(1) value from sys_dict where DATE(create_time) = CURDATE() - INTERVAL 4 DAY UNION ALL
|
||||
select '前五天' text, count(1) value from sys_dict where DATE(create_time) = CURDATE() - INTERVAL 5 DAY UNION ALL
|
||||
select '前六天' text, count(1) value from sys_dict where DATE(create_time) = CURDATE() - INTERVAL 6 DAY UNION ALL
|
||||
select '前七天' text, count(1) value from sys_dict where DATE(create_time) = CURDATE() - INTERVAL 7 DAY
|
||||
SELECT dt.date_col text, sum(if(t.create_time is null, 0, 1)) value
|
||||
FROM (
|
||||
SELECT CURDATE() - INTERVAL a.num DAY AS date_col FROM (SELECT 0 AS num UNION ALL SELECT 1 UNION ALL SELECT 2 UNION ALL SELECT 3 UNION ALL SELECT 4 UNION ALL SELECT 5 UNION ALL SELECT 6) a) dt
|
||||
LEFT JOIN sys_dict t ON dt.date_col = DATE_FORMAT(t.create_time, '%Y-%m-%d')
|
||||
GROUP BY dt.date_col ORDER BY dt.date_col DESC
|
||||
</if>
|
||||
<if test="type == 'role'">
|
||||
select '前一天' text, count(1) value from sys_role where DATE(create_time) = CURDATE() - INTERVAL 1 DAY UNION ALL
|
||||
select '前两天' text, count(1) value from sys_role where DATE(create_time) = CURDATE() - INTERVAL 2 DAY UNION ALL
|
||||
select '前三天' text, count(1) value from sys_role where DATE(create_time) = CURDATE() - INTERVAL 3 DAY UNION ALL
|
||||
select '前四天' text, count(1) value from sys_role where DATE(create_time) = CURDATE() - INTERVAL 4 DAY UNION ALL
|
||||
select '前五天' text, count(1) value from sys_role where DATE(create_time) = CURDATE() - INTERVAL 5 DAY UNION ALL
|
||||
select '前六天' text, count(1) value from sys_role where DATE(create_time) = CURDATE() - INTERVAL 6 DAY UNION ALL
|
||||
select '前七天' text, count(1) value from sys_role where DATE(create_time) = CURDATE() - INTERVAL 7 DAY
|
||||
SELECT dt.date_col text, sum(if(t.create_time is null, 0, 1)) value
|
||||
FROM (
|
||||
SELECT CURDATE() - INTERVAL a.num DAY AS date_col FROM (SELECT 0 AS num UNION ALL SELECT 1 UNION ALL SELECT 2 UNION ALL SELECT 3 UNION ALL SELECT 4 UNION ALL SELECT 5 UNION ALL SELECT 6) a) dt
|
||||
LEFT JOIN sys_role t ON dt.date_col = DATE_FORMAT(t.create_time, '%Y-%m-%d')
|
||||
GROUP BY dt.date_col ORDER BY dt.date_col DESC
|
||||
</if>
|
||||
<if test="type == 'law'">
|
||||
select '前一天' text, count(1) value from bus_user where DATE(create_time) = CURDATE() - INTERVAL 1 DAY UNION ALL
|
||||
select '前两天' text, count(1) value from bus_user where DATE(create_time) = CURDATE() - INTERVAL 2 DAY UNION ALL
|
||||
select '前三天' text, count(1) value from bus_user where DATE(create_time) = CURDATE() - INTERVAL 3 DAY UNION ALL
|
||||
select '前四天' text, count(1) value from bus_user where DATE(create_time) = CURDATE() - INTERVAL 4 DAY UNION ALL
|
||||
select '前五天' text, count(1) value from bus_user where DATE(create_time) = CURDATE() - INTERVAL 5 DAY UNION ALL
|
||||
select '前六天' text, count(1) value from bus_user where DATE(create_time) = CURDATE() - INTERVAL 6 DAY UNION ALL
|
||||
select '前七天' text, count(1) value from bus_user where DATE(create_time) = CURDATE() - INTERVAL 7 DAY
|
||||
SELECT dt.date_col text, sum(if(t.create_time is null, 0, 1)) value
|
||||
FROM (
|
||||
SELECT CURDATE() - INTERVAL a.num DAY AS date_col FROM (SELECT 0 AS num UNION ALL SELECT 1 UNION ALL SELECT 2 UNION ALL SELECT 3 UNION ALL SELECT 4 UNION ALL SELECT 5 UNION ALL SELECT 6) a) dt
|
||||
LEFT JOIN bus_user t ON dt.date_col = DATE_FORMAT(t.create_time, '%Y-%m-%d')
|
||||
GROUP BY dt.date_col ORDER BY dt.date_col DESC
|
||||
</if>
|
||||
</select>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user