|
|
|
@ -201,7 +201,7 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService {
|
|
|
|
|
return R.data("success"); |
|
|
|
|
} |
|
|
|
|
@Override |
|
|
|
|
public R exportHydropowerStationMonthReport(HttpServletResponse response, HashMap<String, Object> map, Integer year, Integer month, Long deptId,String deptName) { |
|
|
|
|
public R exportHydropowerStationMonthReport(HttpServletResponse response, HashMap<String, Object> map, Integer year, Integer month, Long deptId,String deptName) throws ParseException { |
|
|
|
|
R<List<Dept>> deptByCurrentUser = sysClient.getDeptByCurrentUser(); |
|
|
|
|
if (!deptByCurrentUser.isSuccess()||deptByCurrentUser.getData()==null){ |
|
|
|
|
return R.fail("用户权限查询失败"); |
|
|
|
@ -219,9 +219,9 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService {
|
|
|
|
|
List<StationEntity> stationEntityList = stationService.list(Wrappers.<StationEntity>lambdaQuery() |
|
|
|
|
.in(StationEntity::getRefDept, deptIds) |
|
|
|
|
.eq(StationEntity::getType, HomePageConstant.HYDROPOWER)); |
|
|
|
|
stationEntityList=Optional.ofNullable(stationEntityList).orElse(new ArrayList<>()).stream().filter(s->Func.isNotEmpty(s.getCommissionTime())).collect(Collectors.toList()); |
|
|
|
|
if (CollectionUtil.isNotEmpty(stationEntityList)) { |
|
|
|
|
int commissionTime = stationEntityList.stream().map(s -> { |
|
|
|
|
List<StationEntity> stationEntityListByCommissionTime=Optional.ofNullable(stationEntityList).orElse(new ArrayList<>()).stream().filter(s->Func.isNotEmpty(s.getCommissionTime())).collect(Collectors.toList()); |
|
|
|
|
if (CollectionUtil.isNotEmpty(stationEntityListByCommissionTime)) { |
|
|
|
|
int commissionTime = stationEntityListByCommissionTime.stream().map(s -> { |
|
|
|
|
Duration dur = Duration.between(s.getCommissionTime(), LocalDateTime.now()); |
|
|
|
|
return (int) dur.toDays(); |
|
|
|
|
}).reduce(Integer::max).get(); |
|
|
|
@ -236,10 +236,11 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService {
|
|
|
|
|
Integer yearBefore = year - 1; |
|
|
|
|
map.put("yearBefore", yearBefore); |
|
|
|
|
map.put("month", month); |
|
|
|
|
Integer monthBefore = month - 1; |
|
|
|
|
String monStartMonBefore = TimeUtils.getEarlyTime(yearBefore, month); |
|
|
|
|
String[] split = monStartMonBefore.split("-"); |
|
|
|
|
Integer monthBefore = Integer.valueOf(split[1]); |
|
|
|
|
map.put("monthBefore", monthBefore); |
|
|
|
|
// map.put("date", date);
|
|
|
|
|
|
|
|
|
|
map.put("stationName", deptName); |
|
|
|
|
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy年MM月dd日"); |
|
|
|
|
map.put("writeTime", simpleDateFormat.format(new Date())); |
|
|
|
@ -262,7 +263,6 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService {
|
|
|
|
|
// 今年当月
|
|
|
|
|
String monthStart = TimeUtils.getMonthStart(year, month); |
|
|
|
|
String monthEndV2 = TimeUtils.getMonthEndV2(year, month); |
|
|
|
|
|
|
|
|
|
List<HydropowerUnitRealVo> reals = (List<HydropowerUnitRealVo>) redisTemplate.opsForValue().get(load_hydropower_unit_real_key); |
|
|
|
|
List<HydropowerUnitRealVo> realsByDept = reals.stream().filter(s -> deptIds.contains(s.getDeptId())).collect(Collectors.toList()); |
|
|
|
|
// 装机容量占比数据组装
|
|
|
|
@ -294,6 +294,7 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService {
|
|
|
|
|
//装机容量占比图
|
|
|
|
|
ImageEntity capacityProportionChart = JFreeUtil.pieChartByDouble("水电项目装机容量占比图", capacityProportionMap, 500, 400); |
|
|
|
|
map.put("capacityProportionChart", capacityProportionChart); |
|
|
|
|
map.put("factoryComparisonChart", "---暂无数据---"); |
|
|
|
|
//各发电站发电量环比图+表格数据组装
|
|
|
|
|
List<MonPowerPercentageVo> powerPercentageVoList = getMonPowerPercentageVos(year, month, deptList, deptIds, stationEntityList, stationIds, yearBefore, monthBefore); |
|
|
|
|
// getPowerData(deptList, yearStart, yearEnd, yearBeforeStart, yearBeforeEnd, monthStart, monthEnd, beforeMonthStart, beforeMonthEnd, monthStartBeforeYear, monthEndBeforeYear, devices, planYearData, powerPercentageVoList);
|
|
|
|
@ -315,14 +316,21 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService {
|
|
|
|
|
for (MonPowerPercentageVo monPowerPercentageVo : powerPercentageVoList) { |
|
|
|
|
HashMap<String, String> power = new HashMap<>(); |
|
|
|
|
power.put("name", monPowerPercentageVo.getDeptName()); |
|
|
|
|
power.put("monthBefore", monPowerPercentageVo.getPowerMonBefore()+"MW"); |
|
|
|
|
power.put("month",monPowerPercentageVo.getPowerMon()+"MW"); |
|
|
|
|
power.put("monthBefore", monPowerPercentageVo.getPowerMonBefore()+"MkWh"); |
|
|
|
|
power.put("month",monPowerPercentageVo.getPowerMon()+"MkWh"); |
|
|
|
|
powerMap.add(power); |
|
|
|
|
} |
|
|
|
|
map.put("power", powerMap); |
|
|
|
|
String dateFormat=""; |
|
|
|
|
if (month<10){ |
|
|
|
|
dateFormat=year+"-"+"0"+month; |
|
|
|
|
}else { |
|
|
|
|
dateFormat=year+"-"+month; |
|
|
|
|
} |
|
|
|
|
//表格总计
|
|
|
|
|
List<PlanGenerationEntity> planYearAll = planGenertionClient.getPlanGenerationByParam(null, Collections.singletonList(deptId.toString()), year.toString()); |
|
|
|
|
List<PlanGenerationEntity> planMonAll = planGenertionClient.getPlanGenerationByParam(null, Collections.singletonList(deptId.toString()), year + "-" + month); |
|
|
|
|
List<String> deptIdsString = deptIds.stream().map(String::valueOf).collect(Collectors.toList()); |
|
|
|
|
List<PlanGenerationEntity> planYearAll = planGenertionClient.getPlanGenerationByParam(null, deptIdsString, year.toString()); |
|
|
|
|
List<PlanGenerationEntity> planMonAll = planGenertionClient.getPlanGenerationByParam(null, deptIdsString, dateFormat); |
|
|
|
|
getTabelSum(deptId, powerPercentageVoList, planYearAll, planMonAll, map); |
|
|
|
|
//发电情况统计表数据
|
|
|
|
|
ArrayList<HashMap<String, String>> list = new ArrayList<>(powerPercentageVoList.size()); |
|
|
|
@ -335,7 +343,7 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService {
|
|
|
|
|
temp.put("year", String.valueOf(monPowerPercentageVo.getPowerYear())); |
|
|
|
|
temp.put("monPercentage", monPowerPercentageVo.getPowerMonPercentage() * 100 + "%"); |
|
|
|
|
temp.put("yearPercentage", monPowerPercentageVo.getPowerYearPercentage() * 100 + "%"); |
|
|
|
|
temp.put("plan", monPowerPercentageVo.getPlanPercentage() * 100 + "%"); |
|
|
|
|
temp.put("plan", monPowerPercentageVo.getPlanPercentage()+ "%"); |
|
|
|
|
list.add(temp); |
|
|
|
|
} |
|
|
|
|
map.put("powerGeneration", list); |
|
|
|
@ -402,7 +410,7 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService {
|
|
|
|
|
//表格数据
|
|
|
|
|
HashMap<String, String> temp = new HashMap<>(); |
|
|
|
|
temp.put("deptName", "总计"); |
|
|
|
|
temp.put("checkLevel", "无等级"); |
|
|
|
|
temp.put("checkLevel", ""); |
|
|
|
|
temp.put("findShortagesMon", "0"); |
|
|
|
|
temp.put("shortagesMon", "0"); |
|
|
|
|
temp.put("findShortagesYear", "0"); |
|
|
|
@ -503,10 +511,12 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService {
|
|
|
|
|
int count = yearTicketCollect.size(); |
|
|
|
|
ticketChartCell.setTicketYear(count); |
|
|
|
|
List<Long> ticketIds = yearTicketCollect.stream().map(BaseEntity::getId).collect(Collectors.toList()); |
|
|
|
|
ticketChartCell.setTicketYearPassCount(0); |
|
|
|
|
R<Long> ticketPassCount = ticketInfoClient.getTicketPassByIds(ticketIds); |
|
|
|
|
if (ticketPassCount.isSuccess() && ticketPassCount.getData() != null && count != 0) { |
|
|
|
|
double ticketYearPerc = BigDecimal.valueOf(ticketPassCount.getData()).divide(BigDecimal.valueOf(count), 2, BigDecimal.ROUND_UP).doubleValue(); |
|
|
|
|
ticketChartCell.setTicketYeaPercr(ticketYearPerc); |
|
|
|
|
ticketChartCell.setTicketYearPassCount(ticketPassCount.getData().intValue()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if (CollectionUtils.isNotEmpty(monthTicketCollect)) { |
|
|
|
@ -514,10 +524,13 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService {
|
|
|
|
|
int count = monthTicketCollect.size(); |
|
|
|
|
ticketChartCell.setTicketMon(count); |
|
|
|
|
List<Long> monthTicketIds = monthTicketCollect.stream().map(BaseEntity::getId).collect(Collectors.toList()); |
|
|
|
|
//合格数量
|
|
|
|
|
R<Long> ticketMonthPassCount = ticketInfoClient.getTicketPassByIds(monthTicketIds); |
|
|
|
|
ticketChartCell.setTicketMonPassCount(0); |
|
|
|
|
if (ticketMonthPassCount.isSuccess() && ticketMonthPassCount.getData() != null && count != 0) { |
|
|
|
|
double ticketMonthPerc = BigDecimal.valueOf(ticketMonthPassCount.getData()).divide(BigDecimal.valueOf(count), 2, BigDecimal.ROUND_UP).doubleValue(); |
|
|
|
|
ticketChartCell.setTicketMonPerc(ticketMonthPerc); |
|
|
|
|
ticketChartCell.setTicketMonPassCount(ticketMonthPassCount.getData().intValue()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -536,9 +549,11 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService {
|
|
|
|
|
ticketChartCell.setTicketYear(count); |
|
|
|
|
List<Long> ticketIds = yearOperateCollect.stream().map(BaseEntity::getId).collect(Collectors.toList()); |
|
|
|
|
R<Long> ticketPassCount = ticketInfoClient.getTicketPassByIds(ticketIds); |
|
|
|
|
ticketChartCell.setTicketYearPassCount(0); |
|
|
|
|
if (ticketPassCount.isSuccess() && ticketPassCount.getData() != null && count != 0) { |
|
|
|
|
double ticketYearPerc = BigDecimal.valueOf(ticketPassCount.getData()).divide(BigDecimal.valueOf(count), 2, BigDecimal.ROUND_UP).doubleValue(); |
|
|
|
|
ticketChartCell.setTicketYeaPercr(ticketYearPerc); |
|
|
|
|
ticketChartCell.setTicketYearPassCount(ticketPassCount.getData().intValue()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if (CollectionUtils.isNotEmpty(monthOperateCollect)) { |
|
|
|
@ -547,9 +562,11 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService {
|
|
|
|
|
ticketChartCell.setTicketMon(count); |
|
|
|
|
List<Long> monthTicketIds = monthOperateCollect.stream().map(BaseEntity::getId).collect(Collectors.toList()); |
|
|
|
|
R<Long> ticketMonthPassCount = ticketInfoClient.getTicketPassByIds(monthTicketIds); |
|
|
|
|
ticketChartCell.setTicketMonPassCount(0); |
|
|
|
|
if (ticketMonthPassCount.isSuccess() && ticketMonthPassCount.getData() != null && count != 0) { |
|
|
|
|
double ticketMonthPerc = BigDecimal.valueOf(ticketMonthPassCount.getData()).divide(BigDecimal.valueOf(count), 2, BigDecimal.ROUND_UP).doubleValue(); |
|
|
|
|
ticketChartCell.setTicketMonPerc(ticketMonthPerc); |
|
|
|
|
ticketChartCell.setTicketMonPassCount(ticketMonthPassCount.getData().intValue()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -569,10 +586,20 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService {
|
|
|
|
|
sumCell.setTicketType(mapTicketChart.getKey()); |
|
|
|
|
sumCell.setTicketName(TicketConstants.TicketTypeNameEnum.getTicketNameByType(mapTicketChart.getKey())); |
|
|
|
|
List<TicketChartCell> ticketChartValue = mapTicketChart.getValue(); |
|
|
|
|
sumCell.setTicketMon(ticketChartValue.stream().mapToInt(TicketChartCell::getTicketMon).sum()); |
|
|
|
|
sumCell.setTicketYear(ticketChartValue.stream().mapToInt(TicketChartCell::getTicketYear).sum()); |
|
|
|
|
sumCell.setTicketMonPerc(ticketChartValue.stream().mapToDouble(TicketChartCell::getTicketMonPerc).sum()); |
|
|
|
|
sumCell.setTicketYeaPercr(ticketChartValue.stream().mapToDouble(TicketChartCell::getTicketYeaPercr).sum()); |
|
|
|
|
int sumTicketMon = ticketChartValue.stream().mapToInt(TicketChartCell::getTicketMon).sum(); |
|
|
|
|
sumCell.setTicketMon(sumTicketMon); |
|
|
|
|
int sumTicketYear = ticketChartValue.stream().mapToInt(TicketChartCell::getTicketYear).sum(); |
|
|
|
|
sumCell.setTicketYear(sumTicketYear); |
|
|
|
|
int sumTicketMonPass = ticketChartValue.stream().mapToInt(TicketChartCell::getTicketMonPassCount).sum(); |
|
|
|
|
int sumTicketYearPass = ticketChartValue.stream().mapToInt(TicketChartCell::getTicketYearPassCount).sum(); |
|
|
|
|
if (sumTicketMonPass>0&&sumTicketMon>0){ |
|
|
|
|
BigDecimal monPassPerc = new BigDecimal(sumTicketMonPass).divide(new BigDecimal(sumTicketMon), 2, BigDecimal.ROUND_UP); |
|
|
|
|
sumCell.setTicketMonPerc(monPassPerc.doubleValue()); |
|
|
|
|
} |
|
|
|
|
if (sumTicketYear>0&&sumTicketYearPass>0){ |
|
|
|
|
BigDecimal yearPassPerc = new BigDecimal(sumTicketYearPass).divide(new BigDecimal(sumTicketYear), 2, BigDecimal.ROUND_UP); |
|
|
|
|
sumCell.setTicketYeaPercr(yearPassPerc.doubleValue()); |
|
|
|
|
} |
|
|
|
|
sumCollect.add(sumCell); |
|
|
|
|
} |
|
|
|
|
TicketChartVo ticketChartVo = new TicketChartVo(); |
|
|
|
@ -621,6 +648,7 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService {
|
|
|
|
|
|
|
|
|
|
private List<MonPowerPercentageVo> getMonPowerPercentageVos(Integer year, Integer month, List<Dept> deptList, List<Long> deptIds, List<StationEntity> stationEntityList, List<Long> stationIds, Integer yearBefore, Integer monthBefore) { |
|
|
|
|
List<String> deptIdsString = deptIds.stream().map(String::valueOf).collect(Collectors.toList()); |
|
|
|
|
//年计划发电量
|
|
|
|
|
List<PlanGenerationEntity> planYearData = planGenertionClient.getPlanGenerationByParam(null, deptIdsString, year.toString()); |
|
|
|
|
List<MonPowerPercentageVo> powerPercentageVoList = new ArrayList<>(); |
|
|
|
|
//水电站,光伏站和带代运维数据近三年数据
|
|
|
|
@ -629,7 +657,8 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService {
|
|
|
|
|
List<String> listByYearBefore = TimeUtils.getListByYear(yearBefore); |
|
|
|
|
String monStart = TimeUtils.getMon(year, month); |
|
|
|
|
String monStartYearBefore = TimeUtils.getMon(yearBefore, month); |
|
|
|
|
String monStartMonBefore = TimeUtils.getMon(year, monthBefore); |
|
|
|
|
String monStartMonBefore = TimeUtils.getEarlyTime(yearBefore, month); |
|
|
|
|
// String monStartMonBefore = TimeUtils.getMon(year, monthBefore);
|
|
|
|
|
// 格式:站点-日期-发电量
|
|
|
|
|
for (Map.Entry<Long, Map<String, Float>> deviceMap : powerMapThree.entrySet()) { |
|
|
|
|
String deptNameByKey; |
|
|
|
@ -649,7 +678,7 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService {
|
|
|
|
|
Double planGeneration = 0d; |
|
|
|
|
List<PlanGenerationEntity> planGenerationById = planYearData.stream().filter(s -> collect.get(0).getRefDept().equals(s.getStationDeptId())).collect(Collectors.toList()); |
|
|
|
|
if (CollectionUtils.isNotEmpty(planGenerationById)) { |
|
|
|
|
planGeneration = Double.valueOf(planGenerationById.get(0).getPlanGeneration()); |
|
|
|
|
planGeneration = Double.valueOf(planGenerationById.stream().mapToDouble(PlanGenerationEntity::getPlanGeneration).sum()); |
|
|
|
|
} |
|
|
|
|
//当前机构近三年的数据
|
|
|
|
|
Map<String, Float> value = deviceMap.getValue(); |
|
|
|
@ -778,11 +807,12 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService {
|
|
|
|
|
private static void getTabelSum(Long deptId, List<MonPowerPercentageVo> powerPercentageVoList, List<PlanGenerationEntity> planYearAll, List<PlanGenerationEntity> planMonAll, HashMap<String, Object> map) { |
|
|
|
|
Float planGeneration = 0f; |
|
|
|
|
if (Func.isNotEmpty(planYearAll)) { |
|
|
|
|
planGeneration = planYearAll.get(0).getPlanGeneration(); |
|
|
|
|
planGeneration =Double.valueOf(planYearAll.stream().mapToDouble(PlanGenerationEntity::getPlanGeneration).sum()).floatValue() ; |
|
|
|
|
} |
|
|
|
|
Float planMonGeneration = 0f; |
|
|
|
|
if (Func.isNotEmpty(planMonAll)) { |
|
|
|
|
planMonGeneration = planMonAll.get(0).getPlanGeneration(); |
|
|
|
|
planMonGeneration =Double.valueOf(planMonAll.stream().mapToDouble(PlanGenerationEntity::getPlanGeneration).sum()).floatValue() ; |
|
|
|
|
// planMonGeneration = planMonAll.get(0).getPlanGeneration();
|
|
|
|
|
} |
|
|
|
|
MonPowerPercentageVo powerVo = new MonPowerPercentageVo(); |
|
|
|
|
powerVo.setDeptId(deptId); |
|
|
|
@ -803,7 +833,8 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService {
|
|
|
|
|
yearPercentage = (powerYear.subtract(powerYearBefore)).divide(powerYearBefore, 2, BigDecimal.ROUND_UP); |
|
|
|
|
} |
|
|
|
|
if (BigDecimal.valueOf(planGeneration).compareTo(BigDecimal.ZERO) != 0) { |
|
|
|
|
planPercentage = powerYear.divide(BigDecimal.valueOf(planGeneration), 2, BigDecimal.ROUND_UP); |
|
|
|
|
//因为计划发电量的单位是kwh,发电量已经转换为万kwh,再加上百分比转换所以需要乘以10000*100
|
|
|
|
|
planPercentage = powerYear.divide(BigDecimal.valueOf(planGeneration).divide(new BigDecimal(1000000)), 2, BigDecimal.ROUND_UP); |
|
|
|
|
// 年计划完成率
|
|
|
|
|
map.put("yearCompletionRate", planPercentage.toString()); |
|
|
|
|
} else { |
|
|
|
@ -820,7 +851,8 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService {
|
|
|
|
|
// 项目月计划完成量
|
|
|
|
|
BigDecimal planMonPercentage = new BigDecimal(0); |
|
|
|
|
if (powerMonth.compareTo(BigDecimal.ZERO) != 0 && BigDecimal.valueOf(planMonGeneration).compareTo(BigDecimal.ZERO) != 0) { |
|
|
|
|
planMonPercentage = powerMonth.divide(BigDecimal.valueOf(planMonGeneration), 2, BigDecimal.ROUND_UP); |
|
|
|
|
//因为计划发电量的单位是kwh,发电量已经转换为万kwh,再加上百分比转换所以需要乘以10000*100
|
|
|
|
|
planMonPercentage = powerMonth.divide(BigDecimal.valueOf(planMonGeneration).divide(new BigDecimal(1000000)), 2, BigDecimal.ROUND_UP); |
|
|
|
|
} |
|
|
|
|
map.put("monCompletionRate", planMonPercentage); |
|
|
|
|
BigDecimal powerMonthBefore = powerPercentageVoList.stream() |
|
|
|
|