Browse Source

货物交接单

24282 1 năm trước cách đây
mục cha
commit
ffab11123d

+ 8 - 0
sd-business/src/main/java/com/sd/business/controller/statement/StatementOfAccountMergeController.java

@@ -117,4 +117,12 @@ public class StatementOfAccountMergeController {
         statementOfAccountMergeService.exportSalesRevenueCostData(dto);
     }
 
+    /**
+     * 货物交接单
+     */
+    @PostMapping("/exportDeliveryOfGoodsExcel")
+    public void exportExcel(@RequestBody List<Long> idList) {
+        statementOfAccountMergeService.exportDeliveryOfGoodsExcel(idList);
+    }
+
 }

+ 5 - 0
sd-business/src/main/java/com/sd/business/entity/outbound/po/OutboundOrder.java

@@ -61,4 +61,9 @@ public class OutboundOrder extends BasePo {
      */
     private Long outboundTimestamp;
 
+    /**
+     * 物流单号
+     */
+    private String express;
+
 }

+ 49 - 0
sd-business/src/main/java/com/sd/business/entity/statement/vo/DeliveryOfGoodsVO.java

@@ -0,0 +1,49 @@
+package com.sd.business.entity.statement.vo;
+
+import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
+import com.alibaba.excel.annotation.ExcelProperty;
+import com.alibaba.excel.annotation.write.style.ColumnWidth;
+import lombok.Getter;
+import lombok.Setter;
+
+import java.math.BigDecimal;
+import java.util.Date;
+
+@Getter
+@Setter
+@ExcelIgnoreUnannotated
+public class DeliveryOfGoodsVO {
+
+    @ColumnWidth(20)
+    @ExcelProperty(value = "出入库单号")
+    private String receiptNumber;
+
+    @ColumnWidth(20)
+    @ExcelProperty(value = "业务日期")
+    private Date businessDate;
+
+    @ColumnWidth(20)
+    @ExcelProperty(value = "仓库")
+    private String warehouse;
+
+    @ColumnWidth(30)
+    @ExcelProperty(value = "规格")
+    private String spec;
+
+    @ColumnWidth(20)
+    @ExcelProperty(value = "出库数量")
+    private BigDecimal outboundQuantity;
+
+    @ColumnWidth(20)
+    @ExcelProperty(value = "订单号")
+    private String orderCode;
+
+    @ColumnWidth(20)
+    @ExcelProperty(value = "系统订单号")
+    private String orderWlnCode;
+
+    @ColumnWidth(20)
+    @ExcelProperty(value = "快递单号")
+    private String express;
+
+}

+ 8 - 0
sd-business/src/main/java/com/sd/business/service/statement/StatementOfAccountMergeService.java

