|
@@ -39,6 +39,7 @@ import java.lang.reflect.Field;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.math.RoundingMode;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
+import java.time.LocalDate;
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
@@ -410,10 +411,26 @@ public class CustomDisplayServiceImpl implements CustomDisplayService {
|
|
|
}
|
|
|
IndexValCensusVo vo = new IndexValCensusVo();
|
|
|
BigDecimal sewageWaterLastM = new BigDecimal(String.valueOf(customDisplayMapper.getIndexValLastM(stationIds).get("sewageWater")));
|
|
|
- BigDecimal sewageWaterThisM = new BigDecimal(String.valueOf(customDisplayMapper.getIndexValThisM(stationIds).get("sewageWater")));
|
|
|
+ BigDecimal sewageWaterThisM = BigDecimal.valueOf(customDisplayMapper.getFillStcDayTotal(null, DateUtil.format(new Date(), "yyyy-MM"), null, stationIds));
|
|
|
+ BigDecimal sewageWaterToday = BigDecimal.valueOf(customDisplayMapper.getFillStcDayTotal(DateUtil.format(new Date(), "yyyy-MM-dd"), null, null, stationIds));
|
|
|
+ vo.setSewageWaterToday(sewageWaterToday);
|
|
|
+
|
|
|
+
|
|
|
+ LocalDate current = LocalDate.now();
|
|
|
+ int year = current.getYear();
|
|
|
+ int quarter = (current.getMonthValue() - 1) / 3 + 1;
|
|
|
+ BigDecimal sewageWaterQuarter = BigDecimal.valueOf(customDisplayMapper.getFillStcDayTotal(null, null, year + "-" + quarter, stationIds));
|
|
|
+ vo.setSewageWaterQuarter(sewageWaterQuarter);
|
|
|
+
|
|
|
SimpleDateFormat sdfYear = new SimpleDateFormat("yyyy");
|
|
|
SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM");
|
|
|
+ SimpleDateFormat sdfDay = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
Calendar c = Calendar.getInstance();
|
|
|
+ c.add(Calendar.DATE, -1);
|
|
|
+ String yesterday = sdfDay.format(c.getTime());
|
|
|
+ BigDecimal sewageWaterYesterday = BigDecimal.valueOf(customDisplayMapper.getFillStcDayTotal(yesterday, null, null, stationIds));
|
|
|
+ vo.setSewageWaterYesterday(sewageWaterYesterday);
|
|
|
+ c.add(Calendar.DATE, +1);
|
|
|
String thisYear = sdfYear.format(c.getTime());
|
|
|
String thisYearMonth = sdfMonth.format(c.getTime());
|
|
|
BigDecimal sewageWaterThisY = new BigDecimal(String.valueOf(customDisplayMapper.getIndexValTotal(thisYear, null, stationIds).get("sewageWater")));
|
|
@@ -511,6 +528,8 @@ public class CustomDisplayServiceImpl implements CustomDisplayService {
|
|
|
info.setSewageWater(0.0);
|
|
|
info.setEnergyWater(0.0);
|
|
|
info.setEnergyWaterThousand(0.0);
|
|
|
+ info.setEnergySludge(0.0);
|
|
|
+ info.setEnergySludgeThousand(0.0);
|
|
|
List<TfDayStatistics> dayStatisticsEcFinal = dayStatisticsEc.stream()
|
|
|
.filter(e -> DateUtil.parse(e.getScadaTime(),"yyyy-MM-dd").compareTo(DateUtil.parse(info.getScadaTime(),"yyyy-MM-dd")) == 0
|
|
|
&& e.getStationId().equals(info.getStationId()))
|
|
@@ -539,89 +558,97 @@ public class CustomDisplayServiceImpl implements CustomDisplayService {
|
|
|
info.setEnergyWater(energy.divide(cumulativeFlow,4, RoundingMode.HALF_UP).doubleValue());
|
|
|
info.setEnergyWaterThousand(energy.divide(cumulativeFlow,7, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(1000)).doubleValue());
|
|
|
}
|
|
|
+ if (info.getSludgeHandle() != null && info.getEnergy() != null && info.getSludgeHandle() != 0) {
|
|
|
+ BigDecimal energy = BigDecimal.valueOf(info.getEnergy());
|
|
|
+ BigDecimal sludgeHandle = BigDecimal.valueOf(info.getSludgeHandle());
|
|
|
+ info.setEnergySludge(energy.divide(sludgeHandle,4, RoundingMode.HALF_UP).doubleValue());
|
|
|
+ info.setEnergySludgeThousand(energy.divide(sludgeHandle,7, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(1000)).doubleValue());
|
|
|
+ }
|
|
|
});
|
|
|
break;
|
|
|
case "2":
|
|
|
list = customDisplayMapper.getIndexValMonth(wis);
|
|
|
List<TfDayStatistics> monthStatistics = customDisplayMapper.getFillIndexValMonth(wis);
|
|
|
+ list = getFillData(list, monthStatistics);
|
|
|
list.forEach(info -> {
|
|
|
- info.setEnergy(0.0);
|
|
|
- info.setSludgeHandle(0.0);
|
|
|
- info.setSludgeWaterRate(0f);
|
|
|
- info.setSewageWater(0.0);
|
|
|
- info.setEnergyWater(0.0);
|
|
|
- info.setEnergyWaterThousand(0.0);
|
|
|
- List<TfDayStatistics> dayStatisticsFinal = monthStatistics.stream()
|
|
|
- .filter(e ->DateUtil.parse(e.getScadaTime(),"yyyy-MM").compareTo(DateUtil.parse(info.getScadaTime(),"yyyy-MM")) == 0
|
|
|
- && e.getStationId().equals(info.getStationId()))
|
|
|
- .collect(Collectors.toList());
|
|
|
- if (CollUtil.isNotEmpty(dayStatisticsFinal)) {
|
|
|
- info.setSewageWater(dayStatisticsFinal.get(0).getSewageWater());
|
|
|
- info.setSludgeHandle(dayStatisticsFinal.get(0).getSludgeHandle());
|
|
|
- info.setEnergy(dayStatisticsFinal.get(0).getEnergy());
|
|
|
- info.setSludgeWaterRate(dayStatisticsFinal.get(0).getSludgeWaterRate());
|
|
|
+ if (StringUtils.isBlank(wis.getStartDate()) || StringUtils.isBlank(wis.getEndDate())) {
|
|
|
+ return;
|
|
|
}
|
|
|
- if (info.getSewageWater() != null && info.getEnergy() != null && info.getSewageWater() != 0) {
|
|
|
- BigDecimal energy = BigDecimal.valueOf(info.getEnergy());
|
|
|
- BigDecimal cumulativeFlow = BigDecimal.valueOf(info.getSewageWater());
|
|
|
- info.setEnergyWater(energy.divide(cumulativeFlow.multiply(BigDecimal.valueOf(10000)),4, RoundingMode.HALF_UP).doubleValue());
|
|
|
- info.setEnergyWaterThousand(energy.divide(cumulativeFlow.multiply(BigDecimal.valueOf(10000)),7, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(1000)).doubleValue());
|
|
|
+
|
|
|
+ Date startDateMoM = DateUtil.parse(wis.getStartDate(), "yyyy-MM");
|
|
|
+ Date endDateMoM = DateUtil.parse(wis.getEndDate(), "yyyy-MM");
|
|
|
+ Calendar calendarMoM = Calendar.getInstance();
|
|
|
+ calendarMoM.setTime(startDateMoM);
|
|
|
+ calendarMoM.add(Calendar.MONTH, -1);
|
|
|
+ wis.setStartDate(DateUtil.format(calendarMoM.getTime(), "yyyy-MM"));
|
|
|
+ calendarMoM.setTime(endDateMoM);
|
|
|
+ calendarMoM.add(Calendar.MONTH, -1);
|
|
|
+ wis.setEndDate(DateUtil.format(calendarMoM.getTime(), "yyyy-MM"));
|
|
|
+ List<TfDayStatistics> monthStatisticsMoM = customDisplayMapper.getIndexValMonth(wis);
|
|
|
+ List<TfDayStatistics> monthStatisticsFillMoM = customDisplayMapper.getFillIndexValMonth(wis);
|
|
|
+ List<TfDayStatistics> monthStatisticsMoMFinal = getFillData(monthStatisticsMoM, monthStatisticsFillMoM);
|
|
|
+ if (CollUtil.isNotEmpty(monthStatisticsMoMFinal)) {
|
|
|
+ TfDayStatistics statistics = monthStatisticsMoMFinal.get(0);
|
|
|
+ info.setSewageWaterMoM(getYoyOrMomRate(BigDecimal.valueOf(info.getSewageWater()), BigDecimal.valueOf(statistics.getSewageWater())));
|
|
|
+ info.setSludgeHandleMoM(getYoyOrMomRate(BigDecimal.valueOf(info.getSludgeHandle()), BigDecimal.valueOf(statistics.getSludgeHandle())));
|
|
|
+ info.setEnergyMoM(getYoyOrMomRate(BigDecimal.valueOf(info.getEnergy()), BigDecimal.valueOf(statistics.getEnergy())));
|
|
|
+ info.setEnergyWaterMoM(getYoyOrMomRate(BigDecimal.valueOf(info.getEnergyWater()), BigDecimal.valueOf(statistics.getEnergyWater())));
|
|
|
+ info.setEnergySludgeMoM(getYoyOrMomRate(BigDecimal.valueOf(info.getEnergySludge()), BigDecimal.valueOf(statistics.getEnergySludge())));
|
|
|
+ }
|
|
|
+
|
|
|
+ Date startDateYoY = DateUtil.parse(wis.getStartDate(), "yyyy-MM");
|
|
|
+ Date endDateYoY = DateUtil.parse(wis.getEndDate(), "yyyy-MM");
|
|
|
+ Calendar calendarYoY = Calendar.getInstance();
|
|
|
+ calendarYoY.setTime(startDateYoY);
|
|
|
+ calendarYoY.add(Calendar.YEAR, -1);
|
|
|
+ wis.setStartDate(DateUtil.format(calendarYoY.getTime(), "yyyy-MM"));
|
|
|
+ calendarYoY.setTime(endDateYoY);
|
|
|
+ calendarYoY.add(Calendar.YEAR, -1);
|
|
|
+ wis.setEndDate(DateUtil.format(calendarYoY.getTime(), "yyyy-MM"));
|
|
|
+ List<TfDayStatistics> monthStatisticsYoY = customDisplayMapper.getIndexValMonth(wis);
|
|
|
+ List<TfDayStatistics> monthStatisticsFillYoY = customDisplayMapper.getFillIndexValMonth(wis);
|
|
|
+ List<TfDayStatistics> monthStatisticsYoYFinal = getFillData(monthStatisticsYoY, monthStatisticsFillYoY);
|
|
|
+ if (CollUtil.isNotEmpty(monthStatisticsYoYFinal)) {
|
|
|
+ TfDayStatistics statistics = monthStatisticsYoYFinal.get(0);
|
|
|
+ info.setSewageWaterYoY(getYoyOrMomRate(BigDecimal.valueOf(info.getSewageWater()), BigDecimal.valueOf(statistics.getSewageWater())));
|
|
|
+ info.setSludgeHandleYoY(getYoyOrMomRate(BigDecimal.valueOf(info.getSludgeHandle()), BigDecimal.valueOf(statistics.getSludgeHandle())));
|
|
|
+ info.setEnergyYoY(getYoyOrMomRate(BigDecimal.valueOf(info.getEnergy()), BigDecimal.valueOf(statistics.getEnergy())));
|
|
|
+ info.setEnergyWaterYoY(getYoyOrMomRate(BigDecimal.valueOf(info.getEnergyWater()), BigDecimal.valueOf(statistics.getEnergyWater())));
|
|
|
+ info.setEnergySludgeYoY(getYoyOrMomRate(BigDecimal.valueOf(info.getEnergySludge()), BigDecimal.valueOf(statistics.getEnergySludge())));
|
|
|
}
|
|
|
});
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
case "4":
|
|
|
list = customDisplayMapper.getIndexValYear(wis);
|
|
|
List<TfDayStatistics> yearStatistics = customDisplayMapper.getFillIndexValYear(wis);
|
|
|
+ list = getFillData(list, yearStatistics);
|
|
|
list.forEach(info -> {
|
|
|
- info.setEnergy(0.0);
|
|
|
- info.setSludgeHandle(0.0);
|
|
|
- info.setSludgeWaterRate(0f);
|
|
|
- info.setSewageWater(0.0);
|
|
|
- info.setEnergyWater(0.0);
|
|
|
- info.setEnergyWaterThousand(0.0);
|
|
|
- List<TfDayStatistics> dayStatisticsFinal = yearStatistics.stream()
|
|
|
- .filter(e -> DateUtil.parse(e.getScadaTime(),"yyyy").compareTo(DateUtil.parse(info.getScadaTime(),"yyyy")) == 0
|
|
|
- && e.getStationId().equals(info.getStationId()))
|
|
|
- .collect(Collectors.toList());
|
|
|
- if (CollUtil.isNotEmpty(dayStatisticsFinal)) {
|
|
|
- info.setSewageWater(dayStatisticsFinal.get(0).getSewageWater());
|
|
|
- info.setSludgeHandle(dayStatisticsFinal.get(0).getSludgeHandle());
|
|
|
- info.setEnergy(dayStatisticsFinal.get(0).getEnergy());
|
|
|
- info.setSludgeWaterRate(dayStatisticsFinal.get(0).getSludgeWaterRate());
|
|
|
+ if (StringUtils.isBlank(wis.getStartDate()) || StringUtils.isBlank(wis.getEndDate())) {
|
|
|
+ return;
|
|
|
}
|
|
|
- if (info.getSewageWater() != null && info.getEnergy() != null && info.getSewageWater() != 0) {
|
|
|
- BigDecimal energy = BigDecimal.valueOf(info.getEnergy());
|
|
|
- BigDecimal cumulativeFlow = BigDecimal.valueOf(info.getSewageWater());
|
|
|
- info.setEnergyWater(energy.divide(cumulativeFlow.multiply(BigDecimal.valueOf(10000)),4, RoundingMode.HALF_UP).doubleValue());
|
|
|
- info.setEnergyWaterThousand(energy.divide(cumulativeFlow.multiply(BigDecimal.valueOf(10000)),7, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(1000)).doubleValue());
|
|
|
+
|
|
|
+ Date startDateYoY = DateUtil.parse(wis.getStartDate(), "yyyy");
|
|
|
+ Date endDateYoY = DateUtil.parse(wis.getEndDate(), "yyyy");
|
|
|
+ Calendar calendarYoY = Calendar.getInstance();
|
|
|
+ calendarYoY.setTime(startDateYoY);
|
|
|
+ calendarYoY.add(Calendar.YEAR, -1);
|
|
|
+ wis.setStartDate(DateUtil.format(calendarYoY.getTime(), "yyyy"));
|
|
|
+ calendarYoY.setTime(endDateYoY);
|
|
|
+ calendarYoY.add(Calendar.YEAR, -1);
|
|
|
+ wis.setEndDate(DateUtil.format(calendarYoY.getTime(), "yyyy"));
|
|
|
+ List<TfDayStatistics> monthStatisticsYoY = customDisplayMapper.getIndexValMonth(wis);
|
|
|
+ List<TfDayStatistics> monthStatisticsFillYoY = customDisplayMapper.getFillIndexValMonth(wis);
|
|
|
+ List<TfDayStatistics> monthStatisticsYoYFinal = getFillData(monthStatisticsYoY, monthStatisticsFillYoY);
|
|
|
+ if (CollUtil.isNotEmpty(monthStatisticsYoYFinal)) {
|
|
|
+ TfDayStatistics statistics = monthStatisticsYoYFinal.get(0);
|
|
|
+ info.setSewageWaterYoY(getYoyOrMomRate(BigDecimal.valueOf(info.getSewageWater()), BigDecimal.valueOf(statistics.getSewageWater())));
|
|
|
+ info.setSludgeHandleYoY(getYoyOrMomRate(BigDecimal.valueOf(info.getSludgeHandle()), BigDecimal.valueOf(statistics.getSludgeHandle())));
|
|
|
+ info.setEnergyYoY(getYoyOrMomRate(BigDecimal.valueOf(info.getEnergy()), BigDecimal.valueOf(statistics.getEnergy())));
|
|
|
+ info.setEnergyWaterYoY(getYoyOrMomRate(BigDecimal.valueOf(info.getEnergyWater()), BigDecimal.valueOf(statistics.getEnergyWater())));
|
|
|
+ info.setEnergySludgeYoY(getYoyOrMomRate(BigDecimal.valueOf(info.getEnergySludge()), BigDecimal.valueOf(statistics.getEnergySludge())));
|
|
|
}
|
|
|
});
|
|
|
break;
|
|
@@ -1557,4 +1584,50 @@ public class CustomDisplayServiceImpl implements CustomDisplayService {
|
|
|
return stationIds;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ *
|
|
|
+ * @param list 数据统计列表
|
|
|
+ * @param monthStatistics 填报数据列表
|
|
|
+ * @return
|
|
|
+ * @description 获取数据统计的填报相关数据
|
|
|
+ */
|
|
|
+ public List<TfDayStatistics> getFillData(List<TfDayStatistics> list, List<TfDayStatistics> monthStatistics) {
|
|
|
+ if (CollUtil.isEmpty(list) || CollUtil.isEmpty(monthStatistics)) {
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+ list.forEach(info -> {
|
|
|
+ info.setEnergy(0.0);
|
|
|
+ info.setSludgeHandle(0.0);
|
|
|
+ info.setSludgeWaterRate(0f);
|
|
|
+ info.setSewageWater(0.0);
|
|
|
+ info.setEnergyWater(0.0);
|
|
|
+ info.setEnergyWaterThousand(0.0);
|
|
|
+ info.setEnergySludge(0.0);
|
|
|
+ info.setEnergySludgeThousand(0.0);
|
|
|
+ List<TfDayStatistics> dayStatisticsFinal = monthStatistics.stream()
|
|
|
+ .filter(e ->DateUtil.parse(e.getScadaTime(),"yyyy-MM").compareTo(DateUtil.parse(info.getScadaTime(),"yyyy-MM")) == 0
|
|
|
+ && e.getStationId().equals(info.getStationId()))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ if (CollUtil.isNotEmpty(dayStatisticsFinal)) {
|
|
|
+ info.setSewageWater(dayStatisticsFinal.get(0).getSewageWater());
|
|
|
+ info.setSludgeHandle(dayStatisticsFinal.get(0).getSludgeHandle());
|
|
|
+ info.setEnergy(dayStatisticsFinal.get(0).getEnergy());
|
|
|
+ info.setSludgeWaterRate(dayStatisticsFinal.get(0).getSludgeWaterRate());
|
|
|
+ }
|
|
|
+ if (info.getSewageWater() != null && info.getEnergy() != null && info.getSewageWater() != 0) {
|
|
|
+ BigDecimal energy = BigDecimal.valueOf(info.getEnergy());
|
|
|
+ BigDecimal cumulativeFlow = BigDecimal.valueOf(info.getSewageWater());
|
|
|
+ info.setEnergyWater(energy.divide(cumulativeFlow.multiply(BigDecimal.valueOf(10000)),4, RoundingMode.HALF_UP).doubleValue());
|
|
|
+ info.setEnergyWaterThousand(energy.divide(cumulativeFlow.multiply(BigDecimal.valueOf(10000)),7, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(1000)).doubleValue());
|
|
|
+ }
|
|
|
+ if (info.getSludgeHandle() != null && info.getEnergy() != null && info.getSludgeHandle() != 0) {
|
|
|
+ BigDecimal energy = BigDecimal.valueOf(info.getEnergy());
|
|
|
+ BigDecimal sludgeHandle = BigDecimal.valueOf(info.getSludgeHandle());
|
|
|
+ info.setEnergySludge(energy.divide(sludgeHandle,4, RoundingMode.HALF_UP).doubleValue());
|
|
|
+ info.setEnergySludgeThousand(energy.divide(sludgeHandle,7, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(1000)).doubleValue());
|
|
|
+ }
|
|
|
+ });
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+
|
|
|
}
|