|
@@ -1,9 +1,6 @@
|
|
|
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.*;
|
|
|
import cn.com.taiji.domain.dto.LeaceOutDto;
|
|
|
import cn.com.taiji.service.FusionAnalysisService;
|
|
|
import cn.com.taiji.utils.DateUtils;
|
|
@@ -1094,6 +1091,189 @@ public class FusionAnalysisServiceImpl implements FusionAnalysisService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public void fusionAnalysisExcelOriginalOne(FusionQuery query, HttpServletResponse response) throws IOException, ParseException {
|
|
|
+ List<OriginalData> 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) {
|
|
|
+ OriginalData data = new OriginalData();
|
|
|
+ JSONObject sourceItem = jsonArray.getJSONObject(0);
|
|
|
+ data.setMergeTarget(sourceItem.getString("mergeTarget"));
|
|
|
+ data.setNum(jsonArray.size());
|
|
|
+ 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(), OriginalData.class).sheet("融合原始数据")
|
|
|
+ .doWrite(list);
|
|
|
+ } catch (Exception e) {
|
|
|
+ // 重置response
|
|
|
+ System.out.println("导出融合原始数据excel失败:{}" + e.getMessage() + e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void fusionAnalysisExcelOriginalTwo(FusionQuery query, HttpServletResponse response) throws IOException, ParseException {
|
|
|
+ List<OriginalData> 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_TRACK_BEIDOU+time);
|
|
|
+ // 构建查询条件
|
|
|
+ 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);
|
|
|
+ searchSourceBuilder
|
|
|
+ .trackTotalHits(true)
|
|
|
+ .size(query.getPageSize())
|
|
|
+ .sort(SortBuilders.fieldSort("locationTime").order(SortOrder.ASC))
|
|
|
+ .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, "devideNo", outList);
|
|
|
+ outList.forEach(map-> {
|
|
|
+ JSONObject maps = JSONObject.parseObject(JSON.toJSONString(map));
|
|
|
+ JSONArray jsonArray = JSONArray.parseArray(maps.getString("array"));
|
|
|
+ if (jsonArray.size() > 0) {
|
|
|
+ OriginalData data = new OriginalData();
|
|
|
+ JSONObject sourceItem = jsonArray.getJSONObject(0);
|
|
|
+ data.setMergeTarget(sourceItem.getString("devideNo"));
|
|
|
+ data.setNum(jsonArray.size());
|
|
|
+ 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(), OriginalData.class).sheet("北斗原始数据")
|
|
|
+ .doWrite(list);
|
|
|
+ } catch (Exception e) {
|
|
|
+ // 重置response
|
|
|
+ System.out.println("导出北斗原始数据excel失败:{}" + e.getMessage() + e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void fusionAnalysisExcelOriginalThree(FusionQuery query, HttpServletResponse response) throws IOException, ParseException {
|
|
|
+ List<OriginalData> 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_TRACK_RADAR+time);
|
|
|
+ // 构建查询条件
|
|
|
+ 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);
|
|
|
+ searchSourceBuilder
|
|
|
+ .trackTotalHits(true)
|
|
|
+ .size(query.getPageSize())
|
|
|
+ .sort(SortBuilders.fieldSort("receiveTime").order(SortOrder.ASC))
|
|
|
+ .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, "fusionBatchNum", outList);
|
|
|
+ outList.forEach(map-> {
|
|
|
+ JSONObject maps = JSONObject.parseObject(JSON.toJSONString(map));
|
|
|
+ JSONArray jsonArray = JSONArray.parseArray(maps.getString("array"));
|
|
|
+ if (jsonArray.size() > 0) {
|
|
|
+ OriginalData data = new OriginalData();
|
|
|
+ JSONObject sourceItem = jsonArray.getJSONObject(0);
|
|
|
+ data.setMergeTarget(sourceItem.getString("fusionBatchNum"));
|
|
|
+ data.setNum(jsonArray.size());
|
|
|
+ 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(), OriginalData.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>>>
|