From 622cb4fad7bf878dfc99aeb8c0737b524d1d9e56 Mon Sep 17 00:00:00 2001 From: Yangzz <9704.yyds@163.com> Date: Fri, 10 Oct 2025 14:15:10 +0800 Subject: [PATCH] =?UTF-8?q?=E6=97=A5=E6=9C=9F=E6=A0=BC=E5=BC=8F=E8=B0=83?= =?UTF-8?q?=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/gaotao/common/utils/GenDate.java | 15 +++++++++++++++ .../service/impl/PrintLabelRecordServiceImpl.java | 5 +++-- .../impl/PrintRollLabelRecordServiceImpl.java | 5 +++-- 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/gaotao/common/utils/GenDate.java b/src/main/java/com/gaotao/common/utils/GenDate.java index a73da88..75898dc 100644 --- a/src/main/java/com/gaotao/common/utils/GenDate.java +++ b/src/main/java/com/gaotao/common/utils/GenDate.java @@ -1,6 +1,7 @@ package com.gaotao.common.utils; import java.time.LocalDate; +import java.time.format.DateTimeFormatter; import java.time.temporal.ChronoUnit; public class GenDate { @@ -10,4 +11,18 @@ public class GenDate { int excelDate = (int) days; return excelDate+siteCode; } + + /** + * 将LocalDate转换为指定格式的日期字符串 + * @param currentDate 要转换的日期 + * @param dateFormat 日期格式,例如:"yyyy-MM-dd", "yyyyMMdd", "yyyy/MM/dd" 等 + * @return 格式化后的日期字符串 + */ + public static String formatDate(LocalDate currentDate, String dateFormat) { + if (currentDate == null || dateFormat == null || dateFormat.trim().isEmpty()) { + return ""; + } + DateTimeFormatter formatter = DateTimeFormatter.ofPattern(dateFormat); + return currentDate.format(formatter); + } } diff --git a/src/main/java/com/gaotao/modules/label/service/impl/PrintLabelRecordServiceImpl.java b/src/main/java/com/gaotao/modules/label/service/impl/PrintLabelRecordServiceImpl.java index 2d41c28..b407643 100644 --- a/src/main/java/com/gaotao/modules/label/service/impl/PrintLabelRecordServiceImpl.java +++ b/src/main/java/com/gaotao/modules/label/service/impl/PrintLabelRecordServiceImpl.java @@ -5,7 +5,6 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.gaotao.common.constant.SysMsgConstant; import com.gaotao.common.utils.GenDate; -import com.gaotao.modules.app.entity.UserEntity; import com.gaotao.modules.factory.entity.Site; import com.gaotao.modules.factory.service.SiteService; import com.gaotao.modules.label.entity.LabelFormatUserDefault; @@ -170,7 +169,9 @@ public class PrintLabelRecordServiceImpl extends ServiceImpl