Browse Source

对账单bom排序

fgd 1 year ago
parent
commit
5abe9ed632

+ 2 - 2
sd-business/src/main/java/com/sd/business/entity/order/vo/OrderInfoVo.java

@@ -35,7 +35,7 @@ public class OrderInfoVo extends OrderInfo {
     /**
      * 订单包装bom列表
      */
-    private List<OrderInfoVo.OrderPackage> orderPackageList;
+    private List<OrderInfoVo.OrderPackage> orderPackageBomList;
 
     @Getter
     @Setter
@@ -44,7 +44,7 @@ public class OrderInfoVo extends OrderInfo {
         /**
          * bom规格id
          */
-        private Long id;
+        private Long bomSpecId;
 
         /**
          * bom规格编号

+ 0 - 5
sd-business/src/main/java/com/sd/business/entity/statement/vo/DocumentByBomVo.java

@@ -81,9 +81,4 @@ public class DocumentByBomVo {
      */
     private Integer placeholder;
 
-    /**
-     * 订单id
-     */
-    private Long orderId;
-
 }

+ 0 - 6
sd-business/src/main/java/com/sd/business/entity/statement/vo/DocumentBySkuVo.java

@@ -51,10 +51,4 @@ public class DocumentBySkuVo {
      */
     private Integer placeholder;
 
-
-    /**
-     * 订单id
-     */
-    private Long orderId;
-
 }

+ 1 - 0
sd-business/src/main/java/com/sd/business/service/order/impl/OrderOperatingLogServiceImpl.java

@@ -30,6 +30,7 @@ public class OrderOperatingLogServiceImpl extends ServiceImpl<OrderOperatingLogM
     public Page<OrderOperatingLogVo> getPage(OrderOperatingLogSelectDto dto) {
         IWrapper<OrderOperatingLog> wrapper = getWrapper();
         wrapper.orderByDesc("ool", OrderOperatingLog::getId);
+        wrapper.eq("ool", OrderOperatingLog::getOrderId, dto.getId());
         Page<OrderOperatingLogVo> page = this.baseMapper.getPage(dto.getPage(), wrapper);
         List<OrderOperatingLogVo> records = page.getRecords();
         if (records.size() == 0) {

+ 3 - 3
sd-business/src/main/java/com/sd/business/service/order/impl/OrderServiceImpl.java

@@ -231,18 +231,18 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, OrderInfo> implem
 
         List<OrderInfoVo.OrderPackage> orderPackageList = list.stream().map(item -> {
             OrderInfoVo.OrderPackage orderPackage = new OrderInfoVo.OrderPackage();
-            orderPackage.setId(item.getBomSpecId());
+            orderPackage.setBomSpecId(item.getBomSpecId());
             orderPackage.setQuantity(item.getQuantity());
             orderPackage.setCostPrice(item.getCostPrice());
             orderPackage.setInternalSellingPrice(item.getInternalSellingPrice());
             return orderPackage;
         }).collect(Collectors.toList());
         // 赋值品名 品号 销售单价 成本价
-        bomSpecService.attributeAssign(orderPackageList, OrderInfoVo.OrderPackage::getId, (item, bomSpec) -> {
+        bomSpecService.attributeAssign(orderPackageList, OrderInfoVo.OrderPackage::getBomSpecId, (item, bomSpec) -> {
             item.setCode(bomSpec.getCode());
             item.setName(bomSpec.getName());
         });
-        result.setOrderPackageList(orderPackageList);
+        result.setOrderPackageBomList(orderPackageList);
 
         return result;
     }

+ 28 - 31
sd-business/src/main/java/com/sd/business/service/statement/impl/StatementOfAccountServiceImpl.java

@@ -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);