Commit 7dbf3c7d authored by duanruiming's avatar duanruiming

[update] 车道快照数据车道号匹配

parent 0e1709d9
......@@ -31,6 +31,7 @@ public class CrossLaneSnapshotDataDTO {
/**
* 车道号(路网数据)
*/
@Field(type = FieldType.Keyword, name = "laneId")
private String laneId;
/**
* 静态排队长度(米)
......
......@@ -3,6 +3,7 @@ package net.wanji.opt.service.es;
import lombok.extern.slf4j.Slf4j;
import net.wanji.common.constant.Constants;
import net.wanji.common.utils.tool.JacksonUtils;
import net.wanji.common.utils.tool.StringUtils;
import net.wanji.opt.dto.CrossLaneSnapshotDataDTO;
import org.elasticsearch.action.search.SearchRequest;
import org.elasticsearch.action.search.SearchResponse;
......@@ -10,10 +11,7 @@ import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestHighLevelClient;
import org.elasticsearch.client.core.CountRequest;
import org.elasticsearch.client.core.CountResponse;
import org.elasticsearch.index.query.BoolQueryBuilder;
import org.elasticsearch.index.query.MatchQueryBuilder;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.index.query.RangeQueryBuilder;
import org.elasticsearch.index.query.*;
import org.elasticsearch.search.SearchHit;
import org.elasticsearch.search.SearchHits;
import org.elasticsearch.search.builder.SearchSourceBuilder;
......@@ -22,6 +20,7 @@ import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
/**
......@@ -38,7 +37,7 @@ public class LaneSnapshotDataQueryService implements LaneSnapshotService {
@Override
public List<CrossLaneSnapshotDataDTO> queryByCrossIdAndTimeSpan(
String crossId, int startTimeStamp, int endTimeStamp, int pageNum)
String crossId, int startTimeStamp, int endTimeStamp, int pageNum, String laneId)
throws Exception {
List<CrossLaneSnapshotDataDTO> result = new ArrayList<>();
......@@ -46,7 +45,6 @@ public class LaneSnapshotDataQueryService implements LaneSnapshotService {
try {
SearchRequest searchRequest = new SearchRequest(Constants.LANE_SNAPSHOT_DATA_ES_INDEX);
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
MatchQueryBuilder matchQuery = QueryBuilders.matchQuery("crossId", crossId);
RangeQueryBuilder rangeQuery = QueryBuilders.rangeQuery("timeStamp")
.gte(startTimeStamp)
......@@ -56,6 +54,13 @@ public class LaneSnapshotDataQueryService implements LaneSnapshotService {
.must(matchQuery)
.must(rangeQuery);
String[] split = null;
if (StringUtils.isNotBlank(laneId)) {
split = laneId.split(",");
TermsQueryBuilder termsQuery = QueryBuilders.termsQuery("laneId.keyword", Arrays.asList(split));
boolQuery.must(termsQuery);
}
searchSourceBuilder
.query(boolQuery)
.from(pageNum)
......
......@@ -10,7 +10,8 @@ import java.util.List;
* @date 2023/10/26 14:12
*/
public interface LaneSnapshotService {
List<CrossLaneSnapshotDataDTO> queryByCrossIdAndTimeSpan(String crossId, int startTimeStamp, int endTimeStamp, int pageNum) throws Exception;
List<CrossLaneSnapshotDataDTO> queryByCrossIdAndTimeSpan(String crossId, int startTimeStamp,
int endTimeStamp, int pageNum, String laneId) throws Exception;
int queryCountsByCrossIdAndTimeSpan(String crossId, int startTimeStamp, int endTimeStamp) throws Exception;
}
......@@ -1319,7 +1319,8 @@ public class TrendServiceImpl implements TrendService {
// 查询秒级数据
List<CrossLaneSnapshotDataDTO> dtoList =
laneSnapshotDataQueryService.queryByCrossIdAndTimeSpan(crossId, realTimeStartTimeStamp, endTimeStamp, 0);
laneSnapshotDataQueryService.queryByCrossIdAndTimeSpan(crossId, realTimeStartTimeStamp,
endTimeStamp, 0, null);
tableQueryVO.setRealTimeData(buildRealTimeList(dtoList));
// 查询周期数据
......@@ -1980,9 +1981,10 @@ public class TrendServiceImpl implements TrendService {
int start = (int) (crossIdDateTimeVO.getStart().getTime() / 1000);
int end = (int) (crossIdDateTimeVO.getEnd().getTime() / 1000);
int pageNum = crossIdDateTimeVO.getPageNum();
String laneId = crossIdDateTimeVO.getLaneId();
// 查询秒级数据
List<CrossLaneSnapshotDataDTO> dtoList =
laneSnapshotDataQueryService.queryByCrossIdAndTimeSpan(crossId, start, end, pageNum);
laneSnapshotDataQueryService.queryByCrossIdAndTimeSpan(crossId, start, end, pageNum, laneId);
return buildRealTimeList(dtoList);
}
......
......@@ -11,4 +11,6 @@ import lombok.Data;
public class PageNumVO {
@ApiModelProperty(value = "当前页码")
private int pageNum;
@ApiModelProperty(value = "车道编号")
private String laneId;
}
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