huangtf hace 1 año
padre
commit
04d07e5ea5

+ 2 - 2
blade-service/blade-archive/src/main/java/org/springblade/archive/service/impl/ArchiveAutoPdfServiceImpl.java

@@ -713,11 +713,11 @@ public class ArchiveAutoPdfServiceImpl implements IArchiveAutoPdfService {
         }
 
         // 将日期赋值给startDate和endDate
-        if (!minDate.isEmpty()) {
+        if (!minDate.isEmpty() && !minDate.equals("null") && minDate.matches(".*\\d.*")) {
             LocalDateTime localDateTime = FormulaUtil.parseStringToLocalDateTime(minDate, "yyyyMMdd");
             archive.setStartDate(localDateTime);
         }
-        if (!maxDate.isEmpty()) {
+        if (!maxDate.isEmpty() && !maxDate.equals("null") && maxDate.matches(".*\\d.*")) {
             LocalDateTime localDateTime = FormulaUtil.parseStringToLocalDateTime(maxDate, "yyyyMMdd");
             archive.setEndDate(localDateTime);
         }

+ 8 - 0
blade-service/blade-archive/src/main/java/org/springblade/archive/utils/FormulaUtil.java

@@ -1,6 +1,7 @@
 package org.springblade.archive.utils;
 
 import com.fasterxml.jackson.databind.ObjectMapper;
+import org.apache.commons.lang.StringUtils;
 import org.springblade.common.vo.DataVO;
 import org.springblade.manager.entity.ArchiveTree;
 
@@ -54,6 +55,13 @@ public class FormulaUtil {
      * @return
      */
     public static LocalDateTime parseStringToLocalDateTime(String strDate, String pattern) {
+        if (StringUtils.isNotEmpty(strDate)) {
+            strDate =  strDate.replace(".", "");
+            strDate = strDate.replace("-","");
+            strDate = strDate.replace("年","");
+            strDate = strDate.replace("月","");
+            strDate = strDate.replace("日","");
+        }
         DateTimeFormatter formatter = DateTimeFormatter.ofPattern(pattern);
         LocalDate date = LocalDate.parse(strDate, formatter);
         return LocalDateTime.of(date, LocalTime.MIN);