| | |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.common.utils.poi.ExcelUtil; |
| | | import com.ruoyi.energy.dto.EnergyConsumptionDetailDto; |
| | | import com.ruoyi.energy.dto.EnergyConsumptionTypeDto; |
| | | import com.ruoyi.energy.dto.EnergyCostDto; |
| | | import com.ruoyi.energy.dto.EnergyStatisticsDto; |
| | | import com.ruoyi.energy.dto.*; |
| | | import com.ruoyi.energy.mapper.EnergyMapper; |
| | | import com.ruoyi.energy.pojo.Energy; |
| | | import com.ruoyi.energy.pojo.EnergyConsumptionDetail; |
| | |
| | | EnergyStatisticsDto energyStatisticsDto = new EnergyStatisticsDto(); |
| | | //计算总耗用量+总能耗费用 |
| | | Map<String, BigDecimal> map=energyConsumptionDetailMapper.calculateEnergy(energyStatisticsVo); |
| | | |
| | | energyStatisticsDto.setTotalEnergyConsumption(map.get("totalEnergyConsumption")); |
| | | energyStatisticsDto.setTotalEnergyCost(map.get("totalEnergyCost")); |
| | | //平均用量 |
| | |
| | | oldenergyStatisticsVo.setEndDate(masDays); |
| | | Map<String, BigDecimal> oldmap=energyConsumptionDetailMapper.calculateEnergy(oldenergyStatisticsVo); |
| | | if (ObjectUtils.isNotEmpty(oldmap)) { |
| | | BigDecimal changeVite = (map.get("totalEnergyConsumption").subtract(oldmap.get("totalEnergyConsumption"))).divide(oldmap.get("totalEnergyConsumption"), 4, RoundingMode.HALF_UP).multiply(new BigDecimal(100)); |
| | | BigDecimal subtract = map.get("totalEnergyConsumption").subtract(oldmap.get("totalEnergyConsumption")); |
| | | BigDecimal changeVite=BigDecimal.ZERO; |
| | | if (oldmap.get("totalEnergyConsumption").compareTo(BigDecimal.ZERO)>0){ |
| | | changeVite = (subtract).divide(oldmap.get("totalEnergyConsumption"), 4, RoundingMode.HALF_UP).multiply(new BigDecimal(100)); |
| | | } |
| | | energyStatisticsDto.setChangeVite(changeVite); |
| | | } |
| | | //能耗类型占比 |
| | |
| | | energyStatisticsDto.setEnergyCostDtos(energyCostDtos); |
| | | return energyStatisticsDto; |
| | | } |
| | | |
| | | @Override |
| | | public EnergyAccountDto account(EnergyStatisticsVo energyStatisticsVo) { |
| | | EnergyAccountDto energyAccountDto = new EnergyAccountDto(); |
| | | //计算总能耗成本+生产能耗成本+办公能耗成本 |
| | | Map<String, BigDecimal> map=energyConsumptionDetailMapper.calculateEnergy(energyStatisticsVo); |
| | | energyAccountDto.setTotalEnergyCost(map.get("totalEnergyCost"));//总能耗成本 |
| | | energyStatisticsVo.setType("生产"); |
| | | Map<String, BigDecimal> map1=energyConsumptionDetailMapper.calculateEnergy(energyStatisticsVo); |
| | | energyAccountDto.setProductEnergyCost(map1.get("totalEnergyCost"));//生产能耗成本 |
| | | energyStatisticsVo.setType("办公"); |
| | | Map<String, BigDecimal> map2=energyConsumptionDetailMapper.calculateEnergy(energyStatisticsVo); |
| | | energyAccountDto.setOfficeEnergyCost(map2.get("totalEnergyCost"));//办公能耗成本 |
| | | energyStatisticsVo.setType(null);//恢复查询全部 |
| | | //平均成本 |
| | | energyAccountDto.setAverageEnergyCost(energyAccountDto.getTotalEnergyCost().divide(new BigDecimal(energyStatisticsVo.getDays()),2, RoundingMode.HALF_UP)); |
| | | //能耗成本趋势 |
| | | List<EnergyAccountTypeDto> energyAccountTypeDtos=energyConsumptionDetailMapper.energyAccountTypeDtos(energyStatisticsVo); |
| | | energyAccountDto.setEnergyAccountTypeDtos(energyAccountTypeDtos); |
| | | //能耗类型成本占比 |
| | | List<EnergyConsumptionTypeDto> energyConsumptionTypeDtos=energyConsumptionDetailMapper.energyConsumptionTypeProportion(energyStatisticsVo); |
| | | energyAccountDto.setEnergyConsumptionTypeProportion(energyConsumptionTypeDtos); |
| | | //能耗类型明细 |
| | | List<EnergyConsumptionDetailDto> energyConsumptionDetailDtoList=energyConsumptionDetailMapper.energyConsumptionDetailDtos(energyStatisticsVo); |
| | | energyAccountDto.setEnergyConsumptionDetailDtoList(energyConsumptionDetailDtoList); |
| | | return energyAccountDto; |
| | | } |
| | | } |