|
@@ -21,6 +21,7 @@ import org.elasticsearch.client.HttpAsyncResponseConsumerFactory;
|
|
|
import org.elasticsearch.client.RequestOptions;
|
|
|
import org.elasticsearch.client.RestClientBuilder;
|
|
|
import org.elasticsearch.client.RestHighLevelClient;
|
|
|
+import org.elasticsearch.common.geo.GeoPoint;
|
|
|
import org.elasticsearch.core.TimeValue;
|
|
|
import org.elasticsearch.index.query.BoolQueryBuilder;
|
|
|
import org.elasticsearch.index.query.QueryBuilders;
|
|
@@ -83,11 +84,17 @@ public class FusionAnalysisServiceImpl implements FusionAnalysisService {
|
|
|
List<FusionData> list = new CopyOnWriteArrayList<>();
|
|
|
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);
|
|
|
+ SearchRequest request = new SearchRequest(INDEX_SEAT_FK_REALTIMETRAJECTORY_TEST);
|
|
|
// 构建查询条件
|
|
|
BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery();
|
|
|
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
|
|
|
boolQueryBuilder.filter(QueryBuilders.rangeQuery("mergeTime").gte(query.getStartTime()).lte(query.getEndTime()));
|
|
|
+ double[] doubles = new double[]{109.05069874931793,19.75955316191097,109.20963772383247,19.811999020000147,109.35696654655628,19.782373115430687,109.33374624297481,19.66386949715284,109.09473725611036,19.617428889989903,109.05069874931793,19.75955316191097};
|
|
|
+ List<GeoPoint> points = new ArrayList<>();
|
|
|
+ for(int i = 0 ;i < doubles.length;i=i+2) {
|
|
|
+ points.add(new GeoPoint(doubles[i+1],doubles[i]));
|
|
|
+ }
|
|
|
+ boolQueryBuilder.filter(QueryBuilders.geoPolygonQuery("location", points));
|
|
|
searchSourceBuilder.query(boolQueryBuilder);
|
|
|
// TermsAggregationBuilder aggBuilder = AggregationBuilders.terms("ship_field_agg")
|
|
|
// .field("mergeTarget")
|
|
@@ -226,11 +233,17 @@ public class FusionAnalysisServiceImpl implements FusionAnalysisService {
|
|
|
List<FusionData> list = new CopyOnWriteArrayList<>();
|
|
|
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);
|
|
|
+ SearchRequest request = new SearchRequest(INDEX_SEAT_FK_REALTIMETRAJECTORY_TEST);
|
|
|
// 构建查询条件
|
|
|
BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery();
|
|
|
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
|
|
|
boolQueryBuilder.filter(QueryBuilders.rangeQuery("mergeTime").gte(query.getStartTime()).lte(query.getEndTime()));
|
|
|
+ double[] doubles = new double[]{109.05069874931793,19.75955316191097,109.20963772383247,19.811999020000147,109.35696654655628,19.782373115430687,109.33374624297481,19.66386949715284,109.09473725611036,19.617428889989903,109.05069874931793,19.75955316191097};
|
|
|
+ List<GeoPoint> points = new ArrayList<>();
|
|
|
+ for(int i = 0 ;i < doubles.length;i=i+2) {
|
|
|
+ points.add(new GeoPoint(doubles[i+1],doubles[i]));
|
|
|
+ }
|
|
|
+ boolQueryBuilder.filter(QueryBuilders.geoPolygonQuery("location", points));
|
|
|
searchSourceBuilder.query(boolQueryBuilder);
|
|
|
// TermsAggregationBuilder aggBuilder = AggregationBuilders.terms("ship_field_agg")
|
|
|
// .field("mergeTarget")
|
|
@@ -395,6 +408,12 @@ public class FusionAnalysisServiceImpl implements FusionAnalysisService {
|
|
|
BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery();
|
|
|
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
|
|
|
boolQueryBuilder.filter(QueryBuilders.rangeQuery("receiveTime").gte(query.getStartTime()).lte(query.getEndTime()));
|
|
|
+ double[] doubles = new double[]{109.05069874931793,19.75955316191097,109.20963772383247,19.811999020000147,109.35696654655628,19.782373115430687,109.33374624297481,19.66386949715284,109.09473725611036,19.617428889989903,109.05069874931793,19.75955316191097};
|
|
|
+ List<GeoPoint> points = new ArrayList<>();
|
|
|
+ for(int i = 0 ;i < doubles.length;i=i+2) {
|
|
|
+ points.add(new GeoPoint(doubles[i+1],doubles[i]));
|
|
|
+ }
|
|
|
+ boolQueryBuilder.filter(QueryBuilders.geoPolygonQuery("location", points));
|
|
|
searchSourceBuilder.query(boolQueryBuilder);
|
|
|
// TermsAggregationBuilder aggBuilder = AggregationBuilders.terms("ship_field_agg")
|
|
|
// .field("fusionBatchNum")
|
|
@@ -420,22 +439,22 @@ public class FusionAnalysisServiceImpl implements FusionAnalysisService {
|
|
|
}
|
|
|
outList = change(inList, "fusionBatchNum", outList);
|
|
|
outList.forEach(map-> {
|
|
|
- JSONObject maps = JSONObject.parseObject(JSON.toJSONString(map));
|
|
|
+ JSONObject maps = JSONObject.parseObject(JSON.toJSONString(map));
|
|
|
// JSONObject maps = new JSONObject();
|
|
|
// Iterator it = map.keySet().iterator();
|
|
|
// while (it.hasNext()) {
|
|
|
// String key = (String) it.next();
|
|
|
// maps.put(key, map.get(key));
|
|
|
// }
|
|
|
- JSONArray jsonArray = JSONArray.parseArray(maps.getString("array"));
|
|
|
- if (jsonArray.size() > 0) {
|
|
|
- JSONObject job = jsonArray.getJSONObject(0);
|
|
|
- LeaceOutDto dto = new LeaceOutDto();
|
|
|
- dto.setBatchNumber(job.getString("fusionBatchNum"));
|
|
|
- dto.setCount((long) jsonArray.size());
|
|
|
- dtos.add(dto);
|
|
|
- }
|
|
|
- });
|
|
|
+ JSONArray jsonArray = JSONArray.parseArray(maps.getString("array"));
|
|
|
+ if (jsonArray.size() > 0) {
|
|
|
+ JSONObject job = jsonArray.getJSONObject(0);
|
|
|
+ LeaceOutDto dto = new LeaceOutDto();
|
|
|
+ dto.setBatchNumber(job.getString("fusionBatchNum"));
|
|
|
+ dto.setCount((long) jsonArray.size());
|
|
|
+ dtos.add(dto);
|
|
|
+ }
|
|
|
+ });
|
|
|
// Aggregations aggregations = search.getAggregations();
|
|
|
// ParsedStringTerms aggregation = aggregations.get("ship_field_agg");
|
|
|
// for (Terms.Bucket bucket : aggregation.getBuckets()) {
|
|
@@ -446,13 +465,19 @@ public class FusionAnalysisServiceImpl implements FusionAnalysisService {
|
|
|
// }
|
|
|
dtos.forEach(item->{
|
|
|
LeaveOutData data = new LeaveOutData();
|
|
|
- SearchRequest request2 = new SearchRequest(INDEX_SEAT_REALTIMETRAJECTORY_TEST+time);
|
|
|
+ SearchRequest request2 = new SearchRequest(INDEX_SEAT_FK_REALTIMETRAJECTORY_TEST);
|
|
|
// 构建查询条件
|
|
|
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","TA_RADAR"));
|
|
|
+ double[] doubles2 = new double[]{109.05069874931793,19.75955316191097,109.20963772383247,19.811999020000147,109.35696654655628,19.782373115430687,109.33374624297481,19.66386949715284,109.09473725611036,19.617428889989903,109.05069874931793,19.75955316191097};
|
|
|
+ List<GeoPoint> points2 = new ArrayList<>();
|
|
|
+ for(int i = 0 ;i < doubles2.length;i=i+2) {
|
|
|
+ points2.add(new GeoPoint(doubles2[i+1],doubles2[i]));
|
|
|
+ }
|
|
|
+ boolQueryBuilder2.filter(QueryBuilders.geoPolygonQuery("location", points2));
|
|
|
searchSourceBuilder2.query(boolQueryBuilder2)
|
|
|
.trackTotalHits(true)
|
|
|
.size(query.getPageSize())
|
|
@@ -514,6 +539,12 @@ public class FusionAnalysisServiceImpl implements FusionAnalysisService {
|
|
|
BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery();
|
|
|
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
|
|
|
boolQueryBuilder.filter(QueryBuilders.rangeQuery("locationTime").gte(query.getStartTime()).lte(query.getEndTime()));
|
|
|
+ double[] doubles = new double[]{109.05069874931793,19.75955316191097,109.20963772383247,19.811999020000147,109.35696654655628,19.782373115430687,109.33374624297481,19.66386949715284,109.09473725611036,19.617428889989903,109.05069874931793,19.75955316191097};
|
|
|
+ List<GeoPoint> points = new ArrayList<>();
|
|
|
+ for(int i = 0 ;i < doubles.length;i=i+2) {
|
|
|
+ points.add(new GeoPoint(doubles[i+1],doubles[i]));
|
|
|
+ }
|
|
|
+ boolQueryBuilder.filter(QueryBuilders.geoPolygonQuery("location", points));
|
|
|
searchSourceBuilder.query(boolQueryBuilder);
|
|
|
// TermsAggregationBuilder aggBuilder = AggregationBuilders.terms("ship_field_agg")
|
|
|
// .field("fusionBatchNum")
|
|
@@ -565,13 +596,19 @@ public class FusionAnalysisServiceImpl implements FusionAnalysisService {
|
|
|
// }
|
|
|
dtos.forEach(item->{
|
|
|
LeaveOutData data = new LeaveOutData();
|
|
|
- SearchRequest request2 = new SearchRequest(INDEX_SEAT_REALTIMETRAJECTORY+time);
|
|
|
+ SearchRequest request2 = new SearchRequest(INDEX_SEAT_FK_REALTIMETRAJECTORY_TEST);
|
|
|
// 构建查询条件
|
|
|
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"));
|
|
|
+ double[] doubles2 = new double[]{109.05069874931793,19.75955316191097,109.20963772383247,19.811999020000147,109.35696654655628,19.782373115430687,109.33374624297481,19.66386949715284,109.09473725611036,19.617428889989903,109.05069874931793,19.75955316191097};
|
|
|
+ List<GeoPoint> points2 = new ArrayList<>();
|
|
|
+ for(int i = 0 ;i < doubles2.length;i=i+2) {
|
|
|
+ points2.add(new GeoPoint(doubles2[i+1],doubles2[i]));
|
|
|
+ }
|
|
|
+ boolQueryBuilder2.filter(QueryBuilders.geoPolygonQuery("location", points2));
|
|
|
searchSourceBuilder2.query(boolQueryBuilder2)
|
|
|
.trackTotalHits(true)
|
|
|
.size(query.getPageSize())
|
|
@@ -633,6 +670,12 @@ public class FusionAnalysisServiceImpl implements FusionAnalysisService {
|
|
|
BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery();
|
|
|
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
|
|
|
boolQueryBuilder.filter(QueryBuilders.rangeQuery("time").gte(query.getStartTime()).lte(query.getEndTime()));
|
|
|
+ double[] doubles = new double[]{109.05069874931793,19.75955316191097,109.20963772383247,19.811999020000147,109.35696654655628,19.782373115430687,109.33374624297481,19.66386949715284,109.09473725611036,19.617428889989903,109.05069874931793,19.75955316191097};
|
|
|
+ List<GeoPoint> points = new ArrayList<>();
|
|
|
+ for(int i = 0 ;i < doubles.length;i=i+2) {
|
|
|
+ points.add(new GeoPoint(doubles[i+1],doubles[i]));
|
|
|
+ }
|
|
|
+ boolQueryBuilder.filter(QueryBuilders.geoPolygonQuery("location", points));
|
|
|
searchSourceBuilder.query(boolQueryBuilder);
|
|
|
// TermsAggregationBuilder aggBuilder = AggregationBuilders.terms("ship_field_agg")
|
|
|
// .field("fusionBatchNum")
|
|
@@ -684,13 +727,19 @@ public class FusionAnalysisServiceImpl implements FusionAnalysisService {
|
|
|
// }
|
|
|
dtos.forEach(item->{
|
|
|
LeaveOutData data = new LeaveOutData();
|
|
|
- SearchRequest request2 = new SearchRequest(INDEX_SEAT_REALTIMETRAJECTORY_TEST+time);
|
|
|
+ SearchRequest request2 = new SearchRequest(INDEX_SEAT_FK_REALTIMETRAJECTORY_TEST);
|
|
|
// 构建查询条件
|
|
|
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","HLX_AIS_RADAR","HLX_AIS","HLX_RADAR","HLX_ZYD_RADAR"));
|
|
|
+ double[] doubles2 = new double[]{109.05069874931793,19.75955316191097,109.20963772383247,19.811999020000147,109.35696654655628,19.782373115430687,109.33374624297481,19.66386949715284,109.09473725611036,19.617428889989903,109.05069874931793,19.75955316191097};
|
|
|
+ List<GeoPoint> points2 = new ArrayList<>();
|
|
|
+ for(int i = 0 ;i < doubles2.length;i=i+2) {
|
|
|
+ points2.add(new GeoPoint(doubles2[i+1],doubles2[i]));
|
|
|
+ }
|
|
|
+ boolQueryBuilder2.filter(QueryBuilders.geoPolygonQuery("location", points2));
|
|
|
searchSourceBuilder2.query(boolQueryBuilder2)
|
|
|
.trackTotalHits(true)
|
|
|
.size(query.getPageSize())
|
|
@@ -753,6 +802,12 @@ public class FusionAnalysisServiceImpl implements FusionAnalysisService {
|
|
|
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
|
|
|
boolQueryBuilder.filter(QueryBuilders.rangeQuery("receiveTime").gte(query.getStartTime()).lte(query.getEndTime()));
|
|
|
boolQueryBuilder.mustNot(QueryBuilders.termQuery("targetProper","0"));
|
|
|
+ double[] doubles = new double[]{109.05069874931793,19.75955316191097,109.20963772383247,19.811999020000147,109.35696654655628,19.782373115430687,109.33374624297481,19.66386949715284,109.09473725611036,19.617428889989903,109.05069874931793,19.75955316191097};
|
|
|
+ List<GeoPoint> points = new ArrayList<>();
|
|
|
+ for(int i = 0 ;i < doubles.length;i=i+2) {
|
|
|
+ points.add(new GeoPoint(doubles[i+1],doubles[i]));
|
|
|
+ }
|
|
|
+ boolQueryBuilder.filter(QueryBuilders.geoPolygonQuery("location", points));
|
|
|
searchSourceBuilder.query(boolQueryBuilder);
|
|
|
// TermsAggregationBuilder aggBuilder = AggregationBuilders.terms("ship_field_agg")
|
|
|
// .field("fusionBatchNum")
|
|
@@ -795,7 +850,7 @@ public class FusionAnalysisServiceImpl implements FusionAnalysisService {
|
|
|
});
|
|
|
dtos.forEach(item->{
|
|
|
StaticOrDynamicData data = new StaticOrDynamicData();
|
|
|
- SearchRequest request2 = new SearchRequest(INDEX_SEAT_REALTIMETRAJECTORY_TEST+time);
|
|
|
+ SearchRequest request2 = new SearchRequest(INDEX_SEAT_FK_REALTIMETRAJECTORY_TEST);
|
|
|
// 构建查询条件
|
|
|
BoolQueryBuilder boolQueryBuilder2 = QueryBuilders.boolQuery();
|
|
|
SearchSourceBuilder searchSourceBuilder2 = new SearchSourceBuilder();
|
|
@@ -803,6 +858,12 @@ public class FusionAnalysisServiceImpl implements FusionAnalysisService {
|
|
|
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"));
|
|
|
+ double[] doubles2 = new double[]{109.05069874931793,19.75955316191097,109.20963772383247,19.811999020000147,109.35696654655628,19.782373115430687,109.33374624297481,19.66386949715284,109.09473725611036,19.617428889989903,109.05069874931793,19.75955316191097};
|
|
|
+ List<GeoPoint> points2 = new ArrayList<>();
|
|
|
+ for(int i = 0 ;i < doubles2.length;i=i+2) {
|
|
|
+ points2.add(new GeoPoint(doubles2[i+1],doubles2[i]));
|
|
|
+ }
|
|
|
+ boolQueryBuilder2.filter(QueryBuilders.geoPolygonQuery("location", points2));
|
|
|
searchSourceBuilder2.query(boolQueryBuilder2)
|
|
|
.trackTotalHits(true)
|
|
|
.size(query.getPageSize())
|
|
@@ -843,6 +904,197 @@ public class FusionAnalysisServiceImpl implements FusionAnalysisService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public void fusionAnalysisExcelThree(FusionQuery query, HttpServletResponse response) throws IOException, ParseException {
|
|
|
+ List<FusionData> list = new CopyOnWriteArrayList<>();
|
|
|
+ Date startTime = DateUtils.parse(query.getStartTime(),"yyyy-MM-dd");
|
|
|
+ String time = DateUtils.format(startTime,"yyyy-MM-dd");
|
|
|
+ SearchRequest request = new SearchRequest(INDEX_SEAT_FK_REALTIMETRAJECTORY_TEST);
|
|
|
+ // 构建查询条件
|
|
|
+ BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery();
|
|
|
+ SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
|
|
|
+ boolQueryBuilder.filter(QueryBuilders.rangeQuery("mergeTime").gte(query.getStartTime()).lte(query.getEndTime()));
|
|
|
+ double[] doubles = new double[]{109.05069874931793,19.75955316191097,109.20963772383247,19.811999020000147,109.35696654655628,19.782373115430687,109.33374624297481,19.66386949715284,109.09473725611036,19.617428889989903,109.05069874931793,19.75955316191097};
|
|
|
+ List<GeoPoint> points = new ArrayList<>();
|
|
|
+ for(int i = 0 ;i < doubles.length;i=i+2) {
|
|
|
+ points.add(new GeoPoint(doubles[i+1],doubles[i]));
|
|
|
+ }
|
|
|
+ boolQueryBuilder.filter(QueryBuilders.geoPolygonQuery("location", points));
|
|
|
+ searchSourceBuilder.query(boolQueryBuilder);
|
|
|
+ searchSourceBuilder
|
|
|
+ .trackTotalHits(true)
|
|
|
+ .sort(SortBuilders.fieldSort("mergeTime").order(SortOrder.ASC))
|
|
|
+ .size(query.getPageSize())
|
|
|
+ .timeout(TimeValue.timeValueHours(1L))
|
|
|
+ .timeout(TimeValue.timeValueMinutes(30L))
|
|
|
+ .timeout(TimeValue.timeValueSeconds(500L));
|
|
|
+ request.source(searchSourceBuilder);
|
|
|
+ SearchResponse search = client.search(request, COMMON_OPTIONS);
|
|
|
+ SearchHits searchHits = search.getHits();
|
|
|
+ SearchHit[] hits = searchHits.getHits();
|
|
|
+ List<Map<String, Object>> inList = new CopyOnWriteArrayList<Map<String, Object>>();
|
|
|
+ List<Map<String, Object>> outList = new CopyOnWriteArrayList<Map<String, Object>>();
|
|
|
+ for (SearchHit hit : hits) {
|
|
|
+ Map<String, Object> map = new ConcurrentHashMap();
|
|
|
+ map = hit.getSourceAsMap();
|
|
|
+ inList.add(map);
|
|
|
+ }
|
|
|
+ outList = change(inList, "mergeTarget", outList);
|
|
|
+ outList.forEach(map->{
|
|
|
+ JSONObject maps = JSONObject.parseObject(JSON.toJSONString(map));
|
|
|
+ JSONArray jsonArray =JSONArray.parseArray(maps.getString("array"));
|
|
|
+ if (jsonArray.size()>0){
|
|
|
+ FusionData data = new FusionData();
|
|
|
+ Integer num = 0;
|
|
|
+ for (int i = 0; i < jsonArray.size(); i++) {
|
|
|
+ if (i<jsonArray.size()-1){
|
|
|
+ JSONObject job = jsonArray.getJSONObject(i);
|
|
|
+ JSONObject job2 = jsonArray.getJSONObject(i+1);
|
|
|
+ String targetSpeed = job.get("targetSpeed").toString();
|
|
|
+ String targetSpeed2 = job2.get("targetSpeed").toString();
|
|
|
+ Double d= Double.parseDouble(targetSpeed);
|
|
|
+ Double d2= Double.parseDouble(targetSpeed2);
|
|
|
+ Double aDouble = speedUtils(d, d2);
|
|
|
+ if (Double.doubleToLongBits(aDouble)>3L){
|
|
|
+ num++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (num>0){
|
|
|
+ JSONObject sourceItem = jsonArray.getJSONObject(0);
|
|
|
+ JSONObject sourceItem2 = jsonArray.getJSONObject(jsonArray.size()-1);
|
|
|
+ data.setMergeTarget(sourceItem.getString("mergeTarget"));
|
|
|
+ data.setTrackCount((long) jsonArray.size());
|
|
|
+ Date date = null;
|
|
|
+ Date date2 = null;
|
|
|
+ try {
|
|
|
+ date = DateUtils.parse(sourceItem.getString("mergeTime"),"yyyy-MM-dd HH:mm:ss.SSS");
|
|
|
+ date2 = DateUtils.parse(sourceItem2.getString("mergeTime"),"yyyy-MM-dd HH:mm:ss.SSS");
|
|
|
+ } catch (ParseException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ if (date.getTime()>date2.getTime()){
|
|
|
+ data.setStartTime(sourceItem2.getString("mergeTime"));
|
|
|
+ data.setEndTime(sourceItem.getString("mergeTime"));
|
|
|
+ }else {
|
|
|
+ data.setStartTime(sourceItem.getString("mergeTime"));
|
|
|
+ data.setEndTime(sourceItem2.getString("mergeTime"));
|
|
|
+ }
|
|
|
+ data.setFluctuateNumber(num);
|
|
|
+ list.add(data);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ try {
|
|
|
+ System.out.println("进入导出识别融合速度异常波动问题");
|
|
|
+ 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
|
|
|
+ System.out.println("导出识别融合速度异常波动问题excel失败:{}" + e.getMessage() + e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void fusionAnalysisExcelFour(FusionQuery query, HttpServletResponse response) throws IOException, ParseException {
|
|
|
+ List<FusionData> list = new CopyOnWriteArrayList<>();
|
|
|
+ Date startTime = DateUtils.parse(query.getStartTime(),"yyyy-MM-dd");
|
|
|
+ String time = DateUtils.format(startTime,"yyyy-MM-dd");
|
|
|
+ SearchRequest request = new SearchRequest(INDEX_SEAT_FK_REALTIMETRAJECTORY_TEST);
|
|
|
+ // 构建查询条件
|
|
|
+ BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery();
|
|
|
+ SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
|
|
|
+ boolQueryBuilder.filter(QueryBuilders.rangeQuery("mergeTime").gte(query.getStartTime()).lte(query.getEndTime()));
|
|
|
+ double[] doubles = new double[]{109.05069874931793,19.75955316191097,109.20963772383247,19.811999020000147,109.35696654655628,19.782373115430687,109.33374624297481,19.66386949715284,109.09473725611036,19.617428889989903,109.05069874931793,19.75955316191097};
|
|
|
+ List<GeoPoint> points = new ArrayList<>();
|
|
|
+ for(int i = 0 ;i < doubles.length;i=i+2) {
|
|
|
+ points.add(new GeoPoint(doubles[i+1],doubles[i]));
|
|
|
+ }
|
|
|
+ boolQueryBuilder.filter(QueryBuilders.geoPolygonQuery("location", points));
|
|
|
+ searchSourceBuilder.query(boolQueryBuilder);
|
|
|
+ searchSourceBuilder
|
|
|
+ .trackTotalHits(true)
|
|
|
+ .sort(SortBuilders.fieldSort("mergeTime").order(SortOrder.ASC))
|
|
|
+ .size(query.getPageSize())
|
|
|
+ .timeout(TimeValue.timeValueHours(1L))
|
|
|
+ .timeout(TimeValue.timeValueMinutes(30L))
|
|
|
+ .timeout(TimeValue.timeValueSeconds(500L));
|
|
|
+ request.source(searchSourceBuilder);
|
|
|
+ SearchResponse search = client.search(request, COMMON_OPTIONS);
|
|
|
+ SearchHits searchHits = search.getHits();
|
|
|
+ SearchHit[] hits = searchHits.getHits();
|
|
|
+ List<Map<String, Object>> inList = new CopyOnWriteArrayList<Map<String, Object>>();
|
|
|
+ List<Map<String, Object>> outList = new CopyOnWriteArrayList<Map<String, Object>>();
|
|
|
+ for (SearchHit hit : hits) {
|
|
|
+ Map<String, Object> map = new ConcurrentHashMap();
|
|
|
+ map = hit.getSourceAsMap();
|
|
|
+ inList.add(map);
|
|
|
+ }
|
|
|
+ outList = change(inList, "mergeTarget", outList);
|
|
|
+ outList.forEach(map->{
|
|
|
+ JSONObject maps = JSONObject.parseObject(JSON.toJSONString(map));
|
|
|
+ JSONArray jsonArray =JSONArray.parseArray(maps.getString("array"));
|
|
|
+ if (jsonArray.size()>0){
|
|
|
+ FusionData data = new FusionData();
|
|
|
+ Integer num = 0;
|
|
|
+ for (int i = 0; i < jsonArray.size(); i++) {
|
|
|
+ if (i<jsonArray.size()-1){
|
|
|
+ JSONObject job = jsonArray.getJSONObject(i);
|
|
|
+ JSONObject job2 = jsonArray.getJSONObject(i+1);
|
|
|
+ String targetCourse = job.get("targetCourse").toString();
|
|
|
+ String targetCourse2 = job2.get("targetCourse").toString();
|
|
|
+ Double d= Double.parseDouble(targetCourse);
|
|
|
+ Double d2= Double.parseDouble(targetCourse2);
|
|
|
+ Double aDouble = speedUtils(d, d2);
|
|
|
+ if (Double.doubleToLongBits(aDouble)>60L){
|
|
|
+ num++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (num>0){
|
|
|
+ JSONObject sourceItem = jsonArray.getJSONObject(0);
|
|
|
+ JSONObject sourceItem2 = jsonArray.getJSONObject(jsonArray.size()-1);
|
|
|
+ data.setMergeTarget(sourceItem.getString("mergeTarget"));
|
|
|
+ data.setTrackCount((long) jsonArray.size());
|
|
|
+ Date date = null;
|
|
|
+ Date date2 = null;
|
|
|
+ try {
|
|
|
+ date = DateUtils.parse(sourceItem.getString("mergeTime"),"yyyy-MM-dd HH:mm:ss.SSS");
|
|
|
+ date2 = DateUtils.parse(sourceItem2.getString("mergeTime"),"yyyy-MM-dd HH:mm:ss.SSS");
|
|
|
+ } catch (ParseException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ if (date.getTime()>date2.getTime()){
|
|
|
+ data.setStartTime(sourceItem2.getString("mergeTime"));
|
|
|
+ data.setEndTime(sourceItem.getString("mergeTime"));
|
|
|
+ }else {
|
|
|
+ data.setStartTime(sourceItem.getString("mergeTime"));
|
|
|
+ data.setEndTime(sourceItem2.getString("mergeTime"));
|
|
|
+ }
|
|
|
+ data.setFluctuateNumber(num);
|
|
|
+ list.add(data);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ try {
|
|
|
+ System.out.println("进入导出识别融合航向异常波动问题");
|
|
|
+ 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
|
|
|
+ System.out.println("导出识别融合航向异常波动问题excel失败:{}" + e.getMessage() + e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* 按照List<Map<String,Object>>里面map的某个value重新封装成多个不同的list, 原始数据类型List<Map<String,Object>>, 转换后数据类型Map<String,List<Map<String,Object>>>
|
|
|
* @param inList
|
|
@@ -886,4 +1138,12 @@ public class FusionAnalysisServiceImpl implements FusionAnalysisService {
|
|
|
return twoTime-oneTime;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ public Double speedUtils(Double d,Double d2){
|
|
|
+ if (Double.doubleToLongBits(d)>Double.doubleToLongBits(d2)){
|
|
|
+ return d-d2;
|
|
|
+ }else {
|
|
|
+ return d2-d;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|