Commit 2c292324 by zhouhaibao

[+]技师去重

1 parent 3b5953fd
...@@ -1819,6 +1819,16 @@ public class BusinessAnalysisService { ...@@ -1819,6 +1819,16 @@ public class BusinessAnalysisService {
Map<Integer, BigDecimal> quantifiedStaffMap, boolean isLuxury) { Map<Integer, BigDecimal> quantifiedStaffMap, boolean isLuxury) {
BigDecimal totalOutput = BigDecimal.ZERO; BigDecimal totalOutput = BigDecimal.ZERO;
BigDecimal totalStaffCount = 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) { for (StoreInfo store : stores) {
if (store.isLuxury() == isLuxury) { // 根据是否豪华店筛选 if (store.isLuxury() == isLuxury) { // 根据是否豪华店筛选
...@@ -1829,12 +1839,12 @@ public class BusinessAnalysisService { ...@@ -1829,12 +1839,12 @@ public class BusinessAnalysisService {
BigDecimal staffCount = quantifiedStaffMap.getOrDefault(store.getStoreId(), BigDecimal staffCount = quantifiedStaffMap.getOrDefault(store.getStoreId(),
BigDecimal.ZERO); BigDecimal.ZERO);
BigDecimal technicianCount = new BigDecimal(store.getTechnicianCount());
totalOutput = totalOutput.add(storeOutput); totalOutput = totalOutput.add(storeOutput);
totalStaffCount = totalStaffCount.add(staffCount).add(technicianCount); totalStaffCount = totalStaffCount.add(staffCount);
} }
} }
totalStaffCount.add(BigDecimal.valueOf(technicianCount));
MetricsResult result = new MetricsResult(); MetricsResult result = new MetricsResult();
if (totalStaffCount.compareTo(BigDecimal.ZERO) > 0) { if (totalStaffCount.compareTo(BigDecimal.ZERO) > 0) {
...@@ -1992,11 +2002,7 @@ public class BusinessAnalysisService { ...@@ -1992,11 +2002,7 @@ public class BusinessAnalysisService {
profit = integerBigDecimalMap.get(sceneType) == null ? BigDecimal.ZERO profit = integerBigDecimalMap.get(sceneType) == null ? BigDecimal.ZERO
: integerBigDecimalMap.get(sceneType); : integerBigDecimalMap.get(sceneType);
// 毛利率 = 毛利额 / 产值(避免除零) // 毛利率 = 毛利额 / 产值(避免除零)
BigDecimal margin = BigDecimal.ZERO; detail.setProfitMargin(calculatePercent(profit, sceneOutput));
if (sceneOutput.compareTo(BigDecimal.ZERO) > 0) {
margin = profit.divide(sceneOutput, 4, RoundingMode.HALF_UP);
}
detail.setProfitMargin(margin);
} }
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!