Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix sale and purchase table data export api #251

Merged
merged 10 commits into from
Dec 2, 2023
22 changes: 19 additions & 3 deletions core/domain/src/main/java/com/wansenai/bo/PurchaseDataBO.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.wansenai.utils.excel.ExcelExport;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
Expand All @@ -30,42 +31,57 @@ public class PurchaseDataBO {
@JsonFormat(shape = JsonFormat.Shape.STRING)
private Long warehouseId;

@ExcelExport(value = "仓库名称")
private String warehouseName;

@ExcelExport(value = "条码")
private String barCode;

@JsonFormat(shape = JsonFormat.Shape.STRING)
private Long productId;

@ExcelExport(value = "商品名称")
private String productName;

private String productUnit;
@ExcelExport(value = "规格")
private String productStandard;

@ExcelExport(value = "型号")
private String productModel;

private String productStandard;

@ExcelExport(value = "颜色")
private String productColor;

@ExcelExport(value = "库存")
private Integer stock;

@ExcelExport(value = "单位")
private String productUnit;

@ExcelExport(value = "数量")
private Integer productNumber;

@JsonSerialize(using = BigDecimalSerializerBO.class)
@ExcelExport(value = "单价")
private BigDecimal unitPrice;

@JsonSerialize(using = BigDecimalSerializerBO.class)
@ExcelExport(value = "金额")
private BigDecimal amount;

@JsonSerialize(using = BigDecimalSerializerBO.class)
@ExcelExport(value = "税率(%)")
private BigDecimal taxRate;

@JsonSerialize(using = BigDecimalSerializerBO.class)
@ExcelExport(value = "税额")
private BigDecimal taxAmount;

@JsonSerialize(using = BigDecimalSerializerBO.class)
@ExcelExport(value = "价税合计")
private BigDecimal taxTotalPrice;

@ExcelExport(value = "备注")
private String remark;

}
24 changes: 20 additions & 4 deletions core/domain/src/main/java/com/wansenai/bo/SalesDataBO.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.wansenai.utils.excel.ExcelExport;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
Expand All @@ -30,41 +31,56 @@ public class SalesDataBO {
@JsonFormat(shape = JsonFormat.Shape.STRING)
private Long warehouseId;

@ExcelExport("仓库名称")
private String warehouseName;

@ExcelExport("条码")
private String barCode;

@JsonFormat(shape = JsonFormat.Shape.STRING)
private Long productId;

@ExcelExport("商品名称")
private String productName;

private String productModel;
@ExcelExport("规格")
private String productStandard;

private String productUnit;
@ExcelExport("型号")
private String productModel;

@ExcelExport("颜色")
private String productColor;

private String productStandard;

@ExcelExport("库存")
private Integer stock;

@ExcelExport("单位")
private String productUnit;

@ExcelExport("数量")
private Integer productNumber;

@JsonSerialize(using = BigDecimalSerializerBO.class)
@ExcelExport("单价")
private BigDecimal unitPrice;

@JsonSerialize(using = BigDecimalSerializerBO.class)
@ExcelExport("金额")
private BigDecimal amount;

@JsonSerialize(using = BigDecimalSerializerBO.class)
@ExcelExport("税率(%)")
private BigDecimal taxRate;

@JsonSerialize(using = BigDecimalSerializerBO.class)
@ExcelExport("税额")
private BigDecimal taxAmount;

@JsonSerialize(using = BigDecimalSerializerBO.class)
@ExcelExport("价税合计")
private BigDecimal taxTotalPrice;

@ExcelExport("备注")
private String remark;
}
19 changes: 16 additions & 3 deletions core/domain/src/main/java/com/wansenai/bo/ShipmentsDataBO.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.wansenai.utils.excel.ExcelExport;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
Expand All @@ -18,34 +19,46 @@ public class ShipmentsDataBO {
@JsonFormat(shape = JsonFormat.Shape.STRING)
private Long warehouseId;

@ExcelExport(value = "仓库名称")
private String warehouseName;

private String productCode;

@ExcelExport(value = "条码")
private String barCode;

@JsonFormat(shape = JsonFormat.Shape.STRING)
private Long productId;

@ExcelExport(value = "商品名称")
private String productName;

private String productUnit;
@ExcelExport(value = "规格")
private String productStandard;

@ExcelExport(value = "型号")
private String productModel;

@ExcelExport(value = "颜色")
private String productColor;

private String productStandard;

@ExcelExport(value = "库存")
private Integer stock;

@ExcelExport(value = "单位")
private String productUnit;

@ExcelExport(value = "数量")
private Integer productNumber;

@JsonSerialize(using = BigDecimalSerializerBO.class)
@ExcelExport(value = "单价")
private BigDecimal unitPrice;

@JsonSerialize(using = BigDecimalSerializerBO.class)
@ExcelExport(value = "金额")
private BigDecimal amount;

@ExcelExport(value = "备注")
private String remark;
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,6 @@ public class QueryPurchaseOrderDTO {
private Long page;

private Long pageSize;

private Boolean isExportDetail;
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,6 @@ public class QueryPurchaseRefundDTO {
private Long page;

private Long pageSize;

private Boolean isExportDetail;
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,6 @@ public class QueryPurchaseStorageDTO {
private Long page;

private Long pageSize;

private Boolean isExportDetail;
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,6 @@ public class QueryRetailRefundDTO {
private Long page;

private Long pageSize;

private Boolean isExportDetail;
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,6 @@ public class QueryShipmentsDTO {
private Long page;

private Long pageSize;

private Boolean isExportDetail;
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,6 @@ public class QuerySaleOrderDTO {
private Long page;

private Long pageSize;

private Boolean isExportDetail;
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,6 @@ public class QuerySaleRefundDTO {
private Long page;

private Long pageSize;

private Boolean isExportDetail;
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,6 @@ public class QuerySaleShipmentsDTO {
private Long page;

private Long pageSize;

private Boolean isExportDetail;
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import com.wansenai.bo.BigDecimalSerializerBO;
import com.wansenai.bo.FileDataBO;
import com.wansenai.bo.ShipmentsDataBO;
import com.wansenai.utils.excel.ExcelExport;
import lombok.Builder;
import lombok.Data;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1317,29 +1317,119 @@ public Response<Page<PurchaseArrearsVO>> getPurchaseArrearsPage(QueryPurchaseArr
}

@Override
public void exportPurchaseOrderExcel(QueryPurchaseOrderDTO queryPurchaseOrderDTO, HttpServletResponse response) throws Exception {
var data = getPurchaseOrderList(queryPurchaseOrderDTO);
if (!data.isEmpty()) {
var file = ExcelUtils.exportFile(ExcelUtils.DEFAULT_FILE_PATH, "采购订单", data);
ExcelUtils.downloadExcel(file, "采购订单", response);
public void exportPurchaseOrderExcel(QueryPurchaseOrderDTO queryPurchaseOrderDTO, HttpServletResponse response) {
var exportMap = new ConcurrentHashMap<String, List<List<Object>>>();
var mainData = getPurchaseOrderList(queryPurchaseOrderDTO);
if (!mainData.isEmpty()) {
if (queryPurchaseOrderDTO.getIsExportDetail()) {
var subData = new ArrayList<PurchaseDataBO>();
for (PurchaseOrderVO purchaseOrderVO : mainData) {
var detail = getPurchaseOrderDetail(purchaseOrderVO.getId()).getData().getTableData();
if (!detail.isEmpty()) {
detail.forEach(item -> {
var purchaseDataBo = PurchaseDataBO.builder()
.warehouseName(item.getWarehouseName())
.barCode(item.getBarCode())
.productName(item.getProductName())
.productStandard(item.getProductStandard())
.productModel(item.getProductModel())
.productColor(item.getProductColor())
.productUnit(item.getProductUnit())
.productNumber(item.getProductNumber())
.stock(item.getStock())
.unitPrice(item.getUnitPrice())
.amount(item.getAmount())
.taxRate(item.getTaxRate())
.taxAmount(item.getTaxAmount())
.taxTotalPrice(item.getTaxTotalPrice())
.remark(item.getRemark())
.build();
subData.add(purchaseDataBo);
});
}
exportMap.put("采购订单明细", ExcelUtils.getSheetData(subData));
}
}
exportMap.put("采购订单", ExcelUtils.getSheetData(mainData));
ExcelUtils.exportManySheet(response, "采购订单", exportMap);
}
}

@Override
public void exportPurchaseStorageExcel(QueryPurchaseStorageDTO queryPurchaseStorageDTO, HttpServletResponse response) throws Exception {
var data = getPurchaseStorageList(queryPurchaseStorageDTO);
if (!data.isEmpty()) {
var file = ExcelUtils.exportFile(ExcelUtils.DEFAULT_FILE_PATH, "采购入库", data);
ExcelUtils.downloadExcel(file, "采购入库", response);
var exportMap = new ConcurrentHashMap<String, List<List<Object>>>();
var mainData = getPurchaseStorageList(queryPurchaseStorageDTO);
if (!mainData.isEmpty()) {
if (queryPurchaseStorageDTO.getIsExportDetail()) {
var subData = new ArrayList<PurchaseDataBO>();
for (PurchaseStorageVO purchaseStorageVO : mainData) {
var detail = getPurchaseStorageDetail(purchaseStorageVO.getId()).getData().getTableData();
if (!detail.isEmpty()) {
detail.forEach(item -> {
var purchaseDataBo = PurchaseDataBO.builder()
.warehouseName(item.getWarehouseName())
.barCode(item.getBarCode())
.productName(item.getProductName())
.productStandard(item.getProductStandard())
.productModel(item.getProductModel())
.productColor(item.getProductColor())
.productUnit(item.getProductUnit())
.productNumber(item.getProductNumber())
.stock(item.getStock())
.unitPrice(item.getUnitPrice())
.amount(item.getAmount())
.taxRate(item.getTaxRate())
.taxAmount(item.getTaxAmount())
.taxTotalPrice(item.getTaxTotalPrice())
.remark(item.getRemark())
.build();
subData.add(purchaseDataBo);
});
}
exportMap.put("采购入库明细", ExcelUtils.getSheetData(subData));
}
}
exportMap.put("采购入库", ExcelUtils.getSheetData(mainData));
ExcelUtils.exportManySheet(response, "采购入库", exportMap);
}
}

@Override
public void exportPurchaseRefundExcel(QueryPurchaseRefundDTO queryPurchaseRefundDTO, HttpServletResponse response) throws Exception {
var data = getPurchaseRefundList(queryPurchaseRefundDTO);
if (!data.isEmpty()) {
var file = ExcelUtils.exportFile(ExcelUtils.DEFAULT_FILE_PATH, "采购退货", data);
ExcelUtils.downloadExcel(file, "采购退货", response);
var exportMap = new ConcurrentHashMap<String, List<List<Object>>>();
var mainData = getPurchaseRefundList(queryPurchaseRefundDTO);
if (!mainData.isEmpty()) {
if (queryPurchaseRefundDTO.getIsExportDetail()) {
var subData = new ArrayList<PurchaseDataBO>();
for (PurchaseRefundVO purchaseRefundVO : mainData) {
var detail = getPurchaseRefundDetail(purchaseRefundVO.getId()).getData().getTableData();
if (!detail.isEmpty()) {
detail.forEach(item -> {
var purchaseDataBo = PurchaseDataBO.builder()
.warehouseName(item.getWarehouseName())
.barCode(item.getBarCode())
.productName(item.getProductName())
.productStandard(item.getProductStandard())
.productModel(item.getProductModel())
.productColor(item.getProductColor())
.productUnit(item.getProductUnit())
.productNumber(item.getProductNumber())
.stock(item.getStock())
.unitPrice(item.getUnitPrice())
.amount(item.getAmount())
.taxRate(item.getTaxRate())
.taxAmount(item.getTaxAmount())
.taxTotalPrice(item.getTaxTotalPrice())
.remark(item.getRemark())
.build();
subData.add(purchaseDataBo);
});
}
exportMap.put("采购退货明细", ExcelUtils.getSheetData(subData));
}
}
exportMap.put("采购退货", ExcelUtils.getSheetData(mainData));
ExcelUtils.exportManySheet(response, "采购退货", exportMap);
}
}
}
Loading