订单导出或者其他单子导出数据

Controller

**@ApiOperation(value = "导出询价但详情")
    @RequestMapping(name = "导出询价但详情", value = {"/download"}, method = RequestMethod.GET)
    public void download(HttpServletResponse res, @RequestParam(value = "inquiryCode", required = false) String inquiryCode, @RequestParam(value = "customerCode", required = false) String customerCode, @RequestParam(value = "status", required = false) String status) throws IOException {
        String fileName = "Inquiry" + System.currentTimeMillis() + ".xls";
        String[] headers = {"询价单编号", "客户编号", "始发国家", "始发仓库", "询价单状态", "是否带电", "重", "长", "宽", "高", "收件人", "收件人公司", "收件人国家", "收件人省/州", "收件人城市", "收件人地址1", "收件人地址2", "收件人门牌号", "收件人邮箱", "收件人联系方式", "收件人邮编", "备注", "订单号"};
        String[] fieldNames = {"inquiryCode", "customerCode", "origin", "originWarehouse", "statusName", "batteryName", "weight", "length", "width", "height", "recName", "recCompany", "recCountry", "recProvince", "recCity", "address1", "address2", "recDoor", "recEmail", "recMobile", "postCode", "comment", "orderNo"};
        Collection<SearchFilter> filters = Lists.newArrayList();
        if (inquiryCode != null && !inquiryCode.equals("")) {
            SearchFilter.addFilter(filters, SearchFilter.build("inquiryCode", Operator.EQ, inquiryCode));
        }
        if (customerCode != null && !customerCode.equals("")) {
            SearchFilter.addFilter(filters, SearchFilter.build("customerCode", Operator.EQ, customerCode));
        }
        if (status != null && !status.equals("")) {
            SearchFilter.addFilter(filters, SearchFilter.build("status", Operator.EQ, Integer.parseInt(status)));
        }
        SearchFilter.addFilter(filters, SearchFilter.build("deleteFlag", Operator.EQ,0));
        Specification<WlInquiry> specification = ExtendedDynamicSpecifications.bySearchFilter(filters);
        List<WlInquiry> list = wlInquiryService.findAll(specification);
        List<WlInquiry> endList = new ArrayList<>();
        if (list != null) {
            for (WlInquiry inquiry : list) {
                Integer myStatus = inquiry.getStatus();
                //询价单类型
                if (myStatus == 0) {
                    inquiry.setStatusName("待处理");
                } else if (myStatus == 1) {
                    inquiry.setStatusName("已录销售成本");
                } else if (myStatus == 2) {
                    inquiry.setStatusName("已报价");
                }
                //门点类型名
                if (inquiry.getBattery() == 0) {
                    inquiry.setBatteryName("否");
                } else if (inquiry.getBattery() == 1) {
                    inquiry.setBatteryName("是");
                }
                Result result = wlInquiryService.queryOrderNos(inquiry.getInquiryCode());
                if (result.getCode().equals("00000")) {
                    List<String> orderNos = (List<String>) result.getData();
                    if (orderNos != null && orderNos.size() > 0) {
                        for (String orderNo : orderNos) {
                            WlInquiry wlInquiry1=new WlInquiry();
                            BeanUtils.copyProperties(inquiry, wlInquiry1);
                            wlInquiry1.setOrderNo(orderNo);
                            endList.add(wlInquiry1);
                        }
                    } else {
                        endList.add(inquiry);
                    }
                } else {
                    endList.add(inquiry);
                }
            }
        }
        new ExportExcel<WlInquiry>().exportExcel(fileName, headers, endList, fieldNames, res, null);
    }**

pojo

