|
@@ -2,15 +2,28 @@ package com.huaxu.service.impl;
|
|
|
|
|
|
import com.huaxu.client.UserCenterClient;
|
|
|
import com.huaxu.dao.AppReportMonitorMapper;
|
|
|
+import com.huaxu.dao.HomePageReportMapper;
|
|
|
import com.huaxu.dto.CompanySceneInfoDto;
|
|
|
import com.huaxu.dto.OrgBaseTreeInfoDto;
|
|
|
+import com.huaxu.dto.generalView.WaterSupplyChart;
|
|
|
+import com.huaxu.dto.generalView.WaterSupplyData;
|
|
|
+import com.huaxu.dto.homePage.WaterQualityRate;
|
|
|
import com.huaxu.entity.SceneEntity;
|
|
|
+import com.huaxu.model.LoginUser;
|
|
|
import com.huaxu.service.AppReportMonitorService;
|
|
|
+import com.huaxu.service.MonitorDataReportService;
|
|
|
+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.time.LocalDate;
|
|
|
+import java.time.format.DateTimeFormatter;
|
|
|
+import java.time.temporal.TemporalAdjusters;
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.Arrays;
|
|
|
+import java.util.Comparator;
|
|
|
import java.util.List;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
@@ -28,6 +41,12 @@ public class AppReportMonitorServiceImpl implements AppReportMonitorService {
|
|
|
@Autowired
|
|
|
private UserCenterClient userCenterClient;
|
|
|
|
|
|
+ @Resource
|
|
|
+ private HomePageReportMapper homePageReportMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private MonitorDataReportService monitorDataReportService;
|
|
|
+
|
|
|
|
|
|
@Override
|
|
|
public List<SceneEntity> getSceneByCompany(String sceneTypeName,Integer companyOrgId) {
|
|
@@ -38,7 +57,7 @@ public class AppReportMonitorServiceImpl implements AppReportMonitorService {
|
|
|
@Override
|
|
|
public CompanySceneInfoDto getSceneByCompanyBySearch(String sceneTypeName, String condition) {
|
|
|
//先查询公司
|
|
|
- List<OrgBaseTreeInfoDto> orgBaseTreeInfoDtos = userCenterClient.getCompanyByUser(condition,null);
|
|
|
+ List<OrgBaseTreeInfoDto> orgBaseTreeInfoDtos = userCenterClient.getCompanyByUser(condition,new ArrayList<>());
|
|
|
//有公司的展示第一个公司信息
|
|
|
if(orgBaseTreeInfoDtos.size() > 0){
|
|
|
List<SceneEntity> sceneEntities = appReportMonitorMapper.getSceneByCompany(sceneTypeName,orgBaseTreeInfoDtos.get(0).getId());
|
|
@@ -48,7 +67,7 @@ public class AppReportMonitorServiceImpl implements AppReportMonitorService {
|
|
|
List<Integer> companyIds = appReportMonitorMapper.getCompanyBySceneCondition(sceneTypeName,condition);
|
|
|
if(companyIds.size() > 0){
|
|
|
//根据场景的公司id查询公司
|
|
|
- orgBaseTreeInfoDtos = userCenterClient.getCompanyByUser(null,companyIds);
|
|
|
+ orgBaseTreeInfoDtos = userCenterClient.getCompanyByUser("",companyIds);
|
|
|
//有公司的展示第一个公司信息
|
|
|
if(orgBaseTreeInfoDtos.size() > 0){
|
|
|
List<SceneEntity> sceneEntities = appReportMonitorMapper.getSceneByCompany(sceneTypeName,orgBaseTreeInfoDtos.get(0).getId());
|
|
@@ -58,4 +77,108 @@ public class AppReportMonitorServiceImpl implements AppReportMonitorService {
|
|
|
|
|
|
return new CompanySceneInfoDto();
|
|
|
}
|
|
|
+
|
|
|
+ //水源取水、电耗对比曲线
|
|
|
+ @Override
|
|
|
+ public List<WaterSupplyChart> waterEnergyConsumption(Integer sceneId ) {
|
|
|
+
|
|
|
+ LoginUser loginUser = UserUtil.getCurrentUser();
|
|
|
+ String tenantId = loginUser.getTenantId();
|
|
|
+
|
|
|
+ List<WaterSupplyData> waterSupplyDatas = homePageReportMapper.getWaterSupplyData(sceneId,"水源",tenantId,loginUser.getType(),loginUser.getPermissonType(),loginUser.getProgramItemList());
|
|
|
+
|
|
|
+ LocalDate localDate = LocalDate.now();
|
|
|
+ //当天数据
|
|
|
+ BigDecimal waterDataCountDay = monitorDataReportService.getAmountCount(null,sceneId, "水源", 4,1 );
|
|
|
+ BigDecimal powerDataCountDay = monitorDataReportService.getAmountCount(null,sceneId, "水源", 5,1 );
|
|
|
+// BigDecimal drugDataCountDay = monitorDataReportService.getAmountCount(null,sceneId, sceneType, 6,1 );
|
|
|
+ WaterSupplyChart waterSupplyChartToday = new WaterSupplyChart();
|
|
|
+ waterSupplyChartToday.setSort(localDate.getDayOfMonth());
|
|
|
+ waterSupplyChartToday.setDate(DateTimeFormatter.ofPattern("yyyy-MM-dd").format(localDate));
|
|
|
+ waterSupplyChartToday.setWaterData(waterDataCountDay);
|
|
|
+ waterSupplyChartToday.setPowerData(powerDataCountDay);
|
|
|
+// waterSupplyChartToday.setDrugData(drugDataCountDay);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ List<WaterSupplyChart> waterSupplyCharts = new ArrayList<>();
|
|
|
+ waterSupplyDatas.stream()
|
|
|
+ .collect(Collectors.groupingBy(item -> item.getYear() + "-" + item.getMonth() + "-" + item.getDay()))
|
|
|
+ .forEach((key, value) -> {
|
|
|
+ WaterSupplyChart waterSupplyChart = new WaterSupplyChart();
|
|
|
+ waterSupplyChart.setDate(key);
|
|
|
+ value.stream().forEach(waterSupplyData -> {
|
|
|
+ waterSupplyChart.setSort(waterSupplyData.getDay());
|
|
|
+
|
|
|
+ if (waterSupplyData.getParmType() == 3) { //供水
|
|
|
+ waterSupplyChart.setWaterData(waterSupplyData.getAmount());
|
|
|
+ } else if (waterSupplyData.getParmType() == 5) {//电耗
|
|
|
+ waterSupplyChart.setPowerData(waterSupplyData.getAmount());
|
|
|
+ }
|
|
|
+// else if (waterSupplyData.getParmType() == 6) {//药耗
|
|
|
+// waterSupplyChart.setDrugData(waterSupplyData.getAmount());
|
|
|
+// }
|
|
|
+ });
|
|
|
+ waterSupplyCharts.add(waterSupplyChart);
|
|
|
+ });
|
|
|
+
|
|
|
+ waterSupplyCharts.sort(Comparator.comparing(WaterSupplyChart::getSort));
|
|
|
+
|
|
|
+ Integer maxDay = LocalDate.now().with(TemporalAdjusters.lastDayOfMonth()).getDayOfMonth();
|
|
|
+ for(int i=0;i<maxDay;i++){
|
|
|
+ if(i+1 == localDate.getDayOfMonth()){
|
|
|
+ waterSupplyCharts.add(i,waterSupplyChartToday);
|
|
|
+ }else if(i == waterSupplyCharts.size() || !waterSupplyCharts.get(i).getSort().equals(i+1)){
|
|
|
+ waterSupplyCharts.add(i,new WaterSupplyChart(i+1, localDate.getYear()+"-"+localDate.getMonthValue()+"-"+(i+1)));
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+// waterSupplyCharts.sort(Comparator.comparing(WaterSupplyChart::getSort).reversed());
|
|
|
+ return waterSupplyCharts;
|
|
|
+ }
|
|
|
+
|
|
|
+ public List<WaterSupplyChart> getWaterLevelForWaterSource(Integer sceneId ){
|
|
|
+ LoginUser loginUser = UserUtil.getCurrentUser();
|
|
|
+ String tenantId = loginUser.getTenantId();
|
|
|
+
|
|
|
+ List<WaterSupplyData> waterSupplyDatas = homePageReportMapper.getWaterSupplyData(sceneId,"水源",tenantId,loginUser.getType(),loginUser.getPermissonType(),loginUser.getProgramItemList());
|
|
|
+
|
|
|
+ LocalDate localDate = LocalDate.now();
|
|
|
+ //当天数据
|
|
|
+ BigDecimal waterDataCountDay = monitorDataReportService.getAmountCount(null,sceneId, "水源", 12,1 );
|
|
|
+// BigDecimal drugDataCountDay = monitorDataReportService.getAmountCount(null,sceneId, sceneType, 6,1 );
|
|
|
+ WaterSupplyChart waterSupplyChartToday = new WaterSupplyChart();
|
|
|
+ waterSupplyChartToday.setSort(localDate.getDayOfMonth());
|
|
|
+ waterSupplyChartToday.setDate(DateTimeFormatter.ofPattern("yyyy-MM-dd").format(localDate));
|
|
|
+ waterSupplyChartToday.setWaterData(waterDataCountDay);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ List<WaterSupplyChart> waterSupplyCharts = new ArrayList<>();
|
|
|
+ waterSupplyDatas.stream()
|
|
|
+ .collect(Collectors.groupingBy(item -> item.getYear() + "-" + item.getMonth() + "-" + item.getDay()))
|
|
|
+ .forEach((key, value) -> {
|
|
|
+ WaterSupplyChart waterSupplyChart = new WaterSupplyChart();
|
|
|
+ waterSupplyChart.setDate(key);
|
|
|
+ value.stream().forEach(waterSupplyData -> {
|
|
|
+ waterSupplyChart.setSort(waterSupplyData.getDay());
|
|
|
+ if (waterSupplyData.getParmType() == 3) { //供水
|
|
|
+ waterSupplyChart.setWaterData(waterSupplyData.getAmount());
|
|
|
+ }
|
|
|
+ });
|
|
|
+ waterSupplyCharts.add(waterSupplyChart);
|
|
|
+ });
|
|
|
+
|
|
|
+ waterSupplyCharts.sort(Comparator.comparing(WaterSupplyChart::getSort));
|
|
|
+
|
|
|
+ Integer maxDay = LocalDate.now().with(TemporalAdjusters.lastDayOfMonth()).getDayOfMonth();
|
|
|
+ for(int i=0;i<maxDay;i++){
|
|
|
+ if(i+1 == localDate.getDayOfMonth()){
|
|
|
+ waterSupplyCharts.add(i,waterSupplyChartToday);
|
|
|
+ }else if(i == waterSupplyCharts.size() || !waterSupplyCharts.get(i).getSort().equals(i+1)){
|
|
|
+ waterSupplyCharts.add(i,new WaterSupplyChart(i+1, localDate.getYear()+"-"+localDate.getMonthValue()+"-"+(i+1)));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return waterSupplyCharts;
|
|
|
+ }
|
|
|
}
|