|
|
@ -3,6 +3,7 @@ package com.hnac.hzims.operational.census.service.impl; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
|
|
|
|
|
import com.google.common.util.concurrent.ThreadFactoryBuilder; |
|
|
|
import com.hnac.hzims.equipment.entity.PlanGenerationEntity; |
|
|
|
import com.hnac.hzims.equipment.entity.PlanGenerationEntity; |
|
|
|
import com.hnac.hzims.equipment.feign.IPlanGenertionClient; |
|
|
|
import com.hnac.hzims.equipment.feign.IPlanGenertionClient; |
|
|
|
import com.hnac.hzims.equipment.vo.EminfoAndEmParamVo; |
|
|
|
import com.hnac.hzims.equipment.vo.EminfoAndEmParamVo; |
|
|
@ -11,15 +12,15 @@ import com.hnac.hzims.operational.access.service.IOperAccessTaskService; |
|
|
|
import com.hnac.hzims.operational.access.vo.OperAccessTaskVO; |
|
|
|
import com.hnac.hzims.operational.access.vo.OperAccessTaskVO; |
|
|
|
import com.hnac.hzims.operational.census.constants.CensusConstant; |
|
|
|
import com.hnac.hzims.operational.census.constants.CensusConstant; |
|
|
|
import com.hnac.hzims.operational.census.service.TargetService; |
|
|
|
import com.hnac.hzims.operational.census.service.TargetService; |
|
|
|
import com.hnac.hzims.operational.census.vo.*; |
|
|
|
|
|
|
|
import com.hnac.hzims.operational.census.vo.WaterTargetVo; |
|
|
|
import com.hnac.hzims.operational.census.vo.WaterTargetVo; |
|
|
|
|
|
|
|
import com.hnac.hzims.operational.census.vo.*; |
|
|
|
import com.hnac.hzims.operational.defect.service.IOperPhenomenonService; |
|
|
|
import com.hnac.hzims.operational.defect.service.IOperPhenomenonService; |
|
|
|
import com.hnac.hzims.operational.fill.entity.*; |
|
|
|
import com.hnac.hzims.operational.fill.entity.*; |
|
|
|
import com.hnac.hzims.operational.fill.service.*; |
|
|
|
import com.hnac.hzims.operational.fill.service.*; |
|
|
|
|
|
|
|
import com.hnac.hzims.operational.main.constant.HomePageConstant; |
|
|
|
import com.hnac.hzims.operational.main.service.AreaService; |
|
|
|
import com.hnac.hzims.operational.main.service.AreaService; |
|
|
|
import com.hnac.hzims.operational.main.service.IMainSystemMonitoringService; |
|
|
|
import com.hnac.hzims.operational.main.service.IMainSystemMonitoringService; |
|
|
|
import com.hnac.hzims.operational.main.vo.*; |
|
|
|
import com.hnac.hzims.operational.main.vo.*; |
|
|
|
import com.hnac.hzims.operational.main.constant.HomePageConstant; |
|
|
|
|
|
|
|
import com.hnac.hzims.operational.maintenance.dto.OperMaintenanceTaskDTO; |
|
|
|
import com.hnac.hzims.operational.maintenance.dto.OperMaintenanceTaskDTO; |
|
|
|
import com.hnac.hzims.operational.maintenance.service.IOperMaintenanceTaskService; |
|
|
|
import com.hnac.hzims.operational.maintenance.service.IOperMaintenanceTaskService; |
|
|
|
import com.hnac.hzims.operational.maintenance.vo.OperMaintenanceTaskVO; |
|
|
|
import com.hnac.hzims.operational.maintenance.vo.OperMaintenanceTaskVO; |
|
|
@ -45,14 +46,11 @@ import org.springframework.util.CollectionUtils; |
|
|
|
import org.springframework.util.StringUtils; |
|
|
|
import org.springframework.util.StringUtils; |
|
|
|
|
|
|
|
|
|
|
|
import java.math.BigDecimal; |
|
|
|
import java.math.BigDecimal; |
|
|
|
import java.text.SimpleDateFormat; |
|
|
|
|
|
|
|
import java.time.LocalDate; |
|
|
|
import java.time.LocalDate; |
|
|
|
import java.time.LocalDateTime; |
|
|
|
import java.time.LocalDateTime; |
|
|
|
import java.time.LocalTime; |
|
|
|
import java.time.LocalTime; |
|
|
|
import java.util.*; |
|
|
|
import java.util.*; |
|
|
|
import java.util.concurrent.CountDownLatch; |
|
|
|
import java.util.concurrent.*; |
|
|
|
import java.util.concurrent.ExecutorService; |
|
|
|
|
|
|
|
import java.util.concurrent.Executors; |
|
|
|
|
|
|
|
import java.util.stream.Collectors; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
@ -64,41 +62,35 @@ import java.util.stream.Collectors; |
|
|
|
@RequiredArgsConstructor |
|
|
|
@RequiredArgsConstructor |
|
|
|
public class TargetServiceImpl implements TargetService { |
|
|
|
public class TargetServiceImpl implements TargetService { |
|
|
|
|
|
|
|
|
|
|
|
private final IStationService stationService; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private final IMainSystemMonitoringService maintenanceService; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private final PowerService powerService; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private final AreaService areaService; |
|
|
|
private final AreaService areaService; |
|
|
|
|
|
|
|
|
|
|
|
private final IOperMaintenanceTaskService maintenanceTaskService; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private final IOperPhenomenonService phenomenonService; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private final OverService overService; |
|
|
|
private final OverService overService; |
|
|
|
|
|
|
|
|
|
|
|
private final OverDetailsService overDetailsService; |
|
|
|
private final PowerService powerService; |
|
|
|
|
|
|
|
|
|
|
|
private final SolveService solveService; |
|
|
|
private final SolveService solveService; |
|
|
|
|
|
|
|
|
|
|
|
private final OtherService otherService; |
|
|
|
private final OtherService otherService; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private final IStationService stationService; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private final OverDetailsService overDetailsService; |
|
|
|
|
|
|
|
|
|
|
|
private final IOperAccessTaskService accessTaskService; |
|
|
|
private final IOperAccessTaskService accessTaskService; |
|
|
|
|
|
|
|
|
|
|
|
private final IPlanGenertionClient planClient; |
|
|
|
private final IOperPhenomenonService phenomenonService; |
|
|
|
|
|
|
|
|
|
|
|
private final ITicketInfoAllClient ticketInfoAllClient; |
|
|
|
private final IMainSystemMonitoringService maintenanceService; |
|
|
|
|
|
|
|
|
|
|
|
private final ISysClient sysClient; |
|
|
|
private final IOperMaintenanceTaskService maintenanceTaskService; |
|
|
|
|
|
|
|
|
|
|
|
private final RedisTemplate redisTemplate; |
|
|
|
private final ISysClient sysClient; |
|
|
|
|
|
|
|
|
|
|
|
private final SimpleDateFormat sdf = new SimpleDateFormat(DateUtil.PATTERN_DATETIME); |
|
|
|
private final IPlanGenertionClient planClient; |
|
|
|
|
|
|
|
|
|
|
|
private final static String load_hydropower_unit_target_key = "hzims:operation:loadhydropowerunit:target:key"; |
|
|
|
private final ITicketInfoAllClient ticketInfoAllClient; |
|
|
|
|
|
|
|
|
|
|
|
private final static String KEY_INDICATORS_INFO = "hzims:operation:key:indicators:info"; |
|
|
|
private final RedisTemplate redisTemplate; |
|
|
|
|
|
|
|
|
|
|
|
@Value("${hzims.operation.region.deviceClassifyKey}") |
|
|
|
@Value("${hzims.operation.region.deviceClassifyKey}") |
|
|
|
private String device_classify_key; |
|
|
|
private String device_classify_key; |
|
|
@ -109,9 +101,17 @@ public class TargetServiceImpl implements TargetService { |
|
|
|
@Value("${hzims.operation.region.areaDutyInfoKey}") |
|
|
|
@Value("${hzims.operation.region.areaDutyInfoKey}") |
|
|
|
private String areaDutyInfoKey; |
|
|
|
private String areaDutyInfoKey; |
|
|
|
|
|
|
|
|
|
|
|
private final static String loadwaterpump_target_key = "hzims:operation:loadwaterpump:target:key"; |
|
|
|
private final static String load_waterpump_real_key = "hzims:operation:loadwaterpump:real:key"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private final static String load_photovoltaic_real_key = "hzims:operation:photovoltaic:real:key"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private final static String load_hydropower_unit_real_key = "hzims:operation:loadhydropowerunit:real:key"; |
|
|
|
|
|
|
|
|
|
|
|
private final static String loadwaterpump_real_key = "hzims:operation:loadwaterpump:real:key"; |
|
|
|
private final static String load_waterpump_target_key = "hzims:operation:loadwaterpump:target:key"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private final static String load_photovoltaic_target_key = "hzims:operation:photovoltaic:target:key"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private final static String load_hydropower_unit_target_key = "hzims:operation:loadhydropowerunit:target:key"; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 获取站点装机容量 |
|
|
|
* 获取站点装机容量 |
|
|
@ -121,7 +121,7 @@ public class TargetServiceImpl implements TargetService { |
|
|
|
public List<InstalledCapacityVo> installedCapacity(String stationName,Integer type) { |
|
|
|
public List<InstalledCapacityVo> installedCapacity(String stationName,Integer type) { |
|
|
|
// 站点
|
|
|
|
// 站点
|
|
|
|
LambdaQueryWrapper<StationEntity> wappers = Wrappers.lambdaQuery(); |
|
|
|
LambdaQueryWrapper<StationEntity> wappers = Wrappers.lambdaQuery(); |
|
|
|
wappers.eq(StationEntity::getType, HomePageConstant.HYDROPOWER); |
|
|
|
wappers.eq(StationEntity::getType, type); |
|
|
|
wappers.eq(StationEntity::getServeType,2); |
|
|
|
wappers.eq(StationEntity::getServeType,2); |
|
|
|
if(!StringUtils.isEmpty(stationName)){ |
|
|
|
if(!StringUtils.isEmpty(stationName)){ |
|
|
|
wappers.like(StationEntity::getName,stationName); |
|
|
|
wappers.like(StationEntity::getName,stationName); |
|
|
@ -130,46 +130,25 @@ public class TargetServiceImpl implements TargetService { |
|
|
|
if(CollectionUtils.isEmpty(stations)){ |
|
|
|
if(CollectionUtils.isEmpty(stations)){ |
|
|
|
return new ArrayList<>(); |
|
|
|
return new ArrayList<>(); |
|
|
|
} |
|
|
|
} |
|
|
|
if(HomePageConstant.HYDROPOWER.equals(type)){ |
|
|
|
// 设备
|
|
|
|
// 设备
|
|
|
|
List<EminfoAndEmParamVo> devices = maintenanceService.getEmInfoList(); |
|
|
|
List<EminfoAndEmParamVo> devices = maintenanceService.getEmInfoList(); |
|
|
|
return stations.stream().map(station->{ |
|
|
|
return stations.stream().map(station->{ |
|
|
|
|
|
|
|
InstalledCapacityVo item = new InstalledCapacityVo(); |
|
|
|
|
|
|
|
item.setStationName(station.getName()); |
|
|
|
|
|
|
|
List<EminfoAndEmParamVo> stationDevices = devices.stream().filter(device->device.getCreateDept().equals(station.getRefDept())).collect(Collectors.toList()); |
|
|
|
|
|
|
|
if(CollectionUtils.isEmpty(stationDevices)){ |
|
|
|
|
|
|
|
item.setInstalledCapacity(0.0); |
|
|
|
|
|
|
|
item.setDetail("站点暂无设备!"); |
|
|
|
|
|
|
|
return item; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// 装机容量
|
|
|
|
|
|
|
|
double sum = stationDevices.stream().mapToDouble(EminfoAndEmParamVo::getInstalledCapacity).sum(); |
|
|
|
|
|
|
|
item.setInstalledCapacity(sum); |
|
|
|
|
|
|
|
// 装机容量详情
|
|
|
|
|
|
|
|
List<String> details = stationDevices.stream().map(device-> "[" + device.getName() + " " +device.getInstalledCapacity() +"kw]").collect(Collectors.toList()); |
|
|
|
|
|
|
|
item.setDetail(String.join("|",details)); |
|
|
|
|
|
|
|
return item; |
|
|
|
|
|
|
|
}).collect(Collectors.toList()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// 查询填报数据
|
|
|
|
|
|
|
|
String mon = DateUtil.format(new Date(),"yyyy"); |
|
|
|
|
|
|
|
List<PowerEntity> powers = powerService.list(Wrappers.<PowerEntity>lambdaQuery() |
|
|
|
|
|
|
|
.in(PowerEntity::getCreateDept,stations.stream().map(StationEntity::getRefDept).collect(Collectors.toList())) |
|
|
|
|
|
|
|
.ge(PowerEntity::getMon, mon + "-01") |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
return stations.stream().map(station -> { |
|
|
|
|
|
|
|
InstalledCapacityVo item = new InstalledCapacityVo(); |
|
|
|
InstalledCapacityVo item = new InstalledCapacityVo(); |
|
|
|
item.setStationName(station.getName()); |
|
|
|
item.setStationName(station.getName()); |
|
|
|
// 装机容量
|
|
|
|
List<EminfoAndEmParamVo> stationDevices = devices.stream().filter(device->device.getCreateDept().equals(station.getRefDept())).collect(Collectors.toList()); |
|
|
|
List<PowerEntity> stationPowers = powers.stream().filter(o->o.getCreateDept().equals(station.getRefDept())).collect(Collectors.toList()); |
|
|
|
if(CollectionUtils.isEmpty(stationDevices)){ |
|
|
|
if(CollectionUtils.isEmpty(stationPowers)){ |
|
|
|
|
|
|
|
item.setInstalledCapacity(0.0); |
|
|
|
item.setInstalledCapacity(0.0); |
|
|
|
}else{ |
|
|
|
item.setDetail("站点暂无设备!"); |
|
|
|
item.setInstalledCapacity(stationPowers.stream().sorted(Comparator.comparing(PowerEntity::getMon).reversed()).collect(Collectors.toList()).get(0).getInstalledCapacity()); |
|
|
|
return item; |
|
|
|
} |
|
|
|
} |
|
|
|
item.setDetail("站点为填报数据,暂无设备装机容量信息!"); |
|
|
|
// 装机容量
|
|
|
|
|
|
|
|
double sum = stationDevices.stream().mapToDouble(EminfoAndEmParamVo::getInstalledCapacity).sum(); |
|
|
|
|
|
|
|
item.setInstalledCapacity(sum); |
|
|
|
|
|
|
|
// 装机容量详情
|
|
|
|
|
|
|
|
List<String> details = stationDevices.stream().map(device-> "[" + device.getName() + " " +device.getInstalledCapacity() +"kw]").collect(Collectors.toList()); |
|
|
|
|
|
|
|
item.setDetail(String.join("|",details)); |
|
|
|
return item; |
|
|
|
return item; |
|
|
|
}).collect(Collectors.toList()); |
|
|
|
}).filter(capacity->Math.abs(capacity.getInstalledCapacity()) > 0).collect(Collectors.toList()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
@ -180,7 +159,7 @@ public class TargetServiceImpl implements TargetService { |
|
|
|
public List<ElectricGenerationVo> electricGeneration(String stationName,Integer type) { |
|
|
|
public List<ElectricGenerationVo> electricGeneration(String stationName,Integer type) { |
|
|
|
// 站点
|
|
|
|
// 站点
|
|
|
|
LambdaQueryWrapper<StationEntity> wappers = Wrappers.lambdaQuery(); |
|
|
|
LambdaQueryWrapper<StationEntity> wappers = Wrappers.lambdaQuery(); |
|
|
|
wappers.eq(StationEntity::getType, HomePageConstant.HYDROPOWER); |
|
|
|
wappers.eq(StationEntity::getType, type); |
|
|
|
wappers.eq(StationEntity::getServeType,2); |
|
|
|
wappers.eq(StationEntity::getServeType,2); |
|
|
|
if(!StringUtils.isEmpty(stationName)){ |
|
|
|
if(!StringUtils.isEmpty(stationName)){ |
|
|
|
wappers.like(StationEntity::getName,stationName); |
|
|
|
wappers.like(StationEntity::getName,stationName); |
|
|
@ -206,13 +185,36 @@ public class TargetServiceImpl implements TargetService { |
|
|
|
return item; |
|
|
|
return item; |
|
|
|
} |
|
|
|
} |
|
|
|
// 年发电量
|
|
|
|
// 年发电量
|
|
|
|
double sum = targets.stream().mapToDouble(HydropowerUnitTargetVo::getPowerYear).sum(); |
|
|
|
double sum = targets.stream().filter(target->target.getDeptId().equals(station.getRefDept())).mapToDouble(HydropowerUnitTargetVo::getPowerYear).sum(); |
|
|
|
|
|
|
|
item.setElectricGeneration(sum); |
|
|
|
|
|
|
|
// 发电量详情
|
|
|
|
|
|
|
|
List<String> details = targets.stream().filter(target->target.getDeptId().equals(station.getRefDept())).map(target-> "[" + Optional.ofNullable(target.getDeviceCode()).orElse("填报电量") + " " + target.getPowerYear() +"kWh]").collect(Collectors.toList()); |
|
|
|
|
|
|
|
item.setDetail(String.join("|",details)); |
|
|
|
|
|
|
|
return item; |
|
|
|
|
|
|
|
}).filter(generate->Math.abs(generate.getElectricGeneration()) > 0).collect(Collectors.toList()); |
|
|
|
|
|
|
|
}else if(HomePageConstant.PHOTOVOLTAIC.equals(type)){ |
|
|
|
|
|
|
|
List<PhotovoltaicTargetVo> targets = (List<PhotovoltaicTargetVo>) redisTemplate.opsForValue().get(load_photovoltaic_target_key); |
|
|
|
|
|
|
|
if(CollectionUtil.isEmpty(targets)){ |
|
|
|
|
|
|
|
return new ArrayList<>(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return stations.stream().map(station->{ |
|
|
|
|
|
|
|
ElectricGenerationVo item = new ElectricGenerationVo(); |
|
|
|
|
|
|
|
item.setStationName(station.getName()); |
|
|
|
|
|
|
|
List<PhotovoltaicTargetVo> stationTargets = targets.stream().filter(device->device.getDeptId().equals(station.getRefDept())).collect(Collectors.toList()); |
|
|
|
|
|
|
|
if(CollectionUtils.isEmpty(stationTargets)){ |
|
|
|
|
|
|
|
item.setElectricGeneration(0.0); |
|
|
|
|
|
|
|
item.setDetail("站点暂无发电"); |
|
|
|
|
|
|
|
return item; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// 年发电量
|
|
|
|
|
|
|
|
double sum = targets.stream().filter(target->target.getDeptId().equals(station.getRefDept())).mapToDouble(PhotovoltaicTargetVo::getGenerationYear).sum(); |
|
|
|
item.setElectricGeneration(sum); |
|
|
|
item.setElectricGeneration(sum); |
|
|
|
// 发电量详情
|
|
|
|
// 发电量详情
|
|
|
|
List<String> details = targets.stream().map(target-> "[" + target.getDeviceCode() + " " + target.getPowerYear() +"kw]").collect(Collectors.toList()); |
|
|
|
List<String> details = targets.stream().filter(target->target.getDeptId().equals(station.getRefDept())).map(target-> "[" + Optional.ofNullable(target.getDeviceCode()).orElse("填报电量") + " " + target.getGenerationYear() +"kWh]").collect(Collectors.toList()); |
|
|
|
item.setDetail(String.join("|",details)); |
|
|
|
item.setDetail(String.join("|",details)); |
|
|
|
return item; |
|
|
|
return item; |
|
|
|
}).collect(Collectors.toList()); |
|
|
|
}).filter(generate->Math.abs(generate.getElectricGeneration()) > 0).collect(Collectors.toList()); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
// 查询填报数据
|
|
|
|
// 查询填报数据
|
|
|
|
String mon = DateUtil.format(new Date(),"yyyy"); |
|
|
|
String mon = DateUtil.format(new Date(),"yyyy"); |
|
|
@ -243,7 +245,7 @@ public class TargetServiceImpl implements TargetService { |
|
|
|
public List<CompleteGenerationVo> completeGeneration(String stationName,Integer type) { |
|
|
|
public List<CompleteGenerationVo> completeGeneration(String stationName,Integer type) { |
|
|
|
// 站点
|
|
|
|
// 站点
|
|
|
|
LambdaQueryWrapper<StationEntity> wappers = Wrappers.lambdaQuery(); |
|
|
|
LambdaQueryWrapper<StationEntity> wappers = Wrappers.lambdaQuery(); |
|
|
|
wappers.eq(StationEntity::getType, HomePageConstant.HYDROPOWER); |
|
|
|
wappers.eq(StationEntity::getType, type); |
|
|
|
wappers.eq(StationEntity::getServeType,2); |
|
|
|
wappers.eq(StationEntity::getServeType,2); |
|
|
|
if(!StringUtils.isEmpty(stationName)){ |
|
|
|
if(!StringUtils.isEmpty(stationName)){ |
|
|
|
wappers.like(StationEntity::getName,stationName); |
|
|
|
wappers.like(StationEntity::getName,stationName); |
|
|
@ -263,29 +265,77 @@ public class TargetServiceImpl implements TargetService { |
|
|
|
return stations.stream().map(station->{ |
|
|
|
return stations.stream().map(station->{ |
|
|
|
CompleteGenerationVo item = new CompleteGenerationVo(); |
|
|
|
CompleteGenerationVo item = new CompleteGenerationVo(); |
|
|
|
item.setStationName(station.getName()); |
|
|
|
item.setStationName(station.getName()); |
|
|
|
List<HydropowerUnitTargetVo> stationTargets = targets.stream().filter(device->device.getDeptId().equals(station.getRefDept())).collect(Collectors.toList()); |
|
|
|
List<HydropowerUnitTargetVo> stationTargets = targets.stream().filter(target->target.getDeptId().equals(station.getRefDept())).collect(Collectors.toList()); |
|
|
|
// 实际发电量
|
|
|
|
// 实际发电量
|
|
|
|
if(CollectionUtils.isEmpty(stationTargets)){ |
|
|
|
if(CollectionUtils.isEmpty(stationTargets)){ |
|
|
|
item.setRealityGeneration(0.0); |
|
|
|
item.setRealityGeneration(0.0); |
|
|
|
}else { |
|
|
|
}else { |
|
|
|
double sum = targets.stream().mapToDouble(HydropowerUnitTargetVo::getPowerYear).sum(); |
|
|
|
double sum = stationTargets.stream().mapToDouble(HydropowerUnitTargetVo::getPowerYear).sum(); |
|
|
|
item.setRealityGeneration(sum); |
|
|
|
item.setRealityGeneration(sum); |
|
|
|
} |
|
|
|
} |
|
|
|
// 计划发电量
|
|
|
|
if(CollectionUtil.isNotEmpty(plans)){ |
|
|
|
List<Float> planGenerations = plans.stream().filter(plan->plan.getStationId().equals(station.getCode())).map(PlanGenerationEntity::getPlanGeneration).collect(Collectors.toList()); |
|
|
|
// 计划发电量
|
|
|
|
if(CollectionUtils.isEmpty(planGenerations)){ |
|
|
|
double planGenerate = plans.stream().filter(plan -> plan.getStationId().equals(station.getCode())).mapToDouble(PlanGenerationEntity::getPlanGeneration).sum(); |
|
|
|
item.setPlanGeneration(0.0); |
|
|
|
if(Math.abs(planGenerate) <= 0){ |
|
|
|
|
|
|
|
item.setPlanGeneration(0.0); |
|
|
|
|
|
|
|
}else{ |
|
|
|
|
|
|
|
item.setPlanGeneration(planGenerate); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// 完成率
|
|
|
|
|
|
|
|
if(Math.abs(item.getPlanGeneration()) <= 0){ |
|
|
|
|
|
|
|
item.setCompleteRate(0.0); |
|
|
|
|
|
|
|
}else{ |
|
|
|
|
|
|
|
item.setCompleteRate(BigDecimal.valueOf(item.getRealityGeneration() / item.getPlanGeneration() * 100).setScale(1, BigDecimal.ROUND_HALF_UP).doubleValue()); |
|
|
|
|
|
|
|
} |
|
|
|
}else{ |
|
|
|
}else{ |
|
|
|
item.setPlanGeneration(BigDecimal.valueOf(planGenerations.get(0)).setScale(1, BigDecimal.ROUND_HALF_UP).doubleValue()); |
|
|
|
item.setPlanGeneration(0.0); |
|
|
|
} |
|
|
|
|
|
|
|
// 完成率
|
|
|
|
|
|
|
|
if(Math.abs(item.getPlanGeneration()) <= 0){ |
|
|
|
|
|
|
|
item.setCompleteRate(0.0); |
|
|
|
item.setCompleteRate(0.0); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return item; |
|
|
|
|
|
|
|
}).filter(complete->Math.abs(complete.getPlanGeneration()) > 0 || Math.abs(complete.getRealityGeneration()) > 0).collect(Collectors.toList()); |
|
|
|
|
|
|
|
}else if(HomePageConstant.PHOTOVOLTAIC.equals(type)){ |
|
|
|
|
|
|
|
// 计划发电量
|
|
|
|
|
|
|
|
String mon = DateUtil.format(new Date(),"yyyy"); |
|
|
|
|
|
|
|
List<PowerEntity> plans = powerService.list(Wrappers.<PowerEntity>lambdaQuery() |
|
|
|
|
|
|
|
.in(PowerEntity::getCreateDept,stations.stream().map(StationEntity::getRefDept).collect(Collectors.toList())) |
|
|
|
|
|
|
|
.ge(PowerEntity::getMon, mon + "-01") |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
// 设备指标数据
|
|
|
|
|
|
|
|
List<PhotovoltaicTargetVo> targets = (List<PhotovoltaicTargetVo>) redisTemplate.opsForValue().get(load_photovoltaic_target_key); |
|
|
|
|
|
|
|
if(CollectionUtils.isEmpty(targets)){ |
|
|
|
|
|
|
|
return new ArrayList<>(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return stations.stream().map(station->{ |
|
|
|
|
|
|
|
CompleteGenerationVo item = new CompleteGenerationVo(); |
|
|
|
|
|
|
|
item.setStationName(station.getName()); |
|
|
|
|
|
|
|
List<PhotovoltaicTargetVo> stationTargets = targets.stream().filter(target->target.getDeptId().equals(station.getRefDept())).collect(Collectors.toList()); |
|
|
|
|
|
|
|
// 实际发电量
|
|
|
|
|
|
|
|
if(CollectionUtils.isEmpty(stationTargets)){ |
|
|
|
|
|
|
|
item.setRealityGeneration(0.0); |
|
|
|
|
|
|
|
}else { |
|
|
|
|
|
|
|
double sum = stationTargets.stream().mapToDouble(PhotovoltaicTargetVo::getGenerationYear).sum(); |
|
|
|
|
|
|
|
item.setRealityGeneration(sum); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if(CollectionUtil.isNotEmpty(plans)){ |
|
|
|
|
|
|
|
// 计划发电量
|
|
|
|
|
|
|
|
double planGenerate = plans.stream().filter(plan -> plan.getCreateDept().equals(station.getRefDept())).mapToDouble(PowerEntity::getPlannedPowerMon).sum(); |
|
|
|
|
|
|
|
if(Math.abs(planGenerate) <= 0){ |
|
|
|
|
|
|
|
item.setPlanGeneration(0.0); |
|
|
|
|
|
|
|
}else{ |
|
|
|
|
|
|
|
item.setPlanGeneration(planGenerate); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// 完成率
|
|
|
|
|
|
|
|
if(Math.abs(item.getPlanGeneration()) <= 0){ |
|
|
|
|
|
|
|
item.setCompleteRate(0.0); |
|
|
|
|
|
|
|
}else{ |
|
|
|
|
|
|
|
item.setCompleteRate(BigDecimal.valueOf(item.getRealityGeneration() / item.getPlanGeneration() * 100).setScale(1, BigDecimal.ROUND_HALF_UP).doubleValue()); |
|
|
|
|
|
|
|
} |
|
|
|
}else{ |
|
|
|
}else{ |
|
|
|
item.setCompleteRate(BigDecimal.valueOf(item.getRealityGeneration() / item.getPlanGeneration() * 100).setScale(1, BigDecimal.ROUND_HALF_UP).doubleValue()); |
|
|
|
item.setPlanGeneration(0.0); |
|
|
|
|
|
|
|
item.setCompleteRate(0.0); |
|
|
|
} |
|
|
|
} |
|
|
|
return item; |
|
|
|
return item; |
|
|
|
}).collect(Collectors.toList()); |
|
|
|
}).filter(complete->Math.abs(complete.getPlanGeneration()) > 0 || Math.abs(complete.getRealityGeneration()) > 0).collect(Collectors.toList()); |
|
|
|
} |
|
|
|
} |
|
|
|
String mon = DateUtil.format(new Date(),"yyyy"); |
|
|
|
String mon = DateUtil.format(new Date(),"yyyy"); |
|
|
|
List<PowerEntity> powers = powerService.list(Wrappers.<PowerEntity>lambdaQuery() |
|
|
|
List<PowerEntity> powers = powerService.list(Wrappers.<PowerEntity>lambdaQuery() |
|
|
@ -327,24 +377,20 @@ public class TargetServiceImpl implements TargetService { |
|
|
|
}else{ |
|
|
|
}else{ |
|
|
|
types = Collections.singletonList(type); |
|
|
|
types = Collections.singletonList(type); |
|
|
|
} |
|
|
|
} |
|
|
|
// 获取水电站区域机构
|
|
|
|
List<Dept> areas = this.areas(types); |
|
|
|
Map<Dept, List<StationEntity>> areas = areaService.getAuthArea(null,null,types,HomePageConstant.HYDROPOWER_SERVETYPE); |
|
|
|
if(CollectionUtils.isEmpty(areas)){ |
|
|
|
if(MapUtils.isEmpty(areas)){ |
|
|
|
|
|
|
|
return new ArrayList<>(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
List<Dept> depts = areas.keySet().stream().filter(dept -> StringUtils.isEmpty(areaName) || dept.getDeptName().contains(areaName)).collect(Collectors.toList()); |
|
|
|
|
|
|
|
if(CollectionUtils.isEmpty(depts)){ |
|
|
|
|
|
|
|
return new ArrayList<>(); |
|
|
|
return new ArrayList<>(); |
|
|
|
} |
|
|
|
} |
|
|
|
// 开始时间
|
|
|
|
// 开始时间
|
|
|
|
LocalDate firstDay = LocalDate.now().withDayOfYear(1); |
|
|
|
LocalDate firstDay = LocalDate.now().withDayOfYear(1); |
|
|
|
LocalDateTime firstDateTime = LocalDateTime.of(firstDay, LocalTime.MIN); |
|
|
|
LocalDateTime firstDateTime = LocalDateTime.of(firstDay, LocalTime.MIN); |
|
|
|
ExecutorService pool = Executors.newFixedThreadPool(depts.size()); |
|
|
|
ThreadFactory namedThreadFactory = new ThreadFactoryBuilder().setNameFormat("storage-taget-pool-%d").build(); |
|
|
|
|
|
|
|
ScheduledExecutorService exe = new ScheduledThreadPoolExecutor(areas.size(), namedThreadFactory, new ThreadPoolExecutor.AbortPolicy()); |
|
|
|
//监控线程执行完后返回结果
|
|
|
|
//监控线程执行完后返回结果
|
|
|
|
CountDownLatch countDownLatch = new CountDownLatch(depts.size()); |
|
|
|
CountDownLatch countDownLatch = new CountDownLatch(areas.size()); |
|
|
|
List<CompleteTicketVo> completeTickets = new ArrayList<>(); |
|
|
|
List<CompleteTicketVo> completeTickets = new ArrayList<>(); |
|
|
|
pool.execute(()-> { |
|
|
|
exe.execute(()-> { |
|
|
|
for (Dept dept: depts) { |
|
|
|
for (Dept dept: areas) { |
|
|
|
// 双票
|
|
|
|
// 双票
|
|
|
|
DoublePassRateVO doublePass = ticketInfoAllClient.getDoublePassRate(Collections.singletonList(dept.getId()), firstDateTime, LocalDateTime.now()); |
|
|
|
DoublePassRateVO doublePass = ticketInfoAllClient.getDoublePassRate(Collections.singletonList(dept.getId()), firstDateTime, LocalDateTime.now()); |
|
|
|
CompleteTicketVo completeTicketVo = new CompleteTicketVo(); |
|
|
|
CompleteTicketVo completeTicketVo = new CompleteTicketVo(); |
|
|
@ -370,8 +416,33 @@ public class TargetServiceImpl implements TargetService { |
|
|
|
e.printStackTrace(); |
|
|
|
e.printStackTrace(); |
|
|
|
Thread.currentThread().interrupt(); |
|
|
|
Thread.currentThread().interrupt(); |
|
|
|
} |
|
|
|
} |
|
|
|
pool.shutdown(); |
|
|
|
exe.shutdown(); |
|
|
|
return completeTickets; |
|
|
|
return completeTickets.stream().filter(complete->Math.abs(Integer.parseInt(complete.getTicketCount())) > 0 || Math.abs(Integer.parseInt(complete.getCompleteCount())) > 0).collect(Collectors.toList()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 获取区域机构 |
|
|
|
|
|
|
|
* @param types |
|
|
|
|
|
|
|
* @return |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private List<Dept> areas(List<Integer> types) { |
|
|
|
|
|
|
|
List<StationEntity> stations = stationService.list(Wrappers.<StationEntity>lambdaQuery() |
|
|
|
|
|
|
|
.eq(StationEntity::getServeType,HomePageConstant.HYDROPOWER_SERVETYPE) |
|
|
|
|
|
|
|
.in(StationEntity::getType,types) |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
if(CollectionUtil.isEmpty(stations)){ |
|
|
|
|
|
|
|
return new ArrayList<>(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
R<List<Dept>> result = sysClient.getDeptByCurrentUser(); |
|
|
|
|
|
|
|
if(!result.isSuccess() || CollectionUtil.isEmpty(result.getData())){ |
|
|
|
|
|
|
|
return new ArrayList<>(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// 站点父级区域
|
|
|
|
|
|
|
|
List<Long> parents = result.getData().stream().filter(dept->stations.stream().map(StationEntity::getRefDept).collect(Collectors.toList()).contains(dept.getId())).map(Dept::getParentId).distinct().collect(Collectors.toList()); |
|
|
|
|
|
|
|
if(CollectionUtil.isEmpty(parents)){ |
|
|
|
|
|
|
|
return new ArrayList<>(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return result.getData().stream().filter(dept->parents.contains(dept.getId()) && HomePageConstant.AREA.equals(dept.getDeptCategory())).collect(Collectors.toList()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
@ -399,7 +470,13 @@ public class TargetServiceImpl implements TargetService { |
|
|
|
// 双票合格率
|
|
|
|
// 双票合格率
|
|
|
|
item.setTicketCount("*"); |
|
|
|
item.setTicketCount("*"); |
|
|
|
item.setCompleteCount("*"); |
|
|
|
item.setCompleteCount("*"); |
|
|
|
item.setCompleteRate(powers.stream().mapToDouble(o->Double.valueOf(o.getDoubleQualifyRate())).average().toString()); |
|
|
|
List<PowerEntity> stationPower = powers.stream().filter(power->power.getCreateDept().equals(station.getRefDept())).collect(Collectors.toList()); |
|
|
|
|
|
|
|
if(CollectionUtil.isEmpty(stationPower)){ |
|
|
|
|
|
|
|
item.setCompleteRate("0.0"); |
|
|
|
|
|
|
|
}else{ |
|
|
|
|
|
|
|
double rate = stationPower.stream().mapToDouble(o->Double.parseDouble(o.getDoubleQualifyRate())).sum(); |
|
|
|
|
|
|
|
item.setCompleteRate(String.valueOf(BigDecimal.valueOf(rate/ stationPower.size()).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue())); |
|
|
|
|
|
|
|
} |
|
|
|
return item; |
|
|
|
return item; |
|
|
|
}).collect(Collectors.toList()); |
|
|
|
}).collect(Collectors.toList()); |
|
|
|
} |
|
|
|
} |
|
|
@ -427,11 +504,13 @@ public class TargetServiceImpl implements TargetService { |
|
|
|
} |
|
|
|
} |
|
|
|
String startTime = this.getFristDayByYear(); |
|
|
|
String startTime = this.getFristDayByYear(); |
|
|
|
String endTime = DateUtil.format(new Date(),DateUtil.PATTERN_DATETIME); |
|
|
|
String endTime = DateUtil.format(new Date(),DateUtil.PATTERN_DATETIME); |
|
|
|
ExecutorService pool = Executors.newFixedThreadPool(depts.size()); |
|
|
|
ThreadFactory namedThreadFactory = new ThreadFactoryBuilder().setNameFormat("storage-taget-pool-%d").build(); |
|
|
|
|
|
|
|
ScheduledExecutorService exe = new ScheduledThreadPoolExecutor(depts.size(), namedThreadFactory, new ThreadPoolExecutor.AbortPolicy()); |
|
|
|
|
|
|
|
|
|
|
|
//监控线程执行完后返回结果
|
|
|
|
//监控线程执行完后返回结果
|
|
|
|
CountDownLatch countDownLatch = new CountDownLatch(depts.size()); |
|
|
|
CountDownLatch countDownLatch = new CountDownLatch(depts.size()); |
|
|
|
List<CompleteDefectVo> completeDefects = new ArrayList<>(); |
|
|
|
List<CompleteDefectVo> completeDefects = new ArrayList<>(); |
|
|
|
pool.execute(()-> { |
|
|
|
exe.execute(()-> { |
|
|
|
for (Dept dept: depts) { |
|
|
|
for (Dept dept: depts) { |
|
|
|
// 缺陷
|
|
|
|
// 缺陷
|
|
|
|
DutyDefectVO defectVO = phenomenonService.getDutyDefect(startTime, endTime, Collections.singletonList(dept.getId())); |
|
|
|
DutyDefectVO defectVO = phenomenonService.getDutyDefect(startTime, endTime, Collections.singletonList(dept.getId())); |
|
|
@ -454,7 +533,7 @@ public class TargetServiceImpl implements TargetService { |
|
|
|
e.printStackTrace(); |
|
|
|
e.printStackTrace(); |
|
|
|
Thread.currentThread().interrupt(); |
|
|
|
Thread.currentThread().interrupt(); |
|
|
|
} |
|
|
|
} |
|
|
|
pool.shutdown(); |
|
|
|
exe.shutdown(); |
|
|
|
return completeDefects; |
|
|
|
return completeDefects; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -660,9 +739,9 @@ public class TargetServiceImpl implements TargetService { |
|
|
|
return new ArrayList<>(); |
|
|
|
return new ArrayList<>(); |
|
|
|
} |
|
|
|
} |
|
|
|
// 获取设备集合
|
|
|
|
// 获取设备集合
|
|
|
|
List<DeviceClassifyVo> deviceClassifys = devices.stream().sorted(Comparator.comparing(EminfoAndEmParamVo::getCreateDept)).map(device -> { |
|
|
|
List<DeviceClassifyVo> deviceClassifys = devices.stream().filter(device->detpIds.contains(device.getCreateDept())).sorted(Comparator.comparing(EminfoAndEmParamVo::getCreateDept)).map(device -> { |
|
|
|
DeviceClassifyVo deviceClassify = new DeviceClassifyVo(); |
|
|
|
DeviceClassifyVo deviceClassify = new DeviceClassifyVo(); |
|
|
|
deviceClassify.setStationName(stations.stream().filter(o-> o.getRefDept().equals(o.getCreateDept())).collect(Collectors.toList()).get(0).getName()); |
|
|
|
deviceClassify.setStationName(stations.stream().filter(o-> o.getRefDept().equals(device.getCreateDept())).collect(Collectors.toList()).get(0).getName()); |
|
|
|
deviceClassify.setDeviceName(device.getName()); |
|
|
|
deviceClassify.setDeviceName(device.getName()); |
|
|
|
if(faultList.contains(device.getEmCode())){ |
|
|
|
if(faultList.contains(device.getEmCode())){ |
|
|
|
deviceClassify.setDeviceStatus(4); |
|
|
|
deviceClassify.setDeviceStatus(4); |
|
|
@ -693,13 +772,12 @@ public class TargetServiceImpl implements TargetService { |
|
|
|
// 站点
|
|
|
|
// 站点
|
|
|
|
LambdaQueryWrapper<StationEntity> wappers = Wrappers.lambdaQuery(); |
|
|
|
LambdaQueryWrapper<StationEntity> wappers = Wrappers.lambdaQuery(); |
|
|
|
wappers.eq(StationEntity::getType, HomePageConstant.HYDROPOWER); |
|
|
|
wappers.eq(StationEntity::getType, HomePageConstant.HYDROPOWER); |
|
|
|
wappers.eq(StationEntity::getServeType,2); |
|
|
|
wappers.eq(StationEntity::getServeType,HomePageConstant.HYDROPOWER_SERVETYPE); |
|
|
|
if(!StringUtils.isEmpty(stationName)){ |
|
|
|
if(!StringUtil.isEmpty(stationName)){ |
|
|
|
wappers.like(StationEntity::getName,stationName); |
|
|
|
wappers.like(StationEntity::getName,stationName); |
|
|
|
} |
|
|
|
} |
|
|
|
if(!ObjectUtil.isEmpty(deptId)){ |
|
|
|
if(ObjectUtil.isNotEmpty(deptId)){ |
|
|
|
List<Long> deptIds = sysClient.getDeptByCurrentUser().getData().stream().filter(dept -> dept.getParentId().equals(deptId)).map(Dept::getId).collect(Collectors.toList()); |
|
|
|
wappers.in(StationEntity::getRefDept,sysClient.getDeptByCurrentUser().getData().stream().filter(dept -> dept.getParentId().equals(deptId)).map(Dept::getId).collect(Collectors.toList())); |
|
|
|
wappers.in(StationEntity::getRefDept,deptIds); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
List<StationEntity> stations = stationService.list(wappers); |
|
|
|
List<StationEntity> stations = stationService.list(wappers); |
|
|
|
if(CollectionUtils.isEmpty(stations)){ |
|
|
|
if(CollectionUtils.isEmpty(stations)){ |
|
|
@ -707,48 +785,44 @@ public class TargetServiceImpl implements TargetService { |
|
|
|
} |
|
|
|
} |
|
|
|
// 功率
|
|
|
|
// 功率
|
|
|
|
if(HomePageConstant.POWER.equals(target)){ |
|
|
|
if(HomePageConstant.POWER.equals(target)){ |
|
|
|
Map<String, Double> activePowerMap = (Map<String, Double>) redisTemplate.opsForValue().get(activePowerKey); |
|
|
|
// 实时数据
|
|
|
|
|
|
|
|
List<HydropowerUnitRealVo> reals = (List<HydropowerUnitRealVo>) redisTemplate.opsForValue().get(load_hydropower_unit_real_key); |
|
|
|
return stations.stream().map(station->{ |
|
|
|
return stations.stream().map(station->{ |
|
|
|
HydropowerTargetVo hydropowerTarget = new HydropowerTargetVo(); |
|
|
|
HydropowerTargetVo hydropower = new HydropowerTargetVo(); |
|
|
|
hydropowerTarget.setStationName(station.getName()); |
|
|
|
hydropower.setStationName(station.getName()); |
|
|
|
if(MapUtils.isEmpty(activePowerMap)){ |
|
|
|
if(CollectionUtil.isEmpty(reals)){ |
|
|
|
hydropowerTarget.setPower(0.0); |
|
|
|
hydropower.setPower(0.0); |
|
|
|
return hydropowerTarget; |
|
|
|
}else{ |
|
|
|
|
|
|
|
hydropower.setPower(reals.stream().filter(real->real.getDeptId().equals(station.getRefDept())).mapToDouble(HydropowerUnitRealVo::getActivePower).sum()); |
|
|
|
} |
|
|
|
} |
|
|
|
Double power = activePowerMap.get(station.getCode()); |
|
|
|
return hydropower; |
|
|
|
hydropowerTarget.setPower(Optional.ofNullable(power).orElse(0.0)); |
|
|
|
})/*.filter(hydropower -> Math.abs(hydropower.getPower()) > 0)*/.sorted(Comparator.comparing(HydropowerTargetVo::getPower)).collect(Collectors.toList()); |
|
|
|
return hydropowerTarget; |
|
|
|
|
|
|
|
}).sorted(Comparator.comparing(HydropowerTargetVo::getPower)).collect(Collectors.toList()); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 指标数据
|
|
|
|
|
|
|
|
List<HydropowerUnitTargetVo> targets = (List<HydropowerUnitTargetVo>) redisTemplate.opsForValue().get(load_hydropower_unit_target_key); |
|
|
|
// 发电量
|
|
|
|
// 发电量
|
|
|
|
KeyIndicatorsVo keyIndicatorsVo = (KeyIndicatorsVo) redisTemplate.opsForValue().get(KEY_INDICATORS_INFO); |
|
|
|
|
|
|
|
// 水电站
|
|
|
|
|
|
|
|
List<PowerStationTotalVo> powers = keyIndicatorsVo.getPowerStationTotalVoList(); |
|
|
|
|
|
|
|
return stations.stream().map(station->{ |
|
|
|
return stations.stream().map(station->{ |
|
|
|
HydropowerTargetVo hydropowerTarget = new HydropowerTargetVo(); |
|
|
|
HydropowerTargetVo hydropowerTarget = new HydropowerTargetVo(); |
|
|
|
hydropowerTarget.setStationName(station.getName()); |
|
|
|
hydropowerTarget.setStationName(station.getName()); |
|
|
|
if(CollectionUtils.isEmpty(powers)){ |
|
|
|
if(CollectionUtils.isEmpty(targets)){ |
|
|
|
hydropowerTarget.setElectric(0.0); |
|
|
|
|
|
|
|
return hydropowerTarget; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
List<PowerStationTotalVo> stationTargets = powers.stream().filter(o-> o.getStationId().equals(station.getId())).collect(Collectors.toList()); |
|
|
|
|
|
|
|
if(CollectionUtils.isEmpty(stationTargets)){ |
|
|
|
|
|
|
|
hydropowerTarget.setElectric(0.0); |
|
|
|
hydropowerTarget.setElectric(0.0); |
|
|
|
return hydropowerTarget; |
|
|
|
}else{ |
|
|
|
} |
|
|
|
switch (target){ |
|
|
|
switch (target){ |
|
|
|
case 3: |
|
|
|
case 3: |
|
|
|
hydropowerTarget.setElectric(targets.stream().filter(t -> t.getDeptId().equals(station.getRefDept())).mapToDouble(HydropowerUnitTargetVo::getPowerYear).sum()); |
|
|
|
hydropowerTarget.setElectric(new BigDecimal(stationTargets.get(0).getCurrentYearPowerGeneration()).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue()); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case 2: |
|
|
|
case 2: |
|
|
|
hydropowerTarget.setElectric(targets.stream().filter(t -> t.getDeptId().equals(station.getRefDept())).mapToDouble(HydropowerUnitTargetVo::getPowerMon).sum()); |
|
|
|
hydropowerTarget.setElectric(stationTargets.get(0).getPowerGeneration()); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case 1: |
|
|
|
case 1: |
|
|
|
hydropowerTarget.setElectric(targets.stream().filter(t -> t.getDeptId().equals(station.getRefDept())).mapToDouble(HydropowerUnitTargetVo::getPowerDay).sum()); |
|
|
|
hydropowerTarget.setElectric(new BigDecimal(stationTargets.get(0).getCurrentDayPowerGeneration()).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue()); |
|
|
|
break; |
|
|
|
break; |
|
|
|
default: |
|
|
|
|
|
|
|
hydropowerTarget.setElectric(0.0); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return hydropowerTarget; |
|
|
|
return hydropowerTarget; |
|
|
|
}).sorted(Comparator.comparing(HydropowerTargetVo::getElectric)).collect(Collectors.toList()); |
|
|
|
})/*.filter(hydropower -> Math.abs(hydropower.getElectric()) > 0)*/.sorted(Comparator.comparing(HydropowerTargetVo::getElectric)).collect(Collectors.toList()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
@ -776,7 +850,7 @@ public class TargetServiceImpl implements TargetService { |
|
|
|
} |
|
|
|
} |
|
|
|
// 负荷
|
|
|
|
// 负荷
|
|
|
|
if(HomePageConstant.LOADING.equals(target)){ |
|
|
|
if(HomePageConstant.LOADING.equals(target)){ |
|
|
|
List<WaterPumpRealVo> pumps = (List<WaterPumpRealVo>) redisTemplate.opsForValue().get(loadwaterpump_real_key); |
|
|
|
List<WaterPumpRealVo> pumps = (List<WaterPumpRealVo>) redisTemplate.opsForValue().get(load_waterpump_real_key); |
|
|
|
return stations.stream().map(station->{ |
|
|
|
return stations.stream().map(station->{ |
|
|
|
WaterTargetVo water = new WaterTargetVo(); |
|
|
|
WaterTargetVo water = new WaterTargetVo(); |
|
|
|
water.setStationName(station.getName()); |
|
|
|
water.setStationName(station.getName()); |
|
|
@ -787,10 +861,10 @@ public class TargetServiceImpl implements TargetService { |
|
|
|
Double use = pumps.stream().filter(o->o.getDeptId().equals(station.getRefDept())).mapToDouble(WaterPumpRealVo::getActivePower).sum(); |
|
|
|
Double use = pumps.stream().filter(o->o.getDeptId().equals(station.getRefDept())).mapToDouble(WaterPumpRealVo::getActivePower).sum(); |
|
|
|
water.setLoad(Optional.ofNullable(use).orElse(0.0)); |
|
|
|
water.setLoad(Optional.ofNullable(use).orElse(0.0)); |
|
|
|
return water; |
|
|
|
return water; |
|
|
|
}).sorted(Comparator.comparing(WaterTargetVo::getLoad)).collect(Collectors.toList()); |
|
|
|
})/*.filter(water -> Math.abs(water.getLoad()) > 0)*/.sorted(Comparator.comparing(WaterTargetVo::getLoad)).collect(Collectors.toList()); |
|
|
|
} |
|
|
|
} |
|
|
|
// 用电量
|
|
|
|
// 用电量
|
|
|
|
List<WaterPumpTargetVo> targets = (List<WaterPumpTargetVo>) redisTemplate.opsForValue().get(loadwaterpump_target_key); |
|
|
|
List<WaterPumpTargetVo> targets = (List<WaterPumpTargetVo>) redisTemplate.opsForValue().get(load_waterpump_target_key); |
|
|
|
return stations.stream().map(station->{ |
|
|
|
return stations.stream().map(station->{ |
|
|
|
WaterTargetVo water = new WaterTargetVo(); |
|
|
|
WaterTargetVo water = new WaterTargetVo(); |
|
|
|
water.setStationName(station.getName()); |
|
|
|
water.setStationName(station.getName()); |
|
|
@ -808,9 +882,69 @@ public class TargetServiceImpl implements TargetService { |
|
|
|
case 1: |
|
|
|
case 1: |
|
|
|
water.setUse(targets.stream().filter(o->o.getDeptId().equals(station.getRefDept())).mapToDouble(WaterPumpTargetVo::getUsrPowerDay).sum()); |
|
|
|
water.setUse(targets.stream().filter(o->o.getDeptId().equals(station.getRefDept())).mapToDouble(WaterPumpTargetVo::getUsrPowerDay).sum()); |
|
|
|
break; |
|
|
|
break; |
|
|
|
|
|
|
|
default: |
|
|
|
|
|
|
|
water.setUse(0.0); |
|
|
|
} |
|
|
|
} |
|
|
|
return water; |
|
|
|
return water; |
|
|
|
}).sorted(Comparator.comparing(WaterTargetVo::getUse)).collect(Collectors.toList()); |
|
|
|
})/*.filter(water -> Math.abs(water.getUse()) > 0)*/.sorted(Comparator.comparing(WaterTargetVo::getUse)).collect(Collectors.toList()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public List<PhotovoTargetVo> photovoltaicTarget(String stationName, Long deptId, Integer target) { |
|
|
|
|
|
|
|
// 站点
|
|
|
|
|
|
|
|
LambdaQueryWrapper<StationEntity> wappers = Wrappers.lambdaQuery(); |
|
|
|
|
|
|
|
wappers.in(StationEntity::getType, HomePageConstant.waterList); |
|
|
|
|
|
|
|
wappers.eq(StationEntity::getServeType,2); |
|
|
|
|
|
|
|
if(!StringUtils.isEmpty(stationName)){ |
|
|
|
|
|
|
|
wappers.like(StationEntity::getName,stationName); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if(!ObjectUtil.isEmpty(deptId)){ |
|
|
|
|
|
|
|
List<Long> deptIds = sysClient.getDeptByCurrentUser().getData().stream().filter(dept -> dept.getParentId().equals(deptId)).map(Dept::getId).collect(Collectors.toList()); |
|
|
|
|
|
|
|
wappers.in(StationEntity::getRefDept,deptIds); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
List<StationEntity> stations = stationService.list(wappers); |
|
|
|
|
|
|
|
if(CollectionUtils.isEmpty(stations)){ |
|
|
|
|
|
|
|
return new ArrayList<>(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// 负荷
|
|
|
|
|
|
|
|
if(HomePageConstant.LOADING.equals(target)){ |
|
|
|
|
|
|
|
// 实时数据
|
|
|
|
|
|
|
|
List<PhotovoltaicRealVo> reals = (List<PhotovoltaicRealVo>) redisTemplate.opsForValue().get(load_photovoltaic_real_key); |
|
|
|
|
|
|
|
return stations.stream().map(station->{ |
|
|
|
|
|
|
|
PhotovoTargetVo photovo = new PhotovoTargetVo(); |
|
|
|
|
|
|
|
photovo.setStationName(station.getName()); |
|
|
|
|
|
|
|
if(CollectionUtil.isEmpty(reals)){ |
|
|
|
|
|
|
|
photovo.setLoad(0.0); |
|
|
|
|
|
|
|
}else{ |
|
|
|
|
|
|
|
photovo.setLoad(reals.stream().filter(o->o.getDeptId().equals(station.getRefDept())).mapToDouble(PhotovoltaicRealVo::getLoad).sum()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return photovo; |
|
|
|
|
|
|
|
})/*.filter(photovoltaic -> Math.abs(photovoltaic.getLoad()) > 0)*/.sorted(Comparator.comparing(PhotovoTargetVo::getLoad)).collect(Collectors.toList()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// 发电量
|
|
|
|
|
|
|
|
List<PhotovoltaicTargetVo> targets = (List<PhotovoltaicTargetVo>) redisTemplate.opsForValue().get(load_photovoltaic_target_key); |
|
|
|
|
|
|
|
return stations.stream().map(station->{ |
|
|
|
|
|
|
|
PhotovoTargetVo photovo = new PhotovoTargetVo(); |
|
|
|
|
|
|
|
photovo.setStationName(station.getName()); |
|
|
|
|
|
|
|
if(CollectionUtil.isEmpty(targets)){ |
|
|
|
|
|
|
|
photovo.setGenerate(0.0); |
|
|
|
|
|
|
|
}else{ |
|
|
|
|
|
|
|
switch (target){ |
|
|
|
|
|
|
|
case 3: |
|
|
|
|
|
|
|
photovo.setGenerate(targets.stream().filter(o->o.getDeptId().equals(station.getRefDept())).mapToDouble(PhotovoltaicTargetVo::getGenerationYear).sum()); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case 2: |
|
|
|
|
|
|
|
photovo.setGenerate(targets.stream().filter(o->o.getDeptId().equals(station.getRefDept())).mapToDouble(PhotovoltaicTargetVo::getGenerationMon).sum()); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case 1: |
|
|
|
|
|
|
|
photovo.setGenerate(targets.stream().filter(o->o.getDeptId().equals(station.getRefDept())).mapToDouble(PhotovoltaicTargetVo::getGenerationDay).sum()); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
default: |
|
|
|
|
|
|
|
photovo.setGenerate(0.0); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return photovo; |
|
|
|
|
|
|
|
})/*.filter(photovo -> Math.abs(photovo.getGenerate()) > 0)*/.sorted(Comparator.comparing(PhotovoTargetVo::getGenerate)).collect(Collectors.toList()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
@ -912,6 +1046,6 @@ public class TargetServiceImpl implements TargetService { |
|
|
|
calendar.add(Calendar.HOUR_OF_DAY, -calendar.get(Calendar.HOUR_OF_DAY)); |
|
|
|
calendar.add(Calendar.HOUR_OF_DAY, -calendar.get(Calendar.HOUR_OF_DAY)); |
|
|
|
calendar.add(Calendar.MINUTE, -calendar.get(Calendar.MINUTE)); |
|
|
|
calendar.add(Calendar.MINUTE, -calendar.get(Calendar.MINUTE)); |
|
|
|
calendar.add(Calendar.SECOND, -calendar.get(Calendar.SECOND)); |
|
|
|
calendar.add(Calendar.SECOND, -calendar.get(Calendar.SECOND)); |
|
|
|
return sdf.format(calendar.getTime()); |
|
|
|
return DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATETIME); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|