|
@@ -2,6 +2,9 @@ package cn.com.taiji.service.impl;
|
|
|
|
|
|
import cn.com.taiji.domain.FusionData;
|
|
|
import cn.com.taiji.domain.FusionQuery;
|
|
|
+import cn.com.taiji.domain.LeaveOutData;
|
|
|
+import cn.com.taiji.domain.StaticOrDynamicData;
|
|
|
+import cn.com.taiji.domain.dto.LeaceOutDto;
|
|
|
import cn.com.taiji.service.FusionAnalysisService;
|
|
|
import cn.com.taiji.utils.DateUtils;
|
|
|
import com.alibaba.excel.EasyExcel;
|
|
@@ -37,7 +40,8 @@ import java.util.Date;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
|
-import static cn.com.taiji.constants.EsIndexConstants.INDEX_SEAT_REALTIMETRAJECTORY;
|
|
|
+import static cn.com.taiji.constants.EsIndexConstants.*;
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* @author xhl
|
|
@@ -51,9 +55,10 @@ public class FusionAnalysisServiceImpl implements FusionAnalysisService {
|
|
|
private RestHighLevelClient client;
|
|
|
|
|
|
@Override
|
|
|
- public void fusionMergeTimeExcelExport(FusionQuery query, HttpServletResponse response) throws IOException, ParseException {
|
|
|
+ public void fusionAnalysisExcelOne(FusionQuery query, HttpServletResponse response) throws IOException, ParseException {
|
|
|
List<FusionData> list = new ArrayList<>();
|
|
|
- String time = DateUtils.format(new Date(),"yyyy-MM-dd");
|
|
|
+ Date startTime = DateUtils.parse(query.getStartTime(),"yyyy-MM-dd");
|
|
|
+ String time = DateUtils.format(startTime,"yyyy-MM-dd");
|
|
|
SearchRequest request = new SearchRequest(INDEX_SEAT_REALTIMETRAJECTORY+time);
|
|
|
// 构建查询条件
|
|
|
BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery();
|
|
@@ -62,18 +67,18 @@ public class FusionAnalysisServiceImpl implements FusionAnalysisService {
|
|
|
searchSourceBuilder.query(boolQueryBuilder);
|
|
|
TermsAggregationBuilder aggBuilder = AggregationBuilders.terms("ship_field_agg")
|
|
|
.field("mergeTarget")
|
|
|
- .size(query.getPageSize())
|
|
|
+ .size(0)
|
|
|
.subAggregation(
|
|
|
AggregationBuilders.topHits("ship_field_agg_top1")
|
|
|
- .size(query.getPageSize())
|
|
|
+ .size(0)
|
|
|
.sort(
|
|
|
SortBuilders.fieldSort("mergeTime").order(SortOrder.ASC)
|
|
|
)
|
|
|
);
|
|
|
- searchSourceBuilder.sort("merge_time", SortOrder.ASC)
|
|
|
+ searchSourceBuilder
|
|
|
.trackTotalHits(true)
|
|
|
.aggregation(aggBuilder)
|
|
|
- .size(query.getPageSize());
|
|
|
+ .size(0);
|
|
|
request.source(searchSourceBuilder);
|
|
|
SearchResponse search = client.search(request, RequestOptions.DEFAULT);
|
|
|
Aggregations aggregations = search.getAggregations();
|
|
@@ -95,8 +100,8 @@ public class FusionAnalysisServiceImpl implements FusionAnalysisService {
|
|
|
if (i != hits.length-1){
|
|
|
Map<String, Object> map = hits[i].getSourceAsMap();
|
|
|
Map<String, Object> map2 = hits[i+1].getSourceAsMap();
|
|
|
- Date date = DateUtils.parse(map.get("merge_time").toString(),"yyyy-MM-dd");
|
|
|
- Date date2 = DateUtils.parse(map2.get("merge_time").toString(),"yyyy-MM-dd");
|
|
|
+ Date date = DateUtils.parse(map.get("mergeTime").toString(),"yyyy-MM-dd");
|
|
|
+ Date date2 = DateUtils.parse(map2.get("mergeTime").toString(),"yyyy-MM-dd");
|
|
|
Long interval = date2.getTime()-date.getTime();
|
|
|
if (interval>6500L){
|
|
|
num++;
|
|
@@ -115,7 +120,390 @@ public class FusionAnalysisServiceImpl implements FusionAnalysisService {
|
|
|
.doWrite(list);
|
|
|
} catch (Exception e) {
|
|
|
// 重置response
|
|
|
- log.info("导出excel失败:{}" + e.getMessage() + e);
|
|
|
+ log.info("导出识别融合数据率波动问题excel失败:{}" + e.getMessage() + e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void fusionAnalysisExcelTwo(FusionQuery query, HttpServletResponse response) throws IOException, ParseException {
|
|
|
+ List<FusionData> list = new ArrayList<>();
|
|
|
+ Date startTime = DateUtils.parse(query.getStartTime(),"yyyy-MM-dd");
|
|
|
+ String time = DateUtils.format(startTime,"yyyy-MM-dd");
|
|
|
+ SearchRequest request = new SearchRequest(INDEX_SEAT_REALTIMETRAJECTORY+time);
|
|
|
+ // 构建查询条件
|
|
|
+ BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery();
|
|
|
+ SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
|
|
|
+ boolQueryBuilder.filter(QueryBuilders.rangeQuery("mergeTime").gte(query.getStartTime()).lte(query.getEndTime()));
|
|
|
+ searchSourceBuilder.query(boolQueryBuilder);
|
|
|
+ TermsAggregationBuilder aggBuilder = AggregationBuilders.terms("ship_field_agg")
|
|
|
+ .field("mergeTarget")
|
|
|
+ .size(0)
|
|
|
+ .subAggregation(
|
|
|
+ AggregationBuilders.terms("ship_field_agg_one")
|
|
|
+ .field("targetCourse")
|
|
|
+ .size(0)
|
|
|
+ .subAggregation(
|
|
|
+ AggregationBuilders.terms("ship_field_agg_two")
|
|
|
+ .field("targetSpeed")
|
|
|
+ .size(0)
|
|
|
+ .subAggregation(AggregationBuilders.topHits("ship_field_agg_top1")
|
|
|
+ .size(0)
|
|
|
+ .sort(
|
|
|
+ SortBuilders.fieldSort("mergeTime").order(SortOrder.ASC)
|
|
|
+ ))
|
|
|
+ )
|
|
|
+ );
|
|
|
+ searchSourceBuilder
|
|
|
+ .trackTotalHits(true)
|
|
|
+ .aggregation(aggBuilder)
|
|
|
+ .size(0);
|
|
|
+ request.source(searchSourceBuilder);
|
|
|
+ SearchResponse search = client.search(request, RequestOptions.DEFAULT);
|
|
|
+ Aggregations aggregations = search.getAggregations();
|
|
|
+ ParsedStringTerms aggregation = aggregations.get("ship_field_agg");
|
|
|
+ for (Terms.Bucket bucket : aggregation.getBuckets()) {
|
|
|
+ FusionData data = new FusionData();
|
|
|
+ ParsedStringTerms terms = bucket.getAggregations().get("ship_field_agg_one");
|
|
|
+ Integer num = 0;
|
|
|
+ for (Terms.Bucket buc : terms.getBuckets()){
|
|
|
+ ParsedStringTerms termsTwo = buc.getAggregations().get("ship_field_agg_two");
|
|
|
+ for (Terms.Bucket ket : termsTwo.getBuckets()){
|
|
|
+ ParsedTopHits topHit = ket.getAggregations().get("ship_field_agg_top1");
|
|
|
+ SearchHits searchHit = topHit.getHits();
|
|
|
+ SearchHit[] hit = searchHit.getHits();
|
|
|
+ for (int i = 0; i < hit.length; i++) {
|
|
|
+ if (num>2){
|
|
|
+ data.setFluctuateNumber(data.getFluctuateNumber()+1);
|
|
|
+ num =0;
|
|
|
+ }
|
|
|
+ if (i != hit.length-1){
|
|
|
+ Map<String, Object> map = hit[i].getSourceAsMap();
|
|
|
+ Map<String, Object> map2 = hit[i+1].getSourceAsMap();
|
|
|
+ Date date = DateUtils.parse(map.get("mergeTime").toString(),"yyyy-MM-dd");
|
|
|
+ Date date2 = DateUtils.parse(map2.get("mergeTime").toString(),"yyyy-MM-dd");
|
|
|
+ Long interval = date2.getTime()-date.getTime();
|
|
|
+ if (interval<6500L){
|
|
|
+ num++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ data.setMergeTarget(bucket.getKeyAsString());
|
|
|
+ data.setTrackCount(Long.valueOf(bucket.getDocCount()));
|
|
|
+ data.setStartTime(query.getStartTime());
|
|
|
+ data.setEndTime(query.getEndTime());
|
|
|
+ list.add(data);
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
|
|
|
+ response.setCharacterEncoding("utf-8");
|
|
|
+ String fileName = URLEncoder.encode("虚假推送问题", "UTF-8");
|
|
|
+ response.setHeader("Content-Disposition", "attachment;filename=" + fileName + ".xlsx");
|
|
|
+ EasyExcel.write(response.getOutputStream(), FusionData.class).sheet("虚假推送问题")
|
|
|
+ .doWrite(list);
|
|
|
+ } catch (Exception e) {
|
|
|
+ // 重置response
|
|
|
+ log.info("导出虚假推送问题excel失败:{}" + e.getMessage() + e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void tianAoLeaveOutExcel(FusionQuery query, HttpServletResponse response) throws IOException, ParseException {
|
|
|
+ List<LeaveOutData> list = new ArrayList<>();
|
|
|
+ List<LeaceOutDto> dtos = new ArrayList<>();
|
|
|
+ Date startTime = DateUtils.parse(query.getStartTime(),"yyyy-MM-dd");
|
|
|
+ String time = DateUtils.format(startTime,"yyyy-MM-dd");
|
|
|
+ SearchRequest request = new SearchRequest(INDEX_SEAT_TRACK_RADAR+time);
|
|
|
+ // 构建查询条件
|
|
|
+ BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery();
|
|
|
+ SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
|
|
|
+ boolQueryBuilder.filter(QueryBuilders.rangeQuery("receiveTime").gte(query.getStartTime()).lte(query.getEndTime()));
|
|
|
+ searchSourceBuilder.query(boolQueryBuilder);
|
|
|
+ TermsAggregationBuilder aggBuilder = AggregationBuilders.terms("ship_field_agg")
|
|
|
+ .field("fusionBatchNum")
|
|
|
+ .size(0);
|
|
|
+ searchSourceBuilder
|
|
|
+ .trackTotalHits(true)
|
|
|
+ .aggregation(aggBuilder)
|
|
|
+ .size(0);
|
|
|
+ request.source(searchSourceBuilder);
|
|
|
+ SearchResponse search = client.search(request, RequestOptions.DEFAULT);
|
|
|
+ Aggregations aggregations = search.getAggregations();
|
|
|
+ ParsedStringTerms aggregation = aggregations.get("ship_field_agg");
|
|
|
+ for (Terms.Bucket bucket : aggregation.getBuckets()) {
|
|
|
+ LeaceOutDto dto = new LeaceOutDto();
|
|
|
+ dto.setBatchNumber(bucket.getKeyAsString());
|
|
|
+ dto.setCount(Long.valueOf(bucket.getDocCount()));
|
|
|
+ dtos.add(dto);
|
|
|
+ }
|
|
|
+ dtos.forEach(item->{
|
|
|
+ LeaveOutData data = new LeaveOutData();
|
|
|
+ SearchRequest request2 = new SearchRequest(INDEX_SEAT_REALTIMETRAJECTORY+time);
|
|
|
+ // 构建查询条件
|
|
|
+ BoolQueryBuilder boolQueryBuilder2 = QueryBuilders.boolQuery();
|
|
|
+ SearchSourceBuilder searchSourceBuilder2 = new SearchSourceBuilder();
|
|
|
+ boolQueryBuilder2.filter(QueryBuilders.wildcardQuery("trackDeviceNo", "*,"+ item.getBatchNumber() +",*"));
|
|
|
+ boolQueryBuilder2.filter(QueryBuilders.rangeQuery("mergeTime").gte(query.getStartTime()).lte(query.getEndTime()));
|
|
|
+ boolQueryBuilder2.filter(QueryBuilders.termsQuery("mergeType","RADAR","AIS_RADAR","BEIDOU_RADAR","AIS_BEIDOU_RADAR"));
|
|
|
+ searchSourceBuilder2.query(boolQueryBuilder2)
|
|
|
+ .trackTotalHits(true)
|
|
|
+ .size(0);
|
|
|
+ request2.source(searchSourceBuilder2);
|
|
|
+ try {
|
|
|
+ SearchResponse search2 = client.search(request, RequestOptions.DEFAULT);
|
|
|
+ SearchHits searchHits = search2.getHits();
|
|
|
+ Long totalHits = searchHits.getTotalHits().value;
|
|
|
+ if (totalHits<5) {
|
|
|
+ SearchHit[] hits = searchHits.getHits();
|
|
|
+ if (hits.length > 0) {
|
|
|
+ JSONObject sourceItem = JSONObject.parseObject(hits[0].getSourceAsString());
|
|
|
+ data.setMergeTarget(sourceItem.getString("mergeTarget"));
|
|
|
+ data.setStartTime(query.getStartTime());
|
|
|
+ data.setEndTime(query.getEndTime());
|
|
|
+ data.setBatchNumber(item.getBatchNumber());
|
|
|
+ data.setOriginalCount(item.getCount());
|
|
|
+ data.setTrackCount(totalHits);
|
|
|
+ list.add(data);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ try {
|
|
|
+ response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
|
|
|
+ response.setCharacterEncoding("utf-8");
|
|
|
+ String fileName = URLEncoder.encode("天奥轨迹数据遗漏", "UTF-8");
|
|
|
+ response.setHeader("Content-Disposition", "attachment;filename=" + fileName + ".xlsx");
|
|
|
+ EasyExcel.write(response.getOutputStream(), LeaveOutData.class).sheet("天奥轨迹数据遗漏")
|
|
|
+ .doWrite(list);
|
|
|
+ } catch (Exception e) {
|
|
|
+ // 重置response
|
|
|
+ log.info("导出天奥轨迹数据遗漏excel失败:{}" + e.getMessage() + e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void beiDouLeaveOutExcel(FusionQuery query, HttpServletResponse response) throws IOException, ParseException {
|
|
|
+ List<LeaveOutData> list = new ArrayList<>();
|
|
|
+ List<LeaceOutDto> dtos = new ArrayList<>();
|
|
|
+ Date startTime = DateUtils.parse(query.getStartTime(),"yyyy-MM-dd");
|
|
|
+ String time = DateUtils.format(startTime,"yyyy-MM-dd");
|
|
|
+ SearchRequest request = new SearchRequest(INDEX_SEAT_TRACK_BEIDOU+time);
|
|
|
+ // 构建查询条件
|
|
|
+ BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery();
|
|
|
+ SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
|
|
|
+ boolQueryBuilder.filter(QueryBuilders.rangeQuery("locationTime").gte(query.getStartTime()).lte(query.getEndTime()));
|
|
|
+ searchSourceBuilder.query(boolQueryBuilder);
|
|
|
+ TermsAggregationBuilder aggBuilder = AggregationBuilders.terms("ship_field_agg")
|
|
|
+ .field("devideNo")
|
|
|
+ .size(0);
|
|
|
+ searchSourceBuilder
|
|
|
+ .trackTotalHits(true)
|
|
|
+ .aggregation(aggBuilder)
|
|
|
+ .size(0);
|
|
|
+ request.source(searchSourceBuilder);
|
|
|
+ SearchResponse search = client.search(request, RequestOptions.DEFAULT);
|
|
|
+ Aggregations aggregations = search.getAggregations();
|
|
|
+ ParsedStringTerms aggregation = aggregations.get("ship_field_agg");
|
|
|
+ for (Terms.Bucket bucket : aggregation.getBuckets()) {
|
|
|
+ LeaceOutDto dto = new LeaceOutDto();
|
|
|
+ dto.setBatchNumber(bucket.getKeyAsString());
|
|
|
+ dto.setCount(Long.valueOf(bucket.getDocCount()));
|
|
|
+ dtos.add(dto);
|
|
|
+ }
|
|
|
+ dtos.forEach(item->{
|
|
|
+ LeaveOutData data = new LeaveOutData();
|
|
|
+ SearchRequest request2 = new SearchRequest(INDEX_SEAT_REALTIMETRAJECTORY+time);
|
|
|
+ // 构建查询条件
|
|
|
+ BoolQueryBuilder boolQueryBuilder2 = QueryBuilders.boolQuery();
|
|
|
+ SearchSourceBuilder searchSourceBuilder2 = new SearchSourceBuilder();
|
|
|
+ boolQueryBuilder2.filter(QueryBuilders.wildcardQuery("trackDeviceNo", "*,"+ item.getBatchNumber() +",*"));
|
|
|
+ boolQueryBuilder2.filter(QueryBuilders.rangeQuery("mergeTime").gte(query.getStartTime()).lte(query.getEndTime()));
|
|
|
+ boolQueryBuilder2.filter(QueryBuilders.termsQuery("mergeType","BEIDOU","AIS_BEIDOU","BEIDOU_RADAR","AIS_BEIDOU_RADAR"));
|
|
|
+ searchSourceBuilder2.query(boolQueryBuilder2)
|
|
|
+ .trackTotalHits(true)
|
|
|
+ .size(0);
|
|
|
+ request2.source(searchSourceBuilder2);
|
|
|
+ try {
|
|
|
+ SearchResponse search2 = client.search(request, RequestOptions.DEFAULT);
|
|
|
+ SearchHits searchHits = search2.getHits();
|
|
|
+ Long totalHits = searchHits.getTotalHits().value;
|
|
|
+ if (totalHits<5) {
|
|
|
+ SearchHit[] hits = searchHits.getHits();
|
|
|
+ if (hits.length > 0) {
|
|
|
+ JSONObject sourceItem = JSONObject.parseObject(hits[0].getSourceAsString());
|
|
|
+ data.setMergeTarget(sourceItem.getString("mergeTarget"));
|
|
|
+ data.setStartTime(query.getStartTime());
|
|
|
+ data.setEndTime(query.getEndTime());
|
|
|
+ data.setBatchNumber(item.getBatchNumber());
|
|
|
+ data.setOriginalCount(item.getCount());
|
|
|
+ data.setTrackCount(totalHits);
|
|
|
+ list.add(data);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ try {
|
|
|
+ response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
|
|
|
+ response.setCharacterEncoding("utf-8");
|
|
|
+ String fileName = URLEncoder.encode("北斗轨迹数据遗漏", "UTF-8");
|
|
|
+ response.setHeader("Content-Disposition", "attachment;filename=" + fileName + ".xlsx");
|
|
|
+ EasyExcel.write(response.getOutputStream(), LeaveOutData.class).sheet("北斗轨迹数据遗漏")
|
|
|
+ .doWrite(list);
|
|
|
+ } catch (Exception e) {
|
|
|
+ // 重置response
|
|
|
+ log.info("导出北斗轨迹数据遗漏excel失败:{}" + e.getMessage() + e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void hlxyjrhLeaveOutExcel(FusionQuery query, HttpServletResponse response) throws IOException, ParseException {
|
|
|
+ List<LeaveOutData> list = new ArrayList<>();
|
|
|
+ List<LeaceOutDto> dtos = new ArrayList<>();
|
|
|
+ Date startTime = DateUtils.parse(query.getStartTime(),"yyyy-MM-dd");
|
|
|
+ String time = DateUtils.format(startTime,"yyyy-MM-dd");
|
|
|
+ SearchRequest request = new SearchRequest(INDEX_SEAT_HLX_FUSION_SHIP+time);
|
|
|
+ // 构建查询条件
|
|
|
+ BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery();
|
|
|
+ SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
|
|
|
+ boolQueryBuilder.filter(QueryBuilders.rangeQuery("time").gte(query.getStartTime()).lte(query.getEndTime()));
|
|
|
+ searchSourceBuilder.query(boolQueryBuilder);
|
|
|
+ TermsAggregationBuilder aggBuilder = AggregationBuilders.terms("ship_field_agg")
|
|
|
+ .field("targetID")
|
|
|
+ .size(0);
|
|
|
+ searchSourceBuilder
|
|
|
+ .trackTotalHits(true)
|
|
|
+ .aggregation(aggBuilder)
|
|
|
+ .size(0);
|
|
|
+ request.source(searchSourceBuilder);
|
|
|
+ SearchResponse search = client.search(request, RequestOptions.DEFAULT);
|
|
|
+ Aggregations aggregations = search.getAggregations();
|
|
|
+ ParsedStringTerms aggregation = aggregations.get("ship_field_agg");
|
|
|
+ for (Terms.Bucket bucket : aggregation.getBuckets()) {
|
|
|
+ LeaceOutDto dto = new LeaceOutDto();
|
|
|
+ dto.setBatchNumber(bucket.getKeyAsString());
|
|
|
+ dto.setCount(Long.valueOf(bucket.getDocCount()));
|
|
|
+ dtos.add(dto);
|
|
|
+ }
|
|
|
+ dtos.forEach(item->{
|
|
|
+ LeaveOutData data = new LeaveOutData();
|
|
|
+ SearchRequest request2 = new SearchRequest(INDEX_SEAT_REALTIMETRAJECTORY+time);
|
|
|
+ // 构建查询条件
|
|
|
+ BoolQueryBuilder boolQueryBuilder2 = QueryBuilders.boolQuery();
|
|
|
+ SearchSourceBuilder searchSourceBuilder2 = new SearchSourceBuilder();
|
|
|
+ boolQueryBuilder2.filter(QueryBuilders.wildcardQuery("trackDeviceNo", "*,"+ item.getBatchNumber() +",*"));
|
|
|
+ boolQueryBuilder2.filter(QueryBuilders.rangeQuery("mergeTime").gte(query.getStartTime()).lte(query.getEndTime()));
|
|
|
+ boolQueryBuilder2.filter(QueryBuilders.termsQuery("mergeType","AIS","RADAR","AIS_BEIDOU","AIS_RADAR","BEIDOU_RADAR","AIS_BEIDOU_RADAR"));
|
|
|
+ searchSourceBuilder2.query(boolQueryBuilder2)
|
|
|
+ .trackTotalHits(true)
|
|
|
+ .size(0);
|
|
|
+ request2.source(searchSourceBuilder2);
|
|
|
+ try {
|
|
|
+ SearchResponse search2 = client.search(request, RequestOptions.DEFAULT);
|
|
|
+ SearchHits searchHits = search2.getHits();
|
|
|
+ Long totalHits = searchHits.getTotalHits().value;
|
|
|
+ if (totalHits<5) {
|
|
|
+ SearchHit[] hits = searchHits.getHits();
|
|
|
+ if (hits.length > 0) {
|
|
|
+ JSONObject sourceItem = JSONObject.parseObject(hits[0].getSourceAsString());
|
|
|
+ data.setMergeTarget(sourceItem.getString("mergeTarget"));
|
|
|
+ data.setStartTime(query.getStartTime());
|
|
|
+ data.setEndTime(query.getEndTime());
|
|
|
+ data.setBatchNumber(item.getBatchNumber());
|
|
|
+ data.setOriginalCount(item.getCount());
|
|
|
+ data.setTrackCount(totalHits);
|
|
|
+ list.add(data);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ try {
|
|
|
+ response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
|
|
|
+ response.setCharacterEncoding("utf-8");
|
|
|
+ String fileName = URLEncoder.encode("海兰信1级融合轨迹数据遗漏", "UTF-8");
|
|
|
+ response.setHeader("Content-Disposition", "attachment;filename=" + fileName + ".xlsx");
|
|
|
+ EasyExcel.write(response.getOutputStream(), LeaveOutData.class).sheet("海兰信1级融合轨迹数据遗漏")
|
|
|
+ .doWrite(list);
|
|
|
+ } catch (Exception e) {
|
|
|
+ // 重置response
|
|
|
+ log.info("导出海兰信1级融合轨迹数据遗漏excel失败:{}" + e.getMessage() + e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void tianaoStaticOrDynamicLeaveOutExcel(FusionQuery query, HttpServletResponse response) throws IOException, ParseException {
|
|
|
+ List<StaticOrDynamicData> list = new ArrayList<>();
|
|
|
+ List<LeaceOutDto> dtos = new ArrayList<>();
|
|
|
+ Date startTime = DateUtils.parse(query.getStartTime(),"yyyy-MM-dd");
|
|
|
+ String time = DateUtils.format(startTime,"yyyy-MM-dd");
|
|
|
+ SearchRequest request = new SearchRequest(INDEX_SEAT_TRACK_RADAR+time);
|
|
|
+ // 构建查询条件
|
|
|
+ BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery();
|
|
|
+ SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
|
|
|
+ boolQueryBuilder.filter(QueryBuilders.rangeQuery("receiveTime").gte(query.getStartTime()).lte(query.getEndTime()));
|
|
|
+ boolQueryBuilder.filter(QueryBuilders.termQuery("targetProper","1"));
|
|
|
+ searchSourceBuilder.query(boolQueryBuilder);
|
|
|
+ TermsAggregationBuilder aggBuilder = AggregationBuilders.terms("ship_field_agg")
|
|
|
+ .field("fusionBatchNum")
|
|
|
+ .size(0);
|
|
|
+ searchSourceBuilder
|
|
|
+ .trackTotalHits(true)
|
|
|
+ .aggregation(aggBuilder)
|
|
|
+ .size(0);
|
|
|
+ request.source(searchSourceBuilder);
|
|
|
+ SearchResponse search = client.search(request, RequestOptions.DEFAULT);
|
|
|
+ Aggregations aggregations = search.getAggregations();
|
|
|
+ ParsedStringTerms aggregation = aggregations.get("ship_field_agg");
|
|
|
+ for (Terms.Bucket bucket : aggregation.getBuckets()) {
|
|
|
+ LeaceOutDto dto = new LeaceOutDto();
|
|
|
+ dto.setBatchNumber(bucket.getKeyAsString());
|
|
|
+ dto.setCount(Long.valueOf(bucket.getDocCount()));
|
|
|
+ dtos.add(dto);
|
|
|
+ }
|
|
|
+ dtos.forEach(item->{
|
|
|
+ StaticOrDynamicData data = new StaticOrDynamicData();
|
|
|
+ SearchRequest request2 = new SearchRequest(INDEX_SEAT_REALTIMETRAJECTORY+time);
|
|
|
+ // 构建查询条件
|
|
|
+ BoolQueryBuilder boolQueryBuilder2 = QueryBuilders.boolQuery();
|
|
|
+ SearchSourceBuilder searchSourceBuilder2 = new SearchSourceBuilder();
|
|
|
+ boolQueryBuilder2.filter(QueryBuilders.wildcardQuery("trackDeviceNo", "*,"+ item.getBatchNumber() +",*"));
|
|
|
+ boolQueryBuilder2.filter(QueryBuilders.termQuery("targetType","0"));
|
|
|
+ boolQueryBuilder2.filter(QueryBuilders.rangeQuery("mergeTime").gte(query.getStartTime()).lte(query.getEndTime()));
|
|
|
+ boolQueryBuilder2.filter(QueryBuilders.termsQuery("mergeType","RADAR","AIS_RADAR","BEIDOU_RADAR","AIS_BEIDOU_RADAR"));
|
|
|
+ searchSourceBuilder2.query(boolQueryBuilder2)
|
|
|
+ .trackTotalHits(true)
|
|
|
+ .size(0);
|
|
|
+ request2.source(searchSourceBuilder2);
|
|
|
+ try {
|
|
|
+ SearchResponse search2 = client.search(request, RequestOptions.DEFAULT);
|
|
|
+ SearchHits searchHits = search2.getHits();
|
|
|
+ SearchHit[] hits = searchHits.getHits();
|
|
|
+ if (hits.length > 0) {
|
|
|
+ JSONObject sourceItem = JSONObject.parseObject(hits[0].getSourceAsString());
|
|
|
+ data.setMergeTarget(sourceItem.getString("mergeTarget"));
|
|
|
+ data.setBatchNumber(item.getBatchNumber());
|
|
|
+ list.add(data);
|
|
|
+ }
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ try {
|
|
|
+ response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
|
|
|
+ response.setCharacterEncoding("utf-8");
|
|
|
+ String fileName = URLEncoder.encode("天奥静态数据与动态轨迹融合", "UTF-8");
|
|
|
+ response.setHeader("Content-Disposition", "attachment;filename=" + fileName + ".xlsx");
|
|
|
+ EasyExcel.write(response.getOutputStream(), StaticOrDynamicData.class).sheet("天奥静态数据与动态轨迹融合")
|
|
|
+ .doWrite(list);
|
|
|
+ } catch (Exception e) {
|
|
|
+ // 重置response
|
|
|
+ log.info("导出天奥静态数据与动态轨迹融合excel失败:{}" + e.getMessage() + e);
|
|
|
}
|
|
|
}
|
|
|
}
|