From fb97f83e39a0995fb70326c492a0bcd37af5e300 Mon Sep 17 00:00:00 2001
From: liujie <1793218484@qq.com>
Date: 星期三, 12 十一月 2025 17:45:57 +0800
Subject: [PATCH] Merge branch 'master' of http://120.76.84.145:10101/gitblit/r/java/mobile_community
---
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TOldsterWarningServiceImpl.java | 32 ++++++++++++++++++++++++--------
1 files changed, 24 insertions(+), 8 deletions(-)
diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TOldsterWarningServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TOldsterWarningServiceImpl.java
index 140bee4..74d0862 100644
--- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TOldsterWarningServiceImpl.java
+++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TOldsterWarningServiceImpl.java
@@ -15,6 +15,8 @@
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
+import java.time.LocalDate;
+import java.time.Period;
import java.util.ArrayList;
import java.util.List;
@@ -36,23 +38,37 @@
if(CollectionUtils.isEmpty(list)){
return pageInfo;
}
+
for (TOldsterWarningVO oldsterWarningVO : list) {
- int age = IDCardAgeCalculator.calculateAge(oldsterWarningVO.getIdCard());
- oldsterWarningVO.setOldsterAge(age);
+ LocalDate birthDate = oldsterWarningVO.getBirthDate();
+ LocalDate currentDate = LocalDate.now();
+ // 使用Period类计算两个日期之间的年数差异
+ Period period = Period.between(birthDate, currentDate);
+ int years = period.getYears();
+ // 如果当前日期小于出生日期的下一个生日,则需要减去一年(因为我们还没有过生日)
+ if (currentDate.isBefore(birthDate.plusYears(years).plusMonths(1).minusDays(1))) {
+ years--;
+ }
+ oldsterWarningVO.setOldsterAge(years);
}
pageInfo.setRecords(list);
return pageInfo;
}
@Override
- public List<TOldsterWarningExport> exportOldsterWarning(TCourseOrderQuery query) {
+ public List<TOldsterWarningExport> exportOldsterWarning(OldsterListQuery query) {
List<TOldsterWarningExport> list = this.baseMapper.exportOldsterWarning(query);
- if(CollectionUtils.isEmpty(list)){
- return new ArrayList<>();
- }
for (TOldsterWarningExport oldsterWarningExport : list) {
- int age = IDCardAgeCalculator.calculateAge(oldsterWarningExport.getIdCard());
- oldsterWarningExport.setOldsterAge(age);
+ LocalDate birthDate = oldsterWarningExport.getBirthDate();
+ LocalDate currentDate = LocalDate.now();
+ // 使用Period类计算两个日期之间的年数差异
+ Period period = Period.between(birthDate, currentDate);
+ int years = period.getYears();
+ // 如果当前日期小于出生日期的下一个生日,则需要减去一年(因为我们还没有过生日)
+ if (currentDate.isBefore(birthDate.plusYears(years).plusMonths(1).minusDays(1))) {
+ years--;
+ }
+ oldsterWarningExport.setOldsterAge(years);
}
return list;
}
--
Gitblit v1.7.1