Commit 675f68aa authored by tangwei's avatar tangwei

解决冲突

parents 90171a85 bf4c4b37
...@@ -177,6 +177,39 @@ public class CommonServiceImpl { ...@@ -177,6 +177,39 @@ public class CommonServiceImpl {
return socialContributionDtoPage; return socialContributionDtoPage;
} }
public <T> List<T> getListDataByCondtion(Map<String, List<String>> mustQuerCondtion, Map<String, String> shouldQuerCondtion, Class<T> tClass, Map<String, String> likeQuerCondtion) {
BoolQueryBuilder queryBuilder = QueryBuilders.boolQuery();
if (!ObjectUtils.isEmpty(mustQuerCondtion)) {
for (String key : mustQuerCondtion.keySet()) {
List<String> va = mustQuerCondtion.get(key);
queryBuilder.must(QueryBuilders.termsQuery(key, va));
}
}
if (!ObjectUtils.isEmpty(shouldQuerCondtion)) {
for (String key : shouldQuerCondtion.keySet()) {
queryBuilder.should(QueryBuilders.wildcardQuery(key, shouldQuerCondtion.get(key)));
}
}
if (!ObjectUtils.isEmpty(likeQuerCondtion)) {
for (String key : likeQuerCondtion.keySet()) {
queryBuilder.must(QueryBuilders.wildcardQuery(key, "*" + likeQuerCondtion.get(key) + "*"));
}
}
Query query = new NativeSearchQueryBuilder()
.withQuery(queryBuilder)
.build();
query.setTrackTotalHits(true);
SearchHits search = elasticsearchTemplate.search(query, tClass);
if (search.hasSearchHits()) {
List<SearchHit<T>> searchHitList = search.getSearchHits();
List<T> list = searchHitList.stream().map(hit -> hit.getContent()).collect(Collectors.toList());
return list;
}
return null;
}
public List<StationCacheInfoDto> getListStationCacheInfoDto() { public List<StationCacheInfoDto> getListStationCacheInfoDto() {
List<StationCacheInfoDto> stationCacheInfoDtos = new ArrayList<>(); List<StationCacheInfoDto> stationCacheInfoDtos = new ArrayList<>();
List<Region> regionList = regionMapper.selectList(new QueryWrapper<Region>().eq("LEVEL", 1)); List<Region> regionList = regionMapper.selectList(new QueryWrapper<Region>().eq("LEVEL", 1));
...@@ -213,7 +246,7 @@ public class CommonServiceImpl { ...@@ -213,7 +246,7 @@ public class CommonServiceImpl {
queryBuilder.must( QueryBuilders.termsQuery(key, va)); queryBuilder.must( QueryBuilders.termsQuery(key, va));
} }
TermsAggregationBuilder tb1 = AggregationBuilders.terms("groupKey").field(groupKey); TermsAggregationBuilder tb1 = AggregationBuilders.terms("groupKey").field(groupKey).size(1000);
SumAggregationBuilder buyCountSum = AggregationBuilders.sum("buyCountSum").field(keyavg); SumAggregationBuilder buyCountSum = AggregationBuilders.sum("buyCountSum").field(keyavg);
tb1.subAggregation(buyCountSum); // 通过typeId字段分组统计总数 tb1.subAggregation(buyCountSum); // 通过typeId字段分组统计总数
Query query = new NativeSearchQueryBuilder() Query query = new NativeSearchQueryBuilder()
...@@ -262,7 +295,7 @@ public class CommonServiceImpl { ...@@ -262,7 +295,7 @@ public class CommonServiceImpl {
queryBuilder.must( QueryBuilders.termsQuery(key, va)); queryBuilder.must( QueryBuilders.termsQuery(key, va));
} }
TermsAggregationBuilder tb1 = AggregationBuilders.terms("groupKey").field(groupKey); TermsAggregationBuilder tb1 = AggregationBuilders.terms("groupKey").field(groupKey).size(1000);
AvgAggregationBuilder buyCountAvg = AggregationBuilders.avg("buyCountAvg").field(keyavg); AvgAggregationBuilder buyCountAvg = AggregationBuilders.avg("buyCountAvg").field(keyavg);
tb1.subAggregation(buyCountAvg); // 通过typeId字段分组统计总数 tb1.subAggregation(buyCountAvg); // 通过typeId字段分组统计总数
......
...@@ -1922,18 +1922,40 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator { ...@@ -1922,18 +1922,40 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
public Map<String, Object> generatingCapacity (String gatewayId,String query){ public Map<String, Object> generatingCapacity (String gatewayId,String query){
String querySql = " SELECT * FROM indicators_"+gatewayId+" WHERE equipmentIndexName=~/发电量/"; // String querySql = " SELECT * FROM indicators_"+gatewayId+" WHERE equipmentIndexName=~/发电量/";
if (null != query){ // if (null != query){
querySql = querySql + " "+ query; // querySql = querySql + " "+ query;
// }
// List<IndicatorsDto> queryList = influxDButils.getListData(querySql,IndicatorsDto.class);
// Map<String, List<IndicatorsDto>> maps = queryList.stream().collect(Collectors.groupingBy(IndicatorsDto::getEquipmentIndexName));
// Map<String, Object> hashMap = new HashMap<>();
// for (String s : maps.keySet()) {
// List<IndicatorsDto> indicatorsDtos = maps.get(s);
// Double totalvalue =indicatorsDtos.stream().filter(obj -> !ObjectUtils.isEmpty(obj.getValue())).mapToDouble(l->Double.parseDouble(l.getValue())).sum();
// hashMap.put(s,totalvalue);
// }
// return hashMap;
Map<String, List<String>> queryCondtion = new HashMap<>();
queryCondtion.put(CommonConstans.QueryStringEquipmentIndexName, Arrays.asList("日发电量", "月发电量", "年发电量"));
queryCondtion.put(CommonConstans.QueryStringGateWayId, Arrays.asList(gatewayId));
Map<String, String> likeQuerCondtion = new HashMap<>();
if(query!=null){
likeQuerCondtion.put(CommonConstans.QueryStringFrontMoudle, "逆变器");
} }
List<IndicatorsDto> queryList = influxDButils.getListData(querySql,IndicatorsDto.class);
Map<String, List<IndicatorsDto>> maps = queryList.stream().collect(Collectors.groupingBy(IndicatorsDto::getEquipmentIndexName)); List<ESEquipments> result = commonServiceImpl.getListDataByCondtions(queryCondtion, null, ESEquipments.class, likeQuerCondtion);
Double powerOfDayFD = 0.0000;
Double powerOfMonthFD = 0.0000;
Double powerOfAnnualFD = 0.0000;
powerOfDayFD = powerOfDayFD + keepFourdecimalPlaces(commonServiceImpl.getSumByEquipmentIndxName(result, "日发电量"));
powerOfMonthFD = powerOfMonthFD + keepFourdecimalPlaces(commonServiceImpl.getSumByEquipmentIndxName(result, "月发电量"));
powerOfAnnualFD = powerOfAnnualFD + keepFourdecimalPlaces(commonServiceImpl.getSumByEquipmentIndxName(result, "年发电量"));
Map<String, Object> hashMap = new HashMap<>(); Map<String, Object> hashMap = new HashMap<>();
for (String s : maps.keySet()) { hashMap.put("日发电量",powerOfDayFD);
List<IndicatorsDto> indicatorsDtos = maps.get(s); hashMap.put("月发电量",powerOfMonthFD);
Double totalvalue =indicatorsDtos.stream().filter(obj -> !ObjectUtils.isEmpty(obj.getValue())).mapToDouble(l->Double.parseDouble(l.getValue())).sum(); hashMap.put("年发电量",powerOfAnnualFD);
hashMap.put(s,totalvalue);
}
return hashMap; return hashMap;
} }
...@@ -1952,6 +1974,10 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator { ...@@ -1952,6 +1974,10 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
return "0"; return "0";
} }
public Double keepFourdecimalPlaces(Double param) {
return Double.valueOf(String.format("%.4f", param));
}
} }
...@@ -868,7 +868,7 @@ public class MonitoringServiceImpl { ...@@ -868,7 +868,7 @@ public class MonitoringServiceImpl {
queryCondtion.put(CommonConstans.QueryStringGateWayId,Arrays.asList(stationBasic.getFanGatewayId())); queryCondtion.put(CommonConstans.QueryStringGateWayId,Arrays.asList(stationBasic.getFanGatewayId()));
Map<String,String> shouldQueryCondtion = new HashMap<>(); Map<String,String> shouldQueryCondtion = new HashMap<>();
shouldQueryCondtion.put(CommonConstans.QueryStringFrontMoudle, "逆变器"); shouldQueryCondtion.put(CommonConstans.QueryStringFrontMoudle, "逆变器");
List<ESEquipments> result = commonServiceImpl.getListDataByCondtionsLike(queryCondtion, null, ESEquipments.class,shouldQueryCondtion); List<ESEquipments> result = commonServiceImpl.getListDataByCondtions(queryCondtion, null, ESEquipments.class,shouldQueryCondtion);
powerOfDayGF.updateAndGet(v -> v + commonServiceImpl.getSumByEquipmentIndxName(result, "日发电量")); powerOfDayGF.updateAndGet(v -> v + commonServiceImpl.getSumByEquipmentIndxName(result, "日发电量"));
powerOfMonthGF.updateAndGet(v -> v + commonServiceImpl.getSumByEquipmentIndxName(result, "月发电量")); powerOfMonthGF.updateAndGet(v -> v + commonServiceImpl.getSumByEquipmentIndxName(result, "月发电量"));
powerOfAnnualGF.updateAndGet(v -> v + commonServiceImpl.getSumByEquipmentIndxName(result, "年发电量")); powerOfAnnualGF.updateAndGet(v -> v + commonServiceImpl.getSumByEquipmentIndxName(result, "年发电量"));
......
...@@ -205,7 +205,7 @@ public class MonitoringServiceImpl { ...@@ -205,7 +205,7 @@ public class MonitoringServiceImpl {
queryCondtion.put(CommonConstans.QueryStringGateWayId, Arrays.asList(stationCacheInfoDto.getFanGatewayId())); queryCondtion.put(CommonConstans.QueryStringGateWayId, Arrays.asList(stationCacheInfoDto.getFanGatewayId()));
List<ESEquipments> result = commonServiceImpl.getListDataByCondtions(queryCondtion, null, ESEquipments.class); List<ESEquipments> result = commonServiceImpl.getListDataByCondtions(queryCondtion, null, ESEquipments.class);
completionOfPowerIndicatorsDto.setWindSpeedOrIrradiance(String.format(CommonConstans.Twodecimalplaces, commonServiceImpl.getAvagerByEquipmentIndxName(result, "30秒平均风速"))); completionOfPowerIndicatorsDto.setWindSpeedOrIrradiance(String.format(CommonConstans.Twodecimalplaces, commonServiceImpl.getAvagerByEquipmentIndxName(result, "30秒平均风速")));
completionOfPowerIndicatorsDto.setActivePower(String.format(CommonConstans.Twodecimalplaces, (commonServiceImpl.getSumByEquipmentIndxName(result1, "220kV夏雩线212线路测控装置PCS-9705TA有功功率一次值") / 1000))); completionOfPowerIndicatorsDto.setActivePower(String.format(CommonConstans.Twodecimalplaces, (commonServiceImpl.getSumByEquipmentIndxName(result1, "220kV夏雩线212线路测控装置PCS-9705TA有功功率一次值"))));
completionOfPowerIndicatorsDto.setDailyPower(String.format(CommonConstans.Fourdecimalplaces, commonServiceImpl.getSumByEquipmentIndxName(result, "日发电量"))); completionOfPowerIndicatorsDto.setDailyPower(String.format(CommonConstans.Fourdecimalplaces, commonServiceImpl.getSumByEquipmentIndxName(result, "日发电量")));
completionOfPowerIndicatorsDto.setMonthlyPower(String.format(CommonConstans.Fourdecimalplaces, commonServiceImpl.getSumByEquipmentIndxName(result, "月发电量"))); completionOfPowerIndicatorsDto.setMonthlyPower(String.format(CommonConstans.Fourdecimalplaces, commonServiceImpl.getSumByEquipmentIndxName(result, "月发电量")));
completionOfPowerIndicatorsDto.setAnnualPower(String.format(CommonConstans.Fourdecimalplaces, commonServiceImpl.getSumByEquipmentIndxName(result, "年发电量"))); completionOfPowerIndicatorsDto.setAnnualPower(String.format(CommonConstans.Fourdecimalplaces, commonServiceImpl.getSumByEquipmentIndxName(result, "年发电量")));
...@@ -221,7 +221,7 @@ public class MonitoringServiceImpl { ...@@ -221,7 +221,7 @@ public class MonitoringServiceImpl {
List<ESEquipments> result = commonServiceImpl.getListDataByCondtions(queryCondtion, null, ESEquipments.class, likeQuerCondtion); List<ESEquipments> result = commonServiceImpl.getListDataByCondtions(queryCondtion, null, ESEquipments.class, likeQuerCondtion);
List<ESEquipments> result1 = commonServiceImpl.getListDataByCondtions(queryCondtion1, null, ESEquipments.class); List<ESEquipments> result1 = commonServiceImpl.getListDataByCondtions(queryCondtion1, null, ESEquipments.class);
completionOfPowerIndicatorsDto.setWindSpeedOrIrradiance(String.format(CommonConstans.Twodecimalplaces, commonServiceImpl.getSumByEquipmentIndxName(result1, "WTX-801_25_WTX-801_总辐射"))); completionOfPowerIndicatorsDto.setWindSpeedOrIrradiance(String.format(CommonConstans.Twodecimalplaces, commonServiceImpl.getSumByEquipmentIndxName(result1, "WTX-801_25_WTX-801_总辐射")));
completionOfPowerIndicatorsDto.setActivePower(String.format(CommonConstans.Twodecimalplaces, commonServiceImpl.getSumByEquipmentIndxName(result1, "南瑞光差保护_313P") * CommonConstans.kwToMv)); completionOfPowerIndicatorsDto.setActivePower(String.format(CommonConstans.Twodecimalplaces, commonServiceImpl.getSumByEquipmentIndxName(result1, "南瑞光差保护_313P")));
completionOfPowerIndicatorsDto.setDailyPower(String.format(CommonConstans.Fourdecimalplaces, commonServiceImpl.getSumByEquipmentIndxName(result, "日发电量") * CommonConstans.pvGenPoweActor * CommonConstans.pvGenPoweActorDay)); completionOfPowerIndicatorsDto.setDailyPower(String.format(CommonConstans.Fourdecimalplaces, commonServiceImpl.getSumByEquipmentIndxName(result, "日发电量") * CommonConstans.pvGenPoweActor * CommonConstans.pvGenPoweActorDay));
completionOfPowerIndicatorsDto.setMonthlyPower(String.format(CommonConstans.Fourdecimalplaces, commonServiceImpl.getSumByEquipmentIndxName(result, "月发电量") * CommonConstans.pvGenPoweActor)); completionOfPowerIndicatorsDto.setMonthlyPower(String.format(CommonConstans.Fourdecimalplaces, commonServiceImpl.getSumByEquipmentIndxName(result, "月发电量") * CommonConstans.pvGenPoweActor));
completionOfPowerIndicatorsDto.setAnnualPower(String.format(CommonConstans.Fourdecimalplaces, commonServiceImpl.getSumByEquipmentIndxName(result, "年发电量") * CommonConstans.pvGenPoweActor)); completionOfPowerIndicatorsDto.setAnnualPower(String.format(CommonConstans.Fourdecimalplaces, commonServiceImpl.getSumByEquipmentIndxName(result, "年发电量") * CommonConstans.pvGenPoweActor));
...@@ -286,7 +286,9 @@ public class MonitoringServiceImpl { ...@@ -286,7 +286,9 @@ public class MonitoringServiceImpl {
Map<String, List<String>> queryCondtion = new HashMap<>(); Map<String, List<String>> queryCondtion = new HashMap<>();
queryCondtion.put(CommonConstans.QueryStringEquipmentIndexName, Arrays.asList("日发电量", "月发电量", "年发电量")); queryCondtion.put(CommonConstans.QueryStringEquipmentIndexName, Arrays.asList("日发电量", "月发电量", "年发电量"));
queryCondtion.put(CommonConstans.QueryStringGateWayId, Arrays.asList(stationCacheInfoDto.getFanGatewayId())); queryCondtion.put(CommonConstans.QueryStringGateWayId, Arrays.asList(stationCacheInfoDto.getFanGatewayId()));
List<ESEquipments> result = commonServiceImpl.getListDataByCondtions(queryCondtion, null, ESEquipments.class); Map<String, String> likeQuerCondtion = new HashMap<>();
likeQuerCondtion.put(CommonConstans.QueryStringFrontMoudle, "逆变器");
List<ESEquipments> result = commonServiceImpl.getListDataByCondtions(queryCondtion, null, ESEquipments.class,likeQuerCondtion);
dailyPower.updateAndGet(v -> v + keepFourdecimalPlaces(commonServiceImpl.getSumByEquipmentIndxName(result, "日发电量") * CommonConstans.pvGenPoweActor * CommonConstans.pvGenPoweActorDay)); dailyPower.updateAndGet(v -> v + keepFourdecimalPlaces(commonServiceImpl.getSumByEquipmentIndxName(result, "日发电量") * CommonConstans.pvGenPoweActor * CommonConstans.pvGenPoweActorDay));
monthlyPower.updateAndGet(v -> v + keepFourdecimalPlaces(commonServiceImpl.getSumByEquipmentIndxName(result, "月发电量") * CommonConstans.pvGenPoweActor)); monthlyPower.updateAndGet(v -> v + keepFourdecimalPlaces(commonServiceImpl.getSumByEquipmentIndxName(result, "月发电量") * CommonConstans.pvGenPoweActor));
annualPower.updateAndGet(v -> v + keepFourdecimalPlaces(commonServiceImpl.getSumByEquipmentIndxName(result, "年发电量") * CommonConstans.pvGenPoweActor)); annualPower.updateAndGet(v -> v + keepFourdecimalPlaces(commonServiceImpl.getSumByEquipmentIndxName(result, "年发电量") * CommonConstans.pvGenPoweActor));
...@@ -588,7 +590,7 @@ public class MonitoringServiceImpl { ...@@ -588,7 +590,7 @@ public class MonitoringServiceImpl {
public Page<HashMap<String, String>> getDetailsOnPowergeneration(String areaName) { public Page<HashMap<String, String>> getDetailsOnPowergeneration(String areaName) {
Page<HashMap<String, String>> hashMapPage = new Page<>(1, 99); Page<HashMap<String, String>> hashMapPage = new Page<>(1, 99);
List<HashMap<String, String>> hashMapList = new ArrayList<>(); List<HashMap<String, String>> hashMapList = new ArrayList<>();
List<StationBasic> stationBasicList = stationBasicMapper.selectList(new QueryWrapper<StationBasic>().eq("station_type", "FDZ").isNotNull("fan_gateway_id")); List<StationBasic> stationBasicList = stationBasicMapper.selectList(new QueryWrapper<StationBasic>().isNotNull("fan_gateway_id"));
//日发电量 //日发电量
AtomicReference<Double> dailyPower = new AtomicReference<>(0.0); AtomicReference<Double> dailyPower = new AtomicReference<>(0.0);
//月发电量 //月发电量
...@@ -777,14 +779,14 @@ public class MonitoringServiceImpl { ...@@ -777,14 +779,14 @@ public class MonitoringServiceImpl {
queryCondtion.put(CommonConstans.QueryStringGateWayId, Arrays.asList(stationBasic.getFanGatewayId())); queryCondtion.put(CommonConstans.QueryStringGateWayId, Arrays.asList(stationBasic.getFanGatewayId()));
Map<String, String> shouldQueryCondtion = new HashMap<>(); Map<String, String> shouldQueryCondtion = new HashMap<>();
shouldQueryCondtion.put(CommonConstans.QueryStringFrontMoudle, "逆变器"); shouldQueryCondtion.put(CommonConstans.QueryStringFrontMoudle, "逆变器");
List<ESEquipments> result = commonServiceImpl.getListDataByCondtions(queryCondtion, shouldQueryCondtion, ESEquipments.class); List<ESEquipments> result = commonServiceImpl.getListDataByCondtions(queryCondtion, null, ESEquipments.class,shouldQueryCondtion);
total = commonServiceImpl.getSumByEquipmentIndxName(result, finalIndicator) * CommonConstans.pvGenPoweActor; total = commonServiceImpl.getSumByEquipmentIndxName(result, finalIndicator) * CommonConstans.pvGenPoweActor*CommonConstans.pvGenPoweActorDay;
} else { } else {
Map<String, List<String>> queryCondtion = new HashMap<>(); Map<String, List<String>> queryCondtion = new HashMap<>();
queryCondtion.put(CommonConstans.QueryStringEquipmentIndexName, Arrays.asList(finalIndicator)); queryCondtion.put(CommonConstans.QueryStringEquipmentIndexName, Arrays.asList(finalIndicator));
queryCondtion.put(CommonConstans.QueryStringGateWayId, Arrays.asList(stationBasic.getFanGatewayId())); queryCondtion.put(CommonConstans.QueryStringGateWayId, Arrays.asList(stationBasic.getFanGatewayId()));
List<ESEquipments> result = commonServiceImpl.getListDataByCondtions(queryCondtion, null, ESEquipments.class); List<ESEquipments> result = commonServiceImpl.getListDataByCondtions(queryCondtion, null, ESEquipments.class);
total = commonServiceImpl.getSumByEquipmentIndxName(result, finalIndicator) * CommonConstans.pvGenPoweActor; total = commonServiceImpl.getSumByEquipmentIndxName(result, finalIndicator);
} }
stationBasic.setAddress(String.format(CommonConstans.Twodecimalplaces, (total * 10) / install)); stationBasic.setAddress(String.format(CommonConstans.Twodecimalplaces, (total * 10) / install));
if (stationBasic.getAddress().equals("NaN")) { if (stationBasic.getAddress().equals("NaN")) {
......
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