Commit 1d5c3da8 by zhouhaibao

feat(supervisor): 添加门店业绩管理相关接口

- 新增AllStorePerformanceRequest请求类,用于总部运营视角的门店业绩查询
- 新增StaffPerformanceRequest请求类,用于盯防驻店销售业绩查询
- 新增StorePerformanceByMerchantRequest请求类,用于门店维度业绩看板查询
- 新增StorePerformanceRequest请求类,用于盯防门店业绩查询
- 新增SupervisorPerformanceRequest请求类,用于督导业绩查询
- 更新rpc-dj-supervisor-api依赖版本至5.8.2-SNAPSHOT
- 在SupervisorDashboardController中新增6个业绩相关接口方法
- 实现驻店销售业绩、门店业绩、督导业绩等多维度统计功能
- 添加公共响应转换方法convertRpcResponse统一处理RPC响应
- 支持按日期类型、统计维度、区域等多种条件进行筛选查询
1 parent cdc6ea40
......@@ -20,7 +20,7 @@
<dependency>
<groupId>cn.com.glsx.dj</groupId>
<artifactId>rpc-dj-supervisor-api</artifactId>
<version>1.0.0-SNAPSHOT</version>
<version>5.8.2-SNAPSHOT</version>
</dependency>
<dependency>
......
......@@ -8,6 +8,7 @@ import cn.com.glsx.dj.peanalysis.remote.BusinessSceneAnalysisRemote;
import cn.com.glsx.dj.supervisor.dto.*;
import cn.com.glsx.dj.supervisor.remote.SupervisorDashboardRemote;
import cn.com.glsx.dj.supervisor.request.*;
import cn.com.glsx.dj.supervisor.dto.SupervisionQueryReq;
import cn.com.glsx.dj.supervisor.service.AiAnalysisService;
import cn.com.glsx.dj.supervisor.util.CommonUtil;
import cn.com.glsx.framework.core.beans.rpc.RpcResponse;
......@@ -467,19 +468,156 @@ public class SupervisorDashboardController {
return calendar.getTime();
}
// @ServiceMethod(method = "dj.api.car.boutique.inspection.batch.file.short.url", needInSession = NeedInSessionType.NO)
// @ApiOperation("生成录音短链")
// public RopResponse<String> generateFileUrlShortLink(GenerateFileUrlShortLinkRequest receptionDetailRequest){
// ReceptionDetailRequestDTO req = CommonUtil.convertRequest(ReceptionDetailRequestDTO.class);
// try {
// return CommonUtil.convertRopResponse(conversationBatchRemote.generateFileUrlShortLink(req));
// } catch (RpcServiceException e) {
// log.error("=====生成录音短链 rpcServiceException:{}", e.getMessage());
// return RopResponse.error(e);
// } catch (Exception e) {
// log.error("=====生成录音短链 exception:{}", e.getMessage(), e);
// return RopResponse.error("生成录音短链失败");
// }
// }
/**
* 盯防驻店销售业绩接口
* <p>
* 获取督导管理范围内的驻店销售业绩数据
* 支持问界鸿蒙和通用品牌区分统计
* </p>
*
* @param request 查询参数
* @return 驻店销售业绩列表
*/
@ServiceMethod(method = "dj.api.supervisor.staff.performance", needInSession = NeedInSessionType.YES)
@ApiOperation("盯防驻店销售业绩接口")
public RopResponse<List<StaffPerformanceDTO>> getStaffPerformance(StaffPerformanceRequest request) {
log.info("盯防驻店销售业绩接口:{}", request);
try {
SupervisionQueryReq req = CommonUtil.convertRequest(SupervisionQueryReq.class);
RpcResponse<List<StaffPerformanceDTO>> result = supervisorDashboardRemote.getStaffPerformance(req);
return convertRpcResponse(result);
} catch (RpcServiceException e) {
log.error("Controller__invoke__getStaffPerformance__bizException:{}", e.getMessage(), e);
return RopResponse.error(e);
} catch (Exception e) {
log.error("Controller__invoke__getStaffPerformance__exception", e);
return RopResponse.error("服务异常");
}
}
/**
* 盯防门店业绩接口
* <p>
* 获取督导管理范围内的门店业绩数据
* 支持问界鸿蒙和通用品牌区分统计
* </p>
*
* @param request 查询参数
* @return 门店业绩列表
*/
@ServiceMethod(method = "dj.api.supervisor.store.performance", needInSession = NeedInSessionType.YES)
@ApiOperation("盯防门店业绩接口")
public RopResponse<List<StorePerformanceDTO>> getStorePerformance(StorePerformanceRequest request) {
log.info("盯防门店业绩接口:{}", request);
try {
SupervisionQueryReq req = CommonUtil.convertRequest(SupervisionQueryReq.class);
RpcResponse<List<StorePerformanceDTO>> result = supervisorDashboardRemote.getStorePerformance(req);
return convertRpcResponse(result);
} catch (RpcServiceException e) {
log.error("Controller__invoke__getStorePerformance__bizException:{}", e.getMessage(), e);
return RopResponse.error(e);
} catch (Exception e) {
log.error("Controller__invoke__getStorePerformance__exception", e);
return RopResponse.error("服务异常");
}
}
/**
* 门店维度业绩看板接口
* <p>
* 入口:从工作台&团队页面--团队概况中,点击门店数量的区域,跳转进入
* 数据默认按照品牌进行区分统计,支持"问界鸿蒙--延保权益"、"通用品牌--延保权益"固定筛选
* 支持日、周、月的时间筛选
* 支持直接搜索门店名称进行查询
* </p>
*
* @param request 查询参数
* @return 门店业绩列表(按门店维度统计)
*/
@ServiceMethod(method = "dj.api.supervisor.store.performance.by.merchant", needInSession = NeedInSessionType.YES)
@ApiOperation("门店维度业绩看板接口")
public RopResponse<List<StaffPerformanceDTO>> getStorePerformanceByMerchant(StorePerformanceByMerchantRequest request) {
log.info("门店维度业绩看板接口:{}", request);
try {
MerchantQueryReq req = CommonUtil.convertRequest(MerchantQueryReq.class);
RpcResponse<List<StaffPerformanceDTO>> result = supervisorDashboardRemote.getStorePerformanceByMerchant(req);
return convertRpcResponse(result);
} catch (RpcServiceException e) {
log.error("Controller__invoke__getStorePerformanceByMerchant__bizException:{}", e.getMessage(), e);
return RopResponse.error(e);
} catch (Exception e) {
log.error("Controller__invoke__getStorePerformanceByMerchant__exception", e);
return RopResponse.error("服务异常");
}
}
/**
* 业绩概览 -- 督导业绩接口(总部运营视角)
* <p>
* 触发场景:运营在"督导业绩" Tab页查看
* 数据复用:界面及统计逻辑复用"驻店销售业绩列表",但统计对象变为"区域督导"
* 包含:辖区门店数、预警门店数、需关注门店数、管理驻店数等管理维度数据
* </p>
*
* @param request 查询参数(总部运营视角,不需要指定督导ID)
* @return 督导业绩列表
*/
@ServiceMethod(method = "dj.api.supervisor.management.supervisor.performance", needInSession = NeedInSessionType.NO)
@ApiOperation("业绩概览 -- 督导业绩接口(总部运营视角)")
public RopResponse<List<SupervisorPerformanceDTO>> getSupervisorPerformance(SupervisorPerformanceRequest request) {
log.info("业绩概览 -- 督导业绩接口:{}", request);
try {
SupervisorManagementQueryReq req = CommonUtil.convertRequest(SupervisorManagementQueryReq.class);
RpcResponse<List<SupervisorPerformanceDTO>> result = supervisorDashboardRemote.getSupervisorPerformance(req);
return convertRpcResponse(result);
} catch (RpcServiceException e) {
log.error("Controller__invoke__getSupervisorPerformance__bizException:{}", e.getMessage(), e);
return RopResponse.error(e);
} catch (Exception e) {
log.error("Controller__invoke__getSupervisorPerformance__exception", e);
return RopResponse.error("服务异常");
}
}
/**
* 业绩概览 -- 门店业绩接口(总部运营视角)
* <p>
* 触发场景:运营在"门店业绩" Tab页查看
* 数据范围:展示所有门店业绩(无负责范围过滤)
* 筛选功能:支持按"区域"进行筛选
* </p>
*
* @param request 查询参数(总部运营视角,不需要指定督导ID)
* @return 门店业绩列表
*/
@ServiceMethod(method = "dj.api.supervisor.management.store.performance", needInSession = NeedInSessionType.NO)
@ApiOperation("业绩概览 -- 门店业绩接口(总部运营视角)")
public RopResponse<List<StorePerformanceDTO>> getAllStorePerformance(AllStorePerformanceRequest request) {
log.info("业绩概览 -- 门店业绩接口:{}", request);
try {
SupervisorManagementQueryReq req = CommonUtil.convertRequest(SupervisorManagementQueryReq.class);
req.setRegion(request.getRegion());
RpcResponse<List<StorePerformanceDTO>> result = supervisorDashboardRemote.getAllStorePerformance(req);
return convertRpcResponse(result);
} catch (RpcServiceException e) {
log.error("Controller__invoke__getAllStorePerformance__bizException:{}", e.getMessage(), e);
return RopResponse.error(e);
} catch (Exception e) {
log.error("Controller__invoke__getAllStorePerformance__exception", e);
return RopResponse.error("服务异常");
}
}
/**
* 公共响应转换方法
*/
private <T> RopResponse<T> convertRpcResponse(RpcResponse<T> rpcResponse) {
if (rpcResponse.isSuccess()) {
return RopResponse.success(rpcResponse.getResult());
} else {
return RopResponse.error(rpcResponse.getError(), rpcResponse.getMessage());
}
}
}
package cn.com.glsx.dj.supervisor.request;
import com.rop.AbstractRopRequest;
import io.swagger.annotations.ApiModelProperty;
import javax.validation.constraints.NotNull;
import lombok.Data;
/**
* 门店业绩请求(总部运营视角)
* <p>
* 触发场景:运营在"门店业绩" Tab页查看
* 数据范围:展示所有门店业绩(无负责范围过滤)
* 筛选功能:支持按"区域"进行筛选
* </p>
*/
@Data
public class AllStorePerformanceRequest extends AbstractRopRequest {
@ApiModelProperty(notes = "开始日期", example = "2026-05-01", required = true)
@NotNull
private String startDate;
@ApiModelProperty(notes = "结束日期", example = "2026-05-31", required = true)
@NotNull
private String endDate;
@ApiModelProperty(notes = "日期类型:0-指定时段,1-周,2-月", example = "2", required = true)
@NotNull
private Integer dateType;
@ApiModelProperty(notes = "统计维度:1-问界鸿蒙--延保权益,2-通用品牌--延保权益", example = "1")
private Integer statDimension;
@ApiModelProperty(notes = "搜索关键词(门店名称)")
private String searchKeyword;
@ApiModelProperty(notes = "门店区域(按区域筛选)")
private String region;
}
\ No newline at end of file
package cn.com.glsx.dj.supervisor.request;
import com.rop.AbstractRopRequest;
import io.swagger.annotations.ApiModelProperty;
import javax.validation.constraints.NotNull;
import lombok.Data;
/**
* 盯防驻店销售业绩请求
* <p>
* 获取督导管理范围内的驻店销售业绩数据
* 支持问界鸿蒙和通用品牌区分统计
* </p>
*/
@Data
public class StaffPerformanceRequest extends AbstractRopRequest {
@ApiModelProperty(notes = "督导ID", example = "supervisor001", required = true)
@NotNull
private String supervisorId;
@ApiModelProperty(notes = "开始日期", example = "2026-05-01", required = true)
@NotNull
private String startDate;
@ApiModelProperty(notes = "结束日期", example = "2026-05-31", required = true)
@NotNull
private String endDate;
@ApiModelProperty(notes = "日期类型:0-指定时段,1-周,2-月", example = "2", required = true)
@NotNull
private Integer dateType;
@ApiModelProperty(notes = "统计维度:1-问界鸿蒙--延保权益,2-通用品牌--延保权益", example = "1")
private Integer statDimension;
@ApiModelProperty(notes = "门店ID")
private Integer merchantId;
}
\ No newline at end of file
package cn.com.glsx.dj.supervisor.request;
import com.rop.AbstractRopRequest;
import io.swagger.annotations.ApiModelProperty;
import javax.validation.constraints.NotNull;
import lombok.Data;
/**
* 门店维度业绩看板请求
* <p>
* 入口:从工作台&团队页面--团队概况中,点击门店数量的区域,跳转进入
* 数据默认按照品牌进行区分统计,支持"问界鸿蒙--延保权益"、"通用品牌--延保权益"固定筛选
* 支持日、周、月的时间筛选
* 支持直接搜索门店名称进行查询
* </p>
*/
@Data
public class StorePerformanceByMerchantRequest extends AbstractRopRequest {
@ApiModelProperty(notes = "督导ID", example = "supervisor001", required = true)
@NotNull
private String supervisorId;
@ApiModelProperty(notes = "开始日期", example = "2026-05-01", required = true)
@NotNull
private String startDate;
@ApiModelProperty(notes = "结束日期", example = "2026-05-31", required = true)
@NotNull
private String endDate;
@ApiModelProperty(notes = "日期类型:0-指定时段,1-周,2-月", example = "2", required = true)
@NotNull
private Integer dateType;
@ApiModelProperty(notes = "统计维度:1-问界鸿蒙--延保权益,2-通用品牌--延保权益", example = "1")
private Integer statDimension;
@ApiModelProperty(notes = "搜索关键词(门店名称)")
private String searchKeyword;
}
\ No newline at end of file
package cn.com.glsx.dj.supervisor.request;
import com.rop.AbstractRopRequest;
import io.swagger.annotations.ApiModelProperty;
import javax.validation.constraints.NotNull;
import lombok.Data;
/**
* 盯防门店业绩请求
* <p>
* 获取督导管理范围内的门店业绩数据
* 支持问界鸿蒙和通用品牌区分统计
* </p>
*/
@Data
public class StorePerformanceRequest extends AbstractRopRequest {
@ApiModelProperty(notes = "督导ID", example = "supervisor001", required = true)
@NotNull
private String supervisorId;
@ApiModelProperty(notes = "开始日期", example = "2026-05-01", required = true)
@NotNull
private String startDate;
@ApiModelProperty(notes = "结束日期", example = "2026-05-31", required = true)
@NotNull
private String endDate;
@ApiModelProperty(notes = "日期类型:0-指定时段,1-周,2-月", example = "2", required = true)
@NotNull
private Integer dateType;
@ApiModelProperty(notes = "统计维度:1-问界鸿蒙--延保权益,2-通用品牌--延保权益", example = "1")
private Integer statDimension;
}
\ No newline at end of file
package cn.com.glsx.dj.supervisor.request;
import com.rop.AbstractRopRequest;
import io.swagger.annotations.ApiModelProperty;
import javax.validation.constraints.NotNull;
import lombok.Data;
/**
* 督导业绩请求(总部运营视角)
* <p>
* 触发场景:运营在"督导业绩" Tab页查看
* 数据复用:界面及统计逻辑复用"驻店销售业绩列表",但统计对象变为"区域督导"
* 包含:辖区门店数、预警门店数、需关注门店数、管理驻店数等管理维度数据
* </p>
*/
@Data
public class SupervisorPerformanceRequest extends AbstractRopRequest {
@ApiModelProperty(notes = "开始日期", example = "2026-05-01", required = true)
@NotNull
private String startDate;
@ApiModelProperty(notes = "结束日期", example = "2026-05-31", required = true)
@NotNull
private String endDate;
@ApiModelProperty(notes = "日期类型:0-指定时段,1-周,2-月", example = "2", required = true)
@NotNull
private Integer dateType;
@ApiModelProperty(notes = "统计维度:1-问界鸿蒙--延保权益,2-通用品牌--延保权益", example = "1")
private Integer statDimension;
@ApiModelProperty(notes = "搜索关键词(督导姓名)")
private String searchKeyword;
}
\ No newline at end of file
  • @wangxw1
    commented
    Master

    一、关键问题与优化建议(仅限 Top 3)

    1. Controller 层请求参数未正确映射至 RPC 请求对象(严重功能缺陷)

    • 问题描述:在 SupervisorDashboardController 新增的 5 个接口方法中,虽然方法签名接收了带有校验注解的入参(如 StaffPerformanceRequest request),但在构建传递给 RPC 的请求对象时,仅使用了 CommonUtil.convertRequest(XXX.class),完全没有将入参 request 中的关键业务属性(如 startDate, endDate, supervisorId 等)赋值给 RPC 请求对象。唯一例外是在 getAllStorePerformance 中手动写了一行 req.setRegion(request.getRegion())。
    • 潜在风险:前端传入的查询时间、督导 ID 等核心过滤条件在 Controller 层全部丢失,导致下游 RPC 服务接收到的是空条件。这将引发严重的业务逻辑错误(如返回全量数据或因缺少必填项导致 RPC 报错)。
    • 优化建议:必须将入参 request 的属性完整映射到 RPC 请求对象中。建议使用 BeanUtils.copyProperties(request, req)、MapStruct 等对象映射工具,或者手动进行 req.setStartDate(request.getStartDate()) 等赋值操作。

    2. 引入 SNAPSHOT 快照版本依赖(违反阿里开发规范与稳定性风险)

    • 问题描述:在 pom.xml 中,将 rpc-dj-supervisor-api 的版本号修改为了 5.8.2-SNAPSHOT。
    • 潜在风险:根据《阿里巴巴 Java 开发手册》强制规定:“线上应用不要依赖 SNAPSHOT 版本(安全包除外)”。SNAPSHOT 版本是不稳定的,随时可能被提供方覆盖更新,会导致团队成员拉取代码时出现行为不一致,或者在生产环境构建时拉取到未经过测试的错误代码,引发线上故障。
    • 优化建议:在代码合并至主干或发布生产环境前,务必将依赖版本号修改为正式的 Release 版本(例如 5.8.2)。

    3. 字符串日期参数缺乏格式校验(健壮性与安全风险)

    • 问题描述:在所有新增的 Request 类(如 StaffPerformanceRequest 等)中,startDate 和 endDate 字段均被定义为 String 类型,且仅使用了 @NotNull 校验是否为空,未校验字符串的格式。
    • 潜在风险:缺乏格式约束会导致调用方可以传入任意字符串(例如 "2026/15/99",甚至包含 SQL 注入特征的恶意字符)。这些非法数据透传到下游 RPC 服务或数据库时,容易引发时间解析异常(ParseException)或潜在的安全漏洞。
    • 优化建议:建议为日期字符串添加正则表达式校验,例如: @Pattern(regexp = "^\\d{4}-\\d{2}-\\d{2}$", message = "日期格式必须为yyyy-MM-dd") 或者更推荐的做法是,将字段类型直接改为 java.time.LocalDate / java.util.Date 并配合框架的时间转换注解。

    二、评分明细

    • 功能实现的正确性与健壮性 (40分):20分。接口入参未正确传递给 RPC 核心业务层,这是一个非常严重的逻辑遗漏,会导致接口完全无法按预期工作,扣20分。
    • 安全性与潜在风险 (30分):25分。请求参数缺乏格式校验(特别是 String 类型的日期),存在一定的脏数据注入风险,扣5分。
    • 最佳实践与可维护性 (20分):12分。引入了 SNAPSHOT 依赖,严重违反了阿里开发规范中的依赖管理规定,扣8分。异常日志打印格式 log.error("...:{}", e.getMessage(), e) 略显冗余。
    • 性能与资源利用 (5分):5分。Controller 层逻辑简单,未见明显的性能瓶颈或资源浪费。
    • 提交信息质量 (5分):5分。Commit message 格式规范(符合 Angular 规范),清晰地列出了新增的类、修改的方法以及实现的业务功能,质量很高。

    总分:67分

Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!