|
@@ -18,6 +18,7 @@ import com.sd.business.entity.bom.po.BomSpec;
|
|
|
import com.sd.business.entity.bom.vo.BomSpecVo;
|
|
|
import com.sd.business.entity.department.constant.DepartmentConstant;
|
|
|
import com.sd.business.entity.inventory.po.Inventory;
|
|
|
+import com.sd.business.entity.order.po.OrderSalesShipmentStatistics;
|
|
|
import com.sd.business.entity.purchase.dto.PurchaseBoardSelectDto;
|
|
|
import com.sd.business.entity.purchase.dto.PurchaseBomDetailsSelectDto;
|
|
|
import com.sd.business.entity.purchase.dto.PurchaseBomSelectDto;
|
|
@@ -151,7 +152,29 @@ public class PurchaseBomServiceImpl extends ServiceImpl<PurchaseBomMapper, Purch
|
|
|
List<Long> bomSpecIds = records.stream().map(PurchaseInTransitBomVo::getBomSpecId).collect(Collectors.toList());
|
|
|
Map<Long, Inventory> inventoryMap = inventoryService.mapKEntity(Inventory::getBomSpecId, q -> q.in(Inventory::getBomSpecId, bomSpecIds).eq(Inventory::getWarehouseId, WarehouseConstant.SEMI_FINISHED_PRODUCT)
|
|
|
.eq(Inventory::getDepartmentId, DepartmentConstant.SD_SPORTS));
|
|
|
+
|
|
|
+ // 获取30天,60天销售数据
|
|
|
+ Date date = new Date();
|
|
|
+ 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");
|
|
|
+
|
|
|
+ Map<Long, List<OrderSalesShipmentStatistics>> sixtyDaysMap = orderSalesShipmentStatisticsService.mapKGroup(OrderSalesShipmentStatistics::getBomSpecId,
|
|
|
+ q -> q.between(OrderSalesShipmentStatistics::getTotalDate, sixtyDaysDate, endDate)
|
|
|
+ .in(OrderSalesShipmentStatistics::getBomSpecId, bomSpecIds));
|
|
|
+ Map<Long, List<OrderSalesShipmentStatistics>> thirtyDaysMap = orderSalesShipmentStatisticsService.mapKGroup(OrderSalesShipmentStatistics::getBomSpecId,
|
|
|
+ q -> q.between(OrderSalesShipmentStatistics::getTotalDate, thirtyDaysDate, endDate)
|
|
|
+ .in(OrderSalesShipmentStatistics::getBomSpecId, bomSpecIds));
|
|
|
+
|
|
|
for (PurchaseInTransitBomVo record : records) {
|
|
|
+ Long bomSpecId = record.getBomSpecId();
|
|
|
+ List<OrderSalesShipmentStatistics> sixtyDaysList = sixtyDaysMap.getOrDefault(bomSpecId, Collections.emptyList());
|
|
|
+ List<OrderSalesShipmentStatistics> thirtyDaysList = thirtyDaysMap.getOrDefault(bomSpecId, Collections.emptyList());
|
|
|
+ BigDecimal salesQuantitySixtyDays = sixtyDaysList.stream().map(OrderSalesShipmentStatistics::getQuantity).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ BigDecimal salesQuantityThirtyDays = thirtyDaysList.stream().map(OrderSalesShipmentStatistics::getQuantity).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ record.setSalesQuantitySixtyDays(salesQuantitySixtyDays);
|
|
|
+ record.setSalesQuantityThirtyDays(salesQuantityThirtyDays);
|
|
|
+
|
|
|
Inventory inventory = inventoryMap.get(record.getBomSpecId());
|
|
|
if (inventory == null) {
|
|
|
record.setInventoryQuantity(BigDecimal.ZERO);
|