| | |
| | | import com.alibaba.excel.EasyExcel; |
| | | import com.alibaba.excel.EasyExcelFactory; |
| | | import com.alibaba.excel.ExcelWriter; |
| | | import com.alibaba.excel.write.builder.ExcelWriterBuilder; |
| | | import com.alibaba.excel.write.metadata.WriteSheet; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; |
| | |
| | | import java.io.IOException; |
| | | import java.io.InputStream; |
| | | import java.net.URLEncoder; |
| | | import java.nio.charset.StandardCharsets; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.UUID; |
| | | |
| | | /** |
| | | * 体温监测控制层 |
| | |
| | | * @param response 返回域 |
| | | */ |
| | | @GetMapping("/export-animalHeat") |
| | | public void exportAnimalHeat(AnimalHeatVo animalHeatVo,HttpServletResponse response){ |
| | | public void exportAnimalHeat(AnimalHeatVo animalHeatVo,HttpServletResponse response) throws Exception{ |
| | | List<AnimalHeatExcel> list = animalHeatService.exportAnimalHeat(animalHeatVo); |
| | | // response.setContentType("application/vnd.ms-excel"); |
| | | // response.setCharacterEncoding(Charsets.UTF_8.name()); |
| | | // String fileName = URLEncoder.encode("体温检测数据" + DateUtil.time(), Charsets.UTF_8.name()); |
| | | // response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".xlsx"); |
| | | // ExcelWriter writer = new ExcelWriterBuilder() |
| | | // .autoCloseStream(true) |
| | | // .file(response.getOutputStream()) |
| | | // .head(AnimalHeatExcel.class) |
| | | // .build(); |
| | | // // xlsx文件上上限是104W行左右,这里如果超过104W需要分Sheet |
| | | // WriteSheet writeSheet = new WriteSheet(); |
| | | // writeSheet.setSheetName("target"); |
| | | // long lastBatchMaxId = 0L; |
| | | // int limit = 500; |
| | | // for (; ; ) { |
| | | // List<AnimalHeatExcel> list = animalHeatService.exportAnimalHeat(animalHeatVo); |
| | | // List list = orderService.queryByScrollingPagination(paymentDateTimeStart, paymentDateTimeEnd, lastBatchMaxId, limit); |
| | | // if (list.isEmpty()) { |
| | | // writer.finish(); |
| | | // break; |
| | | // } else { |
| | | // lastBatchMaxId = list.stream().map(AnimalHeatExcel::getId).max(Long::compareTo).orElse(Long.MAX_VALUE); |
| | | // writer.write(list, writeSheet); |
| | | // } |
| | | // } |
| | | // EasyExcel.write(response.getOutputStream(), AnimalHeatExcel.class).sheet("体温检测数据表").doWrite(list); |
| | | ExcelUtil.export(response, "体温检测数据" + DateUtil.time(), "体温检测数据表", list,AnimalHeatExcel.class ); |
| | | } |
| | | |