Browse Source

修正:统计月报发电量单位转换为万

(cherry picked from commit 7ab75635d2)
zhongwei
ty 7 months ago
parent
commit
1f880d68e9
  1. 36
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/MainSystemMonitoringServiceImpl.java
  2. 45
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/service/impl/OperStationMonthReportServiceImpl.java
  3. 7
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/util/ObjectUtils.java

36
hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/MainSystemMonitoringServiceImpl.java

@ -64,6 +64,8 @@ import java.util.*;
import java.util.concurrent.atomic.AtomicReference; import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import static com.hnac.hzims.operational.util.ObjectUtils.objDivide;
@Service @Service
@Slf4j @Slf4j
@RequiredArgsConstructor @RequiredArgsConstructor
@ -1369,37 +1371,37 @@ public class MainSystemMonitoringServiceImpl implements IMainSystemMonitoringSer
Map<String, Float> value = deviceMap.getValue(); Map<String, Float> value = deviceMap.getValue();
//当月发电量 //当月发电量
BigDecimal powerMon = value.entrySet().stream().filter(s -> currentMon.equals(s.getKey())).map(s -> BigDecimal.valueOf(s.getValue()).setScale(1, RoundingMode.UP)).reduce(BigDecimal.ZERO, BigDecimal::add); BigDecimal powerMon = value.entrySet().stream().filter(s -> currentMon.equals(s.getKey())).map(s -> BigDecimal.valueOf(s.getValue()).setScale(1, RoundingMode.UP)).reduce(BigDecimal.ZERO, BigDecimal::add);
stationReportVO.setFinishPowerMon(powerMon.toString()); stationReportVO.setFinishPowerMon(objDivide(String.valueOf(powerMon)).toString());
//获取计划月发电量 //获取计划月发电量
R<Float> planPowerMonR = planGenertionClient.planGenerationMonthCount(stationEntity.getCode(), month); R<Float> planPowerMonR = planGenertionClient.planGenerationMonthCount(stationEntity.getCode(), month);
double planPowerMon =0; double planPowerMon =0;
if (planPowerMonR.isSuccess()&&ObjectUtil.isNotEmpty(planPowerMonR.getData())) { if (planPowerMonR.isSuccess()&&ObjectUtil.isNotEmpty(planPowerMonR.getData())) {
planPowerMon = planPowerMonR.getData().doubleValue(); planPowerMon = planPowerMonR.getData().doubleValue();
} }
stationReportVO.setPowerMonPlan(planPowerMon); stationReportVO.setPowerMonPlan(objDivide(String.valueOf(planPowerMon)).doubleValue());
//当年发电量 //当年发电量
BigDecimal powerYear = value.entrySet().stream().filter(s -> listByYear.contains(s.getKey())).map(s -> BigDecimal.valueOf(s.getValue()).setScale(1, RoundingMode.UP)).reduce(BigDecimal.ZERO, BigDecimal::add); BigDecimal powerYear = value.entrySet().stream().filter(s -> listByYear.contains(s.getKey())).map(s -> BigDecimal.valueOf(s.getValue()).setScale(1, RoundingMode.UP)).reduce(BigDecimal.ZERO, BigDecimal::add);
stationReportVO.setFinishPowerYear(powerYear.toString()); stationReportVO.setFinishPowerYear(objDivide(String.valueOf(powerYear)).toString());
//获取计划年发电量 //获取计划年发电量
Double planPowerYear = planGenertionClient.getPlanPowerYear(Collections.singletonList(stationEntity.getId().toString()), yearMon[0]); Double planPowerYear = planGenertionClient.getPlanPowerYear(Collections.singletonList(stationEntity.getCode()), yearMon[0]);
stationReportVO.setPowerYearPlan(planPowerYear); stationReportVO.setPowerYearPlan(objDivide(String.valueOf(planPowerYear)).doubleValue());
if (ObjectUtil.isNotEmpty(stationReportVO.getPowerMonPlan()) if (ObjectUtil.isNotEmpty(stationReportVO.getPowerMonPlan())
&&ObjectUtil.isNotEmpty(stationReportVO.getFinishPowerMon()) &&ObjectUtil.isNotEmpty(stationReportVO.getFinishPowerMon())
&& BigDecimal.valueOf(stationReportVO.getPowerMonPlan()).compareTo(BigDecimal.ZERO)!=0){ && BigDecimal.valueOf(stationReportVO.getPowerMonPlan()).compareTo(BigDecimal.ZERO)!=0){
BigDecimal monRate = new BigDecimal(stationReportVO.getFinishPowerMon()).multiply(new BigDecimal(100)) BigDecimal monRate = new BigDecimal(stationReportVO.getFinishPowerMon()).multiply(new BigDecimal(100))
.divide(BigDecimal.valueOf(stationReportVO.getPowerMonPlan()), 2, RoundingMode.UP); .divide(BigDecimal.valueOf(stationReportVO.getPowerMonPlan()), 2, RoundingMode.UP);
stationReportVO.setPowerMonRate(monRate.doubleValue()+"%"); stationReportVO.setPowerMonRate(String.valueOf(monRate.doubleValue()));
}else { }else {
stationReportVO.setPowerMonRate(new Double(0)+"%"); stationReportVO.setPowerMonRate(new Double(0).toString());
} }
if (ObjectUtil.isNotEmpty(stationReportVO.getFinishPowerYear()) if (ObjectUtil.isNotEmpty(stationReportVO.getFinishPowerYear())
&&ObjectUtil.isNotEmpty(stationReportVO.getPowerYearPlan()) &&ObjectUtil.isNotEmpty(stationReportVO.getPowerYearPlan())
&& BigDecimal.valueOf(stationReportVO.getPowerYearPlan()).compareTo(BigDecimal.ZERO)!=0){ && BigDecimal.valueOf(stationReportVO.getPowerYearPlan()).compareTo(BigDecimal.ZERO)!=0){
BigDecimal yearRate = new BigDecimal(stationReportVO.getFinishPowerYear()).multiply(new BigDecimal(100)) BigDecimal yearRate = new BigDecimal(stationReportVO.getFinishPowerYear()).multiply(new BigDecimal(100))
.divide(BigDecimal.valueOf(stationReportVO.getPowerYearPlan()), 2, RoundingMode.UP); .divide(BigDecimal.valueOf(stationReportVO.getPowerYearPlan()), 2, RoundingMode.UP);
stationReportVO.setPowerYearRate(yearRate.doubleValue()+"%"); stationReportVO.setPowerYearRate(String.valueOf(yearRate.doubleValue()));
}else { }else {
stationReportVO.setPowerYearRate(new Double(0)+"%"); stationReportVO.setPowerYearRate(new Double(0).toString());
} }
reportVOS.add(stationReportVO); reportVOS.add(stationReportVO);
} }
@ -1474,33 +1476,33 @@ public class MainSystemMonitoringServiceImpl implements IMainSystemMonitoringSer
} }
} }
Double finishPowerMon = BigDecimal.valueOf(powerCount.get()).doubleValue(); Double finishPowerMon = BigDecimal.valueOf(powerCount.get()).doubleValue();
stationReportVO.setFinishPowerMon(finishPowerMon.toString()); stationReportVO.setFinishPowerMon(objDivide(String.valueOf(finishPowerMon)).toString());
Double finishPowerYear = BigDecimal.valueOf(powerCountYear.get()).doubleValue(); Double finishPowerYear = BigDecimal.valueOf(powerCountYear.get()).doubleValue();
stationReportVO.setFinishPowerYear(finishPowerYear.toString()); stationReportVO.setFinishPowerYear(objDivide(String.valueOf(finishPowerYear)).toString());
//当年的计划发电量 //当年的计划发电量
Double planPowerYear = planGenertionClient.getPlanPowerYear(Collections.singletonList(stationId), year); Double planPowerYear = planGenertionClient.getPlanPowerYear(Collections.singletonList(stationId), year);
stationReportVO.setPowerYearPlan(planPowerYear); stationReportVO.setPowerYearPlan(objDivide(String.valueOf(planPowerYear)).doubleValue());
//当月的计划发电量 //当月的计划发电量
R<Float> planPowerMonR = planGenertionClient.planGenerationMonthCount(stationId, month); R<Float> planPowerMonR = planGenertionClient.planGenerationMonthCount(stationId, month);
Double planPowerMon = planPowerMonR.getData().doubleValue(); Double planPowerMon = planPowerMonR.getData().doubleValue();
stationReportVO.setPowerMonPlan(planPowerMon); stationReportVO.setPowerMonPlan(objDivide(String.valueOf(planPowerMon)).doubleValue());
if (ObjectUtil.isNotEmpty(stationReportVO.getPowerMonPlan()) if (ObjectUtil.isNotEmpty(stationReportVO.getPowerMonPlan())
&&ObjectUtil.isNotEmpty(stationReportVO.getFinishPowerMon()) &&ObjectUtil.isNotEmpty(stationReportVO.getFinishPowerMon())
&& BigDecimal.valueOf(stationReportVO.getPowerMonPlan()).compareTo(BigDecimal.ZERO)!=0){ && BigDecimal.valueOf(stationReportVO.getPowerMonPlan()).compareTo(BigDecimal.ZERO)!=0){
BigDecimal monRate = new BigDecimal(stationReportVO.getFinishPowerMon()).multiply(new BigDecimal(100)) BigDecimal monRate = new BigDecimal(stationReportVO.getFinishPowerMon()).multiply(new BigDecimal(100))
.divide(BigDecimal.valueOf(stationReportVO.getPowerMonPlan()), 2, RoundingMode.UP); .divide(BigDecimal.valueOf(stationReportVO.getPowerMonPlan()), 2, RoundingMode.UP);
stationReportVO.setPowerMonRate(monRate.doubleValue()+"%"); stationReportVO.setPowerMonRate(String.valueOf(monRate.doubleValue()));
}else { }else {
stationReportVO.setPowerMonRate(new Double(0)+"%"); stationReportVO.setPowerMonRate(new Double(0).toString());
} }
if (ObjectUtil.isNotEmpty(stationReportVO.getFinishPowerYear()) if (ObjectUtil.isNotEmpty(stationReportVO.getFinishPowerYear())
&&ObjectUtil.isNotEmpty(stationReportVO.getPowerYearPlan()) &&ObjectUtil.isNotEmpty(stationReportVO.getPowerYearPlan())
&& BigDecimal.valueOf(stationReportVO.getPowerYearPlan()).compareTo(BigDecimal.ZERO)!=0){ && BigDecimal.valueOf(stationReportVO.getPowerYearPlan()).compareTo(BigDecimal.ZERO)!=0){
BigDecimal yearRate = new BigDecimal(stationReportVO.getFinishPowerYear()).multiply(new BigDecimal(100)) BigDecimal yearRate = new BigDecimal(stationReportVO.getFinishPowerYear()).multiply(new BigDecimal(100))
.divide(BigDecimal.valueOf(stationReportVO.getPowerYearPlan()), 2, RoundingMode.UP); .divide(BigDecimal.valueOf(stationReportVO.getPowerYearPlan()), 2, RoundingMode.UP);
stationReportVO.setPowerYearRate(yearRate.doubleValue()+"%"); stationReportVO.setPowerYearRate(String.valueOf(yearRate.doubleValue()));
}else { }else {
stationReportVO.setPowerYearRate(new Double(0)+"%"); stationReportVO.setPowerYearRate(new Double(0).toString());
} }
stationReportVOList.add(stationReportVO); stationReportVOList.add(stationReportVO);
return stationReportVOList; return stationReportVOList;

