From 9a95e74860b573933508c9cc4293a23a53f2b89b Mon Sep 17 00:00:00 2001 From: gjh <1421wake> Date: Fri, 6 Jun 2025 17:32:05 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B7=A5=E5=8D=95=E4=BF=A1=E6=81=AF=E5=AF=BC?= =?UTF-8?q?=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../platform/controller/ExcelController.java | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/ruoyi-modules/guoyan-platform/src/main/java/org/dromara/platform/controller/ExcelController.java b/ruoyi-modules/guoyan-platform/src/main/java/org/dromara/platform/controller/ExcelController.java index 4bb2e81..dc6c690 100644 --- a/ruoyi-modules/guoyan-platform/src/main/java/org/dromara/platform/controller/ExcelController.java +++ b/ruoyi-modules/guoyan-platform/src/main/java/org/dromara/platform/controller/ExcelController.java @@ -11,12 +11,15 @@ import org.dromara.platform.domain.PerformanceManagement; import org.dromara.platform.domain.PointInfo; import org.dromara.platform.domain.bo.PerformanceManagementBo; import org.dromara.platform.domain.bo.PointInfoBo; +import org.dromara.platform.domain.bo.WorkOrderInfoBo; import org.dromara.platform.domain.vo.PerformanceManagementVo; import org.dromara.platform.domain.vo.PointInfoVo; +import org.dromara.platform.domain.vo.WorkOrderInfoVo; import org.dromara.platform.listener.PerformanceManagementListener; import org.dromara.platform.listener.PointInfoListener; import org.dromara.platform.service.IPointInfoService; import org.dromara.platform.service.IProjectInfoService; +import org.dromara.platform.service.IWorkOrderInfoService; import org.dromara.platform.service.ProjectManagerService; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.PostMapping; @@ -37,6 +40,9 @@ import java.util.List; public class ExcelController { @Resource private IPointInfoService pointInfoService ; + + @Resource + private IWorkOrderInfoService workOrderInfoService ; @PostMapping("/uploadPointInfo") public void uploadPointInfo(MultipartFile file, HttpServletResponse response) throws IOException { long t1 = System.currentTimeMillis(); @@ -68,4 +74,21 @@ public class ExcelController { .sheet("点位信息"+currentDate) .doWrite(list); } + + @PostMapping("/ExportWorkOrderInfo") + public void ExportWorkOrderInfo(WorkOrderInfoBo bo, HttpServletResponse response) throws IOException { + List list = workOrderInfoService.queryList(bo); + response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); + response.setCharacterEncoding("utf-8"); + String flag = "工单信息"; + // 这里URLEncoder.encode可以防止中文乱码 当然和easyexcel没有关系 + LocalDate currentDate = LocalDate.now(); + System.out.println("当前日期: " + currentDate); + String fileName = URLEncoder.encode( flag+currentDate, "UTF-8") + .replaceAll("\\+", "%20"); + response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName + ".xlsx"); + EasyExcel.write(response.getOutputStream(), WorkOrderInfoVo.class) + .sheet("工单信息"+currentDate) + .doWrite(list); + } }