Commit ab322bd5 by 张富康

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

2 parents 3d5cecee b653a120
......@@ -1661,10 +1661,10 @@ public class BusinessAnalysisService {
.distinct() // 按手机号去重
.count(); // 统计去重后的数量
// 关键:如果 output 为 0,则覆盖为 0
/* // 关键:如果 output 为 0,则覆盖为 0
if (output == null || output.compareTo(BigDecimal.ZERO) == 0) {
distinctTechnicianCount = 0;
}
}*/
result.setTechnicianCount((int) distinctTechnicianCount);
log.info("门店总产值:{}, 门店技师数量:{}, 门店销售人员数量:{}", output, result.getTechnicianCount(), salesCount);
......@@ -1819,6 +1819,16 @@ public class BusinessAnalysisService {
Map<Integer, BigDecimal> quantifiedStaffMap, boolean isLuxury) {
BigDecimal totalOutput = BigDecimal.ZERO;
BigDecimal totalStaffCount = BigDecimal.ZERO;
long technicianCount = stores.stream()
.filter(store -> store.isLuxury() == isLuxury)
.map(StoreInfo::getTechnicianList)
.filter(Objects::nonNull) // 过滤掉 null 的 technicianList
.flatMap(List::stream) // 展平为 Stream<MerchantStaffResponse>
.map(MerchantStaffResponse::getStaffPhone) // 提取手机号
.filter(Objects::nonNull) // 过滤 null 手机号
.filter(phone -> !phone.trim().isEmpty()) // 可选:过滤空字符串
.distinct() // 按手机号去重
.count();
for (StoreInfo store : stores) {
if (store.isLuxury() == isLuxury) { // 根据是否豪华店筛选
......@@ -1829,12 +1839,12 @@ public class BusinessAnalysisService {
BigDecimal staffCount = quantifiedStaffMap.getOrDefault(store.getStoreId(),
BigDecimal.ZERO);
BigDecimal technicianCount = new BigDecimal(store.getTechnicianCount());
totalOutput = totalOutput.add(storeOutput);
totalStaffCount = totalStaffCount.add(staffCount).add(technicianCount);
totalStaffCount = totalStaffCount.add(staffCount);
}
}
totalStaffCount.add(BigDecimal.valueOf(technicianCount));
MetricsResult result = new MetricsResult();
if (totalStaffCount.compareTo(BigDecimal.ZERO) > 0) {
......@@ -1992,11 +2002,7 @@ public class BusinessAnalysisService {
profit = integerBigDecimalMap.get(sceneType) == null ? BigDecimal.ZERO
: integerBigDecimalMap.get(sceneType);
// 毛利率 = 毛利额 / 产值(避免除零)
BigDecimal margin = BigDecimal.ZERO;
if (sceneOutput.compareTo(BigDecimal.ZERO) > 0) {
margin = profit.divide(sceneOutput, 4, RoundingMode.HALF_UP);
}
detail.setProfitMargin(margin);
detail.setProfitMargin(calculatePercent(profit, sceneOutput));
}
......
......@@ -1535,8 +1535,8 @@ public class BusinessSceneAnalysisService {
List<Integer> merchantIds = req.getMerchantIds();
Integer sceneType = req.convertToSceneType(queryParams.getBizs());
DateTime startTime = DateUtil.beginOfDay(DateUtil.parse(req.getStartTime()));
DateTime endTime = DateUtil.endOfDay(DateUtil.parse(req.getEndTime()));
Date startTime = DateUtil.beginOfDay(DateUtil.parse(req.getStartTime()));
Date endTime = DateUtil.endOfDay(DateUtil.parse(req.getEndTime())).toJdkDate();
List<TrafficContributionRankResponse> res = goodsOrderMapper.findTrafficRank(merchantIds, staffUuids, startTime, endTime, sceneType);
if (CollectionUtils.isEmpty(res)) {
return Collections.emptyList();
......@@ -1735,7 +1735,7 @@ public class BusinessSceneAnalysisService {
case DataStatsConstants.ITEM_CODE_A093: // 轮胎延保-渗透率
case DataStatsConstants.ITEM_CODE_A0102: // 轮胎延保-渗透率
res.setTireWarrantyPenetrationRate(convertPercentage(data.getItemValue()));
res.computeTireWarrantyEcoCoefficient();
// res.computeTireWarrantyEcoCoefficient(); // 轮胎无需计算生态系数
break;
case DataStatsConstants.ITEM_CODE_A090: // 轮胎延保-转化率
res.setTireWarrantyConversionRate(convertPercentage(data.getItemValue()));
......
......@@ -147,37 +147,54 @@
<select id="findTrafficRank" resultType="cn.com.glsx.dj.peanalysis.dto.res.output.TrafficContributionRankResponse">
select
user_id as employeeId,
employee_name as employeeName,
count(*) as totalTrafficContribution
from dj_car_life_goods_order
o.user_id as employeeId,
o.employee_name as employeeName,
count(distinct o.order_code) as totalTrafficContribution
from dj_car_life_goods_order o
left join dj_car_life_pay_order po on po.order_code=o.order_code and po.deleted_flag='N'
<where>
deleted_flag = 'N'
and user_id is not null
and status in (2, 4, 6)
o.deleted_flag = 'N'
and o.user_id is not null
and o.status in (2, 4, 6)
<if test="merchantIds != null and merchantIds.size() > 0">
and merchant_id in
and o.merchant_id in
<foreach collection="merchantIds" item="uuid" open="(" close=")" separator=",">
#{uuid}
</foreach>
</if>
<if test="staffUuids != null and staffUuids.size() > 0">
and user_id in
and o.user_id in
<foreach collection="staffUuids" item="uuid" open="(" close=")" separator=",">
#{uuid}
</foreach>
</if>
<if test="startDate != null and startDate !=''">
and order_time >= #{startDate}
<if test="scene != null">
and o.scene_type = #{scene}
</if>
<if test="endDate != null and endDate !=''">
and order_time &lt;= #{endDate}
<if test="startDate != null">
<![CDATA[ and (
(
o.upgrade_flag='Y' and po.success_date >= #{startDate}
)
or (
o.upgrade_flag='N' and o.order_time >= #{startDate}
)
)
]]>
</if>
<if test="scene != null">
and scene_type = #{scene}
<if test="endDate != null">
<![CDATA[ and (
(
o.upgrade_flag='Y' and po.success_date <= #{endDate}
)
or (
o.upgrade_flag='N' and o.order_time <= #{endDate}
)
)
]]>
</if>
</where>
group by user_id
group by o.user_id
</select>
</mapper>
\ No newline at end of file
  • @wangxw1
    commented
    Master

    Auto Review Result:

    代码审查报告

    问题描述和优化建议

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

    问题描述:

    • 在 UsedCarDataStatsService 类中的 getTrendChart 方法中,预测数据的计算逻辑被重新启用,并添加了额外的条件判断。虽然这部分逻辑看起来是正确的,但缺乏详细的单元测试来验证其在各种边界情况下的行为。

    优化建议:

    • 增加针对预测数据计算逻辑的单元测试,确保在不同输入条件下(例如,不同的开始和结束日期,不同的周期类型等)都能得到预期的结果。
    • 使用参数化测试来覆盖更多的边界情况,提高测试覆盖率。

    2. 安全性与潜在风险(30分)

    问题描述:

    • 从代码片段来看,没有明显的安全漏洞。但是,如果 TrendChartReq 对象中的日期字符串格式不正确,可能会导致 DateUtil.parse 方法抛出异常。
    • 如果 request.getMerchantId() 或 request.getBrandId() 为 null,可能会导致 NPE 异常。

    优化建议:

    • 在解析日期字符串之前,添加对日期格式的校验。
    • 对于可能为 null 的字段,在使用前添加非空检查,或者使用 Java 8 的 Optional 来处理可能的 null 值。

    3. 是否符合最佳实践(20分)

    问题描述:

    • 代码中存在一些未使用的导入语句(如注释掉的导入语句),这可能会导致不必要的编译依赖。
    • 注释掉的代码块仍然存在于代码库中,这可能会引起混淆,影响代码的可读性。

    优化建议:

    • 移除未使用的导入语句。
    • 清理所有注释掉的代码块,确保代码库中只保留必要的代码。

    4. 性能与资源利用效率(5分)

    问题描述:

    • 从现有代码来看,性能问题并不明显。但是,预测数据的计算涉及循环操作和日期计算,如果数据量较大,可能会成为性能瓶颈。

    优化建议:

    • 对于大数据量的情况,可以考虑优化日期计算逻辑,或者使用更高效的数据结构。
    • 对预测数据的计算部分进行性能测试,确保在实际应用中不会出现明显的性能问题。

    5. Commits信息的清晰性与准确性(5分)

    问题描述:

    • 提交信息整体清晰,但有一些细节可以改进。
    • 提交信息中提到的“Merge remote-tracking branch 'origin/v5.5.1' into v5.5.1”并不是这次提交的主要内容,可以考虑将其移除,或者单独作为一个提交。

    优化建议:

    • 确保提交信息简洁明了,仅包含当前提交的主要更改内容。
    • 如果有多个独立的更改点,可以考虑将它们分成多个提交,以便更好地追踪每个更改的具体内容。

    评分明细

    • 功能实现的正确性与健壮性:35/40
    • 安全性与潜在风险:25/30
    • 是否符合最佳实践:15/20
    • 性能与资源利用效率:4/5
    • Commits信息的清晰性与准确性:4/5

    总分

    总分:83分


    以上是对该员工提交代码的详细审查报告,希望对后续的工作有所帮助。

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