|
|
|
@ -834,6 +834,11 @@ public class LabelDataProcessorServiceImpl implements LabelDataProcessorService |
|
|
|
if (!"text".equals(element.getType()) || !"date".equals(element.getDataType())) { |
|
|
|
return false; |
|
|
|
} |
|
|
|
// 流水号后缀只属于完整日期。提取方式为空按完整日期兼容旧模板;周别等类型即使残留勾选也不再追加。 |
|
|
|
String extractType = StringUtils.trimToEmpty(element.getDateExtractType()); |
|
|
|
if (StringUtils.isNotBlank(extractType) && !"full".equalsIgnoreCase(extractType)) { |
|
|
|
return false; |
|
|
|
} |
|
|
|
return StringUtils.equalsAnyIgnoreCase(StringUtils.trimToEmpty(element.getShowSerialNumber()), "true", "y", "1"); |
|
|
|
} |
|
|
|
|
|
|
|
@ -1358,9 +1363,10 @@ public class LabelDataProcessorServiceImpl implements LabelDataProcessorService |
|
|
|
try { |
|
|
|
java.time.LocalDate yearStartDate = java.time.LocalDate.of(date.getYear(), 1, 1); |
|
|
|
long daysBetween = java.time.temporal.ChronoUnit.DAYS.between(yearStartDate, date); |
|
|
|
// 周别展示为年份后两位 + 两位周号,例如 2026 年第 3 周输出 2603 |
|
|
|
String yearSuffix = String.format("%02d", date.getYear() % 100); |
|
|
|
if (daysBetween <= 0) { |
|
|
|
return "01" + yearSuffix; |
|
|
|
return yearSuffix + "01"; |
|
|
|
} |
|
|
|
|
|
|
|
int firstDayOfWeek = 0; // 默认周日为第一天 |
|
|
|
@ -1384,11 +1390,11 @@ public class LabelDataProcessorServiceImpl implements LabelDataProcessorService |
|
|
|
weekNumber = (int) ((daysBetween - daysToNextWeekStart) / 7) + 2; |
|
|
|
} |
|
|
|
int normalizedWeekNumber = Math.max(1, weekNumber); |
|
|
|
return String.format("%02d", normalizedWeekNumber) + yearSuffix; |
|
|
|
return yearSuffix + String.format("%02d", normalizedWeekNumber); |
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
log.error("周数计算失败: date={}, firstDayOfWeek={}", date, firstDayOfWeekStr); |
|
|
|
return "01" + String.format("%02d", date.getYear() % 100); |
|
|
|
return String.format("%02d", date.getYear() % 100) + "01"; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|