Commit 3836e4bb authored by chenzhao's avatar chenzhao

修改代码

parent 94c86e6c
......@@ -458,7 +458,6 @@ public class CommonServiceImpl {
queryBuilder.should(QueryBuilders.wildcardQuery(key, shouldQuerCondtion.get(key)));
}
}
Query query = new NativeSearchQueryBuilder()
.withQuery(queryBuilder)
.build();
......@@ -471,6 +470,8 @@ public class CommonServiceImpl {
}
return null;
}
public <T> List<T> getListDataByCondtions(Map<String, List<String>> mustQuerCondtion, Map<String, String> shouldQuerCondtion, Map<String, String> notMustQuerCondtion, Class<T> tClass) {
BoolQueryBuilder queryBuilder = QueryBuilders.boolQuery();
if (!ObjectUtils.isEmpty(mustQuerCondtion)) {
......@@ -513,4 +514,36 @@ public class CommonServiceImpl {
result = equipments.stream().filter(esEquipments -> esEquipments.getEquipmentIndexName().equals(indexName)).mapToDouble(ESEquipments::getValueDouble).sum();
return result;
}
public <T> List<T> getListDataByCondtions(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;
}
}
......@@ -280,8 +280,8 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
queryCondtion.put(CommonConstans.QueryStringGateWayId, Arrays.asList(stationBasic.getFanGatewayId()));
List<ESEquipments> result = commonServiceImpl.getListDataByCondtions(queryCondtion, null, ESEquipments.class);
Map<String, List<String>> queryCondtion1 = new HashMap<>();
queryCondtion.put(CommonConstans.QueryStringEquipmentIndexName, Arrays.asList("发电状态"));
queryCondtion.put(CommonConstans.QueryStringGateWayId, Arrays.asList(stationBasic.getFanGatewayId()));
queryCondtion1.put(CommonConstans.QueryStringEquipmentIndexName, Arrays.asList("报警状态"));
queryCondtion1.put(CommonConstans.QueryStringGateWayId, Arrays.asList(stationBasic.getFanGatewayId()));
List<ESEquipments> equipNumList = commonServiceImpl.getListDataByCondtions(queryCondtion1, null, ESEquipments.class);
Map<String, String> collect = result.stream().collect(Collectors.toMap(ESEquipments::getEquipmentNumber, ESEquipments::getEquipmentIndexName, (item1, item2) -> item1));
equipNumList.forEach(item -> {
......@@ -366,7 +366,7 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
ESEquipments esEquipments = result.get(i);
if (esEquipments.getEquipmentIndexName().contains("温度")) {
xList.add(esEquipments.getEquipmentIndexName());
yList.add(esEquipments.getValue());
yList.add(esEquipments.getValueDouble().toString());
}
}
realTimeTemperatureResult.put("axisData", xList);
......@@ -786,18 +786,18 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
public void getStatusJDX(String gatewayId, String stationId, String frontModule) {
Map<String, List<String>> queryCondtion = new HashMap<>();
queryCondtion.put(CommonConstans.QueryStringGateWayId, Arrays.asList(gatewayId));
Map<String, String> shouldCodtion = new HashMap<>();
shouldCodtion.put(CommonConstans.QueryStringFrontMoudle, frontModule);
shouldCodtion.put(CommonConstans.QueryStringDisplayName, "合位");
List<ESEquipments> listData = commonServiceImpl.getListDataByCondtions(queryCondtion, shouldCodtion, ESEquipments.class);
Map<String, String> likeCodtion = new HashMap<>();
likeCodtion.put(CommonConstans.QueryStringFrontMoudle, frontModule);
likeCodtion.put(CommonConstans.QueryStringDisplayName+".keyword", "合位");
List<ESEquipments> listData = commonServiceImpl.getListDataByCondtions(queryCondtion, null, ESEquipments.class,likeCodtion);
List<Map<String, Object>> statusMaps = new ArrayList<>();
Map<String, List<ESEquipments>> collect = listData.stream().collect(Collectors.groupingBy(ESEquipments::getFrontModule, LinkedHashMap::new, Collectors.toList()));
for (String s : collect.keySet()) {
Map<String, Object> statusMap = new HashMap<>();
if (frontModule.equals("前光")) {
shouldCodtion.remove(CommonConstans.QueryStringDisplayName);
shouldCodtion.put(CommonConstans.QueryStringSystemType, "模拟量");
List<ESEquipments> value = commonServiceImpl.getListDataByCondtions(queryCondtion, shouldCodtion, ESEquipments.class);
likeCodtion.remove(CommonConstans.QueryStringDisplayName+".keyword");
likeCodtion.put(CommonConstans.QueryStringSystemType+".keyword", "模拟量");
List<ESEquipments> value = commonServiceImpl.getListDataByCondtions(queryCondtion, null, ESEquipments.class,likeCodtion);
for (ESEquipments indicatorsDto : value) {
Double aDouble = Double.valueOf(indicatorsDto.getValue());
statusMap.put(indicatorsDto.getDisplayName() + "Value", String.format(CommonConstans.Twodecimalplaces, aDouble));
......@@ -859,7 +859,7 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
for (ESEquipments listDatum : listData) {
for (ESEquipments indicatorsDto : listData1) {
if (listDatum.getEquipmentNumber().equals(indicatorsDto.getEquipmentNumber())) {
listDatum.setValueLabel(indicatorsDto.getValue());
listDatum.setValueLabel(String.valueOf(indicatorsDto.getValueDouble()/1000));
}
}
......@@ -869,7 +869,7 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
map.put("title", prefix + listDatum.getEquipmentNumber());
//用于参数传递
map.put("title1", listDatum.getEquipmentNumber());
map.put("windSpeed", listDatum.getValue());
map.put("windSpeed", listDatum.getValueDouble());
map.put("power", listDatum.getValueLabel());
//获取风机状态如果获取到的状态为空-则默认为正常运行状态
String fantStatus = ObjectUtils.isEmpty(fanstatutsHashMap.get(listDatum.getEquipmentNumber())) ? "通讯中断" : fanstatutsHashMap.get(listDatum.getEquipmentNumber());
......@@ -1586,10 +1586,10 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
List<ESEquipments> dtos = list1.stream().filter(e -> e.getEquipmentNumber().equals(s)).collect(Collectors.toList());
if (!ValidationUtil.isEmpty(dtos)) {
for (ESEquipments esEquipments : indicatorsDtos) {
lsv = lsv + Math.pow(Double.parseDouble(esEquipments.getValue()) - Double.parseDouble(dtos.get(0).getValue()), 2);
lsv = lsv + Math.pow(esEquipments.getValueDouble() - dtos.get(0).getValueDouble(), 2);
}
}
lsv = Math.sqrt(lsv) / Double.parseDouble(dtos.get(0).getValue());
lsv = Math.sqrt(lsv) / dtos.get(0).getValueDouble();
}
......@@ -1710,7 +1710,7 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
for (ESEquipments listDatum : listData) {
for (ESEquipments esEquipments : listData1) {
if (esEquipments.getEquipmentNumber().equals(listDatum.getEquipmentNumber())) {
esEquipments.setValueLabel(listDatum.getValue());
esEquipments.setValueLabel(listDatum.getValueDouble().toString());
}
}
}
......@@ -1725,7 +1725,7 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
String number = equipNum.substring(equipNum.length() - 1);
map.put("titie", String.valueOf(num));
map.put("titie" + number, equipNum);
map.put("value" + number, String.format(CommonConstans.Twodecimalplaces, Double.parseDouble(esEquipments.getValue())));
map.put("value" + number, String.format(CommonConstans.Twodecimalplaces, esEquipments.getValueDouble()));
map.put("valueLabel" + number, String.format(CommonConstans.Twodecimalplaces, Double.parseDouble(esEquipments.getValueLabel())));
map.put("state" + number, equipStatesMap.get(esEquipments.getEquipmentNumber()));
maps.add(map);
......
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