net
2025-02-14 06d3d15a5a08637041cc601101c063b11b07a346
zhitan-system/src/main/java/com/zhitan/peakvalley/service/impl/PeakValleyServiceImpl.java
@@ -5,6 +5,8 @@
import com.zhitan.common.enums.ElectricityTypeEnum;
import com.zhitan.common.enums.TimeType;
import com.zhitan.common.utils.DateUtils;
import com.zhitan.costmanagement.domain.vo.CostPriceRelevancyVo;
import com.zhitan.costmanagement.mapper.CostPriceRelevancyMapper;
import com.zhitan.model.domain.vo.ModelNodeIndexInfor;
import com.zhitan.model.mapper.ModelNodeMapper;
import com.zhitan.peakvalley.domain.ElectricityDataItem;
@@ -35,7 +37,8 @@
    private ModelNodeMapper modelNodeMapper;
    @Resource
    private PeakValleyMapper electricityDataItemMapper;
    @Resource
    CostPriceRelevancyMapper costPriceRelevancyMapper;
    /**
     * 查询统计数据
@@ -131,14 +134,23 @@
        List<ModelNodeIndexInfor> nodeIndexInfoList = modelNodeMapper.selectIndexByModelCodeAndNodeId(dto.getModelCode(), dto.getNodeId());
        if (CollectionUtils.isNotEmpty(nodeIndexInfoList)) {
            Set<String> indexSet = nodeIndexInfoList.stream().map(ModelNodeIndexInfor::getIndexId).collect(Collectors.toSet());
            List<ElectricityDataItem> dataItemList = electricityDataItemMapper.getDataStatistics(indexSet, startTime, endTime, timeType);
            // 根据小时数据计算天的数据
            List<ElectricityDataItem> dataItemList = electricityDataItemMapper.getDataStatistics(indexSet, startTime, endTime, TimeType.HOUR.name());
            electricityDataMap = dataItemList.stream()
                    .collect(Collectors.groupingBy(li -> DateUtil.formatDateTime(li.getDataTime())));
        }
        while (!startTime.after(endTime)) {
            String mapKey = DateUtil.formatDateTime(startTime);
            List<ElectricityDataItem> dataItemList = electricityDataMap.get(mapKey);
            Date nextTime = DateUtil.offsetDay(startTime, 1);
            List<ElectricityDataItem> dataItemList = new ArrayList<>();
            for (Map.Entry<String, List<ElectricityDataItem>> entry : electricityDataMap.entrySet()) {
                String key = entry.getKey();
                if ((DateUtils.parseDate(key).after(startTime) || DateUtils.parseDate(key).equals(startTime)) && DateUtils.parseDate(key).before(nextTime)) {
                    List<ElectricityDataItem> list = entry.getValue();
                    dataItemList.addAll(list);
                }
            }
            BigDecimal sharpFee = BigDecimal.ZERO;
            BigDecimal sharpPower = BigDecimal.ZERO;
@@ -199,11 +211,11 @@
        AtomicReference<BigDecimal> tipCount = new AtomicReference<>(BigDecimal.ZERO);
        AtomicReference<BigDecimal> troughCount = new AtomicReference<>(BigDecimal.ZERO);
        AtomicReference<BigDecimal> peakCount = new AtomicReference<>(BigDecimal.ZERO);
        reportVOList.stream().forEach(r->{
            PeakValleyLineChatVO costVO = new PeakValleyLineChatVO();
            PeakValleyLineChatVO powerConsumptionVO = new PeakValleyLineChatVO();
            /**
             * 用电量
             */
@@ -243,7 +255,7 @@
            peakFreeCount.set(peakFreeCount.get().add(r.getPeakFee()));
        });
        peakValleyDayTotalVO.setPeakPowerCost(peakFreeCount.get().doubleValue());
        peakValleyDayTotalVO.setPeakPowerCost(peakFreeCount.get().doubleValue());
        peakValleyDayTotalVO.setPeakPowerConsumption(peakCount.get().doubleValue());
        peakValleyDayTotalVO.setFlatPowerCost(flatFreeCount.get().doubleValue());
        peakValleyDayTotalVO.setFlatPowerConsumption(flatCount.get().doubleValue());
@@ -277,13 +289,15 @@
            peakValleyDayTotalVO.setTipPowerCostProportion(0);
            peakValleyDayTotalVO.setTroughPowerCostProportion(0);
        }
        peakValleyDayTotalVO.setTotalCost(powerTotal.doubleValue());
        peakValleyDayTotalVO.setTotalPowerConsumption(freeTotal.doubleValue());
//        peakValleyDayTotalVO.setTotalCost(powerTotal.doubleValue());
//        peakValleyDayTotalVO.setTotalPowerConsumption(freeTotal.doubleValue());
        peakValleyDayTotalVO.setTotalCost(freeTotal.doubleValue());
        peakValleyDayTotalVO.setTotalPowerConsumption(powerTotal.doubleValue());
        peakValleyVO.setTotalVO(peakValleyDayTotalVO);
        peakValleyVO.setCostList(costList);
        peakValleyVO.setPowerConsumptionList(powerConsumptionList);
        return peakValleyVO;
    }
@@ -472,4 +486,9 @@
       return reportVOList;
    }
    @Override
    public PeakValleyDayVO segmentAnalysisDayCustomize(PeakValleyDTO dto) {
        return null;
    }
}