|
@@ -1,23 +1,15 @@
|
|
|
package com.huaxu.service.impl;
|
|
|
|
|
|
-import com.huaxu.client.UserCenterClient;
|
|
|
-import com.huaxu.dao.HomePageReportMapper;
|
|
|
-import com.huaxu.dao.MonitorDataReportMapper;
|
|
|
import com.huaxu.dto.MonthRevenueDto;
|
|
|
import com.huaxu.dto.generalView.DeviceWaterSupply;
|
|
|
-import com.huaxu.model.AjaxMessage;
|
|
|
-import com.huaxu.model.LoginUser;
|
|
|
-import com.huaxu.model.ResultStatus;
|
|
|
import com.huaxu.service.AppPageReportService;
|
|
|
import com.huaxu.service.HomePageReportService;
|
|
|
-import com.huaxu.service.MonitorDataReportService;
|
|
|
import com.huaxu.service.RevenueService;
|
|
|
-import com.huaxu.util.UserUtil;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
-import javax.annotation.Resource;
|
|
|
import java.math.BigDecimal;
|
|
|
+import java.text.DecimalFormat;
|
|
|
import java.time.LocalDate;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Comparator;
|
|
@@ -58,22 +50,37 @@ public class AppPageReportServiceImpl implements AppPageReportService {
|
|
|
*/
|
|
|
@Override
|
|
|
public List<DeviceWaterSupply> deviceSellerWaterReportForMonth(Integer companyOrgId,Integer month) {
|
|
|
- BigDecimal AmountCountMonth = null;
|
|
|
LocalDate localDate = LocalDate.now();
|
|
|
List<DeviceWaterSupply> deviceWaterSupplies = new ArrayList<DeviceWaterSupply>();
|
|
|
List<MonthRevenueDto> sellerWater = revenueService.selectOverviewRevenue(companyOrgId,month);
|
|
|
- if(sellerWater.size()>0 && sellerWater.get(0).getMeterReadingUsage() != null){
|
|
|
- AmountCountMonth = new BigDecimal(sellerWater.get(0).getMeterReadingUsage());
|
|
|
+ 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.setYear(newLocalDate.getYear());
|
|
|
+ deviceWaterSupply.setMonth(newLocalDate.getMonthValue());
|
|
|
+ deviceWaterSupply.setDate(newLocalDate);
|
|
|
+ deviceWaterSupply.setDateLabel(newLocalDate.getYear()+"-"+newLocalDate.getMonthValue());
|
|
|
+ if(revenue == null){
|
|
|
+ deviceWaterSupply.setAmount(BigDecimal.ZERO);
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ deviceWaterSupply.setAmount(new BigDecimal(revenue.getMeterReadingUsage()));
|
|
|
+ }
|
|
|
+ deviceWaterSupplies.add(i, deviceWaterSupply);
|
|
|
}
|
|
|
- DeviceWaterSupply deviceWaterSupplyMonth = new DeviceWaterSupply();
|
|
|
- deviceWaterSupplyMonth.setOrderNo(1);
|
|
|
- deviceWaterSupplyMonth.setAmount(AmountCountMonth != null ? AmountCountMonth : BigDecimal.ZERO);
|
|
|
- deviceWaterSupplyMonth.setYear(localDate.getYear());
|
|
|
- deviceWaterSupplyMonth.setMonth(localDate.getMonthValue());
|
|
|
- deviceWaterSupplyMonth.setDate(localDate);
|
|
|
- deviceWaterSupplyMonth.setDateLabel(localDate.getYear() + "-" + localDate.getMonthValue());
|
|
|
- deviceWaterSupplies.add(0, deviceWaterSupplyMonth);
|
|
|
deviceWaterSupplies.sort(Comparator.comparing(DeviceWaterSupply::getOrderNo).reversed());
|
|
|
return deviceWaterSupplies;
|
|
|
}
|
|
|
+
|
|
|
+ private MonthRevenueDto findRevenue(List<MonthRevenueDto> sellerWater,LocalDate localDate) {
|
|
|
+ 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;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
}
|