|
|
@ -7,7 +7,8 @@ import com.alibaba.excel.write.style.HorizontalCellStyleStrategy; |
|
|
|
import com.alibaba.excel.write.style.column.LongestMatchColumnWidthStyleStrategy; |
|
|
|
import com.easy.admin.common.api.vo.Result; |
|
|
|
import com.easy.admin.modules.huzhou.dto.ProjectTimeOutInfoExportDTO; |
|
|
|
import com.easy.admin.modules.huzhou.dto.ProjectinfoExportDTO; |
|
|
|
import com.easy.admin.modules.huzhou.dto.ProjectInfoExportDTO; |
|
|
|
import com.easy.admin.modules.huzhou.dto.ProjectResultExportDTO; |
|
|
|
import com.easy.admin.modules.huzhou.entity.HuzhouProjectinfo; |
|
|
|
import com.easy.admin.modules.huzhou.entity.ProjectManager; |
|
|
|
import com.easy.admin.modules.huzhou.handler.CustomMergeStrategy; |
|
|
@ -27,6 +28,7 @@ import java.net.URLEncoder; |
|
|
|
import java.time.LocalDate; |
|
|
|
import java.time.LocalDateTime; |
|
|
|
import java.time.format.DateTimeFormatter; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.Arrays; |
|
|
|
import java.util.List; |
|
|
|
import java.util.stream.Collectors; |
|
|
@ -37,9 +39,9 @@ import java.util.stream.Collectors; |
|
|
|
* @Description: 用于后台导入项目负责人信息 |
|
|
|
*/ |
|
|
|
@Slf4j |
|
|
|
@RequestMapping("/projectManager") |
|
|
|
@RequestMapping("/export") |
|
|
|
@RestController |
|
|
|
public class ProjectManagerController { |
|
|
|
public class ExportController { |
|
|
|
@Resource |
|
|
|
private ProjectManagerService projectManagerService; |
|
|
|
|
|
|
@ -89,8 +91,8 @@ public class ProjectManagerController { |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@GetMapping("/downloadRate") |
|
|
|
public void downloadRate(HttpServletResponse response) throws IOException { |
|
|
|
@GetMapping("/projectBoardInfo") |
|
|
|
public void downProjectBoardInfo(HttpServletResponse response) throws IOException { |
|
|
|
// 设置表头样式
|
|
|
|
WriteCellStyle headStyle = new WriteCellStyle(); |
|
|
|
headStyle.setHorizontalAlignment(HorizontalAlignment.CENTER); |
|
|
@ -100,8 +102,8 @@ public class ProjectManagerController { |
|
|
|
bodyStyle.setVerticalAlignment(VerticalAlignment.CENTER); |
|
|
|
// 封装数据
|
|
|
|
List<HuzhouProjectinfo> projectInfoList = projectinfoService.queryBoardInfo(); |
|
|
|
List<ProjectinfoExportDTO> dtoList = projectInfoList.stream() |
|
|
|
.map(projectInfo -> new ProjectinfoExportDTO(projectInfo.getProjectName(), |
|
|
|
List<ProjectInfoExportDTO> dtoList = projectInfoList.stream() |
|
|
|
.map(projectInfo -> new ProjectInfoExportDTO(projectInfo.getProjectName(), |
|
|
|
projectInfo.getSuperiorFundPayRate(), |
|
|
|
projectInfo.getCurrentStage(), |
|
|
|
projectInfo.getTotalPercent(), |
|
|
@ -115,7 +117,7 @@ public class ProjectManagerController { |
|
|
|
// 这里注意 有同学反应使用swagger 会导致各种问题,请直接用浏览器或者用postman
|
|
|
|
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); |
|
|
|
response.setCharacterEncoding("utf-8"); |
|
|
|
String preFileName = "项目看板"; |
|
|
|
String preFileName = "晾晒看报"; |
|
|
|
// 这里URLEncoder.encode可以防止中文乱码 当然和easyexcel没有关系
|
|
|
|
LocalDateTime currentDateTime = LocalDateTime.now(); |
|
|
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); |
|
|
@ -125,17 +127,17 @@ public class ProjectManagerController { |
|
|
|
.replaceAll("\\+", "%20"); |
|
|
|
response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName + ".xlsx"); |
|
|
|
|
|
|
|
EasyExcel.write(response.getOutputStream(), ProjectinfoExportDTO.class) |
|
|
|
EasyExcel.write(response.getOutputStream(), ProjectInfoExportDTO.class) |
|
|
|
.registerWriteHandler(new HorizontalCellStyleStrategy(headStyle, bodyStyle)) |
|
|
|
.registerWriteHandler(new LongestMatchColumnWidthStyleStrategy()) |
|
|
|
.registerWriteHandler(new CustomMergeStrategy(Arrays.asList("superLeader","reformName"))) |
|
|
|
.sheet("项目看板") |
|
|
|
.sheet("晾晒看报") |
|
|
|
.doWrite(dtoList); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@GetMapping("/timeOutInfoExport") |
|
|
|
@GetMapping("/timeOutInfo") |
|
|
|
public void timeOutInfoExport(HttpServletResponse response) throws IOException { |
|
|
|
// 设置表头样式
|
|
|
|
WriteCellStyle headStyle = new WriteCellStyle(); |
|
|
@ -155,13 +157,14 @@ public class ProjectManagerController { |
|
|
|
projectInfo.getSuperiorFundPayRate(), |
|
|
|
projectInfo.getTimeOutPayCount(), |
|
|
|
projectInfo.getTimeOutPaySituation(), |
|
|
|
projectInfo.getUploadFileRate())) |
|
|
|
projectInfo.getUploadFileRate(), |
|
|
|
projectInfo.getProjectTimeOutSituation())) |
|
|
|
.collect(Collectors.toList()); |
|
|
|
|
|
|
|
// 这里注意 有同学反应使用swagger 会导致各种问题,请直接用浏览器或者用postman
|
|
|
|
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); |
|
|
|
response.setCharacterEncoding("utf-8"); |
|
|
|
String preFileName = "超时情况"; |
|
|
|
String preFileName = "晾晒比分评分表"; |
|
|
|
// 这里URLEncoder.encode可以防止中文乱码 当然和easyexcel没有关系
|
|
|
|
LocalDateTime currentDateTime = LocalDateTime.now(); |
|
|
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); |
|
|
@ -175,7 +178,41 @@ public class ProjectManagerController { |
|
|
|
.registerWriteHandler(new HorizontalCellStyleStrategy(headStyle, bodyStyle)) |
|
|
|
.registerWriteHandler(new LongestMatchColumnWidthStyleStrategy()) |
|
|
|
//.registerWriteHandler(new CustomMergeStrategy(Arrays.asList("superLeader","reformName")))
|
|
|
|
.sheet("超时情况") |
|
|
|
.sheet("晾晒比分评分表") |
|
|
|
.doWrite(dtoList); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@GetMapping("/projectResult") |
|
|
|
public void projectResultExport(HttpServletResponse response) throws IOException { |
|
|
|
// 设置表头样式
|
|
|
|
WriteCellStyle headStyle = new WriteCellStyle(); |
|
|
|
headStyle.setHorizontalAlignment(HorizontalAlignment.CENTER); |
|
|
|
// 设置表格内容
|
|
|
|
WriteCellStyle bodyStyle = new WriteCellStyle(); |
|
|
|
bodyStyle.setHorizontalAlignment(HorizontalAlignment.CENTER); ; |
|
|
|
bodyStyle.setVerticalAlignment(VerticalAlignment.CENTER); |
|
|
|
// 封装数据
|
|
|
|
ProjectResultExportDTO projectResultExportDTO = projectinfoService.queryProjectResultCount(); |
|
|
|
List<ProjectResultExportDTO> dtoList = new ArrayList<>(); |
|
|
|
dtoList.add(projectResultExportDTO); |
|
|
|
// 这里注意 有同学反应使用swagger 会导致各种问题,请直接用浏览器或者用postman
|
|
|
|
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); |
|
|
|
response.setCharacterEncoding("utf-8"); |
|
|
|
String preFileName = "项目成果表"; |
|
|
|
// 这里URLEncoder.encode可以防止中文乱码 当然和easyexcel没有关系
|
|
|
|
LocalDateTime currentDateTime = LocalDateTime.now(); |
|
|
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); |
|
|
|
String formattedDateTime = currentDateTime.format(formatter); |
|
|
|
System.out.println("当前日期: " + formattedDateTime); |
|
|
|
String fileName = URLEncoder.encode( preFileName+formattedDateTime, "UTF-8") |
|
|
|
.replaceAll("\\+", "%20"); |
|
|
|
response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName + ".xlsx"); |
|
|
|
|
|
|
|
EasyExcel.write(response.getOutputStream(), ProjectResultExportDTO.class) |
|
|
|
.registerWriteHandler(new HorizontalCellStyleStrategy(headStyle, bodyStyle)) |
|
|
|
.registerWriteHandler(new LongestMatchColumnWidthStyleStrategy()) |
|
|
|
.sheet("项目成果") |
|
|
|
.doWrite(dtoList); |
|
|
|
} |
|
|
|
} |