Commit 64e4e616 by 春觉晓

存量门店分析,生态系数过滤鸿蒙智行品牌

1 parent 95474144
...@@ -59,6 +59,8 @@ public class SceneBaseReq implements Serializable { ...@@ -59,6 +59,8 @@ public class SceneBaseReq implements Serializable {
@ApiModelProperty(notes = "门店号列表") @ApiModelProperty(notes = "门店号列表")
private List<Integer> merchantIds; private List<Integer> merchantIds;
private List<Integer> tempList;
@ApiModelProperty(notes = "门店号列表") @ApiModelProperty(notes = "门店号列表")
private List<Integer> lkastmerchantIds; private List<Integer> lkastmerchantIds;
......
...@@ -21,6 +21,7 @@ import cn.com.glsx.dj.smartcarlife.remote.MerchantOutputTargetConfigRemote; ...@@ -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.RpcPagination;
import cn.com.glsx.framework.core.beans.rpc.RpcResponse; import cn.com.glsx.framework.core.beans.rpc.RpcResponse;
import cn.com.glsx.framework.core.exception.RpcServiceException; 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.request.MerchantStaffRequest;
import cn.com.glsx.merchants.model.response.MerchantProvinceDTO; import cn.com.glsx.merchants.model.response.MerchantProvinceDTO;
import cn.com.glsx.merchants.model.response.MerchantStaffResponse; import cn.com.glsx.merchants.model.response.MerchantStaffResponse;
...@@ -594,6 +595,26 @@ public class BusinessSceneAnalysisService { ...@@ -594,6 +595,26 @@ public class BusinessSceneAnalysisService {
return res; 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;
}
/** /**
* 处理延保预警门店 * 处理延保预警门店
*/ */
...@@ -607,6 +628,11 @@ public class BusinessSceneAnalysisService { ...@@ -607,6 +628,11 @@ public class BusinessSceneAnalysisService {
res.setEcosystemWarningStores(storeIds.size()); res.setEcosystemWarningStores(storeIds.size());
} }
public List<Integer> handleDelayWarningStore(SceneBaseReq req, String startDate, String endDate) { public List<Integer> handleDelayWarningStore(SceneBaseReq req, String startDate, String endDate) {
//过滤鸿蒙智行门店
if (!filterHarmonyStore(req)) {
//返回空list
return Collections.emptyList();
}
Set<Integer> warningSet = new HashSet<>(); Set<Integer> warningSet = new HashSet<>();
DataBizQueryParamsDTO queryParams = req.convertQueryParam(); DataBizQueryParamsDTO queryParams = req.convertQueryParam();
queryParams.setStartDate(startDate); queryParams.setStartDate(startDate);
...@@ -614,7 +640,7 @@ public class BusinessSceneAnalysisService { ...@@ -614,7 +640,7 @@ public class BusinessSceneAnalysisService {
//查询延保-整车渗透率(门店)-A067 //查询延保-整车渗透率(门店)-A067
queryParams.setBrandIds(dataStatsConfig.defaultBrandId); queryParams.setBrandIds(dataStatsConfig.defaultBrandId);
queryParams.setExts("merchantIds"); 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); 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); Map<String, List<DataBusinessDTO>> dataMap = getDataStatsService.parallelCallListMap(itemCodes, queryParams);
for (String itemCode : itemCodes) { for (String itemCode : itemCodes) {
...@@ -741,12 +767,17 @@ public class BusinessSceneAnalysisService { ...@@ -741,12 +767,17 @@ public class BusinessSceneAnalysisService {
res.setEcosystemWarningStores(storeIds.size()); res.setEcosystemWarningStores(storeIds.size());
} }
public List<Integer> handleLightChangeWarningStore(SceneBaseReq req, String startDate, String endDate) { public List<Integer> handleLightChangeWarningStore(SceneBaseReq req, String startDate, String endDate) {
//过滤鸿蒙智行门店
if (!filterHarmonyStore(req)) {
//返回空list
return Collections.emptyList();
}
DataBizQueryParamsDTO queryParams = req.convertQueryParam(); DataBizQueryParamsDTO queryParams = req.convertQueryParam();
queryParams.setStartDate(startDate); queryParams.setStartDate(startDate);
queryParams.setEndDate(endDate); queryParams.setEndDate(endDate);
queryParams.setBrandIds(dataStatsConfig.defaultBrandId); queryParams.setBrandIds(dataStatsConfig.defaultBrandId);
queryParams.setExts("merchantIds"); 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); 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); Map<String, List<DataBusinessDTO>> dataMap = getDataStatsService.parallelCallListMap(itemCodes, queryParams);
//新车交付数-A062 //新车交付数-A062
......
  • @wangxw1
    commented
    Master

    Auto Review Result:

    代码审查报告

    问题描述和优化建议

    1. 临时变量 tempList 的使用

    问题描述: 在 SceneBaseReq 类中添加了一个新的字段 tempList,并在 BusinessSceneAnalysisService 中使用该字段来存储过滤后的 merchantIds。然而,这个字段没有相应的 getter 和 setter 方法,这可能会导致在其他地方无法直接访问和修改该字段。

    优化建议:

    • 为 tempList 添加 getter 和 setter 方法,以确保其可访问性和可维护性。
    • 考虑将 tempList 作为局部变量,而不是类的成员变量,以减少不必要的状态维护。
    public List<Integer> getTempList() {
        return tempList;
    }
    
    public void setTempList(List<Integer> tempList) {
        this.tempList = tempList;
    }
    

    2. 日志记录的重复

    问题描述: 在 filterHarmonyStore 方法中,当 filterMerchantResponse 或 merchantIdList 为空时,日志记录了两次相同的信息。

    优化建议:

    • 合并重复的日志记录,以避免冗余信息。
    if (CollectionUtils.isEmpty(filterMerchantResponse) || CollectionUtils.isEmpty(merchantIdList)) {
        log.info("处理生态系数,过滤鸿蒙智行门店,未查询到符合条件的门店,品牌id[{}]", harmonyBrandId);
        return false;
    }
    

    3. 异常处理缺失

    问题描述: filterHarmonyStore 方法中调用了远程服务 merchantRemote.findMerchantListByBrandIdsProvince,但没有处理可能抛出的异常。

    优化建议:

    • 增加异常处理机制,确保在远程调用失败时能够捕获异常并进行适当的处理。
    try {
        RpcResponse<List<MerchantProvinceDTO>> filterMerchantIdsResponse = merchantRemote.findMerchantListByBrandIdsProvince(carBrandProvinceRequestDTO);
        List<MerchantProvinceDTO> filterMerchantResponse = filterMerchantIdsResponse.getResult();
        // ... 其他逻辑 ...
    } catch (Exception e) {
        log.error("调用远程服务 findMerchantListByBrandIdsProvince 失败", e);
        return false;
    }
    

    4. 提交信息的清晰性

    问题描述: 提交信息 "存量门店分析,生态系数过滤鸿蒙智行品牌" 虽然描述了主要功能,但不够具体,难以快速理解具体的变更内容。

    优化建议:

    • 提供更详细的提交信息,说明具体的变更内容和原因,例如 "添加 filterHarmonyStore 方法以过滤鸿蒙智行品牌门店,并在相关方法中使用过滤后的门店列表"。

    评分明细

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

      • 代码逻辑基本正确,但缺少异常处理和 getter/setter 方法,扣掉5分。
      • 总计:35分
    2. 安全性与潜在风险(30分):

      • 代码中没有明显的安全漏洞,但增加了对远程服务的调用,需要确保异常处理和日志记录。
      • 总计:28分
    3. 是否符合最佳实践(20分):

      • 缺少 getter/setter 方法,日志记录有冗余,扣掉4分。
      • 总计:16分
    4. 性能与资源利用效率(5分):

      • 没有明显的性能问题,但可以考虑将 tempList 作为局部变量。
      • 总计:4分
    5. Commits信息的清晰性与准确性(5分):

      • 提交信息不够具体,扣掉2分。
      • 总计:3分

    总分

    总分:86分


    通过上述优化建议,可以提高代码的健壮性、可维护性和可读性,同时确保提交信息的清晰性。

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