| | |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.apache.poi.ss.usermodel.Workbook; |
| | | import org.springframework.security.core.parameters.P; |
| | | import org.springframework.util.CollectionUtils; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | |
| | | @PostMapping(value = "/export") |
| | | public void mealGeneratorExport(@RequestBody OrderQuery orderQuery) { |
| | | |
| | | List<TOrder> tOrders = orderService.listExport(orderQuery); |
| | | |
| | | int pageSize = 100; |
| | | int currentPage = 0; |
| | | List<TOrder> page = new ArrayList<>(); |
| | | |
| | | while (true) { |
| | | orderQuery.setPageNum(currentPage * pageSize); |
| | | orderQuery.setPageSize(pageSize); |
| | | PageInfo<TOrder> tOrderPageInfo = orderService.pageList(orderQuery); |
| | | List<TOrder> records = tOrderPageInfo.getRecords(); |
| | | if (CollectionUtils.isEmpty(records)) { |
| | | break; // 没有更多数据,退出循环 |
| | | } |
| | | page.addAll(records); // 累加当前页数据 |
| | | currentPage++; // 进入下一页 |
| | | } |
| | | |
| | | List<TCourse> courses = courseService.lambdaQuery().list(); |
| | | List<TInformation> informations = informationService.lambdaQuery().list(); |
| | | for (TOrder record : tOrders) { |
| | | for (TOrder record : page) { |
| | | record.getFormattedCreateTime(); |
| | | if (record.getGoodType()==1){ |
| | | TCourse course = courses.stream().filter(e -> e.getId().equals(record.getGoodId())).findFirst().orElse(null); |
| | |
| | | } |
| | | |
| | | |
| | | Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(), TOrder.class,tOrders ); |
| | | Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(), TOrder.class,page); |
| | | HttpServletResponse response = WebUtils.response(); |
| | | response.setContentType("application/vnd.ms-excel"); |
| | | response.setCharacterEncoding("utf-8"); |