Commit 9a79d868 by zhouhaibao

[+]驻店员工逻辑调整

1 parent 4ef68d20
package cn.com.glsx.dj.supervisor.service; package cn.com.glsx.dj.supervisor.service;
import cn.com.glsx.dj.smartcarlife.dto.ShopMerchantDirectorConfigDTO; import cn.com.glsx.dj.smartcarlife.dto.ShopMerchantDirectorConfigDTO;
import cn.com.glsx.dj.smartcarlife.dto.merchantPerformanceConfig.StaffBaseInfoDTO;
import cn.com.glsx.dj.smartcarlife.enums.DirectorTypeEnum; import cn.com.glsx.dj.smartcarlife.enums.DirectorTypeEnum;
import cn.com.glsx.dj.smartcarlife.remote.ShopMerchantDirectorConfigRemote; import cn.com.glsx.dj.smartcarlife.remote.ShopMerchantDirectorConfigRemote;
import cn.com.glsx.dj.smartcarlife.remote.StaffBaseInfoRemote;
import cn.com.glsx.dj.supervisor.dto.DashboardMetrics; import cn.com.glsx.dj.supervisor.dto.DashboardMetrics;
import cn.com.glsx.dj.supervisor.dto.DashboardQueryReq; import cn.com.glsx.dj.supervisor.dto.DashboardQueryReq;
import cn.com.glsx.dj.supervisor.dto.EmployeeBasicInfoDTO;
import cn.com.glsx.dj.supervisor.dto.EmployeeBasicInfoReq;
import cn.com.glsx.dj.supervisor.dto.EmployeeBehaviorDTO;
import cn.com.glsx.dj.supervisor.dto.EmployeeBehaviorReq;
import cn.com.glsx.dj.supervisor.dto.EmployeePerformanceDTO;
import cn.com.glsx.dj.supervisor.dto.EmployeeRanking; import cn.com.glsx.dj.supervisor.dto.EmployeeRanking;
import cn.com.glsx.dj.supervisor.dto.RecordingItemDTO;
import cn.com.glsx.dj.supervisor.dto.RecordingListDTO;
import cn.com.glsx.dj.supervisor.dto.RecordingSummaryDTO;
import cn.com.glsx.dj.supervisor.dto.SupervisorDashboardVO; import cn.com.glsx.dj.supervisor.dto.SupervisorDashboardVO;
import cn.com.glsx.dj.supervisor.mapper.RecordingStatsMapper; import cn.com.glsx.dj.supervisor.mapper.RecordingStatsMapper;
import cn.com.glsx.dj.supervisor.model.BehaviorDataDTO; import cn.com.glsx.dj.supervisor.model.BehaviorDataDTO;
import cn.com.glsx.dj.supervisor.model.DataBusinessDTO; import cn.com.glsx.dj.supervisor.model.DataBusinessDTO;
import cn.com.glsx.dj.supervisor.model.DataResp; import cn.com.glsx.dj.supervisor.model.DataResp;
import cn.com.glsx.dj.supervisor.model.EmployeeMetricTemp; import cn.com.glsx.dj.supervisor.model.EmployeeMetricTemp;
import cn.com.glsx.dj.supervisor.model.SupervisorWarningBaselineConfig;
import cn.com.glsx.framework.core.beans.rpc.RpcResponse;
import cn.com.glsx.framework.core.exception.RpcServiceException;
import cn.com.glsx.framework.core.util.DateUtils; import cn.com.glsx.framework.core.util.DateUtils;
import cn.com.glsx.merchants.dto.beisen.BeisenEmployeeInfoDTO;
import cn.com.glsx.merchants.remote.MerchantUserRemote;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import java.util.Arrays; import java.util.Arrays;
import java.util.Date; import java.util.Comparator;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
...@@ -47,36 +62,29 @@ public class SupervisorDashboardService { ...@@ -47,36 +62,29 @@ public class SupervisorDashboardService {
private ShopMerchantDirectorConfigRemote shopMerchantDirectorConfigRemote; private ShopMerchantDirectorConfigRemote shopMerchantDirectorConfigRemote;
@Autowired @Autowired
private StaffBaseInfoRemote staffBaseInfoRemote;
@Autowired
private cn.com.glsx.dj.supervisor.mapper.BusinessSceneMapper businessSceneMapper; private cn.com.glsx.dj.supervisor.mapper.BusinessSceneMapper businessSceneMapper;
@Autowired @Autowired
private SupervisorWarningBaselineConfigService supervisorWarningBaselineConfigService; private SupervisorWarningBaselineConfigService supervisorWarningBaselineConfigService;
@Autowired @Autowired
private cn.com.glsx.merchants.remote.MerchantUserRemote merchantUserRemote; private MerchantUserRemote merchantUserRemote;
/** /**
* 获取督导首页数据 * 处理员工列表,包括获取业务场景标签
*
* @param employeeList 员工列表
* @return 业务场景标签映射
*/ */
public SupervisorDashboardVO getDashboardData(DashboardQueryReq req) { private Map<String, String> processEmployeeBusinessScene(List<EmployeeRanking> employeeList) {
// 批量获取驻店人员的业务场景标签
SupervisorDashboardVO vo = new SupervisorDashboardVO();
log.info("开始远程调用获取督导首页数据,请求参数:{}", req);
// 1.获取督导的管理门店以及门店的员工的手机号列表
Map<Integer, List<EmployeeRanking>> storeAndEmployeePhoneList = getSupervisorStoreAndEmployeePhoneList(
req.getSupervisorId(), req.getBizs());
if (storeAndEmployeePhoneList.isEmpty()) {
return vo;
}
// 2. 批量获取驻店人员的业务场景标签
List<String> allPhoneNumbers = new ArrayList<>(); List<String> allPhoneNumbers = new ArrayList<>();
for (List<EmployeeRanking> employeeList : storeAndEmployeePhoneList.values()) { for (EmployeeRanking employee : employeeList) {
for (EmployeeRanking employee : employeeList) { if (employee.getEmployeePhone() != null && !employee.getEmployeePhone().trim().isEmpty()) {
if (employee.getEmployeePhone() != null && !employee.getEmployeePhone().trim().isEmpty()) { allPhoneNumbers.add(employee.getEmployeePhone());
allPhoneNumbers.add(employee.getEmployeePhone());
}
} }
} }
...@@ -93,19 +101,72 @@ public class SupervisorDashboardService { ...@@ -93,19 +101,72 @@ public class SupervisorDashboardService {
} }
} }
List<Integer> collected = storeAndEmployeePhoneList.keySet().stream() // 为每个员工设置业务场景标签
.collect(Collectors.toList()); for (EmployeeRanking employee : employeeList) {
req.setMerchantIds( collected); if (employee.getEmployeePhone() != null) {
String sceneLabel = businessSceneMap.get(employee.getEmployeePhone());
if (sceneLabel != null) {
employee.setBussinessType(sceneLabel);
}
}
}
return businessSceneMap;
}
/**
* 获取督导首页数据
*/
public SupervisorDashboardVO getDashboardData(DashboardQueryReq req) {
SupervisorDashboardVO vo = new SupervisorDashboardVO();
// 1. 获取督导管理的门店列表
List<Integer> merchantIds = getSupervisorMerchants(req.getSupervisorId());
log.info("开始远程调用获取督导首页数据,请求参数:{}", req);
// 1.获取督导的管理门店以及门店的员工的手机号列表
List<EmployeeRanking> storeAndEmployeePhoneList = getSupervisorStoreAndEmployeePhoneList(
req.getSupervisorId(), merchantIds);
if (storeAndEmployeePhoneList.isEmpty()) {
return vo;
}
// 2. 处理员工业务场景标签
processEmployeeBusinessScene(storeAndEmployeePhoneList);
req.setMerchantIds(merchantIds);
// 4. 获取 BI 数据 // 4. 获取 BI 数据
// 根据维度调用不同的 BI 指标 ID (A036, A076, A085 等) // 根据维度调用不同的 BI 指标 ID (A036, A076, A085 等)
List<EmployeeRanking> rawEmployeeData = getDashboardMetrics(req); List<EmployeeRanking> rawEmployeeData = getDashboardMetrics(req);
// 5. 查询预警基线配置 // 5. 以 storeAndEmployeePhoneList 为基准,通过手机号关联设置员工的指标数据
Map<String, List<cn.com.glsx.dj.supervisor.model.SupervisorWarningBaselineConfig>> warningConfigMap = new HashMap<>(); Map<String, EmployeeRanking> metricMap = new HashMap<>();
if (!rawEmployeeData.isEmpty()) { for (EmployeeRanking metric : rawEmployeeData) {
if (metric.getEmployeePhone() != null) {
metricMap.put(metric.getEmployeePhone(), metric);
}
}
// 关联指标数据到员工列表
for (EmployeeRanking employee : storeAndEmployeePhoneList) {
if (employee.getEmployeePhone() != null) {
EmployeeRanking metric = metricMap.get(employee.getEmployeePhone());
if (metric != null) {
// 设置指标数据
employee.setPersonalOutput(metric.getPersonalOutput());
employee.setPersonalUnitPrice(metric.getPersonalUnitPrice());
employee.setPersonalConversion(metric.getPersonalConversion());
}
}
}
// 6. 查询预警基线配置
Map<String, List<SupervisorWarningBaselineConfig>> warningConfigMap = new HashMap<>();
if (!storeAndEmployeePhoneList.isEmpty()) {
List<String> indicatorCodes = Arrays.asList("A085", "A076", "A036"); List<String> indicatorCodes = Arrays.asList("A085", "A076", "A036");
for (String indicatorCode : indicatorCodes) { for (String indicatorCode : indicatorCodes) {
List<cn.com.glsx.dj.supervisor.model.SupervisorWarningBaselineConfig> configs = List<SupervisorWarningBaselineConfig> configs =
supervisorWarningBaselineConfigService.queryWarningBaselineConfig(indicatorCode, req.getDateType()); supervisorWarningBaselineConfigService.queryWarningBaselineConfig(indicatorCode, req.getDateType());
if (configs != null && !configs.isEmpty()) { if (configs != null && !configs.isEmpty()) {
warningConfigMap.put(indicatorCode, configs); warningConfigMap.put(indicatorCode, configs);
...@@ -113,15 +174,8 @@ public class SupervisorDashboardService { ...@@ -113,15 +174,8 @@ public class SupervisorDashboardService {
} }
} }
// 3. 为每个员工设置业务场景标签和预警等级 // 7. 为每个员工设置预警等级
for (EmployeeRanking employee : rawEmployeeData) { for (EmployeeRanking employee : storeAndEmployeePhoneList) {
if (employee.getEmployeePhone() != null) {
String sceneLabel = businessSceneMap.get(employee.getEmployeePhone());
if (sceneLabel != null) {
employee.setBussinessType(sceneLabel);
}
}
// 匹配每个指标的预警等级 // 匹配每个指标的预警等级
Integer conversionWarningLevel = matchWarningLevelByIndicator(employee.getPersonalConversion(), warningConfigMap.get("A085")); Integer conversionWarningLevel = matchWarningLevelByIndicator(employee.getPersonalConversion(), warningConfigMap.get("A085"));
if (conversionWarningLevel != null) { if (conversionWarningLevel != null) {
...@@ -140,79 +194,93 @@ public class SupervisorDashboardService { ...@@ -140,79 +194,93 @@ public class SupervisorDashboardService {
} }
// 3. 组装基础指标 // 3. 组装基础指标
DashboardMetrics metrics = aggregateMetrics(rawEmployeeData); DashboardMetrics metrics = aggregateMetrics(storeAndEmployeePhoneList);
metrics.setStoreCount(collected.size()); metrics.setStoreCount(merchantIds.size());
vo.setMetrics(metrics); vo.setMetrics(metrics);
vo.setEmployeeList(rawEmployeeData); // 前端可能需要做排序,或者这里排好序
// 4. 触发 AI 分析 // 4. 触发 AI 分析
if (!rawEmployeeData.isEmpty() && (req.getNeedAiAnalysis() == null || req.getNeedAiAnalysis())) { if (!storeAndEmployeePhoneList.isEmpty() && (req.getNeedAiAnalysis() == null || req.getNeedAiAnalysis())) {
// 此处为同步演示,使用开始时间-结束日期作为周期参数 // 此处为同步演示,使用开始时间-结束日期作为周期参数
String period = req.getStartDate() + "-" + req.getEndDate(); String period = req.getStartDate() + "-" + req.getEndDate();
String aiSuggestion = aiAnalysisService.generateSuggestion(req.getSupervisorId(), period, rawEmployeeData, req.getBizs()); String aiSuggestion = aiAnalysisService.generateSuggestion(req.getSupervisorId(), period, storeAndEmployeePhoneList, req.getBizs());
vo.setAiAnalysisSuggestion(aiSuggestion); vo.setAiAnalysisSuggestion(aiSuggestion);
} }
// 5. 员工排序
if (req.getSortField() != null) {
int sortField = req.getSortField();
int sortDirection = req.getSortDirection() != null ? req.getSortDirection() : 1; // 默认降序
storeAndEmployeePhoneList.sort((a, b) -> {
int compareResult = 0;
switch (sortField) {
case 1: // 产值
compareResult = a.getPersonalOutput().compareTo(b.getPersonalOutput());
break;
case 2: // 客单价
compareResult = a.getPersonalUnitPrice().compareTo(b.getPersonalUnitPrice());
break;
case 3: // 转化率
compareResult = a.getPersonalConversion().compareTo(b.getPersonalConversion());
break;
default: // 默认按产值
compareResult = a.getPersonalOutput().compareTo(b.getPersonalOutput());
break;
}
return sortDirection == 1 ? -compareResult : compareResult; // 降序时取反
});
} else {
// 默认按产值降序排序
storeAndEmployeePhoneList.sort((a, b) -> b.getPersonalOutput().compareTo(a.getPersonalOutput()));
}
vo.setEmployeeList(storeAndEmployeePhoneList);
return vo; return vo;
} }
public SupervisorDashboardVO getDashboardBehaviorData(DashboardQueryReq req) { public SupervisorDashboardVO getDashboardBehaviorData(DashboardQueryReq req) {
SupervisorDashboardVO vo = new SupervisorDashboardVO(); SupervisorDashboardVO vo = new SupervisorDashboardVO();
// 1. 获取管辖门店 // 1. 获取督导管理的门店列表
Map<Integer, List<EmployeeRanking>> storePhoneMap = getSupervisorStoreAndEmployeePhoneList(req.getSupervisorId(),req.getBizs()); List<Integer> merchantIds = getSupervisorMerchants(req.getSupervisorId());
req.setMerchantIds(merchantIds);
// 1. 获取管辖员工
List<EmployeeRanking> storePhoneMap = getSupervisorStoreAndEmployeePhoneList(
req.getSupervisorId(), merchantIds);
if (storePhoneMap.isEmpty()) return vo; if (storePhoneMap.isEmpty()) return vo;
List<Integer> collected = storePhoneMap.keySet().stream() // 2. 处理员工业务场景标签
.collect(Collectors.toList()); processEmployeeBusinessScene(storePhoneMap);
req.setMerchantIds( collected);
// 2. 批量获取驻店人员的业务场景标签 // 4. 获取行为数据 (多源合并)
List<String> allPhoneNumbers = new ArrayList<>(); List<EmployeeRanking> dataList = fetchBehaviorData(req);
for (List<EmployeeRanking> employeeList : storePhoneMap.values()) { Map<String, EmployeeRanking> metricMap = new HashMap<>();
for (EmployeeRanking employee : employeeList) { for (EmployeeRanking metric : dataList) {
if (employee.getEmployeePhone() != null && !employee.getEmployeePhone().trim().isEmpty()) { if (metric.getEmployeePhone() != null) {
allPhoneNumbers.add(employee.getEmployeePhone()); metricMap.put(metric.getEmployeePhone(), metric);
}
}
}
// 批量查询业务场景标签
Map<String, String> businessSceneMap = new HashMap<>();
if (!allPhoneNumbers.isEmpty()) {
List<Map<String, Object>> sceneList = businessSceneMapper.batchGetBusinessSceneByPhoneNumbers(allPhoneNumbers);
for (Map<String, Object> scene : sceneList) {
String phone = (String) scene.get("phoneNumber");
String businessScene = (String) scene.get("businessScene");
if (phone != null && businessScene != null) {
businessSceneMap.put(phone, businessScene);
}
} }
} }
// 3. 为每个员工设置业务场景标签 // 关联指标数据到员工列表
for (List<EmployeeRanking> employeeList : storePhoneMap.values()) { for (EmployeeRanking employee : storePhoneMap) {
for (EmployeeRanking employee : employeeList) { if (employee.getEmployeePhone() != null) {
if (employee.getEmployeePhone() != null) { EmployeeRanking metric = metricMap.get(employee.getEmployeePhone());
String sceneLabel = businessSceneMap.get(employee.getEmployeePhone()); if (metric != null) {
if (sceneLabel != null) { // 设置指标数据
employee.setBussinessType(sceneLabel); employee.setPersonalOutput(metric.getPersonalOutput());
} employee.setDealCount(metric.getDealCount());
employee.setDefeatCount(metric.getDefeatCount());
employee.setRecordingCount(metric.getRecordingCount());
employee.setLeadCount(metric.getLeadCount());
employee.setMissingRate(metric.getMissingRate());
} }
} }
} }
List<Integer> merchantIds = new ArrayList<>(storePhoneMap.keySet());
req.setMerchantIds(merchantIds);
// 4. 获取行为数据 (多源合并)
List<EmployeeRanking> dataList = fetchBehaviorData(req);
// 3. 聚合卡片数据 // 3. 聚合卡片数据
DashboardMetrics metrics = aggregateMetrics(dataList); DashboardMetrics metrics = aggregateMetrics(storePhoneMap);
metrics.setStoreCount(collected.size()); metrics.setStoreCount(merchantIds.size());
vo.setMetrics(metrics); vo.setMetrics(metrics);
vo.setEmployeeList(dataList);
// 4. 生成 AI 建议 (行为版) // 4. 生成 AI 建议 (行为版)
if (!dataList.isEmpty() && (req.getNeedAiAnalysis() == null || req.getNeedAiAnalysis())) { if (!dataList.isEmpty() && (req.getNeedAiAnalysis() == null || req.getNeedAiAnalysis())) {
...@@ -223,6 +291,44 @@ public class SupervisorDashboardService { ...@@ -223,6 +291,44 @@ public class SupervisorDashboardService {
vo.setAiAnalysisSuggestion("暂无行为数据生成建议。"); vo.setAiAnalysisSuggestion("暂无行为数据生成建议。");
} }
// 5. 员工排序
if (req.getSortField() != null) {
int sortField = req.getSortField();
int sortDirection = req.getSortDirection() != null ? req.getSortDirection() : 1; // 默认降序
storePhoneMap.sort((a, b) -> {
int compareResult = 0;
switch (sortField) {
case 1: // 产值
compareResult = a.getPersonalOutput().compareTo(b.getPersonalOutput());
break;
case 2: // 成交数
compareResult = a.getDealCount().compareTo(b.getDealCount());
break;
case 3: // 战败数
compareResult = a.getDefeatCount().compareTo(b.getDefeatCount());
break;
case 4: // 录音数
compareResult = a.getRecordingCount().compareTo(b.getRecordingCount());
break;
case 5: // 线索数
compareResult = a.getLeadCount().compareTo(b.getLeadCount());
break;
case 6: // 缺失率
compareResult = a.getMissingRate().compareTo(b.getMissingRate());
break;
default: // 成交数
compareResult = a.getDealCount().compareTo(b.getDealCount());
break;
}
return sortDirection == 1 ? -compareResult : compareResult; // 降序时取反
});
} else {
// 默认按产值降序排序
storePhoneMap.sort((a, b) -> b.getPersonalOutput().compareTo(a.getPersonalOutput()));
}
vo.setEmployeeList(storePhoneMap);
return vo; return vo;
} }
...@@ -373,69 +479,60 @@ public class SupervisorDashboardService { ...@@ -373,69 +479,60 @@ public class SupervisorDashboardService {
} }
/** /**
* 根据督导uuid获取门店及门店员工列表(30天内订单的员工) * 查询门店的员工列表
* *
* @param supervisorId 督导id * @param supervisorId 督导id
* @param bizs 业务类型 * @param merchantIds 商户号
* @return 门店及门店员工手机号列表 * @return 员工手机号列表
*/ */
public Map<Integer, List<EmployeeRanking>> getSupervisorStoreAndEmployeePhoneList(String supervisorId, public List<EmployeeRanking> getSupervisorStoreAndEmployeePhoneList(String supervisorId,
Integer bizs) { List<Integer> merchantIds) {
Map<Integer, List<EmployeeRanking>> result = new HashMap<>();
try { try {
// 计算近30天的开始和结束时间
Date endDate = DateUtils.addDate(new Date(), "day",-1);
Date startDate = DateUtils.addDate(new Date(), "day",-29); // 近30天
String startDateStr = DateUtils.formatDate(startDate, "yyyy-MM-dd");
String endDateStr = DateUtils.formatDate(endDate, "yyyy-MM-dd");
// 1. 获取督导管理的门店列表
List<Integer> merchantIds = getSupervisorMerchants(supervisorId);
if (merchantIds == null || merchantIds.isEmpty()) { if (merchantIds == null || merchantIds.isEmpty()) {
log.warn("督导 {} 没有管理的门店", supervisorId); log.warn("督导 {} 没有管理的门店", supervisorId);
return result; return new ArrayList<>();
} }
// 2. 批量从指标系统获取所有门店的员工 A036 数据 // 2. 获取门店的员工列表
DataBizQueryParamsDTO queryParams = new DataBizQueryParamsDTO(); StaffBaseInfoDTO staffParam = new StaffBaseInfoDTO();
queryParams.setBizs(bizs); staffParam.setMerchantIdList(merchantIds);
queryParams.setMerchantIds(merchantIds.stream().map(String::valueOf).collect(Collectors.joining(","))); // 批量传入所有门店ID RpcResponse<List<StaffBaseInfoDTO>> staffResponse = staffBaseInfoRemote.listShopStaffInfoGroupByUUid(staffParam);
queryParams.setItemCodes("A036"); // 个人产值
queryParams.setStartDate(startDateStr); if (staffResponse == null || !staffResponse.isSuccess() || staffResponse.getResult() == null || staffResponse.getResult().isEmpty()) {
queryParams.setEndDate(endDateStr); log.warn("获取门店员工列表失败,督导ID:{}", supervisorId);
queryParams.setExts("merchantId,staffId"); // 按门店和员工聚合 throw new RpcServiceException("获取门店员工列表失败");
}
String jsonBody = cn.hutool.json.JSONUtil.toJsonStr(queryParams); List<StaffBaseInfoDTO> staffList = staffResponse.getResult();
DataResp<List<DataBusinessDTO>> dataResp = getDataStatsService.getListDataResp(jsonBody);
// 3. 按照门店ID分组 // 3. 按照手机号去重,每个手机号只保留一个员工信息
if (dataResp != null && dataResp.getContent() != null && !dataResp.getContent().isEmpty()) { Map<String, StaffBaseInfoDTO> uniqueStaffMap = new HashMap<>();
for (DataBusinessDTO data : dataResp.getContent()) { for (StaffBaseInfoDTO staff : staffList) {
Integer merchantId = data.getMerchantId(); String phone = staff.getStaffPhone();
if (merchantId == null) { if (phone != null && !phone.isEmpty()) {
continue; uniqueStaffMap.put(phone, staff);
}
EmployeeRanking ranking = new EmployeeRanking();
ranking.setEmployeeId(data.getStaffId());
ranking.setEmployeeName(data.getStaffName());
ranking.setEmployeePhone(data.getStaffPhone());
ranking.setPersonalOutput(data.getItemValue()); // A036 个人产值
// 按门店分组
result.computeIfAbsent(merchantId, k -> new ArrayList<>()).add(ranking);
} }
} }
// 4. 按照门店分组,构建员工列表
List<EmployeeRanking> employeeList = new ArrayList<>();
for (StaffBaseInfoDTO staff : uniqueStaffMap.values()) {
EmployeeRanking ranking = new EmployeeRanking();
ranking.setEmployeeName(staff.getStaffName());
ranking.setEmployeePhone(staff.getStaffPhone());
employeeList.add(ranking);
}
return employeeList;
} catch (Exception e) { } catch (Exception e) {
log.error("getSupervisorStoreAndEmployeePhoneList error: {}", e); log.error("getSupervisorStoreAndEmployeePhoneList error: {}", e);
} }
return result; return new ArrayList<>();
} }
private List<Integer> getSupervisorMerchants(String supervisorId) { public List<Integer> getSupervisorMerchants(String supervisorId) {
List<ShopMerchantDirectorConfigDTO> list = shopMerchantDirectorConfigRemote.list(ShopMerchantDirectorConfigDTO.builder() List<ShopMerchantDirectorConfigDTO> list = shopMerchantDirectorConfigRemote.list(ShopMerchantDirectorConfigDTO.builder()
.directorTypes( .directorTypes(
Arrays.asList(DirectorTypeEnum.FLIGHT_SUPERVISION.getValue())) Arrays.asList(DirectorTypeEnum.FLIGHT_SUPERVISION.getValue()))
...@@ -701,7 +798,7 @@ public class SupervisorDashboardService { ...@@ -701,7 +798,7 @@ public class SupervisorDashboardService {
log.info("开始获取个人行为分析数据,请求参数:{}", req); log.info("开始获取个人行为分析数据,请求参数:{}", req);
// 构建个人行为分析数据 // 构建个人行为分析数据
cn.com.glsx.dj.supervisor.dto.EmployeeBehaviorDTO behaviorData = new cn.com.glsx.dj.supervisor.dto.EmployeeBehaviorDTO(); EmployeeBehaviorDTO behaviorData = new EmployeeBehaviorDTO();
// 获取考勤统计和着装预警数据 // 获取考勤统计和着装预警数据
Map<String, Object> attendanceData = businessSceneMapper.getAttendanceAndDressCodeData( Map<String, Object> attendanceData = businessSceneMapper.getAttendanceAndDressCodeData(
...@@ -711,7 +808,7 @@ public class SupervisorDashboardService { ...@@ -711,7 +808,7 @@ public class SupervisorDashboardService {
); );
// 考勤统计 // 考勤统计
cn.com.glsx.dj.supervisor.dto.EmployeeBehaviorDTO.AttendanceData attendance = new cn.com.glsx.dj.supervisor.dto.EmployeeBehaviorDTO.AttendanceData(); EmployeeBehaviorDTO.AttendanceData attendance = new EmployeeBehaviorDTO.AttendanceData();
attendance.setCheckInDays(getIntegerValue(attendanceData, "checkInDays")); // 打卡天数 attendance.setCheckInDays(getIntegerValue(attendanceData, "checkInDays")); // 打卡天数
attendance.setLate(getIntegerValue(attendanceData, "late")); // 迟到 attendance.setLate(getIntegerValue(attendanceData, "late")); // 迟到
attendance.setEarlyLeave(getIntegerValue(attendanceData, "earlyLeave")); // 早退 attendance.setEarlyLeave(getIntegerValue(attendanceData, "earlyLeave")); // 早退
...@@ -727,7 +824,7 @@ public class SupervisorDashboardService { ...@@ -727,7 +824,7 @@ public class SupervisorDashboardService {
req.getEndDate() req.getEndDate()
); );
cn.com.glsx.dj.supervisor.dto.EmployeeBehaviorDTO.DailyReportData dailyReport = new cn.com.glsx.dj.supervisor.dto.EmployeeBehaviorDTO.DailyReportData(); EmployeeBehaviorDTO.DailyReportData dailyReport = new EmployeeBehaviorDTO.DailyReportData();
int totalDays = getIntegerValue(dailyReportData, "totalDays"); int totalDays = getIntegerValue(dailyReportData, "totalDays");
int submitted = getIntegerValue(dailyReportData, "submitted"); int submitted = getIntegerValue(dailyReportData, "submitted");
int rest = getIntegerValue(dailyReportData, "rest"); int rest = getIntegerValue(dailyReportData, "rest");
...@@ -756,7 +853,7 @@ public class SupervisorDashboardService { ...@@ -756,7 +853,7 @@ public class SupervisorDashboardService {
req.getEndDate() req.getEndDate()
); );
cn.com.glsx.dj.supervisor.dto.EmployeeBehaviorDTO.CustomerReceptionData customerReception = new cn.com.glsx.dj.supervisor.dto.EmployeeBehaviorDTO.CustomerReceptionData(); EmployeeBehaviorDTO.CustomerReceptionData customerReception = new EmployeeBehaviorDTO.CustomerReceptionData();
customerReception.setActualDelivery(getIntegerValue(customerReceptionData, "deliveryCount")); // 实际交车数 customerReception.setActualDelivery(getIntegerValue(customerReceptionData, "deliveryCount")); // 实际交车数
customerReception.setReceptionCount(receptionCount); // 接待数量(指标A084) customerReception.setReceptionCount(receptionCount); // 接待数量(指标A084)
customerReception.setNotTouched(getIntegerValue(customerReceptionData, "notTouched")); // 未触客数 customerReception.setNotTouched(getIntegerValue(customerReceptionData, "notTouched")); // 未触客数
...@@ -772,7 +869,7 @@ public class SupervisorDashboardService { ...@@ -772,7 +869,7 @@ public class SupervisorDashboardService {
receptionCount receptionCount
); );
cn.com.glsx.dj.supervisor.dto.EmployeeBehaviorDTO.RecordingAnalysisData recordingAnalysis = new cn.com.glsx.dj.supervisor.dto.EmployeeBehaviorDTO.RecordingAnalysisData(); EmployeeBehaviorDTO.RecordingAnalysisData recordingAnalysis = new EmployeeBehaviorDTO.RecordingAnalysisData();
// 行为标签 // 行为标签
List<String> phones = new ArrayList<>(); List<String> phones = new ArrayList<>();
...@@ -802,7 +899,7 @@ public class SupervisorDashboardService { ...@@ -802,7 +899,7 @@ public class SupervisorDashboardService {
recordingAnalysis.setOhterList(ohterList); recordingAnalysis.setOhterList(ohterList);
// 量化指标 // 量化指标
cn.com.glsx.dj.supervisor.dto.EmployeeBehaviorDTO.QuantitativeIndicators quantitativeIndicators = new cn.com.glsx.dj.supervisor.dto.EmployeeBehaviorDTO.QuantitativeIndicators(); EmployeeBehaviorDTO.QuantitativeIndicators quantitativeIndicators = new EmployeeBehaviorDTO.QuantitativeIndicators();
quantitativeIndicators.setRecordingCount(getIntegerValue(recordingAnalysisData, "recordingCount")); // 录音 quantitativeIndicators.setRecordingCount(getIntegerValue(recordingAnalysisData, "recordingCount")); // 录音
quantitativeIndicators.setDealCount(getIntegerValue(recordingAnalysisData, "dealCount")); // 成交数 quantitativeIndicators.setDealCount(getIntegerValue(recordingAnalysisData, "dealCount")); // 成交数
quantitativeIndicators.setDefeatCount(getIntegerValue(recordingAnalysisData, "defeatCount")); // 战败数 quantitativeIndicators.setDefeatCount(getIntegerValue(recordingAnalysisData, "defeatCount")); // 战败数
...@@ -821,7 +918,7 @@ public class SupervisorDashboardService { ...@@ -821,7 +918,7 @@ public class SupervisorDashboardService {
behaviorData.setRecordingAnalysis(recordingAnalysis); behaviorData.setRecordingAnalysis(recordingAnalysis);
// 着装预警 // 着装预警
cn.com.glsx.dj.supervisor.dto.EmployeeBehaviorDTO.DressCodeWarningData dressCodeWarning = new cn.com.glsx.dj.supervisor.dto.EmployeeBehaviorDTO.DressCodeWarningData(); EmployeeBehaviorDTO.DressCodeWarningData dressCodeWarning = new EmployeeBehaviorDTO.DressCodeWarningData();
dressCodeWarning.setWarningCount(getIntegerValue(attendanceData, "warningCount")); // 预警次数 dressCodeWarning.setWarningCount(getIntegerValue(attendanceData, "warningCount")); // 预警次数
behaviorData.setDressCodeWarning(dressCodeWarning); behaviorData.setDressCodeWarning(dressCodeWarning);
...@@ -891,7 +988,7 @@ public class SupervisorDashboardService { ...@@ -891,7 +988,7 @@ public class SupervisorDashboardService {
* @param req 查询参数 * @param req 查询参数
* @return 人员基础信息 * @return 人员基础信息
*/ */
public cn.com.glsx.dj.supervisor.dto.EmployeeBasicInfoDTO getEmployeeDashboardData(cn.com.glsx.dj.supervisor.dto.EmployeeBasicInfoReq req) { public EmployeeBasicInfoDTO getEmployeeDashboardData(EmployeeBasicInfoReq req) {
log.info("开始获取人员基础信息,请求参数:{}", req); log.info("开始获取人员基础信息,请求参数:{}", req);
// 1. 使用请求中的手机号 // 1. 使用请求中的手机号
...@@ -903,24 +1000,24 @@ public class SupervisorDashboardService { ...@@ -903,24 +1000,24 @@ public class SupervisorDashboardService {
log.info("调用北森接口获取人员基本信息,手机号:{}", phoneNumber); log.info("调用北森接口获取人员基本信息,手机号:{}", phoneNumber);
java.util.List<String> phoneNumbers = new java.util.ArrayList<>(); java.util.List<String> phoneNumbers = new java.util.ArrayList<>();
phoneNumbers.add(phoneNumber); phoneNumbers.add(phoneNumber);
cn.com.glsx.framework.core.beans.rpc.RpcResponse<java.util.List<cn.com.glsx.merchants.dto.beisen.BeisenEmployeeInfoDTO>> beisenResponse = merchantUserRemote.selectByPhones(phoneNumbers); RpcResponse<List<BeisenEmployeeInfoDTO>> beisenResponse = merchantUserRemote.selectByPhones(phoneNumbers);
// 3. 构建人员基础信息 // 3. 构建人员基础信息
cn.com.glsx.dj.supervisor.dto.EmployeeBasicInfoDTO basicInfo = new cn.com.glsx.dj.supervisor.dto.EmployeeBasicInfoDTO(); cn.com.glsx.dj.supervisor.dto.EmployeeBasicInfoDTO basicInfo = new cn.com.glsx.dj.supervisor.dto.EmployeeBasicInfoDTO();
if (beisenResponse.isSuccess() && beisenResponse.getResult() != null && !beisenResponse.getResult().isEmpty()) { if (beisenResponse.isSuccess() && beisenResponse.getResult() != null && !beisenResponse.getResult().isEmpty()) {
cn.com.glsx.merchants.dto.beisen.BeisenEmployeeInfoDTO beisenInfo = beisenResponse.getResult().get(0); BeisenEmployeeInfoDTO beisenInfo = beisenResponse.getResult().get(0);
// 从北森信息中获取数据 // 从北森信息中获取数据
basicInfo.setName(beisenInfo.getName()); // 北森-人员-姓名 basicInfo.setName(beisenInfo.getName()); // 北森-人员-姓名
basicInfo.setPhone(beisenInfo.getMobilePhone()); // 北森-人员-手机号码 basicInfo.setPhone(beisenInfo.getMobilePhone()); // 北森-人员-手机号码
if (beisenInfo.getEntryDate() != null) { if (beisenInfo.getEntryDate() != null) {
basicInfo.setEntryDate( basicInfo.setEntryDate(
cn.com.glsx.framework.core.util.DateUtils.formatDate(beisenInfo.getEntryDate())); // 北森-人员-入职日期 DateUtils.formatDate(beisenInfo.getEntryDate())); // 北森-人员-入职日期
} }
// 年龄:按照生日计算 // 年龄:按照生日计算
if (beisenInfo.getBirthday() != null) { if (beisenInfo.getBirthday() != null) {
basicInfo.setBirthday(cn.com.glsx.framework.core.util.DateUtils.formatDate(beisenInfo.getBirthday())); // 北森-人员-生日 basicInfo.setBirthday(DateUtils.formatDate(beisenInfo.getBirthday())); // 北森-人员-生日
basicInfo.setAge(calculateAge(beisenInfo.getBirthday())); // 计算年龄 basicInfo.setAge(calculateAge(beisenInfo.getBirthday())); // 计算年龄
} }
...@@ -1083,11 +1180,11 @@ public class SupervisorDashboardService { ...@@ -1083,11 +1180,11 @@ public class SupervisorDashboardService {
* @param req 查询参数 * @param req 查询参数
* @return 个人业绩数据 * @return 个人业绩数据
*/ */
public cn.com.glsx.dj.supervisor.dto.EmployeePerformanceDTO getEmployeePerformanceData(cn.com.glsx.dj.supervisor.dto.EmployeePerformanceReq req) { public EmployeePerformanceDTO getEmployeePerformanceData(cn.com.glsx.dj.supervisor.dto.EmployeePerformanceReq req) {
log.info("开始获取个人业绩数据,请求参数:{}", req); log.info("开始获取个人业绩数据,请求参数:{}", req);
// 构建个人业绩数据 // 构建个人业绩数据
cn.com.glsx.dj.supervisor.dto.EmployeePerformanceDTO performanceData = new cn.com.glsx.dj.supervisor.dto.EmployeePerformanceDTO(); EmployeePerformanceDTO performanceData = new EmployeePerformanceDTO();
// 1. 获取门店数据(不传员工id) // 1. 获取门店数据(不传员工id)
// 一次请求所有指标,用逗号隔开 // 一次请求所有指标,用逗号隔开
...@@ -1114,7 +1211,7 @@ public class SupervisorDashboardService { ...@@ -1114,7 +1211,7 @@ public class SupervisorDashboardService {
} }
// 处理门店数据 // 处理门店数据
cn.com.glsx.dj.supervisor.dto.EmployeePerformanceDTO.StorePerformanceData storePerformanceData = new cn.com.glsx.dj.supervisor.dto.EmployeePerformanceDTO.StorePerformanceData(); EmployeePerformanceDTO.StorePerformanceData storePerformanceData = new EmployeePerformanceDTO.StorePerformanceData();
// 总产值(指标A036) // 总产值(指标A036)
storePerformanceData.setTotalValue(storeMetrics.get("A036") != null ? storeMetrics.get("A036").intValue() : 0); storePerformanceData.setTotalValue(storeMetrics.get("A036") != null ? storeMetrics.get("A036").intValue() : 0);
storePerformanceData.setTotalValueRate(storeRates.get("A036")); // 总产值环比 storePerformanceData.setTotalValueRate(storeRates.get("A036")); // 总产值环比
...@@ -1145,7 +1242,7 @@ public class SupervisorDashboardService { ...@@ -1145,7 +1242,7 @@ public class SupervisorDashboardService {
employeeQueryParams.setItemCodes(employeeItemCodes); // 多个指标编码,用逗号隔开 employeeQueryParams.setItemCodes(employeeItemCodes); // 多个指标编码,用逗号隔开
String employeeJsonBody = cn.hutool.json.JSONUtil.toJsonStr(employeeQueryParams); String employeeJsonBody = cn.hutool.json.JSONUtil.toJsonStr(employeeQueryParams);
cn.com.glsx.dj.supervisor.model.DataResp<java.util.List<cn.com.glsx.dj.supervisor.model.DataBusinessDTO>> employeeDataResp = getDataStatsService.getListDataResp(employeeJsonBody); DataResp<List<DataBusinessDTO>> employeeDataResp = getDataStatsService.getListDataResp(employeeJsonBody);
if (employeeDataResp != null && employeeDataResp.getContent() != null && !employeeDataResp.getContent().isEmpty()) { if (employeeDataResp != null && employeeDataResp.getContent() != null && !employeeDataResp.getContent().isEmpty()) {
for (cn.com.glsx.dj.supervisor.model.DataBusinessDTO employeeData : employeeDataResp.getContent()) { for (cn.com.glsx.dj.supervisor.model.DataBusinessDTO employeeData : employeeDataResp.getContent()) {
...@@ -1155,7 +1252,7 @@ public class SupervisorDashboardService { ...@@ -1155,7 +1252,7 @@ public class SupervisorDashboardService {
} }
// 处理人员数据 // 处理人员数据
cn.com.glsx.dj.supervisor.dto.EmployeePerformanceDTO.EmployeeData employeePerformanceData = new cn.com.glsx.dj.supervisor.dto.EmployeePerformanceDTO.EmployeeData(); EmployeePerformanceDTO.EmployeeData employeePerformanceData = new EmployeePerformanceDTO.EmployeeData();
employeePerformanceData.setTotalValue(employeeMetrics.get("A036") != null ? employeeMetrics.get("A036").intValue() : 0); employeePerformanceData.setTotalValue(employeeMetrics.get("A036") != null ? employeeMetrics.get("A036").intValue() : 0);
employeePerformanceData.setTotalValueRate(employeeRates.get("A036")); // 总产值环比 employeePerformanceData.setTotalValueRate(employeeRates.get("A036")); // 总产值环比
employeePerformanceData.setAveragePrice(employeeMetrics.get("A076") != null ? employeeMetrics.get("A076").doubleValue() : 0.0); employeePerformanceData.setAveragePrice(employeeMetrics.get("A076") != null ? employeeMetrics.get("A076").doubleValue() : 0.0);
...@@ -1209,13 +1306,13 @@ public class SupervisorDashboardService { ...@@ -1209,13 +1306,13 @@ public class SupervisorDashboardService {
// 售后成交数(指标A098) // 售后成交数(指标A098)
employeePerformanceData.setPostSaleDealCount(employeeMetrics.get("A098") != null ? employeeMetrics.get("A098").intValue() : 0); employeePerformanceData.setPostSaleDealCount(employeeMetrics.get("A098") != null ? employeeMetrics.get("A098").intValue() : 0);
// 日报填写率:从 getEmployeeBehaviorData 获取日报完成率 // 日报填写率:从 getEmployeeBehaviorData 获取日报完成率
cn.com.glsx.dj.supervisor.dto.EmployeeBehaviorReq behaviorReq = new cn.com.glsx.dj.supervisor.dto.EmployeeBehaviorReq(); EmployeeBehaviorReq behaviorReq = new EmployeeBehaviorReq();
behaviorReq.setEmployeeId(req.getEmployeeId()); behaviorReq.setEmployeeId(req.getEmployeeId());
behaviorReq.setMerchantId(req.getMerchantId()); behaviorReq.setMerchantId(req.getMerchantId());
behaviorReq.setBizs(req.getBizs()); behaviorReq.setBizs(req.getBizs());
behaviorReq.setStartDate(req.getStartDate()); behaviorReq.setStartDate(req.getStartDate());
behaviorReq.setEndDate(req.getEndDate()); behaviorReq.setEndDate(req.getEndDate());
cn.com.glsx.dj.supervisor.dto.EmployeeBehaviorDTO behaviorData = getEmployeeBehaviorData(behaviorReq); EmployeeBehaviorDTO behaviorData = getEmployeeBehaviorData(behaviorReq);
String dailyPerformanceRate = "0%"; String dailyPerformanceRate = "0%";
if (behaviorData != null && behaviorData.getDailyReport() != null) { if (behaviorData != null && behaviorData.getDailyReport() != null) {
dailyPerformanceRate = behaviorData.getDailyReport().getCompletionRate(); dailyPerformanceRate = behaviorData.getDailyReport().getCompletionRate();
...@@ -1234,13 +1331,13 @@ public class SupervisorDashboardService { ...@@ -1234,13 +1331,13 @@ public class SupervisorDashboardService {
trendQueryParams.setDateType(req.getDateType() != null ? req.getDateType() : 0); // 日期类型:0,按指定时段 trendQueryParams.setDateType(req.getDateType() != null ? req.getDateType() : 0); // 日期类型:0,按指定时段
String trendJsonBody = cn.hutool.json.JSONUtil.toJsonStr(trendQueryParams); String trendJsonBody = cn.hutool.json.JSONUtil.toJsonStr(trendQueryParams);
cn.com.glsx.dj.supervisor.model.DataResp<java.util.List<cn.com.glsx.dj.supervisor.model.DataBusinessDTO>> trendDataResp = getDataStatsService.getListDataResp(trendJsonBody); cn.com.glsx.dj.supervisor.model.DataResp<List<cn.com.glsx.dj.supervisor.model.DataBusinessDTO>> trendDataResp = getDataStatsService.getListDataResp(trendJsonBody);
// 处理产值趋势数据 // 处理产值趋势数据
java.util.List<cn.com.glsx.dj.supervisor.dto.EmployeePerformanceDTO.TrendData> trendData = new java.util.ArrayList<>(); List<cn.com.glsx.dj.supervisor.dto.EmployeePerformanceDTO.TrendData> trendData = new ArrayList<>();
if (trendDataResp != null && trendDataResp.getContent() != null && !trendDataResp.getContent().isEmpty()) { if (trendDataResp != null && trendDataResp.getContent() != null && !trendDataResp.getContent().isEmpty()) {
for (cn.com.glsx.dj.supervisor.model.DataBusinessDTO trendItem : trendDataResp.getContent()) { for (cn.com.glsx.dj.supervisor.model.DataBusinessDTO trendItem : trendDataResp.getContent()) {
cn.com.glsx.dj.supervisor.dto.EmployeePerformanceDTO.TrendData trend = new cn.com.glsx.dj.supervisor.dto.EmployeePerformanceDTO.TrendData(); EmployeePerformanceDTO.TrendData trend = new EmployeePerformanceDTO.TrendData();
trend.setDate(trendItem.getStartDate()); // 日期 trend.setDate(trendItem.getStartDate()); // 日期
trend.setValue(trendItem.getItemValue() != null ? trendItem.getItemValue().intValue() : 0); // 产值 trend.setValue(trendItem.getItemValue() != null ? trendItem.getItemValue().intValue() : 0); // 产值
trendData.add(trend); trendData.add(trend);
...@@ -1261,10 +1358,10 @@ public class SupervisorDashboardService { ...@@ -1261,10 +1358,10 @@ public class SupervisorDashboardService {
* @param req 查询参数 * @param req 查询参数
* @return 员工调店记录列表 * @return 员工调店记录列表
*/ */
public java.util.List<cn.com.glsx.dj.supervisor.dto.EmployeeStoreTransferDTO> getEmployeeStoreTransferRecords(cn.com.glsx.dj.supervisor.dto.EmployeeStoreTransferReq req) { public List<cn.com.glsx.dj.supervisor.dto.EmployeeStoreTransferDTO> getEmployeeStoreTransferRecords(cn.com.glsx.dj.supervisor.dto.EmployeeStoreTransferReq req) {
log.info("开始获取员工调店记录,请求参数:{}", req); log.info("开始获取员工调店记录,请求参数:{}", req);
java.util.List<cn.com.glsx.dj.supervisor.dto.EmployeeStoreTransferDTO> transferRecords = businessSceneMapper.getEmployeeStoreTransferRecords( List<cn.com.glsx.dj.supervisor.dto.EmployeeStoreTransferDTO> transferRecords = businessSceneMapper.getEmployeeStoreTransferRecords(
req.getPhoneNumber(), req.getPhoneNumber(),
req.getMerchantIds(), req.getMerchantIds(),
req.getBizs() req.getBizs()
...@@ -1284,11 +1381,11 @@ public class SupervisorDashboardService { ...@@ -1284,11 +1381,11 @@ public class SupervisorDashboardService {
* @param req 查询参数 * @param req 查询参数
* @return 录音列表数据 * @return 录音列表数据
*/ */
public cn.com.glsx.dj.supervisor.dto.RecordingListDTO getRecordingList(cn.com.glsx.dj.supervisor.dto.RecordingQueryReq req) { public RecordingListDTO getRecordingList(cn.com.glsx.dj.supervisor.dto.RecordingQueryReq req) {
log.info("开始获取录音列表,请求参数:{}", req); log.info("开始获取录音列表,请求参数:{}", req);
// 从数据库查询录音列表 // 从数据库查询录音列表
java.util.List<cn.com.glsx.dj.supervisor.dto.RecordingItemDTO> recordingList = businessSceneMapper.getRecordingList( List<cn.com.glsx.dj.supervisor.dto.RecordingItemDTO> recordingList = businessSceneMapper.getRecordingList(
req.getMerchantId(), req.getMerchantId(),
req.getEmployeeId(), // 员工UUID req.getEmployeeId(), // 员工UUID
req.getBiz(), // 业务类型 req.getBiz(), // 业务类型
...@@ -1302,7 +1399,7 @@ public class SupervisorDashboardService { ...@@ -1302,7 +1399,7 @@ public class SupervisorDashboardService {
int defeatCount = 0; int defeatCount = 0;
// 按日期分组统计 // 按日期分组统计
java.util.Map<String, cn.com.glsx.dj.supervisor.dto.RecordingSummaryDTO> dateSummaryMap = new java.util.HashMap<>(); Map<String,RecordingSummaryDTO> dateSummaryMap = new HashMap<>();
for (cn.com.glsx.dj.supervisor.dto.RecordingItemDTO item : recordingList) { for (cn.com.glsx.dj.supervisor.dto.RecordingItemDTO item : recordingList) {
// 设置接待结果 // 设置接待结果
...@@ -1328,9 +1425,9 @@ public class SupervisorDashboardService { ...@@ -1328,9 +1425,9 @@ public class SupervisorDashboardService {
// 按日期分组统计 // 按日期分组统计
if (item.getReceptionStartTime() != null) { if (item.getReceptionStartTime() != null) {
String dateStr = cn.com.glsx.framework.core.util.DateUtils.formatDate(item.getReceptionStartTime(), "yyyy-MM-dd"); String dateStr = cn.com.glsx.framework.core.util.DateUtils.formatDate(item.getReceptionStartTime(), "yyyy-MM-dd");
cn.com.glsx.dj.supervisor.dto.RecordingSummaryDTO dateSummary = dateSummaryMap.get(dateStr); RecordingSummaryDTO dateSummary = dateSummaryMap.get(dateStr);
if (dateSummary == null) { if (dateSummary == null) {
dateSummary = new cn.com.glsx.dj.supervisor.dto.RecordingSummaryDTO(); dateSummary = new RecordingSummaryDTO();
dateSummary.setDate(dateStr); dateSummary.setDate(dateStr);
dateSummary.setTotalRecordings(0); dateSummary.setTotalRecordings(0);
dateSummary.setDealCount(0); dateSummary.setDealCount(0);
...@@ -1347,29 +1444,29 @@ public class SupervisorDashboardService { ...@@ -1347,29 +1444,29 @@ public class SupervisorDashboardService {
} }
// 构建录音摘要 // 构建录音摘要
cn.com.glsx.dj.supervisor.dto.RecordingSummaryDTO summary = new cn.com.glsx.dj.supervisor.dto.RecordingSummaryDTO(); RecordingSummaryDTO summary = new RecordingSummaryDTO();
summary.setDate(req.getDate() != null ? req.getDate() : req.getStartDate()); summary.setDate(req.getDate() != null ? req.getDate() : req.getStartDate());
summary.setTotalRecordings(totalRecordings); summary.setTotalRecordings(totalRecordings);
summary.setDealCount(dealCount); summary.setDealCount(dealCount);
summary.setDefeatCount(defeatCount); summary.setDefeatCount(defeatCount);
// 构建按日期分组的摘要列表 // 构建按日期分组的摘要列表
java.util.List<cn.com.glsx.dj.supervisor.dto.RecordingSummaryDTO> dateSummaryList = new java.util.ArrayList<>(dateSummaryMap.values()); List<RecordingSummaryDTO> dateSummaryList = new ArrayList<>(dateSummaryMap.values());
// 按日期排序 // 按日期排序
dateSummaryList.sort(java.util.Comparator.comparing(cn.com.glsx.dj.supervisor.dto.RecordingSummaryDTO::getDate)); dateSummaryList.sort(Comparator.comparing(RecordingSummaryDTO::getDate));
// 分页处理 // 分页处理
int pageNum = req.getPageNum() != null ? req.getPageNum() : 1; int pageNum = req.getPageNum() != null ? req.getPageNum() : 1;
int pageSize = req.getPageSize() != null ? req.getPageSize() : 10; int pageSize = req.getPageSize() != null ? req.getPageSize() : 10;
int startIndex = (pageNum - 1) * pageSize; int startIndex = (pageNum - 1) * pageSize;
int endIndex = Math.min(startIndex + pageSize, recordingList.size()); int endIndex = Math.min(startIndex + pageSize, recordingList.size());
java.util.List<cn.com.glsx.dj.supervisor.dto.RecordingItemDTO> pagedRecordingList = new java.util.ArrayList<>(); List<RecordingItemDTO> pagedRecordingList = new ArrayList<>();
if (startIndex < recordingList.size()) { if (startIndex < recordingList.size()) {
pagedRecordingList = recordingList.subList(startIndex, endIndex); pagedRecordingList = recordingList.subList(startIndex, endIndex);
} }
// 构建返回数据 // 构建返回数据
cn.com.glsx.dj.supervisor.dto.RecordingListDTO result = new cn.com.glsx.dj.supervisor.dto.RecordingListDTO(); RecordingListDTO result = new RecordingListDTO();
result.setSummary(summary); result.setSummary(summary);
result.setRecordingList(pagedRecordingList); result.setRecordingList(pagedRecordingList);
result.setTotalCount(totalRecordings); result.setTotalCount(totalRecordings);
...@@ -1389,12 +1486,12 @@ public class SupervisorDashboardService { ...@@ -1389,12 +1486,12 @@ public class SupervisorDashboardService {
* @return 预警等级:0-红,1-黄,2-绿 * @return 预警等级:0-红,1-黄,2-绿
*/ */
private Integer matchWarningLevelByIndicator(BigDecimal value, private Integer matchWarningLevelByIndicator(BigDecimal value,
List<cn.com.glsx.dj.supervisor.model.SupervisorWarningBaselineConfig> configs) { List<SupervisorWarningBaselineConfig> configs) {
if (value == null || configs == null || configs.isEmpty()) { if (value == null || configs == null || configs.isEmpty()) {
return 2; // 默认绿色 return 2; // 默认绿色
} }
for (cn.com.glsx.dj.supervisor.model.SupervisorWarningBaselineConfig config : configs) { for (SupervisorWarningBaselineConfig config : configs) {
if (isInRange(value, config.getMinValue(), config.getMaxValue(), config.getMaxValueInf())) { if (isInRange(value, config.getMinValue(), config.getMaxValue(), config.getMaxValueInf())) {
return config.getWarningLevel(); return config.getWarningLevel();
} }
......
...@@ -54,16 +54,17 @@ public class SupervisorEmployeeTrainingInfoService { ...@@ -54,16 +54,17 @@ public class SupervisorEmployeeTrainingInfoService {
} }
// 2、根据督导uuid和业务类型,获取督导下所有门店及员工信息 // 2、根据督导uuid和业务类型,获取督导下所有门店及员工信息
Map<Integer, List<EmployeeRanking>> storeEmployeeMap = List<Integer> merchantIds = supervisorDashboardService.getSupervisorMerchants(supervisorUUID);
supervisorDashboardService.getSupervisorStoreAndEmployeePhoneList(supervisorUUID, request.getBusinessType());
if (CollectionUtils.isEmpty(storeEmployeeMap)) { List<EmployeeRanking> supervisorStoreAndEmployeePhoneList = supervisorDashboardService.getSupervisorStoreAndEmployeePhoneList(
supervisorUUID, merchantIds);
if (CollectionUtils.isEmpty(supervisorStoreAndEmployeePhoneList)) {
log.warn("督导下没有员工信息,supervisorPhone={}", request.getSupervisorPhone()); log.warn("督导下没有员工信息,supervisorPhone={}", request.getSupervisorPhone());
return new ArrayList<>(); return new ArrayList<>();
} }
// 3、提取全部员工手机号(去重) // 3、提取全部员工手机号(去重)
List<String> phoneList = storeEmployeeMap.values().stream() List<String> phoneList = supervisorStoreAndEmployeePhoneList.stream()
.flatMap(List::stream)
.map(EmployeeRanking::getEmployeePhone) .map(EmployeeRanking::getEmployeePhone)
.filter(phone -> phone != null && !phone.isEmpty()) .filter(phone -> phone != null && !phone.isEmpty())
.distinct() .distinct()
......
...@@ -21,7 +21,6 @@ public class SupervisorDashboardServiceTest extends BaseServiceTest { ...@@ -21,7 +21,6 @@ public class SupervisorDashboardServiceTest extends BaseServiceTest {
@Test @Test
public void testGetSupervisorStoreAndEmployeePhoneList() { public void testGetSupervisorStoreAndEmployeePhoneList() {
Map<Integer, List<EmployeeRanking>> employeePhoneList = supervisorDashboardService.getSupervisorStoreAndEmployeePhoneList("63c121922cba4956b2aac3f21dacd92f", null); supervisorDashboardService.getSupervisorStoreAndEmployeePhoneList("63c121922cba4956b2aac3f21dacd92f", null);
TestCase.assertNotNull(employeePhoneList);
} }
} }
\ No newline at end of file \ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!