|
|
@ -1,6 +1,8 @@ |
|
|
|
package com.hnac.hzims.electric.service.impl; |
|
|
|
package com.hnac.hzims.electric.service.impl; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
|
|
|
|
import com.alibaba.fastjson.TypeReference; |
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
|
import com.hnac.hzims.common.logs.utils.StringUtils; |
|
|
|
import com.hnac.hzims.common.logs.utils.StringUtils; |
|
|
|
import com.hnac.hzims.electric.entity.ThirtyEntity; |
|
|
|
import com.hnac.hzims.electric.entity.ThirtyEntity; |
|
|
@ -8,17 +10,15 @@ import com.hnac.hzims.electric.entity.ThreeEntity; |
|
|
|
import com.hnac.hzims.electric.service.IElectricReportService; |
|
|
|
import com.hnac.hzims.electric.service.IElectricReportService; |
|
|
|
import com.hnac.hzims.electric.service.ThirtyService; |
|
|
|
import com.hnac.hzims.electric.service.ThirtyService; |
|
|
|
import com.hnac.hzims.electric.service.ThreeService; |
|
|
|
import com.hnac.hzims.electric.service.ThreeService; |
|
|
|
|
|
|
|
import com.hnac.hzims.electric.vo.ComprehensiveElectricVo; |
|
|
|
import com.hnac.hzims.electric.vo.DeviceElectricVo; |
|
|
|
import com.hnac.hzims.electric.vo.DeviceElectricVo; |
|
|
|
import com.hnac.hzims.electric.vo.TableHeadVo; |
|
|
|
import com.hnac.hzims.electric.vo.TableHeadVo; |
|
|
|
import com.hnac.hzims.equipment.entity.EmInfoEntity; |
|
|
|
import com.hnac.hzims.equipment.vo.EminfoAndEmParamVo; |
|
|
|
import com.hnac.hzims.equipment.service.IEmInfoService; |
|
|
|
|
|
|
|
import com.hnac.hzims.operational.station.entity.StationEntity; |
|
|
|
import com.hnac.hzims.operational.station.entity.StationEntity; |
|
|
|
import com.hnac.hzims.operational.station.feign.IStationClient; |
|
|
|
import com.hnac.hzims.operational.station.feign.IStationClient; |
|
|
|
import com.hnac.hzims.operational.station.vo.StationsByDeptIdsParamVo; |
|
|
|
|
|
|
|
import com.hnac.hzinfo.datasearch.analyse.IAnalyseDataSearchClient; |
|
|
|
import com.hnac.hzinfo.datasearch.analyse.IAnalyseDataSearchClient; |
|
|
|
import com.hnac.hzinfo.datasearch.analyse.po.AnalyseCodeByAnalyseDataPO; |
|
|
|
import com.hnac.hzinfo.datasearch.analyse.po.AnalyseCodeByAnalyseDataPO; |
|
|
|
import com.hnac.hzinfo.datasearch.analyse.po.AnalyzeDataConditionPO; |
|
|
|
import com.hnac.hzinfo.datasearch.analyse.po.AnalyzeDataConditionPO; |
|
|
|
import com.hnac.hzinfo.datasearch.analyse.vo.AnalyseDataTaosVO; |
|
|
|
|
|
|
|
import com.hnac.hzinfo.datasearch.analyse.vo.AnalyzeDataConditionVO; |
|
|
|
import com.hnac.hzinfo.datasearch.analyse.vo.AnalyzeDataConditionVO; |
|
|
|
import lombok.RequiredArgsConstructor; |
|
|
|
import lombok.RequiredArgsConstructor; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
@ -26,11 +26,13 @@ import org.springblade.core.tool.api.R; |
|
|
|
import org.springblade.core.tool.utils.CollectionUtil; |
|
|
|
import org.springblade.core.tool.utils.CollectionUtil; |
|
|
|
import org.springblade.core.tool.utils.DateUtil; |
|
|
|
import org.springblade.core.tool.utils.DateUtil; |
|
|
|
import org.springblade.core.tool.utils.ObjectUtil; |
|
|
|
import org.springblade.core.tool.utils.ObjectUtil; |
|
|
|
import org.springblade.core.tool.utils.StringUtil; |
|
|
|
|
|
|
|
import org.springblade.system.entity.Dept; |
|
|
|
import org.springblade.system.entity.Dept; |
|
|
|
import org.springblade.system.feign.ISysClient; |
|
|
|
import org.springblade.system.feign.ISysClient; |
|
|
|
|
|
|
|
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.*; |
|
|
@ -48,14 +50,16 @@ public class ElectricReportServiceImpl implements IElectricReportService { |
|
|
|
|
|
|
|
|
|
|
|
private final ThirtyService thirtyService; |
|
|
|
private final ThirtyService thirtyService; |
|
|
|
|
|
|
|
|
|
|
|
private final IEmInfoService deviceService; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private final ISysClient sysClient; |
|
|
|
private final ISysClient sysClient; |
|
|
|
|
|
|
|
|
|
|
|
private final IStationClient stationClient; |
|
|
|
private final IStationClient stationClient; |
|
|
|
|
|
|
|
|
|
|
|
private final IAnalyseDataSearchClient analyseDataSearchClient; |
|
|
|
private final IAnalyseDataSearchClient analyseDataSearchClient; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private final RedisTemplate redisTemplate; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public final static String DEVICE_CACHE_COFIG_FINAL = "hzims:equipment:emInfo:deviceCode.emInfoList"; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 基础报表 |
|
|
|
* 基础报表 |
|
|
|
* @param deptId |
|
|
|
* @param deptId |
|
|
@ -92,6 +96,125 @@ public class ElectricReportServiceImpl implements IElectricReportService { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
|
|
|
|
* 综合报表 |
|
|
|
|
|
|
|
* @param deptId |
|
|
|
|
|
|
|
* @return |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public List<ComprehensiveElectricVo> comprehensive(Long deptId,String year) { |
|
|
|
|
|
|
|
// 查询站点
|
|
|
|
|
|
|
|
StationEntity param = new StationEntity(); |
|
|
|
|
|
|
|
param.setRefDept(deptId); |
|
|
|
|
|
|
|
R<StationEntity> station = stationClient.getStationByCodeOrRedDept(param); |
|
|
|
|
|
|
|
if(!station.isSuccess() || ObjectUtil.isEmpty(station.getData())){ |
|
|
|
|
|
|
|
return new ArrayList<>(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// 查询设备
|
|
|
|
|
|
|
|
List<EminfoAndEmParamVo> devices = JSONObject.parseObject(redisTemplate.opsForValue().get(DEVICE_CACHE_COFIG_FINAL).toString(), new TypeReference<List<EminfoAndEmParamVo>>() {}); |
|
|
|
|
|
|
|
if(CollectionUtil.isEmpty(devices)){ |
|
|
|
|
|
|
|
return new ArrayList<>(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// 设备装机容量
|
|
|
|
|
|
|
|
double installedCapacity = devices.stream().filter(device->device.getCreateDept().equals(deptId)).mapToDouble(EminfoAndEmParamVo::getInstalledCapacity).sum(); |
|
|
|
|
|
|
|
// 查询两年发电量
|
|
|
|
|
|
|
|
Calendar calendar = Calendar.getInstance(); |
|
|
|
|
|
|
|
calendar.setTime(DateUtil.parse(year,"yyyy")); |
|
|
|
|
|
|
|
calendar.add(Calendar.YEAR,1); |
|
|
|
|
|
|
|
Date end = calendar.getTime(); |
|
|
|
|
|
|
|
calendar.add(Calendar.YEAR,-2); |
|
|
|
|
|
|
|
Date start = calendar.getTime(); |
|
|
|
|
|
|
|
List<ThreeEntity> threes = threeService.list(Wrappers.<ThreeEntity>lambdaQuery() |
|
|
|
|
|
|
|
.eq(ThreeEntity::getStationId,station.getData().getCode()) |
|
|
|
|
|
|
|
.ge(ThreeEntity::getStrMonth, DateUtil.format(start,DateUtil.PATTERN_DATE)) |
|
|
|
|
|
|
|
.le(ThreeEntity::getStrMonth, DateUtil.format(end,DateUtil.PATTERN_DATE)) |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
calendar.setTime(DateUtil.parse(year,"yyyy")); |
|
|
|
|
|
|
|
calendar.add(Calendar.YEAR,1); |
|
|
|
|
|
|
|
Date finish = calendar.getTime(); |
|
|
|
|
|
|
|
calendar.add(Calendar.YEAR,-1); |
|
|
|
|
|
|
|
Date current = calendar.getTime(); |
|
|
|
|
|
|
|
// fixme 随机器模拟数据
|
|
|
|
|
|
|
|
Random random = new Random(); |
|
|
|
|
|
|
|
List<ComprehensiveElectricVo> electrics = new ArrayList<>(); |
|
|
|
|
|
|
|
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); |
|
|
|
|
|
|
|
current = calendar.getTime(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return electrics; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* 确认机构级别 |
|
|
|
* 确认机构级别 |
|
|
|
* @param deptId |
|
|
|
* @param deptId |
|
|
|
* @return |
|
|
|
* @return |
|
|
@ -450,17 +573,17 @@ public class ElectricReportServiceImpl implements IElectricReportService { |
|
|
|
// 日
|
|
|
|
// 日
|
|
|
|
if (type == 0) { |
|
|
|
if (type == 0) { |
|
|
|
// 站点设备集合
|
|
|
|
// 站点设备集合
|
|
|
|
List<EmInfoEntity> devices = deviceService.list(Wrappers.<EmInfoEntity>lambdaQuery() |
|
|
|
List<EminfoAndEmParamVo> devices = JSONObject.parseObject(redisTemplate.opsForValue().get(DEVICE_CACHE_COFIG_FINAL).toString(), new TypeReference<List<EminfoAndEmParamVo>>() {}); |
|
|
|
.eq(EmInfoEntity::getCreateDept,station.getData().getRefDept()) |
|
|
|
|
|
|
|
.eq(EmInfoEntity::getEmType,2) |
|
|
|
|
|
|
|
.eq(EmInfoEntity::getHomePageDisplay,1) |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
if(CollectionUtil.isEmpty(devices)){ |
|
|
|
if(CollectionUtil.isEmpty(devices)){ |
|
|
|
return new HashMap<>(); |
|
|
|
return new HashMap<>(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
List<EminfoAndEmParamVo> stationDevices = devices.stream().filter(device->device.getCreateDept().equals(station.getData().getRefDept())).collect(Collectors.toList()); |
|
|
|
|
|
|
|
if(CollectionUtil.isEmpty(stationDevices)){ |
|
|
|
|
|
|
|
return new HashMap<>(); |
|
|
|
|
|
|
|
} |
|
|
|
Date date = DateUtil.parse(time,DateUtil.PATTERN_DATE); |
|
|
|
Date date = DateUtil.parse(time,DateUtil.PATTERN_DATE); |
|
|
|
// 根据设备查询当日有功/无功电量
|
|
|
|
// 根据设备查询当日有功/无功电量
|
|
|
|
List<DeviceElectricVo> electrics = this.deviceElectrics(devices,date); |
|
|
|
List<DeviceElectricVo> electrics = this.deviceElectrics(stationDevices,date); |
|
|
|
|
|
|
|
|
|
|
|
// 表头
|
|
|
|
// 表头
|
|
|
|
List<TableHeadVo> tableHeads = new ArrayList<>(); |
|
|
|
List<TableHeadVo> tableHeads = new ArrayList<>(); |
|
|
@ -475,7 +598,7 @@ public class ElectricReportServiceImpl implements IElectricReportService { |
|
|
|
tableHeads.add(secondHead); |
|
|
|
tableHeads.add(secondHead); |
|
|
|
|
|
|
|
|
|
|
|
// 根据设备分组
|
|
|
|
// 根据设备分组
|
|
|
|
devices.forEach(device->{ |
|
|
|
stationDevices.forEach(device->{ |
|
|
|
TableHeadVo tableHead = new TableHeadVo(); |
|
|
|
TableHeadVo tableHead = new TableHeadVo(); |
|
|
|
tableHead.setTableName(device.getName() + "发电量(kWh)"); |
|
|
|
tableHead.setTableName(device.getName() + "发电量(kWh)"); |
|
|
|
tableHead.setIsChildren(true); |
|
|
|
tableHead.setIsChildren(true); |
|
|
@ -486,24 +609,25 @@ public class ElectricReportServiceImpl implements IElectricReportService { |
|
|
|
|
|
|
|
|
|
|
|
Calendar calendar = Calendar.getInstance(); |
|
|
|
Calendar calendar = Calendar.getInstance(); |
|
|
|
calendar.setTime(date); |
|
|
|
calendar.setTime(date); |
|
|
|
|
|
|
|
calendar.add(Calendar.DAY_OF_MONTH,1); |
|
|
|
Date end = calendar.getTime(); |
|
|
|
Date end = calendar.getTime(); |
|
|
|
calendar.add(Calendar.HOUR_OF_DAY,-calendar.get(Calendar.HOUR_OF_DAY)); |
|
|
|
calendar.add(Calendar.DAY_OF_MONTH,-1); |
|
|
|
Date start = calendar.getTime(); |
|
|
|
Date start = calendar.getTime(); |
|
|
|
List<List<Object>> tableDate = new ArrayList<>(); |
|
|
|
List<List<Object>> tableDate = new ArrayList<>(); |
|
|
|
while (start.compareTo(end) < 0){ |
|
|
|
while (start.compareTo(end) < 0){ |
|
|
|
List<Object> item = new ArrayList<>(); |
|
|
|
List<Object> item = new ArrayList<>(); |
|
|
|
String hours = DateUtil.format(start,"yyyy-MM-dd HH"); |
|
|
|
String hours = DateUtil.format(start,"yyyy-MM-dd HH"); |
|
|
|
item.add(start.getMonth() + 1 + "月"); |
|
|
|
item.add(start.getHours() + "时"); |
|
|
|
// 总计:有功、无功
|
|
|
|
// 总计:有功、无功
|
|
|
|
item.add(electrics.stream().filter(electric -> electric.getStrTime().contains(hours)).mapToDouble(DeviceElectricVo::getGenerate).sum()); |
|
|
|
item.add(electrics.stream().filter(electric -> electric.getStrTime().contains(hours)).mapToDouble(DeviceElectricVo::getGenerate).sum()); |
|
|
|
item.add(electrics.stream().filter(electric -> electric.getStrTime().contains(hours)).mapToDouble(DeviceElectricVo::getReactiveGenerate).sum()); |
|
|
|
item.add(electrics.stream().filter(electric -> electric.getStrTime().contains(hours)).mapToDouble(DeviceElectricVo::getReactiveGenerate).sum()); |
|
|
|
|
|
|
|
|
|
|
|
// 遍历机组
|
|
|
|
// 遍历机组
|
|
|
|
devices.stream().sorted(Comparator.comparing(EmInfoEntity::getEmIndex)).forEach(device->{ |
|
|
|
stationDevices.stream().sorted(Comparator.comparing(EminfoAndEmParamVo::getOrd)).forEach(device->{ |
|
|
|
item.add(electrics.stream().filter(electric -> electric.getDeviceCode().equals(device.getNumber()) && electric.getStrTime().contains(hours)).mapToDouble(DeviceElectricVo::getGenerate).sum()); |
|
|
|
item.add(electrics.stream().filter(electric -> electric.getDeviceCode().equals(device.getEmCode()) && electric.getStrTime().contains(hours)).mapToDouble(DeviceElectricVo::getGenerate).sum()); |
|
|
|
item.add(electrics.stream().filter(electric -> electric.getDeviceCode().equals(device.getNumber()) && electric.getStrTime().contains(hours)).mapToDouble(DeviceElectricVo::getReactiveGenerate).sum()); |
|
|
|
item.add(electrics.stream().filter(electric -> electric.getDeviceCode().equals(device.getEmCode()) && electric.getStrTime().contains(hours)).mapToDouble(DeviceElectricVo::getReactiveGenerate).sum()); |
|
|
|
}); |
|
|
|
}); |
|
|
|
calendar.add(Calendar.DAY_OF_MONTH,1); |
|
|
|
calendar.add(Calendar.HOUR_OF_DAY,1); |
|
|
|
start = calendar.getTime(); |
|
|
|
start = calendar.getTime(); |
|
|
|
tableDate.add(item); |
|
|
|
tableDate.add(item); |
|
|
|
} |
|
|
|
} |
|
|
@ -641,18 +765,19 @@ public class ElectricReportServiceImpl implements IElectricReportService { |
|
|
|
* @param devices |
|
|
|
* @param devices |
|
|
|
* @return |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private List<DeviceElectricVo> deviceElectrics(List<EmInfoEntity> devices,Date date) { |
|
|
|
private List<DeviceElectricVo> deviceElectrics(List<EminfoAndEmParamVo> devices,Date date) { |
|
|
|
List<DeviceElectricVo> electrics = new ArrayList<>(); |
|
|
|
List<DeviceElectricVo> electrics = new ArrayList<>(); |
|
|
|
devices.forEach(device->{ |
|
|
|
devices.forEach(device->{ |
|
|
|
Calendar calendar = Calendar.getInstance(); |
|
|
|
Calendar calendar = Calendar.getInstance(); |
|
|
|
calendar.setTime(date); |
|
|
|
calendar.setTime(date); |
|
|
|
|
|
|
|
calendar.add(Calendar.DAY_OF_MONTH,1); |
|
|
|
Date endTime = calendar.getTime(); |
|
|
|
Date endTime = calendar.getTime(); |
|
|
|
LocalDateTime end = LocalDateTime.parse(DateUtil.format(new Date(), DateUtil.format(endTime,DateUtil.PATTERN_DATETIME)), DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATETIME)); |
|
|
|
LocalDateTime end = LocalDateTime.parse(DateUtil.format(new Date(), DateUtil.format(endTime,DateUtil.PATTERN_DATETIME)), DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATETIME)); |
|
|
|
calendar.add(Calendar.HOUR_OF_DAY,-calendar.get(Calendar.HOUR_OF_DAY)); |
|
|
|
calendar.add(Calendar.DAY_OF_MONTH,-1); |
|
|
|
Date startTime = calendar.getTime(); |
|
|
|
Date startTime = calendar.getTime(); |
|
|
|
LocalDateTime start = LocalDateTime.parse(DateUtil.format(new Date(), DateUtil.format(startTime,DateUtil.PATTERN_DATETIME)), DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATETIME)); |
|
|
|
LocalDateTime start = LocalDateTime.parse(DateUtil.format(new Date(), DateUtil.format(startTime,DateUtil.PATTERN_DATETIME)), DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATETIME)); |
|
|
|
AnalyseCodeByAnalyseDataPO param = new AnalyseCodeByAnalyseDataPO(); |
|
|
|
AnalyseCodeByAnalyseDataPO param = new AnalyseCodeByAnalyseDataPO(); |
|
|
|
param.setDeviceCode(device.getNumber()); |
|
|
|
param.setDeviceCode(device.getEmCode()); |
|
|
|
List<AnalyzeDataConditionPO> conditions = new ArrayList<>(); |
|
|
|
List<AnalyzeDataConditionPO> conditions = new ArrayList<>(); |
|
|
|
// 有功电量
|
|
|
|
// 有功电量
|
|
|
|
AnalyzeDataConditionPO generate = new AnalyzeDataConditionPO(); |
|
|
|
AnalyzeDataConditionPO generate = new AnalyzeDataConditionPO(); |
|
|
@ -674,7 +799,8 @@ public class ElectricReportServiceImpl implements IElectricReportService { |
|
|
|
reactive.setSignages("reactive_generation"); |
|
|
|
reactive.setSignages("reactive_generation"); |
|
|
|
reactive.setTimeInterval(1); |
|
|
|
reactive.setTimeInterval(1); |
|
|
|
reactive.setBeginTime(start); |
|
|
|
reactive.setBeginTime(start); |
|
|
|
reactive.setEndTime(end);conditions.add(reactive); |
|
|
|
reactive.setEndTime(end); |
|
|
|
|
|
|
|
conditions.add(reactive); |
|
|
|
param.setSignboardConditions(conditions); |
|
|
|
param.setSignboardConditions(conditions); |
|
|
|
R<List<AnalyzeDataConditionVO>> result = analyseDataSearchClient.getAnalyzeDataByAnalyzeCodeAndSignages(param); |
|
|
|
R<List<AnalyzeDataConditionVO>> result = analyseDataSearchClient.getAnalyzeDataByAnalyzeCodeAndSignages(param); |
|
|
|
if(!result.isSuccess() || ObjectUtil.isEmpty(result.getData())){ |
|
|
|
if(!result.isSuccess() || ObjectUtil.isEmpty(result.getData())){ |
|
|
@ -682,24 +808,25 @@ public class ElectricReportServiceImpl implements IElectricReportService { |
|
|
|
} |
|
|
|
} |
|
|
|
while (startTime.compareTo(endTime) < 0){ |
|
|
|
while (startTime.compareTo(endTime) < 0){ |
|
|
|
DeviceElectricVo electric = new DeviceElectricVo(); |
|
|
|
DeviceElectricVo electric = new DeviceElectricVo(); |
|
|
|
|
|
|
|
electric.setDeviceCode(device.getEmCode()); |
|
|
|
electric.setStrTime(DateUtil.format(startTime,"yyyy-MM-dd HH")); |
|
|
|
electric.setStrTime(DateUtil.format(startTime,"yyyy-MM-dd HH")); |
|
|
|
electric.setTime(startTime.getHours()); |
|
|
|
electric.setTime(startTime.getHours()); |
|
|
|
if(ObjectUtil.isEmpty(result.getData().get(0)) || CollectionUtil.isEmpty(result.getData().get(0).getList())){ |
|
|
|
if(CollectionUtil.isNotEmpty(result.getData()) && ObjectUtil.isNotEmpty(result.getData().get(0)) && CollectionUtil.isNotEmpty(result.getData().get(0).getList())){ |
|
|
|
electric.setGenerate(result.getData().get(0).getList().stream().filter(o->o.getTs().contains(electric.getStrTime())).mapToDouble(val->{ |
|
|
|
electric.setGenerate(result.getData().get(0).getList().stream().filter(o->o.getTs().contains(electric.getStrTime())).mapToDouble(val->{ |
|
|
|
if(StringUtils.isEmpty(val.getVal())){ |
|
|
|
if(StringUtils.isEmpty(val.getVal())){ |
|
|
|
return 0.0; |
|
|
|
return 0.0; |
|
|
|
} |
|
|
|
} |
|
|
|
return Double.parseDouble(val.getVal()); |
|
|
|
return Double.parseDouble(val.getVal()) * device.getRideCount(); |
|
|
|
}).sum()); |
|
|
|
}).sum()); |
|
|
|
}else{ |
|
|
|
}else{ |
|
|
|
electric.setGenerate(0.0); |
|
|
|
electric.setGenerate(0.0); |
|
|
|
} |
|
|
|
} |
|
|
|
if(ObjectUtil.isEmpty(result.getData().get(1)) || CollectionUtil.isEmpty(result.getData().get(1).getList())){ |
|
|
|
if(CollectionUtil.isNotEmpty(result.getData()) && result.getData().size() > 1 && ObjectUtil.isNotEmpty(result.getData().get(1)) && CollectionUtil.isNotEmpty(result.getData().get(1).getList())){ |
|
|
|
electric.setReactiveGenerate(result.getData().get(1).getList().stream().filter(o->o.getTs().contains(electric.getStrTime())).mapToDouble(val->{ |
|
|
|
electric.setReactiveGenerate(result.getData().get(1).getList().stream().filter(o->o.getTs().contains(electric.getStrTime())).mapToDouble(val->{ |
|
|
|
if(StringUtils.isEmpty(val.getVal())){ |
|
|
|
if(StringUtils.isEmpty(val.getVal())){ |
|
|
|
return 0.0; |
|
|
|
return 0.0; |
|
|
|
} |
|
|
|
} |
|
|
|
return Double.parseDouble(val.getVal()); |
|
|
|
return Double.parseDouble(val.getVal()) * device.getRideCount(); |
|
|
|
}).sum()); |
|
|
|
}).sum()); |
|
|
|
}else{ |
|
|
|
}else{ |
|
|
|
electric.setReactiveGenerate(0.0); |
|
|
|
electric.setReactiveGenerate(0.0); |
|
|
|