|
@@ -1,13 +1,20 @@
|
|
|
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.LoginUser;
|
|
|
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;
|
|
@@ -25,23 +32,14 @@ import java.util.List;
|
|
|
public class AppPageReportServiceImpl implements AppPageReportService {
|
|
|
|
|
|
@Autowired
|
|
|
- private HomePageReportService homePageReportService;
|
|
|
+ private MonitorDataReportService monitorDataReportService;
|
|
|
|
|
|
@Autowired
|
|
|
private RevenueService revenueService;
|
|
|
|
|
|
- /**
|
|
|
- * App 总览 前N个月的取水量、制水量
|
|
|
- * @param companyOrgId
|
|
|
- * @param sceneType
|
|
|
- * @param parmType
|
|
|
- * @return
|
|
|
- */
|
|
|
- @Override
|
|
|
- public List<DeviceWaterSupply> deviceWaterReportForMonth(Integer companyOrgId, String sceneType, Integer parmType, Integer month) {
|
|
|
- List<DeviceWaterSupply> deviceWaterSupplies = homePageReportService.deviceWaterReportForMonth(companyOrgId,sceneType,parmType,month);
|
|
|
- return deviceWaterSupplies;
|
|
|
- }
|
|
|
+ @Resource
|
|
|
+ private HomePageReportMapper homePageReportMapper;
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* App 总览 前N个月的售水量
|
|
@@ -74,6 +72,78 @@ public class AppPageReportServiceImpl implements AppPageReportService {
|
|
|
return deviceWaterSupplies;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ /**
|
|
|
+ * App 总览 前N个月的取水量、制水量
|
|
|
+ * @param companyOrgId
|
|
|
+ * @param sceneType
|
|
|
+ * @param parmType
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public List<DeviceWaterSupply> deviceWaterReportForMonth(Integer companyOrgId,String sceneType, Integer parmType,Integer month){
|
|
|
+ LoginUser loginUser = UserUtil.getCurrentUser();
|
|
|
+ String tenantId = loginUser.getTenantId();
|
|
|
+ LocalDate localDate = LocalDate.now();
|
|
|
+
|
|
|
+ List<DeviceWaterSupply> deviceWaterSupplies = homePageReportMapper.getDeviceWaterForMonth(companyOrgId,sceneType,parmType ,tenantId,loginUser.getType(),loginUser.getPermissonType(),loginUser.getProgramItemList(),month);
|
|
|
+
|
|
|
+ BigDecimal AmountCountMonth = monitorDataReportService.getAmountCount(companyOrgId,null, sceneType, parmType,2 );
|
|
|
+
|
|
|
+ DeviceWaterSupply deviceWaterSupplyMonth = new DeviceWaterSupply();
|
|
|
+ deviceWaterSupplyMonth.setOrderNo(1);
|
|
|
+ deviceWaterSupplyMonth.setAmount(AmountCountMonth!=null?AmountCountMonth.divide(new BigDecimal("10000")):BigDecimal.ZERO);
|
|
|
+ deviceWaterSupplyMonth.setYear(localDate.getYear());
|
|
|
+ deviceWaterSupplyMonth.setMonth(localDate.getMonthValue());
|
|
|
+ deviceWaterSupplyMonth.setDate(localDate);
|
|
|
+ deviceWaterSupplyMonth.setDateLabel(localDate.getYear()+"-"+localDate.getMonthValue());
|
|
|
+ deviceWaterSupplies.add(0, deviceWaterSupplyMonth);
|
|
|
+
|
|
|
+ for (int i = 1; i < month; i++) {
|
|
|
+ LocalDate newLocalDate = localDate.plusMonths(-i );
|
|
|
+ if (i == deviceWaterSupplies.size()
|
|
|
+ || newLocalDate.getMonthValue() != deviceWaterSupplies.get(i).getMonth().intValue()
|
|
|
+ || newLocalDate.getYear() != deviceWaterSupplies.get(i).getYear().intValue()) {
|
|
|
+
|
|
|
+ DeviceWaterSupply deviceWaterSupply = new DeviceWaterSupply();
|
|
|
+ deviceWaterSupply.setOrderNo(i + 1);
|
|
|
+ deviceWaterSupply.setAmount(BigDecimal.ZERO);
|
|
|
+ deviceWaterSupply.setYear(newLocalDate.getYear());
|
|
|
+ deviceWaterSupply.setMonth(newLocalDate.getMonthValue());
|
|
|
+ deviceWaterSupply.setDate(newLocalDate);
|
|
|
+ deviceWaterSupply.setDateLabel(newLocalDate.getYear()+"-"+newLocalDate.getMonthValue());
|
|
|
+ deviceWaterSupplies.add(i, deviceWaterSupply);
|
|
|
+ } else {
|
|
|
+ deviceWaterSupplies.get(i).setOrderNo(i + 1);
|
|
|
+ deviceWaterSupplies.get(i).setDate(newLocalDate);
|
|
|
+ deviceWaterSupplies.get(i).setDateLabel(newLocalDate.getYear()+"-"+newLocalDate.getMonthValue());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ deviceWaterSupplies.sort(Comparator.comparing(DeviceWaterSupply::getOrderNo).reversed());
|
|
|
+
|
|
|
+ return deviceWaterSupplies;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<DeviceWaterSupply> deviceWaterReportForDay(Integer companyOrgId, String sceneType, Integer parmType, Integer startYear, Integer startMonth, Integer startDay, Integer endYear, Integer endMonth, Integer endDay) {
|
|
|
+ LoginUser loginUser = UserUtil.getCurrentUser();
|
|
|
+ String tenantId = loginUser.getTenantId();
|
|
|
+ List<DeviceWaterSupply> deviceWaterSupplyList = homePageReportMapper.deviceWaterReportForDay(companyOrgId,
|
|
|
+ sceneType,parmType ,
|
|
|
+ tenantId,loginUser.getType(),
|
|
|
+ loginUser.getPermissonType(),
|
|
|
+ loginUser.getProgramItemList(),
|
|
|
+ startYear,
|
|
|
+ startMonth,
|
|
|
+ startDay,
|
|
|
+ endYear,
|
|
|
+ endMonth,
|
|
|
+ endDay);
|
|
|
+ return deviceWaterSupplyList;
|
|
|
+ }
|
|
|
+
|
|
|
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) {
|