Commit 953c2871 by zhouhaibao

[+]【人员管理 / 督导管理】 查看详情-归属业务错误,【嘀加门店管理助手】团队-业绩 产值对应的预警亮灯与D+后台定义的不一致,【嘀加门店管理助手】团队-行…

…为 员工排行中的录音缺失率百分比展示不正常,【嘀加门店管理助手】团队-业绩 AI分析中涉及到的员工个人与实际驻店统计的人员数不一致
1 parent 4c9cd08c
......@@ -57,7 +57,7 @@ public class EmployeePerformanceDTO implements Serializable {
* 总产值(指标A036)
*/
@ApiModelProperty(notes = "总产值(指标A036)", example = "15000")
private Integer totalValue;
private BigDecimal totalValue;
/**
* 总产值环比
......
......@@ -79,4 +79,12 @@ public class RecordingQueryReq implements Serializable {
@ApiModelProperty(notes = "业务类型", example = "1", required = true)
private Integer biz;
/**
* 手机号
*/
@ApiModelProperty(value = "手机号", example = "12345678901")
private String phoneNumber;
}
\ No newline at end of file
......@@ -86,6 +86,14 @@
<artifactId>rpc-dj-mindworkplate-api</artifactId>
<version>5.6.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
</dependency>
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
</dependency>
</dependencies>
</project>
\ No newline at end of file
......@@ -71,7 +71,7 @@ public interface BusinessSceneMapper {
*/
List<RecordingItemDTO> getRecordingList(
@Param("merchantId") Integer merchantId,
@Param("uuid") String uuid,
@Param("phoneNumber") String phoneNumber,
@Param("biz") Integer biz,
@Param("startDate") String startDate,
@Param("endDate") String endDate
......
......@@ -166,20 +166,7 @@ public class SupervisorDashboardService {
metricMap.put(metric.getEmployeePhone(), metric);
}
}
// 关联指标数据到员工列表
for (EmployeeRanking employee : storeAndEmployeePhoneList) {
if (employee.getEmployeePhone() != null) {
EmployeeRanking metric = metricMap.get(employee.getEmployeePhone());
if (metric != null) {
// 设置指标数据
employee.setPersonalOutput(formatPercentage2(metric.getPersonalOutput()));
employee.setPersonalUnitPrice(formatPercentage2(metric.getPersonalUnitPrice()));
employee.setPersonalConversion(formatPercentage3(metric.getPersonalConversion()));
}
}
}
// 6. 查询预警基线配置
Map<String, List<SupervisorWarningBaselineConfig>> warningConfigMap = new HashMap<>();
if (!storeAndEmployeePhoneList.isEmpty()) {
......@@ -192,20 +179,33 @@ public class SupervisorDashboardService {
}
}
}
// 关联指标数据到员工列表
for (EmployeeRanking employee : storeAndEmployeePhoneList) {
if (employee.getEmployeePhone() != null) {
EmployeeRanking metric = metricMap.get(employee.getEmployeePhone());
if (metric != null) {
// 设置指标数据
employee.setPersonalOutput(formatPercentage2(metric.getPersonalOutput()));
employee.setPersonalUnitPrice(formatPercentage2(metric.getPersonalUnitPrice()));
employee.setPersonalConversion(formatPercentage3(metric.getPersonalConversion()));
}
}
}
// 7. 为每个员工设置预警等级
for (EmployeeRanking employee : storeAndEmployeePhoneList) {
// 匹配每个指标的预警等级
Integer conversionWarningLevel = matchWarningLevelByIndicator(employee.getPersonalConversion(), warningConfigMap.get("A085"));
Integer conversionWarningLevel = matchWarningLevelByIndicator(divideBy100AndRound(employee.getPersonalConversion()), warningConfigMap.get("A085"));
if (conversionWarningLevel != null) {
employee.setConversionWarningLevel(conversionWarningLevel);
}
Integer unitPriceWarningLevel = matchWarningLevelByIndicator(employee.getPersonalUnitPrice(), warningConfigMap.get("A076"));
if (unitPriceWarningLevel != null) {
employee.setUnitPriceWarningLevel(unitPriceWarningLevel);
}
Integer outputWarningLevel = matchWarningLevelByIndicator(employee.getPersonalOutput(), warningConfigMap.get("A036"));
if (outputWarningLevel != null) {
employee.setOutputWarningLevel(outputWarningLevel);
......@@ -258,6 +258,23 @@ public class SupervisorDashboardService {
return vo;
}
/**
* 将给定的值除以100,并保留两位小数。
* 如果输入为 null,返回 null。
*
* @param value 原始数值 (如 employee.getPersonalConversion())
* @return 计算后的结果,保留两位小数;若输入为 null 则返回 null
*/
public static BigDecimal divideBy100AndRound(BigDecimal value) {
if (value == null) {
return null;
}
// scale=2: 保留2位小数
// RoundingMode.HALF_UP: 四舍五入 (银行家舍入是 HALF_EVEN,通常业务用 HALF_UP)
return value.divide(BigDecimal.valueOf(100), 2, RoundingMode.HALF_UP);
}
private <T extends Comparable<? super T>>
Comparator<EmployeeRanking> buildComparator(
Function<EmployeeRanking, T> keyExtractor,
......@@ -303,7 +320,7 @@ public class SupervisorDashboardService {
employee.setDefeatCount(metric.getDefeatCount());
employee.setRecordingCount(metric.getRecordingCount());
employee.setLeadCount(metric.getLeadCount());
employee.setMissingRate(formatPercentage3(metric.getMissingRate()));
employee.setMissingRate(formatPercentage2(metric.getMissingRate()));
}
}
}
......@@ -1315,7 +1332,7 @@ public class SupervisorDashboardService {
// 处理门店数据
EmployeePerformanceDTO.StorePerformanceData storePerformanceData = new EmployeePerformanceDTO.StorePerformanceData();
// 总产值(指标A036)
storePerformanceData.setTotalValue(storeMetrics.get("A036") != null ? storeMetrics.get("A036").intValue() : 0);
storePerformanceData.setTotalValue(storeMetrics.get("A036"));
storePerformanceData.setTotalValueRate(formatPercentage(storeRates.get("A036"))); // 总产值环比
// 客单价(指标A076)
storePerformanceData.setAveragePrice(formatPercentage2(storeMetrics.get("A076")));
......@@ -1609,7 +1626,7 @@ public class SupervisorDashboardService {
// 从数据库查询录音列表
List<RecordingItemDTO> recordingList = businessSceneMapper.getRecordingList(
req.getMerchantId(),
req.getEmployeeId(), // 员工UUID
req.getPhoneNumber(), // 员工手机号
req.getBiz(), // 业务类型
req.getStartDate(), // 开始日期
req.getEndDate() // 结束日期
......@@ -1709,7 +1726,9 @@ public class SupervisorDashboardService {
}
for (SupervisorWarningBaselineConfig config : configs) {
log.info("匹配预警等级,指标值:{},配置:{}", value, config);
if (isInRange(value, config.getMinValue(), config.getMaxValue(), config.getMaxValueInf())) {
log.info("匹配成功,返回预警等级:{}", config.getWarningLevel());
return config.getWarningLevel();
}
}
......
......@@ -100,7 +100,7 @@ public class SupervisorWarningBaselineConfigService {
criteria.andEqualTo("indicatorCode", indicatorCode);
}
if (timeDimension != null) {
criteria.andEqualTo("timeDimension", timeDimension);
criteria.andEqualTo("timeDimension", timeDimension+1);
}
criteria.andEqualTo("deletedFlag", BaseModel.DeletedFlagEnum.N.name());
//根据更新时间降序
......
......@@ -14,11 +14,25 @@
<!-- 批次查询业务场景标签 -->
<select id="batchGetBusinessSceneByPhoneNumbers" parameterType="java.util.List" resultType="java.util.HashMap">
SELECT
si.phone_number as phoneNumber,
COALESCE(GROUP_CONCAT(DISTINCT CASE WHEN go.scene_type = 1 THEN '1' WHEN go.scene_type = 0 THEN CASE WHEN go.business_type = 1 THEN '2' WHEN go.business_type = 2 THEN '3' END END ORDER BY CASE WHEN go.scene_type = 1 THEN '1' WHEN go.scene_type = 0 AND go.business_type = 1 THEN '2' WHEN go.scene_type = 0 AND go.business_type = 2 THEN '3' END SEPARATOR ', '), '') AS businessScene
si.phone_number AS phoneNumber,
COALESCE(
GROUP_CONCAT(
DISTINCT
CASE
WHEN go.scene_type = 1 THEN '2' -- scene_type=1 -> 值2
WHEN go.scene_type = 0 AND go.business_type = 1 THEN '3' -- scene_type=0, biz_type=1 -> 值3
WHEN go.scene_type = 0 AND go.business_type = 2 THEN '1' -- scene_type=0, biz_type=2 -> 值1
ELSE NULL
END
SEPARATOR ','
),
''
) AS businessScene
FROM dj_car_life_staff_info si
LEFT JOIN dj_car_life_goods_order go ON si.staff_uuid = go.seller_user_id AND go.install_upgrade_time &gt;= DATE_SUB(CURDATE(), INTERVAL 30 DAY)
WHERE go.install_upgrade_time >= DATE_SUB(CURDATE(), INTERVAL 30 DAY) and si.phone_number IN
LEFT JOIN dj_car_life_goods_order go
ON si.staff_uuid = go.seller_user_id
-- 如果希望只统计有订单的员工,保留这行;如果想统计所有员工(含无订单的),请注释掉或删掉这行
WHERE go.install_upgrade_time >= DATE_SUB(CURDATE(), INTERVAL 30 DAY) and si.phone_number IN
<foreach collection="phoneNumbers" item="item" open="(" separator="," close=")">
#{item}
</foreach>
......@@ -59,49 +73,50 @@
<!-- 查询录音列表 -->
<select id="getRecordingList" parameterType="map" resultType="cn.com.glsx.dj.supervisor.dto.RecordingItemDTO">
SELECT
t1.merchant_id as merchantId,
t6.merchant_name as merchantName,
t1.customer_name as customerName,
t1.phone_number as phoneNumber,
t1.sales_uuid,
t1.sales_name,
t1.car_brand as carBrand,
t1.car_model as carModel,
t1.reception_start_time as receptionStartTime,
t1.reception_end_time as receptionEndTime,
t3.duration as recordingDuration,
t1.reception_status as receptionStatus,
t1.staff_uuid as staffUuid,
t2.recording_url as recordingUrl,
t1.car_purchase_method,
t2.check_History_Flag as checkHistoryFlag,
t3.id as batchId,
t3.score as score,
t2.id as recordingId,
t2.model_type as modelType,
t2.check_type as checkType,
CASE
WHEN EXISTS (
SELECT 1 FROM customer_order_temp t4
WHERE t4.phone = t1.phone_number
AND t4.scene_type = t1.bussiness_type - 1
AND t4.order_status IN (4,6)
) THEN true
ELSE false
END as orderFinishFlag,
t1.one_car_brand as oneCarBrand,
t5.avg_defence as gfScroe,
t5.customer_type as customerType,
t7.review_status as reviewStatus
FROM reception_customer_info t1
LEFT JOIN inspection_badge_recordings t2 ON t1.id = t2.reception_id
LEFT JOIN inspection_conversation_batch t3 ON t3.record_id=t2.id
SELECT
t1.merchant_id as merchantId,
t6.merchant_name as merchantName,
t1.customer_name as customerName,
t1.phone_number as phoneNumber,
t1.sales_uuid,
t1.sales_name,
t1.car_brand as carBrand,
t1.car_model as carModel,
t1.reception_start_time as receptionStartTime,
t1.reception_end_time as receptionEndTime,
t3.duration as recordingDuration,
t1.reception_status as receptionStatus,
t1.staff_uuid as staffUuid,
t2.recording_url as recordingUrl,
t1.car_purchase_method,
t2.check_History_Flag as checkHistoryFlag,
t3.id as batchId,
t3.score as score,
t2.id as recordingId,
t2.model_type as modelType,
t2.check_type as checkType,
CASE
WHEN EXISTS (
SELECT 1 FROM customer_order_temp t4
WHERE t4.phone = t1.phone_number
AND t4.scene_type = t1.bussiness_type - 1
AND t4.order_status IN (4,6)
) THEN true
ELSE false
END as orderFinishFlag,
t1.one_car_brand as oneCarBrand,
t5.avg_defence as gfScroe,
t5.customer_type as customerType,
t7.review_status as reviewStatus,
t8.phone_number
FROM reception_customer_info t1
LEFT JOIN inspection_badge_recordings t2 ON t1.id = t2.reception_id
LEFT JOIN inspection_conversation_batch t3 ON t3.record_id=t2.id
LEFT JOIN inspection_defence t5 ON (t3.id =t5.batch_id and t5.deleted_flag='N')
LEFT JOIN dj_car_life_service_merchant t6 ON t1.merchant_id=t6.merchant_id
left join excellent_case_review t7 on t2.id = t7.recording_id
WHERE t1.merchant_id = #{merchantId}
AND t1.staff_uuid = #{uuid}
left join dj_car_life_staff_info t8 on t1.staff_uuid =t8.staff_uuid
WHERE t8.phone_number = #{phoneNumber}
AND t1.bussiness_type = #{biz}
AND DATE(T1.reception_start_time) &gt;= #{startDate}
AND DATE(T1.reception_start_time) &lt;= #{endDate}
......
......@@ -113,6 +113,7 @@ public class SupervisorDashboardRemoteImplTest extends BaseServiceTest {
RecordingQueryReq req = new RecordingQueryReq();
req.setMerchantId(44211227);
req.setEmployeeId("584fdb460afa4dad835cbe8d73cfa923");
req.setPhoneNumber("18455784574");
req.setBiz(1);
req.setStartDate("2025-06-01");
req.setEndDate("2026-06-30");
......
  • @wangxw1
    commented
    Master

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

    1. SQL LEFT JOIN 失效导致数据漏查风险(功能正确性)

    • 位置:BusinessSceneMapper.xml -> batchGetBusinessSceneByPhoneNumbers
    • 问题描述:在进行 LEFT JOIN dj_car_life_goods_order go 后,在 WHERE 条件中使用了 go.install_upgrade_time >= DATE_SUB(CURDATE(), INTERVAL 30 DAY)。这会导致隐式的 INNER JOIN,即如果某位员工在近30天内没有订单,该员工的数据将被完全过滤掉,而不是按照 LEFT JOIN 的预期返回空场景标签。开发者在注释中也表现出了对此逻辑的疑虑。
    • 优化建议:若需保留所有传入的员工手机号(即使无订单),必须将右表的过滤条件移至 ON 子句中。 xml <!-- 修改建议 --> LEFT JOIN dj_car_life_goods_order go ON si.staff_uuid = go.seller_user_id AND go.install_upgrade_time >= DATE_SUB(CURDATE(), INTERVAL 30 DAY) WHERE si.phone_number IN ...

    2. 移除空值保护可能引发 NPE 或前端展示异常(健壮性)

    • 位置:SupervisorDashboardService.java 第 1335 行
    • 问题描述:代码由 storeMetrics.get("A036") != null ? storeMetrics.get("A036").intValue() : 0 修改为了直接 storeMetrics.get("A036")。虽然 DTO 中的类型改为了 BigDecimal 允许接收 null,但如果 Map 中不存在 A036,此处直接赋 null 可能会导致调用端(或前端)在进行金额计算或展示时出现 NullPointerException 或空白(通常金额默认应为 0)。
    • 优化建议:使用 getOrDefault 赋予默认值 BigDecimal.ZERO。 java // 修改建议 storePerformanceData.setTotalValue(storeMetrics.getOrDefault("A036", BigDecimal.ZERO));

    3. Maven 依赖重复引入(可维护性)

    • 位置:rpc-dj-supervisor/pom.xml 第 89-96 行
    • 问题描述:com.squareup.okhttp3:okhttp 依赖在 pom.xml 中被连续复制粘贴了两次。虽然 Maven 构建时会解决重复依赖,但这违反了代码整洁之道,且后续升级版本时极易引发“改了一个漏了另一个”的版本冲突问题。
    • 优化建议:删除多余的 <dependency> 声明。

    二、评分明细

    评审项 权重 得分 扣分原因/备注
    1. 功能正确性与健壮性 40分 25分 SQL LEFT JOIN 退化为 INNER JOIN 导致无单员工数据丢失(-10分);移除了总产值的默认值0,潜在空指针或展示异常风险(-5分)。
    2. 安全性与潜在风险 30分 30分 未发现明显安全漏洞,MyBatis 传参正确使用了 #{} 防止 SQL 注入。
    3. 最佳实践与可维护性 20分 17分 pom.xml 中出现重复依赖(-2分);timeDimension+1 存在魔法数字运算,缺乏注释说明(-1分)。
    4. 性能与资源利用 5分 4分 业务代码中多次循环匹配和赋值(如关联指标数据到员工列表),时间复杂度尚可,但 XML 中大范围的 GROUP_CONCAT 注意数据量膨胀(-1分)。
    5. 提交信息质量 5分 5分 Commit Message 详细说明了修复的三个具体业务 Bug(预警亮灯不一致、录音缺失率百分比异常、人员数不一致),便于追溯。

    总分:81分

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