|
@@ -48,6 +48,8 @@ import java.util.concurrent.ThreadPoolExecutor;
|
|
|
import java.util.function.Function;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
+import static java.util.Comparator.comparing;
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* <p>
|
|
@@ -242,8 +244,11 @@ public class StatementOfAccountServiceImpl extends ServiceImpl<StatementOfAccoun
|
|
|
List<DocumentBySkuVo> documentBySkuVoList = orderSkuList.stream()
|
|
|
.map(item -> DocumentBySkuVo.builder()
|
|
|
.skuSpecId(item.getSkuSpecId())
|
|
|
- .orderId(item.getOrderId())
|
|
|
- .quantity(item.getQuantity())
|
|
|
+ // 判断是否是委外订单,如果是委外订单时将bom数量修改为0
|
|
|
+ .quantity(ObjectUtil.isNotEmpty(
|
|
|
+ orderService.getOne(q -> q
|
|
|
+ .eq(OrderInfo::getId, item.getOrderId()).eq(OrderInfo::getType, 2)))
|
|
|
+ ? BigDecimal.ZERO : item.getQuantity())
|
|
|
.unitPrice(item.getUnitPrice()
|
|
|
.add(item.getCustomProcessingFee())
|
|
|
.add(item.getLssueFee())
|
|
@@ -255,13 +260,6 @@ public class StatementOfAccountServiceImpl extends ServiceImpl<StatementOfAccoun
|
|
|
.build())
|
|
|
.peek(item -> item.setSubtotal(item.getQuantity().multiply(item.getUnitPrice())))
|
|
|
.peek(item -> item.setTotal(item.getSubtotal()))
|
|
|
- .peek(item -> {
|
|
|
- // 判断是否是委外订单,如果是委外订单时将bom数量修改为0
|
|
|
- OrderInfo orderInfo = orderService.getOne(q -> q.eq(OrderInfo::getId, item.getOrderId()).eq(OrderInfo::getType, 2));
|
|
|
- if (ObjectUtil.isNotEmpty(orderInfo)) {
|
|
|
- item.setQuantity(BigDecimal.ZERO);
|
|
|
- }
|
|
|
- })
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
|
// 赋值sku规格品名和品号
|
|
@@ -272,7 +270,7 @@ public class StatementOfAccountServiceImpl extends ServiceImpl<StatementOfAccoun
|
|
|
|
|
|
// 合并单价、小计、sku规格id系统的对账数据
|
|
|
Collection<DocumentBySkuVo> documentBySkuVoCollection = documentBySkuVoList.stream()
|
|
|
- .sorted(Comparator.comparing(DocumentBySkuVo::getSkuSpecCode))
|
|
|
+ .sorted(comparing(DocumentBySkuVo::getSkuSpecCode))
|
|
|
.collect(Collectors.toMap(
|
|
|
item -> item.getUnitPrice() + ":" + item.getSkuSpecId(),
|
|
|
Function.identity(),
|
|
@@ -303,9 +301,12 @@ public class StatementOfAccountServiceImpl extends ServiceImpl<StatementOfAccoun
|
|
|
// 主材bom
|
|
|
List<DocumentByBomVo> result = orderSkuList.stream()
|
|
|
.map(item -> DocumentByBomVo.builder()
|
|
|
- .orderId(item.getOrderId())
|
|
|
.bomSpecId(item.getBomSpecId())
|
|
|
- .quantity(item.getQuantity())
|
|
|
+ // 判断是否是委外订单,如果是委外订单时将bom数量修改为0
|
|
|
+ .quantity(ObjectUtil.isNotEmpty(
|
|
|
+ orderService.getOne(q -> q
|
|
|
+ .eq(OrderInfo::getId, item.getOrderId()).eq(OrderInfo::getType, 2)))
|
|
|
+ ? BigDecimal.ZERO : item.getQuantity())
|
|
|
.unitPrice(item.getUnitPrice())
|
|
|
.laserLogoSummary((Objects.equals(item.getCustomProcessingType(), "20")
|
|
|
? item.getCustomProcessingFee().multiply(item.getQuantity()) : BigDecimal.ZERO))
|
|
@@ -327,13 +328,6 @@ public class StatementOfAccountServiceImpl extends ServiceImpl<StatementOfAccoun
|
|
|
.add(item.getManagementFeeSummary())
|
|
|
))
|
|
|
.peek(item -> item.setTotal(item.getSubtotal()))
|
|
|
- .peek(item -> {
|
|
|
- // 判断是否是委外订单,如果是委外订单时将bom数量修改为0
|
|
|
- OrderInfo orderInfo = orderService.getOne(q -> q.eq(OrderInfo::getId, item.getOrderId()).eq(OrderInfo::getType, 2));
|
|
|
- if (ObjectUtil.isNotEmpty(orderInfo)) {
|
|
|
- item.setQuantity(BigDecimal.ZERO);
|
|
|
- }
|
|
|
- })
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
|
// 赋值主材bom品名品号
|
|
@@ -344,7 +338,7 @@ public class StatementOfAccountServiceImpl extends ServiceImpl<StatementOfAccoun
|
|
|
|
|
|
// 合并同加个同规格主材bom,数量相加
|
|
|
Collection<DocumentByBomVo> documentByBomVoCollection = result.stream()
|
|
|
- .sorted(Comparator.comparing(DocumentByBomVo::getBomSpecCode))
|
|
|
+ .sorted(comparing(DocumentByBomVo::getBomSpecCode))
|
|
|
.collect(Collectors.toMap(
|
|
|
item -> item.getUnitPrice() + ":" + item.getBomSpecId(),
|
|
|
Function.identity(),
|
|
@@ -364,6 +358,8 @@ public class StatementOfAccountServiceImpl extends ServiceImpl<StatementOfAccoun
|
|
|
|
|
|
// 赋值合并后结果
|
|
|
result = new ArrayList<>(documentByBomVoCollection);
|
|
|
+ // 按品名升序排序
|
|
|
+ result.sort(comparing(DocumentByBomVo::getBomSpecName));
|
|
|
|
|
|
Map<Long, BigDecimal> orderSkuMap = orderSkuList.stream().collect(Collectors.toMap(BaseIdPo::getId, OrderSku::getQuantity));
|
|
|
|
|
@@ -387,7 +383,7 @@ public class StatementOfAccountServiceImpl extends ServiceImpl<StatementOfAccoun
|
|
|
|
|
|
// 合并同加个同规格包材bom,数量相加
|
|
|
Collection<DocumentByBomVo> bomValues = bomVoList.stream()
|
|
|
- .sorted(Comparator.comparing(DocumentByBomVo::getBomSpecCode))
|
|
|
+ .sorted(comparing(DocumentByBomVo::getBomSpecCode))
|
|
|
.collect(Collectors.toMap(
|
|
|
item -> item.getUnitPrice() + ":" + item.getBomSpecId(),
|
|
|
Function.identity(),
|
|
@@ -514,7 +510,11 @@ public class StatementOfAccountServiceImpl extends ServiceImpl<StatementOfAccoun
|
|
|
.orderId(item.getOrderId())
|
|
|
.orderSkuId(item.getId())
|
|
|
.skuSpecId(item.getSkuSpecId())
|
|
|
- .quantity(item.getQuantity())
|
|
|
+ // 判断是否是委外订单,如果是委外订单时将bom数量修改为0
|
|
|
+ .quantity(ObjectUtil.isNotEmpty(
|
|
|
+ orderService.getOne(q -> q
|
|
|
+ .eq(OrderInfo::getId, item.getOrderId()).eq(OrderInfo::getType, 2)))
|
|
|
+ ? BigDecimal.ZERO : item.getQuantity())
|
|
|
.unitPrice(item.getUnitPrice()
|
|
|
.add(item.getCustomProcessingFee())
|
|
|
.add(item.getLssueFee())
|
|
@@ -525,13 +525,6 @@ public class StatementOfAccountServiceImpl extends ServiceImpl<StatementOfAccoun
|
|
|
.build())
|
|
|
.peek(item -> item.setSubtotal(item.getQuantity().multiply(item.getUnitPrice())))
|
|
|
.peek(item -> item.setTotal(item.getSubtotal()))
|
|
|
- .peek(item -> {
|
|
|
- // 判断是否是委外订单,如果是委外订单时将bom数量修改为0
|
|
|
- OrderInfo orderInfo = orderService.getOne(q -> q.eq(OrderInfo::getId, item.getOrderId()).eq(OrderInfo::getType, 2));
|
|
|
- if (ObjectUtil.isNotEmpty(orderInfo)) {
|
|
|
- item.setQuantity(BigDecimal.ZERO);
|
|
|
- }
|
|
|
- })
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
|
skuSpecService.attributeAssign(skuSpecList, DocumentByOrderVo.SkuSpec::getSkuSpecId, (item, skuSpec) -> {
|
|
@@ -551,7 +544,11 @@ public class StatementOfAccountServiceImpl extends ServiceImpl<StatementOfAccoun
|
|
|
.map(item -> DocumentByOrderVo.BomSpec.builder()
|
|
|
.orderSkuId(item.getId())
|
|
|
.bomSpecId(item.getBomSpecId())
|
|
|
- .quantity(item.getQuantity())
|
|
|
+ // 判断是否是委外订单,如果是委外订单时将bom数量修改为0
|
|
|
+ .quantity(ObjectUtil.isNotEmpty(
|
|
|
+ orderService.getOne(q -> q
|
|
|
+ .eq(OrderInfo::getId, item.getOrderId()).eq(OrderInfo::getType, 2)))
|
|
|
+ ? BigDecimal.ZERO : item.getQuantity())
|
|
|
.unitPrice(item.getUnitPrice())
|
|
|
.laserLogoSummary((Objects.equals(item.getCustomProcessingType(), "20")
|
|
|
? item.getCustomProcessingFee() : BigDecimal.ZERO))
|
|
@@ -576,7 +573,7 @@ public class StatementOfAccountServiceImpl extends ServiceImpl<StatementOfAccoun
|
|
|
.quantity(item.getQuantity())
|
|
|
.unitPrice(item.getUnitPrice())
|
|
|
.build())
|
|
|
- .peek(item -> item.setQuantity(map.get(item.getOrderSkuId()).multiply(item.getQuantity())))
|
|
|
+ .peek(item -> item.setQuantity(ObjectUtil.equals(map.get(item.getOrderSkuId()), BigDecimal.ZERO) ? item.getQuantity() : map.get(item.getOrderSkuId()).multiply(item.getQuantity())))
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
|
bomSpecList.addAll(packBomSpecList);
|