| | |
| | | import com.yuanchu.mom.dto.PerformanceShiftAddDto; |
| | | import com.yuanchu.mom.pojo.PerformanceShift; |
| | | import com.yuanchu.mom.service.PerformanceShiftService; |
| | | import com.yuanchu.mom.utils.StyleUtils; |
| | | import com.yuanchu.mom.utils.StyleMonthUtils; |
| | | import com.yuanchu.mom.utils.StyleYearUtils; |
| | | import com.yuanchu.mom.vo.Result; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | |
| | | |
| | | @ApiOperation(value = "绩效管理-班次-导出") |
| | | @GetMapping("update") |
| | | public void exportToExcel(@NotNull(message = "时间不能为空!") String time, String userName, String laboratory, HttpServletResponse response) throws Exception { |
| | | Map<Object, Object> data = performanceShiftService.exportToExcel(time, userName, laboratory); |
| | | // 设置单元格样式 |
| | | HorizontalCellStyleStrategy horizontalCellStyleStrategy = new HorizontalCellStyleStrategy(StyleUtils.getHeadStyle(), StyleUtils.getContentStyle()); |
| | | // 保存到第一个sheet中 |
| | | public void exportToExcel(@NotNull(message = "时间不能为空!") String time, String userName, String laboratory, Boolean isMonth, HttpServletResponse response) throws Exception { |
| | | Map<Object, Object> data; |
| | | response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); |
| | | response.setHeader("requestType","excel"); |
| | | response.setHeader("Access-Control-Expose-Headers", "requestType"); |
| | | EasyExcel.write(response.getOutputStream()) |
| | | .head((List<List<String>>) data.get("header")) |
| | | .registerWriteHandler(new LongestMatchColumnWidthStyleStrategy()) // 自适应列宽 |
| | | .registerWriteHandler(horizontalCellStyleStrategy) |
| | | .sheet("模板") |
| | | .doWrite((Collection<?>) data.get("data")); |
| | | if (!isMonth) { |
| | | data = performanceShiftService.exportToYearExcel(time, userName, laboratory); |
| | | // 设置单元格样式 |
| | | HorizontalCellStyleStrategy horizontalCellStyleStrategy = new HorizontalCellStyleStrategy(StyleYearUtils.getHeadStyle(), StyleYearUtils.getContentStyle()); |
| | | // 保存到第一个sheet中 |
| | | EasyExcel.write(response.getOutputStream()) |
| | | .head((List<List<String>>) data.get("header")) |
| | | .registerWriteHandler(new LongestMatchColumnWidthStyleStrategy()) // 自适应列宽 |
| | | .registerWriteHandler(horizontalCellStyleStrategy) |
| | | .sheet("年度") |
| | | .doWrite((Collection<?>) data.get("data")); |
| | | } else { |
| | | data = performanceShiftService.exportToMonthExcel(time, userName, laboratory); |
| | | // 设置单元格样式 |
| | | HorizontalCellStyleStrategy horizontalCellStyleStrategy = new HorizontalCellStyleStrategy(StyleMonthUtils.getHeadStyle(), StyleMonthUtils.getContentStyle()); |
| | | EasyExcel.write(response.getOutputStream()) |
| | | .head((List<List<String>>) data.get("header")) |
| | | .registerWriteHandler(horizontalCellStyleStrategy) |
| | | .sheet("月度") |
| | | .doWrite((Collection<?>) data.get("data")); |
| | | } |
| | | } |
| | | } |