Commit 3b428914 authored by zhangsen's avatar zhangsen

监盘大屏bug修改

parent 077f636e
package com.yeejoin.amos.boot.module.jxiop.biz.service.impl; package com.yeejoin.amos.boot.module.jxiop.biz.service.impl;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.module.jxiop.api.entity.MapRegion; import com.yeejoin.amos.boot.module.jxiop.api.entity.MapRegion;
...@@ -16,10 +17,14 @@ import com.yeejoin.amos.boot.module.jxiop.biz.initdata.StationCacheDataInit; ...@@ -16,10 +17,14 @@ import com.yeejoin.amos.boot.module.jxiop.biz.initdata.StationCacheDataInit;
import com.yeejoin.amos.boot.module.jxiop.biz.mapper2.SjglZsjZsbtzMapper; import com.yeejoin.amos.boot.module.jxiop.biz.mapper2.SjglZsjZsbtzMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.utils.InfluxDButils; import com.yeejoin.amos.boot.module.jxiop.biz.utils.InfluxDButils;
import com.yeejoin.amos.component.influxdb.InfluxdbUtil; import com.yeejoin.amos.component.influxdb.InfluxdbUtil;
import lombok.extern.slf4j.Slf4j;
import org.elasticsearch.action.search.SearchRequestBuilder;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.index.query.BoolQueryBuilder; import org.elasticsearch.index.query.BoolQueryBuilder;
import org.elasticsearch.index.query.MatchPhraseQueryBuilder; import org.elasticsearch.index.query.MatchPhraseQueryBuilder;
import org.elasticsearch.index.query.QueryBuilders; import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.search.aggregations.Aggregation; import org.elasticsearch.search.aggregations.Aggregation;
import org.elasticsearch.search.aggregations.AggregationBuilder;
import org.elasticsearch.search.aggregations.AggregationBuilders; import org.elasticsearch.search.aggregations.AggregationBuilders;
import org.elasticsearch.search.aggregations.Aggregations; import org.elasticsearch.search.aggregations.Aggregations;
import org.elasticsearch.search.aggregations.bucket.terms.ParsedStringTerms; import org.elasticsearch.search.aggregations.bucket.terms.ParsedStringTerms;
...@@ -46,6 +51,7 @@ import java.util.Objects; ...@@ -46,6 +51,7 @@ import java.util.Objects;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@Service @Service
@Slf4j
public class CommonServiceImpl { public class CommonServiceImpl {
@Autowired @Autowired
InfluxDButils influxDButils; InfluxDButils influxDButils;
...@@ -216,11 +222,14 @@ public class CommonServiceImpl { ...@@ -216,11 +222,14 @@ public class CommonServiceImpl {
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()
.withQuery(queryBuilder)
.addAggregation(tb1) .addAggregation(tb1)
.withPageable(PageRequest.of(0, 1)) .withQuery(queryBuilder)
.withPageable(PageRequest.of(0, 10000))
.build(); .build();
query.setTrackTotalHits(true); query.setTrackTotalHits(true);
SearchHits search = elasticsearchTemplate.search(query, clas); SearchHits search = elasticsearchTemplate.search(query, clas);
if (search.hasAggregations()) { if (search.hasAggregations()) {
Aggregations aggregations = search.getAggregations(); Aggregations aggregations = search.getAggregations();
......
...@@ -303,7 +303,7 @@ public class LargeScreenImpl { ...@@ -303,7 +303,7 @@ public class LargeScreenImpl {
List<String> listdate= dayReportnq(new Date()); List<String> listdate= dayReportnq(new Date());
seriesData.setAxisData(listdate); seriesData.setAxisData(listdate);
try { try {
emqKeeper.getMqttClient().publish("countryFd", JSON.toJSONString(seriesData).getBytes(),0,false); emqKeeper.getMqttClient().publish("country", JSON.toJSONString(seriesData).getBytes(),0,false);
} catch (MqttException e) { } catch (MqttException e) {
e.printStackTrace(); e.printStackTrace();
} }
...@@ -341,8 +341,8 @@ public class LargeScreenImpl { ...@@ -341,8 +341,8 @@ public class LargeScreenImpl {
mapjn.put("data",listjn); mapjn.put("data",listjn);
mapjn.put("name","当前值"); mapjn.put("name","当前值");
Map<String,Object> mapqn=new HashMap<>(); Map<String,Object> mapqn=new HashMap<>();
mapjn.put("data",listqn); mapqn.put("data",listqn);
mapjn.put("name","同期值"); mapqn.put("name","同期值");
List<Map<String,Object>> list=new ArrayList<>(); List<Map<String,Object>> list=new ArrayList<>();
list.add(mapjn); list.add(mapjn);
...@@ -374,12 +374,13 @@ public class LargeScreenImpl { ...@@ -374,12 +374,13 @@ public class LargeScreenImpl {
List<String> value=new ArrayList<>(); List<String> value=new ArrayList<>();
value.add(RSD); value.add(RSD);
Map<String,List<String>> map=new HashMap<>(); Map<String,List<String>> map=new HashMap<>();
map.put("equipmentIndexName.keyword",value); map.put("equipmentIndexName",value);
List<String> value1=new ArrayList<>(); List<String> value1=new ArrayList<>();
value1.add(monthy); value1.add(monthy);
map.put("moon.keyword",value1); map.put("moon",value1);
List<? extends Terms.Bucket> lidate= commonServiceImpl.getgroupsum(map,"value" ,"day.keyword", ESDailyPowerGeneration.class); List<? extends Terms.Bucket> lidate= commonServiceImpl.getgroupsum(map,"value" ,"day", ESDailyPowerGeneration.class);
Map<String,Double> mapdta=new HashMap<>(); Map<String,Double> mapdta=new HashMap<>();
DecimalFormat format2 = new DecimalFormat("#.0000"); DecimalFormat format2 = new DecimalFormat("#.0000");
...@@ -422,13 +423,13 @@ public class LargeScreenImpl { ...@@ -422,13 +423,13 @@ public class LargeScreenImpl {
List<String> value=new ArrayList<>(); List<String> value=new ArrayList<>();
value.add(RSD); value.add(RSD);
Map<String,List<String>> map=new HashMap<>(); Map<String,List<String>> map=new HashMap<>();
map.put("equipmentIndexName.keyword",value); map.put("equipmentIndexName",value);
map.put("gatewayId.keyword", gatewayId); map.put("gatewayId", gatewayId);
List<String> value1=new ArrayList<>(); List<String> value1=new ArrayList<>();
value1.add(monthy); value1.add(monthy);
map.put("moon.keyword",value1); map.put("moon",value1);
List<? extends Terms.Bucket> lidate= commonServiceImpl.getgroupsum(map,"valueDouble" ,"day.keyword",ESEquipments.class); List<? extends Terms.Bucket> lidate= commonServiceImpl.getgroupsum(map,"value" ,"day",ESDailyPowerGeneration.class);
Map<String,Double> mapdta=new HashMap<>(); Map<String,Double> mapdta=new HashMap<>();
DecimalFormat format2 = new DecimalFormat("#.0000"); DecimalFormat format2 = new DecimalFormat("#.0000");
...@@ -473,7 +474,7 @@ public class LargeScreenImpl { ...@@ -473,7 +474,7 @@ public class LargeScreenImpl {
cal.setTime(month);//month 为指定月份任意日期 cal.setTime(month);//month 为指定月份任意日期
int year = cal.get(Calendar.YEAR); int year = cal.get(Calendar.YEAR);
int m = cal.get(Calendar.MONTH); int m = cal.get(Calendar.MONTH);
int dayNumOfMonth = DateUtil.getDaysByYearMonth(year, m); int dayNumOfMonth = DateUtil.getDaysByYearMonth(year, m + 1);
cal.set(Calendar.DAY_OF_MONTH, 1);// 从一号开始 cal.set(Calendar.DAY_OF_MONTH, 1);// 从一号开始
for (int i = 0; i < dayNumOfMonth; i++ ) { for (int i = 0; i < dayNumOfMonth; i++ ) {
......
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