Commit 9ca6f5bf authored by caotao's avatar caotao

Merge branch 'developer' of http://39.98.45.134:8090/moa/amos-boot-biz into developer

parents f21cfcf3 2dad2cc8
...@@ -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));
......
...@@ -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));
}
} }
...@@ -819,8 +819,8 @@ public class MonitoringServiceImpl { ...@@ -819,8 +819,8 @@ public class MonitoringServiceImpl {
//装机容量 //装机容量
HashMap<String, String> stringHashMap = new HashMap<>(); HashMap<String, String> stringHashMap = new HashMap<>();
BigDecimal totalInstall = new BigDecimal(getInstallCapity(stationBasicListAll)); BigDecimal totalInstall = new BigDecimal(getInstallCapity(stationBasicListAll));
stringHashMap.put("title", totalInstall.toString()); // stringHashMap.put("title", totalInstall.toString());
stringHashMap.put("data", ""); //stringHashMap.put("data", "");
// list.add(stringHashMap); // list.add(stringHashMap);
//风电站 //风电站
HashMap<String, String> stringHashMap1 = new HashMap<>(); HashMap<String, String> stringHashMap1 = new HashMap<>();
......
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