|
|
@@ -1,13 +1,16 @@
|
|
|
package com.sckw.report.service.impl;
|
|
|
|
|
|
-import com.sckw.core.web.context.LoginUserHolder;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import com.sckw.core.web.response.BaseResult;
|
|
|
import com.sckw.order.api.feign.OrderStatisticsFeignService;
|
|
|
import com.sckw.order.api.model.DailySalesStatisticsDto;
|
|
|
import com.sckw.order.api.model.DailyShipmentStatisticsDto;
|
|
|
import com.sckw.order.api.model.GoodsAmountStatisticsDto;
|
|
|
import com.sckw.order.api.model.GoodsVolumeStatisticsDto;
|
|
|
-import com.sckw.report.model.vo.*;
|
|
|
+import com.sckw.report.model.vo.DailySalesAmountVo;
|
|
|
+import com.sckw.report.model.vo.DailyShipmentAmountVo;
|
|
|
+import com.sckw.report.model.vo.GoodsSalesAmountRatioVo;
|
|
|
+import com.sckw.report.model.vo.GoodsSalesVolumeRatioVo;
|
|
|
import com.sckw.report.service.KwBiReportService;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
@@ -18,7 +21,10 @@ import java.math.BigDecimal;
|
|
|
import java.math.RoundingMode;
|
|
|
import java.time.LocalDate;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
-import java.util.*;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Collections;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@Service
|
|
|
@@ -31,9 +37,8 @@ public class KwBiReportServiceImpl implements KwBiReportService {
|
|
|
|
|
|
@Override
|
|
|
public DailyShipmentAmountVo getDailyShipmentAmount() {
|
|
|
- Long entId = LoginUserHolder.getEntId();
|
|
|
- BaseResult<List<DailyShipmentStatisticsDto>> result = orderStatisticsFeignService.getDailyShipmentByCategory(entId, 7);
|
|
|
-
|
|
|
+ BaseResult<List<DailyShipmentStatisticsDto>> result = orderStatisticsFeignService.getDailyShipmentByCategory(7);
|
|
|
+ log.info("getDailyShipmentAmount {}", JSONObject.toJSONString(result));
|
|
|
DailyShipmentAmountVo vo = new DailyShipmentAmountVo();
|
|
|
List<String> dates = generateLast7Days();
|
|
|
vo.setDates(dates);
|
|
|
@@ -57,7 +62,7 @@ public class KwBiReportServiceImpl implements KwBiReportService {
|
|
|
dataMap.forEach((category, dateAmountMap) -> {
|
|
|
DailyShipmentAmountVo.ShipmentCategoryData data = new DailyShipmentAmountVo.ShipmentCategoryData();
|
|
|
data.setCategoryName(category);
|
|
|
-
|
|
|
+
|
|
|
List<BigDecimal> amounts = new ArrayList<>();
|
|
|
for (String date : dates) {
|
|
|
amounts.add(dateAmountMap.getOrDefault(date, BigDecimal.ZERO));
|
|
|
@@ -72,8 +77,8 @@ public class KwBiReportServiceImpl implements KwBiReportService {
|
|
|
|
|
|
@Override
|
|
|
public DailySalesAmountVo getDailySalesAmount() {
|
|
|
- Long entId = LoginUserHolder.getEntId();
|
|
|
- BaseResult<List<DailySalesStatisticsDto>> result = orderStatisticsFeignService.getDailySalesByCategory(entId, 7);
|
|
|
+ BaseResult<List<DailySalesStatisticsDto>> result = orderStatisticsFeignService.getDailySalesByCategory(7);
|
|
|
+ log.info("getDailySalesAmount {}", JSONObject.toJSONString(result));
|
|
|
|
|
|
DailySalesAmountVo vo = new DailySalesAmountVo();
|
|
|
List<String> dates = generateLast7Days();
|
|
|
@@ -113,8 +118,8 @@ public class KwBiReportServiceImpl implements KwBiReportService {
|
|
|
|
|
|
@Override
|
|
|
public GoodsSalesVolumeRatioVo getGoodsSalesVolumeRatio() {
|
|
|
- Long entId = LoginUserHolder.getEntId();
|
|
|
- BaseResult<List<GoodsVolumeStatisticsDto>> result = orderStatisticsFeignService.getGoodsVolumeTop5(entId);
|
|
|
+ BaseResult<List<GoodsVolumeStatisticsDto>> result = orderStatisticsFeignService.getGoodsVolumeTop5();
|
|
|
+ log.info("getGoodsSalesVolumeRatio {}", JSONObject.toJSONString(result));
|
|
|
|
|
|
GoodsSalesVolumeRatioVo vo = new GoodsSalesVolumeRatioVo();
|
|
|
|
|
|
@@ -133,7 +138,7 @@ public class KwBiReportServiceImpl implements KwBiReportService {
|
|
|
GoodsSalesVolumeRatioVo.GoodsVolumeRatioItem item = new GoodsSalesVolumeRatioVo.GoodsVolumeRatioItem();
|
|
|
item.setGoodsName(dto.getGoodsName());
|
|
|
item.setVolume(dto.getTotalVolume() != null ? dto.getTotalVolume() : BigDecimal.ZERO);
|
|
|
-
|
|
|
+
|
|
|
BigDecimal percentage = BigDecimal.ZERO;
|
|
|
if (totalVolume.compareTo(BigDecimal.ZERO) > 0) {
|
|
|
percentage = item.getVolume().multiply(new BigDecimal("100"))
|
|
|
@@ -149,8 +154,8 @@ public class KwBiReportServiceImpl implements KwBiReportService {
|
|
|
|
|
|
@Override
|
|
|
public GoodsSalesAmountRatioVo getGoodsSalesAmountRatio() {
|
|
|
- Long entId = LoginUserHolder.getEntId();
|
|
|
- BaseResult<List<GoodsAmountStatisticsDto>> result = orderStatisticsFeignService.getGoodsAmountTop5(entId);
|
|
|
+ BaseResult<List<GoodsAmountStatisticsDto>> result = orderStatisticsFeignService.getGoodsAmountTop5();
|
|
|
+ log.info("getGoodsSalesAmountRatio {}", JSONObject.toJSONString(result));
|
|
|
|
|
|
GoodsSalesAmountRatioVo vo = new GoodsSalesAmountRatioVo();
|
|
|
|
|
|
@@ -187,12 +192,12 @@ public class KwBiReportServiceImpl implements KwBiReportService {
|
|
|
List<String> dates = new ArrayList<>();
|
|
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MM/dd");
|
|
|
LocalDate today = LocalDate.now();
|
|
|
-
|
|
|
+
|
|
|
for (int i = 6; i >= 0; i--) {
|
|
|
LocalDate date = today.minusDays(i);
|
|
|
dates.add(date.format(formatter));
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
return dates;
|
|
|
}
|
|
|
-}
|
|
|
+}
|