增加报表
This commit is contained in:
parent
17a770a656
commit
9fa8ea7032
|
@ -3,7 +3,7 @@ package com.northtecom.visatrack.api.controller.api;
|
|||
import com.northtecom.visatrack.api.base.exception.BaseException;
|
||||
import com.northtecom.visatrack.api.base.web.Status;
|
||||
import com.northtecom.visatrack.api.controller.vo.AllReportDataSummary;
|
||||
import com.northtecom.visatrack.api.controller.vo.MonthlyReportDataSummary;
|
||||
import com.northtecom.visatrack.api.controller.vo.ReportDataSummary;
|
||||
import com.northtecom.visatrack.api.controller.vo.ReportDataSummaryItem;
|
||||
import com.northtecom.visatrack.api.controller.vo.VisaCaseResponse;
|
||||
import com.northtecom.visatrack.api.data.entity.CaseVisaReport;
|
||||
|
@ -55,17 +55,28 @@ public class CaseVisaReportReportController {
|
|||
|
||||
@GetMapping("/QueryMonthlyReportData")
|
||||
@Operation(summary = "按月查询报表数据", description = "按月查询报表数据,月份的格式为 yyyy-MM 例如 2022-10")
|
||||
public MonthlyReportDataSummary QueryAllReportData(String monthKey) {
|
||||
public ReportDataSummary QueryAllReportData(String monthKey) {
|
||||
CaseVisaReport caseVisaReport = this.caseVisaReportService.QueryByMonth(monthKey);
|
||||
if (caseVisaReport == null) {
|
||||
throw new BaseException(Status.BAD_REQUEST, "没有找到对应的报表数据");
|
||||
}
|
||||
List<VisaCase> visaCaseList = visaCaseService.QueryByMonthKey(monthKey);
|
||||
MonthlyReportDataSummary monthlyReportDataSummary = new MonthlyReportDataSummary();
|
||||
monthlyReportDataSummary.setSummaryItem(new ReportDataSummaryItem(caseVisaReport));
|
||||
monthlyReportDataSummary.setVisaCaseList(VisaCaseResponse.newList(visaCaseList));
|
||||
return monthlyReportDataSummary;
|
||||
ReportDataSummary reportDataSummary = new ReportDataSummary();
|
||||
reportDataSummary.setTitle(monthKey);
|
||||
reportDataSummary.setSummaryItem(new ReportDataSummaryItem(caseVisaReport));
|
||||
reportDataSummary.setVisaCaseList(VisaCaseResponse.newList(visaCaseList));
|
||||
return reportDataSummary;
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("/QueryLastCompetedDaysReportData")
|
||||
@Operation(summary = "按照最后N天完成签证查询报表数据", description = "按照最后N天完成签证查询报表数据,数入参数为最后N天的天数")
|
||||
public ReportDataSummary QueryLastCompetedDaysReportData(Integer lastCompetedDays) {
|
||||
List<VisaCase> visaCaseList = visaCaseService.QueryByLastCompletedDay(lastCompetedDays);
|
||||
ReportDataSummary reportDataSummary = new ReportDataSummary();
|
||||
reportDataSummary.setTitle(String.format("Last %d Days Complete Cases", lastCompetedDays));
|
||||
reportDataSummary.setSummaryItem(new ReportDataSummaryItem(visaCaseList));
|
||||
reportDataSummary.setVisaCaseList(VisaCaseResponse.newList(visaCaseList));
|
||||
return reportDataSummary;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,7 +12,8 @@ import java.util.List;
|
|||
* @Description:
|
||||
*/
|
||||
@Data
|
||||
public class MonthlyReportDataSummary {
|
||||
public class ReportDataSummary {
|
||||
private String title;
|
||||
private ReportDataSummaryItem summaryItem;
|
||||
private List<ReportDataVisaCategorySummaryItem> categorySummaryItem;
|
||||
private List<ReportDataVisaConsulateSummaryItem> consulateSummaryItem;
|
|
@ -1,8 +1,13 @@
|
|||
package com.northtecom.visatrack.api.controller.vo;
|
||||
|
||||
import com.northtecom.visatrack.api.data.entity.CaseVisaReport;
|
||||
import com.northtecom.visatrack.api.data.entity.VisaCase;
|
||||
import com.northtecom.visatrack.api.service.enums.VisaStatus;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* Created with IntelliJ IDEA.
|
||||
*
|
||||
|
@ -31,4 +36,22 @@ public class ReportDataSummaryItem {
|
|||
this.setAveWaitingDaysForCompleteCases(item.getAveWaitingDaysForCompleteCases().toString());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public ReportDataSummaryItem(List<VisaCase> visaCaseList) {
|
||||
this.setMonth("");
|
||||
this.setPendingCaseCount(visaCaseList.stream().filter(x -> x.getVisaStatus().equals(VisaStatus.Pending)).toArray().length);
|
||||
this.setClearCaseCount(visaCaseList.stream().filter(x -> x.getVisaStatus().equals(VisaStatus.Clear)).toArray().length);
|
||||
this.setRejectCaseCount(visaCaseList.stream().filter(x -> x.getVisaStatus().equals(VisaStatus.Reject)).toArray().length);
|
||||
this.setTotalCaseCount(visaCaseList.size());
|
||||
|
||||
List<VisaCaseResponse> visaCaseResponseList =
|
||||
visaCaseList.stream().map(VisaCaseResponse::new).collect(Collectors.toList());
|
||||
|
||||
if (visaCaseResponseList.size() == 0) {
|
||||
this.setAveWaitingDaysForCompleteCases("N/A");
|
||||
} else {
|
||||
this.setAveWaitingDaysForCompleteCases(String.valueOf(visaCaseResponseList.stream().mapToInt(VisaCaseResponse::getWaitDayCounts).average().getAsDouble()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@ public class VisaCaseResponse {
|
|||
private LocalDate dateVisaCheckCompleted;
|
||||
private LocalDate dateVisaIssued;
|
||||
private String waitDays;
|
||||
private Integer waitDayCounts;
|
||||
private String saveUserId;
|
||||
|
||||
public VisaCaseResponse() {
|
||||
|
@ -47,8 +48,10 @@ public class VisaCaseResponse {
|
|||
|
||||
if (visaCase.getDateVisaInterview() != null && visaCase.getDateVisaCheckCompleted() != null) {
|
||||
this.setWaitDays(String.valueOf(visaCase.getDateVisaCheckCompleted().toEpochDay() - visaCase.getDateVisaInterview().toEpochDay()));
|
||||
this.setWaitDayCounts((int) (visaCase.getDateVisaCheckCompleted().toEpochDay() - visaCase.getDateVisaInterview().toEpochDay()));
|
||||
} else {
|
||||
this.setWaitDays("N/A");
|
||||
this.setWaitDayCounts(0);
|
||||
}
|
||||
|
||||
if (visaCase.getSaveUserId() != null) {
|
||||
|
|
|
@ -45,6 +45,7 @@ public class CaseVisaReportService {
|
|||
return caseVisaReportRepository.findByMonth(monthKey).orElse(null);
|
||||
}
|
||||
|
||||
|
||||
public List<CaseStatusConsulateSummaryReport> QueryStatusConsulateSummaryReport(String monthKey) {
|
||||
DateRange dateRange = DateRange.ofMonthKey(monthKey);
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ spring:
|
|||
application:
|
||||
name: usvisatrack
|
||||
title: Us Visa Track API
|
||||
version: 1.0.6
|
||||
version: 1.0.7
|
||||
jackson:
|
||||
mapper:
|
||||
accept-case-insensitive-properties: true
|
||||
|
|
Loading…
Reference in New Issue