|
@@ -293,6 +293,13 @@ public class MarketEmailsServiceImpl extends MyBaseServiceImpl<MarketEmailsMappe
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+ // 回填客户 AI 分析结果(一对一关联 customer_analysis_result,取最新一条)
|
|
|
|
|
+ Map<Long, CustomerAnalysisResultEntity> analysisMap = getLatestAnalysisMap(customerIdSet);
|
|
|
|
|
+ for (MarketEmailsOpenVO v : voList) {
|
|
|
|
|
+ if (v.getCustomerId() != null) {
|
|
|
|
|
+ v.setCustomerAnalysisResult(analysisMap.get(v.getCustomerId()));
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
} catch (Exception ex) {
|
|
} catch (Exception ex) {
|
|
|
log.warn("查询客户名称失败,customerIds={} err={}", customerIdSet, ex.getMessage());
|
|
log.warn("查询客户名称失败,customerIds={} err={}", customerIdSet, ex.getMessage());
|
|
|
}
|
|
}
|
|
@@ -707,22 +714,8 @@ public class MarketEmailsServiceImpl extends MyBaseServiceImpl<MarketEmailsMappe
|
|
|
if (c.getId() != null) customerMap.put(c.getId(), c);
|
|
if (c.getId() != null) customerMap.put(c.getId(), c);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- // 回填客户等级 / 核心标签(从 CustomerAnalysisResultEntity)
|
|
|
|
|
- // 一个 customer 可能有多个分析结果,取最新一条(id 最大)
|
|
|
|
|
- List<CustomerAnalysisResultEntity> analysisList =
|
|
|
|
|
- customerAnalysisResultEntityService.list(
|
|
|
|
|
- new LambdaQueryWrapper<CustomerAnalysisResultEntity>()
|
|
|
|
|
- .in(CustomerAnalysisResultEntity::getCustomerId, customerIdSet)
|
|
|
|
|
- .eq(CustomerAnalysisResultEntity::getIsDelete, CommonConstant.DEL_FLAG_0)
|
|
|
|
|
- .orderByDesc(CustomerAnalysisResultEntity::getId));
|
|
|
|
|
- Map<Long, CustomerAnalysisResultEntity> analysisMap = new HashMap<>();
|
|
|
|
|
- if (!CollectionUtils.isEmpty(analysisList)) {
|
|
|
|
|
- for (CustomerAnalysisResultEntity a : analysisList) {
|
|
|
|
|
- if (a.getCustomerId() != null && !analysisMap.containsKey(a.getCustomerId())) {
|
|
|
|
|
- analysisMap.put(a.getCustomerId(), a);
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ // 回填客户等级 / 核心标签(从 CustomerAnalysisResultEntity,一对一关联,取最新一条)
|
|
|
|
|
+ Map<Long, CustomerAnalysisResultEntity> analysisMap = getLatestAnalysisMap(customerIdSet);
|
|
|
for (MarketEmailsReplyVO v : voList) {
|
|
for (MarketEmailsReplyVO v : voList) {
|
|
|
CustomerEntity c = customerMap.get(v.getCustomerId());
|
|
CustomerEntity c = customerMap.get(v.getCustomerId());
|
|
|
if (c != null) {
|
|
if (c != null) {
|
|
@@ -854,6 +847,13 @@ public class MarketEmailsServiceImpl extends MyBaseServiceImpl<MarketEmailsMappe
|
|
|
v.setCustomerName(c.getCustomerName());
|
|
v.setCustomerName(c.getCustomerName());
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+ // 回填客户 AI 分析结果(一对一关联 customer_analysis_result,取最新一条)
|
|
|
|
|
+ Map<Long, CustomerAnalysisResultEntity> analysisMap = getLatestAnalysisMap(customerIdSet);
|
|
|
|
|
+ for (MarketEmailsProtectVO v : voList) {
|
|
|
|
|
+ if (v.getCustomerId() != null) {
|
|
|
|
|
+ v.setCustomerAnalysisResult(analysisMap.get(v.getCustomerId()));
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
} catch (Exception ex) {
|
|
} catch (Exception ex) {
|
|
|
log.warn("回填客户名失败,customerIds={} err={}", customerIdSet, ex.getMessage());
|
|
log.warn("回填客户名失败,customerIds={} err={}", customerIdSet, ex.getMessage());
|
|
|
}
|
|
}
|
|
@@ -862,6 +862,36 @@ public class MarketEmailsServiceImpl extends MyBaseServiceImpl<MarketEmailsMappe
|
|
|
return Result.ok(voList);
|
|
return Result.ok(voList);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 批量查询客户最新的 AI 分析结果(一对一关联 customer_analysis_result)。
|
|
|
|
|
+ * <p>
|
|
|
|
|
+ * 客户与 CustomerAnalysisResultEntity 理论上是一对一,但 DB 上可能因重算产生多条记录;
|
|
|
|
|
+ * 这里按 id DESC 取最新一条,避免重复计数。
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param customerIdSet 客户 id 集合(可为空)
|
|
|
|
|
+ * @return key = customerId,value = 最新一条 CustomerAnalysisResultEntity(无命中则为空 map)
|
|
|
|
|
+ */
|
|
|
|
|
+ private Map<Long, CustomerAnalysisResultEntity> getLatestAnalysisMap(Set<Long> customerIdSet) {
|
|
|
|
|
+ Map<Long, CustomerAnalysisResultEntity> analysisMap = new HashMap<>();
|
|
|
|
|
+ if (CollectionUtils.isEmpty(customerIdSet)) {
|
|
|
|
|
+ return analysisMap;
|
|
|
|
|
+ }
|
|
|
|
|
+ List<CustomerAnalysisResultEntity> analysisList =
|
|
|
|
|
+ customerAnalysisResultEntityService.list(
|
|
|
|
|
+ new LambdaQueryWrapper<CustomerAnalysisResultEntity>()
|
|
|
|
|
+ .in(CustomerAnalysisResultEntity::getCustomerId, customerIdSet)
|
|
|
|
|
+ .eq(CustomerAnalysisResultEntity::getIsDelete, CommonConstant.DEL_FLAG_0)
|
|
|
|
|
+ .orderByDesc(CustomerAnalysisResultEntity::getId));
|
|
|
|
|
+ if (!CollectionUtils.isEmpty(analysisList)) {
|
|
|
|
|
+ for (CustomerAnalysisResultEntity a : analysisList) {
|
|
|
|
|
+ if (a.getCustomerId() != null && !analysisMap.containsKey(a.getCustomerId())) {
|
|
|
|
|
+ analysisMap.put(a.getCustomerId(), a);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ return analysisMap;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 移除保护:按邮件主键 id 把 has_protect 置 0(保留 has_suspend)
|
|
* 移除保护:按邮件主键 id 把 has_protect 置 0(保留 has_suspend)
|
|
|
*/
|
|
*/
|