Commit a03ccfa5 by 林永健

feat(analysis): 支持趋势数据的预估值计算和屏蔽门店过滤

- 在趋势数据接口中新增预估趋势功能,基于起始时间和产值进行计算
- 新增请求参数isPredictTrend用于控制是否启用趋势预估
- 查询门店权限时支持屏蔽配置的门店ID,过滤结果中排除屏蔽门店
- 业务层、RPC接口和请求响应类中新增对应字段支持过滤和预估功能
- 修改时间参数类型及范围,保证查询的准确性和完整性
- 数据查询层增加对屏蔽门店的排除处理,确保数据准确性
- 区域分布响应添加商户ID列表,支持前端更丰富展示
- 修正多个渗透率指标代码映射,保持指标一致性
- 代码中增加日志记录屏蔽门店过滤后的门店列表,方便问题定位
1 parent 0b53dc0e
...@@ -25,6 +25,7 @@ public class SalePotentialCustomersReq implements Serializable { ...@@ -25,6 +25,7 @@ public class SalePotentialCustomersReq implements Serializable {
*/ */
@ApiModelProperty(notes = "关联商户id ") @ApiModelProperty(notes = "关联商户id ")
private List<Integer> merchantIds; private List<Integer> merchantIds;
private List<Integer> excludeMerchantIds;
/** /**
* 是否绑定 0-否 1-是 * 是否绑定 0-否 1-是
......
...@@ -87,6 +87,9 @@ public class SceneBaseReq implements Serializable { ...@@ -87,6 +87,9 @@ public class SceneBaseReq implements Serializable {
@ApiModelProperty(notes = "是否查询达成率趋势") @ApiModelProperty(notes = "是否查询达成率趋势")
private boolean withTargetRatio; private boolean withTargetRatio;
@ApiModelProperty(notes = "是否预估趋势")
private boolean isPredictTrend;
@ApiModelProperty(notes = "查询类型") @ApiModelProperty(notes = "查询类型")
private int queryType; private int queryType;
......
...@@ -6,6 +6,7 @@ import lombok.Data; ...@@ -6,6 +6,7 @@ import lombok.Data;
import java.io.Serializable; import java.io.Serializable;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.List;
@ApiModel(description = "区域分布响应") @ApiModel(description = "区域分布响应")
...@@ -25,4 +26,6 @@ public class RegionalDistributionResponse implements Serializable { ...@@ -25,4 +26,6 @@ public class RegionalDistributionResponse implements Serializable {
@ApiModelProperty(notes = "新车交付数总和") @ApiModelProperty(notes = "新车交付数总和")
private BigDecimal deliveryCount; private BigDecimal deliveryCount;
private List<Integer> merchantIds;
} }
...@@ -34,4 +34,7 @@ public class TrendOutputResponse implements Serializable { ...@@ -34,4 +34,7 @@ public class TrendOutputResponse implements Serializable {
@ApiModelProperty(notes = "达成率") @ApiModelProperty(notes = "达成率")
private BigDecimal ratio; private BigDecimal ratio;
@ApiModelProperty(notes = "预估值")
private BigDecimal predictValue = BigDecimal.ZERO;
} }
...@@ -6,6 +6,7 @@ import org.apache.ibatis.annotations.Mapper; ...@@ -6,6 +6,7 @@ import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import org.oreframework.datasource.mybatis.mapper.OreMapper; import org.oreframework.datasource.mybatis.mapper.OreMapper;
import java.util.Date;
import java.util.List; import java.util.List;
@Mapper @Mapper
...@@ -15,7 +16,7 @@ public interface GoodsOrderMapper extends OreMapper<GoodsOrder> { ...@@ -15,7 +16,7 @@ public interface GoodsOrderMapper extends OreMapper<GoodsOrder> {
List<TrafficContributionRankResponse> findTrafficRank( List<TrafficContributionRankResponse> findTrafficRank(
@Param("merchantIds") List<Integer> merchantIds, @Param("merchantIds") List<Integer> merchantIds,
@Param("staffUuids") List<String> staffUuids, @Param("staffUuids") List<String> staffUuids,
@Param("startDate") String startDate, @Param("startDate") Date startDate,
@Param("endDate") String endDate, @Param("endDate") Date endDate,
@Param("scene") Integer sceneType); @Param("scene") Integer sceneType);
} }
\ No newline at end of file \ No newline at end of file
...@@ -174,6 +174,10 @@ public class BusinessSceneAnalysisService { ...@@ -174,6 +174,10 @@ public class BusinessSceneAnalysisService {
.distinct() .distinct()
.collect(Collectors.toList()); .collect(Collectors.toList());
log.info("查询指标[{}]门店权限:{}", itemCode, merchantIds); log.info("查询指标[{}]门店权限:{}", itemCode, merchantIds);
if (CollectionUtils.isNotEmpty(req.getExcludeIds())) {
merchantIds = merchantIds.stream().filter(p -> req.getExcludeIds().contains(p)).collect(Collectors.toList());
log.info("查询指标[{}]门店权限, 屏蔽:{}:{}", itemCode, req.getExcludeIds(), merchantIds);
}
return merchantIds; return merchantIds;
} }
...@@ -230,6 +234,13 @@ public class BusinessSceneAnalysisService { ...@@ -230,6 +234,13 @@ public class BusinessSceneAnalysisService {
*/ */
public List<TrendOutputResponse> trendOutput(SceneBaseReq req) { public List<TrendOutputResponse> trendOutput(SceneBaseReq req) {
List<TrendOutputResponse> res; List<TrendOutputResponse> res;
try {
req.setMerchantIds(getMerchantIdPermission(req, false));
}catch (Exception e){
return Collections.emptyList();
}
// 查询指标数据 // 查询指标数据
DataBizQueryParamsDTO queryParams = req.convertQueryParam(); DataBizQueryParamsDTO queryParams = req.convertQueryParam();
// 自定义的周期,在进行指标查询趋势图时,需要改为按日周期去查 // 自定义的周期,在进行指标查询趋势图时,需要改为按日周期去查
...@@ -252,18 +263,12 @@ public class BusinessSceneAnalysisService { ...@@ -252,18 +263,12 @@ public class BusinessSceneAnalysisService {
// 查询目标产值(周期=月时才展示) // 查询目标产值(周期=月时才展示)
Map<Date, BigDecimal> monthTargetOutputMap = new HashMap<>(); Map<Date, BigDecimal> monthTargetOutputMap = new HashMap<>();
if (queryParams.getDateType() == 2 && req.isWithTargetRatio()) { if (queryParams.getDateType() == 2 && req.isWithTargetRatio()) {
List<Integer> merchantIds;
try {
merchantIds = getMerchantIdPermission(req, false);
}catch (Exception e){
return Collections.emptyList();
}
byte businessType = req.convertToBusinessType(queryParams.getBizs()); byte businessType = req.convertToBusinessType(queryParams.getBizs());
RpcPagination<MerchantOutputTargetConfigDTO> pagination = new RpcPagination<>(); RpcPagination<MerchantOutputTargetConfigDTO> pagination = new RpcPagination<>();
pagination.setPageSize(Integer.MAX_VALUE); pagination.setPageSize(Integer.MAX_VALUE);
pagination.setPageNum(1); pagination.setPageNum(1);
MerchantOutputTargetConfigDTO condition = new MerchantOutputTargetConfigDTO(); MerchantOutputTargetConfigDTO condition = new MerchantOutputTargetConfigDTO();
condition.setMerchantIdList(merchantIds); condition.setMerchantIdList(req.getMerchantIds());
condition.setBusinessType(businessType); condition.setBusinessType(businessType);
pagination.setCondition(condition); pagination.setCondition(condition);
Date startDate = DateUtil.parseDate(queryParams.getStartDate()); Date startDate = DateUtil.parseDate(queryParams.getStartDate());
...@@ -872,7 +877,13 @@ public class BusinessSceneAnalysisService { ...@@ -872,7 +877,13 @@ public class BusinessSceneAnalysisService {
log.info("查询指标返回空, req:{}, res:{}", queryParams, dataResp); log.info("查询指标返回空, req:{}, res:{}", queryParams, dataResp);
return res; return res;
} }
Map<Integer, List<DataBusinessDTO>> dataMerchantMap = dataResp.getContent().stream() List<DataBusinessDTO> dataList = dataResp.getContent();
if (CollectionUtils.isNotEmpty(req.getExcludeIds())) {
dataList = dataList.stream()
.filter(p -> !req.getExcludeIds().contains(p.getMerchantId()))
.collect(Collectors.toList());
}
Map<Integer, List<DataBusinessDTO>> dataMerchantMap = dataList.stream()
.collect(Collectors.groupingBy(p -> p.getMerchantId())); .collect(Collectors.groupingBy(p -> p.getMerchantId()));
// 查询区域 // 查询区域
...@@ -888,14 +899,14 @@ public class BusinessSceneAnalysisService { ...@@ -888,14 +899,14 @@ public class BusinessSceneAnalysisService {
RegionalDistributionResponse item = new RegionalDistributionResponse(); RegionalDistributionResponse item = new RegionalDistributionResponse();
item.setProvinceId(provinceCode); item.setProvinceId(provinceCode);
item.setProvinceName(merchants.stream().map(MerchantProvinceDTO::getProvinceName).filter(StringUtils::isNotBlank).findFirst().orElse("")); item.setProvinceName(merchants.stream().map(MerchantProvinceDTO::getProvinceName).filter(StringUtils::isNotBlank).findFirst().orElse(""));
item.setMerchantIds(merchants.stream().map(p -> p.getMerchantId()).distinct().collect(Collectors.toList()));
int storeCount = 0; int storeCount = 0;
BigDecimal itemVal = BigDecimal.ZERO; BigDecimal itemVal = BigDecimal.ZERO;
for (MerchantProvinceDTO p : merchants) { for (MerchantProvinceDTO p : merchants) {
if (!dataMerchantMap.containsKey(p.getMerchantId())) { if (!dataMerchantMap.containsKey(p.getMerchantId())) {
continue; continue;
} }
List<DataBusinessDTO> dataList = dataMerchantMap.get(p.getMerchantId()); DataBusinessDTO data = mergeDataList(dataMerchantMap.get(p.getMerchantId()));
DataBusinessDTO data = mergeDataList(dataList);
if (data.getItemValue().compareTo(BigDecimal.ZERO) == 0) { if (data.getItemValue().compareTo(BigDecimal.ZERO) == 0) {
log.info("门店无交付数, id:{}, name:{}", data.getMerchantId(), data.getMerchantName()); log.info("门店无交付数, id:{}, name:{}", data.getMerchantId(), data.getMerchantName());
continue; continue;
...@@ -940,6 +951,7 @@ public class BusinessSceneAnalysisService { ...@@ -940,6 +951,7 @@ public class BusinessSceneAnalysisService {
// 展业数 // 展业数
queryParam.setCreatedDateStart(null).setCreatedDateEnd(null).setSignedTimeEnd(null).setSignedTimeEnd(null) queryParam.setCreatedDateStart(null).setCreatedDateEnd(null).setSignedTimeEnd(null).setSignedTimeEnd(null)
.setExcludeMerchantIds(req.getExcludeIds())
.setFirstPayTimeStart(startDate).setFirstPayTimeEnd(endDate).setPotentialCustomersStatus(Lists.newArrayList(4)); .setFirstPayTimeStart(startDate).setFirstPayTimeEnd(endDate).setPotentialCustomersStatus(Lists.newArrayList(4));
res.setNewStoreCount(salePotentialCustomersMapper.countStoreSummary(queryParam)); res.setNewStoreCount(salePotentialCustomersMapper.countStoreSummary(queryParam));
...@@ -978,7 +990,12 @@ public class BusinessSceneAnalysisService { ...@@ -978,7 +990,12 @@ public class BusinessSceneAnalysisService {
*/ */
public List<ContactRateAnalysisResponse> touchRateSummary(SceneBaseReq req) { public List<ContactRateAnalysisResponse> touchRateSummary(SceneBaseReq req) {
List<ContactRateAnalysisResponse> res = new ArrayList<>(); List<ContactRateAnalysisResponse> res = new ArrayList<>();
List<Integer> merchantIds = getMerchantIdPermission(req, DataStatsConstants.ITEM_CODE_A064, false); List<Integer> merchantIds;
try {
merchantIds = getMerchantIdPermission(req, DataStatsConstants.ITEM_CODE_A064, false);
}catch (Exception e){
return res;
}
// 查询区域 // 查询区域
RpcResponse<List<MerchantProvinceDTO>> merchantProvinceListByIds = merchantRemote.findMerchantProvinceListByIds(merchantIds); RpcResponse<List<MerchantProvinceDTO>> merchantProvinceListByIds = merchantRemote.findMerchantProvinceListByIds(merchantIds);
...@@ -1204,7 +1221,7 @@ public class BusinessSceneAnalysisService { ...@@ -1204,7 +1221,7 @@ public class BusinessSceneAnalysisService {
*/ */
public List<StoreListResponse> storeList(SceneBaseReq req) { public List<StoreListResponse> storeList(SceneBaseReq req) {
try { try {
req.setMerchantIds(getMerchantIdPermission(req)); req.setMerchantIds(getMerchantIdPermission(req, false));
}catch (Exception e){ }catch (Exception e){
return Collections.emptyList(); return Collections.emptyList();
} }
...@@ -1518,7 +1535,9 @@ public class BusinessSceneAnalysisService { ...@@ -1518,7 +1535,9 @@ public class BusinessSceneAnalysisService {
List<Integer> merchantIds = req.getMerchantIds(); List<Integer> merchantIds = req.getMerchantIds();
Integer sceneType = req.convertToSceneType(queryParams.getBizs()); Integer sceneType = req.convertToSceneType(queryParams.getBizs());
List<TrafficContributionRankResponse> res = goodsOrderMapper.findTrafficRank(merchantIds, staffUuids, req.getStartTime(), req.getEndTime(), sceneType); DateTime startTime = DateUtil.beginOfDay(DateUtil.parse(req.getStartTime()));
DateTime endTime = DateUtil.endOfDay(DateUtil.parse(req.getEndTime()));
List<TrafficContributionRankResponse> res = goodsOrderMapper.findTrafficRank(merchantIds, staffUuids, startTime, endTime, sceneType);
if (CollectionUtils.isEmpty(res)) { if (CollectionUtils.isEmpty(res)) {
return Collections.emptyList(); return Collections.emptyList();
} }
...@@ -1609,9 +1628,15 @@ public class BusinessSceneAnalysisService { ...@@ -1609,9 +1628,15 @@ public class BusinessSceneAnalysisService {
}); });
// 日报完成率: 完成日报天数(触客数)/总天数 // 日报完成率: 完成日报天数(触客数)/总天数
if (Objects.nonNull(res.getTotalContactCount())) { queryParams.setItemCodes(DataStatsConstants.ITEM_CODE_A084);
queryParams.setDateType(0); // 按天聚合查天数
DataResp<List<DataBusinessDTO>> dataResp = getDataStatsService.getListDataResp(JSON.toJSONString(queryParams));
if (CollectionUtils.isEmpty(dataResp.getContent())) {
log.error("日报完成率查询失败,参数:{}", queryParams);
} else {
int reportCount = dataResp.getContent().size();
long dateDiff = DateUtil.betweenDay(DateUtil.parse(queryParams.getStartDate()), DateUtil.parse(queryParams.getEndDate()), true) + 1; long dateDiff = DateUtil.betweenDay(DateUtil.parse(queryParams.getStartDate()), DateUtil.parse(queryParams.getEndDate()), true) + 1;
res.setDailyReportCompletionRate(res.getTotalContactCount() res.setDailyReportCompletionRate(BigDecimal.valueOf(reportCount)
.multiply(BigDecimal.valueOf(100)) .multiply(BigDecimal.valueOf(100))
.divide(BigDecimal.valueOf(dateDiff), 2, RoundingMode.HALF_UP)); .divide(BigDecimal.valueOf(dateDiff), 2, RoundingMode.HALF_UP));
} }
...@@ -1672,6 +1697,7 @@ public class BusinessSceneAnalysisService { ...@@ -1672,6 +1697,7 @@ public class BusinessSceneAnalysisService {
res.setVehicleWarrantyDealCount(scaleItemValue(data.getItemValue())); res.setVehicleWarrantyDealCount(scaleItemValue(data.getItemValue()));
break; break;
case DataStatsConstants.ITEM_CODE_A067: // 整车延保-渗透率 case DataStatsConstants.ITEM_CODE_A067: // 整车延保-渗透率
case DataStatsConstants.ITEM_CODE_A0100: // 整车延保-渗透率
res.setVehicleWarrantyPenetrationRate(convertPercentage(data.getItemValue())); res.setVehicleWarrantyPenetrationRate(convertPercentage(data.getItemValue()));
res.computeVehicleWarrantyEcoCoefficient(); // 整车延保-生态系数 res.computeVehicleWarrantyEcoCoefficient(); // 整车延保-生态系数
break; break;
...@@ -1683,6 +1709,7 @@ public class BusinessSceneAnalysisService { ...@@ -1683,6 +1709,7 @@ public class BusinessSceneAnalysisService {
res.setSafetyPackageDealCount(scaleItemValue(data.getItemValue())); res.setSafetyPackageDealCount(scaleItemValue(data.getItemValue()));
break; break;
case DataStatsConstants.ITEM_CODE_A092: // 安心包-渗透率 case DataStatsConstants.ITEM_CODE_A092: // 安心包-渗透率
case DataStatsConstants.ITEM_CODE_A0101: // 安心包-渗透率
res.setSafetyPackagePenetrationRate(convertPercentage(data.getItemValue())); res.setSafetyPackagePenetrationRate(convertPercentage(data.getItemValue()));
res.computeSafetyPackageEcoCoefficient(); // 安心包-生态系数 res.computeSafetyPackageEcoCoefficient(); // 安心包-生态系数
break; break;
...@@ -1694,6 +1721,7 @@ public class BusinessSceneAnalysisService { ...@@ -1694,6 +1721,7 @@ public class BusinessSceneAnalysisService {
res.setBatteryWarrantyDealCount(scaleItemValue(data.getItemValue())); res.setBatteryWarrantyDealCount(scaleItemValue(data.getItemValue()));
break; break;
case DataStatsConstants.ITEM_CODE_A094: // 电池延保-渗透率 case DataStatsConstants.ITEM_CODE_A094: // 电池延保-渗透率
case DataStatsConstants.ITEM_CODE_A0103: // 电池延保-渗透率
res.setBatteryWarrantyPenetrationRate(convertPercentage(data.getItemValue())); res.setBatteryWarrantyPenetrationRate(convertPercentage(data.getItemValue()));
res.computeBatteryWarrantyEcoCoefficient(); // 电池延保-生态系数 res.computeBatteryWarrantyEcoCoefficient(); // 电池延保-生态系数
break; break;
...@@ -1705,6 +1733,7 @@ public class BusinessSceneAnalysisService { ...@@ -1705,6 +1733,7 @@ public class BusinessSceneAnalysisService {
res.setTireWarrantyDealCount(scaleItemValue(data.getItemValue())); res.setTireWarrantyDealCount(scaleItemValue(data.getItemValue()));
break; break;
case DataStatsConstants.ITEM_CODE_A093: // 轮胎延保-渗透率 case DataStatsConstants.ITEM_CODE_A093: // 轮胎延保-渗透率
case DataStatsConstants.ITEM_CODE_A0102: // 轮胎延保-渗透率
res.setTireWarrantyPenetrationRate(convertPercentage(data.getItemValue())); res.setTireWarrantyPenetrationRate(convertPercentage(data.getItemValue()));
res.computeTireWarrantyEcoCoefficient(); res.computeTireWarrantyEcoCoefficient();
break; break;
...@@ -1716,6 +1745,7 @@ public class BusinessSceneAnalysisService { ...@@ -1716,6 +1745,7 @@ public class BusinessSceneAnalysisService {
res.setWindowFilmDealCount(scaleItemValue(data.getItemValue())); res.setWindowFilmDealCount(scaleItemValue(data.getItemValue()));
break; break;
case DataStatsConstants.ITEM_CODE_A0108: // 车窗膜-渗透率 case DataStatsConstants.ITEM_CODE_A0108: // 车窗膜-渗透率
case DataStatsConstants.ITEM_CODE_A0110: // 车窗膜-渗透率
res.setWindowFilmPenetrationRate(convertPercentage(data.getItemValue())); res.setWindowFilmPenetrationRate(convertPercentage(data.getItemValue()));
break; break;
case DataStatsConstants.ITEM_CODE_A0109: // 车窗膜-转化率 case DataStatsConstants.ITEM_CODE_A0109: // 车窗膜-转化率
...@@ -1729,6 +1759,7 @@ public class BusinessSceneAnalysisService { ...@@ -1729,6 +1759,7 @@ public class BusinessSceneAnalysisService {
res.setCarBodyFilmDealCount(scaleItemValue(data.getItemValue())); res.setCarBodyFilmDealCount(scaleItemValue(data.getItemValue()));
break; break;
case DataStatsConstants.ITEM_CODE_A0113: // 车身膜-渗透率 case DataStatsConstants.ITEM_CODE_A0113: // 车身膜-渗透率
case DataStatsConstants.ITEM_CODE_A0115: // 车身膜-渗透率
res.setCarBodyFilmPenetrationRate(convertPercentage(data.getItemValue())); res.setCarBodyFilmPenetrationRate(convertPercentage(data.getItemValue()));
break; break;
case DataStatsConstants.ITEM_CODE_A0114: // 车身膜-转化率 case DataStatsConstants.ITEM_CODE_A0114: // 车身膜-转化率
...@@ -1742,6 +1773,7 @@ public class BusinessSceneAnalysisService { ...@@ -1742,6 +1773,7 @@ public class BusinessSceneAnalysisService {
res.setAccessoriesDealCount(scaleItemValue(data.getItemValue())); res.setAccessoriesDealCount(scaleItemValue(data.getItemValue()));
break; break;
case DataStatsConstants.ITEM_CODE_A0118: // 精品附件-渗透率 case DataStatsConstants.ITEM_CODE_A0118: // 精品附件-渗透率
case DataStatsConstants.ITEM_CODE_A0120: // 精品附件-渗透率
res.setAccessoriesPenetrationRate(convertPercentage(data.getItemValue())); res.setAccessoriesPenetrationRate(convertPercentage(data.getItemValue()));
break; break;
case DataStatsConstants.ITEM_CODE_A0119: // 精品附件-转化率 case DataStatsConstants.ITEM_CODE_A0119: // 精品附件-转化率
...@@ -1754,9 +1786,10 @@ public class BusinessSceneAnalysisService { ...@@ -1754,9 +1786,10 @@ public class BusinessSceneAnalysisService {
}); });
// 计算单车采购产值 // 计算单车采购产值
BigDecimal rate = aggregateType.equals("staffIds") ? BigDecimal.ONE : BigDecimal.valueOf(0.35); // BigDecimal rate = aggregateType.equals("staffIds") ? BigDecimal.ONE : BigDecimal.valueOf(0.35);
res.setCarBodyFilmPerCarOutput(computeSingleVehiclePurchaseOutput(res.getCarBodyFilmPerCarOutput(), res.getNewCarDeliveryCount(), rate)); BigDecimal rate = BigDecimal.valueOf(0.35);
res.setAccessoriesPerCarOutput(computeSingleVehiclePurchaseOutput(res.getAccessoriesPerCarOutput(), res.getNewCarDeliveryCount(), rate)); // res.setCarBodyFilmPerCarOutput(computeSingleVehiclePurchaseOutput(res.getCarBodyFilmPerCarOutput(), res.getNewCarDeliveryCount(), rate));
// res.setAccessoriesPerCarOutput(computeSingleVehiclePurchaseOutput(res.getAccessoriesPerCarOutput(), res.getNewCarDeliveryCount(), rate));
res.setWindowFilmPerCarOutput(computeSingleVehiclePurchaseOutput(res.getWindowFilmPerCarOutput(), res.getNewCarDeliveryCount(), rate)); res.setWindowFilmPerCarOutput(computeSingleVehiclePurchaseOutput(res.getWindowFilmPerCarOutput(), res.getNewCarDeliveryCount(), rate));
res.computeWindowFilmEcoCoefficient(); // 车窗膜-生态系数 res.computeWindowFilmEcoCoefficient(); // 车窗膜-生态系数
res.computeCarBodyFilmEcoCoefficient(); // 车身膜-生态系数 res.computeCarBodyFilmEcoCoefficient(); // 车身膜-生态系数
......
...@@ -95,6 +95,12 @@ ...@@ -95,6 +95,12 @@
#{item} #{item}
</foreach> </foreach>
</if> </if>
<if test="excludeMerchantIds != null and excludeMerchantIds.size() > 0">
and spc.merchant_id not in
<foreach item="item" collection="excludeMerchantIds" separator="," open="(" close=")" index="">
#{item}
</foreach>
</if>
<if test="isBind != null"> <if test="isBind != null">
and spc.is_bind = #{isBind} and spc.is_bind = #{isBind}
</if> </if>
......
  • @wangxw1
    commented
    Master

    Auto Review Result:

    代码审查报告

    问题描述和优化建议

    1. SalePotentialCustomersReq 类

    • 问题: 新增的 excludeMerchantIds 字段没有对应的 getter 和 setter 方法。
    • 影响: 其他模块无法访问和设置该字段。
    • 建议: 添加对应的 getter 和 setter 方法。

    2. SceneBaseReq 类

    • 问题: 新增的 isPredictTrend 字段没有对应的 getter 和 setter 方法。
    • 影响: 其他模块无法访问和设置该字段。
    • 建议: 添加对应的 getter 和 setter 方法。

    3. RegionalDistributionResponse 类

    • 问题: 新增的 merchantIds 字段没有对应的 getter 和 setter 方法。
    • 影响: 其他模块无法访问和设置该字段。
    • 建议: 添加对应的 getter 和 setter 方法。

    4. TrendOutputResponse 类

    • 问题: 新增的 predictValue 字段没有对应的 getter 和 setter 方法。
    • 影响: 其他模块无法访问和设置该字段。
    • 建议: 添加对应的 getter 和 setter 方法。

    5. BusinessSceneAnalysisService 类

    • 问题: 在 getMerchantIdPermission 方法调用后,过滤门店逻辑存在错误。 java if (CollectionUtils.isNotEmpty(req.getExcludeIds())) { merchantIds = merchantIds.stream().filter(p -> req.getExcludeIds().contains(p)).collect(Collectors.toList()); log.info("查询指标[{}]门店权限, 屏蔽:{}:{}", itemCode, req.getExcludeIds(), merchantIds); } 这里的逻辑应该是排除 excludeIds 中的门店 ID,而不是包含它们。
    • 影响: 导致实际逻辑与预期不符,可能会返回错误的结果。
    • 建议: 修改为排除 excludeIds 中的门店 ID。 java if (CollectionUtils.isNotEmpty(req.getExcludeIds())) { merchantIds = merchantIds.stream().filter(p -> !req.getExcludeIds().contains(p)).collect(Collectors.toList()); log.info("查询指标[{}]门店权限, 屏蔽:{}:{}", itemCode, req.getExcludeIds(), merchantIds); }

    6. BusinessSceneAnalysisService 类

    • 问题: 在 touchRateSummary 方法中,捕获异常后直接返回空列表,可能隐藏潜在问题。 java try { merchantIds = getMerchantIdPermission(req, DataStatsConstants.ITEM_CODE_A064, false); } catch (Exception e){ return res; }
    • 影响: 异常信息被忽略,难以排查问题。
    • 建议: 增加日志记录异常信息,以便于后续排查问题。 java try { merchantIds = getMerchantIdPermission(req, DataStatsConstants.ITEM_CODE_A064, false); } catch (Exception e){ log.error("获取商户ID权限时发生异常", e); return res; }

    7. BusinessSceneAnalysisService 类

    • 问题: 在 storeList 方法中,调用 getMerchantIdPermission 方法时缺少参数。 java try { req.setMerchantIds(getMerchantIdPermission(req)); } catch (Exception e){ return Collections.emptyList(); }
    • 影响: 可能导致方法调用错误。
    • 建议: 确保传递正确的参数。 java try { req.setMerchantIds(getMerchantIdPermission(req, false)); } catch (Exception e){ return Collections.emptyList(); }

    8. BusinessSceneAnalysisService 类

    • 问题: 在 dailyReportCompletionRate 计算中,直接使用 dataResp.getContent().size() 来计算日报完成率,未验证数据的有效性。 java int reportCount = dataResp.getContent().size();
    • 影响: 如果 dataResp.getContent() 中的数据不符合预期,可能导致计算错误。
    • 建议: 增加数据有效性验证。 java if (CollectionUtils.isEmpty(dataResp.getContent())) { log.error("日报完成率查询失败,参数:{}", queryParams); return res; // 或者返回默认值 } int reportCount = dataResp.getContent().size();

    9. 注释与文档

    • 问题: 部分代码缺少必要的注释,难以理解其功能和作用。
    • 影响: 影响代码可读性和可维护性。
    • 建议: 增加必要的注释,提高代码可读性。

    评分明细

    1. 功能实现的正确性与健壮性(40分):

      • 代码逻辑基本正确,但存在一些小错误和潜在问题。
      • 得分: 32分
    2. 安全性与潜在风险(30分):

      • 代码中未发现明显的安全漏洞。
      • 得分: 28分
    3. 是否符合最佳实践(20分):

      • 缺少部分 getter 和 setter 方法,影响代码的可访问性。
      • 注释不足,影响代码可读性。
      • 得分: 15分
    4. 性能与资源利用效率(5分):

      • 代码中未发现明显的性能问题。
      • 得分: 5分
    5. Commits信息的清晰性与准确性(5分):

      • 提交信息清晰,准确描述了变更内容。
      • 得分: 5分

    总分: 85分

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