use of com.tony.billing.response.costrecord.ReportResponse in project BillingDubbo by TonyJiangWJ.
the class CostReportController method getDailyCostReport.
@RequestMapping("/daily/report/get")
public ReportResponse getDailyCostReport(@ModelAttribute("request") @Validated DailyCostReportRequest reportRequest) {
ReportResponse response = new ReportResponse();
try {
List<ReportEntity> result = costReportService.getReportInfoBetween(reportRequest.getStartDate(), reportRequest.getEndDate(), reportRequest.getUserId());
if (CollectionUtils.isEmpty(result)) {
ResponseUtil.dataNotExisting(response);
} else {
response.setReportList(BeanCopyUtil.copy(result, ReportDTO.class));
ResponseUtil.success(response);
}
return response;
} catch (Exception e) {
logger.error("/daily/report/get error", e);
return ResponseUtil.sysError(response);
}
}
use of com.tony.billing.response.costrecord.ReportResponse in project BillingDubbo by TonyJiangWJ.
the class CostReportController method getReport.
@RequestMapping(value = "/report/get")
public ReportResponse getReport(@ModelAttribute("request") CostReportRequest request) {
ReportResponse response = new ReportResponse();
try {
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM");
LocalDate localDate = LocalDate.now();
List<String> monthList = new ArrayList<>();
if (StringUtils.isEmpty(request.getStartMonth()) || StringUtils.isEmpty(request.getEndMonth())) {
int ngm = -6;
localDate = localDate.plusMonths(ngm);
for (int i = 0; i < -ngm; i++) {
localDate = localDate.plusMonths(1);
monthList.add(localDate.format(dateTimeFormatter));
}
} else {
YearMonth start = YearMonth.parse(request.getStartMonth(), dateTimeFormatter);
YearMonth end = YearMonth.parse(request.getEndMonth(), dateTimeFormatter);
do {
monthList.add(start.format(dateTimeFormatter));
start = start.plusMonths(1);
} while (!start.isAfter(end));
}
return getReportResponse(monthList, request.getUserId(), response);
} catch (Exception e) {
logger.error("/report/get error", e);
ResponseUtil.sysError(response);
}
return response;
}
Aggregations