修复签证数据查询bug

This commit is contained in:
yang.xie 2022-10-16 07:30:28 +08:00
parent 2248a8a1a7
commit 7c4090c0fb
3 changed files with 23 additions and 6 deletions

View File

@ -40,4 +40,22 @@ public interface VisaCaseRepository extends PagingAndSortingRepository<VisaCase,
List<Object[]> queryMonthAvgWaitDaysReport(@Param("startDate") LocalDate startDate,
@Param("endDate") LocalDate endDate);
@Query(value = "select * \n" +
"from usvisatrack.visa_case \n" +
"where date_visa_check_completed >=:startDate and date_visa_check_completed <:endDate \n" +
"and date_visa_check_completed is not null and visa_status <> 'Pending' \n" +
"order by date_visa_check_completed", nativeQuery = true)
List<VisaCase> queryCompletedCase(@Param("startDate") LocalDate startDate,
@Param("endDate") LocalDate endDate);
@Query(value = "select * \n" +
"from usvisatrack.visa_case \n" +
"where date_visa_interview >=:startDate and date_visa_interview < :endDate \n" +
"order by date_visa_interview", nativeQuery = true)
List<VisaCase> queryByCheckDateRange(@Param("startDate") LocalDate startDate,
@Param("endDate") LocalDate endDate);
}

View File

@ -28,7 +28,8 @@ public class DateRange {
*/
public static DateRange ofLastCompletedDay(Integer lastCompletedDays) {
DateRange dateRange = new DateRange();
dateRange.setStart(LocalDate.now().minusDays(lastCompletedDays));
dateRange.setStart(LocalDate.now().minusDays(lastCompletedDays - 1));
dateRange.setEnd(LocalDate.now().plusMonths(1));
return dateRange;
}

View File

@ -104,7 +104,7 @@ public class VisaCaseService {
DateRange checkDateRange = DateRange.ofMonthKey(monthKey);
VisaCaseSpecification visaCaseSpecification = new VisaCaseSpecification();
visaCaseSpecification.setCheckDateDateRange(checkDateRange);
return visaCaseRepository.findAll(visaCaseSpecification, getDefaultSort());
return visaCaseRepository.queryByCheckDateRange(checkDateRange.getStart(), checkDateRange.getEnd());
}
/**
@ -115,10 +115,8 @@ public class VisaCaseService {
*/
public List<VisaCase> QueryByLastCompletedDay(Integer lastCompletedDays) {
DateRange completedDateRange = DateRange.ofLastCompletedDay(lastCompletedDays);
VisaCaseSpecification visaCaseSpecification = new VisaCaseSpecification();
visaCaseSpecification.setCompleteDateRange(completedDateRange);
visaCaseSpecification.setVisaStatus(VisaStatus.Clear);
return visaCaseRepository.findAll(visaCaseSpecification, getDefaultSort());
return visaCaseRepository.queryCompletedCase(completedDateRange.getStart(), completedDateRange.getEnd());
}
/**