Commit ee23cf47 by 范富荣

Merge remote-tracking branch 'origin/main' into main

2 parents 526a5cd6 953c2871
......@@ -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. 业务逻辑与数据越权/性能风险(功能与安全)

    • 问题描述:将 req.setStaffUuids(...) 注释掉意味着下游查询或处理逻辑将丢失员工 UUID 的过滤条件。如果下游 SQL 或 RPC 接口未对 staffUuids 为空的情况做防御性编程,可能会导致:
      • 数据越权泄露:原本只查询特定员工的数据,现在变成了全量查询,导致用户看到不属于其权限范围的数据。
      • 性能灾难(OOM / 慢SQL):条件缺失可能引发数据库全表扫描,返回海量数据,导致内存溢出(OOM)或数据库 CPU 飙升。
    • 优化建议:需严格确认业务需求是否真的要求移除该过滤条件。如果是,请确保下游系统对 staffUuids 为 null/empty 的情况有正确的默认处理(如拦截或走特定的全量聚合逻辑);如果只是本地调试忘记恢复,请立即撤销该修改。

    2. 废弃代码残留,违反《阿里巴巴 Java 开发手册》(可维护性)

    • 问题描述:直接使用 // 注释掉无用代码而不删除。
    • 规范依据:《阿里巴巴 Java 开发手册》明确规定:“不在代码中使用注释掉的代码。如果无用,请直接删除。代码的演进历史应该由版本控制系统(Git/SVN)来维护,而不是用注释的形式保留。”
    • 优化建议:如果确认该业务逻辑已废弃,请直接删除该行代码;如果是暂时屏蔽,应在注释旁添加 TODO 及屏蔽原因和计划恢复的时间。

    3. 提交信息(Commit Message)缺乏背景说明(提交规范)

    • 问题描述:提交信息为“修改查询督导产值逻辑”,描述过于宽泛。它只说明了“做了什么(What)”,但没有说明“为什么这么做(Why)”。
    • 优化建议:对于改变核心查询条件(如移除员工过滤)的敏感操作,提交信息必须说明业务背景。例如:“修改查询督导产值逻辑:因XX业务调整,现需查询全量督导产值,故移除特定 staffUuids 的过滤条件”。

    二、评分明细

    • 1. 功能实现的正确性与健壮性(25/40分):移除关键过滤条件可能导致下游逻辑异常或非预期的全量查询,存在极大的逻辑隐患。
    • 2. 安全性与潜在风险(20/30分):缺失过滤条件可能引发水平越权(数据泄露)及慢查询/OOM(可用性风险)。
    • 3. 最佳实践与可维护性(15/20分):遗留注释代码(僵尸代码),直接违反了阿里规约和 Clean Code 原则。
    • 4. 性能与资源利用(3/5分):若引发全表扫描,将对数据库和应用内存造成不必要的资源消耗。
    • 5. 提交信息质量(3/5分):提交信息缺少必要的业务背景(Why),不利于后续的问题排查和代码回溯。

    总分:66分

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