【add】超标报表导出功能实现

This commit is contained in:
nixj 2024-05-11 15:18:10 +08:00
parent 4fbcbd779a
commit e1d23c8ef4
5 changed files with 31 additions and 3 deletions

View File

@ -61,4 +61,7 @@ order_car_record
flight_order_detail
hotel_order_detail
train_order_detail
car_order_detail
car_order_detail
## 超标订单标表
order_exceed_standard

View File

@ -53,10 +53,28 @@ public class ManageController {
.body(resource);
}
@ApiOperation("超标查询接口")
@ApiOperation("超标报表查询接口")
@PostMapping("/standard/query")
public PageResult<OrderExceedStandardExcel> standardQuery(@RequestBody StandardQueryDto dto){
return manageService.standardQuery(dto);
}
@ApiOperation("超标报表导出接口")
@PostMapping("/standard/export")
public ResponseEntity<Resource> standardExport(@RequestBody StandardQueryDto dto){
dto.setPageNum(1);
dto.setPageSize(Integer.MAX_VALUE);
File file = manageService.standardExport(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);
}
}

View File

@ -11,7 +11,7 @@ import java.math.BigDecimal;
* @Date2024/5/11 8:51
*/
@Data
public class OrderExceedStandardExcel {
public class OrderExceedStandardExcel extends BaseExcel{
@ExcelProperty("订单号")
private String orderNo;
@ExcelProperty("出差人")

View File

@ -20,4 +20,6 @@ public interface ManageService {
File saveConsumptionDetail(ConsumptionDetailDto dto);
PageResult<OrderExceedStandardExcel> standardQuery(StandardQueryDto dto);
File standardExport(StandardQueryDto dto);
}

View File

@ -61,6 +61,11 @@ public class ManageServiceImpl implements ManageService {
return PageResult.totalPageNum(page.getTotalElements(), excelList);
}
@Override
public File standardExport(StandardQueryDto dto) {
return ExcelUtil.exportReport(standardQuery(dto).getRecords());
}
private static List<OrderExceedStandardExcel> getOrderExceedStandardExcels(Page<OrderExceedStandard> page) {
List<OrderExceedStandard> orderList = page.getContent();
List<OrderExceedStandardExcel> excelList = new ArrayList<>();