Commit 3ee65f91 by zhouhaibao

Merge remote-tracking branch 'origin/v5.5.1' into v5.5.1

2 parents 7858fe82 64e4e616
......@@ -59,6 +59,8 @@ public class SceneBaseReq implements Serializable {
@ApiModelProperty(notes = "门店号列表")
private List<Integer> merchantIds;
private List<Integer> tempList;
@ApiModelProperty(notes = "门店号列表")
private List<Integer> lkastmerchantIds;
......@@ -196,8 +198,9 @@ public class SceneBaseReq implements Serializable {
}
switch (bizs){
case 1:
case 3:
return 2;
case 3:
return 4;
case 2:
return 1;
case 4:
......
......@@ -7,6 +7,6 @@ import org.springframework.context.annotation.Configuration;
public class DataStatsConfig {
/** 无品牌时的默认传参 */
@Value("${default.brand.id:-1,-2,3454}")
@Value("${default.brand.id:-1,-2,3454,-4}")
public String defaultBrandId;
}
......@@ -21,6 +21,7 @@ import cn.com.glsx.dj.smartcarlife.remote.MerchantOutputTargetConfigRemote;
import cn.com.glsx.framework.core.beans.rpc.RpcPagination;
import cn.com.glsx.framework.core.beans.rpc.RpcResponse;
import cn.com.glsx.framework.core.exception.RpcServiceException;
import cn.com.glsx.merchants.dto.merchant.CarBrandProvinceRequestDTO;
import cn.com.glsx.merchants.model.request.MerchantStaffRequest;
import cn.com.glsx.merchants.model.response.MerchantProvinceDTO;
import cn.com.glsx.merchants.model.response.MerchantStaffResponse;
......@@ -161,31 +162,35 @@ public class BusinessSceneAnalysisService {
return getMerchantIdPermission(req, itemCode, containLast, false);
}
private List<Integer> getMerchantIdPermission(SceneBaseReq req, String itemCode, boolean containLast, boolean filterPermission) {
DataBizQueryParamsDTO queryParams = req.convertQueryParam();
queryParams.setBrandIds(dataStatsConfig.defaultBrandId);
queryParams.setItemCodes(itemCode);
queryParams.setExts("merchantIds");
if (containLast) {
queryParams.setStartDate(DateUtils.offsetDateWithCycleType(queryParams.getStartDate(), req.getCycleType(),-1));
List<Integer> merchantIds = req.getMerchantIds();
if (StringUtils.isNotBlank(itemCode)) {
DataBizQueryParamsDTO queryParams = req.convertQueryParam();
queryParams.setBrandIds(dataStatsConfig.defaultBrandId);
queryParams.setItemCodes(itemCode);
queryParams.setExts("merchantIds");
if (containLast) {
queryParams.setStartDate(DateUtils.offsetDateWithCycleType(queryParams.getStartDate(), req.getCycleType(),-1));
}
List<DataBusinessDTO> totalOutputList = businessAnalysisService.getTotalOutputGroupByMerchant(queryParams);
if (CollectionUtils.isEmpty(totalOutputList)) {
log.warn("查询指标[{}]返回空, queryParams:{}", itemCode, queryParams);
throw new RpcServiceException("查询指标返回空");
}
merchantIds = totalOutputList.stream()
.map(p -> p.getMerchantId())
.filter(Objects::nonNull)
.distinct()
.collect(Collectors.toList());
log.info("查询指标[{}]门店权限:{}", itemCode, merchantIds);
}
List<DataBusinessDTO> totalOutputList = businessAnalysisService.getTotalOutputGroupByMerchant(queryParams);
if (CollectionUtils.isEmpty(totalOutputList)) {
log.warn("查询指标[{}]返回空, queryParams:{}", itemCode, queryParams);
throw new RpcServiceException("查询指标返回空");
}
List<Integer> merchantIds = totalOutputList.stream()
.map(p -> p.getMerchantId())
.filter(Objects::nonNull)
.distinct()
.collect(Collectors.toList());
log.info("查询指标[{}]门店权限:{}", itemCode, merchantIds);
if (filterPermission) {
// 查询上个周期的,需要过滤经营品类
merchantIds = filterStoreTypeAndCategoryPermission(merchantIds, req);
log.info("查询指标[{}]门店权限, 过滤经营品类:{}", itemCode, merchantIds);
}
if (CollectionUtils.isNotEmpty(req.getExcludeIds())) {
merchantIds = merchantIds.stream().filter(p -> req.getExcludeIds().contains(p)).collect(Collectors.toList());
merchantIds = merchantIds.stream().filter(p -> !req.getExcludeIds().contains(p)).collect(Collectors.toList());
log.info("查询指标[{}]门店权限, 屏蔽:{}:{}", itemCode, req.getExcludeIds(), merchantIds);
}
if (CollectionUtils.isEmpty(merchantIds)) {
......@@ -590,6 +595,26 @@ public class BusinessSceneAnalysisService {
return res;
}
public boolean filterHarmonyStore(SceneBaseReq req) {
Integer harmonyBrandId = env.getProperty("dj.pe.analysis.business.scene.harmony.brandId", Integer.class, 2365);
log.info("处理生态系数,过滤鸿蒙执行门店,品牌id[{}]", harmonyBrandId);
CarBrandProvinceRequestDTO carBrandProvinceRequestDTO = new CarBrandProvinceRequestDTO();
carBrandProvinceRequestDTO.setFirstBrandIdList(Collections.singletonList(harmonyBrandId));
carBrandProvinceRequestDTO.setMerchantNoList(req.getMerchantIds());
RpcResponse<List<MerchantProvinceDTO>> filterMerchantIdsResponse = merchantRemote.findMerchantListByBrandIdsProvince(carBrandProvinceRequestDTO);
List<MerchantProvinceDTO> filterMerchantResponse = filterMerchantIdsResponse.getResult();
if (CollectionUtils.isEmpty(filterMerchantResponse)) {
log.info("处理生态系数,过滤鸿蒙智行门店,未查询到符合条件的门店,品牌id[{}]", harmonyBrandId);
return false;
}
List<Integer> merchantIdList = filterMerchantResponse.stream().map(MerchantProvinceDTO::getMerchantId).filter(Objects::nonNull).collect(Collectors.toList());
if (CollectionUtils.isEmpty(merchantIdList)) {
log.info("处理生态系数,过滤鸿蒙智行门店,未查询到符合条件的门店,品牌id[{}]", harmonyBrandId);
return false;
}
req.setTempList(merchantIdList);
return true;
}
/**
* 处理延保预警门店
*/
......@@ -603,6 +628,11 @@ public class BusinessSceneAnalysisService {
res.setEcosystemWarningStores(storeIds.size());
}
public List<Integer> handleDelayWarningStore(SceneBaseReq req, String startDate, String endDate) {
//过滤鸿蒙智行门店
if (!filterHarmonyStore(req)) {
//返回空list
return Collections.emptyList();
}
Set<Integer> warningSet = new HashSet<>();
DataBizQueryParamsDTO queryParams = req.convertQueryParam();
queryParams.setStartDate(startDate);
......@@ -610,7 +640,7 @@ public class BusinessSceneAnalysisService {
//查询延保-整车渗透率(门店)-A067
queryParams.setBrandIds(dataStatsConfig.defaultBrandId);
queryParams.setExts("merchantIds");
queryParams.setMerchantIds(StringUtils.join(req.getMerchantIds(), ","));
queryParams.setMerchantIds(StringUtils.join(req.getTempList(), ","));
List<String> itemCodes = Lists.newArrayList(DataStatsConstants.ITEM_CODE_A067, DataStatsConstants.ITEM_CODE_A092, DataStatsConstants.ITEM_CODE_A094);
Map<String, List<DataBusinessDTO>> dataMap = getDataStatsService.parallelCallListMap(itemCodes, queryParams);
for (String itemCode : itemCodes) {
......@@ -737,12 +767,17 @@ public class BusinessSceneAnalysisService {
res.setEcosystemWarningStores(storeIds.size());
}
public List<Integer> handleLightChangeWarningStore(SceneBaseReq req, String startDate, String endDate) {
//过滤鸿蒙智行门店
if (!filterHarmonyStore(req)) {
//返回空list
return Collections.emptyList();
}
DataBizQueryParamsDTO queryParams = req.convertQueryParam();
queryParams.setStartDate(startDate);
queryParams.setEndDate(endDate);
queryParams.setBrandIds(dataStatsConfig.defaultBrandId);
queryParams.setExts("merchantIds");
queryParams.setMerchantIds(StringUtils.join(req.getMerchantIds(), ","));
queryParams.setMerchantIds(StringUtils.join(req.getTempList(), ","));
List<String> itemCodes = Lists.newArrayList(DataStatsConstants.ITEM_CODE_A0107, DataStatsConstants.ITEM_CODE_A062, DataStatsConstants.ITEM_CODE_A0112, DataStatsConstants.ITEM_CODE_A0117);
Map<String, List<DataBusinessDTO>> dataMap = getDataStatsService.parallelCallListMap(itemCodes, queryParams);
//新车交付数-A062
......@@ -928,6 +963,19 @@ public class BusinessSceneAnalysisService {
}
res.add(response);
}
List<TrafficSummaryResponse> validRes = res.stream()
.filter(p -> p.getRatio().compareTo(BigDecimal.ZERO) > 0).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(validRes) && validRes.size() > 1) {
int validCount = validRes.size();
BigDecimal preValidRatio = validRes.stream().map(p -> p.getRatio())
.limit(validCount - 1)
.reduce(BigDecimal.ZERO, BigDecimal::add);
log.info("有效占比记录数:{},前有效占比总和:{}", validCount, preValidRatio);
res.stream()
.filter(p -> p.getRatio().compareTo(BigDecimal.ZERO) > 0)
.skip(validCount - 1)
.forEach(p -> p.setRatio(BigDecimal.valueOf(100).subtract(preValidRatio)));
}
return res;
}
......@@ -1453,6 +1501,12 @@ public class BusinessSceneAnalysisService {
StoreDetailSummaryResponse res = new StoreDetailSummaryResponse();
DataBizQueryParamsDTO queryParams = req.convertQueryParam();
try {
req.setMerchantIds(getMerchantIdPermission(req, false));
}catch (Exception e){
return res;
}
// 查询门店信息、所属服务商、区域运营、销售、线上运营
Integer sceneType = req.convertToSceneType(queryParams.getBizs());
List<StoreSettingDTO> storeList = serviceMerchantMapper.findStoreSetting(req.getMerchantIds(), sceneType);
......@@ -1551,6 +1605,12 @@ public class BusinessSceneAnalysisService {
Map<String, StoreEmployeeRankResponse.EmployeeAnalysisItem> empMap = new HashMap<>();
StoreEmployeeRankResponse.StoreSummaryData storeSummary = new StoreEmployeeRankResponse.StoreSummaryData();
try {
req.setMerchantIds(getMerchantIdPermission(req, null, false));
}catch (Exception e){
return res;
}
// 查询指标(员工维度)
DataBizQueryParamsDTO queryParams = req.convertQueryParam();
queryParams.setBrandIds(dataStatsConfig.defaultBrandId);
......@@ -1632,6 +1692,12 @@ public class BusinessSceneAnalysisService {
List<String> staffUuids = req.getStaffUuids();
List<Integer> merchantIds = req.getMerchantIds();
try {
req.setMerchantIds(getMerchantIdPermission(req, null, false));
}catch (Exception e){
return Collections.emptyList();
}
Integer sceneType = req.convertToSceneType(queryParams.getBizs());
Byte businessType = req.convertToBusinessType(queryParams.getBizs());
Date startTime = DateUtil.beginOfDay(DateUtil.parse(req.getStartTime()));
......@@ -1662,6 +1728,12 @@ public class BusinessSceneAnalysisService {
EmployeeDetailSummaryResponse res = new EmployeeDetailSummaryResponse();
DataBizQueryParamsDTO queryParams = req.convertQueryParam();
try {
req.setMerchantIds(getMerchantIdPermission(req, null, false));
}catch (Exception e){
return res;
}
// 查询指标
queryParams.setBrandIds(dataStatsConfig.defaultBrandId);
if (StringUtils.isBlank(queryParams.getExts())) {
......@@ -1763,6 +1835,12 @@ public class BusinessSceneAnalysisService {
public GoodsCategorySummaryResponse goodsSummary(SceneBaseReq req) {
GoodsCategorySummaryResponse res = new GoodsCategorySummaryResponse();
try {
req.setMerchantIds(getMerchantIdPermission(req, null, false));
}catch (Exception e){
return res;
}
// 查询指标
DataBizQueryParamsDTO queryParams = req.convertQueryParam();
Integer bizs = queryParams.getBizs();
......
  • @wangxw1
    commented
    Master

    Auto Review Result:

    代码审查报告

    问题描述和优化建议

    1. calculateMom 方法的问题

    • 问题描述:
      • 当 current 为 null 时,将其设置为 BigDecimal.ZERO 可能会导致不正确的环比计算。
      • 当 last 为 null 或 0 时,返回 null 可能会导致调用者需要额外的空值检查。
    • 优化建议:
      • 考虑保留原始逻辑,即当 current 为 null 时返回 null,而不是将其设置为 BigDecimal.ZERO。
      • 当 last 为 null 或 0 时,根据业务需求决定返回 100% 还是 null,但应确保调用者知道如何处理这些情况。 java private BigDecimal calculateMom(BigDecimal current, BigDecimal last) { if (current == null) { return null; } if (last == null || last.compareTo(BigDecimal.ZERO) == 0) { return current.compareTo(BigDecimal.ZERO) > 0 ? new BigDecimal("100.00") : BigDecimal.ZERO; } return current.subtract(last) .divide(last, 6, RoundingMode.HALF_UP); }

    2. checkQuyu 方法的引入

    • 问题描述:
      • 新增了 checkQuyu 方法来检查特定角色 (7 和 8),这在多个地方被重复使用。
    • 优化建议:
      • 该方法的引入没有问题,但可以考虑将 checkSup 和 checkQuyu 合并为一个方法,或者使用一个更通用的方法来检查角色列表。 java private boolean checkRole(Integer loginRole, Set<Integer> roles) { return loginRole != null && roles.contains(loginRole); } // 使用示例 if (checkRole(req.getLoginRole(), Set.of(1, 2))) { ... } if (checkRole(req.getLoginRole(), Set.of(7, 8))) { ... }

    3. log.info 中的日志标签错误

    • 问题描述:
      • 在 log.info 中,日志标签错误地从 rankList 改为了 dplrankList。
    • 优化建议:
      • 修正日志标签以避免混淆。 java log.info("rankList: {}", rankList);

    4. rpcPagination 的分页设置

    • 问题描述:
      • 直接设置了 pageNum 为 1 和 pageSize 为 100000,可能导致性能问题或内存不足。
    • 优化建议:
      • 根据实际需求动态设置分页参数,或者至少添加注释说明为何选择这样的分页大小。 java rpcPagination.setPageNum(1); rpcPagination.setPageSize(100000); // 注意:大分页可能导致性能问题

    5. 提交信息的清晰性

    • 问题描述:
      • 提交信息 全国排名调整;Merge remote-tracking branch 'origin/v5.5.1' into v5.5.1 不够清晰,合并分支的操作不应包含在主要功能描述中。
    • 优化建议:
      • 分开描述主要功能和合并操作。 plaintext 全国排名调整

    评分明细

    1. 功能实现的正确性与健壮性(40分):30分(部分逻辑需要进一步确认)
    2. 安全性与潜在风险(30分):30分(未发现明显安全漏洞)
    3. 是否符合最佳实践(20分):15分(代码结构良好,但存在一些改进空间)
    4. 性能与资源利用效率(5分):3分(分页设置可能存在问题)
    5. Commits信息的清晰性与准确性(5分):2分(提交信息不够清晰)

    总分: 100分

    注意:由于代码片段有限,部分评分基于现有信息进行判断,可能需要进一步的上下文审查以获得更准确的评分。

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