|
@@ -4,7 +4,6 @@ import cn.hutool.core.collection.CollectionUtil;
|
|
|
import cn.hutool.core.date.DateTime;
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
-import com.tofly.common.core.util.StringUtil;
|
|
|
import com.tofly.xrtygis.config.CallCenterFeign;
|
|
|
import com.tofly.xrtygis.custom.entity.dto.*;
|
|
|
import com.tofly.xrtygis.custom.entity.vo.ProductionAndSalesVo;
|
|
@@ -13,6 +12,8 @@ import com.tofly.xrtygis.custom.service.CostOfWaterReportService;
|
|
|
import com.tofly.xrtygis.em.WaterBills;
|
|
|
import com.tofly.xrtygis.em.WaterSold;
|
|
|
import com.tofly.xrtygis.em.WaterSoldPrice;
|
|
|
+import com.tofly.xrtygis.entity.AdministrativeArea;
|
|
|
+import com.tofly.xrtygis.entity.AdminstrativeType;
|
|
|
import com.tofly.xrtygis.entity.CountPlanValue;
|
|
|
import com.tofly.xrtygis.entity.Satisfaction;
|
|
|
import com.tofly.xrtygis.entity.vo.MarketingStatisticsVo;
|
|
@@ -52,59 +53,68 @@ public class CostOfWaterReportServiceImpl implements CostOfWaterReportService {
|
|
|
|
|
|
* 产销差统计
|
|
|
*
|
|
|
- * @param year 年份 默认当前年份
|
|
|
+ * @param startMonth 月份
|
|
|
+ * @param endMonth 月份
|
|
|
* @return map
|
|
|
*/
|
|
|
@Override
|
|
|
- public Map<String, ProductionAndSalesVo> productionAndSalesCount(String year) {
|
|
|
+ public Map<String, ProductionAndSalesVo> productionAndSalesCount(String startMonth, String endMonth) {
|
|
|
Map<String, ProductionAndSalesVo> returnMap = new HashMap<>(3);
|
|
|
- Date now = new Date();
|
|
|
- if (StringUtil.isEmpty(year)) {
|
|
|
- year = String.valueOf(DateUtil.year(now));
|
|
|
- }
|
|
|
- String nowMonth = year + "-" + DateUtil.format(now, "MM");
|
|
|
- List<ProductionAndSalesDto> budgetProductionAndSalesData = costOfWaterReportMapper.getBudgetProductionAndSalesData(year);
|
|
|
+
|
|
|
+ List<ProductionAndSalesDto> budgetProductionAndSalesData = costOfWaterReportMapper.getBudgetProductionAndSalesData(startMonth.substring(0, 4));
|
|
|
BigDecimal budgetWaterSupplySum = null;
|
|
|
BigDecimal budgetSellWaterSum = null;
|
|
|
- ProductionAndSalesDto budget = null;
|
|
|
+ List<ProductionAndSalesDto> budget = new ArrayList<>();
|
|
|
if (CollectionUtil.isNotEmpty(budgetProductionAndSalesData)) {
|
|
|
|
|
|
budgetWaterSupplySum = BigDecimal.valueOf(budgetProductionAndSalesData.stream().mapToDouble(ProductionAndSalesDto::getWaterSupply).sum());
|
|
|
budgetSellWaterSum = BigDecimal.valueOf(budgetProductionAndSalesData.stream().mapToDouble(ProductionAndSalesDto::getSellWater).sum());
|
|
|
- budget = budgetProductionAndSalesData.stream().filter(i -> i.getMonth().equals(nowMonth)).collect(Collectors.toList()).get(0);
|
|
|
+ budget = budgetProductionAndSalesData.stream().filter(i -> i.getMonth().compareTo(startMonth) >= 0 && i.getMonth().compareTo(endMonth) <= 0).collect(Collectors.toList());
|
|
|
}
|
|
|
|
|
|
- List<ProductionAndSalesDto> actualProductionAndSalesData = costOfWaterReportMapper.getActualProductionAndSalesData(year);
|
|
|
+ List<ProductionAndSalesDto> actualProductionAndSalesData = costOfWaterReportMapper.getActualProductionAndSalesData(startMonth.substring(0, 4));
|
|
|
|
|
|
BigDecimal actualWaterSupplySum = null;
|
|
|
BigDecimal actualSellWaterSum = null;
|
|
|
- ProductionAndSalesDto actual = null;
|
|
|
+ List<ProductionAndSalesDto> actual = new ArrayList<>();
|
|
|
if (CollectionUtil.isNotEmpty(actualProductionAndSalesData)) {
|
|
|
actualWaterSupplySum = BigDecimal.valueOf(budgetProductionAndSalesData.stream().mapToDouble(ProductionAndSalesDto::getWaterSupply).sum());
|
|
|
actualSellWaterSum = BigDecimal.valueOf(budgetProductionAndSalesData.stream().mapToDouble(ProductionAndSalesDto::getSellWater).sum());
|
|
|
- actual = budgetProductionAndSalesData.stream().filter(i -> i.getMonth().equals(nowMonth)).collect(Collectors.toList()).get(0);
|
|
|
+ actual = budgetProductionAndSalesData.stream().filter(i -> i.getMonth().compareTo(startMonth) >= 0 && i.getMonth().compareTo(endMonth) <= 0).collect(Collectors.toList());
|
|
|
}
|
|
|
- returnMap.put("waterSupply", ProductionAndSalesVo.builder()
|
|
|
- .budgetSum(budgetWaterSupplySum).budgetMonth(Objects.nonNull(budget) ? BigDecimal.valueOf(budget.getWaterSupply()) : null)
|
|
|
- .actualSum(actualWaterSupplySum).actualMonth(Objects.nonNull(actual) ? BigDecimal.valueOf(actual.getWaterSupply()) : null)
|
|
|
+
|
|
|
+ BigDecimal supplyBudgetMonth = CollectionUtil.isNotEmpty(budget) ? BigDecimal.valueOf(budget.stream().mapToDouble(ProductionAndSalesDto::getWaterSupply).sum()) : null;
|
|
|
+ BigDecimal supplyActualMonth = CollectionUtil.isNotEmpty(actual) ? BigDecimal.valueOf(actual.stream().mapToDouble(ProductionAndSalesDto::getWaterSupply).sum()) : null;
|
|
|
+
|
|
|
+ ProductionAndSalesVo waterSupply = ProductionAndSalesVo.builder()
|
|
|
+ .budgetSum(budgetWaterSupplySum).budgetMonth(supplyBudgetMonth)
|
|
|
+ .actualSum(actualWaterSupplySum)
|
|
|
+ .actualMonth(supplyActualMonth)
|
|
|
.differ(Objects.nonNull(budgetWaterSupplySum) && Objects.nonNull(actualWaterSupplySum) ?
|
|
|
actualWaterSupplySum.subtract(budgetWaterSupplySum).divide(budgetWaterSupplySum, 4, BigDecimal.ROUND_HALF_UP).multiply(HUNDRED) : null)
|
|
|
- .build());
|
|
|
-
|
|
|
- returnMap.put("sellWater", ProductionAndSalesVo.builder()
|
|
|
- .budgetSum(budgetSellWaterSum).budgetMonth(Objects.nonNull(budget) ? BigDecimal.valueOf(budget.getSellWater()) : null)
|
|
|
- .actualSum(actualSellWaterSum).actualMonth(Objects.nonNull(actual) ? BigDecimal.valueOf(actual.getSellWater()) : null)
|
|
|
+ .build();
|
|
|
+ returnMap.put("waterSupply", waterSupply);
|
|
|
+
|
|
|
+ BigDecimal sellBudgetMonth = CollectionUtil.isNotEmpty(budget) ? BigDecimal.valueOf(budget.stream().mapToDouble(ProductionAndSalesDto::getSellWater).sum()) : null;
|
|
|
+ BigDecimal sellActualMonth = CollectionUtil.isNotEmpty(actual) ? BigDecimal.valueOf(actual.stream().mapToDouble(ProductionAndSalesDto::getSellWater).sum()) : null;
|
|
|
+ ProductionAndSalesVo sellWater = ProductionAndSalesVo.builder()
|
|
|
+ .budgetSum(budgetSellWaterSum).budgetMonth(sellBudgetMonth)
|
|
|
+ .actualSum(actualSellWaterSum).actualMonth(sellActualMonth)
|
|
|
.differ(Objects.nonNull(budgetSellWaterSum) && Objects.nonNull(actualSellWaterSum) ?
|
|
|
actualSellWaterSum.subtract(budgetSellWaterSum).divide(budgetSellWaterSum, 4, BigDecimal.ROUND_HALF_UP).multiply(HUNDRED) : null)
|
|
|
- .build());
|
|
|
+ .build();
|
|
|
+
|
|
|
+ returnMap.put("sellWater", sellWater);
|
|
|
|
|
|
BigDecimal budgetSum = Objects.nonNull(budgetWaterSupplySum) ? budgetWaterSupplySum.subtract(budgetSellWaterSum).divide(budgetWaterSupplySum, 4, BigDecimal.ROUND_HALF_UP).multiply(HUNDRED) : null;
|
|
|
BigDecimal actualSum = Objects.nonNull(actualWaterSupplySum) ? actualWaterSupplySum.subtract(actualSellWaterSum).divide(actualWaterSupplySum, 4, BigDecimal.ROUND_HALF_UP).multiply(HUNDRED) : null;
|
|
|
+ BigDecimal budgetMonth = Objects.nonNull(supplyBudgetMonth) && Objects.nonNull(sellBudgetMonth) ? supplyBudgetMonth.subtract(sellBudgetMonth).divide(supplyBudgetMonth, 4, BigDecimal.ROUND_HALF_UP).multiply(HUNDRED) : null;
|
|
|
+ BigDecimal actualMonth = Objects.nonNull(supplyActualMonth) && Objects.nonNull(sellActualMonth) ? supplyActualMonth.subtract(sellActualMonth).divide(supplyActualMonth, 4, BigDecimal.ROUND_HALF_UP).multiply(HUNDRED) : null;
|
|
|
returnMap.put("productionAndSales", ProductionAndSalesVo.builder()
|
|
|
.budgetSum(budgetSum)
|
|
|
- .budgetMonth(Objects.nonNull(budget) ? BigDecimal.valueOf(budget.getProduction()) : null)
|
|
|
+ .budgetMonth(budgetMonth)
|
|
|
.actualSum(actualSum)
|
|
|
- .actualMonth(Objects.nonNull(actual) ? BigDecimal.valueOf(actual.getProduction()) : null)
|
|
|
+ .actualMonth(actualMonth)
|
|
|
.differ(Objects.nonNull(budgetSum) && Objects.nonNull(actualSum) ? actualSum.subtract(budgetSum).divide(budgetSum, 4, BigDecimal.ROUND_HALF_UP).multiply(HUNDRED) : null)
|
|
|
.build());
|
|
|
|
|
@@ -115,15 +125,16 @@ public class CostOfWaterReportServiceImpl implements CostOfWaterReportService {
|
|
|
* 按用水性质分售水量完成情况
|
|
|
*
|
|
|
* @param type 类型 1:用水性质分售水量完成情况 2:(四)售水均价 3 水费回收
|
|
|
- * @param yearMonth 年月
|
|
|
+ * @param startMonth 开始年月
|
|
|
+ * @param endMonth 结束年月
|
|
|
* @return map
|
|
|
*/
|
|
|
@Override
|
|
|
- public Map<String, MarketingStatisticsVo> marketingStatistics(String yearMonth, Integer type) {
|
|
|
+ public Map<String, MarketingStatisticsVo> marketingStatistics(String startMonth,String endMonth, Integer type) {
|
|
|
Map<String, MarketingStatisticsVo> result = new HashMap<>();
|
|
|
|
|
|
- String nowYear = yearMonth.substring(0, 4);
|
|
|
- String lastYear = DateUtil.format(DateUtil.offsetMonth(DateUtil.parse(yearMonth, "yyyy-MM"), -12), "yyyy");
|
|
|
+ String nowYear = startMonth.substring(0, 4);
|
|
|
+ String lastYear = DateUtil.format(DateUtil.offsetMonth(DateUtil.parse(startMonth, "yyyyMM"), -12), "yyyy");
|
|
|
|
|
|
|
|
|
List<CountPlanValue> nowValueList = countPlanValueService.list(Wrappers.<CountPlanValue>lambdaQuery().eq(CountPlanValue::getOneType, type).like(CountPlanValue::getYearMonth, nowYear));
|
|
@@ -133,32 +144,47 @@ public class CostOfWaterReportServiceImpl implements CostOfWaterReportService {
|
|
|
List<CountPlanValue> nowDataList = costOfWaterReportMapper.getWaterCostSoldWaterData(nowYear);
|
|
|
List<CountPlanValue> lastDataList = costOfWaterReportMapper.getWaterCostSoldWaterData(lastYear);
|
|
|
|
|
|
- result.put("waterSold", dateCompute(nowDataList, lastDataList, yearMonth, null, true));
|
|
|
+ result.put("waterSold", dateCompute(nowDataList, lastDataList, startMonth,endMonth, null, true));
|
|
|
for (WaterSold value : WaterSold.values()) {
|
|
|
- result.put(value.getKey(), dateCompute(nowValueList, lastValueList, yearMonth, value.getType(), true));
|
|
|
+ result.put(value.getKey(), dateCompute(nowValueList, lastValueList, startMonth,endMonth, value.getType(), true));
|
|
|
}
|
|
|
} else if (2 == type) {
|
|
|
|
|
|
for (WaterSoldPrice value : WaterSoldPrice.values()) {
|
|
|
- result.put(value.getKey(), dateCompute(nowValueList, lastValueList, yearMonth, value.getType(), false));
|
|
|
+ result.put(value.getKey(), dateCompute(nowValueList, lastValueList, startMonth,endMonth, value.getType(), false));
|
|
|
}
|
|
|
|
|
|
} else if (3 == type) {
|
|
|
|
|
|
for (WaterBills value : WaterBills.values()) {
|
|
|
- result.put(value.getKey(), dateCompute(nowValueList, lastValueList, yearMonth, value.getType(), true));
|
|
|
+ result.put(value.getKey(), dateCompute(nowValueList, lastValueList, startMonth,endMonth, value.getType(), true));
|
|
|
}
|
|
|
MarketingStatisticsVo planCharges = result.get("planCharges");
|
|
|
MarketingStatisticsVo actualCharges = result.get("actualCharges");
|
|
|
|
|
|
+ BigDecimal yearPlanNumber = actualCharges.getYearPlanNumber();
|
|
|
+ BigDecimal yearPlanNumber1 = planCharges.getYearPlanNumber();
|
|
|
+ BigDecimal actualNumber = actualCharges.getActualNumber();
|
|
|
+ BigDecimal actualNumber1 = planCharges.getActualNumber();
|
|
|
+ BigDecimal sumActualNumber = actualCharges.getSumActualNumber();
|
|
|
+ BigDecimal sumActualNumber1 = planCharges.getSumActualNumber();
|
|
|
+ BigDecimal sumPlanNumber = actualCharges.getSumPlanNumber();
|
|
|
+ BigDecimal sumPlanNumber1 = planCharges.getSumPlanNumber();
|
|
|
+ BigDecimal difference = actualCharges.getDifference();
|
|
|
+ BigDecimal difference1 = planCharges.getDifference();
|
|
|
+ BigDecimal lastYearSumActualNumber = actualCharges.getLastYearSumActualNumber();
|
|
|
+ BigDecimal lastYearSumActualNumber1 = planCharges.getLastYearSumActualNumber();
|
|
|
+ BigDecimal lastYearDifference = actualCharges.getLastYearDifference();
|
|
|
+ BigDecimal lastYearDifference1 = planCharges.getLastYearDifference();
|
|
|
+
|
|
|
result.put("recoveryRate", MarketingStatisticsVo.builder()
|
|
|
- .yearPlanNumber(actualCharges.getYearPlanNumber() != null && planCharges.getYearPlanNumber() != null ? actualCharges.getYearPlanNumber().divide(planCharges.getYearPlanNumber(), 4, BigDecimal.ROUND_HALF_UP) : null)
|
|
|
- .actualNumber(actualCharges.getActualNumber() != null && planCharges.getActualNumber() != null ? actualCharges.getActualNumber().divide(planCharges.getActualNumber(), 4, BigDecimal.ROUND_HALF_UP) : null)
|
|
|
- .sumActualNumber(actualCharges.getSumActualNumber() != null && planCharges.getSumActualNumber() != null ? actualCharges.getSumActualNumber().divide(planCharges.getSumActualNumber(), 4, BigDecimal.ROUND_HALF_UP) : null)
|
|
|
- .sumPlanNumber(actualCharges.getSumPlanNumber() != null && planCharges.getSumPlanNumber() != null ? actualCharges.getSumPlanNumber().divide(planCharges.getSumPlanNumber(), 4, BigDecimal.ROUND_HALF_UP) : null)
|
|
|
- .difference(actualCharges.getDifference() != null && planCharges.getDifference() != null ? actualCharges.getDifference().divide(planCharges.getDifference(), 4, BigDecimal.ROUND_HALF_UP) : null)
|
|
|
- .lastYearSumActualNumber(actualCharges.getLastYearSumActualNumber() != null && planCharges.getLastYearSumActualNumber() != null ? actualCharges.getLastYearSumActualNumber().divide(planCharges.getLastYearSumActualNumber(), 4, BigDecimal.ROUND_HALF_UP) : null)
|
|
|
- .lastYearDifference(actualCharges.getLastYearDifference() != null && planCharges.getLastYearDifference() != null ? actualCharges.getLastYearDifference().divide(planCharges.getLastYearDifference(), 4, BigDecimal.ROUND_HALF_UP) : null)
|
|
|
+ .yearPlanNumber(yearPlanNumber != null && yearPlanNumber1 != null && yearPlanNumber1.compareTo(BigDecimal.ZERO) != 0 ? yearPlanNumber.divide(yearPlanNumber1, 4, BigDecimal.ROUND_HALF_UP) : null)
|
|
|
+ .actualNumber(actualNumber != null && actualNumber1 != null && actualNumber1.compareTo(BigDecimal.ZERO) != 0 ? actualNumber.divide(actualNumber1, 4, BigDecimal.ROUND_HALF_UP) : null)
|
|
|
+ .sumActualNumber(sumActualNumber != null && sumActualNumber1 != null && sumActualNumber1.compareTo(BigDecimal.ZERO) != 0 ? sumActualNumber.divide(sumActualNumber1, 4, BigDecimal.ROUND_HALF_UP) : null)
|
|
|
+ .sumPlanNumber(sumPlanNumber != null && sumPlanNumber1 != null && sumPlanNumber1.compareTo(BigDecimal.ZERO) != 0 ? sumPlanNumber.divide(sumPlanNumber1, 4, BigDecimal.ROUND_HALF_UP) : null)
|
|
|
+ .difference(difference != null && difference1 != null && difference1.compareTo(BigDecimal.ZERO) != 0 ? difference.divide(difference1, 4, BigDecimal.ROUND_HALF_UP) : null)
|
|
|
+ .lastYearSumActualNumber(lastYearSumActualNumber != null && lastYearSumActualNumber1 != null && lastYearSumActualNumber1.compareTo(BigDecimal.ZERO) != 0 ? lastYearSumActualNumber.divide(lastYearSumActualNumber1, 4, BigDecimal.ROUND_HALF_UP) : null)
|
|
|
+ .lastYearDifference(lastYearDifference != null && lastYearDifference1 != null && lastYearDifference1.compareTo(BigDecimal.ZERO) != 0 ? lastYearDifference.divide(lastYearDifference1, 4, BigDecimal.ROUND_HALF_UP) : null)
|
|
|
.build());
|
|
|
}
|
|
|
return result;
|
|
@@ -167,20 +193,22 @@ public class CostOfWaterReportServiceImpl implements CostOfWaterReportService {
|
|
|
|
|
|
* 满意度统计
|
|
|
*
|
|
|
- * @param yearMonth 年月 yyyy-MM
|
|
|
+ * @param startMonth 年月 yyyyMM
|
|
|
+ * @param endMonth 年月 yyyyMM
|
|
|
* @return map
|
|
|
*/
|
|
|
@Override
|
|
|
- public Map<String, List<Satisfaction>> satisfactionStatistics(String yearMonth) {
|
|
|
+ public Map<String, List<Satisfaction>> satisfactionStatistics(String startMonth, String endMonth) {
|
|
|
List<Satisfaction> sumList = new ArrayList<>();
|
|
|
- DateTime monthDate = DateUtil.parse(yearMonth, "yyyy-MM");
|
|
|
- DateTime start = DateUtil.beginOfMonth(monthDate);
|
|
|
- DateTime end = DateUtil.endOfMonth(monthDate);
|
|
|
+ DateTime startData = DateUtil.parse(startMonth, "yyyyMM");
|
|
|
+ DateTime endData = DateUtil.parse(endMonth, "yyyyMM");
|
|
|
+ DateTime start = DateUtil.beginOfMonth(startData);
|
|
|
+ DateTime end = DateUtil.endOfMonth(endData);
|
|
|
Map<String, List<Satisfaction>> result = new HashMap<>(3);
|
|
|
List<Satisfaction> hotline = callCenterFeign.getSatisfactionStatis(DateUtil.format(start, "yyyy-MM-dd HH:mm:ss"), DateUtil.format(end, "yyyy-MM-dd HH:mm:ss")).getResult().stream().filter(Objects::nonNull).collect(Collectors.toList());
|
|
|
- List<Satisfaction> frontDesk = satisfactionService.list(Wrappers.<Satisfaction>lambdaQuery().eq(Satisfaction::getMonthPlan, yearMonth)).stream().filter(Objects::nonNull).collect(Collectors.toList());
|
|
|
+ List<Satisfaction> frontDesk = costOfWaterReportMapper.satisfactionStatistics(startMonth,endMonth);
|
|
|
List<Satisfaction> afterSales = costOfWaterReportMapper.returnVisitTickets(start, end).stream().filter(Objects::nonNull).collect(Collectors.toList());
|
|
|
- result.put("frontDesk", frontDesk);
|
|
|
+ result.put("frontDesk", CollectionUtil.isNotEmpty(frontDesk) ? frontDesk : new ArrayList<>());
|
|
|
result.put("hotline", CollectionUtil.isNotEmpty(hotline) ? hotline : new ArrayList<>());
|
|
|
result.put("afterSales", CollectionUtil.isNotEmpty(afterSales) ? afterSales : new ArrayList<>());
|
|
|
|
|
@@ -194,11 +222,11 @@ public class CostOfWaterReportServiceImpl implements CostOfWaterReportService {
|
|
|
|
|
|
Satisfaction sum = new Satisfaction();
|
|
|
|
|
|
- BigDecimal verySatisfied = sumList.stream().map(Satisfaction::getVerySatisfied).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
- BigDecimal satisfied = sumList.stream().map(Satisfaction::getSatisfied).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
- BigDecimal general = sumList.stream().map(Satisfaction::getGeneral).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
- BigDecimal dissatisfied = sumList.stream().map(Satisfaction::getDissatisfied).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
- BigDecimal total = sumList.stream().map(Satisfaction::getTotal).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ BigDecimal verySatisfied = sumList.stream().filter(Objects::nonNull).map(Satisfaction::getVerySatisfied).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ BigDecimal satisfied = sumList.stream().filter(Objects::nonNull).map(Satisfaction::getSatisfied).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ BigDecimal general = sumList.stream().filter(Objects::nonNull).map(Satisfaction::getGeneral).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ BigDecimal dissatisfied = sumList.stream().filter(Objects::nonNull).map(Satisfaction::getDissatisfied).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ BigDecimal total = sumList.stream().filter(Objects::nonNull).map(Satisfaction::getTotal).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
|
|
|
BigDecimal scores = (total.compareTo(BigDecimal.ZERO) != 0 ? verySatisfied.add(satisfied.multiply(BigDecimal.valueOf(0.85))).add(general.multiply(BigDecimal.valueOf(0.7))).add(dissatisfied.multiply(BigDecimal.valueOf(0.5))).divide(total, 4, BigDecimal.ROUND_HALF_UP).multiply(BigDecimal.valueOf(100)) : BigDecimal.ZERO);
|
|
|
|
|
@@ -217,21 +245,23 @@ public class CostOfWaterReportServiceImpl implements CostOfWaterReportService {
|
|
|
|
|
|
* 业务工单统计
|
|
|
*
|
|
|
- * @param yearMonth 年月 yyyy-MM
|
|
|
+ * @param startMonth 年月 yyyyMM
|
|
|
+ * @param endMonth 年月 yyyyMM
|
|
|
* @return map
|
|
|
*/
|
|
|
@Override
|
|
|
- public List<BusinessTicketsCount> businessTicketsCount(String yearMonth) {
|
|
|
+ public List<BusinessTicketsCount> businessTicketsCount(String startMonth, String endMonth) {
|
|
|
List<BusinessTicketsCount> result = new ArrayList<>(2);
|
|
|
- DateTime monthTime = DateUtil.parse(yearMonth, "yyyy-MM");
|
|
|
- DateTime beginMonth = DateUtil.beginOfMonth(monthTime);
|
|
|
- DateTime endMonth = DateUtil.endOfMonth(monthTime);
|
|
|
+ DateTime startTime = DateUtil.parse(startMonth, "yyyy-MM");
|
|
|
+ DateTime endTIme = DateUtil.parse(endMonth, "yyyy-MM");
|
|
|
+ DateTime beginTime = DateUtil.beginOfMonth(startTime);
|
|
|
+ DateTime endTime = DateUtil.endOfMonth(endTIme);
|
|
|
|
|
|
|
|
|
- BigDecimal afterCallProcessingTime = callCenterFeign.afterCallProcessingTime(DateUtil.format(beginMonth, "yyyy-MM-dd HH:mm:ss"), DateUtil.format(endMonth, "yyyy-MM-dd HH:mm:ss"));
|
|
|
+ BigDecimal afterCallProcessingTime = callCenterFeign.afterCallProcessingTime(DateUtil.format(beginTime, "yyyy-MM-dd HH:mm:ss"), DateUtil.format(endTime, "yyyy-MM-dd HH:mm:ss"));
|
|
|
|
|
|
|
|
|
- BigDecimal hotlineTickets = costOfWaterReportMapper.hotlineTicketsCount(beginMonth, endMonth);
|
|
|
+ BigDecimal hotlineTickets = costOfWaterReportMapper.hotlineTicketsCount(beginTime, endTime);
|
|
|
|
|
|
BigDecimal hotLineAvgTime = hotlineTickets.compareTo(BigDecimal.ZERO) != 0 && afterCallProcessingTime.compareTo(BigDecimal.ZERO) != 0 ? afterCallProcessingTime.divide(hotlineTickets, 2, BigDecimal.ROUND_HALF_UP) : BigDecimal.ZERO;
|
|
|
|
|
@@ -242,8 +272,8 @@ public class CostOfWaterReportServiceImpl implements CostOfWaterReportService {
|
|
|
.inTimeRate(minutes <= 1 ? "合格" : "不合格").build());
|
|
|
result.add(BusinessTicketsCount.builder()
|
|
|
.name("售后服务")
|
|
|
- .averageTime(costOfWaterReportMapper.afterTicketsCount(beginMonth, endMonth))
|
|
|
- .inTimeRate(costOfWaterReportMapper.ticketsInTimeCompute(beginMonth, endMonth).toString()).build());
|
|
|
+ .averageTime(costOfWaterReportMapper.afterTicketsCount(beginTime, endTIme))
|
|
|
+ .inTimeRate(costOfWaterReportMapper.ticketsInTimeCompute(beginTime, endTime).toString()).build());
|
|
|
return result;
|
|
|
}
|
|
|
|
|
@@ -251,173 +281,185 @@ public class CostOfWaterReportServiceImpl implements CostOfWaterReportService {
|
|
|
|
|
|
* 单位成本
|
|
|
*
|
|
|
- * @param yearMonth 年月 yyyy-MM
|
|
|
+ * @param startMonth 年月 yyyy-MM
|
|
|
+ * @param endMonth 年月 yyyy-MM
|
|
|
* @return map
|
|
|
*/
|
|
|
@Override
|
|
|
- public List<UnitCost> unitCost(String yearMonth) {
|
|
|
+ public List<UnitCost> unitCost(String startMonth, String endMonth) {
|
|
|
+
|
|
|
+ DateTime nowStart = DateUtil.parse(startMonth, "yyyyMM");
|
|
|
+ DateTime nowEnd = DateUtil.parse(endMonth, "yyyyMM");
|
|
|
+
|
|
|
+ String lastYearStart = DateUtil.format(DateUtil.offsetMonth(nowStart, -12), "yyyyMM");
|
|
|
+ String lastYearEnd = DateUtil.format(DateUtil.offsetMonth(nowEnd, -12), "yyyyMM");
|
|
|
+
|
|
|
+ long between = DateUtil.betweenMonth(nowStart, nowEnd, true);
|
|
|
+ DateTime lastEnd = DateUtil.offsetMonth(nowStart, -1);
|
|
|
+ DateTime lastStart = DateUtil.offsetMonth(lastEnd, Math.toIntExact(-between));
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ List<WaterCostCalDto> nowList = costOfWaterReportMapper.waterCostCalData(startMonth,endMonth);
|
|
|
+ List<WaterCostCalDto> lastMonthList = costOfWaterReportMapper.waterCostCalData(DateUtil.format(lastStart,"yyyyMM"),DateUtil.format(lastEnd,"yyyyMM"));
|
|
|
+ List<WaterCostCalDto> lastYearList = costOfWaterReportMapper.waterCostCalData(lastYearStart,lastYearEnd);
|
|
|
|
|
|
- DateTime parse = DateUtil.parse(yearMonth, "yyyy-MM");
|
|
|
- String lastMonth = DateUtil.format(DateUtil.offsetMonth(parse, -1), "yyyy-MM");
|
|
|
- String lastYearMonth = DateUtil.format(DateUtil.offsetMonth(parse, -12), "yyyy-MM");
|
|
|
-
|
|
|
- List<String> yearMonthList = new ArrayList<>();
|
|
|
- yearMonthList.add(yearMonth);
|
|
|
- yearMonthList.add(lastMonth);
|
|
|
- yearMonthList.add(lastYearMonth);
|
|
|
-
|
|
|
- List<WaterCostCalDto> waterCostCal = costOfWaterReportMapper.waterCostCalData(yearMonthList);
|
|
|
- List<WaterCostCalDto> nowList = null;
|
|
|
- List<WaterCostCalDto> lastMonthList = null;
|
|
|
- List<WaterCostCalDto> lastYearList = null;
|
|
|
-
|
|
|
- if (CollectionUtil.isNotEmpty(waterCostCal)) {
|
|
|
- nowList = waterCostCal.stream().filter(item -> yearMonth.equals(item.getMonth())).collect(Collectors.toList());
|
|
|
- lastMonthList = waterCostCal.stream().filter(item -> lastMonth.equals(item.getMonth())).collect(Collectors.toList());
|
|
|
- lastYearList = waterCostCal.stream().filter(item -> lastYearMonth.equals(item.getMonth())).collect(Collectors.toList());
|
|
|
- }
|
|
|
|
|
|
List<UnitCost> result = new ArrayList<>();
|
|
|
result.add(UnitCost.builder().name("供水量")
|
|
|
.value(CollectionUtil.isNotEmpty(nowList) ? nowList.get(0).getGslTotal() : BigDecimal.ZERO)
|
|
|
.yearOnYear(CollectionUtil.isNotEmpty(nowList) && CollectionUtil.isNotEmpty(lastYearList) && lastYearList.get(0).getGslTotal().compareTo(BigDecimal.ZERO) != 0 ? nowList.get(0).getGslTotal().subtract(lastYearList.get(0).getGslTotal()).divide(lastYearList.get(0).getGslTotal(), 4, BigDecimal.ROUND_HALF_UP).multiply(HUNDRED) : BigDecimal.ZERO)
|
|
|
- .annulus(CollectionUtil.isNotEmpty(nowList) && CollectionUtil.isNotEmpty(lastMonthList) && lastMonthList.get(0).getGslTotal().compareTo(BigDecimal.ZERO) != 0 ? nowList.get(0).getGslTotal().subtract(lastMonthList.get(0).getGslTotal()).divide(lastMonthList.get(0).getGslTotal(), 4, BigDecimal.ROUND_HALF_UP).multiply(HUNDRED) : BigDecimal.ZERO).build());
|
|
|
+ .annulus(CollectionUtil.isNotEmpty(nowList) && CollectionUtil.isNotEmpty(lastMonthList) && lastMonthList.get(0).getGslTotal().compareTo(BigDecimal.ZERO) != 0 ? nowList.get(0).getGslTotal().subtract(lastMonthList.get(0).getGslTotal()).divide(lastMonthList.get(0).getGslTotal(), 4, BigDecimal.ROUND_HALF_UP).multiply(HUNDRED) : BigDecimal.ZERO)
|
|
|
+ .build());
|
|
|
|
|
|
result.add(UnitCost.builder().name("售水量")
|
|
|
.value(CollectionUtil.isNotEmpty(nowList) ? nowList.get(0).getSslTotal() : BigDecimal.ZERO)
|
|
|
.yearOnYear(CollectionUtil.isNotEmpty(nowList) && CollectionUtil.isNotEmpty(lastYearList) && lastYearList.get(0).getSslTotal().compareTo(BigDecimal.ZERO) != 0 ? nowList.get(0).getSslTotal().subtract(lastYearList.get(0).getSslTotal()).divide(lastYearList.get(0).getSslTotal(), 4, BigDecimal.ROUND_HALF_UP).multiply(HUNDRED) : BigDecimal.ZERO)
|
|
|
- .annulus(CollectionUtil.isNotEmpty(nowList) && CollectionUtil.isNotEmpty(lastMonthList) && lastMonthList.get(0).getSslTotal().compareTo(BigDecimal.ZERO) != 0 ? nowList.get(0).getSslTotal().subtract(lastMonthList.get(0).getSslTotal()).divide(lastMonthList.get(0).getSslTotal(), 4, BigDecimal.ROUND_HALF_UP).multiply(HUNDRED) : BigDecimal.ZERO).build());
|
|
|
+ .annulus(CollectionUtil.isNotEmpty(nowList) && CollectionUtil.isNotEmpty(lastMonthList) && lastMonthList.get(0).getSslTotal().compareTo(BigDecimal.ZERO) != 0 ? nowList.get(0).getSslTotal().subtract(lastMonthList.get(0).getSslTotal()).divide(lastMonthList.get(0).getSslTotal(), 4, BigDecimal.ROUND_HALF_UP).multiply(HUNDRED) : BigDecimal.ZERO)
|
|
|
+ .build());
|
|
|
|
|
|
result.add(UnitCost.builder().name("产销差")
|
|
|
.value(CollectionUtil.isNotEmpty(nowList) ? nowList.get(0).getCxc() : BigDecimal.ZERO)
|
|
|
.yearOnYear(CollectionUtil.isNotEmpty(nowList) && CollectionUtil.isNotEmpty(lastYearList) && lastYearList.get(0).getCxc().compareTo(BigDecimal.ZERO) != 0 ? nowList.get(0).getCxc().subtract(lastYearList.get(0).getCxc()).divide(lastYearList.get(0).getCxc(), 4, BigDecimal.ROUND_HALF_UP).multiply(HUNDRED) : BigDecimal.ZERO)
|
|
|
- .annulus(CollectionUtil.isNotEmpty(nowList) && CollectionUtil.isNotEmpty(lastMonthList) && lastMonthList.get(0).getCxc().compareTo(BigDecimal.ZERO) != 0 ? nowList.get(0).getCxc().subtract(lastMonthList.get(0).getCxc()).divide(lastMonthList.get(0).getCxc(), 4, BigDecimal.ROUND_HALF_UP).multiply(HUNDRED) : BigDecimal.ZERO).build());
|
|
|
+ .annulus(CollectionUtil.isNotEmpty(nowList) && CollectionUtil.isNotEmpty(lastMonthList) && lastMonthList.get(0).getCxc().compareTo(BigDecimal.ZERO) != 0 ? nowList.get(0).getCxc().subtract(lastMonthList.get(0).getCxc()).divide(lastMonthList.get(0).getCxc(), 4, BigDecimal.ROUND_HALF_UP).multiply(HUNDRED) : BigDecimal.ZERO)
|
|
|
+ .build());
|
|
|
|
|
|
result.add(UnitCost.builder().name("漏损率")
|
|
|
.value(CollectionUtil.isNotEmpty(nowList) ? nowList.get(0).getLsl() : BigDecimal.ZERO)
|
|
|
.yearOnYear(CollectionUtil.isNotEmpty(nowList) && CollectionUtil.isNotEmpty(lastYearList) && lastYearList.get(0).getLsl().compareTo(BigDecimal.ZERO) != 0 ? nowList.get(0).getLsl().subtract(lastYearList.get(0).getLsl()).divide(lastYearList.get(0).getLsl(), 4, BigDecimal.ROUND_HALF_UP).multiply(HUNDRED) : BigDecimal.ZERO)
|
|
|
- .annulus(CollectionUtil.isNotEmpty(nowList) && CollectionUtil.isNotEmpty(lastMonthList) && lastMonthList.get(0).getLsl().compareTo(BigDecimal.ZERO) != 0 ? nowList.get(0).getLsl().subtract(lastMonthList.get(0).getLsl()).divide(lastMonthList.get(0).getLsl(), 4, BigDecimal.ROUND_HALF_UP).multiply(HUNDRED) : BigDecimal.ZERO).build());
|
|
|
+ .annulus(CollectionUtil.isNotEmpty(nowList) && CollectionUtil.isNotEmpty(lastMonthList) && lastMonthList.get(0).getLsl().compareTo(BigDecimal.ZERO) != 0 ? nowList.get(0).getLsl().subtract(lastMonthList.get(0).getLsl()).divide(lastMonthList.get(0).getLsl(), 4, BigDecimal.ROUND_HALF_UP).multiply(HUNDRED) : BigDecimal.ZERO)
|
|
|
+ .build());
|
|
|
|
|
|
result.add(UnitCost.builder().name("单位变动成本(元/千吨)")
|
|
|
.value(CollectionUtil.isNotEmpty(nowList) ? nowList.get(0).getZscb() : BigDecimal.ZERO)
|
|
|
.yearOnYear(CollectionUtil.isNotEmpty(nowList) && CollectionUtil.isNotEmpty(lastYearList) && lastYearList.get(0).getZscb().compareTo(BigDecimal.ZERO) != 0 ? nowList.get(0).getZscb().subtract(lastYearList.get(0).getZscb()).divide(lastYearList.get(0).getZscb(), 4, BigDecimal.ROUND_HALF_UP).multiply(HUNDRED) : BigDecimal.ZERO)
|
|
|
- .annulus(CollectionUtil.isNotEmpty(nowList) && CollectionUtil.isNotEmpty(lastMonthList) && lastMonthList.get(0).getZscb().compareTo(BigDecimal.ZERO) != 0 ? nowList.get(0).getZscb().subtract(lastMonthList.get(0).getZscb()).divide(lastMonthList.get(0).getZscb(), 4, BigDecimal.ROUND_HALF_UP).multiply(HUNDRED) : BigDecimal.ZERO).build());
|
|
|
+ .annulus(CollectionUtil.isNotEmpty(nowList) && CollectionUtil.isNotEmpty(lastMonthList) && lastMonthList.get(0).getZscb().compareTo(BigDecimal.ZERO) != 0 ? nowList.get(0).getZscb().subtract(lastMonthList.get(0).getZscb()).divide(lastMonthList.get(0).getZscb(), 4, BigDecimal.ROUND_HALF_UP).multiply(HUNDRED) : BigDecimal.ZERO)
|
|
|
+ .build());
|
|
|
|
|
|
result.add(UnitCost.builder().name("制水药剂成本")
|
|
|
.value(CollectionUtil.isNotEmpty(nowList) ? nowList.get(0).getZsyjcb() : BigDecimal.ZERO)
|
|
|
.yearOnYear(CollectionUtil.isNotEmpty(nowList) && CollectionUtil.isNotEmpty(lastYearList) && lastYearList.get(0).getZsyjcb().compareTo(BigDecimal.ZERO) != 0 ? nowList.get(0).getZsyjcb().subtract(lastYearList.get(0).getZsyjcb()).divide(lastYearList.get(0).getZsyjcb(), 4, BigDecimal.ROUND_HALF_UP).multiply(HUNDRED) : BigDecimal.ZERO)
|
|
|
- .annulus(CollectionUtil.isNotEmpty(nowList) && CollectionUtil.isNotEmpty(lastMonthList) && lastMonthList.get(0).getZsyjcb().compareTo(BigDecimal.ZERO) != 0 ? nowList.get(0).getZsyjcb().subtract(lastMonthList.get(0).getZsyjcb()).divide(lastMonthList.get(0).getZsyjcb(), 4, BigDecimal.ROUND_HALF_UP).multiply(HUNDRED) : BigDecimal.ZERO).build());
|
|
|
+ .annulus(CollectionUtil.isNotEmpty(nowList) && CollectionUtil.isNotEmpty(lastMonthList) && lastMonthList.get(0).getZsyjcb().compareTo(BigDecimal.ZERO) != 0 ? nowList.get(0).getZsyjcb().subtract(lastMonthList.get(0).getZsyjcb()).divide(lastMonthList.get(0).getZsyjcb(), 4, BigDecimal.ROUND_HALF_UP).multiply(HUNDRED) : BigDecimal.ZERO)
|
|
|
+ .build());
|
|
|
|
|
|
result.add(UnitCost.builder().name("常用制水药剂成本")
|
|
|
.value(CollectionUtil.isNotEmpty(nowList) ? nowList.get(0).getCyzsyj() : BigDecimal.ZERO)
|
|
|
.yearOnYear(CollectionUtil.isNotEmpty(nowList) && CollectionUtil.isNotEmpty(lastYearList) && lastYearList.get(0).getCyzsyj().compareTo(BigDecimal.ZERO) != 0 ? nowList.get(0).getCyzsyj().subtract(lastYearList.get(0).getCyzsyj()).divide(lastYearList.get(0).getCyzsyj(), 4, BigDecimal.ROUND_HALF_UP).multiply(HUNDRED) : BigDecimal.ZERO)
|
|
|
- .annulus(CollectionUtil.isNotEmpty(nowList) && CollectionUtil.isNotEmpty(lastMonthList) && lastMonthList.get(0).getCyzsyj().compareTo(BigDecimal.ZERO) != 0 ? nowList.get(0).getCyzsyj().subtract(lastMonthList.get(0).getCyzsyj()).divide(lastMonthList.get(0).getCyzsyj(), 4, BigDecimal.ROUND_HALF_UP).multiply(HUNDRED) : BigDecimal.ZERO).build());
|
|
|
+ .annulus(CollectionUtil.isNotEmpty(nowList) && CollectionUtil.isNotEmpty(lastMonthList) && lastMonthList.get(0).getCyzsyj().compareTo(BigDecimal.ZERO) != 0 ? nowList.get(0).getCyzsyj().subtract(lastMonthList.get(0).getCyzsyj()).divide(lastMonthList.get(0).getCyzsyj(), 4, BigDecimal.ROUND_HALF_UP).multiply(HUNDRED) : BigDecimal.ZERO)
|
|
|
+ .build());
|
|
|
|
|
|
result.add(UnitCost.builder().name("PAC")
|
|
|
.value(CollectionUtil.isNotEmpty(nowList) ? nowList.get(0).getPaccb() : BigDecimal.ZERO)
|
|
|
.yearOnYear(CollectionUtil.isNotEmpty(nowList) && CollectionUtil.isNotEmpty(lastYearList) && lastYearList.get(0).getPaccb().compareTo(BigDecimal.ZERO) != 0 ? nowList.get(0).getPaccb().subtract(lastYearList.get(0).getPaccb()).divide(lastYearList.get(0).getPaccb(), 4, BigDecimal.ROUND_HALF_UP).multiply(HUNDRED) : BigDecimal.ZERO)
|
|
|
- .annulus(CollectionUtil.isNotEmpty(nowList) && CollectionUtil.isNotEmpty(lastMonthList) && lastMonthList.get(0).getPaccb().compareTo(BigDecimal.ZERO) != 0 ? nowList.get(0).getPaccb().subtract(lastMonthList.get(0).getPaccb()).divide(lastMonthList.get(0).getPaccb(), 4, BigDecimal.ROUND_HALF_UP).multiply(HUNDRED) : BigDecimal.ZERO).build());
|
|
|
+ .annulus(CollectionUtil.isNotEmpty(nowList) && CollectionUtil.isNotEmpty(lastMonthList) && lastMonthList.get(0).getPaccb().compareTo(BigDecimal.ZERO) != 0 ? nowList.get(0).getPaccb().subtract(lastMonthList.get(0).getPaccb()).divide(lastMonthList.get(0).getPaccb(), 4, BigDecimal.ROUND_HALF_UP).multiply(HUNDRED) : BigDecimal.ZERO)
|
|
|
+ .build());
|
|
|
|
|
|
result.add(UnitCost.builder().name("食盐")
|
|
|
.value(CollectionUtil.isNotEmpty(nowList) ? nowList.get(0).getSycb() : BigDecimal.ZERO)
|
|
|
.yearOnYear(CollectionUtil.isNotEmpty(nowList) && CollectionUtil.isNotEmpty(lastYearList) && lastYearList.get(0).getSycb().compareTo(BigDecimal.ZERO) != 0 ? nowList.get(0).getSycb().subtract(lastYearList.get(0).getSycb()).divide(lastYearList.get(0).getSycb(), 4, BigDecimal.ROUND_HALF_UP).multiply(HUNDRED) : BigDecimal.ZERO)
|
|
|
- .annulus(CollectionUtil.isNotEmpty(nowList) && CollectionUtil.isNotEmpty(lastMonthList) && lastMonthList.get(0).getSycb().compareTo(BigDecimal.ZERO) != 0 ? nowList.get(0).getSycb().subtract(lastMonthList.get(0).getSycb()).divide(lastMonthList.get(0).getSycb(), 4, BigDecimal.ROUND_HALF_UP).multiply(HUNDRED) : BigDecimal.ZERO).build());
|
|
|
+ .annulus(CollectionUtil.isNotEmpty(nowList) && CollectionUtil.isNotEmpty(lastMonthList) && lastMonthList.get(0).getSycb().compareTo(BigDecimal.ZERO) != 0 ? nowList.get(0).getSycb().subtract(lastMonthList.get(0).getSycb()).divide(lastMonthList.get(0).getSycb(), 4, BigDecimal.ROUND_HALF_UP).multiply(HUNDRED) : BigDecimal.ZERO)
|
|
|
+ .build());
|
|
|
|
|
|
result.add(UnitCost.builder().name("成品次钠")
|
|
|
.value(CollectionUtil.isNotEmpty(nowList) ? nowList.get(0).getCncb() : BigDecimal.ZERO)
|
|
|
.yearOnYear(CollectionUtil.isNotEmpty(nowList) && CollectionUtil.isNotEmpty(lastYearList) && lastYearList.get(0).getCncb().compareTo(BigDecimal.ZERO) != 0 ? nowList.get(0).getCncb().subtract(lastYearList.get(0).getCncb()).divide(lastYearList.get(0).getCncb(), 4, BigDecimal.ROUND_HALF_UP).multiply(HUNDRED) : BigDecimal.ZERO)
|
|
|
- .annulus(CollectionUtil.isNotEmpty(nowList) && CollectionUtil.isNotEmpty(lastMonthList) && lastMonthList.get(0).getCncb().compareTo(BigDecimal.ZERO) != 0 ? nowList.get(0).getCncb().subtract(lastMonthList.get(0).getCncb()).divide(lastMonthList.get(0).getCncb(), 4, BigDecimal.ROUND_HALF_UP).multiply(HUNDRED) : BigDecimal.ZERO).build());
|
|
|
+ .annulus(CollectionUtil.isNotEmpty(nowList) && CollectionUtil.isNotEmpty(lastMonthList) && lastMonthList.get(0).getCncb().compareTo(BigDecimal.ZERO) != 0 ? nowList.get(0).getCncb().subtract(lastMonthList.get(0).getCncb()).divide(lastMonthList.get(0).getCncb(), 4, BigDecimal.ROUND_HALF_UP).multiply(HUNDRED) : BigDecimal.ZERO)
|
|
|
+ .build());
|
|
|
|
|
|
result.add(UnitCost.builder().name("应急制水药剂")
|
|
|
.value(CollectionUtil.isNotEmpty(nowList) ? nowList.get(0).getYjzsyj() : BigDecimal.ZERO)
|
|
|
.yearOnYear(CollectionUtil.isNotEmpty(nowList) && CollectionUtil.isNotEmpty(lastYearList) && lastYearList.get(0).getYjzsyj().compareTo(BigDecimal.ZERO) != 0 ? nowList.get(0).getYjzsyj().subtract(lastYearList.get(0).getYjzsyj()).divide(lastYearList.get(0).getYjzsyj(), 4, BigDecimal.ROUND_HALF_UP).multiply(HUNDRED) : BigDecimal.ZERO)
|
|
|
- .annulus(CollectionUtil.isNotEmpty(nowList) && CollectionUtil.isNotEmpty(lastMonthList) && lastMonthList.get(0).getYjzsyj().compareTo(BigDecimal.ZERO) != 0 ? nowList.get(0).getYjzsyj().subtract(lastMonthList.get(0).getYjzsyj()).divide(lastMonthList.get(0).getYjzsyj(), 4, BigDecimal.ROUND_HALF_UP).multiply(HUNDRED) : BigDecimal.ZERO).build());
|
|
|
+ .annulus(CollectionUtil.isNotEmpty(nowList) && CollectionUtil.isNotEmpty(lastMonthList) && lastMonthList.get(0).getYjzsyj().compareTo(BigDecimal.ZERO) != 0 ? nowList.get(0).getYjzsyj().subtract(lastMonthList.get(0).getYjzsyj()).divide(lastMonthList.get(0).getYjzsyj(), 4, BigDecimal.ROUND_HALF_UP).multiply(HUNDRED) : BigDecimal.ZERO)
|
|
|
+ .build());
|
|
|
|
|
|
result.add(UnitCost.builder().name("制水PAM")
|
|
|
.value(CollectionUtil.isNotEmpty(nowList) ? nowList.get(0).getPamzscbTwo() : BigDecimal.ZERO)
|
|
|
.yearOnYear(CollectionUtil.isNotEmpty(nowList) && CollectionUtil.isNotEmpty(lastYearList) && lastYearList.get(0).getPamzscbTwo().compareTo(BigDecimal.ZERO) != 0 ? nowList.get(0).getPamzscbTwo().subtract(lastYearList.get(0).getPamzscbTwo()).divide(lastYearList.get(0).getPamzscbTwo(), 4, BigDecimal.ROUND_HALF_UP).multiply(HUNDRED) : BigDecimal.ZERO)
|
|
|
- .annulus(CollectionUtil.isNotEmpty(nowList) && CollectionUtil.isNotEmpty(lastMonthList) && lastMonthList.get(0).getPamzscbTwo().compareTo(BigDecimal.ZERO) != 0 ? nowList.get(0).getPamzscbTwo().subtract(lastMonthList.get(0).getPamzscbTwo()).divide(lastMonthList.get(0).getPamzscbTwo(), 4, BigDecimal.ROUND_HALF_UP).multiply(HUNDRED) : BigDecimal.ZERO).build());
|
|
|
+ .annulus(CollectionUtil.isNotEmpty(nowList) && CollectionUtil.isNotEmpty(lastMonthList) && lastMonthList.get(0).getPamzscbTwo().compareTo(BigDecimal.ZERO) != 0 ? nowList.get(0).getPamzscbTwo().subtract(lastMonthList.get(0).getPamzscbTwo()).divide(lastMonthList.get(0).getPamzscbTwo(), 4, BigDecimal.ROUND_HALF_UP).multiply(HUNDRED) : BigDecimal.ZERO)
|
|
|
+ .build());
|
|
|
|
|
|
result.add(UnitCost.builder().name("复合盐")
|
|
|
.value(CollectionUtil.isNotEmpty(nowList) ? nowList.get(0).getGmsjcb() : BigDecimal.ZERO)
|
|
|
.yearOnYear(CollectionUtil.isNotEmpty(nowList) && CollectionUtil.isNotEmpty(lastYearList) && lastYearList.get(0).getGmsjcb().compareTo(BigDecimal.ZERO) != 0 ? nowList.get(0).getGmsjcb().subtract(lastYearList.get(0).getGmsjcb()).divide(lastYearList.get(0).getGmsjcb(), 4, BigDecimal.ROUND_HALF_UP).multiply(HUNDRED) : BigDecimal.ZERO)
|
|
|
- .annulus(CollectionUtil.isNotEmpty(nowList) && CollectionUtil.isNotEmpty(lastMonthList) && lastMonthList.get(0).getGmsjcb().compareTo(BigDecimal.ZERO) != 0 ? nowList.get(0).getGmsjcb().subtract(lastMonthList.get(0).getGmsjcb()).divide(lastMonthList.get(0).getGmsjcb(), 4, BigDecimal.ROUND_HALF_UP).multiply(HUNDRED) : BigDecimal.ZERO).build());
|
|
|
+ .annulus(CollectionUtil.isNotEmpty(nowList) && CollectionUtil.isNotEmpty(lastMonthList) && lastMonthList.get(0).getGmsjcb().compareTo(BigDecimal.ZERO) != 0 ? nowList.get(0).getGmsjcb().subtract(lastMonthList.get(0).getGmsjcb()).divide(lastMonthList.get(0).getGmsjcb(), 4, BigDecimal.ROUND_HALF_UP).multiply(HUNDRED) : BigDecimal.ZERO)
|
|
|
+ .build());
|
|
|
|
|
|
result.add(UnitCost.builder().name("活性炭")
|
|
|
.value(CollectionUtil.isNotEmpty(nowList) ? nowList.get(0).getFtcb() : BigDecimal.ZERO)
|
|
|
.yearOnYear(CollectionUtil.isNotEmpty(nowList) && CollectionUtil.isNotEmpty(lastYearList) && lastYearList.get(0).getFtcb().compareTo(BigDecimal.ZERO) != 0 ? nowList.get(0).getFtcb().subtract(lastYearList.get(0).getFtcb()).divide(lastYearList.get(0).getGslTotal(), 4, BigDecimal.ROUND_HALF_UP).multiply(HUNDRED) : BigDecimal.ZERO)
|
|
|
- .annulus(CollectionUtil.isNotEmpty(nowList) && CollectionUtil.isNotEmpty(lastMonthList) && lastMonthList.get(0).getFtcb().compareTo(BigDecimal.ZERO) != 0 ? nowList.get(0).getFtcb().subtract(lastMonthList.get(0).getFtcb()).divide(lastMonthList.get(0).getGslTotal(), 4, BigDecimal.ROUND_HALF_UP).multiply(HUNDRED) : BigDecimal.ZERO).build());
|
|
|
+ .annulus(CollectionUtil.isNotEmpty(nowList) && CollectionUtil.isNotEmpty(lastMonthList) && lastMonthList.get(0).getFtcb().compareTo(BigDecimal.ZERO) != 0 ? nowList.get(0).getFtcb().subtract(lastMonthList.get(0).getFtcb()).divide(lastMonthList.get(0).getGslTotal(), 4, BigDecimal.ROUND_HALF_UP).multiply(HUNDRED) : BigDecimal.ZERO)
|
|
|
+ .build());
|
|
|
|
|
|
result.add(UnitCost.builder().name("制泥PAM")
|
|
|
.value(CollectionUtil.isNotEmpty(nowList) ? nowList.get(0).getWnpamcb() : BigDecimal.ZERO)
|
|
|
.yearOnYear(CollectionUtil.isNotEmpty(nowList) && CollectionUtil.isNotEmpty(lastYearList) && lastYearList.get(0).getWnpamcb().compareTo(BigDecimal.ZERO) != 0 ? nowList.get(0).getWnpamcb().subtract(lastYearList.get(0).getWnpamcb()).divide(lastYearList.get(0).getWnpamcb(), 4, BigDecimal.ROUND_HALF_UP).multiply(HUNDRED) : BigDecimal.ZERO)
|
|
|
- .annulus(CollectionUtil.isNotEmpty(nowList) && CollectionUtil.isNotEmpty(lastMonthList) && lastMonthList.get(0).getWnpamcb().compareTo(BigDecimal.ZERO) != 0 ? nowList.get(0).getWnpamcb().subtract(lastMonthList.get(0).getWnpamcb()).divide(lastMonthList.get(0).getWnpamcb(), 4, BigDecimal.ROUND_HALF_UP).multiply(HUNDRED) : BigDecimal.ZERO).build());
|
|
|
+ .annulus(CollectionUtil.isNotEmpty(nowList) && CollectionUtil.isNotEmpty(lastMonthList) && lastMonthList.get(0).getWnpamcb().compareTo(BigDecimal.ZERO) != 0 ? nowList.get(0).getWnpamcb().subtract(lastMonthList.get(0).getWnpamcb()).divide(lastMonthList.get(0).getWnpamcb(), 4, BigDecimal.ROUND_HALF_UP).multiply(HUNDRED) : BigDecimal.ZERO)
|
|
|
+ .build());
|
|
|
|
|
|
result.add(UnitCost.builder().name("能耗")
|
|
|
.value(CollectionUtil.isNotEmpty(nowList) ? nowList.get(0).getDfcb() : BigDecimal.ZERO)
|
|
|
.yearOnYear(CollectionUtil.isNotEmpty(nowList) && CollectionUtil.isNotEmpty(lastYearList) && lastYearList.get(0).getDfcb().compareTo(BigDecimal.ZERO) != 0 ? nowList.get(0).getDfcb().subtract(lastYearList.get(0).getDfcb()).divide(lastYearList.get(0).getDfcb(), 4, BigDecimal.ROUND_HALF_UP).multiply(HUNDRED) : BigDecimal.ZERO)
|
|
|
- .annulus(CollectionUtil.isNotEmpty(nowList) && CollectionUtil.isNotEmpty(lastMonthList) && lastMonthList.get(0).getDfcb().compareTo(BigDecimal.ZERO) != 0 ? nowList.get(0).getDfcb().subtract(lastMonthList.get(0).getDfcb()).divide(lastMonthList.get(0).getDfcb(), 4, BigDecimal.ROUND_HALF_UP).multiply(HUNDRED) : BigDecimal.ZERO).build());
|
|
|
+ .annulus(CollectionUtil.isNotEmpty(nowList) && CollectionUtil.isNotEmpty(lastMonthList) && lastMonthList.get(0).getDfcb().compareTo(BigDecimal.ZERO) != 0 ? nowList.get(0).getDfcb().subtract(lastMonthList.get(0).getDfcb()).divide(lastMonthList.get(0).getDfcb(), 4, BigDecimal.ROUND_HALF_UP).multiply(HUNDRED) : BigDecimal.ZERO)
|
|
|
+ .build());
|
|
|
|
|
|
result.add(UnitCost.builder().name("水费")
|
|
|
.value(CollectionUtil.isNotEmpty(nowList) ? nowList.get(0).getSfcb() : BigDecimal.ZERO)
|
|
|
.yearOnYear(CollectionUtil.isNotEmpty(nowList) && CollectionUtil.isNotEmpty(lastYearList) && lastYearList.get(0).getSfcb().compareTo(BigDecimal.ZERO) != 0 ? nowList.get(0).getSfcb().subtract(lastYearList.get(0).getSfcb()).divide(lastYearList.get(0).getSfcb(), 4, BigDecimal.ROUND_HALF_UP).multiply(HUNDRED) : BigDecimal.ZERO)
|
|
|
- .annulus(CollectionUtil.isNotEmpty(nowList) && CollectionUtil.isNotEmpty(lastMonthList) && lastMonthList.get(0).getSfcb().compareTo(BigDecimal.ZERO) != 0 ? nowList.get(0).getSfcb().subtract(lastMonthList.get(0).getSfcb()).divide(lastMonthList.get(0).getSfcb(), 4, BigDecimal.ROUND_HALF_UP).multiply(HUNDRED) : BigDecimal.ZERO).build());
|
|
|
+ .annulus(CollectionUtil.isNotEmpty(nowList) && CollectionUtil.isNotEmpty(lastMonthList) && lastMonthList.get(0).getSfcb().compareTo(BigDecimal.ZERO) != 0 ? nowList.get(0).getSfcb().subtract(lastMonthList.get(0).getSfcb()).divide(lastMonthList.get(0).getSfcb(), 4, BigDecimal.ROUND_HALF_UP).multiply(HUNDRED) : BigDecimal.ZERO)
|
|
|
+ .build());
|
|
|
|
|
|
result.add(UnitCost.builder().name("水资源费")
|
|
|
.value(CollectionUtil.isNotEmpty(nowList) ? nowList.get(0).getSzysfcb() : BigDecimal.ZERO)
|
|
|
.yearOnYear(CollectionUtil.isNotEmpty(nowList) && CollectionUtil.isNotEmpty(lastYearList) && lastYearList.get(0).getSzysfcb().compareTo(BigDecimal.ZERO) != 0 ? nowList.get(0).getSzysfcb().subtract(lastYearList.get(0).getSzysfcb()).divide(lastYearList.get(0).getSzysfcb(), 4, BigDecimal.ROUND_HALF_UP).multiply(HUNDRED) : BigDecimal.ZERO)
|
|
|
- .annulus(CollectionUtil.isNotEmpty(nowList) && CollectionUtil.isNotEmpty(lastMonthList) && lastMonthList.get(0).getSzysfcb().compareTo(BigDecimal.ZERO) != 0 ? nowList.get(0).getSzysfcb().subtract(lastMonthList.get(0).getSzysfcb()).divide(lastMonthList.get(0).getSzysfcb(), 4, BigDecimal.ROUND_HALF_UP).multiply(HUNDRED) : BigDecimal.ZERO).build());
|
|
|
+ .annulus(CollectionUtil.isNotEmpty(nowList) && CollectionUtil.isNotEmpty(lastMonthList) && lastMonthList.get(0).getSzysfcb().compareTo(BigDecimal.ZERO) != 0 ? nowList.get(0).getSzysfcb().subtract(lastMonthList.get(0).getSzysfcb()).divide(lastMonthList.get(0).getSzysfcb(), 4, BigDecimal.ROUND_HALF_UP).multiply(HUNDRED) : BigDecimal.ZERO)
|
|
|
+ .build());
|
|
|
|
|
|
result.add(UnitCost.builder().name("原水费")
|
|
|
.value(CollectionUtil.isNotEmpty(nowList) ? nowList.get(0).getYsfcb() : BigDecimal.ZERO)
|
|
|
.yearOnYear(CollectionUtil.isNotEmpty(nowList) && CollectionUtil.isNotEmpty(lastYearList) && lastYearList.get(0).getYsfcb().compareTo(BigDecimal.ZERO) != 0 ? nowList.get(0).getYsfcb().subtract(lastYearList.get(0).getYsfcb()).divide(lastYearList.get(0).getYsfcb(), 4, BigDecimal.ROUND_HALF_UP).multiply(HUNDRED) : BigDecimal.ZERO)
|
|
|
- .annulus(CollectionUtil.isNotEmpty(nowList) && CollectionUtil.isNotEmpty(lastMonthList) && lastMonthList.get(0).getYsfcb().compareTo(BigDecimal.ZERO) != 0 ? nowList.get(0).getYsfcb().subtract(lastMonthList.get(0).getYsfcb()).divide(lastMonthList.get(0).getYsfcb(), 4, BigDecimal.ROUND_HALF_UP).multiply(HUNDRED) : BigDecimal.ZERO).build());
|
|
|
+ .annulus(CollectionUtil.isNotEmpty(nowList) && CollectionUtil.isNotEmpty(lastMonthList) && lastMonthList.get(0).getYsfcb().compareTo(BigDecimal.ZERO) != 0 ? nowList.get(0).getYsfcb().subtract(lastMonthList.get(0).getYsfcb()).divide(lastMonthList.get(0).getYsfcb(), 4, BigDecimal.ROUND_HALF_UP).multiply(HUNDRED) : BigDecimal.ZERO)
|
|
|
+ .build());
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
|
|
|
* 单耗
|
|
|
*
|
|
|
- * @param yearMonth yearMonth
|
|
|
+ * @param startMonth startMonth
|
|
|
+ * @param endMonth startMonth
|
|
|
* @return map
|
|
|
*/
|
|
|
@Override
|
|
|
- public List<UnitCost> unitConsumption(String yearMonth) {
|
|
|
+ public List<UnitCost> unitConsumption(String startMonth, String endMonth) {
|
|
|
|
|
|
- DateTime parse = DateUtil.parse(yearMonth, "yyyy-MM");
|
|
|
- DateTime lastDateTime = DateUtil.offsetMonth(parse, -1);
|
|
|
- String lastMonth = DateUtil.format(lastDateTime, "yyyy-MM");
|
|
|
- DateTime lastYear = DateUtil.offsetMonth(parse, -12);
|
|
|
- String lastYearMonth = DateUtil.format(lastYear, "yyyy-MM");
|
|
|
-
|
|
|
- List<String> yearMonthList = new ArrayList<>();
|
|
|
- yearMonthList.add(yearMonth);
|
|
|
- yearMonthList.add(lastMonth);
|
|
|
- yearMonthList.add(lastYearMonth);
|
|
|
-
|
|
|
- List<WaterUnitCalDto> waterUnitCal = costOfWaterReportMapper.waterUnitCalData(yearMonthList);
|
|
|
-
|
|
|
- List<WaterUnitCalDto> nowList = null;
|
|
|
- List<WaterUnitCalDto> lastMonthList = null;
|
|
|
- List<WaterUnitCalDto> lastYearList = null;
|
|
|
-
|
|
|
- if (CollectionUtil.isNotEmpty(waterUnitCal)) {
|
|
|
- nowList = waterUnitCal.stream().filter(item -> yearMonth.equals(item.getMonth())).collect(Collectors.toList());
|
|
|
- lastMonthList = waterUnitCal.stream().filter(item -> lastMonth.equals(item.getMonth())).collect(Collectors.toList());
|
|
|
- lastYearList = waterUnitCal.stream().filter(item -> lastYearMonth.equals(item.getMonth())).collect(Collectors.toList());
|
|
|
- }
|
|
|
+ DateTime startTime = DateUtil.parse(startMonth, "yyyyMM");
|
|
|
+ DateTime endTIme = DateUtil.parse(endMonth, "yyyyMM");
|
|
|
+
|
|
|
+ DateTime lastStart = DateUtil.offsetMonth(startTime, -12);
|
|
|
+ DateTime lastEnd = DateUtil.offsetMonth(endTIme, -12);
|
|
|
+ String lastYearStart = DateUtil.format(lastStart, "yyyyMM");
|
|
|
+ String lastYearEnd = DateUtil.format(lastEnd, "yyyyMM");
|
|
|
+
|
|
|
+ long between = DateUtil.betweenMonth(startTime, endTIme, true);
|
|
|
+ DateTime lastMonthEnd = DateUtil.offsetMonth(startTime, -1);
|
|
|
+ DateTime lastMonthStart = DateUtil.offsetMonth(lastEnd, Math.toIntExact(-between));
|
|
|
+
|
|
|
+ List<WaterUnitCalDto> nowList = costOfWaterReportMapper.waterUnitCalData(startMonth,endMonth);
|
|
|
+ List<WaterUnitCalDto> lastMonthList = costOfWaterReportMapper.waterUnitCalData(DateUtil.format(lastMonthStart,"yyyyMM"),DateUtil.format(lastMonthEnd,"yyyyMM"));
|
|
|
+ List<WaterUnitCalDto> lastYearList = costOfWaterReportMapper.waterUnitCalData(lastYearStart,lastYearEnd);
|
|
|
|
|
|
- String nowTable = "TF_YWPN_SCADAHISTORY_R_" + DateUtil.format(parse, "yyyyMM");
|
|
|
- String lastTable = "TF_YWPN_SCADAHISTORY_R_" + DateUtil.format(lastDateTime, "yyyyMM");
|
|
|
- String lastYearTable = "TF_YWPN_SCADAHISTORY_R_" + DateUtil.format(lastYear, "yyyyMM");
|
|
|
+ DateTime nowStart = DateUtil.beginOfMonth(startTime);
|
|
|
+ DateTime nowEnd = DateUtil.endOfMonth(endTIme);
|
|
|
+ List<ScadaAvg> nowValue = costOfWaterReportMapper.getScadaAvgValue(nowStart,nowEnd);
|
|
|
|
|
|
- Integer nowCount = costOfWaterReportMapper.tableIsExist(nowTable);
|
|
|
- Integer lastCount = costOfWaterReportMapper.tableIsExist(lastTable);
|
|
|
- Integer lastYearCount = costOfWaterReportMapper.tableIsExist(lastYearTable);
|
|
|
+ DateTime lastStartTime = DateUtil.beginOfMonth(lastMonthStart);
|
|
|
+ DateTime lastEndTime = DateUtil.endOfMonth(lastMonthEnd);
|
|
|
+ List<ScadaAvg> lastValue = costOfWaterReportMapper.getScadaAvgValue(lastStartTime,lastEndTime);
|
|
|
|
|
|
- List<ScadaAvg> nowValue = nowCount == 0 ? new ArrayList<>() : costOfWaterReportMapper.getScadaAvgValue(nowTable);
|
|
|
- List<ScadaAvg> lastValue = lastCount == 0 ? new ArrayList<>() : costOfWaterReportMapper.getScadaAvgValue(lastTable);
|
|
|
- List<ScadaAvg> lastYearValue = lastYearCount == 0 ? new ArrayList<>() : costOfWaterReportMapper.getScadaAvgValue(lastYearTable);
|
|
|
+ DateTime startLastYear = DateUtil.beginOfMonth(lastStart);
|
|
|
+ DateTime endLastYear = DateUtil.beginOfMonth(lastEnd);
|
|
|
+
|
|
|
+ List<ScadaAvg> lastYearValue = costOfWaterReportMapper.getScadaAvgValue(startLastYear,endLastYear);
|
|
|
|
|
|
BigDecimal nowTurbidity = CollectionUtil.isNotEmpty(nowValue) ? nowValue.stream().filter(s->s.getItcd().equals(TURBIDITY)).collect(Collectors.toList()).get(0).getAvgNum() : BigDecimal.ZERO;
|
|
|
BigDecimal lastTurbidity = CollectionUtil.isNotEmpty(lastValue) ? lastValue.stream().filter(s->s.getItcd().equals(TURBIDITY)).collect(Collectors.toList()).get(0).getAvgNum() : BigDecimal.ZERO;
|
|
@@ -439,39 +481,48 @@ public class CostOfWaterReportServiceImpl implements CostOfWaterReportService {
|
|
|
|
|
|
result.add(UnitCost.builder().name("PAC").value(CollectionUtil.isNotEmpty(nowList) ? nowList.get(0).getPacdh() : BigDecimal.ZERO)
|
|
|
.yearOnYear(CollectionUtil.isNotEmpty(nowList) && CollectionUtil.isNotEmpty(lastYearList) && lastYearList.get(0).getPacdh().compareTo(BigDecimal.ZERO) != 0 ? nowList.get(0).getPacdh().subtract(lastYearList.get(0).getPacdh()).divide(lastYearList.get(0).getPacdh(), 4, BigDecimal.ROUND_HALF_UP).multiply(HUNDRED) : BigDecimal.ZERO)
|
|
|
- .annulus(CollectionUtil.isNotEmpty(nowList) && CollectionUtil.isNotEmpty(lastMonthList) && lastMonthList.get(0).getPacdh().compareTo(BigDecimal.ZERO) != 0 ? nowList.get(0).getPacdh().subtract(lastMonthList.get(0).getPacdh()).divide(lastMonthList.get(0).getPacdh(), 4, BigDecimal.ROUND_HALF_UP).multiply(HUNDRED) : BigDecimal.ZERO).build());
|
|
|
+ .annulus(CollectionUtil.isNotEmpty(nowList) && CollectionUtil.isNotEmpty(lastMonthList) && lastMonthList.get(0).getPacdh().compareTo(BigDecimal.ZERO) != 0 ? nowList.get(0).getPacdh().subtract(lastMonthList.get(0).getPacdh()).divide(lastMonthList.get(0).getPacdh(), 4, BigDecimal.ROUND_HALF_UP).multiply(HUNDRED) : BigDecimal.ZERO)
|
|
|
+ .build());
|
|
|
|
|
|
result.add(UnitCost.builder().name("食盐").value(CollectionUtil.isNotEmpty(nowList) ? nowList.get(0).getSydh() : BigDecimal.ZERO)
|
|
|
.yearOnYear(CollectionUtil.isNotEmpty(nowList) && CollectionUtil.isNotEmpty(lastYearList) && lastYearList.get(0).getSydh().compareTo(BigDecimal.ZERO) != 0 ? nowList.get(0).getSydh().subtract(lastYearList.get(0).getSydh()).divide(lastYearList.get(0).getSydh(), 4, BigDecimal.ROUND_HALF_UP).multiply(HUNDRED) : BigDecimal.ZERO)
|
|
|
- .annulus(CollectionUtil.isNotEmpty(nowList) && CollectionUtil.isNotEmpty(lastMonthList) && lastMonthList.get(0).getSydh().compareTo(BigDecimal.ZERO) != 0 ? nowList.get(0).getSydh().subtract(lastMonthList.get(0).getSydh()).divide(lastMonthList.get(0).getSydh(), 4, BigDecimal.ROUND_HALF_UP).multiply(HUNDRED) : BigDecimal.ZERO).build());
|
|
|
+ .annulus(CollectionUtil.isNotEmpty(nowList) && CollectionUtil.isNotEmpty(lastMonthList) && lastMonthList.get(0).getSydh().compareTo(BigDecimal.ZERO) != 0 ? nowList.get(0).getSydh().subtract(lastMonthList.get(0).getSydh()).divide(lastMonthList.get(0).getSydh(), 4, BigDecimal.ROUND_HALF_UP).multiply(HUNDRED) : BigDecimal.ZERO)
|
|
|
+ .build());
|
|
|
|
|
|
result.add(UnitCost.builder().name("成品次钠").value(CollectionUtil.isNotEmpty(nowList) ? nowList.get(0).getCndh() : BigDecimal.ZERO)
|
|
|
.yearOnYear(CollectionUtil.isNotEmpty(nowList) && CollectionUtil.isNotEmpty(lastYearList) && lastYearList.get(0).getCndh().compareTo(BigDecimal.ZERO) != 0 ? nowList.get(0).getCndh().subtract(lastYearList.get(0).getCndh()).divide(lastYearList.get(0).getCndh(), 4, BigDecimal.ROUND_HALF_UP).multiply(HUNDRED) : BigDecimal.ZERO)
|
|
|
- .annulus(CollectionUtil.isNotEmpty(nowList) && CollectionUtil.isNotEmpty(lastMonthList) && lastMonthList.get(0).getCndh().compareTo(BigDecimal.ZERO) != 0 ? nowList.get(0).getCndh().subtract(lastMonthList.get(0).getCndh()).divide(lastMonthList.get(0).getCndh(), 4, BigDecimal.ROUND_HALF_UP).multiply(HUNDRED) : BigDecimal.ZERO).build());
|
|
|
+ .annulus(CollectionUtil.isNotEmpty(nowList) && CollectionUtil.isNotEmpty(lastMonthList) && lastMonthList.get(0).getCndh().compareTo(BigDecimal.ZERO) != 0 ? nowList.get(0).getCndh().subtract(lastMonthList.get(0).getCndh()).divide(lastMonthList.get(0).getCndh(), 4, BigDecimal.ROUND_HALF_UP).multiply(HUNDRED) : BigDecimal.ZERO)
|
|
|
+ .build());
|
|
|
|
|
|
result.add(UnitCost.builder().name("制水PAM").value(CollectionUtil.isNotEmpty(nowList) ? nowList.get(0).getPamdh() : BigDecimal.ZERO)
|
|
|
.yearOnYear(CollectionUtil.isNotEmpty(nowList) && CollectionUtil.isNotEmpty(lastYearList) && lastYearList.get(0).getPamdh().compareTo(BigDecimal.ZERO) != 0 ? nowList.get(0).getPamdh().subtract(lastYearList.get(0).getPamdh()).divide(lastYearList.get(0).getPamdh(), 4, BigDecimal.ROUND_HALF_UP).multiply(HUNDRED) : BigDecimal.ZERO)
|
|
|
- .annulus(CollectionUtil.isNotEmpty(nowList) && CollectionUtil.isNotEmpty(lastMonthList) && lastMonthList.get(0).getPamdh().compareTo(BigDecimal.ZERO) != 0 ? nowList.get(0).getPamdh().subtract(lastMonthList.get(0).getPamdh()).divide(lastMonthList.get(0).getPamdh(), 4, BigDecimal.ROUND_HALF_UP).multiply(HUNDRED) : BigDecimal.ZERO).build());
|
|
|
+ .annulus(CollectionUtil.isNotEmpty(nowList) && CollectionUtil.isNotEmpty(lastMonthList) && lastMonthList.get(0).getPamdh().compareTo(BigDecimal.ZERO) != 0 ? nowList.get(0).getPamdh().subtract(lastMonthList.get(0).getPamdh()).divide(lastMonthList.get(0).getPamdh(), 4, BigDecimal.ROUND_HALF_UP).multiply(HUNDRED) : BigDecimal.ZERO)
|
|
|
+ .build());
|
|
|
|
|
|
result.add(UnitCost.builder().name("复合盐").value(CollectionUtil.isNotEmpty(nowList) ? nowList.get(0).getFhydh() : BigDecimal.ZERO)
|
|
|
.yearOnYear(CollectionUtil.isNotEmpty(nowList) && CollectionUtil.isNotEmpty(lastYearList) && lastYearList.get(0).getFhydh().compareTo(BigDecimal.ZERO) != 0 ? nowList.get(0).getFhydh().subtract(lastYearList.get(0).getFhydh()).divide(lastYearList.get(0).getFhydh(), 4, BigDecimal.ROUND_HALF_UP).multiply(HUNDRED) : BigDecimal.ZERO)
|
|
|
- .annulus(CollectionUtil.isNotEmpty(nowList) && CollectionUtil.isNotEmpty(lastMonthList) && lastMonthList.get(0).getFhydh().compareTo(BigDecimal.ZERO) != 0 ? nowList.get(0).getFhydh().subtract(lastMonthList.get(0).getFhydh()).divide(lastMonthList.get(0).getFhydh(), 4, BigDecimal.ROUND_HALF_UP).multiply(HUNDRED) : BigDecimal.ZERO).build());
|
|
|
+ .annulus(CollectionUtil.isNotEmpty(nowList) && CollectionUtil.isNotEmpty(lastMonthList) && lastMonthList.get(0).getFhydh().compareTo(BigDecimal.ZERO) != 0 ? nowList.get(0).getFhydh().subtract(lastMonthList.get(0).getFhydh()).divide(lastMonthList.get(0).getFhydh(), 4, BigDecimal.ROUND_HALF_UP).multiply(HUNDRED) : BigDecimal.ZERO)
|
|
|
+ .build());
|
|
|
|
|
|
result.add(UnitCost.builder().name("活性炭").value(CollectionUtil.isNotEmpty(nowList) ? nowList.get(0).getFtdh() : BigDecimal.ZERO)
|
|
|
.yearOnYear(CollectionUtil.isNotEmpty(nowList) && CollectionUtil.isNotEmpty(lastYearList) && lastYearList.get(0).getFtdh().compareTo(BigDecimal.ZERO) != 0 ? nowList.get(0).getFtdh().subtract(lastYearList.get(0).getFtdh()).divide(lastYearList.get(0).getFtdh(), 4, BigDecimal.ROUND_HALF_UP).multiply(HUNDRED) : BigDecimal.ZERO)
|
|
|
- .annulus(CollectionUtil.isNotEmpty(nowList) && CollectionUtil.isNotEmpty(lastMonthList) && lastMonthList.get(0).getFtdh().compareTo(BigDecimal.ZERO) != 0 ? nowList.get(0).getFtdh().subtract(lastMonthList.get(0).getFtdh()).divide(lastMonthList.get(0).getFtdh(), 4, BigDecimal.ROUND_HALF_UP).multiply(HUNDRED) : BigDecimal.ZERO).build());
|
|
|
+ .annulus(CollectionUtil.isNotEmpty(nowList) && CollectionUtil.isNotEmpty(lastMonthList) && lastMonthList.get(0).getFtdh().compareTo(BigDecimal.ZERO) != 0 ? nowList.get(0).getFtdh().subtract(lastMonthList.get(0).getFtdh()).divide(lastMonthList.get(0).getFtdh(), 4, BigDecimal.ROUND_HALF_UP).multiply(HUNDRED) : BigDecimal.ZERO)
|
|
|
+ .build());
|
|
|
|
|
|
result.add(UnitCost.builder().name("制泥PAM").value(CollectionUtil.isNotEmpty(nowList) ? nowList.get(0).getPamwndh() : BigDecimal.ZERO)
|
|
|
.yearOnYear(CollectionUtil.isNotEmpty(nowList) && CollectionUtil.isNotEmpty(lastYearList) && lastYearList.get(0).getPamwndh().compareTo(BigDecimal.ZERO) != 0 ? nowList.get(0).getPamwndh().subtract(lastYearList.get(0).getPamwndh()).divide(lastYearList.get(0).getPamwndh(), 4, BigDecimal.ROUND_HALF_UP).multiply(HUNDRED) : BigDecimal.ZERO)
|
|
|
- .annulus(CollectionUtil.isNotEmpty(nowList) && CollectionUtil.isNotEmpty(lastMonthList) && lastMonthList.get(0).getPamwndh().compareTo(BigDecimal.ZERO) != 0 ? nowList.get(0).getPamwndh().subtract(lastMonthList.get(0).getPamwndh()).divide(lastMonthList.get(0).getPamwndh(), 4, BigDecimal.ROUND_HALF_UP).multiply(HUNDRED) : BigDecimal.ZERO).build());
|
|
|
+ .annulus(CollectionUtil.isNotEmpty(nowList) && CollectionUtil.isNotEmpty(lastMonthList) && lastMonthList.get(0).getPamwndh().compareTo(BigDecimal.ZERO) != 0 ? nowList.get(0).getPamwndh().subtract(lastMonthList.get(0).getPamwndh()).divide(lastMonthList.get(0).getPamwndh(), 4, BigDecimal.ROUND_HALF_UP).multiply(HUNDRED) : BigDecimal.ZERO)
|
|
|
+ .build());
|
|
|
|
|
|
result.add(UnitCost.builder().name("能耗").value(CollectionUtil.isNotEmpty(nowList) ? nowList.get(0).getNhdh() : BigDecimal.ZERO)
|
|
|
.yearOnYear(CollectionUtil.isNotEmpty(nowList) && CollectionUtil.isNotEmpty(lastYearList) && lastYearList.get(0).getNhdh().compareTo(BigDecimal.ZERO) != 0 ? nowList.get(0).getNhdh().subtract(lastYearList.get(0).getNhdh()).divide(lastYearList.get(0).getNhdh(), 4, BigDecimal.ROUND_HALF_UP).multiply(HUNDRED) : BigDecimal.ZERO)
|
|
|
- .annulus(CollectionUtil.isNotEmpty(nowList) && CollectionUtil.isNotEmpty(lastMonthList) && lastMonthList.get(0).getNhdh().compareTo(BigDecimal.ZERO) != 0 ? nowList.get(0).getNhdh().subtract(lastMonthList.get(0).getNhdh()).divide(lastMonthList.get(0).getNhdh(), 4, BigDecimal.ROUND_HALF_UP).multiply(HUNDRED) : BigDecimal.ZERO).build());
|
|
|
+ .annulus(CollectionUtil.isNotEmpty(nowList) && CollectionUtil.isNotEmpty(lastMonthList) && lastMonthList.get(0).getNhdh().compareTo(BigDecimal.ZERO) != 0 ? nowList.get(0).getNhdh().subtract(lastMonthList.get(0).getNhdh()).divide(lastMonthList.get(0).getNhdh(), 4, BigDecimal.ROUND_HALF_UP).multiply(HUNDRED) : BigDecimal.ZERO)
|
|
|
+ .build());
|
|
|
|
|
|
result.add(UnitCost.builder().name("自用水率").value(CollectionUtil.isNotEmpty(nowList) ? nowList.get(0).getZysl() : BigDecimal.ZERO)
|
|
|
.yearOnYear(CollectionUtil.isNotEmpty(nowList) && CollectionUtil.isNotEmpty(lastYearList) && lastYearList.get(0).getZysl().compareTo(BigDecimal.ZERO) != 0 ? nowList.get(0).getZysl().subtract(lastYearList.get(0).getZysl()).divide(lastYearList.get(0).getZysl(), 4, BigDecimal.ROUND_HALF_UP).multiply(HUNDRED) : BigDecimal.ZERO)
|
|
|
- .annulus(CollectionUtil.isNotEmpty(nowList) && CollectionUtil.isNotEmpty(lastMonthList) && lastMonthList.get(0).getZysl().compareTo(BigDecimal.ZERO) != 0 ? nowList.get(0).getZysl().subtract(lastMonthList.get(0).getZysl()).divide(lastMonthList.get(0).getZysl(), 4, BigDecimal.ROUND_HALF_UP).multiply(HUNDRED) : BigDecimal.ZERO).build());
|
|
|
+ .annulus(CollectionUtil.isNotEmpty(nowList) && CollectionUtil.isNotEmpty(lastMonthList) && lastMonthList.get(0).getZysl().compareTo(BigDecimal.ZERO) != 0 ? nowList.get(0).getZysl().subtract(lastMonthList.get(0).getZysl()).divide(lastMonthList.get(0).getZysl(), 4, BigDecimal.ROUND_HALF_UP).multiply(HUNDRED) : BigDecimal.ZERO)
|
|
|
+ .build());
|
|
|
return result;
|
|
|
}
|
|
|
|
|
@@ -575,10 +626,34 @@ public class CostOfWaterReportServiceImpl implements CostOfWaterReportService {
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ * 售水量-按行政类型统计
|
|
|
+ *
|
|
|
+ * @param startMonth 开始月份
|
|
|
+ * @param endMonth 结束月份
|
|
|
+ * @return list
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public List<AdminstrativeType> administrativeTypeCount(String startMonth, String endMonth) {
|
|
|
+ return costOfWaterReportMapper.administrativeTypeCount(startMonth, endMonth);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ * 售水量-按行政区域划分统计
|
|
|
+ *
|
|
|
+ * @param startMonth 开始月份
|
|
|
+ * @param endMonth 结束月份
|
|
|
+ * @return list
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public List<AdministrativeArea> administrativeAreaCount(String startMonth, String endMonth) {
|
|
|
+ return costOfWaterReportMapper.administrativeAreaCount(startMonth, endMonth);
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
|
- private MarketingStatisticsVo dateCompute(List<CountPlanValue> nowDataList, List<CountPlanValue> lastDataList, String yearMonth, Integer type, Boolean isSum) {
|
|
|
+ private MarketingStatisticsVo dateCompute(List<CountPlanValue> nowDataList, List<CountPlanValue> lastDataList, String startMonth,String endMonth, Integer type, Boolean isSum) {
|
|
|
if (type != null) {
|
|
|
nowDataList = nowDataList.stream().filter(c -> c.getTwoType().equals(type)).collect(Collectors.toList());
|
|
|
lastDataList = lastDataList.stream().filter(c -> c.getTwoType().equals(type)).collect(Collectors.toList());
|
|
@@ -613,10 +688,10 @@ public class CostOfWaterReportServiceImpl implements CostOfWaterReportService {
|
|
|
waterSoldYearPlan = BigDecimal.valueOf(waterSoldYearPlanCollect.stream().mapToDouble(c -> c.getPlanNumber().doubleValue()).average().getAsDouble()).setScale(4, BigDecimal.ROUND_HALF_UP);
|
|
|
}
|
|
|
}
|
|
|
- waterSoldMonthActualList = nowDataList.stream().filter(c -> c.getYearMonth().equals(yearMonth) && c.getActualNumber() != null).collect(Collectors.toList());
|
|
|
+ waterSoldMonthActualList = nowDataList.stream().filter(c ->c.getYearMonth().compareTo(startMonth) >= 0 && c.getYearMonth().compareTo(endMonth) <= 0 && c.getActualNumber() != null).collect(Collectors.toList());
|
|
|
|
|
|
- List<CountPlanValue> waterSoldSumActualValueCollect = nowDataList.stream().filter(c -> c.getYearMonth().compareTo(yearMonth) <= 0 && c.getActualNumber() != null).collect(Collectors.toList());
|
|
|
- List<CountPlanValue> waterSoldSumPlanValueCollect = nowDataList.stream().filter(c -> c.getYearMonth().compareTo(yearMonth) <= 0 && c.getActualNumber() != null).collect(Collectors.toList());
|
|
|
+ List<CountPlanValue> waterSoldSumActualValueCollect = nowDataList.stream().filter(c -> c.getYearMonth().compareTo(endMonth) <= 0 && c.getActualNumber() != null).collect(Collectors.toList());
|
|
|
+ List<CountPlanValue> waterSoldSumPlanValueCollect = nowDataList.stream().filter(c -> c.getYearMonth().compareTo(endMonth) <= 0 && c.getActualNumber() != null).collect(Collectors.toList());
|
|
|
|
|
|
if (CollectionUtil.isNotEmpty(waterSoldSumActualValueCollect)) {
|
|
|
if (isSum) {
|
|
@@ -636,7 +711,7 @@ public class CostOfWaterReportServiceImpl implements CostOfWaterReportService {
|
|
|
waterSoldDifference = waterSoldSumActualValue != null && waterSoldSumPlanValue != null ? waterSoldSumActualValue.subtract(waterSoldSumPlanValue) : null;
|
|
|
waterSoldDifferenceRate = waterSoldDifference != null ? waterSoldDifference.divide(waterSoldSumPlanValue, 4, BigDecimal.ROUND_HALF_UP).multiply(HUNDRED) : null;
|
|
|
|
|
|
- List<CountPlanValue> lastYearWaterSoldSumActualValueCollect = lastDataList.stream().filter(c -> c.getYearMonth().compareTo(yearMonth) <= 0 && c.getActualNumber() != null).collect(Collectors.toList());
|
|
|
+ List<CountPlanValue> lastYearWaterSoldSumActualValueCollect = lastDataList.stream().filter(c -> c.getYearMonth().compareTo(endMonth) <= 0 && c.getActualNumber() != null).collect(Collectors.toList());
|
|
|
if (CollectionUtil.isNotEmpty(lastYearWaterSoldSumActualValueCollect)) {
|
|
|
if (isSum) {
|
|
|
lastYearWaterSoldSumActualValue = BigDecimal.valueOf(lastYearWaterSoldSumActualValueCollect.stream().mapToDouble(c -> c.getActualNumber().doubleValue()).sum());
|
|
@@ -648,7 +723,8 @@ public class CostOfWaterReportServiceImpl implements CostOfWaterReportService {
|
|
|
lastYearWaterSoldDifferenceRate = lastYearWaterSoldDifference != null ? lastYearWaterSoldDifference.divide(lastYearWaterSoldSumActualValue, 4, BigDecimal.ROUND_HALF_UP).multiply(HUNDRED) : null;
|
|
|
|
|
|
return MarketingStatisticsVo.builder()
|
|
|
- .yearPlanNumber(waterSoldYearPlan).actualNumber(CollectionUtil.isNotEmpty(waterSoldMonthActualList) ? Objects.requireNonNull(waterSoldMonthActualList).get(0).getActualNumber() : null)
|
|
|
+ .yearPlanNumber(waterSoldYearPlan)
|
|
|
+ .actualNumber(waterSoldMonthActualList.stream().map(CountPlanValue::getActualNumber).filter(Objects::nonNull).reduce(BigDecimal.ZERO,BigDecimal::add))
|
|
|
.sumActualNumber(waterSoldSumActualValue).sumPlanNumber(waterSoldSumPlanValue)
|
|
|
.difference(waterSoldDifference).differenceRate(waterSoldDifferenceRate)
|
|
|
.lastYearSumActualNumber(lastYearWaterSoldSumActualValue).lastYearDifference(lastYearWaterSoldDifference)
|