Commit c89d5639 authored by caotao's avatar caotao

1.运行监盘省份左侧数据接入

parent 4ce938c7
......@@ -179,6 +179,7 @@ public class CommonConstans {
public static final String YEAR_GEN_HOURS = "年利用小时数";
public static final String WIND_SPEED_THIRTY_SECONDS = "30秒平均风速";
public static final String TOTAL_RADIATION = "辐照度";
public static final String ACTIVE_POWER = "有功功率";
//------------------监盘服务改造新增常量结束------------------------------
......
......@@ -517,7 +517,8 @@ public class DemoController extends BaseController {
public List<CoreValuesDto> testFeignCall() {
List<CoreValuesDto> coreValuesDtos =coreCommonService.getValuesByStationNamesAndPointsNames(null,null);
// monitorService.getTotalData();
monitorService.getNationWideInfo("江西省","gis");
// monitorService.getNationWideInfo("江西省","gis");
monitorService.getCompletionOfPowerIndicatorsByProvinceName(1,20,"陕西省");
// Double sum = coreCommonService.getSumOfByPointName(coreValuesDtos, CommonConstans.DAY_POWER_GENERATION);
// Double avg = coreCommonService.getAverageOfByPointName(coreValuesDtos, CommonConstans.DAY_POWER_GENERATION);
return coreValuesDtos;
......
package com.yeejoin.amos.boot.module.jxiop.biz.service;
import com.yeejoin.amos.boot.module.jxiop.biz.dto.RegionNationWideDto;
import com.yeejoin.amos.boot.module.jxiop.biz.dto.ResultsData;
import java.util.List;
public interface MonitorService {
public void getTotalData();
public List<RegionNationWideDto> getNationWideInfo(String provinceName, String type);
public ResultsData getCompletionOfPowerIndicatorsByProvinceName(int current, int size, String provinceName);
}
......@@ -8,9 +8,7 @@ import com.yeejoin.amos.boot.module.jxiop.api.entity.*;
import com.yeejoin.amos.boot.module.jxiop.api.mapper.*;
import com.yeejoin.amos.boot.module.jxiop.biz.ESDto.ESEquipments;
import com.yeejoin.amos.boot.module.jxiop.biz.constants.CommonConstans;
import com.yeejoin.amos.boot.module.jxiop.biz.dto.CoreValuesDto;
import com.yeejoin.amos.boot.module.jxiop.biz.dto.RegionNationWideDto;
import com.yeejoin.amos.boot.module.jxiop.biz.dto.StationCacheInfoDto;
import com.yeejoin.amos.boot.module.jxiop.biz.dto.*;
import com.yeejoin.amos.boot.module.jxiop.biz.service.CoreCommonService;
import com.yeejoin.amos.boot.module.jxiop.biz.service.MonitorService;
import lombok.RequiredArgsConstructor;
......@@ -22,6 +20,7 @@ import org.typroject.tyboot.component.emq.EmqKeeper;
import java.math.BigDecimal;
import java.net.URLDecoder;
import java.util.*;
import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.Collectors;
@Service
......@@ -217,15 +216,15 @@ public class MonitorServiceImpl implements MonitorService {
regionNationWideDto.setStaitionType(stationCacheInfoDto.getStationType());
String speendOrirradiate = "0.00";
regionNationWideDto.setStationCapacity(stationCacheInfoDto.getInstalledCapacity());
if (stationCacheInfoDto.getStationType().equals("FDZ")&&stationCacheInfoDto.getStationCoreName()!=null&&stationCacheInfoDto.getBoosterCoreName()!=null) {
List<CoreValuesDto> coreValuesDtoList = coreValuesDtos.stream().filter(coreValuesDto ->coreValuesDto.getName().equals(stationCacheInfoDto.getStationCoreName())||coreValuesDto.getName().equals(stationCacheInfoDto.getBoosterCoreName())).collect(Collectors.toList());
if (coreValuesDtoList != null&&coreValuesDtoList.size()>0) {
speendOrirradiate = String.format(CommonConstans.Twodecimalplaces,coreCommonService.getAverageOfByPointName(coreValuesDtoList,CommonConstans.WIND_SPEED_THIRTY_SECONDS));
if (stationCacheInfoDto.getStationType().equals("FDZ") && stationCacheInfoDto.getStationCoreName() != null && stationCacheInfoDto.getBoosterCoreName() != null) {
List<CoreValuesDto> coreValuesDtoList = coreValuesDtos.stream().filter(coreValuesDto -> coreValuesDto.getName().equals(stationCacheInfoDto.getStationCoreName()) || coreValuesDto.getName().equals(stationCacheInfoDto.getBoosterCoreName())).collect(Collectors.toList());
if (coreValuesDtoList != null && coreValuesDtoList.size() > 0) {
speendOrirradiate = String.format(CommonConstans.Twodecimalplaces, coreCommonService.getAverageOfByPointName(coreValuesDtoList, CommonConstans.WIND_SPEED_THIRTY_SECONDS));
}
} else if (stationCacheInfoDto.getStationType().contains("GFDZ")) {
List<CoreValuesDto> coreValuesDtoList = coreValuesDtos.stream().filter(coreValuesDto ->coreValuesDto.getName().equals(stationCacheInfoDto.getStationCoreName())||coreValuesDto.getName().equals(stationCacheInfoDto.getBoosterCoreName())).collect(Collectors.toList());
if (coreValuesDtoList != null&&coreValuesDtoList.size()>0) {
speendOrirradiate = String.format(CommonConstans.Twodecimalplaces,coreCommonService.getAverageOfByPointName(coreValuesDtoList,CommonConstans.WIND_SPEED_THIRTY_SECONDS));
} else if (stationCacheInfoDto.getStationType().contains("GFDZ") && stationCacheInfoDto.getStationCoreName() != null && stationCacheInfoDto.getBoosterCoreName() != null) {
List<CoreValuesDto> coreValuesDtoList = coreValuesDtos.stream().filter(coreValuesDto -> coreValuesDto.getName().equals(stationCacheInfoDto.getStationCoreName()) || coreValuesDto.getName().equals(stationCacheInfoDto.getBoosterCoreName())).collect(Collectors.toList());
if (coreValuesDtoList != null && coreValuesDtoList.size() > 0) {
speendOrirradiate = String.format(CommonConstans.Twodecimalplaces, coreCommonService.getAverageOfByPointName(coreValuesDtoList, CommonConstans.WIND_SPEED_THIRTY_SECONDS));
}
}
......@@ -263,13 +262,149 @@ public class MonitorServiceImpl implements MonitorService {
}
}
public ResultsData getCompletionOfPowerIndicatorsByProvinceName(int current, int size, String provinceName) {
List<ColModel> colModels = new ArrayList<>();
List<CompletionOfPowerIndicatorsDto> completionOfPowerIndicatorsDtoList = new ArrayList<>();
ColModel colModelStatitonName = new ColModel("stationName", "stationName", "场站", "场站", "dataGrid", "stationName");
ColModel colModelInstallCapactity = new ColModel("installCapactity", "installCapactity", "装机容量", "装机容量", "dataGrid", "installCapactity");
ColModel colModelWindSpeedOrIrradiance = new ColModel("windSpeedOrIrradiance", "windSpeedOrIrradiance", "风速/辐照度", "风速/辐照度", "dataGrid", "windSpeedOrIrradiance");
ColModel colModelActivePower = new ColModel("activePower", "activePower", "有功", "有功", "dataGrid", "activePower");
ColModel colModelDailyPower = new ColModel("dailyPower", "dailyPower", "日发电量", "日发电量", "dataGrid", "dailyPower");
ColModel colModelMonthlyPower = new ColModel("monthlyPower", "monthlyPower", "月发电量", "月发电量", "dataGrid", "monthlyPower");
ColModel colModelAnnualPower = new ColModel("annualPower", "annualPower", "年发电量", "年发电量", "dataGrid", "annualPower");
colModels.add(colModelStatitonName);
colModels.add(colModelInstallCapactity);
colModels.add(colModelWindSpeedOrIrradiance);
colModels.add(colModelActivePower);
colModels.add(colModelDailyPower);
colModels.add(colModelMonthlyPower);
colModels.add(colModelAnnualPower);
List<StationCacheInfoDto> stationCacheInfoDtoList = this.getListStationCacheInfoDto();
List<StationCacheInfoDto> stationCacheInfoDtos = stationCacheInfoDtoList.stream().filter(stationCacheInfoDto -> stationCacheInfoDto.getBelongProvince().equals(provinceName)).collect(Collectors.toList());
if (ObjectUtils.isEmpty(stationCacheInfoDtos)) {
DataGridMock dataGridMock = new DataGridMock(current, 0, false, 1, null);
ResultsData resultsData = new ResultsData(dataGridMock, colModels);
return resultsData;
}
//日发电量
AtomicReference<Double> dailyPower = new AtomicReference<>(0.0);
//月发电量
AtomicReference<Double> monthlyPower = new AtomicReference<>(0.0);
//年发电量
AtomicReference<Double> annualPower = new AtomicReference<>(0.0);
//年发电量完成比例
String completionRatio = "0.00";
//年利用小时数
AtomicReference<Double> useHours = new AtomicReference<>(0.0);
AtomicReference<Double> installCapacity = new AtomicReference<>(0.0);
AtomicReference<Double> fdzInstallCapacity = new AtomicReference<>(0.0);
AtomicReference<Double> gfzinstallCapacity = new AtomicReference<>(0.0);
//年发电量
AtomicReference<Double> fdzannualPower = new AtomicReference<>(0.0);
AtomicReference<Double> gfzannualPower = new AtomicReference<>(0.0);
List<CoreValuesDto> coreValuesDtos = coreCommonService.getValuesByStationNamesAndPointsNames(null, null);
//遍历列表
stationCacheInfoDtos.forEach(stationCacheInfoDto -> {
CompletionOfPowerIndicatorsDto completionOfPowerIndicatorsDto = new CompletionOfPowerIndicatorsDto();
completionOfPowerIndicatorsDto.setStationName(stationCacheInfoDto.getStationName());
completionOfPowerIndicatorsDto.setInstallCapactity(stationCacheInfoDto.getInstalledCapacity());
try {
if (stationCacheInfoDto.getStationType().equals("FDZ") && stationCacheInfoDto.getStationCoreName() != null && stationCacheInfoDto.getBoosterCoreName() != null) {
//用于组装-es查询条件
List<CoreValuesDto> coreValuesDtoList = coreValuesDtos.stream().filter(coreValuesDto -> coreValuesDto.getName().equals(stationCacheInfoDto.getStationCoreName()) || coreValuesDto.getName().equals(stationCacheInfoDto.getBoosterCoreName())).collect(Collectors.toList());
if (coreValuesDtoList != null && coreValuesDtoList.size() > 0) {
completionOfPowerIndicatorsDto.setWindSpeedOrIrradiance(String.format(CommonConstans.Twodecimalplaces, coreCommonService.getSumOfByPointName(coreValuesDtoList, CommonConstans.WIND_SPEED_THIRTY_SECONDS)));
completionOfPowerIndicatorsDto.setDailyPower(String.format(CommonConstans.Fourdecimalplaces, coreCommonService.getSumOfByPointName(coreValuesDtoList, CommonConstans.DAY_POWER_GENERATION)));
completionOfPowerIndicatorsDto.setMonthlyPower(String.format(CommonConstans.Fourdecimalplaces, coreCommonService.getSumOfByPointName(coreValuesDtoList, CommonConstans.MONTH_POWER_GENERATION)));
completionOfPowerIndicatorsDto.setAnnualPower(String.format(CommonConstans.Fourdecimalplaces, coreCommonService.getSumOfByPointName(coreValuesDtoList, CommonConstans.YEAR_POWER_GENERATION)));
dailyPower.updateAndGet(v -> v + keepFourdecimalPlaces(coreCommonService.getSumOfByPointName(coreValuesDtoList, CommonConstans.DAY_POWER_GENERATION)));
monthlyPower.updateAndGet(v -> v + keepFourdecimalPlaces(coreCommonService.getSumOfByPointName(coreValuesDtoList, CommonConstans.MONTH_POWER_GENERATION)));
annualPower.updateAndGet(v -> v + keepFourdecimalPlaces(coreCommonService.getSumOfByPointName(coreValuesDtoList, CommonConstans.YEAR_POWER_GENERATION)));
fdzannualPower.updateAndGet(v -> v + keepFourdecimalPlaces(coreCommonService.getSumOfByPointName(coreValuesDtoList, CommonConstans.YEAR_POWER_GENERATION)));
completionOfPowerIndicatorsDto.setActivePower(String.format(CommonConstans.Twodecimalplaces, (coreCommonService.getSumOfByPointName(coreValuesDtoList, CommonConstans.ACTIVE_POWER))));
fdzInstallCapacity.updateAndGet(v -> v + Double.parseDouble(stationCacheInfoDto.getInstalledCapacity()));
}
} else if (stationCacheInfoDto.getStationType().contains("GFDZ") && stationCacheInfoDto.getStationCoreName() != null && stationCacheInfoDto.getBoosterCoreName() != null) {
Map<String, List<String>> queryCondtion = new HashMap<>();
queryCondtion.put(CommonConstans.QueryStringEquipmentIndexName, CommonConstans.taiHeGenIndicator);
queryCondtion.put(CommonConstans.QueryStringGateWayId, Arrays.asList(stationCacheInfoDto.getBoosterGatewayId()));
Map<String, List<String>> queryCondtion1 = new HashMap<>();
queryCondtion1.put(CommonConstans.QueryStringEquipmentIndexName, Arrays.asList("WTX-801_25_WTX-801_总辐射", "南瑞光差保护_313P"));
List<CoreValuesDto> coreValuesDtoList = coreValuesDtos.stream().filter(coreValuesDto -> coreValuesDto.getName().equals(stationCacheInfoDto.getStationCoreName()) || coreValuesDto.getName().equals(stationCacheInfoDto.getBoosterCoreName())).collect(Collectors.toList());
if (coreValuesDtoList != null && coreValuesDtoList.size() > 0) {
completionOfPowerIndicatorsDto.setDailyPower(String.format(CommonConstans.Fourdecimalplaces, coreCommonService.getSumOfByPointName(coreValuesDtoList, CommonConstans.DAY_POWER_GENERATION)));
completionOfPowerIndicatorsDto.setMonthlyPower(String.format(CommonConstans.Fourdecimalplaces, coreCommonService.getSumOfByPointName(coreValuesDtoList, CommonConstans.MONTH_POWER_GENERATION)));
completionOfPowerIndicatorsDto.setAnnualPower(String.format(CommonConstans.Fourdecimalplaces, coreCommonService.getSumOfByPointName(coreValuesDtoList, CommonConstans.YEAR_POWER_GENERATION)));
dailyPower.updateAndGet(v -> v + keepFourdecimalPlaces(coreCommonService.getSumOfByPointName(coreValuesDtoList, CommonConstans.DAY_POWER_GENERATION)));
monthlyPower.updateAndGet(v -> v + keepFourdecimalPlaces(coreCommonService.getSumOfByPointName(coreValuesDtoList, CommonConstans.MONTH_POWER_GENERATION)));
annualPower.updateAndGet(v -> v + keepFourdecimalPlaces(coreCommonService.getSumOfByPointName(coreValuesDtoList, CommonConstans.YEAR_POWER_GENERATION)));
gfzannualPower.updateAndGet(v -> v + keepFourdecimalPlaces(coreCommonService.getSumOfByPointName(coreValuesDtoList, CommonConstans.YEAR_POWER_GENERATION)));
completionOfPowerIndicatorsDto.setWindSpeedOrIrradiance(String.format(CommonConstans.Twodecimalplaces, coreCommonService.getSumOfByPointName(coreValuesDtoList, CommonConstans.TOTAL_RADIATION)));
completionOfPowerIndicatorsDto.setActivePower(String.format(CommonConstans.Twodecimalplaces, coreCommonService.getSumOfByPointName(coreValuesDtoList, CommonConstans.ACTIVE_POWER)));
gfzinstallCapacity.updateAndGet(v -> v + Double.parseDouble(stationCacheInfoDto.getInstalledCapacity()));
}
}else {
completionOfPowerIndicatorsDto.setWindSpeedOrIrradiance("----");
completionOfPowerIndicatorsDto.setActivePower("----");
completionOfPowerIndicatorsDto.setDailyPower("----");
completionOfPowerIndicatorsDto.setMonthlyPower("----");
completionOfPowerIndicatorsDto.setAnnualPower("----");
completionOfPowerIndicatorsDto.setInstallCapactity("----");
}
} catch (Exception exception) {
completionOfPowerIndicatorsDto.setWindSpeedOrIrradiance("----");
completionOfPowerIndicatorsDto.setActivePower("----");
completionOfPowerIndicatorsDto.setDailyPower("----");
completionOfPowerIndicatorsDto.setMonthlyPower("----");
completionOfPowerIndicatorsDto.setAnnualPower("----");
completionOfPowerIndicatorsDto.setInstallCapactity("----");
}
completionOfPowerIndicatorsDtoList.add(completionOfPowerIndicatorsDto);
});
Page<SocialContributionDto> socialContributionDtoPage = new Page<SocialContributionDto>();
List<SocialContributionDto> socialContributionDtoList = new ArrayList<>();
completionRatio = String.format(CommonConstans.Twodecimalplaces, coreCommonService.getAverageOfByPointName(coreValuesDtos, CommonConstans.YEAR_GEN_ATTAINMENT_RATE));
SocialContributionDto dailyPowerdto = new SocialContributionDto();
dailyPowerdto.setTitle(String.format(CommonConstans.Fourdecimalplaces, dailyPower.get()));
dailyPowerdto.setUnit("万kWh");
SocialContributionDto monthlyPowerdto = new SocialContributionDto();
monthlyPowerdto.setTitle(String.format(CommonConstans.Fourdecimalplaces, monthlyPower.get()));
monthlyPowerdto.setUnit("万kWh");
SocialContributionDto annualPowerdto = new SocialContributionDto();
annualPowerdto.setTitle(String.format(CommonConstans.Fourdecimalplaces, annualPower.get()));
annualPowerdto.setUnit("万kWh");
SocialContributionDto completionRatioDto = new SocialContributionDto();
completionRatioDto.setTitle(completionRatio);
completionRatioDto.setUnit("%");
socialContributionDtoList.add(dailyPowerdto);
socialContributionDtoList.add(monthlyPowerdto);
socialContributionDtoList.add(annualPowerdto);
socialContributionDtoList.add(completionRatioDto);
// socialContributionDtoList.add(useHoursDto);
socialContributionDtoPage.setRecords(socialContributionDtoList);
socialContributionDtoPage.setTotal(100);
socialContributionDtoPage.setCurrent(1);
Integer allsize = completionOfPowerIndicatorsDtoList.size();
DataGridMock dataGridMock = new DataGridMock(current, allsize, false, allsize / size + 1, completionOfPowerIndicatorsDtoList);
ResultsData resultsData = new ResultsData(dataGridMock, colModels);
try {
emqKeeper.getMqttClient().publish(provinceName + "_completion_of_powerindicator_list_topic", JSON.toJSON(resultsData).toString().getBytes("UTF-8"), 1, true);
emqKeeper.getMqttClient().publish(provinceName + "_completion_of_powerindicator_topic", JSON.toJSON(socialContributionDtoPage).toString().getBytes("UTF-8"), 1, true);
log.info("-----------------发送区域实时生产数据消息=================== 成功!" + JSON.toJSONString(socialContributionDtoPage));
} catch (Exception exception) {
log.error("-----------------发送区域实时生产数据消息=================== 失败!");
}
return resultsData;
}
/**
* 获取场站的缓存信息,后续启动时需要将此数据从
*
* @return
*/
public List<StationCacheInfoDto> getListStationCacheInfoDto() {
List<StationCacheInfoDto> stationCacheInfoDtos = new ArrayList<>();
List<Region> regionList = regionMapper.selectList(new QueryWrapper<Region>().eq("LEVEL", 1));
List<MapRegion> mapRegionList = mapRegionMapper.selectList(new QueryWrapper<MapRegion>().isNotNull("name"));
......@@ -297,4 +432,8 @@ public class MonitorServiceImpl implements MonitorService {
return stationCacheInfoDtos;
}
public Double keepFourdecimalPlaces(Double param) {
return Double.valueOf(String.format("%.4f", param));
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment