Browse Source

新增订单总体积、总重量

24282 1 year ago
parent
commit
fda59f1d6b

+ 11 - 0
sd-business/src/main/java/com/sd/business/entity/order/vo/IssueBillVo.java

@@ -3,6 +3,7 @@ package com.sd.business.entity.order.vo;
 import lombok.Getter;
 import lombok.Setter;
 
+import java.math.BigDecimal;
 import java.util.Date;
 import java.util.List;
 
@@ -101,6 +102,16 @@ public class IssueBillVo {
     private Long masterOrderId;
 
     /**
+     * 总体积
+     */
+    private BigDecimal totalNetWeight;
+
+    /**
+     * 总净重
+     */
+    private BigDecimal totalVolume;
+
+    /**
      * 合并订单列表
      */
     private List<String> groupOrderCodeList;

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

@@ -2,6 +2,7 @@ package com.sd.business.service.order.impl;
 
 import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.util.ObjectUtil;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.fjhx.file.utils.ObsFileUtil;
 import com.ruoyi.common.core.domain.BaseIdPo;
@@ -97,9 +98,31 @@ public class IssueBillServiceImpl implements IssueBillService {
 
         Map<Long, List<String>> map = orderInfoList.stream().collect(
                 Collectors.groupingBy(OrderInfo::getMasterOrderId, Collectors.mapping(OrderInfo::getCode, Collectors.toList())));
-        records.forEach(item -> {
-            item.setGroupOrderCodeList(map.getOrDefault(item.getId(), Collections.emptyList()));
-        });
+        records.forEach(item -> item.setGroupOrderCodeList(map.getOrDefault(item.getId(), Collections.emptyList())));
+
+
+        QueryWrapper<OrderEncasement> orderEncasementWrapper = new QueryWrapper<>();
+        orderEncasementWrapper.select(
+                "order_id as orderId",
+                "ifnull(sum(netWeight*total),0) totalNetWeight",
+                "ifnull(sum(length*width*height*total/1000000),0) totalVolume"
+        );
+        orderEncasementWrapper.in("order_id", orderIdList);
+        orderEncasementWrapper.groupBy("order_id");
+
+        List<Map<String, Object>> mapList = orderEncasementService.listMaps(orderEncasementWrapper);
+        Map<Long, Map<String, Object>> orderEncasementMap = mapList.stream().collect(Collectors.toMap(item -> (Long) item.get("orderId"), Function.identity()));
+
+        for (IssueBillVo record : records) {
+            Map<String, Object> itemMap = orderEncasementMap.get(record.getId());
+            if (itemMap != null) {
+                record.setTotalNetWeight((BigDecimal) itemMap.get("totalNetWeight"));
+                record.setTotalVolume((BigDecimal) itemMap.get("totalVolume"));
+            } else {
+                record.setTotalNetWeight(BigDecimal.ZERO);
+                record.setTotalVolume(BigDecimal.ZERO);
+            }
+        }
 
         return page;
     }