|
@@ -9,6 +9,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
+import java.text.DecimalFormat;
|
|
|
import java.time.LocalDate;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Comparator;
|
|
@@ -52,11 +53,11 @@ public class AppPageReportServiceImpl implements AppPageReportService {
|
|
|
LocalDate localDate = LocalDate.now();
|
|
|
List<DeviceWaterSupply> deviceWaterSupplies = new ArrayList<DeviceWaterSupply>();
|
|
|
List<MonthRevenueDto> sellerWater = revenueService.selectOverviewRevenue(companyOrgId,month);
|
|
|
- for (int i = 1; i <= month; i++) {
|
|
|
- LocalDate newLocalDate = localDate.plusMonths(i-1);
|
|
|
+ for (int i = 0; i < month; i++) {
|
|
|
+ LocalDate newLocalDate = localDate.plusMonths(-i);
|
|
|
MonthRevenueDto revenue = findRevenue(sellerWater,newLocalDate);
|
|
|
DeviceWaterSupply deviceWaterSupply = new DeviceWaterSupply();
|
|
|
- deviceWaterSupply.setOrderNo(i + 1);
|
|
|
+ deviceWaterSupply.setOrderNo(i+1);
|
|
|
deviceWaterSupply.setYear(newLocalDate.getYear());
|
|
|
deviceWaterSupply.setMonth(newLocalDate.getMonthValue());
|
|
|
deviceWaterSupply.setDate(newLocalDate);
|
|
@@ -65,16 +66,16 @@ public class AppPageReportServiceImpl implements AppPageReportService {
|
|
|
deviceWaterSupply.setAmount(BigDecimal.ZERO);
|
|
|
}
|
|
|
else{
|
|
|
- deviceWaterSupply.setAmount(new BigDecimal(revenue.getBigUserUsage()));
|
|
|
+ deviceWaterSupply.setAmount(new BigDecimal(revenue.getMeterReadingUsage()));
|
|
|
}
|
|
|
- deviceWaterSupplies.add(i, deviceWaterSupply);
|
|
|
+ deviceWaterSupplies.add(i+1, deviceWaterSupply);
|
|
|
}
|
|
|
deviceWaterSupplies.sort(Comparator.comparing(DeviceWaterSupply::getOrderNo).reversed());
|
|
|
return deviceWaterSupplies;
|
|
|
}
|
|
|
|
|
|
private MonthRevenueDto findRevenue(List<MonthRevenueDto> sellerWater,LocalDate localDate) {
|
|
|
- String dateString = String.format("%s-%s-1", localDate.getYear(), localDate.getMonthValue());
|
|
|
+ String dateString = String.format("%s-%s", localDate.getYear(),new DecimalFormat("#00").format(localDate.getMonthValue()));
|
|
|
for (MonthRevenueDto revenue : sellerWater) {
|
|
|
if (revenue.getCollectDateString().equals(dateString)) {
|
|
|
return revenue;
|