|
|
|
@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
|
|
import com.google.common.util.concurrent.ThreadFactoryBuilder; |
|
|
|
|
import com.hnac.hzims.EquipmentConstants; |
|
|
|
|
import com.hnac.hzims.equipment.entity.EmParamEntity; |
|
|
|
|
import com.hnac.hzims.equipment.entity.StartStopDurationEntity; |
|
|
|
|
import com.hnac.hzims.equipment.entity.ThirtyGenerationEntity; |
|
|
|
|
import com.hnac.hzims.equipment.entity.ThreeGenerationEntity; |
|
|
|
|
import com.hnac.hzims.equipment.vo.EminfoAndEmParamVo; |
|
|
|
@ -19,10 +20,7 @@ import com.hnac.hzims.operational.main.vo.*;
|
|
|
|
|
import com.hnac.hzims.operational.station.StationConstants; |
|
|
|
|
import com.hnac.hzims.operational.station.entity.HzimsAnalyzeModelStationEntity; |
|
|
|
|
import com.hnac.hzims.operational.station.entity.StationEntity; |
|
|
|
|
import com.hnac.hzims.scheduled.service.equipment.DeviceParamService; |
|
|
|
|
import com.hnac.hzims.scheduled.service.equipment.DeviceService; |
|
|
|
|
import com.hnac.hzims.scheduled.service.equipment.ThirtyGenerateService; |
|
|
|
|
import com.hnac.hzims.scheduled.service.equipment.ThreeGenerateService; |
|
|
|
|
import com.hnac.hzims.scheduled.service.equipment.*; |
|
|
|
|
import com.hnac.hzims.scheduled.service.operation.fill.*; |
|
|
|
|
import com.hnac.hzims.scheduled.service.operation.home.ModelStationService; |
|
|
|
|
import com.hnac.hzims.scheduled.service.operation.home.RealTargetService; |
|
|
|
@ -42,7 +40,6 @@ import com.hnac.hzinfo.sdk.core.response.HzPage;
|
|
|
|
|
import com.hnac.hzinfo.sdk.core.response.Result; |
|
|
|
|
import com.hnac.hzinfo.sdk.v5.device.DeviceDataClient; |
|
|
|
|
import com.xxl.job.core.log.XxlJobLogger; |
|
|
|
|
import io.undertow.util.CopyOnWriteMap; |
|
|
|
|
import lombok.RequiredArgsConstructor; |
|
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
|
import org.apache.commons.collections4.MapUtils; |
|
|
|
@ -58,7 +55,9 @@ import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
|
|
import java.math.BigDecimal; |
|
|
|
|
import java.math.RoundingMode; |
|
|
|
|
import java.time.Duration; |
|
|
|
|
import java.time.LocalDate; |
|
|
|
|
import java.time.LocalDateTime; |
|
|
|
|
import java.time.format.DateTimeFormatter; |
|
|
|
|
import java.util.*; |
|
|
|
|
import java.util.concurrent.*; |
|
|
|
@ -102,6 +101,8 @@ public class RealTargetServiceImpl implements RealTargetService {
|
|
|
|
|
|
|
|
|
|
private final ThirtyGenerateService thirtyGenerateService; |
|
|
|
|
|
|
|
|
|
private final StartStopDurationService startStopDurationService; |
|
|
|
|
|
|
|
|
|
private final RedisTemplate redisTemplate; |
|
|
|
|
|
|
|
|
|
private final IHeWeatherWeatherClient heWeatherWeatherClient; |
|
|
|
@ -293,6 +294,9 @@ public class RealTargetServiceImpl implements RealTargetService {
|
|
|
|
|
List<HydropowerUnitTargetVo> targets = this.generteFill(stations); |
|
|
|
|
// 水电站设备
|
|
|
|
|
List<EminfoAndEmParamVo> devices = this.pumpDevices(stations.stream().map(StationEntity::getRefDept).collect(Collectors.toList())); |
|
|
|
|
// 今年已经过去多少个小时了
|
|
|
|
|
double hoursPassed = this.hoursPassed(); |
|
|
|
|
|
|
|
|
|
Random random = new Random(); |
|
|
|
|
if(CollectionUtil.isNotEmpty(devices)){ |
|
|
|
|
CountDownLatch countDownLatch = new CountDownLatch(devices.size()); |
|
|
|
@ -319,16 +323,29 @@ public class RealTargetServiceImpl implements RealTargetService {
|
|
|
|
|
target.setActivePowerVoList(this.getLoadsByDay(device)); |
|
|
|
|
// 30天发电量
|
|
|
|
|
target.setGenerationPowerVoList(this.getGenerationPowerList(generations,device)); |
|
|
|
|
if(station.isPresent()){ |
|
|
|
|
// 查询设备当年开停机数据
|
|
|
|
|
List<StartStopDurationEntity> durations = startStopDurationService.list(Wrappers.<StartStopDurationEntity>lambdaQuery() |
|
|
|
|
.eq(StartStopDurationEntity::getStationId,station.get().getCode()) |
|
|
|
|
.eq(StartStopDurationEntity::getDeviceCode,device.getEmCode()) |
|
|
|
|
); |
|
|
|
|
if(CollectionUtil.isEmpty(durations)){ |
|
|
|
|
target.setStartupDurationYear(0.0); |
|
|
|
|
target.setShutDownDurationYear(hoursPassed); |
|
|
|
|
}else{ |
|
|
|
|
target.setStartupDurationYear(durations.stream().mapToDouble(StartStopDurationEntity::getStartDuration).sum()); |
|
|
|
|
target.setShutDownDurationYear(durations.stream().mapToDouble(StartStopDurationEntity::getStopDuration).sum()); |
|
|
|
|
} |
|
|
|
|
}else{ |
|
|
|
|
target.setStartupDurationYear(0.0); |
|
|
|
|
target.setShutDownDurationYear(hoursPassed); |
|
|
|
|
} |
|
|
|
|
// FIXME 本次开机/停机时间
|
|
|
|
|
Calendar calendar = Calendar.getInstance(); |
|
|
|
|
calendar.add(Calendar.MINUTE,random.nextInt(1440)); |
|
|
|
|
target.setStartDownTime(DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATETIME)); |
|
|
|
|
// FIXME 本次开/停机时长
|
|
|
|
|
target.setStartupDownDuration(random.nextDouble() * 24); |
|
|
|
|
// FIXME 今年开机时长
|
|
|
|
|
target.setStartupDurationYear(random.nextDouble() * 5024); |
|
|
|
|
// FIXME 今年停机时长
|
|
|
|
|
target.setShutDownDurationYear(5024 - target.getStartupDurationYear()); |
|
|
|
|
targets.add(target); |
|
|
|
|
countDownLatch.countDown(); |
|
|
|
|
}catch (Exception exception){ |
|
|
|
@ -347,7 +364,6 @@ public class RealTargetServiceImpl implements RealTargetService {
|
|
|
|
|
if(CollectionUtil.isEmpty(targets)){ |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
redisTemplate.opsForValue().set(load_hydropower_unit_target_key,targets); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -421,6 +437,20 @@ public class RealTargetServiceImpl implements RealTargetService {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 今年过去多少个小时 |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
private double hoursPassed() { |
|
|
|
|
LocalDateTime now = LocalDateTime.now(); |
|
|
|
|
// 获取当前年份的第一个小时
|
|
|
|
|
LocalDateTime startOfYear = LocalDateTime.of(now.getYear(), 1, 1, 0, 0); |
|
|
|
|
// 计算持续时间
|
|
|
|
|
Duration duration = Duration.between(startOfYear, now); |
|
|
|
|
// 输出过了多少个小时
|
|
|
|
|
return Double.parseDouble(String.valueOf(duration.toHours())); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 水利-泵组实时加载 |
|
|
|
|
* @param param |
|
|
|
|
*/ |
|
|
|
@ -667,10 +697,10 @@ public class RealTargetServiceImpl implements RealTargetService {
|
|
|
|
|
double dischargeFlow=this.getWaterLevel(item.getInstanceCode(),HomePageConstant.DISCHARGE_FLOW); |
|
|
|
|
waterLevelVo.setDischargeFlow(dischargeFlow); |
|
|
|
|
// 前水位当日曲线
|
|
|
|
|
Map<Integer, String> frontCurveMap=this.getWaterLevelMap(item.getInstanceCode(),HomePageConstant.FRONT_WATER_LEVEL); |
|
|
|
|
Map<String, String> frontCurveMap=this.getWaterLevelMap(item.getInstanceCode(),HomePageConstant.FRONT_WATER_LEVEL); |
|
|
|
|
waterLevelVo.setFrontCurveMap(frontCurveMap); |
|
|
|
|
// 后水位当日曲线
|
|
|
|
|
Map<Integer, String> rearCurveMap=this.getWaterLevelMap(item.getInstanceCode(),HomePageConstant.REAR_WATER_LEVEL); |
|
|
|
|
Map<String, String> rearCurveMap=this.getWaterLevelMap(item.getInstanceCode(),HomePageConstant.REAR_WATER_LEVEL); |
|
|
|
|
waterLevelVo.setRearCurveMap(rearCurveMap); |
|
|
|
|
list.add(waterLevelVo); |
|
|
|
|
} |
|
|
|
@ -1262,11 +1292,14 @@ public class RealTargetServiceImpl implements RealTargetService {
|
|
|
|
|
* @param signage |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
private Map<Integer, String> getWaterLevelMap(String instanceCode, String signage) { |
|
|
|
|
// 开始日期
|
|
|
|
|
String start = DateUtil.format(new Date(),DateUtil.PATTERN_DATE) + " 00:00:00"; |
|
|
|
|
// 结束日期
|
|
|
|
|
String end = DateUtil.format(new Date(),DateUtil.PATTERN_DATE) + " 23:59:59"; |
|
|
|
|
private Map<String, String> getWaterLevelMap(String instanceCode, String signage) { |
|
|
|
|
Calendar calendar = Calendar.getInstance(); |
|
|
|
|
calendar.setTime(new Date()); |
|
|
|
|
// 结束时间
|
|
|
|
|
String end = DateUtil.format(calendar.getTime(),"yyyy-MM-dd HH") + ":59:59"; |
|
|
|
|
calendar.add(Calendar.HOUR_OF_DAY,-23); |
|
|
|
|
// 开始时间
|
|
|
|
|
String start = DateUtil.format(calendar.getTime(),"yyyy-MM-dd HH") + ":00:00"; |
|
|
|
|
List<AnalyseDataTaosVO> datas = dataService.periodTargetData(start, end,6, 2,instanceCode,signage); |
|
|
|
|
if(CollectionUtil.isEmpty(datas)){ |
|
|
|
|
return new HashMap<>(); |
|
|
|
@ -1275,14 +1308,14 @@ public class RealTargetServiceImpl implements RealTargetService {
|
|
|
|
|
key-> { |
|
|
|
|
if(key.getTs().contains(".0")){ |
|
|
|
|
Date dateTime = DateUtil.parse(key.getTs(), "yyyy-MM-dd HH:mm:ss.s"); |
|
|
|
|
return dateTime.getHours(); |
|
|
|
|
return DateUtil.format(dateTime,DateUtil.PATTERN_DATETIME); |
|
|
|
|
} |
|
|
|
|
Date dateTime = DateUtil.parse(key.getTs() + ".0", "yyyy-MM-dd HH:mm:ss.s"); |
|
|
|
|
return dateTime.getHours(); |
|
|
|
|
return DateUtil.format(dateTime,DateUtil.PATTERN_DATETIME); |
|
|
|
|
}, |
|
|
|
|
value -> { |
|
|
|
|
if(StringUtil.isEmpty(value.getVal())){ |
|
|
|
|
return ""; |
|
|
|
|
return "0.0"; |
|
|
|
|
} |
|
|
|
|
return value.getVal(); |
|
|
|
|
}) |
|
|
|
@ -1526,7 +1559,7 @@ public class RealTargetServiceImpl implements RealTargetService {
|
|
|
|
|
calendar.add(Calendar.HOUR_OF_DAY,-23); |
|
|
|
|
// 开始日期
|
|
|
|
|
Date start = calendar.getTime(); |
|
|
|
|
List<AnalyseDataTaosVO> records = dataService.periodTargetData(DateUtil.format(start,"yyyy-MM-dd HH") + ":00:00", DateUtil.format(end,DateUtil.PATTERN_DATETIME), 3, 2, device.getEmCode(), HomePageConstant.PV_LOAD); |
|
|
|
|
List<AnalyseDataTaosVO> records = dataService.periodTargetData(DateUtil.format(start,"yyyy-MM-dd HH") + ":00:00", DateUtil.format(start,"yyyy-MM-dd HH") + ":59:59", 3, 2, device.getEmCode(), HomePageConstant.PV_LOAD); |
|
|
|
|
List<ActivePowerVo> activePowers = new ArrayList<>(); |
|
|
|
|
while (start.compareTo(end) <= 0){ |
|
|
|
|
String time = DateUtil.format(start,"yyyy-MM-dd HH"); |
|
|
|
@ -1626,13 +1659,13 @@ public class RealTargetServiceImpl implements RealTargetService {
|
|
|
|
|
target.setDeptName(station.getName()); |
|
|
|
|
// 当年发电量
|
|
|
|
|
target.setPowerYear(generateService.generate(year,station.getCode())); |
|
|
|
|
// FIXME 去年发电量
|
|
|
|
|
// 去年发电量
|
|
|
|
|
target.setPowerYesterYear(0f); |
|
|
|
|
// 当月发电量
|
|
|
|
|
target.setPowerMon(generateService.generate(mon,station.getCode())); |
|
|
|
|
// 当日发电量
|
|
|
|
|
target.setPowerDay(generateService.generate(day,station.getCode())); |
|
|
|
|
// FIXME 昨日发电量
|
|
|
|
|
// 昨日发电量
|
|
|
|
|
target.setPowerYesterDay(0f); |
|
|
|
|
// 30天发电量
|
|
|
|
|
target.setGenerationPowerVoList(generateService.generate30Day(day,station.getCode())); |
|
|
|
|