diff --git a/yudao-module-mp/yudao-module-mp-api/src/main/java/cn/iocoder/yudao/module/mp/enums/ErrorCodeConstants.java b/yudao-module-mp/yudao-module-mp-api/src/main/java/cn/iocoder/yudao/module/mp/enums/ErrorCodeConstants.java index 5c74fce0e..471d3b2ea 100644 --- a/yudao-module-mp/yudao-module-mp-api/src/main/java/cn/iocoder/yudao/module/mp/enums/ErrorCodeConstants.java +++ b/yudao-module-mp/yudao-module-mp-api/src/main/java/cn/iocoder/yudao/module/mp/enums/ErrorCodeConstants.java @@ -18,6 +18,7 @@ public interface ErrorCodeConstants { ErrorCode STATISTICS_GET_USER_SUMMARY_FAIL = new ErrorCode(1006001000, "获取用户增减数据失败,原因:{}"); ErrorCode STATISTICS_GET_USER_CUMULATE_FAIL = new ErrorCode(1006001001, "获得用户累计数据失败,原因:{}"); ErrorCode STATISTICS_GET_UPSTREAM_MESSAGE_FAIL = new ErrorCode(1006001002, "获得消息发送概况数据失败,原因:{}"); + ErrorCode STATISTICS_GET_INTERFACE_SUMMARY_FAIL = new ErrorCode(1006001003, "获得接口分析数据失败,原因:{}"); // TODO 要处理下 ErrorCode COMMON_NOT_EXISTS = new ErrorCode(1006001002, "用户不存在"); diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/account/MpAccountController.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/account/MpAccountController.java index 866f7475a..e2192f5c6 100644 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/account/MpAccountController.java +++ b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/account/MpAccountController.java @@ -2,10 +2,7 @@ package cn.iocoder.yudao.module.mp.controller.admin.account; import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.mp.controller.admin.account.vo.MpAccountCreateReqVO; -import cn.iocoder.yudao.module.mp.controller.admin.account.vo.MpAccountPageReqVO; -import cn.iocoder.yudao.module.mp.controller.admin.account.vo.MpAccountRespVO; -import cn.iocoder.yudao.module.mp.controller.admin.account.vo.MpAccountUpdateReqVO; +import cn.iocoder.yudao.module.mp.controller.admin.account.vo.*; import cn.iocoder.yudao.module.mp.convert.account.MpAccountConvert; import cn.iocoder.yudao.module.mp.dal.dataobject.account.MpAccountDO; import cn.iocoder.yudao.module.mp.service.account.MpAccountService; @@ -18,6 +15,7 @@ import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import javax.validation.Valid; +import java.util.List; import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; @@ -71,6 +69,14 @@ public class MpAccountController { return success(MpAccountConvert.INSTANCE.convertPage(pageResult)); } + @GetMapping("/list-all-simple") + @ApiOperation(value = "获取公众号账号精简信息列表") + @PreAuthorize("@ss.hasPermission('mp:account:query')") + public CommonResult> getSimpleAccounts() { + List list = mpAccountService.getAccountList(); + return success(MpAccountConvert.INSTANCE.convertList02(list)); + } + @PutMapping("/generate-qr-code") @ApiOperation("生成公众号二维码") @ApiImplicitParam(name = "id", value = "编号", required = true, dataTypeClass = Long.class) diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/account/vo/MpAccountSimpleRespVO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/account/vo/MpAccountSimpleRespVO.java new file mode 100644 index 000000000..f3826eaa1 --- /dev/null +++ b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/account/vo/MpAccountSimpleRespVO.java @@ -0,0 +1,17 @@ +package cn.iocoder.yudao.module.mp.controller.admin.account.vo; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +@ApiModel("管理后台 - 公众号账号精简信息 Response VO") +@Data +public class MpAccountSimpleRespVO { + + @ApiModelProperty(value = "编号", required = true, example = "1024") + private Long id; + + @ApiModelProperty(value = "公众号名称", required = true, example = "芋道源码") + private String name; + +} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/statistics/MpStatisticsController.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/statistics/MpStatisticsController.java index 5c55b113b..2447f49a5 100644 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/statistics/MpStatisticsController.java +++ b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/statistics/MpStatisticsController.java @@ -1,14 +1,12 @@ package cn.iocoder.yudao.module.mp.controller.admin.statistics; import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.mp.controller.admin.statistics.vo.MpStatisticsGetReqVO; -import cn.iocoder.yudao.module.mp.controller.admin.statistics.vo.MpStatisticsUpstreamMessageRespVO; -import cn.iocoder.yudao.module.mp.controller.admin.statistics.vo.MpStatisticsUserCumulateRespVO; -import cn.iocoder.yudao.module.mp.controller.admin.statistics.vo.MpStatisticsUserSummaryRespVO; +import cn.iocoder.yudao.module.mp.controller.admin.statistics.vo.*; import cn.iocoder.yudao.module.mp.convert.statistics.MpStatisticsConvert; import cn.iocoder.yudao.module.mp.service.statistics.MpStatisticsService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; +import me.chanjar.weixin.mp.bean.datacube.WxDataCubeInterfaceResult; import me.chanjar.weixin.mp.bean.datacube.WxDataCubeMsgResult; import me.chanjar.weixin.mp.bean.datacube.WxDataCubeUserCumulate; import me.chanjar.weixin.mp.bean.datacube.WxDataCubeUserSummary; @@ -59,4 +57,12 @@ public class MpStatisticsController { return success(MpStatisticsConvert.INSTANCE.convertList03(list)); } + @GetMapping("/interface-summary") + @ApiOperation("获取消息发送概况数据") + @PreAuthorize("@ss.hasPermission('mp:statistics:query')") + public CommonResult> getInterfaceSummary(MpStatisticsGetReqVO getReqVO) { + List list = mpStatisticsService.getInterfaceSummary( + getReqVO.getAccountId(), getReqVO.getDate()); + return success(MpStatisticsConvert.INSTANCE.convertList04(list)); + } } diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/statistics/vo/MpStatisticsInterfaceSummaryRespVO.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/statistics/vo/MpStatisticsInterfaceSummaryRespVO.java new file mode 100644 index 000000000..f244507d5 --- /dev/null +++ b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/controller/admin/statistics/vo/MpStatisticsInterfaceSummaryRespVO.java @@ -0,0 +1,28 @@ +package cn.iocoder.yudao.module.mp.controller.admin.statistics.vo; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.Date; + +@ApiModel("管理后台 - 某一天的接口分析数据 Response VO") +@Data +public class MpStatisticsInterfaceSummaryRespVO { + + @ApiModelProperty(value = "日期", required = true) + private Date refDate; + + @ApiModelProperty(value = "通过服务器配置地址获得消息后,被动回复用户消息的次数", required = true, example = "10") + private Integer callbackCount; + + @ApiModelProperty(value = "上述动作的失败次数", required = true, example = "20") + private Integer failCount; + + @ApiModelProperty(value = "总耗时,除以 callback_count 即为平均耗时", required = true, example = "30") + private Integer totalTimeCost; + + @ApiModelProperty(value = "最大耗时", required = true, example = "40") + private Integer maxTimeCost; + +} diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/convert/account/MpAccountConvert.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/convert/account/MpAccountConvert.java index 32c212230..5f8fde36a 100644 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/convert/account/MpAccountConvert.java +++ b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/convert/account/MpAccountConvert.java @@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.mp.convert.account; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.module.mp.controller.admin.account.vo.MpAccountCreateReqVO; import cn.iocoder.yudao.module.mp.controller.admin.account.vo.MpAccountRespVO; +import cn.iocoder.yudao.module.mp.controller.admin.account.vo.MpAccountSimpleRespVO; import cn.iocoder.yudao.module.mp.controller.admin.account.vo.MpAccountUpdateReqVO; import cn.iocoder.yudao.module.mp.dal.dataobject.account.MpAccountDO; import org.mapstruct.Mapper; @@ -25,4 +26,6 @@ public interface MpAccountConvert { PageResult convertPage(PageResult page); + List convertList02(List list); + } diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/convert/statistics/MpStatisticsConvert.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/convert/statistics/MpStatisticsConvert.java index 54c69ba81..174b0fdc3 100644 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/convert/statistics/MpStatisticsConvert.java +++ b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/convert/statistics/MpStatisticsConvert.java @@ -1,8 +1,10 @@ package cn.iocoder.yudao.module.mp.convert.statistics; +import cn.iocoder.yudao.module.mp.controller.admin.statistics.vo.MpStatisticsInterfaceSummaryRespVO; import cn.iocoder.yudao.module.mp.controller.admin.statistics.vo.MpStatisticsUpstreamMessageRespVO; import cn.iocoder.yudao.module.mp.controller.admin.statistics.vo.MpStatisticsUserCumulateRespVO; import cn.iocoder.yudao.module.mp.controller.admin.statistics.vo.MpStatisticsUserSummaryRespVO; +import me.chanjar.weixin.mp.bean.datacube.WxDataCubeInterfaceResult; import me.chanjar.weixin.mp.bean.datacube.WxDataCubeMsgResult; import me.chanjar.weixin.mp.bean.datacube.WxDataCubeUserCumulate; import me.chanjar.weixin.mp.bean.datacube.WxDataCubeUserSummary; @@ -31,4 +33,8 @@ public interface MpStatisticsConvert { }) MpStatisticsUpstreamMessageRespVO convert(WxDataCubeMsgResult bean); + List convertList04(List list); + + @Mapping(source = "refDate", target = "refDate", dateFormat = "yyyy-MM-dd") + MpStatisticsInterfaceSummaryRespVO convert(WxDataCubeInterfaceResult bean); } diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/account/MpAccountService.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/account/MpAccountService.java index 05248c4cd..bbcff2d2b 100644 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/account/MpAccountService.java +++ b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/account/MpAccountService.java @@ -7,6 +7,7 @@ import cn.iocoder.yudao.module.mp.controller.admin.account.vo.MpAccountUpdateReq import cn.iocoder.yudao.module.mp.dal.dataobject.account.MpAccountDO; import javax.validation.Valid; +import java.util.List; /** * 公众号账号 Service 接口 @@ -66,6 +67,13 @@ public interface MpAccountService { */ PageResult getAccountPage(MpAccountPageReqVO pageReqVO); + /** + * 获得公众号账号列表 + * + * @return 公众号账号列表 + */ + List getAccountList(); + /** * 生成公众号账号的二维码 * diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/account/MpAccountServiceImpl.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/account/MpAccountServiceImpl.java index 4da23dd4d..319d345ed 100644 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/account/MpAccountServiceImpl.java +++ b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/account/MpAccountServiceImpl.java @@ -155,6 +155,11 @@ public class MpAccountServiceImpl implements MpAccountService { return mpAccountMapper.selectPage(pageReqVO); } + @Override + public List getAccountList() { + return mpAccountMapper.selectList(); + } + @Override public void generateAccountQrCode(Long id) { // 校验存在 diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/statistics/MpStatisticsService.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/statistics/MpStatisticsService.java index 18cfffde4..1f1eaaf30 100644 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/statistics/MpStatisticsService.java +++ b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/statistics/MpStatisticsService.java @@ -1,5 +1,6 @@ package cn.iocoder.yudao.module.mp.service.statistics; +import me.chanjar.weixin.mp.bean.datacube.WxDataCubeInterfaceResult; import me.chanjar.weixin.mp.bean.datacube.WxDataCubeMsgResult; import me.chanjar.weixin.mp.bean.datacube.WxDataCubeUserCumulate; import me.chanjar.weixin.mp.bean.datacube.WxDataCubeUserSummary; @@ -41,4 +42,13 @@ public interface MpStatisticsService { */ List getUpstreamMessage(Long accountId, LocalDateTime[] date); + /** + * 获取接口分析数据 + * + * @param accountId 公众号账号编号 + * @param date 时间区间 + * @return 接口分析数据 + */ + List getInterfaceSummary(Long accountId, LocalDateTime[] date); + } diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/statistics/MpStatisticsServiceImpl.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/statistics/MpStatisticsServiceImpl.java index ef316b579..4c3b37413 100644 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/statistics/MpStatisticsServiceImpl.java +++ b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/statistics/MpStatisticsServiceImpl.java @@ -4,6 +4,7 @@ import cn.hutool.core.date.DateUtil; import cn.iocoder.yudao.module.mp.framework.mp.core.MpServiceFactory; import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.mp.api.WxMpService; +import me.chanjar.weixin.mp.bean.datacube.WxDataCubeInterfaceResult; import me.chanjar.weixin.mp.bean.datacube.WxDataCubeMsgResult; import me.chanjar.weixin.mp.bean.datacube.WxDataCubeUserCumulate; import me.chanjar.weixin.mp.bean.datacube.WxDataCubeUserSummary; @@ -62,4 +63,15 @@ public class MpStatisticsServiceImpl implements MpStatisticsService { } } + @Override + public List getInterfaceSummary(Long accountId, LocalDateTime[] date) { + WxMpService mpService = mpServiceFactory.getRequiredMpService(accountId); + try { + return mpService.getDataCubeService().getInterfaceSummary( + DateUtil.date(date[0]), DateUtil.date(date[1])); + } catch (WxErrorException e) { + throw exception(STATISTICS_GET_INTERFACE_SUMMARY_FAIL, e.getError().getErrorMsg()); + } + } + } diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/user/vo/user/UserSimpleRespVO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/user/vo/user/UserSimpleRespVO.java index a815253e9..e616b87cb 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/user/vo/user/UserSimpleRespVO.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/user/vo/user/UserSimpleRespVO.java @@ -6,7 +6,7 @@ import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; -@ApiModel("用户精简信息 Response VO") +@ApiModel("管理后台 - 用户精简信息 Response VO") @Data @NoArgsConstructor @AllArgsConstructor diff --git a/yudao-ui-admin/src/api/mp/account.js b/yudao-ui-admin/src/api/mp/account.js index 48ee61f35..d4ff6d94c 100644 --- a/yudao-ui-admin/src/api/mp/account.js +++ b/yudao-ui-admin/src/api/mp/account.js @@ -43,6 +43,14 @@ export function getAccountPage(query) { }) } +// 获取公众号账号精简信息列表 +export function getSimpleAccounts() { + return request({ + url: '/mp/account/list-all-simple', + method: 'get', + }) +} + // 生成公众号二维码 export function generateAccountQrCode(id) { return request({ diff --git a/yudao-ui-admin/src/api/mp/statistics.js b/yudao-ui-admin/src/api/mp/statistics.js index d24375c22..0a3497b46 100644 --- a/yudao-ui-admin/src/api/mp/statistics.js +++ b/yudao-ui-admin/src/api/mp/statistics.js @@ -26,3 +26,12 @@ export function getUserCumulate(query) { params: query }) } + +// 获得接口分析数据 +export function getInterfaceSummary(query) { + return request({ + url: '/mp/statistics/interface-summary', + method: 'get', + params: query + }) +} diff --git a/yudao-ui-admin/src/views/mp/statistics/index.vue b/yudao-ui-admin/src/views/mp/statistics/index.vue index b0f056f91..678ff831a 100644 --- a/yudao-ui-admin/src/views/mp/statistics/index.vue +++ b/yudao-ui-admin/src/views/mp/statistics/index.vue @@ -1,63 +1,70 @@ - -