fix(prison): 修复刑期总天数计算错误
- 使用 ChronoUnit.DAYS.between 计算入监日期到释放日期的总天数 - 修复后:2024-01-15 到 2027-07-14 = 1276天(原错误计算为743天) - 确保与其他日期计算逻辑一致
This commit is contained in:
parent
653e55a075
commit
182b7a7b43
@ -72,6 +72,9 @@ public class PrisonerDashboardStatsRespVO {
|
||||
@Schema(description = "剩余刑期天数", example = "1000")
|
||||
private Integer remainingDays;
|
||||
|
||||
@Schema(description = "刑期总天数", example = "1276")
|
||||
private Integer sentenceDays;
|
||||
|
||||
@Schema(description = "累计违规次数", example = "5")
|
||||
private Integer violationCount;
|
||||
|
||||
|
||||
@ -200,17 +200,28 @@ public class PrisonDashboardServiceImpl implements PrisonDashboardService {
|
||||
}
|
||||
|
||||
// 入狱和出狱时间
|
||||
if (prisoner.getImprisonmentDate() != null) {
|
||||
if (prisoner.getImprisonmentDate() != null && prisoner.getReleaseDate() != null) {
|
||||
vo.setImprisonmentDate(prisoner.getImprisonmentDate().toString());
|
||||
vo.setServedDays((int) ChronoUnit.DAYS.between(prisoner.getImprisonmentDate(), LocalDate.now()));
|
||||
}
|
||||
if (prisoner.getReleaseDate() != null) {
|
||||
vo.setReleaseDate(prisoner.getReleaseDate().toString());
|
||||
// 计算剩余刑期天数
|
||||
// 计算刑期总天数(从入监日期到释放日期)
|
||||
long sentenceDays = ChronoUnit.DAYS.between(prisoner.getImprisonmentDate(), prisoner.getReleaseDate());
|
||||
vo.setSentenceDays((int) sentenceDays);
|
||||
// 计算已服刑天数(从入监日期到当前日期)
|
||||
vo.setServedDays((int) ChronoUnit.DAYS.between(prisoner.getImprisonmentDate(), LocalDate.now()));
|
||||
// 计算剩余刑期天数(从当前日期到释放日期)
|
||||
long remainingDays = ChronoUnit.DAYS.between(LocalDate.now(), prisoner.getReleaseDate());
|
||||
vo.setRemainingDays(remainingDays > 0 ? (int) remainingDays : 0);
|
||||
} else if (prisoner.getImprisonmentDate() != null) {
|
||||
vo.setImprisonmentDate(prisoner.getImprisonmentDate().toString());
|
||||
vo.setServedDays((int) ChronoUnit.DAYS.between(prisoner.getImprisonmentDate(), LocalDate.now()));
|
||||
if (prisoner.getReleaseDate() != null) {
|
||||
vo.setReleaseDate(prisoner.getReleaseDate().toString());
|
||||
long remainingDays = ChronoUnit.DAYS.between(LocalDate.now(), prisoner.getReleaseDate());
|
||||
vo.setRemainingDays(remainingDays > 0 ? (int) remainingDays : 0);
|
||||
}
|
||||
} else {
|
||||
vo.setRemainingDays(null);
|
||||
vo.setSentenceDays(null);
|
||||
}
|
||||
|
||||
// 监区信息(查询实际监区名称)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user