下载批量发货订单列表
This commit is contained in:
parent
3814b4a9a5
commit
a159c0d0db
@ -17,6 +17,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@ -53,6 +54,7 @@ public interface OrderService extends IService<Order> {
|
||||
|
||||
/**
|
||||
* 查询导出订单列表
|
||||
*
|
||||
* @param orderSearchParams 查询参数
|
||||
* @return 导出订单列表
|
||||
*/
|
||||
|
@ -1,6 +1,7 @@
|
||||
package cn.lili.modules.order.order.serviceimpl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.io.IoUtil;
|
||||
import cn.hutool.core.text.CharSequenceUtil;
|
||||
@ -77,9 +78,9 @@ import javax.servlet.ServletOutputStream;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 子订单业务层实现
|
||||
@ -506,33 +507,34 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
|
||||
@Override
|
||||
public void getBatchDeliverList(HttpServletResponse response, List<String> logisticsName) {
|
||||
ExcelWriter writer = ExcelUtil.getWriter();
|
||||
writer.addHeaderAlias("sn", "订单号");
|
||||
writer.addHeaderAlias("logisticsName", "物流公司");
|
||||
writer.addHeaderAlias("logisticsNo", "物流单号");
|
||||
//Excel 头部
|
||||
ArrayList<String> rows = new ArrayList<>();
|
||||
rows.add("订单编号");
|
||||
rows.add("物流公司");
|
||||
rows.add("物流编号");
|
||||
writer.writeHeadRow(rows);
|
||||
|
||||
ExcelDTO excelDTO=new ExcelDTO("asd","2","3");
|
||||
List<ExcelDTO> list = new ArrayList<>();
|
||||
list.add(excelDTO);
|
||||
writer.write(list,true);
|
||||
//存放下拉列表
|
||||
//存放下拉列表 ----店铺已选择物流公司列表
|
||||
String[] logiList = logisticsName.toArray(new String[]{});
|
||||
CellRangeAddressList cellRangeAddressList = new CellRangeAddressList(2, 2, 2, 3);
|
||||
// writer.addSelect(cellRangeAddressList, logiList);
|
||||
response.setContentType("application/vnd.ms-excel;charset=utf-8");
|
||||
String name = "XXX国际贸易公司";
|
||||
response.setHeader("Content-Disposition", "attachment;filename="+name+".xls");
|
||||
CellRangeAddressList cellRangeAddressList = new CellRangeAddressList(1, 200, 1, 1);
|
||||
writer.addSelect(cellRangeAddressList, logiList);
|
||||
|
||||
ServletOutputStream out = null;
|
||||
try {
|
||||
//设置公共属性,列表名称
|
||||
response.setContentType("application/vnd.ms-excel;charset=utf-8");
|
||||
response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode("批量发货导入模板", "UTF8") + ".xls");
|
||||
out = response.getOutputStream();
|
||||
writer.flush(out, true);
|
||||
} catch (IOException e) {
|
||||
log.error("获取待发货订单编号列表错误",e);
|
||||
} catch (Exception e) {
|
||||
log.error("获取待发货订单编号列表错误", e);
|
||||
} finally {
|
||||
writer.close();
|
||||
}
|
||||
IoUtil.close(out);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void batchDeliver(MultipartFile files) {
|
||||
|
||||
@ -552,7 +554,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
|
||||
orderBatchDeliverDTO.setLogisticsNo(objects.get(2).toString());
|
||||
orderBatchDeliverDTOList.add(orderBatchDeliverDTO);
|
||||
}
|
||||
}catch (Exception e){
|
||||
} catch (Exception e) {
|
||||
throw new ServiceException("文件读取失败");
|
||||
}
|
||||
//循环检查是否符合规范
|
||||
@ -574,9 +576,9 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
|
||||
Order order = this.getOne(new LambdaQueryWrapper<Order>()
|
||||
.eq(Order::getStoreId, UserContext.getCurrentUser().getStoreId())
|
||||
.eq(Order::getSn, orderBatchDeliverDTO.getOrderSn()));
|
||||
if (order==null) {
|
||||
if (order == null) {
|
||||
throw new ServiceException("订单编号:'" + orderBatchDeliverDTO.getOrderSn() + " '不存在");
|
||||
}else if(order.getOrderStatus().equals(OrderStatusEnum.DELIVERED.name())){
|
||||
} else if (order.getOrderStatus().equals(OrderStatusEnum.DELIVERED.name())) {
|
||||
throw new ServiceException("订单编号:'" + orderBatchDeliverDTO.getOrderSn() + " '不能发货");
|
||||
}
|
||||
//查看物流公司
|
||||
|
@ -146,16 +146,16 @@ public class OrderStoreController {
|
||||
return ResultUtil.data(orderService.getTraces(orderSn));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "下载待发货的订单列表")
|
||||
@ApiOperation(value = "下载待发货的订单列表",produces="application/octet-stream")
|
||||
@GetMapping(value = "/downLoadDeliverExcel")
|
||||
public ResultMessage<Object> downLoadDeliverExcel() {
|
||||
public void downLoadDeliverExcel() {
|
||||
HttpServletResponse response = ThreadContextHolder.getHttpResponse();
|
||||
//获取店铺已经选择物流公司列表
|
||||
List<String> logisticsName = storeLogisticsService.getStoreSelectedLogisticsName();
|
||||
//下载订单批量发货Excel
|
||||
this.orderService.getBatchDeliverList(response,logisticsName);
|
||||
|
||||
return ResultUtil.success(ResultCode.SUCCESS);
|
||||
//return ResultUtil.success(ResultCode.SUCCESS);
|
||||
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user