|
|
@ -1,7 +1,6 @@ |
|
|
|
package com.hnac.hzims.electric.service.impl; |
|
|
|
package com.hnac.hzims.electric.service.impl; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.io.unit.DataUnit; |
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
import com.alibaba.fastjson.TypeReference; |
|
|
|
import com.alibaba.fastjson.TypeReference; |
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
@ -32,6 +31,8 @@ import org.springblade.system.feign.ISysClient; |
|
|
|
import org.springframework.data.redis.core.RedisTemplate; |
|
|
|
import org.springframework.data.redis.core.RedisTemplate; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.math.BigDecimal; |
|
|
|
|
|
|
|
import java.math.RoundingMode; |
|
|
|
import java.time.LocalDateTime; |
|
|
|
import java.time.LocalDateTime; |
|
|
|
import java.time.format.DateTimeFormatter; |
|
|
|
import java.time.format.DateTimeFormatter; |
|
|
|
import java.util.*; |
|
|
|
import java.util.*; |
|
|
@ -134,14 +135,82 @@ public class ElectricReportServiceImpl implements IElectricReportService { |
|
|
|
Date finish = calendar.getTime(); |
|
|
|
Date finish = calendar.getTime(); |
|
|
|
calendar.add(Calendar.YEAR,-1); |
|
|
|
calendar.add(Calendar.YEAR,-1); |
|
|
|
Date current = calendar.getTime(); |
|
|
|
Date current = calendar.getTime(); |
|
|
|
|
|
|
|
// fixme 随机器模拟数据
|
|
|
|
|
|
|
|
Random random = new Random(); |
|
|
|
|
|
|
|
List<ComprehensiveElectricVo> electrics = new ArrayList<>(); |
|
|
|
while (current.compareTo(finish) < 0){ |
|
|
|
while (current.compareTo(finish) < 0){ |
|
|
|
|
|
|
|
ComprehensiveElectricVo comprehensive = new ComprehensiveElectricVo(); |
|
|
|
|
|
|
|
comprehensive.setMonth(current.getMonth() + 1 + "月"); |
|
|
|
|
|
|
|
String currentMon = DateUtil.format(calendar.getTime(),"yyyy-MM"); |
|
|
|
|
|
|
|
String currentYear = DateUtil.format(calendar.getTime(),"yyyy"); |
|
|
|
|
|
|
|
calendar.add(Calendar.YEAR,-1); |
|
|
|
|
|
|
|
String lastMon = DateUtil.format(calendar.getTime(),"yyyy-MM"); |
|
|
|
|
|
|
|
String lastYear = DateUtil.format(calendar.getTime(),"yyyy"); |
|
|
|
|
|
|
|
calendar.add(Calendar.YEAR,1); |
|
|
|
|
|
|
|
// 电量
|
|
|
|
|
|
|
|
if(CollectionUtil.isNotEmpty(threes)){ |
|
|
|
|
|
|
|
comprehensive.setMonthGenerate(threes.stream().filter(o->o.getStrMonth().contains(currentMon)).mapToDouble(o->o.getGenerate().doubleValue()).sum()); |
|
|
|
|
|
|
|
comprehensive.setLastMonthGenerate(threes.stream().filter(o->o.getStrMonth().contains(lastMon)).mapToDouble(o->o.getGenerate().doubleValue()).sum()); |
|
|
|
|
|
|
|
if(comprehensive.getMonthGenerate() > 0 && comprehensive.getLastMonthGenerate() > 0){ |
|
|
|
|
|
|
|
comprehensive.setLastMonthGenerateRate(BigDecimal.valueOf(comprehensive.getMonthGenerate() / comprehensive.getLastMonthGenerate() * 100).setScale(2, RoundingMode.HALF_UP).doubleValue()); |
|
|
|
|
|
|
|
}else{ |
|
|
|
|
|
|
|
comprehensive.setLastMonthGenerateRate(0.0); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// 本月等效小时
|
|
|
|
|
|
|
|
if(comprehensive.getMonthGenerate() > 0){ |
|
|
|
|
|
|
|
comprehensive.setMonthEquivalent(BigDecimal.valueOf(comprehensive.getMonthGenerate() / installedCapacity).setScale(2, RoundingMode.HALF_UP).doubleValue()); |
|
|
|
|
|
|
|
}else{ |
|
|
|
|
|
|
|
comprehensive.setMonthEquivalent(0.0); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// 去年同月等效小时
|
|
|
|
|
|
|
|
if(comprehensive.getLastMonthGenerate() > 0){ |
|
|
|
|
|
|
|
comprehensive.setLastMonthEquivalent(BigDecimal.valueOf(comprehensive.getLastMonthGenerate() / installedCapacity).setScale(2, RoundingMode.HALF_UP).doubleValue()); |
|
|
|
|
|
|
|
}else{ |
|
|
|
|
|
|
|
comprehensive.setLastMonthEquivalent(0.0); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
comprehensive.setYearGenerate(threes.stream().filter(o->o.getStrMonth().contains(currentYear)).mapToDouble(o->o.getGenerate().doubleValue()).sum()); |
|
|
|
|
|
|
|
comprehensive.setLastYearGenerate(threes.stream().filter(o->o.getStrMonth().contains(lastYear)).mapToDouble(o->o.getGenerate().doubleValue()).sum()); |
|
|
|
|
|
|
|
if(comprehensive.getYearGenerate() > 0 && comprehensive.getLastYearGenerate() > 0){ |
|
|
|
|
|
|
|
comprehensive.setLastYearGenerateRate(BigDecimal.valueOf(comprehensive.getYearGenerate() / comprehensive.getLastYearGenerate() * 100).setScale(2, RoundingMode.HALF_UP).doubleValue()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if(CollectionUtil.isEmpty(electrics)){ |
|
|
|
|
|
|
|
// 本年等效小时
|
|
|
|
|
|
|
|
comprehensive.setYearEquivalent(comprehensive.getMonthEquivalent()); |
|
|
|
|
|
|
|
// 去年同期等效小时
|
|
|
|
|
|
|
|
comprehensive.setLastYearEquivalent(comprehensive.getLastMonthEquivalent()); |
|
|
|
|
|
|
|
}else{ |
|
|
|
|
|
|
|
// 累计等效小时
|
|
|
|
|
|
|
|
comprehensive.setYearEquivalent(electrics.stream().mapToDouble(ComprehensiveElectricVo::getMonthEquivalent).sum() + comprehensive.getMonthEquivalent()); |
|
|
|
|
|
|
|
comprehensive.setLastYearEquivalent(electrics.stream().mapToDouble(ComprehensiveElectricVo::getLastMonthEquivalent).sum() + comprehensive.getLastMonthEquivalent()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}else{ |
|
|
|
|
|
|
|
comprehensive.setMonthGenerate(0.0); |
|
|
|
|
|
|
|
comprehensive.setLastMonthGenerate(0.0); |
|
|
|
|
|
|
|
comprehensive.setYearGenerate(0.0); |
|
|
|
|
|
|
|
comprehensive.setLastYearGenerate(0.0); |
|
|
|
|
|
|
|
comprehensive.setLastMonthGenerateRate(0.0); |
|
|
|
|
|
|
|
comprehensive.setLastYearGenerateRate(0.0); |
|
|
|
|
|
|
|
comprehensive.setMonthEquivalent(0.0); |
|
|
|
|
|
|
|
comprehensive.setLastMonthEquivalent(0.0); |
|
|
|
|
|
|
|
comprehensive.setYearEquivalent(0.0); |
|
|
|
|
|
|
|
comprehensive.setLastYearEquivalent(0.0); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// 降雨 : fixme 模拟降雨
|
|
|
|
|
|
|
|
comprehensive.setMonthRain(BigDecimal.valueOf(random.nextDouble() * 10 * 8).setScale(2, RoundingMode.HALF_UP).doubleValue()); |
|
|
|
|
|
|
|
comprehensive.setLastMonthRain(BigDecimal.valueOf(random.nextDouble() * 10 * 8).setScale(2, RoundingMode.HALF_UP).doubleValue()); |
|
|
|
|
|
|
|
if(CollectionUtil.isEmpty(electrics)){ |
|
|
|
|
|
|
|
comprehensive.setYearRain(comprehensive.getMonthRain()); |
|
|
|
|
|
|
|
comprehensive.setLastYearRain(comprehensive.getLastMonthRain()); |
|
|
|
|
|
|
|
}else{ |
|
|
|
|
|
|
|
// 累计降雨
|
|
|
|
|
|
|
|
comprehensive.setYearRain(electrics.stream().mapToDouble(ComprehensiveElectricVo::getMonthRain).sum() + comprehensive.getMonthRain()); |
|
|
|
|
|
|
|
comprehensive.setLastYearRain(electrics.stream().mapToDouble(ComprehensiveElectricVo::getLastMonthRain).sum() + comprehensive.getLastMonthRain()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
electrics.add(comprehensive); |
|
|
|
calendar.add(Calendar.MONTH,1); |
|
|
|
calendar.add(Calendar.MONTH,1); |
|
|
|
current = calendar.getTime(); |
|
|
|
current = calendar.getTime(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return electrics; |
|
|
|
return null; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|