`@DynamicInsert
@DynamicUpdate
@Entity
@Table(name = “wl_inquiry”, schema = “sdorder”)
public class WlInquiry extends OrderListenerEntity {
@ApiModelProperty(value = “询价单编号”)
private String inquiryCode;
@ApiModelProperty(value = “客户代码”)
private String customerCode;
@ApiModelProperty(value = “始发地”)
private String origin;
@ApiModelProperty(value = “始发仓库”)
private String originWarehouse;
@ApiModelProperty(value = “派送服务编号”)
private String transferCode;
@ApiModelProperty(value = “派送服务名称”)
private String transferName;
@ApiModelProperty(value = “是否带电 0 否,1 是”)
private Integer battery;
@ApiModelProperty(value = “包裹重”)
private BigDecimal weight;
@ApiModelProperty(value = “长”)
private BigDecimal length;
@ApiModelProperty(value = “宽”)
private BigDecimal width;
@ApiModelProperty(value = “高”)
private BigDecimal height;
@ApiModelProperty(value = “收件人”)
private String recName;
@ApiModelProperty(value = “收件人公司”)
private String recCompany;
@ApiModelProperty(value = “收件人邮箱”)
private String recEmail;
@ApiModelProperty(value = “收件人手机号”)
private String recMobile;
@ApiModelProperty(value = “收件人国家”)
private String recCountry;
@ApiModelProperty(value = “收件人省/州”)
private String recProvince;
@ApiModelProperty(value = “收件人城市”)
private String recCity;
@ApiModelProperty(value = “收件人门牌号”)
private String recDoor;
@ApiModelProperty(value = “目的地邮编”)
private String postCode;
@ApiModelProperty(value = “地址1”)
private String address1;
@ApiModelProperty(value = “地址2”)
private String address2;
@ApiModelProperty(value = “备注”)
private String comment;
@ApiModelProperty(value = “询价单状态 0 待处理,1已录销售成本,2已报价”)
private Integer status;
@ApiModelProperty(value = “报价币种”)
private String currency;
@ApiModelProperty(value = “报价金额”)
private BigDecimal price;
@ApiModelProperty(value = “录入成本人”)
private String serviceCode;
@JsonFormat(pattern = “yyyy-MM-dd HH:mm:ss”, timezone = “GMT+08”)
@ApiModelProperty(value = “录入成本时间”)
private Date serviceTime;
@JsonFormat(pattern = “yyyy-MM-dd HH:mm:ss”, timezone = “GMT+08”)
@ApiModelProperty(value = “报价截止开始时间”)
private Date deadBeginTime;
@JsonFormat(pattern = “yyyy-MM-dd HH:mm:ss”, timezone = “GMT+08”)
@ApiModelProperty(value = “报价截止结束时间”)
private Date deadEndTime;
@ApiModelProperty(value = “录入成本备注”)
private String serviceComment;
@ApiModelProperty(value = “销售成本”)
private BigDecimal salePrice;
@ApiModelProperty(value = “录入销售人”)
private String saleCode;
@JsonFormat(pattern = “yyyy-MM-dd HH:mm:ss”, timezone = “GMT+08”)
@ApiModelProperty(value = “录入销售时间”)
private Date saleTime;
@ApiModelProperty(value = “录入销售备注”)
private String saleComment;
private String orgCode;
private Integer orgType;
private String createUser;
private String updateUser;
private Integer mode;
@ApiModelProperty(“判断是否是当前登录人创建”)
private String isCreate;
private String orderNo;
private String statusName;
private String BatteryName;
private List serviceData = Lists.newArrayList();

@Id
@Column(name = "inquiry_code", nullable = false, length = 40)
public String getInquiryCode() {
    return inquiryCode;
}

public void setInquiryCode(String inquiryCode) {
    this.inquiryCode = inquiryCode;
}

@Basic
@Column(name = "customer_code", nullable = true, length = 50)
public String getCustomerCode() {
    return customerCode;
}

public void setCustomerCode(String customerCode) {
    this.customerCode = customerCode;
}

@Basic
@Column(name = "origin", nullable = true, length = 50)
public String getOrigin() {
    return origin;
}

public void setOrigin(String origin) {
    this.origin = origin;
}

@Basic
@Column(name = "origin_warehouse", nullable = true, length = 40)
public String getOriginWarehouse() {
    return originWarehouse;
}

public void setOriginWarehouse(String originWarehouse) {
    this.originWarehouse = originWarehouse;
}

@Basic
@Column(name = "transfer_code", nullable = true, length = 40)
public String getTransferCode() {
    return transferCode;
}

public void setTransferCode(String transferCode) {
    this.transferCode = transferCode;
}

@Basic
@Column(name = "transfer_name", nullable = true, length = 40)
public String getTransferName() {
    return transferName;
}

public void setTransferName(String transferName) {
    this.transferName = transferName;
}

@Basic
@Column(name = "battery", nullable = true)
public Integer getBattery() {
    return battery;
}

public void setBattery(Integer battery) {
    this.battery = battery;
}

@Basic
@Column(name = "weight", nullable = true, precision = 2)
public BigDecimal getWeight() {
    return weight;
}

public void setWeight(BigDecimal weight) {
    this.weight = weight;
}

@Basic
@Column(name = "length", nullable = true, precision = 6)
public BigDecimal getLength() {
    return length;
}

public void setLength(BigDecimal length) {
    this.length = length;
}

@Basic
@Column(name = "width", nullable = true, precision = 6)
public BigDecimal getWidth() {
    return width;
}

public void setWidth(BigDecimal width) {
    this.width = width;
}

@Basic
@Column(name = "height", nullable = true, precision = 6)
public BigDecimal getHeight() {
    return height;
}

public void setHeight(BigDecimal height) {
    this.height = height;
}

@Basic
@Column(name = "post_code", nullable = true, length = 50)
public String getPostCode() {
    return postCode;
}

public void setPostCode(String postCode) {
    this.postCode = postCode;
}

@Basic
@Column(name = "rec_name")
public String getRecName() {
    return recName;
}

public void setRecName(String recName) {
    this.recName = recName;
}

@Basic
@Column(name = "rec_company")
public String getRecCompany() {
    return recCompany;
}

public void setRecCompany(String recCompany) {
    this.recCompany = recCompany;
}

@Basic
@Column(name = "rec_email")
public String getRecEmail() {
    return recEmail;
}

public void setRecEmail(String recEmail) {
    this.recEmail = recEmail;
}

@Basic
@Column(name = "rec_mobile")
public String getRecMobile() {
    return recMobile;
}

public void setRecMobile(String recMobile) {
    this.recMobile = recMobile;
}

@Basic
@Column(name = "rec_country", nullable = true, length = 40)
public String getRecCountry() {
    return recCountry;
}

public void setRecCountry(String recCountry) {
    this.recCountry = recCountry;
}

@Basic
@Column(name = "rec_province")
public String getRecProvince() {
    return recProvince;
}

public void setRecProvince(String recProvince) {
    this.recProvince = recProvince;
}

@Basic
@Column(name = "rec_city")
public String getRecCity() {
    return recCity;
}

public void setRecCity(String recCity) {
    this.recCity = recCity;
}

@Basic
@Column(name = "rec_door")
public String getRecDoor() {
    return recDoor;
}

public void setRecDoor(String recDoor) {
    this.recDoor = recDoor;
}

@Basic
@Column(name = "address2", length = 40)
public String getAddress2() {
    return address2;
}

public void setAddress2(String address2) {
    this.address2 = address2;
}


@Basic
@Column(name = "address1", nullable = true, length = 40)
public String getAddress1()
{
    return address1;
}

public void setAddress1(String address) {
    this.address1 = address;
}


@Basic
@Column(name = "comment", nullable = true, length = 255)
public String getComment() {
    return comment;
}

public void setComment(String comment) {
    this.comment = comment;
}

@Basic
@Column(name = "status", nullable = false)
public Integer getStatus() {
    return status;
}

public void setStatus(Integer status) {
    this.status = status;
}

@Basic
@Column(name = "currency", nullable = true, length = 10)
public String getCurrency() {
    return currency;
}

public void setCurrency(String currency) {
    this.currency = currency;
}

@Basic
@Column(name = "price", nullable = true, precision = 2)
public BigDecimal getPrice() {
    return price;
}

public void setPrice(BigDecimal price) {
    this.price = price;
}

@Basic
@Column(name = "service_code", nullable = true, length = 50)
public String getServiceCode() {
    return serviceCode;
}

public void setServiceCode(String serviceCode) {
    this.serviceCode = serviceCode;
}

@Basic
@Column(name = "service_time", nullable = true)
public Date getServiceTime() {
    return serviceTime;
}

public void setServiceTime(Date serviceTime) {
    this.serviceTime = serviceTime;
}

@Basic
@Column(name = "dead_begin_time", nullable = true)
public Date getDeadBeginTime() {
    return deadBeginTime;
}

public void setDeadBeginTime(Date deadBeginTime) {
    this.deadBeginTime = deadBeginTime;
}

@Basic
@Column(name = "dead_end_time", nullable = true)
public Date getDeadEndTime() {
    return deadEndTime;
}

public void setDeadEndTime(Date deadEndTime) {
    this.deadEndTime = deadEndTime;
}

@Basic
@Column(name = "service_comment", nullable = true, length = 255)
public String getServiceComment() {
    return serviceComment;
}

public void setServiceComment(String serviceComment) {
    this.serviceComment = serviceComment;
}

@Basic
@Column(name = "sale_price", nullable = true, precision = 2)
public BigDecimal getSalePrice() {
    return salePrice;
}

public void setSalePrice(BigDecimal salePrice) {
    this.salePrice = salePrice;
}

@Basic
@Column(name = "sale_code", nullable = true, length = 50)
public String getSaleCode() {
    return saleCode;
}

public void setSaleCode(String saleCode) {
    this.saleCode = saleCode;
}

@Basic
@Column(name = "sale_time", nullable = true)
public Date getSaleTime() {
    return saleTime;
}

public void setSaleTime(Date saleTime) {
    this.saleTime = saleTime;
}

@Basic
@Column(name = "sale_comment", nullable = true, length = 255)
public String getSaleComment() {
    return saleComment;
}

public void setSaleComment(String saleComment) {
    this.saleComment = saleComment;
}

@Basic
@Column(name = "org_code", nullable = false, length = 30)
public String getOrgCode() {
    return orgCode;
}

public void setOrgCode(String orgCode) {
    this.orgCode = orgCode;
}

@Basic
@Column(name = "org_type", nullable = false)
public Integer getOrgType() {
    return orgType;
}

public void setOrgType(Integer orgType) {
    this.orgType = orgType;
}

@Basic
@Column(name = "create_user", nullable = true, length = 40)
public String getCreateUser() {
    return createUser;
}

public void setCreateUser(String createUser) {
    this.createUser = createUser;
}


@Basic
@Column(name = "update_user", nullable = true, length = 40)
public String getUpdateUser() {
    return updateUser;
}

public void setUpdateUser(String updateUser) {
    this.updateUser = updateUser;
}

@Basic
@Column(name = "mode", nullable = true)
public Integer getMode() {
    return mode;
}

public void setMode(Integer mode) {
    this.mode = mode;
}

@Transient
public String getOrderNo() {
    return orderNo;
}

public void setOrderNo(String orderNo) {
    this.orderNo = orderNo;
}

@Transient
public String getStatusName() {
    return statusName;
}

public void setStatusName(String statusName) {
    this.statusName = statusName;
}

@Transient
public String getBatteryName() {
    return BatteryName;
}

public void setBatteryName(String batteryName) {
    BatteryName = batteryName;
}

@Transient
public String getIsCreate() {
    return isCreate;
}

public void setIsCreate(String isCreate) {
    this.isCreate = isCreate;
}

@LazyCollection(LazyCollectionOption.FALSE)
@OneToMany(mappedBy = "wlInquiry", fetch = FetchType.LAZY, cascade = CascadeType.ALL, orphanRemoval = true)
@NotFound(action = NotFoundAction.IGNORE)
@Where(clause = "delete_flag = 0")
public List<WlInquiryProject> getServiceData() {
    return serviceData;
}

public void setServiceData(List<WlInquiryProject> serviceData) {
    this.serviceData = serviceData;
}

}
`

上面全是get 以及set方法 所以自己看着来<>

Service

@Service
public class WlInquiryService {

    @Autowired
    private WlOrderDao wlOrderDao;

public Result queryOrderNos(String inquiryCode) {
        Result result = new Result();
        try {
            List <String> orderNos = wlOrderDao.queryOrderNos(inquiryCode);
            result.setCode("00000");
            result.setMsg("查询到订单号");
            result.setData(orderNos);
        } catch (Exception e) {
            logger.error("查询失败", e.getCause());
            return Result.failure("查询失败,原因:" + e.getMessage(), "Query failed, reason:" + e.getMessage());
        }
        return result;
    }
    }

Dao

public interface WlOrderDao extends PagingAndSortingRepository<WlOrders, String>, JpaSpecificationExecutor<WlOrders> {

 @Query(value = "select wl_order_no from wl_orders where inquiry_code = :inquiryCode and delete_flag = 0", nativeQuery = true)
    List<String> queryOrderNos(@Param("inquiryCode") String inquiryCode);
}

全程无笑话 多无聊 自己能看懂 就仿着写,看不懂的就多看看

这个就是导出后的样子 但是没截全 文档比较长
文档名字(Excele的文档名:Inquiry1566803550574.xls)…

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值