提交 f99f479b 作者: 925993793@qq.com

统战部接口返回调整

上级 88ba36a4
...@@ -393,8 +393,8 @@ public class StatisticalAnalysisController { ...@@ -393,8 +393,8 @@ public class StatisticalAnalysisController {
public Result<?> singleCountryStatistic(@RequestParam String subjectId, @RequestParam String country, public Result<?> singleCountryStatistic(@RequestParam String subjectId, @RequestParam String country,
@RequestParam(required = false) String startTime, @RequestParam(required = false) String startTime,
@RequestParam(required = false) String endTime) { @RequestParam(required = false) String endTime) {
Map<String, Object> map = esService.singleCountryStatistic(subjectId, country, startTime, endTime); List<Map<String, Object>> maps = esService.singleCountryStatistic(subjectId, country, startTime, endTime);
return Result.OK(map); return Result.OK(maps);
} }
......
...@@ -2829,9 +2829,8 @@ public class EsService { ...@@ -2829,9 +2829,8 @@ public class EsService {
} }
public Map<String,Object> singleCountryStatistic(String subjectId,String country, String startTime, String endTime) { public List<Map<String,Object>> singleCountryStatistic(String subjectId,String country, String startTime, String endTime) {
Map<String, Object> map = new HashMap<>(); List<Map<String,Object>> dataList = new ArrayList<>();
//根据地区的id从ES查询相关的记录 //根据地区的id从ES查询相关的记录
SearchRequest searchRequest = new SearchRequest(Constants.SUBJECT_INDEX); SearchRequest searchRequest = new SearchRequest(Constants.SUBJECT_INDEX);
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder(); SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
...@@ -2876,18 +2875,24 @@ public class EsService { ...@@ -2876,18 +2875,24 @@ public class EsService {
try { try {
SearchResponse searchResponse = client.search(searchRequest, RequestOptions.DEFAULT); SearchResponse searchResponse = client.search(searchRequest, RequestOptions.DEFAULT);
long totalCount = searchResponse.getHits().getTotalHits().value; long totalCount = searchResponse.getHits().getTotalHits().value;
Map<String, Object> countMap = new HashMap<>();
countMap.put("name", "风险事件");
countMap.put("value", totalCount);
dataList.add(countMap);
Aggregations aggregations = searchResponse.getAggregations(); Aggregations aggregations = searchResponse.getAggregations();
ParsedNested labels = aggregations.get("labels"); ParsedNested labels = aggregations.get("labels");
Aggregations labelsAggregations = labels.getAggregations(); Aggregations labelsAggregations = labels.getAggregations();
Terms groupCountry = labelsAggregations.get("group_risk"); Terms groupCountry = labelsAggregations.get("group_risk");
List<? extends Terms.Bucket> buckets = groupCountry.getBuckets(); List<? extends Terms.Bucket> buckets = groupCountry.getBuckets();
String mainRiskType = riskTypeMap.get(buckets.get(0).getKeyAsString()); String mainRiskType = riskTypeMap.get(buckets.get(0).getKeyAsString());
map.put("mainRiskType", mainRiskType); Map<String, Object> riskMap = new HashMap<>();
map.put("totalCount", totalCount); riskMap.put("name", "主要风险");
riskMap.put("value", mainRiskType);
dataList.add(riskMap);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
return map; return dataList;
} }
public List<CountVO> countryStatistic(String subjectId, String startTime, String endTime) { public List<CountVO> countryStatistic(String subjectId, String startTime, String endTime) {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论