|
@@ -1,21 +1,19 @@
|
|
package com.qunzhixinxi.hnqz.admin.service.impl;
|
|
package com.qunzhixinxi.hnqz.admin.service.impl;
|
|
|
|
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
-import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
|
|
|
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
-import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.qunzhixinxi.hnqz.admin.entity.*;
|
|
import com.qunzhixinxi.hnqz.admin.entity.*;
|
|
-import com.qunzhixinxi.hnqz.admin.enums.TenantStatus;
|
|
|
|
-import com.qunzhixinxi.hnqz.admin.service.*;
|
|
|
|
|
|
+import com.qunzhixinxi.hnqz.admin.service.SysFileService;
|
|
|
|
+import com.qunzhixinxi.hnqz.admin.service.WmDaCustomerService;
|
|
|
|
+import com.qunzhixinxi.hnqz.admin.service.WmDaCustomerStatisticsService;
|
|
import com.qunzhixinxi.hnqz.admin.util.OsEnvUtils;
|
|
import com.qunzhixinxi.hnqz.admin.util.OsEnvUtils;
|
|
import com.qunzhixinxi.hnqz.common.core.util.R;
|
|
import com.qunzhixinxi.hnqz.common.core.util.R;
|
|
import lombok.AllArgsConstructor;
|
|
import lombok.AllArgsConstructor;
|
|
import net.fenghaitao.AutoExcel;
|
|
import net.fenghaitao.AutoExcel;
|
|
import net.fenghaitao.parameters.TemplateExportPara;
|
|
import net.fenghaitao.parameters.TemplateExportPara;
|
|
import org.apache.commons.io.IOUtils;
|
|
import org.apache.commons.io.IOUtils;
|
|
-import org.apache.poi.ss.usermodel.*;
|
|
|
|
|
|
+import org.apache.poi.ss.usermodel.Workbook;
|
|
import org.springframework.mock.web.MockMultipartFile;
|
|
import org.springframework.mock.web.MockMultipartFile;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
@@ -50,75 +48,8 @@ public class WmDaCustomerStatisticsServiceImpl implements WmDaCustomerStatistics
|
|
|
|
|
|
private final WmDaCustomerService wmDaCustomerService;
|
|
private final WmDaCustomerService wmDaCustomerService;
|
|
|
|
|
|
- private final WmDeptGmvRecordService wmDeptGmvRecordService;
|
|
|
|
-
|
|
|
|
- private final WmDeptGmvService wmDeptGmvService;
|
|
|
|
-
|
|
|
|
private final SysFileService sysFileService;
|
|
private final SysFileService sysFileService;
|
|
|
|
|
|
- /**
|
|
|
|
- * 查询当月销售列表
|
|
|
|
- *
|
|
|
|
- * @param page
|
|
|
|
- * @param queryWrapper
|
|
|
|
- * @return
|
|
|
|
- */
|
|
|
|
-// @Override
|
|
|
|
-// public IPage<WmDaCustomer> listCurrentMonthStatisticsPage(Page page, Wrapper<WmDaCustomer> queryWrapper) {
|
|
|
|
-// LambdaQueryWrapper<WmDaCustomer> query = (LambdaQueryWrapper<WmDaCustomer>) queryWrapper;
|
|
|
|
-// // 已上线的客户
|
|
|
|
-// query.eq(WmDaCustomer::getCustomerStatus, TenantStatus.GOING_ONLINE);
|
|
|
|
-// // 部门id不为空
|
|
|
|
-// query.isNotNull(WmDaCustomer::getDeptId);
|
|
|
|
-// IPage<WmDaCustomer> pageResult = wmDaCustomerService.page(page, queryWrapper);
|
|
|
|
-// List<WmDaCustomer> records = pageResult.getRecords();
|
|
|
|
-// // 当前年月和上一日
|
|
|
|
-// String year = String.valueOf(LocalDate.now().getYear());
|
|
|
|
-// String month = String.valueOf(LocalDate.now().getMonthValue());
|
|
|
|
-// String day = String.valueOf(LocalDate.now().getDayOfMonth() - 1);
|
|
|
|
-//
|
|
|
|
-// records.forEach(wmDaCustomer -> {
|
|
|
|
-// WmDeptGmv deptGmv = wmDeptGmvService.getOne(Wrappers.<WmDeptGmv>lambdaQuery()
|
|
|
|
-// .eq(WmDeptGmv::getDeptId, wmDaCustomer.getDeptId())
|
|
|
|
-// .eq(WmDeptGmv::getYear, year)
|
|
|
|
-// .eq(WmDeptGmv::getMonth, month));
|
|
|
|
-// WmDeptGmvRecord wmDeptGmvRecord = null;
|
|
|
|
-// if (deptGmv != null) {
|
|
|
|
-// wmDeptGmvRecord = wmDeptGmvRecordService.getOne(Wrappers.<WmDeptGmvRecord>lambdaQuery()
|
|
|
|
-// .eq(WmDeptGmvRecord::getGmvId, deptGmv.getId())
|
|
|
|
-// .eq(WmDeptGmvRecord::getStatisticsDay, day));
|
|
|
|
-// }
|
|
|
|
-// // 加入业绩统计数据
|
|
|
|
-// WmDaCustomerStatistics customerStatistics = new WmDaCustomerStatistics();
|
|
|
|
-// if (wmDeptGmvRecord != null) {
|
|
|
|
-// customerStatistics.setGmv1(wmDeptGmvRecord.getGmv1());
|
|
|
|
-// customerStatistics.setGmv2(new BigDecimal(wmDeptGmvRecord.getGmv2() * 1.0 / 100)
|
|
|
|
-// .setScale(2, BigDecimal.ROUND_HALF_UP));
|
|
|
|
-// customerStatistics.setIncome(new BigDecimal(wmDeptGmvRecord.getIncome() * 1.0 / 100)
|
|
|
|
-// .setScale(2, BigDecimal.ROUND_HALF_UP));
|
|
|
|
-// } else {
|
|
|
|
-// customerStatistics.setGmv1(0L);
|
|
|
|
-// customerStatistics.setGmv2(new BigDecimal("0.00"));
|
|
|
|
-// customerStatistics.setIncome(new BigDecimal("0.00"));
|
|
|
|
-// }
|
|
|
|
-// Map<String, WmDaCustomerStatistics> entRes = new HashMap<>(1);
|
|
|
|
-// entRes.put(month, customerStatistics);
|
|
|
|
-// wmDaCustomer.setMultiGMVStatistics(entRes);
|
|
|
|
-// wmDaCustomer.setDeptGmvList(null);
|
|
|
|
-// }
|
|
|
|
-// );
|
|
|
|
-//
|
|
|
|
-// List<WmDaCustomer> temp = records.stream().sorted((o1, o2) -> {
|
|
|
|
-// Map<String, WmDaCustomerStatistics> o1Map = o1.getMultiGMVStatistics();
|
|
|
|
-// BigDecimal bd1 = o1Map.get(month).getIncome();
|
|
|
|
-// Map<String, WmDaCustomerStatistics> o2Map = o2.getMultiGMVStatistics();
|
|
|
|
-// BigDecimal bd2 = o2Map.get(month).getIncome();
|
|
|
|
-// return bd2.compareTo(bd1);
|
|
|
|
-// }).collect(Collectors.toList());
|
|
|
|
-// pageResult.setRecords(temp);
|
|
|
|
-// return pageResult;
|
|
|
|
-// }
|
|
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* 查询指定月的统计列表
|
|
* 查询指定月的统计列表
|
|
*
|
|
*
|
|
@@ -140,7 +71,11 @@ public class WmDaCustomerStatisticsServiceImpl implements WmDaCustomerStatistics
|
|
// gmv数据
|
|
// gmv数据
|
|
List<WmDeptGmv> deptGmvList = wmDaCustomer.getDeptGmvList();
|
|
List<WmDeptGmv> deptGmvList = wmDaCustomer.getDeptGmvList();
|
|
if (CollectionUtil.isNotEmpty(deptGmvList)) {
|
|
if (CollectionUtil.isNotEmpty(deptGmvList)) {
|
|
- deptGmvList.forEach(wmDeptGmv -> {
|
|
|
|
|
|
+ deptGmvList.stream().filter(wmDeptGmv -> {
|
|
|
|
+ // 过滤,只取指定月份区间的数据
|
|
|
|
+ int month = Integer.parseInt(wmDeptGmv.getMonth());
|
|
|
|
+ return month >= startMonth && month <= endMonth;
|
|
|
|
+ }).forEach(wmDeptGmv -> {
|
|
// 封装GMV数据
|
|
// 封装GMV数据
|
|
WmDaCustomerStatistics customerStatistics = new WmDaCustomerStatistics();
|
|
WmDaCustomerStatistics customerStatistics = new WmDaCustomerStatistics();
|
|
// 如果企业的积分是以分为单位,则需要转换 '分'->'元'
|
|
// 如果企业的积分是以分为单位,则需要转换 '分'->'元'
|