Commit db78ad4c by 谢海旭

v5.7.0版本 飞行督导:pc端督导管理查询逻辑调整

1 parent de9908f0
......@@ -368,20 +368,7 @@ public class SupervisorTaskInfoService {
}
}
// 4. 批量查询每个督导管理的门店数(GROUP BY director_phone)
List<SupervisorDirectorConfigDTO> supervisorDirectorConfigDTOS = supervisorTaskInfoMapper.queryDirectorConfigBySupervisorPhone(phoneList);
// supervisorDirectorConfigDTOS 按手机号分组
Map<String, List<SupervisorDirectorConfigDTO>> directorConfigMap = supervisorDirectorConfigDTOS.stream()
.collect(Collectors.groupingBy(SupervisorDirectorConfigDTO::getDirectorPhone));
List<SupervisorStoreManagerDTO> supervisorStoreManagerDTOList = supervisorTaskInfoMapper.queryStoreMangerUuidListBySupervisorPhone(phoneList);
Map<String, List<String>> supervisorMap = new HashMap<>();
if (supervisorStoreManagerDTOList != null) {
supervisorMap = supervisorStoreManagerDTOList.stream()
.collect(Collectors.groupingBy(SupervisorStoreManagerDTO::getSupervisorPhone, Collectors.mapping(SupervisorStoreManagerDTO::getStoreManagerUuid, Collectors.toList())));
}
// 5. 组装结果
// 5. 组装结果 - 遍历每个督导,调用 Dashboard 接口获取统计数据
List<SupervisorPageDTO> pageList = new ArrayList<>();
for (MerchantStaffResponse staff : staffList) {
......@@ -395,20 +382,38 @@ public class SupervisorTaskInfoService {
dto.setEntryDate(beisenDto.getEntryDate());
}
// 管理门店数 产值
List<SupervisorDirectorConfigDTO> directorConfigList = directorConfigMap.get(staff.getStaffPhone());
if (CollectionUtil.isNotEmpty(directorConfigList)) {
dto.setManagedStoreCount(directorConfigList.size());
dto.setOutputValue(getMerchantListMonthlyOutput(directorConfigList.stream().map(SupervisorDirectorConfigDTO::getMerchantId).collect(Collectors.toList())));
// 通过 Dashboard 接口获取团队人员数、管理门店数、产值
if (StringUtils.isNotBlank(staff.getUuid())) {
try {
DashboardQueryReq req = new DashboardQueryReq();
req.setSupervisorId(staff.getUuid());
req.setDateType(4); // 4-全部
req.setStartDate(DateUtil.beginOfMonth(new Date()).toDateStr());
req.setEndDate(DateUtil.endOfMonth(new Date()).toDateStr());
req.setNeedAiAnalysis(false);
SupervisorDashboardVO dashboardData = supervisorDashboardService.getDashboardData(req);
if (dashboardData != null && dashboardData.getMetrics() != null) {
DashboardMetrics metrics = dashboardData.getMetrics();
dto.setTeamStaffCount(metrics.getStaffCount() != null ? metrics.getStaffCount() : 0);
dto.setManagedStoreCount(metrics.getStoreCount() != null ? metrics.getStoreCount() : 0);
dto.setOutputValue(metrics.getTotalOutput() != null ? metrics.getTotalOutput() : java.math.BigDecimal.ZERO);
} else {
dto.setTeamStaffCount(0);
dto.setManagedStoreCount(0);
dto.setOutputValue(java.math.BigDecimal.ZERO);
}
} catch (Exception e) {
log.error("查询督导Dashboard数据失败,督导手机号:{},uuid:{}", staff.getStaffPhone(), staff.getUuid(), e);
dto.setTeamStaffCount(0);
dto.setManagedStoreCount(0);
dto.setOutputValue(java.math.BigDecimal.ZERO);
}
} else {
dto.setTeamStaffCount(0);
dto.setManagedStoreCount(0);
dto.setOutputValue(java.math.BigDecimal.ZERO);
}
// 团队人员总数(暂不实现,返回0)
List<String> storeManagerUuidList = supervisorMap.get(staff.getStaffPhone());
dto.setTeamStaffCount(storeManagerUuidList != null ? storeManagerUuidList.size() : 0);
pageList.add(dto);
}
......
......@@ -23,6 +23,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
......@@ -71,6 +72,9 @@ public class SupervisorTaskInfoServiceTest extends BaseServiceTest {
request.setMerchantId(43423334);
request.setMerchantName("萨达梵蒂冈");
request.setTaskContext("督导记录sdhnasuihfasifnasfnassjasidjkioasdasfn");
request.setUpdatedBy("xiehx");
request.setUpdatedPhone("13603070903");
request.setUpdatedDate(new Date());
ArrayList<SupervisorTaskCourse> taskCourseList = new ArrayList<>();
SupervisorTaskCourse course = new SupervisorTaskCourse();
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!