【add】订单导出功能实现
This commit is contained in:
parent
7f0acc3b3f
commit
d9e130ff61
|
@ -100,6 +100,24 @@ public class ManageController {
|
||||||
return Result.Success(SUCCESS,manageService.orderPageQuery(dto));
|
return Result.Success(SUCCESS,manageService.orderPageQuery(dto));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ApiOperation("订单报表导出接口")
|
||||||
|
@PostMapping("/order/export")
|
||||||
|
public ResponseEntity<Resource> orderExport(@RequestBody OrderPageQuery dto){
|
||||||
|
dto.setPageNum(1);
|
||||||
|
dto.setPageSize(Integer.MAX_VALUE);
|
||||||
|
File file = manageService.orderExport(dto);
|
||||||
|
Resource resource;
|
||||||
|
try {
|
||||||
|
resource = new InputStreamResource(new FileInputStream(file));
|
||||||
|
} catch (FileNotFoundException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
return ResponseEntity.ok()
|
||||||
|
.header("Content-Disposition", "attachment; filename=" + file.getName())
|
||||||
|
.contentType(MediaType.parseMediaType("application/octet-stream"))
|
||||||
|
.body(resource);
|
||||||
|
}
|
||||||
|
|
||||||
@ApiOperation("订单下载记录查询接口")
|
@ApiOperation("订单下载记录查询接口")
|
||||||
@PostMapping("/order/downloadRecordQuery")
|
@PostMapping("/order/downloadRecordQuery")
|
||||||
public Result<?> orderDownloadRecordQuery(){
|
public Result<?> orderDownloadRecordQuery(){
|
||||||
|
|
|
@ -31,7 +31,7 @@ public class OrderPageExcel extends BaseExcel {
|
||||||
private String productTypeName;
|
private String productTypeName;
|
||||||
@ExcelProperty("价格")
|
@ExcelProperty("价格")
|
||||||
private String price; // 价格
|
private String price; // 价格
|
||||||
@ExcelProperty
|
@ExcelIgnore
|
||||||
private String employeeNo;
|
private String employeeNo;
|
||||||
@ExcelIgnore
|
@ExcelIgnore
|
||||||
private Long originId;
|
private Long originId;
|
||||||
|
@ -63,7 +63,7 @@ public class OrderPageExcel extends BaseExcel {
|
||||||
|
|
||||||
public String getStatusName(){
|
public String getStatusName(){
|
||||||
if (status==null){
|
if (status==null){
|
||||||
return status;
|
return "未开始";
|
||||||
}
|
}
|
||||||
if(productType.equals(LEG_TYPE_HOTEL)){
|
if(productType.equals(LEG_TYPE_HOTEL)){
|
||||||
switch (status){
|
switch (status){
|
||||||
|
|
|
@ -36,4 +36,6 @@ public interface ManageService {
|
||||||
List<OrderDownloadRecord> orderDownloadRecordQuery();
|
List<OrderDownloadRecord> orderDownloadRecordQuery();
|
||||||
|
|
||||||
PageResult<OrderPageExcel> orderPageQuery(OrderPageQuery dto);
|
PageResult<OrderPageExcel> orderPageQuery(OrderPageQuery dto);
|
||||||
|
|
||||||
|
File orderExport(OrderPageQuery dto);
|
||||||
}
|
}
|
||||||
|
|
|
@ -170,14 +170,18 @@ public class ManageServiceImpl implements ManageService {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PageResult<OrderPageExcel> orderPageQuery(OrderPageQuery dto) {
|
public PageResult<OrderPageExcel> orderPageQuery(OrderPageQuery dto) {
|
||||||
// //数据权限
|
//数据权限
|
||||||
// List<Long> routeIds=baseUtil.getRouteIds();
|
List<Long> dataRouteIds=baseUtil.getRouteIds();
|
||||||
// if (routeIds==null||routeIds.isEmpty()) {
|
if (dataRouteIds==null||dataRouteIds.isEmpty()) {
|
||||||
// return PageResult.totalPageNum(0, new ArrayList<>());
|
return PageResult.totalPageNum(0, new ArrayList<>());
|
||||||
// }
|
}
|
||||||
|
dto.setRouteIds(dataRouteIds);
|
||||||
//行程号
|
//行程号
|
||||||
if (!dto.getRouteOrderNo().isEmpty()){
|
if (!dto.getRouteOrderNo().isEmpty()){
|
||||||
List<RouteOrder> routeOrders=jdbcRouteRepository.findAllByRouteOrderNoContains(dto.getRouteOrderNo());
|
List<RouteOrder> routeOrders=jdbcRouteRepository.findAllByRouteOrderNoContains(dto.getRouteOrderNo());
|
||||||
|
if (routeOrders == null || routeOrders.isEmpty()) {
|
||||||
|
return PageResult.totalPageNum(0, new ArrayList<>());
|
||||||
|
}
|
||||||
if (dto.getRouteIds()==null){
|
if (dto.getRouteIds()==null){
|
||||||
dto.setRouteIds(routeOrders.stream().map(RouteOrder::getRouteId).toList());
|
dto.setRouteIds(routeOrders.stream().map(RouteOrder::getRouteId).toList());
|
||||||
}else {
|
}else {
|
||||||
|
@ -203,6 +207,7 @@ public class ManageServiceImpl implements ManageService {
|
||||||
//处理地点信息
|
//处理地点信息
|
||||||
List<Long> locationIds = new ArrayList<>(list.stream().map(OrderDetail::getOriginId).toList());
|
List<Long> locationIds = new ArrayList<>(list.stream().map(OrderDetail::getOriginId).toList());
|
||||||
locationIds.addAll(list.stream().map(OrderDetail::getDestinationId).toList());
|
locationIds.addAll(list.stream().map(OrderDetail::getDestinationId).toList());
|
||||||
|
locationIds=locationIds.stream().distinct().filter(Objects::nonNull).collect(Collectors.toList());
|
||||||
List<Location> locations=locationRepository.findByLocationIdIn(locationIds);
|
List<Location> locations=locationRepository.findByLocationIdIn(locationIds);
|
||||||
//根据类型处理出行订单信息
|
//根据类型处理出行订单信息
|
||||||
Map<Long, OrderPageExcel> orderPageDtoMap=new HashMap<>();
|
Map<Long, OrderPageExcel> orderPageDtoMap=new HashMap<>();
|
||||||
|
@ -219,6 +224,7 @@ public class ManageServiceImpl implements ManageService {
|
||||||
}
|
}
|
||||||
//处理行程单信息
|
//处理行程单信息
|
||||||
List<Long> routeIds=list.stream().map(OrderDetail::getRouteId).toList();
|
List<Long> routeIds=list.stream().map(OrderDetail::getRouteId).toList();
|
||||||
|
routeIds=routeIds.stream().distinct().filter(Objects::nonNull).collect(Collectors.toList());
|
||||||
List<RouteOrder> routeOrders=jdbcRouteRepository.findByRouteIdIn(routeIds);
|
List<RouteOrder> routeOrders=jdbcRouteRepository.findByRouteIdIn(routeIds);
|
||||||
|
|
||||||
List<OrderPageExcel> result = list.stream().map(temp -> {
|
List<OrderPageExcel> result = list.stream().map(temp -> {
|
||||||
|
@ -228,13 +234,14 @@ public class ManageServiceImpl implements ManageService {
|
||||||
}
|
}
|
||||||
BeanUtils.copyProperties(temp, obj);
|
BeanUtils.copyProperties(temp, obj);
|
||||||
OrderPageExcel finalObj = obj;
|
OrderPageExcel finalObj = obj;
|
||||||
Location origin=locations.stream().filter(s->s.getLocationId().equals(finalObj.getOriginId())).toList().get(0);
|
|
||||||
Location destination=locations.stream().filter(s->s.getLocationId().equals(finalObj.getDestinationId())).toList().get(0);
|
List<Location> origin=locations.stream().filter(s->s.getLocationId().equals(finalObj.getOriginId())).toList();
|
||||||
if (origin!=null){
|
List<Location> destination=locations.stream().filter(s->s.getLocationId().equals(finalObj.getDestinationId())).toList();
|
||||||
finalObj.setOriginName(origin.getLocationName());
|
if (!origin.isEmpty()){
|
||||||
|
finalObj.setOriginName(origin.get(0).getLocationName());
|
||||||
}
|
}
|
||||||
if (destination!=null){
|
if (!destination.isEmpty()){
|
||||||
finalObj.setDestinationName(destination.getLocationName());
|
finalObj.setDestinationName(destination.get(0).getLocationName());
|
||||||
}
|
}
|
||||||
List<RouteOrder> orders=routeOrders.stream().filter(s->s.getRouteId().equals(finalObj.getRouteId())).toList();
|
List<RouteOrder> orders=routeOrders.stream().filter(s->s.getRouteId().equals(finalObj.getRouteId())).toList();
|
||||||
if (!orders.isEmpty()) {
|
if (!orders.isEmpty()) {
|
||||||
|
@ -246,6 +253,11 @@ public class ManageServiceImpl implements ManageService {
|
||||||
return PageResult.totalPageNum(count, result);
|
return PageResult.totalPageNum(count, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public File orderExport(OrderPageQuery dto) {
|
||||||
|
return ExcelUtil.exportReport(orderPageQuery(dto).getRecords());
|
||||||
|
}
|
||||||
|
|
||||||
private void dealOrderTrainRecord(List<OrderDetail> entry,Map<Long, OrderPageExcel> orderPageDtoMap){
|
private void dealOrderTrainRecord(List<OrderDetail> entry,Map<Long, OrderPageExcel> orderPageDtoMap){
|
||||||
if (entry!=null&&!entry.isEmpty()){
|
if (entry!=null&&!entry.isEmpty()){
|
||||||
List<TrainOrderDetail> trainOrderDetails=jdbcTrainOrderDetailRepository.findAllByOrderIdIn(entry.stream().map(OrderDetail::getOrderId).toList());
|
List<TrainOrderDetail> trainOrderDetails=jdbcTrainOrderDetailRepository.findAllByOrderIdIn(entry.stream().map(OrderDetail::getOrderId).toList());
|
||||||
|
|
Loading…
Reference in New Issue