| | |
| | | package com.dy.pmsProduct.schedule; |
| | | |
| | | import com.alibaba.excel.EasyExcel; |
| | | import com.alibaba.excel.converters.Converter; |
| | | import com.dy.common.aop.SsoPowerAop; |
| | | import com.dy.common.webUtil.BaseResponse; |
| | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.net.URLEncoder; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | |
| | | @RestController |
| | | @RequestMapping(path="schedule") |
| | | public class ScheduleCtrl { |
| | | private static final String fileName = "排班信息" ; |
| | | private static final String sheetName = "排班信息" ; |
| | | |
| | | private ScheduleSv sv; |
| | | @Autowired |
| | | public void setScheduleSv(ScheduleSv scheduleSv) { |
| | |
| | | return BaseResponseUtils.buildSuccess(list); |
| | | } |
| | | |
| | | |
| | | private String fileName = "排班信息" ; |
| | | private String sheetName = "排班信息" ; |
| | | @PostMapping(path="export") |
| | | @SsoPowerAop(power = "-1") |
| | | @Log("导出排班") |
| | |
| | | List<Converter> list = new ArrayList<>() ; |
| | | |
| | | List<PrSchedule> schList = sv.selectAll(queryVo); |
| | | // 使用并行流提高性能 |
| | | schList.parallelStream().forEach(sch -> { |
| | | schList.forEach(sch -> { |
| | | sch.relList.forEach(rel -> { |
| | | ExcelVo vo = new ExcelVo(); |
| | | vo.id = sch.id.toString(); |
| | | vo.userName = sch.userName; |
| | | vo.scheduleDate = sch.scheduleDate; |
| | | vo.dt = sch.dt; |
| | |
| | | list.add(vo); |
| | | }); |
| | | }); |
| | | QrCodeUtil.downloadExcel(response, fileName,sheetName,list); |
| | | |
| | | try{ |
| | | response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); |
| | | response.setCharacterEncoding("utf-8"); |
| | | fileName = URLEncoder.encode(fileName, "UTF-8").replaceAll("\\+", "%20"); |
| | | response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName + ".xlsx"); |
| | | EasyExcel.write(response.getOutputStream(), list.get(0).getClass()).sheet(sheetName) |
| | | .registerWriteHandler(new CustomCellWriteHandler()).doWrite(list); |
| | | }catch (Exception e){ |
| | | log.error("导出排班信息异常", e); |
| | | } |
| | | } |
| | | } |