@@ -56,6 +56,7 @@ public interface StatementOfAccountMergeService {
 
     /**
      * 查询销售收入成本分页
+     *
      * @param dto
      * @return
      */
@@ -63,7 +64,14 @@ public interface StatementOfAccountMergeService {
 
     /**
      * 导出销售收入成本数据
+     *
      * @param dto
      */
     void exportSalesRevenueCostData(SalesRevenueCostSelectDto dto);
+
+    /**
+     * 导出货物交接单excel
+     */
+    void exportDeliveryOfGoodsExcel(List<Long> idList);
+
 }

+ 95 - 0
sd-business/src/main/java/com/sd/business/service/statement/impl/StatementOfAccountMergeServiceImpl.java

@@ -19,6 +19,7 @@ import com.sd.business.entity.order.enums.OrderClassifyEnum;
 import com.sd.business.entity.order.po.OrderInfo;
 import com.sd.business.entity.order.po.OrderSku;
 import com.sd.business.entity.order.po.OrderSkuProductionCost;
+import com.sd.business.entity.outbound.po.OutboundOrder;
 import com.sd.business.entity.sku.bo.SkuSpecBo;
 import com.sd.business.entity.sku.po.SkuSpec;
 import com.sd.business.entity.statement.dto.*;
@@ -30,6 +31,7 @@ import com.sd.business.service.inventory.InventoryFinishedOrderDetailService;
 import com.sd.business.service.order.OrderService;
 import com.sd.business.service.order.OrderSkuProductionCostService;
 import com.sd.business.service.order.OrderSkuService;
+import com.sd.business.service.outbound.OutboundOrderService;
 import com.sd.business.service.sku.SkuSpecService;
 import com.sd.business.service.statement.StatementOfAccountExportService;
 import com.sd.business.service.statement.StatementOfAccountMergeService;
@@ -38,9 +40,11 @@ import com.sd.business.strategy.impl.DefaultExportStrategy;
 import com.sd.business.strategy.impl.DocumentByOrderExcelExportStrategy;
 import com.sd.business.strategy.impl.SalesOutWarehouseDetailsExportStrategy;
 import com.sd.framework.util.Assert;
+import com.sd.framework.util.excel.util.ExcelUtil;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import javax.servlet.http.HttpServletResponse;
 import java.math.BigDecimal;
 import java.math.RoundingMode;
 import java.util.*;
@@ -59,6 +63,9 @@ import java.util.stream.Collectors;
 public class StatementOfAccountMergeServiceImpl implements StatementOfAccountMergeService {
 
     @Autowired
+    private HttpServletResponse response;
+
+    @Autowired
     private StatementOfAccountService statementOfAccountService;
 
     @Autowired
@@ -85,6 +92,9 @@ public class StatementOfAccountMergeServiceImpl implements StatementOfAccountMer
     @Autowired
     private InventoryFinishedOrderDetailService inventoryFinishedOrderDetailService;
 
+    @Autowired
+    private OutboundOrderService outboundOrderService;
+
     @Override
     public Page<StatementOfAccountMergePageVo> getPage(StatementOfAccountMergePageDto dto) {
 
@@ -510,6 +520,15 @@ public class StatementOfAccountMergeServiceImpl implements StatementOfAccountMer
                 DateUtil.formatDate(new Date()) + " 销售收入成本表");
     }
 
+    @Override
+    public void exportDeliveryOfGoodsExcel(List<Long> idList) {
+        List<String> orderWlnCodeList = getOrderWlnCodeList(idList);
+        List<OutboundOrder> outboundOrderList = getOutboundOrderList(orderWlnCodeList);
+        List<DeliveryOfGoodsVO> deliveryOfGoodsVOList = getDeliveryOfGoodsVOList(outboundOrderList);
+        ExcelUtil.export(response, "货物交接单", "货物交接单明细", deliveryOfGoodsVOList, DeliveryOfGoodsVO.class);
+    }
+
+
     private List<Long> getIdList(GetDocumentDto dto) {
 
         String idGroupConcat = dto.getIdGroupConcat();
@@ -525,4 +544,80 @@ public class StatementOfAccountMergeServiceImpl implements StatementOfAccountMer
         return idList;
     }
 
+    /**
+     * 获取万里牛订单编号列表
+     *
+     * @param idList 对账单id列表
+     * @return 万里牛订单编号列表
+     */
+    private List<String> getOrderWlnCodeList(List<Long> idList) {
+        if (idList.isEmpty()) {
+            return Collections.emptyList();
+        }
+        List<OrderInfo> list = orderService.list(q -> q.in(OrderInfo::getStatementOfAccountId, idList));
+        return list.stream().map(OrderInfo::getWlnCode).collect(Collectors.toList());
+    }
+
+    /**
+     * 获取出库单列表
+     *
+     * @param orderWlnCodeList 万里牛订单编号列表
+     * @return 出库单列表
+     */
+    private List<OutboundOrder> getOutboundOrderList(List<String> orderWlnCodeList) {
+        if (orderWlnCodeList.isEmpty()) {
+            return Collections.emptyList();
+        }
+        return outboundOrderService.list(q -> q.in(OutboundOrder::getOrderWlnCode, orderWlnCodeList));
+    }
+
+    /**
+     * 获取货物交接单数据列表
+     *
+     * @param outboundOrderList 出库单列表
+     * @return 货物交接单数据列表
+     */
+    private List<DeliveryOfGoodsVO> getDeliveryOfGoodsVOList(List<OutboundOrder> outboundOrderList) {
+        if (outboundOrderList.isEmpty()) {
+            return Collections.emptyList();
+        }
+
+        List<String> skuSpecCodeList = outboundOrderList.stream().map(OutboundOrder::getSkuSpecCode).collect(Collectors.toList());
+        Map<String, String> map = skuSpecService.mapKV(SkuSpec::getCode, SkuSpec::getName, q -> q.in(SkuSpec::getCode, skuSpecCodeList));
+
+        return outboundOrderList.stream()
+                .map(item -> {
+                    DeliveryOfGoodsVO deliveryOfGoodsVO = new DeliveryOfGoodsVO();
+                    deliveryOfGoodsVO.setReceiptNumber(item.getCode());
+                    deliveryOfGoodsVO.setBusinessDate(item.getOutboundTime());
+                    deliveryOfGoodsVO.setWarehouse(getWarehouseName(item.getStorageCode()));
+                    deliveryOfGoodsVO.setSpec(map.get(item.getSkuSpecCode()));
+                    deliveryOfGoodsVO.setOutboundQuantity(item.getQuantity());
+                    deliveryOfGoodsVO.setOrderCode(item.getOrderCode());
+                    deliveryOfGoodsVO.setOrderWlnCode(item.getOrderWlnCode());
+                    deliveryOfGoodsVO.setExpress(item.getExpress());
+                    return deliveryOfGoodsVO;
+                })
+                .sorted(Comparator.comparing(DeliveryOfGoodsVO::getBusinessDate))
+                .collect(Collectors.toList());
+    }
+
+
+    private String getWarehouseName(String code) {
+        if (Objects.equals(code, "T007")) {
+            return "胜德体育仓-佰卓";
+        }
+        if (Objects.equals(code, "B012")) {
+            return "胜德体育仓-A9";
+        }
+        if (Objects.equals(code, "B013")) {
+            return "胜德体育仓-A1";
+        }
+        if (Objects.equals(code, "B014")) {
+            return "胜德体育仓-A8";
+        }
+
+        return code;
+    }
+
 }

+ 1 - 0
sd-wln/src/main/java/com/sd/wln/service/impl/WlnOutboundOrderServiceImpl.java

@@ -63,6 +63,7 @@ public class WlnOutboundOrderServiceImpl implements WlnOutboundOrderService {
                 outboundOrder.setQuantity(itemDetails.getBigDecimal("nums"));
                 outboundOrder.setOutboundTime(item.getDate("modify_time"));
                 outboundOrder.setOutboundTimestamp(item.getLong("modify_time"));
+                outboundOrder.setExpress(item.getString("express"));
                 outboundOrderList.add(outboundOrder);
             }