|
@@ -12,6 +12,7 @@ import com.ruoyi.common.core.domain.BaseIdPo;
|
|
|
import com.ruoyi.common.utils.wrapper.IWrapper;
|
|
|
import com.sd.business.entity.order.po.OrderInfo;
|
|
|
import com.sd.business.entity.order.po.OrderSku;
|
|
|
+import com.sd.business.entity.order.po.OrderSkuBom;
|
|
|
import com.sd.business.entity.statement.dto.FileUploadDto;
|
|
|
import com.sd.business.entity.statement.dto.StatementOfAccountDto;
|
|
|
import com.sd.business.entity.statement.dto.StatementOfAccountSelectDto;
|
|
@@ -24,6 +25,7 @@ import com.sd.business.mapper.statement.StatementOfAccountMapper;
|
|
|
import com.sd.business.service.bom.BomSpecService;
|
|
|
import com.sd.business.service.department.DepartmentService;
|
|
|
import com.sd.business.service.order.OrderService;
|
|
|
+import com.sd.business.service.order.OrderSkuBomService;
|
|
|
import com.sd.business.service.order.OrderSkuService;
|
|
|
import com.sd.business.service.sku.SkuSpecService;
|
|
|
import com.sd.business.service.statement.StatementOfAccountService;
|
|
@@ -57,6 +59,9 @@ public class StatementOfAccountServiceImpl extends ServiceImpl<StatementOfAccoun
|
|
|
private OrderSkuService orderSkuService;
|
|
|
|
|
|
@Autowired
|
|
|
+ private OrderSkuBomService orderSkuBomService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
private DepartmentService departmentService;
|
|
|
|
|
|
@Autowired
|
|
@@ -268,6 +273,7 @@ public class StatementOfAccountServiceImpl extends ServiceImpl<StatementOfAccoun
|
|
|
// 获取订单sku
|
|
|
List<OrderSku> orderSkuList = orderSkuService.list(q -> q.in(OrderSku::getOrderId, ordedrIdList));
|
|
|
|
|
|
+ // 主材bom
|
|
|
List<DocumentByBomVo> result = orderSkuList.stream()
|
|
|
.map(item -> DocumentByBomVo.builder()
|
|
|
.bomSpecId(item.getBomSpecId())
|
|
@@ -281,27 +287,77 @@ public class StatementOfAccountServiceImpl extends ServiceImpl<StatementOfAccoun
|
|
|
.deliveryMaterialsFeeSummary(item.getDeliveryMaterialsFee().multiply(item.getQuantity()))
|
|
|
.packingLaborSummary(item.getPackingLabor().multiply(item.getQuantity()))
|
|
|
.build())
|
|
|
+ .peek(item -> item.setSubtotal(item.getUnitPrice().multiply(item.getQuantity())
|
|
|
+ .add(item.getLaserLogoSummary())
|
|
|
+ .add(item.getLaserMitochondrialSummary())
|
|
|
+ .add(item.getLssueFeeSummary())
|
|
|
+ .add(item.getDeliveryMaterialsFeeSummary())
|
|
|
+ .add(item.getPackingLaborSummary())))
|
|
|
+ .peek(item -> item.setTotal(item.getSubtotal()))
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
|
+ // 赋值主材bom品名品号
|
|
|
bomSpecService.attributeAssign(result, DocumentByBomVo::getBomSpecId, (item, bomSpec) -> {
|
|
|
item.setBomSpecCode(bomSpec.getCode());
|
|
|
item.setBomSpecName(bomSpec.getName());
|
|
|
});
|
|
|
|
|
|
+ // 合并同加个同规格主材bom,数量相加
|
|
|
Collection<DocumentByBomVo> documentByBomVoCollection = result.stream()
|
|
|
.sorted(Comparator.comparing(DocumentByBomVo::getBomSpecCode))
|
|
|
.collect(Collectors.toMap(
|
|
|
item -> item.getUnitPrice() + ":" + item.getBomSpecId(),
|
|
|
Function.identity(),
|
|
|
(v1, v2) -> {
|
|
|
-
|
|
|
+ v1.setQuantity(v1.getQuantity().add(v2.getQuantity()));
|
|
|
+ v1.setLaserLogoSummary(v1.getLaserLogoSummary().add(v2.getLaserLogoSummary()));
|
|
|
+ v1.setLaserMitochondrialSummary(v1.getLaserMitochondrialSummary().add(v2.getLaserMitochondrialSummary()));
|
|
|
+ v1.setLssueFeeSummary(v1.getLssueFeeSummary().add(v2.getLssueFeeSummary()));
|
|
|
+ v1.setDeliveryMaterialsFeeSummary(v1.getDeliveryMaterialsFeeSummary().add(v2.getDeliveryMaterialsFeeSummary()));
|
|
|
+ v1.setPackingLaborSummary(v1.getPackingLaborSummary().add(v2.getPackingLaborSummary()));
|
|
|
+ v1.setSubtotal(v1.getSubtotal().add(v2.getSubtotal()));
|
|
|
+ v1.setTotal(v1.getSubtotal());
|
|
|
return v1;
|
|
|
}
|
|
|
)).values();
|
|
|
|
|
|
-
|
|
|
+ // 赋值合并后结果
|
|
|
result = new ArrayList<>(documentByBomVoCollection);
|
|
|
|
|
|
+ // 包材bom
|
|
|
+ List<OrderSkuBom> orderSkuBomList = orderSkuBomService.list(q -> q.in(OrderSkuBom::getOrderId, ordedrIdList));
|
|
|
+ List<DocumentByBomVo> bomVoList = orderSkuBomList.stream().map(item ->
|
|
|
+ DocumentByBomVo.builder()
|
|
|
+ .bomSpecId(item.getBomSpecId())
|
|
|
+ .quantity(item.getQuantity())
|
|
|
+ .unitPrice(item.getUnitPrice())
|
|
|
+ .subtotal(item.getUnitPrice().multiply(item.getQuantity()))
|
|
|
+ .total(item.getUnitPrice().multiply(item.getQuantity()))
|
|
|
+ .build()
|
|
|
+ ).collect(Collectors.toList());
|
|
|
+
|
|
|
+ // 赋值包材bom品名品号
|
|
|
+ bomSpecService.attributeAssign(bomVoList, DocumentByBomVo::getBomSpecId, (item, bomSpec) -> {
|
|
|
+ item.setBomSpecCode(bomSpec.getCode());
|
|
|
+ item.setBomSpecName(bomSpec.getName());
|
|
|
+ });
|
|
|
+
|
|
|
+ // 合并同加个同规格包材bom,数量相加
|
|
|
+ Collection<DocumentByBomVo> bomValues = bomVoList.stream()
|
|
|
+ .sorted(Comparator.comparing(DocumentByBomVo::getBomSpecCode))
|
|
|
+ .collect(Collectors.toMap(
|
|
|
+ item -> item.getUnitPrice() + ":" + item.getBomSpecId(),
|
|
|
+ Function.identity(),
|
|
|
+ (v1, v2) -> {
|
|
|
+ v1.setQuantity(v1.getQuantity().add(v2.getQuantity()));
|
|
|
+ v1.setSubtotal(v1.getSubtotal().add(v2.getSubtotal()));
|
|
|
+ v1.setTotal(v1.getSubtotal());
|
|
|
+ return v1;
|
|
|
+ }
|
|
|
+ )).values();
|
|
|
+
|
|
|
+ // 合并主材包材
|
|
|
+ result.addAll(bomValues);
|
|
|
|
|
|
return result;
|
|
|
}
|