|
|
@@ -31,6 +31,7 @@ import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
import java.io.IOException;
|
|
|
import java.math.BigDecimal;
|
|
|
@@ -38,6 +39,7 @@ import java.math.RoundingMode;
|
|
|
import java.nio.file.Files;
|
|
|
import java.nio.file.Path;
|
|
|
import java.nio.file.Paths;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@@ -1526,4 +1528,72 @@ public class TaskStatisticsServiceImpl implements TaskStatisticsService {
|
|
|
return list;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 控制台 - 业务数据 -渠道明细导出
|
|
|
+ * @param taskStatisticsVo
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public HttpResult detailExport(TaskStatisticsVo taskStatisticsVo) {
|
|
|
+ if (StringUtils.isNotEmpty(taskStatisticsVo.getTreeType())) {
|
|
|
+ if ((StringUtils.isNotEmpty(taskStatisticsVo.getTreeUserId()) && "2".equals(taskStatisticsVo.getTreeType()))) {
|
|
|
+ List<String> userIds = this.getNextLevel(taskStatisticsVo.getTreeUserId());
|
|
|
+ if (!userIds.isEmpty() && userIds.get(0) != null) {
|
|
|
+ taskStatisticsVo.setUserIds(userIds);
|
|
|
+ } else {
|
|
|
+ taskStatisticsVo.setUserId(taskStatisticsVo.getTreeUserId());
|
|
|
+ }
|
|
|
+ } else if (StringUtils.isNotEmpty(taskStatisticsVo.getTreeUserId()) && "1".equals(taskStatisticsVo.getTreeType())) {
|
|
|
+ taskStatisticsVo.setDeptId(taskStatisticsVo.getTreeUserId());
|
|
|
+ taskStatisticsVo.setTreeUserId(null);
|
|
|
+ taskStatisticsVo.setUserIds(new ArrayList<>());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ PageVo<TaskStatisticsVo> pageVo = new PageVo<>();
|
|
|
+ Page<TaskStatisticsVo> page = new Page<>(taskStatisticsVo.getPageNum(), taskStatisticsVo.getPageSize());
|
|
|
+ page.setSearchCount(false).setOptimizeCountSql(false);//关闭count查询
|
|
|
+ pageVo.setPageNum(taskStatisticsVo.getPageNum());
|
|
|
+ pageVo.setPageSize(taskStatisticsVo.getPageSize());
|
|
|
+
|
|
|
+ HashMap<String, String> dateMapByType = getDateMapByTypeNew(taskStatisticsVo.getDateType(), taskStatisticsVo.getCreatetimeStart(), taskStatisticsVo.getCreatetimeEnd());
|
|
|
+ taskStatisticsVo.setCreatetimeStart(dateMapByType.get("startDate"));
|
|
|
+ taskStatisticsVo.setCreatetimeEnd(dateMapByType.get("endDate"));
|
|
|
+ getDateByType(taskStatisticsVo.getDateType(), taskStatisticsVo);
|
|
|
+
|
|
|
+ IPage<BusinessAgentData> list = this.taskStatisticsMapper.getBusinessAgentData(page, taskStatisticsVo);
|
|
|
+ List<BusinessAgentData> records = list.getRecords();
|
|
|
+ List<String> ids = records.stream()
|
|
|
+ .map(BusinessAgentData::getUserId) // 提取每个对象的id属性
|
|
|
+ .collect(Collectors.toList()); // 收集到新的List中
|
|
|
+ if(!CollectionUtils.isEmpty(taskStatisticsVo.getUserIds())){
|
|
|
+ ids.addAll(taskStatisticsVo.getUserIds());
|
|
|
+ }
|
|
|
+ taskStatisticsVo.setUserIds(ids);
|
|
|
+
|
|
|
+ List<ChannelDetailsExport> result = taskStatisticsMapper.getAgentDataDetails(taskStatisticsVo);
|
|
|
+ for (ChannelDetailsExport channelDetailsExport : result) {
|
|
|
+ BusinessAgentData businessAgentData = new BusinessAgentData();
|
|
|
+ businessAgentData.setDeptId(channelDetailsExport.getDeptId());
|
|
|
+ this.appendName(businessAgentData);
|
|
|
+ if (StringUtils.isNotEmpty(businessAgentData.getDeptName())) {
|
|
|
+ channelDetailsExport.setDeptName(businessAgentData.getDeptName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ String uploadPath = this.uploadPath + "/excel/";
|
|
|
+ Path path = Paths.get(uploadPath);
|
|
|
+ if (!Files.exists(path)) {
|
|
|
+ try {
|
|
|
+ Files.createDirectories(path);
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
+ String formattedDate = sdf.format(new Date());
|
|
|
+ String fileName = EasyExcelUtils.downExcel(uploadPath, "渠道业务数据明细导出"+formattedDate, ChannelDetailsExport.class, result);
|
|
|
+ return HttpResult.ok("", uploadUrl + "excel/" + fileName);
|
|
|
+ }
|
|
|
+
|
|
|
}
|