This commit is contained in:
lifenlong 2021-06-13 14:51:39 +08:00
parent 5a4f8e2a72
commit 3814b4a9a5
8 changed files with 117 additions and 34 deletions

View File

@ -39,7 +39,7 @@ public class AppVersionBuyerController {
return ResultUtil.data(appVersionService.getAppVersion(appType));
}
@ApiOperation(value = "获取版本号")
@ApiOperation(value = "获取版本号列表")
@ApiImplicitParam(name = "appType", value = "app类型", required = true, paramType = "path")
@GetMapping("/appVersion/{type}")
public ResultMessage<IPage<AppVersion>> appVersion(PageVO pageVO, @PathVariable String appType) {

View File

@ -249,7 +249,7 @@ lili:
# jwt 细节设定
jwt-setting:
# token过期时间分钟
tokenExpireTime: 1
tokenExpireTime: 30
# 使用Spring @Cacheable注解失效时间
cache:

View File

@ -46,7 +46,7 @@ spring:
open-in-view: false
# Redis
redis:
host: 127.0.0.1
host: 192.168.0.116
port: 6379
password: lilishop
lettuce:

View File

@ -45,8 +45,8 @@
<de.codecentric>2.3.1</de.codecentric>
<userAgentUtils>1.21</userAgentUtils>
<interceptor-api>1.2</interceptor-api>
<poi-version>5.0.0</poi-version>
<poi-ooxml-version>5.0.0</poi-ooxml-version>
<poi-version>4.1.2</poi-version>
<poi-ooxml-version>4.1.2</poi-ooxml-version>
<logstash-logback-encoder>6.6</logstash-logback-encoder>
<zxing>3.4.1</zxing>
<slf4j-api>1.7.28</slf4j-api>

View File

@ -0,0 +1,21 @@
package cn.lili.modules.order.order.entity.dto;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @author liushuai(liushuai711 @ gmail.com)
* @version v4.1
* @Description:
* @since 2021/6/13 2:37 下午
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
public class ExcelDTO {
private String sn;
private String logisticsName;
private String logisticsNo;
}

View File

@ -14,6 +14,7 @@ import cn.lili.modules.statistics.model.dto.StatisticsQueryParam;
import cn.lili.modules.system.entity.vo.Traces;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
@ -195,11 +196,20 @@ public interface OrderService extends IService<Order> {
*/
void agglomeratePintuanOrder(String pintuanId, String parentOrderSn);
/**
* 获取待发货订单编号列表
*
* @param response
* @param logisticsName 店铺已选择物流公司列表
* @return 待发货订单编号列表
*/
void getBatchDeliverList(HttpServletResponse response, List<String> logisticsName);
/**
* 订单批量发货
*
* @param list 批量发货列表
* @param files 文件
*/
void batchDeliver(List<OrderBatchDeliverDTO> list);
void batchDeliver(MultipartFile files);
}

View File

@ -5,6 +5,7 @@ import cn.hutool.core.date.DateUtil;
import cn.hutool.core.io.IoUtil;
import cn.hutool.core.text.CharSequenceUtil;
import cn.hutool.json.JSONUtil;
import cn.hutool.poi.excel.ExcelReader;
import cn.hutool.poi.excel.ExcelUtil;
import cn.hutool.poi.excel.ExcelWriter;
import cn.lili.common.aop.syslog.annotation.SystemLogPoint;
@ -69,11 +70,13 @@ import org.apache.rocketmq.spring.core.RocketMQTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
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;
@ -501,11 +504,61 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
}
@Override
public void batchDeliver(List<OrderBatchDeliverDTO> list) {
public void getBatchDeliverList(HttpServletResponse response, List<String> logisticsName) {
ExcelWriter writer = ExcelUtil.getWriter();
writer.addHeaderAlias("sn", "订单号");
writer.addHeaderAlias("logisticsName", "物流公司");
writer.addHeaderAlias("logisticsNo", "物流单号");
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");
ServletOutputStream out = null;
try {
out = response.getOutputStream();
writer.flush(out, true);
} catch (IOException e) {
log.error("获取待发货订单编号列表错误",e);
} finally {
writer.close();
}
IoUtil.close(out);
}
@Override
public void batchDeliver(MultipartFile files) {
InputStream inputStream = null;
List<OrderBatchDeliverDTO> orderBatchDeliverDTOList = new ArrayList<>();
try {
inputStream = files.getInputStream();
// 2.应用HUtool ExcelUtil获取ExcelReader指定输入流和sheet
ExcelReader excelReader = ExcelUtil.getReader(inputStream);
// 可以加上表头验证
// 3.读取第二行到最后一行数据
List<List<Object>> read = excelReader.read(1, excelReader.getRowCount());
for (List<Object> objects : read) {
OrderBatchDeliverDTO orderBatchDeliverDTO = new OrderBatchDeliverDTO();
orderBatchDeliverDTO.setOrderSn(objects.get(0).toString());
orderBatchDeliverDTO.setLogisticsName(objects.get(1).toString());
orderBatchDeliverDTO.setLogisticsNo(objects.get(2).toString());
orderBatchDeliverDTOList.add(orderBatchDeliverDTO);
}
}catch (Exception e){
throw new ServiceException("文件读取失败");
}
//循环检查是否符合规范
checkBatchDeliver(list);
checkBatchDeliver(orderBatchDeliverDTOList);
//订单批量发货
for (OrderBatchDeliverDTO orderBatchDeliverDTO : list) {
for (OrderBatchDeliverDTO orderBatchDeliverDTO : orderBatchDeliverDTOList) {
this.delivery(orderBatchDeliverDTO.getOrderSn(), orderBatchDeliverDTO.getLogisticsNo(), orderBatchDeliverDTO.getLogisticsId());
}
}

View File

@ -22,6 +22,7 @@ import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
@ -50,12 +51,16 @@ public class OrderStoreController {
*/
@Autowired
private OrderService orderService;
/**
* 订单价格
*/
@Autowired
private OrderPriceService orderPriceService;
/**
* 物流公司
*/
@Autowired
private StoreLogisticsService storeLogisticsService;
@ApiOperation(value = "查询订单列表")
@ -141,30 +146,24 @@ public class OrderStoreController {
return ResultUtil.data(orderService.getTraces(orderSn));
}
@ApiOperation(value = "下载待发货的订单列表")
@GetMapping(value = "/downLoadDeliverExcel")
public ResultMessage<Object> downLoadDeliverExcel() {
HttpServletResponse response = ThreadContextHolder.getHttpResponse();
//获取店铺已经选择物流公司列表
List<String> logisticsName = storeLogisticsService.getStoreSelectedLogisticsName();
//下载订单批量发货Excel
this.orderService.getBatchDeliverList(response,logisticsName);
return ResultUtil.success(ResultCode.SUCCESS);
}
@PostMapping(value = "/batchDeliver", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
@ApiOperation(value = "上传文件进行订单批量发货")
@ApiImplicitParam(name = "file", value = "订单列表", required = true, dataType = "file", paramType = "query")
@PostMapping(value = "/batchDeliver")
public void batchDeliver(@RequestParam MultipartFile file) {
InputStream inputStream = null;
try {
inputStream = file.getInputStream();
// 2.应用HUtool ExcelUtil获取ExcelReader指定输入流和sheet
ExcelReader excelReader = ExcelUtil.getReader(inputStream);
// 可以加上表头验证
// 3.读取第二行到最后一行数据
List<List<Object>> read = excelReader.read(1, excelReader.getRowCount());
List<OrderBatchDeliverDTO> orderBatchDeliverDTOList=new ArrayList<>();
for (List<Object> objects : read) {
OrderBatchDeliverDTO orderBatchDeliverDTO=new OrderBatchDeliverDTO();
orderBatchDeliverDTO.setOrderSn(objects.get(0).toString());
orderBatchDeliverDTO.setLogisticsName(objects.get(1).toString());
orderBatchDeliverDTO.setLogisticsNo(objects.get(2).toString());
orderBatchDeliverDTOList.add(orderBatchDeliverDTO);
}
orderService.batchDeliver(orderBatchDeliverDTOList);
} catch (Exception e) {
log.error("上传文件进行订单批量发货错误",e);
}
public ResultMessage<Object> batchDeliver(@RequestPart("files") MultipartFile files) {
orderService.batchDeliver(files);
return ResultUtil.success(ResultCode.SUCCESS);
}
@ApiOperation(value = "查询订单导出列表")