From 9eb627b8fa752eb0c0855fd4d12b76761d67217b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=98=BF=E6=B2=90?= Date: Mon, 29 Apr 2024 19:29:23 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/net/maku/system/service/impl/SysUserServiceImpl.java | 3 +-- .../src/main/java/net/maku/framework/common/utils/ExcelUtils.java | 8 ++++---- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/maku-boot-system/src/main/java/net/maku/system/service/impl/SysUserServiceImpl.java b/maku-boot-system/src/main/java/net/maku/system/service/impl/SysUserServiceImpl.java index f430414..b023da6 100644 --- a/maku-boot-system/src/main/java/net/maku/system/service/impl/SysUserServiceImpl.java +++ b/maku-boot-system/src/main/java/net/maku/system/service/impl/SysUserServiceImpl.java @@ -257,9 +257,8 @@ public class SysUserServiceImpl extends BaseServiceImpl list = list(Wrappers.lambdaQuery(SysUserEntity.class).eq(SysUserEntity::getSuperAdmin, SuperAdminEnum.NO.getValue())); List userExcelVOS = SysUserConvert.INSTANCE.convert2List(list); transService.transBatch(userExcelVOS); - String fileName = "system_user_excel"; // 写到浏览器打开 - ExcelUtils.excelExport(SysUserExcelVO.class, fileName + DateUtils.format(new Date()), null, userExcelVOS); + ExcelUtils.excelExport(SysUserExcelVO.class, "system_user_excel" + DateUtils.format(new Date()), null, userExcelVOS); } } diff --git a/maku-framework/src/main/java/net/maku/framework/common/utils/ExcelUtils.java b/maku-framework/src/main/java/net/maku/framework/common/utils/ExcelUtils.java index 0614721..56149fd 100644 --- a/maku-framework/src/main/java/net/maku/framework/common/utils/ExcelUtils.java +++ b/maku-framework/src/main/java/net/maku/framework/common/utils/ExcelUtils.java @@ -1,6 +1,7 @@ package net.maku.framework.common.utils; import cn.hutool.core.collection.CollectionUtil; +import cn.hutool.core.date.DateUtil; import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.URLUtil; import cn.hutool.extra.spring.SpringUtil; @@ -25,8 +26,7 @@ import java.io.FileInputStream; import java.io.IOException; import java.lang.reflect.Field; import java.nio.charset.StandardCharsets; -import java.time.LocalDateTime; -import java.time.format.DateTimeFormatter; +import java.util.Date; import java.util.List; import java.util.stream.Collectors; @@ -174,8 +174,8 @@ public class ExcelUtils { response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); response.setHeader("Access-Control-Expose-Headers", "Content-Disposition"); response.setCharacterEncoding("UTF-8"); - String timestamp = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss")); - excelName+=timestamp; + + excelName += DateUtil.format(new Date(), "yyyyMMddHHmmss"); String fileName = URLUtil.encode(excelName, StandardCharsets.UTF_8); response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".xlsx");