45
hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/service/impl/OperStationMonthReportServiceImpl.java

@ -57,6 +57,7 @@ import org.springblade.system.vo.DeptVO;
import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.ClassPathResource;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.Assert; import org.springframework.util.Assert;
import org.springframework.util.ObjectUtils;
import org.springframework.web.context.request.RequestAttributes; import org.springframework.web.context.request.RequestAttributes;
import org.springframework.web.context.request.RequestContextHolder; import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes; import org.springframework.web.context.request.ServletRequestAttributes;
@ -349,6 +350,7 @@ public class OperStationMonthReportServiceImpl implements IOperStationMonthRepor
reportVOS.addAll(stationReportVOList); reportVOS.addAll(stationReportVOList);
}); });
} }
getSumStationRunReport(reportVOS);
stationReportAllVo.setStationReportVOList(reportVOS); stationReportAllVo.setStationReportVOList(reportVOS);
}catch (Exception e){ }catch (Exception e){
log.error("", e); log.error("", e);
@ -510,6 +512,49 @@ public class OperStationMonthReportServiceImpl implements IOperStationMonthRepor
return stationReportAllVo; return stationReportAllVo;
} }
private static void getSumStationRunReport(List<StationRunReportVO> reportVOS) {
//合计
StationRunReportVO stationRunReportVO=new StationRunReportVO();
stationRunReportVO.setStationName("合计");
if (CollectionUtil.isNotEmpty(reportVOS)){
double sumPowerMonPlan = reportVOS.stream().mapToDouble(StationRunReportVO::getPowerMonPlan).sum();
stationRunReportVO.setPowerMonPlan(sumPowerMonPlan);
double sumFinishPowerMon = reportVOS.stream().map(StationRunReportVO::getFinishPowerMon).mapToDouble(s -> Double.valueOf(s)).sum();
stationRunReportVO.setFinishPowerMon(String.valueOf(sumFinishPowerMon));
if (!ObjectUtils.isEmpty(sumPowerMonPlan)) {
BigDecimal powerMonRate = new BigDecimal(sumFinishPowerMon).divide(new BigDecimal(sumPowerMonPlan)).setScale(2, BigDecimal.ROUND_UP);
stationRunReportVO.setPowerMonRate(String.valueOf(powerMonRate));
}else {
stationRunReportVO.setPowerMonRate("0.0");
}
double sumPowerYearPlan = reportVOS.stream().mapToDouble(StationRunReportVO::getPowerYearPlan).sum();
stationRunReportVO.setPowerYearPlan(sumPowerYearPlan);
double sumFinishPowerYear = reportVOS.stream().map(StationRunReportVO::getFinishPowerYear).mapToDouble(s -> Double.valueOf(s)).sum();
stationRunReportVO.setFinishPowerYear(String.valueOf(sumFinishPowerYear));
if (!ObjectUtils.isEmpty(sumPowerYearPlan)){
BigDecimal powerYearRate = new BigDecimal(sumFinishPowerYear).divide(new BigDecimal(sumPowerYearPlan)).setScale(2, BigDecimal.ROUND_UP);
stationRunReportVO.setPowerYearRate(String.valueOf(powerYearRate));
}else {
stationRunReportVO.setPowerYearRate("0.0");
}
stationRunReportVO.setIndex(reportVOS.size()+1);
}else {
stationRunReportVO.setPowerMonPlan(0.0d);
stationRunReportVO.setFinishPowerMon("0.0");
stationRunReportVO.setPowerYearPlan(0.0d);
stationRunReportVO.setFinishPowerYear("0.0");
stationRunReportVO.setPowerMonRate("0.0");
stationRunReportVO.setPowerYearRate("0.0");
stationRunReportVO.setIndex(1);
}
reportVOS.add(stationRunReportVO);
reportVOS = reportVOS.stream().map(s -> {
s.setPowerMonRate(s.getPowerMonRate()+"%");
s.setPowerYearRate(s.getPowerYearRate()+"%");
return s;
}).collect(Collectors.toList());
}
/** /**
* 导出统计月报 * 导出统计月报
* @param response * @param response

7
hzims-service/operational/src/main/java/com/hnac/hzims/operational/util/ObjectUtils.java

@ -10,6 +10,7 @@ import org.springblade.system.user.cache.UserCache;
import org.springblade.system.user.entity.User; import org.springblade.system.user.entity.User;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.math.BigDecimal;
import java.util.*; import java.util.*;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -81,4 +82,10 @@ public class ObjectUtils {
} }
return result; return result;
} }
public static BigDecimal objDivide(String s){
BigDecimal bigDecimal = new BigDecimal(s);
BigDecimal res = bigDecimal.divide(new BigDecimal(10000)).setScale(2, BigDecimal.ROUND_UP);
return res;
}
} }

Loading…
Cancel
Save