Commit d0934510af0e6fca23e0911dee3b64bc0e5fa7cb

Authored by YunaiV
1 parent 09e200c3

mp:完成公众号统计的用户累计数据、消息概况数据

yudao-module-mp/yudao-module-mp-api/src/main/java/cn/iocoder/yudao/module/mp/enums/ErrorCodeConstants.java
... ... @@ -16,6 +16,8 @@ public interface ErrorCodeConstants {
16 16  
17 17 // ========== 公众号账号 1006001000============
18 18 ErrorCode STATISTICS_GET_USER_SUMMARY_FAIL = new ErrorCode(1006001000, "获取用户增减数据失败,原因:{}");
  19 + ErrorCode STATISTICS_GET_USER_CUMULATE_FAIL = new ErrorCode(1006001001, "获得用户累计数据失败,原因:{}");
  20 + ErrorCode STATISTICS_GET_UPSTREAM_MESSAGE_FAIL = new ErrorCode(1006001002, "获得消息发送概况数据失败,原因:{}");
19 21  
20 22 // TODO 要处理下
21 23 ErrorCode COMMON_NOT_EXISTS = new ErrorCode(1006001002, "用户不存在");
... ...
yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/statistics/MpStatisticsController.java
1 1 package cn.iocoder.yudao.module.mp.controller.admin.statistics;
2 2  
3 3 import cn.iocoder.yudao.framework.common.pojo.CommonResult;
  4 +import cn.iocoder.yudao.module.mp.controller.admin.statistics.vo.MpStatisticsGetReqVO;
  5 +import cn.iocoder.yudao.module.mp.controller.admin.statistics.vo.MpStatisticsUpstreamMessageRespVO;
  6 +import cn.iocoder.yudao.module.mp.controller.admin.statistics.vo.MpStatisticsUserCumulateRespVO;
  7 +import cn.iocoder.yudao.module.mp.controller.admin.statistics.vo.MpStatisticsUserSummaryRespVO;
4 8 import cn.iocoder.yudao.module.mp.convert.statistics.MpStatisticsConvert;
5 9 import cn.iocoder.yudao.module.mp.service.statistics.MpStatisticsService;
6   -import cn.iocoder.yudao.module.mp.controller.admin.statistics.vo.MpStatisticsGetReqVO;
7 10 import io.swagger.annotations.Api;
8 11 import io.swagger.annotations.ApiOperation;
  12 +import me.chanjar.weixin.mp.bean.datacube.WxDataCubeMsgResult;
  13 +import me.chanjar.weixin.mp.bean.datacube.WxDataCubeUserCumulate;
9 14 import me.chanjar.weixin.mp.bean.datacube.WxDataCubeUserSummary;
10 15 import org.springframework.security.access.prepost.PreAuthorize;
11 16 import org.springframework.validation.annotation.Validated;
... ... @@ -30,9 +35,28 @@ public class MpStatisticsController {
30 35 @GetMapping("/user-summary")
31 36 @ApiOperation("获得用户增减数据")
32 37 @PreAuthorize("@ss.hasPermission('mp:statistics:query')")
33   - public CommonResult<List<WxDataCubeUserSummary>> getAccount(MpStatisticsGetReqVO getReqVO) {
34   - List<WxDataCubeUserSummary> list = mpStatisticsService.getUserSummary(getReqVO.getId(), getReqVO.getDate());
  38 + public CommonResult<List<MpStatisticsUserSummaryRespVO>> getUserSummary(MpStatisticsGetReqVO getReqVO) {
  39 + List<WxDataCubeUserSummary> list = mpStatisticsService.getUserSummary(
  40 + getReqVO.getAccountId(), getReqVO.getDate());
35 41 return success(MpStatisticsConvert.INSTANCE.convertList01(list));
36 42 }
37 43  
  44 + @GetMapping("/user-cumulate")
  45 + @ApiOperation("获得用户累计数据")
  46 + @PreAuthorize("@ss.hasPermission('mp:statistics:query')")
  47 + public CommonResult<List<MpStatisticsUserCumulateRespVO>> getUserCumulate(MpStatisticsGetReqVO getReqVO) {
  48 + List<WxDataCubeUserCumulate> list = mpStatisticsService.getUserCumulate(
  49 + getReqVO.getAccountId(), getReqVO.getDate());
  50 + return success(MpStatisticsConvert.INSTANCE.convertList02(list));
  51 + }
  52 +
  53 + @GetMapping("/upstream-message")
  54 + @ApiOperation("获取消息发送概况数据")
  55 + @PreAuthorize("@ss.hasPermission('mp:statistics:query')")
  56 + public CommonResult<List<MpStatisticsUpstreamMessageRespVO>> getUpstreamMessage(MpStatisticsGetReqVO getReqVO) {
  57 + List<WxDataCubeMsgResult> list = mpStatisticsService.getUpstreamMessage(
  58 + getReqVO.getAccountId(), getReqVO.getDate());
  59 + return success(MpStatisticsConvert.INSTANCE.convertList03(list));
  60 + }
  61 +
38 62 }
... ...
yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/statistics/vo/MpStatisticsGetReqVO.java
... ... @@ -16,7 +16,7 @@ public class MpStatisticsGetReqVO {
16 16  
17 17 @ApiModelProperty(value = "公众号账号的编号", required = true, example = "1024")
18 18 @NotNull(message = "公众号账号的编号不能为空")
19   - private Long id;
  19 + private Long accountId;
20 20  
21 21 @ApiModelProperty(value = "查询时间范围")
22 22 @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
... ...
yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/statistics/vo/MpStatisticsUpstreamMessageRespVO.java 0 → 100644
  1 +package cn.iocoder.yudao.module.mp.controller.admin.statistics.vo;
  2 +
  3 +import io.swagger.annotations.ApiModel;
  4 +import io.swagger.annotations.ApiModelProperty;
  5 +import lombok.Data;
  6 +
  7 +import java.util.Date;
  8 +
  9 +@ApiModel("管理后台 - 某一天的用户增减数据 Response VO")
  10 +@Data
  11 +public class MpStatisticsUpstreamMessageRespVO {
  12 +
  13 + @ApiModelProperty(value = "日期", required = true)
  14 + private Date refDate;
  15 +
  16 + @ApiModelProperty(value = "上行发送了(向公众号发送了)消息的用户数", required = true, example = "10")
  17 + private Integer messageUser;
  18 +
  19 + @ApiModelProperty(value = "上行发送了消息的消息总数", required = true, example = "20")
  20 + private Integer messageCount;
  21 +
  22 +}
... ...
yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/statistics/vo/MpStatisticsUserCumulateRespVO.java 0 → 100644
  1 +package cn.iocoder.yudao.module.mp.controller.admin.statistics.vo;
  2 +
  3 +import io.swagger.annotations.ApiModel;
  4 +import io.swagger.annotations.ApiModelProperty;
  5 +import lombok.Data;
  6 +
  7 +import java.util.Date;
  8 +
  9 +@ApiModel("管理后台 - 某一天的消息发送概况数据 Response VO")
  10 +@Data
  11 +public class MpStatisticsUserCumulateRespVO {
  12 +
  13 + @ApiModelProperty(value = "日期", required = true)
  14 + private Date refDate;
  15 +
  16 + @ApiModelProperty(value = "累计用户量", required = true, example = "10")
  17 + private Integer cumulateUser;
  18 +
  19 +}
... ...
yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/convert/statistics/MpStatisticsConvert.java
1 1 package cn.iocoder.yudao.module.mp.convert.statistics;
2 2  
  3 +import cn.iocoder.yudao.module.mp.controller.admin.statistics.vo.MpStatisticsUpstreamMessageRespVO;
  4 +import cn.iocoder.yudao.module.mp.controller.admin.statistics.vo.MpStatisticsUserCumulateRespVO;
  5 +import cn.iocoder.yudao.module.mp.controller.admin.statistics.vo.MpStatisticsUserSummaryRespVO;
  6 +import me.chanjar.weixin.mp.bean.datacube.WxDataCubeMsgResult;
  7 +import me.chanjar.weixin.mp.bean.datacube.WxDataCubeUserCumulate;
3 8 import me.chanjar.weixin.mp.bean.datacube.WxDataCubeUserSummary;
4 9 import org.mapstruct.Mapper;
  10 +import org.mapstruct.Mapping;
  11 +import org.mapstruct.Mappings;
5 12 import org.mapstruct.factory.Mappers;
6 13  
7 14 import java.util.List;
... ... @@ -11,6 +18,17 @@ public interface MpStatisticsConvert {
11 18  
12 19 MpStatisticsConvert INSTANCE = Mappers.getMapper(MpStatisticsConvert.class);
13 20  
14   - List<WxDataCubeUserSummary> convertList01(List<WxDataCubeUserSummary> list);
  21 + List<MpStatisticsUserSummaryRespVO> convertList01(List<WxDataCubeUserSummary> list);
  22 +
  23 + List<MpStatisticsUserCumulateRespVO> convertList02(List<WxDataCubeUserCumulate> list);
  24 +
  25 + List<MpStatisticsUpstreamMessageRespVO> convertList03(List<WxDataCubeMsgResult> list);
  26 +
  27 + @Mappings({
  28 + @Mapping(source = "refDate", target = "refDate", dateFormat = "yyyy-MM-dd"),
  29 + @Mapping(source = "msgUser", target = "messageUser"),
  30 + @Mapping(source = "msgCount", target = "messageCount"),
  31 + })
  32 + MpStatisticsUpstreamMessageRespVO convert(WxDataCubeMsgResult bean);
15 33  
16 34 }
... ...
yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/statistics/MpStatisticsService.java
1 1 package cn.iocoder.yudao.module.mp.service.statistics;
2 2  
  3 +import me.chanjar.weixin.mp.bean.datacube.WxDataCubeMsgResult;
  4 +import me.chanjar.weixin.mp.bean.datacube.WxDataCubeUserCumulate;
3 5 import me.chanjar.weixin.mp.bean.datacube.WxDataCubeUserSummary;
4 6  
5 7 import java.time.LocalDateTime;
... ... @@ -15,10 +17,28 @@ public interface MpStatisticsService {
15 17 /**
16 18 * 获取用户增减数据
17 19 *
18   - * @param id 公众号账号编号
  20 + * @param accountId 公众号账号编号
19 21 * @param date 时间区间
20 22 * @return 用户增减数据
21 23 */
22   - List<WxDataCubeUserSummary> getUserSummary(Long id, LocalDateTime[] date);
  24 + List<WxDataCubeUserSummary> getUserSummary(Long accountId, LocalDateTime[] date);
  25 +
  26 + /**
  27 + * 获取用户累计数据
  28 + *
  29 + * @param accountId 公众号账号编号
  30 + * @param date 时间区间
  31 + * @return 用户累计数据
  32 + */
  33 + List<WxDataCubeUserCumulate> getUserCumulate(Long accountId, LocalDateTime[] date);
  34 +
  35 + /**
  36 + * 获取消息发送概况数据
  37 + *
  38 + * @param accountId 公众号账号编号
  39 + * @param date 时间区间
  40 + * @return 消息发送概况数据
  41 + */
  42 + List<WxDataCubeMsgResult> getUpstreamMessage(Long accountId, LocalDateTime[] date);
23 43  
24 44 }
... ...
yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/statistics/MpStatisticsServiceImpl.java
... ... @@ -4,6 +4,8 @@ import cn.hutool.core.date.DateUtil;
4 4 import cn.iocoder.yudao.module.mp.framework.mp.core.MpServiceFactory;
5 5 import me.chanjar.weixin.common.error.WxErrorException;
6 6 import me.chanjar.weixin.mp.api.WxMpService;
  7 +import me.chanjar.weixin.mp.bean.datacube.WxDataCubeMsgResult;
  8 +import me.chanjar.weixin.mp.bean.datacube.WxDataCubeUserCumulate;
7 9 import me.chanjar.weixin.mp.bean.datacube.WxDataCubeUserSummary;
8 10 import org.springframework.context.annotation.Lazy;
9 11 import org.springframework.stereotype.Service;
... ... @@ -13,7 +15,7 @@ import java.time.LocalDateTime;
13 15 import java.util.List;
14 16  
15 17 import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
16   -import static cn.iocoder.yudao.module.mp.enums.ErrorCodeConstants.STATISTICS_GET_USER_SUMMARY_FAIL;
  18 +import static cn.iocoder.yudao.module.mp.enums.ErrorCodeConstants.*;
17 19  
18 20 /**
19 21 * 公众号统计 Service 实现类
... ... @@ -28,8 +30,8 @@ public class MpStatisticsServiceImpl implements MpStatisticsService {
28 30 private MpServiceFactory mpServiceFactory;
29 31  
30 32 @Override
31   - public List<WxDataCubeUserSummary> getUserSummary(Long id, LocalDateTime[] date) {
32   - WxMpService mpService = mpServiceFactory.getRequiredMpService(id);
  33 + public List<WxDataCubeUserSummary> getUserSummary(Long accountId, LocalDateTime[] date) {
  34 + WxMpService mpService = mpServiceFactory.getRequiredMpService(accountId);
33 35 try {
34 36 return mpService.getDataCubeService().getUserSummary(
35 37 DateUtil.date(date[0]), DateUtil.date(date[1]));
... ... @@ -38,5 +40,26 @@ public class MpStatisticsServiceImpl implements MpStatisticsService {
38 40 }
39 41 }
40 42  
  43 + @Override
  44 + public List<WxDataCubeUserCumulate> getUserCumulate(Long accountId, LocalDateTime[] date) {
  45 + WxMpService mpService = mpServiceFactory.getRequiredMpService(accountId);
  46 + try {
  47 + return mpService.getDataCubeService().getUserCumulate(
  48 + DateUtil.date(date[0]), DateUtil.date(date[1]));
  49 + } catch (WxErrorException e) {
  50 + throw exception(STATISTICS_GET_USER_CUMULATE_FAIL, e.getError().getErrorMsg());
  51 + }
  52 + }
  53 +
  54 + @Override
  55 + public List<WxDataCubeMsgResult> getUpstreamMessage(Long accountId, LocalDateTime[] date) {
  56 + WxMpService mpService = mpServiceFactory.getRequiredMpService(accountId);
  57 + try {
  58 + return mpService.getDataCubeService().getUpstreamMsg(
  59 + DateUtil.date(date[0]), DateUtil.date(date[1]));
  60 + } catch (WxErrorException e) {
  61 + throw exception(STATISTICS_GET_UPSTREAM_MESSAGE_FAIL, e.getError().getErrorMsg());
  62 + }
  63 + }
41 64  
42 65 }
... ...
yudao-ui-admin/src/api/mp/statistics.js
1 1 import request from '@/utils/request'
2 2  
3   -// TODO 获得公众号账号分页
4   -export function getInterfaceSummary(query) {
  3 +// 获取消息发送概况数据
  4 +export function getUpstreamMessage(query) {
5 5 return request({
6   - url: '/mp/account/page',
  6 + url: '/mp/statistics/upstream-message',
7 7 method: 'get',
8 8 params: query
9 9 })
10 10 }
11 11  
12   -// TODO 获得公众号账号分页
  12 +// 用户增减数据
13 13 export function getUserSummary(query) {
14 14 return request({
15 15 url: '/mp/statistics/user-summary',
... ... @@ -18,10 +18,10 @@ export function getUserSummary(query) {
18 18 })
19 19 }
20 20  
21   -// TODO 获得公众号账号分页
  21 +// 获得用户累计数据
22 22 export function getUserCumulate(query) {
23 23 return request({
24   - url: '/mp/account/page',
  24 + url: '/mp/statistics/user-cumulate',
25 25 method: 'get',
26 26 params: query
27 27 })
... ...
yudao-ui-admin/src/utils/dateUtils.js
... ... @@ -34,17 +34,14 @@ export function endOfDay(date) {
34 34 }
35 35  
36 36 export function betweenDay(date1, date2) {
37   - // 适配 string 字符串的日期
38   - if (typeof date1 === 'string') {
39   - date1 = new Date(date1);
40   - }
41   - if (typeof date2 === 'string') {
42   - date2 = new Date(date2);
43   - }
  37 + date1 = convertDate(date1);
  38 + date2 = convertDate(date2);
  39 + // 计算差值
44 40 return Math.floor((date2.getTime() - date1.getTime()) / (24 * 3600 * 1000));
45 41 }
46 42  
47 43 export function formatDate(date, fmt) {
  44 + date = convertDate(date);
48 45 const o = {
49 46 "M+": date.getMonth() + 1, //月份
50 47 "d+": date.getDate(), //日
... ... @@ -64,3 +61,15 @@ export function formatDate(date, fmt) {
64 61 }
65 62 return fmt;
66 63 }
  64 +
  65 +export function addTime(date, time) {
  66 + date = convertDate(date);
  67 + return new Date(date.getTime() + time);
  68 +}
  69 +
  70 +export function convertDate(date) {
  71 + if (typeof date === 'string') {
  72 + return new Date(date);
  73 + }
  74 + return date;
  75 +}
... ...
yudao-ui-admin/src/views/mp/statistics/index.vue
... ... @@ -9,17 +9,14 @@
9 9 @change="changeDate" >
10 10 </el-date-picker>
11 11 </div>
12   - <el-row>
13   - <el-col :span="12">
14   - <div id="userCumulateChart" :style="{width: '80%', height: '500px'}"></div>
15   - </el-col>
16   - <el-col :span="12">
17   - <div id="interfaceSummaryChart" :style="{width: '80%', height: '500px'}"></div>
18   - </el-col>
19   - <el-col :span="12">
20   - <div id="interfaceSummaryChart2" :style="{width: '80%', height: '500px'}"></div>
21   - </el-col>
22   - </el-row>
  12 +<!-- <el-row>-->
  13 +<!-- <el-col :span="12">-->
  14 +<!-- <div id="interfaceSummaryChart" :style="{width: '80%', height: '500px'}"></div>-->
  15 +<!-- </el-col>-->
  16 +<!-- <el-col :span="12">-->
  17 +<!-- <div id="interfaceSummaryChart2" :style="{width: '80%', height: '500px'}"></div>-->
  18 +<!-- </el-col>-->
  19 +<!-- </el-row>-->
23 20  
24 21 <el-row>
25 22 <el-col :span="12" class="card-box">
... ... @@ -28,18 +25,27 @@
28 25 <span>用户增减数据</span>
29 26 </div>
30 27 <div class="el-table el-table--enable-row-hover el-table--medium">
31   - <div ref="userSummary" style="height: 420px" />
  28 + <div ref="userSummaryChart" style="height: 420px" />
32 29 </div>
33 30 </el-card>
34 31 </el-col>
35   -
36 32 <el-col :span="12" class="card-box">
37 33 <el-card>
38 34 <div slot="header">
39   - <span>内存信息</span>
  35 + <span>累计用户数据</span>
40 36 </div>
41 37 <div class="el-table el-table--enable-row-hover el-table--medium">
42   - <div ref="usedmemory" style="height: 420px" />
  38 + <div ref="userCumulateChart" style="height: 420px" />
  39 + </div>
  40 + </el-card>
  41 + </el-col>
  42 + <el-col :span="12" class="card-box">
  43 + <el-card>
  44 + <div slot="header">
  45 + <span>消息概况数据</span>
  46 + </div>
  47 + <div class="el-table el-table--enable-row-hover el-table--medium">
  48 + <div ref="upstreamMessageChart" style="height: 420px" />
43 49 </div>
44 50 </el-card>
45 51 </el-col>
... ... @@ -61,9 +67,9 @@ require(&#39;echarts/lib/component/tooltip&#39;)
61 67 require('echarts/lib/component/title')
62 68 require('echarts/lib/component/legend')
63 69  
64   -import { getInterfaceSummary, getUserSummary, getUserCumulate } from '@/api/mp/statistics'
  70 +import {getInterfaceSummary, getUserSummary, getUserCumulate, getUpstreamMessage} from '@/api/mp/statistics'
65 71 import { datePickerOptions } from "@/utils/constants";
66   -import {beginOfDay, betweenDay, endOfDay, formatDate} from "@/utils/dateUtils";
  72 +import {addTime, beginOfDay, betweenDay, endOfDay, formatDate} from "@/utils/dateUtils";
67 73  
68 74 export default {
69 75 name: 'mpStatistics',
... ... @@ -71,16 +77,9 @@ export default {
71 77 return {
72 78 date : [beginOfDay(new Date(new Date().getTime() - 3600 * 1000 * 24 * 7)), // -7 天
73 79 endOfDay(new Date(new Date().getTime() - 3600 * 1000 * 24))], // -1 天
  80 + accountId: 1,
74 81  
75 82 xAxisDate: [], // X 轴的日期范围
76   - seriesData1: [],
77   - seriesData2: [],
78   - seriesData3: [],
79   - seriesData4: [],
80   - seriesData5: [],
81   - seriesData6: [],
82   - seriesData7: [],
83   -
84 83 userSummaryOption: { // 用户增减数据
85 84 color: ['#67C23A', '#e5323e'],
86 85 legend: {
... ... @@ -88,7 +87,7 @@ export default {
88 87 },
89 88 tooltip: {},
90 89 xAxis: {
91   - data: this.xAxisDate
  90 + data: [] // X 轴的日期范围
92 91 },
93 92 yAxis: {
94 93 minInterval: 1
... ... @@ -102,7 +101,7 @@ export default {
102 101 }
103 102 },
104 103 barGap: 0,
105   - data: []
  104 + data: [] // 新增用户的数据
106 105 }, {
107 106 name: '取消关注的用户',
108 107 type: 'bar',
... ... @@ -111,7 +110,64 @@ export default {
111 110 show: true
112 111 }
113 112 },
  113 + data: [] // 取消关注的用户的数据
  114 + }]
  115 + },
  116 + userCumulateOption: { // 累计用户数据
  117 + legend: {
  118 + data: ['累计用户量']
  119 + },
  120 + xAxis: {
  121 + type: 'category',
114 122 data: []
  123 + },
  124 + yAxis: {
  125 + minInterval: 1
  126 + },
  127 + series: [{
  128 + name:'累计用户量',
  129 + data: [], // 累计用户量的数据
  130 + type: 'line',
  131 + smooth: true,
  132 + label: {
  133 + normal: {
  134 + show: true
  135 + }
  136 + }
  137 + }]
  138 + },
  139 + upstreamMessageOption: { // 消息发送概况数据
  140 + color: ['#67C23A', '#e5323e'],
  141 + legend: {
  142 + data: ['用户发送人数', '用户发送条数']
  143 + },
  144 + tooltip: {},
  145 + xAxis: {
  146 + data: [] // X 轴的日期范围
  147 + },
  148 + yAxis: {
  149 + minInterval: 1
  150 + },
  151 + series: [{
  152 + name: '用户发送人数',
  153 + type: 'line',
  154 + smooth: true,
  155 + label: {
  156 + normal: {
  157 + show: true
  158 + }
  159 + },
  160 + data: [] // 用户发送人数的数据
  161 + }, {
  162 + name: '用户发送条数',
  163 + type: 'line',
  164 + smooth: true,
  165 + label: {
  166 + normal: {
  167 + show: true
  168 + }
  169 + },
  170 + data: [] // 用户发送条数的数据
115 171 }]
116 172 },
117 173  
... ... @@ -130,14 +186,6 @@ export default {
130 186 },
131 187 methods: {
132 188 changeDate() {
133   -
134   -
135   -
136   - this.seriesData1 = []
137   - this.seriesData2 = []
138   - this.seriesData5 = []
139   - this.seriesData6 = []
140   -
141 189 this.getSummary()
142 190 },
143 191 getSummary() {
... ... @@ -149,76 +197,13 @@ export default {
149 197 this.xAxisDate = []
150 198 const days = betweenDay(this.date[0], this.date[1]) // 相差天数
151 199 for(let i = 0; i <= days; i++){
152   - this.xAxisDate.push(formatDate(new Date(this.date[0].getTime() + 3600 * 1000 * 24 * i), 'yyyy-MM-dd'));
153   - this.seriesData2.push(0)
154   - this.seriesData5.push(0)
155   - this.seriesData6.push(0)
  200 + this.xAxisDate.push(formatDate(addTime(this.date[0], 3600 * 1000 * 24 * i), 'yyyy-MM-dd'));
156 201 }
157 202  
158   - // 用户增减数据
159   - this.userSummaryOption.xAxis.data = [];
160   - this.userSummaryOption.series[0].data = [];
161   - this.userSummaryOption.series[1].data = [];
162   - getUserSummary({
163   - id: 1,
164   - date: [formatDate(this.date[0], 'yyyy-MM-dd HH:mm:ss'), formatDate(this.date[1], 'yyyy-MM-dd HH:mm:ss'),]
165   - }).then(response => {
166   - this.userSummaryOption.xAxis.data = this.xAxisDate;
167   - // 处理数据
168   - this.xAxisDate.forEach((date, index) => {
169   - response.data.forEach((item) => {
170   - // 匹配日期
171   - const refDate = formatDate(new Date(item.refDate), 'yyyy-MM-dd');
172   - if (refDate.indexOf(date) === -1) {
173   - return;
174   - }
175   - // 设置数据到对应的位置
176   - this.userSummaryOption.series[0].data[index] = item.newUser;
177   - this.userSummaryOption.series[1].data[index] = item.cancelUser;
178   - })
179   - })
180   - // 绘制图表
181   - let userSummaryChart = echarts.init(this.$refs.userSummary);
182   - userSummaryChart.setOption(this.userSummaryOption)
183   - })
184   - // .catch(() => {})
185   -
186   - // getUserCumulate({
187   - // startDate: this.startDate,
188   - // endDate: this.endDate
189   - // }).then(response => {
190   - // response.data.forEach((item, index, arr) => {
191   - // this.$set(this.seriesData7, index, item.cumulateUser)
192   - // })
193   - // // 基于准备好的dom,初始化echarts实例
194   - // let userCumulateChart = echarts.init(document.getElementById('userCumulateChart'))
195   - // // 绘制图表
196   - // userCumulateChart.setOption({
197   - // title: { text: '累计用户数据' },
198   - // legend: {
199   - // data: ['累计用户量']
200   - // },
201   - // xAxis: {
202   - // type: 'category',
203   - // data: this.xAxisData
204   - // },
205   - // yAxis: {
206   - // type: 'value'
207   - // },
208   - // series: [{
209   - // name:'累计用户量',
210   - // data: this.seriesData7,
211   - // type: 'line',
212   - // smooth: true,
213   - // label: {
214   - // normal: {
215   - // show: true
216   - // }
217   - // }
218   - // }]
219   - // })
220   - // }).catch(() => {
221   - // })
  203 + // 初始化图表
  204 + this.initUserSummaryChart();
  205 + this.initUserCumulateChart();
  206 + this.initUpstreamMessageChart();
222 207 //
223 208 // //获取接口数据
224 209 // getInterfaceSummary({
... ... @@ -306,6 +291,71 @@ export default {
306 291 // })
307 292 // }).catch(() => {
308 293 // })
  294 + },
  295 + initUserSummaryChart() {
  296 + this.userSummaryOption.xAxis.data = [];
  297 + this.userSummaryOption.series[0].data = [];
  298 + this.userSummaryOption.series[1].data = [];
  299 + getUserSummary({
  300 + accountId: this.accountId,
  301 + date: [formatDate(this.date[0], 'yyyy-MM-dd HH:mm:ss'), formatDate(this.date[1], 'yyyy-MM-dd HH:mm:ss'),]
  302 + }).then(response => {
  303 + this.userSummaryOption.xAxis.data = this.xAxisDate;
  304 + // 处理数据
  305 + this.xAxisDate.forEach((date, index) => {
  306 + response.data.forEach((item) => {
  307 + // 匹配日期
  308 + const refDate = formatDate(new Date(item.refDate), 'yyyy-MM-dd');
  309 + if (refDate.indexOf(date) === -1) {
  310 + return;
  311 + }
  312 + // 设置数据到对应的位置
  313 + this.userSummaryOption.series[0].data[index] = item.newUser;
  314 + this.userSummaryOption.series[1].data[index] = item.cancelUser;
  315 + })
  316 + })
  317 + // 绘制图表
  318 + const userSummaryChart = echarts.init(this.$refs.userSummaryChart);
  319 + userSummaryChart.setOption(this.userSummaryOption)
  320 + }).catch(() => {})
  321 + },
  322 + initUserCumulateChart() {
  323 + this.userCumulateOption.xAxis.data = [];
  324 + this.userCumulateOption.series[0].data = [];
  325 + // 发起请求
  326 + getUserCumulate({
  327 + accountId: this.accountId,
  328 + date: [formatDate(this.date[0], 'yyyy-MM-dd HH:mm:ss'), formatDate(this.date[1], 'yyyy-MM-dd HH:mm:ss'),]
  329 + }).then(response => {
  330 + this.userCumulateOption.xAxis.data = this.xAxisDate;
  331 + // 处理数据
  332 + response.data.forEach((item, index) => {
  333 + this.userCumulateOption.series[0].data[index] = item.cumulateUser;
  334 + })
  335 + // 绘制图表
  336 + const userCumulateChart = echarts.init(this.$refs.userCumulateChart);
  337 + userCumulateChart.setOption(this.userCumulateOption)
  338 + }).catch(() => {})
  339 + },
  340 + initUpstreamMessageChart() {
  341 + this.upstreamMessageOption.xAxis.data = [];
  342 + this.upstreamMessageOption.series[0].data = [];
  343 + this.upstreamMessageOption.series[1].data = [];
  344 + // 发起请求
  345 + getUpstreamMessage({
  346 + accountId: this.accountId,
  347 + date: [formatDate(this.date[0], 'yyyy-MM-dd HH:mm:ss'), formatDate(this.date[1], 'yyyy-MM-dd HH:mm:ss'),]
  348 + }).then(response => {
  349 + this.upstreamMessageOption.xAxis.data = this.xAxisDate;
  350 + // 处理数据
  351 + response.data.forEach((item, index) => {
  352 + this.upstreamMessageOption.series[0].data[index] = item.messageUser;
  353 + this.upstreamMessageOption.series[1].data[index] = item.messageCount;
  354 + })
  355 + // 绘制图表
  356 + const upstreamMessageChart = echarts.init(this.$refs.upstreamMessageChart);
  357 + upstreamMessageChart.setOption(this.upstreamMessageOption);
  358 + }).catch(() => {})
309 359 }
310 360 }
311 361 }
... ...