package com.ruoyi.sales.vo;
|
|
import com.ruoyi.framework.aspectj.lang.annotation.Excel;
|
import com.ruoyi.sales.pojo.SalesLedger;
|
import com.ruoyi.sales.pojo.SalesLedgerProduct;
|
import lombok.Data;
|
|
import java.math.BigDecimal;
|
import java.util.ArrayList;
|
import java.util.Date;
|
import java.util.List;
|
|
/**
|
* 销售台账导出对象(主从表格)。
|
* <p>
|
* 台账字段做纵向合并居中,右侧同行展开该台账下的产品明细,避免出现大片空白单元格。
|
* products 必须是最后一个字段:无产品的台账不会输出产品列,若其后面还有字段会导致列错位。
|
*/
|
@Data
|
public class SalesLedgerExportVo {
|
|
@Excel(name = "销售合同号", needMerge = true)
|
private String salesContractNo;
|
|
@Excel(name = "项目名称", needMerge = true)
|
private String projectName;
|
|
@Excel(name = "录入日期", width = 30, dateFormat = "yyyy-MM-dd", needMerge = true)
|
private Date entryDate;
|
|
@Excel(name = "业务员", needMerge = true)
|
private String salesman;
|
|
@Excel(name = "客户名称", needMerge = true)
|
private String customerName;
|
|
@Excel(name = "录入人", needMerge = true)
|
private String entryPersonName;
|
|
@Excel(name = "合同金额", scale = 2, needMerge = true)
|
private BigDecimal contractAmount;
|
|
@Excel(name = "备注", needMerge = true)
|
private String remarks;
|
|
@Excel(name = "产品明细")
|
private List<Item> products = new ArrayList<>();
|
|
@Data
|
public static class Item {
|
|
@Excel(name = "产品大类")
|
private String productCategory;
|
|
@Excel(name = "规格型号")
|
private String specificationModel;
|
|
@Excel(name = "单位")
|
private String unit;
|
|
@Excel(name = "数量", cellType = Excel.ColumnType.NUMERIC)
|
private BigDecimal quantity;
|
|
@Excel(name = "待发货数量", cellType = Excel.ColumnType.NUMERIC)
|
private BigDecimal noQuantity;
|
|
@Excel(name = "发货状态")
|
private String shippingStatus;
|
|
@Excel(name = "税率(%)", cellType = Excel.ColumnType.NUMERIC)
|
private BigDecimal taxRate;
|
|
@Excel(name = "含税单价(元)", scale = 2)
|
private BigDecimal taxInclusiveUnitPrice;
|
|
@Excel(name = "含税总价(元)", scale = 2)
|
private BigDecimal taxInclusiveTotalPrice;
|
|
@Excel(name = "不含税总价(元)", scale = 2)
|
private BigDecimal taxExclusiveTotalPrice;
|
|
public static Item fromProduct(SalesLedgerProduct product) {
|
Item item = new Item();
|
item.setProductCategory(product.getProductCategory());
|
item.setSpecificationModel(product.getSpecificationModel());
|
item.setUnit(product.getUnit());
|
item.setQuantity(product.getQuantity());
|
item.setNoQuantity(product.getNoQuantity());
|
item.setShippingStatus(product.getShippingStatus());
|
item.setTaxRate(product.getTaxRate());
|
item.setTaxInclusiveUnitPrice(product.getTaxInclusiveUnitPrice());
|
item.setTaxInclusiveTotalPrice(product.getTaxInclusiveTotalPrice());
|
item.setTaxExclusiveTotalPrice(product.getTaxExclusiveTotalPrice());
|
return item;
|
}
|
}
|
|
public static SalesLedgerExportVo fromLedger(SalesLedger ledger) {
|
SalesLedgerExportVo vo = new SalesLedgerExportVo();
|
vo.setSalesContractNo(ledger.getSalesContractNo());
|
vo.setProjectName(ledger.getProjectName());
|
vo.setEntryDate(ledger.getEntryDate());
|
vo.setSalesman(ledger.getSalesman());
|
vo.setCustomerName(ledger.getCustomerName());
|
vo.setEntryPersonName(ledger.getEntryPersonName());
|
vo.setContractAmount(ledger.getContractAmount());
|
vo.setRemarks(ledger.getRemarks());
|
return vo;
|
}
|
|
public void addProduct(SalesLedgerProduct product) {
|
this.products.add(Item.fromProduct(product));
|
}
|
}
|