|
@@ -2,35 +2,29 @@ package com.sd.business.service.order.impl;
|
|
|
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.fjhx.tenant.entity.dict.po.DictCommonData;
|
|
|
import com.fjhx.tenant.service.dict.DictCommonDataService;
|
|
|
-import com.ruoyi.common.core.domain.BaseIdPo;
|
|
|
import com.ruoyi.common.utils.wrapper.IWrapper;
|
|
|
-import com.sd.business.entity.board.bo.TurnoverRateSalesShipmentStatisticsBo;
|
|
|
+import com.sd.business.entity.board.bo.OrderSalesShipmentStatisticsBo;
|
|
|
import com.sd.business.entity.board.dto.TurnoverRateBoardSelectDto;
|
|
|
import com.sd.business.entity.board.vo.TurnoverRateStatisticsVo;
|
|
|
import com.sd.business.entity.bom.po.Bom;
|
|
|
import com.sd.business.entity.bom.po.BomClassify;
|
|
|
import com.sd.business.entity.bom.po.BomSpec;
|
|
|
import com.sd.business.entity.department.constant.DepartmentConstant;
|
|
|
+import com.sd.business.entity.inventory.po.Inventory;
|
|
|
import com.sd.business.entity.inventory.po.InventoryBackup;
|
|
|
-import com.sd.business.entity.order.dto.OrderSalesShipmentStatisticsDto;
|
|
|
-import com.sd.business.entity.order.enums.OrderClassifyEnum;
|
|
|
-import com.sd.business.entity.order.enums.OrderStatusEnum;
|
|
|
import com.sd.business.entity.order.po.OrderInfo;
|
|
|
-import com.sd.business.entity.order.po.OrderSalesShipmentStatistics;
|
|
|
import com.sd.business.entity.order.po.OrderSku;
|
|
|
-import com.sd.business.entity.order.vo.OrderSalesShipmentStatisticsVo;
|
|
|
import com.sd.business.entity.warehouse.constant.WarehouseConstant;
|
|
|
import com.sd.business.mapper.order.OrderSalesShipmentStatisticsMapper;
|
|
|
import com.sd.business.service.inventory.InventoryBackupService;
|
|
|
+import com.sd.business.service.inventory.InventoryService;
|
|
|
import com.sd.business.service.order.OrderSalesShipmentStatisticsService;
|
|
|
-import com.sd.business.service.order.OrderService;
|
|
|
-import com.sd.business.service.order.OrderSkuService;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import javax.annotation.Resource;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.math.RoundingMode;
|
|
|
import java.util.*;
|
|
@@ -48,46 +42,43 @@ import static java.util.Comparator.comparing;
|
|
|
* @since 2023-10-20
|
|
|
*/
|
|
|
@Service
|
|
|
-public class OrderSalesShipmentStatisticsServiceImpl extends ServiceImpl<OrderSalesShipmentStatisticsMapper, OrderSalesShipmentStatistics> implements OrderSalesShipmentStatisticsService {
|
|
|
+public class OrderSalesShipmentStatisticsServiceImpl implements OrderSalesShipmentStatisticsService {
|
|
|
|
|
|
- @Autowired
|
|
|
- private OrderService orderService;
|
|
|
+ @Resource
|
|
|
+ private OrderSalesShipmentStatisticsMapper orderSalesShipmentStatisticsMapper;
|
|
|
|
|
|
@Autowired
|
|
|
- private OrderSkuService orderSkuService;
|
|
|
+ private InventoryBackupService inventoryBackupService;
|
|
|
|
|
|
@Autowired
|
|
|
- private InventoryBackupService inventoryBackupService;
|
|
|
+ private InventoryService inventoryService;
|
|
|
|
|
|
@Autowired
|
|
|
private DictCommonDataService dictCommonDataService;
|
|
|
|
|
|
@Override
|
|
|
- public List<OrderSalesShipmentStatisticsVo> getSalesShipmentStatisticsByDate(OrderSalesShipmentStatisticsDto dto) {
|
|
|
- IWrapper<OrderSalesShipmentStatistics> wrapper = getWrapper();
|
|
|
- wrapper.orderByDesc("osss", OrderSalesShipmentStatistics::getId);
|
|
|
- wrapper.between("osss", OrderSalesShipmentStatistics::getTotalDate, dto.getBeginDate(), dto.getEndDate());
|
|
|
- if (Objects.equals(dto.getBomClassify(), 1)) {
|
|
|
- wrapper.in("bc", BomClassify::getCode, Arrays.asList("201.G","203.G"));
|
|
|
- } else if (Objects.equals(dto.getBomClassify(), 2)){
|
|
|
- wrapper.eq("bc", BomClassify::getCode,"202.G");
|
|
|
- }
|
|
|
- wrapper.ne("bs", BomSpec::getCode, "1010000007");
|
|
|
- wrapper.groupBy("osss.bom_spec_id");
|
|
|
- return this.baseMapper.getSalesShipmentStatisticsList(wrapper);
|
|
|
+ public Map<Long, OrderSalesShipmentStatisticsBo> getSalesShipmentStatisticsByDate(List<Long> bomSpecIds) {
|
|
|
+ Date date = new Date();
|
|
|
+ Date startDate = DateUtil.offsetDay(date, -90);
|
|
|
+ IWrapper<OrderSku> wrapper = IWrapper.getWrapper();
|
|
|
+ wrapper.orderByDesc("os", OrderSku::getId);
|
|
|
+ wrapper.between("oi", OrderInfo::getShippingTime, startDate, date);
|
|
|
+ wrapper.groupBy("bs.id");
|
|
|
+ List<OrderSalesShipmentStatisticsBo> list = orderSalesShipmentStatisticsMapper.getOrderSalesShipmentStatisticsList(wrapper);
|
|
|
+ return list.stream().collect(Collectors.toMap(OrderSalesShipmentStatisticsBo::getBomSpecId, Function.identity()));
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public List<TurnoverRateStatisticsVo> getTurnoverRateStatisticsList(TurnoverRateBoardSelectDto dto) {
|
|
|
Date date = new Date();
|
|
|
- String ninetyDaysDate = DateUtil.format(DateUtil.offsetDay(date, -91), "yyyy-MM-dd");
|
|
|
- String sixtyDaysDate = DateUtil.format(DateUtil.offsetDay(date, -61), "yyyy-MM-dd");
|
|
|
- String thirtyDaysDate = DateUtil.format(DateUtil.offsetDay(date, -31), "yyyy-MM-dd");
|
|
|
- String endDate = DateUtil.format(DateUtil.offsetDay(date, -1), "yyyy-MM-dd");
|
|
|
-
|
|
|
- IWrapper<OrderSalesShipmentStatistics> wrapper = getWrapper();
|
|
|
- wrapper.orderByDesc("osss", OrderSalesShipmentStatistics::getId);
|
|
|
- wrapper.between("osss", OrderSalesShipmentStatistics::getTotalDate, ninetyDaysDate, endDate);
|
|
|
+ String ninetyDaysDate = DateUtil.formatDateTime(DateUtil.offsetDay(date, -90));
|
|
|
+ String sixtyDaysDate = DateUtil.formatDateTime(DateUtil.offsetDay(date, -60));
|
|
|
+ String thirtyDaysDate = DateUtil.formatDateTime(DateUtil.offsetDay(date, -30));
|
|
|
+
|
|
|
+ IWrapper<OrderSku> wrapper = IWrapper.getWrapper();
|
|
|
+ wrapper.orderByDesc("os", OrderSku::getId);
|
|
|
+ wrapper.eq("oi", OrderInfo::getDepartmentId, dto.getDepartmentId());
|
|
|
+ wrapper.between("oi", OrderInfo::getShippingTime, ninetyDaysDate, date);
|
|
|
if (Objects.equals(dto.getBomClassify(), 1)) {
|
|
|
wrapper.eq("bc", BomClassify::getCode, "201.G");
|
|
|
} else if (Objects.equals(dto.getBomClassify(), 2)){
|
|
@@ -100,12 +91,12 @@ public class OrderSalesShipmentStatisticsServiceImpl extends ServiceImpl<OrderSa
|
|
|
wrapper.like("bs", BomSpec::getWidth, dto.getWidth());
|
|
|
wrapper.like("bs", BomSpec::getHeight, dto.getHeight());
|
|
|
wrapper.like("bs", BomSpec::getName, dto.getBomSpecName());
|
|
|
- wrapper.groupBy("osss.bom_spec_id");
|
|
|
- List<TurnoverRateSalesShipmentStatisticsBo> statisticsVoList = this.baseMapper.getTurnoverRateSalesShipmentStatisticsList(wrapper);
|
|
|
+ wrapper.groupBy("bs.id");
|
|
|
+ List<OrderSalesShipmentStatisticsBo> statisticsVoList = orderSalesShipmentStatisticsMapper.getOrderSalesShipmentStatisticsList(wrapper);
|
|
|
if (ObjectUtil.isEmpty(statisticsVoList)) {
|
|
|
return Collections.emptyList();
|
|
|
}
|
|
|
- List<Long> bomSpecIds = statisticsVoList.stream().map(TurnoverRateSalesShipmentStatisticsBo::getBomSpecId).collect(Collectors.toList());
|
|
|
+ List<Long> bomSpecIds = statisticsVoList.stream().map(OrderSalesShipmentStatisticsBo::getBomSpecId).collect(Collectors.toList());
|
|
|
|
|
|
Map<String, String> bomChromatophoreMap = dictCommonDataService.list(q -> q.eq(DictCommonData::getDictCode, "bom_chromatophore"))
|
|
|
.stream().collect(Collectors.toMap(DictCommonData::getDictKey, DictCommonData::getDictValue));
|
|
@@ -125,11 +116,10 @@ public class OrderSalesShipmentStatisticsServiceImpl extends ServiceImpl<OrderSa
|
|
|
Collectors.toMap(InventoryBackup::getBomSpecId, Function.identity())));
|
|
|
|
|
|
// 期末库存数据
|
|
|
- Map<Long, InventoryBackup> endBackupMap = inventoryBackupService.mapKEntity(InventoryBackup::getBomSpecId, q -> q
|
|
|
- .eq(InventoryBackup::getBackupDate, endDate)
|
|
|
- .eq(InventoryBackup::getDepartmentId, DepartmentConstant.SD_SPORTS)
|
|
|
- .eq(InventoryBackup::getWarehouseId, WarehouseConstant.SEMI_FINISHED_PRODUCT)
|
|
|
- .in(InventoryBackup::getBomSpecId, bomSpecIds));
|
|
|
+ Map<Long, Inventory> endBackupMap = inventoryService.mapKEntity(Inventory::getBomSpecId, q -> q
|
|
|
+ .eq(Inventory::getDepartmentId, DepartmentConstant.SD_SPORTS)
|
|
|
+ .eq(Inventory::getWarehouseId, WarehouseConstant.SEMI_FINISHED_PRODUCT)
|
|
|
+ .in(Inventory::getBomSpecId, bomSpecIds));
|
|
|
|
|
|
List<TurnoverRateStatisticsVo> list = statisticsVoList.stream().map(item -> {
|
|
|
Long bomSpecId = item.getBomSpecId();
|
|
@@ -140,44 +130,34 @@ public class OrderSalesShipmentStatisticsServiceImpl extends ServiceImpl<OrderSa
|
|
|
InventoryBackup beginBackupNinetyDays = beginBackupMap.getOrDefault(ninetyDaysDate, Collections.emptyMap()).get(bomSpecId);
|
|
|
InventoryBackup beginBackupSixtyDays = beginBackupMap.getOrDefault(sixtyDaysDate, Collections.emptyMap()).get(bomSpecId);
|
|
|
InventoryBackup beginBackupThirtyDays = beginBackupMap.getOrDefault(thirtyDaysDate, Collections.emptyMap()).get(bomSpecId);
|
|
|
- InventoryBackup endBackup = endBackupMap.get(bomSpecId);
|
|
|
+ Inventory endBackup = endBackupMap.get(bomSpecId);
|
|
|
// 计算bom近90、60、30天的期初库存数量
|
|
|
- BigDecimal beginQuantityNinetyDays;
|
|
|
- BigDecimal beginQuantitySixtyDays;
|
|
|
- BigDecimal beginQuantityThirtyDays;
|
|
|
- BigDecimal endQuantity;
|
|
|
- if (beginBackupNinetyDays == null) {
|
|
|
- beginQuantityNinetyDays = BigDecimal.ZERO;
|
|
|
- } else {
|
|
|
+ BigDecimal beginQuantityNinetyDays = BigDecimal.ZERO;
|
|
|
+ BigDecimal beginQuantitySixtyDays = BigDecimal.ZERO;
|
|
|
+ BigDecimal beginQuantityThirtyDays = BigDecimal.ZERO;
|
|
|
+ BigDecimal endQuantity = BigDecimal.ZERO;
|
|
|
+ if (beginBackupNinetyDays != null) {
|
|
|
beginQuantityNinetyDays = beginBackupNinetyDays.getQuantity()
|
|
|
.add(beginBackupNinetyDays.getLockQuantity() == null ? BigDecimal.ZERO : beginBackupNinetyDays.getLockQuantity());
|
|
|
}
|
|
|
- if (beginBackupSixtyDays == null) {
|
|
|
- beginQuantitySixtyDays = BigDecimal.ZERO;
|
|
|
- } else {
|
|
|
+ if (beginBackupSixtyDays != null) {
|
|
|
beginQuantitySixtyDays = beginBackupSixtyDays.getQuantity()
|
|
|
.add(beginBackupSixtyDays.getLockQuantity() == null ? BigDecimal.ZERO : beginBackupSixtyDays.getLockQuantity());
|
|
|
}
|
|
|
- if (beginBackupThirtyDays == null) {
|
|
|
- beginQuantityThirtyDays = BigDecimal.ZERO;
|
|
|
- } else {
|
|
|
+ if (beginBackupThirtyDays != null) {
|
|
|
beginQuantityThirtyDays = beginBackupThirtyDays.getQuantity()
|
|
|
.add(beginBackupThirtyDays.getLockQuantity() == null ? BigDecimal.ZERO : beginBackupThirtyDays.getLockQuantity());
|
|
|
}
|
|
|
- if (endBackup == null) {
|
|
|
- endQuantity = BigDecimal.ZERO;
|
|
|
- } else {
|
|
|
+ if (endBackup != null) {
|
|
|
endQuantity = endBackup.getQuantity().add(endBackup.getLockQuantity() == null ? BigDecimal.ZERO : endBackup.getLockQuantity());
|
|
|
}
|
|
|
// 时间段天数
|
|
|
BigDecimal days;
|
|
|
- BigDecimal turnoverRateNinetyDays;
|
|
|
- BigDecimal turnoverRateSixtyDays;
|
|
|
- BigDecimal turnoverRateThirtyDays;
|
|
|
- if (ObjectUtil.equals(item.getNinetyDaysSalesQuantity(), BigDecimal.ZERO)
|
|
|
- || ObjectUtil.equals(beginQuantityNinetyDays.add(endQuantity), BigDecimal.ZERO)) {
|
|
|
- turnoverRateNinetyDays = BigDecimal.ZERO;
|
|
|
- } else {
|
|
|
+ BigDecimal turnoverRateNinetyDays = BigDecimal.ZERO;
|
|
|
+ BigDecimal turnoverRateSixtyDays = BigDecimal.ZERO;
|
|
|
+ BigDecimal turnoverRateThirtyDays = BigDecimal.ZERO;
|
|
|
+ if (ObjectUtil.notEqual(item.getNinetyDaysSalesQuantity(), BigDecimal.ZERO)
|
|
|
+ && ObjectUtil.notEqual(beginQuantityNinetyDays.add(endQuantity), BigDecimal.ZERO)) {
|
|
|
days = new BigDecimal(90);
|
|
|
turnoverRateNinetyDays = days
|
|
|
.divide(days.multiply(new BigDecimal("0.5"))
|
|
@@ -185,10 +165,8 @@ public class OrderSalesShipmentStatisticsServiceImpl extends ServiceImpl<OrderSa
|
|
|
.divide(item.getNinetyDaysSalesQuantity(), 4, RoundingMode.HALF_UP),
|
|
|
4, RoundingMode.HALF_UP);
|
|
|
}
|
|
|
- if (ObjectUtil.equals(item.getSixtyDaysSalesQuantity(), BigDecimal.ZERO)
|
|
|
- || ObjectUtil.equals(beginQuantitySixtyDays.add(endQuantity), BigDecimal.ZERO)) {
|
|
|
- turnoverRateSixtyDays = BigDecimal.ZERO;
|
|
|
- } else {
|
|
|
+ if (ObjectUtil.notEqual(item.getSixtyDaysSalesQuantity(), BigDecimal.ZERO)
|
|
|
+ && ObjectUtil.notEqual(beginQuantitySixtyDays.add(endQuantity), BigDecimal.ZERO)) {
|
|
|
days = new BigDecimal(60);
|
|
|
turnoverRateSixtyDays = days
|
|
|
.divide(days.multiply(new BigDecimal("0.5"))
|
|
@@ -196,10 +174,8 @@ public class OrderSalesShipmentStatisticsServiceImpl extends ServiceImpl<OrderSa
|
|
|
.divide(item.getSixtyDaysSalesQuantity(), 4, RoundingMode.HALF_UP),
|
|
|
4, RoundingMode.HALF_UP);
|
|
|
}
|
|
|
- if (ObjectUtil.equals(item.getThirtyDaysSalesQuantity(), BigDecimal.ZERO)
|
|
|
- || ObjectUtil.equals(beginQuantityThirtyDays.add(endQuantity), BigDecimal.ZERO)) {
|
|
|
- turnoverRateThirtyDays = BigDecimal.ZERO;
|
|
|
- } else {
|
|
|
+ if (ObjectUtil.notEqual(item.getThirtyDaysSalesQuantity(), BigDecimal.ZERO)
|
|
|
+ && ObjectUtil.notEqual(beginQuantityThirtyDays.add(endQuantity), BigDecimal.ZERO)) {
|
|
|
days = new BigDecimal(30);
|
|
|
turnoverRateThirtyDays = days
|
|
|
.divide(days.multiply(new BigDecimal("0.5"))
|
|
@@ -229,112 +205,11 @@ public class OrderSalesShipmentStatisticsServiceImpl extends ServiceImpl<OrderSa
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void salesShipmentStatistics() {
|
|
|
- Date date = new Date();
|
|
|
- List<OrderSalesShipmentStatistics> salesShipmentStatisticsList = new ArrayList<>();
|
|
|
- // 统计近7天数据
|
|
|
- for (int i = 7; i >= 1; i--) {
|
|
|
- Date offsetDay = DateUtil.offsetDay(date, -i);
|
|
|
- String formatDate = DateUtil.formatDate(offsetDay);
|
|
|
- List<OrderInfo> list = orderService.list(q -> q
|
|
|
- .eq(OrderInfo::getStatus, OrderStatusEnum.COMPLETION_PRODUCTION.getKey())
|
|
|
- .ne(OrderInfo::getClassify, OrderClassifyEnum.OUTSOURCE_ORDER.getKey())
|
|
|
- .likeRight(OrderInfo::getShippingTime, formatDate)
|
|
|
- .select(BaseIdPo::getId));
|
|
|
- if (list.isEmpty()) {
|
|
|
- return;
|
|
|
- }
|
|
|
- Map<Long, OrderSalesShipmentStatistics> statisticsMap = this.mapKEntity(
|
|
|
- OrderSalesShipmentStatistics::getBomSpecId,
|
|
|
- q -> q.eq(OrderSalesShipmentStatistics::getTotalDate, formatDate));
|
|
|
-
|
|
|
- List<Long> orderIds = list.stream().map(BaseIdPo::getId).collect(Collectors.toList());
|
|
|
- List<OrderSku> orderSkuList = orderSkuService.list(q -> q.in(OrderSku::getOrderId, orderIds));
|
|
|
- Map<Long, BigDecimal> map = orderSkuList.stream().collect(Collectors.toMap(OrderSku::getBomSpecId, OrderSku::getQuantity, BigDecimal::add));
|
|
|
- List<OrderSalesShipmentStatistics> statisticsDtoList = map.keySet().stream().map(item -> {
|
|
|
- OrderSalesShipmentStatistics statistics = statisticsMap.get(item);
|
|
|
- if (statistics == null) {
|
|
|
- statistics = new OrderSalesShipmentStatistics();
|
|
|
- }
|
|
|
- statistics.setTotalDate(offsetDay);
|
|
|
- statistics.setBomSpecId(item);
|
|
|
- statistics.setQuantity(map.get(item));
|
|
|
- return statistics;
|
|
|
- }).collect(Collectors.toList());
|
|
|
- salesShipmentStatisticsList.addAll(statisticsDtoList);
|
|
|
- }
|
|
|
- if (salesShipmentStatisticsList.isEmpty()) {
|
|
|
- return;
|
|
|
- }
|
|
|
- this.saveOrUpdateBatch(salesShipmentStatisticsList);
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
public Map<Long, BigDecimal> getTurnoverRateMapByBomSpecIds(List<Long> bomSpecIds) {
|
|
|
- Map<Long, BigDecimal> map = new HashMap<>();
|
|
|
- // 查询90天的周转率
|
|
|
- Date date = new Date();
|
|
|
- Date beginDate = DateUtil.beginOfDay(DateUtil.offsetDay(date, -91));
|
|
|
- Date endDate = DateUtil.beginOfDay(DateUtil.offsetDay(date, -1));
|
|
|
- OrderSalesShipmentStatisticsDto statisticsDto = new OrderSalesShipmentStatisticsDto();
|
|
|
- statisticsDto.setBeginDate(beginDate);
|
|
|
- statisticsDto.setEndDate(endDate);
|
|
|
- statisticsDto.setBomSpecIds(bomSpecIds);
|
|
|
- List<OrderSalesShipmentStatisticsVo> statisticsVoList = this.getSalesShipmentStatisticsByDate(statisticsDto);
|
|
|
- if (ObjectUtil.isEmpty(statisticsVoList)) {
|
|
|
- return map;
|
|
|
- }
|
|
|
- // 期初库存数据
|
|
|
- Map<Long, InventoryBackup> beginBackupMap = inventoryBackupService.mapKEntity(InventoryBackup::getBomSpecId, q -> q
|
|
|
- .eq(InventoryBackup::getBackupDate, beginDate)
|
|
|
- .eq(InventoryBackup::getDepartmentId, DepartmentConstant.SD_SPORTS)
|
|
|
- .eq(InventoryBackup::getWarehouseId, WarehouseConstant.SEMI_FINISHED_PRODUCT)
|
|
|
- .in(InventoryBackup::getBomSpecId, bomSpecIds));
|
|
|
-
|
|
|
- // 期末库存数据
|
|
|
- Map<Long, InventoryBackup> endBackupMap = inventoryBackupService.mapKEntity(InventoryBackup::getBomSpecId, q -> q
|
|
|
- .eq(InventoryBackup::getBackupDate, endDate)
|
|
|
- .eq(InventoryBackup::getDepartmentId, DepartmentConstant.SD_SPORTS)
|
|
|
- .eq(InventoryBackup::getWarehouseId, WarehouseConstant.SEMI_FINISHED_PRODUCT)
|
|
|
- .in(InventoryBackup::getBomSpecId, bomSpecIds));
|
|
|
-
|
|
|
- for (OrderSalesShipmentStatisticsVo item : statisticsVoList) {
|
|
|
- // 计算周转率
|
|
|
- // 时间段库存周转天数 = 时间段天数 * (1 / 2) * (期初库存数量+期末库存数量) / 时间段销售量;
|
|
|
- // 库存周转率 = 时间段天数 / 库存周转天数。
|
|
|
- // 获取期初和期末数据
|
|
|
- InventoryBackup beginBackup = beginBackupMap.get(item.getBomSpecId());
|
|
|
- InventoryBackup endBackup = endBackupMap.get(item.getBomSpecId());
|
|
|
- BigDecimal beginQuantity;
|
|
|
- BigDecimal endQuantity;
|
|
|
- if (beginBackup == null) {
|
|
|
- beginQuantity = BigDecimal.ZERO;
|
|
|
- } else {
|
|
|
- beginQuantity = beginBackup.getQuantity().add(beginBackup.getLockQuantity() == null ? BigDecimal.ZERO : beginBackup.getLockQuantity());
|
|
|
- }
|
|
|
- if (endBackup == null) {
|
|
|
- endQuantity = BigDecimal.ZERO;
|
|
|
- } else {
|
|
|
- endQuantity = endBackup.getQuantity().add(endBackup.getLockQuantity() == null ? BigDecimal.ZERO : endBackup.getLockQuantity());
|
|
|
- }
|
|
|
- // 时间段天数
|
|
|
- BigDecimal days = new BigDecimal(90);
|
|
|
- BigDecimal turnoverRate;
|
|
|
- if (ObjectUtil.equals(item.getQuantity(), BigDecimal.ZERO)
|
|
|
- || ObjectUtil.equals(beginQuantity.add(endQuantity), BigDecimal.ZERO)) {
|
|
|
- turnoverRate = BigDecimal.ZERO;
|
|
|
- } else {
|
|
|
- turnoverRate = days
|
|
|
- .divide(days.multiply(new BigDecimal("0.5"))
|
|
|
- .multiply(beginQuantity.add(endQuantity))
|
|
|
- .divide(item.getQuantity(), 4, RoundingMode.HALF_UP),
|
|
|
- 4, RoundingMode.HALF_UP);
|
|
|
- }
|
|
|
- if (ObjectUtil.equals(endQuantity, BigDecimal.ZERO) && ObjectUtil.equals(turnoverRate, BigDecimal.ZERO)) {
|
|
|
- continue;
|
|
|
- }
|
|
|
- map.put(item.getBomSpecId(), turnoverRate);
|
|
|
- }
|
|
|
- return map;
|
|
|
+ IWrapper<OrderSku> wrapper = IWrapper.getWrapper();
|
|
|
+ wrapper.in("oq.bom_spec_id", bomSpecIds);
|
|
|
+ wrapper.groupBy("oq.bom_spec_id");
|
|
|
+ List<OrderSalesShipmentStatisticsBo> list = orderSalesShipmentStatisticsMapper.getTurnoverRateMapByBomSpecIds(wrapper);
|
|
|
+ return list.stream().collect(Collectors.toMap(OrderSalesShipmentStatisticsBo::getBomSpecId, OrderSalesShipmentStatisticsBo::getTurnoverRate));
|
|
|
}
|
|
|
}
|