|
|
|
@ -24,8 +24,10 @@ import com.hnac.hzims.operational.main.service.IMainWorkBenchService;
|
|
|
|
|
import com.hnac.hzims.operational.main.service.IUnitRunningTimeService; |
|
|
|
|
import com.hnac.hzims.operational.main.vo.*; |
|
|
|
|
import com.hnac.hzims.operational.report.vo.StationReportVO; |
|
|
|
|
import com.hnac.hzims.operational.report.vo.StationRunReportVO; |
|
|
|
|
import com.hnac.hzims.operational.station.entity.StationEntity; |
|
|
|
|
import com.hnac.hzims.operational.station.service.IStationService; |
|
|
|
|
import com.hnac.hzims.operational.util.TimeUtils; |
|
|
|
|
import com.hnac.hzinfo.datasearch.analyse.IAnalyseDataSearchClient; |
|
|
|
|
import com.hnac.hzinfo.datasearch.analyse.IAnalyseInstanceClient; |
|
|
|
|
import com.hnac.hzinfo.datasearch.analyse.po.AnalyseCodeByAnalyseDataPO; |
|
|
|
@ -50,6 +52,7 @@ import org.springframework.beans.factory.annotation.Value;
|
|
|
|
|
import org.springframework.data.redis.core.RedisTemplate; |
|
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
|
|
import java.math.BigDecimal; |
|
|
|
|
import java.text.SimpleDateFormat; |
|
|
|
|
import java.time.Duration; |
|
|
|
|
import java.time.LocalDate; |
|
|
|
@ -1340,7 +1343,167 @@ public class MainSystemMonitoringServiceImpl implements IMainSystemMonitoringSer
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private final static String RECENT_YEAR_POWER_DATA = "hzims:operation:key:power:data"; |
|
|
|
|
/** |
|
|
|
|
* 获取部门站点发电量情况 |
|
|
|
|
* @param month 2024-01 月份 |
|
|
|
|
*/ |
|
|
|
|
@Override |
|
|
|
|
public void getElectricSituationByRedis(String month,List<StationRunReportVO> reportVOS, List<StationEntity> stationEntityList) { |
|
|
|
|
String[] yearMon = month.split("-"); |
|
|
|
|
Integer year = Integer.valueOf(yearMon[0]); |
|
|
|
|
Integer mon = Integer.valueOf(yearMon[1]); |
|
|
|
|
List<String> listByYear = TimeUtils.getListByYearMon(year, mon); |
|
|
|
|
String currentMon = TimeUtils.getMon(year, mon); |
|
|
|
|
Integer count=0; |
|
|
|
|
Map<Long, Map<String, Float>> powerMapThree = (Map<Long, Map<String, Float>>) redisTemplate.opsForValue().get(RECENT_YEAR_POWER_DATA); |
|
|
|
|
for (Map.Entry<Long, Map<String, Float>> deviceMap : powerMapThree.entrySet()) { |
|
|
|
|
for (StationEntity stationEntity : stationEntityList) { |
|
|
|
|
if (stationEntity.getId().equals(deviceMap.getKey())) { |
|
|
|
|
StationRunReportVO stationReportVO = new StationRunReportVO(); |
|
|
|
|
count++; |
|
|
|
|
stationReportVO.setIndex(count); |
|
|
|
|
stationReportVO.setStationName(stationEntity.getName()); |
|
|
|
|
//当前机构近三年的数据
|
|
|
|
|
Map<String, Float> value = deviceMap.getValue(); |
|
|
|
|
//当月发电量
|
|
|
|
|
BigDecimal powerMon = value.entrySet().stream().filter(s -> currentMon.equals(s.getKey())).map(s -> BigDecimal.valueOf(s.getValue()).setScale(1,BigDecimal.ROUND_UP)).reduce(BigDecimal.ZERO, BigDecimal::add); |
|
|
|
|
stationReportVO.setFinishPowerMon(powerMon.toString()); |
|
|
|
|
//获取计划月发电量
|
|
|
|
|
R<Float> planPowerMonR = planGenertionClient.planGenerationMonthCount(stationEntity.getCode(), month); |
|
|
|
|
double planPowerMon =0; |
|
|
|
|
if (planPowerMonR.isSuccess()&&ObjectUtil.isNotEmpty(planPowerMonR.getData())) { |
|
|
|
|
planPowerMon = planPowerMonR.getData().doubleValue(); |
|
|
|
|
} |
|
|
|
|
stationReportVO.setPowerMonPlan(planPowerMon); |
|
|
|
|
//当年发电量
|
|
|
|
|
BigDecimal powerYear = value.entrySet().stream().filter(s -> listByYear.contains(s.getKey())).map(s -> BigDecimal.valueOf(s.getValue()).setScale(1,BigDecimal.ROUND_UP)).reduce(BigDecimal.ZERO, BigDecimal::add); |
|
|
|
|
stationReportVO.setFinishPowerYear(powerYear.toString()); |
|
|
|
|
//获取计划年发电量
|
|
|
|
|
Double planPowerYear = planGenertionClient.getPlanPowerYear(Arrays.asList(stationEntity.getId().toString()), yearMon[0]); |
|
|
|
|
stationReportVO.setPowerYearPlan(planPowerYear); |
|
|
|
|
if (ObjectUtil.isNotEmpty(stationReportVO.getPowerMonPlan()) |
|
|
|
|
&&ObjectUtil.isNotEmpty(stationReportVO.getFinishPowerMon()) |
|
|
|
|
&&new BigDecimal(stationReportVO.getPowerMonPlan()).compareTo(BigDecimal.ZERO)!=0){ |
|
|
|
|
BigDecimal monRate = new BigDecimal(stationReportVO.getFinishPowerMon()).multiply(new BigDecimal(100)) |
|
|
|
|
.divide(new BigDecimal(stationReportVO.getPowerMonPlan()), 2, BigDecimal.ROUND_UP); |
|
|
|
|
stationReportVO.setPowerMonRate(monRate.doubleValue()+"%"); |
|
|
|
|
}else { |
|
|
|
|
stationReportVO.setPowerMonRate(new Double(0)+"%"); |
|
|
|
|
} |
|
|
|
|
if (ObjectUtil.isNotEmpty(stationReportVO.getFinishPowerYear()) |
|
|
|
|
&&ObjectUtil.isNotEmpty(stationReportVO.getPowerYearPlan()) |
|
|
|
|
&&new BigDecimal(stationReportVO.getPowerYearPlan()).compareTo(BigDecimal.ZERO)!=0){ |
|
|
|
|
BigDecimal yearRate = new BigDecimal(stationReportVO.getFinishPowerYear()).multiply(new BigDecimal(100)) |
|
|
|
|
.divide(new BigDecimal(stationReportVO.getPowerYearPlan()), 2, BigDecimal.ROUND_UP); |
|
|
|
|
stationReportVO.setPowerYearRate(yearRate.doubleValue()+"%"); |
|
|
|
|
}else { |
|
|
|
|
stationReportVO.setPowerYearRate(new Double(0)+"%"); |
|
|
|
|
} |
|
|
|
|
reportVOS.add(stationReportVO); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
@Override |
|
|
|
|
public List<StationRunReportVO> getElectricSituationV2(String month, String stationId) { |
|
|
|
|
String year = month.split("-")[0]; |
|
|
|
|
List<StationRunReportVO> stationReportVOList = new ArrayList<>(); |
|
|
|
|
DateTimeFormatter df = DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATETIME); |
|
|
|
|
StationRunReportVO stationReportVO = new StationRunReportVO(); |
|
|
|
|
//获取对应的发电量
|
|
|
|
|
StationEntity stationEntity = stationService.getStationByCode(stationId); |
|
|
|
|
stationReportVO.setStationName(stationEntity.getName()); |
|
|
|
|
AtomicReference<Float> powerCount = new AtomicReference<>((float) 0L); |
|
|
|
|
AtomicReference<Float> powerCountYear = new AtomicReference<>((float) 0L); |
|
|
|
|
//获取站点所属部门下的设备列表
|
|
|
|
|
List<String> emCodes = emInfoClient.getEmCodeByDeptIdAndHomePage(stationEntity.getRefDept()).getData(); |
|
|
|
|
if (CollectionUtil.isNotEmpty(emCodes)) { |
|
|
|
|
List<String> emCodeList = analyseInstanceClient.getListAnalyseCode(emCodes).getData(); |
|
|
|
|
if (CollectionUtil.isNotEmpty(emCodeList)) { |
|
|
|
|
List<EmInfoEntity> data = emInfoClient.getEmInfoByEmCodes(emCodeList).getData(); |
|
|
|
|
for (EmInfoEntity emInfoEntity : data) { |
|
|
|
|
int ct = 0; |
|
|
|
|
int pt = 0; |
|
|
|
|
R<EmParamEntity> EmParamEntityCT = emParamClient.getParamByEmId(emInfoEntity.getId(), "ct"); |
|
|
|
|
if (EmParamEntityCT.isSuccess() && ObjectUtil.isNotEmpty(EmParamEntityCT.getData()) |
|
|
|
|
&& StringUtil.isNotBlank(EmParamEntityCT.getData().getParamValue())) { |
|
|
|
|
ct = Integer.valueOf(EmParamEntityCT.getData().getParamValue()); |
|
|
|
|
} |
|
|
|
|
R<EmParamEntity> EmParamEntityPT = emParamClient.getParamByEmId(emInfoEntity.getId(), "pt"); |
|
|
|
|
if (EmParamEntityPT.isSuccess() && ObjectUtil.isNotEmpty(EmParamEntityPT.getData()) |
|
|
|
|
&& StringUtil.isNotBlank(EmParamEntityPT.getData().getParamValue())) { |
|
|
|
|
pt = Integer.valueOf(EmParamEntityPT.getData().getParamValue()); |
|
|
|
|
} |
|
|
|
|
//TODO
|
|
|
|
|
int rideCount = ct * pt; |
|
|
|
|
MainVo vo = new MainVo(); |
|
|
|
|
MainVo yearVo = new MainVo(); |
|
|
|
|
R<EmParamEntity> paramByEmId = emParamClient.getParamByEmId(emInfoEntity.getId(), EquipmentConstants.MainEnum.INSTALLED_CAPACITY.getVal()); |
|
|
|
|
if (paramByEmId.isSuccess()) { |
|
|
|
|
if (ObjectUtil.isNotEmpty(paramByEmId.getData())) { |
|
|
|
|
vo.setInstalledCapacity(paramByEmId.getData().getParamValue()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
//循环所有机组
|
|
|
|
|
//根据设备编号 标识 获取 发电量、有功功率数据
|
|
|
|
|
AnalyseCodeByAnalyseDataPO po = new AnalyseCodeByAnalyseDataPO(); |
|
|
|
|
po.setDeviceCode(emInfoEntity.getNumber()); |
|
|
|
|
List<AnalyzeDataConditionPO> signboardConditions = new ArrayList<>(); |
|
|
|
|
AnalyzeDataConditionPO analyzeDataConditionPO = new AnalyzeDataConditionPO(); |
|
|
|
|
analyzeDataConditionPO.setFull(1);//填充 null
|
|
|
|
|
analyzeDataConditionPO.setSignages(GENERATE_SIGNAGE); |
|
|
|
|
analyzeDataConditionPO.setAccessRules(EquipmentConstants.AccessRulesEnum.DIFF_CYCLE.getType());//取数规则 0=(整点值/最早值)、1=最大值、2=最小值、3=平均值、4=(累计值/和值)、5=(变化值/差值) 6=最新值
|
|
|
|
|
analyzeDataConditionPO.setTimeInterval(1);//间隔
|
|
|
|
|
|
|
|
|
|
//月发电量
|
|
|
|
|
analyzeDataConditionPO.setBeginTime(LocalDateTime.parse(month + "-01 00:00:00", df)); |
|
|
|
|
DateTimeFormatter fmt = DateTimeFormatter.ISO_LOCAL_DATE; |
|
|
|
|
LocalDate localDateMonth = LocalDate.parse(month + "-01"); |
|
|
|
|
String endDateTime = fmt.format(localDateMonth.with(TemporalAdjusters.lastDayOfMonth())) + " 23:59:59"; |
|
|
|
|
analyzeDataConditionPO.setEndTime(LocalDateTime.parse(endDateTime, df)); |
|
|
|
|
setValueGenerateCount(analyzeDataConditionPO, signboardConditions, po, rideCount, vo, EquipmentConstants.CycleTypeEnum.MONTH_CYCLE.getType(), true); |
|
|
|
|
//年发电量
|
|
|
|
|
analyzeDataConditionPO.setBeginTime(LocalDateTime.parse(year + "-01-01 00:00:00", df)); |
|
|
|
|
setValueGenerateCount(analyzeDataConditionPO, signboardConditions, po, rideCount, vo, EquipmentConstants.CycleTypeEnum.YEAR_CYCLE.getType(), true); |
|
|
|
|
powerCount.updateAndGet(v -> new Float(v + vo.getMonthGenerateCount())); |
|
|
|
|
powerCountYear.updateAndGet(v -> new Float(v + yearVo.getYearGenerateCount())); |
|
|
|
|
log.info("------------月发电量:[{}]--------", vo.getMonthGenerateCount()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
Double finishPowerMon = new BigDecimal(powerCount.get()).doubleValue(); |
|
|
|
|
stationReportVO.setFinishPowerMon(finishPowerMon.toString()); |
|
|
|
|
Double finishPowerYear = new BigDecimal(powerCountYear.get()).doubleValue(); |
|
|
|
|
stationReportVO.setFinishPowerYear(finishPowerYear.toString()); |
|
|
|
|
//当年的计划发电量
|
|
|
|
|
Double planPowerYear = planGenertionClient.getPlanPowerYear(Arrays.asList(stationId), year); |
|
|
|
|
stationReportVO.setPowerYearPlan(planPowerYear); |
|
|
|
|
//当月的计划发电量
|
|
|
|
|
R<Float> planPowerMonR = planGenertionClient.planGenerationMonthCount(stationId, month); |
|
|
|
|
Double planPowerMon = planPowerMonR.getData().doubleValue(); |
|
|
|
|
stationReportVO.setPowerMonPlan(planPowerMon); |
|
|
|
|
if (ObjectUtil.isNotEmpty(stationReportVO.getPowerMonPlan()) |
|
|
|
|
&&ObjectUtil.isNotEmpty(stationReportVO.getFinishPowerMon()) |
|
|
|
|
&&new BigDecimal(stationReportVO.getPowerMonPlan()).compareTo(BigDecimal.ZERO)!=0){ |
|
|
|
|
BigDecimal monRate = new BigDecimal(stationReportVO.getFinishPowerMon()).multiply(new BigDecimal(100)) |
|
|
|
|
.divide(new BigDecimal(stationReportVO.getPowerMonPlan()), 2, BigDecimal.ROUND_UP); |
|
|
|
|
stationReportVO.setPowerMonRate(monRate.doubleValue()+"%"); |
|
|
|
|
}else { |
|
|
|
|
stationReportVO.setPowerMonRate(new Double(0)+"%"); |
|
|
|
|
} |
|
|
|
|
if (ObjectUtil.isNotEmpty(stationReportVO.getFinishPowerYear()) |
|
|
|
|
&&ObjectUtil.isNotEmpty(stationReportVO.getPowerYearPlan()) |
|
|
|
|
&&new BigDecimal(stationReportVO.getPowerYearPlan()).compareTo(BigDecimal.ZERO)!=0){ |
|
|
|
|
BigDecimal yearRate = new BigDecimal(stationReportVO.getFinishPowerYear()).multiply(new BigDecimal(100)) |
|
|
|
|
.divide(new BigDecimal(stationReportVO.getPowerYearPlan()), 2, BigDecimal.ROUND_UP); |
|
|
|
|
stationReportVO.setPowerYearRate(yearRate.doubleValue()+"%"); |
|
|
|
|
}else { |
|
|
|
|
stationReportVO.setPowerYearRate(new Double(0)+"%"); |
|
|
|
|
} |
|
|
|
|
stationReportVOList.add(stationReportVO); |
|
|
|
|
return stationReportVOList; |
|
|
|
|
} |
|
|
|
|
/** |
|
|
|
|
* 获取部门站点发电量情况 |
|
|
|
|
* |
|
|
|
@ -1380,12 +1543,12 @@ public class MainSystemMonitoringServiceImpl implements IMainSystemMonitoringSer
|
|
|
|
|
int pt = 0; |
|
|
|
|
R<EmParamEntity> EmParamEntityCT = emParamClient.getParamByEmId(emInfoEntity.getId(), "ct"); |
|
|
|
|
if (EmParamEntityCT.isSuccess() && ObjectUtil.isNotEmpty(EmParamEntityCT.getData()) |
|
|
|
|
&& StringUtil.isNotBlank(EmParamEntityCT.getData().getParamValue())) { |
|
|
|
|
&& StringUtil.isNotBlank(EmParamEntityCT.getData().getParamValue())) { |
|
|
|
|
ct = Integer.valueOf(EmParamEntityCT.getData().getParamValue()); |
|
|
|
|
} |
|
|
|
|
R<EmParamEntity> EmParamEntityPT = emParamClient.getParamByEmId(emInfoEntity.getId(), "pt"); |
|
|
|
|
if (EmParamEntityPT.isSuccess() && ObjectUtil.isNotEmpty(EmParamEntityPT.getData()) |
|
|
|
|
&& StringUtil.isNotBlank(EmParamEntityPT.getData().getParamValue())) { |
|
|
|
|
&& StringUtil.isNotBlank(EmParamEntityPT.getData().getParamValue())) { |
|
|
|
|
pt = Integer.valueOf(EmParamEntityPT.getData().getParamValue()); |
|
|
|
|
} |
|
|
|
|
//TODO
|
|
|
|
|